Re: [R] Writing Vector to a File

From: Gundala Viswanath <gundalav_at_gmail.com>
Date: Mon, 23 Jun 2008 22:15:53 +0900

Dear Philipp and Duncan,

I've tried

> write(as.character(myvec), "output.txt", sep="\n")

and

> writeLines(as.character(myvec), "output.txt", sep="\n")

Both yielding same result.

>> 1
>> 1
>> 1
>> 1
>> 1
>> 6241

Is there any other possible explanation, why it still went wrong?

On Mon, Jun 23, 2008 at 8:02 PM, Philipp Pagel <p.pagel_at_wzw.tum.de> wrote:
>> I want to print this vector into a file
>>
>> > myvec
>> [1] --Control --Control --Control --Control --Control HBA2 HBA1
>> [8] HBA1 --Control HBB --Control HBB HBA1 MBP

> [...]

>>
>> However using this command:
>> write(myvec, "output.txt", sep="\n")
>>
>> I get this instead in my output.txt:
>>
>> 1
>> 1
>> 1
>> 1
>> 1
>> 6241
>> 6240
>> 6240
>> 1
>> 6242
>> 1
>> 6242
>> 6240
>> ....
>>
>> What's wrong with my command above?
>
> I think your vector is a factor and what ends up in your file is the
> internal representation of the factor.  Try this instead:
>
> write(as.character(myvec), "output.txt", sep="\n")
>
> cu
>        Philipp
>
>
> --
> Dr. Philipp Pagel
> Lehrstuhl für Genomorientierte Bioinformatik
> Technische Universität München
> Wissenschaftszentrum Weihenstephan
> 85350 Freising, Germany
> http://mips.gsf.de/staff/pagel
>
> ______________________________________________
> 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.
>

______________________________________________
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. Received on Mon 23 Jun 2008 - 13:33:00 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 23 Jun 2008 - 14:30:59 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive