Nanana, as a non-qualified math students, the brain is not good, and poor force, had to learn something practical, hope to support themselves ~ ~ ~
Not blind beep, want to do data aspects of work in the hesitation is to learn R or learn python, a little Python foundation has not forcibly used a Python crawler, found that Python is still more trouble (but still later spent some time to learn some of the Python basic syntax, Find Python is really great, but always feel r more appropriate, R really is more beautiful things ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Please give me more advice!
1. R Vector
I like this thing very much, it is too convenient when I am experimenting with big things-.-
> X1 <-C (1:20)
> x1
[1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
As you can see, the function C () is to generate a vector, and 1:20 means to start at 1 with an interval of 1 and 20.
What happens when you add 2 to the 20 interval?
> x2 <-C (1:20:2)
It doesn't look right, is it like MATLAB? But---
In 1:40:2: Numerical expression has elements:only the first used
Wrong!!! The problem is that C () can't use it! But I don't know why I can't use it ...
The correct is as follows:
> x2 <-seq (1,20,2)
> x2
[1] 1 3 5 7 9 11 13 15 17 19
Note ha, seq is used in the "," not ":", I stepped on this a lot of pits =. =
What if I want to generate a square from 1 to 100?
> brother, this is a write loop//I won't.
2. Matrix
The matrix is a two-dimensional array, but the inside must be a type, such as a value, it is a value, is a character, it is a character.
> x3 <-Matrix (1:20,ncol = 5,nrow = 4)
> x3
[, 1] [, 2] [, 3] [, 4] [, 5]
[1,] 1 5 9 13 17
[2,] 2 6 10 14 18
[3,] 3 7 11 15 19
[4,] 4 8 12 16 20
It is said that there is nothing to sort by row by column, the detailed look at the R document Bar ~ ~ How good.
3. Data frame
Forget the array (declare remember array is OK) ... No problem, direct data frame bar data.frame (c1,c2 ...)
That's the way to look at the examples.
> C1 <-C (1:20)
> C2 <-seq (1,60,3)
> M <-data.frame ("first column" = C1, "second column" = C2)
> M
First column, second column
1 1 1
2 2 4
3 3 7
4 4 10
5 5 13
6 6 16
7 7 19
8 8 22
9 9 25
10 10 28
11 11 31
12 12 34
13 13 37
14 14 40
15 15 43
16 16 46
17 17 49
18 18 52
19 19 55
20 20 58
Notice that there is no, the header is the first column, the second column, right, that is the mark!
and forgot to say how to visit ... I'm dizzy, coming in for a visit:
> m[2,]//Access second line
First column, second column
2 2 4
> m[,2]//access to the second column
[1] 1 4 7 10 13 16 19 22 25 28 31 34 37 40 43 46 49 52 55 58
> m[2,2]//
[1] 4
PS: Why I always visit 2 ....
And then into a plot,
> Plot (M)
Write a loop with R and look at it!
> S[1] <-0
> S
[1] 0 2 5 9 14 20 27 35 44 54 65 77 90 104 119 135 152 170 189 209 230
Reason, really feel so tired of writing loops, the statement is very short ~ ~
Write while when the less than the number hit the "<-" and then into the dead loop ... Just shut the process down and do it tomorrow.
R Language Introduction series the Math dog still does the data.