[R] Give me all operator

Ivan Calandra ivan.calandra at uni-hamburg.de
Wed Nov 17 15:05:25 CET 2010


Well, without knowing what is the structure of Mystruct.Map and 
Mystruct.xy, it's really difficult to know how to help you.
And what is Mystruct by the way!?
Could you send us the output from dput(your_objects) and/or 
str(your_objects)?

I think you're really confused about the structure of your objects. You 
probably need to read more stuff about that!

Ivan

Le 11/17/2010 14:56, Alaios a écrit :
> Thanks a lot for your helpful answer.
> In my case now I have implemented some "struct" with the following 
> structure
> Mystruct.Map
> Mystruct.xy
>
> If I do Mystruct[2].$xy I get correctly the xy values of the second item.
>
> I want now to print all the $xy fields of the Mystruct[[]]
> I tried
> Mystruct[data.frame(a=1:5)]]$xy which returns the following message:
>
> invalid subscript type 'list'
>
>
> I would like to thank you again for your support
> Regards
> Alex
>
> --- On *Wed, 11/17/10, Ivan Calandra /<ivan.calandra at uni-hamburg.de>/* 
> wrote:
>
>
>     From: Ivan Calandra <ivan.calandra at uni-hamburg.de>
>     Subject: Re: [R] Give me all operator
>     To: r-help at r-project.org
>     Date: Wednesday, November 17, 2010, 1:44 PM
>
>     Hi Alex,
>
>     Is that what you're looking for:
>     > df <- data.frame(a=LETTERS[1:5], b=rnorm(5))
>     > df
>        a          b
>     1 A -0.2401323
>     2 B -0.9414998
>     3 C  0.4289836
>     4 D  1.9802749
>     5 E -0.6993612
>     > df[3,2]
>     [1] 0.4289836
>     > df[3,]
>        a         b
>     3 C 0.4289836
>     > df[,2]
>     [1] -0.2401323 -0.9414998  0.4289836  1.9802749 -0.6993612
>     > df[,2, drop=FALSE]
>                 b
>     1 -0.2401323
>     2 -0.9414998
>     3  0.4289836
>     4  1.9802749
>     5 -0.6993612
>
>     See ?"[" for help. In short, in R you use "[", not brackets as in
>     matlab
>     (from your example, I've never used it). You don't need the ":", you
>     just don't write anything in R.
>
>     Ivan
>
>     Le 11/17/2010 14:34, Alaios a écrit :
>     > Hello is there in R any operator that give you all the data of a
>     matrix
>     > for example in matlab
>     >
>     > x(2,3) returns the 2ndth row and 3rdth column
>     > x(2,:) returns all the columns of the 2nd row.
>     >
>     > In R now I would like to print all the
>     >
>     >   CRagent[[i]][2]
>     >
>     >
>     >   CRagent[[:]][2] doesnot work of course. Other option is to
>     make a loop with an index i that spans from 1:last element of
>     CRagent[[]] but this is not that optimal.
>     >
>     > I would like to thank you in aavance for your help
>     > Best Regards
>     > Alex
>     >
>     >
>     >
>     >
>     >     [[alternative HTML version deleted]]
>     >
>     >
>     >
>     > ______________________________________________
>     > R-help at r-project.org </mc/compose?to=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
>     </mc/compose?to=ivan.calandra at uni-hamburg.de>
>
>     **********
>     http://www.for771.uni-bonn.de
>     http://webapp5.rrz.uni-hamburg.de/mammals/eng/mitarbeiter.php
>
>     ______________________________________________
>     R-help at r-project.org </mc/compose?to=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