Paolo Rossi
2011-Jun-15 14:51 UTC
[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@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@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/posting-guide.html> > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]
ONKELINX, Thierry
2011-Jun-15 15:02 UTC
[R] Column of numbers added to dataframe when saving with read.csv
Reading the helpfile (as the posting guide asks you to do) of write.table will solve your problem.> -----Oorspronkelijk bericht----- > Van: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] > Namens Paolo Rossi > Verzonden: woensdag 15 juni 2011 16:52 > Aan: r-help at 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 at 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 at 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 at 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.
Sarah Goslee
2011-Jun-15 15:03 UTC
[R] Column of numbers added to dataframe when saving with read.csv
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
Ivan Calandra
2011-Jun-15 15:04 UTC
[R] Column of numbers added to dataframe when saving with read.csv
Hi Paolo, Not sure to understand you well, but try with row.names=FALSE in your call to write.table() HTH, Ivan Le 6/15/2011 16:51, Paolo Rossi a ?crit :> 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 at 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 at 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/posting-guide.html> >> and provide commented, minimal, self-contained, reproducible code. >> > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at 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. >-- Ivan CALANDRA PhD Student University of Hamburg Biozentrum Grindel und Zoologisches Museum Dept. Mammalogy Martin-Luther-King-Platz 3 D-20146 Hamburg, GERMANY +49(0)40 42838 6231 ivan.calandra at uni-hamburg.de ********** http://www.for771.uni-bonn.de http://webapp5.rrz.uni-hamburg.de/mammals/eng/1525_8_1.php