sequence = "ATCGATCGATCG-ATCGAT-CGATC-GATCGAT-CGATCG-ATCGATCG-CGATCG"
gene_seqs = strsplit(sequence, '-')
print(gene_seqs)
[[1]]
[1] "ATCGATCGATCG" "ATCGAT" "CGATC" "GATCGAT" "CGATCG" "ATCGATCG" "CGATCG"
for(i in gene_seqs) {
reverse_seq = stri_reverse(i)
print(reverse_seq)
seg_len = nchar(i)
print(seg_len)
new_pattern = 'GATC'
location = gregexpr(new_pattern, i)
location = unlist(location)
print(location)
occurance = sum(location != -1)
print(occurance)
}
[1] "GCTAGCTAGCTA" "TAGCTA" "CTAGC" "TAGCTAG" "GCTAGC" "GCTAGCTA" "GCTAGC"
[1] 12 6 5 7 6 8 6
[1] 4 8 -1 2 1 2 4 2
[1] 7
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)
)
print(exam_score)
new_row = data.frame(
ID = c(6, 7),
Name = c("Eli", "Farha"),
Age = c(22, 16),
Score = c(60, 85)
)
new_score1 = rbind(exam_score, new_row)
print(new_score1)
Income = c(1200, 1500, 1100, 2700, 1500, 1750, 2200)
new_score2 = cbind(new_score1, Income)
print(new_score2)
cat("Maximum of age ", max(new_score2[ ,3]), "Maximum of score ", max(new_score2[ ,4]), "Maximum of income ", max(new_score2[ ,5]), "\n")
Maximum of age 30 Maximum of score 100 Maximum of income 2700
cat("Minimum of age ", min(new_score2[ ,3]), "Minimum of score ", min(new_score2[ ,4]), "Minimum of income ", min(new_score2[ ,5]), "\n")
Minimum of age 16 Minimum of score 55 Minimum of income 1100
cat("Median of age ", median(new_score2[ ,3]), "Median of score ", median(new_score2[ ,4]), "Median of income ", median(new_score2[ ,5]), "\n")
Median of age 22 Median of score 81 Median of income 1500
cat("Sum of age ", sum(new_score2[ ,3]), "Sum of score ", sum(new_score2[ ,4]), "Sum of income ", sum(new_score2[ ,5]), "\n")
Sum of age 153 Sum of score 549 Sum of income 11950
cat("Mean of age ", mean(new_score2[ ,3]), "Mean of score ", mean(new_score2[ ,4]), "Mean of income ", mean(new_score2[ ,5]), "\n")
Mean of age 21.85714 Mean of score 78.42857 Mean of income 1707.143
cat("Standar deviation of age ", sd(new_score2[ ,3]), "Standar deviation of score ", sd(new_score2[ ,4]), "Standar deviation of income ", sd(new_score2[ ,5]), "\n")
Standar deviation of age 4.634241 Standar deviation of score 16.00893 Standar deviation of income 568.938
cat("variance of age ", var(new_score2[ ,3]), "Variance of score ", var(new_score2[ ,4]), "variance of income ", var(new_score2[ ,5]), "\n")
variance of age 21.47619 Variance of score 256.2857 variance of income 323690.5
cat("Quantile of age ",quantile(new_score2[ ,3]), "Quantile of score ", quantile(new_score2[ ,4]), "Quantile of income ", quantile(new_score2[ ,5]))
Quantile of age 16 19 22 23.5 30 Quantile of score 55 69 81 87.5 100 Quantile of income 1100 1350 1500 1975 2700
correlationi = cor(new_score2$Age, new_score2$Score)
print(correlationi)
[1] -0.003530227
correlationii = cor(new_score2$Age, new_score2$Income)
print(correlationii)
[1] -0.4167531
correlationiii = cor(new_score2$Score, new_score2$Income)
print(correlationiii)
[1] -0.7177034
new_score2[new_score2$Score >=80, ]
new_score2[new_score2$Age > 20 & new_score2$Age < 30, ]