# R语言从基础入门到提高（一）Intro to basics（基础介绍）

https://www.datacamp.com/home

####（中没有意识到！！！

####

# An addition
5 + 5

# A subtraction
5 - 5

# A multiplication
3 * 5

# A division
(5 + 5) / 2

# Exponentiation
2 ^ 5

# Modulo
28 %% 6

console：
> 5 + 5
[1] 10
>
> # A subtraction
> 5 - 5
[1] 0
>
> # A multiplication
> 3 * 5
[1] 15
>
>  # A division
> (5 + 5) / 2
[1] 5
>
> # Exponentiation
> 2 ^ 5
[1] 32
>
> # Modulo
> 28 %% 6
[1] 4

# Assign the value 42 to x
x <- 42

# Print out the value of the variable x
x
console：
> # Assign the value 42 to x
> x <- 42
>
> # Print out the value of the variable x
> x
[1] 42

# Assign the value 5 to the variable my_apples
my_apples <- 5

# Print out the value of the variable my_apples
my_apples

console：
> # Assign the value 5 to the variable my_apples
> my_apples <- 5
>
> # Print out the value of the variable my_apples
> my_apples
[1] 5
>

# Assign a value to the variables my_apples and my_oranges
my_apples <- 5
my_oranges <-6

# Add these two variables together
my_apples + my_oranges

# Create the variable my_fruit
my_fruit <- my_oranges+my_apples
console：
> # Assign a value to the variables my_apples and my_oranges
> my_apples <- 5
> my_oranges <-6
>
> # Add these two variables together
> my_apples + my_oranges
[1] 11
>
> # Create the variable my_fruit
> my_fruit <- my_oranges+my_apples
>

改错练习：
# Assign a value to the variable my_apples
my_apples <- 5

# Fix the assignment of my_oranges
my_oranges <- "six"

# Create the variable my_fruit and print it out
my_fruit <- my_apples + my_oranges
my_fruit

console：
> # Assign a value to the variable my_apples
> my_apples <- 5
>
> # Fix the assignment of my_oranges
> my_oranges <- "six"
>
> # Create the variable my_fruit and print it out
> my_fruit <- my_apples + my_oranges
Error: non-numeric argument to binary operator
> my_fruit

Click 'Submit Answer' and read the error message. Make sure to understand why this did not work.
Adjust the code so that R knows you have 6 oranges and thus a fruit basket with 11 pieces of fruit.
Take Hint (-30xp)
Incorrect submission
Your code contains an error that you should fix:
Error: non-numeric argument to binary operator
You can do this by setting the my_oranges variable to a numeric value, not a string!


基本数据类型：
Basic data types in R
100xp
R works with numerous data types. Some of the most basic types to get started are:
Decimals(小数，十进制数) values like 4.5 are called numerics.
Natural numbers like 4 are called integers. Integers（整数） are also numerics.
Boolean（布尔） values (TRUE or FALSE) are called logical.(逻辑数)
Text (or string（字符串）) values are called characters.（对象）
Note how the quotation（引用） marks on the right indicate that "some text" is a character.

# Change my_numeric to be 42
my_numeric <- 42

# Change my_character to be "universe"
my_character <- "universe"

# Change my_logical to be FALSE
my_logical <- FALSE

console：
> # Change my_numeric to be 42
> my_numeric <- 42
>
> # Change my_character to be "universe"
> my_character <- "universe"
>
> # Change my_logical to be FALSE
> my_logical <- FALSE


"数据"类型 检查 cheak
Do you remember that when you added 5 + "six", you got an error due to a mismatch in data types? You can avoid such embarrassing situations by checking the data type of a variable beforehand. You can do this with the class()function, as the code on the right shows.

# Declare variables of different types
my_numeric <- 42
my_character <- "universe"
my_logical <- FALSE

# Check class of my_numeric
class(my_numeric)

# Check class of my_character
class(my_character)

# Check class of my_logical
class(my_logical)

console:

> # Declare variables of different types
> my_numeric <- 42
> my_character <- "universe"
> my_logical <- FALSE
>
> # Check class of my_numeric
> class(my_numeric)
[1] "numeric"      小数&整数
>
> # Check class of my_character
> class(my_character)
[1] "character"       字符串
>
> # Check class of my_logical
> class(my_logical)
[1] "logical"      布尔
>


ps:一切内容均是本人总结提炼的，方式有网上查阅，翻阅书籍。如果设计版权希望能及时提醒更改。同时希望注重保护他人成果！

## java语言基础入门——各类流的介绍

1、什么是流？流是一个抽象的概念，代表一串数据集合，当java程序需要从数据源读取数据时，就开启了一个到数据源的流，同样，当数据需要输出数据到达目的地时，也需要开启一个流。流是用来处理数据的通道。流有...
• qq_29672495
• 2016年08月05日 17:56
• 1622

## 【从入门到放弃】WEB前端之HTML+CSS基础03

• yanwydxf
• 2017年07月07日 13:59
• 234

## 深度学习入门介绍系列1

• rodneyzhaonet
• 2014年12月13日 12:10
• 1750

## 【WLAN从入门到精通-基础篇】第4期——华为WLAN产品介绍（了解即可）

• qliu83
• 2017年05月05日 17:35
• 446

## JAVA从入门到放弃到再入门

• vincent_zzh33
• 2018年01月26日 13:27
• 13

## ExtJs从入门到精通

ExtJs从入门到精通（作成中）1、入门篇    ①窗口Window及对话框MessageBox     　地址：http://www.myext.cn/Article/61.html     ②...
• szwangdf
• 2009年05月08日 12:26
• 1622

## 傅里叶分析之从入门到放弃

• qingfengtsing
• 2016年10月20日 19:17
• 982

## Java从入门到精通——基础篇之Java 常用类

• gwblue
• 2013年05月29日 19:49
• 1439

## java从入门到精通 - Java基础

• zyljjf
• 2017年09月28日 15:47
• 40

## python3 从基础入门到高级进阶练习题之----基础篇005

• PythonStory
• 2016年11月09日 16:29
• 433

举报原因： 您举报文章：R语言从基础入门到提高（一）Intro to basics（基础介绍） 色情 政治 抄袭 广告 招聘 骂人 其他 (最多只允许输入30个字)