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

  • SEARCH
  • Home
  • 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 8948171
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:55:18+00:00 2026-06-15T12:55:18+00:00

I have constructed in R a two variable integer valued function f(x,y) which is

  • 0

I have constructed in R a two variable integer valued function f(x,y) which is only well – defined for single entries (not for example f(1,1:5)). I am effectively looking for an integer valued function F(x,y,z,w) which would give the output:

f(x,y),f(x,y+1),...,f(x,w),f(x+1,y),f(x+1,y+1),...,f(x+1,w),...,f(z,y),f(z,y+1),...,f(z,w)

as a (z-x+1) by (w-y+1) matrix. Cheers for any help!

  • 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-15T12:55:19+00:00Added an answer on June 15, 2026 at 12:55 pm

    outer seems to be what you’re looking for here.

    # make a simple function
    f <- function(x, y){x+y}
    x <- 3
    z <- 5
    y <- 2
    w <- 7
    outer(x:z, y:w, f)
    #     [,1] [,2] [,3] [,4] [,5] [,6]
    #[1,]    5    6    7    8    9   10
    #[2,]    6    7    8    9   10   11
    #[3,]    7    8    9   10   11   12
    

    If it’s true that your function really only can take scalars as the input then you may need to use Vectorize to make this approach work

    # Function that can only takes scalars...
    f <- function(x, y){if(length(x) > 1 | length(y) > 1) stop('blah'); x + y}
    outer(x:z, y:w, f)
    #Error in FUN(X, Y, ...) : blah
    myvectorizedfun <- Vectorize(f)
    outer(x:z, y:w, myvectorizedfun)
    #     [,1] [,2] [,3] [,4] [,5] [,6]
    #[1,]    5    6    7    8    9   10
    #[2,]    6    7    8    9   10   11
    #[3,]    7    8    9   10   11   12
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I have two constructor function: var Person = function(xx,xx,xxx,xxxxxxx) { //Person initialization }
I have a header which I constructed like this: <header class=top> <a href=> <span
The following method op belongs to a class with two private integer-valued instance variables,
I have two classes, one of which is a subclass of another, and differs
I have two classes, A and B Class B has a private member variable
I have already searched SO and google, I am not declaring the same variable
I have two classes. Looking to be able to grab a variable that is
I have two options in a Servlet regarding the initialization of a variable that
I have constructed a class to mimic a C# struct: public class Favourite {
I have constructed an XML tree structure of an XML file. I am able

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.