0

Brand new to loops here and can't seem to find an answer. I'm trying to remove consecutively named, character objects with a for loop. What am I doing wrong?

query1 <- c("x")
query2 <- c("x")
query3 <- c("x")
query4 <- c("x")
query5 <- c("x")

for (i in 1:5) {
  rm(list(paste(query),i))
}

1 Answers1

0

You have to make a small modification

for (i in 1:5) {
    rm(list = paste("query",i,sep  = ""))
}
d.b
  • 32,245
  • 6
  • 36
  • 77