Perhaps  ?dput

-- Bert


On Wed, Sep 25, 2013 at 6:10 AM, Lietz, Haiko <haiko.li...@gesis.org> wrote:

> Hi all,
>
> I want to collapse multiple elements of a vector into a single
> comma-separated character element. I only know how to create a list of the
> original elements, but I have not managed to write this into a text file,
> which is necessary.
>
> To illustrate, let's use the airquality dataset and extract the Month and
> Day columns:
>
> library(datasets)
> x <- data.frame(Month = airquality$Month, Day =
> as.character(airquality$Day))
>
> Using the aggregate function
>
> y <- aggregate(x$Day ~ x$Month, data = x, paste)
>
> only seemingly creates what I want because the list can't be written to a
> file.
>
> "1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
> 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31" for the first row should
> actually be a character element.
>
> I've tried it but sapply, ascii, write.matrix don't seem get me there.
>
> Can someone please point me towards the function I need?
>
> Best wishes
>
> Haiko
>
>
> Haiko Lietz
> GESIS - Leibniz Institute for the Social Sciences
> Unter Sachsenhausen 6-8, D-50667 Köln
> Tel: + 49 (0) 221 / 476 94 -223
> eMail: haiko.li...@gesis.org<mailto:haiko.li...@gesis.org>
> Web: http://www.gesis.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.
>
>


-- 

Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm

        [[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.

Reply via email to