Saturday, 11 July 2015

RStudio : Run R code

In this post, I am going to explain how to run code in R Studio.

Step 1: Open R Studio.

Step 2: File -> New File -> R script


Step 3: Type following code and save it as  IfStmt.R
IfStmt.R
marks <- readline("enter your marks: ")

if(marks < 35){
  print("You are failed")
}else if(marks >=35 & marks < 60){
  print("Third class")
}else if(marks >= 60 & marks < 70){
  print("First class")
}else if(marks >= 70 & marks <101 ){
  print("Distinction")
}else{
  print("Wrong marks")
}

Step 4:  Click on the source button. You will get output in console.




Prevoius                                                 Next                                                 Home

No comments:

Post a Comment