I am reading a dataset with the following code from the directory:
df= read.csv('101_E424690_N566610.csv', skip = 6)
then changing the names:
colnames(df) = c("type","date","v1","v2","v3","v4","v5","v6","v7","v8","v9","v10","v11","v12","v13","v14","v15","v16","v17","v18","v19","v20","v21","v22","v23","v24","total")
I am trying to split the file name as it has the ID number, easting and northing and add 3 additional coloumn after “Type” and “data” coloumn before starting “V1”, “V2” etc., I have got some code but I think what I am doing is not right, the codes I am trying is:
split <- strsplit(df,"_")
gsub('df', '', lapply(split, '[', 2))
What I am trying to get is to create 3 additional coloumn and paste ID = 101, Easting = 424690, and Northing = 566610.
is this possible with R?
Many thanks,
Ayan
Ayan, remember to give reproducible examples. One solution to have your columns after the date column: