Reputation: 23
I am trying to read in a .csv file into R. The first 12 rows of the csv contain background information that is not needed, but is in two columns. The rest of the data is from row 13 and is in 10 columns. Is it possible to read in the file from row 13, as using read.csv normally puts the file in 2 columns and ruins it? thanks in advance
Upvotes: 2
Views: 514
Reputation: 812
Say you want to read in rows 13 to 20 and your csv. file is separated by ";":
data <- read.csv("filename.csv", sep = ";", row.names=c(13:20), col_names = c("firstcolname", "secondcolname", "thirdcolname", ..., "tenthcolname"))
Upvotes: 0
Reputation: 420
This should be relatively straightforward with read.csv().
try this:
data <- read.csv(file = "yourdirectory/yourfile.csv", skip = 12, header = FALSE)
Note: setting header = FALSE makes sure that the first line reads in as data rather than as column labels. If these are actually column labels, change to header = TRUE.
Upvotes: 1