Re: [R] array - how to create "logical expression" for subset dynamically

2017-03-05 Thread Bert Gunter
A great example of why you need to read and follow the posting guide -- this is a plain text list: NO HTML. Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic st

Re: [R] array - how to create "logical expression" for subset dynamically

2017-03-05 Thread Rolf Turner
On 04/03/17 06:59, exponential wrote: Hi! I've tried on SO, but without success. Maybe you will be able to help. I have the following array (I use 3-dimensional in this example for simplicity, but it can be 3+ dims - 10,11 or more): a <- c('a1', 'a2', 'a3') b <- c('bb', 'bbb') c <- c('C', 'CC',

[R] array - how to create "logical expression" for subset dynamically

2017-03-05 Thread exponential
Hi! I've tried on SO, but without success. Maybe you will be able to help. I have the following array (I use 3-dimensional in this example for simplicity, but it can be 3+ dims - 10,11 or more): a <- c('a1', 'a2', 'a3') b <- c('bb', 'bbb') c <- c('C', 'CC', 'CCC') dimNa <- list('a' =

Re: [R] Array analogue of row and col

2013-04-06 Thread Tony Plate
slice.index() in base On 4/2/2013 9:53 AM, Enrico Bibbona wrote: Great! Thanks a lot, Enrico 2013/4/2 Duncan Murdoch On 02/04/2013 6:36 AM, Enrico Bibbona wrote: Is there any function that extends to multidimentional arrays the functionalities of "row" and "col" which are just defined for

Re: [R] Array analogue of row and col

2013-04-06 Thread Tony Plate
slice.index() in base On 4/2/2013 6:36 AM, Enrico Bibbona wrote: Is there any function that extends to multidimentional arrays the functionalities of "row" and "col" which are just defined for matrices? Thanks, Enrico Bibbona [[alternative HTML version deleted]] ___

Re: [R] Array analogue of row and col

2013-04-02 Thread Enrico Bibbona
Great! Thanks a lot, Enrico 2013/4/2 Duncan Murdoch > On 02/04/2013 6:36 AM, Enrico Bibbona wrote: > >> Is there any function that extends to multidimentional arrays the >> functionalities of "row" and "col" which are just defined for matrices? >> Thanks, Enrico Bibbona >> > > Not as far as I k

Re: [R] Array analogue of row and col

2013-04-02 Thread Duncan Murdoch
On 02/04/2013 6:36 AM, Enrico Bibbona wrote: Is there any function that extends to multidimentional arrays the functionalities of "row" and "col" which are just defined for matrices? Thanks, Enrico Bibbona Not as far as I know, but there are a lot of functions in packages. You could write your

[R] Array analogue of row and col

