You should include a reprex with your question.
A prose description isn't sufficient, you also need to make a simple reprex that:
- Builds the input data you are using.
- The function you are trying to write, even if it doesn't work.
- Usage of the function you are trying to write, even if it doesn't work.
- Builds the output data you want the function to produce.
You can learn more about reprex's here:
Right now the is an issue with the version of reprex that is in CRAN so you should download it directly from github.
Until CRAN catches up with the latest version install reprex with
devtools::install_github("tidyverse/reprex")
if this gives you an error saying that devtools is not available then use
install.packages("devtools")
and try again.
The reason we ask for a reprex is that it is the easiest and quickest way for someone to understand the issue you are running into and answer it.
Nearly everyone here who is answering questions is doing it on their own time and really appreciate anything you can do to minimize that time.
In any case here is a reprex that shows a couple of ways to select rows from a data.frame:
suppressPackageStartupMessages(library(tidyverse))
# make data.frame
t <- tribble(
~SERIALNO, ~NP, ~TYPE, ~ACR, ~BDSP, ~BLD,
70, 4, 1, "House on less than one acre", 2, "One-family house detached",
106, 0, 1, "House on less than one acre", 0, "2 Apartments"
)
t
#> # A tibble: 2 x 6
#> SERIALNO NP TYPE ACR BDSP BLD
#> <dbl> <dbl> <dbl> <chr> <dbl> <chr>
#> 1 70. 4. 1. House on less than one acre 2. One-family house…
#> 2 106. 0. 1. House on less than one acre 0. 2 Apartments
# using tidyverse
filter(t, BDSP != 0)
#> # A tibble: 1 x 6
#> SERIALNO NP TYPE ACR BDSP BLD
#> <dbl> <dbl> <dbl> <chr> <dbl> <chr>
#> 1 70. 4. 1. House on less than one acre 2. One-family house…
# not using tidyverse
t[t["BDSP"]!= 0,]
#> # A tibble: 1 x 6
#> SERIALNO NP TYPE ACR BDSP BLD
#> <dbl> <dbl> <dbl> <chr> <dbl> <chr>
#> 1 70. 4. 1. House on less than one acre 2. One-family house…
Created on 2018-03-20 by the reprex package (v0.2.0).