convertClipboardAuthorNames: Function to convert a number of 'Firstname Familyname' lines...

View source: R/convertClipboardAuthorNames.R

convertClipboardAuthorNamesR Documentation

Function to convert a number of 'Firstname Familyname' lines on the clipboard to 'Familyname, Firstname'

Description

Function to convert a number of 'Firstname Familyname' lines on the clipboard to 'Familyname, Firstname'

Usage

convertClipboardAuthorNames(toClipboard = TRUE, warn = TRUE)

Arguments

toClipboard

logical: default TRUE sends changed names back to clipboard

warn

logical: prints warning(s)

Value

Character vector of changed names if toClipboard == FALSE

Background

This is a tiny and crude function to convert a number of 'Firstname Familyname' lines on the clipboard to 'Familyname, Firstname'. I wrote it because I was quite often putting records into Zotero where I had a list of authors but in that 'Firstname Familyname' format and I thought it would save me time to have this to do a first, rough, conversion to 'Familyname, Firstname' which Zotero will then suck in happily.

Beware, this is crude, as the default warning say, it will mess up space separated family names like 'Matte Blanco' splitting that to make 'Blanco' alone the family name. It must also fail if there is a mix of ordering in what you feed it and in some other messy challenges. So always check what it has put in the clipboard. However, I find it helps me quite a lot of the time. But then I pretty well always have Rstudio open and the CECPfuns package loaded so it's quick and easy for me to call. As the geeks say your mileage may vary!",

See Also

Other utility functions: fixVarNames(), getAttenuatedR(), getCorrectedR(), whichSetOfN()

Examples

## Not run: 
### the default is that you have your data, e.g.
# Ravindra Khattree
# Zhidong Bai
# Paula Caligiuri
# Yasunori Fijikoshi
# Yuehua Wu
# Arni S.R.
# Srinivasa Rao
# Marepalli B. Rao
### (Those are from the deeply moving obituary of C.R.Ra:
###    Khattree, et al. (2023). Institute of Mathematical Statistics |
###    Obituary: C.R. Rao 1920–2023.
### https://imstat.org/2023/09/30/obituary-c-r-rao-1920-2023/)

### You copy that into the system clipboard and in an interactive R session you run:
convertClipboardAuthorNames()

### That default will try to rearrange the names to its limited extent, print a warning to you
### and put the rearranged names back into the clipboard replacing what was there.

### It's way away from intelligent, hence by default it gives you a warning.
### An example of things it can't handle is 'Arni, S.R.' in the above.
### That is already in the format we want so the function will mess that
### one up: always check the result after pasting it into Zotero (or wherever).
### Nevertheless I think the function now saves me time despite its lack of intelligence.
### I hope it does for you too.

### If you are fed up with the warning you can use:
convertClipboardAuthorNames(warn = FALSE)

### I can't think why but just in case you want the result to be returned to the R prompt
### as a character vector and NOT copied back to the clipboard, use:

convertClipboardAuthorNames(toClipboard = FALSE)

## End(Not run)


cpsyctc/CECPfuns documentation built on Nov. 16, 2024, 10:43 a.m.