similar to: Acumulate assign on lapply list

Displaying 20 results from an estimated 8000 matches similar to: "Acumulate assign on lapply list"

2009 Dec 02
2
lapply assign to list
Hi R users: I got an error that "l1" is not found. This is a sample code: f1<-function(i,l1){ print(l1[[i]]) l1[[i+1]]<<-i return(i) } z1<-list(x=100,NULL,a=c(1,1)) lapply(1:3,f1,l1=z1) My final goal is to update the value of each list component to use it in the following step. I see that print function founds l1[[1]], but the assign instruction not. Thank you
2010 Mar 26
3
Using lapply with two lists
Hello guys, I have a list L1 of matrix. I have another list L2 with the same number of elements representing the row of the L matrix that I want to delete (L1[[i]][-L2[[i]],]) but I can't do this with lapply as it iterates through L1 (first argument) and not L2. Any idea? ----- Anna Lippel -- View this message in context:
2008 Dec 11
2
is there a way to recursilvely lapply
for a simple example: x <- list() x[["a"]] <- list(a=c(1,2,3),b=c(3,4,5)) x[["b"]] <- list(a=c(6,7,8),b=c(9,10,11)) lapply(x,sum) this fails w/ Error in FUN(X[[1L]], ...) : invalid 'type' (list) of argument Just wondering if I have overlooked something obvious. one can also do: lapply(x,lapply,sum) but that assumes that you already know how many levels
2010 Feb 14
1
unexpected results with higher-order functions and lapply
I want to use lapply and a function returning a function in order to build a list of functions. > genr1 <- function(k) {function() {k}} > l1 <- lapply(1:2,genr1) > l1[[1]]() [1] 2 This was unexpected. I had expected the answer to be 1, since that is the value k should be bound to when genr1 is applied to the first element of 1:2. By itself genr1 seems to work fine. >
2004 May 20
2
for() to lapply()
Hi dear R-users: I have the following problem: I have a list of data.frames (12 variables and 60000 rows, each) I have to merge from an specific point of the list to the end of the list, I am doing so with a for() loop but it is too inefficient and it exhausts memory. How can I convert this for() loop in a function and then use lapply?
2008 Jul 14
2
Insurance review statistical methods
Hi R users: I will like to know if somebody works on insurance statistics (actuarial problems) and had use TRICAST, and can tell me if with all the R tools it can be build a solution like TRICAST or similar. In a word: Do you think that R has all the statistical tools (I mean modeling tools) to make a job similar to TRICAST? Does TRICAST has modeling tools that are not implemented on R yet?
2007 Nov 19
4
sequence of vectors
Dear All, I wonder if there is any R function to generate a sequence of vectors from existing ones. For example: x 1<- c(1,2,3) x2 <- c(4,5) x3 <- c(6,7,8) The desired output is a list of all 3*2*3 = 18 possible combinations of elements of x1,x2 and x3. One element for example is (1,4,6). Many thanks in advance, Bernard
2012 Aug 01
2
assign vectors to objects
Hi everyone, I try to add many vectors (L1,L2,L3....) to multiple list objects (a.list, b.list....) in a workspace. Somethings like below, but it is not working. Any suggestions will be appreciated. Best, John lf=ls(pattern=".lst")  for (x in listfiles) {     dat=read.delim(x,header=F)     for (i in lf) {     assign(i$add,as.numeric(dat[,3]))   #or i$add=as.numeric(dat[,3]    
2000 Dec 20
1
Partial table.
Hi R users: Thank you very much for you help, you are very kind. I am again asking for your help to make a function that returns the numbers of elements of each category given in another vector. I mean, I have a vector "x" with several elements (most of them more that once) and other vector "y" with the elements that I want to count in the first vector (is not a exhaustive
2002 Nov 29
2
Obtaining the variable names of a glm object
Is names(model1$coef) what you're looking for? -----Original Message----- From: Kenneth Cabrera [mailto:krcabrer at epm.net.co] Sent: 29 November 2002 10:36 Cc: R-help at stat.math.ethz.ch Subject: [R] Obtaining the variable names of a glm object Hi, R users! Suppose I make a model like this:
2000 Dec 14
1
Sort in descending order
Hi R users: I want to know how can I easily sort in descending order a whole data frame by one or several variables. Thank you very much for your help. Kenneth Cabrera krcabrer at perseus.unalmed.edu.co krcabrer at epm.net.co Universidad Nacional de Colombia, Sede Medell?n -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read
2002 Apr 11
14
Ordinal categorical data with GLM
Hello All: I am trying to replicate the results of an example found in Alan Agresti's "Categorical Data Analysis" on pages 267-269. The example is one of a 2 x 2 cross-classification table of ordinal counts: job satisfaction and income. I am able to get Agresti's results for the independence model (G^2 = 12.03 with df = 9) assuming as he does that the data is nominal, but
2009 Apr 14
4
Forcing the extrapolation of loess through the origin
Hi all, I'm fitting a line to my dataset. Later I want to predict missing values that exceed the [min,max] interval of my empirical data, therefore I choose surface="direct" for extrapolation. l1<-loess(y1~x1,span=0.1,data.frame(x=x1,y=y1),control=loess.control(surface="direct")) In my application it is highly important that the fitted line intercepts at the point of
2006 May 01
3
Repeat dataframe
Hi R list: How can I "repeat" a data frame n times (with n>1000), and obtain a new data frame where all the n data frames are binded by rows? Thank you for your help Kenneth -- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
2011 Aug 17
2
An example of very slow computation
This message is about a curious difference in timing between two ways of computing the same function. One uses expm, so is expected to be a bit slower, but "a bit" turned out to be a factor of >1000. The code is below. We would be grateful if anyone can point out any egregious bad practice in our code, or enlighten us on why one approach is so much slower than the other. The problem
2002 Jun 05
5
Monte Carlo
Doctor in veterinary medecine I have a degree in veterinary epidemiology I would ask if someone can perform Monte Carlo simulation with R. Thanks in advance. Dr Kane Ismaila i_kane at hotmail.com -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info",
2001 Jun 07
3
Diag "Hat" matrix
Hi R users: What is the difference between in the computation of the diag of the "hat" matrix in: "lm.influence" and the matrix operations with "solve()" and "t()"? I mean, this is my X matrix x1 x2 x3 x4 x5 [1,] 0.297 0.310 0.290 0.220 0.1560 [2,] 0.360 0.390 0.369 0.297 0.2050 [3,] 0.075 0.058 0.047 0.034 0.0230 [4,] 0.114 0.100
2007 Jun 14
1
R programming question
Dear All., I've created R-code for which a user will be asked to choose between 2 analyses. I've written one function for each type of analysis. Within each function, the users is prompted to enter information. An example is: cat("Enter value for lower Linf :\n") L1<-scan(n=1) cat("Enter value for upper Linf :\n") L2<-scan(n=1)
2009 Aug 25
3
math symbol + value of a variable in legend.
Hi R users: I will like to have a legend with math symbols and also with the value of a variable. But I cannot obtain both at the same time (symbol + value of a variable): Here is a reproducible example: m1<-5 m2<-12 plot(1:5,1:5,type="n") legend("topleft",legend=c(paste(expression(mu),"=",m1),expression(paste(mu,"=",m2))),lty=1:2) Thank you for
2009 Aug 25
3
math symbol + value of a variable in legend.
Hi R users: I will like to have a legend with math symbols and also with the value of a variable. But I cannot obtain both at the same time (symbol + value of a variable): Here is a reproducible example: m1<-5 m2<-12 plot(1:5,1:5,type="n") legend("topleft",legend=c(paste(expression(mu),"=",m1),expression(paste(mu,"=",m2))),lty=1:2) Thank you for