Re: [R] How can I avoid nested 'for' loops or quicken the process?

2008-12-26 Thread Prof Brian Ripley
On Thu, 25 Dec 2008, Oliver Bandel wrote: Bert Gunter gunter.berton at gene.com writes: FWIW: Good advice below! -- after all, the first rule of optimizing code is: Don't! For the record (yet again), the apply() family of functions (and their packaged derivatives, of course) are merely

Re: [R] Percent damage distribution

2008-12-26 Thread Prof Brian Ripley
Not an R question as yet . In my limited experience (we have some insurance projets), 100% can occur, but otherwise a beta distbribution may suit, which suggests a mixture distribution. But start with an empirical examination (histogram, ecdf, density plot) of the distribution, since it

[R] Upgrading R causes Tinn-R to freeze.

2008-12-26 Thread rkevinburton
I recently upgraded from 2.8.0 to 2.8.1 by first installing the 2.8.1 version then copying the binaries and the library to the 2.8.0 folder. Now Tinn-R will not start up. I just see that start up splash screen for a long period of time. It seems fozen to me. Any guesses on what I did wrong in

Re: [R] How can I avoid nested 'for' loops or quicken the process?

2008-12-26 Thread Peter Dalgaard
Prof Brian Ripley wrote: On Thu, 25 Dec 2008, Oliver Bandel wrote: The apply-functions do bring speed-advantages. This is not only what I read about it, I have used the apply-functions and really got results faster. The reason is simple: an apply-function does make in C, what otherwise

[R] histogramm$density

2008-12-26 Thread austernkommunikation
hello, i am using the hist function with classified values. The class breaks are 1, so histogram$density is != 1. How to plot the histogram with freq=FALSE and the real class density values. I used: h2 = hist(value, breaks = breaks_vector) h2$density = round(h2$counts/sum(h2$counts), 2)

Re: [R] histogramm$density

2008-12-26 Thread Peter Dalgaard
austernkommunikat...@googlemail.com wrote: hello, i am using the hist function with classified values. The class breaks are 1, so histogram$density is != 1. How to plot the histogram with freq=FALSE and the real class density values. I used: h2 = hist(value, breaks = breaks_vector)

Re: [R] Computational Probability

2008-12-26 Thread Gabor Grothendieck
Actually the last line could be simplified to just: s 4 s 6 mean sd sims [1] 0.72 0.45 2500 On Fri, Dec 26, 2008 at 8:33 AM, Gabor Grothendieck ggrothendi...@gmail.com wrote: Try a simulation approach. vignette(rv) for more info. set.seed(1) library(rv) x - rvunif(10) s -

Re: [R] Computational Probability

2008-12-26 Thread Prof Brian Ripley
Look at packages distr* : they can do your example and might do what your real applications. On Fri, 26 Dec 2008, Rory Winston wrote: Hi Firstly , happy Christmas to R-Help! Secondly, I wonder if anyone can help me with the following query: I am trying to reproduce some explicit probability

Re: [R] How can I avoid nested 'for' loops or quicken the process?

2008-12-26 Thread Bert Gunter
Thankyou for the clarification, Brian. This is very helpful (as usual). However, I think the important point, which I misstated, is that whether it be for() or, e.g. lapply(), the loop contents must be evaluated at the interpreted R level, and this is where most time is typically spent. To get

Re: [R] How can I avoid nested 'for' loops or quicken the process?

2008-12-26 Thread Prof Brian Ripley
On Fri, 26 Dec 2008, Bert Gunter wrote: Thankyou for the clarification, Brian. This is very helpful (as usual). However, I think the important point, which I misstated, is that whether it be for() or, e.g. lapply(), the loop contents must be evaluated at the interpreted R level, and this is

Re: [R] Simulating dataset using Parallel Latent CTT model?

2008-12-26 Thread William Revelle
Nidhi, Presumably, you are trying to simulate 20 items all sharing one general factor but having some error. The model as you specified it has no error. Thus all the correlations will be 1 and the factors will not make any sense. Most items have loadings on a general factor of the

[R] lm() with same formula but different column/factor combinations in data frame

2008-12-26 Thread Murtaza Das
Hi, I am trying to find an efficient way of applying a linear regression model to different factor combinations in a data frame. I want to obtain the output with minimal or no use of loops if possible. Please let me know if this query is unclear. Thanks, Murtaza

