Your R code thinks you have a 2x2 contingency table for the chi-squared test, whereas your 'by hand' version treats two of your values as the expected values with which to compare the first two values. You need to decide which setup is correct and use it consistently both times.
Here is your R version:
> test <- matrix(c(4203, 4218, 786, 771), ncol=2)
> dimnames(test) <- list(group = c("control","exp"), click = c("n","y"))
> print(test)
click
group n y
control 4203 786
exp 4218 771
> print(Xsq <- chisq.test(test, correct=F))
Pearson's Chi-squared test
data: test
X-squared = 0.1712, df = 1, p-value = 0.679
This is how you do it 'by hand':
\begin{array}{lrrr}
& &\text{click} & \\
\rm group &\rm n &\rm y &\rm proportion \\
{\rm control} &4203 &786 &0.50 \\
{\rm exp} &4218 &771 &0.50 \\
\rm proportion &0.844 &0.156
\end{array}
Notice that I added the row and column proportions. These are taken as estimates of the probability that an observation will fall in each row (column). The expected count in each cell under the assumption of independence is the row probability times the column probability times the total count. For your data, that gives:
\begin{array}{lrr}
&\text{click} & \\
\rm group &\rm n &\rm y \\
{\rm control} &4210.5 &778.5 \\
{\rm exp} &4210.5 &778.5 \\
\end{array}
Thus the calculation is:
$$
\frac{(4203-4210.5)^2}{4210.5} + \frac{(4218-4210.5)^2}{4210.5} + \frac{(786-778.5)^2}{778.5} + \frac{(771-778.5)^2}{778.5} = 0.1712,
$$
Which is the same as what R gave.
If you take the control row counts as the expected counts, rather than the counts for another condition, you would have the following for your 'by hand' calculation:
$$
\frac{(4218-4203)^2}{4203} + \frac{(771 - 786)^2}{786} = 0.3398
$$
You can also run this version in R like so:
> probs <- test[1,]/sum(test[1,])
> probs
n y
0.8424534 0.1575466
> chisq.test(test[2,], correct=F, p=probs)
Chi-squared test for given probabilities
data: test[2, ]
X-squared = 0.3398, df = 1, p-value = 0.5599
They key is that you specify the p argument with the expected probabilities (R will take care of calculating the expected counts). At any rate, you can see that the $\chi^2$ values are once again the same.