3

I'm attempting to use detach by pasting together arguments. this should be an easy job but is not for me. I knew it was time to ask for help when I thought about using eval(parse())

Normally if I load a package I can detach it as follows:

detach(package:reshape)

I want to do the same by passing the packahe name as a character vector. Here's my attempt:

pack<-"reshape"
detach(paste("package:", pack, sep=""))

Yielding the following error:

> detach(paste("package:", pack, sep=""))
Error in detach(paste("package:", pack, sep = "")) : 
  invalid 'name' argument

Help me please.

Tyler Rinker
  • 108,132
  • 65
  • 322
  • 519

1 Answers1

5

This is similar to another question: Load multiple packages at once

You need to supply the character.only=TRUE argument.

pack<-"reshape"
detach(paste("package:", pack, sep=""), character.only=TRUE)
Community
  • 1
  • 1
Tommy
  • 39,997
  • 12
  • 90
  • 85