0

I'd like to have fixed length/dimensions vectors/matrices in R. Pseudocode:

foo <- fixed_character(LETTERS, length = 26)
foo <- LETTERS[1:10] # throws an error, wrong length

bar <- fixed_matrix(NA, 6, 2)
bar <- matrix(1:12, 3, 4) # wrong dimensions

This would be useful for catching errors and writing robust code. Are there any packages on CRAN that do this?

Steffen Moritz
  • 7,277
  • 11
  • 36
  • 55
dash2
  • 2,024
  • 6
  • 15

1 Answers1

0

I recalled that the rtype system allows you to check the dimensions of vectors and data frames on assignment. The vctrs package also seems relevant.

dash2
  • 2,024
  • 6
  • 15