Skip to content

Commit 1436ea0

Browse files
committed
more standard indentation
1 parent c830246 commit 1436ea0

File tree

4 files changed

+20
-30
lines changed

4 files changed

+20
-30
lines changed

_posts/2012-12-23-sugar-any.md

+2-7
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ The sugar function any() answers the question, "Are any of the values ... ?".
1111

1212

1313

14-
1514
The any_sug() function takes a LogicalVector as an argument and allows one to
1615
enter an expression for the argument as shown in the R examples. In this
1716
example, it is simply wrapper around the sugar function any() and includes
@@ -31,7 +30,6 @@ bool any_sug(LogicalVector x){
3130
}
3231
{% endhighlight %}
3332

34-
3533
{% highlight r %}
3634
x <- c(3, 9, 0, 2, 7, -1, 6)
3735
y <- c(8, 3, 2, 6, 1, 5, 0)
@@ -80,7 +78,6 @@ bool any_sug(LogicalVector x){
8078
[1] TRUE
8179
</pre>
8280

83-
8481
While the above function may seem trivial, it can be easy to forget is_true()
8582
when using any() and will result in a compile error. The check_negative()
8683
function below is an example of a simple utility function to check if a
@@ -99,9 +96,8 @@ void check_negative(NumericVector x) {
9996
}
10097
{% endhighlight %}
10198

102-
10399
{% highlight r %}
104-
check_negative(x)
100+
check_negative(x)
105101
{% endhighlight %}
106102

107103

@@ -113,12 +109,11 @@ The vector contains negative numbers
113109

114110

115111
{% highlight r %}
116-
check_negative(y)
112+
check_negative(y)
117113
{% endhighlight %}
118114

119115

120116

121117
<pre class="output">
122118
The vector does not contain negative numbers
123119
</pre>
124-

_posts/2012-12-23-sugar-diff.md

+8-13
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ src: 2012-12-23-sugar-diff.cpp
99
---
1010

1111

12-
1312
The sugar function diff() computes the difference of consecutive elements
1413
(i.e. lag = 1) of the input vector. Note that the size of the vector returned
1514
is one less than the input vector. The sugar function diff() works the same
@@ -25,10 +24,9 @@ NumericVector diff_sug(NumericVector x){
2524
}
2625
{% endhighlight %}
2726

28-
2927
{% highlight r %}
30-
x <- rnorm(10)
31-
diff_sug(x)
28+
x <- rnorm(10)
29+
diff_sug(x)
3230
{% endhighlight %}
3331

3432

@@ -41,8 +39,8 @@ NumericVector diff_sug(NumericVector x){
4139

4240

4341
{% highlight r %}
44-
# base R function
45-
diff(x)
42+
# base R function
43+
diff(x)
4644
{% endhighlight %}
4745

4846

@@ -52,7 +50,6 @@ NumericVector diff_sug(NumericVector x){
5250
[9] 1.66974
5351
</pre>
5452

55-
5653
One can use the diff() function to compute one period simple returns of stock
5754
prices.
5855

@@ -70,12 +67,11 @@ NumericVector ret_simple(NumericVector x) {
7067
}
7168
{% endhighlight %}
7269

73-
7470
{% highlight r %}
75-
# Close prices of S&P 500
76-
y <- c(1418.55, 1427.84, 1428.48, 1419.45, 1413.58,
77-
1430.36, 1446.79, 1435.81, 1443.69, 1430.15)
78-
ret_simple(y)
71+
# Close prices of S&P 500
72+
y <- c(1418.55, 1427.84, 1428.48, 1419.45, 1413.58,
73+
1430.36, 1446.79, 1435.81, 1443.69, 1430.15)
74+
ret_simple(y)
7975
{% endhighlight %}
8076

8177

@@ -84,4 +80,3 @@ NumericVector ret_simple(NumericVector x) {
8480
[1] NA 0.0065489 0.0004482 -0.0063214 -0.0041354 0.0118706
8581
[7] 0.0114866 -0.0075892 0.0054882 -0.0093787
8682
</pre>
87-

src/2012-12-23-sugar-any.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,6 @@ void check_negative(NumericVector x) {
5656
}
5757

5858
/*** R
59-
check_negative(x)
60-
check_negative(y)
59+
check_negative(x)
60+
check_negative(y)
6161
*/

src/2012-12-23-sugar-diff.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ NumericVector diff_sug(NumericVector x){
2222
}
2323

2424
/*** R
25-
x <- rnorm(10)
26-
diff_sug(x)
27-
# base R function
28-
diff(x)
25+
x <- rnorm(10)
26+
diff_sug(x)
27+
# base R function
28+
diff(x)
2929
*/
3030

3131
/**
@@ -46,8 +46,8 @@ NumericVector ret_simple(NumericVector x) {
4646
}
4747

4848
/*** R
49-
# Close prices of S&P 500
50-
y <- c(1418.55, 1427.84, 1428.48, 1419.45, 1413.58,
51-
1430.36, 1446.79, 1435.81, 1443.69, 1430.15)
52-
ret_simple(y)
49+
# Close prices of S&P 500
50+
y <- c(1418.55, 1427.84, 1428.48, 1419.45, 1413.58,
51+
1430.36, 1446.79, 1435.81, 1443.69, 1430.15)
52+
ret_simple(y)
5353
*/

0 commit comments

Comments
 (0)