Re: [R] lm() with same formula but different column/factor combinations in data frame

2008-12-26 Thread Gabor Grothendieck
See the leaps package. On Fri, Dec 26, 2008 at 12:37 PM, Murtaza Das murtaza...@gmail.com wrote: Hi, I am trying to find an efficient way of applying a linear regression model to different factor combinations in a data frame. I want to obtain the output with minimal or no use of loops if

Re: [R] Computational Probability

2008-12-26 Thread Matthias Kohl
indeed one could use package distr ... library(distr) X - Unif(Min = 0, Max = 1) Y - convpow(X, 10) p(Y)(6) - p(Y)(4) Best Matthias Prof Brian Ripley wrote: Look at packages distr* : they can do your example and might do what your real applications. On Fri, 26 Dec 2008, Rory Winston wrote:

Re: [R] lm() with same formula but different column/factor combinations in data frame

2008-12-26 Thread Murtaza Das
Thanks for replying Gabor. I checked the leaps() function and i think it is intended to find the best combination of predictors in the linear model. Does leaps have a way to combine different factor columns in my data frame as follows : I have the regression model fixed. The combination of

[R] R server without Rserve

2008-12-26 Thread Harsh
Hi All, I am currently using Rserve to call R as a service and execute R scripts. I find problems cropping up because I write my scripts in R (2.8.0) on Windows and communicated with Rserve on Ubuntu to execute them. Rserve running on the Ubuntu machine has R-base 2.6.0 Many a times, when i

Re: [R] Interval censored Data in survreg() with zero values!

2008-12-26 Thread Geraldine Henningsen
Hello again, thank you very much for your help so far. To be more specific, I generate a simplified data set that is similar to my real world data: set.seed( 123 ) data - data.frame( x = runif( 200 ), y = NA ) for( i in 1:200 ){ data$y[ i ] - rweibull( 1, 1, 70 + 10 * data$x[ i ] ) - 30 }

Re: [R] lm() with same formula but different column/factor combinations in data frame

2008-12-26 Thread Gabor Grothendieck
Try variations of this: library(leaps) b-regsubsets(Fertility~.,data=swiss) w - summary(b)$which lapply(1:nrow(w), function(i) coef(lm(Fertility ~., swiss[w[i, ]]))) On Fri, Dec 26, 2008 at 1:57 PM, Murtaza Das murtaza...@gmail.com wrote: Thanks for replying Gabor. I checked the leaps()

Re: [R] Percent damage distribution

2008-12-26 Thread diegol
In my limited experience (we have some insurance projets), 100% can occur, but otherwise a beta distbribution may suit, which suggests a mixture distribution. But start with an empirical examination (histogram, ecdf, density plot) of the distribution, since it may reveal other features. Good

Re: [R] ggplot2 Xlim

2008-12-26 Thread Felipe Carrillo
Wayne: What's crowded are my x axis labels. The bars look fine on my graph but the labels are being displayed from 29 to 170 one by one. I need something like a seq(29,170 by:10) or something like that. I don't want to treat my FL as factor because I don't want a bar per each FL value, I only

Re: [R] ggplot2 Xlim

2008-12-26 Thread hadley wickham
Hi Felipe, It sounds like ForkLength is a factor - what deos str(FL) tell you? You might also need geom_bar(..., stat = identity) since your data are pretabulated. Hadley On Fri, Dec 26, 2008 at 2:44 PM, Felipe Carrillo mazatlanmex...@yahoo.com wrote: Wayne: What's crowded are my x axis

Re: [R] ggplot2 Xlim

2008-12-26 Thread Felipe Carrillo
Thanks Hadley: I had already gone to your website and stat=identity is what I needed. --- On Fri, 12/26/08, hadley wickham h.wick...@gmail.com wrote: From: hadley wickham h.wick...@gmail.com Subject: Re: [R] ggplot2 Xlim To: mazatlanmex...@yahoo.com Cc: r-help@r-project.org, Wayne F

[R] Sweave style file

2008-12-26 Thread John Maindonald
It would, I consider, be useful to note, on the help pages for Sweave and RweaveLatex, that the path to Sweave.sty in the R installation can be extracted as paste(R.home(),share/texmf/, sep=/) or its equivalent. John Maindonald email: john.maindon...@anu.edu.au phone : +61 2