In a list of df df_list
, I wish to convert the column Measures
of each df into numeric.
How can I proceed ?
this list results from a split of an initial dataframe. After splitting, most of the new df have a numeric Measures
column, but a few of them only contain NA for this column. In this case, the Measures
column is unknown.
Reproducible example :
df <- data.frame(
"Sample" = c("Air", "Air", "Air", "Air","Air", "Air", "Air", "Air"),
"Date" = c("1980", "1980", "2000", "2010", "1980", "1990", "2000", "2010"),
"Measures" = c(NA, NA, 484, 221, NA, 131, 417, 476),
"Locality" = c("Paris", "Lyon", "Paris", "Lyon", "Paris", "Lyon", "Paris", "Lyon"),
"Less.Than" = c("<","<","","<","","","<",""),
"Uncertainty" = c(NA,NA,45,NA,10,8,NA,71),
"Nuclides" = c("K-40","K-40", "K-40", "K-40", "C-14", "C-14", "C-14", "C-14"))
df_list <- split(df,list(df$Sample,df$Date), drop=TRUE)```