I think you should prepare you data.frame before DT::datatable
- Add the first row as names for the DF
- delete the first row
With base R
df <- data.frame(V1 = c("Letter", "A", "B"), V2 = c("Number", "1", "2"), stringsAsFactors = FALSE)
names(df) <- df[1, ]
df <- df[-1, ]
df
#> Letter Number
#> 2 A 1
#> 3 B 2
Created on 2018-08-13 by the reprex package (v0.2.0).
with tidyverse
library(tidyverse)
df <- tibble(V1 = c("Letter", "A", "B"), V2 = c("Number", "1", "2"))
df %>%
# rename with first row
set_names(df[1, ]) %>%
# delete the first row
slice(-1)
#> # A tibble: 2 x 2
#> Letter Number
#> <chr> <chr>
#> 1 A 1
#> 2 B 2
Created on 2018-08-13 by the reprex package (v0.2.0).