Lab 6 A
Lab 6 A
Lab 6a- Create, display, access and modify using data frame
Learning Outcomes
At the end of the session, you will be able to:
• Creating data frame and displaying values from data frame
• Accessing values in data frame and expanding row and column of data frame
Activity
1. Creating data frame
1.1. Create the data frame
• Write and run the following in R. Make your conclusion about the code:
1.2. Creating a data frame from matrix and renaming the column
• Write and run the following in R. Make your conclusion about the code:
print(emp.data)
• Or click the ‘table icon’ below. Identify the R code written in R Console.
• Make your conclusion about the difference in both ways of displaying the data
frame.
TEB2164 Introduction to Data Science
Lab 6a- Create, display, access and modify using data frame
print(emp.data$salary)
print(emp.data[["salary"]])
print(emp.data[3])
3.2. Extract the first two rows and then all columns
• Write and run the following in R. Make your conclusion about the code:
5. Extra: Create table below as data frame in R. Modify the structure of the data frame by
adding more rows and columns. Challenge yourself to add various datatype (string, int,
date, etc.) into the table.