Learn R Programming

⚠️There's a newer version (0.5.2) of this package.Take me there.

usefun

A set of general functions that I have used in various projects and in other R packages. They support some miscellaneous operations on data frames, matrices and vectors: adding a row on a ternary (3-value) data.frame based on positive and negative vector-indicators, rearranging a list of data.frames by rownames, pruning rows or columns of a data.frame that contain only one specific value given by the user, checking for matrix equality, pruning and reordering a vector according to the common elements between its names and elements of another given vector, finding the non-common elements between two vectors (outer-section), normalization of a vector, matrix or data.frame's numeric values in a specified range, pretty printing of vector names and values in an R notebook (common names and values between two vectors also supported), retrieving the parent directory of any string path, checking whether a numeric value is inside a given interval, trim the decimal points of a given numeric value, quick saving of data to a file, making a multiple densities plot and a color bar plot and executing a plot string expression while generating the result to the specified file format.

Install

devtools::install_github("bblodfon/usefun")

Examples

See examples in the functions documentation and in the respective tests. Also various functions from this package have been used in this biomarker analysis.

Copy Link

Version

Install

install.packages('usefun')

Monthly Downloads

346

Version

0.4.1

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

John Zobolas

Last Published

October 11th, 2019

Functions in usefun (0.4.1)

make_multiple_density_plot

Multiple densities plot
prune_and_reorder_vector

Prune and reorder vector elements
mat_equal

Matrix equality
prune_columns_from_df

Prune single-value columns from a data frame
pretty_print_name_and_value

Pretty print a name and value
prune_rows_from_df

Prune single-value rows from a data frame
usefun

usefun
outersect

Outersect
normalize_to_range

Range normalization
pretty_print_string

Pretty print a string
remove_commented_and_empty_lines

Remove commented and empty lines
get_common_names

Get the common names of two vectors
plot_string_to_file

Plot string to output format
save_df_to_file

Save data frame to a specified file
ldf_arrange_by_rownames

Rearrange a list of data frames by rownames
save_mat_to_file

Save matrix to a specified file
save_vector_to_file

Save vector to a specified file
specify_decimal

Specify decimal
pretty_print_vector_values

Pretty printing of a vector's values
print_empty_line

Print an empty line
pretty_print_bold_string

Pretty print a bold string
pretty_print_vector_names

Pretty printing of a vector's names attribute
pretty_print_vector_names_and_values

Pretty printing of a vector's names and values
make_color_bar_plot

Make a color bar plot
is_empty

Is object empty?
add_vector_to_df

Add vector to a (n x 2) data frame
get_ternary_class_id

Get ternary class id
get_parent_dir

Retrieve the parent directory
is_between

Is value between two others?
get_common_values

Get the common values of two vectors
add_row_to_ternary_df

Add a row to a 3-valued (ternary) data.frame
get_percentage_of_matches

Get percentage of matches between two vectors
get_average_over_unique_values

Get average over unique values