[R] xtable with ifelse statement

Jannis bt_jannis at yahoo.de
Wed Jul 21 14:06:30 CEST 2010


What exactly do you want to do? To me it looks more like a problem with the arrangement of your lists as with xtable (or ifelse) (so you are better next time of with a more precise subject line).

Please read the posting guide and provide some reproducable code so we can help you (and include your lists etc. via  dump('x',file=stdout())).

As first suggestion I would rearrange your lists in a way that the data you want to have together ends up in one list, but there are several alternatives, depending on what you want to achieve.


Jannis

--- vivi84 <cipullussa at hotmail.com> schrieb am Mi, 21.7.2010:

> Von: vivi84 <cipullussa at hotmail.com>
> Betreff: [R] xtable with ifelse statement
> An: r-help at r-project.org
> Datum: Mittwoch, 21. Juli, 2010 07:23 Uhr
> 
> Hi there,
> I'm very new on R and I hope someone can help me to solve
> the problem in
> using the ifelse statement with the xtable function(library
> xtable). 
> I'm trying to get the printing of the elements of two lists
> in a sorted way.
> These two list have in common the their names.
> I will try to give an example:
> the first list looks like this:
> 
> $code1
> 
> Code              code1
> Nation         
>    Usa
> 
> $code2
> 
> Code              code2
> Nation         
>    Spain
> 
> 
> the second one is like this
> 
> $code 1
> var1               
>     87 
> var2               
>    73
> 
> $code2  
> var1               
>     34
> var2               
>     23
> 
> 
> As you can see the two list have the same names.I tried to
> implement the
> following ifelse statement but it doesn't work
> orde2=function(x,y){
> ifelse(names(x)==names(y),list(print(xtable(x)),print(xtable(y))),NULL)
> 
> What I want is the xtable of this first:
> $code1
> 
> Code              code1
> Nation         
>    Usa
> 
> 
> and after this:
> 
> $code 1
> var1               
>     87 
> var2               
>    73
> 
> 
> And as the first case, the xtable of this;
> $code2
> 
> Code              code2
> Nation         
>    Spain
> 
> 
> and after this:
> 
> $code2  
> var1               
>     34
> var2               
>     23
> 
> Someone Knows if it possible to do this and how??
> Thanks a lot!
> 
> -- 
> View this message in context: http://r.789695.n4.nabble.com/xtable-with-ifelse-statement-tp2296694p2296694.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> 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.
> 





More information about the R-help mailing list