forked from resbaz/r-novice-gapminder
-
Notifications
You must be signed in to change notification settings - Fork 2
/
03-seeking-help.html
92 lines (92 loc) · 6.33 KB
/
03-seeking-help.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="generator" content="pandoc">
<title>Software Carpentry: R for reproducible scientific analysis</title>
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" type="text/css" href="css/bootstrap/bootstrap.css" />
<link rel="stylesheet" type="text/css" href="css/bootstrap/bootstrap-responsive.css" />
<link rel="stylesheet" type="text/css" href="css/swc.css" />
<link rel="stylesheet" type="text/css" href="css/swc-workshop-and-lesson.css" />
<link rel="stylesheet" type="text/css" href="css/lesson.css" />
<link rel="alternate" type="application/rss+xml" title="Software Carpentry Blog" href="http://software-carpentry.org/feed.xml"/>
<meta charset="UTF-8" />
<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body class="lesson">
<div class="container container-full-width card">
<div class="banner">
<a href="http://software-carpentry.org" title="Software Carpentry">
<img alt="Software Carpentry banner" src="img/software-carpentry-banner.png" />
</a>
</div>
<div class="row-fluid">
<div class="span10 offset1">
<h1 class="title">R for reproducible scientific analysis</h1>
<h2 class="subtitle">Seeking help</h2>
<div id="learning-objectives" class="objectives">
<h3>Learning Objectives</h3>
<ul>
<li>To be able read R helpfiles for functions and special operators.</li>
<li>To be able to use CRAN taskviews to identify packages to solve a problem.</li>
<li>To be able to seek help from your peers</li>
</ul>
</div>
<h3 id="reading-help-files">Reading Help files</h3>
<p>Previously, I showed you the <code>read.table</code> function for reading in files. But how did I know what arguments to use?</p>
<p>R, and every package, provide help files for functions. To search for help on a function from a specific function that is in a package loaded into your namespace (your interactive R session):</p>
<pre class="sourceCode r"><code class="sourceCode r">?function_name
<span class="kw">help</span>(function_name)</code></pre>
<p>This will load up a help page in RStudio (or as plain text in R by itself).</p>
<p>Each help page is broken down into sections:</p>
<ul>
<li>Description: An extended description of what the function does.</li>
<li>Usage: The arguments of the function and their default values.</li>
<li>Arguments: An explanation of the data each argument is expecting.</li>
<li>Details: Any important details to be aware of.</li>
<li>Value: The data the function returns.</li>
<li>See Also: Any related functions you might find useful.</li>
<li>Examples: Some examples for how to use the function.</li>
</ul>
<p>Different functions might have different sections, but these are the main ones you should be aware of.</p>
<div id="tip-reading-help-files" class="callout">
<h4>Tip: Reading help files</h4>
<p>One of the most daunting aspects of R is the large number of functions available. It would be prohibitive, if not impossible to remember the correct usage for every function you use. Luckily, the help files mean you don't have to!</p>
</div>
<h3 id="special-operators">Special Operators</h3>
<p>To seek help on special operators, use quotes:</p>
<pre class="sourceCode r"><code class="sourceCode r">?<span class="st">"+"</span></code></pre>
<h3 id="getting-help-on-packages">Getting help on packages</h3>
<p>Many packages come with "vignettes": tutorials and extended example documentation. Without any arguments, <code>vignette()</code> will list all vignettes for all installed packages; <code>vignette(package="package-name")</code> will list all available vignettes for <code>package-name</code>, and <code>vignette("vignette-name")</code> will open the specified vignette.</p>
<p>If a package doesn't have any vignettes, you can usually find help by typing <code>help("package-name")</code>.</p>
<h3 id="when-you-kind-of-remember-the-function">When you kind of remember the function</h3>
<p>If you're not sure what package a function is in, or how it's specifically spelled you can do a fuzzy search:</p>
<pre class="sourceCode r"><code class="sourceCode r">??function_name</code></pre>
<h3 id="when-you-have-no-idea-where-to-begin">When you have no idea where to begin</h3>
<p>If you don't know what function or package you need to use <a href="http://cran.at.r-project.org/web/views">CRAN Task Views</a> is a specially maintained list of packages grouped into fields. This can be a good starting point.</p>
<h3 id="when-your-code-doesnt-work-seeking-help-from-your-peers">When your code doesn't work: seeking help from your peers</h3>
<p>If you're having trouble using a function, 9 times out of 10, the answers you are seeking have already been answered on <a href="http://stackoverflow.com/">Stack Overflow</a>. You can search using the <code>[r]</code> tag.</p>
<p>If you can't find the answer, there are a few useful functions to help you ask a question from your peers:</p>
<pre class="sourceCode r"><code class="sourceCode r">?dput</code></pre>
<p>Will dump the data you're working with into a format so that it can be copy and pasted by anyone else into their R session.</p>
<pre class="sourceCode r"><code class="sourceCode r"><span class="kw">sessionInfo</span>()</code></pre>
<p>Will print out your current version of R, as well as any packages you have loaded. This can be useful for others to help reproduce and debug your issue.</p>
</div>
</div>
<div class="footer">
<a class="label swc-blue-bg" href="http://software-carpentry.org">Software Carpentry</a>
<a class="label swc-blue-bg" href="https://github.com/swcarpentry/lesson-template">Source</a>
<a class="label swc-blue-bg" href="mailto:[email protected]">Contact</a>
<a class="label swc-blue-bg" href="LICENSE.html">License</a>
</div>
</div>
<!-- Javascript placed at the end of the document so the pages load faster -->
<script src="http://software-carpentry.org/v5/js/jquery-1.9.1.min.js"></script>
<script src="http://software-carpentry.org/v5/js/bootstrap/bootstrap.min.js"></script>
</body>
</html>