If you want to obtain licenses for all installed packages, use the installed.packages command.
Borrowing from the help page for this command:
lisc <- installed.packages(fields = "License")
To output licenses to a csv file:
write.csv(lisc[,c(1,10)], "RPackageLicenses.csv")
source share