I am using the following data and have come across a roadblock. I used read.csv to import my raw data into r.
# from OHP$ohp17.value
list(NULL, NULL, "19.9 nmol/L", "0.7 nmol/L", NULL, NULL, "22.6 nmol/L", "3.7 nmol/L", "6.6", "3.7")
I am wanting to use an if statement to tell me whether values within the variable OHP$ohp17.value are "low" or "high". My attempt
OHP$ohp17.value <- as.numeric(unlist(OHP$ohp17.value))
if(OHP$ohp17.value <18) print("Low") else print("High")
issues
Error: 'list' object cannot be coerced to type 'double'
I know that this is because there are units in the variable, not just numbers.
I have tried to convert my variable into numbers using as.numeric().
read.csv, though that does not really explain how you ended with such structure, a list column with NULL values. Could you open that csv in a text editor and include few lines from the top to your question, as text?sub()handles a list with NULLs.help("as.character"): "For lists [...] it deparses the elements individually"