全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 R语言论坛
381 6
2013-09-18
悬赏 50 个论坛币 已解决
这里有个关于 R  画图的问题,向大牛请教一下。

这本书里的http://cran.r-project.org/doc/contrib/usingR.pdf

P38 第 3.9节 第2题。P95有答案,但是不全。
. Plot the graph of brain weight (brain) versus body weight (body) for the data set Animals from the

MASS package. Label the axes appropriately. Alongside on the same graphics page, log(brain weight) versus

log(body weight). Use the row labels to label the points with the three largest body weight values. Label the

axes in untransformed units. [To access this data frame, specify library(MASS)]

我写了以下codes, 但是不能完全解决那个label three largest body weight values. 我试过用identify 但是一用identify(), R总死机.  不知如何解答,所以特此悬赏答案。 只有完全解答的才算最佳,别的回答会视情况奖励。 还有就是画完图后,怎么把它们加入到text file .txt 里?

library(MASS)
attach(Animals)
print(Animals)
plot(body, brain, pch=15, xlab="Body Weight(kg)", ylab="Brain Weight(g)")
row.names(Animals) <- c("Dipliodocus", "Triceratops", "Brachiosaurus")
text(x=body, y=brain, labels=row.names(Animals), pos=4)
detach(Animals)

attach(Animals)
print(Animals)
plot(log(body), log(brain), pch=15, xlab="Log of Body Weight(kg)", ylab="Log of Brain Weight(g)")
row.names(Animals) <- c("Dipliodocus", "Triceratops", "Brachiosaurus")
text(x=body, y=brain, labels=row.names(Animals), pos=4)
detach(Animals)


最佳答案

qoiqpwqr 查看完整内容

plot完之后用 identify(x = body, y = brain, labels = rownames(Animals)) 然后用鼠标去点body weight最大的那三个点,然后按Esc就好了
二维码

扫码加我 拉你入群

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

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

全部回复
2013-9-18 12:30:14
plot完之后用
identify(x = body, y = brain, labels = rownames(Animals))
然后用鼠标去点body weight最大的那三个点,然后按Esc就好了
二维码

扫码加我 拉你入群

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

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

2013-9-18 14:03:00
qoiqpwqr 发表于 2013-9-18 13:32
plot完之后用
identify(x = body, y = brain, labels = rownames(Animals))
然后用鼠标去点body weight最 ...
那个text 貌似不能帮我解决问题, 你说的那个我试过了,可以用拉,我当时没有按esc 所以感觉R 死机了。 但是我要把结果放到text file里才行。应该可以用latex 完成,具体怎么操作啊?
二维码

扫码加我 拉你入群

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

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

2013-9-19 20:55:35
还以为版主是学经济的 咋还编程了呢
顶一下
二维码

扫码加我 拉你入群

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

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

2013-9-19 20:57:50
你想把什么存到txt文件里?
二维码

扫码加我 拉你入群

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

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

2013-9-20 04:41:21
qoiqpwqr 发表于 2013-9-19 20:57
你想把什么存到txt文件里?
Use latex to save plots in txt.
二维码

扫码加我 拉你入群

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

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

点击查看更多内容…
相关推荐
栏目导航
热门文章
推荐文章

分享

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