similar to: "unique" rows in data frame

Displaying 20 results from an estimated 60000 matches similar to: ""unique" rows in data frame"

2012 Nov 11
2
changing the signs in rows or columns in matrices and check them if they are identical
Dear R users, i have this problem with matrices i want to check between two matrices if they are isomorphic i will give an example for what excactly i want   1 -1  1                                 -1  1   1 -1   1  -1                                1  -1  -1   1  1   -1                                1   1  -1 this two matrices are isomorphic beacause if i change the first 2 columns the matrices
2002 Nov 15
1
collapse rows in a matrix
Hi, all, I have a little problem to solve. I'd like to collapse rows which are next to each other but have same value to one row. The following is an example. say x is a data frame like: X1 X2 X3 X4 X5 a 1 0 0 0 1 b 1 0 1 0 1 c 1 0 0 0 1 d 1 0 0 0 1 e 1 0 0 0 1 f 1 1 0 0 1 g 1 1 0 0 1 notice that a, c,d,e are the same. since c,d,e are next to each
2008 Jan 08
2
problem when extacting columns of a data frame in a new data frame
Dear R-users, I would like to create a new data frame composed of 2 columns of another data frame. But it does not give me what I want... > casesCNST[1:10,] case X1 X2 X3 X4 expected 1 A1 0 0 0 0 E 2 A2 0 0 0 1 C 3 A3 0 0 0 2 C 4 A4 0 0 0 3 C 5 A5 0 0 0 4 C 6 A6 0 0 1 0 C 7 A7 0 0 1 1 C 8
2018 May 01
4
issue with model.frame()
A user sent me an example where coxph fails, and the root of the failure is a case where names(mf) is not equal to the term.labels attribute of the formula -- the latter has an extraneous newline. Here is an example that does not use the survival library. # first create a data set with many long names n <- 30? # number of rows for the dummy data set vname <- vector("character",
2011 Jul 16
2
Finding all rows of a matrix equal to vector
Hi everyone, my question might be very trivial, but I could not come up with an answer... I want to find out how often a matrix contains a certain vector as row: x1<-c(1,2,3) x2<-c(1,5,6) x3<-c(7,8,9) A<-matrix(c(rep(x1,5),rep(x2,5),rep(x3,5),rep(x1,5)),nrow=20,ncol=3,byrow=T) How can I find out, how many times x1 is a row of A? Thanks in advance and best regards, Sebastian
2011 Oct 22
1
Data frame manipulation by eliminating rows containing extreme values
Dear All, I have got the limits for removing extreme values for each variables using following function . f=function(x){quantile(x, c(0.25, 0.75),na.rm = TRUE) - matrix(IQR(x,na.rm = TRUE) * c(1.5), nrow = 1) %*% c(-1, 1)} #Example: n <- 100 x1 <- runif(n) x2 <- runif(n) x3 <- x1 + x2 + runif(n)/10 x4 <- x1 + x2 + x3 + runif(n)/10 x5 <-
2005 Apr 22
3
as.data.frame: Error in "names<-.default" (PR#7808)
Hello, I found a potential problem in R 2.1.0 (and R 2.0.1) I expect that > tmp <- FUN(x1, x2, x3, x4) > as.data.frame(tmp) is the same as > as.data.frame(FUN(x1, x2, x3, x4)) since the tmp variable in this case is unnecessary. However, below I will demonstrate that under an odd set of conditions, I can correctly perform as.data.frame(tmp), but not as.data.frame(FUN(x1, x2, x3,
2013 Jan 09
2
Using objects within functions in formulas
Dear all, I'm looking to create a formula within a function to pass to glmer() and I'm having a problem that the following example will illustrate: library(lme4) y1 = rnorm(10) x1 = data.frame(x11=rnorm(10), x12=rnorm(10), x13=rnorm(10)) x1 = data.matrix(x1) w1 = data.frame(w11=sample(1:3,10, replace=TRUE), w12=sample(1:3,10, replace=TRUE), w13=sample(1:3,10, replace=TRUE)) test1 <-
2005 Jun 29
2
quick way to construct formula
Dear R users, I have a data with 1000 variables named "x1", "x2", ..., "x1000", and I want to construct a formula like this format: ~x1+x2+...+x1000+x1:x2+x1:x3+x999:x1000+log(x1)+...+log(x1000) That is: the base variables followed by all interaction terms and all base feature log-transformations. I know I can use several paste functions to construct it. But is
2010 Jun 10
2
Specifying formula inside a function
Hello, How does one specify a formula to lm inside a function (with variable names not known in advance) and have the formula appear explicitly in the output? For example, f <- function(d) { in.model <- sample(c(0,1), ncol(d)-1, replace=T) current.model <- lm(paste(names(d)[1], "~", paste(names(d[2:ncol(d)])[which(in.model == 1)], collapse= "+")), data=d) #***
2012 Sep 12
3
how to create a substraction matrix (subtract a row of every column from the same row in other columns)
Hello I have data like this x1 x2 x3 x4 x5 I want to create a matrix similar to a correlation matrix, but with the difference between the two values, like this x1 x2 x3 x4 x5 x1 x2-x1 x3-x1 x4-x1 x5-x1 x2 x3-x2 x4-x2 x5-x2 x3 x4-x3 x5-x3 x4 x5-x4 x5 Then I
2006 Jul 22
1
ifelse command
Dear: I try to revise the maximum likelihood function below using something constrains. But it seems something wrong with it. Becasue R would not allow me to edit the function like this. It is very appreciate if you can help. function (parameters,y,x1,x2) { p<-parameters[1] alpha1<-parameters[2] beta1<-parameters[3)] delta1<-parameters[4] alpha2<-parameters[5]
2011 Dec 19
2
Summing x1 to x6
Suppose I have the following: x1<-as.vector(rnorm(10)) x2<-as.vector(rnorm(10)) x3<-as.vector(rnorm(10)) x4<-as.vector(rnorm(10)) x5<-as.vector(rnorm(10)) x6<-as.vector(rnorm(10)) x7<-as.vector(rnorm(10)) x8<-as.vector(rnorm(10)) x9<-as.vector(rnorm(10)) x10<-as.vector(rnorm(10)) I would like the mean of x1 to x6 for each vector position. I would do something else
2007 Dec 19
3
array addition
Hi suppose I have two arrays x1,x2 of dimensions a1,b1,c1 and a2,b2,c2 respectively. I want x = x1 "+" x2 with dimensions c(max(a1,a2), max(b1,b2),max (c1,c2)) with x[a,b,c] = x1[a1,b1,c1] + x2[a2,b2,c2] if a <=min(a1,a2) , b<=min (b1,b2), c<=min(c1,c2) and the other bits either x1 or x2 or zero according to whether the coordinates are "in range" for
2010 Jun 04
1
Ignoring missing elements in data.frame()
Hello, I am trying to make a data frame from many elements after running a function which creates many elements, some of which may not end up being real elements due to errors or missing data. For example, I have the following three elements p1s, p2s, and p3s. p9s did not generate the same data as there was an error in the function for some reason. I currently have to delete p9s from the
2012 Sep 17
4
Using paste to create and evaluate a variable expression
Is it possible to use "paste" to write out an expression and evaluate it? Suppose I want to add two vectors X1 and X2, defined as follows: X1 <- 1:6 X2 <- 6:1 If I write the following it looks like what I want but is a character: noquote(paste(paste("X", 1, sep = ""), paste("X", 2, sep = ""), sep = "+")) Is there a way to tell R
2004 Jul 19
10
How to compare X1 = X2 = ... = Xn?
Dear All, I have a data frame with n columns: X1, X2, ., Xn. Now I want to create a new column: if X1 = X2 = . = Xn, the value is 1; Otherwise, the value is 0. How to do that in a quick way instead of doing (n choose 2) comparisons? Thank you, Frank [[alternative HTML version deleted]]
2003 Apr 02
8
lm with an arbitrary number of terms
Hello folks, Any ideas how to do this? data.frame is a data frame with column names "x1",...,"xn" y is a response variable of length dim(data.frame)[1] I want to write a function function(y, data.frame){ lm(y~x1+...+xn) } This would be easy if n was always the same. If n is arbitrary how could I feed the x1+...+xn terms into lm(response~terms)? Thanks Richard -- Dr.
2017 Aug 22
1
boot.stepAIC fails with computed formula
Failed? What was the error message? Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Tue, Aug 22, 2017 at 8:17 AM, Stephen O'hagan <SOhagan at manchester.ac.uk> wrote: > I'm trying to use boot.stepAIC for
2017 Aug 22
0
boot.stepAIC fails with computed formula
The error is "the model fit failed in 50 bootstrap samples Error: non-character argument" Cheers, SOH. On 22/08/2017 17:52, Bert Gunter wrote: > Failed? What was the error message? > > Cheers, > > Bert > > > Bert Gunter > > "The trouble with having an open mind is that people keep coming along > and sticking things into it." > -- Opus (aka