Learn R Programming

str2str (version 1.0.0)

Convert R Objects from One Structure to Another

Description

Offers a suite of functions for converting to and from (atomic) vectors, matrices, data.frames, and (3D+) arrays as well as lists of these objects. It is an alternative to the base R as..() functions (e.g., as.data.frame.array()) that provides more useful and/or flexible restructuring of R objects. To do so, it only works with common structuring of R objects (e.g., data.frames with only atomic vector columns).

Copy Link

Version

Install

install.packages('str2str')

Monthly Downloads

1,179

Version

1.0.0

License

GPL (>= 2)

Maintainer

David Disabato

Last Published

November 20th, 2023

Functions in str2str (1.0.0)

d2ld

Data-Frame to List of Data-Frames
cbind_fill

Bind DataFrames Along Columns - Filling in Missing Rows with NA
codes

Integer Codes of Factor Levels
cbind<-

Add Columns to Data Objects
d2d

Data-Frame to Data-Frame (e.g., factors to character vectors)
cat0

Concatenate and Print with No Separator
cbind_fill_matrix

Bind Matrices Along Columns - Filling in Missing Rows with NA
d2lv

Data-Frame to List of (Atomic) Vectors
d2a

Data-Frame to (3D+) Array or Matrix
d2m

Data-Frame to Matrix
fct2v

Factor to (Atomic) Vector
d2v

Data-Frame to (Atomic) Vector
is.POSIXct

Test for a POSIXct object
grab

grab extracts the contents of objects in an environment based on their object names as a character vector. The object contents are stored to a list where the names are the object names.
dimlabels<-

Add Elements to Vectors
dimlabels

Dimension labels (i.e., names of dimnames)
is.Date

Test for a Date object
inbtw

Elements Inbetween Values Within a (Atomic) Vector
e2l

Environment to List
is.avector

Test for an Atomic Vector
is.cnumeric

Test for Character Numbers
is.names

Test for `names`
is.empty

Test for Empty Characters
la2a

List of (3D+) Arrays to (3D+) Array
is.whole

Test for Whole Numbers
is.dummy

Test for a Dummy Variable
is.row.names

Test for `row.names`
is.rownames

Test for `rownames`
is.colnames

Test for `colnames`
is.POSIXlt

Test for a POSIXlt object
ld2a

List of Data-Frames to a 3D Array
laynames

Names of the Layers (the Third Dimension)
lv2d

List of (atomic) vectors to Data-Frame
lm2v

List of Matrices to (Atomic) Vector
not.names

Identify Elements That are Not Names
lv2m

List of (atomic) Vectors to Matrix
not.colnames

Identify Elements That are Not Colnames
m2d

Matrix to Data-Frame
nlay

Number of Layers (the Third Dimension)
lv2v

List of (atomic) Vectors to (atomic) Vector
ld2d

List of Data-Frames to Data-Frame
m2lv

Matrix to List of (Atomic) Vectors
ld2v

List of Data-Frames to (Atomic) Vector
not.rownames

Identify Elements That are Not Rownames
order.custom

Custom Order Permutation
not.row.names

Identify Elements That are Not Row.names
str2str-package

Structure to Structure
pick

Extract Elements From a (Atomic) Vector
rbind<-

Add Rows to Data Objects
t_list

Transpose a List
sn

Set a Vector's Names as its Elements
unstack2

Unstack one Set of Variables from Long to Wide
stack2

Stack one Set of Variables from Wide to Long
undimname

Undimname an Object
lm2d

List of Matrices to Data-Frame
m2v

Matrix to (Atomic) Vector
v2lv

(Atomic) Vector to List of (Atomic) Vectors
v2frm

Character Vector to Formula
try_fun

Add Try to Function
ndim

Number of Object Dimensions
lm2a

List of Matrices to 3D Array
try_expr

Add Try to Expression
v2m

(Atomic) Vector to Matrix
undim

Undimension an Object
v2d

(Atomic) Vector to Data-Frame
undimlabel

Undimlabel an Object
v2fct

Character Vector to (Unordered) Factor
all_same

Test if All Elements are the Same
append<-

Add Elements to Vectors
Join

Join (or Merge) a List of Data-frames
all_diff

Test if All Elements are Different
a2la

(3D+) Array to List of (3D+) Arrays
a2d

(3D+) Array to Data-Frame
a2lm

(3D) Array to List of Matrices
a2ld

3D Array to List of Data-Frames
abind<-

Add array slices to 3D+ Array `abind<-` adds array slices to arrays as a side effect. It used the function abind in the abind package. The purpose of the function is to replace the need to use ary2 <- abind(ary1, mat1); ary3 <- rbind(ary2, mat2); ary4 <- rbind(ary3, mat3), etc. It allows you to specify the dimension you wish to bind along as well as the dimname you wish to bind after. Unlike `cbind<-`, `rbind<-`, and `append<-`, it does not have overwriting functionality (I could not figure out how to code that); therefore, if value has some dimnames that are the same as those in a, it will NOT overwrite them and simply bind them to a, resulting in duplicate dimnames.
a2v

(3D+) Array to (Atomic) Vector