Error in as.data.frame.default(data, optional = TRUE) : cannot coerce class ‘"function"’ to a data.frame

I have a dataframe.When i try to use aggregate function on the df using few columns,i get error as cannot coerce class ‘"function"’ to a data.frame.I have used dataframe and aggregate functions on the same earlier also but have never got this error earlier.

str(promax_final_data)
tibble [80,634 x 9] (S3: grouped_df/tbl_df/tbl/data.frame)
 $ Date        : Date[1:80634], format: "2020-01-01" "2020-01-01" "2020-01-01" ...
 $ IP.Address  : chr [1:80634] "10.240.57.153:50945" "10.240.57.153:51058" "10.240.57.153:51089" "10.240.57.153:51165" ...
 $ UserName    : chr [1:80634] "Grace.Teh" "Grace.Teh" "Grace.Teh" "Grace.Teh" ...
 $ Machine.ID  : chr [1:80634] "SGPPBU-L-96595" "SGPPBU-L-96595" "SGPPBU-L-96595" "SGPPBU-L-96595" ...
 $ Region      : chr [1:80634] "SGPP" "SGPP" "SGPP" "SGPP" ...
 $ month       : chr [1:80634] "Jan" "Jan" "Jan" "Jan" ...
 $ Quarter     : chr [1:80634] "Q1" "Q1" "Q1" "Q1" ...
 $ Year        : num [1:80634] 2020 2020 2020 2020 2020 2020 2020 2020 2020 2020 ...
 $ sum_as_hours: num [1:80634] 54 18 18 18.1 18.2 ...
 - attr(*, "groups")= tibble [80,634 x 8] (S3: tbl_df/tbl/data.frame)
  ..$ Date      : Date[1:80634], format: "2020-01-01" "2020-01-01" ...
  ..$ IP.Address: chr [1:80634] "10.240.57.153:50945" "10.240.57.153:51058" "10.240.57.153:51089" "10.240.57.153:51165" ...
  ..$ UserName  : chr [1:80634] "Grace.Teh" "Grace.Teh" "Grace.Teh" "Grace.Teh" ...
  ..$ Machine.ID: chr [1:80634] "SGPPBU-L-96595" "SGPPBU-L-96595" "SGPPBU-L-96595" "SGPPBU-L-96595" ...
  ..$ Region    : chr [1:80634] "SGPP" "SGPP" "SGPP" "SGPP" ...
  ..$ month     : chr [1:80634] "Jan" "Jan" "Jan" "Jan" ...
  ..$ Quarter   : chr [1:80634] "Q1" "Q1" "Q1" "Q1" ...
  ..$ .rows     : list<int> [1:80634] 
  .. ..$ : int 1
  .. ..$ : int 2
  .. ..$ : int 3
  .. ..$ : int 4
  .. ..$ : int 5
  .. ..$ : int 6
  .. ..$ : int 7
  .. ..$ : int 8
  .. ..$ : int 9
  .. ..$ : int 10
  .. ..$ : int 11
  .. ..$ : int 12
  .. ..$ : int 13
  .. ..$ : int 14
  .. ..$ : int 15
  .. ..$ : int 16
  .. ..$ : int 17
  .. ..$ : int 18
  .. ..$ : int 19
  .. ..$ : int 20
  .. ..$ : int 21
  .. ..$ : int 22
  .. ..$ : int 23
  .. ..$ : int 24
  .. ..$ : int 25
  .. ..$ : int 26
  .. ..$ : int 27
  .. ..$ : int 28
  .. ..$ : int 29
  .. ..$ : int 30
  .. ..$ : int 31
  .. ..$ : int 32
  .. ..$ : int 33
  .. ..$ : int 34
  .. ..$ : int 35
  .. ..$ : int 36
  .. ..$ : int 37
  .. ..$ : int 38
  .. ..$ : int 39
  .. ..$ : int 40
  .. ..$ : int 41
  .. ..$ : int 42
  .. ..$ : int 43
  .. ..$ : int 44
  .. ..$ : int 45
  .. ..$ : int 46
  .. ..$ : int 47
  .. ..$ : int 48
  .. ..$ : int 49
  .. ..$ : int 50
  .. ..$ : int 51
  .. ..$ : int 52
  .. ..$ : int 53
  .. ..$ : int 54
  .. ..$ : int 55
  .. ..$ : int 56
  .. ..$ : int 57
  .. ..$ : int 58
  .. ..$ : int 59
  .. ..$ : int 60
  .. ..$ : int 61
  .. ..$ : int 62
  .. ..$ : int 63
  .. ..$ : int 64
  .. ..$ : int 65
  .. ..$ : int 66
  .. ..$ : int 67
  .. ..$ : int 68
  .. ..$ : int 69
  .. ..$ : int 70
  .. ..$ : int 71
  .. ..$ : int 72
  .. ..$ : int 73
  .. ..$ : int 74
  .. ..$ : int 75
  .. ..$ : int 76
  .. ..$ : int 77
  .. ..$ : int 78
  .. ..$ : int 79
  .. ..$ : int 80
  .. ..$ : int 81
  .. ..$ : int 82
  .. ..$ : int 83
  .. ..$ : int 84
  .. ..$ : int 85
  .. ..$ : int 86
  .. ..$ : int 87
  .. ..$ : int 88
  .. ..$ : int 89
  .. ..$ : int 90
  .. ..$ : int 91
  .. ..$ : int 92
  .. ..$ : int 93
  .. ..$ : int 94
  .. ..$ : int 95
  .. ..$ : int 96
  .. ..$ : int 97
  .. ..$ : int 98
  .. ..$ : int 99
  .. .. [list output truncated]
  .. ..@ ptype: int(0) 
  ..- attr(*, ".drop")= logi TRUE

min_usage_hours_per_quarter<-aggregate(promax_final_data$sum_as_hours~promax_final_data$Quarter,min)

Error in as.data.frame.default(data, optional = TRUE) : 
  cannot coerce class ‘"function"’ to a data.frame

try

aggregate(formula=sum_as_hours~Quarter,
           data=promax_final_data,
           FUN=min)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.