I have a dataset in R that I am trying to subset into a second data frame.
I'm not really sure it's relevant, but just in case, the data is something along the lines of this:
V1 V2 V3 V4 V5 V6
ab 10 98 0.9 0.1 abc
cd 11 99 0.8 0.05 cde
So I was trying to subset it by doing the following:
df_new = data.frame(data$V2, data$V5, data$V6)
This has actually worked in the past so I didn't think anything of using it here, but for some reason, the output of this was:
data.V2 data.V5 data.V6
10 0.1 abc
11 0.05 cde
So, for some reason the function was adding the name of the original data frame to the column names when I was subsetting it. I checked the documentation and couldn't see an option for preventing this (I just want to keep the original names). So I'm not really sure what exactly was going wrong here.