Hello, The most part of the program works except that the following logical variable does not get created although the second logical variable-based extraction works.
I don't understand what I am doing wrong here. state_pflt200 <- df$p_fatal <200 df[state_pflt200, c("state.name","p_fatal")] I would appreciate receiving your help. Thanks, Pradip Muhuri ##### Below is the code that includes the reproducible example. df <- data.frame (state.name= c("Alabama","Alaska","Arizona","Arkansas","California","Colorado","Connecticut", "Delaware","DC", "Florida","Georgia","Hawaii","Idaho","Illinois","Indiana", "Iowa","Kansas","Kentucky", "Louisiana","Maine","Maryland","Massachusetts","Michigan", "Minnesota","Mississippi","Missouri","Montana","Nebraska","Nevada","New Hampshire", "New Jersey","New Mexico","New York","North Carolina","North Dakota","Ohio","Oklahoma", "Oregon","Pennsylvania","Rhode Island","South Carolina","South Dakota","Tennessee","Texas", "Utah", "Vermont","Virginia","Washington","West Virginia","Wisconsin","Wyoming"), p_fatal = sample(200:500,51,replace=TRUE), t_safety_score = sample(1:10,51,replace=TRUE) ) options (width=120) # The following logical variable does not get created - Don't understand what I am doing wrong state_pflt200 <- df$p_fatal <200 df[state_pflt200, c("state.name","p_fatal")] # The following works state_sslt5 <- df$t_safety_score <5 df[state_sslt5,c("state.name", "t_safety_score")] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.