melt.list: Melt a list by recursively melting each component.

Description Usage Arguments See Also Examples

View source: R/melt.r

Description

Melt a list by recursively melting each component.

Usage

1
2
## S3 method for class 'list'
melt(data, ..., level = 1)

Arguments

data

list to recursively melt

...

further arguments passed to or from other methods.

level

list level - used for creating labels

See Also

cast

Other melt methods: melt.array(), melt.data.frame(), melt.default()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
a <- as.list(c(1:4, NA))
melt(a)
names(a) <- letters[1:4]
melt(a)
a <- list(matrix(1:4, ncol=2), matrix(1:6, ncol=2))
melt(a)
a <- list(matrix(1:4, ncol=2), array(1:27, c(3,3,3)))
melt(a)
melt(list(1:5, matrix(1:4, ncol=2)))
melt(list(list(1:3), 1, list(as.list(3:4), as.list(1:2))))

Example output

  value L1
1     1  1
2     2  2
3     3  3
4     4  4
5    NA  5
  value   L1
1     1    a
2     2    b
3     3    c
4     4    d
5    NA <NA>
   Var1 Var2 value L1
1     1    1     1  1
2     2    1     2  1
3     1    2     3  1
4     2    2     4  1
5     1    1     1  2
6     2    1     2  2
7     3    1     3  2
8     1    2     4  2
9     2    2     5  2
10    3    2     6  2
   Var1 Var2 value Var3 L1
1     1    1     1   NA  1
2     2    1     2   NA  1
3     1    2     3   NA  1
4     2    2     4   NA  1
5     1    1     1    1  2
6     2    1     2    1  2
7     3    1     3    1  2
8     1    2     4    1  2
9     2    2     5    1  2
10    3    2     6    1  2
11    1    3     7    1  2
12    2    3     8    1  2
13    3    3     9    1  2
14    1    1    10    2  2
15    2    1    11    2  2
16    3    1    12    2  2
17    1    2    13    2  2
18    2    2    14    2  2
19    3    2    15    2  2
20    1    3    16    2  2
21    2    3    17    2  2
22    3    3    18    2  2
23    1    1    19    3  2
24    2    1    20    3  2
25    3    1    21    3  2
26    1    2    22    3  2
27    2    2    23    3  2
28    3    2    24    3  2
29    1    3    25    3  2
30    2    3    26    3  2
31    3    3    27    3  2
  value Var1 Var2 L1
1     1   NA   NA  1
2     2   NA   NA  1
3     3   NA   NA  1
4     4   NA   NA  1
5     5   NA   NA  1
6     1    1    1  2
7     2    2    1  2
8     3    1    2  2
9     4    2    2  2
  value L2 L3 L1
1     1  1 NA  1
2     2  1 NA  1
3     3  1 NA  1
4     1 NA NA  2
5     3  1  1  3
6     4  1  2  3
7     1  2  1  3
8     2  2  2  3

reshape2 documentation built on April 14, 2020, 5:26 p.m.