I have a table in Excel with numeric, date, and character type columns. I use the read_excel()
function from readxl library to load data into R. For most of the columns, read_excel
by default does a good job in recognizing the column type.
Problem:
As the number of columns in the table can increase or decrease, I don't want to define col_types
in read_excel
to load data.
Two Excel numeric columns are cost and revenue with '$' in front of the value such as $200.0541. The dollar sign '$' seems to cause the function to mistakenly identify the cost and revenue column as POSIXct
type.
Since new numeric columns might be added later with '$', is it possible to change the column types after loading the data (without using df$cost <- as.numeric(df$cost)
for each column) through a loop?
Edit: link to sample - https://ethercalc.org/ogiqi9s51o45