similar to: comparing rows - a possible solution

Displaying 20 results from an estimated 1500 matches similar to: "comparing rows - a possible solution"

2008 Nov 10
2
Make one vector from matrix comparison
Hello R-users, I have a little problem. I compare each row of a matrix with each row of another matrix. testmat1 <- matrix(c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16), nrow=4) testmat2 <- matrix(c(1,2,3,5,5,6,7,8,9,10,11,12,13,14,15,16), nrow=4) Both matrix differs in the last row. Now I create a loop: for (i in (1:4)){ for (j in (1:4)){ b <- (c(setequal(testmat1[j,],testmat2[i,])))
2016 Apr 06
0
R-dvel [robustness Simulation study of 2 sample test on several combination of factors ]
Hi, i think i have figured the purpose of using this index (i-1)*5+j in the previous example that you gave. It is because that i have to consider the outer loop and inner loop also... so the iterative for i need to minus one because it have ran one times simulation already ,then times the number of sizes of inner loop, then plus the iterative of j.... then for the simulation, i think there will
2009 Oct 27
1
New vector based on if/else statement within for loop?
Hello, I am trying to create a new vector (w) that is based on comparing two vectors (P and Z). The compaison is simple (I created a for loop that reassigns w based on if statement), all Z values >= 24 and P values <=1, w=88 else w=77. I am not getting the correct results for w, see example code below. Any thoughts or suggestions on the correct method. Thank you, Doug P <-
2009 Mar 19
2
find the index of the smallest or biggest number in a vetor or data.frame
Dear R experts, How to find out the index of minimum or maxmum number in a vetor or data.frame? For example, a= n price 1 50 -2 100 0 200 -1 300 ...... I want to find out the row which the n is the smallest or largestest and extract the price. Thanks Ted -- View this message in context:
2008 Nov 10
2
as.Data with minutes resolution
Hi, I have a vetor os dates with day and hour:minutes. > time1 <- c("03/08/08-11:00","03/08/08-11:10") > time1 <- as.Date(time1,"%d/%m/%y-%R") > summary(time1) Min. 1st Qu. Median Mean 3rd Qu. Max. "2008-08-03" "2008-08-03" "2008-08-03" "2008-08-03" "2008-08-03"
2007 Jun 21
1
generating a new variable based on results of a by command
I have a matrix with a set of variables one of which is a factor. Using by() I have calculated something about each group (say the sum). Now I want to create a new variable in the original matrix that contains the results of the by() for each observation that is in the corresponding group. For example I have: --------- a <-c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16) b
2011 Aug 08
1
problem in do.call function
Dear all, I am trying to use "do.call", but I don't think I totally understand this function. Here is an simple example. -------------------------------------------- > B <- matrix(c(.5,.1,.2,.3),2,2) > B [,1] [,2] [1,] 0.5 0.2 [2,] 0.1 0.3 > x <- c(.1,.2) > X <- cbind(1,x) > X x [1,] 1 0.1 [2,] 1 0.2 > > lt <-
2005 Apr 21
1
colSums and rowSums with arrays - different classes and dim ?
Hi, I'm using colSums and rowSums to sum the first dimensions of arrays. It works ok but the resulting object is different. See > a3d <- array(rnorm(120, mean=2), dim=c(20,6,1)) > dim(colSums(a3d)) [1] 6 1 > dim(rowSums(a3d)) NULL > class(colSums(a3d)) [1] "matrix" > class(rowSums(a3d)) [1] "numeric" I was expecting rowSums to preserve the array
2009 Nov 30
2
command similar to colSums for rowSums?
Working with an NxMxO sized matrix, currently I can do this in my code: if (max(colSums(array)) >= number) But to get an equivalent result using rowSums, I have to do: for (i in 1:10) { if (max(rowSums(array[,,i])) >= number) } I'm running both in a much larger loop that loops millions of times, so speed and such is quite a big factor for me. Currently, the colSums line uses about
2011 Aug 08
3
on "do.call" function
Dear all, Even though one of R users answered my question, I cannot understand, so I re-ask this question. I am trying to use "do.call", but I don't think I totally understand this function. Here is an simple example. -------------------------------------------- > B <- matrix(c(.5,.1,.2,.3),2,2) > B [,1] [,2] [1,] 0.5 0.2 [2,] 0.1 0.3 > x <- c(.1,.2) >
2012 Oct 29
1
How emulate the function 'order' without with the function 'sort' in R
Ol? amigos tudo bem ? Espero que sim. Sou novo aqui e gostaria muito da ajuda dos senhores para resolver um pequeno probleminha no R. Ent?o, estou com um probleminha com uma atividade que relaciona duas fun??es no R, ? o seguinte: Primeiro atrav?s da fun??o sample ? criado um vetor aleat?trio: x <- sample(1:100, 20) Depois aplico a fun??o sort que tem como objetivo ordenar os elementos em
2009 Feb 13
3
[LLVMdev] Modeling GPU vector registers, again (with my implementation)
It seems to me that LLVM sub-register is not for the following hardware architecture. All instructions of a hardware are vector instructions. All registers contains 4 32-bit FP sub-registers. They are called r0.x, r0.y, r0.z, r0.w. Most instructions write more than one elements in this way: mul r0.xyw, r1, r2 add r0.z, r3, r4 sub r5, r0, r1 Notice that the four elements of r0 are written
2011 May 16
2
conditional rowsums in sapply
Hi all I have a data frame with duplicate columns and i want to remove duplicates by adding rows in each group of duplicates, but have lots of NA's. Data: dfrm <- data.frame(a = 1:4, b= 1:4, cc= 1:4, dd=1:10, ee=1:4) names(dfrm) <- c("a", "a", "b", "b", "b") dfrm[3,2:3]<-NA dfrm a a b b b 1 1 1 1 1 1 2 2 2 2 2 2 3
2012 Mar 07
4
problem with data
Good Afternoon, ?? I have a small problem with the following code. # The x.sub$Time[[1]] 2006-10-31 19:03:01 EST # when put in variable star give-me star<-x.sub$Time[[1]] print(star) print(x.sub$Time[[1]]) [1] 1 36 32 -........ do not understand why -- View this message in context: http://r.789695.n4.nabble.com/problem-with-data-tp4453510p4453510.html Sent from the R help mailing
2007 Nov 09
2
rowSums() and is.integer()
Hi [R-2.6.0, macOSX 10.4.10]. The helppage says that rowSums() and colSums() are equivalent to 'apply' with 'FUN = sum'. But I came across this: > a <- matrix(1:30,5,6) > is.integer(apply(a,1,sum)) [1] TRUE > is.integer(rowSums(a)) [1] FALSE > so rowSums() returns a float. Why is this? -- Robin Hankin Uncertainty Analyst National Oceanography Centre,
2010 Nov 18
2
RowSums Question
I have a question on RowSums. Lets say i have a timeSeries table A B C 1/1/90 NA 1 1 1/2/90 NA 1 1 1/3/90 NA 1 1 1/4/90 NA 1 1 1/5/90 1 1 1 1/6/90 1 1 1 if i use RowSums, i will get 1/5/90 3 1/6/90 3 but i want 1/1/90 2 1/2/90 2 1/3/90 2 1/4/90 2 1/5/90 3 1/6/90 3 I cant
2017 Apr 01
0
mean(x) != mean(rev(x)) different with x <- c(NA, NaN) for some builds
From ?NA Numerical computations using ?NA? will normally result in ?NA?: a possible exception is where ?NaN? is also involved, in which case either might result. and ?NaN Computations involving ?NaN? will return ?NaN? or perhaps ?NA?: which of those two is not guaranteed and may depend on the R platform (since compilers may re-order computations).
2005 Feb 09
4
subset
Dear all, I am trying to extract rows from a data.frame based on the rowSums != 0. I want to preserve rownames in the first column in the subset. Does anyone know how to extract all species that don't have rowSums equal to zero? Here it is: # dataset x <- data.frame( species=c("sp.1","sp.2","sp.3","sp.4"), site1=c(2,3,0,0), site2=c(0,0,0,0),
2011 Aug 23
0
Matrix:::qr.qy and signature(qr = "sparseQR", y = "dgCMatrix")
> sessionInfo() R version 2.13.1 (2011-07-08) Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit) locale: [1] en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] Matrix_0.999375-50 lattice_0.19-30 loaded via a namespace (and not attached): [1] grid_2.13.1
2018 Mar 21
0
Sum of columns of a data frame equal to NA when all the elements are NA
Should not the result be NULL if you have removed the NA with na.rm=TRUE ? B. > On Mar 21, 2018, at 11:44 AM, Stefano Sofia <stefano.sofia at regione.marche.it> wrote: > > Dear list users, > let me ask you this trivial question. I worked on that for a long time, by now. > Suppose to have a data frame with NAs and to sum some columns with rowSums: > > df <-