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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:38:00+00:00 2026-05-31T16:38:00+00:00

I am getting an argument of length zero after running the code below. I

  • 0

I am getting an argument of length zero after running the code below. I have looked at other users with this issue, however I am unable to figure out the error.

gi <- pm%*%t(pm); #creates a 5k by 5k matrix by multiplying matrix by its transpose
dim(gi); # checks dimensions of matrix
ngen <- dim(pm)[1];
select <- matrix(F,ncol=ngen,nrow=ngen);
for(i in 1:(ngen-1)){
    for(ii in (i+1):ngen){
        if(gi[i,ii] < llim){
            next;
        }
        hit1 <- p.sum[i];
        hit2 <- p.sum[ii];
        if(gi[i,ii] >= qmat[hit1,hit2]){
            select[i,ii] <- TRUE;
        }
    }
}

This code returns the error:

Error in if (gi[i, ii] >= qmat[hit1, hit2]) { : 
  argument is of length zero

I have a feeling that the problem is the gi variable as hit1 and hit2 return values, any ideas how I could fix it? Any assistance would be greatly appreciated.

  • 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-05-31T16:38:01+00:00Added an answer on May 31, 2026 at 4:38 pm

    The most likely reason for the failure is that hit1 or hit2 returns 0.

    m <- matrix(1:12,4)
    m[0,3] # integer(0)
    if (m[0,3] > 0) 'foo!'
    #Error in if (m[0, 3] > 0) "foo!" : argument is of length zero
    

    …And you can use tcrossprod(pm) instead of pm%*%t(pm) – it’s faster and (in my opinion) clearer.

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

Sidebar

Related Questions

I keep getting this : DeprecationWarning: integer argument expected, got float How do I
I have this code to get all my baobjectCode from database. var maxCode =
I am getting Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource
I'm getting the error Invalid argument supplied for foreach() even though the array being
I am getting a Wrong type argument: commandp, (lambda nil (forward-line 5)) here. (global-set-key
Getting started with TDD and I want to ground up a Repository-driven Model. However,
Getting the above error in following code. How to rectify it. Thanks. Please look
I am not able to understand the error with the code below which simply
So I keep getting this error that when I Google for it, the most
I have a few reasons to define a type for a fixed length array

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.