How to enable user to switch between ggplot2 and gVis graphs in R Shiny?

I'm making an app that allows the user to upload any csv file and the app will graph it. I'd like to allow the user to switch between graph styles, gVis and ggplot. The graphs work as implemented by themselves, but I can't seem to figure out how to enable the user to switch them with a checkboxInput (input$switchLine). I'll post only the sample code relative to the problem at h

如何让用户在R Shiny中在ggplot2和gVis图之间切换?

我正在制作一个允许用户上传任何csv文件的应用程序,该应用程序会对其进行绘制。 我想让用户在图形样式,gVis和ggplot之间切换。 这些图自身实现,但我似乎无法弄清楚如何让用户使用checkboxInput(输入$ switchLine)切换它们。 我只会发布与手头问题相关的示例代码,如果您需要更多信息,请告知我。 我已经尝试了像服务器一样的东西: if (input$switchLine) { output$gvisLine } else { output$plotLine } 但

Why R is unable to load a shared object?

I am trying to use XLConnect library in R. If I execute library(XLConnect) I get the following error message: JAVA_HOME cannot be determined from the Registry To resolve this problem I set first the JAVA_HOME variable: Sys.setenv(JAVA_HOME='C:/Program Files (x86)/Java/jre1.8.0_65') library(XLConnect) It looks like it helps me to come further but then I get another problem: unable to load s

为什么R无法加载共享对象?

我试图在R中使用XLConnect库。如果我执行 library(XLConnect) 我收到以下错误消息: JAVA_HOME cannot be determined from the Registry 为了解决这个问题,我首先设置了JAVA_HOME变量: Sys.setenv(JAVA_HOME='C:/Program Files (x86)/Java/jre1.8.0_65') library(XLConnect) 它看起来有助于我进一步发展,但后来又遇到了另一个问题: unable to load shared object 'C:/Program Files/R/R-3.2.2/library/rJava/libs/x64/

Fill area between two lines, with high/low and dates

Forword: I provide a reasonably satisfactory answer to my own question. I understand this is acceptable practice. Naturally my hope is to invite suggestions and improvements. My purpose is to plot two time series (stored in a dataframe with dates stored as class 'Date') and to fill the area between the data points with two different colors according to whether one is above the other.

在两行之间填充区域,高/低和日期

