DS-R | OCT 01 - OCT 17 | Nimisha

Discussion in 'Big Data and Analytics' started by Nishant Singh_3, Oct 1, 2018.

  1. Nishant Singh_3

    Nishant Singh_3 Well-Known Member
    Simplilearn Support

    Joined:
    Aug 1, 2018
    Messages:
    114
    Likes Received:
    5
    Hi Learner,

    This thread is assigned for you to discuss the query and concepts related to Data Science with R course.

    Happy Learning !!

    Regards,
    Team Simplilearn
     
    #1
    Last edited: Nov 6, 2018
  2. Nimisha Pandey

    Trainer

    Joined:
    Aug 4, 2017
    Messages:
    13
    Likes Received:
    5
    Prime Numbers :

    1. Telling whether a number is prime or Not
    2. Get all the prime nos between 2 and 100
    3. Get first 20 prime nos.
    Fibonacci series :

    0, 1, 1, 2, 3, 5, 8, 13, 21,…… till 15th element

    Finding Factorial
     
    #2
    _41622 and Phanindra_4 like this.
  3. _42094

    _42094 Member

    Joined:
    Sep 28, 2018
    Messages:
    7
    Likes Received:
    0
    Hi Nimisha,

    Here is the Assignment solutions. Attached r script as .txt file

    Kind Regards
    Sreedhar (vensyd)
     

    Attached Files:

    #3
  4. Meenakshi satpathy

    Alumni

    Joined:
    May 15, 2017
    Messages:
    2
    Likes Received:
    0

    SOLUTIONS:
    #ques1 prime or not

    chk_prime <-function(){
    num <-as.numeric(readline("Enter number to check number is prime or not "))
    t=0
    if (num>1){
    i=2
    while(i<num){
    if(num%%i==0){
    t=1
    break
    }
    i=i+1
    }
    }
    if(t==0){
    print("Prime")
    }else{
    print("Not Prime")
    }
    }

    chk_prime()
    #ques 2

    pnt_prime <-function(){
    j=3
    while(j<100){
    t=0
    i=2
    while(i<j){
    if(j%%i==0){
    t=1
    break
    }
    i=i+1
    }
    if(t==0){
    print(j)
    }
    j=j+1
    }
    }

    pnt_prime()

    #ques 3 first 20 prime numbers

    fst20_prime <-function(){
    j=3
    cnt=0
    while(j<100){
    t=0
    i=2
    while(i<j){
    if(j%%i==0){
    t=1
    break
    }
    i=i+1
    }
    if (cnt<20){
    if(t==0){
    cnt=cnt+1
    print(j)
    }
    }else{
    break
    }
    j=j+1
    }
    }

    fst20_prime()

    # fibonacci series

    fib <- function(){
    a=0
    b=1
    cnt=2
    print(a)
    print(b)
    while(cnt<16){
    c=a
    a=b
    b=a+c
    print(b)
    cnt=cnt+1
    }
    }
    fib()

    #factorial

    fact<-function(){
    num <-as.numeric(readline("Enter factorial number you want to find: "))
    fact=1
    if (num == 0){
    print(1)
    }else{
    while(num>1){
    fact=fact*num
    num=num-1
    }
    print(fact)
    }
    }

    fact()

    Thanks,
    Meenakshi(jinisatpathy)
     
    #4
  5. Meenakshi satpathy

    Alumni

    Joined:
    May 15, 2017
    Messages:
    2
    Likes Received:
    0

    SOLUTIONS:
    #ques1 prime or not

    chk_prime <-function(){
    num <-as.numeric(readline("Enter number to check number is prime or not "))
    t=0
    if (num>1){
    i=2
    while(i<num){
    if(num%%i==0){
    t=1
    break
    }
    i=i+1
    }
    }
    if(t==0){
    print("Prime")
    }else{
    print("Not Prime")
    }
    }

    chk_prime()
    #ques 2

    pnt_prime <-function(){
    j=3
    while(j<100){
    t=0
    i=2
    while(i<j){
    if(j%%i==0){
    t=1
    break
    }
    i=i+1
    }
    if(t==0){
    print(j)
    }
    j=j+1
    }
    }

    pnt_prime()

    #ques 3 first 20 prime numbers

    fst20_prime <-function(){
    j=3
    cnt=0
    while(j<100){
    t=0
    i=2
    while(i<j){
    if(j%%i==0){
    t=1
    break
    }
    i=i+1
    }
    if (cnt<20){
    if(t==0){
    cnt=cnt+1
    print(j)
    }
    }else{
    break
    }
    j=j+1
    }
    }

    fst20_prime()

    # fibonacci series

    fib <- function(){
    a=0
    b=1
    cnt=2
    print(a)
    print(b)
    while(cnt<16){
    c=a
    a=b
    b=a+c
    print(b)
    cnt=cnt+1
    }
    }
    fib()

    #factorial

    fact<-function(){
    num <-as.numeric(readline("Enter factorial number you want to find: "))
    fact=1
    if (num == 0){
    print(1)
    }else{
    while(num>1){
    fact=fact*num
    num=num-1
    }
    print(fact)
    }
    }

    fact()

    Thanks,
    Meenakshi(jinisatpathy)
     
    #5
  6. _42094

    _42094 Member

    Joined:
    Sep 28, 2018
    Messages:
    7
    Likes Received:
    0
    #6
  7. _41622

    _41622 Member

    Joined:
    Sep 26, 2018
    Messages:
    2
    Likes Received:
    0
    # get data
    helt <- read.csv(file.choose(),header = T)
    class(helt)
    head(helt)
    # hist of age
    hist(helt$AGE)
    summary(as.factor(helt$AGE))
    #convert int to fact
    helt$AGE <- as.factor(helt$AGE)
    class(helt$AGE)
    summary(helt$AGE)
    helt$AGE<-as.numeric(helt$AGE)
    class(helt$AGE)
    hist(helt$AGE1)
    HI am doing health care project am geeting erro can any suggest how to over come.
    ERROR
    Error in hist.default(helt$AGE1) : 'x' must be numeric
     
    #7
  8. _41622

    _41622 Member

    Joined:
    Sep 26, 2018
    Messages:
    2
    Likes Received:
    0
    can anyone give the replay for this quiery
     
    #8
  9. Kunal Guwalani

    Kunal Guwalani Well-Known Member
    Simplilearn Support

    Joined:
    Jul 17, 2018
    Messages:
    55
    Likes Received:
    3
    Hi Learner,

    I would like to suggest you that there is no need to convert helt$AGE as numeric you can refer the folloing code.
    age=table(HospCost$AGE)
    View(HospCost)
    Freq=table(HospCost$AGE)
    barplot(Freq)
    class(Freq)
    View(HospCost)
    TotalChrgByAge=tapply(HospCost$TOTCHG,HospCost$AGE,max)
    TotalChrgByAge
     
    #9
  10. Bo Yuan

    Bo Yuan Member

    Joined:
    Sep 3, 2018
    Messages:
    13
    Likes Received:
    0
    I am not able to take the data science with R simulation test in LMS. It is keep loading and wont start. This issue has been there for a long time for me that trouble me to unlock the certificate.

    Can someone resolve the issue, please? Thanks in advance.

    I have tried IE, Chrome, Firefox.... None of them can load the page successfully. The page looks like this.
    upload_2018-10-31_13-41-29.png
     
    #10
  11. Priyanka_Mehta

    Priyanka_Mehta Well-Known Member
    Simplilearn Support

    Joined:
    May 25, 2017
    Messages:
    862
    Likes Received:
    58
    Hi, Apologies for the inconvenience. We have already forwarded it to the concerned team and will get it rectified as early as possible.
     
    #11
  12. Priyanka_Mehta

    Priyanka_Mehta Well-Known Member
    Simplilearn Support

    Joined:
    May 25, 2017
    Messages:
    862
    Likes Received:
    58
    Hi Bo Yuan,

    I am glad to inform you that, the Simulation Test is accessible in your LMS account for Data Science with R course.
    upload_2018-11-8_8-41-46.png

    I am sure this will help you. All the very best for the same. Also, would like to appreciate your cooperation in this regards.
     
    #12

Share This Page