<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>R on Dr. Hui Lin</title><link>https://www.huilin.site/categories/r/</link><description>Recent content in R on Dr. Hui Lin</description><generator>Hugo -- gohugo.io</generator><language>zh-cn</language><managingEditor>linhui@pric.org.cn (Dr. Hui Lin (林辉))</managingEditor><webMaster>linhui@pric.org.cn (Dr. Hui Lin (林辉))</webMaster><copyright>© 2026 Hui Lin. All rights reserved.</copyright><lastBuildDate>Fri, 24 Jul 2026 20:35:00 +0800</lastBuildDate><atom:link href="https://www.huilin.site/categories/r/index.xml" rel="self" type="application/rss+xml"/><item><title>Learning ggmap</title><link>https://www.huilin.site/post/learning-ggmap/</link><pubDate>Fri, 31 Mar 2017 14:24:00 +0000</pubDate><author>linhui@pric.org.cn (Dr. Hui Lin (林辉))</author><guid>https://www.huilin.site/post/learning-ggmap/</guid><description>&lt;p&gt;This is a document for myself to review ggmap package, and how to get quick start.&lt;/p&gt;
&lt;p&gt;ggmap is powerful map plot package in R. Compared with maps package, plots exported from ggmaps are elegant.&lt;/p&gt;
&lt;p&gt;Two steps to plot a map: plot a map raster, decorate the base map with your own data.&lt;/p&gt;

&lt;h3 class="relative group"&gt;Step 1: download your base map
 &lt;div id="step-1-download-your-base-map" class="anchor"&gt;&lt;/div&gt;
 
 &lt;span
 class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
 &lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#step-1-download-your-base-map" aria-label="锚点"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h3&gt;
&lt;p&gt;You need to know the location you will plot. Define location in two ways showing below:&lt;/p&gt;</description></item><item><title>Learning ggplot2</title><link>https://www.huilin.site/post/learning-ggplot2/</link><pubDate>Fri, 31 Mar 2017 14:12:00 +0000</pubDate><author>linhui@pric.org.cn (Dr. Hui Lin (林辉))</author><guid>https://www.huilin.site/post/learning-ggplot2/</guid><description>&lt;p&gt;本课程介绍三种R语言的绘图工具包：&lt;code&gt;plot&lt;/code&gt;,&lt;code&gt;qplot&lt;/code&gt;,&lt;code&gt;ggplot&lt;/code&gt;。三种绘图包的能够和语法均不相同。
&lt;code&gt;plot&lt;/code&gt;命令是R语言自带的绘图命令，绘图效果简单，适宜数据分析时绘图。
&lt;code&gt;qplot&lt;/code&gt;命令是R语言初级绘图语言包，能够提供符合出版物标准的简单绘图。得到的图形大方美观。&lt;/p&gt;

&lt;h3 class="relative group"&gt;Lesson: Regression Models Introduction
 &lt;div id="lesson-regression-models-introduction" class="anchor"&gt;&lt;/div&gt;
 
 &lt;span
 class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
 &lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#lesson-regression-models-introduction" aria-label="锚点"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h3&gt;
&lt;p&gt;制图：plot(jitter(child,4) ~ parent,galton)&lt;/p&gt;
&lt;p&gt;建立回归函数：使用函数&lt;code&gt;lm&lt;/code&gt;(linear model)，例如：&lt;/p&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;regrline &amp;lt;- lm(child~parent, galton)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;建立回归函数之后，使用&lt;code&gt;abline&lt;/code&gt;(add straight lines to a plot)函数将回归函数在图表中画出，例如&lt;/p&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;abline(regrline, lwd = 3, col = &amp;#34;red&amp;#34;)
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;#lwd = line width, col = line color&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;画出直线之后可以使用函数&lt;code&gt;summary&lt;/code&gt;查看回归函数的各类参数包括残差， 系数，相关系数等等。&lt;/p&gt;
&lt;hr&gt;

&lt;h3 class="relative group"&gt;qplot
 &lt;div id="qplot" class="anchor"&gt;&lt;/div&gt;
 
 &lt;span
 class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
 &lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#qplot" aria-label="锚点"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;qplot&lt;/code&gt; is a basic function in ggplot2 package. It provides some basic plots (e.g. points, smooth, boxplot) for users to learn their database generally.&lt;/p&gt;</description></item></channel></rss>