Re: [R] Array element is function of its position in the array

2011-12-30 Thread Asher Meir
Yes this is the solution to my problem. I think there is a small typo in old.index, instead of: k=rep(1:nks, rep(njs*nks, nks))) it should be: k=rep(1:nks, rep(nis*njs, nks))) That is, the k index should be replicated by nis*njs,, not nks*njs. Many thanks Asher On Fri, Dec

Re: [R] Array element is function of its position in the array

2011-12-30 Thread Jean V Adams
Asher Meir asher.m...@gmail.com wrote on 12/30/2011 03:45:48 AM: Yes this is the solution to my problem. I think there is a small typo in old.index, instead of: k=rep(1:nks, rep(njs*nks, nks))) it should be: k=rep(1:nks, rep(nis*njs, nks))) That is, the k index

[R] Array element is function of its position in the array

2011-12-29 Thread Asher Meir
I want to create a new array which selects values from an original array based on a function of the indices. That is: I want to create a new matrix Vnew[i,j,k]=Vold[i,j,ks] where ks is a function of the index elements i,j,k. I want to do this WITHOUT a loop. Call the function ksfunction, and the

Re: [R] Array element is function of its position in the array

2011-12-29 Thread Greg Snow
Sent: Thursday, December 29, 2011 1:58 PM To: r-help@r-project.org Subject: [R] Array element is function of its position in the array I want to create a new array which selects values from an original array based on a function of the indices. That is: I want to create a new matrix Vnew[i,j

Re: [R] Array element is function of its position in the array

2011-12-29 Thread Jean V Adams
Asher Meir wrote on 12/29/2011 02:58:00 PM: I want to create a new array which selects values from an original array based on a function of the indices. That is: I want to create a new matrix Vnew[i,j,k]=Vold[i,j,ks] where ks is a function of the index elements i,j,k. I want to do this

Re: [R] Array element is function of its position in the array

2011-12-29 Thread Jean V Adams
Asher Meir asher.m...@gmail.com wrote on 12/29/2011 04:47:21 PM: Hello Jean. Thank you for your prompt response. I have an economic model. I start out with a list of asset levels 1:nks. For every asset level, a person has nis possible income levels and njs possible expense levels, with