Afrikaans
Akan
Albanian
Amharic
Arabic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Hungarian
Icelandic
Igbo
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranî)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Persian
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Russian
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
1
Hello everyone and welcome to the lecture on variables.
2
This lecture we're going to go over some conventions on naming variables and how to assign the variables
3
in R.
4
Let's go ahead and jump to our studio.
5
All right so here we are our studio and what I'm going to show you is just a couple of things that we're
6
going to be learning as we begin our journey on learning the our programming language.
7
And the first one we want to know is what actually comments or code.
8
So what if you just want to leave yourself some notes either in your script or in the console.
9
You can do is use a hash tag and this is similar to the Python programming language.
10
And then whatever you write after the hash tag such as this is a comments.
11
If you end up running this you'll notice that nothing comes out.
12
So let's go ahead and show that in the console.
13
So if I say something like print Hello enter and then if I were to do the exact same thing with a hash
14
tag in front of it notice that I don't get any output because R won't read anything.
15
Pass the hash tag because it treats it as just that comments.
16
So that's one thing I want you to be aware of.
17
And now let's go ahead and discuss variables and how to assign variables so variable names by convention
18
.
19
Start off with lower case letters.
20
So if you had something like variable you would say use this assignment operator and then put in whatever
21
you want to assign that variable.
22
So what's actually happening here.
23
We created a variable name.
24
This case is called variable and we use the assignment operator which is this basically looks like an
25
arrow which is nice for readability.
26
So it's this less and and then a minus or a dash.
27
So they form an arrow and then on the right hand side whatever data object or data type you want to
28
assign to that very well.
29
So for this lecturer it's going to be dealing with integers since that's something we've dealt with
30
before.
31
In the example of arithmetic.
32
So here I am in signing the integer 100 to the variable called variable.
33
So if I call variable again and then go ahead and just click enter in the council will return its assigned
34
value which is 100.
35
So let's go ahead and imagine another example will say bank and assignats 1000.
36
So now if I call bank I get 1000 out as the assignments.
37
So that's a variable assignment works.
38
And you'll notice here in the environment if you ever want to know what variables you have or what values
39
you have in your global environment for this session of Are You can reference this here.
40
So just some quick style guides and convention points usually what you want to do is let's say you want
41
to have multiple words in your variable name.
42
What you would do is separate them by a period or dot.
43
So we can say something like bank accounts and then assign that 100 so that's acceptable.
44
Sometimes you also see this sort of notation bank and then instead of a dot They just write a capital
45
A.
46
What you won't see in our as often and is usually known as a bad style season.
47
Underscore now it will still work completely So each of these is technically correct you can use all
48
of these methods but the most common styles you'll see is this Fersen right here separating each of
49
the words.
50
All right.
51
Later on when we discuss functions we'll go over the style guides for namea your functions and functions
52
will actually usually start with capital letters.
53
So finally just go ahead and show a quick simple example how you can use variables to perform calculations
54
in operations that are.
55
Let's go ahead and clear the cons..
56
And here in Windows I'm clearing the consulars by doing control L as a shortcut for that.
57
So I'm just going to go ahead and say make a variable deposit assign it.
58
Let's just say 20 enter.
59
So I have my deposit and I'm going to say bank accounts bank account and I'm going to reassign bank
60
accounts as my current bank account plus my deposit.
61
So notice here before I actually run this line my bank account variable is equal to 100.
62
My deposit is equal to 20 after running this line.
63
What's going to happen by click enter my bank account is going to be equal to 120.
64
So that's going to be the 20 plus the previous 100 value of bank account and it's going to update that
65
variable which is bank accounts and that's the basic way you can use variables in a variable assignment
66
operations.
67
In our ok player I think it's pretty straightforward.
68
The main thing to go to this lecture is that this symbol this arrow symbol is what you're going to be
69
using for variable assignments in our.
70
Okay.
71
Thanks everyone.
72
I'll see you at the next lecture
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.