Dear All, I would like to to group the Ticker by Industry and create file names from the Industry Factor and export to a txt file.
I have tried the folowing ind=finvizAllexETF$Industry ind is then "Aluminum" "Business Services" "Regional Airlines" ind2=gsub(" " ,"",ind) ind3 [1] "Aluminum" "BusinessServices" "RegionalAirlines" > for (i in 1:3) ind3[i]<- AllexETF$Ticker[AllexETF$Industry==ind2[i]] Warning messages: 1: In ind3[i] <- finvizAllexETF$Ticker[AllexETF$Industry == ind2[i]] : number of items to replace is not a multiple of replacement length > str(AllexETF) 'data.frame': 5137 obs. of 11 variables: $ No. : int 1 2 3 4 5 6 7 8 9 10 ... $ Ticker : Factor w/ 5137 levels "A","AA","AAC",..: 1 2 3 4 5 6 7 8 9 10 ... $ Company : Factor w/ 5130 levels "012 Smile.Communications Ltd.",..: 127 158 33 437 141 148 459 25 23 87 ... $ Sector : Factor w/ 9 levels "Basic Materials",..: 8 1 7 4 7 6 4 7 6 7 ... $ Industry : Factor w/ 212 levels "Accident & Health Insurance",..: 175 8 27 43 160 4 105 168 77 16 ... $ Country : Factor w/ 51 levels "Argentina","Australia",..: 51 51 8 51 51 51 51 51 51 51 ... $ Market.Cap: num 10614.9 15229.56 6.35 185.38 734.64 ... $ P.E : num NA NA NA 24.2 NA ... $ Price : num 30.43 15.63 0.78 6.06 5.46 ... $ Change : Factor w/ 1119 levels "","-0.01%","-0.03%",..: 250 114 645 573 109 645 379 10 402 63 ... $ Volume : int 3309434 33389060 7600 42396 4406265 0 4837 447195 75997 738875 ... head(AllexETF) No. Ticker Company Sector Industry Country Market.Cap P.E Price Change Volume 1 1 A Agilent Technologies Inc. Technology Scientific & Technical Instruments USA 10614.90 NA 30.43 -2.31% 3309434 2 2 AA Alcoa, Inc. Basic Materials Aluminum USA 15229.56 NA 15.63 -1.14% 33389060 3 3 AAC Ableauctions.com Inc. Services Business Services Canada 6.35 NA 0.78 0.00% 7600 4 4 AACC Asset Acceptance Capital Corp. Financial Credit Services USA 185.38 24.24 6.06 -6.34% 42396 5 5 AAI AirTran Holdings Inc. Services Regional Airlines USA 734.64 NA 5.46 -1.09% 4406265 6 6 AAII Alabama Aircraft Industries, Inc Industrial Goods Aerospace/Defense Products & Services USA 5.58 NA 1.35 0.00% 0 Thanks in advance, Peter -- View this message in context: http://n4.nabble.com/Data-Manipulation-tp1018249p1018249.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.