On 09.11.2010 16:17, Mohan L wrote:
Dear All,
I have two data like this :
$cat main.csv
name,id,memory,storage
mohan,1,100.20,1.10
ram,1,200,100
kumar,1,400,50
xxx,1,100,40
aaa,1,800,45
mount,1,200,80
main<- read.csv(file='main.csv',sep=',' , header=TRUE)
main
name id memory storage
1 mohan 1 100.2 10
2 ram 1 200.0 100
3 kumar 1 400.0 50
4 xxx 1 100.0 40
5 aaa 1 800.0 45
6 mount 1 200.0 80
$cat other.csv
name,ip,bsent,breceived
mohan,1,12.00,0.01
xxx,1,00.00,1.110
kumat,1,1.00,1.00
mmm,1,10.00,8.08
own,1,20.13,12.08
per,1,1.89,0.89
other<- read.csv(file='other.csv',sep=',' , header=TRUE)
other
name ip bsent breceived
1 mohan 1 12.00 0.01
2 xxx 1 0.00 1.11
3 kumat 1 1.00 1.00
4 mmm 1 10.00 8.08
5 own 1 20.13 12.08
6 per 1 1.89 0.89
I want to merge ip,bsent,breceived column to "main" , If the name in
the the "main" data frame is there in the "other" data frame . some
thinng like this:
name id memory storage ip bsent breceived
mohan 1 100 20 1 12.00 0.01
ram 1 200 100 0 00.00 0.00
kumar 1 400 50 1 1.00 1.00
xxx 1 100 40 1 00.00 1.110
aaa 1 800 45 0 00.00 00.00
mount 1 200 80 0 00.00 00.00
If in case the name in the "main" data frame does not there in the
"other" data frame, simple I want to add zero to ip,bsent,breceived
value.
I hope this can be done with R. Any help will appricated.
See ?merge including its argument all=TRUE.
Uwe Ligges
Thanks for you time.
Thanks& Rg
Mohan L
______________________________________________
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.
______________________________________________
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.