passing a data.frame to a function and subsetting

Dear listers,
I am new in Shiny and I am facing the problem of dealing with a data.frame within a function after having read a text file. In short (I have summarized things eliminating some code),

- in ui I have (among others input)

fileInput('file1', 'Tableau de piégeage', accept=c('text/tab telimited with header', '.txt'))

- in server

reads<-function(tab){
inFile <- tab
if (is.null(inFile))
return(NULL)
tbl <- read.csv(inFile$datapath, header=TRUE, sep="\t", dec =".")
return(tbl)
}

kinetics<-function(densren,eatAT,N,K,area,tpieg){
if(!is.null(tpieg)) tpieg[,2]<-tpieg[,2]/area
}

tabpieg<-reactive(reads(input$file1))
dens2<-reactive(kinetics(input$densren,input$eatAT,input$N,input$K,input$area,tabpieg()))

With tabpieg() I thought that tpieg would be a data.frame, hence subsettable, BUT actually I get this error

Warning: Error in [: object of type 'closure' is not subsettable

Any idea about how to make tabpieg() considered as a subsettable data.frame in the function kinetics() ?

Best,

Patrick

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.