rhandsontable,从作为列值给定的路径导入的图像
我正在尝试导入(a)小表和(b)图像,如Shining应用程序上显示的数据表中的绝对路径所示。(a)实际上只有三行两列。我将代码建模为一个html小部件,但它似乎不起作用。任何建议都是有用的。谢谢rhandsontable,从作为列值给定的路径导入的图像,r,shinyapps,rhandsontable,R,Shinyapps,Rhandsontable,我正在尝试导入(a)小表和(b)图像,如Shining应用程序上显示的数据表中的绝对路径所示。(a)实际上只有三行两列。我将代码建模为一个html小部件,但它似乎不起作用。任何建议都是有用的。谢谢 df <- read.delim("data_summ_png_results.tsv", header = T, sep = "|", quote = "", stringsAsFactors = FALSE) names(df)[6
df <- read.delim("data_summ_png_results.tsv", header = T, sep = "|", quote = "", stringsAsFactors = FALSE)
names(df)[6] = "chart"
然后我创建了列值为的json对象,它为我想要查看/单击表的文件提供了绝对路径
df$Summary = sapply(1:7349, function(x) jsonlite::toJSON(list(df$Summary)))
df$chart = sapply(1:7349, function(x) jsonlite::toJSON(list(df$chart)))
到目前为止,我得到的rhandsontable结果如下所示,但它不起作用
rhandsontable(df, rowHeaders = NULL, width = 800, height = 500) %>%
hot_col(1:3, readOnly = TRUE) %>%
hot_col("Summary", renderer = "
function(instance, td, row, col, prop, value, cellProperties) {
var escaped = Handsontable.helper.stringify(value),
img;
if (escaped.indexOf('~/images/') === 0) {
img = document.createElement('IMG');
img.src = value;
Handsontable.dom.addEvent(img, 'mousedown', function (e){
e.preventDefault(); // prevent selection quirk
});
Handsontable.dsom.empty(td);
td.appendChild(img);
}
else {
// render as text
Handsontable.renderers.TextRenderer.apply(this, arguments);
}
return td;
}") %>%
hot_col("chart", renderer = "
function(instance, td, row, col, prop, value, cellProperties) {
var escaped = Handsontable.helper.stringify(value),
img;
if (escaped.indexOf('~/images/') === 0) {
img = document.createElement('IMG');
img.src = value;
Handsontable.dom.addEvent(img, 'mousedown', function (e){
e.preventDefault(); // prevent selection quirk
});
Handsontable.dsom.empty(td);
td.appendChild(img);
}
else {
// render as text
Handsontable.renderers.TextRenderer.apply(this, arguments);
}
return td;}")
rhandsontable(df, rowHeaders = NULL, width = 800, height = 500) %>%
hot_col(1:3, readOnly = TRUE) %>%
hot_col("Summary", renderer = "
function(instance, td, row, col, prop, value, cellProperties) {
var escaped = Handsontable.helper.stringify(value),
img;
if (escaped.indexOf('~/images/') === 0) {
img = document.createElement('IMG');
img.src = value;
Handsontable.dom.addEvent(img, 'mousedown', function (e){
e.preventDefault(); // prevent selection quirk
});
Handsontable.dsom.empty(td);
td.appendChild(img);
}
else {
// render as text
Handsontable.renderers.TextRenderer.apply(this, arguments);
}
return td;
}") %>%
hot_col("chart", renderer = "
function(instance, td, row, col, prop, value, cellProperties) {
var escaped = Handsontable.helper.stringify(value),
img;
if (escaped.indexOf('~/images/') === 0) {
img = document.createElement('IMG');
img.src = value;
Handsontable.dom.addEvent(img, 'mousedown', function (e){
e.preventDefault(); // prevent selection quirk
});
Handsontable.dsom.empty(td);
td.appendChild(img);
}
else {
// render as text
Handsontable.renderers.TextRenderer.apply(this, arguments);
}
return td;}")