[R] Column of numbers added to dataframe when saving with read.csv
Sarah Goslee
sarah.goslee at gmail.com
Wed Jun 15 17:03:40 CEST 2011
You need to add row.names=FALSE to your write.table() statement.
This and other useful options are documented in the help. And you'll
notice that that first column of row names appears in your R output as
well.
Sarah
On Wed, Jun 15, 2011 at 10:51 AM, Paolo Rossi
<statmailinglists at googlemail.com> wrote:
> 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
>
--
Sarah Goslee
http://www.functionaldiversity.org
More information about the R-help
mailing list