Waiting for answer This question has not been answered yet. You can hire a professional tutor to get the answer.

QUESTION

*]:pointer-events-auto scroll-mt-[calc(var(--header-height)+min(200px,max(70px,20svh)))]" tabindex="-1" dir="auto" data-turn-id="1efd220b-ec94-4291-9b3b-481f653f21f0" data-testid="conversation-turn-4"

*]:pointer-events-auto scroll-mt-[calc(var(--header-height)+min(200px,max(70px,20svh)))]" tabindex="-1" dir="auto" data-turn-id="1efd220b-ec94-4291-9b3b-481f653f21f0" data-testid="conversation-turn-4" data-scroll-anchor="true" data-turn="assistant">Question 1

Running the following code inside a Colab cell will generate a vector x with numerous random values:

set.seed(17679) n <- sample(1e+5 : 1e+7, size = 1) x <- runif(n, 0, 1e+7)

Without displaying the contents of the vector, write some code that shows how many values/elements it contains.

Question 2

From the previous question, use R code to determine what the first and last value/element of the vector x is.

Question 3

Do some internet sleuthing and state what runif() does, what sample() does, and what 1e+5 and 1e+7 mean numerically in decimal form.

Question 4

Use R code to create a dataframe that contains information about your top 10 favourite songs.The dataframe should have three columns:

Artist — the name of the artist/band

Song — the name of the song

Album — the name of the album the song appeared on

Display the dataframe you create.

Question 5

Seligman, Nolen-Hecksema, Thornton, and Thornton (1990) conducted a study with members of a university swim team.Using a questionnaire, they classified participants as optimists or pessimists. Each swimmer first completed their best event, but the researchers falsified their recorded time to make it appear worse than it actually was, thereby inducing disappointment.

Thirty minutes later, swimmers repeated the same event. The researchers predicted that pessimists would perform worse on the second trial, whereas optimists would improve.

The dependent variable was calculated as the ratio of the two times:

time1time2time2​time1​​

Thus, a value greater than 1.0 indicates faster times on the second trial.

The times are as follows:

Optimists:

0.986, 1.108, 1.08, 0.952, 0.998, 1.017, 1.08, 1.026, 1.045, 0.996, 0.923, 1, 1.003, 0.934, 1.009, 1.065, 1.053, 1.108, 0.985, 1.001, 0.924, 0.968, 1.048, 1.027, 1.004, 0.936, 1.04

Pessimists:

0.983, 0.947, 0.932, 1.078, 0.914, 0.955, 0.962, 0.944, 0.941, 0.831, 0.936, 0.995, 0.872, 0.997, 0.983, 1.105, 1.116, 0.997, 0.96, 1.045, 1.095, 0.944, 1.039, 0.927, 0.988, 1.015, 1.045, 0.864, 0.982, 0.915, 1.047

Without using the function mean(), calculate the mean for each group (optimists and pessimists).Based on the means, does it look as if the researchers were correct?

Question 6

Is the study described in the previous question an experiment? Why or why not?

Question 7

Describe what happens to the mean for the optimist and pessimist data respectively if each value has 5 added to it.Show some R code to support your statement.

Question 8

Describe what happens to the mean for the optimist and pessimist data respectively if each value is multiplied by 2.Show some R code to support your statement.

Question 9

Sixty-five participants were asked how much sleep they believe they get on average.Fourteen people answered that they generally sleep about six hours;nineteen about seven hours;twelve get around four hours;nine get about three hours;and eleven get about eight hours.

Calculate the mean.

Question 10

The following dataframe contains the total number of deaths worldwide as a result of earthquakes from 2000 to 2012:

year   deaths 2000     231 2001   21357 2002   11685 2003   33819 2004  228802 2005   88003 2006    6605 2007     712 2008   88011 2009    1790 2010  320120 2011   21953 2012     768

a. Recreate the dataframe using R.b. What percentage of deaths occurred before 2001?c. What percentage of deaths occurred from 2003 to 2010 inclusive?

Question 11

a. Create a plot using the dataframe from Question 10.b. Re-create the plot again, but this time transform the x-axis data using a base-5 logarithm.c. Re-create the plot again, but this time transform the y-axis data using a base-5 logarithm.d. Re-create the plot one more time and transform both axes’ data with a base-5 logarithm.

Question 12

There are two problems in the code below that cause it to produce errors when run.Both problems are subtle — treat this like a “Where’s Waldo” puzzle and look very carefully.

set.seed(20462) values <- round(runif(20, -10, 10)) threshold <- 0 filtered <- values[values > threshold] N       <- length(filtered) sum     <- sum(filtered) minimum <- min(filtered) mean    <- mean(filtered) med     <- median(filtered) sd      <- sd(filtered) IQR     <- IQR(filtered) vals    <- paste(filtered, collapse = ", ") filtered_stats <- data.frame(  N, sum, minimum, mean, med sd, IQR, vals ) filtered_stats

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question