Unexpected ")" in "

Hello all, I am trying to create a boxplot, but R keeps telling me there is an unexpected ")" in my answer, but I am pretty confident all my parentheses match up... here is my script, any help would be very appreciated! I am pretty new to R so I'm just a little confused! Thank you :slight_smile:

boxplot (pilot$Percent Germination ~ pilot$Seed Type * pilot$Light Treatment,
xaxt = "n",
xlab = "Treatment",
ylab = "Percent Seed Germination (%)",
col = c("pink", "purple" ),
at = c(1,2, 4,5, 7,8))

Welcome to the community!

I think the problem is being created because you have column names with spaces. Try this once:

boxplot (pilot$`Percent Germination` ~ pilot$`Seed Type` * pilot$`Light Treatment`,
xaxt = "n",
xlab = "Treatment",
ylab = "Percent Seed Germination (%)",
col = c("pink", "purple" ),
at = c(1,2, 4,5, 7,8))

If it does not solve the problem, please provide a minimal reproducible example. For your case, probably dput(head(pilot, 30)) will be enough. Change 30 if it's not appropriate.


Edit

@savita.m20 : Here were the problems:

Here you were trying to access Percent Germination, Seed Type and Light Treatment from pilot, and that failed. If you see my snippet, I added backticks (`) before and after these, and it works that way.

Hope that helps. If your problem is solved, will you please consider closing the thread? FAQ link below:

That worked! Thank you so much I appreciate it. Also, where was the spacing off, just so I can prevent this mistake in the future! Than you again :slight_smile:

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.