• Wendy Ni

How to Rename Columns in Tibble RStudio

Objective Advantages

RStudio is an integrated development environment for R, a programming language for statistical computing and graphics.

In this blog, we go over renaming columns in RStudio. It is important that we get the correct information across, especially when there's a lot of data so we can avoid confusion.

The Situation

Here's an example for further understanding. In our data set, we have a total of three columns currently named: xlname, xlsex, xltestscores. The goal here is to rename them to be the following respectively: Name, Gender, TestScores.

Steps to Rename Columns in RStudio

  • In RStudio, make sure to have the required packages: tidyverse, readxl, and dplyr

  • Once you have those packages, you can Run the libraries and make sure they are loaded in

  • Create a variable called Tests and assign the data table to it

  • Call the variable Tests again, assign that variable again piped into the rename function and put the new variable - what you want to rename the column = the existing variable (original column name)

Tests <- Tests %>% rename(Name = xlname)

  • Pipe Operator (%>%) which passes data from the output of the function to the left and puts it, by default, into the first parameter of the function on the right

  • Once you have that, you can go ahead and run that line

  • View the table again and now you can see that xlname has been changed to Name (on the right side there is a window with the Environment tab, underneath is Data and there should be your table)

  • Repeat process individually with the next columns or you can combine them within the same function as the following

Tests <- Tests %>% rename(Gender = xlsex, TestScores = xltestscores)

  • Once you have that, you can run the line and view the newly changed column titles on the table

For a more step by step visual tutorial, there will be a video (stay tuned).

Check out this blog where you can change negatives numbers to positive in Google Sheets.

#rstudio #tibble #r #coding #program #language #statistical #computing #howto #rename #columns #table #data #qbo #excel #bookkeeping #financialservices #accounting #financialgps

  • Grey LinkedIn Icon
  • Grey Facebook Icon
  • Grey Instagram Icon

©2019 All Rights Reserved 

Philadelphia, PA | New York City, NYC | hello@FinancialGPS.co