├── .Rbuildignore ├── .gitignore ├── .travis.yml ├── CRAN-RELEASE ├── DESCRIPTION ├── NAMESPACE ├── NEWS.md ├── R ├── Reshape.R ├── Stacked.R ├── cSplit.R ├── concat.split.R ├── expandRows.R ├── getanID.R ├── listCol_l.R ├── listCol_w.R ├── splitstackshape-package.R ├── splitstackshape_helper_functions.R └── stratified.R ├── README.md ├── appveyor.yml ├── codecov.yml ├── cran-comments.md ├── data └── concatenated.RData ├── man ├── FacsToChars.Rd ├── Names.Rd ├── NoSep.Rd ├── Reshape.Rd ├── Stacked.Rd ├── cSplit.Rd ├── charMat.Rd ├── concat.split.Rd ├── concat.split.compact.Rd ├── concat.split.expanded.Rd ├── concat.split.list.Rd ├── concat.split.multiple.Rd ├── concat.test.Rd ├── expandRows.Rd ├── getanID.Rd ├── listCol_l.Rd ├── listCol_w.Rd ├── merged.stack.Rd ├── numMat.Rd ├── othernames.Rd ├── read.concat.Rd ├── splitstackshape-package.Rd └── stratified.Rd ├── revdep ├── README.md ├── check.R ├── checks.rds ├── checks │ ├── Diderot │ │ ├── Diderot_0.12.tar.gz │ │ ├── new │ │ │ ├── Diderot.Rcheck │ │ │ │ └── 00check.log │ │ │ └── libraries.txt │ │ └── old │ │ │ ├── Diderot.Rcheck │ │ │ └── 00check.log │ │ │ └── libraries.txt │ ├── MotifDb │ │ ├── MotifDb_1.24.1.tar.gz │ │ ├── new │ │ │ ├── MotifDb.Rcheck │ │ │ │ └── 00check.log │ │ │ └── libraries.txt │ │ └── old │ │ │ ├── MotifDb.Rcheck │ │ │ └── 00check.log │ │ │ └── libraries.txt │ ├── cnvGSA │ │ ├── cnvGSA_1.26.0.tar.gz │ │ ├── new │ │ │ ├── cnvGSA.Rcheck │ │ │ │ └── 00check.log │ │ │ └── libraries.txt │ │ └── old │ │ │ ├── cnvGSA.Rcheck │ │ │ └── 00check.log │ │ │ └── libraries.txt │ ├── libraries.csv │ ├── pinyin │ │ ├── new │ │ │ ├── libraries.txt │ │ │ └── pinyin.Rcheck │ │ │ │ ├── 00check.log │ │ │ │ ├── 00install.out │ │ │ │ ├── pinyin-Ex.R │ │ │ │ ├── pinyin-Ex.Rout │ │ │ │ └── pinyin-Ex.pdf │ │ ├── old │ │ │ ├── libraries.txt │ │ │ └── pinyin.Rcheck │ │ │ │ ├── 00check.log │ │ │ │ ├── 00install.out │ │ │ │ ├── pinyin-Ex.R │ │ │ │ ├── pinyin-Ex.Rout │ │ │ │ └── pinyin-Ex.pdf │ │ └── pinyin_1.1.5.tar.gz │ └── rodham │ │ ├── new │ │ ├── libraries.txt │ │ └── rodham.Rcheck │ │ │ ├── 00check.log │ │ │ ├── 00install.out │ │ │ ├── rodham-Ex.R │ │ │ ├── rodham-Ex.Rout │ │ │ ├── rodham-Ex.pdf │ │ │ └── tests │ │ │ ├── startup.Rs │ │ │ ├── testthat.R │ │ │ ├── testthat.Rout │ │ │ └── testthat │ │ │ └── test_all.R │ │ ├── old │ │ ├── libraries.txt │ │ └── rodham.Rcheck │ │ │ ├── 00check.log │ │ │ ├── 00install.out │ │ │ ├── rodham-Ex.R │ │ │ ├── rodham-Ex.Rout │ │ │ ├── rodham-Ex.pdf │ │ │ └── tests │ │ │ ├── startup.Rs │ │ │ ├── testthat.R │ │ │ ├── testthat.Rout │ │ │ └── testthat │ │ │ └── test_all.R │ │ └── rodham_0.1.1.tar.gz ├── data.sqlite ├── failures.md ├── library │ └── splitstackshape │ │ ├── new │ │ ├── data.table │ │ │ ├── DESCRIPTION │ │ │ ├── INDEX │ │ │ ├── LICENSE │ │ │ ├── Meta │ │ │ │ ├── Rd.rds │ │ │ │ ├── features.rds │ │ │ │ ├── hsearch.rds │ │ │ │ ├── links.rds │ │ │ │ ├── nsInfo.rds │ │ │ │ ├── package.rds │ │ │ │ └── vignette.rds │ │ │ ├── NAMESPACE │ │ │ ├── NEWS.md │ │ │ ├── R │ │ │ │ ├── data.table │ │ │ │ ├── data.table.rdb │ │ │ │ └── data.table.rdx │ │ │ ├── doc │ │ │ │ ├── datatable-benchmarking.Rmd │ │ │ │ ├── datatable-benchmarking.html │ │ │ │ ├── datatable-faq.R │ │ │ │ ├── datatable-faq.Rmd │ │ │ │ ├── datatable-faq.html │ │ │ │ ├── datatable-importing.Rmd │ │ │ │ ├── datatable-importing.html │ │ │ │ ├── datatable-intro.R │ │ │ │ ├── datatable-intro.Rmd │ │ │ │ ├── datatable-intro.html │ │ │ │ ├── datatable-keys-fast-subset.R │ │ │ │ ├── datatable-keys-fast-subset.Rmd │ │ │ │ ├── datatable-keys-fast-subset.html │ │ │ │ ├── datatable-reference-semantics.R │ │ │ │ ├── datatable-reference-semantics.Rmd │ │ │ │ ├── datatable-reference-semantics.html │ │ │ │ ├── datatable-reshape.R │ │ │ │ ├── datatable-reshape.Rmd │ │ │ │ ├── datatable-reshape.html │ │ │ │ ├── datatable-secondary-indices-and-auto-indexing.R │ │ │ │ ├── datatable-secondary-indices-and-auto-indexing.Rmd │ │ │ │ ├── datatable-secondary-indices-and-auto-indexing.html │ │ │ │ └── index.html │ │ │ ├── help │ │ │ │ ├── AnIndex │ │ │ │ ├── aliases.rds │ │ │ │ ├── data.table.rdb │ │ │ │ ├── data.table.rdx │ │ │ │ └── paths.rds │ │ │ ├── html │ │ │ │ ├── 00Index.html │ │ │ │ └── R.css │ │ │ ├── libs │ │ │ │ └── datatable.so │ │ │ └── tests │ │ │ │ ├── 1206FUT.txt │ │ │ │ ├── 1680-fread-header-encoding.csv │ │ │ │ ├── 2008head.csv │ │ │ │ ├── 530_fread.txt │ │ │ │ ├── 536_fread_fill_1.txt │ │ │ │ ├── 536_fread_fill_2.txt │ │ │ │ ├── 536_fread_fill_3_extreme.txt │ │ │ │ ├── 536_fread_fill_4.txt │ │ │ │ ├── SA2-by-DJZ.csv │ │ │ │ ├── allchar.csv.gz │ │ │ │ ├── alluniquechar.csv │ │ │ │ ├── bad.txt │ │ │ │ ├── benchmark.Rraw │ │ │ │ ├── ch11b.dat │ │ │ │ ├── colnames4096.csv │ │ │ │ ├── doublequote_newline.csv │ │ │ │ ├── fillheader.csv │ │ │ │ ├── fread_blank.txt │ │ │ │ ├── fread_blank2.txt │ │ │ │ ├── fread_blank3.txt │ │ │ │ ├── fread_line_error.csv │ │ │ │ ├── froll.Rraw │ │ │ │ ├── gb18030.txt │ │ │ │ ├── genotypes_genome.txt │ │ │ │ ├── grr.csv.gz │ │ │ │ ├── isoweek_test.csv │ │ │ │ ├── issue_1087_utf8_bom.csv │ │ │ │ ├── issue_1095_fread.txt │ │ │ │ ├── issue_1113_fread.txt │ │ │ │ ├── issue_1116_fread_few_lines.txt │ │ │ │ ├── issue_1116_fread_few_lines_2.txt │ │ │ │ ├── issue_1164_json.txt │ │ │ │ ├── issue_1330_fread.txt │ │ │ │ ├── issue_1462_fread_quotes.txt │ │ │ │ ├── issue_1573_fill.txt │ │ │ │ ├── issue_2051.csv │ │ │ │ ├── issue_2157_sampling_overlap.txt.gz │ │ │ │ ├── issue_2157_sampling_reached_eof_early.txt.bz2 │ │ │ │ ├── issue_563_fread.txt │ │ │ │ ├── issue_773_fread.txt │ │ │ │ ├── issue_785_fread.txt │ │ │ │ ├── iterations.txt │ │ │ │ ├── melt-warning-1752.tsv │ │ │ │ ├── melt_1754.R.gz │ │ │ │ ├── melt_1754_synth.csv │ │ │ │ ├── onecol4096.csv │ │ │ │ ├── other.Rraw │ │ │ │ ├── quoted_multiline.csv │ │ │ │ ├── quoted_no_header.csv │ │ │ │ ├── russellCRCRLF.csv │ │ │ │ ├── russellCRLF.csv │ │ │ │ ├── session_aborted_fatal_error.txt │ │ │ │ ├── test0.txt │ │ │ │ ├── test1372-1.Rdata │ │ │ │ ├── test1372.Rdata │ │ │ │ ├── tests-DESCRIPTION │ │ │ │ ├── tests.Rraw │ │ │ │ ├── unescaped.csv │ │ │ │ ├── utf16be.txt │ │ │ │ ├── utf16le.txt │ │ │ │ └── winallquoted.csv.bz2 │ │ └── splitstackshape │ │ │ ├── DESCRIPTION │ │ │ ├── INDEX │ │ │ ├── Meta │ │ │ ├── Rd.rds │ │ │ ├── data.rds │ │ │ ├── features.rds │ │ │ ├── hsearch.rds │ │ │ ├── links.rds │ │ │ ├── nsInfo.rds │ │ │ └── package.rds │ │ │ ├── NAMESPACE │ │ │ ├── NEWS.md │ │ │ ├── R │ │ │ ├── splitstackshape │ │ │ ├── splitstackshape.rdb │ │ │ └── splitstackshape.rdx │ │ │ ├── data │ │ │ ├── Rdata.rdb │ │ │ ├── Rdata.rds │ │ │ └── Rdata.rdx │ │ │ ├── help │ │ │ ├── AnIndex │ │ │ ├── aliases.rds │ │ │ ├── paths.rds │ │ │ ├── splitstackshape.rdb │ │ │ └── splitstackshape.rdx │ │ │ └── html │ │ │ ├── 00Index.html │ │ │ └── R.css │ │ └── old │ │ ├── data.table │ │ ├── DESCRIPTION │ │ ├── INDEX │ │ ├── LICENSE │ │ ├── Meta │ │ │ ├── Rd.rds │ │ │ ├── features.rds │ │ │ ├── hsearch.rds │ │ │ ├── links.rds │ │ │ ├── nsInfo.rds │ │ │ ├── package.rds │ │ │ └── vignette.rds │ │ ├── NAMESPACE │ │ ├── NEWS.md │ │ ├── R │ │ │ ├── data.table │ │ │ ├── data.table.rdb │ │ │ └── data.table.rdx │ │ ├── doc │ │ │ ├── datatable-benchmarking.Rmd │ │ │ ├── datatable-benchmarking.html │ │ │ ├── datatable-faq.R │ │ │ ├── datatable-faq.Rmd │ │ │ ├── datatable-faq.html │ │ │ ├── datatable-importing.Rmd │ │ │ ├── datatable-importing.html │ │ │ ├── datatable-intro.R │ │ │ ├── datatable-intro.Rmd │ │ │ ├── datatable-intro.html │ │ │ ├── datatable-keys-fast-subset.R │ │ │ ├── datatable-keys-fast-subset.Rmd │ │ │ ├── datatable-keys-fast-subset.html │ │ │ ├── datatable-reference-semantics.R │ │ │ ├── datatable-reference-semantics.Rmd │ │ │ ├── datatable-reference-semantics.html │ │ │ ├── datatable-reshape.R │ │ │ ├── datatable-reshape.Rmd │ │ │ ├── datatable-reshape.html │ │ │ ├── datatable-secondary-indices-and-auto-indexing.R │ │ │ ├── datatable-secondary-indices-and-auto-indexing.Rmd │ │ │ ├── datatable-secondary-indices-and-auto-indexing.html │ │ │ └── index.html │ │ ├── help │ │ │ ├── AnIndex │ │ │ ├── aliases.rds │ │ │ ├── data.table.rdb │ │ │ ├── data.table.rdx │ │ │ └── paths.rds │ │ ├── html │ │ │ ├── 00Index.html │ │ │ └── R.css │ │ ├── libs │ │ │ └── datatable.so │ │ └── tests │ │ │ ├── 1206FUT.txt │ │ │ ├── 1680-fread-header-encoding.csv │ │ │ ├── 2008head.csv │ │ │ ├── 530_fread.txt │ │ │ ├── 536_fread_fill_1.txt │ │ │ ├── 536_fread_fill_2.txt │ │ │ ├── 536_fread_fill_3_extreme.txt │ │ │ ├── 536_fread_fill_4.txt │ │ │ ├── SA2-by-DJZ.csv │ │ │ ├── allchar.csv.gz │ │ │ ├── alluniquechar.csv │ │ │ ├── bad.txt │ │ │ ├── benchmark.Rraw │ │ │ ├── ch11b.dat │ │ │ ├── colnames4096.csv │ │ │ ├── doublequote_newline.csv │ │ │ ├── fillheader.csv │ │ │ ├── fread_blank.txt │ │ │ ├── fread_blank2.txt │ │ │ ├── fread_blank3.txt │ │ │ ├── fread_line_error.csv │ │ │ ├── froll.Rraw │ │ │ ├── gb18030.txt │ │ │ ├── genotypes_genome.txt │ │ │ ├── grr.csv.gz │ │ │ ├── isoweek_test.csv │ │ │ ├── issue_1087_utf8_bom.csv │ │ │ ├── issue_1095_fread.txt │ │ │ ├── issue_1113_fread.txt │ │ │ ├── issue_1116_fread_few_lines.txt │ │ │ ├── issue_1116_fread_few_lines_2.txt │ │ │ ├── issue_1164_json.txt │ │ │ ├── issue_1330_fread.txt │ │ │ ├── issue_1462_fread_quotes.txt │ │ │ ├── issue_1573_fill.txt │ │ │ ├── issue_2051.csv │ │ │ ├── issue_2157_sampling_overlap.txt.gz │ │ │ ├── issue_2157_sampling_reached_eof_early.txt.bz2 │ │ │ ├── issue_563_fread.txt │ │ │ ├── issue_773_fread.txt │ │ │ ├── issue_785_fread.txt │ │ │ ├── iterations.txt │ │ │ ├── melt-warning-1752.tsv │ │ │ ├── melt_1754.R.gz │ │ │ ├── melt_1754_synth.csv │ │ │ ├── onecol4096.csv │ │ │ ├── other.Rraw │ │ │ ├── quoted_multiline.csv │ │ │ ├── quoted_no_header.csv │ │ │ ├── russellCRCRLF.csv │ │ │ ├── russellCRLF.csv │ │ │ ├── session_aborted_fatal_error.txt │ │ │ ├── test0.txt │ │ │ ├── test1372-1.Rdata │ │ │ ├── test1372.Rdata │ │ │ ├── tests-DESCRIPTION │ │ │ ├── tests.Rraw │ │ │ ├── unescaped.csv │ │ │ ├── utf16be.txt │ │ │ ├── utf16le.txt │ │ │ └── winallquoted.csv.bz2 │ │ └── splitstackshape │ │ ├── DESCRIPTION │ │ ├── INDEX │ │ ├── Meta │ │ ├── Rd.rds │ │ ├── data.rds │ │ ├── features.rds │ │ ├── hsearch.rds │ │ ├── links.rds │ │ ├── nsInfo.rds │ │ └── package.rds │ │ ├── NAMESPACE │ │ ├── NEWS.md │ │ ├── R │ │ ├── splitstackshape │ │ ├── splitstackshape.rdb │ │ └── splitstackshape.rdx │ │ ├── data │ │ ├── Rdata.rdb │ │ ├── Rdata.rds │ │ └── Rdata.rdx │ │ ├── help │ │ ├── AnIndex │ │ ├── aliases.rds │ │ ├── paths.rds │ │ ├── splitstackshape.rdb │ │ └── splitstackshape.rdx │ │ └── html │ │ ├── 00Index.html │ │ └── R.css └── problems.md ├── splitstackshape.Rproj └── tests ├── testthat.R └── testthat ├── test_cSplit.R ├── test_concat.split.R ├── test_helpers.R ├── test_listCols.R ├── test_reshape_related.R └── test_stratified.R /.Rbuildignore: -------------------------------------------------------------------------------- 1 | ^.*\.Rproj$ 2 | ^\.Rproj\.user$ 3 | ^\.travis\.yml$ 4 | ^revdep$ 5 | ^cran-comments\.md$ 6 | ^codecov\.yml$ 7 | ^appveyor\.yml$ 8 | ^CRAN-RELEASE$ 9 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .Rproj.user 2 | .Rhistory 3 | .RData 4 | /revdep/.cache.rds 5 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | # R for travis: see documentation at https://docs.travis-ci.com/user/languages/r 2 | 3 | language: R 4 | sudo: false 5 | cache: packages 6 | warnings_are_errors: false 7 | 8 | after_success: 9 | - Rscript -e 'covr::codecov()' 10 | -------------------------------------------------------------------------------- /CRAN-RELEASE: -------------------------------------------------------------------------------- 1 | This package was submitted to CRAN on 2019-04-21. 2 | Once it is accepted, delete this file and tag the release (commit 4b4ecfebd6). 3 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: splitstackshape 2 | Type: Package 3 | Title: Stack and Reshape Datasets After Splitting Concatenated Values 4 | Version: 1.4.8 5 | Date: 2019-04-21 6 | Author: Ananda Mahto 7 | Maintainer: Ananda Mahto 8 | Description: Online data collection tools like Google Forms often export 9 | multiple-response questions with data concatenated in cells. The 10 | concat.split (cSplit) family of functions splits such data into separate 11 | cells. The package also includes functions to stack groups of columns and 12 | to reshape wide data, even when the data are "unbalanced"---something 13 | which reshape (from base R) does not handle, and which melt and dcast from 14 | reshape2 do not easily handle. 15 | License: GPL-3 16 | LazyData: TRUE 17 | LazyLoad: yes 18 | Depends: 19 | R (>= 2.10) 20 | Imports: 21 | data.table (>= 1.9.4) 22 | URL: http://github.com/mrdwab/splitstackshape 23 | BugReports: http://github.com/mrdwab/splitstackshape/issues 24 | RoxygenNote: 6.1.1 25 | Roxygen: list(markdown = TRUE) 26 | Suggests: covr, 27 | testthat 28 | -------------------------------------------------------------------------------- /NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2: do not edit by hand 2 | 3 | export(Reshape) 4 | export(Stacked) 5 | export(cSplit) 6 | export(cSplit_e) 7 | export(cSplit_l) 8 | export(concat.split) 9 | export(concat.split.compact) 10 | export(concat.split.expanded) 11 | export(concat.split.list) 12 | export(concat.split.multiple) 13 | export(expandRows) 14 | export(getanID) 15 | export(listCol_l) 16 | export(listCol_w) 17 | export(merged.stack) 18 | export(stratified) 19 | import(data.table) 20 | importFrom(stats,na.omit) 21 | importFrom(stats,reshape) 22 | importFrom(stats,setNames) 23 | importFrom(utils,count.fields) 24 | importFrom(utils,read.table) 25 | -------------------------------------------------------------------------------- /R/expandRows.R: -------------------------------------------------------------------------------- 1 | #' Expand the Rows of a Dataset 2 | #' 3 | #' Expands (replicates) the rows of a `data.frame` or `data.table`, either by a 4 | #' fixed number, a specified vector, or a value contained in one of the columns 5 | #' in the source `data.frame` or `data.table`. 6 | #' 7 | #' 8 | #' @param dataset The input `data.frame` or `data.table`. 9 | #' @param count The numeric vector of counts OR the column from the 10 | #' dataset that contains the count data. If `count` is a single 11 | #' digit, it is assumed that all rows should be repeated by this amount. 12 | #' @param count.is.col Logical. Is the `count` value a column from the 13 | #' input dataset? Defaults to `TRUE`. 14 | #' @param drop Logical. If `count.is.col = TRUE`, should the "count" 15 | #' column be dropped from the result? Defaults to `TRUE`. 16 | #' @return A `data.frame` or `data.table`, depending on the input. 17 | #' @author Ananda Mahto 18 | #' @references \url{http://stackoverflow.com/a/19519828/1270695} 19 | #' @examples 20 | #' 21 | #' mydf <- data.frame(x = c("a", "b", "q"), 22 | #' y = c("c", "d", "r"), 23 | #' count = c(2, 5, 3)) 24 | #' library(data.table) 25 | #' DT <- as.data.table(mydf) 26 | #' mydf 27 | #' expandRows(mydf, "count") 28 | #' expandRows(DT, "count", drop = FALSE) 29 | #' expandRows(mydf, count = 3) ## This takes values from the third column! 30 | #' expandRows(mydf, count = 3, count.is.col = FALSE) 31 | #' expandRows(mydf, count = c(1, 5, 9), count.is.col = FALSE) 32 | #' expandRows(DT, count = c(1, 5, 9), count.is.col = FALSE) 33 | #' 34 | #' @export expandRows 35 | expandRows <- function(dataset, count, count.is.col = TRUE, drop = TRUE) { 36 | if (isTRUE(count.is.col)) { 37 | vals <- dataset[[count]] 38 | out <- dataset[rep(sequence(nrow(dataset)), vals), ] 39 | if (isTRUE(drop)) out[[count]] <- NULL 40 | } else if (length(count) == 1) { 41 | vals <- count 42 | out <- dataset[rep(sequence(nrow(dataset)), each = vals), ] 43 | } else { 44 | vals <- count 45 | out <- dataset[rep(sequence(nrow(dataset)), vals), ] 46 | } 47 | if (any(vals == 0)) { 48 | mess <- sprintf("The following rows have been dropped from the input: \n\n%s\n", 49 | paste(which(vals == 0), collapse = ", ")) 50 | message(mess) 51 | } 52 | out 53 | } 54 | NULL 55 | -------------------------------------------------------------------------------- /R/getanID.R: -------------------------------------------------------------------------------- 1 | #' Add an "id" Variable to a Dataset 2 | #' 3 | #' Many functions will not work properly if there are duplicated ID variables 4 | #' in a dataset. This function is a convenience function for `.N` from the 5 | #' "data.table" package to create an `.id` variable that when used in conjunction 6 | #' with the existing ID variables, should be unique. 7 | #' 8 | #' 9 | #' @param data The input `data.frame` or `data.table`. 10 | #' @param id.vars The variables that should be treated as ID variables. Defaults 11 | #' to `NULL`, at which point all variables are used to create the new ID variable. 12 | #' @return The input dataset (as a `data.table`) if ID variables are unique, or 13 | #' the input dataset with a new column named `.id`. 14 | #' @author Ananda Mahto 15 | #' @examples 16 | #' 17 | #' mydf <- data.frame(IDA = c("a", "a", "a", "b", "b"), 18 | #' IDB = c(1, 1, 1, 1, 1), values = 1:5) 19 | #' mydf 20 | #' getanID(mydf, c("IDA", "IDB")) 21 | #' 22 | #' mydf <- data.frame(IDA = c("a", "a", "a", "b", "b"), 23 | #' IDB = c(1, 2, 1, 1, 2), values = 1:5) 24 | #' mydf 25 | #' getanID(mydf, 1:2) 26 | #' 27 | #' \dontshow{rm(mydf)} 28 | #' 29 | #' @export getanID 30 | getanID <- function(data, id.vars = NULL) { 31 | if (!is.data.table(data)) data <- as.data.table(data) 32 | else data <- copy(data) 33 | 34 | if (is.numeric(id.vars)) id.vars <- names(data)[id.vars] 35 | if (is.null(id.vars)) id.vars <- names(data) 36 | 37 | .id <- .N <- NULL 38 | 39 | if (any(duplicated(data, by = id.vars))) { 40 | data[, .id := sequence(.N), by = id.vars][] 41 | } else { 42 | data[] 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /R/listCol_l.R: -------------------------------------------------------------------------------- 1 | #' Unlist a Column Stored as a List 2 | #' 3 | #' Unlists a column stored as a \code{list} into a long form. 4 | #' 5 | #' @usage listCol_l(inDT, listcol, drop = TRUE) 6 | #' @param inDT The input dataset. 7 | #' @param listcol The name of the column stored as a \code{list}. 8 | #' @param drop Logical. Should the original column be dropped? Defaults to \code{TRUE}. 9 | #' @return A \code{data.table}. 10 | #' @author Ananda Mahto 11 | #' @seealso \code{\link{listCol_w}} to flatten a \code{list} column into a "wide" format. 12 | #' @examples 13 | #' 14 | #' dat <- data.frame(A = 1:3, B = I(list(c(1, 2), c(1, 3, 5), c(4)))) 15 | #' listCol_l(dat, "B") 16 | #' 17 | #' @export listCol_l 18 | listCol_l <- function(inDT, listcol, drop = TRUE) { 19 | if (!is.data.table(inDT)) inDT <- as.data.table(inDT) 20 | else inDT <- copy(inDT) 21 | LC <- Names(inDT, listcol) 22 | reps <- vapply(inDT[[listcol]], length, 1L) 23 | inDT[[listcol]][reps == 0] <- lapply(inDT[[listcol]][reps == 0], 24 | function(x) { x <- NA; x}) 25 | reps[reps == 0] <- 1 26 | temp <- expandRows(inDT, reps, count.is.col = FALSE) 27 | temp[, ".renameme" := unlist(inDT[[listcol]], use.names = FALSE)] 28 | setnames(temp, ".renameme", paste0(LC, "_ul")) 29 | if (isTRUE(drop)) { 30 | temp[, (LC) := NULL] 31 | } 32 | temp[] 33 | } 34 | NULL 35 | -------------------------------------------------------------------------------- /R/listCol_w.R: -------------------------------------------------------------------------------- 1 | #' Flatten a Column Stored as a List 2 | #' 3 | #' Flattens a column stored as a \code{list} into a wide form. 4 | #' 5 | #' @usage listCol_w(inDT, listcol, drop = TRUE, fill = NA_character_) 6 | #' @param inDT The input dataset. 7 | #' @param listcol The name of the column stored as a \code{list}. 8 | #' @param drop Logical. Should the original column be dropped? Defaults to \code{TRUE}. 9 | #' @param fill The desired fill value. Defaults to \code{NA_character_}. 10 | #' @return A \code{data.table}. 11 | #' @author Ananda Mahto 12 | #' @seealso \code{\link{listCol_l}} to unlist a \code{list} column into a "long" format. 13 | #' @examples 14 | #' 15 | #' dat <- data.frame(A = 1:3, B = I(list(c(1, 2), c(1, 3, 5), c(4)))) 16 | #' listCol_w(dat, "B") 17 | #' 18 | #' @export listCol_w 19 | listCol_w <- function(inDT, listcol, drop = TRUE, fill = NA_character_) { 20 | if (!is.data.table(inDT)) inDT <- as.data.table(inDT) 21 | else inDT <- copy(inDT) 22 | LC <- Names(inDT, listcol) 23 | reps <- vapply(inDT[[listcol]], length, 1L) 24 | Nam <- paste(LC, .pad(sequence(max(reps))), sep = "_fl_") 25 | M <- matrix(fill, nrow = nrow(inDT), ncol = max(reps), 26 | dimnames = list(NULL, Nam)) 27 | M[cbind(rep(sequence(nrow(inDT)), reps), sequence(reps))] <- unlist( 28 | inDT[[listcol]], use.names = FALSE) 29 | 30 | out <- cbind(inDT, M) 31 | if (isTRUE(drop)) { 32 | out[, (LC) := NULL] 33 | } 34 | out[] 35 | } 36 | NULL -------------------------------------------------------------------------------- /R/splitstackshape-package.R: -------------------------------------------------------------------------------- 1 | #' Example Dataset with Concatenated Cells 2 | #' 3 | #' This is a sample dataset to demonstrate the different features of the 4 | #' [concat.split()] family of functions. 5 | #' 6 | #' 7 | #' @name concat.test 8 | #' @aliases concat.test 9 | #' @docType data 10 | #' @format A `data.frame` in which many columns contain concatenated cells. 11 | #' 12 | #' 13 | #' 14 | #' @keywords datasets 15 | NULL 16 | 17 | 18 | #' splitstackshape 19 | #' 20 | #' Stack and Reshape Datasets After Splitting Concatenated Values 21 | #' 22 | #' \tabular{ll}{ Package: \tab splitstackshape\cr Type: \tab Package\cr 23 | #' Version: \tab 1.4.8\cr Date: \tab 2019-04-21\cr License: \tab GPL-3\cr } 24 | #' 25 | #' Online data collection tools like Google Forms often export multiple-response 26 | #' questions with data concatenated in cells. The [concat.split()] family of 27 | #' functions splits such data into separate cells. The package also includes 28 | #' functions to *stack* groups of columns and to *reshape* wide data, even when 29 | #' the data are "unbalanced"---something which [stats::reshape()] does not handle, 30 | #' and which [reshape2::melt()] and [reshape2::dcast()] from *reshape2* do not 31 | #' easily handle. 32 | #' 33 | #' @name splitstackshape-package 34 | #' @aliases splitstackshape splitstackshape-package 35 | #' @docType package 36 | #' @author Ananda Mahto 37 | #' 38 | #' Maintainer: Ananda Mahto 39 | #' @keywords package 40 | #' @import data.table 41 | #' @importFrom stats reshape setNames na.omit 42 | #' @importFrom utils count.fields read.table 43 | #' @examples 44 | #' 45 | #' ## concat.split 46 | #' head(cSplit(concat.test, "Likes", drop = TRUE)) 47 | #' 48 | #' ## Reshape 49 | #' set.seed(1) 50 | #' mydf <- data.frame(id_1 = 1:6, id_2 = c("A", "B"), varA.1 = sample(letters, 6), 51 | #' varA.2 = sample(letters, 6), varA.3 = sample(letters, 6), 52 | #' varB.2 = sample(10, 6), varB.3 = sample(10, 6), 53 | #' varC.3 = rnorm(6)) 54 | #' mydf 55 | #' Reshape(mydf, id.vars = c("id_1", "id_2"), 56 | #' var.stubs = c("varA", "varB", "varC")) 57 | #' 58 | #' ## Stacked 59 | #' Stacked(data = mydf, id.vars = c("id_1", "id_2"), 60 | #' var.stubs = c("varA", "varB", "varC"), 61 | #' sep = ".") 62 | #' \dontrun{ 63 | #' ## Processing times 64 | #' set.seed(1) 65 | #' Nrow <- 1000000 66 | #' Ncol <- 10 67 | #' mybigdf <- cbind(id = 1:Nrow, as.data.frame(matrix(rnorm(Nrow*Ncol), 68 | #' nrow=Nrow))) 69 | #' head(mybigdf) 70 | #' dim(mybigdf) 71 | #' tail(mybigdf) 72 | #' A <- names(mybigdf) 73 | #' names(mybigdf) <- c("id", paste("varA", 1:3, sep = "_"), 74 | #' paste("varB", 1:4, sep = "_"), 75 | #' paste("varC", 1:3, sep = "_")) 76 | #' system.time({ 77 | #' O1 <- Reshape(mybigdf, id.vars = "id", 78 | #' var.stubs = c("varA", "varB", "varC"), sep = "_") 79 | #' O1 <- O1[order(O1$id, O1$time), ] 80 | #' }) 81 | #' system.time({ 82 | #' O2 <- merged.stack(mybigdf, id.vars="id", 83 | #' var.stubs=c("varA", "varB", "varC"), sep = "_") 84 | #' }) 85 | #' system.time({ 86 | #' O3 <- Stacked(mybigdf, id.vars="id", 87 | #' var.stubs=c("varA", "varB", "varC"), sep = "_") 88 | #' }) 89 | #' DT <- data.table(mybigdf) 90 | #' system.time({ 91 | #' O4 <- merged.stack(DT, id.vars="id", 92 | #' var.stubs=c("varA", "varB", "varC"), sep = "_") 93 | #' }) 94 | #' } 95 | #' 96 | NULL 97 | 98 | 99 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # splitstackshape 2 | 3 | [![Travis-CI Build Status](https://travis-ci.org/mrdwab/splitstackshape.svg?branch=master)](https://travis-ci.org/mrdwab/splitstackshape) 4 | [![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/mrdwab/splitstackshape?branch=master&svg=true)](https://ci.appveyor.com/project/mrdwab/splitstackshape) 5 | [![Coverage Status](https://img.shields.io/codecov/c/github/mrdwab/splitstackshape/master.svg)](https://codecov.io/gh/mrdwab/splitstackshape/branch/master) 6 | 7 | R functions to split concatenated data, stack columns of your datasets, and convert your data into different shapes. 8 | 9 | ## Core Functions 10 | 11 | * `cSplit`: A core function that collects the functionality of several of the `concat.split` family of functions. 12 | * `concat.split`: A set of functions to split strings where data have been concatenated into a single value, as is common when getting data collected with tools like Google Forms. (`cSplit_l` to return a `list`; and `cSplit_e` to return an "expanded" view of the input data.) 13 | * `Stacked`: A function to create a list of `stack`ed sets of variables. Similar to `melt` from "reshape2", but doesn't put everything into one very long `data.frame`. 14 | * `Reshape`: A function to allow base R's `reshape` function to work with "unbalanced" datasets. 15 | * `stratified`: A function to take random row samples by groups, similar to `sample_n` and `sample_frac` from "dplyr". 16 | 17 | ## Utilities 18 | 19 | * `getanID`: A function for creating a secondary ID when duplicated "id" variables are present. 20 | * `expandRows`: "Expands" the rows of a dataset. 21 | * `listCol_l` and `listCol_w`: Unlists (long) or flattens (wide) a column in a `data.frame` or a `data.table` stored as a `list`. Neither is vectorized. 22 | 23 | ## Install 24 | 25 | The package [is on CRAN](https://CRAN.R-project.org/package=splitstackshape). You can install it using: 26 | 27 | ```r 28 | install.packages("splitstackshape") 29 | ``` 30 | 31 | To install the V2 beta version, use: 32 | 33 | ```r 34 | devtools::install_github("mrdwab/splitstackshape", ref = "v2.0") 35 | ``` 36 | 37 | To install the V1 development version, use: 38 | 39 | ```r 40 | devtools::install_github("mrdwab/splitstackshape", ref = "v1_development") 41 | ``` 42 | 43 | Current CRAN version: 1.4.8 44 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | # DO NOT CHANGE the "init" and "install" sections below 2 | 3 | # Download script file from GitHub 4 | init: 5 | ps: | 6 | $ErrorActionPreference = "Stop" 7 | Invoke-WebRequest http://raw.github.com/krlmlr/r-appveyor/master/scripts/appveyor-tool.ps1 -OutFile "..\appveyor-tool.ps1" 8 | Import-Module '..\appveyor-tool.ps1' 9 | 10 | install: 11 | ps: Bootstrap 12 | 13 | cache: 14 | - C:\RLibrary 15 | 16 | # Adapt as necessary starting from here 17 | 18 | build_script: 19 | - travis-tool.sh install_deps 20 | 21 | test_script: 22 | - travis-tool.sh run_tests 23 | 24 | on_failure: 25 | - 7z a failure.zip *.Rcheck\* 26 | - appveyor PushArtifact failure.zip 27 | 28 | artifacts: 29 | - path: '*.Rcheck\**\*.log' 30 | name: Logs 31 | 32 | - path: '*.Rcheck\**\*.out' 33 | name: Logs 34 | 35 | - path: '*.Rcheck\**\*.fail' 36 | name: Logs 37 | 38 | - path: '*.Rcheck\**\*.Rout' 39 | name: Logs 40 | 41 | - path: '\*_*.tar.gz' 42 | name: Bits 43 | 44 | - path: '\*_*.zip' 45 | name: Bits 46 | -------------------------------------------------------------------------------- /codecov.yml: -------------------------------------------------------------------------------- 1 | comment: false 2 | -------------------------------------------------------------------------------- /cran-comments.md: -------------------------------------------------------------------------------- 1 | ## Test environments 2 | * ubuntu 14.04 (on travis-ci), R 3.5.3 3 | * win-builder (devel and release) 4 | 5 | ## R CMD check results 6 | 7 | 0 errors | 0 warnings | 0 notes 8 | 9 | -------------------------------------------------------------------------------- /data/concatenated.RData: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrdwab/splitstackshape/edd44d17c5fa69ae9b1b31808c8a2426a1bd7176/data/concatenated.RData -------------------------------------------------------------------------------- /man/FacsToChars.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/splitstackshape_helper_functions.R 3 | \name{FacsToChars} 4 | \alias{FacsToChars} 5 | \title{Convert All Factor Columns to Character Columns} 6 | \usage{ 7 | FacsToChars(mydf) 8 | } 9 | \arguments{ 10 | \item{mydf}{The name of your \code{data.frame}} 11 | } 12 | \description{ 13 | Sometimes, we forget to use the \code{stringsAsFactors} argument when using 14 | \code{\link[utils:read.table]{utils::read.table()}} and related functions. By default, R converts character 15 | columns to factors. Instead of re-reading the data, the \code{FacsToChars} 16 | function will identify which columns are currently factors, and convert them 17 | all to characters. 18 | } 19 | \examples{ 20 | 21 | ## Some example data 22 | dat <- data.frame(title = c("title1", "title2", "title3"), 23 | author = c("author1", "author2", "author3"), 24 | customerID = c(1, 2, 1)) 25 | 26 | str(dat) # current structure 27 | dat2 <- splitstackshape:::FacsToChars(dat) 28 | str(dat2) # Your new object 29 | str(dat) # Original object is unaffected 30 | 31 | } 32 | \seealso{ 33 | \code{\link[utils:read.table]{utils::read.table()}} 34 | } 35 | \author{ 36 | Ananda Mahto 37 | } 38 | -------------------------------------------------------------------------------- /man/Names.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/splitstackshape_helper_functions.R 3 | \name{Names} 4 | \alias{Names} 5 | \title{Dataset Names as a Character Vector, Always} 6 | \usage{ 7 | Names(data, invec) 8 | } 9 | \arguments{ 10 | \item{data}{The input \code{data.frame}.} 11 | 12 | \item{invec}{The \code{names} you want.} 13 | } 14 | \value{ 15 | A character vector of the desired names. 16 | } 17 | \description{ 18 | A convenience function using either character vectors or numeric vectors to 19 | specify a subset of \code{names} of a \code{data.frame}. 20 | } 21 | \examples{ 22 | 23 | mydf <- data.frame(a = 1:2, b = 3:4, c = 5:6) 24 | splitstackshape:::Names(mydf, c("a", "c")) 25 | splitstackshape:::Names(mydf, c(1, 3)) 26 | 27 | } 28 | \author{ 29 | Ananda Mahto 30 | } 31 | -------------------------------------------------------------------------------- /man/NoSep.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/splitstackshape_helper_functions.R 3 | \name{NoSep} 4 | \alias{NoSep} 5 | \title{Split Basic Alphanumeric Strings Which Have No Separators} 6 | \usage{ 7 | NoSep(data, charfirst = TRUE) 8 | } 9 | \arguments{ 10 | \item{data}{The vector of strings to be split.} 11 | 12 | \item{charfirst}{Is the string constructed with characters at the start or 13 | numbers? Defaults to \code{TRUE}.} 14 | } 15 | \value{ 16 | A \code{data.frame} with two columns, \code{.var} and \code{.time_1}. 17 | } 18 | \description{ 19 | Used to split strings like "Abc8" into "Abc" and "8". 20 | } 21 | \note{ 22 | This is a helper function for the \code{\link[=Stacked]{Stacked()}} and \code{\link[=Reshape]{Reshape()}} functions. 23 | } 24 | \examples{ 25 | 26 | x <- paste0("Var", LETTERS[1:3], 1:3) 27 | splitstackshape:::NoSep(x) 28 | 29 | y <- paste0(1:3, "Var", LETTERS[1:3]) 30 | splitstackshape:::NoSep(y, charfirst = FALSE) 31 | 32 | } 33 | \seealso{ 34 | \code{\link[base:strsplit]{base::strsplit()}} 35 | } 36 | \author{ 37 | Ananda Mahto 38 | } 39 | -------------------------------------------------------------------------------- /man/Reshape.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/Reshape.R 3 | \name{Reshape} 4 | \alias{Reshape} 5 | \title{Reshape Wide Data Into a Semi-long Form} 6 | \usage{ 7 | Reshape(data, id.vars = NULL, var.stubs, sep = ".", rm.rownames, ...) 8 | } 9 | \arguments{ 10 | \item{data}{The source \code{data.frame}.} 11 | 12 | \item{id.vars}{The variables that serve as unique identifiers. Defaults to 13 | \code{NULL}, at which point, all names which are not identified as variable groups 14 | are used as the identifiers.} 15 | 16 | \item{var.stubs}{The prefixes of the variable groups.} 17 | 18 | \item{sep}{The character that separates the "variable name" from the "times" 19 | in the wide \code{data.frame}.} 20 | 21 | \item{rm.rownames}{Ignored as \code{data.table}s do not have rownames anyway.} 22 | 23 | \item{\dots}{Further arguments to \code{\link[=NoSep]{NoSep()}} in case the separator is of a 24 | different form.} 25 | } 26 | \value{ 27 | A "long" \code{data.table} of the reshaped data that retains the 28 | attributes added by base R's \code{reshape} function. 29 | } 30 | \description{ 31 | The \code{\link[stats:reshape]{stats::reshape()}} function in base R is very handy when you want a 32 | semi-long (or semi-wide) \code{data.frame}. However, base R's \code{reshape} has 33 | problems is with "unbalanced" panel data, for instance data where one 34 | variable was measured at three points in time, and another only twice. 35 | } 36 | \details{ 37 | This function was written to overcome that limitation of dealing with 38 | unbalanced data, but is also appropriate for basic wide-to-long reshaping 39 | tasks. 40 | 41 | Related functions like \code{\link[utils:stack]{utils::stack()}} in base R and \code{\link[reshape2:melt]{reshape2::melt()}} in 42 | "reshape2" are also very handy when you want a "long" reshaping of data, but 43 | they result in a very long structuring of your data, not the "semi-wide" 44 | format that \code{reshape} produces. \code{\link[data.table:melt]{data.table::melt()}} can produce output like 45 | \code{reshape}, but it also expects an equal number of measurements for each 46 | variable. 47 | } 48 | \examples{ 49 | 50 | set.seed(1) 51 | mydf <- data.frame(id_1 = 1:6, id_2 = c("A", "B"), varA.1 = sample(letters, 6), 52 | varA.2 = sample(letters, 6), varA.3 = sample(letters, 6), 53 | varB.2 = sample(10, 6), varB.3 = sample(10, 6), 54 | varC.3 = rnorm(6)) 55 | mydf 56 | 57 | ## Note that these data are unbalanced 58 | ## reshape() will not work 59 | \dontrun{ 60 | reshape(mydf, direction = "long", idvar=1:2, varying=3:ncol(mydf)) 61 | } 62 | 63 | ## The Reshape() function can handle such scenarios 64 | 65 | Reshape(mydf, id.vars = c("id_1", "id_2"), 66 | var.stubs = c("varA", "varB", "varC")) 67 | 68 | } 69 | \seealso{ 70 | \code{\link[=Stacked]{Stacked()}}, \code{\link[utils:stack]{utils::stack()}}, \code{\link[stats:reshape]{stats::reshape()}}, 71 | \code{\link[reshape2:melt]{reshape2::melt()}}, \code{\link[data.table:melt]{data.table::melt()}} 72 | } 73 | \author{ 74 | Ananda Mahto 75 | } 76 | -------------------------------------------------------------------------------- /man/Stacked.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/Stacked.R 3 | \name{Stacked} 4 | \alias{Stacked} 5 | \title{Stack Columns from a Wide Form to a Long Form} 6 | \usage{ 7 | Stacked(data, id.vars = NULL, var.stubs, sep, keep.all = TRUE, 8 | keyed = TRUE, keep.rownames = FALSE, ...) 9 | } 10 | \arguments{ 11 | \item{data}{The source \code{data.frame}.} 12 | 13 | \item{id.vars}{The variables that serve as unique identifiers. Defaults to \code{NULL}, at which point, all names which are not identified as variable groups are used as the identifiers.} 14 | 15 | \item{var.stubs}{The prefixes of the variable groups.} 16 | 17 | \item{sep}{The character that separates the "variable name" from the "times" 18 | in the wide \code{data.frame}. Alternatively, can be set to 19 | \code{"var.stubs"} (in quotes) if you do not have a value for \code{sep}.} 20 | 21 | \item{keep.all}{Logical. Should all the variables from the source 22 | \code{data.frame} be kept (\code{keep.all = TRUE}) or should the resulting 23 | \code{\link[data.table:data.table]{data.table}} comprise only columns for 24 | the \code{id.vars}, \code{var.stubs}, and "times" (\code{keep.all = FALSE}). 25 | Other variables are \emph{recycled} to appropriate length. For this to work, 26 | both \code{id.vars} and \code{var.stubs} must be specified.} 27 | 28 | \item{keyed}{Logical. Should the \code{Stacked} function automatically set 29 | the \code{key} for the resulting \code{data.table}s. If \code{TRUE} 30 | (default) the \code{key} is set to the \code{id.vars} and the "time" 31 | variables that are created by \code{Stacked}.} 32 | 33 | \item{keep.rownames}{Logical. Should rownames be kept when converting the input to a \code{data.table}? Defaults to \code{FALSE}.} 34 | 35 | \item{\dots}{Other arguments to be passed on when \code{sep = "var.stubs"} (specifically, \code{atStart}: A logical argument to indicate whether the stubs come at the start or at the end of the variable names).} 36 | } 37 | \value{ 38 | A \code{list} of \code{data.table}s with one \code{data.table} for 39 | each "var.stub". The \code{\link[data.table:key]{key}} is set to the 40 | \code{id.vars} and \code{.time_#} vars. 41 | } 42 | \description{ 43 | A function to conveniently stack groups of wide columns into a long form 44 | which can then be \code{\link[data.table:merge]{merge}}d together. 45 | } 46 | \note{ 47 | This is the function internally called by \code{\link{merged.stack}}. 48 | } 49 | \examples{ 50 | 51 | set.seed(1) 52 | mydf <- data.frame(id_1 = 1:6, id_2 = c("A", "B"), 53 | varA.1 = sample(letters, 6), 54 | varA.2 = sample(letters, 6), 55 | varA.3 = sample(letters, 6), 56 | varB.2 = sample(10, 6), 57 | varB.3 = sample(10, 6), 58 | varC.3 = rnorm(6)) 59 | mydf 60 | Stacked(data = mydf, var.stubs = c("varA", "varB", "varC"), sep = ".") 61 | 62 | \dontshow{rm(mydf)} 63 | 64 | } 65 | \seealso{ 66 | \code{\link{stack}}, \code{\link[reshape2:melt]{melt}} from 67 | "reshape2". 68 | } 69 | \author{ 70 | Ananda Mahto 71 | } 72 | -------------------------------------------------------------------------------- /man/cSplit.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/cSplit.R 3 | \name{cSplit} 4 | \alias{cSplit} 5 | \title{Split Concatenated Values into Separate Values} 6 | \usage{ 7 | cSplit(indt, splitCols, sep = ",", direction = "wide", fixed = TRUE, 8 | drop = TRUE, stripWhite = TRUE, makeEqual = NULL, 9 | type.convert = TRUE) 10 | } 11 | \arguments{ 12 | \item{indt}{The input \code{data.frame} or \code{data.table}.} 13 | 14 | \item{splitCols}{The column or columns that need to be split.} 15 | 16 | \item{sep}{The values that serve as a delimiter \emph{within} each column. This 17 | can be a single value if all columns have the same delimiter, or a vector of 18 | values \emph{in the same order as the delimiters in each of the \code{splitCols}}.} 19 | 20 | \item{direction}{The desired direction of the results, either \code{"wide"} 21 | or \code{"long"}.} 22 | 23 | \item{fixed}{Logical. Should the split character be treated as a fixed 24 | pattern (\code{TRUE}) or a regular expression (\code{FALSE})? Defaults to \code{TRUE}.} 25 | 26 | \item{drop}{Logical. Should the original concatenated column be dropped? 27 | Defaults to \code{TRUE}.} 28 | 29 | \item{stripWhite}{Logical. If there is whitespace around the delimiter in 30 | the concatenated columns, should it be stripped prior to splitting? Defaults 31 | to \code{TRUE}.} 32 | 33 | \item{makeEqual}{Logical. Should all groups be made to be the same length? 34 | Defaults to \code{FALSE}.} 35 | 36 | \item{type.convert}{Logical. Should \code{\link[utils:type.convert]{utils::type.convert()}} be used to convert 37 | the result of each column? This would add a little to the execution time.} 38 | } 39 | \value{ 40 | A \code{data.table} with the values split into new columns or rows. 41 | } 42 | \description{ 43 | The \code{cSplit} function is designed to quickly and conveniently split 44 | concatenated data into separate values. 45 | } 46 | \note{ 47 | The \code{cSplit} function replaces most of the earlier \code{concat.split*} 48 | functions. The earlier functions remain for compatibility purposes, but now 49 | they are essentially wrappers for the \code{cSplit} function. 50 | } 51 | \examples{ 52 | 53 | ## Sample data 54 | temp <- head(concat.test) 55 | 56 | ## Split the "Likes" column 57 | cSplit(temp, "Likes") 58 | 59 | ## Split the "Likes" and "Hates" columns -- 60 | ## they have different delimiters... 61 | cSplit(temp, c("Likes", "Hates"), c(",", ";")) 62 | 63 | ## Split "Siblings" into a long form... 64 | cSplit(temp, "Siblings", ",", direction = "long") 65 | 66 | ## Split "Siblings" into a long form, not removing whitespace 67 | cSplit(temp, "Siblings", ",", direction = "long", stripWhite = FALSE) 68 | 69 | ## Split a vector 70 | y <- c("a_b_c", "a_b", "c_a_b") 71 | cSplit(data.frame(y), "y", "_") 72 | 73 | } 74 | \seealso{ 75 | \code{\link[=concat.split]{concat.split()}} 76 | } 77 | \author{ 78 | Ananda Mahto 79 | } 80 | -------------------------------------------------------------------------------- /man/charMat.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/splitstackshape_helper_functions.R 3 | \name{charMat} 4 | \alias{charMat} 5 | \title{Create a Binary Matrix from a List of Character Values} 6 | \usage{ 7 | charMat(listOfValues, fill = NA, mode = "binary") 8 | } 9 | \arguments{ 10 | \item{listOfValues}{A \code{list} of input values to be inserted in a matrix.} 11 | 12 | \item{fill}{The initializing fill value for the empty matrix.} 13 | 14 | \item{mode}{Either \code{"binary"} or \code{"value"}. Defaults to \code{"binary"}.} 15 | } 16 | \value{ 17 | A \code{matrix}. 18 | } 19 | \description{ 20 | Create a binary matrix from a list of character values 21 | } 22 | \details{ 23 | This is primarily a helper function for the \code{\link[=concat.split]{concat.split()}} function when 24 | creating the "expanded" structure. The input is anticipated to be a \code{list} of 25 | values obtained using \code{\link[base:strsplit]{base::strsplit()}}. 26 | } 27 | \examples{ 28 | 29 | invec <- c("rock,electro","electro","rock,jazz") 30 | A <- strsplit(invec, ",") 31 | splitstackshape:::charMat(A) 32 | splitstackshape:::charMat(A, 0) 33 | splitstackshape:::charMat(A, mode = "value") 34 | 35 | } 36 | \seealso{ 37 | \code{\link[base:strsplit]{base::strsplit()}}, \code{\link[=numMat]{numMat()}}. 38 | } 39 | \author{ 40 | Ananda Mahto 41 | } 42 | -------------------------------------------------------------------------------- /man/concat.split.compact.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/concat.split.R 3 | \name{concat.split.compact} 4 | \alias{concat.split.compact} 5 | \title{Split Concatenated Cells into a Condensed Format} 6 | \usage{ 7 | concat.split.compact(data, split.col, sep = ",", drop = FALSE, 8 | fixed = TRUE, ...) 9 | } 10 | \arguments{ 11 | \item{data}{The input \code{data.frame} or \code{data.table}.} 12 | 13 | \item{split.col}{The column that need to be split.} 14 | 15 | \item{sep}{The character separating each value.} 16 | 17 | \item{drop}{Logical. Should the original variable be dropped? Defaults to 18 | \code{FALSE}.} 19 | 20 | \item{fixed}{Logical. Should the split character be treated as a fixed 21 | pattern (\code{TRUE}) or a regular expression (\code{FALSE})? Defaults to \code{TRUE}.} 22 | 23 | \item{\dots}{optional arguments to pass to \code{cSplit}.} 24 | } 25 | \value{ 26 | A \code{data.table}. 27 | } 28 | \description{ 29 | The default splitting method for \code{concat.split}. Formerly based on 30 | \code{\link[=read.concat]{read.concat()}} but presently a simple wrapper around \code{\link[=cSplit]{cSplit()}}. 31 | } 32 | \note{ 33 | THIS FUNCTION IS DEPRECATED AND WILL BE REMOVED FROM LATER VERSIONS OF 34 | "SPLITSTACKSHAPE". It no longer does anything different from \code{\link[=cSplit]{cSplit()}}. It is 35 | recommended that you transition your code to the \code{cSplit} function instead. 36 | } 37 | \examples{ 38 | 39 | \dontrun{ 40 | temp <- head(concat.test) 41 | concat.split.compact(temp, "Likes") 42 | concat.split.compact(temp, 4, ";") 43 | 44 | ## Extra arguments to cSplit 45 | concat.split.compact(temp, "Siblings", drop = TRUE, stripWhite = TRUE) 46 | } 47 | 48 | } 49 | \seealso{ 50 | \code{\link[=read.concat]{read.concat()}}, \code{\link[=cSplit]{cSplit()}} 51 | } 52 | \author{ 53 | Ananda Mahto 54 | } 55 | -------------------------------------------------------------------------------- /man/concat.split.expanded.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/concat.split.R 3 | \name{concat.split.expanded} 4 | \alias{concat.split.expanded} 5 | \alias{cSplit_e} 6 | \title{Split Concatenated Values into their Corresponding Column Position} 7 | \usage{ 8 | cSplit_e(data, split.col, sep = ",", mode = NULL, type = "numeric", 9 | drop = FALSE, fixed = TRUE, fill = NA) 10 | } 11 | \arguments{ 12 | \item{data}{The source \code{data.frame} or \code{data.table}.} 13 | 14 | \item{split.col}{The variable that needs to be split (either name or index 15 | position).} 16 | 17 | \item{sep}{The character separating each value. Can also be a regular 18 | expression.} 19 | 20 | \item{mode}{Can be either \code{"binary"} (where presence of a number in a given 21 | column is converted to "1") or \code{"value"} (where the value is retained and not 22 | recoded to "1"). Defaults to \code{"binary"}.} 23 | 24 | \item{type}{Can be either \code{"numeric"} (where the items being split are 25 | integers) or \code{"character"} (where the items being split are character 26 | strings). Defaults to \code{"numeric"}.} 27 | 28 | \item{drop}{Logical. Should the original variable be dropped? Defaults to 29 | \code{FALSE}.} 30 | 31 | \item{fixed}{Used for \code{\link[base:strsplit]{base::strsplit()}} for allowing regular expressions to 32 | be used.} 33 | 34 | \item{fill}{Desired "fill" value. Defaults to \code{NA}.} 35 | } 36 | \value{ 37 | A \code{data.frame} or \code{data.table} depending on the source input. 38 | } 39 | \description{ 40 | "Expand" concatenated numeric or character values to their relevant position 41 | in a \code{data.frame} or \code{data.table} or create a binary representation of such data. 42 | } 43 | \examples{ 44 | 45 | temp <- head(concat.test) 46 | cSplit_e(temp, "Likes") 47 | cSplit_e(temp, 4, ";", fill = 0) 48 | 49 | ## The old function name still works 50 | concat.split.expanded(temp, "Likes") 51 | concat.split.expanded(temp, 4, ";", fill = 0) 52 | concat.split.expanded(temp, 4, ";", mode = "value", drop = TRUE) 53 | concat.split.expanded(temp, "Siblings", type = "character", drop = TRUE) 54 | 55 | } 56 | \seealso{ 57 | \code{\link[=cSplit]{cSplit()}}, \code{\link[=cSplit_l]{cSplit_l()}}, \code{\link[=numMat]{numMat()}}, \code{\link[=charMat]{charMat()}} 58 | } 59 | \author{ 60 | Ananda Mahto 61 | } 62 | -------------------------------------------------------------------------------- /man/concat.split.list.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/concat.split.R 3 | \name{concat.split.list} 4 | \alias{concat.split.list} 5 | \alias{cSplit_l} 6 | \title{Split Concatenated Cells into a List Format} 7 | \usage{ 8 | cSplit_l(data, split.col, sep = ",", drop = FALSE, fixed = FALSE) 9 | } 10 | \arguments{ 11 | \item{data}{The source \code{data.frame} or \code{data.table}.} 12 | 13 | \item{split.col}{The variable that needs to be split (either name or index 14 | position).} 15 | 16 | \item{sep}{The character separating each value. Can also be a regular expression.} 17 | 18 | \item{drop}{Logical. Should the original variable be dropped? Defaults to \code{FALSE}.} 19 | 20 | \item{fixed}{Used for \code{\link[base:strsplit]{base::strsplit()}} for allowing regular expressions to 21 | be used.} 22 | } 23 | \value{ 24 | A \code{data.frame} or \code{data.table} with the concatenated column split and 25 | added as a \code{list}. 26 | } 27 | \description{ 28 | Takes a column in a \code{data.frame} or \code{data.table} with multiple values, splits 29 | the values into a \code{list}, and returns a new \code{data.frame} or \code{data.table}. 30 | } 31 | \examples{ 32 | 33 | temp <- head(concat.test) 34 | str(cSplit_l(temp, "Likes")) 35 | cSplit_l(temp, 4, ";") 36 | 37 | ## The old function name still works 38 | str(concat.split.list(temp, "Likes")) 39 | concat.split.list(temp, 4, ";") 40 | concat.split.list(temp, 4, ";", drop = TRUE) 41 | 42 | } 43 | \seealso{ 44 | \code{\link[=cSplit]{cSplit()}}, \code{\link[=cSplit_e]{cSplit_e()}} 45 | } 46 | \author{ 47 | Ananda Mahto 48 | } 49 | -------------------------------------------------------------------------------- /man/concat.split.multiple.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/concat.split.R 3 | \name{concat.split.multiple} 4 | \alias{concat.split.multiple} 5 | \title{Split Concatenated Cells and Optionally Reshape the Output} 6 | \usage{ 7 | concat.split.multiple(data, split.cols, seps = ",", direction = "wide", 8 | ...) 9 | } 10 | \arguments{ 11 | \item{data}{The source \code{data.frame} or \code{data.table}.} 12 | 13 | \item{split.cols}{A vector of columns that need to be split.} 14 | 15 | \item{seps}{A vector of the separator character used in each column. If all 16 | columns use the same character, you can enter that single character.} 17 | 18 | \item{direction}{The desired form of the resulting \code{data.frame} or \code{data.table}, 19 | either \code{"wide"} or \code{"long"}. Defaults to \code{"wide"}.} 20 | 21 | \item{\dots}{Other arguments to \code{\link[=cSplit]{cSplit()}}.} 22 | } 23 | \value{ 24 | A \code{data.table}. 25 | } 26 | \description{ 27 | This is a wrapper for the \code{\link[=cSplit]{cSplit()}} function to maintain backwards 28 | compatibility with earlier versions of the "splitstackshape" package. It 29 | allows the user to split multiple columns at once and optionally convert the 30 | results into a "long" format. 31 | } 32 | \examples{ 33 | 34 | \dontrun{ 35 | temp <- head(concat.test) 36 | concat.split.multiple(temp, split.cols = c("Likes", "Hates", "Siblings"), 37 | seps = c(",", ";", ",")) 38 | concat.split.multiple(temp, split.cols = c("Likes", "Siblings"), 39 | seps = ",", direction = "long") 40 | } 41 | 42 | } 43 | \seealso{ 44 | \code{\link[=cSplit]{cSplit()}} 45 | } 46 | \author{ 47 | Ananda Mahto 48 | } 49 | -------------------------------------------------------------------------------- /man/concat.test.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/splitstackshape-package.R 3 | \docType{data} 4 | \name{concat.test} 5 | \alias{concat.test} 6 | \title{Example Dataset with Concatenated Cells} 7 | \format{A \code{data.frame} in which many columns contain concatenated cells.} 8 | \description{ 9 | This is a sample dataset to demonstrate the different features of the 10 | \code{\link[=concat.split]{concat.split()}} family of functions. 11 | } 12 | \keyword{datasets} 13 | -------------------------------------------------------------------------------- /man/expandRows.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/expandRows.R 3 | \name{expandRows} 4 | \alias{expandRows} 5 | \title{Expand the Rows of a Dataset} 6 | \usage{ 7 | expandRows(dataset, count, count.is.col = TRUE, drop = TRUE) 8 | } 9 | \arguments{ 10 | \item{dataset}{The input \code{data.frame} or \code{data.table}.} 11 | 12 | \item{count}{The numeric vector of counts OR the column from the 13 | dataset that contains the count data. If \code{count} is a single 14 | digit, it is assumed that all rows should be repeated by this amount.} 15 | 16 | \item{count.is.col}{Logical. Is the \code{count} value a column from the 17 | input dataset? Defaults to \code{TRUE}.} 18 | 19 | \item{drop}{Logical. If \code{count.is.col = TRUE}, should the "count" 20 | column be dropped from the result? Defaults to \code{TRUE}.} 21 | } 22 | \value{ 23 | A \code{data.frame} or \code{data.table}, depending on the input. 24 | } 25 | \description{ 26 | Expands (replicates) the rows of a \code{data.frame} or \code{data.table}, either by a 27 | fixed number, a specified vector, or a value contained in one of the columns 28 | in the source \code{data.frame} or \code{data.table}. 29 | } 30 | \examples{ 31 | 32 | mydf <- data.frame(x = c("a", "b", "q"), 33 | y = c("c", "d", "r"), 34 | count = c(2, 5, 3)) 35 | library(data.table) 36 | DT <- as.data.table(mydf) 37 | mydf 38 | expandRows(mydf, "count") 39 | expandRows(DT, "count", drop = FALSE) 40 | expandRows(mydf, count = 3) ## This takes values from the third column! 41 | expandRows(mydf, count = 3, count.is.col = FALSE) 42 | expandRows(mydf, count = c(1, 5, 9), count.is.col = FALSE) 43 | expandRows(DT, count = c(1, 5, 9), count.is.col = FALSE) 44 | 45 | } 46 | \references{ 47 | \url{http://stackoverflow.com/a/19519828/1270695} 48 | } 49 | \author{ 50 | Ananda Mahto 51 | } 52 | -------------------------------------------------------------------------------- /man/getanID.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/getanID.R 3 | \name{getanID} 4 | \alias{getanID} 5 | \title{Add an "id" Variable to a Dataset} 6 | \usage{ 7 | getanID(data, id.vars = NULL) 8 | } 9 | \arguments{ 10 | \item{data}{The input \code{data.frame} or \code{data.table}.} 11 | 12 | \item{id.vars}{The variables that should be treated as ID variables. Defaults 13 | to \code{NULL}, at which point all variables are used to create the new ID variable.} 14 | } 15 | \value{ 16 | The input dataset (as a \code{data.table}) if ID variables are unique, or 17 | the input dataset with a new column named \code{.id}. 18 | } 19 | \description{ 20 | Many functions will not work properly if there are duplicated ID variables 21 | in a dataset. This function is a convenience function for \code{.N} from the 22 | "data.table" package to create an \code{.id} variable that when used in conjunction 23 | with the existing ID variables, should be unique. 24 | } 25 | \examples{ 26 | 27 | mydf <- data.frame(IDA = c("a", "a", "a", "b", "b"), 28 | IDB = c(1, 1, 1, 1, 1), values = 1:5) 29 | mydf 30 | getanID(mydf, c("IDA", "IDB")) 31 | 32 | mydf <- data.frame(IDA = c("a", "a", "a", "b", "b"), 33 | IDB = c(1, 2, 1, 1, 2), values = 1:5) 34 | mydf 35 | getanID(mydf, 1:2) 36 | 37 | \dontshow{rm(mydf)} 38 | 39 | } 40 | \author{ 41 | Ananda Mahto 42 | } 43 | -------------------------------------------------------------------------------- /man/listCol_l.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/listCol_l.R 3 | \name{listCol_l} 4 | \alias{listCol_l} 5 | \title{Unlist a Column Stored as a List} 6 | \usage{ 7 | listCol_l(inDT, listcol, drop = TRUE) 8 | } 9 | \arguments{ 10 | \item{inDT}{The input dataset.} 11 | 12 | \item{listcol}{The name of the column stored as a \code{list}.} 13 | 14 | \item{drop}{Logical. Should the original column be dropped? Defaults to \code{TRUE}.} 15 | } 16 | \value{ 17 | A \code{data.table}. 18 | } 19 | \description{ 20 | Unlists a column stored as a \code{list} into a long form. 21 | } 22 | \examples{ 23 | 24 | dat <- data.frame(A = 1:3, B = I(list(c(1, 2), c(1, 3, 5), c(4)))) 25 | listCol_l(dat, "B") 26 | 27 | } 28 | \seealso{ 29 | \code{\link{listCol_w}} to flatten a \code{list} column into a "wide" format. 30 | } 31 | \author{ 32 | Ananda Mahto 33 | } 34 | -------------------------------------------------------------------------------- /man/listCol_w.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/listCol_w.R 3 | \name{listCol_w} 4 | \alias{listCol_w} 5 | \title{Flatten a Column Stored as a List} 6 | \usage{ 7 | listCol_w(inDT, listcol, drop = TRUE, fill = NA_character_) 8 | } 9 | \arguments{ 10 | \item{inDT}{The input dataset.} 11 | 12 | \item{listcol}{The name of the column stored as a \code{list}.} 13 | 14 | \item{drop}{Logical. Should the original column be dropped? Defaults to \code{TRUE}.} 15 | 16 | \item{fill}{The desired fill value. Defaults to \code{NA_character_}.} 17 | } 18 | \value{ 19 | A \code{data.table}. 20 | } 21 | \description{ 22 | Flattens a column stored as a \code{list} into a wide form. 23 | } 24 | \examples{ 25 | 26 | dat <- data.frame(A = 1:3, B = I(list(c(1, 2), c(1, 3, 5), c(4)))) 27 | listCol_w(dat, "B") 28 | 29 | } 30 | \seealso{ 31 | \code{\link{listCol_l}} to unlist a \code{list} column into a "long" format. 32 | } 33 | \author{ 34 | Ananda Mahto 35 | } 36 | -------------------------------------------------------------------------------- /man/merged.stack.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/Stacked.R 3 | \name{merged.stack} 4 | \alias{merged.stack} 5 | \title{Take a List of Stacked data.tables and Merge Them} 6 | \usage{ 7 | merged.stack(data, id.vars = NULL, var.stubs, sep, keep.all = TRUE, 8 | ...) 9 | } 10 | \arguments{ 11 | \item{data}{The input \code{data.frame}.} 12 | 13 | \item{id.vars}{The columns to be used as "ID" variables. Defaults to \code{NULL}, at which point, all names which are not identified as variable groups are used as the identifiers.} 14 | 15 | \item{var.stubs}{The prefixes of the variable groups.} 16 | 17 | \item{sep}{The character that separates the "variable name" from the "times" 18 | in the source \code{data.frame}. Alternatively, can be set to 19 | \code{"var.stubs"} (in quotes) if you do not have a value for \code{sep}.} 20 | 21 | \item{keep.all}{Logical. Should all the variables in the source 22 | \code{data.frame} be kept (\code{keep.all = TRUE}) or only those which 23 | comprise the \code{id.vars} and split data from the \code{var.stubs} 24 | (\code{keep.all = FALSE}).} 25 | 26 | \item{\dots}{Other arguments to be passed on to \code{\link{Stacked}} (for example, \code{keep.rownames} to retain the rownames of the input dataset, or \code{atStart}, in case \code{sep = "var.stubs"} is specified).} 27 | } 28 | \value{ 29 | A merged \code{data.table}. 30 | } 31 | \description{ 32 | A wrapper around the \code{\link{Stacked}} function to 33 | \code{\link[data.table:merge]{merge}} the resulting \code{list} into a 34 | single \code{data.table}. 35 | } 36 | \note{ 37 | The \code{keyed} argument to \code{\link{Stacked}} has been hard- 38 | coded to \code{TRUE} to make \code{merge} work. 39 | } 40 | \examples{ 41 | 42 | set.seed(1) 43 | mydf <- data.frame(id_1 = 1:6, id_2 = c("A", "B"), 44 | varA.1 = sample(letters, 6), 45 | varA.2 = sample(letters, 6), 46 | varA.3 = sample(letters, 6), 47 | varB.2 = sample(10, 6), 48 | varB.3 = sample(10, 6), 49 | varC.3 = rnorm(6)) 50 | mydf 51 | merged.stack(mydf, var.stubs = c("varA", "varB", "varC"), sep = ".") 52 | 53 | \dontshow{rm(mydf)} 54 | 55 | } 56 | \seealso{ 57 | \code{\link{Stacked}}, \code{\link{Reshape}} 58 | } 59 | \author{ 60 | Ananda Mahto 61 | } 62 | -------------------------------------------------------------------------------- /man/numMat.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/splitstackshape_helper_functions.R 3 | \name{numMat} 4 | \alias{numMat} 5 | \title{Create a Numeric Matrix from a List of Values} 6 | \usage{ 7 | numMat(listOfValues, fill = NA, mode = "binary") 8 | } 9 | \arguments{ 10 | \item{listOfValues}{A \code{list} of input values to be inserted in a matrix.} 11 | 12 | \item{fill}{The initializing fill value for the empty matrix.} 13 | 14 | \item{mode}{Either \code{"binary"} or \code{"value"}. Defaults to \code{"binary"}.} 15 | } 16 | \value{ 17 | A \code{matrix}. 18 | } 19 | \description{ 20 | Create a numeric matrix from a list of values 21 | } 22 | \details{ 23 | This is primarily a helper function for the \code{\link[=concat.split]{concat.split()}} function when 24 | creating the "expanded" structure. The input is anticipated to be a \code{list} of 25 | values obtained using \code{\link[base:strsplit]{base::strsplit()}}. 26 | } 27 | \examples{ 28 | 29 | invec <- c("1,2,4,5,6", "1,2,4,5,6", "1,2,4,5,6", 30 | "1,2,4,5,6", "-1,1,2,5,6", "1,2,5,6") 31 | A <- strsplit(invec, ",") 32 | splitstackshape:::numMat(A) 33 | splitstackshape:::numMat(A, fill = 0) 34 | splitstackshape:::numMat(A, mode = "value") 35 | 36 | } 37 | \seealso{ 38 | \code{\link[base:strsplit]{base::strsplit()}}, \code{\link[=charMat]{charMat()}}. 39 | } 40 | \author{ 41 | Ananda Mahto 42 | } 43 | -------------------------------------------------------------------------------- /man/othernames.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/splitstackshape_helper_functions.R 3 | \name{othernames} 4 | \alias{othernames} 5 | \title{Extract All Names From a Dataset Other Than the Ones Listed} 6 | \usage{ 7 | othernames(data, toremove) 8 | } 9 | \arguments{ 10 | \item{data}{The input \code{data.frame}.} 11 | 12 | \item{toremove}{The \code{names} you want to exclude.} 13 | } 14 | \value{ 15 | A character vector of the remaining names. 16 | } 17 | \description{ 18 | A convenience function for \code{setdiff(names(data), -some_vector_of_names-)}. 19 | } 20 | \examples{ 21 | 22 | mydf <- data.frame(a = 1:2, b = 3:4, c = 5:6) 23 | splitstackshape:::othernames(mydf, "a") 24 | 25 | } 26 | \seealso{ 27 | \code{\link[base:setdiff]{base::setdiff()}} 28 | } 29 | \author{ 30 | Ananda Mahto 31 | } 32 | -------------------------------------------------------------------------------- /man/read.concat.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/splitstackshape_helper_functions.R 3 | \name{read.concat} 4 | \alias{read.concat} 5 | \title{Read Concatenated Character Vectors Into a data.frame} 6 | \usage{ 7 | read.concat(data, col.prefix, sep, ...) 8 | } 9 | \arguments{ 10 | \item{data}{The input data.} 11 | 12 | \item{col.prefix}{The desired column prefix for the output \code{data.frame}.} 13 | 14 | \item{sep}{The character that acts as a delimiter.} 15 | 16 | \item{\dots}{Other arguments to pass to \code{\link[utils:read.table]{utils::read.table()}}.} 17 | } 18 | \value{ 19 | A \code{data.frame}. 20 | } 21 | \description{ 22 | Originally a helper function for the \code{\link[=concat.split.compact]{concat.split.compact()}} function. This 23 | function has now been effectively replaced by \code{\link[=cSplit]{cSplit()}}. 24 | } 25 | \examples{ 26 | 27 | vec <- c("a,b", "c,d,e", "f, g", "h, i, j,k") 28 | splitstackshape:::read.concat(vec, "var", ",") 29 | 30 | ## More than 5 lines the same 31 | ## `read.table` would fail with this 32 | vec <- c("12,51,34,17", "84,28,17,10", "11,43,28,15", 33 | "80,26,17,91", "10,41,25,13", "97,35,23,12,13") 34 | splitstackshape:::read.concat(vec, "var", ",") 35 | 36 | } 37 | \seealso{ 38 | \code{\link[utils:read.table]{utils::read.table()}} 39 | } 40 | \author{ 41 | Ananda Mahto 42 | } 43 | -------------------------------------------------------------------------------- /man/splitstackshape-package.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/splitstackshape-package.R 3 | \docType{package} 4 | \name{splitstackshape-package} 5 | \alias{splitstackshape-package} 6 | \alias{splitstackshape} 7 | \title{splitstackshape} 8 | \description{ 9 | Stack and Reshape Datasets After Splitting Concatenated Values 10 | } 11 | \details{ 12 | \tabular{ll}{ Package: \tab splitstackshape\cr Type: \tab Package\cr 13 | Version: \tab 1.4.8\cr Date: \tab 2019-04-21\cr License: \tab GPL-3\cr } 14 | 15 | Online data collection tools like Google Forms often export multiple-response 16 | questions with data concatenated in cells. The \code{\link[=concat.split]{concat.split()}} family of 17 | functions splits such data into separate cells. The package also includes 18 | functions to \emph{stack} groups of columns and to \emph{reshape} wide data, even when 19 | the data are "unbalanced"---something which \code{\link[stats:reshape]{stats::reshape()}} does not handle, 20 | and which \code{\link[reshape2:melt]{reshape2::melt()}} and \code{\link[reshape2:dcast]{reshape2::dcast()}} from \emph{reshape2} do not 21 | easily handle. 22 | } 23 | \examples{ 24 | 25 | ## concat.split 26 | head(cSplit(concat.test, "Likes", drop = TRUE)) 27 | 28 | ## Reshape 29 | set.seed(1) 30 | mydf <- data.frame(id_1 = 1:6, id_2 = c("A", "B"), varA.1 = sample(letters, 6), 31 | varA.2 = sample(letters, 6), varA.3 = sample(letters, 6), 32 | varB.2 = sample(10, 6), varB.3 = sample(10, 6), 33 | varC.3 = rnorm(6)) 34 | mydf 35 | Reshape(mydf, id.vars = c("id_1", "id_2"), 36 | var.stubs = c("varA", "varB", "varC")) 37 | 38 | ## Stacked 39 | Stacked(data = mydf, id.vars = c("id_1", "id_2"), 40 | var.stubs = c("varA", "varB", "varC"), 41 | sep = ".") 42 | \dontrun{ 43 | ## Processing times 44 | set.seed(1) 45 | Nrow <- 1000000 46 | Ncol <- 10 47 | mybigdf <- cbind(id = 1:Nrow, as.data.frame(matrix(rnorm(Nrow*Ncol), 48 | nrow=Nrow))) 49 | head(mybigdf) 50 | dim(mybigdf) 51 | tail(mybigdf) 52 | A <- names(mybigdf) 53 | names(mybigdf) <- c("id", paste("varA", 1:3, sep = "_"), 54 | paste("varB", 1:4, sep = "_"), 55 | paste("varC", 1:3, sep = "_")) 56 | system.time({ 57 | O1 <- Reshape(mybigdf, id.vars = "id", 58 | var.stubs = c("varA", "varB", "varC"), sep = "_") 59 | O1 <- O1[order(O1$id, O1$time), ] 60 | }) 61 | system.time({ 62 | O2 <- merged.stack(mybigdf, id.vars="id", 63 | var.stubs=c("varA", "varB", "varC"), sep = "_") 64 | }) 65 | system.time({ 66 | O3 <- Stacked(mybigdf, id.vars="id", 67 | var.stubs=c("varA", "varB", "varC"), sep = "_") 68 | }) 69 | DT <- data.table(mybigdf) 70 | system.time({ 71 | O4 <- merged.stack(DT, id.vars="id", 72 | var.stubs=c("varA", "varB", "varC"), sep = "_") 73 | }) 74 | } 75 | 76 | } 77 | \author{ 78 | Ananda Mahto 79 | 80 | Maintainer: Ananda Mahto \href{mailto:mrdwab@gmail.com}{mrdwab@gmail.com} 81 | } 82 | \keyword{package} 83 | -------------------------------------------------------------------------------- /revdep/README.md: -------------------------------------------------------------------------------- 1 | # Platform 2 | 3 | |field |value | 4 | |:--------|:----------------------------| 5 | |version |R version 3.5.1 (2018-07-02) | 6 | |os |Ubuntu 18.10 | 7 | |system |x86_64, linux-gnu | 8 | |ui |RStudio | 9 | |language |en_IN:en | 10 | |collate |en_IN.UTF-8 | 11 | |ctype |en_IN.UTF-8 | 12 | |tz |America/Los_Angeles | 13 | |date |2019-04-21 | 14 | 15 | # Dependencies 16 | 17 | |package |old |new |Δ | 18 | |:---------------|:------|:------|:--| 19 | |splitstackshape |1.4.6 |1.4.8 |* | 20 | |data.table |1.12.2 |1.12.2 | | 21 | 22 | # Revdeps 23 | 24 | ## Failed to check (2) 25 | 26 | |package |version |error |warning |note | 27 | |:----------------------|:-------|:-----|:-------|:----| 28 | |contextual |? | | | | 29 | |sensitivityCalibration |? | | | | 30 | 31 | -------------------------------------------------------------------------------- /revdep/check.R: -------------------------------------------------------------------------------- 1 | library("devtools") 2 | 3 | revdep_check() 4 | revdep_check_save_summary() 5 | revdep_check_print_problems() 6 | -------------------------------------------------------------------------------- /revdep/checks.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrdwab/splitstackshape/edd44d17c5fa69ae9b1b31808c8a2426a1bd7176/revdep/checks.rds -------------------------------------------------------------------------------- /revdep/checks/Diderot/Diderot_0.12.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrdwab/splitstackshape/edd44d17c5fa69ae9b1b31808c8a2426a1bd7176/revdep/checks/Diderot/Diderot_0.12.tar.gz -------------------------------------------------------------------------------- /revdep/checks/Diderot/new/Diderot.Rcheck/00check.log: -------------------------------------------------------------------------------- 1 | * using log directory ‘/home/mrdwab/Documents/Packages/splitstackshape/revdep/checks/Diderot/new/Diderot.Rcheck’ 2 | * using R version 3.5.1 (2018-07-02) 3 | * using platform: x86_64-pc-linux-gnu (64-bit) 4 | * using session charset: UTF-8 5 | * using options ‘--no-manual --no-build-vignettes’ 6 | * checking for file ‘Diderot/DESCRIPTION’ ... OK 7 | * checking extension type ... Package 8 | * this is package ‘Diderot’ version ‘0.12’ 9 | * checking package namespace information ... OK 10 | * checking package dependencies ... ERROR 11 | Packages required but not available: ‘RCurl’ ‘doParallel’ 12 | 13 | See section ‘The DESCRIPTION file’ in the ‘Writing R Extensions’ 14 | manual. 15 | * DONE 16 | Status: 1 ERROR 17 | -------------------------------------------------------------------------------- /revdep/checks/Diderot/new/libraries.txt: -------------------------------------------------------------------------------- 1 | Library: /home/mrdwab/Documents/Packages/splitstackshape/revdep/library/splitstackshape/new 2 | data.table (1.12.2) 3 | splitstackshape (1.4.8) 4 | 5 | Library: /home/mrdwab/Documents/Packages/splitstackshape/revdep/library/Diderot 6 | bitops (1.0-6) 7 | codetools (0.2-16) 8 | data.table (1.12.2) 9 | foreach (1.4.4) 10 | igraph (1.2.4) 11 | iterators (1.0.10) 12 | lattice (0.20-38) 13 | magrittr (1.5) 14 | Matrix (1.2-17) 15 | pkgconfig (2.0.2) 16 | stringi (1.4.3) 17 | -------------------------------------------------------------------------------- /revdep/checks/Diderot/old/Diderot.Rcheck/00check.log: -------------------------------------------------------------------------------- 1 | * using log directory ‘/home/mrdwab/Documents/Packages/splitstackshape/revdep/checks/Diderot/old/Diderot.Rcheck’ 2 | * using R version 3.5.1 (2018-07-02) 3 | * using platform: x86_64-pc-linux-gnu (64-bit) 4 | * using session charset: UTF-8 5 | * using options ‘--no-manual --no-build-vignettes’ 6 | * checking for file ‘Diderot/DESCRIPTION’ ... OK 7 | * checking extension type ... Package 8 | * this is package ‘Diderot’ version ‘0.12’ 9 | * checking package namespace information ... OK 10 | * checking package dependencies ... ERROR 11 | Packages required but not available: ‘RCurl’ ‘doParallel’ 12 | 13 | See section ‘The DESCRIPTION file’ in the ‘Writing R Extensions’ 14 | manual. 15 | * DONE 16 | Status: 1 ERROR 17 | -------------------------------------------------------------------------------- /revdep/checks/Diderot/old/libraries.txt: -------------------------------------------------------------------------------- 1 | Library: /home/mrdwab/Documents/Packages/splitstackshape/revdep/library/splitstackshape/old 2 | data.table (1.12.2) 3 | splitstackshape (1.4.6) 4 | 5 | Library: /home/mrdwab/Documents/Packages/splitstackshape/revdep/library/Diderot 6 | bitops (1.0-6) 7 | codetools (0.2-16) 8 | data.table (1.12.2) 9 | foreach (1.4.4) 10 | igraph (1.2.4) 11 | iterators (1.0.10) 12 | lattice (0.20-38) 13 | magrittr (1.5) 14 | Matrix (1.2-17) 15 | pkgconfig (2.0.2) 16 | stringi (1.4.3) 17 | -------------------------------------------------------------------------------- /revdep/checks/MotifDb/MotifDb_1.24.1.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrdwab/splitstackshape/edd44d17c5fa69ae9b1b31808c8a2426a1bd7176/revdep/checks/MotifDb/MotifDb_1.24.1.tar.gz -------------------------------------------------------------------------------- /revdep/checks/MotifDb/new/MotifDb.Rcheck/00check.log: -------------------------------------------------------------------------------- 1 | * using log directory ‘/home/mrdwab/Documents/Packages/splitstackshape/revdep/checks/MotifDb/new/MotifDb.Rcheck’ 2 | * using R version 3.5.1 (2018-07-02) 3 | * using platform: x86_64-pc-linux-gnu (64-bit) 4 | * using session charset: UTF-8 5 | * using options ‘--no-manual --no-build-vignettes’ 6 | * checking for file ‘MotifDb/DESCRIPTION’ ... OK 7 | * checking extension type ... Package 8 | * this is package ‘MotifDb’ version ‘1.24.1’ 9 | * checking package namespace information ... OK 10 | * checking package dependencies ... ERROR 11 | Packages required but not available: 12 | ‘S4Vectors’ ‘IRanges’ ‘Biostrings’ ‘rtracklayer’ 13 | 14 | See section ‘The DESCRIPTION file’ in the ‘Writing R Extensions’ 15 | manual. 16 | * DONE 17 | Status: 1 ERROR 18 | -------------------------------------------------------------------------------- /revdep/checks/MotifDb/new/libraries.txt: -------------------------------------------------------------------------------- 1 | Library: /home/mrdwab/Documents/Packages/splitstackshape/revdep/library/splitstackshape/new 2 | data.table (1.12.2) 3 | splitstackshape (1.4.8) 4 | 5 | Library: /home/mrdwab/Documents/Packages/splitstackshape/revdep/library/MotifDb 6 | BH (1.69.0-1) 7 | BiocGenerics (0.28.0) 8 | BiocParallel (1.16.6) 9 | bitops (1.0-6) 10 | data.table (1.12.2) 11 | formatR (1.6) 12 | futile.logger (1.4.3) 13 | futile.options (1.0.1) 14 | GenomeInfoDbData (1.2.0) 15 | lambda.r (1.2.3) 16 | lattice (0.20-38) 17 | Matrix (1.2-17) 18 | matrixStats (0.54.0) 19 | RUnit (0.4.32) 20 | snow (0.4-3) 21 | XML (3.98-1.19) 22 | zlibbioc (1.28.0) 23 | -------------------------------------------------------------------------------- /revdep/checks/MotifDb/old/MotifDb.Rcheck/00check.log: -------------------------------------------------------------------------------- 1 | * using log directory ‘/home/mrdwab/Documents/Packages/splitstackshape/revdep/checks/MotifDb/old/MotifDb.Rcheck’ 2 | * using R version 3.5.1 (2018-07-02) 3 | * using platform: x86_64-pc-linux-gnu (64-bit) 4 | * using session charset: UTF-8 5 | * using options ‘--no-manual --no-build-vignettes’ 6 | * checking for file ‘MotifDb/DESCRIPTION’ ... OK 7 | * checking extension type ... Package 8 | * this is package ‘MotifDb’ version ‘1.24.1’ 9 | * checking package namespace information ... OK 10 | * checking package dependencies ... ERROR 11 | Packages required but not available: 12 | ‘S4Vectors’ ‘IRanges’ ‘Biostrings’ ‘rtracklayer’ 13 | 14 | See section ‘The DESCRIPTION file’ in the ‘Writing R Extensions’ 15 | manual. 16 | * DONE 17 | Status: 1 ERROR 18 | -------------------------------------------------------------------------------- /revdep/checks/MotifDb/old/libraries.txt: -------------------------------------------------------------------------------- 1 | Library: /home/mrdwab/Documents/Packages/splitstackshape/revdep/library/splitstackshape/old 2 | data.table (1.12.2) 3 | splitstackshape (1.4.6) 4 | 5 | Library: /home/mrdwab/Documents/Packages/splitstackshape/revdep/library/MotifDb 6 | BH (1.69.0-1) 7 | BiocGenerics (0.28.0) 8 | BiocParallel (1.16.6) 9 | bitops (1.0-6) 10 | data.table (1.12.2) 11 | formatR (1.6) 12 | futile.logger (1.4.3) 13 | futile.options (1.0.1) 14 | GenomeInfoDbData (1.2.0) 15 | lambda.r (1.2.3) 16 | lattice (0.20-38) 17 | Matrix (1.2-17) 18 | matrixStats (0.54.0) 19 | RUnit (0.4.32) 20 | snow (0.4-3) 21 | XML (3.98-1.19) 22 | zlibbioc (1.28.0) 23 | -------------------------------------------------------------------------------- /revdep/checks/cnvGSA/cnvGSA_1.26.0.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrdwab/splitstackshape/edd44d17c5fa69ae9b1b31808c8a2426a1bd7176/revdep/checks/cnvGSA/cnvGSA_1.26.0.tar.gz -------------------------------------------------------------------------------- /revdep/checks/cnvGSA/new/cnvGSA.Rcheck/00check.log: -------------------------------------------------------------------------------- 1 | * using log directory ‘/home/mrdwab/Documents/Packages/splitstackshape/revdep/checks/cnvGSA/new/cnvGSA.Rcheck’ 2 | * using R version 3.5.1 (2018-07-02) 3 | * using platform: x86_64-pc-linux-gnu (64-bit) 4 | * using session charset: UTF-8 5 | * using options ‘--no-manual --no-build-vignettes’ 6 | * checking for file ‘cnvGSA/DESCRIPTION’ ... OK 7 | * checking extension type ... Package 8 | * this is package ‘cnvGSA’ version ‘1.26.0’ 9 | * checking package namespace information ... OK 10 | * checking package dependencies ... ERROR 11 | Packages required but not available: ‘brglm’ ‘doParallel’ ‘GenomicRanges’ 12 | 13 | Packages suggested but not available for checking: 14 | ‘cnvGSAdata’ ‘org.Hs.eg.db’ 15 | 16 | See section ‘The DESCRIPTION file’ in the ‘Writing R Extensions’ 17 | manual. 18 | * DONE 19 | Status: 1 ERROR 20 | -------------------------------------------------------------------------------- /revdep/checks/cnvGSA/new/libraries.txt: -------------------------------------------------------------------------------- 1 | Library: /home/mrdwab/Documents/Packages/splitstackshape/revdep/library/splitstackshape/new 2 | data.table (1.12.2) 3 | splitstackshape (1.4.8) 4 | 5 | Library: /home/mrdwab/Documents/Packages/splitstackshape/revdep/library/cnvGSA 6 | assertthat (0.2.1) 7 | BH (1.69.0-1) 8 | BiocGenerics (0.28.0) 9 | bit (1.1-14) 10 | bit64 (0.9-7) 11 | bitops (1.0-6) 12 | blob (1.1.1) 13 | codetools (0.2-16) 14 | data.table (1.12.2) 15 | DBI (1.0.0) 16 | digest (0.6.18) 17 | foreach (1.4.4) 18 | GenomeInfoDbData (1.2.0) 19 | iterators (1.0.10) 20 | magrittr (1.5) 21 | memoise (1.1.0) 22 | pkgconfig (2.0.2) 23 | plogr (0.2.0) 24 | prettyunits (1.0.2) 25 | profileModel (0.6.0) 26 | Rcpp (1.0.1) 27 | RSQLite (2.1.1) 28 | zlibbioc (1.28.0) 29 | -------------------------------------------------------------------------------- /revdep/checks/cnvGSA/old/cnvGSA.Rcheck/00check.log: -------------------------------------------------------------------------------- 1 | * using log directory ‘/home/mrdwab/Documents/Packages/splitstackshape/revdep/checks/cnvGSA/old/cnvGSA.Rcheck’ 2 | * using R version 3.5.1 (2018-07-02) 3 | * using platform: x86_64-pc-linux-gnu (64-bit) 4 | * using session charset: UTF-8 5 | * using options ‘--no-manual --no-build-vignettes’ 6 | * checking for file ‘cnvGSA/DESCRIPTION’ ... OK 7 | * checking extension type ... Package 8 | * this is package ‘cnvGSA’ version ‘1.26.0’ 9 | * checking package namespace information ... OK 10 | * checking package dependencies ... ERROR 11 | Packages required but not available: ‘brglm’ ‘doParallel’ ‘GenomicRanges’ 12 | 13 | Packages suggested but not available for checking: 14 | ‘cnvGSAdata’ ‘org.Hs.eg.db’ 15 | 16 | See section ‘The DESCRIPTION file’ in the ‘Writing R Extensions’ 17 | manual. 18 | * DONE 19 | Status: 1 ERROR 20 | -------------------------------------------------------------------------------- /revdep/checks/cnvGSA/old/libraries.txt: -------------------------------------------------------------------------------- 1 | Library: /home/mrdwab/Documents/Packages/splitstackshape/revdep/library/splitstackshape/old 2 | data.table (1.12.2) 3 | splitstackshape (1.4.6) 4 | 5 | Library: /home/mrdwab/Documents/Packages/splitstackshape/revdep/library/cnvGSA 6 | assertthat (0.2.1) 7 | BH (1.69.0-1) 8 | BiocGenerics (0.28.0) 9 | bit (1.1-14) 10 | bit64 (0.9-7) 11 | bitops (1.0-6) 12 | blob (1.1.1) 13 | codetools (0.2-16) 14 | data.table (1.12.2) 15 | DBI (1.0.0) 16 | digest (0.6.18) 17 | foreach (1.4.4) 18 | GenomeInfoDbData (1.2.0) 19 | iterators (1.0.10) 20 | magrittr (1.5) 21 | memoise (1.1.0) 22 | pkgconfig (2.0.2) 23 | plogr (0.2.0) 24 | prettyunits (1.0.2) 25 | profileModel (0.6.0) 26 | Rcpp (1.0.1) 27 | RSQLite (2.1.1) 28 | zlibbioc (1.28.0) 29 | -------------------------------------------------------------------------------- /revdep/checks/libraries.csv: -------------------------------------------------------------------------------- 1 | package,old,new,delta 2 | splitstackshape,1.4.6,1.4.8,* 3 | data.table,1.12.2,1.12.2, 4 | -------------------------------------------------------------------------------- /revdep/checks/pinyin/new/libraries.txt: -------------------------------------------------------------------------------- 1 | Library: /home/mrdwab/Documents/Packages/splitstackshape/revdep/library/splitstackshape/new 2 | data.table (1.12.2) 3 | splitstackshape (1.4.8) 4 | 5 | Library: /home/mrdwab/Documents/Packages/splitstackshape/revdep/library/pinyin 6 | data.table (1.12.2) 7 | -------------------------------------------------------------------------------- /revdep/checks/pinyin/new/pinyin.Rcheck/00check.log: -------------------------------------------------------------------------------- 1 | * using log directory ‘/home/mrdwab/Documents/Packages/splitstackshape/revdep/checks/pinyin/new/pinyin.Rcheck’ 2 | * using R version 3.5.1 (2018-07-02) 3 | * using platform: x86_64-pc-linux-gnu (64-bit) 4 | * using session charset: UTF-8 5 | * using options ‘--no-manual --no-build-vignettes’ 6 | * checking for file ‘pinyin/DESCRIPTION’ ... OK 7 | * this is package ‘pinyin’ version ‘1.1.5’ 8 | * checking package namespace information ... OK 9 | * checking package dependencies ... OK 10 | * checking if this is a source package ... OK 11 | * checking if there is a namespace ... OK 12 | * checking for executable files ... OK 13 | * checking for hidden files and directories ... OK 14 | * checking for portable file names ... OK 15 | * checking for sufficient/correct file permissions ... OK 16 | * checking whether package ‘pinyin’ can be installed ... OK 17 | * checking installed package size ... OK 18 | * checking package directory ... OK 19 | * checking DESCRIPTION meta-information ... OK 20 | * checking top-level files ... OK 21 | * checking for left-over files ... OK 22 | * checking index information ... OK 23 | * checking package subdirectories ... OK 24 | * checking R files for non-ASCII characters ... OK 25 | * checking R files for syntax errors ... OK 26 | * checking whether the package can be loaded ... OK 27 | * checking whether the package can be loaded with stated dependencies ... OK 28 | * checking whether the package can be unloaded cleanly ... OK 29 | * checking whether the namespace can be loaded with stated dependencies ... OK 30 | * checking whether the namespace can be unloaded cleanly ... OK 31 | * checking loading without being on the library search path ... OK 32 | * checking dependencies in R code ... OK 33 | * checking S3 generic/method consistency ... OK 34 | * checking replacement functions ... OK 35 | * checking foreign function calls ... OK 36 | * checking R code for possible problems ... OK 37 | * checking Rd files ... OK 38 | * checking Rd metadata ... OK 39 | * checking Rd cross-references ... OK 40 | * checking for missing documentation entries ... OK 41 | * checking for code/documentation mismatches ... OK 42 | * checking Rd \usage sections ... OK 43 | * checking Rd contents ... OK 44 | * checking for unstated dependencies in examples ... OK 45 | * checking examples ... OK 46 | * DONE 47 | Status: OK 48 | -------------------------------------------------------------------------------- /revdep/checks/pinyin/new/pinyin.Rcheck/00install.out: -------------------------------------------------------------------------------- 1 | * installing *source* package ‘pinyin’ ... 2 | ** package ‘pinyin’ successfully unpacked and MD5 sums checked 3 | ** R 4 | ** inst 5 | ** byte-compile and prepare package for lazy loading 6 | ** help 7 | *** installing help indices 8 | ** building package indices 9 | ** testing if installed package can be loaded 10 | * DONE (pinyin) 11 | -------------------------------------------------------------------------------- /revdep/checks/pinyin/new/pinyin.Rcheck/pinyin-Ex.R: -------------------------------------------------------------------------------- 1 | pkgname <- "pinyin" 2 | source(file.path(R.home("share"), "R", "examples-header.R")) 3 | options(warn = 1) 4 | library('pinyin') 5 | 6 | base::assign(".oldSearch", base::search(), pos = 'CheckExEnv') 7 | base::assign(".old_wd", base::getwd(), pos = 'CheckExEnv') 8 | cleanEx() 9 | nameEx("bookdown2py") 10 | ### * bookdown2py 11 | 12 | flush(stderr()); flush(stdout()) 13 | 14 | ### Name: bookdown2py 15 | ### Title: Convert the Chinese headers of bookdown .Rmd files into Pinyin 16 | ### Aliases: bookdown2py 17 | 18 | ### ** Examples 19 | 20 | bookdown2py(dic = NA) 21 | 22 | 23 | 24 | cleanEx() 25 | nameEx("file.rename2py") 26 | ### * file.rename2py 27 | 28 | flush(stderr()); flush(stdout()) 29 | 30 | ### Name: file.rename2py 31 | ### Title: Rename files according to a given dictionary 32 | ### Aliases: file.rename2py 33 | 34 | ### ** Examples 35 | 36 | file.rename2py(dic = NA) 37 | 38 | 39 | 40 | cleanEx() 41 | nameEx("file2py") 42 | ### * file2py 43 | 44 | flush(stderr()); flush(stdout()) 45 | 46 | ### Name: file2py 47 | ### Title: Convert the characters in an entire files according to a given 48 | ### dictionary 49 | ### Aliases: file2py 50 | 51 | ### ** Examples 52 | 53 | file2py(dic = NA) 54 | 55 | 56 | 57 | cleanEx() 58 | nameEx("load_dic") 59 | ### * load_dic 60 | 61 | flush(stderr()); flush(stdout()) 62 | 63 | ### Name: load_dic 64 | ### Title: Load a customized dictionary. 65 | ### Aliases: load_dic 66 | 67 | ### ** Examples 68 | 69 | load_dic() 70 | 71 | 72 | 73 | cleanEx() 74 | nameEx("pinyin") 75 | ### * pinyin 76 | 77 | flush(stderr()); flush(stdout()) 78 | 79 | ### Name: pinyin 80 | ### Title: Former version of py() 81 | ### Aliases: pinyin 82 | 83 | ### ** Examples 84 | 85 | pinyin() 86 | 87 | 88 | 89 | cleanEx() 90 | nameEx("py") 91 | ### * py 92 | 93 | flush(stderr()); flush(stdout()) 94 | 95 | ### Name: py 96 | ### Title: Convert strings of Chinese characters into Pinyin. 97 | ### Aliases: py 98 | 99 | ### ** Examples 100 | 101 | py(dic = NA) 102 | 103 | 104 | 105 | cleanEx() 106 | nameEx("pydic") 107 | ### * pydic 108 | 109 | flush(stderr()); flush(stdout()) 110 | 111 | ### Name: pydic 112 | ### Title: Load a Pinyin library 113 | ### Aliases: pydic 114 | 115 | ### ** Examples 116 | 117 | pydic() 118 | 119 | 120 | 121 | ### *