Plotting standard error in R

0 votes

I have data on the catch rate of certain species of fish.

fish 1  fish 2  fish 3
0.000   3.265   9.872
2.147   1.013   0.000

I have calculated the mean catch rate for each fish using:

a <- colMeans(df)

I have also calculated the standard error:

stdError <- (sapply(df,sd))/sqrt(length(df))

I have created a dotplot using:

dotplot(a, xlab="mean catch", ylab = "species",las =2,)

How do I add error bars to this plot? I would prefer not to use ggplot if possible. I am currently using the inbuilt functions in R but have access to Lattice.

Nov 6, 2018 in Data Analytics by Hannah
• 14,080 points
21 views

1 answer to this question.

0 votes

You can probably use dot plot for this purpose. The dot plot as a representation of a distribution consists of group of data points plotted on a simple scale. Dot plots are used for continuous, quantitative, univariate data. Data points may be labelled if there are few of them. Dot plots are one of the simplest statistical plots, and are suitable for small to moderate sized data sets. They are useful for highlighting clusters and gaps, as well as outliers. 

The Hmisc package extends most lattice functions to better incorporate confidence intervals.

Here's an example of how you would use it. Note that we combine the data you want to plot here into a data.frame so we can use a proper formula symtax

mm<-data.frame(a,stdError, fish=names(a))
library(lattice)
library(Hmisc)
Dotplot(fish~Cbind(a, a-stdError, a+stdError), mm,
    xlab="mean catch", ylab = "species",las =2)
answered Nov 6, 2018 by Kalgi
• 37,320 points

Related Questions In Data Analytics

0 votes
1 answer

Plotting multiple graphs on the same page in R

If you want to plot 4 graphs ...READ MORE

answered Mar 27, 2018 in Data Analytics by Bharani
• 4,550 points
41 views
0 votes
1 answer

What is the standard naming convention for the variables in R?

Use of period separator e.g. product.prices <- c(12.01, ...READ MORE

answered Apr 25, 2018 in Data Analytics by shams
• 3,580 points
19 views
0 votes
1 answer

Error saying "Error in rnorm() : argument "n" is missing, with no default" in R

Hey @ali, rnorm() function requires an argument, ...READ MORE

answered Oct 30, 2018 in Data Analytics by Maverick
• 10,040 points
138 views
0 votes
1 answer

"Error in eval(ei, envir) : object 'RDX2' not found" when trying to source the code in R

This is a very common issue that ...READ MORE

answered Oct 30, 2018 in Data Analytics by Maverick
• 10,040 points
345 views
0 votes
1 answer

Stacked barchart - R programming with ggplot2

Use ggplot2 to map the variables to ...READ MORE

answered Nov 5, 2018 in Data Analytics by Kalgi
• 37,320 points
32 views
0 votes
1 answer

How to color geom_bar by y-axis values?

You can use cut ggplot(cars, aes(x = as.factor(cyl))) + ...READ MORE

answered Dec 6, 2018 in Data Analytics by Maverick
• 10,040 points
44 views
0 votes
1 answer

Loop to automate the plotting process in R

Try something like this: library(tidyverse) data(iris) ## create a grid ...READ MORE

answered Dec 6, 2018 in Data Analytics by Maverick
• 10,040 points
25 views
0 votes
1 answer

How to sort a data frame by columns in R?

You can just use the order function ...READ MORE

answered Apr 10, 2018 in Data Analytics by darklord
• 6,140 points
73 views
0 votes
1 answer

"Error in if" while trying to execute simple code in R

This caused non-logical data or missing values passed ...READ MORE

answered Oct 31, 2018 in Data Analytics by Kalgi
• 37,320 points
27 views
0 votes
1 answer

"no applicable method" Error in r programming

This is caused by using an object-oriented ...READ MORE

answered Oct 31, 2018 in Data Analytics by Kalgi
• 37,320 points
44 views