r - tapply function complains that args are unequal length yet they appear to match -
Some display to show the failed call, error message, and length in question:
& Lt; - tapply (molten $ activity, molten $ theme, molten $ variable), meanwhile error in # tapply (molten, c (molten $ activity, molten $ theme, molten $ variable) ) ,: The length of the length of the argument (molten $ activity) # [1] 679734 length (molten $ theme) # [1] 679734 Length (molten $ variable) # [1] 679734 Dim (molten) # [1] 679734 4 str (molten) # 'data.frame': 679734 Object of 4 variables: # $ Activity: Factor W / 6 level "Walking", "Walking_UPSTAIRS", ..: 5 5 5 5 5 5 5 5 5 ... # $ Theme: Factor w / 30 Level "1", "2", "3", "4", ..: 2 2 2 2 2 2 2 2 2 2 ... # $ variable: factor w / 66 level "TBDACC-finance () - X", ..: 1 1 1 1 1 1 1 1 1 1 1 ... # $ Price: Number 0.257 0.286 0.275 0.27 0.275 ...
if you have ? Tapply If you have a look, you will see that X is "a nuclear object, especially a vector" you feed tapply with the data frame ("molten"), Which is not a nuclear object, see is.atomic and try is.atomic (molten) . In addition, your grouping variables must be provided in the form of the list (see as the INDEX argument). Something works:
tapply (X = warpbreaks $ breaks, INDEX = list (warpbreaks $ wool, warpbreaks $ stress), mean) # LMH # A 44.55556 24.00000 24.55556 # B 28.22222 28.77778 18.77778
Comments
Post a Comment