Question

Which R code should use for this question? I know it should use for loop, but...

Which R code should use for this question? I know it should use for loop, but don't know how to bulid the code.

Repeat 10 simple random samples that selected from the following data form called 'goals' 49 additional times and combine to have 50 sample means. Now find the sample mean and sample variance of the 50 sample means. The 'goals' is a data form like this with 251 oberservations and 2 variables like the following:

index,goal
1,100
2,100
3,100
4,100
5,100
6,100
7,100
8,100
9,100
10,100

11,100
12,100
13,100
14,100
15,100
16,100
17,100
18,100
19,100
20,100
21,99
22,98
23,95
24,95
25,95
26,95
27,95
28,95
29,95
30,95
31,95
32,90
33,90
34,90
35,90
36,90
37,90
38,90
39,90
40,90
41,90
42,90
43,90
44,90
45,90
46,90
47,90
48,90
49,90
50,90
51,90
52,90
53,90
54,90
55,90
56,90
57,90
58,90
59,90
60,90
61,90
62,90
63,90
64,90
65,90
66,90
67,89
68,89
69,88
70,88
71,88
72,87
73,87
74,86
75,86
76,86
77,86
78,86
79,85
80,85
81,85
82,85
83,85
84,85
85,85
86,85
87,85
88,85
89,85
90,85
91,85
92,85
93,85
94,85
95,85
96,85
97,85
98,85
99,85
100,85
101,85
102,85
103,85
104,85
105,85
106,85
107,85
108,85
109,85
110,85
111,85
112,85
113,85
114,85
115,85
116,85
117,85
118,85
119,85
120,85
121,85
122,85
123,85
124,85
125,85
126,85
127,85
128,85
129,85
130,85
131,85
132,85
133,85
134,85
135,85
136,85
137,85
138,85
139,85
140,85
141,85
142,85
143,85
144,85
145,85
146,83
147,83
148,83
149,82
150,80
151,80
152,80
153,80
154,80
155,80
156,80
157,80
158,80
159,80
160,80
161,80
162,80
163,80
164,80
165,80
166,80
167,80
168,80
169,80
170,80
171,80
172,80
173,80
174,80
175,80
176,80
177,80
178,80
179,80
180,80
181,80
182,80
183,80
184,80
185,80
186,80
187,80
188,80
189,80
190,80
191,80
192,80
193,80
194,80
195,80
196,80
197,80
198,80
199,80
200,80
201,80
202,80
203,80
204,80
205,80
206,80
207,80
208,80
209,80
210,80
211,80
212,80
213,80
214,80
215,80
216,78
217,75
218,75
219,75
220,75
221,75
222,75
223,75
224,75
225,75
226,75
227,75
228,75
229,75
230,73
231,73
232,70
233,70
234,70
235,70
236,70
237,70
238,70
239,70
240,70
241,70
242,70
243,70
244,70
245,70
246,70
247,70
248,68
249,62
250,60
251,50

Homework Answers

Answer #1

the gaol data set is not given

however we can create some random data and code it as below

set.seed(1234)

list1 <- 1:60
list2 <- 1:60
list3 <- 1:60

n <- 50 ## 50 samples
runs <- data.frame(run=1:n,threes=NA,twos=NA) ## create place holders for data in columns
for(i in 1:n) {
sample_list1 <-(sample(list1,10, replace=FALSE))
sample_list2 <-(sample(list2,20, replace=FALSE))
sample_list3 <-(sample(list3,30, replace=FALSE))
  
combined_randomgenes <- c(sample_list1, sample_list2, sample_list3)
combined_counts <- as.data.frame(table(combined_randomgenes))
  
runs$threes[i] <- sum(combined_counts$Freq==3) ## use mean instead of sum here
runs$twos[i] <- sum(combined_counts$Freq==2)
}


### now use means and sd

mean(runs$threes)
sd(runs$threes)

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
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT