Displaying 1 result from an estimated 1 matches for "changinga".
Did you mean:
changing
2012 Jul 11
1
sapply question
Why does this sapply code change df3 but not df1?
Thanks
df1 <- read.table(text="
cola colb colc cold cole
1 NA 5 9 NA 17
2 NA 6 NA 14 NA
3 3 NA 11 15 19
4 4 8 12 NA 20
", header=TRUE)
df2 <-df1*2
df1
df2
df3 <-sapply(names(df1),function(x) {df1[[x]]<- df2[[x]]})
df1
df3
[[alternative HTML version deleted]]