Coder Social home page Coder Social logo

heck's Introduction

heck

R-CMD-check heck status badge Codecov test coverage CRAN status

This repository was developed from the excellent extendr tutorial. This package is a thin wrapper around the rust crate heck allowing R to convert character vectors to specific cases super fast.

Installation

You can install the development version of heck like so:

r-universe:

install.packages("heck", repos = c("https://dyfanjones.r-universe.dev", "https://cran.r-project.org"))

Github:

remotes::install_github("dyfanjones/heck")

Code of Conduct

Please note that the R heck project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

Example

library(heck)


x <- "Demo String"

to_kebab_case(x)
#> [1] "demo-string"
to_lower_camel_case(x)
#> [1] "demoString"
to_upper_camel_case(x)
#> [1] "DemoString"
to_pascal_case(x)
#> [1] "DemoString"
to_snake_case(x)
#> [1] "demo_string"
to_snek_case(x)
#> [1] "demo_string"
to_title_case(x)
#> [1] "Demo String"
to_train_case(x)
#> [1] "Demo-String"
to_shouty_kebab_case(x)
#> [1] "DEMO-STRING"
to_shouty_snake_case(x)
#> [1] "DEMO_STRING"

heck's People

Contributors

dyfanjones avatar josiahparry avatar olivroy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

josiahparry

heck's Issues

heck installation issue: rhub issue macos (R-devel)

* installing *source* package ‘heck’ ...
** using staged installation
** libs
using C compiler: ‘Apple clang version 15.0.0 (clang-1500.0.40.1)’
using SDK: ‘’
rm -Rf heck.so ./rust/target/release/libheck.a entrypoint.o /Users/runner/work/heck/heck/check/heck.Rcheck/00_pkg_src/heck/src/.cargo /Users/runner/work/heck/heck/check/heck.Rcheck/00_pkg_src/heck/src/vendor
clang -arch x86_64 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I/opt/R/x86_64/include    -fPIC  -falign-functions=64 -Wall -g -O2  -c entrypoint.c -o entrypoint.o
if [ -f ./rust/vendor.tar.xz ]; then \
		tar xf rust/vendor.tar.xz && \
		mkdir -p /Users/runner/work/heck/heck/check/heck.Rcheck/00_pkg_src/heck/src/.cargo && \
		cp rust/vendor-config.toml /Users/runner/work/heck/heck/check/heck.Rcheck/00_pkg_src/heck/src/.cargo/config.toml; \
	fi
# In some environments, ~/.cargo/bin might not be included in PATH, so we need
# to set it here to ensure cargo can be invoked. It is appended to PATH and
# therefore is only used if cargo is absent from the user's PATH.
if [ "true" != "true" ]; then \
		export CARGO_HOME=/Users/runner/work/heck/heck/check/heck.Rcheck/00_pkg_src/heck/src/.cargo; \
	fi && \
		export PATH="/Users/runner/work/heck/heck/check/heck.Rcheck/R_check_bin:/opt/R/x86_64/bin:/opt/gfortran/bin:/usr/local/lib/ruby/gems/3.0.0/bin:/usr/local/opt/[email protected]/bin:/usr/local/opt/pipx_bin:/Users/runner/.cargo/bin:/usr/local/opt/curl/bin:/usr/local/bin:/usr/local/sbin:/Users/runner/bin:/Users/runner/.yarn/bin:/Users/runner/Library/Android/sdk/tools:/Users/runner/Library/Android/sdk/platform-tools:/Library/Frameworks/Python.framework/Versions/Current/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/usr/bin:/bin:/usr/sbin:/sbin:/Users/runner/.dotnet/tools:/Users/runner/.cargo/bin" && \
			cargo build -j 2 --offline --lib --release --manifest-path=./rust/Cargo.toml --target-dir ./rust/target && \
			echo `cargo --version` && echo `rustc --version`;
   Compiling proc-macro2 v1.0.79
   Compiling unicode-ident v1.0.12
   Compiling libR-sys v0.7.0
   Compiling paste v1.0.14
   Compiling quote v1.0.36
   Compiling syn v2.0.58
   Compiling extendr-api v0.7.0
error[E0428]: the name `R_altrep_Coerce_method_t` is defined multiple times
   --> /Users/runner/work/heck/heck/check/heck.Rcheck/00_pkg_src/heck/src/./rust/target/release/build/libR-sys-80f46fe92fda2ece/out/bindings.rs:595:1
    |
595 | / pub type R_altrep_Coerce_method_t =
596 | |     ::std::option::Option<unsafe extern "C" fn(arg1: SEXP, arg2: ::std::os::raw::c_int) -> SEXP>;
    | |_________________________________________________________________________________________________^ `R_altrep_Coerce_method_t` redefined here
    |
   ::: /Users/runner/work/heck/heck/check/heck.Rcheck/00_pkg_src/heck/src/vendor/libR-sys/src/lib.rs:80:1
    |
80  | / pub type R_altrep_Coerce_method_t =
81  | |     ::std::option::Option<unsafe extern "C" fn(arg1: SEXP, arg2: SEXPTYPE) -> SEXP>;
    | |____________________________________________________________________________________- previous definition of the type `R_altrep_Coerce_method_t` here
    |
    = note: `R_altrep_Coerce_method_t` must be defined only once in the type namespace of this module

error[E0428]: the name `Rf_isS4` is defined multiple times
    --> /Users/runner/work/heck/heck/check/heck.Rcheck/00_pkg_src/heck/src/./rust/target/release/build/libR-sys-80f46fe92fda2ece/out/bindings.rs:1721:5
     |
1721 |     pub fn Rf_isS4(arg1: SEXP) -> Rboolean;
     |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Rf_isS4` redefined here
     |
    ::: /Users/runner/work/heck/heck/check/heck.Rcheck/00_pkg_src/heck/src/vendor/libR-sys/src/lib.rs:83:1
     |
83   | pub unsafe fn Rf_isS4(arg1: SEXP) -> Rboolean {
     | --------------------------------------------- previous definition of the value `Rf_isS4` here
     |
     = note: `Rf_isS4` must be defined only once in the value namespace of this module

For more information about this error, try `rustc --explain E0428`.
error: could not compile `libR-sys` (lib) due to 2 previous errors
warning: build failed, waiting for other jobs to finish...
make: *** [rust/target/release/libheck.a] Error 101
ERROR: compilation failed for package ‘heck’
* removing ‘/Users/runner/work/heck/heck/check/heck.Rcheck/heck’

Cran Issue

Dear maintainer,

Please see the problems shown on
https://cran.r-project.org/web/checks/check_results_heck.html.

Please correct before 2024-07-10 to safely retain your package on CRAN.

Version: 0.1.0
Check: compiled code
Result: WARN 
  File ‘heck/libs/heck.so’:
    Found non-API calls to R: ‘ENVFLAGS’, ‘FRAME’, ‘HASHTAB’, ‘PRCODE’,
      ‘PRENV’, ‘PRSEEN’, ‘PRVALUE’, ‘Rf_findVarInFrame3’, ‘SET_BODY’,
      ‘SET_CLOENV’, ‘SET_ENCLOS’, ‘SET_ENVFLAGS’, ‘SET_FORMALS’,
      ‘SET_PRCODE’, ‘SET_PRENV’, ‘SET_PRVALUE’, ‘STRING_PTR’, ‘SYMVALUE’,
      ‘XLENGTH_EX’
  These entry points may be removed soon:
  ‘PRSEEN’, ‘SYMVALUE’
  
  Compiled code should not call non-API entry points in R.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.