Warning: Error in model.frame.default: 'data' must be a data.frame, environment, or list - How to fix?

Hi all, appreciate any help you can give as I'm new to shiny and have been doing okay right up until deployment!

I'm getting the above error (title of question) when trying to deploy the app. It works fine locally. I'm not really sure what part of my code is the causing the problem so any help is gratefully received. Thank you!

Code below:
library(shiny)

ui <- fluidPage(

titlePanel("Instructor Rating"),
sidebarLayout(
    sidebarPanel(
        selectInput("variable", "Variable:", 
                    c("Class" = "class",
                      "Attendance" = "attendance")),
    ),
    
    
    mainPanel(
        h3(textOutput("caption")),
        plotOutput("CIPlot")
    )
)

)

server <- function(input, output) {

library(gplots)

formulaText <- reactive({
    paste("instructor.t ~", input$variable)
})

output$caption <- renderText({
    formulaText()
})

xtext <- reactive({
    paste(input$variable)
})

output$CIPlot <- renderPlot({
    plotmeans(as.formula(formulaText()), data = df, connect = FALSE, ylab = "Normalized Instructor Scores", xlab = xtext(), barwidth = 2, barcol = "blue")
})

}

shinyApp(ui, server)

Application logs:
2022-01-03T08:48:28.144596+00:00 shinyapps[5388455]: The following object is masked from ‘package:stats’:
2022-01-03T08:48:28.283748+00:00 shinyapps[5388455]: 179: func
2022-01-03T08:48:28.270435+00:00 shinyapps[5388455]: Warning: Error in model.frame.default: 'data' must be a data.frame, environment, or list
2022-01-03T08:48:28.283745+00:00 shinyapps[5388455]: 187: stop
2022-01-03T08:48:28.283761+00:00 shinyapps[5388455]: 139: drawPlot
2022-01-03T08:48:28.144597+00:00 shinyapps[5388455]: lowess
2022-01-03T08:48:28.283762+00:00 shinyapps[5388455]: 125: reactive:plotObj
2022-01-03T08:48:28.283765+00:00 shinyapps[5388455]: 5: eval
2022-01-03T08:48:28.283763+00:00 shinyapps[5388455]: 15:
2022-01-03T08:48:28.283762+00:00 shinyapps[5388455]: 96: renderFunc
2022-01-03T08:48:28.283763+00:00 shinyapps[5388455]: 8: retry
2022-01-03T08:48:28.283746+00:00 shinyapps[5388455]: 186: model.frame.default
2022-01-03T08:48:28.283764+00:00 shinyapps[5388455]: 7: connect$retryingStartServer
2022-01-03T08:48:28.283748+00:00 shinyapps[5388455]: 181: renderPlot [/srv/connect/apps/Instructor/app.R#39]
2022-01-03T08:48:28.283763+00:00 shinyapps[5388455]: 13: fn
2022-01-03T08:48:28.283763+00:00 shinyapps[5388455]: 95: output$CIPlot
2022-01-03T08:48:28.283764+00:00 shinyapps[5388455]: 6: eval
2022-01-03T08:48:28.283762+00:00 shinyapps[5388455]: 109: drawReactive
2022-01-03T08:48:31.096030+00:00 shinyapps[5388455]: Warning: Error in model.frame.default: 'data' must be a data.frame, environment, or list
2022-01-03T08:48:31.102226+00:00 shinyapps[5388455]: 187: stop
2022-01-03T08:48:31.102229+00:00 shinyapps[5388455]: 186: model.frame.default
2022-01-03T08:48:31.102230+00:00 shinyapps[5388455]: 181: renderPlot [/srv/connect/apps/Instructor/app.R#39]
2022-01-03T08:48:31.102231+00:00 shinyapps[5388455]: 179: func
2022-01-03T08:48:31.102231+00:00 shinyapps[5388455]: 139: drawPlot
2022-01-03T08:48:31.102232+00:00 shinyapps[5388455]: 125: reactive:plotObj
2022-01-03T08:48:31.102233+00:00 shinyapps[5388455]: 96: renderFunc
2022-01-03T08:48:31.102233+00:00 shinyapps[5388455]: 95: output$CIPlot
2022-01-03T08:48:31.102233+00:00 shinyapps[5388455]: 15:
2022-01-03T08:48:31.102234+00:00 shinyapps[5388455]: 13: fn
2022-01-03T08:48:31.102232+00:00 shinyapps[5388455]: 109: drawReactive
2022-01-03T08:48:31.102234+00:00 shinyapps[5388455]: 8: retry
2022-01-03T08:48:31.102235+00:00 shinyapps[5388455]: 7: connect$retryingStartServer
2022-01-03T08:48:31.102235+00:00 shinyapps[5388455]: 6: eval
2022-01-03T08:48:31.102235+00:00 shinyapps[5388455]: 5: eval
2022-01-03T08:48:32.407958+00:00 shinyapps[5388455]: Warning: Error in model.frame.default: 'data' must be a data.frame, environment, or list
2022-01-03T08:48:32.413612+00:00 shinyapps[5388455]: 181: renderPlot [/srv/connect/apps/Instructor/app.R#39]
2022-01-03T08:48:32.413613+00:00 shinyapps[5388455]: 179: func
2022-01-03T08:48:32.413611+00:00 shinyapps[5388455]: 186: model.frame.default
2022-01-03T08:48:32.413610+00:00 shinyapps[5388455]: 187: stop
2022-01-03T08:48:32.413615+00:00 shinyapps[5388455]: 96: renderFunc
2022-01-03T08:48:32.413615+00:00 shinyapps[5388455]: 95: output$CIPlot
2022-01-03T08:48:32.413613+00:00 shinyapps[5388455]: 125: reactive:plotObj
2022-01-03T08:48:32.413614+00:00 shinyapps[5388455]: 109: drawReactive
2022-01-03T08:48:32.413613+00:00 shinyapps[5388455]: 139: drawPlot
2022-01-03T08:48:32.413636+00:00 shinyapps[5388455]: 13: fn
2022-01-03T08:48:32.413637+00:00 shinyapps[5388455]: 8: retry
2022-01-03T08:48:32.413636+00:00 shinyapps[5388455]: 15:
2022-01-03T08:48:32.413637+00:00 shinyapps[5388455]: 7: connect$retryingStartServer
2022-01-03T08:48:32.413638+00:00 shinyapps[5388455]: 6: eval
2022-01-03T08:48:32.413638+00:00 shinyapps[5388455]: 5: eval

URL: https://djw1.shinyapps.io/Instructor

> rsconnect::appDependencies()
package version source
1 DBI 1.1.1 CRAN
2 DT 0.18 CRAN
3 KernSmooth 2.23-20 CRAN
4 LambertW 0.6.6 CRAN
5 LiblineaR 2.10-12 CRAN
6 MASS 7.3-54 CRAN
7 Matrix 1.3-4 CRAN
8 MatrixModels 0.5-0 CRAN
9 ModelMetrics 1.2.2.2 CRAN
10 R6 2.5.1 CRAN
11 RColorBrewer 1.1-2 CRAN
12 Rcpp 1.0.7 CRAN
13 RcppArmadillo 0.10.6.0.0 CRAN
14 RcppEigen 0.3.3.9.1 CRAN
15 RcppParallel 5.1.4 CRAN
16 SQUAREM 2021.1 CRAN
17 SparseM 1.81 CRAN
18 abind 1.4-5 CRAN
19 askpass 1.1 CRAN
20 assertthat 0.2.1 CRAN
21 backports 1.2.1 CRAN
22 base64enc 0.1-3 CRAN
23 bayestestR 0.11.5 CRAN
24 bestNormalize 1.8.2 CRAN
25 bit 4.0.4 CRAN
26 bit64 4.0.5 CRAN
27 bitops 1.0-7 CRAN
28 blob 1.2.2 CRAN
29 boot 1.3-28 CRAN
30 broom 0.7.9 CRAN
31 bslib 0.3.1 CRAN
32 butcher 0.1.5 CRAN
33 caTools 1.18.2 CRAN
34 cachem 1.0.6 CRAN
35 callr 3.7.0 CRAN
36 car 3.0-11 CRAN
37 carData 3.0-4 CRAN
38 caret 6.0-88 CRAN
39 cellranger 1.1.0 CRAN
40 class 7.3-19 CRAN
41 cli 3.0.1 CRAN
42 clipr 0.7.1 CRAN
43 codetools 0.2-18 CRAN
44 colorspace 2.0-2 CRAN
45 commonmark 1.7 CRAN
46 conquer 1.0.2 CRAN
47 corrplot 0.92 CRAN
48 cowplot 1.1.1 CRAN
49 cpp11 0.4.2 CRAN
50 crayon 1.4.1 CRAN
51 credentials 1.3.2 CRAN
52 crosstalk 1.1.1 CRAN
53 curl 4.3.2 CRAN
54 data.table 1.14.0 CRAN
55 datawizard 0.2.1 CRAN
56 dbplyr 2.1.1 CRAN
57 desc 1.3.0 CRAN
58 digest 0.6.27 CRAN
59 doParallel 1.0.16 CRAN
60 doRNG 1.8.2 CRAN
61 dplyr 1.0.7 CRAN
62 dtplyr 1.2.0 CRAN
63 effectsize 0.5 CRAN
64 ellipsis 0.3.2 CRAN
65 emmeans 1.7.0 CRAN
66 estimability 1.3 CRAN
67 evaluate 0.14 CRAN
68 fansi 0.5.0 CRAN
69 farver 2.1.0 CRAN
70 fastmap 1.1.0 CRAN
71 forcats 0.5.1 CRAN
72 foreach 1.5.1 CRAN
73 foreign 0.8-81 CRAN
74 fs 1.5.0 CRAN
75 gargle 1.2.0 CRAN
76 generics 0.1.0 CRAN
77 gert 1.4.3 CRAN
78 ggeffects 1.1.1 CRAN
79 ggplot2 3.3.5 CRAN
80 ggpubr 0.4.0 CRAN
81 ggrepel 0.9.1 CRAN
82 ggsci 2.9 CRAN
83 ggsignif 0.6.3 CRAN
84 gh 1.3.0 CRAN
85 gitcreds 0.1.1 CRAN
86 glue 1.4.2 CRAN
87 googledrive 2.0.0 CRAN
88 googlesheets4 1.0.0 CRAN
89 gower 0.2.2 CRAN
90 gplots 3.1.1 CRAN
91 gridExtra 2.3 CRAN
92 gtable 0.3.0 CRAN
93 gtools 3.9.2 CRAN
94 haven 2.4.3 CRAN
95 heplots 1.3-9 CRAN
96 highr 0.9 CRAN
97 hms 1.1.0 CRAN
98 htmltools 0.5.2 CRAN
99 htmlwidgets 1.5.3 CRAN
100 httpuv 1.6.2 CRAN
101 httr 1.4.2 CRAN
102 ids 1.0.1 CRAN
103 ini 0.3.1 CRAN
104 insight 0.14.5 CRAN
105 ipred 0.9-11 CRAN
106 isoband 0.2.5 CRAN
107 iterators 1.0.13 CRAN
108 jquerylib 0.1.4 CRAN
109 jsonlite 1.7.2 CRAN
110 knitr 1.33 CRAN
111 labeling 0.4.2 CRAN
112 lamW 2.1.0 CRAN
113 later 1.3.0 CRAN
114 lattice 0.20-44 CRAN
115 lava 1.6.9 CRAN
116 lazyeval 0.2.2 CRAN
117 lifecycle 1.0.0 CRAN
118 lme4 1.1-27.1 CRAN
119 lobstr 1.1.1 CRAN
120 lubridate 1.7.10 CRAN
121 magrittr 2.0.1 CRAN
122 maptools 1.1-1 CRAN
123 markdown 1.1 CRAN
124 matrixStats 0.60.1 CRAN
125 mgcv 1.8-36 CRAN
126 mime 0.11 CRAN
127 minqa 1.2.4 CRAN
128 mnormt 2.0.2 CRAN
129 modelr 0.1.8 CRAN
130 munsell 0.5.0 CRAN
131 mvtnorm 1.1-2 CRAN
132 nlme 3.1-152 CRAN
133 nloptr 1.2.2.2 CRAN
134 nnet 7.3-16 CRAN
135 nortest 1.0-4 CRAN
136 numDeriv 2016.8-1.1 CRAN
137 openssl 1.4.4 CRAN
138 openxlsx 4.2.4 CRAN
139 pROC 1.17.0.1 CRAN
140 parameters 0.15.0 CRAN
141 paran 1.5.2 CRAN
142 pbkrtest 0.5.1 CRAN
143 performance 0.8.0 CRAN
144 pillar 1.6.2 CRAN
145 pkgconfig 2.0.3 CRAN
146 plyr 1.8.6 CRAN
147 polynom 1.4-0 CRAN
148 prettyunits 1.1.1 CRAN
149 processx 3.5.2 CRAN
150 prodlim 2019.11.13 CRAN
151 progress 1.2.2 CRAN
152 promises 1.2.0.1 CRAN
153 ps 1.6.0 CRAN
154 psych 2.1.9 CRAN
155 purrr 0.3.4 CRAN
156 quantreg 5.86 CRAN
157 randomForest 4.6-14 CRAN
158 rappdirs 0.3.3 CRAN
159 readr 2.1.1 CRAN
160 readxl 1.3.1 CRAN
161 recipes 0.1.16 CRAN
162 rematch 1.0.1 CRAN
163 rematch2 2.1.2 CRAN
164 reprex 2.0.1 CRAN
165 reshape2 1.4.4 CRAN
166 rio 0.5.27 CRAN
167 rlang 0.4.11 CRAN
168 rmarkdown 2.10 CRAN
169 rngtools 1.5 CRAN
170 rpart 4.1-15 CRAN
171 rprojroot 2.0.2 CRAN
172 rstatix 0.7.0 CRAN
173 rstudioapi 0.13 CRAN
174 rvest 1.0.1 CRAN
175 sass 0.4.0 CRAN
176 scales 1.1.1 CRAN
177 selectr 0.4-2 CRAN
178 shiny 1.6.0 CRAN
179 shinydashboard 0.7.2 CRAN
180 shinythemes 1.2.0 CRAN
181 sjPlot 2.8.10 CRAN
182 sjlabelled 1.1.8 CRAN
183 sjmisc 2.8.7 CRAN
184 sjstats 0.18.1 CRAN
185 sourcetools 0.1.7 CRAN
186 sp 1.4-5 CRAN
187 stringi 1.7.4 CRAN
188 stringr 1.4.0 CRAN
189 survival 3.2-11 CRAN
190 sys 3.4 CRAN
191 tibble 3.1.4 CRAN
192 tidyr 1.1.3 CRAN
193 tidyselect 1.1.1 CRAN
194 tidyverse 1.3.1 CRAN
195 timeDate 3043.102 CRAN
196 tinytex 0.33 CRAN
197 tmvnsim 1.0-2 CRAN
198 tzdb 0.2.0 CRAN
199 usethis 2.0.1 CRAN
200 utf8 1.2.2 CRAN
201 uuid 1.0-3 CRAN
202 vctrs 0.3.8 CRAN
203 viridisLite 0.4.0 CRAN
204 vroom 1.5.7 CRAN
205 whisker 0.4 CRAN
206 withr 2.4.2 CRAN
207 xfun 0.25 CRAN
208 xml2 1.3.2 CRAN
209 xtable 1.8-4 CRAN
210 yaml 2.2.1 CRAN
211 zip 2.2.0 CRAN
Warning messages:
1: In FUN(X[[i]], ...) :
Failed to infer source for package 'credentials'; using latest available version on CRAN instead
2: In FUN(X[[i]], ...) :
Failed to infer source for package 'gert'; using latest available version on CRAN instead
3: In FUN(X[[i]], ...) :
Failed to infer source for package 'gitcreds'; using latest available version on CRAN instead
4: In FUN(X[[i]], ...) :
Failed to infer source for package 'gert'; using latest available version on CRAN instead
5: In FUN(X[[i]], ...) :
Failed to infer source for package 'gitcreds'; using latest available version on CRAN instead
6: In FUN(X[[i]], ...) :
Failed to infer source for package 'credentials'; using latest available version on CRAN instead
7: Unable to package DESCRIPTION files: Couldn't find DESCRIPTION file for credentials

In the code above, where does df come from? I do not see it defined and by default it is the density function of the F distribution, which would surely cause an error.

1 Like

Ah thank you, locally it is just relying on an already defined dataframe called df but I hadn't defined that in the app and made the data available for the app. Appreciate your help!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.