Skip to content

Commit fa3d9cd

Browse files
committed
fix #20
1 parent 11c5ed9 commit fa3d9cd

2 files changed

Lines changed: 87 additions & 75 deletions

File tree

docs/00-introduction.md

Lines changed: 5 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -381,40 +381,6 @@ number with a decimal:
381381
[1] 3
382382
```
383383

384-
385-
## Getting help with function arguments
386-
387-
What if you wanted to round to one significant digit? `round()` can do
388-
this, but you may first need to read the help to find out how. To see
389-
the help (in R sometimes also called a "vignette") enter a `?` in front
390-
of the function name:
391-
392-
!!! r-project "r"
393-
394-
```r
395-
?round()
396-
```
397-
398-
The "Help" tab will show you information (often, too much information).
399-
You will slowly learn how to read and make sense of help files. Checking
400-
the "Usage" or "Examples" headings is often a good place to look first.
401-
If you look under "Arguments," we also see what arguments we can pass to
402-
this function to modify its behavior. You can also see a function's
403-
argument using the `args()` function:
404-
405-
!!! r-project "r"
406-
407-
```r
408-
args(round)
409-
```
410-
411-
!!! success "Output"
412-
413-
```
414-
function (x, digits = 0)
415-
NULL
416-
```
417-
418384
`round()` takes two arguments, `x`, which is the number to be rounded,
419385
and a `digits` argument. The `=` sign indicates that a default (in this
420386
case 0) is already set. Since `x` is not set, `round()` requires we
@@ -437,7 +403,7 @@ the digits argument when we call the function:
437403

438404
Or, R accepts what we call "positional arguments", if you pass a
439405
function arguments separated by commas, R assumes that they are in the
440-
order you saw when we used `args()`. In the case below that means that
406+
order specified in the help manual for each function (see [Getting help with R](08-r-help.md)). In the case below that means that
441407
`x` is 3.14159 and digits is 2.
442408

443409
!!! r-project "r"
@@ -446,50 +412,14 @@ order you saw when we used `args()`. In the case below that means that
446412
round(3.14159, 2)
447413
```
448414

449-
Finally, what if you are using `?` to get help for a function in a
450-
package not installed on your system, such as when you are running a
451-
script which has dependencies.
452-
453-
!!! r-project "r"
454-
455-
```r
456-
?geom_point()
457-
```
458-
459-
The above will return an error:
460-
461-
!!! failure "Error"
415+
!!! success "Output"
462416

463-
```
464-
Error in .helpForCall(topicExpr, parent.frame()) :
465-
no methods for ‘geom_point’ and no documentation for it as a function
466-
```
417+
```
418+
[1] 3.14
419+
```
467420

468-
Use two question marks (i.e. `??geom_point()`) and R will return results
469-
from a search of the documentation for packages you have installed on
470-
your computer in the "Help" tab. Finally, if you think there should be a
471-
function, for example a statistical test, but you aren't sure what it is
472-
called in R, or what functions may be available, use the `help.search()`
473-
function.
474421

475-
!!! question "Exercise: Searching for R functions"
476-
477-
Use `help.search()` to find R functions for the following statistical
478-
functions. Remember to put your search query in quotes inside the
479-
function's parentheses.
480-
481-
* Chi-Squared test
482-
* Student t-test
483-
* Mixed linear model
484-
485-
??? success Solution
486-
487-
While your search results may return several tests, we list a few
488-
you might find:
489422

490-
- Chi-Squared test: `stats::Chisquare`
491-
- Student t-test: `stats::t.test`
492-
- Mixed linear model: `stats::lm.glm`
493423

494424
We will discuss more on where to look for the libraries and packages
495425
that contain functions you want to use. For now, be aware that two

docs/08-r-help.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,88 @@ some tips to make this process as helpful and efficient as possible.
2929

3030
> "Never memorize something that you can look up" — A. Einstein
3131
32+
33+
## Getting help with function arguments
34+
35+
What if you wanted to round to one significant digit? `round()` can do
36+
this, but you may first need to read the help to find out how. To see
37+
the help (in R sometimes also called a "vignette") enter a `?` in front
38+
of the function name:
39+
40+
!!! r-project "r"
41+
42+
```r
43+
?round()
44+
```
45+
46+
The "Help" tab will show you information (often, too much information).
47+
You will slowly learn how to read and make sense of help files. Checking
48+
the "Usage" or "Examples" headings is often a good place to look first.
49+
If you look under "Arguments," we also see what arguments we can pass to
50+
this function to modify its behavior. You can also see a function's
51+
argument using the `args()` function:
52+
53+
!!! r-project "r"
54+
55+
```r
56+
args(round)
57+
```
58+
59+
!!! success "Output"
60+
61+
```
62+
function (x, digits = 0)
63+
NULL
64+
```
65+
66+
67+
68+
Finally, what if you are using `?` to get help for a function in a
69+
package not installed on your system, such as when you are running a
70+
script which has dependencies.
71+
72+
!!! r-project "r"
73+
74+
```r
75+
?geom_point()
76+
```
77+
78+
The above will return an error:
79+
80+
!!! failure "Error"
81+
82+
```
83+
Error in .helpForCall(topicExpr, parent.frame()) :
84+
no methods for ‘geom_point’ and no documentation for it as a function
85+
```
86+
87+
Use two question marks (i.e. `??geom_point()`) and R will return results
88+
from a search of the documentation for packages you have installed on
89+
your computer in the "Help" tab. Finally, if you think there should be a
90+
function, for example a statistical test, but you aren't sure what it is
91+
called in R, or what functions may be available, use the `help.search()`
92+
function.
93+
94+
!!! question "Exercise: Searching for R functions"
95+
96+
Use `help.search()` to find R functions for the following statistical
97+
functions. Remember to put your search query in quotes inside the
98+
function's parentheses.
99+
100+
* Chi-Squared test
101+
* Student t-test
102+
* Mixed linear model
103+
104+
??? success Solution
105+
106+
While your search results may return several tests, we list a few
107+
you might find:
108+
109+
- Chi-Squared test: `stats::Chisquare`
110+
- Student t-test: `stats::t.test`
111+
- Mixed linear model: `stats::lm.glm`
112+
113+
32114
## Finding help on Stackoverflow and Biostars
33115

34116
Two popular websites will be of great help with many R problems. For

0 commit comments

Comments
 (0)