To print out the first 10 rows of a dataframe in R, I am using head(data.frame, 10).
head(data.frame, 10)
But this dataframe has 64 variables, and I only want to select 3 of those variables to show for my print out of the first 10 rows.
Can I use the head function to do this?
You can use dplyr::select first and then run head after that in a pipe :)
df <- data.frame(x = rnorm(100, mean = 1, sd = 0.5), y = rnorm(100, 30, 2), z = rnorm(100, 200, 20)) df %>% select(x, y) %>% head(., 10)
1.4m articles
1.4m replys
5 comments
57.0k users