tidy datasets: ‘col_types’ to read a variable in the format you want

I have been having issues in my datasets as one variable is both numeric and text. Rather than arguing with excel, tidy offers a quick and painless solution: col_types:

dt <- read_csv("_yourdataset_.csv", col_types = cols(tricky_variable = "c"))[/sourcecode language="r"]

with date, time, numeric, integers, doubles, guess (let tidy guess the type) and skip as some of the available options.

Author: acarioli

is a researcher at the Geography and Environment department of the University of Southampton, WorldPop project team. She is also affiliated researcher at CED, UAB and Dondena Centre. Her interests include spatial econometrics and modeling, bayesian methods, machine learning processes, forecasting, micro-data simulation, and data visualization. Demo-traveler, Mac enthusiast, R zealot and Rladies member.