Can anyone help me with my R code?

forage_data_plot <- forage_data %>% group_by(seed_type,distance) %>%
  summarize (mean_visits = mean(visits), sem =sd(visits)/sqrt(length(visits)))
jpeg("interaction_ggplot_forgae2.jpeg,width=1100,height=600“)
par(mar = c(6,6,2,2),mgp=c(3,1,0)) #margins of plot
pd <- position_dodge(0.1)
ggplot(forage_data_plot, # our data
       aes(x=seed_type,y=mean_visits,colour=distance,group=distance))+
  ylab("mean_visits\n") + xlab("seed_type/n") +
  scale_color_manual(values = c("N" = "firebrick", "Y" = "darkslategray4"))+
  theme(axis.line.x = element_line(color="black", size = 0.7),
        axis.line.y = element_line(color="black", size = 0.7),
        axis.title = element_text(family = "Helvetica", color="#666666",
        face="bold",  size=32), axis.text=element_text(size=28),
        panel.background=element_rect(fill="white"),
        legend.text=element_text(size=25),
        legend.title=element_text(size=30), 
        legend.key.height = unit(3, "line"),
        legend.key = element_rect(fill = "white")) +
    geom_errorbar(aes(ymin=mean_visits-sem, ymax=mean_visits+sem),
                  width=.1, size=0.9, position=pd, colour="gray32") +
    geom_line(position=pd, size=0.9) + #lines between means (points)
    geom_point(position=pd, size=5) #points of means 
    
dev.off() 

Warning messages:
1: Removed 4 rows containing missing values (geom_path).
2: Removed 4 rows containing missing values (geom_point).
3: In grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
Windows字体数据库里没有这样的字体系列
4: In grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
Windows字体数据库里没有这样的字体系列
5: In grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
Windows字体数据库里没有这样的字体系列
6: In grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
Windows字体数据库里没有这样的字体系列
7: In grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
Windows字体数据库里没有这样的字体系列

(these Chinese character means that they do not have this font in the database)

I cannot see my plot, and I don't know why there are missing values. Do I need to download some font to solve this problem?

summary(foraging_anova)
Df Sum Sq Mean Sq
seed_type 1 369.2 369.2
distance 1 2.3 2.3
seed_type:distance 1 0.1 0.1

Also, for the summary of ANOVA, seems like it does not have the statistical results. What should I do

I know it might be a stupid question, but I really really need help.

The only error that jumps to my eyes is this one, you are putting the closing quotes in the wrong place, try with this instead:

jpeg("interaction_ggplot_forgae2.jpeg", width = 1100, height = 600)

If this doesn't work, please provide a proper REPRoducible EXample (reprex) for your issue.

You have a "curly" double quotation mark after height = 600 in the call to jpeg(). Try changing that to a standard straight double quote like all the other quotation marks in the code.
Edit: the answer above by andresrcs is more accurate than my answer.

Thank you, it works now

If your question's been answered (even by you!), would you mind choosing a solution? It helps other people see which questions still need help, or find solutions if they have similar problems. Here’s how to do it:

Sorry, some new issues are coming up. I just updated my question, would you mind look at it and give me some suggestions? Thank you very much

As I told you on a previous post, If you need specific help, please provide a proper reproducible example, also please make sure to follow this guidelines about how to make a good R related question.

I am not sure if I did the right thing, but here is my minimal code

library(dplyr)
library(ggplot2)

read in experiment data

forage_data <- read.csv("export data - Sheet1.csv")
#see the first few rows
head(forage_data)
#rename columns
colnames(forage_data)<-c("distance","seed_type","visits")
#what type of data
str(forage_data_plot)

forage_data_plot <- forage_data %>% group_by(seed_type,distance) %>%
summarize (mean_visits = mean(visits), sem =sd(visits)/sqrt(length(visits)))
jpeg("interaction_ggplot_forgae2.jpeg",width=1100,height=600)
par(mar = c(6,6,2,2),mgp=c(3,1,0)) #margins of plot
pd <- position_dodge(0.1)
ggplot(forage_data_plot, # our data
aes(x=seed_type,y=mean_visits,colour=distance,group=distance)) +
ylab("mean_visits\n") + xlab("seed_type/n") +
scale_color_manual(values = c("N" = "firebrick", "Y" = "darkslategray4"))+
theme(axis.line.x = element_line(color="black", size = 0.7),
axis.line.y = element_line(color="black", size = 0.7),
axis.title = element_text(family = "Helvetica", color="#666666",
face="bold", size=32), axis.text=element_text(size=28),
panel.background=element_rect(fill="white"),
legend.text=element_text(size=25),
legend.title=element_text(size=30),
legend.key.height = unit(3, "line"),
legend.key = element_rect(fill = "white")) +
geom_errorbar(aes(ymin=mean_visits-sem, ymax=mean_visits+sem),
width=.1, size=0.9, position=pd, colour="gray32") +
geom_line(position=pd, size=0.9) + #lines between means (points)
geom_point(position=pd, size=5) #points of means

dev.off()

foraging_anova <- aov(formula = mean_visits ~ seed_type * distance, data = forage_data_plot)

summary(foraging_anova)

That is not reproducible since we don't have access to your local files (i.e. export data - Sheet1.csv), please read the link I gave you before and try to make a proper reproducible example including sample data on a copy/paste friendly format.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.