I have been learning R recently. While executing the following codes, I found the following results:
Code:
data<-read.csv("pen.csv",header=TRUE)
head(data)
require(reshape2)
dat<-melt(data=data)
names(dat)<-c("species","weight")
summary(dat)
Result:
> summary(dat)
| species | weight |
|------------------|-----------------|
| Adelie :6 | Min. :181.0 |
| Gentoo :6 | 1st Qu.:193.0 |
| Chinstrap:6 | Median :202.0 |
| | Mean :202.3 |
| | 3rd Qu.:215.0 |
| | Max. :216.0 |
| | NA's :3 |
I was expecting the result like this:
| species | weight |
|------------------|-----------------|
| Adelie :5 | Min. :181.0 |
| Gentoo :6 | 1st Qu.:193.0 |
|Chinstrap :4 | Median :202.0 |
| | Mean :202.3 |
| | 3rd Qu.:215.0 |
| | Max. :216.0 |
| | NA's :3 |
I even tried considering species as a factor (dat$species<-as.factor(dat$species))
.Got the same result. Could anyone help? (Here, I have attached the data set)
Adelie | Gentoo | Chinstrap |
---|---|---|
181 | 215 | 202 |
186 | 215 | 193 |
195 | 215 | 210 |
NA | 216 | 198 |
193 | 215 | NA |
190 | 210 | NA |