I'm trying to build an app in which I can select the data file (input$dataset), then add a new datetime column formatting date and time previous columns to make plots with ggplot2.
I use 'within' that previously worked in batch scripts and in Rstudio. But now I get this error message:
no applicable method for 'within' applied to an object of class "reactive"
How can I apply this method to a reactive object? Should I use another command? cbind? ddply?
datos=reactive({
read.csv(input$dataset,header=T,sep=";",na.strings="-99.900")
within(datos, datetime <- as.POSIXct(paste(FECHA,H_SOLAR),format = "%y/%m/%d %H:%M:%S"))
})
Thanks in advance
EDIT:
Following the answer below I understand a reactive source can't be modified, say add a column to the data frame. The point is I want to use ggplot in this way (adapting an old R script):
p=ggplot(datos(),aes_string(x="datetime", y=input$var,colour="as.character(stat_id)")) +
geom_line()
}
So, how should I add datetime to datos? Maybe creating datos2 as a new reactive source merging datos and datetime?
EDIT 2 Added full code to github https://github.com/pacomet/git