# NOT RUN {
df <- data.frame(
x = as.character(runif(10)),
y = as.character(sample(10)),
stringsAsFactors = FALSE
)
str(df)
str(type_convert(df))
df <- data.frame(x = c("NA", "10"), stringsAsFactors = FALSE)
str(type_convert(df))
# Type convert can be used to infer types from an entire dataset
type_convert(
read_csv(readr_example("mtcars.csv"),
col_types = cols(.default = col_character())))
# }
Run the code above in your browser using DataLab