Search results

  1. E

    How can I drop observations when a variable is equal to any number from a sequence?

    I have a variable in a data set that has numbers between 0 and 1000. I want to drop observations where the variable is equal to any number from the sequence S=42 + k*12 k=(0,infinity) Right now the only way I know to do this is by typing out drop if var == 42 | var == 54 | etc...
  2. E

    Adding up the coefficients of a contemporaneous and a once-lagged variable

    Hello, I'm stuck on what's probably a trivial problem, but I can't figure out how to go about it as I am a semi-beginner, so I would really appreciate the help of anyone who can assist me. I'm doing empirical work and I want to combine the effects of a variable and a once-lag of the variable...
  3. E

    Adding a new column in R data frame with values conditional on another column

    Suppose I have the data frame: table<- data.frame(population=c(100, 300, 5000, 2000, 900, 2500), habitat=c(1,2,3,4,5,6)) Now I want to add a new column table$size with the values 1 if population< 500, 2 if 500<=population<1000, 3 if 1000<=population<2000, 4 if 2000<=population<3000, 5 if...