Data Science Certification Training - R Programming | Dec 3 - 19

Discussion in 'Big Data and Analytics' started by Shohini_1, Dec 3, 2018.

  1. Shohini_1

    Shohini_1 Active Member
    Simplilearn Support

    Joined:
    Sep 24, 2018
    Messages:
    23
    Likes Received:
    0
    This thread is dedicated to Data Science Certification Training - R Programming - Dec 3,4,5,6,7,10,11,12,13,14,17,18,19
     
    #1
  2. Amanjeet Sahu

    Amanjeet Sahu Member

    Joined:
    Dec 5, 2018
    Messages:
    3
    Likes Received:
    0
    Assignment:
    num=2
    for(i in 1:10) {
    print(paste(num, 'x', i, '=', num*i))
    }
     
    #2
  3. Amanjeet Sahu

    Amanjeet Sahu Member

    Joined:
    Dec 5, 2018
    Messages:
    3
    Likes Received:
    0
    Assignment:
    num=2
    for(i in 1:10) {
    print(paste(num, 'x', i, '=', num*i))
    }
     
    #3
  4. _50305

    _50305 New Member

    Joined:
    Nov 30, 2018
    Messages:
    1
    Likes Received:
    0
    Any posts here till now??
     
    #4
  5. _48023

    _48023 New Member

    Joined:
    Nov 13, 2018
    Messages:
    1
    Likes Received:
    0
    #Assignment: print the table of 2, any no
    input_num = as.integer(readline(prompt = "Enter a number: "))
    for(i in 1:10) {
    print(paste(num,'x', i, '=', input_num*i))
    }
     
    #5
  6. _49538

    _49538 New Member

    Joined:
    Nov 26, 2018
    Messages:
    1
    Likes Received:
    0
    #Code to print table of 2

    for (i in 1:10)

    {

    paste(i+1)->val

    val

    val1=i*2

    paste("2X",val,"=",val1,sep = "")->result

    print(result)

    }



    #Code to print 1111,111,11,1

    for(i in 1:4)

    {

    x=1

    for(j in i:3-i)

    {

    if(i=="4")

    paste(x)

    else

    paste(1,x)->x

    }

    as.character(x)

    print(x)

    }



    #Code to add missing value in gender col to be as M

    ID = c(1:3)

    Name = c("Raj", "Suman", "Rahul")

    Gender = c("M", NA, "M")

    Phy = c(60, 63, 70)

    students = data.frame(ID, Name, Gender, Phy)

    students



    is.na(students$Gender)->g

    students$Gender[g]="M"

    students
     
    #6
  7. _41485

    _41485 Member

    Joined:
    Sep 25, 2018
    Messages:
    7
    Likes Received:
    0
  8. _41485

    _41485 Member

    Joined:
    Sep 25, 2018
    Messages:
    7
    Likes Received:
    0
    #Assignment: print the table of 2
    # 2 X 1 = 2
    # 2 X 2 = 4

    #2 X 10 = 20

    num = as.integer(readline(prompt = "Enter a number: "))
    for(i in 1:20)
    {
    print(paste(num,'x', i, '=', num*i))
    }
     
    #8
  9. _41485

    _41485 Member

    Joined:
    Sep 25, 2018
    Messages:
    7
    Likes Received:
    0
    #Assignment:
    #the missing values in the gender col have to be imputed as Male

    students$Gender[(is.na(students$Gender))=="TRUE"] = "M"
    students
     
    #9
  10. _41485

    _41485 Member

    Joined:
    Sep 25, 2018
    Messages:
    7
    Likes Received:
    0
    #Q. Find the average sepal length of Setosa species.
    #Hint: use function "mean"
    #Hint: Following is the mean function

    mean(iris$Sepal.Length[iris$Species=='setosa'], na.rm = T)
     
    #10
  11. _41485

    _41485 Member

    Joined:
    Sep 25, 2018
    Messages:
    7
    Likes Received:
    0
    #titanic dataset

    #Q. Find the number of passengers who survived
    sum(titanic_train$Survived, na.rm = T) -> sur_passengers
    sur_passengers
     
    #11
  12. _41485

    _41485 Member

    Joined:
    Sep 25, 2018
    Messages:
    7
    Likes Received:
    0
    #Q. Find the age of Timothy

    titanic_train$Age[which(titanic_train$Name %in% "McCarthy, Mr. Timothy J")] -> age
    age
     
    #12
  13. _41485

    _41485 Member

    Joined:
    Sep 25, 2018
    Messages:
    7
    Likes Received:
    0
    #Q. Find names of passengers having age>35

    titanic_train$Name[which(titanic_train$Age > 35)] -> name_passenger
    name_passenger
     
    #13
  14. Amanjeet Sahu

    Amanjeet Sahu Member

    Joined:
    Dec 5, 2018
    Messages:
    3
    Likes Received:
    0
    View(mtcars)
    des<- summary(mtcars$disp)
    des<- as.array(des)
    plot(density(mtcars$disp), main = "Density chart", col ="red", las=2)
    abline(v = mean(mtcars$disp),
    col = "blue",
    lwd = 2)
    abline(v = median(mtcars$disp),
    col = "red",
    lwd = 2)
    abline(v = des[2],
    col = "yellow",
    lwd = 2)
    abline(v = des[5],
    col = "green",
    lwd = 2)
    legend(x = "topright", # location of legend within plot area
    c("Mean", "Median", "1st Quartile", "3rd Quartile"),
    col = c("blue", "red", "yellow", "green"),
    lwd = c(2, 2, 2, 2),cex = 0.75)
    sd(mtcars$disp)-> std_dev
    std_dev
     
    #14

Share This Page