我正在尝试运行这个闪亮的应用程序,它接收一些数据,然后处理它,在一个名为"out"的变量中给出一些比例表。然后使用purrr包映射的函数绘制这些表。该应用程序在我试图定义函数的部分中给了我以下错误:-
cannot coerce type 'environment' to vector of type 'character'
renderUI
函数需要在ggplot
图上调用renderPlot
。这是添加了output$plots
。output$plots <- renderUI({ plots <- function(x) { d = x %>% as.data.frame() %>% tidyr::pivot_longer(!grp) %>% dplyr::group_by(name) %>% dplyr::mutate(n = 1:n()) gg <- ggplot(data = d) + # put ggplot into a variable geom_path(aes( x = grp, y = value, group = factor(name), color = factor(name) ), size = 0.7) + geom_point(aes( x = grp, y = value, color = factor(name) ), size = 2) + geom_text( data = d %>% filter(n == max(n)), aes( x = grp, y = value, label = name, color = factor(name) ), nudge_x = 0.2 ) + labs(x = "Group", y = "P", title = "") + theme_bw() + theme(legend.position = "none") renderPlot(gg) # call renderPlot on the ggplot variable }