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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:22:56+00:00 2026-05-22T16:22:56+00:00

I was wondering if there is a technical difference between the assignment operators =

  • 0

I was wondering if there is a technical difference between the assignment operators "=" and "<-" in R. So, does it make any difference if I use:

Example 1: a = 1 or a <- 1

Example 2: a = c(1:20) or a <- c(1:20)

Thanks for your help

Sven

  • 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-22T16:22:57+00:00Added an answer on May 22, 2026 at 4:22 pm

    Yes there is. This is what the help page of '=' says:

    The operators <- and = assign into the
    environment in which they are
    evaluated. The operator <- can be used
    anywhere, whereas the operator = is
    only allowed at the top level (e.g.,
    in the complete expression typed at
    the command prompt) or as one of the
    subexpressions in a braced list of
    expressions.

    With “can be used” the help file means assigning an object here. In a function call you can’t assign an object with = because = means assigning arguments there.

    Basically, if you use <- then you assign a variable that you will be able to use in your current environment. For example, consider:

    matrix(1,nrow=2)
    

    This just makes a 2 row matrix. Now consider:

    matrix(1,nrow<-2)
    

    This also gives you a two row matrix, but now we also have an object called nrow which evaluates to 2! What happened is that in the second use we didn’t assign the argument nrow 2, we assigned an object nrow 2 and send that to the second argument of matrix, which happens to be nrow.

    Edit:

    As for the edited questions. Both are the same. The use of = or <- can cause a lot of discussion as to which one is best. Many style guides advocate <- and I agree with that, but do keep spaces around <- assignments or they can become quite hard to interpret. If you don’t use spaces (you should, except on twitter), I prefer =, and never use ->!

    But really it doesn’t matter what you use as long as you are consistent in your choice. Using = on one line and <- on the next results in very ugly code.

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

Sidebar

Related Questions

Wondering if there is any Text to Speech software available as a plug in
Wondering if there's any not-too-hard way to edit non-form text in html 4. I
Wondering if there is any way to get the lambda expressions that result from
Just wondering if there is any way (in C) to get the contents of
Just wondering if there is any way to get the NS records in C#.
I'm wondering about the difference between what is defined by the several standards of
I've been wondering for long why there doesn't seem to be any parsers for,
Are there any technical Design-by-Contract solutions for Java projects similar to XINS ? I'm
Wondering if there is a good way to generate temporary URLs that expire in
Just wondering if there is an easy way to add the functionality to duplicate

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.