Hello,

Try the following.

x1 <- read.table(text = "
1 10
3  5
0  0
")

x2 <- read.table(text = "
2 10
0  0
3  5
")


x3 <- merge(x1, x2, by = "V1", all = TRUE)
res <- data.frame(x3[1], sum = rowSums(x3[-1], na.rm = TRUE))
res <- res[-(res$sum == 0), ]
res


Hope this helps,

Rui Barradas

Em 23-08-2013 13:59, Anindya Sankar Dey escreveu:
HI All,

Suppose I have two table like below

Table 1:

1 10
3  5
0  0

Table 2:

2 10
0  0
3  5


I need to create a new table like below

Table 3:

1 10
2 10
3 10

The row may interchange in table 3, but is there any way to do this instead
of writing lot of if-else and loops?

Thanks in advance.


______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to