Comments (6)
incorporated, see YuLab-SMU@03a9394#diff-3fc538c4fa03e2b111fe20ab306291513d8d306fb319e4ea6cb64b671f7f014e.
from scholar.
try this:
---
output: html_document
---
```{r results = "asis"}
scholar::format_publications("NrfwEncAAAAJ", "R Thériault") |> cat(sep='\n\n')
```
```{r results = "asis"}
scholar::format_publications("NrfwEncAAAAJ", "R Thériault")
```
```{r results = "asis"}
scholar::format_publications("NrfwEncAAAAJ", "R Thériault") |> print(quote=FALSE)
```
from scholar.
You are welcome to create a PR for the vignette.
from scholar.
In the meanwhile, here is a workaround and function that give decent results. Reproducible rmarkdown example:
---
output: html_document
---
# Publications
```{r, results = "asis", echo = FALSE, message = FALSE}
format.authors <- function(scholar.profile, author.name) {
library(dplyr)
swap_initials <- function(author.name) {
sub("(.*) (.*)", "\\2, \\1.", trimws(author.name))
}
pubs <- scholar::get_publications(scholar.profile)
pubs %>%
strsplit(x = .$author, split = ",") -> pubs2
lapply(pubs2, function(x) {
x <- swap_initials(x)
x[length(x)] <- paste0("& ", x[length(x)])
x <- paste0(x, collapse = ", ")
ifelse(startsWith(x, "& "), sub("& ", "", x), x)
}
) -> pubs$author
author.name2 <- swap_initials(author.name)
pubs %>%
arrange(desc(year)) %>%
mutate(journal = paste0("*", journal, "*"),
Publications = paste0(author, " (", year, "). ",
title, ". ", journal, ". ",
number),
Publications = gsub(author.name2, paste0("**", author.name2, "**"), Publications)) %>%
select(Publications)
}
pubs <- format.authors("NrfwEncAAAAJ", "R Thériault")
cat(unlist(pubs), sep = "\\\n \\\n")
```
However, this workaround won't work if you are indenting your publications in vitae
/LaTeX
: the other references will all be indented by LaTex as if they were the same unit/paragraph. Using the following to indent:
\setlength{\parindent}{-0.2in}
\setlength{\leftskip}{0.2in}
Despite the indenting problem, would you consider adding this function to scholar
?
from scholar.
Amazing!
One reflection I had was whether we should include within the function output the following bit for proper rmarkdown formatting:
cat(unlist(pubs), sep = "\\\n \\\n")
If not included the full rmarkdown workflow would need to be something like:
scholar::format_publications("NrfwEncAAAAJ", "R Thériault") |>
unlist() |>
cat(sep = "\\\n \\\n")
Or should we let the user do that? I think adding it would be one fewer step for the user using rmarkdown. However, it would not be in a proper format for further manipulation outside of rmarkdown (and not consistent with other functions). Yet, I don't know how people would use this outside of rmarkdown. Perhaps only to make some manual edits if the function fails in some aspects.
Second, be aware that there is a minor issue that my function does not deal with yet, which is the situation of having multiple initials. For example, it formats the initials SA as "SA.", whereas technically according to APA style it should be "S. A.". But that's probably the lowest possible priority. If I find a fix eventually I'll come back to post it here.
from scholar.
Awesome, the first one looks good for APA style, and the last one I think could be useful for other styles that use numbering. I think it would be neat to eventually have a vignette (or blog post) for this.
from scholar.
Related Issues (20)
- Years with zero citations cause get_article_cite_history() to fail HOT 3
- get_publications() returns NA for all pubids HOT 2
- author_position() typos in calculation for `Position_Normalized`
- get_publications() `pubid` outputs all `<NA>` HOT 1
- Getting full article citation information (not only the summary)
- get_publication 404 errors HOT 1
- Get scholar does not work for ids with punctuation
- fix to get_scholar_id HOT 1
- Fix for duplicate profiles HOT 1
- Unclear documentation for swap_initials() within the format_publications function. HOT 1
- Error in predict_h_index() HOT 1
- get_complete_authors returns NA HOT 1
- Error in predict_h_index() HOT 3
- predict.r
- get_coauthors limited to 20 coauthors HOT 1
- add function get_pubs_all_authors - submission HOT 1
- Retrieving field-of-interest/expertise labels HOT 3
- get_publications(id) is not returning pubid HOT 3
- get_article_cite_history(id, pubid) sometimes is not returning HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from scholar.