Error in aggregate.data.frame : arguments must have same length

前端 未结 5 1602
我寻月下人不归
我寻月下人不归 2021-02-06 02:09

I keep getting this error and I\'m not quite sure what it means. All of my variable names are consistent and there are no typos. Am I missing something here?

The code

5条回答
  •  耶瑟儿~
    2021-02-06 02:58

    I used get this error.
    The simple solution to remove this error is to write all the variables along with their dataset name like "ds_name$var_name".
    I'm not sure what is the dataset name is your case, so I'll give you another similar example.

    curYearRev <-aggregate(hr$Year.Total, by = list(hr$Hospital_ID,hr$District_ID,hr$Instrument_ID) , FUN = sum)
    

    Here, "hr" is the dataset name and "Year.Total", "Hospital_ID", "District_ID", "Instrument_ID" are the variables in "hr" dataset.

    Writing aggregate functions in this way will never give you any errors again.

提交回复
热议问题