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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T01:22:41+00:00 2026-06-06T01:22:41+00:00

I have a data frame that’s about ts1[100, 2000] in dimension as follows: >

  • 0

I have a data frame that’s about ts1[100, 2000] in dimension as follows:

> ts1[1:8, 1:6]
       DD LEVEL     X136747     X136749     X136752     X136753     ... ...
1 D04MX.x    LC        0.25        0.30       -0.01       -0.05
2 D08MX.x    LC        0.22        0.11        0.11        0.00
3 D15MX.x    LC        0.31        0.33       -0.23       -0.08
4 D29MX.x    LC        0.28        0.14       -0.28       -0.08
5 D04HX.x    SC        0.11       -0.26       -0.21       -0.33
6 D08HX.x    SC        0.25       -0.23       -0.07       -0.25
7 D15HX.x    SC        0.29        0.03       -0.05       -0.10
8 D29HX.x    SC        0.29        0.13       -0.09        0.02
... ...

I would like to replace all the values that are between -0.1 and 0.1 under the columns named X###### (ts1[3:ncol(ts1)]) to be 0. I tried the following:

> ts1 <- ifelse(abs(ts1) < 1, 0, ts1)
Error in Math.data.frame(ts1) : 
  non-numeric variable in data frame: DDLEVEL
> ts1[which(abs(ts1) < 1)] <- 0
Error in Math.data.frame(ts1) : 
  non-numeric variable in data frame: DDLEVEL
> ts1[which(abs(is.numeric(ts1)) < 1)] <- 0
> ts1
  DD LEVEL X1367471_at X1367495_at X1367527_at X1367536_at
1  0    LC        0.25        0.30       -0.01       -0.05
2  0    LC        0.22        0.11        0.11        0.00
3  0    LC        0.31        0.33       -0.23       -0.08
... ...
> ts1 <- ts1[, lapply(.SD[3:ncol(ts1)], ifelse(abs(ts1) < 1, 0, ts1))]
Error in Math.data.frame(ts1) : 
  non-numeric variable in data frame: DDLEVEL

What am I doing wrong? I do need to retain the first two columns. Any shortcut? 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-06-06T01:22:42+00:00Added an answer on June 6, 2026 at 1:22 am

    Assuming your data is named df:

    colsToEdit <- grepl("X", names(df))
    df[, colsToEdit][abs(df[, colsToEdit]) <= 0.1] <- 0
    

    Gives you:

     DD LEVEL X136747 X136749 X136752 X136753
    1 D04MX.x    LC    0.25    0.30    0.00    0.00
    2 D08MX.x    LC    0.22    0.11    0.11    0.00
    3 D15MX.x    LC    0.31    0.33   -0.23    0.00
    4 D29MX.x    LC    0.28    0.14   -0.28    0.00
    5 D04HX.x    SC    0.11   -0.26   -0.21   -0.33
    6 D08HX.x    SC    0.25   -0.23    0.00   -0.25
    7 D15HX.x    SC    0.29    0.00    0.00    0.00
    8 D29HX.x    SC    0.29    0.13    0.00    0.00
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a data frame in R that has come about from running some
I have a data frame that looks as follows (8 columns - the myPOSIX
I have a data frame that follows the below long Pattern: Name MedName Name1
I have a data frame that is 100 X 100. There are 30 columns
I have a data.frame that looks like this: > head(ff.df) .id pio caremgmt prev
I have a data.frame in R that looks like this: score rms template aln_id
I have a data frame in R that looks like this: > TimeOffset, Source,
I have a data.frame and I'm trying to create a frequency table that shows
Let's assume that we have a data frame x which contains the columns job
I have a (dense) dataset that consist of 5 groups, so my data.frame looks

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.