similar to: Product of certain rows in a matrix

Displaying 20 results from an estimated 3000 matches similar to: "Product of certain rows in a matrix"

2013 Sep 04
2
Random products of rows in a matrix
Hello everybody, Without any loop and any package, I would like to return N products of M rows in a matrix A : Today, I managed to do it with a loop : B <- matrix(NA, ncol = ncol(A), nrow = 0) for (i in 1 : N) B <- rbind(B, apply(A[sample(1 : nrow(A), M, replace = T), ], 2, prod)) Do you have a solution ? Thank you in advance ! [[alternative HTML version deleted]]
2013 Sep 27
3
Compare species presence and absence between sites
Dear List, I want to compare the presence and absence of bird species based on the sites in a matrix. The matrix has 5 rows for Island A, B, C, D, and E. It has 100 columns for bird species D001-D100. In each cell of the matrix, the presence-absence of bird species will be recorded as 1 or 0. (For example, if species D001 is found on Island D, the matrix cell of species D001 and Island D
2013 Apr 15
3
Indices of lowest values in matrix
Dear R users,Sorry for such a basic question. I really need to know that how can i pick the indices of 5 lowest values from each row of a matrix with dimensions 12*12??Thank you very much in advance Elisa [[alternative HTML version deleted]]
2013 Feb 13
3
date and matrices
Hi Elisa, Try this: date1<-format(seq.Date(as.Date("1991.1.1",format="%Y.%m.%d"),as.Date("1996.12.31",format="%Y.%m.%d"),by="day"),"%Y.%m.%d") ?length(date1) #[1] 2192 mat1<-matrix(c(.314,.314,.273,.273,.236,.236,.236,.236,.273,.314,.403,.314),ncol=1) res1<-
2013 Mar 18
4
Counting confidence intervals
Hi, I have a 2 x 10000 matrix of confidence intervals. The first column is the lower and the next column is the upper. I want to cont how many times a number say 12 lies in the interval. Can anyone assist? -- Thanks, Jim. [[alternative HTML version deleted]]
2013 Jan 10
1
merging command
HI Eliza, You could do this: set.seed(15) mat1<-matrix(sample(1:800,124*12,replace=TRUE),nrow=12) # smaller dataset #Your codes ?list1<-list() ?for(i in 1:ncol(mat1)){ ? list1[[i]]<-t(apply(mat1,1,function(x) x[i]-x)) ? list1} ?x<-list1?? x<-matrix(unlist(x),nrow=12) x<-abs(x) ?y<-colSums(x, na.rm=FALSE) z<-matrix(y,ncol=10) ?z<-as.dist(z) ?z ?# ?? 1?? 2?? 3?? 4?? 5??
2013 Feb 27
2
matrix multiplication
Hi, Try this: #mat1 is the data res<-do.call(cbind,lapply(seq_len(nrow(mat1)),function(i) {new1<-do.call(rbind,lapply(seq_len(nrow(mat1[-i,])),function(j) {x1<-rbind(mat1[i,],mat1[j,]); x2<-(abs(x1[1,1]-x1[2,1])*abs(x1[1,5]-x1[2,5]))+(abs(x1[1,2]-x1[2,2])*abs(x1[1,6]-x1[2,6]))+(abs(x1[1,3]-x1[2,3])*abs(x1[1,7]-x1[2,7]))+(abs(x1[1,4]-x1[2,4])*abs(x1[1,8]-x1[2,8]))}));new1}))
2012 Nov 27
3
loop command to matrix
Dear UseRs,Extremely sorry for a basic question. I have a matrix of 19 rows and 365 columns. what i want to do is the following...First i want to leave out column number 1 and want to calculate the row wise mean of the remaining columns, which will obviously give me 365 values in one column, and then subtracting these values from the column i left out i.e. col=1 then i want to leave out column 2
2013 Apr 24
2
Distance matrices Combinations
Dear UseRs, MY PROBLEM IS A SMALL PIECE OF A REAL BIG AND A COMPLICATED PROBLEM. IF I DELIBERATE IN A VERY SIMPLE WAY THEN ALL I WANT IS TO PUT ALL THE POSSIBLE COMBINATIONS OF 75 DISTANCE MATRICES (BY TAKING 4 MATRICES, MORE COMMONLY 75C4), in the following equation. t<-as.matrix((MAT1)^2+(MAT2)^2+(MAT3)^2+(MAT4)^2+,upper=T,diag=T)) Then "1215450" values of "t"(one for
2013 Feb 19
1
data format
Hi, Try this: el<- read.csv("el.csv",header=TRUE,sep="\t",stringsAsFactors=FALSE) ?elsplit<- split(el,el$st) ? datetrial<-data.frame(date1=seq.Date(as.Date("1930.1.1",format="%Y.%m.%d"),as.Date("2010.12.31",format="%Y.%m.%d"),by="day")) elsplit1<- lapply(elsplit,function(x)
2012 Dec 12
1
Subset of Data
Hi Arun, I have a question about choosing a subset of data. I have a matrix of 5000 in 3500. I want to choose specific variables such as proc1 to proc1000 and Lab1 to Lab1600 and put it into a new matrix to run some correlation analysis. Since I have 3500 variables, I don't know from what column my lab or procedures start. I really appreciate your help. Thanks.   Best,Farnoosh Sheikhi
2013 Sep 20
3
search species with all absence in a presence-absence matrix
Dear list I have a matrix composed of islandID as rows and speciesID as columns. IslandID: Island A, B, C….O (15 islands in total) SpeciesID: D0001, D0002, D0003….D0100 (100 species in total) The cell of the matrix describes presence (1) or absence (0) of the species in an island. Now I would like to search the species with absence (0) in all the islands (Island A to Island O.)
2013 Sep 26
2
Sums based on values of other matrix
Dear all, I have a big problem: - I got two matrices, A and B - A shows identifies the value of B, however the values of B must be summed - For instance, 1 1 2 2 2 2 1 1 gives matrix a 3 4 2 1 1 1 2 2 gives matrix b Now the result for the value 1 would be 7 4 which are the rowsums of the values of matrix B given that matrix A has the value 1. How can I do this automatically? I
2012 Dec 05
3
data manipulation between vector and matrix
Dear list, I was curious how to subtract a vector from matrix? Say, I have mat <- matrix(1:40, nrow=20, ncol=2) x <-c(1,2) I want, x-mat[1,] and x-mat[2,], and so on... Basically, subtract column elements of x against column elements in mat. But x-mat won't do it. Thanks, Mike [[alternative HTML version deleted]]
2013 Jan 22
6
plot two time series with different length and different starting point in one figure.
Hello, I do have two different time series A and B, they are different in length and starting point. A starts in Jan, 2012 and ends in Dec, 2012 and B starts in March, 2012 and ends in Nov, 2012. How can I plot those two series A and B in the same plot? I.E., from Jan. 2012 - Feb, 2012, it would have one data point from A and from Mar, 2012-Nov, 2012, it would have two data points from A and B,
2013 Apr 12
2
processing matrix equation derived from rows of two matrices
Hi, May be this helps: ?tb[1,]%*%(((val-rep(meansb79[1,],5))^2)/6) #??????? [,1] #[1,] 1.47619 tryvarb<-c(1,2,3,4,4,4,4) ?var(tryvarb) #[1] 1.47619 tb[2,]%*%(((val-rep(meansb79[2,],5))^2)/6) #???????? [,1] #[1,] 1.904762 sapply(seq_len(nrow(tb)),function(i) tb[i,]%*%(((val-rep(meansb79[i,],5))^2/6))) # [1] 1.4761905 1.9047619 1.9047619 1.9047619 1.9047619 2.2857143 1.9047619 # [8] 1.9047619
2013 Jan 03
5
splitting matrices
Dear useRs, i want to split a matrix having 1116rows and 12 columns. i want to split that matrix into 36 small matrices each having 12 columns and 31 rows. The big matrix should be splitted row wise. which means that the first small matrix should copy values which are in first 31 rows and 12 columns of the big matrix. similarly 2nd small matrix should contain values from 32nd to 63rd row of the
2013 Sep 26
1
Grouping Matrix by Columns; OHLC Data
HI, May be this helps: set.seed(24) ?mat1<- matrix(sample(1:60,30*24,replace=TRUE),ncol=24) colnames(mat1)<- rep(c("O","H","L","C"),6) indx<-seq_along(colnames(mat1)) n<- length(unique(colnames(mat1))) ?res<- lapply(split(indx,(indx-1)%%n+1),function(i) mat1[,i]) lapply(res,head,2) #$`1` #????? O? O? O? O? O? O #[1,] 18 56 51 24 24 52 #[2,]
2013 Apr 03
2
Creating data frame from individual files
Dear Group: I have 72 files (.txt). Each file has 2 columns and column 1 is always identical for all 70 files. Each file has 90,799 rows and is standard across all files. I want to create a matrix 40(rows) x 70 columns. I tried : temp = list.files(pattern="*.txt") named.list <- lapply(temp, read.delim) library(data.table) files.matrix <-rbindlist(named.list) >
2010 Aug 15
3
Rows index/colProds
Hi, Is there any function to replace colProds that finds column-wise products of a matrix? Or is there any other function that would give a better solution this problem ? I have a matrix and an array, example: > a GSM1.CEL GSM2.CEL GSM1.CEL 10000_at 1 3 1 10001_at 3 3 3 > b 10000_at