3  Computing with R

\[ \newcommand{\dnorm}{\text{dnorm}} \newcommand{\pnorm}{\text{pnorm}} \newcommand{\recip}{\text{recip}} \]

Reading questions

Reading question 3.1 What is the name of the character “\(\LARGE{\sim}\)” ?

Squiggle       Wave       Tilde       Caret      

question id: squiggle

Reading question 3.2 What does the R statement in Active R chunk lst-bogus-intro do?

Active R chunk 3.1

The statement creates a function named b() whose output is always 13.3.

The statement lets you refer to the value 13.3 by the name b.

The statement asks whether b is less than \(-13.3\).

question id: assignment-1

Reading question 3.3 In referring to R computing, what is “argument”?

It’s another word for “function.”

It’s another word for “parameter.”

It’s another word for “input to a function.”

question id: argument-is-what

Reading question 3.4 You will see R commands like those in Active R chunk lst-03-reading-george throughout this book, so we might as well start off with them:

Active R chunk 3.2
  1. What name is being given to the function?
x       x-squared       f       george      

question id: makefun-a

  1. What kind of R/computational thing is x^2 ~ x?
a function       a name       a tilde expression      

question id: makefun-b

  1. Which of these characters will you aways find in a tilde expression?
x       =       ~      

question id: makefun-c

  1. Using Active R chunk lst-03-makefun-d, evaluate the function george() on the input value 7. Since george() is defined in Active R chunk lst-03-reading-george, make sure to run the code there first.
Active R chunk 3.3

Note about collecting answers. The contents of interactive R chunks are collected when you submit your work, along with other answers in the document.

  1. All of these except one is a reasonable way to put the tilde character into words. Which is the exception?
“as a function of”       “versus”       “tilde”       “with respect to”       “squiggle”      

question id: makefun-e

  1. How many arguments does makeFun() take in the above command?
No arguments.       One argument       Two arguments.       Three arguments.      

question id: makefun-f

Reading question 3.5 The statement in the following code block makes use of a name that has not previously been assigned a value. This is a mistake, but it is a common one.

Active R chunk 3.4
  1. Run the code in Active R chunk lst-unbound-y. It will produce an error message. Following the flag Error: is a short message that attempts to explain what went wrong. What does “not found” mean?

y is not a name.

The name y is not bound to a value.

The name x is not bound to a value.

The parentheses are out of place.

question id: not-found

  1. Add a line to the code in Active R chunk lst-unbound-y that will assign y the value 16. There are two places you can put the new line: before the old one or after the old one. Put it in the right place so that the command formed by the two lines does not generate an error.

Remember: The code you have entered in the R blocks is automatically included when you collect the answers for the assignment.

No answers yet collected