Strangeness with filtering in R and showing summary of filtered data

后端 未结 1 399
野趣味
野趣味 2021-01-25 19:01

I have a data frame loaded using the CSV Library in R, like

mySheet <- read.csv(\"Table.csv\", sep=\";\")

I now can print a summary on that

相关标签:
1条回答
  • 2021-01-25 19:32

    What you are dealing with here are factors from reading the csv file. You can get subSheet to forget the missing factors with

    subSheet$Diagnose <- droplevels(subSheet$Diagnose)
    

    or

    subSheet$Diagnose <- subSheet$Diagnose[ , drop=TRUE] 
    

    just before you do summary(subSheet).

    Personally I dislike factors, as they cause me too many problems, and I only convert strings to factors when I really need to. So I would have started with something like

    mySheet <- read.csv("Table.csv", sep=";", stringsAsFactors=FALSE) 
    
    0 讨论(0)
提交回复
热议问题