/ Python And R Data science skills: 08 sample program for analysis R language telugu

Thursday 19 April 2018

08 sample program for analysis R language telugu

----------------------------------------------------------
#Data
revenue <- c(14574.49, 7606.46, 8611.41, 9175.41, 8058.65, 8105.44, 11496.28, 9766.09, 10305.32, 14379.96, 10713.97, 15433.50)
expenses <- c(12051.82, 5695.07, 12319.20, 12089.72, 8658.57, 840.20, 3285.73, 5821.12, 6976.93, 16618.61, 10054.37, 3803.96)
revenue
# profit for each month
profit<-revenue-expenses

# profit after tax for each month (the tax rate is 30%)
tax<-profit*0.3
tax
pat<-profit-tax
pat
# profit margin for each month - equals to profit a after tax divided by revenue
pmem<-round(pat/revenue,2)*100
?round
#pmem1<-round(pmem,2)
pmem


# good months - where the profit after tax was greater than the mean for the year
x<-mean(pat)
x
goodmonths<- pat>x
goodmonths
#bad months - where the profit after tax was less than the mean for the year

badmonths<- pat<x
badmonths
# the best month - where the profit after tax was max for the year
bestmonth<-pat==max(pat)
bestmonth
pat
# the worst month - where the profit after tax was min for the year
worstmonth<-pat==min(pat)
worstmonth
############
revenue1<-(round(revenue/1000,0))
expenses1<-(round(expenses/1000,0))
profit1<-(round(profit/1000,0))
pat1<-(round(pat/1000,0))
revenue1
expenses1
profit1
pat1
pmem
goodmonths
badmonths
bestmonth
worstmonth
m<-rbind(
  revenue1,
  expenses1,
  profit1,
  pat1,
  pmem,
  goodmonths,
  badmonths,
  bestmonth,
  worstmonth
)
m

No comments:

Post a Comment