## How to create a function that returns a p-value min(1, 2*min(P{N ≤ i}, P{N ≥ i})) in R?

I am trying to create a function that performs the sign test. The function should take in vector x and median m and returns a p-value defined by min(1, 2*min(P{N ≤ i}, P{N ≥ i})), where N~Bin(n, 0.5), n is the amount of values which are no…