R Tutorial #2 – Math with Scalars and Vectors – Statistical Programming Language R

Part 2 of my R Tutorial – Doing Math with Scalars Vectors.

I show how to create variables in R and how to assign values (scalars or vectors) to them. I also show how to calculate with those variables in R and I use some mathematical functions like sum, prod, min, max, mean, var.


waleedmahmoud02 says:

What is the sign typed before the o.5 and in the other steps ?

maziarkr says:

Can anyone tell me please what is Product [prod(a) I mean]?

Boom says:

great work. I would recommend zooming on smaller part of the monitor so it makes it easier for us to read.

SoHoTandCool says:

you are just awesome bro!!! the exact stuff i needed!!!

GH123XL says:

In SPSS, you have the table where you put all o the coding number such as 2,2,4,1 (if you know what I mean). In R, where is the data take from? Excel?. Thank you very much.

Santosh Sahoo says:

If would like to have a vector that contains 40 1s you may use replicate function instead. Ex.. items <- rep(1,40)

kgangavaram says:

Please use a bigger font size , when you record a video tutorial ..


Leonardo Gutierrez says:

“sort” command puts the lowest value first and the highest value at the last. regards!

fallen4fate says:

Thanks! This is great! 🙂

Eric S. says:

Firstly, thanks for making this video. Its already been a help to me, and I’m only three minutes in.

I am trying to change the “step size”, but I’m missing something. I’ve tried it a couple of ways:

a <- seq(10, 100, by"10) a<-seq(10, 100, by"10) a<-c(10:100,by"10) ....and so on and so on, but R doesn't want to listen to me. What am I doing wrong?

Leonardo Gutierrez says:

Thanks a lot for posting this!!! 🙂

Leonardo Gutierrez says:

thanks! you’re right Giovanni

Eric S. says:

Nevermind. I figured it out. For my version it seems to be “by=” not ” by” “. Back to the video. Thanks again, this is great.

MrKernkraft4000 says:

@waleedmahmoud02 I made the video into 720p hd and it shows an = sign

codenamerishi says:

awesome video
what does ‘sort’ command do ???

RapidReader4 says:

Thank you so much.

TheEechee says:

a<-seq(10,100, by=10)

smmmm says:

Thank you very much!! Your videos are very helpful to me as well!!!!

Roshan D'Almeida says:

how can u get a sequence of length 40 with 1 printed 40 times… ie  1 1 1 1 1… 40times??? awaiting reply

codenamerishi says:

or you can see the video in 720p

SoHoTandCool says:

you are just awesome! thanks.

tajuara100 says:

Thank you very much, I really like R, your videos are very helpfull

Gregarious says:

I’m a Linux and Apple OS X developer, I’ve done many cool things with R, but as soon as I saw the Windows crap, I was forced by my conscience to stop watching.

Eddie Gashi says:

prod returns the product of all the values present in its arguments


print(prod(1:7)) == print(gamma(8))

Max Herrada says:

Thanks for your Tutorial. 😉

xyzkab00m says:

Very nice Video, thx a lot. To me personally the Kraut accent is nowhere near as annoying as the one of the indian dude that posted tutorials on the same topic. Kartoffelkopf ;D

giovanni9107 says:

That’s because he spelled the word length wrong.

Leonardo Gutierrez says:

Hi!! I just downloaded the new version of R 2.15.2. On what you explained on minute 5:50 the program recognized the full vector
[1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
[39] 1 1

 Write a comment


Do you like our videos?
Do you want to see more like that?

Please click below to support us on Facebook!