zoukankan      html  css  js  c++  java
  • 08/07/2017 R

    from today,i will learn something about the R.

    install R studio

    code:

    1.>install.packages("swirl")

    >library(swirl)##this sentence just for using of the swirl package.

    >swirl()##for the beginning of the swirl

    2.select the basic building blocks.  If at any point you'd like more information on a paticular topic,you can type the help.start() at the prompt. when  you input

    "help.start()",there are some resources for you about the problem.  (at some moment ,i i will try it )

    R can be used as a simple caculatorjust like " > 5 + 7",then press the enter,you will get the result.

    x <- 5 + 7.#there is a single space between two elements(<- is one element).And at this time, R thinks that you do not use the result immediately.so,when you write the x <- 5 + 7,and then you put the enter button,there is not a result.if you want a result ,you should write down the x,then click(press) the enter button.In other words,to view the contents of the variable x,just type x and press enter.

    Then type y <- x - 3. then type y,you will find that the result is 9. so x and y can be used in the next time because they are variables.

    To create a vector(a small collection of numbers),please type c(),which stands for "concatenate" or "combination".For example,To create a vector that containing the numbers 1.1,9 and 3.14,type c(1.1,9,3.14).

    3.any time you have some questions about a particular function,for example ,you want to get more information about the c(),,just type ?c.

    >z <- c(1.1,9,3.4)#make a vector and z stores the result.

    type z to view its contents. The result is like that 1.10  9.00 3.14. Notice that there are no commas seperating the values in the output.

    And you can combine the vetors to make a new vector.For example,type c (z,5.55) ,the result is like that 1.10 9.00 3.14 5.55.

    > z * 2 + 100 #Firstly,R mutiplied each of the 3 elements in z by 2..Then it added 100 to each of the elements.

     the result of the sqrt(z) is the same as z0.5.

    my_sqrt <-  sqrt(z-1)   my_div <- z / my_sqrt.  the result of this format is  that the first element of my_div is equal to the first element of z divided by the first element of my_sqrt,and so on...

    when you ask R to compute Z * 2 + 100,what it really compute is this :z * c(2,2,2) + c(100,100,100).

    When you ask R to compute c(1,2,3,4) + c(0,2)(try),the result is  1 4 3 6

    when you ask R to compute c(1,2,3,4) + c(1,2,3),the result is 2 4 7 5 and a waring (because the 3 is not enoug to recycle ).

     
     
  • 相关阅读:
    P1829 [国家集训队]Crash的数字表格 / JZPTAB 莫比乌斯反演
    Luogu P1447 [NOI2010]能量采集 数论??欧拉
    Luogu P2522 [HAOI2011]Problem b 莫比乌斯反演
    Luogu P2257 YY的GCD 莫比乌斯反演
    [笔记] 数论函数小记
    [笔记] 线性筛小记
    Luogu P1092 虫食算 爆搜
    Luogu P1066 2^k进制数 组合数学
    Luogu P1641 [SCOI2010]生成字符串 组合数学
    Luogu P2532 [AHOI2012]树屋阶梯 卡特兰数
  • 原文地址:https://www.cnblogs.com/lzida9223/p/7139091.html
Copyright © 2011-2022 走看看