[R] value changed after paste() function
Bert Gunter
gunter.berton at gene.com
Mon Mar 21 17:32:35 CET 2011
Inline below.
On Mon, Mar 21, 2011 at 8:18 AM, kellysong <song.qiao at student.dit.ie> wrote:
> Hi all,
>
> I am new user in R, I am trying to to use paste function to concatenate
> strings which has been fetched from database table(postgres database), the
> following are my code:
>
> when i do:
> > sqlFetch(channel,'transactions')
>
> outputs are following(only parts, there are around 200 transactions in
> total)
>
> orderid productname price quantity discount
> 1 T10248 potato 1.80 10 0.00
> 2 T10248 sweets 2.00 5 0.00
> 3 T10249 milk 1.99 9 0.00
> 4 T10249 apple 2.35 40 0.00
>
>
> when i do:
>> paste(sqlFetch(channel,'transactions'))
>
> outputs are:
> [1] "c(1, 1, 2, 2)"
> [2] "c(7, 8, 6, 1)"
> [3] "c(1.8, 2, 1.99, 2.35) "
> [4] "c(10, 5, 9, 40)"
> [5] "c(0, 0, 0, 0) "
>
>
> any idea why the orderid and the productname have been changed?? and what
The results of sqlFetch is a data frame whose alphanumeric columns are
factors. You need to spend some (more) time with "An Introduction to
R" learning about R's data structures and basic procedures BEFORE you
start using it. After you have done so,
?do.call
and
?factor
will tell you how to deal with this sort of thing. But it is doubtful
that you will understand until you have first spent some time with the
basic docs.
-- Bert
> should i do to solve this??
>
> Any help would be very appreciated!
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/value-changed-after-paste-function-tp3393845p3393845.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.
>
--
Bert Gunter
Genentech Nonclinical Biostatistics
467-7374
http://devo.gene.com/groups/devo/depts/ncb/home.shtml
More information about the R-help
mailing list