Eliminating NAs from a ggplot

后端 未结 6 949
暖寄归人
暖寄归人 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:16

    You can use the function subset inside ggplot2. Try this

    library(ggplot2)
    
    data("iris")
    iris$Sepal.Length[5:10] <- NA # create some NAs for this example
    
    ggplot(data=subset(iris, !is.na(Sepal.Length)), aes(x=Sepal.Length)) + 
    geom_bar(stat="bin")
    

提交回复
热议问题