I have been using this in order to get the proportion of counts for each class for two groups but am not getting the right results.
It must be the proportion of vegclas within each density and not the overall proportion of the total count.
veg %>%
  group_by(density,vegclas) %>%
  summarise(total.count=n(),
                 avg=total.count/count(veg)*100)
Result:
Source: local data frame [12 x 4]
Groups: density [?]
   density vegclas total.count      avg
    (fctr)  (fctr)       (int)    (chr)
1        H       1        1201 <dbl[1]>
2        H       2        1258 <dbl[1]>
3        H       3         162 <dbl[1]>
4        H       4        4745 <dbl[1]>
5        H       5        2807 <dbl[1]>
6        H       6         114 <dbl[1]>
7        L       1        1109 <dbl[1]>
8        L       2         469 <dbl[1]>
9        L       3          56 <dbl[1]>
10       L       4        1701 <dbl[1]>
11       L       5         691 <dbl[1]>
12       L       6         204 <dbl[1]>
Edit:
Using the length(veg) gave my this:
   density vegclas total.count      avg
    (fctr)  (fctr)       (int)    (dbl)
1        H       1        1201  7506.25
2        H       2        1258  7862.50
3        H       3         162  1012.50
4        H       4        4745 29656.25
5        H       5        2807 17543.75
6        H       6         114   712.50
7        L       1        1109  6931.25
8        L       2         469  2931.25
9        L       3          56   350.00
10       L       4        1701 10631.25
11       L       5         691  4318.75
12       L       6         204  1275.00
 
     
    