Md. Kamruzzaman
2023-Nov-03 00:40 UTC
[R] I need to create new variables based on two numeric variables and one dichotomize conditional category variables.
Hello Everyone, I have three variables: Waist circumference (WC), serum triglyceride (TG) level and gender. Waist circumference and serum triglyceride is numeric and gender (male and female) is categorical. From these three variables, I want to calculate the "Lipid Accumulation Product (LAP) Index". The equation to calculate LAP is different for male and females. I am giving both equations below. LAP for male = (WC-65)*TG LAP for female = (WC-58)*TG My question is 'how can I calculate the LAP and create a single new column? Your cooperation will be highly appreciated. Thanks in advance. With Regards *--------------------------------* *Md Kamruzzaman* *PhD **Research Fellow (**Medicine**)* Discipline of Medicine and Centre of Research Excellence in Translating Nutritional Science to Good Health Adelaide Medical School | Faculty of Health and Medical Sciences The University of Adelaide Adelaide SA 5005 [[alternative HTML version deleted]]
Bert Gunter
2023-Nov-03 14:43 UTC
[R] I need to create new variables based on two numeric variables and one dichotomize conditional category variables.
Well, something like: LAP <- ifelse(gender =='male', (WC-65)*TG, (WC-58)*TG) The exact code depends on whether your variables are in a data frame or list or whatever, which you failed to specify. If so, ?with may be useful. Cheers, Bert On Fri, Nov 3, 2023 at 3:43?AM Md. Kamruzzaman <mkzaman.m at gmail.com> wrote:> Hello Everyone, > I have three variables: Waist circumference (WC), serum triglyceride (TG) > level and gender. Waist circumference and serum triglyceride is numeric and > gender (male and female) is categorical. From these three variables, I want > to calculate the "Lipid Accumulation Product (LAP) Index". The equation to > calculate LAP is different for male and females. I am giving both equations > below. > > LAP for male = (WC-65)*TG > LAP for female = (WC-58)*TG > > My question is 'how can I calculate the LAP and create a single new column? > > Your cooperation will be highly appreciated. > > Thanks in advance. > > With Regards > > *--------------------------------* > > *Md Kamruzzaman* > > *PhD **Research Fellow (**Medicine**)* > Discipline of Medicine and Centre of Research Excellence in Translating > Nutritional Science to Good Health > Adelaide Medical School | Faculty of Health and Medical Sciences > The University of Adelaide > Adelaide SA 5005 > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]
Maybe Matching Threads
- I need to create new variables based on two numeric variables and one dichotomize conditional category variables.
- I need to create new variables based on two numeric variables and one dichotomize conditional category variables.
- I need to create new variables based on two numeric variables and one dichotomize conditional category variables.
- [EXTERNAL] RE: I need to create new variables based on two numeric variables and one dichotomize conditional category variables.
- ANOVA with repeated measurements (Dan Rajdl)