Re: [R] unwanted as.integer

From: Thomas Lumley <tlumley_at_u.washington.edu>
Date: Sat 31 Jul 2004 - 03:34:14 EST

Surely it's simply just to use as.numeric() to stop them being integers?

This is fixed in r-devel anyway -- you have a choice of a bunch of deparsing options.

        -thomas

On Fri, 30 Jul 2004, Sundar Dorai-Raj wrote:

>
>
> Jack Tanner wrote:
>
> > Sundar Dorai-Raj wrote:
> >
> >> Not sure about what sqlQuery is doing but you can wrap your return
> >> value in a eval(parse(text = x)) to evaluate the "as.integer(.)"
> >> string. As in,
> >>
> >> a <- eval(parse(text = a))
> >
> >
> > This works, except it doesn't.
> >
> > > a <- sqlQuery(irrdb, "select count(field) from mytable where field=1")
> > > print(a)
> > count(field)
> > 1 8
> > > paste(a)
> > [1] "as.integer(8)"
> > > eval(parse(text=a))
> > [1] 8
> > > paste(eval(parse(text=a)))
> > [1] "8"
> >
> > That's great, but...
> > > paste(list(eval(parse(text=a)), eval(parse(text=a))))
> > [1] "as.integer(8)" "as.integer(8)"
> >
> > Argh!!! What the hell is going on?
> >
>
>
> I think you meant
>
> paste(c(eval(parse(text=a)), eval(parse(text=a))))
>
> or
>
> do.call("paste", list(eval(parse(text=a)), eval(parse(text=a))))
>
> Not sure which you want.
>
> Or better yet, if `a' is a vector:
>
> a <- c(a, a, a, a)
> b <- lapply(a, function(x) eval(parse(text = x)))
> # I seem to recall you needing to create an HTML table
> do.call("paste", c(b, sep = "</td><td>"))
> # or
> paste(unlist(b), collapse = "</td><td>")
>
> --sundar
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>

Thomas Lumley			Assoc. Professor, Biostatistics
tlumley@u.washington.edu	University of Washington, Seattle

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Sat Jul 31 03:52:50 2004

This archive was generated by hypermail 2.1.8 : Wed 03 Nov 2004 - 22:55:23 EST