Skip to main content

DV-EXP-2


Before Proceeding for Ploting Charts in R Programming, Go through this link and Explore GGPLOT2




==================================


==================================


==================================


==================================


==================================


==================================


==================================



                                               ==================================





==================================




==============================================================



===============================================================







===============================================================








=================================================================


Exercise 4: GGPLOT2 in R

Group manipulation and data reshaping in R, understanding the philosophy of ggplot2, bar plot, pie chart, histogram, boxplot, scatter plotand regression plots


1.  Write R Script for Group Manipulation and Data Reshaping

For following data

Group

A

A

B

B

C

C

Value

10

15

12

18

8

14



# Install the dplyr package if not already installed

if (!require(dplyr)) {

  install.packages("dplyr")

}

if (!require(tidyr)) {

  install.packages("tidyr")

}

library(dplyr)

library(tidyr)

# Load necessary libraries

library(dplyr)

# Create a sample dataset

data <- data.frame(

  Group = c("A", "A", "B", "B", "C", "C"),

  Value = c(10, 15, 12, 18, 8, 14)

)

# Group manipulation: Calculate the mean value for each group

group_means <- data %>%

  group_by(Group) %>%

  summarise(Mean_Value = mean(Value))

# Data reshaping: Convert to wide format

wide_data <- pivot_wider(group_means, names_from = Group, values_from = Mean_Value)

# Print the result

print(wide_data)



output:

# A tibble: 1 × 3
      A     B     C
  <dbl> <dbl> <dbl>
1  12.5    15    11



=========================================================================================================================================










 

Comments

Popular posts from this blog

Data Mining - Assignment & ELA Test-1

  Table – 1 Groceries Dataset Transaction ID Items T1 Milk, Bread, Butter, Eggs, Sugar, Tea, Coffee, Biscuit, Cheese, Yogurt T2 Bread, Butter, Jam, Eggs, Milk, Sugar, Biscuit, Tea, Coffee, Yogurt T3 Bread, Butter, Cheese, Jam, Eggs, Milk, Yogurt, Biscuit, Tea, Coffee T4 Milk, Bread, Cheese, Butter, Sugar, Eggs, Coffee, Tea, Yogurt, Biscuit T5 Butter, Bread, Jam, Milk, Sugar, Coffee, Biscuit, Eggs, Yogurt, Tea T6 Milk, Butter, Cheese, Sugar, Biscuit, Yogurt, Eggs, Bread, Coffee, Tea T7 Bread, Jam, Milk, Butter, Eggs, Biscuit, Coffee, Yogurt, Sugar, Tea T8 Butter, Cheese, Bread, Eggs, Milk, Biscuit, Sugar, Tea, Coffee, Yogurt T9 Bread, Butter, Jam, Cheese, Yogurt, Biscuit, Coffee, Tea, Eggs, Milk T10 Milk, Bread, Butter...

Tableau

TABLEAU EXPERIMENTS Consider the Dhoni Dataset  click here  solve the following experiments using Tableau Tool Here are a few experiment ideas for students to create visualizations in Tableau using the cricket dataset: Experiment 1: Runs vs. Opponent Objective:  Visualize how the player's performance in terms of runs varies against different opponents. Task:  Create a bar chart showing the total runs scored against each opposing team. Additional Insight:  Add a color gradient to highlight highest to lowest run totals. Experiment 2: Performance Over Time Objective:  Analyze the player’s performance trends over the course of the season. Task:  Develop a line chart that plots runs scored over time (by date). Additional Insight:  Include a dual-axis to plot catches and stumpings alongside runs. Experiment 3: Heatmap of Performances by Stadium Objective:  Compare the player’s performance at different stadiums. Task:  Create a heatmap to displ...

DBMS001

DBMS Practice Experiment   Design 7 tables as per the given requirements, with at least 10 rows per table, including primary keys and foreign keys wherever appropriate. Your tables should be as follows (attributes are suggested but you may modify them if needed):   Table: Department Attribute Data Type Description dept_id (PK) INT Unique ID for department dept_name VARCHAR(50) Name of the department hod_name VARCHAR(50) Head of department name office_location VARCHAR(50) Location of the department office contact_email VARCHAR(50) Department email contact_phone VARCHAR(15) ...