-
Book Overview & Buying
-
Table Of Contents
R for Data Science Cookbook (n)
By :
For those of you familiar with databases, you may already know how to perform an insert operation to append a new record to the dataset. Alternatively, you can use an alter operation to add a new column (attribute) into a table. In R, you can also perform insert and alter operations but much more easily. We will introduce the rbind and cbind function in this recipe so that you can easily append a new record or new attribute to the current dataset with R.
Refer to the Converting data types recipe and convert each attribute of imported data into the proper data type. Also, rename the columns of the employees and salaries datasets by following the steps from the Renaming the data variable recipe.
Perform the following steps to add a new record or new variable into the dataset:
First, use rbind to insert a new record to employees:
> employees <- rbind(employees, c(10011, '1960-01-01', 'Jhon', 'Doe', 'M', '1988-01-01'))
We can then reassign the...
Change the font size
Change margin width
Change background colour