Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The following corresponds to the programming language R. Please help answer. 1) Using a `for()` loop to iterate over a vector and solve for variable

The following corresponds to the programming language R. Please help answer.

1) Using a `for()` loop to iterate over a vector and solve for variable 'y' using the `y = mx + b` equation.

# Use variable assignment to assign 10 as b and 1 as m b <- 10 m <- 1

a) # Create a vector that ranges from 1 to 100 and name it 'x' using variable assignment.

b) # Create a holding vector for 'y' using the rep() function that is of the same length as vector x, but populate this vector with NaN.

c) # Write out what each line below means in words: for (i in 1:length(x)) { # WRITE YOUR ANSWER HERE y[i] <- m * x[i] + b # WRITE YOUR ANSWER HERE

d) # Print y

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi

12th edition

133544613, 978-0133544619

More Books

Students also viewed these Databases questions