The tapply function takes three arguments and groups the first argument by the second argument to apply the third argument. It can be used to compute the average amount of iron sorted by high and low protein foods, by applying the mean function to the iron values after grouping them by the high protein variable. Running tapply on the USDA dataset's iron and high protein variables with the mean function calculates the average iron for foods with high and low protein.
The tapply function takes three arguments and groups the first argument by the second argument to apply the third argument. It can be used to compute the average amount of iron sorted by high and low protein foods, by applying the mean function to the iron values after grouping them by the high protein variable. Running tapply on the USDA dataset's iron and high protein variables with the mean function calculates the average iron for foods with high and low protein.
The tapply function takes three arguments and groups the first argument by the second argument to apply the third argument. It can be used to compute the average amount of iron sorted by high and low protein foods, by applying the mean function to the iron values after grouping them by the high protein variable. Running tapply on the USDA dataset's iron and high protein variables with the mean function calculates the average iron for foods with high and low protein.