r:data_structures
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
r:data_structures [2018/11/20 08:39] – [Editing a Data Frame] hkimscil | r:data_structures [2019/09/19 18:16] (current) – [Creating a Factor (Categorical Variable)] hkimscil | ||
---|---|---|---|
Line 54: | Line 54: | ||
^ Object | ^ Object | ||
- | | Number | + | | Number |
- | | Vector of numbers | + | | Vector of numbers |
- | | Character string | + | | Character string |
- | | Vector of character strings | + | | Vector of character strings |
- | | Factor | + | | Factor |
- | | List | list(" | + | | List | '' |
- | | Data frame | data.frame(x=1: | + | | Data frame | '' |
- | | Function | + | | Function |
===== Class ===== | ===== Class ===== | ||
Line 135: | Line 135: | ||
Grouping: This is a technique for labeling or tagging your data items according to their group. See the Introduction to Chapter 6. | Grouping: This is a technique for labeling or tagging your data items according to their group. See the Introduction to Chapter 6. | ||
+ | |||
+ | < | ||
+ | > A | ||
+ | [1] 1 2 2 3 3 4 4 4 4 2 1 2 3 3 | ||
+ | > str(A) | ||
+ | num [1:14] 1 2 2 3 3 4 4 4 4 2 ... | ||
+ | > fA <- factor(A) | ||
+ | > fA | ||
+ | [1] 1 2 2 3 3 4 4 4 4 2 1 2 3 3 | ||
+ | Levels: 1 2 3 4 | ||
+ | > str(fA) | ||
+ | | ||
+ | > | ||
+ | </ | ||
===== Data Frames ===== | ===== Data Frames ===== | ||
Line 227: | Line 241: | ||
[1] 11 12 13 14 15 16 | [1] 11 12 13 14 15 16 | ||
</ | </ | ||
- | |||
- | <WRAP box help>The above code is very useful. But, sometimes the recycling rule is very annoying. How would I avoid it? | ||
- | </ | ||
====== Creating a Factor (Categorical Variable) ====== | ====== Creating a Factor (Categorical Variable) ====== | ||
Line 252: | Line 263: | ||
< | < | ||
- | > f | + | > f # note that there is no Fri in the below output. |
[1] Wed Thu Mon Wed Thu Thu Thu Tue Thu Tue | [1] Wed Thu Mon Wed Thu Thu Thu Tue Thu Tue | ||
Levels: Mon Tue Wed Thu Fri | Levels: Mon Tue Wed Thu Fri | ||
Line 996: | Line 1007: | ||
<WRAP box help>Can you save it as " | <WRAP box help>Can you save it as " | ||
+ | |||
+ | When you read back the csv file? How would you avoid like the below output? I mean aovid X column? | ||
+ | < | ||
+ | 1 1 -0.818 | ||
+ | 2 2 -0.667 | ||
+ | 3 3 -0.494 | ||
+ | 4 4 -0.819 | ||
+ | |||
+ | Or even, how would I save the csv file, without the X column? | ||
</ | </ | ||
r/data_structures.1542670745.txt.gz · Last modified: 2018/11/20 08:39 by hkimscil