Attribute Combinations

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Attribute Combinations

reichmaj
R-help forum

 

Looking for a function or some guidance for obtaining the percentage of
attribute combinations, for example

 

V1           V2           V3

A             A             B

A             B             C

A             A             D            

A             A             B

A             A             B

A             B             C

A             C             B            

A             C             B

A             B             C

A             C             C

 

Results

A,A,B     0.30

A,B,C     0.30

A,A,D    0.10

A,C,B     0.20 etc

 

Sincerely

 

Jeff Reichman

(314) 457-1966

 


        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: [EXTERNAL] Attribute Combinations

R help mailing list-2
# assuming your data frame is named "x", you can get the counts of each combo:

table(do.call(paste0, x))

# and to get the proportions:

table(do.call(paste0, x))/nrow(x)


-----Original Message-----
From: R-help <[hidden email]> On Behalf Of Jeff Reichman
Sent: Thursday, May 21, 2020 10:22 AM
To: [hidden email]
Subject: [EXTERNAL] [R] Attribute Combinations

R-help forum

 

Looking for a function or some guidance for obtaining the percentage of attribute combinations, for example

 

V1           V2           V3

A             A             B

A             B             C

A             A             D            

A             A             B

A             A             B

A             B             C

A             C             B            

A             C             B

A             B             C

A             C             C

 

Results

A,A,B     0.30

A,B,C     0.30

A,A,D    0.10

A,C,B     0.20 etc

 

Sincerely

 

Jeff Reichman

(314) 457-1966

 


        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Attribute Combinations

John Kane-3
In reply to this post by reichmaj
One possible way
library(tidyr)

dat1  <-  structure(list(V1 = c("A", "A", "A", "A", "A", "A", "A", "A",
"A", "A"), V2 = c("A", "B", "A", "A", "A", "B", "C", "C", "B",
"C"), V3 = c("B", "C", "D", "B", "B", "C", "B", "B", "C", "C"
)), class = "data.frame", row.names = c(NA, -10L))

dat2  <-  unite(dat1, att, V1, V2, V3, sep = ",")

prop.table(table(dat2$att))

A,A,B A,A,D A,B,C A,C,B A,C,C
  0.3   0.1   0.3   0.2   0.1

On Thu, 21 May 2020 at 13:22, Jeff Reichman <[hidden email]> wrote:

> R-help forum
>
>
>
> Looking for a function or some guidance for obtaining the percentage of
> attribute combinations, for example
>
>
>
> V1           V2           V3
>
> A             A             B
>
> A             B             C
>
> A             A             D
>
> A             A             B
>
> A             A             B
>
> A             B             C
>
> A             C             B
>
> A             C             B
>
> A             B             C
>
> A             C             C
>
>
>
> Results
>
> A,A,B     0.30
>
> A,B,C     0.30
>
> A,A,D    0.10
>
> A,C,B     0.20 etc
>
>
>
> Sincerely
>
>
>
> Jeff Reichman
>
> (314) 457-1966
>
>
>
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] 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.
>


--
John Kane
Kingston ON Canada

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Attribute Combinations

Ista Zahn
In reply to this post by reichmaj
Another one just for fun:

prop.table(table(interaction(x)))

or possibly

prop.table(table(droplevels(interaction(x))))

Best,
Ista


On Thu, May 21, 2020 at 1:22 PM Jeff Reichman <[hidden email]> wrote:

>
> R-help forum
>
>
>
> Looking for a function or some guidance for obtaining the percentage of
> attribute combinations, for example
>
>
>
> V1           V2           V3
>
> A             A             B
>
> A             B             C
>
> A             A             D
>
> A             A             B
>
> A             A             B
>
> A             B             C
>
> A             C             B
>
> A             C             B
>
> A             B             C
>
> A             C             C
>
>
>
> Results
>
> A,A,B     0.30
>
> A,B,C     0.30
>
> A,A,D    0.10
>
> A,C,B     0.20 etc
>
>
>
> Sincerely
>
>
>
> Jeff Reichman
>
> (314) 457-1966
>
>
>
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] 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.

______________________________________________
[hidden email] 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.