Skip to content
Prev 18739 / 21312 Next

[Bioc-devel] DataFrameList to Wide Format DataFrame

A metadata column on a DataFrame runs along its 2nd dimension so is not 
a good place to put the list names.

Have you tried unlist()?

 ? library(S4Vectors)

 ? DF <- DataFrame(id=letters[1:10], score=runif(10))

 ? f <- sample(LETTERS[1:3], 10, replace=TRUE)

 ? DFL <- split(DF, f)

 ? DFL
 ? # SplitDataFrameList of length 3
 ? # $A
 ? # DataFrame with 2 rows and 2 columns
 ? #? ????????? id???? score
 ? # ? <character> <numeric>
 ? # 1?????????? f? 0.894709
 ? # 2?????????? h? 0.801125
 ? #
 ? # $B
 ? # DataFrame with 1 row and 2 columns
 ? #? ????????? id???? score
 ? # ? <character> <numeric>
 ? # 1?????????? d? 0.538166
 ? #
 ? # $C
 ? # DataFrame with 7 rows and 2 columns
 ? #? ????????? id???? score
 ? # ? <character> <numeric>
 ? # 1?????????? a 0.0145477
 ? # 2?????????? b 0.2507581
 ? # 3?????????? c 0.4388678
 ? # 4?????????? e 0.5219524
 ? # 5?????????? g 0.6377634
 ? # 6?????????? i 0.1892103
 ? # 7?????????? j 0.1829650

 ? unlist(DFL)

 ? # DataFrame with 10 rows and 2 columns
 ? #? ????????? id???? score
 ? # ? <character> <numeric>
 ? # A?????????? f 0.8947085
 ? # A?????????? h 0.8011255
 ? # B?????????? d 0.5381664
 ? # C?????????? a 0.0145477
 ? # C?????????? b 0.2507581
 ? # C?????????? c 0.4388678
 ? # C?????????? e 0.5219524
 ? # C?????????? g 0.6377634
 ? # C?????????? i 0.1892103
 ? # C?????????? j 0.1829650

BTW this is a user question so is more appropriate for the support site.

H.
On 16/12/2021 22:00, Dario Strbenac via Bioc-devel wrote: