similar to: MARGIN in base::unique.matrix() and base::unique.array()

Displaying 20 results from an estimated 10000 matches similar to: "MARGIN in base::unique.matrix() and base::unique.array()"

2007 Nov 02
0
applying duplicated, unique and match to lists?
Dear R developers, While improving duplicated.array() and friends and developing equivalents for the new ff package for large datasets I came across two questions: 1) is it safe to use duplicated.default(), unique.default() and match() on arbitrary lists? If so, we can speed up duplicated.array and friends considerably by using list() instead of paste(collapse="\r") 2) while
2011 Nov 17
1
inaccuracy in man page for duplicated() + anyDuplicated() not working with MARGIN=0
Hi, In man page for duplicated: Value: ?duplicated()?: For a vector input, a logical vector of the same length as ?x?. For a data frame, a logical vector with one element for each row. For a matrix or array, a logical array with the same dimensions and dimnames. When 'x' is a matrix or array, the returned value is NOT a logical array: > m <-
2005 Nov 23
4
x[1,], x[1,,], x[1,,,], ...
Hi, is there a function in R already doing what I try to do below: # Let 'x' be an array with *any* number of dimensions (>=1). x <- array(1:24, dim=c(2,2,3,2)) ... x <- array(1:24, dim=c(4,3,2)) i <- 2:3 ndim <- length(dim(x)) if (ndim == 1) y <- x[i] else if (ndim == 2) y <- x[i,] else if (ndim == 3) y <- x[i,,] else ... and so on. My current
2011 Mar 27
1
run function on subsets of matrix
I was wondering if it is possible to do the following in a smarter way. I want get the mean value across the columns of a matrix, but I want to do this on subrows of the matrix, given by some vector(same length as the the number of rows). Something like nObs<- 6 nDim <- 4 m <- matrix(rnorm(nObs*nDim),ncol=nDim) fac<-sample(1:(nObs/2),nObs,rep=T) ##loop trough different
2010 Feb 05
1
unique function works funny
I have 3 nested functions, the core function goes like this: listx<-function(x,tox) { xt=table(x) wa=sort(unique(x,fromLast=FALSE)) print(xt) print(wa) ...... return(kk) } listx get called in functionB, and functionB get called in functionC. When I test functionB, the listx function works just fine. When I call functionB from functionC, strange thing happened: My result for xt: 0.07 0.17
2011 Oct 05
1
unique possible bug
Hi, I am trying to read in a rather large list of transactions using the arules library. It seems in the coerce method into the dgCmatrix, it somewhere calls unique. Unique.c throws an error when n > 536870912; however, when 4*n was modified to 2*n in 2004, the overflow protection should have changed from 2^29 to 2^30, right? If so, how would I change it in my copy? Do I have to recompile
2002 May 30
1
problem of compile fortran program
I want to call dll from R but encounter problem in compiling the fortran program. First I try "Rcmd shlib prog.f", it failed and warning: make[1]: `libR.a' is up to date. make: *** No rule to make target `'prog.o', needed by `prog.a'. stop. Then I try to compile it by absoft fortran compiler, it works and produces prog.dll. But when this routine is called in R, it
2004 Aug 19
0
suggesting a new feature for unique()
Dear R-devel, May I suggest that a new feature be added to a couple of unique() methods? Sometimes it's useful to have the indices of the original data that the unique elements come from, so that the original data can be recreated from the unique()ed data. I suggest that an `index' argument be added for unique. Below is a suggested patch against R/src/library/base/R/duplicated.R: ***
2004 May 27
1
R-1.9.0: Error in paste(ncomp, "LV's") : Argument "ncomp" is missing, with no default
Is it just my installation or bug in 1.9.0 ? The same thing works fine in 1.8.1 Best regards, Ryszard # R-1.9.0 library(pls.pcr) nr <- 8; ndim <- 2 x <- matrix(rnorm(nr*ndim), nrow=nr) y <- as.matrix(x[,1]) for (i in 2:ndim) y <- y + x[,i] y <- y + rnorm(length(y)) m <- pls(x,y,validation='CV') # Error in paste(ncomp, "LV's") : Argument
2012 Jul 23
1
duplicated() variation that goes both ways to capture all duplicates
Dear all The trouble with the current duplicated() function in is that it can report duplicates while searching fromFirst _or_ fromLast, but not both ways. Often users will want to identify and extract all the copies of the item that has duplicates, not only the duplicates themselves. To take the example from the man page: > data(iris) > iris[duplicated(iris), ] ##duplicates while
2008 May 08
1
[PATCH] Typo in 'unique' help page (PR#11401)
--- src/library/base/man/unique.Rd | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/src/library/base/man/unique.Rd b/src/library/base/man/unique.Rd index a8397c7..4664a34 100644 --- a/src/library/base/man/unique.Rd +++ b/src/library/base/man/unique.Rd @@ -29,7 +29,7 @@ unique(x, incomparables = FALSE, \dots) \item{x}{a vector or a data frame or an array or
2013 Oct 30
1
unique(1:3,nmax=1) freezes R
Dear all, I was playing around with factor contrasts, and found the argument nmax on function factor. When using nmax=1, R froze completely, and I had to close it from task manager. After some debugging, I found that the problem is actually in unique-function, where the internal unique function is called: .Internal(unique(x, incomparables, fromLast, nmax)) More generally, it looks like
2010 Jan 16
2
Extracing only Unique Rows based on only 1 Column
To Whomever is Interested, I have spent several days searching the web, help files, the R wiki and the archives of this mailing list for a solution to this problem, but nonetheless I apologize in advance if I have missed something obvious. The problem is this; I have a 5-column data frame with about 4.2 million rows, and want to create a new (and hopefully much smaller) data frame that
2007 Oct 29
1
meaning of lenwrk value in adapt function
R-listers, In using the adapt function, I am getting the following warning: Ifail=2, lenwrk was too small. -- fix adapt() ! Check the returned relerr! in: adapt(ndim = 2, lower = lower.limit, upper = upper.limit, functn = pr.set, Would someone explain what the 'lenwrk' value indicates in order to help diagnose this issue. Also, what are the possible codes for Ifail, so I can set
2007 Mar 28
1
warnings on adapt
Hi all I was wondering if someone could help me. I have to estimate some parameters, so I am using the function nlm. Inside this function I have to integrate, hence I am using the function adapt. I don't understand why it is giving the following warnings: At the beginning: Warning: a final empty element has been omitted the part of the args list of 'c' being evaluated was:
2008 Mar 12
1
Problem when calling FORTRAN subroutine (dll)
Hello, I am trying to call a FORTRAN subroutine from R. The Fortran code is @: http://lib.stat.cmu.edu/apstat/206 It performs a bivariate isotonic regression on a rectangular grid (m X n) matrix. I used the g77 compiler and successfully created a dll file and it also loads successfully from R. But somehow the programs fails to run properly. (I do get the correct result when I compile the
2008 Oct 19
1
multivariate integral with ADAPT when the parameter is close to boundary
Dear All, There is one problem I encountered when I used ADAPT to compute some 2-D integral w.r.t beta density. For example, when I try to run the following comments: fun2<-function(theta){return(dbeta(theta[1],0.005,0.005)*dbeta(theta[2],0.005,0.005))} int.fun2<-adapt(ndim=2,lo = c(0,0), up = c(1,1),functn = fun2,eps = 1e-4) It seems it will take very long time to run. Acturally, I
2012 Nov 15
1
bug with mapply() on an S4 object
Hi, Starting with ordinary vectors, so we know what to expect: > mapply(function(x, y) {x * y}, 101:106, rep(1:3, 2)) [1] 101 204 309 104 210 318 > mapply(function(x, y) {x * y}, 101:106, 1:3) [1] 101 204 309 104 210 318 Now with an S4 object: setClass("A", representation(aa="integer")) a <- new("A", aa=101:106) > length(a)
2011 Jan 20
6
Identify duplicate numbers and to increase a value
Hi everybody. I want to identify duplicate numbers and to increase a value of 0.01 for each time that it is duplicated. Example: x=c(1,2,3,5,6,2,8,9,2,2) I want to do this: 1 2 + 0.01 3 5 6 2 + 0.02 8 9 2 + 0.03 2 + 0.04 I am trying to get something like this: 1 2.01 3 5 6 2.02 8 9 2.03 2.04 Actually I just know the way to identify the duplicated numbers rbind(x, duplicated(x) |
2011 Dec 02
1
1.6x speedup for requal() function (in R/src/main/unique.c)
Hi, FWIW: /* Taken from R/src/main/unique.c */ static int requal(SEXP x, int i, SEXP y, int j) { if (i < 0 || j < 0) return 0; if (!ISNAN(REAL(x)[i]) && !ISNAN(REAL(y)[j])) return (REAL(x)[i] == REAL(y)[j]); else if (R_IsNA(REAL(x)[i]) && R_IsNA(REAL(y)[j])) return 1; else if (R_IsNaN(REAL(x)[i]) && R_IsNaN(REAL(y)[j])) return 1;