Calcular casos possíveis.r 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. ## Calcular casos possíveis: Cria um .csv com as combinações possíveis para as variáveis
  2. ## Copyright (c) 2017, 2018 Adonay Felipe Nogueira <https://libreplanet.org/wiki/User:Adfeno>
  3. ## This program is free software: you can redistribute it and/or
  4. ## modify it under the terms of the GNU General Public License as
  5. ## published by the Free Software Foundation, version 3 of the
  6. ## License.
  7. ## This program is distributed in the hope that it will be useful, but
  8. ## WITHOUT ANY WARRANTY; without even the implied warranty of
  9. ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. ## General Public License for more details.
  11. ## You should have received a copy of the GNU General Public License
  12. ## along with this program. If not, see
  13. ## <https://www.gnu.org/licenses/>.
  14. args <- commandArgs(trailingOnly = TRUE)
  15. arquivo_de_saida_csv <- args[1]
  16. ## Cria as dimensões com três categorias.
  17. dimensoes <- lapply(1:14,
  18. function(x) {
  19. c(0, NA, 1)})
  20. ## Insere as dimensões com duas categorias.
  21. dimensoes <- append(dimensoes,
  22. list(0:1),
  23. 4)
  24. ## Define os nomes das dimensões, conforme as alíneas mencionadas na
  25. ## metodologia proposta..
  26. names(dimensoes) <- letters[1:length(dimensoes)]
  27. ## Escreve os casos possíveis em um arquivo CSV.
  28. write.csv(expand.grid(dimensoes),
  29. file = arquivo_de_saida_csv,
  30. na = "",
  31. row.names = FALSE)