-1

I need to clean/modify the data, but I am interested in data where var1=0 only. Can I 'permanently' remove the data where var1=0 or is missing, so that I can simplify my codes. For example,for summary statistics i have mytable <- xtabs(~var1+ var2+var3, data = mydata), but i would like to cross tab with only two variables (var2 and var3)where var1=0.

Beata
  • 7
  • 4

1 Answers1

1

Maybe you can try something:

mydata_clean <- mydata[mydata$var1 !=0,] # to remove rows data where var1 = 0

mytable <- xtabs(~var2+var3, data = mydata_clean) # to perform xtabs on var2 and var3 only

If it does not work, you should put a reproducible example of your data, it will make things easier for people trying to help you.

dc37
  • 15,105
  • 3
  • 13
  • 29
  • @Beata, glad to hear ;) – dc37 Nov 18 '19 at 05:36
  • 3
    @Beata I noticed you haven't accepted any answer until now. if the answer provided works for you, please consider accepting the answer by clicking on check mark next to vote button. If there are multiple answers to your question select one whichever you think as best. Also read [What should I do when someone answers my question?](https://stackoverflow.com/help/someone-answers). – Ronak Shah Nov 18 '19 at 06:04