for
loop and a while
loop.double_matrix
. Manually specify the first column
equal to the values 1, 2, and 3. Using a nested loop, fill in the
matrix, row by row, such that each value is double that to its
left.eval=FALSE
). ChatGPT can be accessed at
chat.openai.com.doubler
, that
takes a single number as its input and returns a vector of length 8. The
vector should contain the initial value, doubled consecutive times. Be
sure to check if a single number was given!doubler
on the inputs 1, 2, and 3. Do
you get the same values as in question 1.2? (You should!)apply()
statement to take the
median value of each column in the cars
dataset.ggplot
, make a scatterplot of the
speed
and dist
variables in cars
.
Then, add an appropriate horizontal and vertical line symbolizing the
median value of each variable.for
loop and a while
loop.ANSWER: YOUR ANSWER HERE
double_matrix
. Manually specify the first column
equal to the values 1, 2, and 3. Using a nested loop, fill in the
matrix, row by row, such that each value is double that to its
left.For example, the first row of the matrix should be: 1, 2, 4, 8, 16, 32, 64, 128
# [YOUR CODE HERE]
eval=FALSE
). ChatGPT can be accessed at
chat.openai.com.# [ChatGPT's CODE HERE]
ANSWER: YOUR ANSWER HERE
Hint: You can flip 5 coins using the code
rbinom(n=1,size=5,prob=.5)
. You have gotten 5 heads when
the output is 5
.
# [YOUR CODE HERE]
ANSWER: YOUR ANSWER HERE
doubler
, that
takes a single number as its input and returns a vector of length 8. The
vector should contain the initial value, doubled consecutive times. Be
sure to check if a single number was given!Hint: If input is 1, output should be
c(1,2,4,8,16,32,64,128)
.
# [YOUR CODE HERE]
doubler
on the inputs 1, 2, and 3. Do
you get the same values as in question 1.2? (You should!)# [YOUR CODE HERE]
apply()
statement to take the
median value of each column in the cars
dataset.Hint: Use the median()
function inside your
apply()
command!
# [YOUR CODE HERE]
ggplot
, make a scatterplot of the
speed
and dist
variables in cars
.
Then, add an appropriate horizontal and vertical line symbolizing the
median value of each variable.Hint: Using the layers
geom_vline(xintercept = )
and
geom_hline(yintercept = )
# [YOUR CODE HERE]