You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Everyone is doing a great job so far with their data cleaning scripts!
I've noticed that often, after reading in data, lots of time is being spent "fixing" the resulting table:
correcting the types of columns (e.g. turning a row of "characters" into "numeric")
fixing NA values (e.g. if your data has missing values recorded as something R thinks is a word, not a missing value)
A lot of these issues can be fixed most easily by mastering the function that reads in the data. There are three good ways to read in data that will cover most common cases in this class. Save yourself lots of time and read their help files!
?read.delim (same as ?read.csv)
?readxl::read_excel
?readr::read_csv
For example:
column types
Let's say you have one character column (an id variable) and one numeric column (e.g. mass):
Hello @BIOL548O/all ,
start your week with some free R advice! 💻 💸
Everyone is doing a great job so far with their data cleaning scripts!
I've noticed that often, after reading in data, lots of time is being spent "fixing" the resulting table:
NA
values (e.g. if your data has missing values recorded as something R thinks is a word, not a missing value)A lot of these issues can be fixed most easily by mastering the function that reads in the data. There are three good ways to read in data that will cover most common cases in this class. Save yourself lots of time and read their help files!
?read.delim
(same as?read.csv
)?readxl::read_excel
?readr::read_csv
For example:
column types
Let's say you have one character column (an id variable) and one numeric column (e.g. mass):
read.delim("data-raw/mydata.csv", colClasses = c("character", "numeric"))
readxl::read_excel("data-raw/mydata.csv", col_types = c("text", "numeric"))
readr
. seevignette("column-types")
:or, equivalently
specify your "missing" code:
All three functions also let you specify what your code for "missing" is. Let's say that in your data the missing value is coded "
N/A
":The text was updated successfully, but these errors were encountered: