How to do cross-references in SciFlow

SciFlow is one of several options when it comes to collaborative writing. I like the intuitive interface, but sometimes it can be hard to see some useful features built in — like cross-references to other sections and figures/tables. This is super easy in SciFlow.

Let’s start with a new document. In this example, I have two sections on the left, with a table in Section 2. I have also pressed the “outline” button to see the document outline on the right.

In this example, I want to add a cross-reference to section 2 at the end of the “Main text” section. I simply select the section I want to refer to on the right

and drop it in the text where I want the cross-reference to appear.

Here we go, the placeholder for the cross-reference is included.

We can cross-reference figures and tables in the same way. Select the figure or table on the right (note the “Figures, Tables & Equations” below the list of sections),

and drag it

into the main text:

At the time of writing, the placeholder makes no distinction between figures and tables, but it’s just a placeholder…

A bit like when using LaTeX, in SciFlow you use “What You See is What You Mean”, so the output will probably look different from what you have on the screen. Indeed, this is a strength of SciFlow, both in that it allows you to export in many formats, and in that it prevents you from spending hours tinkering with the formatting. Unlike some other online editors, SciFlow is good at producing Word documents that are commonplace in the social sciences (many journals insist on a Word document during submission), or PDF, as you like. You choose the style and can readily change that style because SciFlow separates content from form.

Here’s that little section in one style:

and here in another style:

There you go, placeholders replaced with the relevant text depending on the template used.

Counting Articles in Nexis Uni

We wanted to count the number of articles on a number of keywords that were published in specific newspapers. This is a measure of salience. So we have a list of keywords (e.g. Boris Johnson, Jeremy Corbyn, Jo Swinson, Caroline Lucas), a date range (e.g. 1 January 2017 to 31 December 2017), and Nexis Uni to get the articles. In this case, we were not interested in the contents of the articles, so I downloaded the meta data (headline, publication, an empty “summary” column, and the date of the publication). Nexis Uni gives me a spreadsheet per keyword. With some 30 keywords, I did not want a manual approach.

What we wanted in the end was a spreadsheet, with all dates in the date range and the number of articles for each keyword as a column. Here’s how I did this in R:

sheets = list.files(pattern="*.XLSX")

This gives me a list of all the XLSX files in the folder. I use library(readxl) because it imports the dates properly, unlike some of the other options to open XLSX files in R.

library(readxl)

for (i in 1:length(sheets)) {
assign(paste("N", i, sep=""), read_excel(sheets[i]))
}

Here I chose a loop to read in the data from the Nexis spreadsheets, each into a separate container. I guess I could have used a list or something, but for this project speed was no concern.

Next, we need a list of dates in the date range. The seq() already works, but to make this match the date format from the Excel documents, I need to wrap everything in the as.POSIXlt.

dat = as.POSIXlt(seq(from=as.Date("2017-01-01"), to=as.Date("2017-12-31"), by=1))

Now comes the actual work. First I create a vector with the dates of the articles in the Nexis spreadsheet for each keyword. Some dates in the date range have no articles, others have one, others still have more than one. I then use sapply() to match the dates, and colSums() to count the number of articles for a given day.

for (i in 1:length(sheets)) {
assign(paste("D", i, sep=""), eval(parse(text=paste("N", i, "$Date", sep=""))))
assign(paste("S", i, sep=""), eval(parse(text=paste("sapply(dat, function(x) D", i, "== x)", sep=""))))
assign(paste("H", i, sep=""), eval(parse(text=paste("colSums(S", i, ")", sep=""))))
}

At this stage I regret not using a list or data frame, but this code combines the different variables:

hits = data.frame(dat)
for (i in 1:length(sheets)) {
hits = cbind(hits, eval(parse(text=paste("H", i, sep=""))))
}

And then I add the names of the sheets and I have a data frame I can export with write.csv() or whatever.

colnames(hits) = c("date", sheets)

Creating Sparklines in MS Word

A few years back I’ve prepared a step-by-step guide to creating sparklines in SPSS and MS Word. I’ve come up with the idea long before learning about what is today widely known as sparklines from Edward Tufte (writing a physics lab report in high school). After a recent comment by a colleague (“you can do that in Word?”), I’ve decided to put this tutorial online.

The general principle applies to any software package to create the original graphs, including MS Excel. Continue reading “Creating Sparklines in MS Word”