Error code in my RStudio but not when ran on someone else's RStudio

I'm very new when it comes to RStudio and I was given a code that I modified and used to create vertical distribution plots and it worked perfectly. I needed to add a "N=" on each plot and when I went back to use this code and same data, I am now receiving a

"Error in -0.01 * height : non-numeric argument to binary operator"

I never received this error before and I sent the code and data to my friend for them to try out and they are not receiving this error message.

What could be causing this and why would this error be showing up now and not before?

I tried the code the way it was ran before adding anything new to it.

Please help!
This is the code


filepath <- "Pteropod Distribution Folder"
#This is the drive and folder where you want it to store your plots

len <- (length(pteropod[0,])-1)/2
position <- 1
for (i in 1:len){
  path <- paste(names(pteropod[i+position]),".jpeg")
  #This tells it to save your plots as jpegs and store them in the filepath you created above
  #these are the 2 lines that set the max each loop
  barplot(matrix(-pteropod[,i+position]),beside= TRUE,horiz=TRUE,col="white",axes=F,xlim=c(-maxi,maxi),width=c(300,200,400,400,200))
  barplot(matrix(pteropod[,i+1+position]), beside= TRUE, horiz=TRUE,col="black",add=TRUE,axes=F,xlim=c(-maxi,maxi),width=c(300,200,400,400,200))
  axseq <- seq(-maxi,maxi,maxi/5)
  mtext(side=3,expression(paste(Abundance," (No. ",10^-7,m^-3,")")),2,cex=1.5)
  mtext(side=2,"Depth (m)",cex=1.5,2.5)
  mtext(side=1, str_replace(names(pteropod[i+position]), "\\.", " "),1,cex=2,font=3)
  title(main=bquote(atop(italic(.(i)), "N = " ~.(nrow(current.sp)))))
  position <- position + 1

Thank you in advance for any help!

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