I have Legal data that looks like this. I'm using RStudio.
> head(gsu[,107:117])
HtoODay PAOSLDME DUSHD POELRD XCAB WESDF BILOE HYPERDIF IMPSENS Billing MALLAMP
42 0 <NA> No No <NA> <NA> <NA> No <NA> Hourly NA
61 0 <NA> Yes Yes <NA> Yes <NA> Yes <NA> Hourly NA
230 0 <NA> No Yes <NA> <NA> <NA> Yes <NA> Hourly NA
235 0 <NA> No No <NA> <NA> <NA> Yes <NA> Hourly NA
302 0 <NA> No No <NA> <NA> No No <NA> Hourly NA
336 3 <NA> No No Yes <NA> <NA> No <NA> Consult NA
>
I want to get a row count of unique Yes occurrences. By which I mean, if Yes occurs in one column, this registers as a count of 1 regardless of the Yes or No value of another column.
For example, Row 61 would count as 1 count of Yes, even though the row contains multiples Yes's across columns, whereas Row 336 would also register in the overall count as 1, given only one instance of Yes.
Essentially, how do I count unique rows of binary instances across columns, without accounting for multiple within-row instances?
rowSums(df=="Yes", na.rm=TRUE)>=1
gives
# 42 61 230 235 302 336
#FALSE TRUE TRUE TRUE FALSE TRUE
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With