Question

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 1st missing is “5” so replace 1st missing by “5”.

Give R expressions that return a vector of the data set after replacing missing values randomly by selecting values randomly from a vector in (a).

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)

Give R expressions that return a vector of the data set without missing values:
x[!is.na(x)]

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”.
x[is.na(x)] <- x[which(is.na(x))-1]

Give R expressions that return a vector of the data set after replacing missing values randomly by selecting values randomly from a vector in (a).
x[is.na(x)] <- x[sample(x)]

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
. 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...
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.
Here is a data set summarized as a stem-and-leaf plot: 3   00014558899 4 001222566677899 5 05679...
Here is a data set summarized as a stem-and-leaf plot: 3   00014558899 4 001222566677899 5 05679 6 789 How many data values are in this data set? n=n= What is the minimum value in the last class? What is the minimum value in the entire sample? How many of the original values are greater than 40?
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?
Consider the following small data set. Subject x y 1 15 31 2 7 19 3...
Consider the following small data set. Subject x y 1 15 31 2 7 19 3 10 25 4 4 28 5 5 31 Find the linear correlation coefficient. r=
A new set of measurements are obtained with the values 0, 1,2, 3, 4, 5, 6,...
A new set of measurements are obtained with the values 0, 1,2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 and these values are found 0, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 0 times, respectively. Find the the average value of the measurements and the statistical uncertainty based on the measurements.
Here is a data set summarized as a stem-and-leaf plot: 3   00024677779 4 0003445677888899 5 04456...
Here is a data set summarized as a stem-and-leaf plot: 3   00024677779 4 0003445677888899 5 04456 6 669 How many data values are in this data set? n=n= What is the minimum value in the last class? What is the minimum value in the entire sample? How many of the original values are greater than 40? The test scores for two algebra classes are shown in the Stem and Leaf below. Test Scores Period 9 Period 10 9 8 2...
1. Use the following data for question 1 (Suppose we have the population data set) (3...
1. Use the following data for question 1 (Suppose we have the population data set) (3 points). 6, 9, 9, 10, 8, 9, 4, 7, 10, 9, 5, 8, 10, 6, 9, 6, 8, 8, 7, 9 -Provide a frequency distribution table -Report the mean, mode, median, range, variance and SD -Provide a histogram here to check the distribution shape: Explanation:
Data Set: x y 0 4 2 2 2 0 5 -2 6 1 1. Find...
Data Set: x y 0 4 2 2 2 0 5 -2 6 1 1. Find intercept b0 2. Find slope B1 3. Find the best fitted linear regression equation 4.Graph observations 5.Graph the linear equation on the same plot 6. Find the coefficient of Determination r² 7. Find the linear correlation coefficient r 8.Interpret r (the correlation between x & y)
Consider the following sample data set: 1 2 3 4 4 5 1. What is the...
Consider the following sample data set: 1 2 3 4 4 5 1. What is the mode? 2. What is the median? 3. What is the mean? 4. What is the sample standard deviation? Interpret it? Show your algebra. 5. Find the IQR and find if there is any outlier?
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT