是否可以在闪亮的应用程序运行时编写 R 代码?我已经构建了一个闪亮的应用程序,但希望让用户可以选择在闪亮的应用程序中编写自己的 R 代码。我想让控制台与查看器和简化的环境窗格一起闪亮。我从来没有见过这样的事情,所以在我花很多时间做这件事之前,我想知道这是否可能。有人见过这样的东西吗?
感谢 Cory,我找到了 rfiddle,这正是我正在寻找的。但是我似乎无法让它工作。我使用了 r-fiddles 网站所说的 iframe 来嵌入 rfiddle,但我不断收到此错误消息:
Error in withReactiveDomain(shinysession, { :
No handler registered for for type .clientdata_output_<iframe width="300" height="600" src="http://r-fiddle.org/#/embed/eYsWfghB/1" allowfullscreen="allowfullscreen" frameborder="0"></iframe>_hidden
Run Code Online (Sandbox Code Playgroud)
library(shiny)
ui = shinyUI(
fluidPage(
htmlOutput(tags$iframe(width=300, height=600,
src='http://r-fiddle.org/#/embed/eYsWfghB/1',
allowfullscreen='allowfullscreen', frameborder='0'))
)
)
server = shinyServer(function(input, output, session) {
})
shiny::shinyApp(ui,server)
Run Code Online (Sandbox Code Playgroud) 我在让 highcharter 与我闪亮的应用程序一起使用时遇到问题。真正奇怪的是,有些高图表可以工作,有些则不行。这可能是一些我没有发现的愚蠢错误。无论如何,这里有一些代码:
library(shiny)
library(highcharter)
library(ggplot2)
ui <- fluidPage(
column(width = 12,
highchartOutput("hc_more.FA",height="500px")
)
)
server = function(input, output) {
output$hc_more.FA <- renderHighchart({
hchart(diamonds$carat)
})
}
shinyApp(ui = ui, server = server)
Run Code Online (Sandbox Code Playgroud)
这是我的会话信息:
sessionInfo()
R version 3.3.0 (2016-05-03)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] …Run Code Online (Sandbox Code Playgroud) 我一直在互联网上搜索我的问题的答案,但到目前为止,我发现所有人都提出同样的问题,但与我有不同的情况.
大多数人在他们的ggplot上有两个或更多的数据集,并添加一个图例来显示哪一个是哪个.但是,我绘制了一条线,但线内有多种颜色.
以下是我的输出图片,以便进一步说明:

我想创建一个图例来指定每种颜色的含义.
这是我的代码:
p04 <- read.csv("p04_datalog.csv",header=TRUE)
#The following line activates the ggplot2 add-on
library(ggplot2)
#This line will eliminate all -1 values for GS_ReelRaiseLowerAngle
p04_NoNegative <- subset(p04, p04$GS_ReelRaiseLowerAngle != -1)
#This creates an array of colors that are to be used with the plotting scripts
fieldcolors <- ifelse(p04_NoNegative$GS_Field == "Out of Bounds","black",ifelse(p04_NoNegative$GS_Field ==
"Clumping","Orange",ifelse(p04_NoNegative$GS_Field == "Down","purple",ifelse(p04_NoNegative$GS_Field ==
"High Moisture","darkblue",ifelse(p04_NoNegative$GS_Field == "High Thin","pink",ifelse(p04_NoNegative$GS_Field ==
"High Weeds","green",ifelse(p04_NoNegative$GS_Field == "Low Moisture","cyan",ifelse(p04_NoNegative$GS_Field ==
"Low Thin","white",ifelse(p04_NoNegative$GS_Field == "Low Weeds","green4",ifelse(p04_NoNegative$GS_Field ==
"Medium Thin","red",ifelse(p04_NoNegative$GS_Field == "Medium …Run Code Online (Sandbox Code Playgroud) 使用数组:
my_array <- c(F,T,T,F,F,T,T,T,F,T,F)
Run Code Online (Sandbox Code Playgroud)
我需要一个脚本来告诉我该值从False到True的次数.只是通过眼睛很容易看到它做了3次.我只对它从False切换到True而不是从True切换到False感兴趣.