I am trying to read in a CSV file - and am attempting to force the columns to be of a certain type. But the very last column gives me an error: "Error in is.list(col_types) : Unknown shortcut: g"
Any advice, please? Thank you!
library(readr)
# Create data frame & write it out:
temp <- data.frame(a = 1:1001,
mystring_b = c(rep(NA, 1000), "1"),
mystring_c = c(rep(NA, 1000), "2"))
write.csv(temp, "temp.csv", row.names = F)
# Grab its names:
temp_labels <- names(read_csv("temp.csv", n_max = 0))
# Specify data type - for each column:
labels_type <- ifelse(grepl("mystring", temp_labels), "numeric", "guess")
# Reading in while forcing column types:
temp <- read_csv("temp.csv", col_types = labels_type)
# Error in is.list(col_types) : Unknown shortcut: g