-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathfunction.R
More file actions
29 lines (23 loc) · 1009 Bytes
/
Copy pathfunction.R
File metadata and controls
29 lines (23 loc) · 1009 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
citeRpacks <- function(pkg_list, filename, RStudio = FALSE) {
#ht to https://stackoverflow.com/questions/2470248/write-lines-of-text-to-a-file-in-r for sink()
for (i in 1:length(pkg_list)) {
sink(file = paste(filename, ".bib", sep = ""), append = T)
writeLines(toBibtex(citation(package = pkg_list[i])))
sink()
}
if(RStudio) {
c <- RStudio.Version()$citation
sink(file = paste(filename, ".bib", sep = ""), append = T)
writeLines(paste("@Manual{,",
"\n title = {", c$title, "},",
"\n author = {{", c$author, "}},",
"\n organization = {", c$organization, "},",
"\n address = {", c$address, "},",
"\n year = {", c$year, "},",
"\n note = {", RStudio.Version()$version, "}",
"\n url = {", c$url, "},",
"\n }",
sep = ""))
sink()
}
}