0% found this document useful (0 votes)
20 views2 pages

Vit Online Learning Institute: Worksheet - I Creation of Vectors and Strings

This document provides instructions to create various vectors and strings in R, including numeric, integer, character, and complex vectors as well as strings of country names. Students are asked to combine the country name strings using paste and other functions, extract substrings, and determine classes and lengths of the created objects. The goal is for students to practice creating and manipulating different vector and string data types in R.

Uploaded by

Vasu Sehgal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views2 pages

Vit Online Learning Institute: Worksheet - I Creation of Vectors and Strings

This document provides instructions to create various vectors and strings in R, including numeric, integer, character, and complex vectors as well as strings of country names. Students are asked to combine the country name strings using paste and other functions, extract substrings, and determine classes and lengths of the created objects. The goal is for students to practice creating and manipulating different vector and string data types in R.

Uploaded by

Vasu Sehgal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

VIT ONLINE LEARNING INSTITUTE

WORKSHEET – I
CREATION OF VECTORS AND STRINGS
Course Name: Programming in R Faculty: Dr. Swarna Priya RM
Credits: 4
1. Create the vectors:
(a) Numeric vector having elements 123,45,67,28,59
(b) Integer Vector having elements 45,56,89,2,34,56
(c) Character vector having elements to be name of the months.
(d) Complex vector with any set of 10 complex numbers.
2. Use the function paste to create the following character vectors. First create the vector. And
then use paste function to form a sentence as per the requirement given in each case. Print on
the console.
(a) ("HI", "HOW", “DO”,”YOU”,”DO”).
Note that there is a single space between them.
(b)("This", “is”,”really”,”Awesome”,”to”,”learn”,”that”,”am”,”able”,”to”,”program”).
(i) In this case, there is no space between the words.
(ii) In this case the words are separated by using the character ‘–‘.
3. Create a vector of having the co-efficients of the quadratic equation as given below. Name
them as quad1…quadn.
(i) 10x3 + 8x2 + 7x + 3=0
(ii) 12y4 – 10y3 +14y2 -5y -3=0
(iii) 22z4 – 11z3 +13z2 -15z -33=0

4. Determine the class of the objects created in the question 3.


5. Determine the length of the object “quad1”
6. Determine the name associated with the vector created.
7. Create a string and name it is as “Country”. Similarly create 12 strings with 12 country names
and name them as you wish.
8. Combine all the strings created in the question 7 using paste function.
9. Combine all the strings created in the question 7 without using paste function. (Just try)
10. Create a complex vector with elements 2+6i, 3+7i, 4+8i. Print the created vector. Display
the class of the vector.
11. Create an integer vector with elements 99, 88, 77, 66, 55, 44, 33, 22, 11, 1. Display the
created vector on the console.
12. Create a string by name “Programme”. Assign it with a string “Bachelor of Engineering”.
Display the string create on the R console.
13. Create a substring from the string created in the question 12 starting from the index value
‘3’ and ending with the index value ‘7’.

You might also like