Config Router

  • Google Sheets
  • CCNA Online training
    • CCNA
  • CISCO Lab Guides
    • CCNA Security Lab Manual With Solutions
    • CCNP Route Lab Manual with Solutions
    • CCNP Switch Lab Manual with Solutions
  • Juniper
  • Linux
  • DevOps Tutorials
  • Python Array
You are here: Home / R debugging: “only 0’s may be mixed with negative subscripts”

R debugging: “only 0’s may be mixed with negative subscripts”

August 23, 2021 by James Palmer

The problem: actionlist$RPos[1000] has a value of 21. n1 ranges from -31 to 0. When you add them you get a vector with a mix of positive and negative values, which isn’t allowed in subsetting.
How I got there: First check traceback():
traceback()
5: `[.data.frame`(z, actionlist$RPos[i] + n1, j) at #8
4: z[actionlist$RPos[i] + n1, j] at #8
3: is.data.frame(x) at #8
2: cor(z[actionlist$RPos[i] + n1, j], x[, j]) at #8
1: GetTopN(10)

This tells me the problem is in actionlist$RPos[i] + n1 most likely. Then I just added a simple print(i) statement to tell me which iteration was the problem. (Alternatively, you could probably have just checked actionlist$RPos + n1 for trouble spots manually.

For tidyverse users, dplyr gives this error if you try to subset a grouped df, you need to call ungroup first.

Related

Filed Under: Uncategorized

Recent Posts

  • How do I give user access to Jenkins?
  • What is docker volume command?
  • What is the date format in Unix?
  • What is the difference between ARG and ENV Docker?
  • What is rsync command Linux?
  • How to Add Music to Snapchat 2021 Android? | How to Search, Add, Share Songs on Snapchat Story?
  • How to Enable Snapchat Notifications for Android & iPhone? | Steps to Turn on Snapchat Bitmoji Notification
  • Easy Methods to Fix Snapchat Camera Not Working Black Screen Issue | Reasons & Troubleshooting Tips to Solve Snapchat Camera Problems
  • Detailed Procedure for How to Update Snapchat on iOS 14 for Free
  • What is Snapchat Spotlight Feature? How to Make a Spotlight on Snapchat?
  • Snapchat Hack Tutorial 2021: Can I hack a Snapchat Account without them knowing?

Copyright © 2025 · News Pro Theme on Genesis Framework · WordPress · Log in