楼主: oliyiyi
91828 2410

【latex版】水贴   [推广有奖]

831
oliyiyi 发表于 2015-9-9 16:28:16
This week we’ll start out with a part on the prerequisites – which is why I labeled it Part 0 – of your R-setup.

832
oliyiyi 发表于 2015-9-9 16:29:27
Using an Editor

When writing functions and creating packages it is extremely important to write your syntax in an environment that has functionalities beyond the basic R GUI. Many people use RStudio, which I can also wholeheartedly recommend. A main pro of RStudio is that it is a cross-platform IDE, meaning that your R-Code will look and feel the same on a Windows machine and on a Mac Book (which can be incredibly helpful if you’re teaching R). The same goes for Emacs with ESS. Most other alternatives are more OS-specific: Notepad Plus with the NppToR add-on is a good choice on Windows and gedit with the rgedit extension is what I can recommend if you’re running Ubuntu Linux. No matter which of these you choose, they all give you much more information about your code than standard R and – in some cases – come with a plethora of debugging functionalities which are quite handy for writing your own packages.

833
oliyiyi 发表于 2015-9-9 16:30:00
Setting up R in Ubuntu (15.04)

At this point I’ll assume that you have R installed on your machine. If you don’t, follow these instructions on the official site. For creating your own packages it is important that you not only install the base version of R, but also the developer version via terminal.

834
oliyiyi 发表于 2015-9-9 16:30:45
  1. sudo apt-get install r-base r-base-devel
复制代码

835
oliyiyi 发表于 2015-9-9 16:31:26
Additionally, there are two packages I would strongly recommend using when you are building your own R packages: devtools and roxygen2. The problem with using the former is that it requires some additional libraries to be installed on your machine. What you can do is to install all the necessary libraries.

836
oliyiyi 发表于 2015-9-9 16:31:59
  1. sudo apt-get install libcurl4-openssl-dev libcurl4-gnutls-dev libxml2-dev libssl-dev
复制代码

837
oliyiyi 发表于 2015-9-9 16:32:42
Once these are installed you can open up R and use to install these two packages.
  1. install.packages('devtools')
  2. install.packages('roxygen2')
复制代码

838
oliyiyi 发表于 2015-9-9 16:33:42
#Setting up R in Windows

If you are running Windows, the initial setup is a bit more complicated. But, with a few tweaks it is possible to make the package building work just fine. Because I run Ubuntu on my machine I am no expert with setting this up but following this excellent guide by Steven Mosher, I was able to make it work in 10 minutes on Windows 8.1 (and it still works despite the upgrade to Windows 10).

839
oliyiyi 发表于 2015-9-9 16:34:18
Setting up R in Mac OS X

If you are running Mac OS X you don’t need to take any extra steps in your R setup. It should work straight out of the box – but be aware that the current R version (3.2.2 as of this writing) will only run on Mac OS X 10.9 or higher.

So, now that we’ve gotten this out of the way, we can start taking the first steps towards building our own R package.

Next time, we’ll create some functions and start the initial package build.

840
oliyiyi 发表于 2015-9-9 16:35:30
Today I am happy to announce a new lesson for my free email course Learn to Map Census Data in R. This lesson explains how to get and map historic census data in R. While I had intended this lesson to only go to new signups, it looks like my email provider sent it (along with resending the conclusion email!) to anyone who ever took the course. I apologize for this! For reference, here is the lesson:

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注jltj
拉您入交流群
GMT+8, 2026-3-1 17:55