My code is stupidly simple and yet I cannot figure out what is wrong. Instead of having the data show the mortality for each population at each concentration, each populations mortality is showing up in the same concentration?
Asked
Active
Viewed 25 times
0
-
3Welcome to SO! It would be easier to help you if you provide [a minimal reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) including a snippet of your data or some fake data. Please do not post an image of code/data/errors [for these reasons](https://meta.stackoverflow.com/questions/285551/why-not-upload-images-of-code-errors-when-asking-a-question/285557#285557). – stefan Jul 20 '22 at 18:41
-
Your `Pop` and `Conc` columns are both factor variables rather than numeric variables. Do you know how they became factors? Did something happen earlier in your code that made that change? Because that should not have happened normally. Please don't post pictures of code or data. Share your data in a [reproducible format](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) so we can copy/paste into R for testing rather than having to retype everything. – MrFlick Jul 20 '22 at 19:21
1 Answers
0
You have not provided an example of your dataset, so I used some random values to create a dataframe that looks similar to yours. Here is the code to display mortality at each level of concentration, coloring each point by the type of population (if I understood your question correctly):
Mortality <- data.frame(Pop=factor(c(1,2,3,4,1,2,3,4)),
Conc = factor(c(0.03, 0.03, 0.03, 0.03, 1, 1, 1, 1)),
Mort = c(0.1, 0.15, 0.25, 0.53, 0.525, 0.6, 0.54, 0.3))
ggplot(Mortality, aes(x=Conc, y=Mort )) +
geom_point(aes(color=Pop), size=3)

Katia
- 3,784
- 1
- 14
- 27