My first attempt was to plot data from Forbes 1000 list (refer to the exercise posted by Prasoon sharma)
Here is a bubble chart showing Forbes top 25 companies by Market Capitalization
Source code:
## read the csv file FORBES.DF <- read.csv("forbes2000list_for_2011.csv") ## assign titles names(FORBES.DF)<- c("Rank", "Company", "Country", "Industry", "Sales", "Profits", "Assets", "MarketCap") ## create a smaller vector Forbes100ByMC <- FORBES.DF[order(-FORBES.DF$MarketCap),][1:100,] Forbes25 <- Forbes100ByMC[1:25, ] ## plot the bubble chart using 'symbols' radius <- sqrt(Forbes25$MarketCap/pi) sales <- as.numeric(as.character(Forbes25$Sales)) profits <- as.numeric(as.character(Forbes25$Profits)) symbols(sales, profits, circles=radius, inches=0.9, fg="white", bg="light blue", xlab="Sales($'Billions)", ylab="Profits($'Billions)", main="Forbes 25 By Market Capitalization", xlim=c(min(range(sales))-50, max(range(sales))+50), ylim=c(min(range(profits))-2, max(range(profits))+2)) ## print the names of companies text(sales, profits, Forbes25$Company, cex=0.6, col="dark red")
Any feedback toward writting better 'R' code is welcome.