I'm a beginner learning how to subset specific rows and columns from a dataset in R. I am using the state.x77 dataset in R Studio as practice. When I try to select specified columns, I get the following error message:
library(dplyr)
library(tibble)
select(state.x77, Income, HS Grad)
Error: unexpected symbol in "select(state.x77, Income, HS Grad"
I do not understand what symbol in that line of code is not correct.
Also, if I am trying to filter a certain state in addition to selecting certain columns (variables), how do I use the filter function when the list of states is the row names? When I try:
rownames_to_column(state.x77, var = "State")
it creates a column called State for the state names but it does not seem to be permanent when I go to view state.x77 (and thus I can't use the filter function).
I am sorry, I am very much a beginner. Any help would be appreciated.
Thank you.