read.delim() not working in shiny but fine if ran from the console

时间:2015-06-15 14:59:10

标签: r shiny

I'm trying to use read.delim() to read a text file that I will use as a dataframe containing stuff I want to plot. Explicitly I'm using:

fullmat<- read.delim("data/myfile.txt", sep="\t", header=TRUE)

This works perfectly fine if I run from the console. However when I try running the app I get ERROR: object 'fullmat' not found and not even the ui is displayed.

I know I'm in the right wd directory because I'm also using readShapePoly() and read.tree() to read other files that are in the same path than myfile.txt and the code works well if I comment the line using read.delim().

So in short, for some reason I can read data into R, but not using read.delim(). Could someone please tell me what am I missing? I could provide the txt file in question if necessary.

Thanks

1 个答案:

答案 0 :(得分:0)

Ahhhh brilliant, sorry!! I just realized:

I'm using my fullmat dataframe as part of my ui.R, so I need to call it there and not only in server.R as I was doing. This was not obvious to me, so I'm posting this as an answer in case someone stumbles with the same issue.

So: if you are creating an object/reading a file to use in your ui.R make sure you create it there or at least source it from there, it doesn't work if you leave it in server.R