library(devtools)
library(rpivotTable)
install_github("ramnathv/htmlwidgets")
install_github("smartinsightsfromdata/rpivotTable")
-----------------------------------------------------------------------------------
--------------------
library(devtool)
library(rpivotTable)
espn = read.csv("espn.CSV",header=TRUE)
rpivotTable(espn, rows="Gender", col="Location", aggregatorName="Average",
vals="Income", rendererName="Table")
library(devtool)
library(rpivotTable)
product=read.csv("pivot-table.CSV",header=TRUE)
rpivotTable(product, rows="Product", col="Catgeory",
aggregatorName="Average",vals="Amount", rendererName="Table")
Case1
Q1.
library(devtools)
library(rpivotTable)
espn = read.csv("espn.CSV",header=TRUE)
rpivotTable(espn, row="Gender", aggregatorName="Count as Fraction of
Total",rendererName="Table")
Q2
rpivotTable(espn, row="Age", aggregatorName="Count as Fraction of Total",
vals="Age", rendererName="Table")
Q3.
rpivotTable(espn, row="Location", col ="Gender", aggregatorName="Count",
rendererName="Table")
Q4.
rpivotTable(espn, col="Location", aggregatorName="Count as Fraction of
Total",rendererName="Table")
Q5.
rpivotTable(espn, col="Income", rows="Age" ,aggregatorName="Count as Fraction of
Total", vals="Location", rendererName="Table")
Case 2(pivot-table)
Q1.
Q2.
Q3.
Q4.
Q5.
-----------------------------------------------------------------------------------
-----------------------------------------
For using melt and cast function
5.Question: What the average export amount to United States for both category?
pivot_table.c <-cast(pivot_table.m,Category ~ variable,margins = c("grand_row"),
mean, subset=(Country== "United States") )
pivot_table.c
if you want to display category country and also product in above question then
pivot_table.c <-cast(pivot_table.m, Category+Country+Product ~ variable, margins =
c("grand_row"), sum)
pivot_table.c
13.Question: Compare the average amount of Apple exports to Australia and Canada
cast(pivot_table, Country ~ Product, mean) # Analyzes the means (average amounts)
between each pair of countries and products
-----------------------------------------------------------------------------------
-
MUltiple tables analysis
library(readxl)
> Data <- read_excel("C:/Users/PRS/Desktop/merger/Data.xlsx")
> View(Data)
>library(readxl)
> Dept <- read_excel("C:/Users/PRS/Desktop/merger/Dept.xlsx")
> View(Dept)
> library(readxl)
> Faculty <- read_excel("C:/Users/PRS/Desktop/merger/Faculty.xlsx")
> View(Faculty)
View(dept)
head(dept)
m1=merge(Data,Dept,by="Dept. Code")
library(devtools)
library(rpivotTable)
pivot2=read.csv("tab3.csv",header=TRUE)
-----------------------------------------------------------------------------------
-----------------------
different file format
-----------------------------------------------------------------------------------
---------------------
for importing txt file
> m4=merge(data2,states,by="Store")
>write.csv(m4, file = "tab5.csv")
library(rpivotTable)
pivot3=read.csv("tab5.csv",header=TRUE)