Plot.New Has Not Been Called Yet

plot.new has not been called yet error in rmarkdown (Rstudio 1.0.44)

The following will work

{plot(seq(1,10,1))
abline(a=0,b=1)}

R: plot.new has not been called yet

It seems like you're mixing ggplot and base R plot. Instead of creating the first plot and then adding lines later, why don't you simply create the whole plot with ggplot? This would look like:

ggplot() + geom_line(data=Wanna5, mapping= aes(x=AA, y=BB))
+ geom_line(data = Wanna15, aes(x = AA, y = BB),
col = 'green')

Does that help?

Error in R jupyter plot.new has not been called yet.

It's not the problem with jupyter, for curve, you need to provide the function, and also plot something before you do curve with add=TRUE. try something like this below:

f = function(x){
dnorm(x,mean=mean(iris$Petal.Width),sd=sd(iris$Petal.Width))
}
values = 1:10
plot(values,f(values),col="blue")
curve(f,values,add=TRUE)

Sample Image

Error in int_abline....plot.new has not been called yet, how to put line of best fit?

you are mixing ggplot and plot functions. Those can't be mixed easily, so just use one plotting style.

solution with plot:

plot(mtcars$wt, mtcars$mpg)
abline(17.147, 7.245)

plot

solution with ggplot

q <- qplot(x = wt, y = mpg, data = mtcars, color = am)
q + geom_abline(intercept=17.147, slope=7.245)

ggplot

data points to plot. Error: plot.new has not been called yet

We can use geom_text from ggplot2

library(ggplot2)
ggplot(TreismanData3, aes(CPI2013, GCB2013)) +
geom_point(position = "jitter", na.rm = TRUE) +
geom_smooth(method = loess) +
labs(x="Perception", y="Experience")+
theme_bw() +
geom_text(aes(label = wbcode))


Related Topics



Leave a reply



Submit