Abhisek92

Q1.R

Oct 28th, 2021
903
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. library("openxlsx")
  2. library("ggplot2")
  3. library("stats")
  4.  
  5. df <- read.xlsx("Labour Market.xlsx")
  6. freq <- aggregate(df$Employment.Status, by=list(df$Employment.Status), FUN=length)
  7. # plot this
  8. g1 <- ggplot(freq, aes(x=Group.1, y=x)) + geom_bar(stat="identity") +
  9.     scale_x_continuous(breaks=seq(min(freq$Group.1), max(freq$Group.1), 1), name="Employment Status") +
  10.     scale_y_continuous(breaks=seq(0, max(freq$x) + 1, 5), name="Frequncy Distribution of Employment Status", expand = c(0, 0))
  11.  
  12.  
  13. ai <- df[c('AGE', 'Income', 'SEX')]
  14. aim = ai[ai$SEX == 1, ]
  15. aif = ai[ai$SEX == 2, ]
  16.  
  17. aim_g <- aggregate(aim$Income, by=list(aim$AGE), FUN=mean)
  18. aim_g <- aim_g[order(aim_g$Group.1), ]
  19. # plot this
  20. gm <- ggplot(aim_g, aes(x=Group.1, y=x)) + geom_line(stat="identity") + geom_point(stat="identity") +
  21.     scale_x_continuous(breaks=seq(min(aim_g$Group.1), max(aim_g$Group.1), 1), name="Age") +
  22.     scale_y_continuous(breaks=seq(0, max(aim_g$x) + 1, 100000), name="Income", expand = c(0, 0))
  23.  
  24. aif_g <- aggregate(aif$Income, by=list(aif$AGE), FUN=mean)
  25. aif_g <- aif_g[order(aif_g$Group.1), ]
  26. gf <- ggplot(aif_g, aes(x=Group.1, y=x)) + geom_line(stat="identity") + geom_point(stat="identity") +
  27.     scale_x_continuous(breaks=seq(min(aif_g$Group.1), max(aif_g$Group.1), 1), name="Age") +
  28.     scale_y_continuous(breaks=seq(0, max(aif_g$x) + 1, 100000), name="Income", expand=c(0, 0))
  29.  
  30. aix <- aggregate(ai$Income, by=list(ai$AGE), FUN=mean)
  31. aix <- aix[order(aix$Group.1), ]
  32. gx <- ggplot(aix, aes(x=Group.1, y=x)) + geom_line(stat="identity") + geom_point(stat="identity") +
  33.     scale_x_continuous(breaks=seq(min(aix$Group.1), max(aix$Group.1), 1), name="Age") +
  34.     scale_y_continuous(breaks=seq(min(aix$x), max(aix$x) + 1, 5), name="Income", expand=c(0, 0))
  35.  
  36. sd(df$Hours.worked.per.week)
  37. sd(df$Income)
  38.  
  39. gender_income <- aggregate(df$Income, by=list(aim$SEX), FUN=mean)
  40. gender_worktime <- aggregate(df$Length.of.time.at.job , by=list(aim$SEX), FUN=mean)
  41. gender_weeklyhours <- aggregate(df$Hours.worked.per.week, by=list(aim$SEX), FUN=mean)
  42. gender_schooling <- aggregate(df$Years.of.secondary.schooling, by=list(aim$SEX), FUN=mean)
  43.  
  44.  
RAW Paste Data