[S] assignments to data frames -- addendum

Jeff Longmate (jlongmate@smtplink.coh.org)
Fri, 13 Nov 98 11:03:13 -0800

My question crossed in the traffic with the reply originating with Bill Dunlap,
who offered:
> df$Text <- I(as.character(df$Text))
and noted:
> (With some syntaxes this I isn't needed, but you might as well use it.)
It never occurred to me to use I() in this context, and my question was about
trying to understand the variation among the different syntaxes. I'm still
curious, but Bill's comment certainly helps. There is still a difference in
attributes lurking somewhere, however:

> df <- data.frame(a=letters[1:5], n=1:5)
> df[[1]] <- I(as.character(df[[1]]))
> data.class(df[[1]])
[1] "AsIs"
> mode(df[[1]])
[1] "character"

Jeffrey A. Longmate, Ph.D. Phone: 626-359-8111 ext.2478
Department of Biostatistics Fax: 626-301-8802
City of Hope National Medical Center E-mail: jlongmat@coh.org
and Beckman Research Institute
1500 East Duarte Road
Duarte CA, USA 91010-3000

This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news