我想用hist函数创建一个重叠的相对频率表。 我在r脚本中运行以下代码,它可以工作,但是当我在markdown中运行它时,会给我一个错误
with(newtable,hist(weight[Habit == 'NonSmoker'],prob = TRUE, density = 20, col = 'red',xlab = 'Weight(in ounces)', main = 'Histogram of weight by Smoking Status' , xlim = range(weight), ylim = c(0,0.03)))
with(newtable,hist(weight[Habit == 'Smoker'],prob = TRUE, density = 30, col = 'blue', breaks = 20, add = TRUE))
错误
Error in segments(lx1, ly1, lx2, ly2, ...) : plot.new has not been called yet
有人可以告诉我如何解决这个问题吗?
答案 0 :(得分:0)