Day: February 5, 2021

R Examples for Beginners – Check if a Number is Odd or Even in R Programming

(R Example for Citizen Data Scientist & Business Analyst)   Check if a Number is Odd or Even in R Programming In this example, a number entered by the user is checked whether it’s an odd number or an even number.   Example: Check Odd and Even Number # Program to check if the input …

R Examples for Beginners – R Program to Check for Leap Year

(R Example for Citizen Data Scientist & Business Analyst)   R Program to Check for Leap Year This program checks whether an year (integer) entered by the user is a leap year or not. A leap year is exactly divisible by 4 except for century years (years ending with 00). The century year is a …

R Examples for Beginners – R Program to Print the Fibonacci Sequence

(R Example for Citizen Data Scientist & Business Analyst)   R Program to Print the Fibonacci Sequence In this example, you’ll learn to print the Fibonacci sequence using a while loop. A Fibonacci sequence is the integer sequence of 0, 1, 1, 2, 3, 5, 8…. The first two terms are 0 and 1. All …

R Examples for Beginners – R Program to check Armstrong Number

(R Example for Citizen Data Scientist & Business Analyst)   R Program to check Armstrong Number In this example, you’ll learn to check whether a number is an Armstrong number or not using a while loop.   An Armstrong number, also known as narcissistic number, is a number that is equal to the sum of …

R Examples for Beginners – R Program to Check Prime Number

(R Example for Citizen Data Scientist & Business Analyst)   R Program to Check Prime Number Example to check whether an integer (entered by the user) is a prime number or not using control statements.   A positive integer greater than 1 which has no other factors except 1 and the number itself is called …

R Examples for Beginners – R Multiplication Table

(R Example for Citizen Data Scientist & Business Analyst)   R Multiplication Table In this example, you will learn to print the multiplication table of a number (entered by the user) from 1 to 10.   Example: Multiplication Table # R Program to find the multiplicationtable (from 1 to 10) # take input from the …

R Examples for Beginners – R Program to Find the Factorial of a Number

(R Example for Citizen Data Scientist & Business Analyst)   R Program to Find the Factorial of a Number In this example, you’ll learn to find the factorial of a number without using a recursive function.   The factorial of a number is the product of all the integers from 1 to that number. For …

R Examples for Beginners – R Program to Sort a Vector

(R Example for Citizen Data Scientist & Business Analyst)   R Program to Sort a Vector In this example, you’ll learn to sort a vector in R using sort() function.   Sorting of vectors can be done using the sort() function. By default, it sorts in ascending order. To sort in descending order we can pass decreasing=TURE. Note …

R Examples for Beginners – R Program to Find Minimum and Maximum

(R Example for Citizen Data Scientist & Business Analyst)   R Program to Find Minimum and Maximum In this example, you’ll learn to find the minimum and maximum numbers from a list using min() and max() function respectively. You’ll also learn to use the range() function.   We can find the minimum and the maximum …

R Examples for Beginners – R Program to Sample from a Population

(R Example for Citizen Data Scientist & Business Analyst)   R Program to Sample from a Population In this example, you will learn to take sample from a population using sample() function. We generally require to sample data from a large population. R has a function called sample() to do the same. We need to provide the …