Conditional Statements - English
- Questions posted on Forums
- R Tutorials - English
-
Conditional statement assignment
assignment question:Use the built-in data set iris. Find the Species, in which Sepal.Length is greater than Petal.Length. 2. Count all such Species.solution: iris$find = ifelse(iris$Sepal.Length > iris$Petal.Length,1,0)View(iris) sum(ifelse(iris$Sepal.Length > iris$Petal.Length,1,0))[1] 150Is it correct or any better code can be implemented ?
10-11M 40-50SMay 15, 2025, 1:04 a.m. suhailalphacs
-
Some problem on the execution of the statement
I am trying to execute this statement. In this, I have to get one output i.e. India won the first ODI but I got two times instead of one. please provide me a useful solutionif(inScore[1]> ausScore[1])( print("India won the first ODI"))
03-04M 20-30SMay 14, 2025, 11:59 p.m. sumankr545
-
Conditional Statements
Count all such Species.Answer for Assignment Question
09-10M 0-10SMay 15, 2025, 3:33 p.m. bvs.nnsvidya@gmail.com
-
Conditional Statements
Use the built-in data set iris. Find the Species, in which Sepal.Length is greater than Petal.Length. please send the answer
11-12M 0-10SMay 15, 2025, 4:49 p.m. bvs.nnsvidya@gmail.com
-
Adding a new column
Is it possible to add a new column to a specific position in a dataframe?
09-10M 30-40SMay 15, 2025, 4:05 p.m. vijayaprabhu
-
1Overview of R and RStudio
-
2Installing R and RStudio on Linux
-
3Installing R and RStudio on Windows
-
4Introduction to basics of R
-
5Introduction to Data Frames in R
-
6Introduction to RStudio
-
7Introduction to R script
-
8Working directories in RStudio
-
9Indexing and Slicing Data Frames
-
10Creating Matrices using Data Frames
-
11Operations on Matrices and Data Frames
-
12Merging and Importing Data
-
13Data types and Factors
-
14Lists and its Operations
-
15Plotting Histograms and Pie Chart
-
16Plotting Bar Charts and Scatter Plot
-
17Introduction to ggplot2
-
18Aesthetic Mapping in ggplot2
-
19Data Manipulation using dplyr Package
-
20More Functions in dplyr Package
-
21Pipe Operator
-
Conditional Statements
-
23Functions in R
Questions posted on ST Forums:
Outline:
About conditional statements Syntax of if, else and else if statements Use if, else and else if statements Use if else function Arguments of if else function Add a new column in an existing data frame Read and store a csv file View a data frame Count true values in a column Use sum function