[R] Fwd: Questions about working with a dataframe
Jacqueline Oehri
jacqueline.oehri at gmx.ch
Thu Jun 27 12:00:43 CEST 2013
Dear Mr. Kane
Thank you very much for your recommendations!!! And I apologise for all circumstances!! I will do so as you said in the future!
Have a nice day,
Best wishes Jacqueline
Gesendet: Mittwoch, 26. Juni 2013 um 17:34 Uhr
Von: "John Kane" <jrkrideau at inbox.com>
An: "Jacqueline Oehri" <jacqueline.oehri at gmx.ch>, "David Winsemius" <dwinsemius at comcast.net>, r-help at r-project.org
Betreff: RE: Aw: Re: [R] Fwd: Questions about working with a dataframe
It is always better when dealing with R to use plain text. HTML messes things up badly sometimes and it is also a good idea to reply to the R-help list rather than individual respondents. You can get more responses if the problem continues and if either of us were away then it might be weeks before we managed to reply
Other responses in line
John Kane
Kingston ON Canada
-----Original Message-----
From: jacqueline.oehri at gmx.ch
Sent: Wed, 26 Jun 2013 11:18:41 +0200 (CEST)
To: dwinsemius at comcast.net, jrkrideau at inbox.com, r-help at r-project.org
Subject: Aw: Re: [R] Fwd: Questions about working with a dataframe
Dear Mr. Kane and dear Mr. Winsemius
Thanks a lot for your quick answers and good recommendations!!! And I apologise for attaching such a big file before!!
I think I could solve the problem;
Maybe you can tell me if its right what I have done?
As John said, the str(WWA) and str(oWWA) gave different outputs for "WWA$speciesName":
> class(WWA$speciesName)
[1] "character"
> class(oWWA$speciesName)
[1] "factor"
What I did is this:
> oWWA$speciesName <-as.character(oWWA$speciesName)
and now I've got:
> class(oWWA$speciesName)
[1] "character"
and the function I wanted to use works well:
> Sp_per_coordID_oWWA <-tapply((oWWA$speciesName), oWWA$coordID, list)
-->Question: Do you think I did this right and this didn't mess up the structure of the dataset? As far as I can see, I see no problem but I m not so experienced as you are!
.Yes, I think you found the problem. It is always a good idea to use str() when reading in a csv file and even when doing data transformations with R as things can change in sometimes unexpected ways.
You might also want to look at "stringsAsFactors" which is either TRUE or FALSE. For historical reasons, what I cannot remember, R often reads in repetitive strings as Factors rather than Characters.
Thank you very very much for your answers!!! It helped me a lot!!
-->second Question: I had problems with using dput(head(WWA)), because I think its still too big, so that I m not able to post all the output from "dput(head(WWA)))", even when i subsetted it first to only three rows:
> WWAsubset <-WWA[c(1:3),]
> dput(head(WWAsubset))
(see after str(WWA) and str(oWWA)
Yes you can set the number of lines of output with something like dput(head(dat1, 10)) which would output the first 10 lines of the data.frame dat1.
____________________________________________________________
FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop!
More information about the R-help
mailing list