[R] Column of numbers added to dataframe when saving with read.csv

ONKELINX, Thierry Thierry.ONKELINX at inbo.be
Wed Jun 15 17:02:05 CEST 2011


Reading the helpfile (as the posting guide asks you to do) of write.table will solve your problem.

> -----Oorspronkelijk bericht-----
> Van: r-help-bounces op r-project.org [mailto:r-help-bounces op r-project.org]
> Namens Paolo Rossi
> Verzonden: woensdag 15 juni 2011 16:52
> Aan: r-help op r-project.org
> Onderwerp: [R] Column of numbers added to dataframe when saving with
> read.csv
> 
> I have a dataframe object having the following structure
> 
>  FinalOutput[1:3,]
>      GasDays 2011-03-31 2010-09-30 2010-10-31 2010-11-30 2010-12-31
> 2011-01-31 2011-02-28
> 1 2006-10-01  217303553  221205033  222824639  217016511  216093460
> 216477468  216834021
> 2 2006-10-02  231158527  234565250  236004109  231467851  230100639
> 230079907  230734064
> 3 2006-10-03  282062314  285427832  286372163  282532055  280930498
> 281155966  281124614
> After using
> write.table(FinalOutput, paste("ModelComparison.csv", sep = ''), sep = ',')
> 
> the out put I get on the csv is
> 
> 
> 
>  GasDays 31/03/2011 30/09/2010     31/10/2010      30/11/2010
>  31/12/2010            31/01/2011       28/02/2011         31/03/2011
> 1              01/10/2006 217303553.3 221205032.6
> 222824638.7       217016510.8
> 216093460       216477467.9       216834021            217303553.3
> 2              02/10/2006 231158527.1 234565249.7
>  236004108.7       231467850.7       230100639.1       230079907.4
> 230734064.4       231158527.1
> 3              03/10/2006 282062314.5 285427831.6
> 286372163       282532055.2       280930497.7
> 281155966         281124613.8       282062314.5
> 
> 
> so essentially one column  full  of 1,2,3, ... is added to the file when saving it.
> 
> Can someone pelase help me to get rid of it?
> 
> Thanks
> 
> Paolo
> 
> 
> 
> 
> On 14 June 2011 13:59, Saravanan
> <saravanan.thirumuruganathan op gmail.com>wrote:
> 
> > Hello All,
> >
> > I have a dataset and I wish to obtain all possible data cuboids from
> > it using R . For eg if my data frame is :
> >
> > A    B    C
> > 1    1    1
> > 1    2    1
> > 2    2    1
> >
> > The output intended is :
> > A=1
> > A=2
> > B=1
> > B=2
> > C=1
> > A=1,B=1
> > A=1,B=2
> > A=2,B=2
> > A=1,C=1
> > A=2,C=1
> > B=1,C=1
> > B=2,C=1
> > A=1,B=1,C=1
> > A=1,B=2,C=1
> > A=2,B=2,C=1
> >
> > Are there any function(s) to do this in R ? I tried a combination of
> > expand.grid and combn but the resulting code was very ugly and needed
> > lot of hacks to make it work. I also tried to check the code for
> > arules (which constructs similar "itemsets") but unfortunately its
> > code is in C and I am not very familiar in writing R extensions. Any
> > pointers to functions will be much appreciated.
> >
> > Regards,
> > Saravanan
> >
> > ______________________________________________
> > R-help op 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<http://www.r-project.org/p
> > osting-guide.html> and provide commented, minimal, self-contained,
> > reproducible code.
> >
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help op 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.



More information about the R-help mailing list