2

Basically ctb2 is city tax band a variable in data set, i just renamed it to make it easier for me, i have produced a summary and a table for the ctb2 as a starter like my advisor says, who also said i need to remove the Us from the variable since they are unknowns so i can just have the levels A to I as they are more relevant to my analysis she also said i could replace them by NAs of which i have no idea how to do that as well been struggling to remove the U from the variable as I have no idea how I need to keep just A to I and get rid of the U and the 952 just standing there. Im quite new to R and been researching on how but nothing make sense. Please help

> summary(ctb2)
        A      B      C      D      E      F      G      H      I      U 
952  72258  75890 116903 104229  83516  49943  50607   5689    131  35020 
  • 1
    Can you include a bit more about your problem? maybe the line that generated `ctb2` and `dput(ctb2)` so we can reproduce this. FWIW, it looks like the `952` is the row name like and that is just part of the way the R console displays. I'd also suggest looking through any one of the excellent R Intros out there on the web. – Justin Jan 16 '13 at 23:50
  • i have reedited the question let me know if this helps? – wilmah deda Jan 17 '13 at 00:17
  • @Justin the `952` isn't a row name, it's a count of empty (or perhaps " ") entries in `ctb2`. – Jonathan Christensen Jan 17 '13 at 00:19
  • In addition, since `ctb2` seems to have hundreds of thousands of entries, giving us `dput(ctb2)` probably wouldn't be terribly helpful... – Jonathan Christensen Jan 17 '13 at 00:20
  • Fair, but a [minimal reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) lets us know a lot more about the specifics of the problem. It also, in my experience, often leads to finding a solution or at least a deeper understanding. – Justin Jan 17 '13 at 00:34

1 Answers1

1

The following should work:

ctb2[ctb2=="U"] <- NA

Since you also seem to have empty entries, you might want to do

ctb2[ctb2==""] <- NA

or

ctb2[ctb2==" "] <- NA

depending on what exactly that 952 is counting there.

Jonathan Christensen
  • 3,756
  • 1
  • 19
  • 16