跳过正文

R

Learning ggmap

··1 分钟
This is a document for myself to review ggmap package, and how to get quick start. ggmap is powerful map plot package in R. Compared with maps package, plots exported from ggmaps are elegant. Two steps to plot a map: plot a map raster, decorate the base map with your own data. Step 1: download your base map # You need to know the location you will plot. Define location in two ways showing below:

Learning ggplot2

··2 分钟
本课程介绍三种R语言的绘图工具包:plot,qplot,ggplot。三种绘图包的能够和语法均不相同。 plot命令是R语言自带的绘图命令,绘图效果简单,适宜数据分析时绘图。 qplot命令是R语言初级绘图语言包,能够提供符合出版物标准的简单绘图。得到的图形大方美观。 Lesson: Regression Models Introduction # 制图:plot(jitter(child,4) ~ parent,galton) 建立回归函数:使用函数lm(linear model),例如: regrline <- lm(child~parent, galton) 建立回归函数之后,使用abline(add straight lines to a plot)函数将回归函数在图表中画出,例如 abline(regrline, lwd = 3, col = "red") #lwd = line width, col = line color 画出直线之后可以使用函数summary查看回归函数的各类参数包括残差, 系数,相关系数等等。 qplot # qplot is a basic function in ggplot2 package. It provides some basic plots (e.g. points, smooth, boxplot) for users to learn their database generally.