All language subtitles for 5. Vector Basics

af Afrikaans
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bn Bengali
bs Bosnian
bg Bulgarian
ca Catalan
ceb Cebuano
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English Download
eo Esperanto
et Estonian
tl Filipino
fi Finnish
fr French
fy Frisian
gl Galician
ka Georgian
de German
el Greek
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian Download
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
km Khmer
ko Korean
ku Kurdish (Kurmanji)
ky Kyrgyz
lo Lao
la Latin
lv Latvian
lt Lithuanian
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mn Mongolian
my Myanmar (Burmese)
ne Nepali
no Norwegian
ps Pashto
fa Persian
pl Polish
pt Portuguese
pa Punjabi
ro Romanian
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
st Sesotho
sn Shona
sd Sindhi
si Sinhala
sk Slovak
sl Slovenian
so Somali
es Spanish
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
te Telugu
th Thai
tr Turkish
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
or Odia (Oriya)
rw Kinyarwanda
tk Turkmen
tt Tatar
ug Uyghur
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:00,990 --> 00:00:06,580 Hello everyone and welcome to the lecture on vector basics and this lecture were to learn how to construct 2 00:00:06,580 --> 00:00:11,880 the vector using the combined function the different rules about constructing a vector and how to use 3 00:00:11,880 --> 00:00:15,600 the names function to assign names to each element in our vector. 4 00:00:15,600 --> 00:00:18,960 Let's go ahead and jump to our studio to get started. 5 00:00:18,960 --> 00:00:25,920 All right so here our studio and let's discuss the vector so vector is just a one dimensional array 6 00:00:25,920 --> 00:00:31,620 that can hold character numeric or logical data elements and we create a vector by using the combined 7 00:00:31,620 --> 00:00:34,570 function which is just the letter c of some parentheses. 8 00:00:34,830 --> 00:00:37,930 So let's go ahead and create a couple of factors. 9 00:00:37,980 --> 00:00:40,560 We'll start by creating a vector of numerics. 10 00:00:40,590 --> 00:00:47,670 So I'll call this NBC as the variable name of the assignment operator that little arrow and then use 11 00:00:47,670 --> 00:00:54,030 the combined function which is that C lose some parentheses and then pass an individual elements separated 12 00:00:54,030 --> 00:00:55,260 by a comma. 13 00:00:55,260 --> 00:01:02,970 So let's just say one two three four five separated by commas and notice in my environment I have NVC 14 00:01:03,720 --> 00:01:10,380 and if I call NABC I get back my one dimensional array of those five elements and we can go ahead and 15 00:01:10,380 --> 00:01:18,180 call class on NVC and all return numeric since every element in that vector is a numeric. 16 00:01:18,180 --> 00:01:20,480 Let's go ahead and just see a couple more examples. 17 00:01:20,520 --> 00:01:29,250 Let's say I wanted a vector of characters let's call it C C and we'll just go ahead and pass in USA 18 00:01:29,290 --> 00:01:29,360 . 19 00:01:29,370 --> 00:01:36,500 So you will say s a. 20 00:01:36,960 --> 00:01:42,900 And remember to put in the C here for the combined function in order to actually create that vector 21 00:01:43,320 --> 00:01:47,250 c v c and then we have USA. 22 00:01:47,280 --> 00:01:47,720 All right. 23 00:01:47,720 --> 00:01:51,900 And if I check the class it's going to return character. 24 00:01:51,930 --> 00:01:55,380 Finally let's get a vector of logicals. 25 00:01:55,380 --> 00:02:04,050 So those boolean values and we'll just say T capital T capital F stands for true false LGC is true false 26 00:02:04,050 --> 00:02:04,080 . 27 00:02:04,080 --> 00:02:08,260 And if I check the class of that it's a logical. 28 00:02:08,430 --> 00:02:09,070 All right. 29 00:02:09,390 --> 00:02:14,970 So something to note here is you may be wondering well what if I try to put in different data types 30 00:02:15,270 --> 00:02:16,360 into a vector. 31 00:02:16,380 --> 00:02:18,670 What would the class function return. 32 00:02:18,690 --> 00:02:24,390 So one of the rules about vectors is that you can't mix data types into the elements of that vector 33 00:02:24,390 --> 00:02:29,060 array R will convert the other elements to force everything to be of the same class. 34 00:02:29,070 --> 00:02:31,890 We're going to show you an example of how that would work. 35 00:02:31,890 --> 00:02:41,970 So going to create a variable v and then going to try to combine let's say a logical true with some 36 00:02:42,060 --> 00:02:45,120 numbers 20 and 40. 37 00:02:45,120 --> 00:02:51,030 So if I try doing that they'll notice if I call back that vector V that true has been converted to a 38 00:02:51,030 --> 00:02:52,660 numeric one. 39 00:02:52,980 --> 00:02:56,980 And that is going to be because everything else in that vector was numeric. 40 00:02:57,030 --> 00:02:59,250 So if I call class on the. 41 00:02:59,400 --> 00:03:01,640 Everything has been converted to a numeric. 42 00:03:01,650 --> 00:03:06,720 Likewise if I put in false that false would have been converted to a 0 number. 43 00:03:06,820 --> 00:03:11,040 Let's show you another example of mixing data types. 44 00:03:11,040 --> 00:03:22,160 Let's say I had a character let's say just USA as a string and some numbers 20 31. 45 00:03:22,200 --> 00:03:26,080 You might be thinking well how can USA be converted into a numeric. 46 00:03:26,160 --> 00:03:31,300 Well in this case what are we going to do it's going to convert everything else into a character. 47 00:03:31,320 --> 00:03:34,640 So everything matches the character of USA. 48 00:03:35,040 --> 00:03:40,950 So if I call in class VI now everything in that vector is a character Scotius something to keep in mind 49 00:03:40,950 --> 00:03:40,970 . 50 00:03:40,980 --> 00:03:44,190 You can't mix up these data types elements in a vector. 51 00:03:44,190 --> 00:03:49,320 Later on we'll learn about other data structures such as a list which will allow us to mix and match 52 00:03:49,320 --> 00:03:53,360 different data types into an organizational array. 53 00:03:53,370 --> 00:03:54,140 All right. 54 00:03:54,390 --> 00:03:58,360 With that being said let's go ahead and talk about vector names. 55 00:03:59,280 --> 00:04:02,900 So let's imagine we had a vector of temperature data. 56 00:04:02,970 --> 00:04:10,200 So I go in and clear this make a new vector called temp's and put in some temperature data. 57 00:04:10,200 --> 00:04:17,850 Let's go ahead and say 72 degrees 71 degrees and some other just numbers and good and fill these in 58 00:04:17,850 --> 00:04:22,010 as you see fit 75. 59 00:04:22,010 --> 00:04:29,370 So let's go ahead and make one for each week day so Monday Tuesday Wednesday Thursday Friday Saturday 60 00:04:30,240 --> 00:04:32,320 Sunday. 61 00:04:32,370 --> 00:04:33,060 All right. 62 00:04:33,390 --> 00:04:38,760 So these are in Fahrenheit hopefully Celsius will be quite hot. 63 00:04:38,970 --> 00:04:40,300 So we are temps. 64 00:04:41,040 --> 00:04:48,540 And if you notice very cold temps back I have an array of numbers but no names to associate with each 65 00:04:48,540 --> 00:04:49,950 of those temperatures stand for. 66 00:04:49,950 --> 00:04:55,590 So I don't know if the Week starts at Sunday or Monday here and I want to add that information and I 67 00:04:55,590 --> 00:04:58,200 can do that using the names function. 68 00:04:58,620 --> 00:05:08,550 So I'm going to go ahead and say names pass in the vector that I want to name and then apply or assign 69 00:05:08,790 --> 00:05:12,470 a vector of names for the temps vector. 70 00:05:12,660 --> 00:05:17,160 So it's going to started off on Monday so I'll say Tuesday 71 00:05:20,310 --> 00:05:21,030 Thursday 72 00:05:25,220 --> 00:05:37,860 will say Friday Saturday Sunday say the sun makes sure that one last ones in single quotes or double 73 00:05:37,860 --> 00:05:39,360 quotes. 74 00:05:40,490 --> 00:05:46,430 OK so I've been able to assign names to each of these elements if I cold temps. 75 00:05:46,430 --> 00:05:49,340 Now notice the output. 76 00:05:49,410 --> 00:05:52,530 Now each of these temperatures has been assigned a name. 77 00:05:52,530 --> 00:05:56,820 This is going to be really useful because now later on we learn about indexing vectors. 78 00:05:56,850 --> 00:06:00,520 I can use these names to grab data out of the vector. 79 00:06:00,840 --> 00:06:05,600 Something to note is that I don't have to keep rewriting this long vector of weekdays. 80 00:06:05,610 --> 00:06:13,980 I could just assign this vector to let's say a vector called days may go ahead and do that in the press 81 00:06:14,130 --> 00:06:19,370 on the up arrow on my keyboard and let's go ahead instead of using names here. 82 00:06:19,410 --> 00:06:25,150 When I'm going to do is assigned this to a new vector called days. 83 00:06:25,590 --> 00:06:27,090 So never called days. 84 00:06:27,180 --> 00:06:33,450 I have this character vector of day information on Monday Tuesday etc. and then I can do this sort of 85 00:06:33,450 --> 00:06:36,810 operation names temps 86 00:06:40,620 --> 00:06:43,250 and assign days to it in this format. 87 00:06:43,470 --> 00:06:48,200 So usually when you're doing names obviously will get the same result here same vector. 88 00:06:48,360 --> 00:06:52,740 But as I mentioned usually in reading names you're not going to write this whole long vector multiple 89 00:06:52,740 --> 00:06:54,410 times feasible times. 90 00:06:54,480 --> 00:07:00,730 Your first assigned to a vector like so and then use that vector in your name assignment later on. 91 00:07:00,740 --> 00:07:06,690 OK so let's just go over everything we learned just quickly throughout this lecture. 92 00:07:06,690 --> 00:07:11,700 We learn how to use the combine function which is c and if you can go ahead and check out the history 93 00:07:12,720 --> 00:07:14,060 here on this panel. 94 00:07:14,100 --> 00:07:16,430 So we took out the combined function. 95 00:07:16,440 --> 00:07:22,410 Learn how to use it learn that vectors can only take up one data type otherwise other data types will 96 00:07:22,410 --> 00:07:23,390 be converted. 97 00:07:23,430 --> 00:07:27,010 We learn how to use names and learn about the vector assignment. 98 00:07:27,350 --> 00:07:32,740 OK later on we're going to learn much more about how to use and work with vectors in our. 99 00:07:32,790 --> 00:07:35,040 Thanks everyone and I'll see you at the next lecture. 10280

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.