Still getting error in dev.off() : cannot shut down device 1 (the null device)

I am new to R so I dont exactly know what kind of information to provide to get help but here it goes: I get the error “Error in dev.off() : cannot shut down device 1 (the null device)” when I try to make a plot… any plot. My latest code is:

pdf("spec_accum_w_sample.pdf")
plot(specaccum(counts))
dev.off()

An empty pdf file and a plot get successfully produced but when I write dev.off() it does not write into the created pdf. Instead I get the error above. I have tried restarting RStudio as well as anything else suggested on this link: Error in dev.off() : cannot shut down device 1 (the null device). I have also tried the initial code suggested on the ticket to re-create the author’s pie chart, but still get the same error despite trying all of the suggestions

I do not find any other place that addresses this specific error. I am running R version 3.4.4 (2018-03-15) Platform: x86_64-apple-darwin15.6.0 (64-bit) Running under: macOS Sierra 10.12.6

Is there anything else I can try? Am I supposed to install something or update something to get dev.off() to work?

Leave a Comment