I have a data frame with measurements.
One column show the measurements in mm, and the other in units (which is a relative scale varying with zoom-level on the stereo microscope I was using). I want to go through every row of my data frame, and for each "length_mm" that equals NA, I want to use the value in "length_units" to calculate "length_mm".
So far I've tried this code:
convert_to_mm <- function(x) {
x["length_mm"==NA] <- x["length_units"]/10
x["length_mm"]
}
apply(zooplankton[,c("length_mm","length_units")], 1, convert_to_mm)
Sometimes I also have instances where both "length_mm" and "length_units" equals NA. In these cases I want to just skip the row.