[R] Exporting data to a text file

John Kane jrkrideau at yahoo.ca
Tue Aug 5 16:38:29 CEST 2008


Don't worry about the warning. R is just telling you that you're appending something :)  I'm not sure why it does that. Perhaps just to make sure that you know that you reallly want to append ?  


--- On Mon, 8/4/08, pacomet <pacomet at gmail.com> wrote:

> From: pacomet <pacomet at gmail.com>
> Subject: Re: [R] Exporting data to a text file
> To: jrkrideau at yahoo.ca
> Cc: r-help at r-project.org
> Received: Monday, August 4, 2008, 7:03 AM
> Hi John
> 
> I don't get an error message but a warning
> 
> >
> write.table(myclara$clustering,"cluster.dat",append=TRUE)
> Warning message:
> In write.table(myclara$clustering, "cluster.dat",
> append = TRUE) :
>   appending column names to file
> >
> 
> Here it is the output of str(myclara), it looks
> "strange" to me. I think
> "clustering" are integers and "data"
> are real numbers
> 
> >str(myclara)
> List of 10
>  $ sample    : chr [1:56] "32356"
> "33277" "43230" "52386" ...
>  $ medoids   : num [1:8, 1:14]  7.888 12.019  5.427  0.725
> 17.688 ...
>   ..- attr(*, "dimnames")=List of 2
>   .. ..$ : chr [1:8] "109056" "98194"
> "56959" "109806" ...
>   .. ..$ : chr [1:14] "lon" "lat"
> "sst01" "sst02" ...
>  $ i.med     : int [1:8] 20482 16158 5137 20722 48599 56033
> 68028 64308
>  $ clustering: Named int [1:75459] 1 1 1 1 1 1 1 1 1 1 ...
>   ..- attr(*, "names")= chr [1:75459]
> "12296" "12297" "12298"
> "12299" ...
>  $ objective : num 3.22
>  $ clusinfo  : num [1:8, 1:4] 15055  9474  5164 13702 11340
> ...
>   ..- attr(*, "dimnames")=List of 2
>   .. ..$ : NULL
>   .. ..$ : chr [1:4] "size" "max_diss"
> "av_diss" "isolation"
>  $ diss      :Classes 'dissimilarity',
> 'dist'  atomic [1:1540] 1.11 6.54
> 4.62 3.30 4.32 ...
>   .. ..- attr(*, "Size")= int 56
>   .. ..- attr(*, "Metric")= chr
> "euclidean"
>   .. ..- attr(*, "Labels")= chr [1:56]
> "32356" "33277" "43230"
> "52386" ...
>  $ call      : language clara(x = mydata, k = 8)
>  $ silinfo   :List of 3
>   ..$ widths         : num [1:56, 1:3] 1 1 1 1 1 1 1 1 2 2
> ...
>   .. ..- attr(*, "dimnames")=List of 2
>   .. .. ..$ : chr [1:56] "96250"
> "109056" "130058" "116317" ...
>   .. .. ..$ : chr [1:3] "cluster"
> "neighbor" "sil_width"
>   ..$ clus.avg.widths: num [1:8] 0.343 0.355 0.533 0.265
> 0.308 ...
>   ..$ avg.width      : num 0.362
>  $ data      : num [1:75459, 1:14] 8.68 8.72 8.77 8.81 8.86
> ...
>   ..- attr(*, "dimnames")=List of 2
>   .. ..$ : chr [1:75459] "12296"
> "12297" "12298" "12299" ...
>   .. ..$ : chr [1:14] "lon" "lat"
> "sst01" "sst02" ...
>  - attr(*, "class")= chr [1:2] "clara"
> "partition"
> 
> 
> 
> I can't output the two variables in two different files
> without any problem.
> 
> Thanks
> 
> 
> 2008/8/1 John Kane <jrkrideau at yahoo.ca>
> 
> > try
> > str(myclara)
> > to see what you have - a data frame , matrix etc
> >
> > Are you getting any error messages?
> >
> > I tried your write.table commands and they work okay.
> >
> >
> > --- On Fri, 8/1/08, pacomet <pacomet at gmail.com>
> wrote:
> >
> > > From: pacomet <pacomet at gmail.com>
> > > Subject: [R] Exporting data to a text file
> > > To: r-help at r-project.org
> > > Received: Friday, August 1, 2008, 12:49 PM
> > > HI R users
> > >
> > > With clara function I get a data frame (maybe
> this is not
> > > the exact word,
> > > I'm new to R) with the following variables:
> > >
> > > > names(myclara)
> > >  [1] "sample"     "medoids"
> > > "i.med"      "clustering"
> > > "objective"
> > >  [6] "clusinfo"   "diss"
> > > "call"       "silinfo"
> > > "data"
> > >
> > > I want to export "clustering" and
> > > "data" to a new text file so I try
> > >
> > > >
> write.table(myclara$data,"cluster.dat")
> > > >
> > >
> write.table(myclara$clustering,"cluster.dat",append=TRUE)
> > >
> > > Variable data is properly exported but clustering
> is not
> > > appended to the
> > > output file.
> > >
> > > Please, where is the mistake? is it possible to
> export the
> > > two variables in
> > > just a sentence?
> > >
> > > thanks in advance
> > >
> > > Paco
> > >
> > > --
> > > _________________________
> > > El ponent la mou, el llevant la plou
> > > Usuari Linux registrat: 363952
> > > -------
> > > Fotos: http://picasaweb.google.es/pacomet
> > >
> > >       [[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.
> >
> >
> >     
> __________________________________________________________________
> > Connect with friends from any web browser - no
> download required. Try the
> > new Yahoo! Canada Messenger for the Web BETA at
> > http://ca.messenger.yahoo.com/webmessengerpromo.php
> >
> 
> 
> 
> -- 
> _________________________
> El ponent la mou, el llevant la plou
> Usuari Linux registrat: 363952
> -------
> Fotos: http://picasaweb.google.es/pacomet


      __________________________________________________________________
[[elided Yahoo spam]]



More information about the R-help mailing list