79380333

Date: 2025-01-23 08:35:46
Score: 1
Natty:
Report link

vapply is similar to lapply but returns an atomic vector. For this reason, the return type of the function producing the elements of this vector must be specified because atomic vectors can only have one data type.

Vectors are the fundamental data type of R and so to specify a type in R, the length of the vector also needs to be specified. If the data type is a character type, then you need to set

FUN.VALUE = character(1)

which means that the data type of the vector is character vectors of one element. Without specifying the length, the default length is zero and vapply will return an error if the function returns a vector of non-zero length.

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Low reputation (1):
Posted by: SimonMaths