Q1. Construct and modify a data frame in R language using Reassignment, Lab Reports of Artificial Intelligence

Q1. Construct and modify a data frame in R language using Reassignment

Typology: Lab Reports

2021/2022

Uploaded on 03/29/2023

samridh-garg
samridh-garg 🇮🇳

4 documents

1 / 6

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Artificial Intelligence and Machine Learning Lab
(CSP-303)
Practical-5
Submitted By:
Samridh Garg
19BCS1815
CSE-5(C)
Submitted to:
Er. Nilesh Bharati
pf3
pf4
pf5

Partial preview of the text

Download Q1. Construct and modify a data frame in R language using Reassignment and more Lab Reports Artificial Intelligence in PDF only on Docsity!

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 the data frame.

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 the data frame.

print(emp.data) summary(emp.data) #Add a new row New_row_DF1 <- rbind(emp.data, c("6","Silvestor stallone",750,"2012- 01 - 06"))

Print the new row

New_row_DF

Add a new column

New_col_DF1 <- cbind(emp.data, blood_sugar = c(100, 600, 180,250,400))

Print the new column

New_col_DF emp.data[1] emp.data$emp_name