similar to: run function on subsets of matrix

Displaying 20 results from an estimated 600 matches similar to: "run function on subsets of matrix"

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 Apr 18
3
how to extract options for a function call
Hi, I'm having some difficulties formulating this question. But what I want, is to extract the options associated with a parameter for a function. e.g. method = c("Nelder-Mead", "BFGS", "CG", "L-BFGS-B", "SANN") in the optim function. So I would like to have a vector with c("Nelder-Mead", "BFGS", "CG",
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 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
2009 Jul 16
2
Count the number of occurences in ranges
I got a vector of probabilities like, probs<-c(0.001,0.5,0.02,1,.....) Is there any nice and easy builtin function to get the number of occurences within some specified probabality range. Like with 2% it would be occur[1] = sum(probs[probs>0&probs<0.02]) occur[2] = sum(probs[probs>0.02&probs<0.04]) ... occur[50] =sum(probs[probs>0.09] & probs<1) (If it was a
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:
2018 Jul 02
1
MARGIN in base::unique.matrix() and base::unique.array()
Hi, The man page for base::unique.matrix() and base::unique.array() says that MARGIN is expected to be a single integer. OTOH the code in charge of checking the user supplied MARGIN is: if (length(MARGIN) > ndim || any(MARGIN > ndim)) stop(gettextf("MARGIN = %d is invalid for dim = %d", MARGIN, dx), domain = NA) which doesn't really make sense. As
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
2009 Jul 17
1
get a vector with filenames with a certain extension in a folder
Hi I got a script that works on file with the extension ".qed" that are al located in a folder '~/works/' Is there are R function that will fetch all the filenames from the works subdir, similar to 'ls ~/works/*.qed' Thanks in advance
2011 May 05
1
Looping over graphs in igraph
Hi, I'm trying to do some basic social network analysis with igraph in R, but I'm new to R and haven't been able to find documentation on a couple basic things: I want to run igraph's community detection algorithms on a couple thousand small graphs but don't know how to automate igraph looking at multiple graphs described in a single csv file. My data look like something in
2011 Oct 07
1
Strange behaviour with the Homals Package
Dear R users and experts, I am using Homals to perform categorical PCA on some survey data. The documentation is a bit obscure, however, I followed the examples. X is a matrix with ordinal 1-5 Likert scale entries on 24 questions from about 2500 respondents. So I run X.nlpc = homals(X, rank = 1, level = "ordinal", ndim = 10) to get the first 10 pc's (the number of dimensions is
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
2013 Oct 18
1
crr question‏ in library(cmprsk)
Hi all I do not understand why I am getting the following error message. Can anybody help me with this? Thanks in advance. install.packages("cmprsk") library(cmprsk) result1 <-crr(ftime, fstatus, cov1, failcode=1, cencode=0 ) one.pout1 = predict(result1,cov1,X=cbind(1,one.z1,one.z2)) predict.crr(result1,cov1,X=cbind(1,one.z1,one.z2)) Error: could not find function
2011 Apr 07
3
force output dimension of table function
I have a small annoying problem. When I use the 'table' function on a simple vector it counts the number of occurences. So depending on the values of my input vector the function returns a class of type table with different lengths. Is there an easy way to tell the table function, the values to expect? That is ############# > set.seed(0) > s<-sample(0:5,5,rep=T) > s [1] 5 1
2011 Dec 15
3
From Distance Matrix to 2D coordinates
Dear All, I am struggling with the following problem: I am given a NxN symmetric matrix P ( P[i,i]=0, i=1...N and P[i,j]>0 for i!=j) which stands for the relative distances of N points. I would like use it to get the coordinates of the N points in a 2D plane. Of course, the solution is not unique (given one solution, I can translate or rotate all the points by the same amount and generate
2010 Mar 16
1
Problem with S3 to S4 transition
Hello to everybody I am developing a package using R and have the following problem: I used to work in a mixture of S3 and S4 mechanism environment: as a matter of fact, I used to define my classes (say "DB" for illustration) using the setClass function (with representation field), and I was using the S3 implicit mechanism writing the functions: print.DB and plot.DB. Recently, I
2011 Jul 01
4
Access only part of last dimension of table/matrix
I would like to do some operations inside a function using only one value for the last dimension of a table/matrix: tabfn <- function (dfrm, facvec, YN ="event"){ return( Etbl <- do.call(table, dfrm[ , c(facvec, "event") ]) ) # just want Etbl[,,,"TRUE"] or Etbl[,, "TRUE"] or Etbl[,"TRUE"] }
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: ***