0% found this document useful (0 votes)
16 views9 pages

R Programming: Lists, Matrices, Dataframes

Uploaded by

sharmansai6
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)
16 views9 pages

R Programming: Lists, Matrices, Dataframes

Uploaded by

sharmansai6
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

LAB-3

Lists
1. Write a R program to create a list containing strings, numbers, vectors and a logical
value.
Code:

Output:

2. R Program to merge two given lists into one list


Code:

Output:

3. R Program to convert a given list to vector


Code:

Output:

4. R Program to count number of objects in a given list


Code:

Output:

5. R Program to add a new item to a given list


Code:

Output:
Matrix
1. R Program to create a blank or empty matrix
Code:

Output:

2. Write a R program to create two 2x3 matrix and add, subtract, multiply and divide
the matrixes.
Code:

Output:
3. Write a R program to create a matrix taking a given vector of numbers as input and
define the column and row names. Display the matrix.
Code:

Output:
Data Frame
1. Write a R program to create a data frame from four given vectors.
name = c('Anastasia', 'Dima', 'Katherine', 'James', 'Emily', 'Michael', 'Matthew', 'Laura',
'Kevin', 'Jonas')
score = c(12.5, 9, 16.5, 12, 9, 20, 14.5, 13.5, 8, 19)
attempts = c(1, 3, 2, 3, 2, 3, 1, 1, 2, 1)
qualify = c('yes', 'no', 'yes', 'no', 'no', 'yes', 'yes', 'no', 'no', 'yes')
Code:

Output:
2. R Program to Convert a List to a Dataframe
Code:

Output:

3. R Program to Create an Empty Dataframe


Code:

Output:

4. R Program to Combine Two Dataframe into One


Code:
Output:

5. R Program to Extract Columns From a Dataframe


Code:

Output:

6. Write a R program to extract specific column from a data frame using column name.
Code:
Output:

You might also like