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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:29:34+00:00 2026-05-27T05:29:34+00:00

This is going to sound like a basic question but… How do I use

  • 0

This is going to sound like a basic question but… How do I use universal constants with R?

I was used to being able to just write e or PI in matlab, and these variables were reserved for the universal constants. Are those available in R as well? How to access/use them?

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-05-27T05:29:35+00:00Added an answer on May 27, 2026 at 5:29 am

    pi (note the lowercase) is defined but e is not, although exp(1) is obviously available.

    pi
    # [1] 3.141593
    

    The small number of built-in constants are described :

    ?Constants
    

    It would be possible to cure this lack-of-e problem with this code:

    e <- exp(1)
    lockBinding("e", globalenv())
    e
    #[1] 2.718282
    e <- 2.5
    #Error: cannot change value of locked binding for 'e'
    

    (Thanks to Hadley for illustrating this in a different SO thread.)
    You probably also should go to:

    ?NumericConstants
    

    Where you will read among other things: “A numeric constant immediately followed by i is regarded as an imaginary complex number.”

    The other important constants are TRUE and FALSE, and while T and F can be used in a clean session, T and F are not reserved and can be assigned other values, which will then provoke difficult to debug errors, so their use is deprecated. (Although, I suppose one could also use the lockBinding strategy on them as well.)

    There are a few character “constants”, such as the 26 item character vectors: letters, LETTERS, as well as 12 months in your locale: month.abb and month.name. The Greek letters (lower and uppercase) and some math notation can be accessed via methods described in ?plotmath.

    The state.name and state.abb mentioned by Tyler below are actually part of the (USA) state dataset in the “datasets” package which is loaded by default:

    library(help="datasets")
    

    If you see an example that uses the cars, chickwts, iris or any of the other dataframes in “datasets”, as many help() examples do, these objects can be assumed to be available on any R user’s machine.

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

Sidebar

Related Questions

This is going to sound like a silly question, but I'm still learning C,
I guess this is going to sound like a pretty basic question to any
This is going to sound like a dumb question, but I was wondering where
Sorry this is going to sound like a ridiculous question but can methods (not
I know I am going to sound very noobish for asking this question BUT
This is going to sound like an odd request, but... I have a web
OK, this is going to sound like a crazy idea - but I'm interested
Well this is going to sound like a lame question, I know. This is
This is going to sound too silly / too basic - sorry about that,
Okay, I'm going to sound like an idiot with this one. Here goes. I've

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.