我想生成一个timevis图,其中字体大小根据变量的重要性而变化。
使用源数据框中的“样式”选项,我可以更改字体颜色。但是,当我使用相同的方法尝试更改字体大小时,R无法正确呈现变量。
以下是我的数据示例:
data <- structure(list(groups = c("Deadline.1", "Deadline.1", "Deadline.1",
"Deadline.1", "Deadline.1"), content = c("Geography Tutorials: Critical
Thinking & Techniques", "Principles of Geographical Inquiry I", "Geography
in Action",
"Physical Geography: Earth Surface Processes & Landforms", "Biogeography &
Ecology"
), start = structure(c(17459, 17505, 17631, 17911, 18048), class = "Date"),
end = structure(c(17459, 17505, 17631, 17911, 18048), class = "Date"),
type = c("point", "point", "point", "point", "point"), id = c(1L,
2L, 7L, 9L, 10L), Assessment = c("1500 word essay ", "Group survey",
"20% attendance (5% per block)", "2 hr exam ", "2 hr exam "
), Percentage = c(15, 15, 20, 100, 100), style = c("'font-size:15px;'",
"'font-size:15px;'", "'font-size:20px;'", "'font-size:100px;'",
"'font-size:100px;'")), row.names = c(NA, 5L), class = "data.frame")
这是我代码的相关部分。显然,在最终版本中,我将在“百分比”和字体大小之间建立一个更微妙的链接功能。但是,不管字体大小,这都行不通。
library(shiny)
library(timevis)
library(tidyr)
library(plyr)
library(dplyr)
data$style <- paste0("'font-size:", data$Percentage, "px;'")
### example time vis rendering (doesn't work)
timevis(data = data[2:3, ]) ### random variable choice
### but this works
data$style <- 'color: red'
timevis(data = data[2:3, ])
任何建议都非常欢迎。我主要不是模型开发人员,也不是应用程序开发人员,因此,如果这是由于琐碎的HTML错误所致,我们深表歉意。