Vinit R Programming
Vinit R Programming
Submitted By
Vinit Koshti
(Reg. No. 20220702139)
BACHELOR OF TECHNOLOGY
In
KARNAVATI UNIVERSITY
Uvarsad, Gandhinagar, Gujarat-382422
DECEMBER 2024
Experiment-
1 Download and install R-Programming environment and install
basic packages using install. Packages () command in R.
Date: 05-08-
2024
1. Download R:
o Go to the official R website: https://cran.r-project.org/
o Choose your operating system (Windows, macOS, or Linux).
o Download and run the appropriate installer for your system.
2. Install R:
o Run the downloaded installer and follow the installation instructions.
o Once installed, R will be available on your system.
1. Open R or RStudio.
2. Use install.packages () to install packages.
Program:
Result: Rstudio install successfully.
Experiment-
2 Learn all the basics of R-Programming (Datatypes, Variables)
Date: 05-08-
2024
Theory:
Algorithm:
1. Start R environment.
2. Create variables of different data types:
o Numeric
o Character
o Logical
3. Perform operations on these variables.
4. Create vectors, lists, and data frames.
5. Access and manipulate the elements of these structures.
6. End the R session.
Program:
Result:
Summary of the Experiment:
The various operations on data frames in R has been implemented and
successfully verified
Experiment-
3 To perform Basic Mathematical Operations in R
Date: 05-08-
2024
Theory:
Algorithm:
1. Start R environment.
2. Define numeric variables.
3. Perform addition, subtraction, multiplication, and division
operations.
4. Use mathematical functions like sqrt(), log(), exp().
5. End the R session.
Program:
Result:
Summary of the Experiment:
The various Mathematical operations in R has been implemented and
successfully verified
Experiment-
4 To Perform various operators in R
Date: 05-08-
2024
Theory:
Algorithm:
1. Start R environment.
2. Define variables to use with operators.
3. Perform arithmetic operations (+, -, *, /).
4. Use relational operators (>, <, ==, !, =).
5. Apply logical operators (&, | , !).
6. Use assignment operators (=, <-).
7. End the R session.
Program:
Result:
Summary of the Experiment:
The various operations in R has been implemented and successfully
verified
AIM: Write a program to check whether a year (integer) entered by the user
is a leap year or not?
THEORY:
A leap year is a year divisible by 4 but not by 100, unless it's also divisible
by 400. This means:
ALGORITHM:
PROGRAM:
RESULT:
Theory:
Algorithm:
1. Start R environment.
2. Create a matrix using matrix() function.
3. Perform operations on the matrix (e.g., addition, multiplication).
4. Create a list using list() function.
5. Access and manipulate list elements.
6. End the R session.
Program:
Result:
Summary of the Experiment:
The various operations in R has been implemented and successfully
verified
Experiment-
7 Implementation of Array, Factors in R Programming
Date: 05-08-
2024
Theory:
Algorithm:
1. Start R environment.
2. Create an array using array() function.
3. Perform operations on the array.
4. Create factors using factor() function.
5. Manipulate and analyze factors.
6. End the R session.
Program:
Result:
Theory:
A Data Frame in R is a two-dimensional table-like structure where each
column contains values of one variable, and each row contains a set of
values from each column. It allows for easy manipulation of tabular data
by performing operations like adding/removing columns, filtering rows,
sorting, and applying functions across rows/columns.
Algorithm Steps:
Create a Data Frame using data.frame () with vectors as input.
Access data by referencing rows/columns via $, [], or column names.
Add or remove columns by assigning values to new columns or
setting columns to NULL.
Filter rows using logical conditions on the data frame.
Sort the data by using the order () function on a column.
Merge data frames using merge () on common keys.
Apply functions to rows/columns with apply () or get a summary of the
dat.
Program:
r
Theory:
Dummy data, or sample data, is artificially generated data used for
testing, development, and learning purposes. In R, this can be done using
built-in functions like data.frame(), rep(), and sample(). Data manipulation
includes filtering rows based on conditions, sorting data, modifying or
adding columns, and summarizing the dataset for analysis. These
operations are essential for handling real-world data for statistical
modeling and visualization.
Algorithm Steps:
2. Access Data:
3. Manipulate Data:
4. Summarize Data:
Use functions like summary (), mean (), max (), min () to summarize data.
5. View Results:
Algorithm:
1. Create a Data Frame: Use data.frame () to create a data frame with
columns of data.
2. Access Data:
3. Manipulate Data:
Program:
Result:
Theory:
2. For Loop:
o Loop over a sequence of values using for.
3. While Loop:
o Execute code repeatedly as long as a condition is TRUE using while.
4. Repeat Loop:
o Repeat code indefinitely until a break condition is encountered.
Program:
Result: All the control structure successfully run.
Theory:
The dplyr package in R is designed for fast and easy data manipulation
tasks. It provides a set of functions (often referred to as "verbs") such as
filter (), select (), arrange (), mutate (), summarize (), and group by().
These functions allow for powerful, efficient, and readable data
manipulation. dplyr often uses the pipe operator (%> %) to chain
multiple operations together, improving readability and making the code
concise.
Algorithm:
Program:
Result: All the data manipulation done successfully.
Summary of Experiment: Data Manipulation with dplyr package
executed successfully.
Algorithm:
Program:
Result: All the data manipulation done successfully.
Algorithm :
Load the ggplot2 package
Create a data frame
Create a basic plot
Add geometric objects
Customize the plot
Facet the plot
Display the plot
Program :
Result: All the data manipulation done successfully.