forked from STAT545-UBC/STAT545-UBC-original-website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
block000_r-rstudio-install.html
175 lines (151 loc) · 8.05 KB
/
block000_r-rstudio-install.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="pandoc" />
<title>Installing R and RStudio</title>
<script src="libs/jquery-1.11.0/jquery.min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link href="libs/bootstrap-2.3.2/css/united.min.css" rel="stylesheet" />
<link href="libs/bootstrap-2.3.2/css/bootstrap-responsive.min.css" rel="stylesheet" />
<script src="libs/bootstrap-2.3.2/js/bootstrap.min.js"></script>
<style type="text/css">code{white-space: pre;}</style>
<link rel="stylesheet"
href="libs/highlight/default.css"
type="text/css" />
<script src="libs/highlight/highlight.js"></script>
<style type="text/css">
pre:not([class]) {
background-color: white;
}
</style>
<script type="text/javascript">
if (window.hljs && document.readyState && document.readyState === "complete") {
window.setTimeout(function() {
hljs.initHighlighting();
}, 0);
}
</script>
<link rel="stylesheet" href="libs/local/nav.css" type="text/css" />
</head>
<body>
<style type = "text/css">
.main-container {
max-width: 940px;
margin-left: auto;
margin-right: auto;
}
</style>
<div class="container-fluid main-container">
<header>
<div class="nav">
<a class="nav-logo" href="index.html">
<img src="static/img/stat545-logo-s.png" width="70px" height="70px"/>
</a>
<ul>
<li class="home"><a href="index.html">Home</a></li>
<li class="faq"><a href="faq.html">FAQ</a></li>
<li class="syllabus"><a href="syllabus.html">Syllabus</a></li>
<li class="topics"><a href="topics.html">Topics</a></li>
<li class="people"><a href="people.html">People</a></li>
</ul>
</div>
</header>
<div id="header">
<h1 class="title">Installing R and RStudio</h1>
</div>
<div id="TOC">
<ul>
<li><a href="#r-and-rstudio">R and RStudio</a></li>
<li><a href="#testing-testing">Testing testing</a></li>
<li><a href="#add-on-packages">Add-on packages</a></li>
<li><a href="#further-resources">Further resources</a></li>
</ul>
</div>
<div id="r-and-rstudio" class="section level3">
<h3>R and RStudio</h3>
<ul>
<li><p>Install <a href="http://www.r-project.org">R, a free software environment for statistical computing and graphics</a> from <a href="http://cran.rstudio.com">CRAN</a>, the Comprehensive R Archive Network. It is <strong>highly recommended</strong> to install a precompiled binary distribution for your operating system – use the links up at the top of the CRAN page linked above!</p></li>
<li>Install RStudio’s IDE (stands for <em>integrated development environment</em>), a powerful user interface for R. Get the Open Source Edition of RStudio Desktop: <a href="http://www.rstudio.com/products/rstudio/">http://www.rstudio.com/products/rstudio/</a>
<ul>
<li>RStudio comes with a <strong>text editor</strong>, so there is no immediate need to install a separate stand-alone editor.</li>
<li>RStudio can <strong>interface with Git(Hub)</strong>. However, you must do all the Git(Hub) set up described elsewhere before you can take advantage of this.</li>
</ul></li>
</ul>
<p>If you have a pre-existing installation of R and/or RStudio, we <strong>highly recommend</strong> that you reinstall both and upgrade to the most recent version. It is very easy and RStudio, specifically, is changing rapidly and positively (written 2014-11). You may even wish to use the preview version of RStudio (we do!) <a href="http://www.rstudio.com/products/rstudio/download/preview/">available here</a>.</p>
<ul>
<li>If you upgrade R, you will need to update any packages you have installed. The command below should get you started, though you may need to specify more arguments if, e.g., you have been using a non-default library for your packages.</li>
</ul>
<pre class="r"><code> update.packages(ask = FALSE, checkBuilt = TRUE)</code></pre>
<p>Note: this will only look for updates on CRAN. So if you use a package that lives <em>only</em> on GitHub or if you want a develoment version from GitHub, you will need to update manually, e.g. via <code>devtools::install_github()</code>.</p>
</div>
<div id="testing-testing" class="section level3">
<h3>Testing testing</h3>
<ul>
<li><p>Do whatever is appropriate for your OS to launch RStudio. You should get a window similar to the screenshot you see <a href="http://www.rstudio.com/wp-content/uploads/2014/04/rstudio-workbench.png">here</a>, but yours will be more boring because you haven’t written any code or made any figures yet!</p></li>
<li><p>Put your cursor in the pane labelled Console, which is where you interact with the live R process. Create a simple object with code like <code>x <- 2 * 4</code> (followed by enter or return). Then inspect the <code>x</code> object by typing <code>x</code> followed by enter or return. You should see the value 8 print to screen. If yes, you’ve succeeded in installing R and RStudio.</p></li>
</ul>
</div>
<div id="add-on-packages" class="section level3">
<h3>Add-on packages</h3>
<p>R is an extensible system and many people share useful code they have developed as a <em>package</em> via CRAN and GitHub. To install a package from CRAN, for example the <a href="http://plyr.had.co.nz"><code>plyr</code></a> package for data aggregation, here is one way to do it in the R console (there are others).</p>
<pre class="r"><code>install.packages("plyr", dependencies = TRUE)</code></pre>
<p>By including <code>dependencies = TRUE</code>, we are being explicit and extra-careful to install any additional packages the target package, <code>plyr</code> in the example above, needs to have around.</p>
<p>You could use the above method to install the following packages, all of which we will use:</p>
<ul>
<li><code>dplyr</code>, <a href="http://plyr.had.co.nz">package webpage</a></li>
<li><code>ggplot2</code> <a href="http://docs.ggplot2.org/">package webpage</a></li>
</ul>
</div>
<div id="further-resources" class="section level3">
<h3>Further resources</h3>
<p>The above will get your basic setup ready but here are some links if you are interested in reading a bit further.</p>
<ul>
<li>How to Use RStudio
<ul>
<li><a href="https://support.rstudio.com/hc/en-us/categories/200035113-Documentation">https://support.rstudio.com/hc/en-us/categories/200035113-Documentation</a></li>
</ul></li>
<li>RStudio Troubleshooting and FAQ
<ul>
<li><a href="https://support.rstudio.com/hc/en-us/categories/200031758-Knowledge-Base">https://support.rstudio.com/hc/en-us/categories/200031758-Knowledge-Base</a></li>
</ul></li>
<li>RStudio’s leads for learning R
<ul>
<li><a href="https://support.rstudio.com/hc/en-us/articles/201141096-Getting-Started-with-R">https://support.rstudio.com/hc/en-us/articles/201141096-Getting-Started-with-R</a></li>
</ul></li>
<li>R Installation and Administration
<ul>
<li><a href="http://cran.r-project.org/doc/manuals/R-admin.html">http://cran.r-project.org/doc/manuals/R-admin.html</a></li>
</ul></li>
<li>R FAQ:
<ul>
<li><a href="http://cran.r-project.org/doc/FAQ/R-FAQ.html">http://cran.r-project.org/doc/FAQ/R-FAQ.html</a></li>
</ul></li>
<li>More about add-on packages in the R Installation and Administration Manual
<ul>
<li><a href="http://cran.r-project.org/doc/manuals/R-admin.html#Add_002don-packages">http://cran.r-project.org/doc/manuals/R-admin.html#Add_002don-packages</a></li>
</ul></li>
</ul>
</div>
<div class="footer">
This work is licensed under the <a href="http://creativecommons.org/licenses/by-nc/3.0/">CC BY-NC 3.0 Creative Commons License</a>.
</div>
</div>
<script>
// add bootstrap table styles to pandoc tables
$(document).ready(function () {
$('tr.header').parent('thead').parent('table').addClass('table table-condensed');
});
</script>
<!-- dynamically load mathjax for compatibility with self-contained -->
<script>
(function () {
var script = document.createElement("script");
script.type = "text/javascript";
script.src = "https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML";
document.getElementsByTagName("head")[0].appendChild(script);
})();
</script>
</body>
</html>