Hi all, I am trying to set up logical function(s) to deal with two adjustments to a blood glucose value. I have been dinking around in Excel and assume this will be much easier in R. DF is date-time, BG value in mg/dL,test strip 4/3/13 19:20 105 Aviva-491350 4/4/13 21:03 74 Aviva-491350 4/6/13 17:40 81 Aviva-491640 4/6/13 17:40 82 Aviva-491350 4/6/13 22:48 106 Aviva-491640 4/6/13 22:48 102 Aviva-491350 4/7/13 5:32 87 Aviva-491350 4/7/13 5:32 103 Aviva-491640 What I need are the high and low ranges based on "acceptable" standards of the measured values. The logical expressions need to be IF BG =>100 then "High limit" would = (BG+(BG*.15)) IF BG =>100 then "Low limit" would = (BG-(BG*.15)) and IF BG <100 then "High limit" would = (BG+15) IF BG <100 then "Low limit" would = (BG-15) The standards are written as: 95% of the individual glucose results shall fall within ±15 mg/dL of the reference results at glucose concentrations less than 100 mg/dL and within ±15% at glucose concentrations greater than or equal to 100 mg/dL. Then I need to plot the measured value and also show the high & low "acceptable" values. Thanks for any who respond. Bruce [[alternative HTML version deleted]]
Neotropical bat risk assessments
2013-May-07 14:02 UTC
[R] How does one set up logical functions?
Hi all, I am trying to set up logical function(s) to deal with two adjustments to a blood glucose value. I have been dinking around in Excel and assume this will be much easier in R. DF is date-time, BG value in mg/dL,test strip 4/3/13 19:20 105 Aviva-491350 4/4/13 21:03 74 Aviva-491350 4/6/13 17:40 81 Aviva-491640 4/6/13 17:40 82 Aviva-491350 4/6/13 22:48 106 Aviva-491640 4/6/13 22:48 102 Aviva-491350 4/7/13 5:32 87 Aviva-491350 4/7/13 5:32 103 Aviva-491640 What I need are the high and low ranges based on "acceptable" standards of the measured values. The logical expressions need to be IF BG =>100 then "High limit" would = (BG+(BG*.15)) IF BG =>100 then "Low limit" would = (BG-(BG*.15)) and IF BG <100 then "High limit" would = (BG+15) IF BG <100 then "Low limit" would = (BG-15) The standards are written as: 95% of the individual glucose results shall fall within ±15 mg/dL of the reference results at glucose concentrations less than 100 mg/dL and within ±15% at glucose concentrations greater than or equal to 100 mg/dL. Then I need to plot the measured value and also show the high & low "acceptable" values. Thanks for any who respond. Bruce -- Bruce W. Miller, PhD. Neotropical bat risk assessments If we lose the bats, we may lose much of the tropical vegetation and the lungs of the planet Using acoustic sampling to map species distributions for >15 years. Providing Interactive identification keys to the vocal signatures of New World Bats For various project details see: https://sites.google.com/site/batsoundservices/ [[alternative HTML version deleted]]
Bruce, Try something like this df$limlo <- ifelse(df$BG>=100, df$BG-(df$BG*0.15), df$BG-15) df$limhi <- ifelse(df$BG>=100, df$BG+(df$BG*0.15), df$BG+15) plot(seq(df$BG), df$BG, ylim=range(df$limlo, df$limhi)) arrows(seq(df$BG), df$limlo, seq(df$BG), df$limhi, length=0.1, angle=90, code=3) Jean On Tue, May 7, 2013 at 8:54 AM, Bruce Miller <batsncats@gmail.com> wrote:> Hi all, > > I am trying to set up logical function(s) to deal with two adjustments > to a blood glucose value. > I have been dinking around in Excel and assume this will be much easier > in R. > > DF is date-time, BG value in mg/dL,test strip > 4/3/13 19:20 105 Aviva-491350 > 4/4/13 21:03 74 Aviva-491350 > 4/6/13 17:40 81 Aviva-491640 > 4/6/13 17:40 82 Aviva-491350 > 4/6/13 22:48 106 Aviva-491640 > 4/6/13 22:48 102 Aviva-491350 > 4/7/13 5:32 87 Aviva-491350 > 4/7/13 5:32 103 Aviva-491640 > > > What I need are the high and low ranges based on "acceptable" standards > of the measured values. > > The logical expressions need to be > IF BG =>100 then "High limit" would = (BG+(BG*.15)) > IF BG =>100 then "Low limit" would = (BG-(BG*.15)) > and > IF BG <100 then "High limit" would = (BG+15) > IF BG <100 then "Low limit" would = (BG-15) > > The standards are written as: 95% of the individual glucose results > shall fall within ą15 mg/dL of the reference results at glucose > concentrations less than 100 mg/dL and within ą15% at glucose > concentrations greater than or equal to 100 mg/dL. > > Then I need to plot the measured value and also show the high & low > "acceptable" values. > > Thanks for any who respond. > > Bruce > > > [[alternative HTML version deleted]] > > > ______________________________________________ > R-help@r-project.org mailing list > 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]]