<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/data-munging-with-r-preview-storing-values-assigning/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://jcarroll.com.au/2017/06/26/data-munging-with-r-preview-storing-values-assigning/"> R – Irregularly Scheduled Programming</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<div>
<div>
<p>Since about October last year, I’ve been writing an introduction to R book. It’s<br>
been quite the experience. I’ve finally started making time to document some of<br>
the interesting things I’ve learned (about R, about writing, about how to<br>
bring those two together) along the way.</p>
</div>
<p><span></span></p>
<div>
<p>The book is aimed at proper beginners; people with absolutely no formal coding<br>
experience. This tends to mean people coming from Excel who need to do more than<br>
a spreadsheet can/should.</p>
</div>
<p>
<blockquote data-width="450" data-lang="en" class="twitter-tweet" data-partner="jetpack">
<p lang="en" dir="ltr">I'm writing an R book for real beginners (ppl with 0 code XP) via <a rel="nofollow" href="https://twitter.com/ManningBooks" target="_blank">@ManningBooks</a>! What tripped you up most when you first learned R? Pls RT!</p>
<p>— Jonathan Carroll (@carroll_jono) <a rel="nofollow" href="https://twitter.com/carroll_jono/status/780746085727735808" target="_blank">September 27, 2016</a></p></blockquote>
</div>
<div>
<p>Most of the books I’ve looked at which claim to teach programming begin with<br>
some strong assumptions about the reader already knowing how to program, and<br>
teach the specific syntax of some language. That’s no good if this is your first<br>
language, so I’m working towards teaching the concepts, the language, and the<br>
syntax (warts and all).</p>
</div>
<div>
<p>The book is currently available under the Manning Early Access Program (MEAP)<br>
which means if you buy it you get the draft of the first three chapters right<br>
now. If you find something you still don’t understand, or you don’t like how<br>
I’ve written some/all of it, then jump onto the forum and let me know. I make<br>
more edits and write more chapters, and you get updated versions. Lather, rinse,<br>
repeat until the final version and you get a polished book which (if I’m any<br>
good) contains what you want it to.</p>
</div>
<div>
<p>I’m genuinely interested in getting this right; I want to help people learn R. I<br>
contribute a bit of time on Stack Overflow answering people’s questions, and<br>
it’s very common to see questions that shouldn’t need asking. I don’t blame the<br>
user for not knowing something (a different answer for not searching, perhaps),<br>
but I can help make the resource they need.</p>
</div>
<div>
<p>
<a rel="nofollow" href="https://www.manning.com/books/data-munging-with-r?a_aid=datamungingwithr&a_bid=1dc44480" target="_blank">To show that I really want people to contribute, here’s a discount code to<br>
sweeten the deal: use <code>mlcarroll</code> for 50% off here.</a></p>
</div>
<div>
<p>Chapter 1 is a free download, so please check that out too! At the moment the<br>
MEAP covers the first three chapters, but the following four aren’t too far<br>
behind.</p>
</div>
<div>
<p>I’ll document some of the behind-the-scenes process shortly, but for now here’s<br>
an excerpt from chapter 2:</p>
</div>
<div>
<h2><a rel="nofollow" href="https://jcarroll.com.au/2017/06/26/data-munging-with-r-preview-storing-values-assigning/#storing-values-assigning" target="_blank"></a>2.2. Storing Values (Assigning)</h2>
<div>
<div>
<p>In order to do something with our data, we will need to tell <code>R</code> what to call<br>
it, so that we can refer to it in our code. In programming in general, we<br>
typically have <em>variables</em> (things that may vary) and <em>values</em> (our data). We’ve<br>
already seen that different data <em>values</em> can have different <em>types</em>, but we<br>
haven’t told <code>R</code> to store any of them yet. Next, we’ll create some <em>variables</em><br>
to store our data <em>values</em>.</p>
</div>
<div>
<h3><a rel="nofollow" href="https://jcarroll.com.au/2017/06/26/data-munging-with-r-preview-storing-values-assigning/#data-variables" target="_blank"></a>2.2.1. Data (Variables)</h3>
<div>
<p>If we have the values <code>4</code> and <code>8</code> and we want to do something with them, we can<br>
use the values literally (say, add them together as <code>4 + 8</code>). You may be<br>
familiar with this if you frequently use Excel; data values are stored in cells<br>
(groups of which you can opt to name) and you tell the program which values you<br>
wish to combine in some calculation by selecting the cells with the mouse or<br>
keyboard. Alternatively, you can opt to refer to cells by their grid reference<br>
(e.g. <code>A1</code>). Similarly to this second method, we can store values in <em>variables</em><br>
(things that may vary) and <em>abstract</em> away the values. In <code>R</code>, assigning of<br>
values to variables takes the following form</p>
</div>
<div>
<div>
<pre><code data-lang="r">variable &lt;- value</code></pre>
</div>
</div>
<div>
<p>The <em>assignment operator</em> <code>&lt;-</code> can be thought of as storing the value/thing on<br>
the right hand side into the name/thing on the left hand side. For example, try<br>
typing <code>x &lt;- 4</code> into the <code>R</code> <code><strong>Console</strong></code> then press <kbd>Enter</kbd>:</p>
</div>
<div>
<div>
<img src="https://i1.wp.com/jcarroll.com.au/wp-content/uploads/2017/06/variable_value.png?w=200&ssl=1" data-recalc-dims="1">
</div>
<div>Figure 2. 1. The <em>variable</em> <code>x</code> has been assigned the <em>value</em> <code>4</code>.</div>
</div>
<p>You could just as easily use the equals sign to achieve this; <code>x = 4</code> but I<br>
recommend you use <code>&lt;-</code> for this for reasons that will become clear later.</p>
<p>You’ll notice that the <code><strong>Environment</strong></code> tab of the <code><strong>Workspace</strong></code> pane now lists<br>
<code>x</code> under <code><strong>Values</strong></code> and shows the number 4 next to it, as shown in <a rel="nofollow" href="https://jcarroll.com.au/2017/06/26/data-munging-with-r-preview-storing-values-assigning/#fig-x_eq_4" target="_blank">[fig-x_eq_4]</a></p>
<div>
<div>
<img src="https://i0.wp.com/jcarroll.com.au/wp-content/uploads/2017/06/fig-x_eq_4.png?w=450&ssl=1" data-recalc-dims="1">
</div>
<div>Figure 2. 2. The <em>variable</em> <code>x</code> has been assigned the <em>value</em> <code>4</code>.</div>
</div>
<div>
<p>What happened behind the scenes was that when we pressed <kbd>Enter</kbd>, <code>R</code> took<br>
the entire expression that we entered (<code>x &lt;- 4</code>) and evaluated it. Since we<br>
told <code>R</code> to <em>assign</em> the value <code>4</code> to the variable <code>x</code>, <code>R</code> converted the value<br>
<code>4</code> to binary and placed that in the computer’s memory. <code>R</code> then gives us a<br>
reference to that place in the computer’s memory and labels it <code>x</code>. A diagram of<br>
this process is shown in <a rel="nofollow" href="https://jcarroll.com.au/2017/06/26/data-munging-with-r-preview-storing-values-assigning/#fig-assign" target="_blank">[fig-assign]</a> Nothing else appeared in the<br>
<code><strong>Console</strong></code> because the action of assigning a value doesn’t <em>return</em> anything<br>
(we’ll cover this more in our section on functions).</p>
</div>
<div>
<div>
<img src="https://i1.wp.com/jcarroll.com.au/wp-content/uploads/2017/06/assign.png?w=450&ssl=1" data-recalc-dims="1">
</div>
<div>Figure 2. 3. Assigning a value to a variable. The value entered is converted to binary, then stored in memory, the reference to which is labelled by the variable.</div>
</div>
<div>
<p>This is overly simplified, of course. Technically speaking, in <code>R</code>, names have<br>
objects rather than the other way around. This means that <code>R</code> can be quite<br>
memory efficient since it doesn’t create a copy of anything it doesn’t need to.</p>
</div>
<div>
<table>
<tbody>
<tr>
<td>
<i title="Caution"></i>
</td>
<td>
<div>On <em>“hidden”</em> variables</div>
<div>
<p>Variables which begin with a period (e.g. <code>.length</code>) are considered<br>
<em>hidden</em> and do not appear in the <code><strong>Environment</strong></code> tab of the <code><strong>Workspace</strong></code>. They otherwise behave exactly as any other variable; they can be printed and manipulated. An example of one of these is the <code>.Last.value</code> variable, which exists from the moment you load up <code>R</code> (with the value <code>TRUE</code>) — this contains the output value of the last statement executed (handy if you forgot to assign it to something).<br>
There are very few reasons you’ll want to use this feature (dot-prefixed hidden variables) on purpose at the moment, so for<br>
now, avoid creating variable names with this pattern. The exception to the<br>
<em>hidden</em> nature of these is again the <code>.Last.value</code> variable which you can<br>
request to be visible in the <code><strong>Environment</strong></code> tab via<br>
<span><span>Tools</span> ▸ <span>Global Options…​</span> ▸ <span>General</span> ▸ <span>Show .Last.value in environment listing</span></span>.</p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<div>
<p>We can retrieve the value assigned to the variable <code>x</code> by asking <code>R</code> to print<br>
the value of <code>x</code></p>
</div>
<div>
<div>
<pre><code data-lang="r">print(x = x)</code></pre>
</div>
</div>
<div>
<div>
<pre>#> [1] 4</pre>
</div>
</div>
<div>
<p>for which we have a useful shortcut — if your entire expression is just a<br>
variable, <code>R</code> will assume you mean to <code>print()</code> it, so</p>
</div>
<div>
<div>
<pre><code data-lang="r">x</code></pre>
</div>
</div>
<div>
<div>
<pre>#> [1] 4</pre>
</div>
</div>
<div>
<p>works just the same.</p>
</div>
<div>
<p>Now, about that <code>[1]</code>: it’s important to know that in <code>R</code>, there’s no such thing<br>
as a single value; every value is actually a <em>vector</em> of values (we’ll cover<br>
these properly in the next chapter, but think of these as collections of values<br>
of the same type).<sup>[<a rel="nofollow" href="https://jcarroll.com.au/2017/06/26/data-munging-with-r-preview-storing-values-assigning/#_footnote_1" title="View footnote." target="_blank">1</a>]</sup><br>
Whenever <code>R</code> prints a value it allows for the case where the value contains more<br>
than one number. To make this easier on the eye, it labels the first value<br>
appearing on the line by it’s position in the collection. For collections<br>
(vectors) with just a single value, this might appear strange, but this makes<br>
more sense once our variables contain more values</p>
</div>
<div>
<div>
<pre><code data-lang="r"># Print the column names of the mtcars dataset
names(x = mtcars)</code></pre>
</div>
</div>
<div>
<div>
<pre>#>  [1] &quot;mpg&quot;  &quot;cyl&quot;  &quot;disp&quot; &quot;hp&quot;   &quot;drat&quot; &quot;wt&quot;   &quot;qsec&quot; &quot;vs&quot;   &quot;am&quot;   &quot;gear&quot;
#> [11] &quot;carb&quot;</pre>
</div>
</div>
<div>
<p>We can assign another variable to another value</p>
</div>
<div>
<div>
<pre><code data-lang="r">y &lt;- 8</code></pre>
</div>
</div>
<div>
<p>There are few restrictions for what we can name our data <em>values</em>, but <code>R</code> will<br>
complain if you try to break them. Variables should start with a letter, not a<br>
number. Trying to create the variable <code>2b</code> will generate an error. Variables can<br>
also start with a dot (<code>.</code>) as long as it’s not immediately followed by a<br>
number, although you may wish to avoid doing so. The rest of the variable name<br>
can consist of letters (upper and lower case) and numbers, but not punctuation<br>
(except <code>.</code> or <code>_</code>) or other symbols (except the dot, though again, preferably<br>
not).</p>
</div>
<div>
<p>There are also certain <em>reserved words</em> that you can’t name variables as. Some<br>
are <em>reserved</em> for built-in functions or keywords</p>
</div>
<div>
<p><code>if</code>, <code>else</code>, <code>repeat</code>, <code>while</code>, <code>function</code>, <code>for</code>, <code>in</code>, <code>next</code>, and <code>break</code>.</p>
</div>
<div>
<p>Others are <em>reserved</em> for particular values</p>
</div>
<div>
<p><code>TRUE</code>, <code>FALSE</code>, <code>NULL</code>, <code>Inf</code>, <code>NaN</code>, <code>NA</code>, <code>NA_integer_</code>, <code>NA_real_</code>,<br>
<code>NA_complex_</code>, and <code>NA_character_</code>.</p>
</div>
<div>
<p>We’ll come back to what each of these means, but for now you just need to know<br>
that you can’t create a variable with one of those names.</p>
</div>
<div>
<table>
<tbody>
<tr>
<td>
<i title="Caution"></i>
</td>
<td>
<div>On overwriting names</div>
<div>
<p>What you <strong>can</strong> do however, which you may wish to take care with, is <em>overwrite</em><br>
the in-built names of variables and functions. By default, the value <code>pi</code> is<br>
available (π = 3.141593).</p>
</div>
<div>
<p>If you were translating an equation into code, and wanted to enter the value<br>
<em>p<sub>i</sub></em> you might accidentally call it <code>pi</code> and in doing so change the default<br>
value, causing all sorts of trouble when you next go to use it or call a<br>
function you’ve written which expects it to still be the default.</p>
</div>
<div>
<p>The default value can still be accessed by specifying the package in which it is<br>
defined, separated by two colons (<code>::</code>). In the case of <code>pi</code>, this is the <code>base</code><br>
package.</p>
</div>
<div>
<div>
<pre><code data-lang="r">pi &lt;- 3L <b>(1)</b>
base::pi <b>(2)</b></code></pre>
</div>
</div>
<div>
<div>
<pre>#> [1] 3.141593</pre>
</div>
</div>
<div>
<ol>
<li>
<p>Re-defining <code>pi</code> to be equal to exactly <code>3</code></p>
</li>
<li>
<p>The default, correct value is still available.</p>
</li>
</ol>
</div>
<div>
<p>This is also an issue for functions, with the same solution; specify the package<br>
in which it is defined to use that definition. We’ll return to this in<br>
a section on ‘scope’.</p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<div>
<p>We’ll cover how to do things to our variables in more detail in the next<br>
section, but for now let’s see what happens if we add our variables <code>x</code> and <code>y</code><br>
in the same way as we did for our regular numbers</p>
</div>
<div>
<div>
<pre><code data-lang="r">x + y</code></pre>
</div>
</div>
<div>
<div>
<pre>#> [1] 12</pre>
</div>
</div>
<div>
<p>which is what we got when we added these numbers explicitly. Note that since our<br>
expression produces just a number (no assignment), the value is printed. We’ll<br>
cover how to add and subtract values in more depth in our section on basic mathematics.</p>
</div>
<div>
<p><code>R</code> has no problems with overwriting these values, and it doesn’t mind what data<br>
you overwrite these with.<sup>[<a rel="nofollow" href="https://jcarroll.com.au/2017/06/26/data-munging-with-r-preview-storing-values-assigning/#_footnote_2" title="View footnote." target="_blank">2</a>]</sup></p>
</div>
<div>
<div>
<pre><code data-lang="r">y &lt;- 'banana'
y</code></pre>
</div>
</div>
<div>
<div>
<pre>#> [1] &quot;banana&quot;</pre>
</div>
</div>
<div>
<p><code>R</code> is <em>case-sensitive</em>, which means that it treats <code>a</code> and <code>A</code> as distinct<br>
names. You can have a variable named <code>myVariable</code> and another named <code>MYvariable</code><br>
and another named <code>myVARIABLE</code> and <code>R</code> will hold the value assigned to each<br>
independently.</p>
</div>
<div>
<div>On variable names</div>
<blockquote><p>
There are only two hard things in Computer Science: cache invalidation and naming things.
</p>
</blockquote>
<div>
— Phil Karlton<br>
<cite>Principal Curmudgeon Netscape Communications Corporation</cite>
</div>
</div>
<div>
<p>I said earlier that <code>R</code> won’t keep track of your units so it’s a good idea to<br>
name your variables in a way that makes logical sense, is meaningful, and will<br>
help you remember what it represents. Variables <code>x</code> and <code>y</code> are fine for playing<br>
around with values, but aren’t particularly meaningful if your data represents<br>
speeds, where you may want to use something like <code>speed_kmph</code> for speeds in<br>
kilometers per hour. Underscores (<code>_</code>) are allowed in variable names, but<br>
whether or not you use them is up to you. Some programmers prefer to name<br>
variables in this way (sometimes referred to as ‘snake_case’), others prefer<br>
‘CamelCase’. The use of periods (dots, <code>.</code>) to separate words is discouraged for<br>
reasons beyond the scope of this book.<sup>[<a rel="nofollow" href="https://jcarroll.com.au/2017/06/26/data-munging-with-r-preview-storing-values-assigning/#_footnote_3" title="View footnote." target="_blank">3</a>]</sup></p>
</div>
<div>
<table>
<tbody>
<tr>
<td>
<i title="Important"></i>
</td>
<td>
<div>Naming things</div>
<div>
<p>Be careful when naming your variables. Make them meaningful and<br>
concise. In six months from now, will you remember what <code>data_17</code> corresponds to? Tomorrow, will you remember that <code>newdata</code> was updated twice?</p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div>
<h3><a rel="nofollow" href="https://jcarroll.com.au/2017/06/26/data-munging-with-r-preview-storing-values-assigning/#unchanging-data" target="_blank"></a>2.2.2. Unchanging Data</h3>
<div>
<p>If you’re familiar with working with data in a spreadsheet program (such as<br>
Excel), you may expect your variables to behave in a way that they<br>
won’t. Automatic recalculation is a very useful feature of spreadsheet programs,<br>
but it’s not how <code>R</code> behaves.</p>
</div>
<div>
<p>If we assign our two variables, then add them, we can save that result to<br>
another variable</p>
</div>
<div>
<div>
<pre><code data-lang="r">a &lt;- 4
b &lt;- 8
sum_of_a_and_b &lt;- a + b</code></pre>
</div>
</div>
<div>
<p>This has the value we expect</p>
</div>
<div>
<div>
<pre><code data-lang="r">print(x = sum_of_a_and_b)</code></pre>
</div>
</div>
<div>
<div>
<pre>#> [1] 12</pre>
</div>
</div>
<div>
<p>Now, if we <em>change</em> one of these values</p>
</div>
<div>
<div>
<pre><code data-lang="r">b &lt;- 2</code></pre>
</div>
</div>
<div>
<p>this has <strong>no impact</strong> on the value of the variable we created to hold the sum<br>
earlier</p>
</div>
<div>
<div>
<pre><code data-lang="r">print(x = sum_of_a_and_b)</code></pre>
</div>
</div>
<div>
<div>
<pre>#> [1] 12</pre>
</div>
</div>
<div>
<p>Once the sum was calculated, and that value stored in a variable, the connection<br>
to the original values was lost. This makes things <em>reliable</em> because you know<br>
for sure what value a variable will have at any point in your calculation by<br>
following the steps that lead to it, whereas a spreadsheet depends much more on<br>
its current overall <em>state</em>.</p>
</div>
</div>
<div>
<h3><a rel="nofollow" href="https://jcarroll.com.au/2017/06/26/data-munging-with-r-preview-storing-values-assigning/#assigmnent-operators-code-code-vs-code-code" target="_blank"></a>2.2.3. Assigmnent Operators (<code>&lt;-</code> vs <code>=</code>)</h3>
<div>
<p>If you’ve read some <code>R</code> code already, you’ve possibly seen that both <code>&lt;-</code> and<br>
<code>=</code> are used to assign values to objects, and this tends to cause some<br>
confusion. Technically, <code>R</code> will accept either when assigning variables, so in<br>
that respect it comes down to a matter of style (I still highly recommend<br>
assigning with <code>&lt;-</code>). The big difference comes when using functions that take<br>
<em>arguments</em> — there you should only use <code>=</code> to specify what the <em>value</em> of the<br>
<em>argument</em>. For example, when we inspected the <code>mtcars</code> data, we could<br>
specify a string with which to indent the output</p>
</div>
<div>
<div>
<pre><code data-lang="r">str(object = mtcars, indent.str = '>>  ')</code></pre>
</div>
</div>
<div>
<div>
<pre>#> 'data.frame':	32 obs. of  11 variables:
#> >>  $ mpg : num  21 21 22.8 21.4 18.7 18.1 14.3 24.4 22.8 19.2 ...
#> >>  $ cyl : num  6 6 4 6 8 6 8 4 4 6 ...
#> >>  $ disp: num  160 160 108 258 360 ...
#> >>  $ hp  : num  110 110 93 110 175 105 245 62 95 123 ...
#> >>  $ drat: num  3.9 3.9 3.85 3.08 3.15 2.76 3.21 3.69 3.92 3.92 ...
#> >>  $ wt  : num  2.62 2.88 2.32 3.21 3.44 ...
#> >>  $ qsec: num  16.5 17 18.6 19.4 17 ...
#> >>  $ vs  : num  0 0 1 1 0 1 0 1 1 1 ...
#> >>  $ am  : num  1 1 1 0 0 0 0 0 0 0 ...
#> >>  $ gear: num  4 4 4 3 3 3 3 4 4 4 ...
#> >>  $ carb: num  4 4 1 1 2 1 4 2 2 4 ...</pre>
</div>
</div>
<div>
<p>If we had used <code>&lt;-</code> instead of <code>=</code> for either argument, then <code>R</code> would treat<br>
that as creating a new variable <code>object</code> or <code>indent.str</code> with value <code>mtcars</code> or<br>
<code>'>> '</code> respectively, which isn’t what we want.</p>
</div>
<div>
<table>
<tbody>
<tr>
<td>
<i title="Example"></i>
</td>
<td>
<div>Assigning to variables.</div>
<div>
<div>
<pre><code data-lang="r">score &lt;- 4.8
score</code></pre>
</div>
</div>
<div>
<div>
<pre>#> [1] 4.8</pre>
</div>
</div>
<div>
<div>
<pre><code data-lang="r">str(object = score)</code></pre>
</div>
</div>
<div>
<div>
<pre>#>  num 4.8</pre>
</div>
</div>
<div>
<div>
<pre><code data-lang="r">fruit &lt;- 'banana'
fruit</code></pre>
</div>
</div>
<div>
<div>
<pre>#> [1] &quot;banana&quot;</pre>
</div>
</div>
<div>
<div>
<pre><code data-lang="r">str(object = fruit)</code></pre>
</div>
</div>
<div>
<div>
<pre>#>  chr &quot;banana&quot;</pre>
</div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<div>
<p>Note that we didn’t need to tell <code>R</code> that one of these was a number and one was<br>
a string, it figured that out itself. It’s good practice (and easier to read) to<br>
make your <code>&lt;-</code> line up vertically when defining several variables:</p>
</div>
<div>
<div>
<pre><code data-lang="r">first_name &lt;- 'John'
last_name  &lt;- 'Smith'
top_points &lt;- 23</code></pre>
</div>
</div>
<div>
<p>but only if this can be achieved without adding too many spaces (exactly how<br>
many is too many is up to you).</p>
</div>
<div>
<table>
<tbody>
<tr>
<td>
<i title="Caution"></i>
</td>
<td>
<div>
<div>Watch this space!</div>
<p>An extra space can make a big difference to the syntax. Compare:</p>
</div>
<div>
<div>
<pre><code data-lang="r">a &lt;- 3</code></pre>
</div>
</div>
<div>
<p>with</p>
</div>
<div>
<div>
<pre><code data-lang="r">a &lt; - 3</code></pre>
</div>
</div>
<div>
<div>
<pre>#> [1] FALSE</pre>
</div>
</div>
<div>
<p>In the first case we assigned the value <code>3</code> to the variable <code>a</code> (which returns<br>
nothing). In the second case, with a wayward space, we <em>compared</em> <code>a</code> to the<br>
value <code>-3</code> which returns <code>FALSE</code> (I’ll explain why that works at all, later).</p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<div>
<p>Now that we know how to provide some data to <code>R</code>, what if we want to explicitly<br>
tell <code>R</code> that our data should be of a specific type, or we want to convert our<br>
data to a different type? That’s an article for another day.</p>
</div>
<div>
<p><a rel="nofollow" href="https://www.manning.com/books/data-munging-with-r?a_aid=datamungingwithr&a_bid=1dc44480" target="_blank">If you’re interested in seeing more, and hopefully providing feedback on what<br>
you do/don’t like about it, then use the discount code <code>mlcarroll</code> here</a><br>
for 50% off and get reading!</p>
</div>
</div>
</div>
</div>
<div>
<hr>
<div>
<a rel="nofollow" href="https://jcarroll.com.au/2017/06/26/data-munging-with-r-preview-storing-values-assigning/#_footnoteref_1" target="_blank">1</a>. In technical terms, <code>R</code> has no <em>scalar</em> types.
</div>
<div>
<a rel="nofollow" href="https://jcarroll.com.au/2017/06/26/data-munging-with-r-preview-storing-values-assigning/#_footnoteref_2" target="_blank">2</a>. This is where the distinction of <em>weakly typed</em> becomes important – in a <em>strongly typed</em> language you would not be able to arbitrarily change the type of a variable.
</div>
<div>
<a rel="nofollow" href="https://jcarroll.com.au/2017/06/26/data-munging-with-r-preview-storing-values-assigning/#_footnoteref_3" target="_blank">3</a>. This syntax is already used within <code>R</code> to denote functions acting on a specific class, such as <code>print.Date()</code>.
</div>
</div>

