From 2dbbbc932b5b3ae84d23805e5ef8d83bef79fdb1 Mon Sep 17 00:00:00 2001 From: Don Armstrong Date: Thu, 5 Jul 2012 14:47:38 -0700 Subject: [PATCH] add more information on variables --- r/learning_r/variables_and_objects.mdwn | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/r/learning_r/variables_and_objects.mdwn b/r/learning_r/variables_and_objects.mdwn index 202dd8b..f75c164 100644 --- a/r/learning_r/variables_and_objects.mdwn +++ b/r/learning_r/variables_and_objects.mdwn @@ -4,10 +4,25 @@ Variables and Objects --------------------- Like most computer languages, R uses variables as a means of storing -information in memory and retrieving it later. A variable +information in memory and retrieving it later. Variables can be +assigned to using the `<-` or `=` operator. For example, to assign the +number `5` to the variable `foo`, you would write + +[[!sweavealike echo=1 results="hide" code=""" +foo <- 5 +"""]] + +Variables can retrieved simply by referring to them by name. For +example, to add `8` to the variable `foo` and store the result in +`bar`, you would do the following: + +[[!sweavealike echo=1 results="hide" code=""" +bar <- foo + 8 +"""]] + In R, variables are more correctly called objects, because they have -structure and do not directly refer to a memory. +structure and do not directly refer to a specific memory location. Basic Types ---------- -- 2.39.2