- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to rename a single column in an R data frame?
We can do this by defining the newname as shown below −
> Samp <- data.frame(sample(1:100,10)) > Samp sample.1.100..10. 1 47 2 63 3 57 4 16 5 53 6 7 7 54 8 2 9 13 10 14 > colnames(Samp) <- "Sampled Values" > Samp Sampled Values 1 47 2 63 3 57 4 16 5 53 6 7 7 54 8 2 9 13 10 14
Since we only have one column in the data frame, so it is sufficient to use the object name.
- Related Articles
- How to extract a single column of an R data frame as a data frame?
- How to add single quotes to strings in an R data frame column?
- How to remove single quote from string column in an R data frame?
- How to convert multiple columns into single column in an R data frame?
- How to create a boxplot of single column in R data frame with column name?
- How to standardized a column in an R data frame?
- How to separate two values in single column in R data frame?
- How to update single value in an R data frame?
- How to remove a column from an R data frame?
- How to replace a complete column in an R data frame?
- How to remove a character in an R data frame column?
- How to create a group column in an R data frame?
- How to create a lagged column in an R data frame?
- How to check whether a column exists in an R data frame?
- How to sort a numerical factor column in an R data frame?

Advertisements