0% found this document useful (0 votes)
5 views5 pages

Practical 3

The document contains R code for data analysis, including creating data frames, calculating summary statistics, and generating plots. It includes operations on tree data and student marks, as well as attempts to read CSV files and handle errors in functions. The code also demonstrates the use of functions for calculating mean, median, and results based on total marks.

Uploaded by

ffreakscience
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views5 pages

Practical 3

The document contains R code for data analysis, including creating data frames, calculating summary statistics, and generating plots. It includes operations on tree data and student marks, as well as attempts to read CSV files and handle errors in functions. The code also demonstrates the use of functions for calculating mean, median, and results based on total marks.

Uploaded by

ffreakscience
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

> A1_PRACTICAL_NO<-3

> A2_NAME<-"MUKUL MANOHAR BHOSALE"


> A3_MIS<-612515177
> A4_DIVISION_BATCH<-"DIVISION-2, BATCH-4"
> A5_DATE<-"05-02-2026"
> data()
> table1<- [Link](trees)
> summary_table1<-summary(table1)
> summary(table1)
Girth Height Volume
Min. : 8.30 Min. :63 Min. :10.20
1st Qu.:11.05 1st Qu.:72 1st Qu.:19.40
Median :12.90 Median :76 Median :24.20
Mean :13.25 Mean :76 Mean :30.17
3rd Qu.:15.25 3rd Qu.:80 3rd Qu.:37.30
Max. :20.60 Max. :87 Max. :77.00
> table1_class_girth<-class(table1$Girth)
> table1_class_height<-class(table1$Height)
> table1_class_volume<-class(table1$Volume)
> head_trees<-head(table1)
> tail_tress<-tail(table1)
> table1_max_girth<-max(table1$Girth)
> table1_min_girth<-min(table1$Girth)
> table1_max_height<-max(table1$Height)
> table1_min_height<-min(table1$Height)
> table1_max_volume<-max(table1$Volume)
> table1_min_volume<-min(table1$Volume)
> #QUESTION2
> table<-[Link]("[Link]")
> book1_mean_year<-mean(table$YEAR)
> book1_mean_ug_pg<-mean(table$[Link])
> book1_mean_hsc_ug<-mean(table$[Link])
> book1_mean_matric<-mean(table$MATRIC)
> book1_mean_total<-mean(table$TOTAL)
> book1_median_ug_pg<-median(table$[Link])
> book1_median_hsc_ug<-median(table$[Link])
> book1_median_matric<-median(table$MATRIC)
> book1_median_total<-median(table$TOTAL)
> book1_mode_ug_pg<-getmode(table$[Link])
Error in getmode(table$[Link]) : could not find function "getmode"

> book1_mode_hsc_ug<-getmode(table$[Link])
Error in getmode(table$[Link]) : could not find function "getmode"

> book1_mode_matir<-getmode(table$MATRIC)
Error in getmode(table$MATRIC) : could not find function "getmode"

> book1_mode_total<-getmode(table$TOTAL)
Error in getmode(table$TOTAL) : could not find function "getmode"
> chartpie<-pie(table$[Link])
> chartpie_total<-pie(table$TOTAL)
> summary_table<-summary(table)
> plot_table<-plot(table$[Link])
> book1_max_ug_pg<-max(table$[Link])
> book1_min_ug_pg<-min(table$[Link])
> book1_range_ug_pg<-range(table$[Link])
> book1_max_hsc_ug<-max(table$[Link])
> book1_min_hsc_ug<-min(table$[Link])
> book1_range_hsc_ug<-range(table$[Link])
> book1_max_matric<-max(table$MATRIC)
> book1_min_matric<-min(table$MATRIC)
> book1_range_matric<-range(table$MATRIC)
> his_table<-hist(table)
Error in [Link](table) : 'x' must be numeric

> new_col_df<- cbind("student_data",total= data(student_data $marks_maths)+


data(student_data$marks_physics)+data(student_data $marks_chemistry))
Error in data(student_data$marks_maths) + data(student_data$marks_physics) :
non-numeric argument to binary operator
In addition: Warning messages:
1: In data(student_data$marks_maths) :
data set ‘student_data$marks_maths’ not found
2: In data(student_data$marks_physics) :
data set ‘student_data$marks_physics’ not found

> data1<- data("co2")


