Question

In: Statistics and Probability

Need To Do this in R Studio...Here are the Instruction steps: 1. Using the 1:n construct,...

Need To Do this in R Studio...Here are the Instruction steps:

1. Using the 1:n construct, create the sequence 4,8,12, ..., 48.
2. Similarly, create the sequence 0,5,10,15, ..., 100.
3. Using a for() loop and the print() function, print the values 2,3,4,..., 7.
4. Using a for() loop and the print() function, print the values 8,11,14, ..., 26.
5. Create a vector with a length of 10. Then, using a for() loop, assign the values
3,6,9, ..., 30. to the vector.
6. (a) Create a vector x, with a length of 100.
(b) Then simulate rolling a pair of dice 100 times.
To do this, you can use, within a for() loop, the code: x[i] <- sample(c(1:6), 1, replace=T) + sample(c(1:6), 1, replace=T)
Each individual result will lie in the range 2--12.
Then, to see the distribution of your results, use the code: table(x)
(The function table() will create a frequency table for you)

Solutions

Expert Solution

Find the code below:

# Part (1)
(1:12)*4

# Part (2)
(0:20)*5

# Part (3)
for(i in 2:7){
  print(i)
}

# Part (4)
for(i in 2:8){
  print(3*i + 2)
}

# Part (5)
x = numeric(10)
for(i in 1:10){
  x[i] = 3*i
}
x

# Part (6)
# (a)
x = numeric(100)
# (b)
for(i in 1:100){
  x[i] = sample(c(1:6), 1, replace=T) + sample(c(1:6), 1, replace=T)
}
table(x)

Output:

.


Related Solutions

I want this to be solved using R studio or R software, please. Here is the...
I want this to be solved using R studio or R software, please. Here is the example: The data in stat4_prob5 present the performance of a chemical process as a function of sever controllable process variables. (a) Fit a multiple regression modelrelating CO2product (y) to total solvent (x1) and hydrogen consumption (x2) and report the fitted regression line. (b) Find a point estimatefor the variance term σ2. (c) Construct the ANOVA tableand test for the significance of the regression using...
Answer using R Studio Here we consider the amount of data needed to perform hypothesis testing....
Answer using R Studio Here we consider the amount of data needed to perform hypothesis testing. Suppose we are testing a coin using observations of tosses. We wish to test H0: p = 0.5 against an alternative of HA : p = 0.6 (in this question use one-sided tests only). How many tosses are needed to guarantee a size Æ∑ 0.05 and Ø∑ 0.2? Now generalize to consider HA : p = 0.5+delta. Choose sensible values for delta and quantify...
Perform the following tasks on R Studio/R Construct a function called conv3 which inputs a measurement...
Perform the following tasks on R Studio/R Construct a function called conv3 which inputs a measurement in centimeters and outputs the corresponding measurement in inches. However, if a negative value is entered as an input, no conversion of unit is done and an error message is printed instead.
USING R STUDIO- Write the r commands for the following. 1. Non-Linear Models 1.1 Load the...
USING R STUDIO- Write the r commands for the following. 1. Non-Linear Models 1.1 Load the {ISLR} and {GGally} libraries. Load and attach the College{ISLR} data set. [For you only]: Open the College data set and its help file and familiarize yourself with the data set and its fields. 1.2 Inspect the data with the ggpairs(){GGally} function, but do not run the ggpairs plots on all variables because it will take a very long time. Only include these variables in...
How do I do this in R Studio? 1 Students who performed poorly on a City...
How do I do this in R Studio? 1 Students who performed poorly on a City of New York Skills Assessment Test were enrolled in a summer math program. Scores of 10 students before and after the summer program were recorded. They were: Before = 18,18,21,18,18,20,23,23,21,17 After = 24,25,33,29,33,36,34,36,34,27 (Scores for individual students are in the same order in each list.) Did the NYC summer math program improve student performance significantly? 8. How many points did student scores improve on...
construct an AOV table including expected mean squares in R studio A study was designed to...
construct an AOV table including expected mean squares in R studio A study was designed to evaluate the effectiveness of new treatments to reduce the systolic blood pressure of patients determined to have high blood pressure. Three drugs were selected for evaluation. There are numerous nondrug treatments for reducing blood pressure including various combinations of a controlled diet, exercise programs, biofeedback and so on. the researchers randomly selected three non drug treatments for examination in the study. The age of...
Need to construct ANOVA table in R using the below information We have five groups and...
Need to construct ANOVA table in R using the below information We have five groups and three observations per group. The group means Exercise 3.4 are 6.5, 4.5, 5.7, 5.7, and 5.1, and the mean square for error is .75. Compute an ANOVA table using R for these data
How do I input this in R studio 1. Combine the following lists into a matrix...
How do I input this in R studio 1. Combine the following lists into a matrix called animals, where each list becomes a row: Cats = 2,2,4 Dogs = 1,2,1 Cows = 30,35,41 2. Add column names of “Farm A”, Farm B”, and “Farm C”. 3. Transpose the rows and columns in animals and store the result to a matrix called farms. 4. Display the contents of farms.
Perform the following tasks on R Studio Construct a function called conv1 which inputs a measurement...
Perform the following tasks on R Studio Construct a function called conv1 which inputs a measurement in centimeters and outputs the corresponding measurement in inches and construct another function called conv2 which inputs a measurement in centimeters and outputs the corresponding measurements in inches, feet, and meters
Movies 3a and 3b: 1. Using either R studio and/or SPSS calculate the mean and standard...
Movies 3a and 3b: 1. Using either R studio and/or SPSS calculate the mean and standard deviation for the question 4 data (first tab in your excel spreadsheet). Be sure to cut and paste your output from SPSS and/or your R code into this document. (1 point) The standard deviation was: The mean was: Age 5 3 5 3 2 3 1 2 4 2 4 2 6 5 5 4 3 5 3 1 4 2 3 5 6...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT