Taking the Grunfeld data, which is built-in in R, for example,

(1)How can I construct a dataset (or dataframe) that consists of the data
of all firms in 1951?

(2)How can I calculate the average capital in each form over the period
1951-1954?
What I can imagine is to categorize the data by firm, and then select the
data between 1951 and 1954 for each firm, but how can I do it?

Thanks,

Miao

Grunfeld data:
  invest value capital firm year  317.6 3078.5 2.8 General Motors 1935
391.8 4661.7 52.6 General Motors 1936  410.6 5387.1 156.9 General Motors
1937  257.7 2792.2 209.2 General Motors 1938  330.8 4313.2 203.4 General
Motors 1939  461.2 4643.9 207.2 General Motors 1940  512 4551.2 255.2 General
Motors 1941  448 3244.1 303.7 General Motors 1942  499.6 4053.7 264.1 General
Motors 1943  547.5 4379.3 201.6 General Motors 1944  561.2 4840.9 265 General
Motors 1945  688.1 4900.9 402.2 General Motors 1946  568.9 3526.5 761.5 General
Motors 1947  529.2 3254.7 922.4 General Motors 1948  555.1 3700.2
1020.1 General
Motors 1949  642.9 3755.6 1099 General Motors 1950  755.9 4833 1207.7 General
Motors 1951  891.2 4924.9 1430.5 General Motors 1952  1304.4 6241.7
1777.3 General
Motors 1953  1486.7 5593.6 2226.3 General Motors 1954  209.9 1362.4 53.8 US
Steel 1935  355.3 1807.1 50.5 US Steel 1936  469.9 2676.3 118.1 US Steel
1937  262.3 1801.9 260.2 US Steel 1938  230.4 1957.3 312.7 US Steel 1939
361.6 2202.9 254.2 US Steel 1940
...........

	[[alternative HTML version deleted]]

