0% found this document useful (0 votes)
1 views1 page

Unit 2 R Programming

The document outlines a series of tasks to be performed using R programming, including displaying text, performing arithmetic operations, creating sequences, and utilizing control structures like loops and conditionals. It also includes tasks for working with different data types, calculating statistical measures, and implementing functions. Overall, it serves as a guide for basic R programming exercises.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views1 page

Unit 2 R Programming

The document outlines a series of tasks to be performed using R programming, including displaying text, performing arithmetic operations, creating sequences, and utilizing control structures like loops and conditionals. It also includes tasks for working with different data types, calculating statistical measures, and implementing functions. Overall, it serves as a guide for basic R programming exercises.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

1. Write an R script to display "Hello, World!" and save it in RStudio.

2. Perform basic arithmetic operations in R (addition, subtraction, multiplication, division,


and modulus).
3. Create a sequence of numbers from 1 to 20 and calculate the mean, median, and sum of
the sequence.
4. Create variables of different data types: numeric, character, logical, and print their values.
5. Write an R script to check if a number is positive, negative, or zero using an if-else
statement.
6. Write an R script to print numbers from 1 to 100 using a for loop.
7. Write an R script to calculate the factorial of a number using a while loop.
8. Use a switch statement to perform a basic calculator function: addition, subtraction,
multiplication, or division.
9. Write an R script to print the current date, time, and session information.
10. Write an R script to find the largest of three numbers using nested if-else statements.
11. Write an R script to calculate the sum of all even numbers from 1 to 100 using a for loop.
12. Write an R script to print the Fibonacci series up to a given number using a while loop.
13. Write a function in R to check if a number is prime.
14. Use a for loop to calculate the sum of the first 50 natural numbers.
15. Use a while loop to reverse the digits of a number.

You might also like