为了测试我编写的相似度算法的效果,我创建了一个闪亮的应用程序,以便人们可以探索数据的输出。
下拉列表非常简单,允许用户选择酒店并返回数据集中的匹配项。因此,相似之处在于我从网站上提取英雄形象并在酒店名称下显示它的相似性(见图像很清楚)。这在RStudio应用预览中效果很好。
但是当我使用shinyapps.io部署应用程序时,我得到以下内容:
以下是呈现图片的代码:
function sortTable() {
var table, rows, switching, i, x, y, shouldSwitch;
table = document.getElementById("myTable");
switching = true;
/* Make a loop that will continue until
no switching has been done: */
while (switching) {
// Start by saying: no switching is done:
switching = false;
rows = table.getElementsByTagName("TR");
/* Loop through all table rows (except the
first, which contains table headers): */
for (i = 1; i < (rows.length - 1); i++) {
// Start by saying there should be no switching:
shouldSwitch = false;
/* Get the two elements you want to compare,
one from current row and one from the next: */
x = rows[i].getElementsByTagName("TD")[0];
y = rows[i + 1].getElementsByTagName("TD")[0];
// Check if the two rows should switch place:
if (x.innerHTML.toLowerCase() > y.innerHTML.toLowerCase()) {
// I so, mark as a switch and break the loop:
shouldSwitch= true;
break;
}
}
if (shouldSwitch) {
/* If a switch has been marked, make the switch
and mark that a switch has been done: */
rows[i].parentNode.insertBefore(rows[i + 1], rows[i]);
switching = true;
}
}
}
它在html中找到图像源并选择一个特定的图像源。我使用uiOutput()来渲染它。
知道为什么图像在shinyapps上没有正确显示?