Reputation: 35
I am currently trying to publish a shinyapp to shinyapp.io but I am having trouble configuring my rdrop2 token to upload my data file with it. It is in csv form and I using app.R. Since I cannot upload the token on here in fear of having my Dropbox completely available online I will do my best.
The function I am using with rdrop2 is the following:
token <- drop_auth()
saveRDS(token, "droptoken.rds")
token <- readRDS("droptoken.rds")
drop_acc(dtoken = token)
statadata <- drop_read_csv("/shinyapp/alldata.csv")
g <- na.omit(statadata)
data <- reactive({
g[1:input$scatterD3_nb,]
})
ui <- fluidPage(...
When I run the shiny app on RStudio it is fully functional but when I deploy the app it gives me one of two errors.
ERROR: oauth_listener() needs an interactive environment.
or
Error in func(fname, ...) : app.R did not return a shiny.appobj object.
neither error occurs when I am just printing it into the RStudio viewer.
While I fix this issue is there a way to simply create the data set by copying the csv file text editor version directly into r with something like
read.csv("country,nutsid,year,cyril_index_left,delta_cyril_left,manifesto,cyril_index_abs
,cyril_index,cyril_index_right,delta_cyril_right,Employment_15_64_,Employment_total,youth_employment,L_Employment_total,
L_youth_employment,growth, Austria,AT11,2002,-1017.925,-216.9429,-17.64,72.93657,1017.925,
0,-977.0339,1.1,0.9,0.5,-2.1,-8.9,4.7,Austria,AT11,2006,-923.9658,93.95892,
-4.308,104.4628,923.9658,0,0,0.8,0.4,-1.9,2.5,2.8,1.6", sep = ",")
I really do not see any other solution because shiny won't read my data from local files anyway.
Upvotes: 3
Views: 2105
Reputation: 176638
You can use the text=
argument to read.table
(and therefore read.csv
):
x <- read.csv(text="country,nutsid,year,cyril_index_left,delta_cyril_left,manifesto,cyril_index_abs,cyril_index,cyril_index_right,delta_cyril_right,Employment_15_64_,Employment_total,youth_employment,L_Employment_total,L_youth_employment,growth
Austria,AT11,2002,-1017.925,-216.9429,-17.64,72.93657,1017.925,0,-977.0339,1.1,0.9,0.5,-2.1,-8.9,4.7
Austria,AT11,2006,-923.9658,93.95892,-4.308,104.4628,923.9658,0,0,0.8,0.4,-1.9,2.5,2.8,1.6")
Upvotes: 11
Reputation: 368181
Sure. Use something like this.
Lines <- "
header1, header2
val1, 12
val2, 23
"
con <- textConnection(lines)
data <- read.csv(con)
close(con)
You can simplify and have the multiline expression around read.csv(textConnection("...here..."))
as well.
You can also paste from the clipboard, but that tends to get OS specific and less portable.
Upvotes: 7