@@ -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,
419385and a ` digits ` argument. The ` = ` sign indicates that a default (in this
420386case 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
438404Or, R accepts what we call "positional arguments", if you pass a
439405function 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
494424We will discuss more on where to look for the libraries and packages
495425that contain functions you want to use. For now, be aware that two
0 commit comments