"n.via...@libero.it" <n.via...@libero.it> writes:
Hi,

> 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
>

So far so good.

>
> 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: 

Well I'm not sure what the first problem is. But if I understand the
"second problem", you can do something like this:

dup.null <- function(mat) {
  mat["CFISCALE", duplicated(mat["CFISCALE",])] <- NA
  mat["RAGSOCB", duplicated(mat["RAGSOCB",])] <- NA
  return(mat)
  }

repor <- lapply(repor, dup.null)


Best,
Ista

> $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@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.

______________________________________________
R-help@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.

Reply via email to