statscloud

URL Parameters

If you're opening a statscloud project from a link, or you've got the link to share your current project with others, you may have noticed that this link can be quite long and has some weird gobbledygook inside it. Take a look at this one for instance:

https://statscloud.app/project/temp/?vars=Group,Score&dataTypes=1:n;2:r&labels=1:Drug,Placebo&analyses=1:2:independentTTest&title=Independent-Samples%20t-Test%20Template

That looks awful on a first glace, but it can actually be understood quite easily when you break it down.

Note: Just before you go any further - it's not actually neccessary to understand any of this: statscloud will automatically generate a link for you when you 'Share' your project and you'll never be required to write your own links yourself. Unless you really want to. If you do, be our guest!

The link contains a set of instructions that statscloud uses when it loads the page. These instructions, or options, are known as 'URL parameters' (or 'query strings'). They're very common on websites, and you've probably encountered them before if you've looked at the links of websites in your address bar. The first parameter always starts with an ? symbol, and all subsequent parameters start with a &. In every case, they're followed by the name of an attribute (e.g. dataType), a = symbol, and then the values of the parameters afterwards.

In the example above, we have five attributes: vars, dataTypes, labels, analyses and title, each of which have their own values and instructions which statscloud understands. Let's have a look through them.

Variables (vars)

The vars attribute contains a list of variables we want statscloud to create when it starts up. In the example above, the vars parameter is:

?vars=Group,Score

This means that we want statscloud to create two variables; one called "Group" and the other called "Score". Each of the variables we want to create is separated by a comma. So, for instance, if we wanted to create five variables to denote five questionnaire items, we could have something like ?vars=Q01,Q02,Q03,Q04,Q05. This would create five variables with the names "Q01", "Q02", "Q03", "Q04", and "Q05". Easy.

The vars attribute, however, only creates varable names and does not declare anything else specific about those variables. At this point, we;ve just declared five boring variables that don't have any other information than a name. To make them more useful, we need some other attributes:

Data type (dataType)

Once you've declared the variables you want to use in your data set (using the vars attribute above), you can then apply some options to them. The dataType attribute (as the name suggests) gives each of these values a data type. Here, our data type parameter is:

&dataTypes=1:n;2:r

Here, the numbers refer to the variable number, and the letters refer to the data type. In this case, this code 1:r means "make variable 1 a ratio (or numeric) variable", and 2:n means "make variable 2 a nominal (or categorical) variable". Each data type we want to declare is separated by a semi-colon.

If we want multiple variables to have the same data type, we can batch them up and declare them altogether. For instance, if we want variables 1, 2, 3, 4, and 5 to all be 'ratio' variables, we would write &dataType=1,2,3,4,5:r.

As in the Variables tab in StatsCloud, there are six data types we can choose from. These are:

Symbol DataType
r Ratio (Numeric)
n Nominal (Categorical)
o Ordinal (Rank)
s String (Text)
d Date
t Time

Labels (labels)

If we delcare a variable as being 'nominal' or 'ordinal', we can also attach labels (or shortcuts) to these variables. For instance, in our example above, we have a nominal variable (the first one), and we want this to have two value labels (Drug and Placebo).

&labels=1:Drug,Placebo

This instruction means "Give variable 1 two labels; "Drug" and "Placebo". Again, you can use as many labels as you like here, as long as you seperate them with a comma. You can also batch together variables that have the same labels. For instance, if your first five variables all have a 'Yes/No' response, you could write &labels=1,2,3,4,5:Yes,No. Everything to the left of the colon is a list of variables, and everything to the right are the labels you'd like these variabels to have. Again, you seperate each batch of label designations with a semi-colon (;).

Colours (colours)

The colours attribute is very similar to the dataType attribute. Here,we can assign colours to our variables using exactly the same syntax. For instance, you may have the following URL parameter:

&colours=1:r;2:b

Again, the numbers refer to the variables, and the letters refer to the colour names. In this example we're saying "make variable 1 red, and make variable 2 blue". You can batch variable numbers together as before, so &colours=1,2,3,4,5:o would make your first five variables orange. A list of the available colours are below:

Letter Colour
r Red
b Blue
y Yellow
g Green
p Purple
o Orange

If you don't declare any colours, all your variables will be grey, and that's no fun.

Hidden

The 'hidden' attribute is very simple. If you'd like to 'hide' variables in your data set, you can use the &hidden= attribute. When you do, you simply list all the variables you would like to be hidden, separated by commas. So, the code &hidden=1,2,3 would hide variables 1, 2, and 3. Simple.

Locked

The 'locked' attribute works exactly the same as 'hidden'. Just use the &locked= attribute with your variable numbers declared afterwards to lock them. So, the text &locked=2,3 would lock variables 2 and 3.

Now things get interesting because one other thing we can do is group related variables together. Let's say we have a repeated measures design with two conditions that measure a "Score"; one 'Before' and one 'After'. The code for this may look like this:

https://statscloud.app/project/temp/?vars=Before,After&dataTypes=1,2:r&related=1-2:Time(Before-After):Score

We understand everything up to the related bit (two variables called "Before" and "After" are created and given a 'Ratio' data type), so let's decode that.

