similar to: x <- 1:2; dim(x) <- 2? A vector or not?

Displaying 20 results from an estimated 30000 matches similar to: "x <- 1:2; dim(x) <- 2? A vector or not?"

2011 Dec 22
2
Indexing multi-dimensional table
I want to take slices of a multi-dimensional table (or array) without knowing the number of dimensions in advance. As a test I tried using (in this example a 3d table): do.call(`[`, list(tbl, x,NULL,NULL)] where I built the list on the fly. It works great as long as I only want the first dimension however when I try a different dimension, say with list(tbl,NULL,x,NULL), I get
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*`,
2005 Jan 21
6
dim vs length for vectors
Hi all, I'm not sure if this is a feature or a bug (and I did read the FAQ and the posting guide, but am still not sure). Some of my students have been complaining and I thought I just might ask: Let K be a vector of length k. If one types dim(K), you get NULL rather than [1] k. Is this logical? Here's the way I explain it (and maybe someone can provide a more accurate
2008 May 02
2
mosaic plot of "vcd" package does not stretch with 2-dimension?
Hi, I like mosaic function of "vcd" package. I have played around it. I have found out that mosaic plot data table is 2-dimension does not stretch when you enlarge a mosaic plot. It is okay when data table is 3 or more dimension. The first one is of 3-dimension table case, and the second one is 2-dimension. With the first plot, you can drag window to enlarge a plot. With the
2004 Aug 20
3
Loss of rownames and colnames
Hi, I am working on some microarray data, and have some problems with writing iterations. In essence, the problem is that objects with three dimensions don't have rownames and colnames. These colnames and rownames would otherwise still be there in 2 dimensional objects. I need to generate multiple iterations of a 2 means-clustering algorithm, and these objects thus probably need 3
2023 Oct 31
1
dim<-() changed in R-devel; no longer removing "dimnames" when doing dim(x) <- dim(x)
Hi Martin, Henrik, I actually like this change. Makes a lot of sense IMO that dim(x) <- dim(x) be a no-op, or, more generally, that foo(x) <- foo(x) be a no-op for any setter/getter combo. FWIW S4Arrays::set_dim() does that too. It also preserves the dimnames if the right value is only adding or dropping outermost (ineffective) dimensions: ??? > x <- array(1:6, dim=c(2,3,1),
2009 Jul 25
1
Determine the dimension-names of an element in an array in R
Hi: How can I extract the dimension-names of a pre-defined element in a multidimensional array in R ? A toy example is provided below: I have a 4-dimensional array with each dimension having certain length. In the below example, "mydatastructure" explains the structure of my data. mydatastructure = array(0, dim=c(length(b),length(z),length(x),length(d)), dimnames=list(b,z,x,d)) where,
2017 Jul 14
3
Making 2 dimensional vector from the 3 dimensional one
Hi All, I want to make a 1 dimension vector from the first two dimensions of a 3 dimension array, so make a 2 dimension vector from a 3-dimension one, with "fusing" (making as.vector) the first two dimensions. It seems to be very easy, but I cannot find the solution, I mean it would very strange, that I would do taking the single 1 dimensional vectors from the 3 dimensional one, make one
2023 Oct 30
2
dim<-() changed in R-devel; no longer removing "dimnames" when doing dim(x) <- dim(x)
>>>>> Henrik Bengtsson >>>>> on Sun, 29 Oct 2023 10:42:19 -0700 writes: > Hello, > the fix of PR18612 > (https://bugs.r-project.org/show_bug.cgi?id=18612) in > r85380 > (https://github.com/wch/r-source/commit/2653cc6203fce4c48874111c75bbccac3ac4e803) > caused a change in `dim<-()`. Specifically, in the past,
2010 Dec 13
1
Qs re writing/reading arrays, dataframes
Hi! I'm just getting started with R (and with the analysis of large datasets in general). I have several beginner-level questions whose answers I have not been able to find, and was hoping one of you would be kind enough to throw me a cluebrick or two. I have a 6-dimensional numeric array (which I'll call myarray) that is "fully named". By this I mean that non-NULL dimnames
2017 Jun 01
2
subletting an array according to dimnames
Hi all, I have a three dimensional array with the corresponding dimension names. I would like to subset the array according to the dimension names. For example, suppose I want to extract the values corresponding to A=20, B=10, C=0. I know I can do: P2[dimnames(P2)$A==20, dimnames(P2)$B==10, dimnames(P2)$C==0] But is there a better way for doing this? Thanks for your help! Hanna >
2003 Oct 28
2
proposal for "strict" versions of subsetting operators
I'd like to propose adding "strict" versions of the subsetting operators "[", "[[", and "$" to the R language. These strict versions would be intended for use in programming rather than in interactive use. They do not perform any form of partial string matching or opportunistic simplification such as dimension dropping by default. They allow more
2010 Nov 27
1
return vector of element names for vector, matrix or array
Just as as.vector() takes a vector, matrix or array and returns a vector in row-major order, I'd like to write a function to take such an object and return the dimension names, pasted with some separator, as a similar vector. Here is something ugly cobbled together to demonstrate what I want: a function to work for any number of dimensions. vecnames <- function(x, sep=':') {
2009 Apr 21
1
n-dimensional vector operations
Let's start with a concrete case of n=3 dimensions. Along dimension x, I have a matrix of 5 vectors (each with ten rows) Along dimension y, I have a matrix of 3 vectors (each with ten rows) Along dimension z, I have a matrix of 2 vectors (each with ten rows) I am trying to write a: function(..., funcp) { } where funcp(...) is an operator which works on n vectors and returns a numeric.
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".
2010 Sep 08
2
Drop single-dimensional array
Hi Simon, thank you for the concise reply. Do you mean the reported behavior of drop() is not a bug? It looks like a borderline bug to me (see below), but I'm not the judge of that. If this is the intended behavior and serves an actual purpose, then that could be explicitly documented in a \note{} on the help page. Such a note would slightly reduce the surprise of users running into this
2006 Feb 27
3
how to use the basis matrix of "ns" in R? really confused by multi-dim spline filtering?
Hi all, Could anybody recommend some easy-to-understand and example based notes/tutorials on how to use cubic splines to do filtering on multi-dimension data? I am confused by the 1-dimensional case, and more confused by multi-dimensional case. I found all the books suddenly become very abstract when it comes to this subject. They don't provide examples in R or Splus at all. Specifically,
2003 Sep 10
4
recording and taking mean of a set of matrices
I'm looking for a good form in which to store matrix results of a simulation. I am doing a simulation study. Each simulation generates some data and then analyzes it. I want to record the results of many simulations and analyze them. Say r has the results of one simulation, and I care about r$coefficients, a vector of coefficients, and r$var, the estimated covariance matrix. I'll do
2017 Jun 02
0
subletting an array according to dimnames
Have you tried P2["20", "10", "0"] ? Jean On Thu, Jun 1, 2017 at 3:10 PM, li li <hannah.hlx at gmail.com> wrote: > Hi all, > I have a three dimensional array with the corresponding dimension names. > I would like to subset the array according to the dimension names. For > example, > suppose I want to extract the values corresponding to A=20,
2023 Oct 29
1
dim<-() changed in R-devel; no longer removing "dimnames" when doing dim(x) <- dim(x)
Hello, the fix of PR18612 (https://bugs.r-project.org/show_bug.cgi?id=18612) in r85380 (https://github.com/wch/r-source/commit/2653cc6203fce4c48874111c75bbccac3ac4e803) caused a change in `dim<-()`. Specifically, in the past, any `dim<-()` assignment would _always_ remove "dimnames" and "names" attributes per help("dim"): The replacement method changes