-
Notifications
You must be signed in to change notification settings - Fork 1k
Open
Labels
Milestone
Description
nafill and setnafill only supports numeric types.
library(data.table)
x = letters[1:10]
x[c(1:2, 5:6, 9:10)] = NA
nafill(x, "locf")
# Error in nafill(x, "locf") :
# 'x' argument must be numeric type, or list/data.table of numeric types
setnafill(x, "locf")
# Error in setnafill(x, "locf") :
# 'x' argument is atomic vector, in-place update is supported only for list/data.table
Both zoo::na.locf and tidyr::fill support all data types.
zoo::na.locf(x, na.rm = FALSE)
# [1] NA NA "c" "d" "d" "d" "g" "h" "h" "h"
tidyr::fill(tibble::as_tibble(x), value)
# A tibble: 10 x 1
# value
# <chr>
# 1 NA
# 2 NA
# 3 c
# 4 d
# 5 d
# 6 d
# 7 g
# 8 h
# 9 h
# 10 h
Feature request for supporting character, factor and other types. It's useful in many cases in merging and cleaning data.tables/data.frames. Unlike matrix, data.frames/data.tables usually contain columns of arbitrary types, and it's very common for data.tables/data.frames to have NA values filled in columns of arbitrary types, especially characters. Right now I have to import the specific functions from other packages just for that functionalities and those functions are much slower than the ones created by data.table.
Thank you for creating this superior data.table package.
ismirsehregal, artemklevtsov, hope-data-science, MichaelChirico, afparsons and 35 more