Basic R Programs for Beginners
Basic R Programs for Beginners - Important Points
16. | What is the output of the following R code snippet? x <- c(1, 2, 3, 4, 5) |
---|
A. A data frame with three columns: y, mean_x, and sd_x, containing the unique values of y in the z data frame, along with the mean and standard deviation of the x values for each value of y.
B. A data frame with two columns: mean_x and sd_x, containing the mean and standard deviation of the x values in the z data frame, grouped by the y values.
C. An error message, because the group_by function can only be used on numeric columns.
D. An error message, because the summarize function cannot be used on grouped data.
View Answer Discuss Work SpaceAnswer: option a
Explanation:
17. | What is the output of the following R code snippet? x <- c(1, 2, 3, 4, 5) |
---|
A. A scatterplot with points at the (x, y) coordinates of the data in the z data frame.
B. A scatterplot with points at the (y, x) coordinates of the data in the z data frame.
C. An error message, because ggplot2 cannot be used with data frames.
D. An error message, because geom_point() cannot be used with non-numeric data.
View Answer Discuss Work SpaceAnswer: option a
Explanation:
18. | What is the output of the following R code snippet? x <- c(1, 2, 3, 4, 5) |
---|
A. A bar chart with bars at the y-axis labels "one", "two", "three", "four", and "five", with heights corresponding to the x values in the z data frame.
B. A bar chart with bars at the x-axis labels "one", "two", "three", "four", and "five", with heights corresponding to the y values in the z data frame.
C. An error message, because ggplot2 cannot be used with non-numeric data.
D. An error message, because the geom_bar function cannot be used with non-numeric data.
View Answer Discuss Work SpaceAnswer: option a
Explanation:
19. | What is the output of the following R code snippet? x <- c(1, 2, 3, 4, 5) |
---|
A. A boxplot with boxes at the y-axis labels "one", "two", "three", "four", and "five", with widths corresponding to the x values in the z data frame.
B. A boxplot with boxes at the x-axis labels "one", "two", "three", "four", and "five", with heights corresponding to the y values in the z data frame.
C. An error message, because ggplot2 cannot be used with non-numeric data.
D. An error message, because the geom_boxplot function cannot be used with non-numeric data.
View Answer Discuss Work SpaceAnswer: option b
Explanation: