Muthayammal College of Arts and Science Rasipuram: Assignment No - 1
Muthayammal College of Arts and Science Rasipuram: Assignment No - 1
Rasipuram
Assignment No - 1
Name : K.Haritha
Roll no : 21UST004
Date :
K.Haritha
1.BUILT IN FUNCTION
Mathematical Functions
Statistical Probability Functions
String Functions
Other Statistical Functions
1. Mathematical Functions
2. Statistical Functions
median(): Median
var(): Variance
paste(): Conca…
Types of R – Charts
Bar plot or Bar Chart in R is used to represent the values in data vector as height of
the bars. The data vector passed to the function is represented over y-axis of the graph. Bar
chart can behave like histogram by using table() function instead of data vector.
where
Pie chart is a circular chart divided into different segments according to the ratio of
data provided. The total value of the pie is 100 and the segments tell the fraction of the whole
pie. It is another method to represent statistical data in graphical form and pie() function is
used to perform the same.
x is data vector
Histogram
where
x is data vector
Scatter Plot
A Scatter plot is another type of graphical representation used to plot the points to
show relationship between two data vectors. One of the data vectors is represented on x-axis
and another on y-axis.
type specifies the type of plot to be drawn. For example, “l” for lines, “p” for points,
“s” for stair steps, etc.
Box Plot
Box plot shows how the data is distributed in the data vector. It represents five values
in the graph i.e., minimum, first quartile, second quartile(median), third quartile, the
maximum value of the data vector.
where
notch, if TRUE then creates notch on both the sides of the box
3. DATA INPUTTING, DATA ACCESSING AND INDEXING
You can create a data frame by entering data manually using the `data.frame()` function. For
example:
If your data is in a CSV (Comma-Separated Values) file, you can use the `read.csv()` function
to import it into R. For example:
To read data from an Excel file, you can use packages like `readxl` or `openxlsx`. For
example, with the `readxl` package
install.packages("readxl")
library(readxl)
You can read data directly from a URL using functions like `read.csv()` or other specific
functions based on the data format.
R provides various functions to generate synthetic data, such as `rnorm()` for generating
random numbers following a normal distribution.
Depending on your data source, you may need to use specialized packages. For instance, the
`jsonlite` package can be used to read JSON data, and the `httr` package can help you retrieve data
from web APIs.
DATA ACCESSING
You can access specific rows and columns in a data frame using square brackets `[ ]`.
For example:
You can filter rows based on specific conditions using logical indexing. For example:
3. Subsetting Data
You can create subsets of your data based on criteria. For example:
4. Sorting Data
You can sort your data by one or more columns using the `order()` function. For example:
5. Aggregating Data
You can compute summary statistics on your data using functions like `sum()`, `mean()`,
`median()`, etc., or use the `aggregate()` function for more complex aggregations.
6. Merging Data
You can merge two or more data frames together based on common columns using functions
like `merge()` or `dplyr` package functions like `left_join()`, `inner_join()`, etc.
You can access elements in lists and matrices using indexing similar to data frames, but with
double square brackets `[[]]` for lists and single brackets `[]` for matrices.
INDEXING
For example:
• Vector Indexing
In a vector, you can access elements by their position using square brackets. For
instance, my_vector[3] retrieves the third element of the vector.
• Matrix Indexing
For matrices, you can use row and column indices to access specific elements. For
example, my_matrix[2, 4] retrieves the element in the second row and fourth column.
Data frames allow indexing by both row and column, such as my_data_frame[1,
"Name"] to access the "Name" column of the first row.