datacarpentry / R-ecology-lesson

Data Analysis and Visualization in R for Ecologists
https://datacarpentry.org/R-ecology-lesson/
Other
311 stars 508 forks source link

Renaming empty labels "missing" #329

Closed kathy0305 closed 6 years ago

kathy0305 commented 6 years ago

R-ecology-lesson

Starting with data

Renaming factors

levels(sex) returned 3 levels "" "F" "M" so we decided to rename "" (empty sex label) "missing" levels(sex)[1] <- "missing"

I think we should stay consistent of how R names/represents missing data with NA specially that we introduced NA in the previous lesson. If the intention is to show the missing values in the plot, we can use NA in "" levels(sex)[1] <- "NA"

I just feel that they should start referring to missing values as NA's

aurielfournier commented 6 years ago

Great idea. Would you be willing to submit a pull request with this change?

kathy0305 commented 6 years ago

ofcourse! should we change it to levels(sex)[1] <- NA or levels(sex)[1] <- "NA" ?

aurielfournier commented 6 years ago

levels(sex)[1] <- NA

kathy0305 commented 6 years ago

Ok, then when we plot(surveys$sex) only F and M will show

aurielfournier commented 6 years ago

Oh. right. Hmm.

I don't use baseplot enough to know how to make it label the NAs as something.

@fmichonneau what are your thoughts? Should we leave it as 'missing' since the NAs don't get an x axis label with baseplot?

BinxiePeterson commented 6 years ago

I don't think the missing data should be excluded from the plot - it might be important to show the number of missing data versus M and F. But +1 for levels(sex)[1] <- NA to keep it consistent!

fmichonneau commented 6 years ago

I was traveling and couldn't comment earlier. My suggestion would be to use "undetermined" instead of "missing". This way we keep the data in the plot and we don't introduce the confusion over missing data being represented as NA.

aurielfournier commented 6 years ago

@kathy0305 would you be willing to write up a pull request with @fmichonneau suggestion?

kathy0305 commented 6 years ago

Oh, sure! pull request on its way. Thanks

fmichonneau commented 6 years ago

this is has been implemented. Thanks @kathy0305 !