in Education by
Can someone state the difference between the assignment operators = and <- in R? Is this the only difference in both these operators mentioned in the example below: x <- y <- 6 x = y = 6 x = y <- 6 x <- y = 6 # Error in (x <- y) = 6 : could not find function "<-<-" Select the correct answer from above options

1 Answer

0 votes
by
 
Best answer
The operator <- can be used anywhere whereas the operator = can only be used at top level. It will be more clearer when it’s used to set an argument value in function call. You can also use one of the tidy_* functions in the formatR and it will automatically replace = with <-. Ex. library(formatR) tidy_source(text = "x=1:5", arrow = TRUE) ## x <- 1:5 To fix the error of your syntax use prefix notation for assignment. x <- 6 `<-`(x, 6) #same thing y = 6 `=`(y, 6) #also the same thing parser interprets x <- y <- 6 as `<-`(x, `<-`(y, 6)) Our expectation is that x <- y = 6 would then be `<-`(x, `=`(y, 6)) but actually it will result as `=`(`<-`(x, y), 6) This is happening because = is lower precedence than <- Hope this helps.

Related questions

0 votes
    According to the R language definition, the difference between & and && (correspondingly | and ||) is that the former ... OrElse in R? Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    A categorical variable V1 in a data frame D1 can have values represented by the letters from A to Z. I want to create a ... B','N',T')) Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    I have two integer values a and b, but I need their ratio in floating point. I know that a < b, and I want ... the following? c= a / b Select the correct answer from above options...
asked Jan 26, 2022 in Education by JackTerrance
0 votes
    The four most frequently used types of data objects in R are vectors, matrices, data frames and ________ (a) ... Out of R Programming Select the correct answer from above options...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    The entities that R creates and manipulates are known as ________ (a) objects (b) task (c) container (d) ... Started of R Programming Select the correct answer from above options...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    How missing values and impossible values are represented in R language? (a) NA (b) NAN (c) NA & NAN ... and Debugging of R Programming Select the correct answer from above options...
asked Feb 12, 2022 in Education by JackTerrance
0 votes
    What are the data types in R on which binary operators can be applied? (a) Scalars (b) Matrices (c) ... and Debugging of R Programming Select the correct answer from above options...
asked Feb 16, 2022 in Education by JackTerrance
0 votes
    R objects can have attributes, which are like ________ for the object. (a) metadata (b) features (c) ... Out of R Programming Select the correct answer from above options...
asked Feb 15, 2022 in Education by JackTerrance
0 votes
    Factors are the r-objects which are created using a _________ (a) Vector (b) Matrix (c) Lists (d) Array ... and Out of R Programming Select the correct answer from above options...
asked Feb 15, 2022 in Education by JackTerrance
0 votes
    Which of the following can be used to display the names of (most of) the objects which are currently stored ... of R Programming Select the correct answer from above options...
asked Feb 15, 2022 in Education by JackTerrance
0 votes
    Decimal values are referred as ________ data types in R. (a) Numeric (b) Character (c) Integer (d) Lists ... and Out of R Programming Select the correct answer from above options...
asked Feb 15, 2022 in Education by JackTerrance
0 votes
    If commands are stored in an external file, say commands.R in the working directory work, they may be executed ... of R Programming Select the correct answer from above options...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    Numbers in R are generally treated as _______ precision real numbers. (a) single (b) double (c) real (d) ... and Out of R Programming Select the correct answer from above options...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    What are the different types of sorting algorithms available in R language? (a) Bubble (b) Selection (c) ... of R Programming Select the correct answer from above options...
asked Feb 13, 2022 in Education by JackTerrance
...