search for: tfun

Displaying 10 results from an estimated 10 matches for "tfun".

Did you mean: fun
2010 Nov 11
3
Evaluation puzzle
...tform print(m) print(ls(parent.frame())) mf <- eval(m, parent.frame()) names(mf) } Here is the test data tdata <- data.frame(age= c(12, 24, 36)*365.25, sex=c(1,2,1), year=as.Date('1953/03/10', '1960/02/23', '1978/09.22')) tfun <- function(mydata) { zed <- 100 + (1:nrow(mydata)) * 20 survexp.test(zed ~ 1, data=mydata) } And the result of the exercise. % R --vanilla R version 2.11.0 (2010-04-22) > library(survival) # to pick up the survexp.us data > tfun(tdata) model.frame(formula = "z...
2010 Nov 23
1
using the "apply" method for functions with multiple inputs
...ly method on a function with several inputs, but cannot figure out how to send multiple arguments to the function (not multiple runs of the same function, but one run of the function including two variables - each used within the function). a <- c(1:10,999,999,999) b <- c(11:20,999,999,999) tfun <- function(x,y){ if( (x = 1 & y !=999) || (x > 1 & x < 999 & y == 999) ) x1 <- 1 else x1 <-0 } #this doesn't work - gives an error " 'y' is missing tfilt <- sapply(data.frame(a,b), tfun) thanks, joe -- View this message in context: htt...
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
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 y ~ x + z...
1997 Jun 06
1
R-beta: nlm
...e 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 > nlm(tfun,0) Error: Argument "y" is missing, with no default Thus the problem I have is as follows: llkfun -- generic function to calculate the likelihood for given data and parameters mlefun -- f...
2007 Apr 08
1
buglet in terms calculations
...t code that uses the term.labels fails. In particular, it seems (of those tested) that glm, lda, randomForest seem to work fine, while nnet, rpart can't handle nonsyntactic names in formulae as such In particlar, rpart contains this code: lapply(m[attr(Terms, "term.labels")], tfun) which fails for the reasons given. One way to get around this, might be to modify the do_termsform code, right now we have: PROTECT(varnames = allocVector(STRSXP, nvar)); for (v = CDR(varlist), i = 0; v != R_NilValue; v = CDR(v)) SET_STRING_ELT(varnames, i++, STRING_ELT(d...
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
2007 Jul 16
2
Error while fitting Partial Proportional Odds model using vglm
...mary(ppo) I get the following error: Error in "[<-"(`*tmp*`, , index, value = c(1.13512932539841, 0.533057528200189, : number of items to replace is not a multiple of replacement length In addition: Warning messages: 1: NaNs produced in: log(x) 2: fitted values close to 0 or 1 in: tfun(mu = mu, y = y, w = w, res = FALSE, eta = eta, extra) 3: 19 elements replaced by 1.819e-12 in: checkwz(wz, M = M, trace = trace, wzeps = control$wzepsilon) Ironically, it works ok with Proportional Odds (change parallel = T above), but fails with PPO (parallel = F). I will appreciate any help t...
2010 Nov 24
0
4. Rexcel (Luis Felipe Parra)-how to run a code from excel
...ly method on a function with several inputs, but cannot figure out how to send multiple arguments to the function (not multiple runs of the same function, but one run of the function including two variables - each used within the function). a <- c(1:10,999,999,999) b <- c(11:20,999,999,999) tfun <- function(x,y){ if( (x = 1 & y !=999) || (x > 1 & x < 999 & y == 999) ) x1 <- 1 else x1 <-0 } #this doesn't work - gives an error " 'y' is missing tfilt <- sapply(data.frame(a,b), tfun) thanks, joe -- View this message in context: htt...