similar to: using the "apply" method for functions with multiple inputs

Displaying 20 results from an estimated 1800 matches similar to: "using the "apply" method for functions with multiple inputs"

2010 Nov 11
3
Evaluation puzzle
The survexp function can fail when called from another function. The "why" of this has me baffled, however. Here is a simple test case, using a very stripped down version of survexp: survexp.test <- function(formula, data, weights, subset, na.action, rmap, times, cohort=TRUE, conditional=FALSE, ratetable=survexp.us, scale=1, npoints, se.fit,
2003 Mar 02
1
model.frame.default problem in function definition
Could someone point me in the right direction for the following issue: A function is defined as follows: tfun <- function(dat) { fmla <- as.formula("y~x+z") dat2 <- dat mdl <- lm(fmla,dat2) mdl <- step(mdl) } Then the following code dat <- data.frame(x=1:10,z=1:10,y=(1:10)^2+10*(1:10)) tfun(dat) generates the output Start: AIC= 43.67
1997 Jun 06
1
R-beta: nlm
I am trying to use the function "nlm" to find the mle. I want to use a generic function for the likelihood which would require me to use both the parameters and the data as arguments. But nlm requires the function to have only the parameters as arguments for this function (see example below). > testfun <- function(x,y) sum((x-y)^2) # x - parameters, y - data >
2007 Apr 08
1
buglet in terms calculations
Hi, Vince and I have noticed a problem with non-syntactic names in data frames and some modeling code (but not all modeling code). The following, while almost surely as documented could be a bit more helpful: m = matrix(rnorm(100), nc=10) colnames(m) = paste(1:10, letters[1:10], sep="_") d = data.frame(m, check.names=FALSE) f = formula(`1_a` ~ ., data=d) tm =
2012 Jun 25
2
Fast Kendall's Tau
Hello. Has any further action been taken regarding implementing David Simcha's fast Kendall tau code (now found in the package pcaPP as cor.fk) into R-base? It is literally hundreds of times faster, although I am uncertain as to whether he wrote code for testing the significance of the parameter. The last mention I have seen of this was in 2010
2007 Jul 16
2
Error while fitting Partial Proportional Odds model using vglm
Dear R developers: I am trying to fit a PPO model using vglm from the library VGAM, and get an error while executing the code. Here is the data, code, and error: Data: first row is the column names. a = age, and 1,2,3, 4 and 5 are condition grades. a 1 2 3 4 5 1 1 0 0 0 0 2 84 2 7 10 2 3 16 0 6 6 2 4 13 0 3 4 0 5 0 0 0 1 0 Library(VGAM)
2011 Mar 12
1
Passing a character argument onto a function
I am a new R user and am beginning to employ function creation in my statistical work. I am running into a problem when I want to pass on a character (text) to the function as an argument. I have a simple example below to demonstrate this problem. I cannot seem to find a fix in my R book or in the blog posts. I'm sure this has been covered before but my newbie status means I lack the R
2011 Apr 20
2
'Record' row values every time the binary value in a collumn changes
My question is twofold. Part 1: My data looks like this: (example set, real data has 2*10^6 rows) binary<-c(1,1,1,0,0,0,1,1,1,0,0) Chromosome<-c(1,1,1,1,1,1,2,2,2,2,2) start<-c(12,17,18,20,25,36,12,15,16,17,19) Table<-cbind(Chromosome,start,binary) Chromosome start binary [1,] 1 12 1 [2,] 1 17 1 [3,] 1 18 1 [4,] 1
2010 Nov 24
0
4. Rexcel (Luis Felipe Parra)-how to run a code from excel
Hi Louis, It's simple to run a r script from the excel spreadsheet. Just write your code, source("C:\\Quantil Aplicativos\\Genercauca\\BackwardSelectionNC.r"), into a cell of a workingsheet. Then right-click the cell and select "run code" in the pop-up menu. Hope this will help you. Best, Bernard -----????----- ???: r-help-bounces at r-project.org [mailto:r-help-bounces
2012 Mar 10
1
Draw values from multiple data sets as inputs to a Monte-Carlo function; then apply across entire matrix
Hi all, I am trying to implement a Monte-Carlo simulation for each cell in a spatial matrix (using mcd2 package) . I have figured out how to conduct the simulation using data from a single location (where I manually input distribution parameters into the R code), but am having trouble (a) adjusting the code to pull input variables from my various data sets and then (b) applying the entire
2006 May 14
2
apply, apply speed vs. traditional looping mechanisms
Can someone tell me why apply (and apply) are faster in performing repeated operations than a for (or do) loop? I am looking for a technical explanation. Thanks, John John Sorkin M.D., Ph.D. Chief, Biostatistics and Informatics Baltimore VA Medical Center GRECC and University of Maryland School of Medicine Claude Pepper OAIC University of Maryland School of Medicine Division of Gerontology
2013 Mar 27
1
Passing arguments between apply and l(s)apply functions vs. nested for loop
Hi R community, I have a question concerning passing arguments between apply and lapply? Or maybe, once my problem is explained, the question is really about how to best transform my nested for loops into list/matrix operations; I am just beginning this transformation away from nested for loops, so I beg of you to have some lenience regarding my ignorance. Part I: I used a set of nested for
2012 Dec 12
2
using 'apply' to apply princomp to an array of datasets
Hi everyone, Suppose I have a 3D array of datasets, where say dimension 1 corresponds to cases, dimension 2 to datasets, and dimension 3 to observations within a dataset. As an example, suppose I do the following: > x <- sample(1:20, 48, replace=TRUE) > datasets <- array(x, dim=c(4,3,2)) Here, for each j=1,2,3, I'd like to think of datasets[,j,] as a single data matrix with
2010 Aug 06
3
How to apply apply?!
guRus I have say a dataframe, d and I wish to do the following: 1) For each row, I want to take one particular value of the row and multiply it by 2. How do I do it. Say the data frame is as below: OPEN HIGH LOW CLOSE 1931.2 1931.2 1931.2 1931.2 0 0 0 999.05 0 0 0 1052.5 0 0 0 987.8 0 0 0 925.6 0 0 0 866 0 0 0 1400.2 0 0 0 754.5 0 0 0 702.6 0 0 0 653.25 0 0 0 348 0 0 0 801 866.55 866.55
2019 Oct 17
1
List of applied policy if 'apply group policies = yes'...
Ahem, again revising docs... I've not found a place where there's a ist of policy applied if i set: apply group policies = yes There's something like that? they are exactly the policy in: samba-tool domain passwordsettings show Thanks. -- dott. Marco Gaiarin GNUPG Key ID: 240A3D66 Associazione ``La Nostra Famiglia''
2007 Feb 21
1
Trying to get an apply to work with a list in applying names to tables
I am trying to use apply and a list to supply names to a set of tables I want to generate. Below is an example that I hope mimics the larger original problem. EXAMPLE aa <- c( 2,2,1,1,2) bb <- c(5,6,6,7,4) aan <- c("yes", "no") bbn <- c("a", "b", "c", "d") mynames <- c("abby", "billy") mylist <-
2011 Oct 20
1
Applying function with separate dataframe (calibration file) supplying some inputs
Hello, I am not entirely sure the subject line captures what I am trying to do, but hopefully this description of the problem will help folks to see my challenge and hopefully offer constructive assistance. I have an experimental setup where I measure the decrease in oxygen in small vials as an organism, such as an oyster, consumes the oxygen. Each vial is calibrated before the experiment and
2006 Jul 22
0
how to apply before/after_filter to actionmailer
hi, I want to perform some action before/after each email was delivered. How can I apply before/after_filter to actionmailer? Thanks. Best Regards, Zhenjian -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060722/8f014133/attachment.html
2006 Jun 05
5
apply more than one condition to a find(:all
Hi I have the find statement below, how can I apply another condition to this to say AND status > 3 @projectReport = Project.find(:all, :conditions => ''status != 7'') Thanks scott -- Posted via http://www.ruby-forum.com/.
2006 Apr 04
2
How to apply class from Stylesheet to "link_to" element???
Hi, This is the "img" class for anchor element inside my stylesheet. ===================== A.img:link { color: #ffffff; text-decoration: none; } A.img:visited { color: #ffffff; text-decoration: none; } ====================== I can easily apply this tag inside my html document as follows:- ======= < a href="goodbye.html" class="img"> ======= Now I want to