Related attributes have three parts which are separated by a colon. The first part (1-2) declares the range of variables we want to group together, the second part (Time(Before-After)) declares each factor and its levels, and the third part (Score) is the name of the outcome.

The first part, the range of variables, is simple enough. Here, the code 1-2 means "get variables 1 through to 2".

The second part declares some text outside brackets, the factor name, and some text inside brackets (the levels of that factor). In this example, the factor name is "Time" and the levels are "Before" and "After". Each of the level names are separated by hypens (-). So this part of the code is saying "Create a factor called 'Time' and give it two levels; 'Before' and 'After'"). For this part of the parameter, we can have multiple factors (and levels), separated by commas. For instance, if we have a 2x2 design, the code may look like this:

&related=1-4:Time(Before-After),Position(Sitting-Standing):Score

This clever bit of code will automatically assign these four variables to one 'related conditions' variable with the four conditions; 'before sitting', 'before standing', 'after sitting' and 'after standing'.

The third bit is also quite simple. This is just the name we want give our outcome name (that is common to all conditions we just declared). We've simply said "...and call this variable 'Score'".

Note: If you have any analyses in your project that require the data to be grouped together as related variables, these related variables will be declared automatically in your shared project, even if you haven't done this yourself in the app

Analyses

Now the good stuff. This attribute is used to (you guessed it) declare what analyses we want running when the project loads. If you've understood everything up to this point, this section will be a doddle. Let's go back to our original example. Here, we have the following text:

&analyses=1:2:independentTTest

You'll notice here we have three sections, separated again by colons. The first section declares our 'predictor' variables, the second declares our 'outcome' variables, and the third section declares what analysis we'd like to do. In this example, we're saying "with variable 1 as a predictor and variable 2 as an outcome, run an independent-samples t test".

Of course, some tests don't have predictor variables, so the first section can be blank. For instance:

https://statscloud.app/project/temp/?vars=X,Y&dataTypes=1,2:r&analyses=:1,2:pearsonsR&title=Pearson%27s%20R%20Template

Here we can see we've declared 2 ratio variables (simply called 'X' and 'Y') and we've requested statscloud runs a Pearson's R correlation on them. In this case, both variables (1 and 2) are outcome variables, so there are no predictor variables declared between the = and the first colon, and the outcome variables are declared together (separated by commas) in the outcomes section.

Note: You probably would've worked out by now that it's possible to enter complete nonsense here. For instance, if you don't declare the predictor and outcome variables as required for the test you want to run, statscloud will just ignore what you've written. Sorry.

Title (title)

We'll end with an easy one. The title attribute simply declares the title you've given your project which will show up at the top. This looks like this:

&title=Independent-Samples%20t-Test%20Template

Now is probably a good time to mention that browsers don't like spaces in links. So, whenever you expect to see a space, you'll see a lovely %20 instead. Don't worry, this is perfectly normal, and statscloud will know exactly what to do with this when it reads it. It just looks a bit ugly here.

Data (data)

It's also possible to declare data in a query string using the data attribute. You can either do this by declaring raw data as the value of the attribute, or by referencing a link where the data can be found.

From raw data

The easiest way to import data using the data attribute is to declare raw data as the value.

https://statscloud.app/project/temp/?data=[[1,2,3],[a,b,c]]

In this example, statscloud will load up with two columns of data: (1,2,3) and (a,b,c). Each column of data is declared in square brackets, and separated by a comma. The whole array of column data needs to be surrounded by another pair of square brackets. If statscloud.app detects that your data attribute value is in the format "[[]]", it will assume your data is declared as raw values and will attempt to import them as a matrix.

Note: Owing to the limits of browsers (and the length of URLs they can handle), there is a finite amount of raw data that can be declared in this way. The amount of raw data that can be imported will depend on the format of the data in your data set. For instance, values with lots of decimal points or long category names will result in a longer URL string. When generating a URL with raw data via the 'Share' pop-up, the app will warn you if your URL is likely to encounter issues with browsers.

If you import raw data this way, you can also include a vars attribute with an array of variable names. If statscloud detects that you have declared both raw data and a list of variable names, it will assign the variable names to the columns of data for you:

https://statscloud.app/project/temp/?data=[[1,2,3],[a,b,c]]&vars=Numbers,Letters

From a URI

If you'd like to link to a data set stored at a public URI, you can pass in data attribute with the value of the link the data set is stored at:

https://statscloud.app/project/temp/?data=https://raw.githubusercontent.com/dangurn/data sets/master/fisher-iris.csv

In this example, the project will look up the data file found at the URI https://raw.githubusercontent.com/dangurn/data sets/master/fisher-iris.csv and be ready to import this.

Note: If you'd like to import data from a data set stored at a website outside statscloud.app, CORE users will be prompted to download the data first and then import this manually into StatsCloud. PRO users will see the data without performing this step.

Alternatively, you can simply pass in the name of a data set stored on the statscloud.app server:

https://statscloud.app/project/temp/?data=chickens

This link will open up the "chickens" data set chickens. Because this data set is stored on the statscloud.app server https://statscloud.app/data sets/chickens.csv, it can load up the data set immediately without prompting the user to download the data and import it manually.

Note: You can see the full list of data sets available by visiting statscoud.app/home/examples. When you open any of these projects, you'll notice the URL displays in the address bar.