1 Important Notes
1.2 Help
2 Don’t forget the help commands. Every official package has documented functions.
2.1 When you know the name of the function, use: ?function
?mean2.2 Performing a search on all package installed on your system.
??mean2.3 Search for information in function help pages and vignettes for all CRAN packages.
RSiteSearch("mean")1.3 Variable types
The most common types of variables to be defined in R
1.3.1 Numeric
vet <- c(-1,0,1)
vet
## [1] -1 0 1class(vet) # The function `class` return the class of the vector
## [1] "numeric"vet <- c(-1.5, 0.593, 1)
class(vet)
## [1] "numeric"1.3.3 Character
- Defined as text and has no numeric value
vet <- as.character(c(-1,0,1))
vet
## [1] "-1" "0" "1"class(vet)
## [1] "character"- Provincial acronyms of South Africa
texto <- c("EC","FS","GT","NL","LP","MP","NC","NW","WC")
texto
## [1] "EC" "FS" "GT" "NL" "LP" "MP" "NC" "NW" "WC"class(texto)
## [1] "character"1.3.4 Factor
- Both numeric and character variables can be made into factors, but a factor’s levels will always be character values
vet <- factor(c(-1.5, 0.593, 1))
vet
## [1] -1.5 0.593 1
## Levels: -1.5 0.593 1class(vet)
## [1] "factor"texto <- factor(c("EC","FS","GT","NL","LP","MP","NC","NW","WC"))
texto
## [1] EC FS GT NL LP MP NC NW WC
## Levels: EC FS GT LP MP NC NL NW WCclass(texto)
## [1] "factor"