Re: [R] write.table and append

2013-02-08 Thread Brian Smith
Ah, I didn't know this! Thanks Ben. On Fri, Feb 8, 2013 at 10:18 AM, Ben Tupper wrote: > Hi, > > On Feb 8, 2013, at 9:40 AM, Brian Smith wrote: > > > Hi, > > > > I am trying to append tables on file with this sample code: > > > >for(i in 1:2){ > >mat <- data.frame(sample(1:30

Re: [R] write.table and append

2013-02-08 Thread Ben Tupper
Hi, On Feb 8, 2013, at 9:40 AM, Brian Smith wrote: > Hi, > > I am trying to append tables on file with this sample code: > >for(i in 1:2){ >mat <- data.frame(sample(1:30,9),3,3) >colnames(mat) <- letters[1:3] >ifelse(i == > 1,write.table(mat,paste('te

Re: [R] write.table and append

2013-02-08 Thread Brian Smith
Thanks Louis! That seems to work! On Fri, Feb 8, 2013 at 10:06 AM, Louis Aslett wrote: > I believe your problem stems from using ifelse() actually ... it > requires the statements which it runs to return a value with the same > shape as the test, which write.table() isn't doing. > > Just change i

Re: [R] write.table and append

2013-02-08 Thread Louis Aslett
I believe your problem stems from using ifelse() actually ... it requires the statements which it runs to return a value with the same shape as the test, which write.table() isn't doing. Just change it to a regular if with an else and you'll be fine: for(i in 1:2){ mat <- data.frame(sample(1:30

[R] write.table and append

2013-02-08 Thread Brian Smith
Hi, I am trying to append tables on file with this sample code: for(i in 1:2){ mat <- data.frame(sample(1:30,9),3,3) colnames(mat) <- letters[1:3] ifelse(i == 1,write.table(mat,paste('test.txt',sep=''),row.names=F), write.table(mat,paste('test.txt',sep