Я написал служебные функции для этого. Теперь, когда я знаю о drop.levels gdata, он выглядит довольно похожим. Здесь они (из здесь ):
present_levels <- function(x) intersect(levels(x), x)
trim_levels <- function(...) UseMethod("trim_levels")
trim_levels.factor <- function(x) factor(x, levels=present_levels(x))
trim_levels.data.frame <- function(x) {
for (n in names(x))
if (is.factor(x[,n]))
x[,n] = trim_levels(x[,n])
x
}
df = Daru::DataFrame.from_csv("df.csv")
df.set_index "time"
df.index = Daru::DateTimeIndex.new(df.index)
df
<Daru::DataFrame(5x2)>
min max
2018-01-01 101 103
2018-01-02 102 105
2018-01-03 103 200
2018-01-04 104 109
2018-01-05 105 110