similar to: matrix dimension and for loop

Displaying 20 results from an estimated 40000 matches similar to: "matrix dimension and for loop"

2008 May 13
2
array dimension changes with assignment
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] 3178 93 > dim(pmin(SNP1,SNP2)) [1] 3178 93
2008 Sep 10
1
Return dimension index from array with n-dimensions
Hi, I have been dealing with some problems finding a fast way of getting to know in what dimension a specific value is located out of an array (like the 'which' function for a vector returns its position). Unable to find anything about this on the internet I wrote a function myself. Could you please comment if such a function already exists, and if not, please feel free to comment the
2013 Jun 07
4
matched samples, dataframe, panel data
I R-helpers #I have a data panel of thousands of firms, by year and industry and #one dummy variable that separates the firms in two categories: 1 if the firm have an auditor; 0 if not #and another variable the represents the firm dimension (total assets in thousand of euros) #I need to create two separated samples with the same number os firms where #one firm in the first have a corresponding
2009 Jul 23
1
dimension trouble for a matrix
Dear R People: I'm having trouble with something that should be very simple. I'm setting up a matrix outside of a loop and writing items into it during the loop. Here is the output: > glob3b("sites.info") dim 27 3 [1] "/raid1/osg-app" Error in xy[i, ] : incorrect number of dimensions Here is the function: > glob3b function(xx) { x.df <-
2002 May 03
2
delete rows
Hello, I would like to know how to delete some rows? Suppose I have a large data frame look something like this: x1 x2 x3 .............. a 1 0.45 b 1 0.41 c 0 0.43 a 1 0.39 d 1 0.40 e 0 0.41 r 1 0.42 a 0 0.46 . . .. I would like to have another data frame which has all
2008 Apr 23
1
combining two (or more) tables by creating another dimension
Dear R community, I wish to combine two tables in one by adding an additional dimension: e.g.: > t1<-as.table(matrix(rnorm(40),nrow=4,ncol=10));rownames(t1)<-c("rowone","rowtwo","rowthree","rowfour") > t1 A B C D E F G H I J rowone
2011 Apr 12
1
How to set the dimension of a matrix correctly?
Hi all, I use kriging to interpolate the precipitation from stations, but the map of this results show lots of stripes. (please see the attachment)I think there's something wrong with the setting of the dimension of this matrix, however, I have no idea how to know or test to see if this setting is correct or not.I've tried to switch the latitude and longitude, but still got the same
2002 Apr 25
2
install a package from CRAN
Hi, I've tried to install package "tseries" on my computer (on Windows) but it doesn't work so far. I have Perl but no compilers (C or Fortran) installed. So could anyone who happens to have them please mail me the binaries? Many thanks in advance, Sonchawan _________________________________________________________________
2004 Aug 31
2
Dimension of apply(X, MARGIN, FUN) when FUN returns a matrix
Dear all, apply(X, MARGIN, FUN, ...) returns an array of dimension c(n, dim(X)[MARGIN]) when FUN returns a vector of length n > 1. Matrices and arrays are also vectors, so if FUN returns a matrix or an array, apply returns an array of dimension c(n, dim(X)[MARGIN]) as above. This is in accordance with the description of apply in the Blue Book, and also how Splus works (at least v6.0). I am
2013 Jun 10
2
please check this
Hi, Try this: which(duplicated(res10Percent)) # [1] 117 125 157 189 213 235 267 275 278 293 301 327 331 335 339 367 369 371 379 #[20] 413 415 417 441 459 461 477 479 505 res10PercentSub1<-subset(res10Percent[which(duplicated(res10Percent)),],dummy==1)? #most of the duplicated are dummy==1 res10PercentSub0<-subset(res10Percent[which(duplicated(res10Percent)),],dummy==0)
2006 Jul 27
2
Vector extracted from a matrix. How can I specify dimensions in as.matrix?
Transpose vector extracted from a matrix Hello, I am doing a recursive analysis that uses every line (vector) of a matrix in a loop. In the model, I need to transpose those vectors that are extracted from a matrix. Using simple vectors (no matrix involved) the transpose function works fine: simplevector <-matrix(1:3,3,1) tsimplevector <-t(simplevector) #transposed dim(simplevector)
2011 Mar 08
1
repeat matrix column within each array third dimension
Hello all, I'm working with a matrix that will have varying dimensions. It will populate an array such that the number of matrix columns will determine the number of 3rd dimension levels of the array. Rows will be the same for both. For this example lets say the array will have 2 columns, but that's not fixed. dim(arr)<-c(dim(mat)[1],2,dim(mat)[2]) I wish to repeat each matrix
2012 Aug 16
3
r data structures
hi, i'm trying to understand r data structures. i see that vectors, matrix, factors and arrays have a "dimension." there seems to be no mention of dimensionality anywhere for lists or dataframes. can i consider lists and frames to be of fixed dimension 2? thanks, jay s
2009 Nov 25
3
questions on the ff package
Hi, I have two questions on using the ff package and wonder if anyone who used ff can share some thoughts. I need to save a matrix as a memory-mapped file and load it back later. To save the matrix, I use mat = matrix(1:20, 4, 5) matFF = ff(mat, dim=dim(mat), filename="~/a.mat", overwrite=TRUE, dimnames = dimnames(mat)) To load it back, I use matFF2 = ff(vmode = "double",
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
2011 Feb 18
6
sort a 3 dimensional array across third dimension ?
I'm attempting to sort a 3 dimensional array that looks like this > x , , 1 [,1] [,2] [1,] 9 9 [2,] 7 9 , , 2 [,1] [,2] [1,] 6 5 [2,] 4 6 , , 3 [,1] [,2] [1,] 2 1 [2,] 3 2 Such that it ends up like this .... > y , , 1 [,1] [,2] [1,] 2 1 [2,] 3 2 , , 2 [,1] [,2] [1,] 6 5 [2,] 4 6 , , 3 [,1] [,2]
2017 Jun 07
3
Adding zeros in each dimension of an array
For a data frame, we can add an additional row or column easily. For example, we can add an additional row of zero and an additional row of column as follows. Is there an easy and similar way to add zeros in each dimension? For example, for array(1:12, dim=c(2,2,3))? Thanks for your help!! Hanna > x <- as.data.frame(matrix(1:20,4,5))> x[5,] <- 0> x[,6] <- 0> x V1 V2
2017 Jun 01
0
Reversing one dimension of an array, in a generalized case
?? > z <- array(1:24,dim=2:4) > all.equal(f(z,3),f2(z,3)) [1] "Attributes: < Component ?dim?: Mean relative difference: 0.4444444 >" [2] "Mean relative difference: 0.6109091" In fact, > dim(f(z,3)) [1] 2 3 4 > dim(f2(z,3)) [1] 3 4 2 Have I made some sort of stupid error here? Or have I misunderstood what was wanted? Cheers, Bert Bert Gunter
2017 Jun 01
5
Reversing one dimension of an array, in a generalized case
Hi All: I have been looking for an elegant way to do the following, but haven't found it, I have never had a good understanding of any of the "apply" functions. A simplified idea is I have an array, say: junk(5, 10, 3) where (5, 10, 3) give the dimension sizes, and I want to reverse the second dimension, so I could do: junk1 <- junk[, rev(seq_len(10), ] but what I am
2017 Jun 01
3
Reversing one dimension of an array, in a generalized case
Here is an alternative approach using apply(). Note that with apply() you are reversing rows or columns not indices of rows or columns so apply(junk, 2, rev) reverses the values in each column not the column indices. We actually need to use rev() on everything but the index we are interested in reversing: f2 <- function(a, wh) { dims <- seq_len(length(dim(a))) dims <-