获取数据维度
> dim(df)
[1] 14 5
'data.frame': 14 obs. of 5 variables:
$ Outlook : Factor w/ 3 levels "overcast","rainy",..: 3 3 1 2 2 2 1 3 3 2 ...
$ Temperature: Factor w/ 3 levels "cool","hot","mild": 2 2 2 3 1 1 1 3 1 3 ...
$ Humidity : Factor w/ 2 levels "high","normal": 1 1 1 1 2 2 2 1 2 2 ...
$ Windy : logi FALSE TRUE FALSE FALSE FALSE TRUE ...
$ Play : Factor w/ 2 levels "no","yes": 1 1 2 2 2 1 2 1 2 2 ...
Outlook Temperature Humidity Windy Play
overcast:4 cool:4 high :7 Mode :logical no :5
rainy :5 hot :4 normal:7 FALSE:8 yes:9
sunny :5 mild:6 TRUE :6
df.Outlook df.Temperature
1 sunny hot
2 sunny hot
3 overcast hot
4 rainy mild
5 rainy cool
6 rainy cool
7 overcast cool
8 sunny mild
9 sunny cool
10 rainy mild
11 sunny mild
12 overcast mild
13 overcast hot
14 rainy mild
|
head(df)
tail(df)
|
df$Windy <- as.character(df$Windy)
df$Windy[df$Windy == "0"] <- "FALSE"
df$Windy[df$Windy == "1"] <- "TRUE"
df$Windy <- as.factor(df$Windy)
一个比较详细dataframe操作的参考:
https://www.datacamp.com/community/tutorials/15-easy-solutions-data-frame-problems-r
7672



被折叠的 条评论
为什么被折叠?



