Question: Option A: One important tool we haven't covered yet is a loop, such as a for-loop. In such a loop, R will iterate over the

 Option A: One important tool we haven't covered yet is aloop, such as a for-loop. In such a loop, R will iterate

Option A: One important tool we haven't covered yet is a loop, such as a for-loop. In such a loop, R will iterate over the values of an object using a counter. This is really helpful when you want to do something over and over again. Create a notebook with an R-cell in it where you can answer these questions. When answering, include your code and the output] (a) (2 points) Create a character vector called pr which stores the names of all the provinces in Canada. Then, create a second vector called pop which stores the population of each province in pr. You might want to look this up on Statistics Canada's website? (b) (2 points) In a for-loop, the syntax looks like: for (COUNTER in LIST) \{ do_stuff - to (COUNTER) do stor) The object COUNTER is a variable which the loop runs over, and LIST is a vector-like object that can be counted over. For example, try the code: What does it do? c) (2 points) Now, use a for-loop to print out the name of each province. 1) (4 points) In R, you can combine two pieces of text together with the with paste() command: n

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!