这里有个关于 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) versuslog(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)