R language learning basis (1)

Reference materials: a PPT (I do not know who) & "153 minutes to learn R"

  • Auto-completion command:
    Tab key can automatically complete R command;
    using the Tab key twice to return all possible completions command list.
  • Clear variables:
    using RM () function,
    clear the variable x, rm(x)
    clear all variables,
    RM (LS List = (All = TRUE))
  • After changing the display decimal digits
    used Options (= digits)
    digits parameter can be from 1 to 22, the default is 7.
  • Call system program
    used sysytem () function, or by shell.exec ()
    , such as:
    System ( "Notepad")
    shell.exec ( "C: / the WINDOWS / Clock")
  • What CRAN that?
    Comprehensive R Archive Network, is to have the same information, including a collection of networks release version of R, package, documentation and source code.
  • R upgrade, but do not want to reinstall Packages
    to copy the files in the old version remains the library directory to the new version of the library catalog, then update.packages ();
    or unload R, the R attached to the old catalog, and then update. packages ()
  • Uninstall Packages already installed
remove.packages(c("pkg1","pkg2"),lib=file.path("path","to","library"))
  • View R's working directory
    using the getwd()命令get working directory of R;
    use setwd()命令to set the working directory location;
    the working directory: working directory
  • Save the
    use save.image()函数, Rdata saved to a file;
    use save (..., file =) R stored objects;
  • R meaning the initial state of loading the package
packages description
stats Commonly used statistical functions
graphics Basic drawing functions
grDevices Base or grid graphics device
utils R tool function
datasets Basic data set
methods R class defines methods and tools for programming objects and
base Basis function
  • View currently loaded packages
    use search()函数
    .packages(all.available = TRUE)to get a list of locally installed packages
  • Built using the R data sets
    data()函数can be loaded into memory;
  • Data type
    R not a scalar, vector storage by various types of data.
    Wherein factorfactor, used for labeling the sample.

Here Insert Picture Description
Not yet fathom ......

  • dataframe
    Matrix data block, a data set loose, can consist of different types of columns (number, factors, characters and the like) composed (matrix-like).
  • Function Code
    Enter function name carriage return;
    if it is a function of the class, consider using methods(类函数名)can see the list of functions, find a specific function, enter it, then Enter.
  • View matrix before and after a few lines
    head()函数;tail()函数
  • Meaning of formula symbols
Symbolic expression effect meaning
+ Or: Variable connection Interactions between variables
* - a*b=a+b+a:b
^ - (a+b+c)^2=(a+b+c)*(a+b+c)
- - Removed, (a + b + c) ^ 2-a: b = a + b + c + b: c + a: c
. - Update () is the function already represented
  • Reads the data portion
    using foreign包, read some statistical data software;
    read the data in Excel, the recommended method is: first Excel file saved as csv file (comma separated values), useread.csv()函数
  • Call output
    capture.output()函数: the output of R into a character or a file.
  • Read and write data directly from memory
    to use read.table("clipboard");write.table("clipboard")
  • The factor into digital
    as.numeric(as.character(f))
    as.numeric(levels(f))[as.integer(f)]
  • Input data using a spreadsheet
    edit()函数andfix()函数
Published 109 original articles · won praise 30 · views 10000 +

Guess you like

Origin blog.csdn.net/qq_43448491/article/details/103887805