search for: columtodelete

Displaying 2 results from an estimated 2 matches for "columtodelete".

2023 Jan 15
2
Removing variables from data frame with a wile card
...three columns one <- rep(1,10) one two <- rep(2,10) two three <- rep(3,10) three mydata <- data.frame(one=one, two=two, three=three) cat("Data frame with three columns\n") mydata # Drop the column whose name starts with th, i.e. column three # Find the location of the column ColumToDelete <- grep("th",colnames((mydata))) cat("The colomumn to be dropped is the column called three, which is column",ColumToDelete,"\n") ColumToDelete # Drop the column whose name starts with "th" newdata2 <- mydata[,-ColumnToDelete] cat("Data frame afte...
2023 Jan 14
1
Removing variables from data frame with a wile card
Hello Avi, while something like d$something <- ... may seem like you're directly modifying the data it does not actually do so. Most R objects try to be immutable, that is, the object may not change after creation. This guarantees that if you have a binding for same object the object won't change sneakily. There is a data structure that is in fact mutable which are environments. For