-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathindex.html
794 lines (376 loc) · 18.9 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
<!DOCTYPE html>
<!--[if IEMobile 7 ]><html class="no-js iem7"><![endif]-->
<!--[if lt IE 9]><html class="no-js lte-ie8"><![endif]-->
<!--[if (gt IE 8)|(gt IEMobile 7)|!(IEMobile)|!(IE)]><!--><html class="no-js" lang="en"><!--<![endif]-->
<head>
<meta charset="utf-8">
<title>Nice R Code</title>
<meta name="author" content="Rich FitzJohn & Daniel Falster">
<meta name="description" content="Transitioning from an interactive plot in R to a publication-ready
plot can create a messy script file with lots of statements and use of
global …">
<!-- http://t.co/dKP3o1e -->
<meta name="HandheldFriendly" content="True">
<meta name="MobileOptimized" content="320">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="canonical" href="http://nicercode.github.io/">
<link href="/favicon.png" rel="icon">
<link href="/stylesheets/screen.css" media="screen, projection" rel="stylesheet" type="text/css">
<script src="/javascripts/modernizr-2.0.js"></script>
<script src="/javascripts/ender.js"></script>
<script src="/javascripts/octopress.js" type="text/javascript"></script>
<link href="/atom.xml" rel="alternate" title="Nice R Code" type="application/atom+xml">
<!--Fonts from Google"s Web font directory at http://google.com/webfonts -->
<link href='http://fonts.googleapis.com/css?family=Bitter:400,700,400italic' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Source+Sans+Pro:400,700,400italic' rel='stylesheet' type='text/css'>
<!-- mathjax config similar to math.stackexchange -->
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
jax: ["input/TeX", "output/HTML-CSS"],
tex2jax: {
inlineMath: [ ['$', '$'] ],
displayMath: [ ['$$', '$$']],
processEscapes: true,
skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
},
messageStyle: "none",
"HTML-CSS": { preferredFont: "TeX", availableFonts: ["STIX","TeX"] }
});
</script>
<script src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML" type="text/javascript"></script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-39493992-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body class="collapse-sidebar sidebar-footer" >
<header role="banner"><hgroup>
<h1><a href="/">Nice R Code</a></h1>
<h2>Punning code better since 2013</h2>
</hgroup>
</header>
<nav role="navigation"><ul class="subscription" data-subscription="rss">
<li><a href="/atom.xml" rel="subscribe-rss" title="subscribe via RSS">RSS</a></li>
</ul>
<form action="http://google.com/search" method="get">
<fieldset role="search">
<input type="hidden" name="q" value="site:nicercode.github.io" />
<input class="search" type="text" name="q" results="0" placeholder="Search"/>
</fieldset>
</form>
<ul class="main-navigation">
<li><a href="/">Blog</a></li>
<li><a href="/blog/archives">Archives</a></li>
<li><a href="/guide.html">Guides</a></li>
<li><a href="/modules">Modules</a></li>
<li><a href="/about">About</a></li>
</ul>
</nav>
<div id="main">
<div id="content">
<div class="blog-index">
<article>
<header>
<h1 class="entry-title"><a href="/blog/2013-07-09-figure-functions/">Figure functions</a></h1>
<p class="meta">
<span class="byline author vcard">Posted by <a href="/about#Team" span class="fn">Rich FitzJohn</span></span> </a>
-
<time datetime="2013-07-09T16:41:00+10:00" pubdate data-updated="true">09 July 2013</time> -
<span class="categories">
<a class='category' href='/blog/categories/r/'>R</a>, <a class='category' href='/blog/categories/plotting/'>plotting</a>
</span>
</p>
</header>
<div class="entry-content"><p>Transitioning from an interactive plot in R to a publication-ready
plot can create a messy script file with lots of statements and use of
global variables. This post outlines an approach that I have used to
simplify the process and keeps code readable.</p>
</div>
<footer>
<a rel="full-article" href="/blog/2013-07-09-figure-functions/">Read on →</a>
</footer>
</article>
<article>
<header>
<h1 class="entry-title"><a href="/blog/2013-07-09-modifying-data-with-lookup-tables/">Modifying data with lookup tables</a></h1>
<p class="meta">
<span class="byline author vcard">Posted by <a href="/about#Team" span class="fn">Daniel Falster</span></span> </a>
-
<time datetime="2013-07-09T08:20:00+10:00" pubdate data-updated="true">09 July 2013</time> -
<span class="categories">
<a class='category' href='/blog/categories/data/'>data</a>, <a class='category' href='/blog/categories/project/'>project</a>
</span>
</p>
</header>
<div class="entry-content"><!-- The problem:
- importing new data
- amount of code to be written (opportunities for mistake)
- separating data from scripts
- maintaining record of where data came from
Common approach
- long sequence of data modifying code
Solution
- use lookup table, find and replace
-->
<p>In many analyses, data is read from a file, but must be modified before it can be used. For example you may want to add a new column of data, or do a “find” and “replace” on a site, treatment or species name. There are 3 ways one might add such information. The first involves editing the original data frame – although you should <em>never</em> do this, I suspect this method is quite common. A second – and widely used – approach for adding information is to modify the values using code in your script. The third – and nicest – way of adding information is to use a lookup table.</p>
</div>
<footer>
<a rel="full-article" href="/blog/2013-07-09-modifying-data-with-lookup-tables/">Read on →</a>
</footer>
</article>
<article>
<header>
<h1 class="entry-title"><a href="/blog/2013-05-17-organising-my-project/">Organizing the project directory</a></h1>
<p class="meta">
<span class="byline author vcard">Posted by <a href="/about#Team" span class="fn">Marcela Diaz</span></span> </a>
-
<time datetime="2013-05-17T08:20:00+10:00" pubdate data-updated="true">17 May 2013</time> -
<span class="categories">
<a class='category' href='/blog/categories/2013-mq/'>2013-MQ</a>, <a class='category' href='/blog/categories/guest/'>guest</a>, <a class='category' href='/blog/categories/module/'>module</a>, <a class='category' href='/blog/categories/project/'>project</a>
</span>
</p>
</header>
<div class="entry-content"><p>This is a guest post by Marcela Diaz, a PhD student at Macquarie University. </p>
<p>Until recently, I hadn’t given much attention to organising files in my project. All the documents and files from my current project were spread out in two different folders, with very little sub folder division. All the files where together in the same place and I had multiple versions of the same file, with different dates. As you can see, things were getting a bit out of control.</p>
</div>
<footer>
<a rel="full-article" href="/blog/2013-05-17-organising-my-project/">Read on →</a>
</footer>
</article>
<article>
<header>
<h1 class="entry-title"><a href="/blog/2013-05-07-how-long-is-a-function/">How long is a function?</a></h1>
<p class="meta">
<span class="byline author vcard">Posted by <a href="/about#Team" span class="fn">Rich FitzJohn</span></span> </a>
-
<time datetime="2013-05-07T11:10:00+10:00" pubdate data-updated="true">07 May 2013</time> -
</p>
</header>
<div class="entry-content"><p>Within the R project and contributed packages, how long do functions
tend to be? In our experience, people seem to think that functions
are only needed when you need to use a piece of code multiple times,
or when you have a really large problem. However, many functions are
actually very small.</p>
</div>
<footer>
<a rel="full-article" href="/blog/2013-05-07-how-long-is-a-function/">Read on →</a>
</footer>
</article>
<article>
<header>
<h1 class="entry-title"><a href="/blog/2013-04-30-excel-and-line-endings/">Excel and line endings</a></h1>
<p class="meta">
<span class="byline author vcard">Posted by <a href="/about#Team" span class="fn">Rich FitzJohn</span></span> </a>
-
<time datetime="2013-04-30T09:39:00+10:00" pubdate data-updated="true">30 April 2013</time> -
<span class="categories">
<a class='category' href='/blog/categories/data/'>data</a>, <a class='category' href='/blog/categories/git/'>git</a>
</span>
</p>
</header>
<div class="entry-content"><p>On a Mac, Excel produces csv files with the wrong line endings, which
causes problems for git (amongst other things).</p>
<p>This issue plagues at least
<a href="http://developmentality.wordpress.com/2010/12/06/excel-2008-for-macs-csv-bug/">Excel 2008</a>
and 2011, and possibly other versions.</p>
<p>Basically, saving a file as comma separated values (csv) uses a
carriage return <code>\r</code> rather than a line feed <code>\n</code> as a newline. Way
back before OS X, this was actually the correct Mac file ending, but
after the move to be more unix-y, the correct line ending should be
<code>\n</code>.</p>
</div>
<footer>
<a rel="full-article" href="/blog/2013-04-30-excel-and-line-endings/">Read on →</a>
</footer>
</article>
<article>
<header>
<h1 class="entry-title"><a href="/blog/2013-04-23-git/">git</a></h1>
<p class="meta">
<span class="byline author vcard">Posted by <a href="/about#Team" span class="fn">Rich FitzJohn & Daniel Falster</span></span> </a>
-
<time datetime="2013-04-23T17:51:00+10:00" pubdate data-updated="true">23 April 2013</time> -
<span class="categories">
<a class='category' href='/blog/categories/module/'>module</a>
</span>
</p>
</header>
<div class="entry-content"><p>Thanks to everyone who came along and was such good sports with
learning git today. Hopefully you now have enough tools to help you use git in your own
projects. The notes are available (in fairly raw form)
<a href="/git">here</a>. Please let us know where they are unclear and we will
update them.</p>
<p>To re-emphasise our closing message – start using it on a
project, start thinking about what you want to track, and start
thinking about what constitutes a logical commit. Once you get into a
rhythm it will seem much easier. Bring your questions along to the
class in 2 weeks time.</p>
<p>Also, to re-emphasise that git is not a backup system. Make sure that
you have your work backed up, just in case something terrible happens.
I recommend <a href="http://www.crashplan.com/">crash plan</a> which you can use
for free for backing up onto external hard drives (and for a fee).</p>
<h2 id="feedback">Feedback</h2>
<p>We welcome any and all feedback on the material and how we present it.
You can give <em>anonymous</em> feedback by emailing G2G admin (you should
have the address already – I’m only not putting it up here in a vain
effort to slow down spam bots). Alternatively, you are welcome to
email either or both of us, or leave a comment on a relevant page.</p>
</div>
</article>
<article>
<header>
<h1 class="entry-title"><a href="/blog/2013-04-05-why-nice-code/">Why I want to write nice R code</a></h1>
<p class="meta">
<span class="byline author vcard">Posted by <a href="/about#Team" span class="fn">Daniel Falster</span></span> </a>
-
<time datetime="2013-04-05T14:46:00+11:00" pubdate data-updated="true">05 April 2013</time> -
<span class="categories">
<a class='category' href='/blog/categories/module/'>module</a>
</span>
</p>
</header>
<div class="entry-content"><!--
Why are students here
Goals: performance, learning, affective, social
Value: attainment, intrinsic, instrumental
Instrumental - allows you to accomplish other important goals (extrinsic
rewards), i.e. learn about world, write papers, impress others
Intrinsic - value nice code for itself (craftsmanship)
Attainment - satisfaction in getting something to work
-->
<p>Writing code is fast becoming a key - if not the most important - skill for
doing research in the 21st century. As scientists, we live in extraordinary
times. The amount of data (information) available to us is increasing
exponentially, allowing for rapid advances in our understanding of the world
around us. The amount of information contained in a standard scientific paper
also seems to be on the rise. Researchers therefore need to be able to handle
ever larger amounts of data to ask novel questions and get papers published.
Yet, the standard tools used by many biologists - point and click programs for
manipulating data, doing stats and making plots - do not allow us to scale-up
our analyses to match data availability, at least not without many, many more
‘clicks’.</p>
</div>
<footer>
<a rel="full-article" href="/blog/2013-04-05-why-nice-code/">Read on →</a>
</footer>
</article>
<article>
<header>
<h1 class="entry-title"><a href="/blog/2013-04-05-projects/">Designing projects</a></h1>
<p class="meta">
<span class="byline author vcard">Posted by <a href="/about#Team" span class="fn">Rich FitzJohn</span></span> </a>
-
<time datetime="2013-04-05T14:34:00+11:00" pubdate data-updated="true">05 April 2013</time> -
</p>
</header>
<div class="entry-content"><p>The scientific process is naturally incremental, and many projects
start life as random notes, some code, then a manuscript, and
eventually everything is a bit mixed together.</p>
</div>
<footer>
<a rel="full-article" href="/blog/2013-04-05-projects/">Read on →</a>
</footer>
</article>
<article>
<header>
<h1 class="entry-title"><a href="/blog/2013-03-08-nice-r-code-2013-plans/">Plans for ‘Nice R code module’, Macquarie University 2013</a></h1>
<p class="meta">
<span class="byline author vcard">Posted by <a href="/about#Team" span class="fn">Rich FitzJohn & Daniel Falster</span></span> </a>
-
<time datetime="2013-03-08T09:58:00+11:00" pubdate data-updated="true">08 March 2013</time> -
<span class="categories">
<a class='category' href='/blog/categories/module/'>module</a>
</span>
</p>
</header>
<div class="entry-content"><p>Welcome to the Nice R code module. This module is targeted at researchers who
are already using R and want to write nicer code. By ‘nicer’ we mean code that
is easy to write, is easy to read, runs fast, gives reliable results, is easy
to reuse in new projects, and is easy to share with collaborators. When you
write nice code, you do better science, are more productive, and have more fun.</p>
<p>We have a tentative schedule of plans for the 2013 Nice R Code module. The
module consists of 9 one hour sessions and one 3 hour session.
The topics covered fall into two broad categories: <em>workflow</em> and
<em>coding</em>. Both are essential for writing nicer code. At the beginning of the
module we are going to focus on the
first, as this will cross over into all computing work people do.</p>
</div>
<footer>
<a rel="full-article" href="/blog/2013-03-08-nice-r-code-2013-plans/">Read on →</a>
</footer>
</article>
<article>
<header>
<h1 class="entry-title"><a href="/blog/2013-02-12-r-ecology-evolution/">R in ecology and evolution</a></h1>
<p class="meta">
<span class="byline author vcard">Posted by <a href="/about#Team" span class="fn">Rich FitzJohn</span></span> </a>
-
<time datetime="2013-02-12T17:57:00+11:00" pubdate data-updated="true">12 February 2013</time> -
</p>
</header>
<div class="entry-content"><p>On this blog, we (Daniel Falster and I) are hoping to record bits of
information about using R for ecology and evolution. Communicating
tips person-to-person is too inefficient, and recently helping out at
a <a href="http://software-carpentry.org">software carpentry</a> boot camp made
us interested in broadcasting ideas more widely.</p>
</div>
</article>
<div class="pagination">
<a href="/blog/archives">Blog Archives</a>
</div>
</div>
<aside class="sidebar">
<section>
<h1>Recent Posts</h1>
<ul id="recent_posts">
<li class="post">
<a href="/blog/2013-07-09-figure-functions/">Figure functions</a>
</li>
<li class="post">
<a href="/blog/2013-07-09-modifying-data-with-lookup-tables/">Modifying data with lookup tables</a>
</li>
<li class="post">
<a href="/blog/2013-05-17-organising-my-project/">Organizing the project directory</a>
</li>
<li class="post">
<a href="/blog/2013-05-07-how-long-is-a-function/">How long is a function?</a>
</li>
<li class="post">
<a href="/blog/2013-04-30-excel-and-line-endings/">Excel and line endings</a>
</li>
</ul>
</section>
</aside>
</div>
</div>
<footer role="contentinfo"><p>
Copyright © 2016 - Rich FitzJohn & Daniel Falster -
<span class="credit">Powered by <a href="http://octopress.org">Octopress</a></span>
</p>
</footer>
<script type="text/javascript">
var disqus_shortname = 'nicercode';
var disqus_script = 'count.js';
(function () {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/' + disqus_script;
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
}());
</script>
<script type="text/javascript">
(function(){
var twitterWidgets = document.createElement('script');
twitterWidgets.type = 'text/javascript';
twitterWidgets.async = true;
twitterWidgets.src = 'http://platform.twitter.com/widgets.js';
document.getElementsByTagName('head')[0].appendChild(twitterWidgets);
})();
</script>
</body>
</html>