Question: in R Write a script that, for the numbers 1 through 100, will print YAY if the number is divisible by 3, BOO if it
in R Write a script that, for the numbers 1 through 100, will print YAY if the number is divisible by 3, BOO if it is divisible by 5, YAYBOO if it divisible by 3 and 5. For any odd number that does NOT have "YAYBOO", "YAY" or "BOO" next to it, generate a random integer uniformly distributed between 1 and 2. Show the number in the same column as the one where you printed "YAY", "BOO", and "YAYBOO." For any number not yet assigned a value generate a random number from the Lognormal distribution with a mean of 1,000 and a value of the sigma^2 parameter of 5. and assign 100 to the value 100.
I began this by doing this but am stuck at the next step, could someone give me some help?
##open tidyverse to make the code neater and set up number 1-100 install.packages("tidyverse") library(tidyverse) YBscale <- data.frame(1:100)
##create solution ####Begining with assigning the case of divisible by 3, 5, and then both: YBoutput <- YBscale %>% mutate(X1.100 = case_when (YBscale %% 15 == 0 ~ "YAYBOO", FBscale %% 3 == 0 ~ "YAY", FBscale %% 5 == 0 ~ "BOO", TRUE ~ as.character(YBscale)))
This part runs fine, my issue comes when I try to execute the next part:
#### Now for all other integers, assign them to random integer uniformly #### distributed between 1000 and 2000: YBoutput %>% mutate(X1.100 = case_when (YBoutput %% 2 != 0 ~ runif(1,min = 1000, max = 2000), TRUE ~ as.character(YBscale)))
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
