Hi! I am Mike Marin and in this video 嗨！我是迈克马林和这部影片
we will get our first hands-on experience using R. 我们将使用R来获得我们的第一手实践经验。
For the most part of this video we will discuss assigning values to objects in R, 在这部影片的大部分内容中，我们将讨论为R中的对象赋值，
basic arithmetic functions and a few other handy things to know 基本的算术功能和一些其他方便的知识
when getting started with R. 当开始使用R.
first we can assign a value to an object in R using the equal sign (=) 首先我们可以使用等号（=）为R中的对象赋值
let's create an object called x 让我们创建一个名为x的对象
and store in it the value 11. 并在其中存储值11。
If we would like to see 如果我们想看看
what is stored in an object, we can ask R 存储在一个对象中的东西，我们可以问R
to "print" that object or 以“打印”该对象或
we may simply type the name of the object itself. 我们可以简单地键入对象本身的名称。
You should note 你应该注意
that R is case sensitive. we can see if we type capital X R是区分大小写的。我们可以看到我们是否输入大写字母X.
R returns an error message letting us know R返回一条错误消息让我们知道
there is no object capital X stored in R's memory R的内存中没有存储对象资本X.
instead of using the equal sign 而不是使用等号
to assign values to objects we may also use the "less than sign <" 为对象分配值我们也可以使用“小于号”<“
and a dash "-" to create an arrow. Here we'll assign the value 7 和一个破折号“ - ”来创建一个箭头。这里我们将分配值7
to the object "y". 到对象“y”。
The choice to use the equal sign 选择使用等号
or the arrow is simply a matter of preference 或者箭头只是一个偏好问题
and usually the one that one chooses to use 通常是一个选择使用的人
really is just an artifact of which one they learned first 真的只是他们第一个学到的东西
I prefer using the arrow but that's just my own personal choice 我更喜欢使用箭头，但这只是我个人的选择
R will easily overwrite objects R很容易覆盖对象
for example if we try to assign the value 9 to y 例如，如果我们尝试将值9赋给y
the object y now has a value of 9 对象y现在的值为9
and the value of 7 has been 和7的价值已经
overwritten. To see what is stored in R's 覆盖。查看R中存储的内容
memory or in the workspace we can take a look 内存或工作区中，我们可以看看
up here at the workspace in R or 在R或者R的工作区中
we may use the "ls command" to ask R 我们可以使用“ls命令”来问R
to let us know everything that stored in the workspace memory 让我们知道存储在工作区内存中的所有内容
we may remove an object 我们可能会删除一个对象
from the workspace memory using the "rm command" 从工作区内存使用“rm命令”
here let's remove y from R's memory 这里我们从R的内存中删除y
we can now see the object y is not found 我们现在可以看到没有找到对象y
now let's just go back ahead and store the value 9 and y 现在让我们回到前面并存储值9和y
because we're gonna come back to using this later. 因为我们稍后会回来使用它。
Object names in R R中的对象名称
may include numbers or periods, for example 例如可以包括数字或句点
"x.1" is equal to say 14 “x.1”等于14
Although the number may not appear as the first character 尽管该号码可能不会显示为第一个字符
in the object's name, for example if we try to assign 在对象名称中，例如，如果我们尝试分配
the value of 22 to the object "1x" 对象“1x”的值为22
we will see we are returned an error message; 我们会看到我们返回了一条错误消息;
we may also assign 我们也可以分配
character values to objects in R rather than numbers 字符值给R中的对象而不是数字
we can do this by including quotation marks 我们可以通过加引号来实现这一点
around the characters, for example 例如，在角色周围
let's create an object xx and we will assign to it 让我们创建一个对象xx，我们将分配给它
the characters "marin". 人物“马林”。
We can now see these characters are stored in the object xx. 我们现在可以看到这些字符存储在对象xx中。
It's worth noting that if we include numbers in quotations in R 值得注意的是，如果我们在R中包含引号中的数字
R will treat these as characters and not numeric R会将这些视为字符而不是数字
when performing operations on them. for example 当对他们进行操作时。例如
if we assign a value in quotations "1" 如果我们在报价单中指定一个值“1”
to the object yy, R will treat 对象yy，R会对待
yy as a character not as a number. yy作为一个字符而不是一个数字。
We may perform arithmetic operations in R, for example 11 我们可以在R中执行算术运算，例如11
plus 14 is 25 加14是25
7 times 9 is 63 . We may also perform the same 7次9是63。我们也可能会执行相同的操作
operations on objects in R. recall that we have stored 对R.中的对象进行操作，记得我们已经存储了
the value 11 in the object x and the value 对象x中的值11和值
9 in the object y. we can add 9在对象y中。我们可以添加
x and y together using the addition sign (+). x和y一起使用加号（+）。
we may wish to store this 我们不妨存储这个
in a new object called z. 在一个名为z的新对象中。
similarly we can subtract y from x 同样我们可以从x中减去y
we can multiply x and y 我们可以乘以x和y
or we can divide: x divided by y 或者我们可以将x除以y
we can also perform other arithmetic operations 我们也可以执行其他算术运算
for example we can square y 例如我们可以平方米
we can take x squared and add this 我们可以将x平方并加上
to y squared y平方
we can take the square root of y using "sqrt command" 我们可以使用“sqrt命令”取y的平方根
or we may simply take y 或者我们可以简单地拿y
and raise it to the power of a half 并提升到一半的力量
we can take the natural logarithm or ln 我们可以采取自然对数或ln
using the "log command" 使用“日志命令”
we can take the exponent of y 我们可以取y的指数
that is the anti log using the "exp command" 那就是使用“exp命令”的反日志
we can also calculate logs of other bases 我们也可以计算其他基地的日志
for example log base 2 using the "log2 command" 例如使用“log2命令”的日志库2
we can calculate the absolute value using the "abs command" 我们可以使用“abs命令”来计算绝对值
here the absolute value of -14 is 14 这里-14的绝对值是14
We will end off this video by mentioning a few helpful things to know in R 我们将通过提及R中一些有用的知识来结束此视频
The first is that if you've entered an incomplete command 首先是如果你输入了一个不完整的命令
R will follow that up with a plus sign (+) letting you know R会用一个加号（+）让你知道
there's an incomplete command. we can see if we don't complete this 有一个不完整的命令。我们可以看看我们是否完成这个
R will still give us a plus sign. Once we add the R仍然会给我们一个加号。一旦我们添加了
close parentheses to end this command 关闭圆括号来结束这个命令
R will now return the square root of y to us. R现在将返回y的平方根到我们。
A second thing worth knowing is a very handy shortcut: 值得了解的第二件事是一个非常方便的捷径：
using the "arrow up key" on the keyboard 使用键盘上的“向上箭头键”
will bring you to the last command that was entered in R 会将您带入在R中输入的最后一个命令
hitting the arrow key up again will bring you to the previously entered command 再次按下箭头键会使您看到之前输入的命令
and so on. we can see every time we hit the arrow up key 等等。每次我们点击箭头键时我们都可以看到
this brings us to the previously entered command in R 这将我们带到之前输入的命令中
we can hit the "arrow down key" to move forward 我们可以击中“向下箭头键”向前迈进
in the commands that have been entered 在已经输入的命令中
Finally one may want to include some writing 最后可能需要包括一些文字
or comments within their code to remind themselves 或在其代码中提醒自己
of why they entered certain code when looking through things later on 他们为什么在后面查看事情时输入了某些代码
for example you might want to have:" the code below 例如你可能想要：“下面的代码
is for ..." so when you look back on this code a month later 是为了...“，所以当你一个月后回顾这段代码的时候
you can remember why you were entering certain things 你可以记住你为什么要进入某些东西
you'll notice that R gives us an error here, it doesn't recognize this as being a command 你会注意到R在这里给我们一个错误，它不认为这是一个命令
including the number sign or hash (#) 包括数字符号或散列（＃）
in front of this will let R know to ignore 在这之前会让R知道忽略
everything that follows after the number sign or the hash (#) 数字符号或哈希后面的所有内容（＃）
this will become useful as you start to write more lengthy code 这会在您开始编写更长的代码时变得有用
and want to be able to include notes reminding you what you did in this code 并希望能够包含提醒您在本代码中做了什么的注释
In the next video we will discuss creating vectors and matrices 在下一个视频中，我们将讨论创建矢量和矩阵
and performing some operations on these 并对这些进行一些操作
Thanks for watching this video and make sure to check out my other instructional videos 感谢观看此视频并确保查看我的其他教学视频 118