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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T03:33:11+00:00 2026-06-10T03:33:11+00:00

I have a data frame of the form: >df stationid station gear sample lat

  • 0

I have a data frame of the form:

>df
stationid    station      gear sample     lat    lon       date depth
1     25679          CORBOX150    UE4 53.9015 7.8617 15.07.1987    19
2     25681 UE9 Kern CORCRB050    UE9 54.0167 7.3982 15.07.1987    33
3        NA                           54.0167 7.3982 15.07.1987    33

a logical test on stationid gives me, next to the correct first line, an annoying line full of NAs:

> df[df$stationid=="25679",]
stationid station      gear sample     lat    lon       date depth
1      25679         CORBOX150    UE4 53.9015 7.8617 15.07.1987    19
NA        NA    <NA>      <NA>   <NA>      NA     NA       <NA>    NA

why is that?

Somewhere in line 3 of df, things get messed up, I suppose.

Heres the data:

df<-structure(list(stationid = c(25679L, 25681L, NA), station = structure(c(2L, 
3L, 1L), .Label = c("", " ", "UE9 Kern"), class = "factor"), 
gear = structure(c(2L, 3L, 1L), .Label = c("", "CORBOX150", 
"CORCRB050"), class = "factor"), sample = structure(c(2L, 
3L, 1L), .Label = c("", "UE4", "UE9"), class = "factor"), 
lat = c(53.9015, 54.0167, 54.0167), lon = c(7.8617, 7.3982, 
7.3982), date = structure(c(1L, 1L, 1L), .Label = "15.07.1987", class = "factor"), 
depth = c(19L, 33L, 33L)), .Names = c("stationid", "station", 
"gear", "sample", "lat", "lon", "date", "depth"), class = "data.frame", row.names = c(NA, 
-3L))
  • 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-10T03:33:13+00:00Added an answer on June 10, 2026 at 3:33 am

    Any comparison with NA leads to a result of NA (See http://cran.r-project.org/doc/manuals/R-intro.html#Missing-values ) … you can either use

    df[df$stationid==25679 & !is.na(df$stationid),]
    

    or (as suggested in the comment above)

    df[which(df$stationid==25679),] 
    

    or

    subset(df,stationid==25679)
    

    (subset has the sometimes unwanted side-effect of dropping NA values, but in this case it’s exactly what you do want)

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

Sidebar

Related Questions

In a data.frame, I have a date time stamp in the form: head(x$time) [1]
I have a data.frame in the form: Date 2011-08-16 2011-08-17 2011-08-28 2011-09-01 2011-09-05 2011-09-06
Another ggplot legend question! I have a dataset of the form test <- data.frame(
I have a data frame of daily data: df with four columns: Date, A,
I have a data frame of the form: Family Code Length Type 1 A
I have a data frame in the following form SPY.Open SPY.High SPY.Low SPY.Close SPY.Volume
I have a 'long-form' data frame with columns id (the primary key) and featureCode
I have a data set of the form: df <- data.frame(var1 = c(1976-07-04 ,
I have a data frame where one column is (meant to be) a date
I have the following code, z <- data.frame(a=sample.int(10),b=sample.int(10),c=sample.int(10)) letter <- c(a,c,b) # this will

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.