Exactly -- also found creating horizontal vector helps:

> df <- data.frame(matrix(1:5,nrow=1))
> colnames(df) <- LETTERS[1:5]
> df
  A B C D E
1 1 2 3 4 5

Thanks,
Alexy

On Sep 17, 2008, at 1:17 AM, Moshe Olshansky wrote:

If df is your data.frame, then
colnames(df) <- c("col1","Col2","COL3")



--- On Wed, 17/9/08, Alexy Khrabrov <[EMAIL PROTECTED]> wrote:

From: Alexy Khrabrov <[EMAIL PROTECTED]>
Subject: [R] creating horizontal dataframes with column names
To: [EMAIL PROTECTED]
Received: Wednesday, 17 September, 2008, 1:52 PM
Greetings -- in order to write back to SQL databases, one
needs to
create a dataframe with values.  I can get column names of
an existing
table with sqlColumns.  Say I have a vector of values (if
they're all
the same type), or a list (if different).  How do I create
a dataframe
with column names given by my sqlColumns?  To make it
concrete, how do
we make a dataframe

A B C
1 2 3

out of

column.names <- LETTERS[1:3]
values <- 1:3

?
Cheers,
Alexy

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

______________________________________________
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