2013-04-02 Thread Enrico Bibbona
Is there any function that extends to multidimentional arrays the functionalities of "row" and "col" which are just defined for matrices? Thanks, Enrico Bibbona [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://st

Re: [R] array complexity for the MH test

2012-06-25 Thread Richard M. Heiberger
I will try again. 1. If you have 5 groups, and split each in half, then you have 10 groups. If MH is applicable to 5 groups, then it should be applicable to the 10 groups as long as they are disjoint groups. 2. I don't think MH applies to your example because the groups do not have similar behavi

Re: [R] array complexity for the MH test

2012-06-24 Thread David Winsemius
On Jun 24, 2012, at 5:30 AM, francogrex wrote: Thanks for your answer. The answer advertises your VCD package, which by the way is a very nice package that I use and recommend for everyone doing such kind of data analysis. However if you really examine the answer you gave me, it does not

Re: [R] array complexity for the MH test

2012-06-24 Thread francogrex
Thanks for your answer. The answer advertises your VCD package, which by the way is a very nice package that I use and recommend for everyone doing such kind of data analysis. However if you really examine the answer you gave me, it does not really or specifically answer my question. -- View this

Re: [R] array complexity for the MH test

2012-06-20 Thread Richard M. Heiberger
You have a very nice graph of a dose-response function here. library(vcd) library(RColorBrewer) Pen <- array(c(0, 0, 6, 5, 3, 0, 3, 6, 6, 2, 0, 4, 5, 6, 1, 0, 2, 5, 0, 0), dim = c(2, 2, 5), dimnames = list( Delay = c("None", "1.5h"),

[R] array complexity for the MH test

2012-06-20 Thread francogrex
If we take the matel-haenszel test on these data of five 2x2 tables stratified along Penicillin.Levels array(c(0, 0, 6, 5, 3, 0, 3, 6, 6, 2, 0, 4, 5, 6, 1, 0, 2, 5, 0, 0), dim = c(2, 2, 5), dimnames = list( Delay = c("None", "1.5h"),

Re: [R] R - Array data loop selection (Solved)

2012-02-05 Thread David Winsemius
0.1931739 -0.5358076 -0.1318054 [1] 0.4009829 0.8228106 0.9057512 -- View this message in context: http://r.789695.n4.nabble.com/R-Array-data-loop-selection-tp4358282p4359994.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-pr

Re: [R] R - Array data loop selection

2012-02-05 Thread dengyu19901102
for (j in 1:180) { ssta_winter[i,j,k] <- mean(temp[i,j,]) } } } -- View this message in context: http://r.789695.n4.nabble.com/R-Array-data-loop-selection-tp4358282p4360028.html Sent from the R help mailing l

Re: [R] R - Array data loop selection

2012-02-05 Thread dengyu19901102
800321 1.996305 [1] 1.046745 1.335898 1.245474 [1] 0.6113644 0.9268212 1.2416964 [1] 1.220745 1.864054 1.566535 [1] -0.5436361 0.4582486 1.8623419 [1] 0.1931739 -0.5358076 -0.1318054 [1] 0.4009829 0.8228106 0.9057512 -- View this message in context: http://r.789695.n4.nabble.com/R-Array-data-loop

Re: [R] R - Array data loop selection

2012-02-05 Thread David Winsemius
.583 [1] 0.583 [1] 0.583 [1] 0.583 [1] 0.583 [1] 0.583 [1] 0.583 [1] 0.583 [1] 0.583 [1] 0.583 [1] 0.583 [1] 0.583 [1] 0.583 [1] 0.583 -- View this message in context: http://r.789695.n4.nabble.com/R-

[R] R - Array data loop selection

2012-02-04 Thread dengyu19901102
context: http://r.789695.n4.nabble.com/R-Array-data-loop-selection-tp4358282p4358282.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting gu

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

2011-12-30 Thread Jean V Adams
Asher Meir 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 should be repli

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 3

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 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 probabilities

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 Greg Snow
rg] On Behalf Of Asher Meir > 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 in

[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 th

[R] array manipulation

2011-11-04 Thread Simone Salvadei
This worked example, hoping to be helpful, has been requested after a (my) further enquiry about array manipulation. I was looking for a command that is equivalent to repmat() in matlab and that could also be applied to array. (for Matlab users) The Matlal code was the following: 1)temp_u=zeros

[R] array manipulation

2011-11-04 Thread Simone Salvadei
This worked example, hoping to be helpful, has been requested after a (my) further enquiry about array manipulation. I was looking for a command that is equivalent to repmat() in matlab and that could also be applied to array. (for Matlab users) The Matlal code was the following: temp_u=zeros(d

Re: [R] array manipulation

2011-11-03 Thread Patrick Burns
You seem to be looking for 'aperm'. There is a chapter in 'S Poetry' (available on http://www.burns-stat.com) that talks about working with higher dimensional arrays. I don't think any changes need to be made for R. On 02/11/2011 16:16, Simone Salvadei wrote: Hello, I'm at the very beginning o

Re: [R] array manipulation

2011-11-02 Thread David Winsemius
On Nov 2, 2011, at 12:16 PM, Simone Salvadei wrote: Hello, I'm at the very beginning of the learning process of this language. Sorry in advance for the (possible but plausible) stupidity of my question. I would like to find a way to permute the DIMENSIONS of an array. Something that sounds

[R] array manipulation

2011-11-02 Thread Simone Salvadei
Hello, I'm at the very beginning of the learning process of this language. Sorry in advance for the (possible but plausible) stupidity of my question. I would like to find a way to permute the DIMENSIONS of an array. Something that sounds like the function "permute()" in matlab. Given an array C

Re: [R] Array

2011-06-18 Thread Muhammad Rahiz
Understood now. Thanks Duncan. Muhammad On Sat, 18 Jun 2011, Duncan Murdoch wrote: On 11-06-18 10:45 AM, Muhammad Rahiz wrote: Hi, Can someone advise why the followind did not produce the array, given the condition specified? s<- 1 a1<- array(dim=c(1,4)) a2<- array(dim=c(2,4)) arr<- ifelse(s

Re: [R] Array

2011-06-18 Thread jim holtman
Try using 'if': > s <- 1 > a1 <- array(dim=c(1,4)) > a2 <- array(dim=c(2,4)) > arr <- if (s == 1) a1 else a2 > str(arr) logi [1, 1:4] NA NA NA NA > On Sat, Jun 18, 2011 at 10:45 AM, Muhammad Rahiz wrote: > Hi, > Can someone advise why the followind did not produce the array, given the > condi

Re: [R] Array

2011-06-18 Thread Duncan Murdoch
On 11-06-18 10:45 AM, Muhammad Rahiz wrote: Hi, Can someone advise why the followind did not produce the array, given the condition specified? s<- 1 a1<- array(dim=c(1,4)) a2<- array(dim=c(2,4)) arr<- ifelse(s==0,a1,a2) See the Value section of ?ifelse. Duncan Murdoch __

[R] Array

2011-06-18 Thread Muhammad Rahiz
Hi, Can someone advise why the followind did not produce the array, given the condition specified? s <- 1 a1 <- array(dim=c(1,4)) a2 <- array(dim=c(2,4)) arr <- ifelse(s==0,a1,a2) Thanks. Muhammad __ R-help@r-project.org mailing list https://stat.

Re: [R] Array Help

2011-03-07 Thread Richard M. Heiberger
abind works well for this example. a1 <- array(1:18, dim=c(3,3,2)) a2 <- array(101:150, dim=c(5,5,2)) a1b <- abind(a1, array(400, dim=c(2,3,2)), along=1) a1c <- abind(a1b, array(500, dim=c(5,2,2)), along=2) dim(a1c) a1 a2 a1c On Mon, Mar 7, 2011 at 6:54 AM, Usman Munir wrote: > Hi, > > I ha

[R] Array Help

2011-03-07 Thread Usman Munir
Hi, I have two 3 D arrays. Both are of this form array_1<- array[n,n,k] array_2<-array[m,m,k] Lets say n=83 and m=80 Since n>m. I would like to add rows and columns to array_2 to make them equal. I want to keep the size of the third dimension fixed i.e.. k. i.e. if (nrow(array_1)>nrow(array_2))

Re: [R] Array help

2010-11-29 Thread bfhancock
Thank you Joshua!! StatTemps[c(1:7, 22:34), ] that's what i needed! I needed different ranges of rows but it is exactly what i was looking for. Thanks so much!! R can be kind of fun! hehe -- View this message in context: http://r.789695.n4.nabble.com/Array-help-tp3062992p3064907.html Sent fr

Re: [R] Array help

2010-11-29 Thread Joshua Wiley
Hi Brian, I believe there was some miscommunication earlier due to R's array class for objects and the colloquial usage of array (the idea that 'array' is used colloquially is a bit odd, but I digress). In any case, here are some steps I take (certainly not the only ones) when exploring a new dat

Re: [R] Array help

2010-11-29 Thread bfhancock
if you can load the PASWR package and pull up StatTemps you will see what I am talking about. Otherwise I fear that my question will just be confusing. -- View this message in context: http://r.789695.n4.nabble.com/Array-help-tp3062992p3063535.html Sent from the R help mailing list archive at

Re: [R] Array help

2010-11-29 Thread Patrick Burns
Instead of: 7:11&23:34 I think you mean: c(7:11, 23:34) Using '&' for concatenation is not an unreasonable idea, but it is decidedly not what R does. It would be instructive to do: 7:11 & 23:34 at the R prompt to see what you get. On 29/11/2010 03:56, bfhancock wrote: Josh, the d

Re: [R] Array help

2010-11-28 Thread David Winsemius
On Nov 28, 2010, at 10:56 PM, bfhancock wrote: Josh, the data set is called StatTemps and is in the PASWR package. I want to make an array that involves only the 8 a.m. and a separate array that involves only the 9 a.m. so i can get info on the temperatures in those groups. So I still w

Re: [R] Array help

2010-11-28 Thread bfhancock
Josh, the data set is called StatTemps and is in the PASWR package. I want to make an array that involves only the 8 a.m. and a separate array that involves only the 9 a.m. so i can get info on the temperatures in those groups. So I still want it in the format of StatTemps but in two arrays that

Re: [R] Array help

2010-11-28 Thread Joshua Wiley
Hi B, What you need to do is pass a vector with the indices you want to extract. So, you have 1:7 (which expands to 1, 2, 3, ... 7) and 12:34 (which again expands). How would you combine two sets of numbers? c(), the combine or concatenate function. Putting this in action: mya <- array(1:510,

[R] Array help

2010-11-28 Thread bfhancock
Hi! I am learning R and have a question that is probably fairly simple for those of you much more learned than I. I am messing with Arrays and am doing some simple stuff to get the hang of them. I will have a seperate array already pulled up and it will have columns and rows. I figured out th

[R] array of objects

2010-09-13 Thread Alaios
Hello everyone. I would like to create some agents that span over a specific area map.Every agent needs to have its own data structures like one or two matrices and one list. I think that the best way to do this is to create objects and every instance of an object will be used for a single agen

Re: [R] Array Data

2010-08-18 Thread Erik Iverson
On 08/18/2010 06:16 AM, navishkumarb wrote: Hello Can any one let me know how to delete a value from an array and then push back rest of the remaining elements up into an array. Thanks Reproducible examples help us understand what you mean. x <- 1:10 x[-1] Is that what you mean?

[R] Array Data

2010-08-18 Thread navishkumarb
Hello Can any one let me know how to delete a value from an array and then push back rest of the remaining elements up into an array. Thanks -- View this message in context: http://r.789695.n4.nabble.com/Array-Data-tp2329643p2329643.html Sent from the R help mailing list archive at Nabble.c

[R] Array Comparision

2010-08-17 Thread navishkumarb
Hello. Can I just know how to compare two different arrays, but take only the elements from first array (both arrays are multidimensional). Its just opposite of "intersect" option in R. Thanks in advance -- View this message in context: http://r.789695.n4.nabble.com/Array-Comparision-tp23281

Re: [R] array manipulation

2010-04-14 Thread Bert Gunter
-project.org Subject: [R] array manipulation Hello listeRs, I'm trying to make a square radius around a given reference point. So given the following array, how can I manipulate it so that x0 <- array(1,dim=c(5,5)) x0 1 1 1 1 1 1 1 1 1 1 1 1 *1* 1 1 1 1 1 1 1 1 1 1 1 1 becomes into 3

[R] array manipulation

2010-04-14 Thread Muhammad Rahiz
Hello listeRs, I'm trying to make a square radius around a given reference point. So given the following array, how can I manipulate it so that x0 <- array(1,dim=c(5,5)) x0 1 1 1 1 1 1 1 1 1 1 1 1 *1* 1 1 1 1 1 1 1 1 1 1 1 1 becomes into 3 3 3 3 3 3 2 2 2 3 3 2 *1* 2 3 3 2 2 2 3 3 3 3 3 3

Re: [R] array question

2010-02-17 Thread Dennis Murphy
Hi: Alternatively, you could use rollmean in the zoo package: library(zoo) x <- c(2, 4, 5, 5, 6, 4, 5, 2, 1) rollmean(x, 4) [1] 4.00 5.00 5.00 5.00 4.25 3.00 which avoids the NAs that get produced from filter: filter(x, rep(1/4, 4)) Time Series: Start = 1 End = 9 Frequency = 1 [1] NA 4.00 5.00

Re: [R] array question

2010-02-17 Thread Benilton Carvalho
you mean something along the lines of filter(x, rep(1/4, 4)) (which you can combine with na.omit) ? On Wed, Feb 17, 2010 at 5:18 PM, Mohsen Jafarikia wrote: > Hello All: > > If I do have: > > x = (2, 4, 5, 5, 6, 4, 5, 2, 1) > y = (9, 11.5, 12.5, 13, 14, 19, 20, 21, 22) > > I wanted to find a s

[R] array question

2010-02-17 Thread Mohsen Jafarikia
Hello All: If I do have: x = (2, 4, 5, 5, 6, 4, 5, 2, 1) y = (9, 11.5, 12.5, 13, 14, 19, 20, 21, 22) I wanted to find a simple function in R which calculates the averages of X and Y for every 4 unit increase of Y. The results should look like: x = (4, 6, 3) #where (2+ 4+ 5+ 5)/ 4

Re: [R] Array of legend text with math symbols from predefined variables

2009-12-13 Thread Uwe Ligges
See Ligges, U. (2002): R Help Desk: Automation of Mathematical Annotation in Plots. R News 2 (3), 32-34. http://www.r-project.org/doc/Rnews/Rnews_2002-3.pdf Uwe Ligges Koen wrote: Hello, I am trying to include legend text with math symbols from a predefined character variable that is read i

[R] Array of legend text with math symbols from predefined variables

2009-12-11 Thread Koen
Hello, I am trying to include legend text with math symbols from a predefined character variable that is read in from a file.   If there is only one line of text in the legend, the following, although cumbersome, works for me:   > LegendText = " 'U' [infinity], '=10 m/s' "   # (read in from a fil

Re: [R] array to matrix or data.frame

2009-09-27 Thread Daniel Malter
Works a charme; thanks much everybody. Daniel. David Winsemius wrote: > > > On Sep 27, 2009, at 6:33 PM, Daniel Malter wrote: > >> >> Hi, I have an array of dimension 6:6:16. I want to stack the >> 16 >> slices of the array into a matrix or a data frame of dimension >> 6:(6*16=9

Re: [R] array to matrix or data.frame

2009-09-27 Thread Rolf Turner
On 28/09/2009, at 11:51 AM, David Winsemius wrote: apply(x, 2 , I) ***Much*** sexier than my solution! cheers, Rolf Turner ## Attention:\ This e-mail message is privileged and co

Re: [R] array to matrix or data.frame

2009-09-27 Thread Gabor Grothendieck
Try this: matrix(aperm(x, c(1,3,2)), nc = 6) On Sun, Sep 27, 2009 at 6:33 PM, Daniel Malter wrote: > > Hi, I have an array of dimension 6:6:16. I want to stack the 16 > slices of the array into a matrix or a data frame of dimension > 6:(6*16=96) in order to write it to a csv fil

Re: [R] array to matrix or data.frame

2009-09-27 Thread David Winsemius
On Sep 27, 2009, at 6:33 PM, Daniel Malter wrote: Hi, I have an array of dimension 6:6:16. I want to stack the 16 slices of the array into a matrix or a data frame of dimension 6:(6*16=96) in order to write it to a csv file. It seems I cannot get the matrix or data.frame f

[R] array to matrix or data.frame

2009-09-27 Thread Daniel Malter
Hi, I have an array of dimension 6:6:16. I want to stack the 16 slices of the array into a matrix or a data frame of dimension 6:(6*16=96) in order to write it to a csv file. It seems I cannot get the matrix or data.frame functions to put the values from the array in the same order

Re: [R] array slice notation?

2009-08-06 Thread SIES 73
Jaffe Subject: Re: [R] array slice notation? To: r-help@r-project.org Message-ID: <24819883.p...@talk.nabble.com> Content-Type: text/plain; charset=UTF-8 Very nice. Two questions: 1> Do you have any idea of the timing difference, if any, between this and the vector-subscripting metho

Re: [R] array slice notation?

2009-08-05 Thread Søren Højsgaard
-boun...@r-project.org] På vegne af Steve Jaffe [sja...@riskspan.com] Sendt: 5. august 2009 04:45 Til: r-help@r-project.org Emne: Re: [R] array slice notation? Very nice. Two questions: 1> Do you have any idea of the timing difference, if any, between this and the vector-subscripting method? 2

Re: [R] array slice notation?

2009-08-04 Thread Steve Jaffe
Very nice. Two questions: 1> Do you have any idea of the timing difference, if any, between this and the vector-subscripting method? 2> How do you generalize this to select multiple rows eg with indexes given by a vector 'v'? Søren Højsgaard wrote: > > You can do >> A <- HairEyeColor >> do.ca

Re: [R] array slice notation?

2009-08-04 Thread Jim Lemon
Hi Steve, I had the same problem when writing the hierobarp function in plotrix. Have a look at the source code (v2.6-4 in my copy lines 128-133) as the solution seems to work well. Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailm

Re: [R] array slice notation?

2009-08-04 Thread Steve Jaffe
correction -- that would work for a single row, if you want the result to be an array with one fewer dimensions. But in general you get an array of the same dimension you started with (where the first dimension may be length 1). So: dim(slice) <- c(length(v), dim(arr)[-1]) Although you *do* hav

Re: [R] array slice notation?

2009-08-04 Thread Søren Højsgaard
g [r-help-boun...@r-project.org] På vegne af Steve Jaffe [sja...@riskspan.com] Sendt: 4. august 2009 21:23 Til: r-help@r-project.org Emne: [R] array slice notation? Suppose I have an n-diml array A and I want to extract the first "row" -- ie all elements A[1, ...] Interactively if I know 

Re: [R] array slice notation?

2009-08-04 Thread Steve Jaffe
Although you *do* have to re-assign the dimensions, otherwise the result is just a flat vector, ie slice <- A[ outer(v, dim(A)[1]*( 1:prod(dim(A)[-1])-1 ), '+') ] dim(slice) <- dim(A)[-1] Steve Jaffe wrote: > > A[ outer(v, dim(A)[1]*( 1:prod(dim(A)[-1])-1 ), '+') ] > -- View this message i

Re: [R] array slice notation?

2009-08-04 Thread Steve Jaffe
Yes, I was thinking more in terms of mental operations than physical. I think the following works, but it doesn't seem entirely transparent :-) Given array A, and a vector of row indices v (ie 1 <= v <= dim(A)[1]), the slice of rows v is A[ outer(v, dim(A)[1]*( 1:prod(dim(A)[-1])-1 ), '+') ]

Re: [R] array slice notation?

2009-08-04 Thread Steve Lianoglou
Hi, On Aug 4, 2009, at 3:23 PM, Steve Jaffe wrote: Suppose I have an n-diml array A and I want to extract the first "row" -- ie all elements A[1, ...] Interactively if I know 'n' I can write A[1,] with (n-1) commas. How do I do the same more generally, eg in a script? (I can think of

[R] array slice notation?

2009-08-04 Thread Steve Jaffe
Suppose I have an n-diml array A and I want to extract the first "row" -- ie all elements A[1, ...] Interactively if I know 'n' I can write A[1,] with (n-1) commas. How do I do the same more generally, eg in a script? (I can think of doing this by converting A to a vector then extracting t

Re: [R] Array

2009-04-24 Thread Erik Iverson
Bronagh Grimes wrote: Hi there, Just wondering if anyone has any tips for using arrays? I am trying to convert the following SAS code to R: You're probably going to get more useful responses in general if, instead of posting code from SAS to be ported to R, you describe what the cod

Re: [R] Array

2009-04-24 Thread Bronagh Grimes
Thanks for this, will have a look now. Much appreciated, -Original Message- From: Peter Dalgaard [mailto:p.dalga...@biostat.ku.dk] Sent: 24 April 2009 11:40 To: Bronagh Grimes Cc: r-help@r-project.org Subject: Re: [R] Array Bronagh Grimes wrote: > Just wondering if anyone has any t

Re: [R] Array

2009-04-24 Thread Peter Dalgaard
Bronagh Grimes wrote: > Just wondering if anyone has any tips for using arrays? You're presupposing that R works like SAS. It doesn't. This looks like a job for reshape (either Hadley Wickham's package or the built-in function). > I am trying to convert the following SAS code to R: > data A2;

[R] Array

2009-04-24 Thread Bronagh Grimes
Hi there, Just wondering if anyone has any tips for using arrays? I am trying to convert the following SAS code to R: data A2; set A1; by subject_id; retain BX1-BX10i; array b(1:10) BX1-BX10 ; if first.subject_id then do ; do j=1 to 10; b(j) =

Re: [R] array manipulation simple questions

2009-02-23 Thread andrew
On Feb 24, 3:57 pm, jdeisenberg wrote: > Λεωνίδας Μπαντής wrote: > > > 1.   Suppose I have a<-c(1:10)  (or a<-array(c(1:10),dim=c(1,10))) > > > and I want to end up with vector b=[0 0 0 0 0 1 1 1 1 1]. i.e. I want to > > substitute alla elements that are <5 with 0 and >5 with 1. > > I think you

Re: [R] array manipulation simple questions

2009-02-23 Thread Gabor Grothendieck
2009/2/23 Λεωνίδας Μπαντής : > > Hi there, > > I am pretty new to R. Actually I started using it yesterday. I have two > questions: > > 1.   Suppose I have a<-c(1:10)  (or a<-array(c(1:10),dim=c(1,10))) > > and I want to end up with vector b=[0 0 0 0 0 1 1 1 1 1]. i.e. I want to > substitute alla

Re: [R] array manipulation simple questions

2009-02-23 Thread jdeisenberg
Λεωνίδας Μπαντής wrote: > > 1. Suppose I have a<-c(1:10) (or a<-array(c(1:10),dim=c(1,10))) > > and I want to end up with vector b=[0 0 0 0 0 1 1 1 1 1]. i.e. I want to > substitute alla elements that are <5 with 0 and >5 with 1. > I think you mean >=5, not > 5. In that case, try this:

[R] array manipulation simple questions

2009-02-23 Thread Λεωνίδας Μπαντής
  Hi there,   I am pretty new to R. Actually I started using it yesterday. I have two questions:   1.   Suppose I have a<-c(1:10)  (or a<-array(c(1:10),dim=c(1,10)))   and I want to end up with vector b=[0 0 0 0 0 1 1 1 1 1]. i.e. I want to substitute alla elements that are <5 with 0 and >5 with

[R] "array" and "which" functions

2009-02-04 Thread Kumudan
Hi all, I have a data frame of coordinates, "coord". I need an "output" (array) where the number of rows = number of rows in "coord". I am trying to use the "which" function to extract indices from the coordinates with the following code: d=2 nd=length(coord[,1]) output=list(array) ... ... which(

Re: [R] Array Making

2008-12-29 Thread Stavros Macrakis
How about c(rbind(A,B,C)) a<-1:5 > b<-11:15 > c<-21:25 > rbind(a,b,c) [,1] [,2] [,3] [,4] [,5] a12345 b 11 12 13 14 15 c 21 22 23 24 25 > c(rbind(a,b,c)) [1] 1 11 21 2 12 22 3 13 23 4 14 24 5 15 25 On Mon, Dec 29, 2008 at 4:01 AM, ykank wrote:

Re: [R] Array Making

2008-12-29 Thread Greg Snow
t; -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- > project.org] On Behalf Of ykank > Sent: Monday, December 29, 2008 2:01 AM > To: r-help@r-project.org > Subject: [R] Array Making > > > Dear R Users > > Suppose I've certain valu

[R] Array Making

2008-12-29 Thread ykank
Dear R Users Suppose I've certain values of A[1], A[2], A[3] ,A[4].B[1],B[2],B[3]..C[1],C[2],C[3].so on..All A,B,Cs are some numeric constant. I want to make an array which will look like [A[1], B[1], C[1], A[2], B[2], C[2], A[3], B[3] ,C[3] Please suggest me any way to do i

Re: [R] array in version 2.8.0

2008-11-02 Thread David Stoffer
Ok- it works now after flushing my objects. The package Oarray doesn't seem to work under version 2.8.0. I emailed Jonathan about it and he said he won't get to updating it until next year. In the meantime, I was trying to produce a seat-of-the-pants workaround and I probably redefined "as.arra

Re: [R] array in version 2.8.0

2008-11-02 Thread Rolf Turner
On 3/11/2008, at 2:11 PM, David Stoffer wrote: What happened? TIA. In version 2.7.x: (x <- array(1:4, c(2,2))) [,1] [,2] [1,]13 [2,]24 as.array(x) [,1] [,2] [1,]13 [2,]24 In version 2.8.0: (x <- array(1:4, c(2,2))) [,1] [,2] [1,]1

[R] array in version 2.8.0

2008-11-02 Thread David Stoffer
What happened? TIA. In version 2.7.x: > (x <- array(1:4, c(2,2))) [,1] [,2] [1,]13 [2,]24 > as.array(x) [,1] [,2] [1,]13 [2,]24 In version 2.8.0: > (x <- array(1:4, c(2,2))) [,1] [,2] [1,]13 [2,]24 > as.array(x) Error: evaluati

Re: [R] array elements incorrect

2008-06-17 Thread Moshe Olshansky
If ind is the vector of rows of dat you are interested in then dat[ind,] is what you need. --- On Wed, 18/6/08, Paul Adams <[EMAIL PROTECTED]> wrote: > From: Paul Adams <[EMAIL PROTECTED]> > Subject: [R] array elements incorrect > To: r-help@r-project.org > Received:

[R] array elements incorrect

2008-06-17 Thread Paul Adams
Hello everyone, I have a question as to what code should be used if one wanted to subset from a dataframe of 7000rows by 38 columns.For example if you wanted to generate a array of 100 by 38 would you not use the following: Z<-(dat,dim=c(100,38)) where dat is the dataframe of 7000by 38 Whenever I

Re: [R] array of arrays

2008-06-09 Thread Michael Prince
Thanks to all three of you. I used a 4 dimensional array as you suggested. I will have to do a lot of loops with loop variables i and j. I should perhaps save my results from time to time, no ? If I need to save "object1" and "object2", the command should be save(object1,object2,file=paste("save"

Re: [R] array of arrays

2008-06-04 Thread Yasir Kaheil
Is it possible to have one array for bias and one for variance? such as.. biasAr= b1 b2 a1 biasbias a2 biasbias and varAr= b1 b2 a1 var var a2 var var then you can combine the two in a data frame? thanks y Michael Prince wrote: > > Dear R users, > > I

[R] array of arrays

2008-06-04 Thread Michael Prince
Dear R users, I want to calculate the bias and variance of an estimator for several values of two parameters a and b. For example : b1 b2 a1 bias bias variance variance a2 bias bias variance variance Can one do array of arrays ? I have tried and it did not wor

Re: [R] array dimension changes with assignment

2008-05-13 Thread Duncan Murdoch
On 5/13/2008 12:47 AM, Knut M. Wittkowski wrote: Why does the assignment of a 3178x93 object to another 3178x93 object remove the dimension attribute? Your example is not reproducible. When I make one that is reproducible, I don't see the error: > GT <- array(dim = c(6,3178,93)) > dim(GT) [

Re: [R] array dimension changes with assignment

2008-05-13 Thread Jeremiah Rounds
>Why does the assignment of a 3178x93 object to >another 3178x93 object remove >the dimension attribute?>> GT <- array(dim = c(6,nrow(InData),ncol(InSNPs)))>> >dim(GT)>[1] 6 3178 93>> SNP1 <- InSNPs[InData[,"C1"],]>> dim(SNP1)>[1] 3178 > 93>> SNP2 <- InSNPs[InData[,"C2"],]>> dim(SNP2)>[1] 31

[R] array dimension changes with assignment

2008-05-13 Thread Knut M. Wittkowski
Why does the assignment of a 3178x93 object to another 3178x93 object remove the dimension attribute? > GT <- array(dim = c(6,nrow(InData),ncol(InSNPs))) > dim(GT) [1]6 3178 93 > SNP1 <- InSNPs[InData[,"C1"],] > dim(SNP1) [1] 3178 93 > SNP2 <- InSNPs[InData[,"C2"],] > dim(SNP2) [1

[R] Array within an array

2008-04-21 Thread Carla Rebelo
Hello, I need help to build an array within an array, i. e., I have this: tt[,,c(1,2)] , , metadados.class_7.R CS WRC LRA Inicial 1.000 1.000 1.000 Final 0.5974482 0.6095162 0.5866560 Indep 0.4335460 0.4799575 0.4169591 Inicial 0.9925572 0.9925572 0.99

Re: [R] Array arithmetic

2008-03-06 Thread Gang Chen
Thank both of you for the suggestions! Gang On Mar 6, 2008, at 2:12 PM, Henrique Dallazuanna wrote: > Hum you are rigth, I forgot of 'else'. > > On 06/03/2008, Benilton Carvalho <[EMAIL PROTECTED]> wrote: >> no, it won't. >> >> you're doing the right math on the "valid" subset... but you're no

Re: [R] Array arithmetic

2008-03-06 Thread Benilton Carvalho
no, it won't. you're doing the right math on the "valid" subset... but you're not returning the zeros where needed therefore, the whole thing will get recycled to match the dimensions. b On Mar 6, 2008, at 2:03 PM, Henrique Dallazuanna wrote: I think this should work: array(A[abs(B)

Re: [R] Array arithmetic

2008-03-06 Thread Henrique Dallazuanna
Hum you are rigth, I forgot of 'else'. On 06/03/2008, Benilton Carvalho <[EMAIL PROTECTED]> wrote: > no, it won't. > > you're doing the right math on the "valid" subset... but you're not > returning the zeros where needed therefore, the whole thing will > get recycled to match the dimension

Re: [R] Array arithmetic

2008-03-06 Thread Henrique Dallazuanna
I think this should work: array(A[abs(B) > 10e-5]/B[abs(B) > 10e-5], dim=c(L, M, N, P)) On 06/03/2008, Gang Chen <[EMAIL PROTECTED]> wrote: > I have two arrays A and B with dimensions of (L, M, N, P) and (L, M, > N), and I want to do > > for (i in 1:L) { > for (j in 1:M) { > for (k in 1:N) {

Re: [R] Array arithmetic

2008-03-06 Thread Benilton Carvalho
apparently you forgot the "commented, minimal, self-contained, reproducible code" part... L = 10 M = 20 N = 30 P = 40 set.seed(1) A = array(rnorm(L*M*N*P), dim=c(L, M, N, P)) B = array(rnorm(L*M*N), dim=c(L, M, N)) B[sample(100, 10)] = 0 C = array(0, dim=c(L, M, N, P)) for (i in 1:L) { for (j i

[R] Array arithmetic

2008-03-06 Thread Gang Chen
I have two arrays A and B with dimensions of (L, M, N, P) and (L, M, N), and I want to do for (i in 1:L) { for (j in 1:M) { for (k in 1:N) { if (abs(B[i, j, k]) > 10e-5) C[i, j, k,] <- A[i, j, k,]/B[i, j, k] else C[i, j, k,] <- 0 } } } How can I get C more efficiently than looping? Thanks

[R] passing R array to Fortran subroutine

2008-02-14 Thread Timothy W. Hilton
Hello, I am trying to run a piece of Fortran code from R, and I am having trouble passing an array to the fortran subroutine. My attempts to pass an array into the fortran are producing memory errors, and I cannot find an example that performs the task. I have looked at "Writing R Extensions

  1   2   >