FAQ

On Tue, 26 Feb 2002, Gabor Grothendieck wrote:

- what is the difference between my.list$dim<- and dim(my.list)<- ?
my.list$dim refers to the element called dim in my.list, it's a
piece of your information.
dim(my.list) refers to the dimension attribute of the object
called my.list, it's an information on how the data are arranged in
the object:
my.list <- list(a1="1",a2=c(1,2,3),a3=1:5,dim=c(2,2))
Information kept in my.list:
my.list$a2 [1] 1 2 3
my.list$dim
[1] 2 2

Instead, information on my.list:
dim(my.list) <- c(2,2)
attributes(my.list)
$dim
[1] 2 2
attributes(my.list)$dim
[1] 2 2

The attributes of an object are organized in a list.


For a matrix it would be equivalent: one thing
are the cell elements, another the dimension of the matrix (that is,
how you want the elements to be organized).
x <- matrix(1:12,ncol=3)
x[1,1] [1] 1
dim(x)
[1] 4 3
which is equivalent to:
attributes(x)$dim
[1] 4 3

- after creating the matrix with both numbers and my.lm elements in it
I tried to convert it to a data frame. I tried data.frame(my.mat)
and as.data.frame(my.mat) but using R 1.4.0 on Windows 2000 I got
Error in format(unlist(x), trim = trim) : first argument must be atomic
for both. Is it possible to convert my.mat to a data frame?
What's the goal? I mean, what information you have and how you want it
organized?

Agus


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._

Search Discussions

Discussion Posts

Previous

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 5 of 5 | next ›
Discussion Overview
groupr-help @
categoriesr
postedFeb 26, '02 at 1:47a
activeFeb 26, '02 at 6:37p
posts5
users3
websiter-project.org
irc#r

People

Translate

site design / logo © 2017 Grokbase