Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ci-misc
R-utility-belt
Commits
3088d486
Commit
3088d486
authored
Feb 16, 2021
by
Quentin Read
Browse files
fxn to replace na in data tables
parent
08a9a0ac
Changes
5
Hide whitespace changes
Inline
Side-by-side
NAMESPACE
View file @
3088d486
...
...
@@ -2,5 +2,6 @@
export(group_nest_dt)
export(read.csv.better)
export(replace_na_dt)
export(unnest_dt)
import(data.table)
R/replace_na_dt.R
0 → 100644
View file @
3088d486
#' Replace NA in a data table
#'
#' Modified from a function written by Matt Dowle
#' See answer at https://stackoverflow.com/questions/7235657/fastest-way-to-replace-nas-in-a-large-data-table
#'
#' @export
replace_na_dt
=
function
(
DT
,
cols
=
names
(
DT
),
replace_with
=
0
)
{
for
(
i
in
cols
)
DT
[
is.na
(
get
(
i
)),
(
i
)
:=
replace_with
]
}
man/group_nest_dt.Rd
View file @
3088d486
...
...
@@ -4,7 +4,7 @@
\alias{group_nest_dt}
\title{Nest a data.table by group}
\usage{
group_nest_dt(dt, ..., .key = "data")
group_nest_dt(dt, ..., .key = "data"
, group_vars = NULL
)
}
\description{
This function was originally written by TS Barrett in a document available at https://osf.io/f6pxw/download.
...
...
man/replace_na_dt.Rd
0 → 100644
View file @
3088d486
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/replace_na_dt.R
\name{replace_na_dt}
\alias{replace_na_dt}
\title{Replace NA in a data table}
\usage{
replace_na_dt(DT, cols = names(DT), replace_with = 0)
}
\description{
Modified from a function written by Matt Dowle
See answer at https://stackoverflow.com/questions/7235657/fastest-way-to-replace-nas-in-a-large-data-table
}
man/unnest_dt.Rd
View file @
3088d486
...
...
@@ -4,7 +4,7 @@
\alias{unnest_dt}
\title{Unnest a nested data.table}
\usage{
unnest_dt(dt, col, id)
unnest_dt(dt, col, id
, id_vars = NULL
)
}
\description{
This function was written by TS Barrett in a document available at https://osf.io/f6pxw/download.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment