I have a data frame from which I want to delete all rows while keeping original structure (columns).
ddf <- data.frame(
vint1 = c(9L, 9L, 6L, 10L, 7L),
vint2 = c(10L, 6L, 2L, 6L, 12L),
vfac1 = factor(c("1", "3", "2", "2", "3")),
vfac2 = factor(c("3", "4", "2", "4", "2"))
)
ddf
#> vint1 vint2 vfac1 vfac2
#> 1 9 10 1 3
#> 2 9 6 3 4
#> 3 6 2 2 2
#> 4 10 6 2 4
#> 5 7 12 3 2
I tried:
ddf = NA
for(i in 1:nrow(ddf) ddf[i,] = NULL
but they do not work. Thanks for your help on this basic question.