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 9118917
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:16:10+00:00 2026-06-17T05:16:10+00:00

I have a vector of size 5 e.g.: a<-c(1,4,6,3,2) I also have another vector

  • 0

I have a vector of size 5 e.g.:

 a<-c(1,4,6,3,2)

I also have another vector of size 1:

 b<-9

I would like to write the following if condition:

if (a>b) { 1
}
else 0
}

I get the following warning:

 Warning message:
In if (fitness_neighbours > user_fitness) { :
  the condition has length > 1 and only the first element will be used

What I would actually like it to do is to check if any of the elements in ‘a’ satisfy the condition.

  • 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-17T05:16:12+00:00Added an answer on June 17, 2026 at 5:16 am

    Use any() and a comparison:

    if(any(a > b)) {
      # Executes if any value in a > b.
    } else {
      # No a is greater than b.
    } 
    

    Another way of doing it using pmax():

    if (any(pmax(a, b) == a)) {
    
    } else {
    
    } 
    

    That’s saying that if any of the max of (a, b) is equal to the value in a, then a must be greater.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a vector of pairs representing hops between nodes which I would like
I have a class symbol_table that has a vector of objects of another class
I have a class in c++ like the following: class myCls { public: myCls();
I wrote a sparse vector class (see #1 , #2 .) I would like
I have a unusual situation, Say I have a class like the following, template
I have a IV (initialization vector) and key, also a cryptogram. I need do
Suppose I have a vector like x = [1 1 1 1 1 1]
Should it be possible to write the following code? What I'd like to do
I have a very large multidimensional vector that changes in size all the time.
I have a single-threaded linux app which I would like to make parallel. It

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.