RStudio not showing plots

Hi all - brand new Rstudio user here. We are using RStudio for an epi class, but unfortunately I have not learned anything in R yet!

We were given a code to practice with in the R0 package, which includes some plots. However, the console keeps getting stuck on "Waiting for profiling to be done..." and no plots ever show up in the "plots" window.

If its helpful: Mac OS 10.14.6, RStudio 1.2.5033

Anyone have any suggestions on how to get the plots to show?
Thank you!

What code did you use?


mGT<-generation.time("gamma", c(3, 1.5)) #see also est.GT

#plot(Germany.1918, col="red")

estR0<-estimate.R(Germany.1918, mGT, begin=1, end=27, methods=c("EG", "ML", "TD", "AR", "SB"),
pop.size=100000, nsim=1000)



par(mfrow=c(3,2), mar=c(2,2,2,2))

#individual plots
par(mfrow=c(2,3), mar=c(2,2,2,2))

#par(mfrow=c(4,4), mar=c(2,2,2,2))
plotfit(estR0$estimates$SB) #works fine in R

##sensitivity analysis of the time window for exponential growth

sen=sensitivity.analysis(sa.type="time", incid=Germany.1918, GT=mGT, begin=1:15, end=16:30,
plot(sen, what=c("criterion","heatmap"))

##sensitivity analysis of the generation time
tmp<-sensitivity.analysis(sa.type="GT", incid=Germany.1918, GT.type="gamma", GT.mean=seq(1,5,1),, begin=1, end=27, est.method="EG")

par(mfrow=c(1,1), mar=c(4,4,4,4))
plot(x=tmp[,"GT.Mean"], xlab="mean GT (days)", y=tmp[,"R"], ylim=c(1.2, 2.1), ylab="R0 (95% CI)",
type="p", pch=19, col="black", main="Sensitivity of R0 to mean GT")
arrows(x0=as.numeric(tmp[,"GT.Mean"]), y0=as.numeric(tmp[,"CI.lower"]),
y1=as.numeric(tmp[,"CI.upper"]), angle=90, code=3, col="black", length=0.05)

^I am getting stuck on line 6, the first plot, but none of the other plots show either.

Maybe something with your setup. It all seems to be working for me. Strange.

Can you post the output of What R version are you running as well?

This is the part where you get stuck, right?

If you start a line in R with an hash (#), the line is seen as a comment and will not be evaluated. When you try to run them, RStudio automatically skippes to the next command (estR0<-estimate.R(Germany.1918,...)) and runs it. Since you are storing the output of this command in estRP , you don't see any output, but only the message and warning that this command produces.

If you for example remove the hash before plot(mGT) in line 6, you should get the plot you are expecting.


jms solved my problem! I so appreciate your help!

To answer your questions, though:
I have R 3.3.3 GUI 1.69 Mavericks build (7328), but I didn't have it open or anything (I'm still a little confused between R and RStudio)
"Darwin Kernel Version 18.7.0: Tue Aug 20 16:57:14 PDT 2019; root:xnu-4903.271.2~2/RELEASE_X86_64"

Omg this fixed it!! Thank you so much!! I seem to be the only person in my class though that had this problem, I wonder why they were able to run it with the (#) still there? Regardless..THANK YOU!!

They would have been able to run the rest of it though.

1 Like

This topic was automatically closed 21 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.