<p><a rel="nofollow" href="https://github.com/jonocarroll/wp_content/blob/master/_posts/2017-06-26-data-munging-with-r-preview-storing-values-assigning.md" target="_blank">View this post on GitHub</a></p>
	<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="https://jcarroll.com.au/2017/06/26/data-munging-with-r-preview-storing-values-assigning/"> R – Irregularly Scheduled Programming</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a rel="nofollow" href="https://www.r-project.org/" title="The R Project for Statistical Computing">R</a> news and <a rel="nofollow" href="https://www.r-bloggers.com/search/tutorial" title="R tutorials">tutorials</a> on topics such as: <a rel="nofollow" href="https://www.r-bloggers.com/search/data%20science" title="Data science">Data science</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data" title="Big Data">Big Data, <a rel="nofollow" href="https://www.r-users.com/" title="R jobs">R jobs</a>, visualization (<a rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2" title="ggplot and ggplot2 tutorials">ggplot2</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/boxplot" title="Boxplots using lattice and ggplot2 tutorials">Boxplots</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/map" title="Maps and gis">maps</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/animation" title="Animation in R">animation</a>), programming (<a rel="nofollow" href="https://www.r-bloggers.com/search/RStudio" title="RStudio IDE for R">RStudio</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/sweave" title="Sweave and literate programming">Sweave</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX" title="LaTeX in R">LaTeX</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/SQL" title="SQL and databases">SQL</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/eclipse" title="Eclipse IDE for R">Eclipse</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/git" title="git and github, Version Control System">git</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/hadoop" title="Large data in R using Hadoop">hadoop</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping" title="Web Scraping of google, facebook, yahoo, twitter and more using R">Web Scraping</a>) statistics (<a rel="nofollow" href="https://www.r-bloggers.com/search/regression" title="Regressions and ANOVA analysis tutorials">regression</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/PCA" title="principal component analysis tutorial">PCA</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/time+series" title="Time series">time series</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/trading" title="finance trading">trading</a>) and more...
<img width="1" alt="" src="http://feeds.feedburner.com/~r/RBloggers/~4/aY0mwMdDvtk" height="1"></a></div>