r - Selecting From Data Frame Using Shiny App -


i wanting select values 2 columns of data frame using selectinput. create data frame using file called kenpomeroyanalysis.r. store data frame in variable called pom.

library(xml) library(dplyr) # parse kenpom data ------------------------------------------------------- pom <- "http://kenpom.com/" %>%   readhtmltable() %>%   data.frame()  #columns keep vars <- c(2,5,6,8,10) pom <- pom[,vars] #change name of columns names(pom) <- c("team","pyth","adjo","adjd","adjt")  #make rows numeric pom <- data.frame(pom$team, sapply(pom[,c("pyth","adjo","adjd","adjt")], function(x) as.numeric(as.character(x)))) names(pom)[1] <- "team"  #delete rows nas pom <- na.omit(pom)  #remove data set rm(list=setdiff(ls(), "pom")) 

i wanting create 2 different selectinput boxes choosing pom$team. first selectinput selecting "home_team" , other selecting "away_team".

library(shiny)  #define ui application shinyui(fluidpage(    #application title   titlepanel("ken pomeroy single game predictions"),    fluidrow(      selectinput("home_team",label="home team", choices=pom$team),      selectinput("away_team",label="away team", choices=pom$team)      ),    mainpanel(      textoutput("text1")      )    )) 

my server.r file trying run kenpomeroyanalysis.r file, can have pom data frame interact with.

library(shiny) source("kenpomeroyanalysis.r")   shinyserver(function(input, output){    output$text1 <- rendertext({     paste(input$home_team,"@",input$away_team)   })  }) 

however, when try running app, error saying:

error: object 'pom' not found 

this makes seem server.r file not first creating data frame pom kenpomeroyanalysis.r file. suggestions?

you can create 1 script more global.r in can source file "kenpomeroyanalysis.r", way accessible both server.r , ui.r. in case capable of being accessed server.r.


Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -