How can i compute the following situation in R?

Suppose that an urn contains a number of black and a number of white balls, and suppose that it is known that the ratio of the numbers is $\frac{3}{1}$ but that it is not known whether the black or the white balls are more numerous. Find the estimator of the probability of drawing a black ball.

I have done this by the following way :

the probability of drawing a black ball is either 0.25 or 0.75.

If n balls are drawn from the urn, the distribution of X, the number of black balls, is given by the *Binomial Distribution*

$f(x;p)=\binom{n}{x}p^x(1-p)^{n-x}\quad ; x=0,1,2,...,n$

where $p$ is the probability of drawing a black ball. Here $p=0.25$ or $0.75$

We shall draw a sample of three balls, that is, n=3, with replacement and attempt to estimate the unknown parameter $p$ of the distribution.

Let us anticipate the results of the drawing of the sample. The possible outcomes and their probabilities are given below :

Outcome:x & 0 & 1 & 2 & 3 \\
f(x;\frac{3}{4}) & \frac{1}{64} & \frac{9}{64} & \frac{27}{64} & \frac{27}{64} \\
f(x;\frac{1}{4}) & \frac{27}{64} & \frac{27}{64} & \frac{9}{64} & \frac{1}{64} \\

In the present example if we found x=0 or 1 in a sample of 3, the estimate for $p$ would be preferred over 0.75.

The estimator may be defined as :

$\hat p$ =
0.25, &\text{for $x=0,1$} \\
0.75, &\text{for $x=2,3$} \\

I want to estimate $p$ for the above situation in R. I tried to do that in the following procedure which seems totally incorrect to me because if several alternative values of $p$ were possible, i can't proceed in the same manner. But i have no more idea also :

ifelse(x==0 & 1, "hat_p=0.25", "hat_p=0.75")

ifelse(x==0 & 1, "hat_p=0.25", "hat_p=0.75")

*"How can i compute the above situation in R?"*