Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started