Basic R Introduction

If you don't already have your computer set up to program in R, then check out this card: http://www.vingle.net/posts/525420-Get-started-with-R
CREATING A VECTOR
To create a vector you can use the c function like this:
x <- c(8,9,16,25, 33)
Or you can even use a sequence function if you want to make a vector that has a sequence, such as 5, 10, 15, 20, 25
y <- seq(5,25, by=5)
You can also use the repeat function if you want to make a vector of 7 2's (e.g. 2,2,2,2,2,2,2)
z <- rep(2, 7)
You can add, multiply vectors together
x+y
y*z
As long as they are same length, unless you get an error.
For more on basic operations, check out this link:
http://www.cyclismo.org/tutorial/R/basicOps.html

5 comments

TechAtHeart

this is so helpful!!!!!!

csgeek

you are very welcome! do you use R?

TechAtHeart

Yes, I do! Sorry I missed your comment. I use this for statistical analysis.

csgeek

@TechAtHeart I just took a course on regression analysis and had to learn this. It's not very hard, which is why I like R.

TechAtHeart

@csgeek very true! I feel very comfortable with R...at least way more comfortable thab when I took a Python class haha. Still fun!