I'd like to write a function to read a csv, which takes 2 arguments, a file name and a column name. Then use the column name as a argument to cols()
This is a cut down version of what I'm trying to do:
Read_a_file <- function(my_file, my_col){
read_csv(file.path('../data',my_file),
col_names = c('xdate', my_col), # File with 2 columns, "xdate" and one other
col_types = cols(
xdate = col_date(format = '%d/%m/%Y'),
my_col = col_double())). # This doesn't work because I need the string specified by my_col not "my_col"
}