I'm starting to learn r using r-studio with data.table, so i'm sorry for asking something this basic. This is what I have (working on a r-markdown):
Object 1:
ps.data <- fread("database.csv")
I'm trying to create an object that is the same that "ps.data" but removing 5 of the columns (simultaneously) that "database.csv" has, but withput altering "ps.data". So far, i've tried this:
First try: works, but extremely inefficient.
ps.data2<-ps.data[,"col1":=NULL]
ps.data3<-ps.data2[,"col2":=NULL]
...
ps.data6<-ps.data5[,"col5":=NULL]
Then remove all objects that i don't need.
Second try: Even though it creates the object without the columns removed, the problem is that now i open "ps.data" and the code also removed the columns in that one.
ps.data2<- ps.data[, c("col1","col2","col3","col4","col5"):=NULL]