You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+20-18
Original file line number
Diff line number
Diff line change
@@ -1,11 +1,11 @@
1
1
How to share data with a statistician
2
2
===========
3
3
4
-
This is a guide for anyone who needs to share data with a statistician. The target audiences I have in mind are:
4
+
This is a guide for anyone who needs to share data with a statistician or data scientist. The target audiences I have in mind are:
5
5
6
-
*Scientific collaborators who need statisticians to analyze data for them
7
-
* Students or postdocs in scientific disciplines looking for consulting advice
8
-
* Junior statistics students whose job it is to collate/clean data sets
6
+
*Collaborators who need statisticians or data scientists to analyze data for them
7
+
* Students or postdocs in various disciplines looking for consulting advice
8
+
* Junior statistics students whose job it is to collate/clean/wrangle data sets
9
9
10
10
The goals of this guide are to provide some instruction on the best way to share data to avoid the most common pitfalls
11
11
and sources of delay in the transition from data collection to data analysis. The [Leek group](http://biostat.jhsph.edu/~jleek/) works with a large
@@ -23,7 +23,7 @@ have to work through all the pre-processing steps first.
23
23
What you should deliver to the statistician
24
24
====================
25
25
26
-
For maximum speed in the analysis this is the information you should pass to a statistician:
26
+
To facilitate the most efficient and timely analysis this is the information you should pass to a statistician:
27
27
28
28
1. The raw data.
29
29
2. A [tidy data set](http://vita.had.co.nz/papers/tidy-data.pdf)
@@ -35,35 +35,36 @@ Let's look at each part of the data package you will transfer.
35
35
36
36
### The raw data
37
37
38
-
It is critical that you include the rawest form of the data that you have access to. Here are some examples of the
38
+
It is critical that you include the rawest form of the data that you have access to. This ensures
39
+
that data provenance can be maintained throughout the workflow. Here are some examples of the
39
40
raw form of data:
40
41
41
42
* The strange [binary file](http://en.wikipedia.org/wiki/Binary_file) your measurement machine spits out
42
43
* The unformatted Excel file with 10 worksheets the company you contracted with sent you
43
44
* The complicated [JSON](http://en.wikipedia.org/wiki/JSON) data you got from scraping the [Twitter API](https://twitter.com/twitterapi)
44
45
* The hand-entered numbers you collected looking through a microscope
45
46
46
-
You know the raw data is in the right format if you:
47
+
You know the raw data are in the right format if you:
47
48
48
49
1. Ran no software on the data
49
-
1. Did not manipulate any of the numbers in the data
50
+
1. Did not modify any of the data values
50
51
1. You did not remove any data from the data set
51
52
1. You did not summarize the data in any way
52
53
53
-
If you did any manipulation of the data at all it is not the raw form of the data. Reporting manipulated data
54
+
If you made any modifications of the raw data it is not the raw form of the data. Reporting modified data
54
55
as raw data is a very common way to slow down the analysis process, since the analyst will often have to do a
55
-
forensic study of your data to figure out why the raw data looks weird.
56
+
forensic study of your data to figure out why the raw data looks weird. (Also imagine what would happen if new data arrived?)
56
57
57
58
### The tidy data set
58
59
59
60
The general principles of tidy data are laid out by [Hadley Wickham](http://had.co.nz/) in [this paper](http://vita.had.co.nz/papers/tidy-data.pdf)
60
-
and [this video](http://vimeo.com/33727555). The paper and the video are both focused on the [R](http://www.r-project.org/) package, which you
61
-
may or may not know how to use. Regardless the four general principles you should pay attention to are:
61
+
and [this video](http://vimeo.com/33727555). While both the paper and the video describe tidy data using [R](http://www.r-project.org/), the principles
62
+
are more generally applicable:
62
63
63
64
1. Each variable you measure should be in one column
64
65
1. Each different observation of that variable should be in a different row
65
66
1. There should be one table for each "kind" of variable
66
-
1. If you have multiple tables, they should include a column in the table that allows them to be linked
67
+
1. If you have multiple tables, they should include a column in the table that allows them to be joined or merged
67
68
68
69
While these are the hard and fast rules, there are a number of other things that will make your data set much easier
69
70
to handle. First is to include a row at the top of each data table/spreadsheet that contains full row names.
@@ -82,12 +83,12 @@ ids and one row for each data type).
82
83
83
84
If you are sharing your data with the collaborator in Excel, the tidy data should be in one Excel file per table. They
84
85
should not have multiple worksheets, no macros should be applied to the data, and no columns/cells should be highlighted.
85
-
Alternatively share the data in a [CSV](http://en.wikipedia.org/wiki/Comma-separated_values) or [TAB-delimited](http://en.wikipedia.org/wiki/Tab-separated_values) text file.
86
+
Alternatively share the data in a [CSV](http://en.wikipedia.org/wiki/Comma-separated_values) or [TAB-delimited](http://en.wikipedia.org/wiki/Tab-separated_values) text file. (Beware however that reading CSV files into Excel can sometimes lead to non-reproducible handling of date and time variables.)
86
87
87
88
88
89
### The code book
89
90
90
-
For almost any data set, the measurements you calculate will need to be described in more detail than you will sneak
91
+
For almost any data set, the measurements you calculate will need to be described in more detail than you can or should sneak
91
92
into the spreadsheet. The code book contains this information. At minimum it should contain:
92
93
93
94
1. Information about the variables (including units!) in the data set not contained in the tidy data
@@ -118,8 +119,8 @@ When you put variables into a spreadsheet there are several main categories you
118
119
Continuous variables are anything measured on a quantitative scale that could be any fractional number. An example
119
120
would be something like weight measured in kg. [Ordinal data](http://en.wikipedia.org/wiki/Ordinal_data) are data that have a fixed, small (< 100) number of levels but are ordered.
120
121
This could be for example survey responses where the choices are: poor, fair, good. [Categorical data](http://en.wikipedia.org/wiki/Categorical_variable) are data where there
121
-
are multiple categories, but they aren't ordered. One example would be sex: male or female. [Missing data](http://en.wikipedia.org/wiki/Missing_data) are data
122
-
that are missing and you don't know the mechanism. You should code missing values as `NA`. [Censored data](http://en.wikipedia.org/wiki/Censoring_\(statistics\)) are data
122
+
are multiple categories, but they aren't ordered. One example would be sex: male or female. This coding is attractive because it is self-documenting. [Missing data](http://en.wikipedia.org/wiki/Missing_data) are data
123
+
that are unobserved and you don't know the mechanism. You should code missing values as `NA`. [Censored data](http://en.wikipedia.org/wiki/Censoring_\(statistics\)) are data
123
124
where you know the missingness mechanism on some level. Common examples are a measurement being below a detection limit
124
125
or a patient being lost to follow-up. They should also be coded as `NA` when you don't have the data. But you should
125
126
also add a new column to your tidy data called, "VariableNameCensored" which should have values of `TRUE` if censored
@@ -135,7 +136,7 @@ Always encode every piece of information about your observations using text. For
135
136
136
137
### The instruction list/script
137
138
138
-
You may have heard this before, but [reproducibility is kind of a big deal in computational science](http://www.sciencemag.org/content/334/6060/1226).
139
+
You may have heard this before, but [reproducibility is a big deal in computational science](http://www.sciencemag.org/content/334/6060/1226).
139
140
That means, when you submit your paper, the reviewers and the rest of the world should be able to exactly replicate
140
141
the analyses from raw data all the way to final results. If you are trying to be efficient, you will likely perform
141
142
some summarization/data analysis steps before the data can be considered tidy.
@@ -186,5 +187,6 @@ Contributors
186
187
*[Jeff Leek](http://biostat.jhsph.edu/~jleek/) - Wrote the initial version.
0 commit comments