[R] Fwd: Questions about working with a dataframe
jrkrideau at inbox.com
Wed Jun 26 17:34:59 CEST 2013
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
Kingston ON Canada
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":
What I did is this:
> oWWA$speciesName <-as.character(oWWA$speciesName)
and now I've got:
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),]
(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