How do you get help for an R function? Show me by getting help for the function mean.
How do you install and load an R package? Show me by creating a “Chord Diagram” using the function chordDiagram from the package circlize. Hint: Look at the help menu for the function and copy and paste the examples at the bottom.
There are three problems with the following code. Please find and correct the errors!
my data <- rnorm(100, mean = 0, sd = -1)
data.mean <- mean(my data)
"data.mean" # Print the value of data.mean
Create a vector called “mixed” with the values [“batman”, 20, “superman”, 10]. Now print the vector “mixed” - did anything in the vector change and if so, why?
Do a Google search to figure out the high temperature in Konstanz over the past 7 days. Write and store the values in a vector called “celcius”.
Convert the temperatures you stored to Fahrenheit using basic math operations. Call this vector “fahrenheit.” Hint: The formula to convert celcius to Fahrenheit is y = x * 9/5 + 32, where x is the temperature in celcius and y is the temperature in Fahrenheit.
Create the following sequence of numbers [10, 20, 30, 40, 50, 12, 13, 14, 97, 107, 117, 127, 137] using a combination of the c(), a:b, and seq() functions.
Create the sequence [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5] using a combination of the rep() and a:b functions
Create a vector called “squares” that contains the squares (x^2) of the values from 1 to 10. What is the mean and median value of the squares from 1 to 10?
Create a vector called “normal.samp” with 50 values from a Normal distribution with population mean 30 and standard deviation 5
Create a vector with 25 values from a Uniform distribution where there minimum and maximum are determined by the results in your previous vector called “normal.samp”. Specifically, make the the minimum value of the distribution to be the minimum value of “normal.samp” and the maximum value of the distribution to be the median of “normal.samp.”
What should the mean and standard deviation of the sum of two standard normal distributions be? Test your prediction by generating the relevant data.
Simulate 100 flips of a fair coin. Do this once using the values 0 and 1 for heads and tails, and once with the string values “Heads” and “Tails”.
Simulate a sample of 20 balls drawn from a bag containing 30 red balls, 50 green balls, and 20 yellow balls. Do this once with replacement (call the vector: “balls.replacement”), and once without replacement (call the vector: “balls.noreplacement”).
Generate a sample of size N from a uniform distribution with minimum X and maximum Y. Select the value of X by drawing a random number from the set c(4, 7, 2, 8, 3). Select the value of Y by drawing a random number from the set c(20, 34, 12, 45). Select the value of N by drawing a random integer between 10 and 100.