R Programming Slip

 


Slip 4 

Write an R program to extract first 10 English letter in lower case and last 10 letters in upper case and extract letters between 22nd to 24th letters in upper case. 

Answer : 

print("First 10 letters in lower case:")
t = head(letters, 10)
print(t)
print("Last 10 letters in upper case:")
t = tail(LETTERS, 10)
print(t)
print("Letters between 22nd to 24th letters in upper case:")
e = tail(LETTERS[22:24])
print(e)

slip 5

Write an R program to find Sum, Mean and Product of a Vector. 

Answer : 

x = c(10, 20, 30)
print("Sum:")
print(sum(x))
print("Mean:")
print(mean(x))
print("Product:")
print(prod(x))

Slip 6

 Write an R program to create a simple bar plot of five subject’s marks. 

Answer : 

marks = c(70, 95, 80, 74)
barplot(marks,
main = "Comparing marks of 5 subjects",
xlab = "Marks",
ylab = "Subject",
names.arg = c("English", "Science", "Math.", "Hist."),
col = "darkred",
horiz = FALSE)

R Programming Slip R Programming Slip Reviewed by technical_saurabh on December 22, 2020 Rating: 5

No comments:

Powered by Blogger.