Link to dataset: CatfishFarm.xlsx
library(tidyr)
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(ggplot2)
library(reshape2)
##
## Attaching package: 'reshape2'
## The following object is masked from 'package:tidyr':
##
## smiths
CFData <- read.csv("CatfishFarm.csv")
colnames(CFData) = as.character(unlist(CFData[1,]))
CFData = CFData[-1,]
CFData = CFData[-7:-8,]
CFData
## Size category 1992 1993 1994 1995 1996 1997
## 2 Broodfish 1/ 1,491 1,169 1,183 1,301 1,171 1,163
## 3 Fingerling/fry 2/ 849,412 669,491 648,628 724,693 823,397 873,457
## 4 Stockers 3/ 634,353 571,254 548,207 554,342 627,834 754,816
## 5 Small foodsize 4/ 166,731 153,600 134,314 138,160 156,297 178,448
## 6 Medium foodsize 5/ 70,495 61,894 48,851 59,159 64,858 84,725
## 7 Large foodsize 6/ 6,769 6,698 5,196 4,536 6,644 7,810
## 1998 1999 2000 2001 2002 2003 2004 2005
## 2 1,187 1,155 1,377 1,327 1,171 1,303 1,113 1,053
## 3 975,542 986,368 1,053,300 1,023,533 1,066,400 990,163 745,849 712,144
## 4 607,878 678,682 790,683 845,287 676,378 775,226 890,275 660,000
## 5 178,511 182,251 200,032 239,655 287,591 254,920 261,323 243,090
## 6 62,140 63,049 77,149 87,926 106,117 127,908 109,120 95,240
## 7 7,295 9,266 5,812 6,872 10,746 11,195 10,947 10,642
## 2006 2007 2008 2009 2010 2011 2012 2013
## 2 1,091 886 801 704 536 495 562 540
## 3 1,045,266 985,620 951,910 728,340 429,590 568,990 451,100 398,510
## 4 781,958 586,320 688,844 586,069 366,090 380,660 463,485 339,260
## 5 214,848 210,340 204,750 193,870 169,030 115,560 112,970 103,520
## 6 103,591 104,080 107,800 105,610 91,790 54,130 64,740 58,015
## 7 10,823 8,986 9,290 9,316 8,570 6,212 3,595 5,155
## 2014 2015 2016
## 2 650 577 520
## 3 420,060 449,510 328,570
## 4 289,080 248,790 204,800
## 5 102,190 96,810 100,850
## 6 50,600 48,220 45,775
## 7 4,500 5,090 3,520
To analyze data yearwise,we choose to use “Spread” function.
TSCFdata <- spread(TCFData,`Size category`,`Budget`)
TSCFdata <- data.frame(TSCFdata)
head(TSCFdata)
## Year Broodfish.1. Fingerling.fry.2. Large.foodsize.6. Medium.foodsize.5.
## 1 1992 1491 849412 6769 70495
## 2 1993 1169 669491 6698 61894
## 3 1994 1183 648628 5196 48851
## 4 1995 1301 724693 4536 59159
## 5 1996 1171 823397 6644 64858
## 6 1997 1163 873457 7810 84725
## Small.foodsize.4. Stockers.3.
## 1 166731 634353
## 2 153600 571254
## 3 134314 548207
## 4 138160 554342
## 5 156297 627834
## 6 178448 754816
TSCFdata <- na.omit(TSCFdata)
TSCFdata$Broodfish.1. <- as.numeric(gsub(",","",TSCFdata$Broodfish.1.))
TSCFdata$Fingerling.fry.2. <- as.numeric(gsub(",","",TSCFdata$Fingerling.fry.2.))
TSCFdata$Large.foodsize.6. <- as.numeric(gsub(",","",TSCFdata$Large.foodsize.6.))
TSCFdata$Medium.foodsize.5. <- as.numeric(gsub(",","",TSCFdata$Medium.foodsize.5.))
TSCFdata$Small.foodsize.4. <- as.numeric(gsub(",","",TSCFdata$Small.foodsize.4.))
TSCFdata$Stockers.3. <- as.numeric(gsub(",","",TSCFdata$Stockers.3.))
TSCFData1 <- mutate(TSCFdata,Total = rowSums(TSCFdata[,2:7]))
ggplot(TSCFData1,aes(x = reorder(Year,Total) , y = Total))+ geom_line(linetype = "dotted") + geom_point(shape = 20,size = 4) + ggtitle("Year wise comparison") + labs(x = "Year", y = "Total Inventory Amount",srt = 45)+ coord_flip()
## geom_path: Each group consists of only one observation. Do you need to
## adjust the group aesthetic?
