- Advanced Analytics with R and Tableau
- Jen Stirrup Ruben Oliva Ramos
- 316字
- 2021-07-02 20:26:04
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.
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:
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.
- Visual FoxPro程序設(shè)計教程(第3版)
- OpenCV for Secret Agents
- Java Web應(yīng)用開發(fā)技術(shù)與案例教程(第2版)
- 游戲程序設(shè)計教程
- 深入淺出DPDK
- 數(shù)據(jù)結(jié)構(gòu)案例教程(C/C++版)
- Mastering Data Mining with Python:Find patterns hidden in your data
- Python3.5從零開始學(xué)
- 代替VBA!用Python輕松實現(xiàn)Excel編程
- 區(qū)塊鏈架構(gòu)之美:從比特幣、以太坊、超級賬本看區(qū)塊鏈架構(gòu)設(shè)計
- Learning Grunt
- Scratch從入門到精通
- Python Machine Learning Cookbook
- 分布式數(shù)據(jù)庫HBase案例教程
- Java Web應(yīng)用開發(fā)