1. Graphs in R Definition: Graphs in R are visual representations of data, used to display relationships, distributions, and comparisons. Use: Data exploration and understanding. Identifying patterns, trends, and outliers. Communicating insights effectively. Supporting statistical analysis. Types of Graphs: R offers a wide variety of plotting functions. Common types include: Univariate: Histograms, Box Plots, Density Plots, Bar Charts (for categorical data). Bivariate: Scatter Plots, Line Charts, Heatmaps, Box Plots (grouped). Multivariate: 3D Scatter Plots, Pair Plots, Faceted Plots, Radar Charts. Specialized: Pie Charts, Q-Q Plots, Violin Plots, Mosaic Plots. 2. Pie Chart Definition: A pie chart is a circular statistical graphic, divided into slices to illustrate numerical proportion. In a pie chart, the arc length of each slice (and consequently its central angle and area) is proportional to the quantity it represents. Use: Best for showing proportions of a whole, especially with a small number of categories. Types: Standard Pie Chart: Simple division of a circle. Exploded Pie Chart: One or more slices are separated from the main body for emphasis. Donut Chart: A pie chart with a hole in the center, often used to display additional information in the middle. Example (Standard Pie Chart): # Sample data x This code creates a pie chart showing the proportion of values for four cities. 3. Bar Chart Definition: A bar chart (or bar graph) presents categorical data with rectangular bars with heights or lengths proportional to the values that they represent. The bars can be plotted vertically or horizontally. Use: Comparing quantities of different categories, showing changes over time, or comparing different groups. Types: Vertical Bar Chart: Bars extend upwards. Horizontal Bar Chart: Bars extend sideways. Grouped Bar Chart: Multiple bars per category, grouped together (e.g., male/female sales per region). Stacked Bar Chart: Bars are divided into segments representing different sub-categories, stacked on top of each other. Example (Vertical Bar Chart): # Sample data H This code generates a bar chart displaying monthly revenue figures. 4. Box Plot Definition: A box plot (or box-and-whisker plot) is a standardized way of displaying the distribution of data based on a five-number summary: minimum, first quartile (Q1), median (Q2), third quartile (Q3), and maximum. Use: Visualizing the distribution, central tendency, and variability of a dataset, and identifying potential outliers. Excellent for comparing distributions between groups. Components: Box: Represents the interquartile range (IQR), from Q1 to Q3. Median (Line inside box): The middle value of the dataset. Whiskers: Extend from the box to the minimum and maximum values within $1.5 \times IQR$ from Q1 and Q3. Outliers (Points): Data points falling outside the whiskers. Example: # Sample data data1 This code creates a box plot comparing the distributions of three different groups of data. 5. Histogram Definition: A histogram is an accurate graphical representation of the distribution of numerical data. It is an estimate of the probability distribution of a continuous variable. It is similar to a bar chart, but the bars represent ranges of data (bins) and are contiguous. Use: Displaying the shape and spread of a continuous dataset, identifying the central tendency, variability, skewness, and modality. Key Features: Bins: The range of data values is divided into intervals (bins). Frequency/Density: The height of each bar represents the frequency (count) or density of data points falling into that bin. Continuous Data: Used for continuous variables, unlike bar charts which are for categorical data. Example: # Sample data (100 random numbers from a normal distribution) data This code generates a histogram showing the frequency distribution of 100 randomly generated numbers.