I'am a very fresh R user and I'd like to know how I could create such structures. I saw R was objects-oriented but I can not find any doccumentation on about how to build my hown ojects. Thanks.
Is it possible to have data stuctures like in C ?
5 messages · Samuel Plessis-Fraissard, Ramon Diaz-Uriarte, Thomas Lumley
Dear Samuel, With regards to the second question, essentially everything in R (S) is an object. As a simple example, if you do:
x <- 1:5
x is an object. It has attributes, there are methods appropriate for printing it, etc. As for the first, the simplest thing to use would be a list, where you can have named components of different types.
y <- list(the.first.vector = 1:5, one.character = "a", another.vector =
10:15) S4 classes do provide more sophisticated ways of dealing with classes, and they might be closer to what you expect from structs in C/C++ and classes in C++. S4 are thoroughly documented in Venables & Ripley's "S Programming" and in Chambers' "Programming with Data". But I think you problably should start with the introductory manuals (such as "An introduction to R", which comes with R) and then maybe move to Venables & Ripley's "S Programming". Hope this helps, Ram?n
On Monday 07 April 2003 14:40, Samuel Plessis-Fraissard wrote:
I'am a very fresh R user and I'd like to know how I could create such structures. I saw R was objects-oriented but I can not find any doccumentation on about how to build my hown ojects. Thanks.
______________________________________________ R-help at stat.math.ethz.ch mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Ram?n D?az-Uriarte Bioinformatics Unit Centro Nacional de Investigaciones Oncol?gicas (CNIO) (Spanish National Cancer Center) Melchor Fern?ndez Almagro, 3 28029 Madrid (Spain) Fax: +-34-91-224-6972 Phone: +-34-91-224-6900 http://bioinfo.cnio.es/~rdiaz
On 7 Apr 2003, Samuel Plessis-Fraissard wrote:
I'am a very fresh R user and I'd like to know how I could create such structures. I saw R was objects-oriented but I can not find any doccumentation on about how to build my hown ojects.
You can build arbitrarily complex structures using lists (and lists of
lists, and...).
This isn't what people mean when they describe R as object-oriented,
though.
There are two systems for handling generic and method functions, so you
can say
print(x)
or
plot(x)
and the appropriate function for printing or plotting an `x' will be
called.
While there is some documentation (see ?class, ?UseMethod, and help for
the `methods' package) and there are quite a lot of examples in R itself
and in the Bioconductor project you probably want to read a book on S
programming.
-thomas
Thomas Lumley <tlumley at u.washington.edu> writes:
|On 7 Apr 2003, Samuel Plessis-Fraissard wrote:
| |> I'am a very fresh R user and I'd like to know how I could create such |> structures. |> |> I saw R was objects-oriented but I can not find any doccumentation on |> about how to build my hown ojects. |> | |You can build arbitrarily complex structures using lists (and lists of |lists, and...). | |This isn't what people mean when they describe R as object-oriented, |though. | |There are two systems for handling generic and method functions, so you |can say | print(x) |or | plot(x) | |and the appropriate function for printing or plotting an `x' will be |called. | |While there is some documentation (see ?class, ?UseMethod, and help for |the `methods' package) and there are quite a lot of examples in R itself |and in the Bioconductor project you probably want to read a book on S |programming. | Thanks
Ramon Diaz <rdiaz at cnio.es> writes: |Dear Samuel, | |With regards to the second question, essentially everything in R (S) is an |object. As a simple example, if you do: |> x <- 1:5 |x is an object. It has attributes, there are methods appropriate for printing |it, etc. | |As for the first, the simplest thing to use would be a list, where you can |have named components of different types. |> y <- list(the.first.vector = 1:5, one.character = "a", another.vector = |10:15) | |S4 classes do provide more sophisticated ways of dealing with classes, and |they might be closer to what you expect from structs in C/C++ and classes in |C++. S4 are thoroughly documented in Venables & Ripley's "S Programming" and |in Chambers' "Programming with Data". | |But I think you problably should start with the introductory manuals (such as |"An introduction to R", which comes with R) and then maybe move to Venables & |Ripley's "S Programming". | | |Hope this helps, | |Ram?n Thanks for help.