list.class: Classify list elments into unique but non-exclusive cases

Description Usage Arguments Value Examples

View source: R/list.group.R

Description

In non-tabular data, a certain field may take multiple values in a collection non-exclusively. To classify these elements into different cases, this function detects all possible cases and for each case all elements are examined whether to belong to that case.

Usage

1
list.class(.data, ..., sorted = TRUE)

Arguments

.data

A list or vector

...

keys

sorted

TRUE to sort the group keys. Ignored when the key has multiple entries.

Value

a list of possible cases each of which contains elements belonging to the case non-exclusively.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
x <-
  list(
    p1=list(name='Ken',age=24,
      interest=c('reading','music','movies'),
      lang=list(r=2,csharp=4,python=3)),
    p2=list(name='James',age=25,
      interest=c('sports','music'),
      lang=list(r=3,java=2,cpp=5)),
    p3=list(name='Penny',age=24,
      interest=c('movies','reading'),
      lang=list(r=1,cpp=4,python=2)))
list.class(x,interest)
list.class(x,names(lang))

Example output

$movies
$movies$p1
$movies$p1$name
[1] "Ken"

$movies$p1$age
[1] 24

$movies$p1$interest
[1] "reading" "music"   "movies" 

$movies$p1$lang
$movies$p1$lang$r
[1] 2

$movies$p1$lang$csharp
[1] 4

$movies$p1$lang$python
[1] 3



$movies$p3
$movies$p3$name
[1] "Penny"

$movies$p3$age
[1] 24

$movies$p3$interest
[1] "movies"  "reading"

$movies$p3$lang
$movies$p3$lang$r
[1] 1

$movies$p3$lang$cpp
[1] 4

$movies$p3$lang$python
[1] 2




$music
$music$p1
$music$p1$name
[1] "Ken"

$music$p1$age
[1] 24

$music$p1$interest
[1] "reading" "music"   "movies" 

$music$p1$lang
$music$p1$lang$r
[1] 2

$music$p1$lang$csharp
[1] 4

$music$p1$lang$python
[1] 3



$music$p2
$music$p2$name
[1] "James"

$music$p2$age
[1] 25

$music$p2$interest
[1] "sports" "music" 

$music$p2$lang
$music$p2$lang$r
[1] 3

$music$p2$lang$java
[1] 2

$music$p2$lang$cpp
[1] 5




$reading
$reading$p1
$reading$p1$name
[1] "Ken"

$reading$p1$age
[1] 24

$reading$p1$interest
[1] "reading" "music"   "movies" 

$reading$p1$lang
$reading$p1$lang$r
[1] 2

$reading$p1$lang$csharp
[1] 4

$reading$p1$lang$python
[1] 3



$reading$p3
$reading$p3$name
[1] "Penny"

$reading$p3$age
[1] 24

$reading$p3$interest
[1] "movies"  "reading"

$reading$p3$lang
$reading$p3$lang$r
[1] 1

$reading$p3$lang$cpp
[1] 4

$reading$p3$lang$python
[1] 2




$sports
$sports$p2
$sports$p2$name
[1] "James"

$sports$p2$age
[1] 25

$sports$p2$interest
[1] "sports" "music" 

$sports$p2$lang
$sports$p2$lang$r
[1] 3

$sports$p2$lang$java
[1] 2

$sports$p2$lang$cpp
[1] 5




$cpp
$cpp$p2
$cpp$p2$name
[1] "James"

$cpp$p2$age
[1] 25

$cpp$p2$interest
[1] "sports" "music" 

$cpp$p2$lang
$cpp$p2$lang$r
[1] 3

$cpp$p2$lang$java
[1] 2

$cpp$p2$lang$cpp
[1] 5



$cpp$p3
$cpp$p3$name
[1] "Penny"

$cpp$p3$age
[1] 24

$cpp$p3$interest
[1] "movies"  "reading"

$cpp$p3$lang
$cpp$p3$lang$r
[1] 1

$cpp$p3$lang$cpp
[1] 4

$cpp$p3$lang$python
[1] 2




$csharp
$csharp$p1
$csharp$p1$name
[1] "Ken"

$csharp$p1$age
[1] 24

$csharp$p1$interest
[1] "reading" "music"   "movies" 

$csharp$p1$lang
$csharp$p1$lang$r
[1] 2

$csharp$p1$lang$csharp
[1] 4

$csharp$p1$lang$python
[1] 3




$java
$java$p2
$java$p2$name
[1] "James"

$java$p2$age
[1] 25

$java$p2$interest
[1] "sports" "music" 

$java$p2$lang
$java$p2$lang$r
[1] 3

$java$p2$lang$java
[1] 2

$java$p2$lang$cpp
[1] 5




$python
$python$p1
$python$p1$name
[1] "Ken"

$python$p1$age
[1] 24

$python$p1$interest
[1] "reading" "music"   "movies" 

$python$p1$lang
$python$p1$lang$r
[1] 2

$python$p1$lang$csharp
[1] 4

$python$p1$lang$python
[1] 3



$python$p3
$python$p3$name
[1] "Penny"

$python$p3$age
[1] 24

$python$p3$interest
[1] "movies"  "reading"

$python$p3$lang
$python$p3$lang$r
[1] 1

$python$p3$lang$cpp
[1] 4

$python$p3$lang$python
[1] 2




$r
$r$p1
$r$p1$name
[1] "Ken"

$r$p1$age
[1] 24

$r$p1$interest
[1] "reading" "music"   "movies" 

$r$p1$lang
$r$p1$lang$r
[1] 2

$r$p1$lang$csharp
[1] 4

$r$p1$lang$python
[1] 3



$r$p2
$r$p2$name
[1] "James"

$r$p2$age
[1] 25

$r$p2$interest
[1] "sports" "music" 

$r$p2$lang
$r$p2$lang$r
[1] 3

$r$p2$lang$java
[1] 2

$r$p2$lang$cpp
[1] 5



$r$p3
$r$p3$name
[1] "Penny"

$r$p3$age
[1] 24

$r$p3$interest
[1] "movies"  "reading"

$r$p3$lang
$r$p3$lang$r
[1] 1

$r$p3$lang$cpp
[1] 4

$r$p3$lang$python
[1] 2

rlist documentation built on Sept. 5, 2021, 5:30 p.m.