I'm learning R and currently looking at ISLR's College.csv dataset (found here). I'm trying to set the first data column as the row names but none of the solutions I've found have worked:
college <- fread("College.csv")
rownames(college) <- college$V1
college <- college[, -1]
college
college <- fread("College.csv")
rownames(college) <- college[[1]]
college <- college[, -1]
college
college <- fread("College.csv")
rownames(college) <- college[,1]
college[,1] <- NULL
college
college <- fread("College.csv")
rownames(college) <- college[,1]
college <- college(, -1)
college
I've found a ton of advice on this issue on StackExchange, on other sites, and in the book I'm using and am confused about why none of it is working for me. I'd welcome any advice.
edit for more detail: I'd like to do this using fread or at least read_csv, and I'd like to do it without reassigning. If that can't be done without reassigning, I'd like to be explicitly told so because I don't trust myself in this matter.