similar to: Remove rows that have repeated items in a particular column

Displaying 20 results from an estimated 6000 matches similar to: "Remove rows that have repeated items in a particular column"

2010 Mar 16
1
labels gone
Dear R users: I am drawing a graph with the following code: Tau<-seq(0.05,0.95,0.05); Pi <- seq(0.19,0.01,-0.01); par(cex.axis=0.8,ps=9,mar=c(1.5,1,0.5,1), oma=c(1,1,0.2,1) ,tck=-0.01); plot(Tau,Pi, type='l', xlab="Tau",ylab="Pi",col=4); I want to make the graph take as little space as possible. Here I run into two problems. One is that the labels are gone, the
2010 Sep 29
1
sample exponential r.v. by MCMC
Dear R users, I am leaning MCMC sampling, and have a problem while trying to sample exponential r.v.'s via the following code: samp <- MCMCmetrop1R(dexp, theta.init=1, rate=2, mcmc=5000, burnin=500, thin=10, verbose=500, logfun=FALSE) I tried other distribtions such as Normal, Gamma with shape>1, it works perfectly fine. Can someon
2011 Jul 28
1
color of math annotation in legend
Dear useRs, Can someone help me to adjust the color of math annotation in a legend? The following code gives me a black "alpha = 2". x=y=1:100 z=seq(0.5,50,by=0.5) plot(x,y,type='l',col='black') lines(x,z,col='red') legend('topleft',c(expression(paste(alpha," = ", 1)), expression(paste(alpha," = ",
2010 Mar 12
2
Handling repeated values differently
mat is a matrix with X and Y values. > mat X Y [1,] 56 20 [2,] 56 21 [3,] 2 50 [4,] 3 46 [5,] 18 77 [6,] 57 12 [7,] 57 36 [8,] 95 45 [9,] 65 23 [10,] 33 25 [11,] 33 98 [12,] 63 96 [13,] 66 75 [14,] 99 54 [15,] 78 65 [16,] 75 69 [17,] 54 68 [18,] 54 67 [19,] 0 22 [20,] 14 74 [21,] 15 52 [22,] 46 10 [23,] 6 20 [24,] 6 30 As you can see, some of the X values repeat. I wish
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
2009 Jul 02
2
matching rows in matrices
I have a matrix such as this, [,1] [,2] [,3] [1,] 1 1 2 [2,] 2 5 5 and a larger matrix such as this, a b [1,] 1 5 [2,] 2 5 [3,] 4 9 [4,] 5 8 [5,] 7 8 [6,] 7 10 [7,] 9 10 what I want to do is check the number of times the columns in the first matrix appear as rows in the second matrix. So for instance in this example 1,5 and 2,5 appear in both so I'd want
2013 Jan 16
3
matrix manipulation with its rows
Dear R users, I have a question about matrix manipulation with its rows. Plz see the simple example below sample <- list(matrix(1:6, nr=2,nc=3), matrix(7:12, nr=2,nc=3), matrix(13:18,nr=2,nc=3)) > sample [[1]] [,1] [,2] [,3] [1,] 1 3 5 [2,] 2 4 6 [[2]] [,1] [,2] [,3] [1,] 7 9 11 [2,] 8 10 12 [[3]] [,1] [,2] [,3] [1,] 13 15 17 [2,]
2010 Feb 12
3
Code working but too slow, any idea for how to speed it up ?(no loop in it)
Hello my friends, here is a code I wrote with no loops on matrix that is taking too long (2 seconds and I call him 720 times --> 12 minutes): mat1 and mat2 are both matrix with 103 columns and 164 rows. sequence <- matrix(seq(1 : ncol(mat1))) returns <- apply(sequence, 1, function, mat1= mat1, mat2 = mat2, day = 1) function<- function(mat1, mat2, colNb, day){
2005 Nov 03
4
merging dataframes
Dear List, I often have to merge two or more data frames containing unique row names but with some columns (names) common to the two data frames and some columns not common. This toy example will explain the kind of setup I am talking about: mat1 <- as.data.frame(matrix(rnorm(20), nrow = 5)) mat2 <- as.data.frame(matrix(rnorm(20), nrow = 4)) rownames(mat1) <- paste("site",
2010 Jan 29
7
Simple question on replace a matrix row
Hello, I have a matrix mat1 of dim [1,8] and mat2 of dim[30,8], I want to replace the first row of mat2 with mat1, this is what I do: mat2[1,]<-mat1 but it transforms mat2 in a list I don't understand, I want it to stay a matrix... ----- Anna Lippel -- View this message in context: http://n4.nabble.com/Simple-question-on-replace-a-matrix-row-tp1427857p1427857.html Sent from the R help
2011 Aug 04
1
matrix rows to single numeric element
I have a matrix of 5 columns and 64 rows, let's call it "mat1". All values are 1 or 0. I need to take the values of the elements by row and create a single numeric element that can be placed its respective slot in a 64-element list, named "list1". For example, mat1[11,1:5] = 0,1,1,0,1 and I must put 01101, with a length of 1, into the 11th element of list1. I can create
2007 Nov 12
1
update matrix with subset of it where only row names match
I guess this has a simple solution: I have matrix 'mat1' which has row and column names, e.g.: A B C row1 0 0 0 row2 0 0 0 .... rown 0 0 0 I have a another matrix 'mat2', essentially a subset of 'mat1' where the rownames are all in 'mat1' e.g.: B row3 5 row8 6 row54 7 I want to insert the values of matrix mat2 for column B (in reality it could be some or
2009 Apr 16
2
error bars in matplot
Hi, I was trying to get error bars in my matplot. I looked at an earlier thread, and the sample code that I made is: #------------------ library(plotrix) mat1 <- matrix(sample(1:30,10),nrow=5,ncol=2) ses <- matrix(sample(1:3,10,replace=T),nrow=5,ncol=2) vect <- seq(20,100,20) rownames(mat1) <- rownames(ses) <- vect colnames(mat1) <- colnames(ses) <- letters[1:2]
2005 Oct 06
1
Compare two distance matrices
Hi all, I am trying to compare two distance matrices with R. I would like to create a XY plot of these matrices and do some linear regression on it. But, I am a bit new to R, so i have a few questions (I searched in the documentation with no success). The first problem is loading a distance matrix into R. This matrix is the output of a the Phylip program Protdist and lookes like this: 5
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.)
2007 Dec 13
1
Two repeated warnings when runing gam(mgcv) to analyze my dataset?
Dear all, I run the GAMs (generalized additive models) in gam(mgcv) using the following codes. m.gam <-gam(mark~s(x)+s(y)+s(lstday2004)+s(ndvi2004)+s(slope)+s(elevation)+disbinary,family=binomial(logit),data=point) And two repeated warnings appeared. Warnings$B!'(B 1: In gam.fit(G, family = G$family, control = control, gamma = gamma, ... : Algorithm did not converge 2: In gam.fit(G,
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,]
2007 Nov 21
2
matrix elementwise average with NA's
Hello fellow R users, I have a matrix computation that I imagine should be relatively easy to do, however I cannot figure out a nice way to do it. I have two matrices, for example mat1 <- matrix(c(1:5,rep(NA,5), 6:10), nrow=3, byrow=T) mat2 <- matrix(c(2:6, 6:10, rep(NA,5)), nrow=3, byrow=T) I'd like to compute the element-wise average for non-NA entries. Of course (mat1+mat2)/2
2003 Oct 31
2
Summing elements in a list
Hi, Suppose that I have a list where each component is a list of two matrices. I also have a vector of weights. How can I collapse my list of lists into a single list of two matrices where each matrix in the result is the weighted sum of the corresponding matrices. I could use a loop but this is a nested calculation so I was hoping there is a more efficient way to do this. To help clarify,
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]]