全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 R语言论坛
3534 3
2009-06-26
想要得到这样的函数:
y =  2x , x<=3;
       5   , else.
code如下:
复制代码

Warning message:
In if (x <= 3) y = 2 * x else y = 5 :
  条件的长度大于一,因此只能用其第一元素
这是为什么呢?
----------------------------------------------------
再附加一个核光滑回归问题:^_^
ksmooth函数只能采用box和normal两个核,有没有用biweight的?
对于用GCV方法选取bandwidth,需要单独使用mgcv吗?
ksmooth用法如下:
ksmooth(x, y, kernel = c("box", "normal"), bandwidth = 0.5,
        range.x = range(x),
        n.points = max(100, length(x)), x.points)
-----------------------------------------------------
期待回复ing 谢谢!
二维码

扫码加我 拉你入群

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

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

全部回复
2009-9-13 23:47:02
同问!!!!!!!!!!!!!!!
二维码

扫码加我 拉你入群

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

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

2009-9-14 00:43:03
"if" is not vectorised and "age" is a vector. Try the following test:

if(c(TRUE, FALSE)) "TRUE" else "FALSE"

You really need to use "ifelse".

ifelse(c(TRUE, FALSE), "TRUE", "FALSE")

As others have suggested, you might want to look at ?cut.

--sundar
二维码

扫码加我 拉你入群

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

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

2009-9-14 00:43:25
"if" is not vectorised and "age" is a vector. Try the following test:

if(c(TRUE, FALSE)) "TRUE" else "FALSE"

You really need to use "ifelse".

ifelse(c(TRUE, FALSE), "TRUE", "FALSE")

As others have suggested, you might want to look at ?cut.

--sundar
二维码

扫码加我 拉你入群

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

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

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

说点什么

分享

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