[Bioc-devel] DataFrameList to Wide Format DataFrame
Hervé Pagès
hp@ge@@on@g|thub @end|ng |rom gm@||@com
Fri Dec 17 07:30:36 CET 2021
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:
> Good day,
>
> Is there a function in the S4Vectors API which converts a
> DataFrameList into a DataFrame, automatically putting the list names
> into one of the metadata columns, analogous to MultiAssayExperiment's
> wideFormat function? The scenario is mutliple data sets from different
> organisations measuring the largely the same set of features and
> patient outcome, but on completely different sets of patients in each
> organisation.
>
> --------------------------------------
> Dario Strbenac
> University of Sydney
> Camperdown NSW 2050
> Australia
> _______________________________________________
> Bioc-devel using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/bioc-devel
--
Hervé Pagès
Bioconductor Core Team
hpages.on.github using gmail.com
More information about the Bioc-devel
mailing list