# - - - - - - - - - - - - - - - # # add fama french 12 industry number and name of industry # defintions obtained from Ken French's Website: #https://mba.tuck.dartmouth.edu/pages/faculty/ken.french/Data_Library/det_12_ind_port.html # modifed by: Jeff L. McMullin on 18-DEC-2020 # Use at your own risk. No warranties implied. # - - - - - - - - - - - - - - - # temp<-dataframe_with_SIC4 temp$FF_IND_12_num <- 12 temp$FF_IND_12 <- "Other" #1 NoDur Consumer NonDurables -- Food, Tobacco, Textiles, Apparel, Leather, Toys; temp$FF_IND_12_num <- ifelse((temp$SIC4 >= 0100) & (temp$SIC4 <= 0999),1,temp$FF_IND_12_num) temp$FF_IND_12_num <- ifelse((temp$SIC4 >= 2000) & (temp$SIC4 <= 2399),1,temp$FF_IND_12_num) temp$FF_IND_12_num <- ifelse((temp$SIC4 >= 2700) & (temp$SIC4 <= 2749),1,temp$FF_IND_12_num) temp$FF_IND_12_num <- ifelse((temp$SIC4 >= 2770) & (temp$SIC4 <= 2799),1,temp$FF_IND_12_num) temp$FF_IND_12_num <- ifelse((temp$SIC4 >= 3100) & (temp$SIC4 <= 3199),1,temp$FF_IND_12_num) temp$FF_IND_12_num <- ifelse((temp$SIC4 >= 3940) & (temp$SIC4 <= 3989),1,temp$FF_IND_12_num) temp$FF_IND_12 <- ifelse(temp$FF_IND_12_num == 1,"NoDur",temp$FF_IND_12) #2 Durbl Consumer Durables -- Cars, TVs, Furniture, Household Appliances; temp$FF_IND_12_num <- ifelse((temp$SIC4 >= 2500) & (temp$SIC4 <= 2519),2,temp$FF_IND_12_num) temp$FF_IND_12_num <- ifelse((temp$SIC4 >= 2590) & (temp$SIC4 <= 2599),2,temp$FF_IND_12_num) temp$FF_IND_12_num <- ifelse((temp$SIC4 >= 3630) & (temp$SIC4 <= 3659),2,temp$FF_IND_12_num) temp$FF_IND_12_num <- ifelse((temp$SIC4 >= 3710) & (temp$SIC4 <= 3711),2,temp$FF_IND_12_num) temp$FF_IND_12_num <- ifelse((temp$SIC4 >= 3714) & (temp$SIC4 <= 3714),2,temp$FF_IND_12_num) temp$FF_IND_12_num <- ifelse((temp$SIC4 >= 3716) & (temp$SIC4 <= 3716),2,temp$FF_IND_12_num) temp$FF_IND_12_num <- ifelse((temp$SIC4 >= 3750) & (temp$SIC4 <= 3751),2,temp$FF_IND_12_num) temp$FF_IND_12_num <- ifelse((temp$SIC4 >= 3792) & (temp$SIC4 <= 3792),2,temp$FF_IND_12_num) temp$FF_IND_12_num <- ifelse((temp$SIC4 >= 3900) & (temp$SIC4 <= 3939),2,temp$FF_IND_12_num) temp$FF_IND_12_num <- ifelse((temp$SIC4 >= 3990) & (temp$SIC4 <= 3999),2,temp$FF_IND_12_num) temp$FF_IND_12 <- ifelse(temp$FF_IND_12_num == 2,"Durbl",temp$FF_IND_12) # 3 Manuf Manufacturing -- Machinery, Trucks, Planes, Off Furn, Paper, Com Printing; temp$FF_IND_12_num <- ifelse((temp$SIC4 >= 2520) & (temp$SIC4 <= 2589),3,temp$FF_IND_12_num) temp$FF_IND_12_num <- ifelse((temp$SIC4 >= 2600) & (temp$SIC4 <= 2699),3,temp$FF_IND_12_num) temp$FF_IND_12_num <- ifelse((temp$SIC4 >= 2750) & (temp$SIC4 <= 2769),3,temp$FF_IND_12_num) temp$FF_IND_12_num <- ifelse((temp$SIC4 >= 3000) & (temp$SIC4 <= 3099),3,temp$FF_IND_12_num) temp$FF_IND_12_num <- ifelse((temp$SIC4 >= 3200) & (temp$SIC4 <= 3569),3,temp$FF_IND_12_num) temp$FF_IND_12_num <- ifelse((temp$SIC4 >= 3580) & (temp$SIC4 <= 3629),3,temp$FF_IND_12_num) temp$FF_IND_12_num <- ifelse((temp$SIC4 >= 3700) & (temp$SIC4 <= 3709),3,temp$FF_IND_12_num) temp$FF_IND_12_num <- ifelse((temp$SIC4 >= 3712) & (temp$SIC4 <= 3713),3,temp$FF_IND_12_num) temp$FF_IND_12_num <- ifelse((temp$SIC4 >= 3715) & (temp$SIC4 <= 3715),3,temp$FF_IND_12_num) temp$FF_IND_12_num <- ifelse((temp$SIC4 >= 3717) & (temp$SIC4 <= 3749),3,temp$FF_IND_12_num) temp$FF_IND_12_num <- ifelse((temp$SIC4 >= 3752) & (temp$SIC4 <= 3791),3,temp$FF_IND_12_num) temp$FF_IND_12_num <- ifelse((temp$SIC4 >= 3793) & (temp$SIC4 <= 3799),3,temp$FF_IND_12_num) temp$FF_IND_12_num <- ifelse((temp$SIC4 >= 3830) & (temp$SIC4 <= 3839),3,temp$FF_IND_12_num) temp$FF_IND_12_num <- ifelse((temp$SIC4 >= 3860) & (temp$SIC4 <= 3899),3,temp$FF_IND_12_num) temp$FF_IND_12 <- ifelse(temp$FF_IND_12_num == 3,"Manuf",temp$FF_IND_12) # 4 Enrgy Oil, Gas, and Coal Extraction and Products; temp$FF_IND_12_num <- ifelse((temp$SIC4 >= 1200) & (temp$SIC4 <= 1399),4,temp$FF_IND_12_num) temp$FF_IND_12_num <- ifelse((temp$SIC4 >= 2900) & (temp$SIC4 <= 2999),4,temp$FF_IND_12_num) temp$FF_IND_12 <- ifelse(temp$FF_IND_12_num == 4,"Enrgy",temp$FF_IND_12) # 5 Chems Chemicals and Allied Products; temp$FF_IND_12_num <- ifelse((temp$SIC4 >= 2800) & (temp$SIC4 <= 2829),5,temp$FF_IND_12_num) temp$FF_IND_12_num <- ifelse((temp$SIC4 >= 2840) & (temp$SIC4 <= 2899),5,temp$FF_IND_12_num) temp$FF_IND_12 <- ifelse(temp$FF_IND_12_num == 5,"Chems",temp$FF_IND_12) # 6 BusEq Business Equipment -- Computers, Software, and Electronic Equipment; temp$FF_IND_12_num <- ifelse((temp$SIC4 >= 3570) & (temp$SIC4 <= 3579),6,temp$FF_IND_12_num) temp$FF_IND_12_num <- ifelse((temp$SIC4 >= 3660) & (temp$SIC4 <= 3692),6,temp$FF_IND_12_num) temp$FF_IND_12_num <- ifelse((temp$SIC4 >= 3694) & (temp$SIC4 <= 3699),6,temp$FF_IND_12_num) temp$FF_IND_12_num <- ifelse((temp$SIC4 >= 3810) & (temp$SIC4 <= 3829),6,temp$FF_IND_12_num) temp$FF_IND_12_num <- ifelse((temp$SIC4 >= 7370) & (temp$SIC4 <= 7379),6,temp$FF_IND_12_num) temp$FF_IND_12 <- ifelse(temp$FF_IND_12_num == 6,"BusEq",temp$FF_IND_12) # 7 Telcm Telephone and Television Transmission; temp$FF_IND_12_num <- ifelse((temp$SIC4 >= 4800) & (temp$SIC4 <= 4899),7,temp$FF_IND_12_num) temp$FF_IND_12 <- ifelse(temp$FF_IND_12_num == 7,"Telcm",temp$FF_IND_12) # 8 Utils Utilities; temp$FF_IND_12_num <- ifelse((temp$SIC4 >= 4900) & (temp$SIC4 <= 4949),8,temp$FF_IND_12_num) temp$FF_IND_12 <- ifelse(temp$FF_IND_12_num == 8,"Utils",temp$FF_IND_12) # 9 Shops Wholesale, Retail, and Some Services (Laundries, Repair Shops); temp$FF_IND_12_num <- ifelse((temp$SIC4 >= 5000) & (temp$SIC4 <= 5999),9,temp$FF_IND_12_num) temp$FF_IND_12_num <- ifelse((temp$SIC4 >= 7200) & (temp$SIC4 <= 7299),9,temp$FF_IND_12_num) temp$FF_IND_12_num <- ifelse((temp$SIC4 >= 7600) & (temp$SIC4 <= 7699),9,temp$FF_IND_12_num) temp$FF_IND_12 <- ifelse(temp$FF_IND_12_num == 9,"Shops",temp$FF_IND_12) #10 Hlth Healthcare, Medical Equipment, and Drugs; temp$FF_IND_12_num <- ifelse((temp$SIC4 >= 2830) & (temp$SIC4 <= 2839),10,temp$FF_IND_12_num) temp$FF_IND_12_num <- ifelse((temp$SIC4 >= 3693) & (temp$SIC4 <= 3693),10,temp$FF_IND_12_num) temp$FF_IND_12_num <- ifelse((temp$SIC4 >= 3840) & (temp$SIC4 <= 3859),10,temp$FF_IND_12_num) temp$FF_IND_12_num <- ifelse((temp$SIC4 >= 8000) & (temp$SIC4 <= 8099),10,temp$FF_IND_12_num) temp$FF_IND_12 <- ifelse(temp$FF_IND_12_num == 10,"Hlth",temp$FF_IND_12) #11 Money Finance: temp$FF_IND_12_num <- ifelse((temp$SIC4 >= 6000) & (temp$SIC4 <= 6999),11,temp$FF_IND_12_num) temp$FF_IND_12 <- ifelse(temp$FF_IND_12_num == 11,"Money",temp$FF_IND_12) dataframe_with_SIC4_and_FF12 <- temp table(dataframe_with_SIC4_and_FF12$FF_IND_12) table(dataframe_with_SIC4_and_FF12$FF_IND_12_num)