|
|
|
@ -12,22 +12,33 @@
|
|
|
|
|
#' highlight: zenburn
|
|
|
|
|
#' ---
|
|
|
|
|
|
|
|
|
|
#' remove objects
|
|
|
|
|
#' removing objects
|
|
|
|
|
#'
|
|
|
|
|
objects()
|
|
|
|
|
|
|
|
|
|
rm(list = ls())
|
|
|
|
|
|
|
|
|
|
#' Libraries
|
|
|
|
|
|
|
|
|
|
#' ## Common ways of getting help when working with R
|
|
|
|
|
#'
|
|
|
|
|
#' Within R use the "?" question symbol before any command and run
|
|
|
|
|
|
|
|
|
|
#' ## Find the formal arguments in a function
|
|
|
|
|
#'
|
|
|
|
|
?dput
|
|
|
|
|
formalArgs(help)
|
|
|
|
|
|
|
|
|
|
formalArgs(table)
|
|
|
|
|
|
|
|
|
|
#' Use "help", "help.search" or "apropos" when need search for some terms
|
|
|
|
|
#' ### Use "help", "help.search" or "find" when need to search for some terms
|
|
|
|
|
#'
|
|
|
|
|
#' Use "help.start" to view all R documentation
|
|
|
|
|
help.start()
|
|
|
|
|
|
|
|
|
|
#' Within R use the "?" question symbol before any command and run the code
|
|
|
|
|
#' to get help on that function.
|
|
|
|
|
#'
|
|
|
|
|
#' Getting help with "dput()" and "Compare" functions:
|
|
|
|
|
#'
|
|
|
|
|
?dput
|
|
|
|
|
|
|
|
|
|
?Compare
|
|
|
|
|
|
|
|
|
|
#' Ask about control-flow constructs in R
|
|
|
|
|
help("if")
|
|
|
|
@ -38,22 +49,34 @@ help("[[")
|
|
|
|
|
#' Help on "Quotes"
|
|
|
|
|
help(Quotes)
|
|
|
|
|
|
|
|
|
|
#' Use "help.search" to find functions matching any word
|
|
|
|
|
help.search("download file")
|
|
|
|
|
|
|
|
|
|
#' Find the formal arguments in a function
|
|
|
|
|
formalArgs(help)
|
|
|
|
|
|
|
|
|
|
formalArgs(table)
|
|
|
|
|
|
|
|
|
|
#' "find" can be used to know which package contains a function
|
|
|
|
|
#' ### "find" can be used to know which package contains a function
|
|
|
|
|
|
|
|
|
|
find("table")
|
|
|
|
|
|
|
|
|
|
find("count")#' this will return nothing, because the package should be loaded
|
|
|
|
|
#' This will return nothing, because the package should be loaded in the session
|
|
|
|
|
#' in order to "find" the function
|
|
|
|
|
|
|
|
|
|
find("count")
|
|
|
|
|
|
|
|
|
|
#' Then, after loading the package that contains the function it should run
|
|
|
|
|
#' without any problem
|
|
|
|
|
library(dplyr)
|
|
|
|
|
|
|
|
|
|
#' "apropos" give the name of objects containing the characters passed to the function
|
|
|
|
|
find("count")
|
|
|
|
|
|
|
|
|
|
#' Unload a package from the environment
|
|
|
|
|
#'
|
|
|
|
|
detach("package:dplyr", unload = TRUE)
|
|
|
|
|
|
|
|
|
|
#' ### "apropos" gives the name of objects containing the characters passed to
|
|
|
|
|
#' the function.
|
|
|
|
|
#'
|
|
|
|
|
#' Remember that wihin R (almost) everything that exist is an object and everything
|
|
|
|
|
#' that happens is a function. Thus apropos will find any object (including
|
|
|
|
|
#' functions) within the session matching the word.
|
|
|
|
|
|
|
|
|
|
count_testing <- c(1,2)
|
|
|
|
|
|
|
|
|
@ -61,35 +84,50 @@ apropos("count")
|
|
|
|
|
|
|
|
|
|
#' ## Examples and demostration of functions
|
|
|
|
|
#'
|
|
|
|
|
#' ### Examples included in packages documentation
|
|
|
|
|
#'
|
|
|
|
|
#' The function to show examples of any functions is called "example":
|
|
|
|
|
example(glm)
|
|
|
|
|
|
|
|
|
|
library(lubridate)
|
|
|
|
|
example(ymd)
|
|
|
|
|
#' To extract examples of any function, the package containing the function should
|
|
|
|
|
#' be loaded in the session:
|
|
|
|
|
#'
|
|
|
|
|
library(data.table)
|
|
|
|
|
|
|
|
|
|
example(Compare)
|
|
|
|
|
#' Check some examples on how to use the function ".N" in the "data.table" package
|
|
|
|
|
example(.N)
|
|
|
|
|
|
|
|
|
|
library(dplyr)
|
|
|
|
|
example(case_when)
|
|
|
|
|
|
|
|
|
|
#' ### Using "demo()"
|
|
|
|
|
demo(graphics)
|
|
|
|
|
|
|
|
|
|
#' Use "help.start" to view all R documentation
|
|
|
|
|
help.start()
|
|
|
|
|
|
|
|
|
|
#' ## Searching in packages
|
|
|
|
|
#'
|
|
|
|
|
#' Obtain help in packages
|
|
|
|
|
|
|
|
|
|
library(help = data.table)
|
|
|
|
|
|
|
|
|
|
#' ## Finding objects within a package and checking documentation
|
|
|
|
|
|
|
|
|
|
#' Finding objects within a package
|
|
|
|
|
|
|
|
|
|
#' ### Finding objects
|
|
|
|
|
#'
|
|
|
|
|
#' Here we use "grep" to look for objects within the package "data.table".
|
|
|
|
|
#' The function "search" is applied to look for R objects, thus the function
|
|
|
|
|
#' will return the names of every function within the package
|
|
|
|
|
#'
|
|
|
|
|
library(data.table)
|
|
|
|
|
|
|
|
|
|
objects(grep("data.table", search()))
|
|
|
|
|
|
|
|
|
|
#' List vignettes in a package
|
|
|
|
|
#' Take a look to the objects in the base package:
|
|
|
|
|
#'
|
|
|
|
|
obase <- objects(grep("base", search()))
|
|
|
|
|
|
|
|
|
|
head(obase, n=10)
|
|
|
|
|
|
|
|
|
|
#' ### List vignettes in a package
|
|
|
|
|
|
|
|
|
|
vignette(package = "data.table")
|
|
|
|
|
|
|
|
|
@ -97,17 +135,8 @@ browseVignettes("data.table")
|
|
|
|
|
|
|
|
|
|
vignette("datatable-faq")
|
|
|
|
|
|
|
|
|
|
#' Edit dataframe using R data editor
|
|
|
|
|
#'
|
|
|
|
|
|
|
|
|
|
carros <- cars
|
|
|
|
|
|
|
|
|
|
fix(carros)
|
|
|
|
|
|
|
|
|
|
carros
|
|
|
|
|
#' End
|
|
|
|
|
|
|
|
|
|
#' Unload a package from the environment
|
|
|
|
|
#' You can export this document as html using "rmarkdown":
|
|
|
|
|
#'
|
|
|
|
|
#' detach("package:data.table", unload = TRUE)
|
|
|
|
|
|
|
|
|
|
#' End
|
|
|
|
|
#' rmarkdown::render("./help_r.R")
|
|
|
|
|