Data Science Certification Training - R Programming | JAN 11 - FEB 09 | Samridhi

Discussion in 'Big Data and Analytics' started by Shohini_1, Jan 10, 2020.

  1. Shohini_1

    Shohini_1 Well-Known Member
    Simplilearn Support

    Joined:
    Sep 24, 2018
    Messages:
    117
    Likes Received:
    12
    Hi All,

    Use this thread for your doubt clarification.
     
    #1
    Adewale Aderonmu likes this.
  2. Samridhi Dutta

    Samridhi Dutta Well-Known Member
    Trainer

    Joined:
    Aug 16, 2017
    Messages:
    169
    Likes Received:
    20
    #Assignment: print a table of 2: 10 using nested for loops
    "2 X 1 = 2"
    "2 X 2 = 4"
    "2 X 3 = 6"

    "3 X 1 = 3"
    "3 X 2 = 6"
     
    #2
  3. Abdul Rashid

    Abdul Rashid New Member

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

    Attached Files:

    #3
  4. Makarand Kulkarni

    Makarand Kulkarni New Member

    Joined:
    Dec 30, 2019
    Messages:
    1
    Likes Received:
    0
    My assignment attached
     

    Attached Files:

    #4
  5. Kiruba Shankar

    Kiruba Shankar New Member

    Joined:
    Dec 1, 2019
    Messages:
    1
    Likes Received:
    0
    Here you go!!! :)

    for(i in 2:10)
    {
    for(j in 1:10)
    {
    cat( i , " X ", j , " = " , i*j , "\n", sep = "")
    }
    print(" \n")
    }
     
    #5
  6. Nithisha B R

    Nithisha B R New Member

    Joined:
    Jan 1, 2020
    Messages:
    1
    Likes Received:
    0
    for (i in 2:10) {
    for (j in 1:10) {
    cat(i,"X",j, "=", i*j,"\n",sep = "")
    }
    cat("\n\n")
    }
     
    #6
  7. Akshay_15

    Akshay_15 New Member

    Joined:
    Dec 16, 2015
    Messages:
    1
    Likes Received:
    0
    #tables from 2 to 10

    for(i in 2:10){
    cat("\n","Table for ",i,"\n",sep="")
    for(j in 1:10){
    cat(i,"X",j,"=",i*j,"\n", sep=" ")
    }
    }
     
    #7
  8. Kousik Das

    Kousik Das New Member

    Joined:
    Nov 19, 2019
    Messages:
    1
    Likes Received:
    0
    #========================================
    # assign value of num = 2 or any integere number
    num = 2
    # use for loop to iterate 10 times
    for(i in 1:10) {
    print(paste(num,'x', i, '=', num*i))
    }
     
    #8
  9. Abhijit_78

    Abhijit_78 Member

    Joined:
    Nov 9, 2019
    Messages:
    2
    Likes Received:
    0
    for (a in c(2:10))
    {
    for (b in c(1:10))
    {
    print(paste(a, "*", b,"=", a * b))
    }
    }
     
    #9
  10. Shilpa_93

    Shilpa_93 New Member

    Joined:
    Jan 4, 2020
    Messages:
    1
    Likes Received:
    0
    Hi , i need url to download R
     
    #10
  11. Sandip Gujar

    Sandip Gujar New Member

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

    Attached Files:

    #11
  12. Abhijit_78

    Abhijit_78 Member

    Joined:
    Nov 9, 2019
    Messages:
    2
    Likes Received:
    0
    #12
  13. Chinthalapally Manideep

    Joined:
    Jan 3, 2020
    Messages:
    1
    Likes Received:
    0
    pls go through it
     

    Attached Files:

    #13
  14. Aaditya Jittha

    Joined:
    Dec 27, 2019
    Messages:
    4
    Likes Received:
    0
    Hi Samridhi,

    PFA my assigment.

    Thanks,
    Aaditya
     

    Attached Files:

    #14
  15. Aaditya Jittha

    Joined:
    Dec 27, 2019
    Messages:
    4
    Likes Received:
    0
    Hi Samridhi,

    I have a doubt regarding the use-case of "paste" and "cat" command.In the below code can i use cat command instead of paste?

    p = NULL #neither bool nor integer nor numeric nor character
    for(i in 1:10)
    {
    if(i==1)
    p = i
    else
    p = paste(p,i, sep = ",")
    }
    p
    print(p)

    Thanks,
    Aaditya
     
    #15
  16. Debasish Biswas

    Debasish Biswas New Member

    Joined:
    Dec 28, 2019
    Messages:
    1
    Likes Received:
    0
    for(i in 2:10){
    for(j in 1:3){
    print(paste(i,"X",j,"=",i*j))
    }
    }
     
    #16
  17. Prerna Sharma_3

    Prerna Sharma_3 New Member

    Joined:
    Dec 2, 2019
    Messages:
    1
    Likes Received:
    0
    my assignment file
     

    Attached Files:

    #17
  18. John_302

    John_302 Member

    Joined:
    Jan 2, 2020
    Messages:
    2
    Likes Received:
    0
     

    Attached Files:

    #18
  19. Samridhi Dutta

    Samridhi Dutta Well-Known Member
    Trainer

    Joined:
    Aug 16, 2017
    Messages:
    169
    Likes Received:
    20
    #19
  20. Nanar Chahverdian

    Joined:
    Jan 9, 2020
    Messages:
    2
    Likes Received:
    0
    for (num1 in 2:10) {
    cat('\n')
    for (num2 in 1:10) {
    cat(num1, 'x', num2, '=', num1*num2, '\n')
    }
    }
     
    #20
  21. Nanar Chahverdian

    Joined:
    Jan 9, 2020
    Messages:
    2
    Likes Received:
    0
    Dear Samridhi, can you please check below two questions?
    class(cat(1,2,3)) #why NULL?
    class(paste(1,2,3)) #why character?
     
    #21
  22. Gautam Lakshmiratan

    Joined:
    Dec 7, 2019
    Messages:
    7
    Likes Received:
    0
    Need to understand why this trailing message comes after every iteration. The output is:
    "30 Levels: Akira American Beauty Back to the Future ... Whiplash"
    The code is:
    # Creating a start point.
    iteration = 1

    # want to repeat until we reach the sixth operation -- but not execute the sixth time.
    # While iteration is less or equal to five...
    while (iteration <= 5) {

    print(c("This is iteration number:",as.character(iteration)))

    # ...print the "name" column of the iteration row.
    print(movies_data[iteration,]$name)

    # And then, we increase the "iteration" value -- so that we actually reach our stopping condition
    iteration = iteration + 1
    }

    Dataset used Movie_Data
    source: download.file("https://ibm.box.com/shared/static/n5ay5qadfe7e1nnsv5s01oe1x62mq51j.csv", destfile="movies-db.csv")
     
    #22
    Last edited: Jan 16, 2020 at 7:38 PM
  23. Raghavan Komanduru

    Joined:
    Dec 24, 2019
    Messages:
    4
    Likes Received:
    0
    Hi Samridhi,
    I am practicing the code that we discussed last week. Regarding the for loop, I could execute the code shown below initially. But later, when I was trying to use break command and execute, then, the output shown is the same code and the variable itself and not the expected output. Not sure, where I am missing. Then onward, none of the codes are executing with Ctrl+Enter.

    for(day in 1:31)
    {
    if(day>=20 & day<28)
    next
    cat("The child came on the date. The date is: ", day,"/01/2020\n", sep="")
    if(day==29)
    {
    cat("The Child is leaving the School on: ", day,"01/2020", sep = " ")
    break
    }
    }
    day

    Output shown in console as below:
    + for(day in 1:31)
    + { + if(day>=20 & day<28)+ next+ cat("The child came on the date. The date is: ", day,"/01/2020\n", sep="")+ if(day==29)+ {+ cat("The Child is leaving the School on: ", day,"01/2020", sep = " ")+ break+ }+ }+ day
    Can I get help to know what is going wrong with the code?
     
    #23
    Last edited: Jan 17, 2020 at 2:14 AM
  24. Arunkumar Rathinam

    Arunkumar Rathinam New Member

    Joined:
    Dec 17, 2019
    Messages:
    1
    Likes Received:
    0
    Hey Samridhi!

    Here's the Assignment - "Multiplication Tables"

    i = NULL
    j = NULL
    for( i in 2:10)
    {
    for(j in 1:10)
    {
    k = i*j
    cat(i,"x",j,"=",k,"\n")
    }
    }
     
    #24
  25. Gayathri Poovannan

    Gayathri Poovannan New Member

    Joined:
    Dec 17, 2019
    Messages:
    1
    Likes Received:
    0
    #Assignment for tables
    i = NULL
    j = NULL
    for( i in 2:10)
    {
    for(j in 1:10)
    {
    k = i*j
    cat(i,"x",j,"=",k,"\n")
    }
    }
     
    #25
  26. Amit Sharma_49

    Joined:
    Dec 27, 2019
    Messages:
    2
    Likes Received:
    0
    outer = 10
    inner = 10

    for (i in 1:eek:uter )
    {
    for (j in 1:inner)
    {
    print(sprintf("%d X %d = %d", i , j , i * j))
    }
    cat("\n")
    }
     
    #26
  27. Amit Sharma_49

    Joined:
    Dec 27, 2019
    Messages:
    2
    Likes Received:
    0
    cat() prints and does not return a value and paste() returns character vector

    putting a code snippet which explains this

    >var = cat("name")
    name
    > var1 = paste("name")
    >
    > var
    NULL
    > var1
    [1] "name"
    >
     
    #27
  28. John_302

    John_302 Member

    Joined:
    Jan 2, 2020
    Messages:
    2
    Likes Received:
    0
    Hi believe if you scroll down the console window, you should find the output immediately after the print of the code
     
    #28
  29. Gautam Lakshmiratan

    Joined:
    Dec 7, 2019
    Messages:
    7
    Likes Received:
    0
    Please find results below..

    [1] "2 X 1 = 2"
    [1] "2 X 2 = 4"
    [1] "2 X 3 = 6"
    [1] "2 X 4 = 8"
    [1] "2 X 5 = 10"
    [1] "2 X 6 = 12"
    [1] "2 X 7 = 14"
    [1] "2 X 8 = 16"
    [1] "2 X 9 = 18"
    [1] "2 X 10 = 20"

    [1] "3 X 1 = 3"
    [1] "3 X 2 = 6"
    [1] "3 X 3 = 9"
    [1] "3 X 4 = 12"
    [1] "3 X 5 = 15"
    [1] "3 X 6 = 18"
    [1] "3 X 7 = 21"
    [1] "3 X 8 = 24"
    [1] "3 X 9 = 27"
    [1] "3 X 10 = 30"

    [1] "4 X 1 = 4"
    [1] "4 X 2 = 8"
    [1] "4 X 3 = 12"
    [1] "4 X 4 = 16"
    [1] "4 X 5 = 20"
    [1] "4 X 6 = 24"
    [1] "4 X 7 = 28"
    [1] "4 X 8 = 32"
    [1] "4 X 9 = 36"
    [1] "4 X 10 = 40"

    [1] "5 X 1 = 5"
    [1] "5 X 2 = 10"
    [1] "5 X 3 = 15"
    [1] "5 X 4 = 20"
    [1] "5 X 5 = 25"
    [1] "5 X 6 = 30"
    [1] "5 X 7 = 35"
    [1] "5 X 8 = 40"
    [1] "5 X 9 = 45"
    [1] "5 X 10 = 50"
     

    Attached Files:

    #29
  30. Raghavan Komanduru

    Joined:
    Dec 24, 2019
    Messages:
    4
    Likes Received:
    0
    Issue is resolved by support team. Thanks
     
    #30
  31. Raghavan Komanduru

    Joined:
    Dec 24, 2019
    Messages:
    4
    Likes Received:
    0
    Hi Samridhi,

    I could finally complete coding. below is my code. Sorry for late submission of the assignment.

    for (i in 2:10)
    {
    for(j in 1:10)
    {
    print(paste(i,"*",j,"=",i*j,sep=""))
    }
    }

    Enjoying coding. Thanks
     
    #31
  32. nikhil suresh

    nikhil suresh New Member

    Joined:
    Jan 3, 2020
    Messages:
    1
    Likes Received:
    0

    c <- 2
    for (i in 1:10){
    print(paste(c,"x",i,"=",c*i))
    }

    This is for 2 table ...same thing can be changed to 3 ,4 ,5 and so on
     
    #32
  33. Sujit Supekar

    Sujit Supekar New Member

    Joined:
    Dec 24, 2019
    Messages:
    1
    Likes Received:
    1
    Hi,
    does anyone have the chats saved from last week's sessions?
    Please share if yes.
    Thanks.
     
    #33
    Raghavan Komanduru likes this.
  34. Gautam Lakshmiratan

    Joined:
    Dec 7, 2019
    Messages:
    7
    Likes Received:
    0
    receiving an error is R Studio
    err msg:" the process cannot access the file because it is being used by another process"

    how do we resolve this?
     
    #34
  35. Raghavan Komanduru

    Joined:
    Dec 24, 2019
    Messages:
    4
    Likes Received:
    0
    Hi Samridhi,

    I think I do not have access to your google Drive to access the data sets and assignment files. I only have access to 11th Jan 2020 folder - (https://drive.google.com/drive/folders/1gq6lLJKuzH4u5PO1ftJ9JYGwFqaUik-U). Can I get the complete folder access to download the assignment files and the data sets for practicing.

    Thanks in advance,
    Raghavan K
     
    #35

Share This Page