Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8054891
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T08:14:53+00:00 2026-06-05T08:14:53+00:00

I’ve written a function that contains multiple subfunctions. The subfunctions are all exactly like

  • 0

I’ve written a function that contains multiple subfunctions. The subfunctions are all exactly like the the one below:

Lfunction <- function(mydata, mydata.hex) {

mydata.Lest <- Lest(mydata)

mydata.hex.Lest <- Lest(mydata.hex)

pdf(file="Lplot.pdf")

plot(mydata.Lest, xlim=c(0,200), ylim=c(0,200), main="L Function", xlab="Distance Between Particles (r)", ylab=expression(paste(L(r))), legend = legend(x=165, y=30, c("CSR", "mydata", "mydata.hex"), lty = c(2,1,4), col = c("red", "black","blue"), border = "black"))

plot(mydata.hex.Lest, xlim=c(0,200), ylim=c(0,200), add = TRUE, lty = c(4,2), col = c("blue", "red"))

dev.off()

}

It basically just plots the F function for my two point patterns (mydata and mydata.hex) and exports the image as a PDF to a designated folder on my computer.

For some reason, I’m getting the following error message:

Error in !is.null(legend) && legend : invalid ‘y’ type in ‘x && y’

Now, I’ve gotten this message every time I’ve altered the legend on the plot of an F, G, J, K, L or PCF function. I figured that it was irrelevant since it still produces the graph, and in the location I specified.

The problem is that this error causes my large function (which runs roughly 10 functions like the one shown above) to stop evaluating. The large function looks like this:

GenPDFs <- function(file_name){
mydata <- CreatePPP(file_name)
mydata.hex <- GenHexLat()
Density(mydata)
Lfunction(mydata, mydata.hex)
LfunctionGDS(mydata, mydata.hex)
Ffunction(mydata, mydata.hex)
FfunctionGDS(mydata, mydata.hex)
Gfunction(mydata, mydata.hex)
GfunctionGDS(mydata, mydata.hex)
Jfunction(mydata, mydata.hex)
Kfunction(mydata, mydata.hex)
KfunctionGDS(mydata, mydata.hex)
PCFfunction(mydata, mydata.hex)
#for (i in 1:30) {
#   dev.off()
#   }
}

Thus, I have to manually enter the values into each function.

Does anyone know how to get rid of this warning message? Is there any way to turn it off or negate it from appearing? Or, if you’ve had this error message, do you know how to fix it? For some reason no matter what syntax I use, it produces this error message.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T08:14:58+00:00Added an answer on June 5, 2026 at 8:14 am

    Could you be passing a function call to the (possibly) non-existent ‘legend’ argument of plot? Try this instead:

    pdf(file="Lplot.pdf")
      plot(mydata.Lest, xlim=c(0,200), ylim=c(0,200), main="L Function", 
              xlab="Distance Between Particles (r)", ylab=expression(paste(L(r))),  
              lty = c(2,1,4), col = c("red", "black","blue"), border = "black"))
      legend(x=165, y=30, c("CSR", "mydata", "mydata.hex")
      plot(mydata.hex.Lest, xlim=c(0,200), ylim=c(0,200), add = TRUE, 
               lty = c(4,2), col = c("blue", "red"))
    dev.off()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
I am reading a book about Javascript and jQuery and using one of the
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.