DataSharkBites: Bite-sized R Wisdom
Welcome to DataSharkBites, where we serve up quick, powerful insights into data science using R. Just like a shark, these bites are designed to be swift, precise, and leave a lasting impression!
Featured Bite
Sharpen Your dplyr Skills: The slice() Function
Ever needed to grab specific rows from your data frame? The slice()
function from dplyr is your go-to tool!
library(dplyr)
# Sample data
<- data.frame(x = 1:10, y = letters[1:10])
df
# Get the first 5 rows
%>% slice(1:5)
df
# Get every other row
%>% slice(seq(1, n(), by = 2))
df
# Get the last 3 rows
%>% slice(tail(n():1, 3)) df
Remember: Like a shark’s precision bite, slice()
lets you extract exactly the rows you need!
Explore more DataSharkBites below and boost your R skills one bite at a time!
No matching items