I have an xls file that i am importing to R, i then want to create a dataframe of the table of data within the file, I'm currently getting stuck removing some of the data within the xls that i don't need.
In the below example I would like to create a data frame of cols A:G, excluding the 'xxxx' data.
xxxx xxxxx
xxxx xxxxx
xxxx xxxxx
A B C D E F G
1 2 3 4 5 6 7
2 3 4 5 6 7 8
3 4 5 6 7 8 9
4 5 6 7 8 9 10
5 6 7 8 9 10 11
6 7 8 9 10 11 12
7 8 9 10 11 12 13
8 9 10 11 12 13 14
9 10 11 12 13 14 15
xxxxx
CodePudding user response:
I was able to find a solution, adding skip = 4 when importing the xls to exclude the first 4 rows and then this to exclude any rows after the first NA in col B:
NonNAindex <- which(!is.na(df$B))
firstNonNA <- max(NonNAindex)
df <- df[1:firstNonNA, ]
CodePudding user response:
Is there any reason you can't delete the extraneous "xxxx" data from the file before importing to R?