官术网_书友最值得收藏!

Core essentials of R programming

One of the reasons for R's success is its use of variables. Variables are used in all aspects of R programming. For example, variables can hold data, strings to access a database, whole models, queries, and test results. Variables are a key part of the modeling process, and their selection has a fundamental impact on the usefulness of the models. Therefore, variables are an important place to start since they are at the heart of R programming.

Variables

In the following section we will deal with the variables—how to create variables and working with variables.

Creating variables

It is very simple to create variables in R, and to save values in them. To create a variable, you simply need to give the variable a name, and assign a value to it.

In many other languages, such as SQL, it's necessary to specify the type of value that the variable will hold. So, for example, if the variable is designed to hold an integer or a string, then this is specified at the point at which the variable is created.

Unlike other programming languages, such as SQL, R does not require that you specify the type of the variable before it is created. Instead, R works out the type for itself, by looking at the data that is assigned to the variable.

In R, we assign variables using an assignment variable, which is a less than sign (<) followed by a hyphen (-). Put together, the assignment variable looks like so:

Working with variables

It is important to understand what is contained in the variables. It is easy to check the content of the variables using the ls command. If you need more details of the variables, then the ls.str command will provide you with more information.

If you need to remove variables, then you can use the rm function.

主站蜘蛛池模板: 陈巴尔虎旗| 临桂县| 分宜县| 永泰县| 莒南县| 淮滨县| 萍乡市| 丰镇市| 剑阁县| 樟树市| 儋州市| 济源市| 卓资县| 鹤山市| 海阳市| 鸡东县| 夹江县| 中卫市| 苍山县| 双桥区| 区。| 西丰县| 仪陇县| 砚山县| 巴林左旗| 重庆市| 芦溪县| 吉首市| 清涧县| 南投市| 盘山县| 长海县| 全南县| 南部县| 东山县| 信阳市| 鄂托克前旗| 西丰县| 潞西市| 潢川县| 丰镇市|