Eliminating NAs from a ggplot

后端 未结 6 965
暖寄归人
暖寄归人 2020-11-30 09:40

Very basic question here as I\'m just starting to use R, but I\'m trying to create a bar plot of factor counts in ggplot2 and when plotting, get 14 little colored blips repr

6条回答
  •  悲&欢浪女
    2020-11-30 10:18

    Additionally, adding na.rm= TRUE to your geom_bar() will work.

    ggplot(data = MyData,aes(x= the_variable, fill=the_variable, na.rm = TRUE)) + 
       geom_bar(stat="bin", na.rm = TRUE)
    

    I ran into this issue with a loop in a time series and this fixed it. The missing data is removed and the results are otherwise uneffected.

提交回复
热议问题