I have a csv dataset for student of ID 229, where:
StudID Score Weight
229 65 51
229 45 43
229 82 79
and I'm going to calculate the mean of score and weight of student, where I want to obtain as below:
Measurements Mean Value #Measurements and mean value are new column names
Score 64 #score and weight which used to be column names are now under measurements
Weight 57.67
So what i did so far is as below:
stud_data <- read.csv("student_weight.csv")
stud_mean <- colMeans(stud_data[2:3]) #finding the mean of only score and weight
which gives me the below when i print stud_mean:
Score Weight
64 57.67
Is it possible to format output in a way i would obtain:
Measurements Mean Value #Measurements and Mean value are new column names
Score 64
Weight 57.67