similar to: Random products of rows in a matrix

Displaying 20 results from an estimated 8000 matches similar to: "Random products of rows in a matrix"

2013 Sep 02
3
Product of certain rows in a matrix
Hi, You could try: A<- matrix(unlist(read.table(text=" 1 2 3 4 5 6 7 8 9 9 8 7 6 5 4 3 2 1 ",sep="",header=FALSE)),ncol=3,byrow=FALSE,dimnames=NULL) library(matrixStats) ?res1<-t(sapply(split(as.data.frame(A),as.numeric(gl(nrow(A),2,6))),colProds)) ?res1 #? [,1] [,2] [,3] #1??? 4?? 10?? 18 #2?? 63?? 64?? 63 #3?? 18?? 10??? 4
2013 Apr 08
3
Reshaping a table
Hello all, I have data in the form of a table: X Y1 Y2 0.1 3 2 0.2 2 1 And I would like to transform in the form: X Y 0.1 Y1 0.1 Y1 0.1 Y1 0.1 Y2 0.1 Y2 0.2 Y1 0.2 Y1 0.2 Y2 Any ideas how? Thanks in advance, IOanna [[alternative HTML version deleted]]
2012 Oct 30
4
There is pmin and pmax each taking na.rm, how about psum?
Hi, Please consider the following : x = c(1,3,NA,5) y = c(2,NA,4,1) min(x,y,na.rm=TRUE) # ok [1] 1 max(x,y,na.rm=TRUE) # ok [1] 5 sum(x,y,na.rm=TRUE) # ok [1] 16 pmin(x,y,na.rm=TRUE) # ok [1] 1 3 4 1 pmax(x,y,na.rm=TRUE) # ok [1] 2 3 4 5 psum(x,y,na.rm=TRUE) [1] 3 3 4 6 # expected result Error: could not find function "psum" # actual result
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??
2012 Apr 19
4
Column(row)wise minimum and maximum
Hi, Currently, the "base" has colSums, colMeans. It seems that it would be useful to extend this to also include colMin, colMax (of course, rowMin and rowMax, as well) in order to facilitate faster computations for large vectors (compared to using apply). Has this been considered before? Please forgive me if this has already been discussed before. Thanks, Ravi Ravi Varadhan, Ph.D.
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 Jun 01
1
error about MCA
Hi,all: I want to perform multiple correspondance analysis via MCA{FactoMineR}. The data is in the attachment. My code: dat<-read.delim("e:\\mydata.txt",header=T) MCA(dat,quanti.sup=7,quali.sup=1:6) Error in `[.data.frame`(tab, , i) : undefined columns selected My question: Why does the error happen? Many thanks. Best. -------------- next part -------------- An embedded and
2013 Mar 22
3
Distance calculation
Hi Elisa, I hope this is what you wanted. dat1<-read.csv("peaks.csv",sep=",") #Subset dat2<-dat1[1:5,] res1<-do.call(cbind,lapply(seq_len(nrow(dat2)),function(i) do.call(rbind,lapply(split(rbind(dat2[i,],dat2[-i,]),1:nrow(rbind(dat2[i,],dat2[-i,]))), function(x) {x1<-rbind(dat2[i,],x);
2012 Dec 16
3
averaging X of specific Y (latitude)
Hello I have a table describing butterfly range traits. It is composed of three columns as below Species name range size (X) latitude of range midpoint (Y) There are 11 kinds of butterflies. Each has its range size, and the latitude of each range midpoint ranges from 9 to 19. I would like to have the average range size of every degree of latitude. For example, the average range
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
2013 Apr 18
1
select and do some calculations/manipulations on certain rows based on conditions in R
Hi, May be this helps (Assuming that there are only '0's and '1's in the dataset) dat1<-read.table(text=" ??????? ID X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 1?? 5184??? 0??? 0??? 0??? 0??? 0?? 0?? 0??? 0??? 0??? 1???? 0????? 0????? 0????? 0????? 0????? 0 2?? 6884??? 0??? 0??? 1??? 0??? 0?? 1?? 0??? 0??? 0??? 0???? 0????? 0????? 0????? 0????? 0????? 0 3?
2013 Mar 29
1
multiple plots and looping assistance requested (single plot)
HI Irucka, Please check this: temp<- structure(list(`:Bostoncitydata` = structure(list(Month = c(1L, 2L, 3L, NA), Data1 = c(1.5, 12.3, 11.4, NA), Data2 = c(9.1342, 12.31, 3.5, NA)), .Names = c("Month", "Data1", "Data2"), class = "data.frame", row.names = c(NA, -4L)), `:Chicagocitydata` = structure(list(Month = c(1L, 2L, 3L, 4L, 5L, NA), Data1 = c(1.52,
2013 Apr 19
5
how to subtotal by rows
Dear R-users, I have a dataset as like below, and I want to subtotal the values of rice,wheat and maize by year for each fid. fid      year     rice     wheat      maize ------------------------------------------------ 1        1995      5        NA           NA 1        1995      NA        3           NA 1        1995      NA       NA           2 1        1996      4        NA           NA 1  
2013 Feb 08
2
Count of Histogram Bins using Shingles with lattice
I know that I can get a count of histogram bins in base R with plot=FALSE. However, I'd like to do the same thing with lattice. The problem is that I've set up shingles, and I'd like to get the count within each bin within each shingle. plot=FALSE doesn't seem to do it. [[alternative HTML version deleted]]
2005 Feb 28
1
memory problem with mac os X
Dear list, I am using R.2.0.1 on a G5 biprocessor 2.5GHz with 2Go RAM (Mac OS X 10.3.8). I'm trying to calculate an object of type "dist". I am getting the following memory error : *** malloc: vm_allocate(size=1295929344) failed (error code=3) *** malloc[25960]: error: Can't allocate region Error: cannot allocate vector of size 1265554 Kb When I do a top on the terminal, I
2013 Jan 21
4
compare and count data
Dear r-users,   I have these data below:   I would like to compare each column with a certain value and count how many in each column less than that specified value.    odd column (1,3,5) will compare with 1.61 and even column (2,4,6) will compare with 75 and I would like to count how many for each column.      I tried these below but it give me just one set of data.   critical  <-
2013 Mar 13
4
boxplot
Hi, I try to boxplot following data on the subset of (V1,V3,V5,V7) and (V2,V4,V6,V8) V1 V2 V3 V4 V5 V6 V7 V8 2 4 6 7 12 33 43 53 how can I use boxplot function to plot it? thanks, William
2017 Jun 01
3
Reversing one dimension of an array, in a generalized case
> On 1 Jun 2017, at 22:42, Roy Mendelssohn - NOAA Federal <roy.mendelssohn at noaa.gov> wrote: > > Thanks to all for responses/. There was a question of exactly what was wanted. It is the generalization of the obvious example I gave, > >>>> junk1 <- junk[, rev(seq_len(10), ] > > > so that > > junk[1,1,1 ] = junk1[1,10,1] > junk[1,2,1] =
2013 Apr 20
7
Reshape or Plyr?
H all, I have relative abundance data from >100 sites. This is from acoustic monitoring and usually the data is for 2-3 nights but in some cases my be longer like months or years for each location.. The data output from my management data base is proved by species by night for each location so data frame would look like this below. What I need to do is sum the Survey_time by Spec_Code for
2018 Jan 30
2
sum() returns NA on a long *logical* vector when nb of TRUE values exceeds 2^31
Hi Martin, Henrik, Thanks for the follow up. @Martin: I vote for 2) without *any* hesitation :-) (and uniformity could be restored at some point in the future by having prod(), rowSums(), colSums(), and others align with the behavior of length() and sum()) Cheers, H. On 01/27/2018 03:06 AM, Martin Maechler wrote: >>>>>> Henrik Bengtsson <henrik.bengtsson at gmail.com>