1. Create a vector named x1 which contains a sequence starting at 1 and ending at 8, with each successive element being 1 larger than the other, i.e. (1, 2, 3, 4, 5, 6, 7, 8)

Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter6: Arrays
Section: Chapter Questions
Problem 5GZ
icon
Related questions
Question
1. Create a vector named x1 which contains a sequence starting at 1 and ending at 8, with each
successive element being 1 larger than the other, i.e. (1, 2, 3, 4, 5, 6, 7, 8)
2. Before running the program, explain what will happen if you run the following code: \code{x1
+3} - Now run this program. What happened? What is this an example of?
3. Create an R function called \func{divideBy()}, which takes two arguments, \var{x} and
\var {y}. Let \var{x} be the quantity to divide, and let \var{y} be the quantity to divide
\var{x} by. Thus, if \var{x} = 3 and \var{y} = 2, the function should return 1.5
4. Can the function created in 3) take vector arguments? Answer this first before running the
program, and then experiment in R.
5. The following problem is MUCH easier if you've taken the time to install RStudio. Please use
RStudio! Let's make use of an example dataset - the \var{College} dataset from R package
\var{ISLR}. If you haven't used this package before, you'll have to install it with
\code{install.packages ("ISLR")}. This puts the source, including functions, datasets, and
other objects on your computer. You must then load/attach the package into your instance of R,
so that you can actually use the package. This is done by typing \code{library (ISLR)} in the
console. Now you're ready! The \var {College} variable holds the data frame for the College
dataset.
Type \code{?College} and hit enter in the console. This will bring up the help page for the
\var {College} dataset, that includes descriptions of the variables.
Transcribed Image Text:1. Create a vector named x1 which contains a sequence starting at 1 and ending at 8, with each successive element being 1 larger than the other, i.e. (1, 2, 3, 4, 5, 6, 7, 8) 2. Before running the program, explain what will happen if you run the following code: \code{x1 +3} - Now run this program. What happened? What is this an example of? 3. Create an R function called \func{divideBy()}, which takes two arguments, \var{x} and \var {y}. Let \var{x} be the quantity to divide, and let \var{y} be the quantity to divide \var{x} by. Thus, if \var{x} = 3 and \var{y} = 2, the function should return 1.5 4. Can the function created in 3) take vector arguments? Answer this first before running the program, and then experiment in R. 5. The following problem is MUCH easier if you've taken the time to install RStudio. Please use RStudio! Let's make use of an example dataset - the \var{College} dataset from R package \var{ISLR}. If you haven't used this package before, you'll have to install it with \code{install.packages ("ISLR")}. This puts the source, including functions, datasets, and other objects on your computer. You must then load/attach the package into your instance of R, so that you can actually use the package. This is done by typing \code{library (ISLR)} in the console. Now you're ready! The \var {College} variable holds the data frame for the College dataset. Type \code{?College} and hit enter in the console. This will bring up the help page for the \var {College} dataset, that includes descriptions of the variables.
Expert Solution
steps

Step by step

Solved in 6 steps with 2 images

Blurred answer
Knowledge Booster
Passing Array as Argument
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning