Hi all, I'm pretty new to shiny and I just published my first app. In the console, it worked 100% fine, but now that I've published it, I'm getting an odd error message that I'm not fully understanding. (I did not get this error in the console). If you could shed some light on the error, I would very much appreciate it. Basically, from a command buttom, I'm running the following code to use this custom function:
ApplyModels=function(Result){
ConfR=CalculateConfChamp(Result)
ConfR=ConfR %>%
arrange(-ConfR$SimmedRPI)
###Set Simulated RPI Rankings
rank=1
for(i in 1:nrow(ConfR)){
ConfR[i,10]=rank
rank=rank+1
}
ConfR=ConfR %>%
rename(Rank=10)
ConfR$`Win%`=ConfR$SimmedWins/(ConfR$SimmedWins+ConfR$SimmedLosses)
PredictR=ConfR %>%
select("Rank","Team","conference","Win%","ConfChamp")
PredictR=PredictR %>%
rename(
Name=Team,
Conf=conference,
`Conf Champ?`=ConfChamp
)
#if(exists('Probabilities')==TRUE){Probabilities=Probabilities[0,]}
#Probabilities=predict(model3,PredictR[1,],"prob")
for(i in 1:nrow(PredictR)){
tryCatch({
message("Calculating Probabilities from Present Results",paste(" ",round((i/nrow(PredictR))*100,digits = 1),"% Complete",sep = ""))
Row=predict(model3,PredictR[i,],"prob")
Row$Team=PredictR[i,2]
if(i==1){Probabilities=Row}
#Error here....
if(i!=1)Probabilities=rbind(Row,Probabilities)
},error=function(e){})
}
#view(Probabilities)
FinalR=merge.data.frame(Probabilities,ConfR,all.y = TRUE,by.x = "Team",by.y = "Team")
FinalR=FinalR %>%
rename(
AutoProbSim=A,
AtLargeProbSim=L,
NoBidProbSim=N,
SeedProbSim=S,
)
Actu=FinalR %>%
select("Team","ActualWins","ActuallLosses","ActualRPI","conference")
Actu$`Win%`=Actu$ActualWins/(Actu$ActualWins+Actu$ActuallLosses)
Actu=Actu %>%
arrange(-Actu$ActualRPI)
##Set Actual RPI Rankings
rank=1
for(i in 1:nrow(Actu)){
Actu[i,7]=rank
rank=rank+1
}
Actu=Actu %>%
rename(
Rank=7
)
Actu=Actu %>%
select("Rank","conference","Win%","Team")
Actu=Actu %>%
rename(Conf=conference)
Probabilities=Probabilities[0,]
##Get Actual Probabilities
for(i in 1:nrow(Actu)){
tryCatch({
message("Calculating Probabilities from Simulation Results",paste(" ",round((i/nrow(Actu))*100,digits = 1),"% Complete",sep = ""))
Row=predict(InSeason,Actu[i,],"prob")
Row$Team=Actu[i,4]
Probabilities=rbind(Row,Probabilities)
},error=function(e){})
}
FinalR=merge.data.frame(Probabilities,FinalR,all.y = TRUE,by.x = "Team",by.y = "Team")
FinalR=FinalR %>%
rename(
AutoProbAct=A,
AtLargeProbAct=L,
NoBidProbAct=N,
SeedProbAct=S,
)
rm(ConfR)
rm(Actu)
rm(Probabilities)
return(FinalR)
}
However, my log looks like this:
2021-01-09T00:19:15.800062+00:00 shinyapps[3455333]: Calculating Probabilities from Present Results 93.1% Complete
2021-01-09T00:19:15.821554+00:00 shinyapps[3455333]: Calculating Probabilities from Present Results 96.5% Complete
2021-01-09T00:19:15.800678+00:00 shinyapps[3455333]: Calculating Probabilities from Present Results 93.8% Complete
2021-01-09T00:19:15.821555+00:00 shinyapps[3455333]: Calculating Probabilities from Present Results 97.2% Complete
2021-01-09T00:19:15.821555+00:00 shinyapps[3455333]: Calculating Probabilities from Present Results 97.6% Complete
2021-01-09T00:19:15.821556+00:00 shinyapps[3455333]: Calculating Probabilities from Present Results 98.6% Complete
2021-01-09T00:19:15.821556+00:00 shinyapps[3455333]: Calculating Probabilities from Present Results 98.3% Complete
2021-01-09T00:19:15.821553+00:00 shinyapps[3455333]: Calculating Probabilities from Present Results 96.2% Complete
2021-01-09T00:19:15.821817+00:00 shinyapps[3455333]: Calculating Probabilities from Present Results 99.7% Complete
2021-01-09T00:19:15.821554+00:00 shinyapps[3455333]: Calculating Probabilities from Present Results 96.9% Complete
2021-01-09T00:19:15.821555+00:00 shinyapps[3455333]: Calculating Probabilities from Present Results 97.9% Complete
2021-01-09T00:19:15.827507+00:00 shinyapps[3455333]: 86: merge.data.frame
2021-01-09T00:19:15.823083+00:00 shinyapps[3455333]: Warning: Error in as.data.frame: object 'Probabilities' not found
2021-01-09T00:19:15.821556+00:00 shinyapps[3455333]: Calculating Probabilities from Present Results 99% Complete
2021-01-09T00:19:15.827517+00:00 shinyapps[3455333]: 12: fn
2021-01-09T00:19:15.821557+00:00 shinyapps[3455333]: Calculating Probabilities from Present Results 99.3% Complete
2021-01-09T00:19:15.827518+00:00 shinyapps[3455333]: 7: connect$retry
2021-01-09T00:19:15.822121+00:00 shinyapps[3455333]: Calculating Probabilities from Present Results 100% Complete
2021-01-09T00:19:15.827520+00:00 shinyapps[3455333]: 5: eval
2021-01-09T00:19:15.827506+00:00 shinyapps[3455333]: 88: as.data.frame
2021-01-09T00:19:15.827508+00:00 shinyapps[3455333]: 84: observeEventHandler [/srv/connect/apps/Monte/app.R#1361]
2021-01-09T00:19:15.827518+00:00 shinyapps[3455333]: 6: eval
2021-01-09T00:19:15.827507+00:00 shinyapps[3455333]: 85: ApplyModels [/srv/connect/apps/Monte/app.R#53]
2021-01-09T00:19:15.827508+00:00 shinyapps[3455333]: 13: runApp
If you could clarify what's going wrong, I'd greatly appreciate it. Thanks