Computing a Gaussian posterior from a Gaussian prior and likelihood function in R I'm new to both R and Bayesian statistics, and I have a problem where I have a normally distributed prior that elicits a mean and standard deviation.  The introduced likelihood function is also normally distributed with a mean and standard deviation that can be drawn from a sample.
Now I understand that a posterior is formed that will also be normally distributed.  I have been asked to generate this in R, but I cannot find an example of R code where the posterior is formed from a normally distributed prior and likelihood function.  
Could someone please point me in the right direction.  Thanks.  
 A: I'm going to assume since you're new to Bayesian analysis that you're supposed to do this through conjugate updating.
You understand that the posterior distribution is normal, but how exactly is this known? For certain priors we know the exact relationships between prior, likelihood, and posterior: see here for a handy table. Your situation is probably contained within this table, though it may require some reflection on your part to decide which prior you are actually using (i.e., known or unknown variance). These posterior updates are obtained by working through the algebra of 
$$
\text{Posterior}(\theta \mid \text{data}) \propto \text{Likelihood}(\text{data} \mid \theta) \times \text{Prior}(\theta).
$$
It may be useful, since you claim to be new to Bayesian analysis, to work through this calculation for your problem and see exactly the algebraic relationship between the prior(s) and the data and how they form the posterior parameters found in the table linked above. (Hint: the proportionality constant is related to the constant which would make the distribution integrate to 1 on the whole support).
Now, once you have the posterior distribution fully specified, you are theoretically done. If you need concrete evidence of your success (or even want to check how reasonable the values are), you can do sampling on your posterior through the built-in rnorm function, or you can plot the actual distribution values through dnorm on a grid of appropriate values. 
