hongsheng wu
2011-Apr-01 14:00 UTC
[R] read.table question #only need to change column names
Hi all,
I have a huge data set. All I want to do is to change the column names of
the it. So if I use read.table, I can read the data in and change colnames
and then write back, such as,
t <- read.table("a.txt", header = T, sep = "\t")
colnames(t)
colnames(t) <- c("....) # new column names
write.table(t, "a.txt", quote = F, sep = "\t", row.names =
F, col.names = T)
My question is that is there a better to do this without reading in and
write out data entirely?
Thanks.
Alex
[[alternative HTML version deleted]]
David Winsemius
2011-Apr-01 14:50 UTC
[R] read.table question #only need to change column names
On Apr 1, 2011, at 10:00 AM, hongsheng wu wrote:> Hi all, > > I have a huge data set. All I want to do is to change the column > names of > the it. So if I use read.table, I can read the data in and change > colnames > and then write back, such as, > > t <- read.table("a.txt", header = T, sep = "\t") > > colnames(t) > > colnames(t) <- c("....) # new column names > > write.table(t, "a.txt", quote = F, sep = "\t", row.names = F, > col.names = T) > > My question is that is there a better to do this without reading in > and > write out data entirely?With an editor. -- David Winsemius, MD West Hartford, CT