正在加载图片...
Vectors and Vectorized Calculations >1s(0 character(0) the workspace is empty >x=1:5 we assign the vector (1,2,3,4,5)to the object name x y=c(5,4,3,2,1)#c for concatenate x typing the object name displays the object content [1]12345 >y [1]54321 >1s(0 [1]"x""y" now the workspace contains the objects x and y >X^2 [1]1491625 the square operation is vectorized y+x [1]66666 the summation is elementwise,vectorized x"y same here [1]11627165 10Vectors and Vectorized Calculations > ls() character(0) # the workspace is empty > x=1:5 # we assign the vector (1,2,3,4,5) to the object name x > y=c(5,4,3,2,1) # c for concatenate > x # typing the object name displays the object content [1] 1 2 3 4 5 > y [1] 5 4 3 2 1 > ls() [1] "x" "y" # now the workspace contains the objects x and y > xˆ2 [1] 1 4 9 16 25 # the square operation is vectorized > y+x [1] 6 6 6 6 6 # the summation is elementwise, vectorized > xˆy # same here [1] 1 16 27 16 5 10
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有