[R] How to merge two tables
Jeff Newmiller
jdnewmil at dcn.davis.ca.us
Mon Feb 22 20:45:31 CET 2016
I can see no coherent way to merge these two tables. They do not appear to
have consistent definitions for uniqueness of individual rows. Nor do they
have consistent column definitions. If you think they do, you will need to
be more clear in your question about how you want them to be merged.
As for expanding, you might try using something like
ageExpand <- age[ rep( seq_along( age[[1]] ), times=age[,"count"] ), 1:3 ]
On Tue, 23 Feb 2016, Xiyan Lon wrote:
> Dear all,
> I am currently studying categorical data analysis, if I have two tables:
>
> R> cross
> sex cross death count
> 1 FEMALE WEF YES 26
> 2 MALE WEF YES 14
> 3 FEMALE OGG YES 32
> 4 MALE OGG YES 43
> 5 FEMALE TGA YES 8
> 6 MALE TGA YES 10
> 7 FEMALE WEF NO 6
> 8 MALE WEF NO 7
> 9 FEMALE OGG NO 26
> 10 MALE OGG NO 12
> 11 FEMALE TGA NO 16
> 12 MALE TGA NO 26
>
> R> age
> sex age death count
> 1 FEMALE 17Y YES 16
> 2 MALE 17Y YES 4
> 3 FEMALE 18Y YES 40
> 4 MALE 18Y YES 51
> 5 FEMALE 17Y NO 32
> 6 MALE 17Y NO 42
> 7 FEMALE 18Y NO 26
> 8 MALE 18Y NO 15
>
> - How to merge two tables.
> - How to expand both tables such as:
>
> sex age cross death
> FEMALE 17Y WEF YES
> ...
> FEMALE 18Y TGA NO
>
>
> Warm regards,
> Xiyan Lon
>
> This email has been sent from a virus-free computer protected by Avast.
> www.avast.com <https://www.avast.com/sig-email>
> <#DDB4FAA8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.
>
---------------------------------------------------------------------------
Jeff Newmiller The ..... ..... Go Live...
DCN:<jdnewmil at dcn.davis.ca.us> Basics: ##.#. ##.#. Live Go...
Live: OO#.. Dead: OO#.. Playing
Research Engineer (Solar/Batteries O.O#. #.O#. with
/Software/Embedded Controllers) .OO#. .OO#. rocks...1k
More information about the R-help
mailing list