



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Q1. Construct and modify a data frame in R language using Reassignment
Typology: Lab Reports
1 / 6
This page cannot be seen from the preview
Don't miss anything!




Artificial Intelligence and Machine Learning Lab (CSP- 303 ) Practical- 5 Submitted By: Samridh Garg 19BCS CSE-5(C) Submitted to: Er. Nilesh Bharati
Q1. Construct and modify a data frame in R language using Reassignment. Answer: Code: emp.data <- data.frame( emp_id = c (1:5), emp_name = c("Rick","Dan","Michelle","Ryan","Gary"), salary = c(623.3,515.2,611.0,729.0,843.25), start_date =as.Date(c("2012- 01 - 01","2013- 09 - 23","2014- 11 - 15","2014- 05 - 11", "2015- 03 - 27")), stringsAsFactors = FALSE )
print(emp.data) summary(emp.data)
Q2. Add rows and columns to an already constructed data frame.(useof:rbind,cbind) Answer: Code: emp.data <- data.frame( emp_id = c (1:5), emp_name = c("Rick","Dan","Michelle","Ryan","Gary"), salary = c(623.3,515.2,611.0,729.0,843.25), start_date =as.Date(c("2012- 01 - 01","2013- 09 - 23","2014- 11 - 15","2014- 05 - 11", "2015- 03 - 27")), stringsAsFactors = FALSE )
print(emp.data) summary(emp.data) #Add a new row New_row_DF1 <- rbind(emp.data, c("6","Silvestor stallone",750,"2012- 01 - 06"))
New_row_DF
New_col_DF1 <- cbind(emp.data, blood_sugar = c(100, 600, 180,250,400))
New_col_DF emp.data[1] emp.data$emp_name