DS WITH R | Priyanka

Discussion in 'Big Data and Analytics' started by Kunal Guwalani, Jul 28, 2019.

  1. Kunal Guwalani

    Kunal Guwalani Well-Known Member
    Simplilearn Support

    Joined:
    Jul 17, 2018
    Messages:
    168
    Likes Received:
    14
    Hi All,

    Use this thread for Data Science With R queries.
     
    #1
  2. priyanka_217

    priyanka_217 Priyanka Dhoot
    Customer

    Joined:
    Jul 23, 2019
    Messages:
    19
    Likes Received:
    1
    Hi All.. I have uploaded code used in our last session on the google drive
     
    #2
  3. Vikas Kanodia_1

    Joined:
    May 23, 2019
    Messages:
    12
    Likes Received:
    0
    how to use multiple commands with the SWITCH statement when condition is true
     
    #3
  4. Vikas Kanodia_1

    Joined:
    May 23, 2019
    Messages:
    12
    Likes Received:
    0
    how the values are passing in x variable when you have created custom function average
     
    #4
  5. Vino Pandey

    Vino Pandey New Member

    Joined:
    Jul 6, 2019
    Messages:
    1
    Likes Received:
    0
    vector1=c(4,2,1)
    vector2 =c(2,45,65,78,9,10)
    column.name=c("col1", "col2","col3")
    row.name=c("row1", 'row2', "row3")
    matrix.name=c("matrix1", "matrix2","matrix3")
    result =array(c(vector1,vector2)dim=c(4,4,3), dimnames=list(row.name, column.name, matrix.name))

    what I am doing wrong in above code as I am getting below error
    unexpected symbol in "result =array(c(vector1,vector2)dim"
     
    #5
  6. priyanka_217

    priyanka_217 Priyanka Dhoot
    Customer

    Joined:
    Jul 23, 2019
    Messages:
    19
    Likes Received:
    1
    Name="Amit"
    switch(Name,Priyanka={print("My Name")},Amit={print("Student1")},Vikas={print("Student2")},
    Other={print("Other")})
    Try the above code, n in the variable created name change the values and re-run the code
     
    #6
  7. _7182

    _7182 Member

    Joined:
    May 9, 2017
    Messages:
    3
    Likes Received:
    1
    Hi Priyanka,
    Following command is giving error. Can you hep for the same.
    age<-18
    switch(age,18={print("Minor")},Other={print("Major")})
     
    #7
  8. Dipesh Sharma

    Dipesh Sharma Member

    Joined:
    Jul 25, 2019
    Messages:
    2
    Likes Received:
    1
    if we change this to

    age="18"
    switch(age,"18"={print("Minor")},Other={print("Major")})

    then it works
     
    #8
  9. Abir A Khan

    Abir A Khan New Member

    Joined:
    Jun 29, 2019
    Messages:
    1
    Likes Received:
    0
    Hi, Priyanka,
    I have been through the self learning videos but the Hypothesis & Regression part is difficult to understand so its a request during live session go from scratch no all that topics.. up till now i have understood everthing, I mean previous 3 sessions
     
    #9
  10. priyanka_217

    priyanka_217 Priyanka Dhoot
    Customer

    Joined:
    Jul 23, 2019
    Messages:
    19
    Likes Received:
    1
    HI Abir,

    Dont worry. Will be covering from scratch about the topics mentioned and there terminologies
     
    #10
  11. priyanka_217

    priyanka_217 Priyanka Dhoot
    Customer

    Joined:
    Jul 23, 2019
    Messages:
    19
    Likes Received:
    1
    Hi Dipesh,
    Below is the list of data types that are allowed in SWITCH command. As per which, number values assigned to variable AGE in ur command is not allowed. Use some string or logical parameter instead.

    Allowed data types for switch parameter value
    You can’t use the switch statement to compare all types of values, such as all types of objects and primitives.
    There are limitations on the types of arguments that a switch statement can accept.
    A switch statement accepts arguments of type char, byte, short, int, and String(starting from Java version 7).
    It also accepts arguments and expressions of types enum, Character, Byte, Integer, and Short, but because these aren’t on the OCAJP exam objectives, We won’t cover them in these article.
    The switch statement doesn’t accept arguments of type long, float, double,boolean or any object besides String.
     
    #11
  12. priyanka_217

    priyanka_217 Priyanka Dhoot
    Customer

    Joined:
    Jul 23, 2019
    Messages:
    19
    Likes Received:
    1

    Hi Vinod,
    the number of columns and rows mantioned by you is 4, whereas u have given only 3 names. Hence the error. Please compare your code to the below code:
    vector1=c(4,2,1)
    vector2 =c(2,45,65,78,9,10)
    column.name=c("col1", "col2","col3","col4")
    row.name=c("row1", 'row2', "row3","row4")
    matrix.name=c("matrix1", "matrix2","matrix3")
    result =array(c(vector1,vector2),dim=c(4,4,3), dimnames=list(row.name, column.name, matrix.name))
    result
     
    #12
  13. priyanka_217

    priyanka_217 Priyanka Dhoot
    Customer

    Joined:
    Jul 23, 2019
    Messages:
    19
    Likes Received:
    1
    can you please share the code you are talking about
     
    #13
  14. Snigdha sagarika ray

    Joined:
    Jul 18, 2019
    Messages:
    5
    Likes Received:
    0
    Hi priyanka,
    A<-c(10,20,4,30,50,60)
    summary(A)
    o/p-
    min 1stqu. median mean 3rdQu. Max
    4 12.5 25.0 29.0 45.0 60.0
    Here the 1stQu is calculate as the 25% of the element present in the vtr. So here the 25% is 1.5 . where did you get the 1stQu. value i.e 12.5 , medain 25 and the 3rd qu. 45
     
    #14
  15. Vikas Kanodia_1

    Joined:
    May 23, 2019
    Messages:
    12
    Likes Received:
    0
    age=10
    switch(age , 1={print("worng")} , 10={print("Correct")})

    getting errror
    Error: unexpected '=' in "switch(age , 1="

    Please help
     
    #15
  16. Shohini_1

    Shohini_1 Well-Known Member
    Simplilearn Support

    Joined:
    Sep 24, 2018
    Messages:
    84
    Likes Received:
    4
    Hi Learner,

    Greetings !!
    Thanks for reaching out to us.

    We’ve received your request and we’re working to get back with you as quickly as possible. Your concern requires a closer look and a little more time, so thank you for your patience in the meantime.
     
    #16
  17. Rohan Jarande

    Rohan Jarande New Member

    Joined:
    Jul 12, 2019
    Messages:
    1
    Likes Received:
    0
    hello maam,
    after downloading the r studio its appearing different then our practice lab .Its downloading the gu version not the R studio.Please help me with the issue.
     
    #17
  18. Mandeep Sharma

    Joined:
    Apr 26, 2019
    Messages:
    5
    Likes Received:
    0
    Please share the word cloud



    Please confirm about this
    Error in plot.new() : figure margins too large
    > plot(pc, type="line")Error in plot.new() : figure margins too large> attributes(pc) code.
     
    #18
    Last edited: Aug 17, 2019
  19. Sumit Kumar Jhamb

    Sumit Kumar Jhamb New Member

    Joined:
    Jun 26, 2019
    Messages:
    1
    Likes Received:
    0
    Hi Priyanka,

    As we know that our live sessions are recorded, can you please put them also on Google drive. Or let me know they are available on the portal.
     
    #19
  20. priyanka_217

    priyanka_217 Priyanka Dhoot
    Customer

    Joined:
    Jul 23, 2019
    Messages:
    19
    Likes Received:
    1
    please check now
     
    #20
  21. priyanka_217

    priyanka_217 Priyanka Dhoot
    Customer

    Joined:
    Jul 23, 2019
    Messages:
    19
    Likes Received:
    1
    #21
  22. priyanka_217

    priyanka_217 Priyanka Dhoot
    Customer

    Joined:
    Jul 23, 2019
    Messages:
    19
    Likes Received:
    1
    Hi Vikas,
    Below is the list of data types that are allowed in SWITCH command. As per which, number values assigned to variable AGE in ur command is not allowed. Use some string or logical parameter instead.

    Allowed data types for switch parameter value
    You can’t use the switch statement to compare all types of values, such as all types of objects and primitives.
    There are limitations on the types of arguments that a switch statement can accept.
    A switch statement accepts arguments of type char, byte, short, int, and String(starting from Java version 7).
    It also accepts arguments and expressions of types enum, Character, Byte, Integer, and Short, but because these aren’t on the OCAJP exam objectives, We won’t cover them in these article.
    The switch statement doesn’t accept arguments of type long, float, double,boolean or any object besides String.
     
    #22
  23. priyanka_217

    priyanka_217 Priyanka Dhoot
    Customer

    Joined:
    Jul 23, 2019
    Messages:
    19
    Likes Received:
    1
    have shared it on google drive
     
    #23
  24. Sanjib Ganguly

    Joined:
    Jun 19, 2019
    Messages:
    8
    Likes Received:
    0
    Hi
    The last R class was taken by Sonal Ghansani on Statistics where she had mentioned to provide the files in the drive . But I do not see the Files and the slides and the Code Files the shared Google Drive can you pelase help me in this regard
     
    #24
  25. Sanjib Ganguly

    Joined:
    Jun 19, 2019
    Messages:
    8
    Likes Received:
    0
    I do not see the 11th Session uploaded in the drive . can any one please help
     
    #25
  26. Snigdha sagarika ray

    Joined:
    Jul 18, 2019
    Messages:
    5
    Likes Received:
    0
    Could you please reply to this message?
     
    #26
  27. _7182

    _7182 Member

    Joined:
    May 9, 2017
    Messages:
    3
    Likes Received:
    1
    Hi Priyanka, I have tried to do the assignments. Need some more understanding on converting the question to R code. Request you to review the attached file and revert with your observations.
     

    Attached Files:

    #27
    priyanka_217 likes this.
  28. priyanka_217

    priyanka_217 Priyanka Dhoot
    Customer

    Joined:
    Jul 23, 2019
    Messages:
    19
    Likes Received:
    1
    Hi,

    The formula to calculate Quartile is (in case of even numbers):
    Q1 : (n+1)/4
    Q2: 2(n+1)/4
    Q3: 3(n+1)/4
    This will give you the position of the element that will be the Quartile value.
    For Example the median : so as per the formula the Q2(Median) will be 3.5th position value : that is excatly in between 20 and 30 (as they are middle values) so,its 25.

    Logic of quartiles:
    There’s a slight difference between a quarter and quartile. A quarter is the whole slice of cake which is divided in 4 parts, but a quartile is the mark of the cake cutter makes at the end of the slice.
     
    #28
  29. _7182

    _7182 Member

    Joined:
    May 9, 2017
    Messages:
    3
    Likes Received:
    1
    Hi Priyanka,

    Request you to validate the assignment and provide your feedback on prioirty.
     
    #29
  30. Sanjib Ganguly

    Joined:
    Jun 19, 2019
    Messages:
    8
    Likes Received:
    0
    Hi Priyanka , can you please upload the R files from the last session I am not able to find the same in the drive .
     
    #30
  31. priyanka_217

    priyanka_217 Priyanka Dhoot
    Customer

    Joined:
    Jul 23, 2019
    Messages:
    19
    Likes Received:
    1
    #31
  32. Dipesh Sharma

    Dipesh Sharma Member

    Joined:
    Jul 25, 2019
    Messages:
    2
    Likes Received:
    1
    Hi Priyanka,

    How can we add data labels on bar plot etc?
     
    #32
    priyanka_217 likes this.
  33. Ashish Gohil

    Ashish Gohil New Member

    Joined:
    Jul 23, 2019
    Messages:
    1
    Likes Received:
    1
    Hi Priyanka,
    In Data visualization session, you given assignment to draw India Map.here is the code below, please review

    library(ggmap)
    India <- c(left = 65, bottom = 5, right = 98, top = 36)
    get_stamenmap(India, zoom = 4, maptype = "toner-lite") %>% ggmap()
     
    #33
    priyanka_217 likes this.
  34. Sanjib Ganguly

    Joined:
    Jun 19, 2019
    Messages:
    8
    Likes Received:
    0
    #34
  35. priyanka_217

    priyanka_217 Priyanka Dhoot
    Customer

    Joined:
    Jul 23, 2019
    Messages:
    19
    Likes Received:
    1
    PFA file with comments
     

    Attached Files:

    #35
  36. priyanka_217

    priyanka_217 Priyanka Dhoot
    Customer

    Joined:
    Jul 23, 2019
    Messages:
    19
    Likes Received:
    1
    Hi Dipesh,

    Below is the command:
    barplot(counts,main = "Bar Plot" , xlab = "Disp",
    ylab = "Frequency", names=c("High","Medium","Low") ,
    legend=rownames(counts),col=c("red","yellow","green"))

    You have to use "names" command
     
    #36
  37. priyanka_217

    priyanka_217 Priyanka Dhoot
    Customer

    Joined:
    Jul 23, 2019
    Messages:
    19
    Likes Received:
    1
    Hi Ashish,

    This is great. Keep exploring more.
     
    #37
    Ashish Gohil likes this.
  38. Sanjib Ganguly

    Joined:
    Jun 19, 2019
    Messages:
    8
    Likes Received:
    0
    HI Priyanka
    Shall I upload the Assignment for Web Data which is done or shall we wait for discussing the same in the next class before Uploading .
    I have done in all in one .R file with the outputs in Comments.
     
    #38
  39. priyanka_217

    priyanka_217 Priyanka Dhoot
    Customer

    Joined:
    Jul 23, 2019
    Messages:
    19
    Likes Received:
    1
    Hi Sanjib,

    Please upload the file.
     
    #39
  40. Sanjib Ganguly

    Joined:
    Jun 19, 2019
    Messages:
    8
    Likes Received:
    0
    I have an .R file containing output in the R file itself and
    I have an .R file containing output in the R file itself. In the submit button I am not able to submit the .R file
     
    #40
  41. priyanka_217

    priyanka_217 Priyanka Dhoot
    Customer

    Joined:
    Jul 23, 2019
    Messages:
    19
    Likes Received:
    1
    HI Sanjib,

    Copy the code in a notepad and upload the same.
     
    #41
  42. Sanjib Ganguly

    Joined:
    Jun 19, 2019
    Messages:
    8
    Likes Received:
    0
    For the association code I am not Able to get the Count Coulmn output on running the inspect command on arules object
     
    #42
  43. priyanka_217

    priyanka_217 Priyanka Dhoot
    Customer

    Joined:
    Jul 23, 2019
    Messages:
    19
    Likes Received:
    1
    Hi Sanjib,

    Please try the 2 below methods:
    To print the association rules, we use a function called inspect(). However, if you have package ‘tm’ attached in the session, it creates a conflict with the arules package. Thus, we need to check and detach the package.

    This code is used to deattach the package :
    if(sessionInfo()['basePkgs']=="tm" | sessionInfo()['otherPkgs']=="tm"){
    detach(package:tm, unload=TRUE)
    }

    inspect(basket_rules)

    #Alternative to inspect() is to convert rules to a dataframe and then use View()
    New_groc - is them model values:

    df_basket <- as(new_groc,"data.frame")
    View(df_basket)
     
    #43
  44. Snigdha sagarika ray

    Joined:
    Jul 18, 2019
    Messages:
    5
    Likes Received:
    0
    Hi priyanka,
    In logistic regression how to calculate the Threshold value to predict the probability of y being 0 or 1?
    what is the exact formula to calculate it manually and what is the formula in R programming as well?
    Threshold value= we chose for our model like if y is greater than threshold value then y=1 else y=0
     
    #44
  45. Snigdha sagarika ray

    Joined:
    Jul 18, 2019
    Messages:
    5
    Likes Received:
    0
    I want your help with the project submission. could you please contact me through my email i.e snigdha.ray56@gmail.com. It will be helpful
     
    #45
  46. priyanka_217

    priyanka_217 Priyanka Dhoot
    Customer

    Joined:
    Jul 23, 2019
    Messages:
    19
    Likes Received:
    1
    HI Sanjib,

    Sorry. i am not allowed to contact any student personally over Phone or email.
    Please post your query here
     
    #46
  47. Snigdha sagarika ray

    Joined:
    Jul 18, 2019
    Messages:
    5
    Likes Received:
    0
    Hi priyanka,
    I have not received any reply from regarding my doubts which we talked over the phone.
     
    #47
  48. SAPPA CHANUKYA

    SAPPA CHANUKYA New Member

    Joined:
    Jul 21, 2019
    Messages:
    1
    Likes Received:
    0
    priyanka mam, can u please tell me how to handle dates in r.and how can we filter the data according to year
     
    #48

Share This Page