ncols_by_variable: Number of columns for each variable in data

Description Usage Arguments Details Value Examples

Description

Count the number of columns for each variable found in Excel data file

Usage

1

Arguments

data.xls

is the output data frame from xls_read

Details

This function is used to check whether the number of columns in each variable in the Excel file are the same for the same data type (1 or 2). It used as input the output of the function xls_read. This identifies non-standard files of data arrangement.

Value

data frame

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
## Not run: 
if(interactive()){
library(stringr)
xfiles_l <- list.files("vignettes/dvd_xls_files", recursive = TRUE, full.names = TRUE)
fpath <- basename(xfiles_l)
length(xfiles_l)
# select file 2
sel <- str_detect(fpath, ".*_(\\S|\\s)\\.xls\\.xls") |
  str_detect(fpath, ".*[:punct:]_\\.xls") |
  str_detect(fpath, ".*[A-z]{1}_\\.xls\\.xls") |
  str_detect(fpath, ".*[A-z]{1}_V\\.xls\\.xls")
length(xfiles_l[sel])
# verficação dos arquivos 2 (outras variáveis)
data_l <- lapply(xfiles_l[sel], function(ifile) xls_read(file.xls = ifile))
# check num od columns by variable
ncol_vars <- plyr::ldply(l, function(x) {
  cat(attr(x, "meta")[["id"]], "\n")
  ncols_by_variable(x)
})
head(ncol_vars)
 }

## End(Not run)

lhmet/rinmetxls documentation built on May 28, 2019, 11:33 a.m.