[R] R: characters

Martin Lam tmlammail at yahoo.com
Wed Aug 17 13:52:01 CEST 2005


Hmm, it seems that the only difference is the use of
"as.data.frame(a)" instead of "a". Hence, the same
result can be done with:

a <- rbind(c(T, T, F), c(F, F, T))
a[a==F]=""
as.data.frame(a)

A possible drawback is that the mode changes from
logical to character when using a[a==F]=""

Instead you could use a[a==F]=NA, but that won't get
you blank lines.

Best,

Martin


--- Dimitris Rizopoulos
<dimitris.rizopoulos at med.kuleuven.be> wrote:

> you could convert it to a data.frame, i.e.,
> 
> a <- rbind(c(T, T, F), c(F, F, T))
> a[!a] <- ""
> as.data.frame(a)
> 
> 
> I hope it helps.
> 
> Best,
> Dimitris
> 
> ----
> Dimitris Rizopoulos
> Ph.D. Student
> Biostatistical Centre
> School of Public Health
> Catholic University of Leuven
> 
> Address: Kapucijnenvoer 35, Leuven, Belgium
> Tel: +32/16/336899
> Fax: +32/16/337015
> Web: http://www.med.kuleuven.be/biostat/
>     
>
http://www.student.kuleuven.be/~m0390867/dimitris.htm
> 
> 
> ----- Original Message ----- 
> From: "Clark Allan" <Allan at stats.uct.ac.za>
> To: <r-help at stat.math.ethz.ch>
> Sent: Wednesday, August 17, 2005 12:35 PM
> Subject: [R] R: characters
> 
> 
> > hi all
> >
> > assume that i have the following table
> >
> > a=rbind(c(T,T,F),c(F,F,T))
> >> a
> >      [,1]  [,2]  [,3]
> > [1,]  TRUE  TRUE FALSE
> > [2,] FALSE FALSE  TRUE
> >
> > I would like to change all the FALSE entries to a
> blank. how can i 
> > do
> > this?
> >
> > i could simply use
> >
> > a[a==F]=""
> > a
> >
> > but then how would i remove the " " from the
> entries.
> >
> > i know that this should be very easy!!!
> >
> > /
> > allan
> 
> 
>
--------------------------------------------------------------------------------
> 
> 
> > ______________________________________________
> > R-help at stat.math.ethz.ch mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide! 
> > http://www.R-project.org/posting-guide.html
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>




More information about the R-help mailing list