I have four variables with names of cvd75plus, res75plus. Mi75plus and ast75plus.

I want to have a percentage of total admissions for the 75 plus age group. So I combined all the four variables to form a new variable using script as:


I assume this will give me sum of all these variables row-wise.

Now I want to calculate the total %age of hospitaladmissions for 75 plus age group. What should be the command for getting percentage of the whole variable i.e. all75plus.

> View(workdata$pcn75plus)
> sum(workdata$pcn75plus)

However, this doesnt seem to be working right. Can someone please provide how to get the percentage for the whole variable?

Thanks in advance

New contributor
hasan sohail is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • 1
    $\begingroup$ Hi, coding questions usually goes to stack overflow $\endgroup$ – rep_ho Jun 30 at 12:01