-
Notifications
You must be signed in to change notification settings - Fork 15
Data Types
Cghlewis edited this page May 9, 2024
·
57 revisions
Some of the most common variable classes you will encounter include:
- Character
- Numeric (Double)
- Integer
- Factor
- Date
- POSIXt
- Logical
And common data types include:
- Character
- Numeric (Double)
- Integer
- Logical
- Convert variable class to numeric
- Convert variable class to character
- Convert variable class to factor
- Convert variable class to date
Main functions used in examples
Package | Functions |
---|---|
base | class(); typeof(); as.factor(); as.numeric(); as.character() |
utils | str() |
lubridate | as_date(); as_datetime(); mdy(); parse_date_time() |
forcats | as_factor(); fct_relevel() |
janitor | excel_numeric_to_date() |
dplyr | glimpse() |
Other functions used in examples
Package | Functions |
---|---|
base | attributes(); levels() |
dplyr | mutate(); across(); all_of(); pull() |
purrr | map() |
tidyselect | everything(); where() |
Resources
- https://tibble.tidyverse.org/articles/types.html
- https://swcarpentry.github.io/r-novice-inflammation/13-supp-data-structures/
- https://resbaz.github.io/2014-r-materials/lessons/01-intro_r/data-structures.html
- https://mgimond.github.io/ES218/Week02a.html
- https://stackoverflow.com/questions/8855589/a-comprehensive-survey-of-the-types-of-things-in-r-mode-and-class-and-type
- https://evoldyn.gitlab.io/evomics-2018/ref-sheets/R_lubridate.pdf
- https://www.youtube.com/watch?v=_rPde-SPDVE
- https://www.youtube.com/watch?v=OEweA4yVAuI
- https://www.r-bloggers.com/2013/08/date-formats-in-r/
- https://rdrr.io/cran/janitor/man/excel_numeric_to_date.html
- https://epirhandbook.com/en/working-with-dates.html