To calculate a confidence interval in R, you can use the t.test()
function. This function requires a sample of data with a numeric variable, and can calculate a confidence interval based on a specified level of confidence:
main.r120 chars7 lines
This will give you the lower and upper bounds of the confidence interval. If you want to specify a different level of confidence, you can pass it as an argument:
main.r79 chars3 lines
You can also calculate a confidence interval for the difference between two groups using the same t.test()
function:
main.r220 chars8 lines
This will give you the lower and upper bounds of the confidence interval for the difference between the two group means.
gistlibby LogSnag