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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T13:46:58+00:00 2026-06-14T13:46:58+00:00

So it got a csv I’m reading into an R dataframe, it looks like

  • 0

So it got a csv I’m reading into an R dataframe, it looks like this

clientx,clienty,screenx,screeny
481,855,481,847
481,784,481,847
481,784,481,847
879,292,879,355

First line is of course the header. So we have 4 columns with numeric data in it, ranging from 1 to 4 digits. There are no negative numbers in the set except -1 which marks a missing value.
I want to remove every row that contains a -1 in any of the 4 columns.

Thanks in advance for the help

  • 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-14T13:46:59+00:00Added an answer on June 14, 2026 at 1:46 pm

    Your most efficient way will be to use the na.strings argument of read.csv() to code all -1 values as NA, then to drop incomplete cases.


    Step 1: set na.strings=-1 in read.csv():

    x <- read.csv(text="
    clientx,clienty,screenx,screeny
    481,855,481,847
    481,784,481,847
    481,784,481,847
    -1,292,879,355", header=TRUE, na.strings=-1)
    
    x
    clientx clienty screenx screeny
    1     481     855     481     847
    2     481     784     481     847
    3     481     784     481     847
    4      NA     292     879     355
    

    Step 2: Now use complete.cases or na.omit:

    x[complete.cases(x), ]
      clientx clienty screenx screeny
    1     481     855     481     847
    2     481     784     481     847
    3     481     784     481     847
    
    na.omit(x)
      clientx clienty screenx screeny
    1     481     855     481     847
    2     481     784     481     847
    3     481     784     481     847
    

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

Sidebar

Related Questions

I've got a CSV file with a format that looks like this: FieldName1, FieldName2,
I've got a CSV file that looks like this: id, name 0, A.D. TRAMONTANA
I've got a CSV with some data that looks like this: A0A0A0,48.5674500000,-54.8432250000,Gander,NL A0A1A0,47.0073470000,-52.9589210000,Aquaforte,NL A0A1B0,47.3622800000,-53.2939930000,Avondale,NL
I've got a bunch of csv files that I'm reading into R and including
I've got a multiline file that I would like to turn into a csv
I've got a CSV file that looks like: 1,3,3,5,4,5,5 Now I want to change
I've got a column in a CSV file that looks like c(,1,1 1e-3) (i.e.
I've got a data.csv file which is structured like this: n John Smith stats
I got a lot of files whose names are like this: tmp1.csv tmp32.csv tmp9.csv
I got an interesting problem: file1.csv has a few hundred rows like: Code,DTime 1,2010-12-26

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.