[R] Fwd: as.list

Ivan Calandra ivan.calandra at uni-hamburg.de
Wed Oct 27 15:26:05 CEST 2010


Hi Sibylle,

I was about to send you an email, but I'll modify it thanks to your second!

Is PA what you expect? Does it contain the data you want?
You should provide some sample data.
If the importation worked, try to copy/paste the output of dput(PA), 
which we can then copy/paste in our console. That function is great to 
share R objects. If your dataset is too big, try dput(head(PA)), which 
outputs only the first line of it.

Regarding the selection, I think you're doing it wrong. which() returns 
a logical vector, which is probably not what you're looking for.
Maybe:
KANE <- PA[PA$Site=="KA" & PA$part=="NE", ]  ## the last comma is 
important to select all the columns for the rows you've chosen
Read ?"[" or ?subset to understand more

The barplot() might work better then.

HTH,
Ivan

Le 10/27/2010 15:09, "Sibylle Stöckli" a écrit :
> -------- Original-Nachricht --------
> Datum: Wed, 27 Oct 2010 15:03:48 +0200
> Von: "Sibylle Stöckli"<sibylle.stoeckli at gmx.ch>
> An: Rhelp<r-help at r-project.org>
> Betreff: as.list
>
> Dear R-users
>
> sorry, here Rcode included (attachment has been removed)
>
> I would like to read a txt file as list, to select rows and columns, and to create barplots.
>
> (1) selection of parameter site and part: ok
> (2) read txt file as list: problem with (1) as there are NA's (the lines not selected)
>
> (3) barplot: 5 different groups of bars (the selected columns H5,H8, S5,S8, C8). In each group 4 different bars (parameter diversity)
> -->  error in -0.01*height: non-numeric argument to binary operator
>
> PROBLEM
> As (2) gives NULL, I think that there is a mistake in my r-script with the vector/list function.
>
> Thanks
> Sibylle
>
> R-Code
>
> PA<-read.table("Biotree_partitioning.txt", header=TRUE)
> KANE<-which((PA$site=="KA")&(PA$part=="NE"))
> KANE.LIST<-vector("list", dim(PA[KANE,])[2]-4)
> KANE.LIST
>
> barplot(KANE.LIST, col=as.numeric(PA$diveristy))
>
>
>
> ______________________________________________
> 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.

-- 
Ivan CALANDRA
PhD Student
University of Hamburg
Biozentrum Grindel und Zoologisches Museum
Abt. Säugetiere
Martin-Luther-King-Platz 3
D-20146 Hamburg, GERMANY
+49(0)40 42838 6231
ivan.calandra at uni-hamburg.de

**********
http://www.for771.uni-bonn.de
http://webapp5.rrz.uni-hamburg.de/mammals/eng/mitarbeiter.php



More information about the R-help mailing list