Anyone run in to his problem? I have a shiny app that uses SQL files to import data from MS SQL server using the RODBC package. I've narrowed down the problem to here in the server.R file:
ch <- odbcConnect(dsn = xxxxxx)
iQry <- readChar("LeaderDashInd.sql", file.info("LeaderDashInd.sql")$size, T)
oQry <- readChar("LeaderDashOrg.sql", file.info("LeaderDashOrg.sql")$size, T)
iDat <- sqlQuery(channel = ch, query = iQry, stringsAsFactors = F)
oDat <- sqlQuery(channel = ch, query = oQry, stringsAsFactors = F)
odbcClose(ch)
# PREPROCESSING --------------------------
cy <- max(iDat$CampYear)
The app stops at the last line above and gives... Error in iDat$CampYear : $ operator is invalid for atomic vectors. I know this chunk is the problem because when I have the same app run off imported csv files, it works.
A couple things to note:
- This code runs first in the server.R file outside the shinyServer function.
- The app runs fine when launched from my workstation through R Studio. It only stops working when run on our Shiny Server installation.
- Shiny packages are up to date and shiny server is a recent install.
Any thoughts?
class(iDat)? What type of query are you running exactly? Doesn't sound like you are getting a data.frame back. Maybe you are getting an error. - MrFlick