I\'m working with a dataframe, one column of which contains values that are mostly numeric but may contain non-numeric entries. I would like to split this column into multiple
This does not use any packages:
transform(df, x1 = ifelse(grepl(" ", x), sub(" .*", "", x), NA), x2 = sub(".* ", "", paste(x)))
giving:
ID x x1 x2 1 1 < 0.1 < 0.1 2 2 100 100 3 3 A 2.5 A 2.5 4 4 200 200