Many Thanks¡¡¡ I will try this night, I have read this I think could help me.
I´m conscient the question was badly formulated now, I will try to explain better next time¡¡¡ On a side note: apply always accesses the function you use at least once. If the input is a dataframe without any rows but with defined variables, it sends "FALSE" as an argument to the function. If the dataframe is completely empty, it sends a logical(0) to the function. > x <- data.frame(a=numeric(0)) > str(x) 'data.frame': 0 obs. of 1 variable: $ a: num > y <- apply(x,MARGIN=1,FUN=function(x){print(x)}) [1] FALSE > x <- data.frame() > str(x) 'data.frame': 0 obs. of 0 variables > y <- apply(x,MARGIN=1,FUN=function(x){print(x)}) logical(0) 2011/7/12 Sarah Goslee <sarah.gos...@gmail.com> > Hi, > > You don't provide us with a reproducible example, so I can't provide you > with > actual code. But two approaches come to mind: > 1. Create da2 with one row and n columns, then change the appropriate > elements, > if any, based on your conditions. > 2. Do the conditional parts, then check to see whether da2 is empty. > If it is, then > replace the empty data frame with a data frame of one row and n columns. > > Sarah > > On Tue, Jul 12, 2011 at 3:51 AM, Trying To learn again > <tryingtolearnag...@gmail.com> wrote: > > Hi all, > > > > I first create a matrix/data frame called "d2" if another matrix > > accomplishes some restrictions "dacc2" > > > > da2<-da1[colSums(dacc2)>9,] > > da2<-da2[(da2[,13]=24),] > > write.csv(da2, file =paste('hggi', i,'.csv',sep = '')) > > > > The thing is if finally da2 cannot get/passs the filters, it cannot > writte a > > csv because there is no any true condition. > > > > How can I create anyway a csv with zeros of one row and "n" columns > (being n > > the number of columns of da2? > > > > I need a loop? > > Rarely. > > > -- > Sarah Goslee > http://www.functionaldiversity.org > [[alternative HTML version deleted]]
______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.