全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 R语言论坛
1335 5
2012-01-02
1如何用二分法求解方程在(-10,10)之间的根。
2*X^3-4*X^2+3*X-6=0

2 如何调用数据中某个变量作为条件。
如 student中的age序列,如果要输出年龄>20的学生的全部信息或者成绩(一部分)信息。如何调用age序列写if条件。

问题可能不难,但是刚刚开始学习R,真的不会,求帮助!!!灰常感谢!!!
二维码

扫码加我 拉你入群

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

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

全部回复
2012-1-2 13:16:09
f=function(x)2*x^3-4*x^2+3*x-6
uniroot(f,c(-10,10))

后面那个你可以用subset,比如整个数据是x  subset(x,x$age>20)
二维码

扫码加我 拉你入群

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

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

2012-1-2 13:26:51
zufe1985 发表于 2012-1-2 13:16
f=function(x)2*x^3-4*x^2+3*x-6
uniroot(f,c(-10,10))
$root
[1] 2

$f.root
[1] 5.329071e-15

$iter
[1] 2

$estim.prec
[1] 6.103516e-05
帮忙看看这个结果 嘿嘿
下面那个懂了
非常感谢啦
二维码

扫码加我 拉你入群

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

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

2012-1-2 13:50:09
$root 就是你想要得到的根, f$root是你这个跟所对应的function的值
root and f.root give the location of the root and the value of the function evaluated at that point. iter and estim.prec give the number of iterations used and an approximate estimated precision for root.
二维码

扫码加我 拉你入群

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

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

2012-1-2 14:22:55
zufe1985 发表于 2012-1-2 13:50
$root 就是你想要得到的根, f$root是你这个跟所对应的function的值
root and f.root give the location  ...
太感谢了   
二维码

扫码加我 拉你入群

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

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

2012-1-2 14:24:39
Good to learn.
二维码

扫码加我 拉你入群

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

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

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

说点什么

分享

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