Plotting standard error in R

+1 vote

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
• 18,570 points
493 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
• 52,360 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,660 points
1,169 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,670 points
450 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,840 points
2,969 views
+1 vote
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,840 points
4,661 views
+1 vote
2 answers

Stacked barchart - R programming with ggplot2

Use position = stack inside geom_bar() ggplot(mydata, aes(x = ...READ MORE

answered Aug 23, 2019 in Data Analytics by anonymous
• 33,030 points
672 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,840 points
937 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 7, 2018 in Data Analytics by Maverick
• 10,840 points
1,183 views
+1 vote
2 answers

How to sort a data frame by columns in R?

You can use dplyr function arrange() like ...READ MORE

answered Aug 21, 2019 in Data Analytics by anonymous
• 33,030 points
1,416 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
• 52,360 points
423 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
• 52,360 points
2,234 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP