Chap 3 Review

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

Exercise 1  

  1. Is xx a legitimate name in R?
True       False      

question id: 03-legitimate-name-1

  1. Is x_x a legitimate name in R?
True       False      

question id: 03-legitimate-name-2

  1. Is -x a legitimate name in R?
True       False      

question id: 03-legitimate-name-3

  1. Is 3x a legitimate name in R?
True       False      

question id: 03-legitimate-name-4

  1. Is sqrt a legitimate name in R?
True       False      

question id: 03-legitimate-name-5

  1. Is x + y a legitimate name in R?
True       False      

question id: 03-legitimate-name-6

  1. Is 3 * x a legitimate name in R?
True       False      

question id: 03-legitimate-name-7

  1. Is xprime a legitimate name in R?
True       False      

question id: 03-legitimate-name-8

9, Is x prime a legitimate name in R?

True       False      

question id: 03-legitimate-name-9

  1. Is dx a legitimate name in R?
True       False      

question id: 03-legitimate-name-10

  1. Is dx_f a legitimate name in R?
True       False      

question id: 03-legitimate-name-11

Exercise 2  

  1. What’s wrong with this assignment statement? x < 4

Nothing

it is missing part of the <- token.

x is an improper name.

question id: 03-whats-wrong-1

  1. What’s wrong with this assignment statement? 3*x <- 4

Nothing

It should use addition instead of multiplication.

The item to the left of <- needs to be a name

There is no x on the right-hand side of the assignment arrow.

question id: 03-whats-wrong-2

  1. What’s wrong with this assignment statement? x -> 3+4

Nothing

You cannot use addition in an assignment statement.

The assignment has to point toward the name, not the value

question id: 03-whats-wrong-3

Exercise 3 We can write something like \[f(x) \equiv x^2\] in mathematical notation. Is it legit in R to write f(x) <- x^2 ?

Yes, it is fine.

f(x) is not a valid name in R.

Almost. You need to use () instead of <- .

question id: IK57Kb

Exercise 4 Which of these is the right way to translate \(e^x\) into R?

e^x

exp(x)

e(x)

There is no R equivalent.

question id: cbynFm

Exercise 5 If x has been assigned the value pi/2, what will be the value of the R expression 2 sin(x)?

0, since \(\sin(\pi/2) = 0\).

1, since \(\sin(\pi/2) = 1\).

2, since \(\sin(\pi/2) = 1\).

No value. The expression is in error.

question id: 2yXUur

Exercise 6  

  1. What’s wrong with the R command

f <- 3*x + 2

for defining a function?

It needs to be f(x) <- 3*x + 2

It needs to be f <- makeFun(3*x + 2)

It needs to be f <- makeFun(3*x + 2 ~ x).

Nothing is wrong

question id: bad-expressions-1

  1. What’s wrong with this R command for creating an exponential function named g?

g <- makeFun(e^y ~ y)

e^y is not the exponential function

It uses y as the argument instead of x.

Better to name the argument x

Nothing

question id: bad-expressions-2

  1. What’s suspect about this R command?

g <- makeFun(exp(y) ~ x)

The formula is exp(y) but the argument name is x

There is a tilde expression as the argument to makeFun().

The function name should be G, not g.

Nothing

question id: bad-expressions-3

  1. What’s wrong with the R expression sin*(x + 3)?

There is no function named sin*()

It should be sin+(x+3)

It should be sin^(x+3)

Nothing

question id: bad-expressions-4

Exercise 7 What does e^3 mean in R?

It corresponds to \(e^3\), which happens to be 20.09

A shorthand for eee.

The value stored under the name e will be raised to the third power.

question id: Eb8Pqe

Exercise 8 What’s missing in the R expression (x+3)(x+1)?

There is a missing closing parenthesis.

There is an extra closing parenthesis.

The multiplication symbol, *, is missing.

Nothing

question id: QEt5un

Exercise 9 Which of these phrases is most appropriate for describing what the R command z <- sin(17) is doing?

Gives a name to a value.

Applies a function to an input to produce an output.

Makes a copy of an existing object.

The name of an object.

it is invalid as a command.

question id: WWacOx

Exercise 10 Which of these phrases is most appropriate for describing what the R command sin(17) is doing?

Gives a name to a value.

Applies a function to an input to produce an output.

Makes a copy of an existing object.

The name of an object.

It is invalid as a command.

question id: KdtU01

Exercise 11 Which of these phrases is most appropriate for describing what the R command z <- x is doing?

Gives a name to a value.

Applies a function to an input to produce an output.

Makes a copy of an existing object.

The name of an object.

It is invalid as a command.

question id: 4vzqOX

Exercise 12 Which of these phrases is most appropriate for describing what the R command fred is doing?

Gives a name to a value.

Applies a function to an input to produce an output.

Makes a copy of an existing object.

The name of an object.

It is invalid as a command.

question id: jW85Kl

Exercise 13 In the following statement, what is pnorm?

pnorm(3, mean=4, sd=6 )

The name of the function being applied to the three arguments.

A named argument

An argument to be used without a name.

question id: IEokf0

Exercise 14 In the statement following statement, what is mean=4?

pnorm(3, mean=4, sd=6 )

The name of the function being applied to the three arguments.

A named argument

An argument to be used without a name.

question id: VxuzVl

Exercise 15 In the following statement, what is 3?

pnorm(3, mean=4, sd=6 )

The name of the function being applied to the three arguments.

A named argument

An argument to be used without a name.

question id: oBHViq

Exercise 16 Will these two statements give the same result?

pnorm(y=3, mean=4, sd=6)

pnorm(3, mean=4, sd=6)

Yes, same arguments to the same function means the output will be the same.

No. The name of the first argument to pnorm() is not x.

question id: Nxcaf8

Exercise 17 Will these two statements give the same result?

pnorm(3, mean=4, sd=6)

pnorm(3, sd=6, mean=4)

Yes.       No. The arguments are different.      

question id: uOuqB7

Exercise 18 Will these two statements give the same result?

pnorm(3, mean=4, sd=6)

pnorm(3, sd=4, mean=6)

Yes       No      

question id: oxpoxr

Exercise 19 What is the value of 16^1/2?

4       8      

question id: 73iI9q

Exercise 20 Suppose n <- 3. What will be the value of 2^n-1?

4       7       8      

question id: kexahG

Exercise 21 Suppose n <- 3. What will be the value of 2^(n-1)?

4       7       8      

question id: LZcAvO

Exercise 22 In g <- makeFun(3*z + 2 ~ z), which is the name of the input to the function g()?

\(x\)       \(y\)       \(z\)       \(t\)      

question id: Xv9nXx

Exercise 23 Will this statement work in R? sin(4)

Yes       No      

question id: IayXv5

Exercise 24 Will this statement work in R? Sin(4)

Yes       No      

question id: M5Fu3U

Exercise 25 Will this statement work in R to calculate \(\sin(4)\)? sin[4]

Yes       No      

question id: PYGaqQ

No answers yet collected