similar to: coerce vector into array - change filling sequence

Displaying 20 results from an estimated 2000 matches similar to: "coerce vector into array - change filling sequence"

2013 Apr 14
1
R 3.0.0 memory use
I did some benchmarking of data frame code, and it appears that R 3.0.0 is far worse than earlier versions of R in terms of how many large objects it allocates space for, for data frame operations - creation, subscripting, subscript replacement. For a data frame with n rows, it makes either 2 or 4 extra copies of all of: 8n bytes (e.g. double precision) 24n bytes 32n bytes
2005 Mar 28
2
Generating list of vector coordinates
Hi. Can anyone suggest a simple way to obtain in R a list of vector coordinates of the following form? The code below is Mathematica. In[5]:= Flatten[Table[{i,j,k},{i,3},{j,4},{k,5}], 2] Out[5]= {{1,1,1},{1,1,2},{1,1,3},{1,1,4},{1,1,5},{1,2,1},{1,2,2},{1,2,3},{1 ,2,4},{1,2, 5},{1,3,1},{1,3,2},{1,3,3},{1,3,4},{1,3,5},{1,4,1},{1,4,2},{1,4,3}, {1,4,
2006 Jun 17
2
managing data
Dear mailing list, may some one be kind to help me solve following problem. I am trying to write a code that will combine two tables "x" and "y". The first columns of both tables are unique identification for the rows. The first column of table "X" is a sub set of the first column of "Y". I need to find the matching rows in both tables by looking on their
2012 Jul 20
3
Execute a function
Hi, I would like to evaluate a function, with 3 arguments, for instance, myfunc<-function(a,b,c) { sqrt(a)-exp(b)+4*c } How to execute myfunc(x,y,z), for all x, all y and all z, where x,y,z are vectors? Thank you very much in advance -- View this message in context: http://r.789695.n4.nabble.com/Execute-a-function-tp4637182.html Sent from
2016 Apr 27
3
Same sum, different sets of integers
Hi, Do you have ideas, how to find all those different combinations of integers (>0) that produce as a sum, a certain integer. i.e.: if that sum is 3, the possibilities are c(1,1,1), c(1,2), c(2,1) 4, the possibilities are c(1,1,1,1),c(1,1,2),c(1,2,1),c(2,1,1),c(2,2),c(1,3),c(3,1) etc. Best regards, Atte Tenkanen
2010 Sep 28
2
cochran Q test
Dear all, I am trying to look for a built in function that performs the cochran Q test. that is, cochranq.test(X) where X is a contingency table (maybe a matrix or data.frame). The output will naturally be the test statisitcs, p-value, etc. A quick search on Google gives me the cochran.test in the 'outlier' package, but I had a look at the description of the test and it doesn't look
2010 Dec 20
2
package "arules" - 'transpose' of the transactions
Suppose this is my list of transactions: set.seed(200) tran=random.transactions(100,3) inspect(tran) items transactionID 1 {item80} trans1 2 {item8, item20} trans2 3 {item28} trans3 I want to get the 'transpose' of the data, i.e. transactionID items 1 {trans2} item8 2 {trans2} item20 3 {trans3} item28 4 {trans1} item80 I
2012 Feb 09
2
fill an array by rows
I've dug around but not been able to find anything, am probably missing something obvious. How can I fill a three-dimensional (or higher dimension) array by rows instead of columns. eg new1 <- array(c(1:125), c(5,5,5)) works fine for me but fills it by columns and new2 <- array(c(1:125), c(5,5,5), byrow=TRUE) throws an error. Am I missing something obvious? I also tried
2016 Apr 28
0
Same sum, different sets of integers
This is not the most efficient, but gets the idea across. This is the largest sum I can compute on my laptop with 16GB of memory. If I try to set N to 9, I run out of memory due to the size of the expand.grid. > N <- 8 # value to add up to > # create expand.grid for all combinations and convert to matrix > x <- as.matrix(expand.grid(rep(list(0:(N - 1)), N))) > > # generate
2010 Dec 27
1
aperm() should retain class of input object
aperm() was designed for multidimensional arrays, but is also useful for table objects, particularly with the lattice, vcd and vcdExtra packages. But aperm() was designed and implemented before other related object classes were conceived, and I propose a small tune-up to make it more generally useful. The problem is that aperm() always returns an object of class 'array', which
2009 Feb 24
2
Transpose array
Hi Listers, Is there a way that I can transpose an array... Suppose I have the following array... x<-array(c(1,2,3,4),dim=c(1,2,2)) , , 1 [,1] [,2] [1,] 1 2 , , 2 [,1] [,2] [1,] 3 4 And I would like to get the following result... , , 1 [,1] [1,] 1 [,2] 2 , , 2 [,1] [,2] [1,] 3 [,2] 4 Thanks in advance, Marcio -- View this message in context:
2016 Apr 28
1
Same sum, different sets of integers
I came up with this, using recursion. Short and should work for n greater than 9 :) Peter sumsToN = function(n) { if (n==1) return(1); out = lapply(1:(n-1), function(i) { s1 = sumsToN(n-i); lapply(s1, c, i) }) c(n, unlist(out, recursive = FALSE)); } > sumsToN(4) [[1]] [1] 4 [[2]] [1] 3 1 [[3]] [1] 2 1 1 [[4]] [1] 1 1 1 1 [[5]] [1] 1 2 1 [[6]] [1] 2 2 [[7]] [1] 1 1 2
2008 Jan 24
3
Alternating numbers in rep()
All, I'm trying to obtain a one-liner to generate a certain sequence of alternatign numbers. Consider: > unlist(rep(list(c(1,2), c(3,4)), each = 6)) [1] 1 2 1 2 1 2 1 2 1 2 1 2 3 4 3 4 3 4 3 4 3 4 3 4 I'd like the result to be as above but continue until 38. Of course, I could hardcode this going up to c(37,38), but is there a more elegant way? Thanks! David
2004 Mar 10
3
aperm() and as.list() args to "["
Hi everyone. I'm playing with aperm(): a <- 1:24 dim(a) <- c(2,3,2,2) permutation <- c(1,2,4,3) b <- aperm(a,permutation) So if my understanding is right, a[1,3,2,1] == b[c(1,3,2,1)[permutation] ] but this isn't what I want because the RHS evaluates to a vector, and I am trying to identify a single element of b. How do I modify the RHS to give what I want? Following
2007 Aug 19
2
Does anyone else think this might be worth a warning?!?
Hi, I was *very* surprised by this little trick for new players: mean() only considers its first argument! > mean(1,1,2) [1] 1 > mean(2,1,1) [1] 2 I found this very different behaviour to max(): > max(1,1,2) [1] 2 > max(2,1,1) [1] 2 Perhaps this is the wrong list to ask, but does anyone else think this a little on the interesting side? Is it not possible to detect a
2010 Jul 29
1
Using 'dimname names' in aperm() and apply()
I think that the "dimname names" of tables and arrays could make aperm() and apply() (and probably some other functions) easier to use. (dimname names are, for example, created by table() ) The use would be something like: -- x <-table( from=sample(3,100,rep=T), to=sample(5,100,rep=T)) trans <- x / apply(x,"from",sum) y <- aperm( trans,
2000 Jun 13
1
problem with aperm? (PR#568)
R version 1.0.1 OS RedHat Linux 6.1 In attempting to test for numeric vectors in a data frame, I tried: apply(dataframe,2,is.numeric) and found that it returned FALSE for all vectors whether they were numeric or not. I tracked this to the fact that as.array() was converting the data frame to character vectors, and thought I could solve it by using array(), which preserved the mode of the
2008 Oct 15
1
Forecasting using ARIMAX
Dear R-helpers, I would appreicate if someone can help me on the transfer parameter in ARIMAX and also see what I am doing is correct. I am using ARIMAX with 2 Exogeneous Variables and 10 years data are as follows: DepVar Period, depVar, IndepVar1 Period, indepVar1, IndepVar2 Period, indepVar2 Jan 1998,708,Jan 1998,495,Jan 1998,245.490 Feb 1998,670,Feb 1998,421.25,Feb 1998,288.170 Mar
2007 Aug 31
3
Choosing the optimum lag order of ARIMA model
Dear all R users, I am really struggling to determine the most appropriate lag order of ARIMA model. My understanding is that, as for MA [q] model the auto correlation coeff vanishes after q lag, it says the MA order of a ARIMA model, and for a AR[p] model partial autocorrelation vanishes after p lags it helps to determine the AR lag. And most appropriate model choosed by this argument gives
2010 Nov 05
2
About 5.1 Arrays
Hi folks, (Learning R) 5.1 Arrays http://cran.r-project.org/doc/manuals/R-intro.html#Vectors-and-assignment 1) If continued on previous example (3.1 Intrinsic attributes: mode and length), > z <- 0:9 > dim(z) <- c(3,5,100) Error in dim(z) <- c(3, 5, 100) : dims [product 1500] do not match the length of object [10] failed. 2) Ran; > z <- 0:1499 > dim(z) <-