> data()
> data1<-data("CO2")
> table1<-[Link](co2)
> student_data<- [Link](
+ mis<-c(01,02,03,04,05,06),
+ Name = c("A", "B", "C", "D", "E"),
+ Marks_chemistry = c(25,27,15,30,17),
+ Marks_maths= c(15,27,20,28,13),
+ Marks_physics= c(20,30,15,19,22)
+ )
Error in [Link](mis <- c(1, 2, 3, 4, 5, 6), Name = c("A", "B", "C", :
arguments imply differing number of rows: 6, 5

> student_data<- [Link](


+ mis<-c(01,02,03,04,05,),
+ Name = c("A", "B", "C", "D", "E",),
+ Marks_chemistry = c(25,27,15,30,17),
+ Marks_maths= c(15,27,20,28,13),
+ Marks_physics= c(20,30,15,19,22)
+ )
Error in c(1, 2, 3, 4, 5, ) : argument 6 is empty

> student_data<- [Link](


+ mis<-c(01,02,03,04,05),
+ Name = c("A", "B", "C", "D", "E",),
+ Marks_chemistry = c(25,27,15,30,17),
+ Marks_maths= c(15,27,20,28,13),
+ Marks_physics= c(20,30,15,19,22)
+ )
Error in c("A", "B", "C", "D", "E", ) : argument 6 is empty

> student_data<- [Link](


+ mis<-c(01,02,03,04,05),
+ Name = c("A", "B", "C", "D", "E"),
+ Marks_chemistry = c(25,27,15,30,17),
+ Marks_maths= c(15,27,20,28,13),
+ Marks_physics= c(20,30,15,19,22)
+ )
> view(student_data)
Error in view(student_data) : could not find function "view"

> view(student_data)
Error in view(student_data) : could not find function "view"

> View(student_data)
> student_data<- [Link](
+ mis=-c(01,02,03,04,05),
+ Name = c("A", "B", "C", "D", "E"),
+ Marks_chemistry = c(25,27,15,30,17),
+ Marks_maths= c(15,27,20,28,13),
+ Marks_physics= c(20,30,15,19,22)
+ )
> student_data<- [Link](
+ mis=c(01,02,03,04,05),
+ Name = c("A", "B", "C", "D", "E"),
+ Marks_chemistry = c(25,27,15,30,17),
+ Marks_maths= c(15,27,20,28,13),
+ Marks_physics= c(20,30,15,19,22)
+ )
> student_data$total_marks=
student_data$Marks_chemistry+student_data$Marks_maths+student_data$Marks_physics
> View(student_data)
> result_function <- function(total) {
+ if(total>30){
+ return("pass")
+ }else{
+ return("fail")
+ }
+ }
> student_data$result=result_function(student_data)
Error in if (total > 30) { : the condition has length > 1

> if(total_marks>30){
+ return("pass")
+ }else{
+ return("fail")
+ }
Error: object 'total_marks' not found

> if(total>30){
+ return("pass")
+ }else{
+ return("fail")
+ }
Error: object 'total' not found

> result_function<- function(total){


+ if (total>30){
+ returnValue("pass")
+ }
+ else{
+ return("fail")
+ }
+ }
> student_data$result=result_function(student_data$total_marks)
Error in if (total > 30) { : the condition has length > 1

> result_function <- function(total) {


+ ifelse(total > 30, "pass", "fail")
+ }
> student_data$result=result_function(student_data$total_marks)
> q3_Student_Data$Result <- result_function(q3_Student_Data$Total_Marks)
Error: object 'q3_Student_Data' not found
Called from: ifelse(total > 30, "pass", "fail")

Browse[1]> student_data_summary<-summary(student_data)
Browse[1]> student_data_summary<-summary(student_data)
Browse[1]> hfaeb
Error during wrapup: object 'hfaeb' not found
Error: no more error handlers available (recursive errors?); invoking 'abort'
restart
Browse[1]> student_Data$Result <- result_function(student_data$)
Error during wrapup: unexpected ')' in "student_Data$Result <-
result_function(student_data$)"
Error: no more error handlers available (recursive errors?); invoking 'abort'
restart
Browse[1]> Q
> student_data_summary<- summary(student_data)
> summary(student_data)
mis Name Marks_chemistry Marks_maths Marks_physics
total_marks
Min. :1 Length:5 Min. :15.0 Min. :13.0 Min. :15.0 Min.
:50.0
1st Qu.:2 Class :character 1st Qu.:17.0 1st Qu.:15.0 1st Qu.:19.0 1st
Qu.:52.0
Median :3 Mode :character Median :25.0 Median :20.0 Median :20.0
Median :60.0
Mean :3 Mean :22.8 Mean :20.6 Mean :21.2 Mean
:64.6
3rd Qu.:4 3rd Qu.:27.0 3rd Qu.:27.0 3rd Qu.:22.0 3rd
Qu.:77.0
Max. :5 Max. :30.0 Max. :28.0 Max. :30.0 Max.
:84.0
result
Length:5
Class :character
Mode :character

> q4_vector <- c(2.3,4.4,5,5,6,6.5,6.5,6.5,8.6,9.2,4.4,4.4,5.4,5,2,4.4)


> q4_mean <- mean(q4)
Error: object 'q4' not found

> q4_mean <- mean(q4_vector)


> q4_median <- median(q4_vector)
> q4_mode <- getmode(q4_vector)
Error in getmode(q4_vector) : could not find function "getmode"

> q4_min <- min(q4_vector)


> q4_max <- max(q4_vector)
> q4_range <- range(q4_vector)
> q4_hist <- hist(q4_vector)
> q4_bar <- barplot(q4_vector)
> data_tooth <- ToothGrowth
> View(data_tooth)
> q5_structure <- str(data_tooth)
'[Link]': 60 obs. of 3 variables:
$ len : num 4.2 11.5 7.3 5.8 6.4 10 11.2 11.2 5.2 7 ...
$ supp: Factor w/ 2 levels "OJ","VC": 2 2 2 2 2 2 2 2 2 2 ...
$ dose: num 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 ...
> q5_class_len <- class(data_tooth$len)
> q5_class_supp <- class(data_tooth$supp)
> q5_class_dose <- class(data_tooth$dose)
> q5_bar <- barplot(data_tooth$dose)
> q5_scatter <- plot(data_tooth$len, data_tooth$dose)

You might also like