Hello! I'm not grasping why cbind (in the code below) warns that Warning message: number of rows of result is not a multiple of vector length (arg 2) in: cbind(z, p) when I do sections <- function(length, parts) { p <- 1:parts q <- length %/% parts z <- array(p, dim=c(parts,q)) r <- length %% parts if ( r > 0 ) { p[r+1:length(p)] <- NA z <- cbind(z,p) } z <- na.omit(as.vector(t(z))) } and then sections(32,5) -> a As I see it, rows in result are 5 and the vector length of p (which is 5) is a multiple of 5. kind regards, Paul -- Paul Lemmens NICI, University of Nijmegen ASCII Ribbon Campaign /"\ Montessorilaan 3 (B.01.03) Against HTML Mail \ / NL-6525 HR Nijmegen X The Netherlands / \ Phonenumber +31-24-3612648 Fax +31-24-3616066
Paul Lemmens <P.Lemmens at nici.kun.nl> writes:> Hello! > > I'm not grasping why cbind (in the code below) warns that > > Warning message: > number of rows of result > is not a multiple of vector length (arg 2) in: cbind(z, p) > > when I do > > sections <- function(length, parts) > { > p <- 1:parts > q <- length %/% parts > z <- array(p, dim=c(parts,q)) > > r <- length %% parts > if ( r > 0 ) > { > p[r+1:length(p)] <- NA > z <- cbind(z,p) > } > > z <- na.omit(as.vector(t(z))) > } > > and then > > sections(32,5) -> a > > As I see it, rows in result are 5 and the vector length of p (which is > 5) is a multiple of 5.Did you intend p[(r+1):length(p)] <- NA ? -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
Possibly Parallel Threads
- Numbers that look equal, should be equal, but if() doesn't see as equal (repost with code included)
- is.na(v)<-b (was: Re: Beginner's query - segmentation fault)
- Accessing columns in data.frame using formula
- subset(..., drop=TRUE) doesn't seem to work.
- library(car) Anova() and Error-term in aov()