a.
The output of the function is,
> length(y);y=="a";y=="b"
[1] 3
[1] TRUE FALSE FALSE
[1] FALSE FALSE FALSE
This shows that the length of vector y is 3.
The first element of y is "a"
None of the element of y is "b"
b.
> nchar(y)
[1] 1 2 3
The output shows that three elements of vector y are of length 1, 2 and 3.
2.
a.
The output of the function are
> (x
>=2)|(x<4);(x>=2)&(x<4);!(x<3)
[1] TRUE TRUE TRUE TRUE
[1] TRUE FALSE FALSE TRUE
[1] TRUE TRUE FALSE FALSE
The output displays TRUE for the elements of x which satisfies the boolean conditions else displays FALSE.
b.
> which(x <= 3)
[1] 1 3 4
The output shows that the element at position 1, 3, 4 are less than or equal to 3.
3.
a.
> x = c(T,F,T);c(1.2,x);1+x;
[1] 1.2 1.0 0.0 1.0
[1] 2 1 2
The output shows that the code c(1.2,x) coerced the boolean variable x to numeric variable.
1 + x code coerced the real number to integer.
b.
> x = c(T,F,T);y=c("3","2");c(1.2,x,y)
[1] "1.2" "TRUE" "FALSE" "TRUE" "3" "2"
Since, R coerce boolean variable, character and numeric variable to character variable.
c.
> y=c("3","2");c(1.2,y);c(1.2,as.numeric(y))
[1] "1.2" "3" "2"
[1] 1.2 3.0 2.0
The code c(1.2,y) coerce numeric variable to character variable.
When we convert y to numeric variable, 1.2 was not coerced to character variable.
4.
a.
> x = c(3,"NA",NA);x;
[1] "3" "NA" NA
Here "NA" is a character variable with value as NA.
NA is not applicable in R.
b.
> x = c(1,3,NA);mean(x)
[1] NA
The mean of x is NA because one of the element of x is NA.
c.
> x = c(1,3,NA);mean(x, na.rm = TRUE)
[1] 2
na.rm = TRUE parameter ignores NA value in the calculation of mean.
What is the R code and result in Rstudio or R 1. Define a character vector...
What is the Rcode and result in Rstudio 3. What is the difference between a vector and a list in R? What about the difference between a matrix and a dataframe in R? Without using R, provide the output from the following command in R: 16; d = array(c, dim = c(2,4, 2))an,2, 5. Explain the connection between z and y, where = qnorm(5); y = pnorm (0
What is the R code and result in Rstudio 1. The following data gives, for each amount by which an elastic band is stretched over the end of a ruler, the distance that the band moved when released: stretch 46 54 48 50 44 4 52 distance 148 182 173166 109 141 166 Create a data frame in R with two columns that contain "stretch and "dis tance" respectively. Plot the distance versus the stretch using plot) function What trend...
What is the code and result in Rstudio or R 1. Suppose we have a random sample 1.12, 0.44, -1.49, 0.02, 0.81, -1.34,1.34, 0.51,-0.12, 0.97. (a). Use two methods to find the sample mean (b). Use two methods to find the sample variance. (c). Find the sample standard deviation. 2. We can use function rt(n 100, df 2) to generate a random sample from a t-distribution with two degrees of freedom. The sample size is n 100. (a). Generate a...
Paste the R code for each exercise along with the answers. If: Age <- c(22, 25, 18, 20) Name <- c("James", "Mathew", "Olivia", "Stella") Gender <- c("M", "M", "F", "F") then what is the R-code for getting the following output: ## Age Name Gender ## 1 22 James M ## 2 25 Mathew M a. DataFrame = data.frame(c(Age), c(Name), c(Gender)) subset(DataFrame, Gender == "M") b. DataFrame = data.frame(c(Age),c(Name),c(Gender)) subset(Gender=="M"), eval=FALSE c. DataFrame = data.frame(Age,Name,Gender) subset(DataFrame,Gender=="M") d. DataFrame = data.frame(c(Age,Name,Gender))...
Problem 4 please. The vector space axioms are given in the 2nd image. Problem 4. Let V be a vector space over R. Prove that for any a, b E R and c E V with x ba mplies ах а Hint. Axiom (VS 8) will be needed in your proof. Definition 0.1. A vector space V over a field F is a set V with and addition operation + and scalar multiplication operation - by elements of F that...
Question 1: Vector Spaces and Subspaces (a) Show that (C(0, 1]), R, +,), the set of continuous functions from [0, 1 to R equipped with the usual function addition and scalar multiplication, is a vector space. (b) Let (V, K, +,-) be a vector space. Show that a non-empty subset W C V which is closed under and - necessarily contains the zero vector. (c) Is the set {(x,y)T: z,y E R, y a subspace of R2? Justify.
Evaluate the line integral ∫ F *dr where C is given by the vector function r(t). F(x, y, z) = (x + y2) i + xz j + (y + z) k, r(t) = t2i + t3j − 2t k, 0 ≤ t ≤ 2
Find the derivative, r'(t), of the vector function. r(t) = eti- j+ln(1 + 7t)k r'(t) = Find parametric equations for the tangent line to the curve with the given parametric equations at the specified point. T = 5e, y = te, c = tetp:/5, 0, 0) x(t), y(t), z(t) =
3. (10 total points) A particle travels along the intersection of (2) 1z=x+y (a) (2 points) Write the path of particle as a vector might find cos2(t)+ sin? (t) = 1 useful. function r(t) =< x(t),y(t), z(t) > of t. Hint: you (b) (4 points) Find the equation of the tangent plane of z = x+y at (1,3). (c) (4 points) Find the tangent line of the particle path at the point (1,0,1). 3. (10 total points) A particle travels...
Problem 1: Let y()- r(t+2)-r(t+1)+r(t)-r(t-1)-u(t-1)-r(t-2)+r(t-3), where r(t) is the ramp function. a) plot y(t) b) plot y'() c) Plot y(2t-3) d) calculate the energy of y(t) note: r(t) = t for t 0 and 0 for t < 0 Problem 2: Let x(t)s u(t)-u(t-2) and y(t) = t[u(t)-u(t-1)] a) b) plot x(t) and y(t) evaluate graphically and plot z(t) = x(t) * y(t) Problem 3: An LTI system has the impulse response h(t) = 5e-tu(t)-16e-2tu(t) + 13e-3t u(t) The input...