[R] R code for overlapping variables -- count

Ebert,Timothy Aaron tebert @end|ng |rom u||@edu
Mon Jun 3 13:12:41 CEST 2024


One could make dummy variables if the existing variables are otherwise. If Female is a variable that includes other options (no-response, non-binary, ...) then recode it using dummy.female and the others would be similarly named.

-----Original Message-----
From: R-help <r-help-bounces using r-project.org> On Behalf Of peter dalgaard
Sent: Monday, June 3, 2024 5:02 AM
To: Shadee Ashtari <shadee.ashtari using gmail.com>
Cc: r-help using r-project.org
Subject: Re: [R] R code for overlapping variables -- count

[External Email]

If they are binary (0/1 dummies), can't you just "&" them as in

table(Female & USA & MidIncome)

(or sum() if you don't care about the number of 0s)

-pd

> On 2 Jun 2024, at 00:31 , Shadee Ashtari <shadee.ashtari using gmail.com> wrote:
>
> Hi!
>
> I am trying to find the code for how to get counts for intersectional
> variables. For example, I have three unique categorical variables --
> "Female," "USA," and "MidIncome" -- and I'm trying to see how many
> people I have at the intersection of the three.
>
> Thank you so much,
> Shadee
>
>       [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat/
> .ethz.ch%2Fmailman%2Flistinfo%2Fr-help&data=05%7C02%7Ctebert%40ufl.edu
> %7C66abf8af810348ed21b408dc83abdfd6%7C0d4da0f84a314d76ace60a62331e1b84
> %7C0%7C0%7C638530021430818928%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAw
> MDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=
> a2oUZzOdXDHnzPA3Oo98DIp%2BFIqpg5o1fT0fcE%2BvkQI%3D&reserved=0
> PLEASE do read the posting guide
> http://www.r/
> -project.org%2Fposting-guide.html&data=05%7C02%7Ctebert%40ufl.edu%7C66
> abf8af810348ed21b408dc83abdfd6%7C0d4da0f84a314d76ace60a62331e1b84%7C0%
> 7C0%7C638530021430825783%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiL
> CJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=L2I%2
> BxXV3kHZUwflUx0%2BGrakGbbOV6AWV7dul7%2FyuIBU%3D&reserved=0
> and provide commented, minimal, self-contained, reproducible code.

--
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Office: A 4.23
Email: pd.mes using cbs.dk  Priv: PDalgd using gmail.com

______________________________________________
R-help using 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.



More information about the R-help mailing list