您的位置:首页 > 其它

R下一些函数

2016-07-04 20:25 351 查看
head(),tail() : 得到数据的最前或最后的数据。默认6条。可以加参数设置。

summary() : 汇总

数理统计例子

library(ggplot2)
library(plotly)
head(state.x77)
summary(state.x77)

state <- data.frame(state.name,state.region,state.x77)
attach(state)
state_p <- data.frame(state.name,state.region,Area)
p <- ggplot(state_p,aes(x=state_p$state.region,y=state_p$Area,fill=state_p$state.region)) + geom_boxplot()  + ggtitle("美国不同地区州面积")
ggplotly(p)

plot_ly(state_p,x=state.region,y=Area,color = state.region,type = 'box')

pairs(state)

k <- ggplot(state,aes(x=Illiteracy,y=Murder,color=state.region)) + geom_point() +  geom_smooth(method=lm, se=FALSE, fullrange=TRUE) + theme_classic()
ggplotly(k)

cor(state.x77)

q1 <- ggplot(state,aes(x=Murder,y=Life.Exp)) + geom_point() +  geom_smooth(method=lm, se=FALSE, fullrange=TRUE) + theme_classic()
ggplotly(q1)
q2 <- ggplot(state,aes(x=Murder,y=Life.Exp,color=state.region)) + geom_point() +  geom_smooth(method=lm, se=FALSE, fullrange=TRUE) + theme_classic()
ggplotly(q2)


RStudio可以装R MarkDown导出html或pdf
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: