R Program Problem: please answer and explain this question step by step in detai
ID: 3221793 • Letter: R
Question
R Program Problem: please answer and explain this question step by step in detail using the program R, I am not very sure how to use program R, so please explain in detail
To begin, create an object called "Name" that is a list containing the names of all group members. You will need to use quotation marks around each name to identify the input as text. This problem asks you to manually create a list of data values called "x1' (that's a and one) and perform some basic computations and manipulations with that list. Make sure that you are using the object names EXACTLY as stated here and that the objects are saved to the workspace file that you submit. (a) Create an object named "x1' that is a list consisting of the five data values {1,3,5,6,6,7,9 (b) Use the mean function to compute the mean of x1' and assign that value to the object xlave' (c) Use the median function to compute the median of x1' and assign that value to the object x1med' (d) Use the sd function to compute the standard deviation of x1' and assign that value to the object xlsd. (e) Add the five data values t1, 2,4,8,8) to the end of 'x1' and assign that new list to the object x1new (f) Use the length function to compute the number of data values in x1' and assign that value to the objects 'x1len'.Explanation / Answer
Solution:-
R programming codes are:-
(a)
x1 <- list(c(1,2,3,4,5))
list()<- It is a finction to create list in R.
(b)
x1ave <- lapply(x1,mean)
The syntax of lapply() is
lapply(X, FUN, ...)
where X = a list object
FUN = the function to be applied to each element of X
lapply() <- This function is used to returns a list of the same length as X, each element of which is the result of applying FUN to the corresponding element of X.
(c)
x1med <- lapply(x1,median)
(d)
x1sd <- lapply(x1,sd)
(e)
x2 <- list(c(1,2,4,8,8))
x1new <- mapply(append,x1,x2,SIMPLIFY =F)
The syntax of mapply() is
mapply(FUN, ...,, SIMPLIFY = TRUE)
mapply() <- It applies FUN to the first elements , the second elements, the third elements, and so on.
SIMPLIFY<- logical or character string; attempt to reduce the result to a vector, matrix or higher dimensional array.
(f)
x1len <- lapply(x1,length)
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.