Question

In: Computer Science

In R syntax, I have created a vector called: “ all_numbers <- c(10:21, seq(21:30)) “ but...

In R syntax, I have created a vector called: “ all_numbers <- c(10:21, seq(21:30)) “

but how do i create a variable “eleventh” that contains 11th element in ‘all_numbers' and also create a vector ‘some_numbers’ that contains 2nd through the 5th elements of ‘all_numbers’ ?

Solutions

Expert Solution

SOURCE CODE:

*Please follow the comments to better understand the code.

**Please look at the Screenshot below and use this code to copy-paste.

***The code in the below screenshot is neatly indented for better understanding.

#Your all_number vector here.
all_numbers <- c(10:21, seq(21:30))
print(all_numbers)

# To get the 11th number, we use the subscript [11] as follows.
eleventh <- all_numbers[11]
print(paste('Eleventh Number is ', eleventh))


#To get some numbers from 2 to 5 position, we do like this
some_numbers <- all_numbers[2:5]
print('2 to 5 position numbers are ')
print(some_numbers)

=================

SCREENSHOT:


Related Solutions

Hi i have this for a practical tomorrow (C++): a) Write a function vector merge(vector a,...
Hi i have this for a practical tomorrow (C++): a) Write a function vector merge(vector a, vector b) that merges two vectors, alternating elements from both vectors. If one vector is shorter than the other, then alternate as long as you can and then append the remaining elements from the longer vector. For example, if a is 1 4 9 16 and b is 9 7 4 9 11 Then merge returns the vector 1 9 4 7 9 4...
Syntax error in C. I am not familiar with C at all and I keep getting...
Syntax error in C. I am not familiar with C at all and I keep getting this one error "c error expected identifier or '(' before } token" Please show me where I made the error. The error is said to be on the very last line, so the very last bracket #include #include #include #include   int main(int argc, char*_argv[]) {     int input;     if (argc < 2)     {         input = promptUserInput();     }     else     {         input = (int)strtol(_argv[1],NULL, 10);     }     printResult(input);...
Let C(R) be the vector space of continuous functions from R to R with the usual...
Let C(R) be the vector space of continuous functions from R to R with the usual addition and scalar multiplication. Determine if W is a subspace of C(R). Show algebraically and explain your answers thoroughly. a. W = C^n(R) = { f ∈ C(R) | f has a continuous nth derivative} b. W = {f ∈ C^2(R) | f''(x) + f(x) = 0} c. W = {f ∈ C(R) | f(-x) = f(x)}.
Considering a Character vector called statusDesc=c(“senior”,”sophomore”,”junior”,”freshman”). Write R code(s) to create a factor called statusFac that...
Considering a Character vector called statusDesc=c(“senior”,”sophomore”,”junior”,”freshman”). Write R code(s) to create a factor called statusFac that will take statusDesc as an argument and has four levels in the order of “freshman,” ”sophomore,” ”junior,” and “senior.” Use the following codes to generate 10 random numbers to represent 10 random ages. set.seed(1) ages=rnorm(10,24,24) Based on the variable ages, use cut() to create a factor called ageFac that has 4 levels “child”,”teen”,”adult”, and “senior”.   The corresponding age ranges are (3,13],(13,18],(18,60],and (60,120]. For example,...
Write MIPS assembly code for the following C code. for (i = 10; i < 30;...
Write MIPS assembly code for the following C code. for (i = 10; i < 30; i ++) { if ((ar[i] > b) || (ar[i] <= c)) ar[i] = 0; else ar[i] = a; }
Hello, this question relates to a class I am taking called introduction to C++. I have...
Hello, this question relates to a class I am taking called introduction to C++. I have no experience writing programs and outside of learning out of a textbook, and studying on my own, have little understanding of logic. I have been assigned a problem that requires me to write a program for a Grocery Bill, where the consumer inputs the price for 5 items, that the program calculates the total with a 6% sales tax. I really am not sure...
How would I test a code i made in FreeBSD? I created a dictionary called ls...
How would I test a code i made in FreeBSD? I created a dictionary called ls and inside of it i made a makefile and a code called ls.c; trying to recreate the ls -l command and want to test it.
Write a function in c++, called afterAll that takes two parameters, a vector of string and...
Write a function in c++, called afterAll that takes two parameters, a vector of string and a string. The function returns true if the 2nd parameter comes after all of the strings in the vector, order-wise, false if not. As an example, "zoo" comes after "yuzu".
Linear Algebra we know that x ∈ R^n is a nonzero vector and C is a...
Linear Algebra we know that x ∈ R^n is a nonzero vector and C is a real number. find all values of C such that ( In − Cxx^T ) is nonsingular and find its inverse knowing that its inverse is of the same form
In c++ how do I search a vector for a name and then determine if the...
In c++ how do I search a vector for a name and then determine if the name is found?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT