0

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)```
Sylvain
  • 133
  • 1
  • 10
  • 1
    Please, provide a minimal reproducible example: [How to make a great R reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). – PaulS Jun 30 '22 at 09:24
  • Your `Measures` _are_ numeric, your question is unclear to me. – jay.sf Jun 30 '22 at 09:56

0 Answers0