I'm using reactive function in order to do the 2 things at the same time:
see the code below:
file_info<-reactive({
filename <- file.choose()
data <- read.csv(filename, skip=1)
file_name <- basename(filename)
})
however, the file_info() only contains the file_name, which forces to me to write another reactive function to get the data uploaded:
Raw<- reactive({
inFile <- input$file1
if (is.null(inFile))
return(NULL)
Raw<-read.csv(inFile$datapath, header=TRUE ,sep=",")
})
I think there should be another efficient way to do this, thanks in advance for any suggestions.
Return values in R are meant to be contained in a single object, either in functions or in reactives. However, I would recommend gathering your content in a list and get the return values from your reactive in a temp variable. Then, get what you want from this temp variable. Like:
myReactive({
# does stuff
return(
list(
val1 = val1,
val2 = val2
)
)
}}
.tmp <- myReactive()
x <- .tmp$val1
y <- .tmp$val2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With