R 是一门数据科学非常好的工具,但是由于一些原因还是需要学习一下其他工具,比如python,python很好,pecifically pandas and the wonderful scikit-learn。
散点图
R
ggplot(mtcars , aes(x = hp , y = mpg)) +
geom_point()
python
ggplot(mtcars , aes(x = 'hp' , y = 'mpg')) +\
geom_point()

箱线图
R
ggplot(mtcars , aes(x = factor(cyl) , y = mpg)) +
geom_boxplot()
python
mtcars['cyl'] = pd.factorize(mtcars.cyl)[0]
ggplot(mtcars , aes(x = 'cyl' , y = 'mpg')) +\
geom_boxplot()

直方图
R
ggplot(mtcars , aes(x = mpg)) +
geom_histogram(colour = "black" , fill = "red" , bins = 10) +
scale_x_continuous(breaks = seq(0 , 40, 5))
python
ggplot(mtcars , aes(x = 'mpg')) +\
geom_histogram(fill = 'red' , bins = 10)

分页
R
ggplot(mtcars , aes(x = hp , y = qsec)) +
geom_point() +
facet_wrap(~factor(cyl))
python
ggplot(mtcars , aes(x = 'hp' , y = 'qsec')) +\
geom_point() +\
facet_wrap(~'cyl')

更多调整
R
ggplot(mtcars , aes(x = hp , y = mpg , colour = factor(cyl))) +
geom_point()

python
ggplot(mtcars , aes(x = 'hp' , y = 'mpg' , color = 'name')) +\
geom_point()

R
ggplot(diamonds , aes(x = price , fill = color)) +
geom_histogram(colour = "black") +
facet_wrap(~cut)

python
ggplot(diamonds , aes(x = 'price' , fill = 'color')) +\
geom_histogram(colour = 'black') +\
facet_wrap('cut')

添加我的微信吧
网友评论