前言:我对自己的问题提供了一个合理满意的答案。 我明白这是可以接受的做法。 当然,我的希望是邀请建议和改进。 我的目的是绘制两个时间序列(存储在数据框中,日期存储为“Date”类),并根据两个数据点之间是否高于另一个来填充两个不同颜色的数据点之间的区域。 例如,绘制债券指数和股票指数,并在股票指数高于债券指数时填充红色区域,否则用蓝色填充该区域。 我为此使用了ggplot2 ,因为我对该软件包非常熟悉(作者

Extract rows from a data.frame based on common values with a list

I'm looking for an easy way for filtering rows from a data.frame, based on a list of numeric sequences. Here's a exemple: My initial data frame: data <- data.frame(x=c(0,1,2,0,1,2,3,4,5,12,2,0,10,11,12,13),y="other_data") My list: list1 <- list(1:5,10:13) My goal is to keep only the rows from "data" which contains exactly the same numeric sequences of "list1&q

根据列表中的公共值从data.frame中提取行

我正在寻找一种简单的方法来根据数字序列列表从data.frame中过滤行。 这是一个例子: 我的初始数据框: data <- data.frame(x=c(0,1,2,0,1,2,3,4,5,12,2,0,10,11,12,13),y="other_data") 我的列表: list1 <- list(1:5,10:13) 我的目标是只保留来自“数据”的行,其中包含与“数据”的“x”列完全相同的“list1”数字序列。 所以输出data.frame应该是: finaldata <- data.frame(x=c(1:5,10:13),y="other_data") 任

R: count days that start at sunset

I'm analysing temporal patterns in a complex data set consisting of several environmental variables as well as activity data from various animal species. These data have been collected by multiple experimental setups, and data from each setup have been stored once per minute. The project has been running for several years now, so my data set is rather large. The first few lines of one of

R:计算在日落时开始的日子

我正在分析由多个环境变量组成的复杂数据集中的时间模式以及来自各种动物物种的活动数据。 这些数据已经通过多个实验设置收集,每个设置的数据每分钟存储一次。 这个项目已经运行好几年了,所以我的数据集相当大。 其中一个数据集的前几行如下所示: > head(setup_01) DateTime Film_number unused PIR Wheel Temperature LightOld LightDay LightNight LightUV IDnumbers error mouse shrew vole rat

Run R interactively from Rscript

I'm trying to start a shiny app or an interactive .Rmd document from an Rscript. However, all I get is a message Listening on http://127.0.0.1:... I believe this is because R is running in interactive mode (another post about this). How can I write the proper Rscript so that either of the following would work? My script #!/usr/bin/Rscript ## This library(shiny) runApp(appDir = "../a

从Rs交互式运行R

我正尝试从Rscript启动一个闪亮的应用程序或交互式.Rmd文档。 但是,我所得到的只是一个信息 在http://127.0.0.1上收听:... 我相信这是因为R在交互模式下运行(关于这个的另一篇文章)。 我怎样才能写出正确的Rscript,以便下列任何一种工作? 我的脚本 #!/usr/bin/Rscript ## This library(shiny) runApp(appDir = "../app") ## Or this ## rmarkdown::run("Main.Rmd") 如果我正确地理解了你的问题,我就可以用Rs

R benchmarking of Spectre and Meltdown mitigations on Windows

Like many, I suspect, I was a little concerned about whether recent Windows updates to address Meltdown and Spectre would have a significant adverse effect on calculation time in R. I do quite a lot of survival analysis using large(ish) data sets, which already takes a long time. Unfortunately it only occurred to me after updating my main PC, so decided to do a little benchmarking using an old o

R在Windows上进行Specter和Meltdown缓解的基准测试

像许多人一样,我怀疑,我有点担心最近的Windows更新是否解决Meltdown和Spectre会对R中的计算时间产生显着的不利影响。我使用大型(ish)数据集进行了很多生存分析,已经需要很长时间了。 不幸的是,它在我更新我的主PC后才发生,因此决定在相关的Windows更新之前和之后使用旧的基准测试进行一次基准测试。 结果非常有趣。 test replications elapsed relative user.self sys.self Pre-Update 100 287.31

ggplot2 secondary axis strange output

I am trying two make a double y-axis plot with ggplot2. However, the primary y-axis text values are changed (and limits) and one of the variables is wrong displayed ("mean" variable). Edit: The text labels for the "mean" variable are ranging from 0.55 until 0.75, making difficult to see the varibility. However, in the original step for that plot (p <- p + geom_line(aes(y

ggplot2次轴奇怪的输出

我正在尝试两个使用ggplot2进行双y轴绘图。 但是,主要的y轴文本值被改变(和限制),其中一个变量显示错误(“平均”变量)。 编辑: “均值”变量的文本标签范围从0.55到0.75,很难看到变化。 然而,在该绘图的原始步骤中(p <-p + geom_line(aes(y = mean_d,color =“mean”))+ geom_point(aes(y = mean_d,color =“mean”)))从0.7757到0.7744。 它应该显示为原始步骤(也许它必须是在ggplot调用中操作数据?)另外

Subset and ggplot2

I have a problem to plot a subset of a data frame with ggplot2. My df is like: ID Value1 Value2 P1 100 12 P1 120 13 ... P2 300 11 P2 400 16 ... P3 130 15 P3 140 12 ... How can I now plot Value1 vs Value2 only for IDs P1 and P3? For example I tried: ggplot(subset(df,ID=="P1 & P3") + geom_line(aes(Value1, Value2, group=ID, colour=ID))) but I always receive an error. ps I also tried many

子集和ggplot2

我有一个问题,用ggplot2绘制一个数据框的子集。 我的DF如下所示: ID Value1 Value2 P1 100 12 P1 120 13 ... P2 300 11 P2 400 16 ... P3 130 15 P3 140 12 ... 现在我怎么能仅为ID P1和P3绘制Value1与Value2? 例如,我尝试过: ggplot(subset(df,ID=="P1 & P3") + geom_line(aes(Value1, Value2, group=ID, colour=ID))) 但我总是收到一个错误。 PS我也试过很多与P1和P3的组合,但我总是失败.. 这里有两个子集

control series line colors and

I am using ggplot2 to plot a time series of sensor data (however I have found it impossible to manipulate the x-axis to show the time in a readable format). The data frame I am using is in the form of > head(df) timeCol dataCol ToolFactor Delta Chuck Tool 1 1/5/2016 0:02 63.90383 1_A 0.000000 A 1 2 1/5/2016 0:02 63.58735 1_A -0.316475 A 1 3 1/5

控制系列线的颜色和

我使用ggplot2绘制传感器数据的时间序列(但是我发现无法操作x轴以可读格式显示时间)。 我正在使用的数据框架的形式是 > head(df) timeCol dataCol ToolFactor Delta Chuck Tool 1 1/5/2016 0:02 63.90383 1_A 0.000000 A 1 2 1/5/2016 0:02 63.58735 1_A -0.316475 A 1 3 1/5/2016 0:03 64.45610 1_A 0.868747 A 1 4 1/5/2016 0:03 64.25554 1_A