dt <- structure(list(fct = structure(c(1L, 2L, 3L, 4L, 3L, 4L, 1L, 2L, 3L, 1L, 2L, 3L, 2L, 3L, 4L),
.Label = c("a", "b", "c", "d"), class = "factor"),
X = c(2L, 4L, 3L, 2L, 5L, 4L, 7L, 2L, 9L, 1L, 4L, 2L, 5L, 4L, 2L)),
.Names = c("fct", "X"), class = "data.frame", row.names = c(NA, -15L))
If you want to learn more about R programming watch this tutorial on Introduction to Data Science with R