dplyr - Checking if an r package is currently attached -


i having trouble workflow because sourcing multiple scripts in rmarkdown, of require package dplyr , of use plyr.

the problem rename function exists in both packages , if dplyr attached rename function in plyr won't work.

how include in scripts function checks if dplyr attached, and, if is, detach it?

i know how detach packages via detach("package:dplyr", unload = true). don't know how check if package attached or not.

i agree best approach use dplyr::rename , plyr::rename explicitely call function want.

however, if did want check if package attached, , detatch use

if("plyr" %in% (.packages())){   detach("package:plyr", unload=true)  }