DATA SCIENCE WITH R | AUG 01 - AUG 30 | PRIYANKA (2020)

Discussion in 'Big Data and Analytics' started by Support Simplilearn(4685), Aug 1, 2020.

  1. Support Simplilearn(4685)

    Alumni

    Joined:
    Feb 11, 2010
    Messages:
    154
    Likes Received:
    19
    #1
  2. Anushree BS

    Anushree BS Member

    Joined:
    Nov 27, 2019
    Messages:
    5
    Likes Received:
    2
    Which version of excel we have to use during R programming class
     
    #2
  3. RAMKUMAR P

    RAMKUMAR P Member

    Joined:
    Mar 19, 2020
    Messages:
    4
    Likes Received:
    1
    Hi Priynaka,
    I'm unable to find the class, may i know how to find the class of the below code and mentioned console also for your reference.
    CODE:
    z="Ramkumar"
    class(z)
    z1=789
    z11="45"
    class(z1)


    Console:
    ///// I'am unable to find the class of the above > z1=789
    > z11="45"
    > class(c(z,z1,z11))
    class(z1)
    class(z1)
    class(c)
    class(z1)

    Regards,
    Ramkumar.P
     
    #3
  4. priyanka_217

    priyanka_217 Priyanka Dhoot
    Customer

    Joined:
    Jul 23, 2019
    Messages:
    139
    Likes Received:
    5
    Hi Flynn
     
    #4
  5. Rajesh Bhide(4910)

    Rajesh Bhide(4910) New Member

    Joined:
    Nov 25, 2014
    Messages:
    1
    Likes Received:
    1
    Hello Priyanka ,

    ":" operator is to generate list of number.
    > 2:10
    [1] 2 3 4 5 6 7 8 9 10

    " %in% " operator is used to search first argument in second argument.

    > 1 %in% 2:10
    [1] FALSE
     
    #5
    priyanka_217 likes this.
  6. _34111

    _34111 New Member

    Joined:
    Jul 6, 2018
    Messages:
    1
    Likes Received:
    1
    Day 2: Operator Assignment
    :- to express the entire range of number
    > 1:10
    [1] 1 2 3 4 5 6 7 8 9 10 [Output]
    %in% : To check if the element is there in the array
    t <- c(1,2,3,4,5,6,7,8)
    2 %in% t
    [1] TRUE [Output]
    11%in%t
    [1] FALSE [Output]
     
    #6
    priyanka_217 likes this.
  7. Bhanu Kiran(3284)

    Bhanu Kiran(3284) New Member

    Joined:
    Jan 22, 2013
    Messages:
    1
    Likes Received:
    1
    # Both of the assignments i

    # : Operator by Bhanu
    > V = 2:8
    > print(V)
    [1] 2 3 4 5 6 7 8
    Colon operator. It creates the series of numbers in sequence for a vector.



    # %in% Operator by Bhanu
    > v1 = 8
    > V2 = 12
    > Vx = 1:10
    > print(v1 %in% Vx)
    [1] TRUE
    > print(V2 %in% Vx)
    [1] FALSE
    This operator is used to identify if an element belongs to a vector.
     
    #7
    priyanka_217 likes this.
  8. Abhijeet Dey_4

    Abhijeet Dey_4 New Member

    Joined:
    Jun 28, 2020
    Messages:
    1
    Likes Received:
    1
    #Assignment 2nd August

    %in% is used to check whether that element is present in that set or not. If yes will be TRUE or else will get False.
     
    #8
    Last edited: Aug 2, 2020
    priyanka_217 likes this.
  9. Samay Honnangi

    Joined:
    Jul 25, 2020
    Messages:
    2
    Likes Received:
    1
    ASSIGNMENT

    1) Colon operator : - used to create series of number in sequence
    Example: h = 1:10
    print(h)
    [1] 1 2 3 4 5 6 7 8 9 10 #OUTPUT

    2) % in % operator: used to identify if any element is present in that group
    Example: A = 6
    B = 1:10
    print(A %in% B)
    [1] TRUE #Number 6 is present in 1 to 10 series
     
    #9
    priyanka_217 likes this.
  10. Sri Kumar Jami

    Sri Kumar Jami New Member

    Joined:
    Jul 28, 2020
    Messages:
    1
    Likes Received:
    1
    Script:
    # Assigning range of values to a variable (Array)
    x= 1:10
    print(x)
    y= 5
    # Operator %in% is used to check if a value is a part of a list of values (Array) and returns boolean results
    z = y%in%x
    print(z)


    Output:
    > x= 1:10
    > print(x)
    [1] 1 2 3 4 5 6 7 8 9 10
    > y= 5
    > z = y%in%x
    > print(z)
    [1] TRUE
    >
     
    #10
    priyanka_217 likes this.
  11. Pooja Choudhary_1

    Joined:
    Jul 13, 2020
    Messages:
    2
    Likes Received:
    1
    Assignment 02 Aug, 2020.
    #This colon ":" Operator is used to make a list from the first number to second.
    #For example x:y, if x is 1 and y is 50, the output will be a list of numbers from 1 to 50
    x=1
    y=50
    Colon_Operator = x:y
    Colon_Operator
    #%in% Operator is used to find whether a value belongs to a vector or list of values
    #For example, if m is 5, n is 15, and vector is a list of numbers
    m = 5
    n = 15
    vector <- c(1,2,3,4,5,6,7,8,9,10,11,12)
    #Now if I pass the command, It gives TRUE
    m %in% vector
    #But FALSE if I gave the command
    n %in% vector
     
    #11
    priyanka_217 likes this.
  12. Nikhil Garg_4

    Nikhil Garg_4 New Member

    Joined:
    Jul 30, 2020
    Messages:
    1
    Likes Received:
    2
    #Assignment 1 - use of ":"

    a=1
    b=4
    c=10

    a:c

    [1] 1 2 3 4 5 6 7 8 9 10
    Hence ":" shows the all values that fall in between.

    #Assignment 2 - use of "%in%"
    x=11
    y=4
    z=c(1,2,3,4,5,6,7,8,9,10)

    > x %in% z
    [1] FALSE
    > y %in% z
    [1] TRUE

    Hence "%in%" lookups for value in other data.
     
    #12
  13. RAHUL GAUTAM KEDAR

    RAHUL GAUTAM KEDAR New Member

    Joined:
    Jun 27, 2020
    Messages:
    1
    Likes Received:
    0
    nobody show me in forum community
     
    #13
  14. Supriya Basa

    Supriya Basa New Member

    Joined:
    Jul 15, 2020
    Messages:
    1
    Likes Received:
    0
    Hi Priyanka,

    Please find the Assignment.

    Thank you.
     

    Attached Files:

    #14
  15. PADMANABHA RAO PAIDI

    Joined:
    Jun 30, 2020
    Messages:
    4
    Likes Received:
    2
    Hi Priyanka,

    Thank you for today's session. Following is today's session's assignment

    : Colon Operator -
    It creates the series of numbers in sequence for a vector.

    v = 1:10
    class(v)
    print(v)

    It produces the following results -

    > v = 1:10
    > class(v)
    [1] "integer"
    > print(v)
    [1] 1 2 3 4 5 6 7 8 9 10



    %in% Operator -

    It is used to identify if an element belongs to a vector.

    v1 = 8
    v2 = 12
    t = 1:10
    print(v1 %in% t)
    print(v2 %in% t)

    It produces the following results -

    > v1 = 8
    > v2 = 12
    > t = 1:10
    > print(v1 %in% t)
    [1] TRUE
    > print(v2 %in% t)
    [1] FALSE
     
    #15
    priyanka_217 likes this.
  16. Ritika Sinha

    Ritika Sinha Member

    Joined:
    Jul 29, 2020
    Messages:
    2
    Likes Received:
    1
    > # Operator Assignment
    > # :
    > # creates no. of series in sequence
    > x=3:8
    > print(x)
    [1] 3 4 5 6 7 8
    >
    > # %in%
    > # used to check whether the no. is present on list or not
    > a=4
    > b=12
    > t=2:9
    > print(a%in%t)
    [1] TRUE
    > print(b%in%t)
    [1] FALSE
     
    #16
    priyanka_217 likes this.
  17. Kumar Warthak

    Kumar Warthak New Member

    Joined:
    Jul 28, 2020
    Messages:
    1
    Likes Received:
    1
    Hi Priyanka,

    Please find details about today's assignment:

    Assignment: (: and %in%)

    : - It creates the series of numbers in sequence for a vector.
    v <-2:8
    print(v)
    Output:
    [1] 2 3 4 5 6 7 8

    %in% - This operator is used to identify if an element belongs to a vector.

    v1 <-8
    v2 <-12
    t <-1:10
    print(v1 %in% t)
    print(v2 %in% t)

    Output:

    [1] TRUE
    [1] FALSE
     
    #17
    priyanka_217 likes this.
  18. Harsaranjeet Kaur

    Joined:
    Jul 28, 2020
    Messages:
    2
    Likes Received:
    1
    #%n% is used to identify if an element is present in given data
    a = 100
    b = c(1,2,3,4,5,100,101)
    print(a %in% b)

    str = c("hello","world")
    "world" %in% str

    # : is used to specify range
    print(1:10)
    print(10:1)
     
    #18
    priyanka_217 likes this.
  19. Anushree BS

    Anushree BS Member

    Joined:
    Nov 27, 2019
    Messages:
    5
    Likes Received:
    2
    Assignment
    1) : operator generate sequences from starting value of a sequence to maximal end of a sequence for example 1:4 which indicates {1] 1 2 3 4
    When i run the command which is P=1:4 in global environment it shows P=int [1:4] 1 2 3 4

    2) %in%
    when i run this operator in R it gives the result as FALSE
    P=C%in%B
    so in global environment it shows P=FALSE
     
    #19
    Last edited: Aug 2, 2020
  20. SHASHWAT GAUTAM

    SHASHWAT GAUTAM New Member

    Joined:
    Jul 25, 2020
    Messages:
    1
    Likes Received:
    1
    # :Function (to create a series of numbers in sequence)
    > A= 5:12
    > print(A)
    [1] 5 6 7 8 9 10 11 12


    >
    > #%in% Function (to identify if an element belongs to a list/series and return boolean value)
    >
    > B= 7
    > c= 18
    > print(B%in%A)
    [1] TRUE
    > print(C%in%A)
    [1] FALSE
     
    #20
    priyanka_217 likes this.
  21. RAMKUMAR P

    RAMKUMAR P Member

    Joined:
    Mar 19, 2020
    Messages:
    4
    Likes Received:
    1
    Hi Priyanka,

    Here we go Assignment on 2'Aug'20 (Session) - operator

    1. :)) Colon - Operator - its performance the sequence in the integer data type
    @Script Part:-

    Z=1:5
    Z
    class(Z)

    @console Part:-
    > Z=1:5
    > Z
    [1] 1 2 3 4 5
    > class(Z)
    [1] "integer"


    2. %in% - It's using to identifiers the logical operator in the difference data type(and it produce the result True/False)
    @Script Part:-

    Z=4
    Y=c(1,2,7,4)
    Z %in% Y
    class(Z %in% Y)

    @console Part:-
    > Z=4
    > Y=c(1,2,7,4)
    > Z %in% Y
    [1] TRUE
    > class(Z)
    [1] "numeric"
    > class(Z %in% Y)
    [1] "logical"
     
    #21
    priyanka_217 likes this.
  22. Ashritha M G

    Ashritha M G New Member

    Joined:
    Jul 16, 2020
    Messages:
    1
    Likes Received:
    1
    # : is used to generate sequence of numbers
    1:10
    a=1:10
    # %in% is used to find whether the specified number in sequence
    b=5
    c=55
    b%in%a
    c%in%a

    console
    > 1:10
    [1] 1 2 3 4 5 6 7 8 9 10> a=1:10> > # %in% is used to find whether the apecified number in sequence> b=5> c=55> b%in%a[1] TRUE> c%in%a[1] FALSE
     
    #22
    priyanka_217 likes this.
  23. Goutham Raj TD

    Joined:
    Mar 6, 2020
    Messages:
    2
    Likes Received:
    1
    ##### ASSIGNMENT : explore Additional Operators###
    Code
    a <- 3:10
    print(a)
    #%in%
    b=7
    c=11
    print(b %in% a)
    print(c %in% a)

    Output
    > a <- 3:10
    > print(a)
    [1] 3 4 5 6 7 8 9 10
    > b=7
    > c=11
    > print(b %in% a)
    [1] TRUE
    > print(c %in% a)
    [1] FALSE

    Explanation
    : to create a sequential array of numbers between the specified range
    %in% to check if the first number is a part of the array mentioned in the second variable
     
    #23
    priyanka_217 likes this.
  24. Sreelakshmi S Menon

    Sreelakshmi S Menon New Member

    Joined:
    Jul 29, 2020
    Messages:
    1
    Likes Received:
    1
    Assignment week 1
     

    Attached Files:

    #24
    priyanka_217 likes this.
  25. Rashmi Korane

    Rashmi Korane New Member

    Joined:
    Jul 29, 2020
    Messages:
    1
    Likes Received:
    1
    # ********* Additional operators in R ********
    : , %in% these are the miscellaneous operators in R.
    # colon :
    # prints the series of numbers between range provided
    g= 2:6
    print(g)
    2 3 4 5 6

    # %in% operator
    # it is used to identify if an element belongs to a given set(.array). if the elements is present the set than it return TRUE else it gives output as FALSE
    r=10
    s= 19
    y=c(10,11,12,13,14,15,16)
    r %in% y
    TRUE
    s %in% y
    FALSE
     
    #25
    priyanka_217 likes this.
  26. SURAJ KUMAR PATTANAYAK

    Joined:
    Jul 16, 2020
    Messages:
    1
    Likes Received:
    1
    ##### ASSIGNMENT : explore Additional Operators###

    1) Code

    a <- 3:10
    print(a)

    Output
    > a <- 3:10
    > print(a)

    [1] 3 4 5 6 7 8 9 10

    explanation- :) is used to generate sequence of numbers)



    2) Code

    a <- 3:10
    print(a)

    b=7
    c=11
    print(b %in% a)
    print(c %in% a)

    Output
    > b=7
    > c=11
    > print(b %in% a)
    [1] TRUE
    > print(c %in% a)
    [1] FALSE

    explanation-(to identify if an element belongs to a list/series and return boolean value)
     
    #26
    priyanka_217 likes this.
  27. KumarDeepak548

    KumarDeepak548 New Member
    Simplilearn Support

    Joined:
    Aug 2, 2020
    Messages:
    1
    Likes Received:
    1
    : range of values

    > A=c(1:10)
    > A
    [1] 1 2 3 4 5 6 7 8 9 10

    %in% is used to check if a value is a part of a list (Array)

    > 10%in%A
    [1] TRUE
    > 0%in%A
    [1] FALSE
     
    #27
    priyanka_217 likes this.
  28. sneha charkha

    sneha charkha Member

    Joined:
    Jul 18, 2020
    Messages:
    3
    Likes Received:
    1
    Hello,
    Please find attached file for 2nd August assignment

    Regards,
    Sneha
     

    Attached Files:

    #28
    Last edited: Aug 4, 2020
    priyanka_217 likes this.
  29. MANOJ KUMAR GOVINDAN

    Joined:
    Jul 25, 2020
    Messages:
    3
    Likes Received:
    1
    [1] FALSE
    > z="Ramkumar"
    > class(z)
    [1] "character"
    > z1=789
    > z11="45"
    > class(z1)
    [1] "numeric"



    I get the below result. It should work. where are you using?

    [1] FALSE
    > z="Ramkumar"
    > class(z)
    [1] "character"
    > z1=789
    > z11="45"
    > class(z1)
    [1] "numeric"
     
    #29
  30. MANOJ KUMAR GOVINDAN

    Joined:
    Jul 25, 2020
    Messages:
    3
    Likes Received:
    1

    Goood one Deepak. keep going..
     
    #30
  31. ashishgaurkhede

    ashishgaurkhede New Member
    Alumni

    Joined:
    Aug 3, 2020
    Messages:
    1
    Likes Received:
    1
    02/08/2020 - Assignment on operators

    1. ":" is used to iterate the values between a range.

    > a=1
    > b=10
    > a:b
    [1] 1 2 3 4 5 6 7 8 9 10

    2. "%in%" is used to check if a value is present between a range.

    > x=1
    > y=10
    > z=3
    > z %in% x:y
    [1] TRUE
     
    #31
    priyanka_217 likes this.
  32. trupti tijare

    trupti tijare Member

    Joined:
    Jun 3, 2020
    Messages:
    2
    Likes Received:
    1
    2/08/2020 assignment on operator
    1. %in% operator is used to identify if an element belongs to the vector or not
    > a=5
    > b=101
    > t=c(1,2,3,4,5,6,7,8)
    > a %in% t
    [1] TRUE
    > b %in% t
    [1] FALSE

    2.: operator is used to find range
    > n=5:8
    > print(n)
    [1] 5 6 7 8
     
    #32
    priyanka_217 likes this.
  33. Parag Kishor Chavan

    Joined:
    Jul 22, 2020
    Messages:
    2
    Likes Received:
    1
    Hi Priyanka,

    ## Assignment 1 ##

    ":" operator is used to print a range of specified numbers

    A <- 4:9
    A
    [1] 4 5 6 7 8 9 => OUTPUT

    "%in%" operator is used to check if the given element belongs to a Vector as per which it gives the Output as TRUE (if exists) else FALSE

    6 %in% A
    [1] TRUE

    10 %in% A
    [1] FALSE
     
    #33
    priyanka_217 likes this.
  34. SOWMYA NAGAMPALLI

    Joined:
    Jul 18, 2020
    Messages:
    3
    Likes Received:
    1
    1:10 %in% c(1,3,5,9)
    [1] TRUE FALSE TRUE FALSE TRUE FALSE FALSE FALSE TRUE FALSE
    > A=c(1:10)
    > A
    [1] 1 2 3 4 5 6 7 8 9 10

    %in% is used to check if a value is a part of a list (Array)
    > 10%in%A
    [1] TRUE
    > 0%in%A
    [1] FALSE
     
    #34
    priyanka_217 likes this.
  35. Mukund Ramasubramanian

    Mukund Ramasubramanian Active Member
    Alumni

    Joined:
    May 11, 2020
    Messages:
    16
    Likes Received:
    3
    Assignments - 2nd August 2020

    :
    #It enables assigning a series of elements in continuity to the variable.
    c=2:8
    c
    print(c)

    Output:
    c
    [1] 2 3 4 5 6 7 8


    %in%
    #
    %in% is like an intersection operation used in sets. If we have two variables and we need to check the presence of the value of one of the declared variables in another variable, we can make use of the %in% operator.
    For instance, we have two variables namely A and B, wherein A contains values "2,3,4,5,6,7, and 8" B contains the value 6
    When we use the operator as,A%in%B, the output will be FALSE FALSE FALSE FALSE TRUE FALSE FALSE as one of the values stored in A is present in B.

    A=2:8
    B=6
    A%in%B

    Output:
    A%in%B
    [1] FALSE FALSE FALSE FALSE TRUE FALSE FALSE
     
    #35
    priyanka_217 likes this.
  36. SUKHENDU BISWAL

    SUKHENDU BISWAL New Member

    Joined:
    Jul 27, 2020
    Messages:
    1
    Likes Received:
    0
    ASSIGNMENT-1
    A=5
    B=7
    A:B

    print(A:B)
    [1] 5 6 7 OUTPUT

    ANS-This operator is showing the sequence of numbers.


    ASSIGNMENT-2
    A=5
    B=1:5
    A%in%B
    [1] TRUE output

    Again

    A=5
    B=1:4
    A%in%B

    [1] FALSE output

    Ans- This operator is used to identify the presence of value of one variable within another variable or within the given set.
     
    #36
  37. Gaurav sharma_57

    Gaurav sharma_57 New Member

    Joined:
    Apr 30, 2020
    Messages:
    1
    Likes Received:
    0
    Hi Priyanka

    USE OF : COLON Operator IN R
    this is use for sequence like if we want to get a numbers from 1 to 10 than we can use it
    1:10=(1 2 3 4 5 6 7 8 9 10)
    use of %in%
    it is use to identify if an element belongs to a vector or not
    like v1=1,2,3,4,5 and v2=5
    so v2 %in% v1 then the answer will be True
     
    #37
  38. MANOJ KUMAR GOVINDAN

    Joined:
    Jul 25, 2020
    Messages:
    3
    Likes Received:
    1
    Assignment 1:

    What: Significance of :
    Why: Specify the sequence that includes the indices "from" to "to"
    When: To create index or work with range of values.


    > c(1:10)
    [1] 1 2 3 4 5 6 7 8 9 10


    > a = c(1:10)
    >
    > 10%in%a
    [1] TRUE

    > a%in%10
    [1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE TRUE


    > a%in%1:10
    [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE

    > 20:30%in%15:24
    [1] TRUE TRUE TRUE TRUE TRUE FALSE FALSE FALSE FALSE FALSE FALSE



    > phrase <- c('I','Know','myself')
    > phrase[1:2]
    [1] "I" "Know"
    > phrase[1:3]
    [1] "I" "Know" "myself"
     
    #38
    priyanka_217 likes this.
  39. Atul Patel_4

    Atul Patel_4 New Member

    Joined:
    Jul 27, 2020
    Messages:
    1
    Likes Received:
    0
    2nd August 2020- assignment on operator %in%
    1. %in% is value matching. This operator is used to identify if an element belongs to the vector or not.
    In the code x %in% y, the first element of x is compared to all elements in y, then the second element of x is compared to all elements of y, and so on. Here, compare means "is the current element of x equal to any value in y" and therefore the output is a logical vector that has the same length of x and not (necessarily) y.

    # R %in% operator

    v1 <- 3

    v2 <- 101

    t <- c(1,2,3,4,5,6,7,8)

    v1 %in% t

    In the above example v1 is present in t, so the output will be [1] TRUE

    # R %in% operator


    v2 %in% t

    v2 is not present in t, so the output will be [1] FALSE



    2.":" operator is used to find range that specifies starting point or lower bound and upper bound or last value
    > A= 5:14
    > print(A)
    [1] 5 6 7 8 9 10 11 12 13 14
     
    #39
  40. Guru Charan Tontanahal

    Joined:
    Jul 21, 2020
    Messages:
    1
    Likes Received:
    0
    # Assignment 1 :

    Priyanka Madam,

    Thank you for the class,

    ' : ' Colon operator is used to generate a range of values. These values start from value specified on the left side of the colon and ends with the value specified on the right side of the colon. By default range of values are generated in the increments of 1.

    '%in%' is a key statement used to verify and print the value(s) specified on the left hand side of the %n% key statement is/are present in the values specified on the right side.

    > 1:20
    [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
    > a = 1:20
    > print(a)
    [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
    > b = 10:30
    > print(b)
    [1] 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
    > a %in% b
    [1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
    [17] TRUE TRUE TRUE TRUE
     
    #40
  41. Nivas Jagtap

    Nivas Jagtap New Member

    Joined:
    Jul 1, 2020
    Messages:
    1
    Likes Received:
    0
    > #Assignment # 1
    >
    > # ":" is an arithmetic operator in R used to define range of numeric values
    >
    > # "%in%" is the logical operator used to identify logical results of the presence of value
    > # within the defined range of values
    >
    >
    > #Example #1
    > #Allowed age group range within the university
    > x=18:22
    > print("Allowed age group for university admission")
    [1] "Allowed age group for university admission"
    > print(x)
    [1] 18 19 20 21 22
    >
    >
    > #candidate A with age 16
    > A=16
    > y=A%in%x
    >
    > print("your age is")
    [1] "your age is"
    > print(A)
    [1] 16
    > print(y)
    [1] FALSE
    > print("You are not ligible for admission in university")
    [1] "You are not ligible for admission in university"
    >
    > #candidate B with age 20
    > B=20
    > z=B%in%x
    >
    > print("your age")
    [1] "your age"
    > print(B)
    [1] 20
    > print(z)
    [1] TRUE
    > print("You are eligible for admission in university")
    [1] "You are eligible for admission in university"
    >
    > #-------------------------------------------------------------------------
    > # example 2
    >
    > #type of car brands available in ABC showroom
    > a=c("AUDI","FORD","TATA","GMC", "JEEP")
    >
    > print(a)
    [1] "AUDI" "FORD" "TATA" "GMC" "JEEP"
    > #is "AUDI" car brand available in ABC showroom
    > "AUDI"%in%a
    [1] TRUE
    > #is "TOYATO" car brand available in ABC showroom
    > "TOYATO"%in%a
    [1] FALSE
    > #--------------------------- End of assignment #1 -
     
    #41
  42. Lavkush Singh_1

    Lavkush Singh_1 New Member

    Joined:
    Dec 21, 2019
    Messages:
    1
    Likes Received:
    0
    Assignment 1

    : (Colon) operator
    Colon is a binary operator in R, which is used to create sequences, in steps of 1, increasing or decreasing.
    The sequence includes the starting and the ending number
    Can also be used with negative numbers

    > 1:6
    [1] 1 2 3 4 5 6

    > -1:-5
    [1] -1 -2 -3 -4 -5

    > 4:-6
    [1] 4 3 2 1 0 -1 -2 -3 -4 -5 -6

    > -2:3
    [1] -2 -1 0 1 2 3

    -----------------------------------------------------

    %in% operator in R
    %in% operator, also a binary operator, checks if one entity is contained in another.
    returns boolean

    > 5 %in% 1:6 # 5 is present in sequence 1,2,3,4,5,6
    [1] TRUE

    > c(2,3) %in% 1:5 # 2,3 is present in sequence 1,2,3,4,5, vector of boolean is retured for each element we asked for
    [1] TRUE TRUE

    > c("a", "c") %in% c("a", "z", "b", "y") # can also be used with vectors
    [1] TRUE FALSE

    > 5:10 %in% 1:20 # this %in% operator can also be used to check if a small sequence is contained in a bigger sequence
    [1] TRUE TRUE TRUE TRUE TRUE TRUE

    > 1:20 %in% 11:15 # or %in% can also be used to check if some elements of bigger sequence are present in smaller sequence
    [1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE TRUE TRUE TRUE
    [14] TRUE TRUE FALSE FALSE FALSE FALSE FALSE

    #combining with other operators, we may obtain the indices of the contained values.
     
    #42
  43. Jagannath Rajeev Lochan

    Joined:
    Jun 6, 2020
    Messages:
    1
    Likes Received:
    0
    hi priyanka,
    Assignment

    > 2:3
    [1] 2 3
    > B:C
    [1] 7 8
    > D=B:C
    > print(D)
    [1] 7 8
    > 2%in%3
    [1] FALSE
    > B%in%c
    [1] FALSE
    > I=B%in%c
    > print(I)
    [1] FALSE
     
    #43
  44. priyanka_217

    priyanka_217 Priyanka Dhoot
    Customer

    Joined:
    Jul 23, 2019
    Messages:
    139
    Likes Received:
    5
    excel is not required...it was just for introduction of stats
     
    #44
  45. priyanka_217

    priyanka_217 Priyanka Dhoot
    Customer

    Joined:
    Jul 23, 2019
    Messages:
    139
    Likes Received:
    5
    Hi Rajkumar,

    your code looks fine. Have you created the variables first in GE by running the statements?
     
    #45
  46. Jagannath Prasad

    Jagannath Prasad New Member

    Joined:
    Jul 15, 2020
    Messages:
    1
    Likes Received:
    0
    : operator - shows all numbers in sequence (start value to end value)
    %in% operator - checks if the value is present in the array and return true/false

    > a=1:10
    > print(a)
    [1] 1 2 3 4 5 6 7 8 9 10
    > b=10
    > c=15
    > b %in% a
    [1] TRUE
    > c %in% a
    [1] FALSE
     
    #46
  47. Shalini K

    Shalini K Member

    Joined:
    Jun 29, 2020
    Messages:
    4
    Likes Received:
    0
  48. Soma Ghosh Choudhury

    Joined:
    Jul 27, 2020
    Messages:
    1
    Likes Received:
    0
    02 Aug 2020
    Data Science with R
    Assignment
    ":" function
    Colon ":" function in R, express the entire range of a series
    M=2:8
    int [1,7] 2 3 4 5 6 7 8
    >M=2:8
    K=12:16
    int [1,5] 12 13 14 15 16
    >K=12:16
    "%in%" function
    this function checks if the element is in the series or not
    K1=13:15
    K1%in%K
    [1] TRUE TRUE TRUE
    K2=30:35
    K2%in%K
    [1] FALSE FALSE FALSE FALSE FALSE FALSE

    Regards,
    Soma
     
    #48
  49. Jignesh Khamar

    Jignesh Khamar New Member

    Joined:
    Jul 20, 2020
    Messages:
    1
    Likes Received:
    0
    Day 2: Operator Assignment

    : (Colon operator) It creates the series of numbers in sequence for a vector.
    TV = 10:18
    print(TV)
    [1] 10 11 12 13 14 15 16 17 18


    %in% This operator is used to identify if an element belongs to a vector.
    > TV1 = 5
    > TV2 = 15
    > TX = 1:10
    > print(TV1 %in% TX)
    [1] TRUE
    > print(TV2 %in% TX)
    [1] FALSE
     
    #49
  50. Shijin Varghese

    Shijin Varghese New Member

    Joined:
    Jul 22, 2020
    Messages:
    1
    Likes Received:
    0
    Hi Priyanka,

    the colon operator is used to specify the range of numbers which is useful to load into a variable
    c <- -10:10

    and %in% is used to find the presence of one value/variable in another
    c <- -10:10
    print(-10%in%v) will yield a result TRUE indicating presence of -10 in c, whereas print(-20%in%c) will show FALSE denoting value -20 is not present in c.
     
    #50

Share This Page