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

  • Home
  • SEARCH
  • 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 8722037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:19:21+00:00 2026-06-13T07:19:21+00:00

Created a data frame: simpleDF<- structure(list(vals = c(NA, NaN, 2)), .Names = vals, row.names

  • 0

Created a data frame:

simpleDF<- structure(list(vals = c(NA, NaN, 2)), .Names = "vals", row.names = c(NA, 
-3L), class = "data.frame")


> is.na(simpleDF$vals)
[1]  TRUE  TRUE FALSE
> is.nan(simpleDF$vals)
[1] FALSE  TRUE FALSE

Now, when I change the data frame to include a string value:

simpleDF <- structure(list(vals = structure(c(NA, 2L, 1L, 3L), .Label = c("2", 
"NaN", "test"), class = "factor")), .Names = "vals", row.names = c(NA, 
-4L), class = "data.frame")

> is.na(simpleDF$vals)
[1]  TRUE FALSE FALSE FALSE
> is.nan(simpleDF$vals)
[1] FALSE FALSE FALSE FALSE

I did not understand why NaN is no longer recognized by is.nan()? Sure there would be an explanation ..

  • 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-13T07:19:22+00:00Added an answer on June 13, 2026 at 7:19 am

    NaN is a value that only makes sense in numeric vector, so it gets converted to the character string "NaN" when the class of the vector it is in is (explicitly or implicitly) converted from numeric to character or factor.

    vals
    # [1]  NA NaN   2
    as.character(vals)
    # [1] NA    "NaN" "2" 
    c(vals, "A")
    # [1] NA    "NaN" "2"   "A"  
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've created a data structure like below public class LogList { public int _id;
First, I created a data frame like below: age=18:29 height=c(76.1,77,78.1,78.2,78.8,79.7,79.9,81.1,81.2,81.8,82.8,83.5) height1=c(71.1,75,77.1,73.2,77.8,73.7,78.9,87.1,86.2,85.8,82.8,83.5) village=data.frame(age=age,height=height,height1=height1) Now, I
I have a data.frame called series_to_plot.df which I created by combining a number of
I need to create a data.frame that will be populated one row at a
I created a function that will fill a data frame but I forgot to
I am trying to use the structure() function to create a data frame in
You know how you can supply a vector of names to a data frame
Here is the structure of my data: > str(highered.tweets) 'data.frame': 2950 obs. of 5
I have created a data frame from a SQL query using the RODBC package.
I have created a data frame my.df and wish to select rows (or delete

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.