Renaming the data variable
The use of a data frame enables the user to select and filter data by row names and column names. As not all imported datasets contain row names and column names, we need to rename this dataset with a built-in naming function.
Getting ready
In this recipe, you need to prepare your environment with R installed and a computer that can access the Internet.
How to do it…
Perform the following steps to rename data:
First, download
employees.csv
from the GitHub link https://github.com/ywchiu/rcookbook/raw/master/chapter3/employees.csv:> download.file("https://github.com/ywchiu/rcookbook/raw/master/chapter3/employees.csv", " employees.csv")
Additionally, download
salaries.csv
from the GitHub link https://github.com/ywchiu/rcookbook/raw/master/chapter3/salaries.csv:> download.file("https://github.com/ywchiu/rcookbook/raw/master/chapter3/salaries.csv", "salaries.csv")
Next, read the file into an R session with the
read.csv
function:> employees <- read.csv('employees...