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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:24:50+00:00 2026-05-25T01:24:50+00:00

What is the difference between NULL and character(0) | integer(0) etc? > identical(NULL, character(0))

  • 0

What is the difference between NULL and character(0) | integer(0) etc?

> identical(NULL, character(0))
[1] FALSE

> is.null(integer(0))
[1] FALSE

> str(character(0))
 chr(0) 

> str(NULL)
 NULL

In general it seems you can pass NULL as parameters into functions, and that an empty vector is generally returned as character(0), integer(0), etc.

Why is this the case? Come to think of it, is there a test for zero-ness, a la is.integer0?

  • 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-25T01:24:50+00:00Added an answer on May 25, 2026 at 1:24 am

    The R Language Definition has this on NULL:

    There is a special object called NULL. It is used whenever there is a need to indicate or
    specify that an object is absent. It should not be confused with a vector or list of zero
    length. The NULL object has no type and no modifiable properties. There is only one NULL
    object in R, to which all instances refer. To test for NULL use is.null. You cannot set
    attributes on NULL.

    So by definition NULL is very different to zero length vectors. A zero length vector very much isn’t absent. NULL is really a catch-all for something that is absent or not set, but not missing-ness, which is the job of NA. There is an exception, the zero-length pairlist, as mentioned by @Owen. The Language Definition states:

    A zero-length pairlist is NULL, as would be expected in Lisp but in contrast to a zero-length list.

    which highlights the exception in this case.

    To test for a zero-length vector use something like if(length(foo) == 0L) for example. And combine that with a class check (is.character(foo)) if you want a specific type of zero length vector.

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

Sidebar

Related Questions

I am told that good developers can spot/utilize the difference between Null and False
Is there a difference between NULL and null in PHP? Sometimes they seem to
Whats the difference between a Null pointer & a Void pointer ?
Is there any difference between null and System.DBNull.Value? If yes, what is it? I
I have a very simple question - Difference between NULL and empty matrices in
What is the difference between null and undefined in JavaScript?
Is there a big performance difference between varcharColumn IS NOT NULL and tinyint =
What's the difference between the following two? Background={x:Null} and Background=Transparent
Can anyone please explain what's the difference between the two kinds of getView() implementation?
What is the difference between using (char)0 and '\0' to denote the terminating null

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.