Read in the files pointed out by Richie Cotton, but be sure to add additional arguments to the application call. For example, add header=TRUE .
file.names <- c("file X.txt", "file Y.txt", "file Z.txt") file.list <- lapply(file.names, read.table, header=TRUE)
Then you might need merge_recurse from the reshape package :
require(reshape) mynewframe <- merge_recurse(file.list,all.x=TRUE,all.y=TRUE,by="ProbeID")
This will work for any given number of data blocks, if not a billion of them. See the ?merge help page for more information on the arguments used.
CORRECTION: in merge_recurse you need to use all.x and all.y , as shown in the above correction. You cannot just use the shortcut all or you will get errors.
Little demo:
X2 <- data.frame(ProbeID=(2:4),Z2=4:6) X1 <- data.frame(ProbeID=1:3,Z1=1:3) X3 <- data.frame(ProbeID=1:3,Z3=7:9) file.list <- list(X1,X2,X3) mynewframe <- merge_recurse(file.list,all.x=TRUE,all.y=TRUE,by="ProbeID") > mynewframe ProbeID Z1 Z2 Z3 1 1 1 NA 7 2 2 2 4 8 3 3 3 5 9 4 4 NA 6 NA
source share