Recently Published
Nusaiba Tazreen Tanisha - Assignment 2
Assignment 2
Given a data frame as following
exam_score = data.frame(
ID = c(1, 2, 3, 4, 5),
Name = c("Alice", "Bob", "David", "John", "Jenny"),
Age = c(20, 25, 30, 22, 18),
Score = c(100, 78, 90, 55, 81)
)
Create this data frame.
Add 2 new rows.
Add a new column called “Income”. This column should be numerical.
Find max, min, median, sum, mean, standard deviation, variance, and quantiles of columns Age, Score, and Income.
Find correlation between
Age and score
Age and income
Score and income
Select rows where the score is greater than or equal to 80
Select rows with the age range of 20 to 30
Select rows with age 22, 25, and 30.
Nusaiba Tazreen Tanisha - Assignment 1
Question 1
Imagine, you have a DNA sequence consisting of letters from "A", "C", "G", and "T".
a. Create two variables — gene1: with 8 characters and gene2: with 3 characters.
b. Concatenate the two variables
c. Create a substring from variable 1 starting from index 2 to 5
d. Does the pattern of gene2 exist in gene1? If yes, find the index.
Here is an example of a DNA sequence of length 5:
DNA = “ACCGT”
Question 2
Select any two integer numbers and store them in two variables. Now do the following arithmetic
operation on the two numbers and store each result in variables and print it.
1. Add
2. subtract
3. multiply
4. divide
5. power
6. modulo
The “Add” is done for you as an example
var1 = 10
var2 = 3
result_add = var1 + var2
print(result_add)
Question 3
Use condition and loop to assign letter grade to a vector of scores.
● Create a scores vector with the following numbers: 100, 90, 50, 20, 30, 88, 66,
75, 71, 91, 0, 45, 61
● Now use a for loop and conditional (if else) to determine letter grade for each
score.
● Create an age vector with 13 numbers ranging from 20 to 80 years.
● Now use calculate the correlation between age and score and explain the
correlation nature.
● Select 3-10 elements from scores and age to store them in new variables.
● Now calculate the correlation again between these two new variables.