R Merge Function


merge(arg1,arg2 ...) {...} function merges two data frames by common columns.

Let's create two data frames and merge them:

>exp <- data.frame(samples=c("a","b","c"),values=c(2.43,5.32,-1.23))
>backedup <- data.frame(patients=c("a","b","c"),marked=c("yes","yes","no"))
>x <- merge(exp,backedup,by.x="samples",by.y="patients")
>x

samples values marked
1 a 2.43 yes
2 b 5.32 yes
3 c -1.23 no

endmemo.com © 2024  | Terms of Use | Privacy | Home