title: Plotting posterior distribution in R
body: <p>I want to compute a posterior density plot with conjugate prior</p>
  
  <p>I have data with known parameters (mean =30 , sd =10)</p>
  
  <p>I have two priors one with normal distribution with known parameter ( mean =10 , sd=5) and other with t distribution with same mean and sd but degree of freedom 4</p>
  
  <p>I want a graph with  density plots for prior,data and posterior ?</p>
  
  <p>can you help me with r code for this problem ?</p>
  
  <p>Plus I am getting wrong density function for posterior in my opinion..Here is my code so far</p>
  
  <pre><code>x=seq(from=-90, to=90, by= 1)
  data=dnorm(x,mean=30,sd =10)
  prior = dnorm(x,mean=10,sd =5)
  posterior = dnorm(x,mean=10,sd =5)*dnorm(x,mean=30,sd =10) # prior* data  #Prior*data
  
  plot(x,data , type="l", col="blue")
  lines(x,prior, type="l", col="red")
  lines(x,posterior , type="l", col="green")
  </code></pre>