# How to take overall percentage of a variable in R? [closed]

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:

workdata$all75plus<-c(cvd75plus+res75plus+ast75plus+mi75plus)  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. workdata$$pcn75plus<-workdata$$all75plus/sum(workdata$$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?