Refer to the image. Please use R CODE. This is a computer science question.
The probability of rejecting at least one null hypothesis given all null hypotheses are true is 1- (1-0.05)^k. Suppose the p-value for each single hypothesis test is obtained. Use the Benjami and Hochberg algorithm. First label the p values in ascending order such that p1< p2<..< p(k) and denote by H(ti the null hypothesis corresponding to p(i). Second, define i0 as the largest i p(i)< 0.05i /k. The decision rule rejects all H(i) for i=1.. i(0). Write a function named as bd.adjust using the Benjami Hochber g algorithm. The arguments of this function include a numerical vector pvs of p-value and significance level a (set its default value = 0.05). the output will be a logic vector having the same length as the pvs, using FALSE(F) to denote rejecting a specific null hypothesis. For example, (T, F, T) means the algorithm rejects the second null but fails to reject the first and third. Note that the output should be the final decisions for the series of hypotheses in the original order based on the Benjamini and Hochberg algorithm. Implement your function bh.adjust(pvs) with the following vectors for pvs. Interpret your output using words regarding which null hypotheses are rejected and which are not.
pvs=c(0.04, 0.02)
pvs=c(0.039,0.024, 0.35, 0.009, 0.1)
pvs=c(0.34, 0.015, 0.029, 0.008, 0.49)
pvs=c(0.34, 0.015, 0.029, 0.008, 0.49, 0.001, 0.72, 0.54)