Hi Chitta, I am not sure there is a single function (yet) that calculates and draws CIs directly from the data. But there is always the option to calculate the CIs beforehand (for instance with the functions summarySE for between-subjects factors and summarySEwithin for within-subjects factors, both in the Rmisc package), save them to a vector (or your dataframe with the means) and then add to your graph. There are some easy bar graphs in the ggglot2 package; useful linegraphs can be drawn with the plotCI function (but beware, by default plot CI plots the +/-1 SE bars and not the 95% CI).
Yes, these polygon-graphs are a very useful option when your independent variable is continuous. My solution is useful only for independent variables that are categorical.
The geom_errorbar() function in ggplot2 is really handy for adding error bars. Confidence intervals are really useful for ecology because 1) p-values can often be misleading, plus they are highly overused and 2) if's the CI's don't overlap then it's very likely that the populations that you're looking at are significantly different
#Here's the R code in case you want to run a simulation.
require(ggplot2)
# Set up some data. Use a sample size of 100 to
# approach normality for simplicity
x = c(rep("A",100),rep("B",100))
# One of our populations will have a mean of 13
# and a sd of 2 while the other will have a mean
# of 15 and a sd of 2.5
y = c(rnorm(100,13,2),rnorm(100,15,2.5))
#Set everything up into a data frame
data = as.data.frame(list(x = x, y = y))
# In case you want to calculate different
# levels of confidence. You will need to remember
# that these are 2-sided distributions so use these
# to calculate your Z scores:
# this will calculate the 90% CI
qt(.95, 1000) # 1.65
# 95% CI
qt(.975, 1000) # 1.96
# 99% CI
qt(.995, 1000) # 2.58
# If we want the 95% CI our z score will be 1.96
# You can use the aggregate functions to calculate the
# mean and 95% CI.
# The formula for calculating a CI is: Z * standard error
# so in this case the 95% CI = 1.96 * (sd(x)/sqrt(length(x)))