Hi, if I do
Z<-rnorm(50)
Followed by
Dim(Z)
I get NULL. Is this correct? Shouldn't I get 50 instead?
TIA
Chris
DISCLAIMER:\ L'utilizzo non autorizzato del presente messagg...{{dropped}}
Newbie help on dim
9 messages · Christian Prinoth, Dimitris Rizopoulos, Andy Bunn +3 more
yes it is correct! look at ?dim() for more info. In this case you need length(), i.e., Z <- rnorm(50) length(Z) I hope it helps. Best, Dimitris ---- Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/16/336899 Fax: +32/16/337015 Web: http://www.med.kuleuven.be/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm ----- Original Message ----- From: "Christian Prinoth" <Christian.Prinoth at epsilonsgr.it> To: <r-help at stat.math.ethz.ch> Sent: Thursday, September 01, 2005 2:00 PM Subject: [R] Newbie help on dim
Hi, if I do
Z<-rnorm(50)
Followed by
Dim(Z)
I get NULL. Is this correct? Shouldn't I get 50 instead?
TIA
Chris
DISCLAIMER:\ L'utilizzo non autorizzato del presente
messagg...{{dropped}}
______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Check out the "dim vs length for vectors" thread: http://finzi.psych.upenn.edu/R/Rhelp02a/archive/50720.html This thread goes through the bug-or-feature discussion which is always entertaining from a socio-R perspective. Also, note "Dim" with a capital D doesn't exist. HTH, Andy
-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch]On Behalf Of Christian Prinoth
Sent: Thursday, September 01, 2005 8:01 AM
To: r-help at stat.math.ethz.ch
Subject: [R] Newbie help on dim
Hi, if I do
Z<-rnorm(50)
Followed by
Dim(Z)
I get NULL. Is this correct? Shouldn't I get 50 instead?
TIA
Chris
DISCLAIMER:\ L'utilizzo non autorizzato del presente messagg...{{dropped}}
______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Christian Prinoth wrote:
Hi, if I do Z<-rnorm(50) Followed by Dim(Z) I get NULL. Is this correct? Shouldn't I get 50 instead?
No, because Z has no dim attribute. ?dim tells you: "For an array (and hence in particular, for a matrix) dim retrieves the dim attribute of the object. It is NULL or a vector of mode integer."
TIA
Chris
DISCLAIMER:\ L'utilizzo non autorizzato del presente messagg...{{dropped}}
______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Yes, PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Uwe Ligges
Should the Value: section of the help page read: For an array (and hence in particular, for a matrix) dim retrieves the dim attribute of the object. It is NULL for a vector of mode integer. NOTE: for not or in the second sentence.
Uwe Ligges wrote:
Christian Prinoth wrote:
Hi, if I do Z<-rnorm(50) Followed by Dim(Z) I get NULL. Is this correct? Shouldn't I get 50 instead?
No, because Z has no dim attribute. ?dim tells you: "For an array (and hence in particular, for a matrix) dim retrieves the dim attribute of the object. It is NULL or a vector of mode integer."
TIA
Chris
DISCLAIMER:\ L'utilizzo non autorizzato del presente messagg...{{dropped}}
______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Yes, PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html Uwe Ligges ______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Chuck Cleland, Ph.D. NDRI, Inc. 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 452-1424 (M, W, F) fax: (917) 438-0894
Chuck Cleland wrote:
Should the Value: section of the help page read: For an array (and hence in particular, for a matrix) dim retrieves the dim attribute of the object. It is NULL for a vector of mode integer. NOTE: for not or in the second sentence.
NO!!! The help page is correct! The *value* is either NULL *or* a vector of mode integer. It is always NULL for any vector without dim attribute (also for character vectors!): x <- "a" dim(x) # NULL dim(x) <- 1 dim(x) # 1 Uwe Ligges
Uwe Ligges wrote:
Christian Prinoth wrote:
Hi, if I do Z<-rnorm(50) Followed by Dim(Z) I get NULL. Is this correct? Shouldn't I get 50 instead?
No, because Z has no dim attribute. ?dim tells you: "For an array (and hence in particular, for a matrix) dim retrieves the dim attribute of the object. It is NULL or a vector of mode integer."
TIA
Chris
DISCLAIMER:\ L'utilizzo non autorizzato del presente
messagg...{{dropped}}
______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Yes, PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html Uwe Ligges ______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
On Thu, 01 Sep 2005 08:25:14 -0400 Chuck Cleland wrote:
Should the Value: section of the help page read: For an array (and hence in particular, for a matrix) dim retrieves the dim attribute of the object. It is NULL for a vector of mode integer.
This statement is true, but less general than It is NULL or a vector of mode integer. hence the latter is surely preferred. Z
NOTE: for not or in the second sentence. Uwe Ligges wrote:
Christian Prinoth wrote:
Hi, if I do Z<-rnorm(50) Followed by Dim(Z) I get NULL. Is this correct? Shouldn't I get 50 instead?
No, because Z has no dim attribute. ?dim tells you: "For an array (and hence in particular, for a matrix) dim retrieves the dim attribute of the object. It is NULL or a vector of mode integer."
TIA Chris DISCLAIMER:\ L'utilizzo non autorizzato del presente
messagg...{{dropped}}>
______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html Yes, PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Uwe Ligges ______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
-- Chuck Cleland, Ph.D. NDRI, Inc. 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 452-1424 (M, W, F) fax: (917) 438-0894
______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Achim Zeileis wrote:
On Thu, 01 Sep 2005 08:25:14 -0400 Chuck Cleland wrote:
Should the Value: section of the help page read: For an array (and hence in particular, for a matrix) dim retrieves the dim attribute of the object. It is NULL for a vector of mode integer.
This statement is true, but less general than It is NULL or a vector of mode integer. hence the latter is surely preferred.
Z, in fact, it is not true: x <- integer(1) dim(x) <- 1 typeof(x) # "integer" dim(x) # 1 Best, Uwe
Z
NOTE: for not or in the second sentence. Uwe Ligges wrote:
Christian Prinoth wrote:
Hi, if I do Z<-rnorm(50) Followed by Dim(Z) I get NULL. Is this correct? Shouldn't I get 50 instead?
No, because Z has no dim attribute. ?dim tells you: "For an array (and hence in particular, for a matrix) dim retrieves the dim attribute of the object. It is NULL or a vector of mode integer."
TIA Chris DISCLAIMER:\ L'utilizzo non autorizzato del presente
messagg...{{dropped}}>
______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html Yes, PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Uwe Ligges ______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
-- Chuck Cleland, Ph.D. NDRI, Inc. 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 452-1424 (M, W, F) fax: (917) 438-0894
______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
On Thu, 01 Sep 2005 14:44:53 +0200 Uwe Ligges wrote:
Achim Zeileis wrote:
On Thu, 01 Sep 2005 08:25:14 -0400 Chuck Cleland wrote:
Should the Value: section of the help page read: For an array (and hence in particular, for a matrix) dim retrieves
the>dim attribute of the object. It is NULL for a vector of mode integer. This statement is true, but less general than It is NULL or a vector of mode integer. hence the latter is surely preferred.
Z, in fact, it is not true: x <- integer(1) dim(x) <- 1 typeof(x) # "integer" dim(x) # 1
But then: is.vector(x) # FALSE but let's not start nitpicking here. Z
Best, Uwe
Z
NOTE: for not or in the second sentence. Uwe Ligges wrote:
Christian Prinoth wrote:
Hi, if I do Z<-rnorm(50) Followed by Dim(Z) I get NULL. Is this correct? Shouldn't I get 50 instead?
No, because Z has no dim attribute. ?dim tells you: "For an array (and hence in particular, for a matrix) dim retrieves the dim attribute of the object. It is NULL or a vector of mode integer."
TIA Chris DISCLAIMER:\ L'utilizzo non autorizzato del presente
messagg...{{dropped}}>
______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html Yes, PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Uwe Ligges ______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
-- Chuck Cleland, Ph.D. NDRI, Inc. 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 452-1424 (M, W, F) fax: (917) 438-0894
______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html