[R] merge question

Dr Eberhard W Lisse el at lisse.NA
Mon Jun 30 00:32:50 CEST 2014


Thanks,

I then set NA to 0, and can do the sutraction,

great.

el


On 2014-06-29, 22:32 , Michael Peng wrote:
> you can get a new data frame by
> merge(qpiso, qplegit, all.x = TRUE, all.y = TRUE, by = "iso" )
> Take the subtraction on the new data frame.
> 
> 
> 
> 
> 2014-06-29 11:24 GMT-05:00 Dr Eberhard Lisse <nospam at lisse.na
> <mailto:nospam at lisse.na>>:
> 
>     I have two data frames like so
> 
>     > qpiso
>         iso requests
>     1    A1       20
>     2    A2      199
>     3    AD        5
>     4    AE      176
>     ...
>     189  ZW       82
> 
>     > qplegit
>         iso requests
>     1    A2       36
>     2    AE        4
>     3    AM        2
>     4    AO        1
>     ...
>     100  ZW        3
> 
> 
>     I want to create another dataframe qpspam which contains all pairs
>     from pqiso with the values for requests of qplegit being subtracted
>     from those which exist in qpiso,
> 
>     ie
>         iso requests
>     1    A1       20
>     2    A2      163
>     3    AD        5
>     4    AE      172
>     ...
>     189  ZW       79
> 
>     but don't know how to do this, and google isn't too helpful.
> 
>     As usual, a solution is preferred, but a pointer to where I can
>     read this up is equally appreciated :-)-O
> 
>     el
> 
>     ______________________________________________
>     R-help at r-project.org <mailto:R-help at 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.
> 
> 



More information about the R-help mailing list