You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: episodes/01-r-basics.Rmd
+75-6Lines changed: 75 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -252,16 +252,42 @@ longer exists.
252
252
Error: object 'gene_name' not found
253
253
```
254
254
255
-
## Understanding object data types (modes)
255
+
## Understanding object data types (classes and modes)
256
256
257
-
In R, **every object has two properties**:
257
+
In R, **every object has several properties**:
258
258
259
259
-**Length**: How many distinct values are held in that object
260
260
-**Mode**: What is the classification (type) of that object.
261
+
-**Class**: A property assigned to an object that determines how a function
262
+
will operate on it.
261
263
262
264
We will get to the "length" property later in the lesson. The **"mode" property**
263
-
**corresponds to the type of data an object represents**. The most common modes
264
-
you will encounter in R are:
265
+
**corresponds to the type of data an object represents** and the **"class" property determines how functions will work with that object.**
266
+
267
+
268
+
::::::::::::::::::::::::::::::::::::::::: callout
269
+
270
+
## Tip: Classess vs. modes
271
+
272
+
The difference between modes and classes is a bit **confusing** and the subject of
273
+
several [online discussions](https://stackoverflow.com/questions/35445112/what-is-the-difference-between-mode-and-class-in-r).
274
+
Often, these terms are used interchangeably. Do you really need to know
275
+
the difference?
276
+
277
+
Well, perhaps. This section is important for you to have a better understanding
278
+
of how R works and how to write usable code. However, you might not come across
279
+
a situation where the difference is crucial while you are taking your first steps
280
+
in learning R. However, the overarching concept—**that objects in R have these properties and that you can use functions to check or change them**—is very important!
281
+
282
+
In this lesson we will mostly stick to **mode** but we will throw in a few
283
+
examples of the `class()` and `typeof()` so you can see some examples of where
- Base R has many useful functions for manipulating your data, but all of R's capabilities are greatly enhanced by software packages developed by the community
0 commit comments