Re: [R] re place column names

From: R Help <rhelp.stats_at_gmail.com>
Date: Fri, 22 Feb 2008 11:42:19 -0400

names(dat) will return the column names for a dataset called dat, and they can also be set this way.

names(dat) <- c("firstName","secondName","thirdName",...)

I would suggest reading the column names into a vector, and then assigning them as demonstrated above.

On Fri, Feb 22, 2008 at 9:42 AM, hochoi <evilonegirl2006_at_yahoo.com> wrote:
>
> Hi,
>
> When I tried to replace column names in a data set with label names read
> from a separated file,
> I got the following message:
>
> Error in `[.data.frame` (dataset, , classlabel): undefined columns selected
>
> I am new in R programming languague. Could someone please tell me what do I
> need to consider in the dataset dataframe.
> There are no column names in the dataset dataframe,
> When I entered
> dimnames(dataset)[[2]]
> [1] "X1" "X2" "X3" "X4" "X5" "X6" "X7" "X8" "X9" "X10" "X11" "X12"
>
> [13] "X13" "X14" "X15" "X16" "X17" "X18" "X19" "X20" "X21" "X22" "X23" "X24"
>
> [25] "X25" "X26" "X27" "X34" "X35" "X36" "X37" "X38" "X28" "X29" "X30" "X31"
>
> [37] "X32" "X33"
>
> Thanks
> --
> View this message in context: http://www.nabble.com/replace-column-names-tp15633387p15633387.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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 Fri 22 Feb 2008 - 15:50:34 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 Fri 22 Feb 2008 - 16:30:16 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