[R] initiate elements in a dataframe with lists

Thierry Onkelinx th|erry@onke||nx @end|ng |rom |nbo@be
Wed Jul 25 09:26:30 CEST 2018


Dear Bogdan,

You are looking for x$intersectA <- vector("list", nrow(x))

Best regards,


ir. Thierry Onkelinx
Statisticus / Statistician

Vlaamse Overheid / Government of Flanders
INSTITUUT VOOR NATUUR- EN BOSONDERZOEK / RESEARCH INSTITUTE FOR NATURE AND
FOREST
Team Biometrie & Kwaliteitszorg / Team Biometrics & Quality Assurance
thierry.onkelinx using inbo.be
Havenlaan 88 bus 73, 1000 Brussel
www.inbo.be

///////////////////////////////////////////////////////////////////////////////////////////
To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to say
what the experiment died of. ~ Sir Ronald Aylmer Fisher
The plural of anecdote is not data. ~ Roger Brinner
The combination of some data and an aching desire for an answer does not
ensure that a reasonable answer can be extracted from a given body of data.
~ John Tukey
///////////////////////////////////////////////////////////////////////////////////////////

<https://www.inbo.be>

2018-07-25 8:55 GMT+02:00 Bogdan Tanasa <tanasa using gmail.com>:

> Dear all,
>
> assuming that I do have a dataframe like :
>
> x <- data.frame(TYPE=c("DEL", "DEL", "DUP", "TRA", "INV", "TRA"),
> CHRA=c("chr1", "chr1", "chr1", "chr1", "chr2", "chr2"),
> POSA=c(10, 15, 120, 340, 100, 220),
> CHRB=c("chr1", "chr1", "chr1", "chr2", "chr2", "chr1"),
> POSB=c(30, 100, 300, 20, 200, 320)) ,
>
> how could I initiate another 2 columns in x, where each element in these 2
> columns is going to be a list (the list could be updated later). Thank you
> !
>
> Shall I do,
>
> for (i in 1:dim(x)[1]) { x$intersectA[i] <- list()}
>
> for (i in 1:dim(x)[1]) { x$intersectB[i] <- list()}
>
> nothing is happening. Thank you very much !
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help using r-project.org 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.
>

	[[alternative HTML version deleted]]




More information about the R-help mailing list