Skip to content
Back to formatted view

Raw Message

Message-ID: <49DB016F.8080700@biostat.ku.dk>
Date: 2009-04-07T07:31:59Z
From: Peter Dalgaard
Subject: Writing specific columns to a data file
In-Reply-To: <e06366b70904061941t17fee1b3sdea4a6617f0f1f58@mail.gmail.com>

Coen van Hasselt wrote:
> By only selecting the first column, i.e. write.table(data[,1], file="", .....) ?

Notice that this drops to a vector, losing the variable name.

Brendan may need data[,1, drop=FALSE], and/or give row.names=FALSE to 
write.table, depending on what the real problem was.

> 
> On Tue, Apr 7, 2009 at 12:28, Brendan Morse <morse.brendan at gmail.com> wrote:
>> Hi, I have a function that generates some output with 2 columns, but I
>> only want to write the first column to a file. Is there a way to do
>> this in the write.table command?
>>
>> thetaout=write.table(estimatedtheta, file="/Users/morse07/Desktop/R/
>> Trial/score.dat", row.names=F, col.names=F)
>>
>> Any advice would be great, thanks!


-- 
    O__  ---- Peter Dalgaard             ?ster Farimagsgade 5, Entr.B
   c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
  (*) \(*) -- University of Copenhagen   Denmark      Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)              FAX: (+45) 35327907