0

I have an excel sheet similar to the example below but with many rows and columns.

ID HT Stroke HT follow up Stroke follow up
1 No No Yes No
2 Yes No No No
3 Missing Yes Missing No

HT refers to hypertension. I wanted to create a barplot showing the number of rows with "no" or "missing" for HT, and the number of rows with "yes" or "missing" for HT follow up. The y axis would be the number of counts and the x axis would be divided into two parts; ht and ht follow up, each part with two bars. What i did so far was create a dataset with the columns id, ht, and ht follow up. This dataset has the rows filtered to have ht rows that are either "no" or "filtered", and ht follow up rows that are either "yes" or "missing".

ht=exceldata[,c('id','HT','HTFU')]
ht1=subset(ht, HT=="No"|HT=="Missing")
ht2=subset(ht1,HTFU=="Yes"|HTFU=="Missing")

Any help would be appreciated!

alia
  • 1
  • 1
    Welcome to Stack Overflow! Can you please read and incorporate elements from [How to make a great R reproducible example?](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). Especially the aspects of using `dput()` for the input? – wibeasley Jan 25 '22 at 14:19
  • @wibeasley hey, can you please explain what you mean? is my question not clear? – alia Jan 25 '22 at 16:31
  • I think the question itself it clear, but there are a few things preventing a good answer. Include (a) the input dataset in teh code by using `dput()` and (b) ideally the expected/desired output. Notice we aren't able to manipulate `exceldata` because we don't know its values. Use a small dataset as an example input. That link above explains it better than I can. Here's another resource: https://www.rstudio.com/resources/webinars/help-me-help-you-creating-reproducible-examples/ – wibeasley Jan 26 '22 at 03:11
  • Please provide enough code so others can better understand or reproduce the problem. – Community Jan 31 '22 at 19:44

0 Answers0