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 function
s or in reactive
s. 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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.