]> git.donarmstrong.com Git - don.git/blobdiff - r/learning_r/variables_and_objects.mdwn
creating tag page tags/org-mode
[don.git] / r / learning_r / variables_and_objects.mdwn
index 064b4d04c21604ea2d1f4be8d4c66d8fe3aca7fb..f75c164cd006940e2b95fd107f1c14d6fd732b76 100644 (file)
@@ -1,21 +1,47 @@
 [[!meta title="Learning R: Basic Variables and Objects"]]
 
-Eventually here, you'll see some explanation of basic usage of
-variables and objects in R. For the time being, there are just some
-tests of my
-[sweavealike](http://git.donarmstrong.com/?p=ikiwiki_plugins.git;a=blob;f=sweavealike.pm;hb=HEAD)
-plugin for IkiWiki.
+Variables and Objects
+---------------------
 
+Like most computer languages, R uses variables as a means of storing
+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 code="""
-a <- 1
-a <- a + 10
-print(a)
+[[!sweavealike echo=1 results="hide" code="""
+foo <- 5
 """]]
 
-[[!sweavealike figure=1 echo=1 results="hide" code="""
-plot(1:10,(1:10)^2,xlab="x",ylab="x^2",main="Example figure")
-"""]
+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 specific memory location.
+
+Basic Types
+----------
+
+Vectors
+=======
+
+A vector is the major data type used in R. You can think of it as a
+line of cells, each containing a value of the same type.
+[Type here means a number or a string.]
+
+
+Lists
+=====
+
+
+Object Attributes
+-----------------
+
+
 
 
-testing