Hi I am not sure if I understand it correctly but maybe a <-seq(0,8, by = sign(8-0)*0.25) b <-seq(8,16, by = sign(16-8)*0.25) const <-runif(1000,50,60) const <- rep(const, 33) d <-exp(-const*a)+exp(-const*b) dim(d) <- c(33,1000)
gives you matrix 33x1000 Maybe you can simplyfy the example to 10 columns and 3 rows and show better what do you want to do with it. Regards Petr > -----Original Message----- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of Andras Farkas > Sent: Wednesday, August 29, 2012 12:25 PM > To: r-help@r-project.org > Subject: [R] Help on not matching object lengths > > Dear All > > I have the following code set up: > Code #1 > a <-matrix(seq(0,8, by = sign(8-0)*0.25)) b <-matrix(seq(8,16, by = > sign(16-8)*0.25)) c <-runif(1000,50,60) d <-exp(-c*a)+exp(-c*b) > > This will give me the obvious error message of lengths not > matching. What I am trying to do here is to have 33 rows x 1000 > columns d values calculated in total. As an eaxmple for visual, this is > what it supposed to look like where d1,d2,d3 and so on up to d1000 are > calculated using the equation and the respective a and b values: > Code #2 > d1 <-runif(33,10,20) > d2 <-runif(33,15,20) > d3 <-runif(33,18,20) > e <-cbind(a,b,d1,d2,d3) > > Next, I would like to generate 33 x 1000 newd values again using newa > and newb values and the same c values, eg: > Code #3 > newa <-matrix(seq(16,24, by = sign(24-16)*0.25)) newb <- > matrix(seq(24,36, by = sign(36-24)*0.25)) c <-runif(1000,50,60) newd <- > exp(-c*newa)+exp(-c*newb) > > Next I would like to sum d(ith) and newd(ith) according to their by > sequence location in the matrices (or whatever type of objects we are > working at this point) based on a and newa . As an example, Code > #1 should generate a of 0,0.25,0.5, and so on with respective d for the > a value 0, 0.25, 0.5, and so on..., while Code #3 should generate newa > of 16,16.25,16.5, and so on with respective newd for the a value 0, > 0.25, 0.5, and so on..... In the next object generated, we should again > have 33 rows x 1000 columns with values, the first row in the first > column would have the result of (d at 0+newd at 16), the second row > would have the result of (d at 0.25+newd at 16.25), while the 3rd row > would have the result of (d at 0.5+newd at 16.5), and so on... > > Last, after the sums established, I would need to find the value/s that > are >x in each column of the latest object, and multiply by 0.25 to > generate a list or row 34 for that matter for each 1000 columns, than > in this row or list I would need to find all values that are >y. > > I apologize for the lengthy question, and all of your help would be > greatly apreciated, > > sincerely, > > andras > [[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.