0

enter image description here

Hi everybody,

I tried to add a ver-line to this histogram for identify the density of a simulated networks with my observed data as the line should be on 0.124, by the code: lines(rep(gden(friendnet),2),c(0,30),col="red",lwd=5)

but I face error:

Error in plot.xy(xy.coords(x, y), type = type, ...) : plot.new has not been called yet

Blockquote

  • 3
  • 2
    It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. – MrFlick Mar 04 '20 at 20:50

1 Answers1

0

Show your code and data. This works just fine:

set.seed(42)
x <- rnorm(100, .124, .015)
hist(x, ylim=c(0, 30))
lines(rep(.124, 2), c(0, 30))

enter image description here

dcarlson
  • 10,936
  • 2
  • 15
  • 18
  • True. I was copying his code to show that his error message suggests a problem in code that he did not include in his question, but as long as he wants to go to the top of the plot window, `abline` is easier. – dcarlson Mar 04 '20 at 21:13
  • Thank you guys for your comments I checked it again and the problem was not about the code itself this error happen when you put the lines() function in another chunk.. Again Thanks for your support – Mohamed Salah Mar 04 '20 at 21:23