全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 R语言论坛
3733 2
2016-09-22
data(engel)
> attach(engel)
> hist (foodexp)
> curve (density(foodexp),add=T)
Error in curve(density(foodexp), add = T) :
  'expr'要么是函数,要么调用,要么是包含'x'的表达式
> plot (income,foodexp,xlab="Household Income",ylab="Food Expenditure",
+       type="n",cex=.5)
> points(income,foodexp,cex=0.5,col="blue")

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2016-9-23 04:33:33
不知道对不对。curve的第一个参数是一个函数,然后是开始和结束的数值。

你大概可以用另外的方法画图。

plot(density(foodexp))
hist(foodexp,freq=F,add=T)
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2016-9-30 06:04:31
Agree with @szsu. "curve" function expect a function as input. If you just wanted to add density line on top of a histogram just use "lines". Try the following codes:
复制代码

I have no clue where to find the engel data frame and was unable to test the codes myself.
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群