I tried finding random number but failed to get 3 random integers which can be divisible by 5.

  1. Generate 3 random integers (not be a decimal no.) between 100 and 999 which is divisible by 5

sample(100:999, 3)
[1] 251 446 473

As you can see, what is the code to get random number that is only divisible by 5?

  1. R program which accepts the group of alphabet characters from the user and count the occurrence of each character. Also find the frequency.

X<-("The percentage of page views that a particular SKU receives relative to the number of page views for all products")
X
[1] "The percentage of page views that a particular SKU receives relative to the number of page views for all products"
nchar(X)
[1] 113
library(stringr)
str_count(X, "a")
[1] 9
str_count(X, "b")
[1] 1
count(X, '1')
X1 freq
1 1 1

As you can see, I am unable to find the frequency for a specific character? please suggest some different approach. thanks in advance

Hi, please see the homework policy for assignment related questions.

For the first question, rewording it as

generate three numbers divisible by 5 from random numbers between 100 and 500.

No three random integers are guaranteed to contain at least one occurrence of x%%5 = 0.

The second question is similar in the sense that each character might be ambiguous. Does it mean each character in the alphabet or each character in X? As to frequency, think of it as the number of a particular object in a group of objects divided by the total number of objects in the group.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.