similar to: Applying function to elements of matrices in a list

Displaying 20 results from an estimated 10000 matches similar to: "Applying function to elements of matrices in a list"

2010 Nov 09
3
Row-wise recurive function call
Dear Group, I have a following dataset: > a A B C D 1 22 3 31 40 2 26 31 36 32 3 3 7 49 16 4 24 40 27 26 5 20 45 47 0 6 34 43 11 18 7 48 48 24 2 8 3 16 39 48 9 20 49 7 21 10 17 36 47 10 > dput(a) structure(list(A = c(22L, 26L, 3L, 24L, 20L, 34L, 48L, 3L, 20L, 17L), B = c(3L, 31L, 7L, 40L, 45L, 43L, 48L, 16L, 49L, 36L), C = c(31L, 36L, 49L, 27L, 47L, 11L, 24L,
2012 Nov 12
2
Selected matrices of an array and put into a list
Dear R users, I have an array that has matrices that i want BB[16,5,2:27] i want to put each of the 26 matrices into a List  thanks in advance [[alternative HTML version deleted]]
2010 Nov 17
2
slicing list with matrices
A list contains several matrices. Over all matrices (list elements) I'd like to access one matrix cell: m <- matrix(1:9, nrow=3, dimnames=list(LETTERS[1:3], letters[1:3])) l <- list(m1=m, m2=m*2, m3=m*3) l[[3]] # works l[[3]][1:2, ] # works l[[1:3]][1, 1] # does not work How can I slice all C-c combinations in the list? S?ren -- S?ren Vogel, Dipl.-Psych. (Univ.), PhD-Student, Eawag,
2012 Apr 20
3
Matrix multiplication by multple constants
Dear R helpers Suppose x  <- c(1:3) y  <- matrix(1:12, ncol = 3, nrow = 4) > y      [,1] [,2] [,3] [1,]    1    5    9 [2,]    2    6   10 [3,]    3    7   11 [4,]    4    8   12 I wish to multiply 1st column of y by first element of x i.e. 1, 2nd column of y by 2nd element of x i.e. 2 an so on. Thus the resultant matrix should be like > z      [,1]   [,2]    [,3] [1,]    1   
2011 Aug 23
4
Correlation discrepancy
Dear R list, I have one very elementary question regrading correlation between two variables. x = c(44,46,46,47,45,43,45,44) y = c(44,43,41,41,46,48,44,43) > cov(x, y) [1] -2.428571 However, if I try to calculate the covariance using the formula as covariance = sum((x-mean(x))*(y-mean(y)))/8       # no of of paired obs. = 8 or     covariance = sum(x*y)/8-(mean(x)*mean(y)) gives
2012 Nov 05
2
averaging a list of matrices element wise
Dear all, I have a list of n matrices which all have the same dimension (r x s). What would be a fast/elegant way to calculate the element wise average? So result[1, 1] <- mean(c(raw[[1]][1, 1] , raw[[2]][1, 1], raw[[...]][1, 1], raw[[n]][1, 1])) Here is my attempt. #create a dummy dataset n <- 3 r <- 5 s <- 6 raw <- lapply(seq_len(n), function(i){ matrix(rnorm(r * s), ncol =
2010 Nov 07
3
regular exprs
Dear All, I would appreciate any help with the following: given the vector 'x' x <- c("Ass1", "Ass.s1", "Ass2", "Ass.s2") I would like to pick up the positions where the character string contains "Ass" but does not contain "Ass.s", so for 'x' that would be positions 1 and 3. I guess this could be programmed around
2011 Jan 06
5
How to join matrices of different row length from a list
Hi, I have several matrix in a list, for example: e [[1]] [,1] [,2] [1,] 1 3 [2,] 2 4 [[2]] [,1] [,2] [1,] 1 4 [2,] 2 5 [3,] 3 6 [[3]] [,1] [,2] [1,] 2 1 I would like to join them by column i.e. [,1] [,2] [,3] [,4][,5] [,6] [1,] 1 3 1 4 2 1 [2,] 2 4 2 5 NA NA [3,] NA NA 3 6 NA NA I have tried
2012 Nov 01
3
convert list without same component length to matrix
Hi, I have this lame question. I want to convert a list (each with varies in length) to matrix with same row length by eliminating vectors outside the needed range. For example: l<-list(NULL) l[[1]]=1,2,3.7 l[[2]]=3,4,5,6,3 l[[3]]=4,2,5,7 l[[4]]=2,4,6,3,2 l[[5]]=3,5,7,2 #so say I want to only have 4 rows and 5 column in my matrix (or data.frame) and eliminating the 5th index value in l[[2]]
2011 Sep 19
2
pasting elements of one character vector together
hello, i am familiar with the paste command with which i can paste for exaple: object <- "Hello" paste(object,"World") now i would like to be able to paste all the elements of the same vector together e.g: object <- c("Hello","World") getting as a result also: "Hello World". Does anyone know the solution to this problem? Thank you
2011 Oct 06
3
Duplicate elements of a vector
Hi, let's assume I have the following vector a: 1 5 23 How can I use R to duplicate the elements so that my new vector looks like: 1 1 5 5 23 23 Many thanks, Syrvn -- View this message in context: http://r.789695.n4.nabble.com/Duplicate-elements-of-a-vector-tp3879561p3879561.html Sent from the R help mailing list archive at Nabble.com.
2010 Oct 15
4
split data with missing data condition
Dear all I have data like this: x y [1,] 59.74889 3.1317081 [2,] 38.77629 1.7102589 [3,] NA 2.2312962 [4,] 32.35268 1.3889621 [5,] 74.01394 1.5361227 [6,] 34.82584 1.1665412 [7,] 42.72262 2.7870875 [8,] 70.54999 3.3917257 [9,] 59.37573 2.6763249 [10,] 68.87422 1.9697770 [11,] 19.00898 2.0584415 [12,] 60.27915 2.5365194 [13,] 50.76850
2010 Oct 20
3
combine vectors in an alternating way
I have two vectors min 0.2, 0.3, 0.6, 0.1 max 0.4,0.5,0.7,0.4 Is there a way to combine these two vector so that the values will be taken from the vectors alternating so that I will get a new minmaxminmaxminmax-vector? minmax 0.2,0.4,0.3,0.5,0.6,0.7,0.1,0.4 Any help is much appreciated -- View this message in context:
2011 Jun 25
2
Multivariate normal density in C for R
Does anyone know of a package that uses C code to calculate a multivariate normal density? My goal is to find a faster way to calculate MVN densities and avoid R loops or apply functions, such as when X and mu are N x K matrices, as opposed to vectors, and in this particular case, speed really matters. I would like to be able to use .C or .Call to pass X, mu, Sigma, and N to a C program and have
2010 Oct 15
2
using apply function and storing output
Hi list, I have a 1710x244 matrix of numerical values and I would like to calculate the mean of every group of three consecutive values per column to obtain a new matrix of 570x244. I could get it done using a for loop but how can I do that using apply functions? In addition to this, do I have to initizalize a 570x244 matrix with 0's to store the calculated values or can the output matrix be
2010 Apr 13
1
Lapack, determinant, multivariate normal density, solution to linear system, C language
r-devel list, I have recently written an R package that solves a linear least squares problem, and computes the multivariate normal density function. The bulk of the code is written in C, with interfacing code to the BLAS and Lapack libraries. The motivation here is speed. I ran into a problem computing the determinant of a symmetric matrix in packed storage. Apparently, there are no explicit
2010 Nov 09
2
Calculate Mean from List
Dear all, I have a list of correlation coefficient matrixes. Each matrix represents one date. For example A[[1]] A B C A 1 0.2 0.3 B 0.2 1 0.4 C 0.3 0.4 1 A[[2]] A B C A 1 0.5 0.6 B
2012 Jun 27
2
how to apply the same function to multiple data set
Hi R-users, I'm trying to repeat the same procedure to 1000 data set. I know this is very easy, but I got stuck finding the right and fastest way in running it. IID50=Riidf[1:50,1:1000] #where IID50 is a dataframe consist of 1000 time series(as column) and 50 time scales (row). #what I tried to do: estIID50=rep(NA,1000) for (i in 1:1000) estIID50[i]=pargev(lmom.ub(IID50[1:50,i])) #warning
2012 Feb 12
3
Vector manipulation
Hello, I am stuck with the following problem. Consider the vector: vec <- c(2,4,6,9,10) I now want to use R to manipulate the vector as follows: [1] 2, 4, 2, 6, 2, 9, 2, 10 In words, the first element of the vector should be placed in front of each following number. Which R commands do I need to achieve that? Cheers -- View this message in context:
2010 Oct 21
1
How to check for missing report pages per client
Hi, Not sure how to go about checking for missing report pages per client. See example below; I like to extract client 730040, because page 46103 is missing. client page 730001 46101 730001 46102 730019 46101 730035 46101 730040 46101 730040 46102 730040 46104 730040 46105 730052 46101 730052 46102 730074 46101 730074 46102 730074 46103 I appreciate any help, Pauline