Conditionally convert strings to a specific numeric value
问题 I'm sure there is an easy answer for this , but I have scanned stack overflow and haven't been able to find a solution. It would seem that potentially a combination of sapply and ifelse functions would do the job (but I'm not sure). So I have a dataframe with characters, except one column which is a numeric value. ####Create dataframe which needs converting df <- data.frame(Sample_1 = rep(letters[1:3], each = 3), Sample_2 = rep("a", times = 9)) df$Number <- rep(seq(from=1,to=3,by=1)) I would