On Nov 17, 2010, at 9:26 AM, Alaios wrote:

It seems that I am confusing something:

List of 50
 $ :List of 2
  ..$ CRmap: logi [1:100, 1:100] NA NA NA NA NA NA ...
  ..$ xy   : num [1:2] 21 11
 $ :List of 2
  ..$ CRmap: logi [1:100, 1:100] NA NA NA NA NA NA ...
  ..$ xy   : num [1:2] 80 68

lapply( Mystruct, "[", "xy")  # should return a list with "xy" elements



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.

It shouldn't. That extra period should mess things up. There is no ". $" operator.


--
David.


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.calan...@uni- hamburg.de>/*
wrote:


     From: Ivan Calandra <ivan.calan...@uni-hamburg.de>
     Subject: Re: [R] Give me all operator
     To: r-help@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@r-project.org </mc/compose?to=r-h...@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.calan...@uni-hamburg.de
     </mc/compose?to=ivan.calan...@uni-hamburg.de>

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

     ______________________________________________
R-help@r-project.org </mc/compose?to=r-h...@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.calan...@uni-hamburg.de

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

______________________________________________
R-help@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.




        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

David Winsemius, MD
West Hartford, CT

______________________________________________
R-help@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.

Reply via email to