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
The `cats` data we are working with is something called a *data frame*. Data frames
191
+
The `cats`(and `cats2`) data we are working with is something called a *data frame*. Data frames
191
192
are one of the most common and versatile types of *data structures* we will work with in R.
192
193
A given column in a data frame cannot be composed of different data types.
193
-
In this case, R does not read everything in the data frame column `weight` as a *double*, therefore the entire
194
+
In this case, R cannot store everything in the data frame column `weight` as a *double* anymore once we add the row for the additional cat (because its weight is `2.3 or 2.4`), therefore the entire
194
195
column data type changes to something that is suitable for everything in the column.
195
196
196
197
When R reads a csv file, it reads it in as a *data frame*. Thus, when we loaded the `cats`
@@ -206,28 +207,7 @@ same number of rows. Different columns in a data frame can be made up of differe
206
207
data types (this is what makes them so versatile), but everything in a given
207
208
column needs to be the same type (e.g., vector, factor, or list).
208
209
209
-
Let's explore more about different data structures and how they behave.
210
-
For now, let's remove that extra line from our cats data and reload it,
211
-
while we investigate this behavior further:
212
-
213
-
feline-data.csv:
214
-
215
-
```
216
-
coat,weight,likes_catnip
217
-
calico,2.1,1
218
-
black,5.0,0
219
-
tabby,3.2,1
220
-
```
221
-
222
-
And back in RStudio:
223
-
224
-
```{r, eval=FALSE}
225
-
cats <- read.csv(file="data/feline-data.csv")
226
-
```
227
-
228
-
```{r, include=FALSE}
229
-
cats <- cats_orig
230
-
```
210
+
Let's explore more about different data structures and how they behave. For now, we will focus on our original data frame `cats` (and we can forget about `cats2` for the rest of this episode).
0 commit comments