Home > Software engineering >  How to Check which type of data type can a function takes in R
How to Check which type of data type can a function takes in R

Time:10-16

I know that collapse::fmean function can be applied to data.frames as well as a single vector. But is there any way to check the kind of data a function accept in R?

collapse::fmean(mtcars)
#>        mpg        cyl       disp         hp       drat         wt       qsec 
#>  20.090625   6.187500 230.721875 146.687500   3.596562   3.217250  17.848750 
#>         vs         am       gear       carb 
#>   0.437500   0.406250   3.687500   2.812500
collapse::fmean(mtcars$mpg)
#> [1] 20.09062

Created on 2022-10-15 by the enter image description here

As you can see in the last line, in this case it is clearly specified what kind of data is accepted for variable x.

  •  Tags:  
  • r
  • Related