Remove specific remarks from Data Frame in R

Asked

Viewed 621 times

0

Good night, guys. I need a little strength from you.

I have a data frame in the panel data format where my N are the municipalities of São Paulo and T are the years of my sample. To illustrate, my database follows the following form:

N                T         Urbanização
Adamantina      2000           92.43
Adamantina      2001           92.71
Adamantina      2002           92.88
Adamantina      2003           93.01
Adolfo          2000           88.02
Adolfo          2001           88.16
Adolfo          2002           88.22
Adolfo          2003           88.44
.               .              .
.               .              . 
.               .              .

I would like a code to take out of my sample the observations on 2003 for all municipalities, so what I want is for these observations to be excluded from my base.

I appreciate any contribution.

2 answers

1

Assuming data be your data.frame:

data <- data[!data$T== 2003, ]

or if the column is a character:

data <- data[!data$T== "2003", ]
  • Excellent, my friend. Thank you very much!

1


As you want to remove from the list all that are equal to 2003, just select all that have the T column other than 2003.

data <- data[data$T!=2003,]

Browser other questions tagged

You are not signed in. Login or sign up in order to post.