If my dataset has columns like this
ID Group Col_item_01 Col_item_02 Col_item 03
1 Blue 11.23 10.12 4.3
2 Green 10.21 18.24 5.9
4 Purple 4.23 7.64 15.97
How can I convert all the columns starting with , Col_item_...
to type numeric from character ? I know I can do this individually , df1$Col_item_01 <- as.numeric(as.character(df1$Col_item_01)
but I am interested in an efficient approach using grep or grepl or string functions to extract just these columns starting with Col_item_...
and changing them to numeric. Any suggestion is much appreciated. Thanks.