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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:17:41+00:00 2026-05-24T17:17:41+00:00

I’m a relative R noob. I’ve got a big dataset that looks something like

  • 0

I’m a relative R noob.

I’ve got a big dataset that looks something like this:

         Tempadjvolt      newmass     rgdeltas
2794       498.5777  0.5355647187   0.00000000
2795       499.7577  0.5355647187   0.00000000
2796       500.7877  0.3415104788  -2.87487763
2797       502.1177  0.4312854788  -1.54487763
2798       500.3877  0.5355647187   0.00000000
2799       502.5377  0.4596354788  -1.12487763
2800       507.6877  0.8072604788   4.02512237
2801       505.2577  0.6432354788   1.59512237
2802       505.7977  0.6796854788   2.13512237
2803       517.8877  1.4957604788  14.22512237
2804       502.2477  0.4400604788  -1.41487763
2805       507.3677  0.7856604788   3.70512237
2806       519.7277  1.6199604788  16.06512237
2807       528.9377  2.2416354788  25.27512237
2808       520.2677  1.6564104788  16.60512237
2809       519.3877  0.5355647187   0.00000000
2810       526.5677  2.0816604788  22.90512237
2811       519.5377  0.5355647187   0.00000000
2812       526.9277  2.1059604788  23.26512237
2813       529.9877  2.3125104788  26.32512237
2814       514.4077  1.2608604788  10.74512237
2815       518.3777  1.5288354788  14.71512237

I’m trying to identify negative rgdeltas values [for example, row 2804] and then ‘look’ 7 positions behind and ahead to find the highest Tempadjvolt and set row 2804’s tempadjvolt to that local max.

The frame is ~4000 rows long, of which ~515 are negative values. I tried a couple for loops that sorta worked… but also spit out a bunch of NAs — which makes me think they were poorly/improperly constructed.

Any assistance would be greatly appreciated.

As was pointed out in the comments, the original post was unclear. I’m not concerned about consecutive negative rgdeltas values. For negative values within 7 of the front and end of the frame, ideally the loop would look as many positions forward and back before the beginning/end. Less concerned with that at this point.

A little more background:
This is part of a signal processing program originally written in C# that I’m attempting to move to R to augment some more facile batch processing of a large number of files output from an environmental monitor. I didn’t write the original code and this is only one small component of a much larger set of stuff going on.

I appreciate the help. Thanks!

  • 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-24T17:17:43+00:00Added an answer on May 24, 2026 at 5:17 pm

    Assume its name is dat:

    negidxs <- as.numeric( rownames(dat)[ dat[[3]] < 0 ] )
     for ( i in negidxs ){ 
          dat[as.character(i), "Tempadjvolt"] <- 
                max(dat[rownames(dat) %in% (i-7):(i+7), "Tempadjvolt"], na.rm=TRUE) }
     dat
      #----------------------------------#
         Tempadjvolt   newmass  rgdeltas
    2794    498.5777 0.5355647  0.000000
    2795    499.7577 0.5355647  0.000000
    2796    517.8877 0.3415105 -2.874878
    2797    517.8877 0.4312855 -1.544878
    2798    500.3877 0.5355647  0.000000
    2799    519.7277 0.4596355 -1.124878
    2800    507.6877 0.8072605  4.025122
    2801    505.2577 0.6432355  1.595122
    2802    505.7977 0.6796855  2.135122
    #snipped-----
    
    • 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
For some reason, after submitting a string like this Jack’s Spindle from a text
I would like to run a str_replace or preg_replace which looks for certain words
I know there's a lot of other questions out there that deal with this
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
this is what i have right now Drawing an RSS feed into the php,

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.