sorry for the simple question but I have a data.frame (df1) of for example 200 rows and 69 columns with some NA and some values equal to 35 and another "data.frame" (df2) of 200 rows and 1 column without NA. I would like to sum the df2 to every column of df1 leaving NA when it is NA and 35 when the entry is 35 in df1. For example:
df1 Col1 Col2 Col3 5 35 21 NA 4 12 35 1 NA .... .... ...... df1 Estimates 5 1 9 ...
Desired output:
df1 Col1 Col2 Col3 10 35 26 NA 5 13 35 10 NA .... .... ......
Can anyone help me please?
Thanks in advance
df1[] <- lapply(df1, `+`, df2$Estimates)or use matrices:data.frame(as.matrix(df1) + df2$Estimates)- alistairecol2you changed 35 to 40 (35+5)... - Sotos