在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
1.R是一种可编程的语言。 2.所有R的函数和数据集是保存在程序包里面的。只有当一个包被载入时,它的内容才可以被访问。在另外版安装文件中,已经包含的程序包有:base一R的基础模块、mle一极大似然估计模块、ts一时间序列分析模块、mva一多元统计分析模块、survival一生存分析模块等等.
R的使用Data TypesR has a wide variety of data types including scalars, vectors (numerical, character, logical), matrices, data frames, and lists.
Creating New VariablesUse the assignment operator <- to create new variables.
FunctionsAlmost everything in R is done through functions. A function is a piece of code written to carry out a specified task; it may accept arguments or parameters (or not) and it may return one or more values (or not!). In R, a function is defined with the construct:
Importing DataImporting data into R is fairly simple. R offers options to import many file types, from CSVs to databases. For example, this is how to import a CSV into R.
Descriptive StatisticsR provides a wide range of functions for obtaining summary statistics. One way to get descriptive statistics is to use the sapply( ) function with a specified summary statistic. Below is how to get the mean with the sapply( ) function:
Possible functions used in sapply include mean, sd, var, min, max, median, range, and quantile. Plotting in RIn R, graphs are typically created interactively. Here is an example:
The plot( ) function opens a graph window and plots weight vs. miles per gallon. The next line of code adds a regression line to this graph. The final line adds a title. PackagesPackages are collections of R functions, data, and compiled code in a well-defined format. The directory where packages are stored is called the library. R comes with a standard set of packages. Others are available for download and installation. Once installed, they have to be loaded into the session to be used.
Getting HelpOnce R is installed, there is a comprehensive built-in help system. At the program's command prompt you can use any of the following:
R里的+不能用来连接字符串 Useful data frame functions
一个例子
|
请发表评论