Replacing na.omit() with !is.na() appears to improve performance with time.
rm(list=ls())
test1 <- (rbind(c(0.1,0.2),0.3,0.1))
rownames(test1)=c('y1','y2','y3')
colnames(test1) = c('x1','x2');
test2 <- (rbind(c(0.8,0.9,0.5),c(0.5,0.1,0.6)))
rownames(test2) = c('y2','y5')
colnames(te
I reworked Frank Schwidom's solution to make it shorter than its original
version.
test1 <- (rbind(c(0.1,0.2),0.3,0.1))
rownames(test1)=c('y1','y2','y3')
colnames(test1) = c('x1','x2');
test2 <- (rbind(c(0.8,0.9,0.5),c(0.5,0.1,0.6)))
rownames(test2) = c('y2','y5')
colnames(test2) = c(
Another approach:
test1 <- data.frame(rbind(c(0.1,0.2),0.3,0.1))
rownames(test1) = c('y1','y2','y3')
colnames(test1) = c('x1','x2');
test2 <- data.frame(rbind(c(0.8,0.9,0.5),c(0.5,0.1,0.6)))
rownames(test2) = c('y2','y5')
colnames(test2) = c('x1','x3','x2')
> test1
x1 x2
y1 0.1 0.2
y2 0.3 0.
test1 <- (rbind(c(0.1,0.2),0.3,0.1))
rownames(test1)=c('y1','y2','y3')
colnames(test1) = c('x1','x2');
test2 <- (rbind(c(0.8,0.9,0.5),c(0.5,0.1,0.6)))
rownames(test2) = c('y2','y5')
colnames(test2) = c('x1','x3','x2')
lTest12 <- list( test1, test2)
namesRow <- unique( unlist( lapply( lTest12, ro
Dear R users,
I am trying to merge tables based on both their row names and column names.
My ultimate goal is to build a distribution table of values for each
combination of row and column names.
I have more test tables, more x's and y's than in the toy example below.
Thanks in advance for your
5 matches
Mail list logo