I have a list of company names that I would like to include in the tickers. Here is the reproducible code to create a list of names that I have:
companynames=structure(list(V1 = structure(1:41, .Label = c("AETNA INC", "ANTHEM INC",
"APPLE INC", "ASPEN INSURANCE HOLDINGS LTD", "BARRICK GOLD CORP",
"BEST BUY CO INC", "CAREFUSION CORP", "CBS CORP-CLASS B NON VOTING",
"CIGNA CORP", "COMPUTER SCIENCES CORP", "COMPUWARE CORP", "COVENTRY HEALTH CARE INC",
"DELPHI AUTOMOTIVE PLC", "DST SYSTEMS INC", "EINSTEIN NOAH RESTAURANT GRO",
"ENSCO PLC-CL A", "EXPEDIA INC", "FIFTH STREET FINANCE CORP",
"GENERAL MOTORS CO", "GENWORTH FINANCIAL INC-CL A", "GREEN BRICK PARTNERS INC",
"HESS CORP", "HUMANA INC", "HUNTINGTON INGALLS INDUSTRIE", "LEGG MASON INC",
"MARKET VECTORS GOLD MINERS", "MARVELL TECHNOLOGY GROUP LTD",
"MICROSOFT CORP", "NCR CORPORATION", "NVR INC", "OAKTREE CAPITAL GROUP LLC",
"REPUBLIC AIRWAYS HOLDINGS IN", "SEAGATE TECHNOLOGY", "SPRINT COMMUNICATIONS INC",
"STARZ - A", "STATE BANK FINANCIAL CORP", "SYMMETRICOM INC",
"TESSERA TECHNOLOGIES INC", "UNITEDHEALTH GROUP INC", "VIRGIN MEDIA INC/OLD",
"XEROX CORP"), class = "factor")), .Names = "V1", class = "data.frame", row.names = c(NA,
-41L))
This gives me something like:
head(companynames)
V1
1 AETNA INC
2 ANTHEM INC
3 APPLE INC
4 ASPEN INSURANCE HOLDINGS LTD
5 BARRICK GOLD CORP
6 BEST BUY CO INC
I would like to receive one more column in which tickers of each of these companies will be placed. So for the first line I have to get AET, the second line will be ATHN, and the third line will be AAPL, etc. My example is in R, but any solution in python or R will be very useful. I'm not sure if there is already a function that does this, or how the best approach is to create a function if it does not exist.