similar to: How to make a 2-dim array being "interpreted" as an array rather than as a matrix

Displaying 20 results from an estimated 20000 matches similar to: "How to make a 2-dim array being "interpreted" as an array rather than as a matrix"

2012 Jun 02
2
Add a dim to an array
Dear list, I'm trying to add a new dim to a multidimensional array. My array looks like this a1 <- array(1:8, c(2, 2, 2)) dimnames(a1) <- list(A = c("A1", "A2"), B = c("B1", "B2"), D = c("D1", "D2")) I would like to add a new dim 'group' with the value "low".
2006 Feb 15
2
Plotting two 3-dimensional time series in a 3 x 2 plot - alternatives to par(mfrow())
I am trying to plot two 3-dimensional time series in one window (such that there will be 3 rows and 2 columns). For zoo and ts objects the par(mfrow...) option does not work. I can get xyplot to make the plots, but data are on widely different scales in the three dimensions, and xyplot uses the same scale on all y-axis which means that in some dimensions the curves will be almost horizontal lines.
2009 Jul 29
1
Subtract matrices within arrays along indices
I have the following array: 3 dimensional object, one dimension being year. Object is 3*3*3 library(plyr, reshape) a1<-rep(c(2007,2008,2009),9) a2<-c(rep("a",9),rep("b",9),rep("c",9)) a3<-c(rep(c(rep(1,3),rep(2,3),rep(3,3)),3)) a4 <- rnorm(27) A<-data.frame(cbind(comp=a2,val=a3, year=a1, a4)) A1<-melt(A, id=c("year", "comp",
2012 Jun 04
2
Convert 2-dim array to 3-dim array
Hello R-users, I'd like to load data from a CSV-file to a 3-dimensional array. However the default seems to be 2-dimensional. It would also be ok to load the data and then convert it to a 3-dimensional structure. I've been trying: dat = read.csv(filename) myArr = as.array(dat, dim = c(12,100,3)) However, I get an error message: Error in `dimnames<-.data.frame`(`*tmp*`,
2012 Apr 19
3
How to "flatten" a multidimensional array into a dataframe?
Hi, I have a three dimensional array, e.g., my.array = array(0, dim=c(2,3,4), dimnames=list( d1=c("A1","A2"), d2=c("B1","B2","B3"), d3=c("C1","C2","C3","C4")) ) what I would like to get is then a dataframe: d1 d2 d3 value A1 B1 C1 0 A2 B1 C1 0 . . . A2 B3 C4 0 I'm sure there is one function to do
2004 May 04
2
Seeing the definition of a function
Dear all, I was trying to see how the function 'confint' is defined. Doing > confint function (object, parm, level = 0.95, ...) UseMethod("confint") <environment: namespace:stats> does not really enlighten me. How can I get to see the implementation (I guess it should be possible according to the general philosophy of the R project)? Thanks in advance S??ren
2003 Jul 30
6
reverse array indexing
Hi, Suppose I have a multidimensional array: tmp <- array(1:8, c(2,2,2)) is there a function out there that, given a one-dimensional array index, will return the separate indices for each array dimension? for instance, tmp[8] is equivalent to tmp[2,2,2]. I'd like to derive the vector (2,2,2) from the index 8. thanks, Brad Buchsbaum
2007 Aug 07
2
array
Hello, I have some files generated from microarray experiments. I used scan() to read the files, and assigned each file to a unique name with many rows and columns. Now I want to create a array (ArrayA) with unique names, and I can use ArrayA[1,2][[6]] to refer the data in each file. Is there any packages available for array of array? Thanks! [[alternative HTML version deleted]]
2017 Jun 06
2
surprisingly, S4 classes with a "dim" or "dimnames" slot are final (in the Java sense)
Hi, It's nice to be able to define S4 classes with slots that correspond to standard attributes: setClass("A1", slots=c(names="character")) setClass("A2", slots=c(dim="integer")) setClass("A3", slots=c(dimnames="list")) By doing this, one gets a few methods for free: a1 <- new("A1", names=letters[1:3])
2017 Jun 06
1
surprisingly, S4 classes with a "dim" or "dimnames" slot are final (in the Java sense)
I've fixed this and will commit soon. Disregard my dim<-() example; that behaves as expected (the class needs a dim<-() method). Michael On Tue, Jun 6, 2017 at 5:16 AM, Michael Lawrence <michafla at gene.com> wrote: > Thanks for the report. The issue is that one cannot set special attributes > like names, dim, dimnames, etc on S4 objects. I was aready working on this >
2008 Jun 04
2
array of arrays
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 work. Actually I would like to get this array for several values of the number of observations. That
2011 Nov 01
4
building a subscript programatically
Hi, On ocasion, you need to subscript an array that has an arbitrary (ie. not known in advance) number of dimensions. How do you deal with these situations? It appears that it is not possible use a list as an index, for instance this fails: > x <- array(NA, c(2,2,2)) > x[list(TRUE,TRUE,2)] Error in x[list(TRUE, TRUE, 2)] : invalid subscript type 'list' The only way I know is
2009 Oct 28
2
Can I write Nothing to a variable?
Just wondering if it's possible to have an item with no content at all. Here's what I was hoping to do, inside a larger function that acts on a 3-D array. I want to enter, as one of the arguments to the main function, the index over which I'm going to do some action. For example, if the action were to calc a sum, I'd specify a given axis and report the sums along that axis
2012 Dec 11
1
Dispatching on a dgCMatrix does not work.
I represent a graph as an adjacency matrix of class "dgCMatrix" (from the Matrix package). > xx 5 x 5 sparse Matrix of class "dgCMatrix" a b c d e a . 1 1 . . b 1 . 1 . . c 1 1 . 1 1 d . . 1 . 1 e . . 1 1 . To check if the matrix defines and undirected graph, I have made the following functions/methods: is.UG <- function (object) { UseMethod("is.UG") }
2004 Jan 04
1
array problem
Dear all, I define , for n=5 or any integer greater than 0. A<-array((1/2)^n , c(rep(2,n))) then for any i not equal to j, and 1<=i,j<=n, B<-apply(a,c(i,j),sum) now B is a 2 by 2 matrix, I also define another costant 2 by 2 matrix G, How can I change the values of each elements of array A, according the rule that, for example, i=3,j=5,
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
2005 Jun 20
2
Fwd: How to sample from a linear mixed model
Thanks. I wonder if there is a general way of extracting var(u) and var(e), which would be needed to simulate u and e. Clearly, one can get the estimated parameters, but is there a clever way of 'setting up' the matrices?? Best S??ren On 6/19/05, S??ren H??jsgaard <Soren.Hojsgaard at agrsci.dk> wrote: > I would like to draw a sample from a linear mixed model y=Xb+Zu+e which has
2009 Jul 09
1
Creating and Using Objects in R
Dear All, I am not very into object-oriented programming, but I would like to learn the ropes for some R applications. Quoting from the online R language definition (paragraph 5.1) > Consider the following simple example. A point in two-dimensional > Euclidean space can be specified by its Cartesian (x-y) or polar > (r-theta) coordinates. Hence, to store information about the location
2010 Nov 26
3
Calling substitute(expr, list(a=1)) when expr <- expression(a+b+c)
# The result I am after is the result after a substitution in an expression, such as substitute(expression(a+b+c), list(a=1)) expression(1 + b + c) # However, the way I want to do it is for a an expression "stored as a variable" as (expr <- expression(a+b+c)) expression(a + b + c) # a) The following does not work (expr2 <- substitute(expr, list(a=1))) expr # b) - whereas this
2006 Sep 08
2
Multiple matrix multiplication with two 3-dimensional arrays
Hi, I need to do several matrix multiplications with the corresponding matrices forming two 3-dimentional arrays. To illustrate my problem, let's say I have the following 3-dimensional arrays: array1 <- array(1:30,dim=c(3,2,5)) array2 <- array(1:20,dim=c(2,2,5)) I know that I can get what I want with the following computation : result <- array(dim=c(dim(array1)[1],