I have code below that works just fine with the .xlxs files given, just trying to figure out how to incorporate new .xlxs files so I can get some new bar graphs with standard error
I keep getting this: Error: path
does not exist: ‘smails.xlsx’
#amphibian mass
library(readxl)
amphibian_mass <- read_excel("amphibian_mass.xlsx")
View(amphibian_mass)
amphib_mass = amphibian_mass
#calculate the mean amphibian mass by tank
mean_by_tank = aggregate(Mass ~ Tank + Treatment_Code +Species, data=amphib_mass, mean)
mean_by_tank
#calculate the mean mass by treatment
mean_by_trt = aggregate(Mass ~ Species + Treatment_Code, data=mean_by_tank, mean)
mean_by_trt
#Standard Error function
st.err <- function(x) {
sd(x)/sqrt(length(x))
}
#Calculate the standard error of the mean mass of amphibians by tank
SE <- aggregate(Mass ~ Species + Treatment_Code, data=mean_by_tank, st.err)
SE
#combine the data to put into one table
mean_by_trt$SE = SE$Mass
mean_by_trt
#plotting library
library(ggplot2)
#define the standard error limits for the creation of the error bars
ymax = mean_by_trt$Mass + mean_by_trt$SE
ymin = mean_by_trt$Mass - mean_by_trt$SE
#create plot (p) of the mean ambiphian mass by treatment with standard error bars
p = ggplot(mean_by_trt, aes(fill=Treatment_Code, y=Mass, x=Species))
p + geom_bar(position=position_dodge(), stat="identity", colour='black') +
geom_errorbar(aes(ymin=ymin, ymax=ymax), width=.2,position=position_dodge(.9)) +
xlab("Species") +
ylab("Mass (g)") +
scale_fill_discrete(name= "Treatment", labels = c("natives", "bullfrog", "mosquitofish", "bullfrog + mosquitofish"))
##this is a .R file, not a .RMD file. To create a markdown pdf from this file, you can 'Compile Report' using Contrl+Shift+k
This code was used to graph the mass on the y-axis and species on the x-axis. I have new data (snails.xlxs) that I want to incorporate into this code, do I just replace everything that says mass with Num-Snails? or just snails?
I keep getting -- Error: `path` does not exist: ‘smails.xlsx’
here is my new .xlxs file:
Tank Treatment_Code Num_Snails shell_size
1 D 391 4.7578
2 B 112 7.3802
3 C 455 5.1552
4 A 917 3.5896
5 B 432 3.8824
6 B 538 3.4698
the original mass .xlxs:
Tank Treatment_Code Species Mass
1 D PSRE 0.33
2 B PSRE 0.57
2 B PSRE 0.42
2 B PSRE 0.26
etc...
Description of issue -
System Information:
- RStudio Edition: (Desktop or Server)
- RStudio Version: 3.5.1
- OS Version:
- R Version:
-
sessionInfo()
:
Referred here from support.rstudio.com