problem-3.3
problem-3.3
We can tabulate the coins then multiply by the amounts to find
the total amount of money in the change bin.
> table(coins$value)
0.01 0.05 0.1 0.25
203 59 42 67
> table(coins$value) * c(0.01, 0.05, 0.1, 0.25)
0.01 0.05 0.1 0.25
2.03 2.95 4.20 16.75
> sum(table(coins$value) * c(0.01, 0.05, 0.1, 0.25))
[1] 25.58
The barplot can be produced with the command
> barplot(table(coins$year))
It shows a generally increasing trend, as it is more likely to contain
more recent coins. Finally, to get the coins by decade, a first
attempt would be to try
> table(cut(coins$year, breaks = seq(1920,2010,by=10)))
But this has ranges like 1921-1930. Using the argument
right=FALSE will cause the intervals to take the form
[a,b), for example, 1920-1929.