Re: [R] data.frame query

2010-10-21 Thread J . delasHeras
you forgot to include "output1" in your cbind call. what I normally do is initialise the variable where I want to store the dataframe prior to starting the loop: output1<-NULL then run the loop, and within it there should be a: output1<-cbind(output1, newdata) where 'newdata' will be the

Re: [R] data.frame query

2010-10-21 Thread David Winsemius
On Oct 21, 2010, at 12:52 PM, Etn wrote: Hi All, Apologies for the simplicity of my question, but I would be grateful for any advice. Thanks I'm trying to put the output from a for loop into a data frame, however I have not been successful. The steps I have taken are: *R-code:* fo

Re: [R] data.frame query

2010-10-21 Thread Adrienne Wootten
Try this: before your loop put this output1 <- NULL in the loop at the end put this temp <- data.frame(cbind(k,n,lam,Q)) output1 <- rbind(output1,temp) this should do the trick for you Adrienne NCSU On Thu, Oct 21, 2010 at 12:52 PM, Etn <2nuzz...@gmail.com> wrote: > Hi All, > > Apologies fo

Re: [R] data.frame query

2010-10-21 Thread Dennis Murphy
Hi: Does this work? mdat <- function(nt, n0, n1) { l <- nt - n0 - 1 k <- seq(l) # same as 1:l n <- n0 - 1 + k lam <- n/nt Q <- seq(n1)[n] data.frame(k = k, n = n, lam = lam, Q = Q) } > mdat(20, 5, 20) k n lam Q 1 1 5 0.25 5 2 2 6 0.30 6 3 3 7 0.3

[R] data.frame query

2010-10-21 Thread Etn
Hi All, Apologies for the simplicity of my question, but I would be grateful for any advice. Thanks I'm trying to put the output from a for loop into a data frame, however I have not been successful. The steps I have taken are: *R-code:* >for (k in 1:(nt-1-n0) ){ >n<- n0-1+k >lam=n/n