I’m almost a complete beginner in R and in programming in general.
I have to tidy a data set, and in order to do that i have to remove rows containing the word “Total”.
I have this so far (railroads is the data set, railroads_clean is supposed to be the tidy version of this).
railroads <-read_xlsx("railroads.xlsx")
railroads_clean <- railroads |>
rename(State = 2,
County = 4,
Employees = 6) |> #renames the relevant columns
select(State, County, Employees) |> #removes columns 1, 3, 5 which all have no data
slice(4:2988) #gets rid of the blank rows at the beginning, unimportant rows at the end, canada
returns this
the rows containing “Total” are all within the State column if that helps, and I need to get rid of all of those rows. Have found some solutions but none have worked in the pipe that I’m using.
What can i put in the pipe after slice(4:2988)?
Thanks
ribrob2 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.