[R] split with list
Joris Meys
jorismeys at gmail.com
Fri Jul 9 12:27:29 CEST 2010
One solution is to put these unwanted entries to ""
repor$9853312 [1:2,2:3] <- ""
Cheers
Joris
On Fri, Jul 9, 2010 at 12:18 PM, n.vialma at libero.it <n.vialma at libero.it> wrote:
>
> Dear List I would like to ask you something concenting a better print of the R output:
> I have a bit data frame which has the following structure:
> CFISCALE RAGSOCB ANNO VAR1 VAR2.........
> 9853312 astra 2005 6 45
>
> 9853312 astra 2006 78 45
>
>
> 9853312 astra 2007 55 76
>
>
> 9653421 geox 2005 35 89
>
>
>
> 9653421 geox 2006 24 33
>
> 9653421 geox 2007 54 55
>
>
> The first thing I did is to split my data frame for CFISCALE. The result is that R has transformed my data frame into a list. The second step was to transpose each element of my list.
> repo=split(rep,rep$CFISCALE)
> repor=lapply(repo,function(x){
> t(x)})
>
>
> When I print my list the format is the following
> $9853312
> 1 2 3
>
> CFISCALE "9853312" "9853312" "9853312"
>
> RAGSOCB "astra" "astra" "astra"
>
> ANNO "2005" "2006" "2007"
>
> VAR1 6 78 55
>
> VAR2 45 45 76
>
>
> There is a way to remove the first row I mean 1, 2 , 3 and to have just one CFISCALE and RAGSOCB???
> For the second problem I tried to use unique but it seems that it doesnt work for list. So what I would like to get is:
> $9853312
>
>
>
>
> CFISCALE "9853312"
>
>
> RAGSOCB "astra"
> ANNO "2005" "2006" "2007"
>
> VAR1 6 78 55
>
> VAR2 45 45 76
>
>
> This is because I next run xtable on my list in order to get a table in Latex, which I woud like to be in a nice format.
> Thanks a lot for your attention!
>
>
>
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> 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.
>
--
Joris Meys
Statistical consultant
Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control
tel : +32 9 264 59 87
Joris.Meys at Ugent.be
-------------------------------
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php
More information about the R-help
mailing list