Re: [R] convert for loop into apply()

2008-08-03 Thread Charles C. Berry
w.cmis.csiro.au/bill.venables/ -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Anh Tran Sent: Saturday, 2 August 2008 4:04 PM To: rlist Subject: [R] convert for loop into apply() Hi all,I know this topic has came up multiple times, but I've never full

Re: [R] convert for loop into apply()

2008-08-03 Thread Hans W. Borchers
Also, your request can easily be formulated as an SQL statement, for example utilizing the 'sqldf' package: library(sqldf) a1 <- data.frame(id = 1:6, cat = paste('cat', rep(1:3, c(2,3,1))), st = c(1, 7, 30, 40, 59, 91), en = c(5, 25, 39, 55

Re: [R] convert for loop into apply()

2008-08-02 Thread Bill.Venables
+61 4 8819 4402 Home Phone: +61 7 3286 7700 mailto:[EMAIL PROTECTED] http://www.cmis.csiro.au/bill.venables/ -----Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Anh Tran Sent: Saturday, 2 August 2008 4:04 PM To: rlist Subject: [R] convert for

Re: [R] convert for loop into apply()

2008-08-02 Thread jim holtman
One way to make it faster is to remove the accessing of the dataframe in the loop. By converting the values you need to compare to matrices, the compares will be faster. Try the following to see if there is a speedup: a1<-data.frame(id=c(1:6), cat=c('cat 1','cat 1','cat 2','cat 2','cat 2','cat 3

[R] convert for loop into apply()

2008-08-01 Thread Anh Tran
Hi all,I know this topic has came up multiple times, but I've never fully understand the apply() function. Anyway, I'm here asking for your help again to convert this loop to apply(). I have 2 data frames with the following information: a1 is the fragment that is need to be covered, a2 is the pro