Hi there,
I was trying to know how to replace NA values in df1new$Weight.R by df1new$Weight.
Please if someone know about it, let me know.
Thank you.
Milagros
Assuming your NA values are actually "None" as in your example, you can use the ifelse function from the base package - base::ifelse
df1new$Weight.R <- ifelse(df1new$Weight.R == "None", df1new$Weight, df1new$Weight.R)
Ok so if they are truly NA, you instead use is.na as the check condition inside of ifelse. Try:
df1new$Weight.R <- ifelse(is.na(df1new$Weight.R), df1new$Weight, df1new$Weight.R)
Michael Garcia answered you well, but as a learning point, to test for equality use == I.e. double =
A single = means assignment the same as <-