Petr,
 
thank you very much for the help, I think this will work... It seems like this 
will generate 33 columns and 1000 rows with calculated values, which is fine. I 
also simply used the function x=d + dnext, which generated another 33 columns 
and 1000 rows object with the cell contents added up. In my example moving 
forward from here I will cut down the sample size as you suggested, so using 
the following code we will get a matrix of 10 rows and 5 columns:
 
y <-matrix(1:50,ncol=5)
 
In the next step i would need to find in each row the values that are greater 
then a pre-specified value (any random number can be picked for the purpose of 
presenting the example, lets pick the number 13). I do not actually need to 
know what the value is, I would just need to know the total number of cells in 
a row which contain values of > 13 out of the 5 of them per row, then I need to 
multiply that count by 0.25 for each row and place them in an object , lets 
call that x (this could also be a matrix perhaps with 1 column). 
 
1. So in the 1st row of y in my example this would be 3, 2nd row is 3, third is 
3, 4th is 4, 5th is 4, and so on...
2. let's multiply them with 0.25 to create x : so 1st is 3*0.25, 2nd is 3*0.25, 
3rd is 3*0.25, 4th is 4*0.25, 5th is 4*0.25, and so on....
 
finally, I would need to find the total number of cells in this newly created x 
that are greater then z, lets make that z = 0.8. based on the example data 
matrix of y this final number should be 7.
 
 Would you mind sharing your input on how to accomplish that?
 
thanks,
 
Andras  


________________________________
From: PIKAL Petr <petr.pi...@precheza.cz>

roject.org> 
Sent: Wednesday, August 29, 2012 11:11 AM
Subject: RE: [R] Help on not matching object lengths

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]]
        [[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.

Reply via email to