This is an R Markdown Notebook. When you execute code within the notebook, the results appear beneath the code.
Try executing this chunk by clicking the Run button within the chunk or by placing your cursor inside it and pressing Ctrl+Shift+Enter.
library(readxl)
library(ggplot2)
competitors <- read_excel("C:/My Work/Data Analytics/Data sets/Biocom_Comp_Ana.xlsx")
names(competitors)<-c("company_name","year","sales","sales_per_change","opm","net_profit",
"net_profit_per_change","npm","eps","ceps")
head(competitors)
ggplot(competitors, aes(x=competitors$sales, y=competitors$company_name)) + geom_boxplot()
competitors<-na.omit(competitors)
competitors$sales_per_change<- substr(competitors$sales_per_change, start = 1, stop = 4)
class(competitors$sales_per_change)<-"numeric"
summary(competitors)
company_name year sales sales_per_change opm
Length:193 Min. :2013 Min. : 14.37 Min. :-9.8000 Min. :-0.1143
Class :character 1st Qu.:2014 1st Qu.: 273.26 1st Qu.: 0.1300 1st Qu.: 0.1073
Mode :character Median :2014 Median : 1003.76 Median : 0.2100 Median : 0.1395
Mean :2015 Mean : 2702.35 Mean : 0.9921 Mean : 0.1506
3rd Qu.:2015 3rd Qu.: 2862.19 3rd Qu.: 0.5400 3rd Qu.: 0.1862
Max. :2016 Max. :28487.03 Max. :12.4000 Max. : 0.4220
net_profit net_profit_per_change npm eps ceps
Min. : 0.24 Min. : -0.9896 Min. :0.0008 Min. : -4.95 Min. :-20.19
1st Qu.: 15.93 1st Qu.: -0.0325 1st Qu.:0.0508 1st Qu.: 5.34 1st Qu.: 10.14
Median : 77.25 Median : 0.2113 Median :0.0905 Median : 14.21 Median : 22.48
Mean : 397.94 Mean : 0.9805 Mean :0.1030 Mean : 22.33 Mean : 31.10
3rd Qu.: 376.15 3rd Qu.: 0.5264 3rd Qu.:0.1443 3rd Qu.: 32.16 3rd Qu.: 44.71
Max. :5656.86 Max. :100.8496 Max. :0.3092 Max. :145.61 Max. :180.58
data<-data.frame(aggregate(. ~ year, data=competitors[competitors$company_name!='Biocon',][,2:10], FUN=sum))
data[data$year=='2013',][,2:9]<-data[data$year=='2013',][,2:9]/(nrow(competitors[competitors$year=='2013',]))
data[data$year=='2014',][,2:9]<-data[data$year=='2014',][,2:9]/(nrow(competitors[competitors$year=='2014',]))
data[data$year=='2015',][,2:9]<-data[data$year=='2015',][,2:9]/(nrow(competitors[competitors$year=='2015',]))
data[data$year=='2016',][,2:9]<-data[data$year=='2016',][,2:9]/(nrow(competitors[competitors$year=='2016',]))
data<-cbind('TOTAL',data)
names(data)[1]<-"company_name"
data<-rbind(data
,competitors[competitors$company_name=="Biocon",])
data
Add a new chunk by clicking the Insert Chunk button on the toolbar or by pressing Ctrl+Alt+I.
When you save the notebook, an HTML file containing the code and output will be saved alongside it (click the Preview button or press Ctrl+Shift+K to preview the HTML file).