Problem 1

histogramma = function(x){
  hist(x, breaks = 2)
  abline(v = mean(x[!is.na(x)]),
       col = "red",
       lwd = 3)
  abline(v = median(x[!is.na(x)]),
       col = "blue",
       lwd = 3)
  legend(x = "topright",
  c("Mean", "Median"),
  col = c("red", "blue"),
  lwd = c(2, 2))
}

Problem 2

Problem 5

a)

b)

c)

Add sector (category variable) to the graph. You may need to merge all categories except for as less the 5 more common ones. Suggestion: Forbes2000$category is a factor. See previous suggestion.

Suggestions: * Including parameters fig.width and fig.height in chunk header in RMarkdown may increase the space available for the graphics. Example: {r fig.width=10, fig.height=8} * ggplot, geom_point and aestetics x, y, color and shape.

ggplot(data, aes(x = marketvalue, y = profits, shape = category, color = country)) +
  geom_point(size = 0.5)+
  xlim(-3, 50)+
  ylim(-10, 10) + labs(title = "Prettier scatterplot 5c")