Question

1. In R, you can choose almost any name you like for an object, as long...

1. In R, you can choose almost any name you like for an object, as long as the name does not begin with a number or a special character like +, -, *, /, ^, !, @, or &.

Note: Remember that the most helpful names will remind you what you put in your object.

Which of these would be valid object names?

^-^

+1

foo

var

2. If your vector contains a sequence of contiguous integers, you can create it with the : shortcut. If run 1:5 in command line. What do you get?

1, 2, 3, 4, 5

[1] 1 2 3 4 5

1 : 5

3.

You can extract any element of a vector by placing pair of brackets behind the vector. Inside the brackets place the number of the element that you’d like to extract.

If you assign vec <- c(1, 2, 4, 8, 16), then vec[3] would return:

vec[3]

4

16

3

4.

Vector recycling: Predict what the code below will return.

1 + c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)

1] 3 4 5 6 7 8 9 10 11 12

[1] 0 1 2 3 4 5 6 7 8 9

[1] 2 3 4 5 6 7 8 9 10 11

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Vou h von [1 ] 1 2 3 4 5 (4 [1] 2 3 4 5 6 7 8 9 10 1111LVIUUSTY yaved Workspace restored] > 1:5 [1] 1 2 3 4 5 > vec<-c(1,2,4,8,16) > vec[3] [1] 4 > 1+c(1,2,3,4,5,6,7,8,9,10) [1]

Add a comment
Know the answer?
Add Answer to:
1. In R, you can choose almost any name you like for an object, as long...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Choose an element in the periodic table and answer the following questions 1. Name of the...

    Choose an element in the periodic table and answer the following questions 1. Name of the element 2. Element Characteristics 3. Atomic Number 4. Atomic Mass 5. Where this element can be found? 6. What minerals is composed of this element? 7. What is the minerals used for? 8. Picture of this element

  • Can you write a function that takes 2 vectors as parameters and returns a larger vector...

    Can you write a function that takes 2 vectors as parameters and returns a larger vector containing the two vectors Example Vector a: 1 2 3 4 5 Vector b: 6 7 8 9 10 Concatenated vector: 1 2 3 4 5 6 7 8 9 10

  • 5.1 Automatic properties Choose One 4 points Given the following code where does the value assigned...

    5.1 Automatic properties Choose One 4 points Given the following code where does the value assigned to the automatic property get stored? ?# 1 class Foo 2 3 string_name; 4 5 string Bar (get;set;) 7 8 10 static void Main() 12 13 object.Bar"Hello"; Foo object new Foo(); 14 0 In the-name field O in a hidden field created by the Property O The value is not stored O You have to create a field to hold the value

  • Function Name: zoomZoom Inputs: 1. (double) An Nx5 array of scooters' speeds at various times 2. (double) The time...

    Function Name: zoomZoom Inputs: 1. (double) An Nx5 array of scooters' speeds at various times 2. (double) The time at which you want to find the scooters' speeds Outputs: 1. (double) A 1x5 vector of scooters' speeds at the given time Background: Scooter go zoom zoom! Function Descripti on : You will be given an array with times in the first column, and speeds of different electric scooters in columns 2-5 that correspond to those times. Use spline interpolation or...

  • You are going to create a Queue. (alternately you can create a list and simply implement...

    You are going to create a Queue. (alternately you can create a list and simply implement enqueue and dequeue functions in the List – that will technically make it a queue). You will fill the first list with numbers consecutively numbered from 2 to n where n is entered by the user (we will call this Q1). When creating your Queue object use the correct function names for enqueue and dequeue functions. Again – sorry, cannot use an Javascript array...

  • Java Questions A class must implement at least one interface. Question 1 options: True False Question...

    Java Questions A class must implement at least one interface. Question 1 options: True False Question 2 (1 point) Abstract methods can be called. Question 2 options: True False Question 3 (1 point) Constructors Question 3 options: Are inherited but cannot be accessed Are inherited and can be accessed Are accessible but are not inherited Are not inherited and cannot be accessed Question 4 (1 point) We can instantiate an object from an abstract class. Question 4 options: True False...

  • 1. Suppose you have created a vector x in R using the command x <-c(2, 7,...

    1. Suppose you have created a vector x in R using the command x <-c(2, 7, 3, 1, 9) . Please find the results for the following commands (2) xlc(1,3,5)] (3) x [2:4] (5) length(x) (6) x [2: length(x)1 (7) x[1: length(x)-1] (8) max(x) (9) min(x) 2. Besides the vector x in question 1, suppose you have created another vector y in R using the command y <- c(1, 2, 3, 4, 5). Please find the results for the following...

  • 6. Declare an object Plane with nothing but a private constructor and destructor. You do not...

    6. Declare an object Plane with nothing but a private constructor and destructor. You do not need to define either the constructor or destructor. 7. Create a vector that can hold Plane objects but do not set an initial size or initialize any elements 8. What kind of variable type is used to store a memory address 9. What operator is used to dereference a pointer to a structure? 10. If you intent on doing file I/O, what #include do...

  • How is Problem 1 (a through e) typed up in Matlab? I would like to know...

    How is Problem 1 (a through e) typed up in Matlab? I would like to know how the commands is typed up along with solution please. Assignment 6 Problem 1) Consider the two following matrix, 1 4 2 2 4 100 and B In(A) 7 9 7 3 42 a) Select just the second row of B. b) Evaluate the sum of the second row of B. c) Multiply the second column of B and the first column of A...

  • Solve in MATLAB Problem 3: Given the vector x- [2 1 0 6 2 3 5...

    Solve in MATLAB Problem 3: Given the vector x- [2 1 0 6 2 3 5 3 4 1 3 2 10 12 4 2 7 9 2 4 51 use a for loop to (a) Add up the values of all elements in x (b) Compute the cumulative sum, y, of elements in x You can check your results using the built-in functions sum and cumsum. Q.5 What is the value of the sum of elements in vector x?...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT