Question

. Suppose you have the following data set with missing values: 1 2 3 4 5...

. Suppose you have the following data set with missing values: 1 2 3 4 5 NA 7 6 NA 5 4 3 NA 2 6 10 14 NA 4 4 4 NA 10 13 16 19 NA

(a) Give R expressions that return a vector of the data set without missing values

(b) Give R expressions that return a vector of the data set after replacing missing values by the last non-missing values. For example, the last non-missing value of the 1st missing is “5” so replace 1st missing by “5”

Homework Answers

Answer #1

> x <- c(1,2,3,4,5,NA,7,6,NA,5,4,3,NA,2,6,10,14,NA,4,4,4,NA,10,13,16,19,NA);x
[1] 1 2 3 4 5 NA 7 6 NA 5 4 3 NA 2 6 10 14
[18] NA 4 4 4 NA 10 13 16 19 NA
a)

> x1 <- na.omit(x) ; x1
[1] 1 2 3 4 5 7 6 5 4 3 2 6 10 14 4 4 4
[18] 10 13 16 19
attr(,"na.action")
[1] 6 9 13 18 22 27
attr(,"class")
[1] "omit"
> x[6]
[1] NA
b)

> x[c(6,9,13,18,22,27)] <- x[c(5,8,12,17,21,26)]
> x
[1] 1 2 3 4 5 5 7 6 6 5 4 3 3 2 6 10 14
[18] 14 4 4 4 4 10 13 16 19 19

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
5. Suppose you have the following data set with missing values: 1 2 3 4 5...
5. Suppose you have the following data set with missing values: 1 2 3 4 5 NA 7 6 NA 5 4 3 NA 2 6 10 14 NA 4 4 4 NA 10 13 16 19 NA Give R expressions that return a vector of the data set without missing values Give R expressions that return a vector of the data set after replacing missing values by the last non-missing values. For example, the last non-missing value of the...
For the following set of data, X Y 1 0 2 2 3 4 4 6...
For the following set of data, X Y 1 0 2 2 3 4 4 6 5 8 a. Compute the Pearson correlation, r, for this data set. b. Re-arrange the Y scores so that the value of r = –1.00.
Let S be the universal set, where: S = { 1 , 2 , 3 ,...
Let S be the universal set, where: S = { 1 , 2 , 3 , ... , 18 , 19 , 20 } Let sets A and B be subsets of S, where: Set A = { 2 , 5 , 6 , 10 , 16 , 17 } Set B = { 5 , 6 , 9 , 11 , 15 , 16 , 17 , 18 , 20 } C = { 2 , 3 , 4...
4. Let set U = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,...
4. Let set U = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20} set A = numbers in U that divide into 12 with no remainder, set B = numbers in U that divide into 16 with no remainder, and set C = the numbers in U that divide into 20 with no remainder. a. Made a Venn diagram showing the elements of the sets U, A,...
4.Construct a B+-tree for the following set of values: (2, 3, 5, 7, 11, 17, 19,...
4.Construct a B+-tree for the following set of values: (2, 3, 5, 7, 11, 17, 19, 23, 29, 31). Assume that the tree is initially empty and the values are added in ascending order. Let the degree of the tree be four, i.e. at most four pointers are allowed in any node. In your answer show the final tree. 5.Show your tree from from question 4 mentioned above after we insert 10. 6.Show your tree from from question 4 mentioned...
Given the following data set, find the Quartiles:  {1, 1, 4, 5, 6, 6, 7, 8, 10,...
Given the following data set, find the Quartiles:  {1, 1, 4, 5, 6, 6, 7, 8, 10, 11, 13, 14, 15, 16}
The following data is X-Bar and R values for 12 samples of size n = 5....
The following data is X-Bar and R values for 12 samples of size n = 5. They were taken from a process measuring various inductance values for a new production line of high fidelity speakers. Subgroup No., (X-Bar), ((Range)) 1 (345) ((13)), 2 (347) ((14)), 3 (350) ((12)), 4 (346) ((11)), 5 (350) ((15)), 6 (345) ((16)), 7 (349)((14)), 8 (348) ((13)), 9 (348)((12)), 10 (354) ((15)), 11 (352) ((13)), 12 (355) ((16)) Create X-Bar and R control charts from...
Given the data set A = {5, 4, 16, 14, 2, 2, 11, 4, 5, 8,...
Given the data set A = {5, 4, 16, 14, 2, 2, 11, 4, 5, 8, 3, 1, 12, 15, 13}, which is the data of a sample taken from a larger population Calculate the mean deviation (5 pts) Calculate the variance (5 pt Calculate the standard deviation (5 pts)
Consider the following two sample data sets. Set 1: 4     5     7    6    8 Set 2:...
Consider the following two sample data sets. Set 1: 4     5     7    6    8 Set 2: 7    19   12    4    2 a. Calculate the coefficient of variation for each data set. b. Which data set has more​ variability?
A data set contains the following seven values. 13 4 6 18 2 5 9 (Round...
A data set contains the following seven values. 13 4 6 18 2 5 9 (Round the intermediate values to 4 decimal places.) a. Find the range. b. Find the mean absolute deviation. (Round your answer to 4 decimal places.) c. Find the population variance. (Round your answer to 4 decimal places.) d. Find the population standard deviation. (Round your answer to 4 decimal places.) e. Find the interquartile range. f. Find the z score for each value. (Round your...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT