SHARE
TWEET

Untitled

a guest Jun 18th, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #Here's a look at the data(cpt1). All the dates follow the following format "%Y-%m-01"
  2.      Cash         Date           isic                          
  3. 1   373165     2014-06-01         K
  4. 2   373165     2014-12-01         K
  5. 3   373165     2017-09-01         K
  6. 4   NA             <NA>           K
  7. 5   4789       2015-05-01         K
  8. 6   982121     2013-07-01         K
  9.                  .
  10.                  .
  11.                  .
  12. #I was able to group to group them by sector and sum them
  13. cpt_by_sector=cpt1 %>% mutate(sector=recode_factor(isic,                                                                          
  14.      'A'='Agriculture','B'='Industry','C'='Industry','D'='Industry',
  15.      'E'='Industry','F'='Industry')) %>%
  16.   group_by(sector) %>% summarise_if(is.numeric, sum, na.rm=T)
  17. #here's the result
  18.    sector         `Cash`
  19.     <fct>         <dbl>            
  20. 1 Agriculture   2094393819.
  21. 2 Industry     53699068183.
  22. 3 Services     223995196357.
  23.  
  24. #Below is what I would like to get. I would like to take into account the fiscal year i.e. from july to june.  
  25. Sector      `2009/10` `2010/11` `2011/12` `2012/13` `2013/14` `2014/15` `2015/16` `2016/17`
  26. <chr>        <dbl>     <dbl>     <dbl>     <dbl>     <dbl>     <dbl>     <dbl>     <dbl>
  27. 1 Agriculture 2.02     3.62      3.65      6.26      7.04      8.36      11.7      11.6
  28. 2 Industry   87.8      117.      170.      163.      185.      211.       240.      252.
  29. 3 Services   271.      343.      479.      495.      584.      664.       738.      821.
  30. 4 Total      361.      464.      653.      664.      776.      883.       990.     1085.
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top