The following is a line of R commands and the corresponding output for an object named “x” in an R Workspace: > class(x); dim(x); colMeans(x); length(x); mean(x); [1] ”data.frame” [1] 15 2 height weight 65.0000 136.7333 [1] 2 [1] NA Warning message: 1 In mean.default(x) : argument is not numeric or logical: returning NA ———— Using the above information, answer the following questions:
(a) How many variables are there in the object x? What are they?
(b) How many observations are there in the object x?
(c) What is the mean of x[,3]?
(d) Compute the sum of each column of x.
(a) How many variables are there in the object x? What are
they?
ans: there are 2 variables in x, which are height, weight
(b) How many observations are there in the object x?
ans:there are 15 observations in x
(c) What is the mean of x[,3]?
ans: There are only 2 columns in x, so mean of 3rd column can not
be calculated
(d) Compute the sum of each column of x.
ans: we know the average of each column, we also know that there
are 15 rows. using this we can calculate the sum
1st column=> sum/15=65.0000=> sum = 15*65=975
2nd column=> sum/15=136.7333=> sum=15*136.7333=2050.9995
Get Answers For Free
Most questions answered within 1 hours.