1. Math
  2. Statistics And Probability
  3. what is the r code and result in rstudio or...

Question: what is the r code and result in rstudio or...

Question details
What is the R code and result in Rstudio or R

1. Define a character vector in R as follows: y - c(a, bc, def) a. Report the output of the following function: length(y);ya;yb b. nchar(x) takes a character vector x as an argument and returns a vector whose elements contain the sizes of the corresponding elements of x. Report the output of nchar(y) 2. Define a numeric vector in R as follows: z=c(3,7,1,2) a. Report the output of the following function: b. which(x > 2) returns the indices of which the expression r>2 is true. Report the output of which(z <= 3) 3. To understand coercion between different data types, report the output of the following R codes a. x = c(T, F, T); c(1.2, x); 1 + x; c. y -c(3, 2); c(1.2,y); c(1.2, as.numeric(y)) 4. To understand NA (not available) in R, consider a. NA is a recognized argument in R, report the output of c(3, NA, NA);x; b. When numerical operation involves NA or missing value, the outcome will also be NA or missing. Report the output of x c(1,3, NA); mean(x) c. We can remove the missing values and then calculate the mean of the remaining elements. Report the output of x = c(1, 3, NA); mean(z, na.rm = TRUE)
Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution