Using tidyverse, you can make use of pivot_longer and pivot_wider:
dat %>% pivot_longer(cols = c("sqft", "age", "housevalue"), names_to = "variable", values_to = "values") %>%
mutate(treat = paste0("treat=", treat)) %>%
pivot_wider(names_from = treat, values_from = values)
which gives:
#A tibble: 3 x 3
variable `treat=0` `treat=1`
<chr> <dbl> <dbl>
1 sqft 1753. 1915.
2 age 37.9 33.2
3 housevalue 215160. 240666.
But now I see you want to convert it into a Kable table, so you need to drop the first column:
m = dat %>% pivot_longer(cols = c("sqft", "age", "housevalue"), names_to = "variable", values_to = "values") %>%
mutate(treat = paste0("treat=", treat)) %>%
pivot_wider(names_from = treat, values_from = values) %>%
select(-variable)