[R] conditional dataframe search and find

2010-07-03 Thread oscar linares
 After some processing...
   ct.df<- data.frame(time,conc)
   ct.df
   gives
  time   conc
   1 0 164.495456
   2 1 133.671185
   3 2 108.622975
   4 3  88.268468
   5 4  71.728126
   6 5  58.287225
   7 6  47.364971
   8 7  38.489403
   9 8  31.276998
   109  25.416103
   11   10  20.653462
   12   11  16.783276
   13   12  13.638313
   14   13  11.082674
   15   14   9.005927
   16   15   7.318336

- Ignored:
   17   16   5.946977
   18   17   4.832592
   19   18   3.927028
   20   19   3.191155
   21   20   2.593175
   22   21   2.107248
   23   22   1.712378
   24   23   1.391501
   25   24   1.130752

   I need to find the time when conc < 25. I can read it off the table but I
am

   looking for a programmatic solution.

   Thanks.
   Oscar


-- 
Oscar A. Linares, MD
Clinical Assistant Professor of Medicine
Department of Medicine
University of Toledo College of Medicine
Toledo, Ohio 43606-3390

Attending Physician
The Detroit Medical Center (DMC)
Harper University Hospital
Wayne State University School of Medicine
Detroit, Michigan 48201

Director
Translational Pharmacokinetics & Pharmacogenomics Unit,
La Plaisance Bay, Bolles Harbor, MI

Medical Director
Monroe Pain Center
Monroe, MI 48162
(http:www.monroepaincenter.com)

Phone (734) 240-8400
Cell (734) 637-7997
Fax (734) 243-6254

oalinare...@gmail.com

[[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.


[R] Calculation error

2010-05-02 Thread oscar linares
Dear Rxperts,

Running the following code:
===
twlo=10; twhi=20; wt=154; vd=0.5; cl=0.046; tau=6; t=3; F=1;

wtkg  <- wt/2.2 # convert lbs to kg

  vd.pt <- wtkg * vd   # compute weight-based vd (L)
  cl.pt <- wtkg * cl   # compute CL (L/hr)
  k <- cl.pt/vd.pt # compute k (hr^-1)

  cave  <- round((twhi - twlo)/log(twhi/twlo),2)
  doserate  <- (cl.pt * cave)/F

  # maintenance dose (Dm)
  total_dose_tau <- round(doserate * tau,0)

  Cmax <- total_dose_tau/vd.pt
  Cmin <- Cmax * exp(-k * tau)

  AR <- 1/(1 - exp(-k * tau))

  Cmaxss <- Cmax * AR
  Cminss <- Cmin * AR
  Cfluctss <- (Cmaxss - Cminss)
  Ct   <- (Cmaxss * exp(-k * t))

  dose_loading_vd <- round(Cmaxss * vd.pt,0)
  dose_loading_dm <- round(total_dose_tau * AR,0)

  options(digits=2)

c("Ther. Win. (mg)"=twlo,"to"=twhi,"Wt (kg)"=wtkg,"Vd (L)"=vd.pt,"CL
(L/hr)"=cl.pt,"Cave (mg)"=cave,"D/tau (mg/hr)"=doserate,"tau
(hr)"=tau,"Total Dose (mg)"=total_dose_tau,"Cmax (mg)"=Cmax,"Cmin
(mg)"=Cmin,"AR"=AR,"Cmaxss (mg/L)"=Cmaxss,"Cminss (mg/L)"=Cminss,"Cfluct
(mg/L)"=Cfluctss,"C(t) (mg/L)"=Ct,"DL wVd (mg)"=dose_loading_vd,"DL wDm
(mg)"=dose_loading_dm)
===
Gives
Ther. Win. (mg)  to Wt (kg)  Vd (L)   CL
(L/hr)   Cave (mg)
   10.020.070.035.0
3.214.4
  D/tau (mg/hr)tau (hr) Total Dose (mg)   Cmax (mg)   Cmin
(mg)  AR
   46.5 6.0   279.0 8.0
4.6 2.4
  Cmaxss (mg/L)   Cminss (mg/L)   Cfluct (mg/L) C(t) (mg/L) DL wVd
(mg) DL wDm (mg)
   18.810.8 8.014.3
658.0   658.0

But, there is an error from R?

AR * total_dose_tau = 658 but that is wrong

Total Dose (mg) = 279 * AR (=2.4) = 670

Please help. I don't want to harm anyone. A difference of 12 mg of a highly
toxic drug can at the very least cause significant harm.


-- 
Oscar
Oscar A. Linares, MD
Translational Medicine Unit
La Plaisance Bay, Bolles Harbor
Monroe, Michigan 48161

Department of Medicine,
University of Toledo College of Medicine
Toledo, OH 43606-3390

Department of Internal Medicine,
The Detroit Medical Center (DMC)
Harper University Hospital
Wayne State University School of Medicine
Detroit, Michigan 48201

[[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.


[R] R programmer Ann Arbor Area

2010-01-06 Thread oscar linares
Dear Rs

Our group is in need of an R programmer to work on Clinical Pharmacokinetics
Project in Ann Arbor, Michigan Area.

Interested R programmers send e-mail to:

olina...@umich.edu

Thanks:-)

-- 
Oscar
Oscar A. Linares, MD
Translational Medicine Unit
LaPlaisance Bay, Bolles Harbor
Monroe, Michigan 48161

Department of Medicine,
University of Toledo College of Medicine
Toledo, OH 43606-3390

Department of Internal Medicine,
The Detroit Medical Center (DMC)
Harper University Hospital
Wayne State University School of Medicine
Detroit, Michigan 48201

[[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.


[R] boxplot help

2010-01-06 Thread oscar linares
 Dear Rexperts,

 I am trying to add a '+' identifying the mean in a boxplot using the
   following
   sizelist <- split(size, grp)
   centers <- boxplot(sizelist, style.bxp = "att", medpch = "o",
   ylab = "Prostate Volume (cm3)")
   points(centers, unlist(lapply(sizelist, mean)), pch = "+")
   But, I get error
   Error in xy.coords(x, y) : 'x' and 'y' lengths differ
   which I do not understand.
   The data follows
   grpsize
   AE9.132
   AE10.07
   AE20.077
   AE14.691
   AE23.698
   E110.356
   E16.313
   E121.708
   E112.651
   E115.464
   E237.2
   E212.639
   E216.791
   E236.996
   E222.808
   CC1.975
   CC3.125
   CC4.433
   CC6.154
   CC4.175
   NC9.301
   NC13.531
   NC12.84
   NC14.336
   NC25.102

   Please help.

-- 
Oscar
Oscar A. Linares, MD
Translational Medicine Unit
LaPlaisance Bay, Bolles Harbor
Monroe, Michigan 48161

Department of Medicine,
University of Toledo College of Medicine
Toledo, OH 43606-3390

Department of Internal Medicine,
The Detroit Medical Center (DMC)
Harper University Hospital
Wayne State University School of Medicine
Detroit, Michigan 48201

[[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.


[R] anova/factor

2009-12-07 Thread oscar linares
Dear Wiza[R]ds,

I have the following data in a data.frame. I need to do an anova with
multiple comparison but I don't know how to factor the groups for analysis.
There are 3 groups, 1,2 and 3 labelled in column 1. Help appreciated with
thanks in advance.

   Group   SI  Sif  SG   Io I2  lol2
  1 9.08e-05 9.08e+00 0.060842287  1.798556446  32.574500  34.37306
  1 2.65e-05 2.65e+00 0.003231478  2.655825884  65.929661  68.58549
  1 0.00e+00 0.00e+00 0.0  3.522121885  73.543024  77.06515
  1 1.68e-05 1.68e+00 0.002958672  4.655116799  53.436267  58.09138
  1 1.06e-06 1.06e-01 0.000483373  2.020228717   3.458982   5.47921
  1 0.00e+00 0.00e+00 0.097785539  4.148313577  87.560551  91.70887
  2 3.27e-05 3.27e+00 0.020160681  3.506062628  45.229857  48.73592
  2 1.63e-05 1.63e+00 0.016336170  3.824083293  71.139331  74.96341
 2 4.47e-05 4.47e+00 0.021202062  7.895615485  57.452354  65.34797
 2 4.38e-05 4.38e+00 0.018721502  4.243604679 110.506859 114.75046
 2 0.00e+00 0.00e+00 0.044930944 13.552492860  88.273415 101.82591
 2 4.30e-05 4.30e+00 0.027125295  6.426449035  55.102468  61.52892
 2 3.80e-05 3.80e+00 0.029939680  0.007273809  92.734675  92.74195
 2 3.65e-06 3.65e-01 0.029382519  0.000221684 103.705858 103.70608
 2 6.36e-06 6.36e-01 0.023179423  1.228886505 127.803373 129.03226
 2 5.86e-13 5.86e-08 0.032732405  1.379044031 104.847896 106.22694
 2 5.71e-06 5.71e-01 0.011643722  2.680653511  77.883436  80.56409
 2 5.86e-13 5.86e-08 0.021973461  1.094195321  49.400687  50.49488
 2 5.86e-13 5.86e-08 0.020197172  2.084520515  51.311323  53.39584
 2 3.07e-06 3.07e-01 0.0  2.308138714 121.203022 123.51116
 3 5.26e-05 5.26e+00 0.012185655  3.348526610  35.880625  39.22915
 3 4.23e-05 4.23e+00 0.028480923  1.709440176  54.767838  56.47728
 3 5.56e-05 5.56e+00 0.0  1.429574183  41.604787  43.03436
 3 9.12e-06 9.12e-01 0.035704097  0.124131665  45.062952  45.18708
 3 2.99e-05 2.99e+00 0.010169719  1.261369666  51.920969  53.18234
 3 4.32e-05 4.32e+00 0.000490530  0.0  16.030226  16.03023


Oscar
-- 
Oscar
Oscar A. Linares, MD
Translational Medicine Unit
LaPlaisance Bay, Bolles Harbor
Monroe, Michigan 48161

Department of Medicine,
University of Toledo College of Medicine
Toledo, OH 43606-3390

Department of Internal Medicine,
The Detroit Medical Center (DMC)
Harper University Hospital
Wayne State University School of Medicine
Detroit, Michigan 48201

[[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.


[R] data manipulation

2009-12-03 Thread oscar linares
Dear Wiza[R]ds,

I have a data.frame header that looks like this:

v2FfaPre15v2FfaPre10v2FfaPre5v2Ffa2v2Ffa3v2Ffa4

I need it to look like this,

1510523 4

i.e., with v2FfaPre and  v2Ffa stripped off

Any suggestions,

Thanks in advance!

-- 
Oscar
Oscar A. Linares, MD
Translational Medicine Unit
LaPlaisance Bay, Bolles Harbor
Monroe, Michigan 48161

Department of Medicine,
University of Toledo College of Medicine
Toledo, OH 43606-3390

Department of Internal Medicine,
The Detroit Medical Center (DMC)
Harper University Hospital
Wayne State University School of Medicine
Detroit, Michigan 48201

[[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.


[R] Plotting observed vs. Predicted values, change of symbols

2009-11-29 Thread oscar linares
Dear Wiz[R]ds,

I am deeply grateful for the help from Duncan Murdoch, Gray Calhoun, and
others. We are almost there. For whatever reason, I can't change the symbol
from a circle to a triangle in the upright posture plots. Any ideas? I have
included the problem in full.

# tritiated (3H)-Norepinephrine(NE) disappearance from plasma
# concentrations supine and upright
# supine
datasu <- data.frame(
time=c(0,1,2,4,6,8,10,15,20),
concsu=c(385.61,265.88,173.87,99.47,66.7,55.27,48.29,39.85,40.66)
)
# upright
dataup <- data.frame(
time=c(0,1,2,4,6,8,10,15,20),
concup=c(767.27,529.03,328.13,225.94,164,151.1,132.02,121.15,70.88)
)

# fit supine
wt.su<- function(resp, time,A1,a1,A2,a2)
{
pred <- A1*exp(-a1*time)+A2*exp(-a2*time)
(resp - pred) / sqrt(pred)
}

fit.wt.su <- nls( ~ wt.su(concsu, time,A1,a1,A2,a2), data=datasu,
  start=list(A1=500,a1=1,A2=100,a2=0.2),
  trace = TRUE)

summary(fit.wt.su)

# fit upright
wt.up<- function(resp, time,B1,b1,B2,b2)
{
pred <- B1*exp(-b1*time)+B2*exp(-b2*time)
(resp - pred) / sqrt(pred)
}

fit.wt.up <- nls( ~ wt.up(concup, time,B1,b1,B2,b2), data=dataup,
  start=list(B1=500,b1=1,B2=100,b2=0.1),
  trace = TRUE)

summary(fit.wt.up)

# Function that returns predicted values and graphics
# by Duncan Murdoch

predictionssu <- function(fit, time) {
  params <- summary(fit)$coefficients[, 1]
  A1 <- params["A1"]
  a1 <- params["a1"]
  A2 <- params["A2"]
  a2 <- params["a2"]

  A1*exp(-a1*time)+A2*exp(-a2*time)
}

predictionsup <- function(fit, time) {
  params <- summary(fit)$coefficients[, 1]
  B1 <- params["B1"]
  b1 <- params["b1"]
  B2 <- params["B2"]
  b2 <- params["b2"]

  B1*exp(-b1*time)+B2*exp(-b2*time)
}

# plot observed and predicted values supine and upright in
# each plot type (linear and smi-log)

# Need upright in same plots (e.g., dashed line)
par(cex.lab=1.2,cex.axis=1.3)

par(mfrow=c(2,1))
plot(c(datasu$concsu, dataup$concup) ~ c(datasu$time, dataup$time), xlab =
"Time (minutes)",
 ylab = "3H-NE (dpm/ml)", main="3H-NE Post-infusion Plasma Disappearance
Curves", ylim=c(0,1000),cex=1.25, pch=16,col=1)

lines(times, predictionssu(fit.wt.su, times))
lines(times, predictionsup(fit.wt.up, times), lty = "dashed")

plot(c(datasu$concsu, dataup$concup) ~ c(datasu$time, dataup$time), xlab =
"Time (minutes)",
 ylab = "3H-NE (dpm/ml)", log = "y", ylim=c(1,1000),cex=1.25,
pch=16,col=1)

lines(times, predictionssu(fit.wt.su, times))
lines(times, predictionsup(fit.wt.up, times), lty = "dashed")

Deeply grateful in advance...
-- 
Oscar
Oscar A. Linares, MD
Translational Medicine Unit
LaPlaisance Bay, Bolles Harbor
Monroe, Michigan 48161

Department of Medicine,
University of Toledo College of Medicine
Toledo, OH 43606-3390

Department of Internal Medicine,
The Detroit Medical Center (DMC)
Harper University Hospital
Wayne State University School of Medicine
Detroit, Michigan 48201

[[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.


[R] Plotting observed vs. fitted values

2009-11-28 Thread oscar linares
Dear Wiza[R]ds,

I am very grateful to Duncan Murdoch for his assistance with this problem.
His help was invaluable. However, the problem has become a little more
complicated for me. Now, in each plot, I need to plot the observed and
fitted values of a supine and upright posture experiment. Here is what I
have and how far I got.

# tritiated (3H)-Norepinephrine(NE) disappearance from plasma
# concentrations supine and upright
# supine
datasu <- data.frame(
time=c(0,1,2,4,6,8,10,15,20),
concsu=c(385.61,265.88,173.87,99.47,66.7,55.27,48.29,39.85,40.66)
)
# upright
dataup <- data.frame(
time=c(0,1,2,4,6,8,10,15,20),
concup=c(767.27,529.03,328.13,225.94,164,151.1,132.02,121.15,70.88)
)

# fit supine
wt.su<- function(resp, time,A1,a1,A2,a2)
{
pred <- A1*exp(-a1*time)+A2*exp(-a2*time)
(resp - pred) / sqrt(pred)
}

fit.wt.su <- nls( ~ wt.su(concsu, time,A1,a1,A2,a2), data=datasu,
  start=list(A1=500,a1=1,A2=100,a2=0.2),
  trace = TRUE)

summary(fit.wt.su)

# fit upright
wt.up<- function(resp, time,B1,b1,B2,b2)
{
pred <- B1*exp(-b1*time)+B2*exp(-b2*time)
(resp - pred) / sqrt(pred)
}

fit.wt.up <- nls( ~ wt.up(concup, time,B1,b1,B2,b2), data=dataup,
  start=list(B1=500,b1=1,B2=100,b2=0.1),
  trace = TRUE)

summary(fit.wt.up)

# Function that returns predicted values and graphics
# by Duncan Murdoch

predictionssu <- function(fit, time) {
  params <- summary(fit)$coefficients[, 1]
  A1 <- params["A1"]
  a1 <- params["a1"]
  A2 <- params["A2"]
  a2 <- params["a2"]

  A1*exp(-a1*time)+A2*exp(-a2*time)
}

predictionsup <- function(fit, time) {
  params <- summary(fit)$coefficients[, 1]
  B1 <- params["B1"]
  b1 <- params["b1"]
  B2 <- params["B2"]
  b2 <- params["b2"]

  B1*exp(-b1*time)+B2*exp(-b2*time)
}

# plot observed and predicted values supine and upright in
# each plot type (linear and smi-log)

# this does supine
times <- seq(0,20, len=100)
par(mfrow=c(2,1))
plot(concsu ~ time, data=datasu)
lines(times, predictionssu(fit.wt.su, times))
plot(concsu ~ time, data=datasu, log="y")
lines(times, predictionssu(fit.wt.su, times))

# Need upright in same plots (e.g., dashed line)


Many thanks in advance...
-- 
Oscar
Oscar A. Linares, MD
Translational Medicine Unit
LaPlaisance Bay, Bolles Harbor
Monroe, Michigan 48161

Department of Medicine,
University of Toledo College of Medicine
Toledo, OH 43606-3390

Department of Internal Medicine,
The Detroit Medical Center (DMC)
Harper University Hospital
Wayne State University School of Medicine
Detroit, Michigan 48201

[[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.


[R] Plot fitted vs observed values

2009-11-28 Thread oscar linares
Dear Wiza[R]ds,

# I have the following experimentally observed data:

csdata <- data.frame(
time=c(0,1,3,9,20),
conc=c(638.697,395.69,199.00,141.58,112.16)
)

# weighting resp means response
wt.MM<- function(resp, time,A1,a1,A2,a2)
{
pred <- A1*exp(-a1*time)+A2*exp(-a2*time)
(resp - pred) / sqrt(pred)
}

# Fit using nls
cs.wt <- nls( ~ wt.MM(conc, time,A1,a1,A2,a2), data=csdata,
  start=list(A1=700,a1=1,A2=100,a2=0.1),
  trace = TRUE)

x<-csdata$time
y<-csdata$conc

# I want to plot the observed vs. fitted values in both linear(y) and log(y)
plots (i.e., linear and semi-log plots)
# Help appreciated...I spent over 2 hours searching archives.

# Thanks in advance.


-- 
Oscar
Oscar A. Linares, MD
Translational Medicine Unit
LaPlaisance Bay, Bolles Harbor
Monroe, Michigan 48161

[[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.


Re: [R] Switch Help

2009-11-18 Thread oscar linares
Thanks for the Rxpert advice! I am up and running again...

Oscar

On Wed, Nov 18, 2009 at 5:57 AM, Colin Millar  wrote:

> I think you just missed some commas out...
>
> aar <-
> function(command = c("scrn", "dx", "df"))
> {
>  command <- match.arg(command)
>   switch(command,
>scrn = cat("scrn  :Screening","\n"),
>dx   = cat("dx:Diagnosis","\n"),
>df   = cat("df:Don't Forget","\n")
>  )
> }
>
> Colin.
>
>
> Ps you don't need the curly brackets here if theres only one expresion,
> and sometimes its good to restrict the inputs to only those you want
> So that
>
> aar("something wrong")
>
> # Error in match.arg(command) : 'arg' should be one of "scrn", "dx",
> "df"
>
>
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
> On Behalf Of oscar linares
> Sent: 18 November 2009 10:40
> To: r-help@r-project.org
> Subject: [R] Switch Help
>
> Dear Rexperts,
>
> Given,
>
> aar <-function(command) {
>
> switch(command,
>  {scrn = cat("scrn  :Screening","\n")}
>  {dx   = cat("dx:Diagnosis","\n")}
>  {df   = cat("df:Don't Forget","\n")}
> )
> }
>
> I want to be able to do:
>
> aar("dx") # function does cat("dx:Diagnosis","\n")
>
> aar(c("dx","df"))  # function does cat("dx:Diagnosis","\n")
># function does df   = cat("df:Don't
> Forget","\n")
>
> BUT IT IS NOT WORKING FOR ME.
>
> Please help:-)
>
> --
> Oscar
> Oscar A. Linares, MD
> Translational Medicine Unit
> LaPlaisance Bay, Bolles Harbor
> Monroe, Michigan
>
> [[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.
>
> __
> This email has been scanned by the MessageLabs Email Security System.
> For more information please visit http://www.messagelabs.com/email
> __
>



-- 
Oscar
Oscar A. Linares, MD
Translational Medicine Unit
LaPlaisance Bay, Bolles Harbor
Monroe, Michigan

[[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.


[R] Switch Help

2009-11-18 Thread oscar linares
Dear Rexperts,

Given,

aar <-function(command) {

switch(command,
  {scrn = cat("scrn  :Screening","\n")}
  {dx   = cat("dx:Diagnosis","\n")}
  {df   = cat("df:Don't Forget","\n")}
)
}

I want to be able to do:

aar("dx") # function does cat("dx:Diagnosis","\n")

aar(c("dx","df"))  # function does cat("dx:Diagnosis","\n")
# function does df   = cat("df:Don't
Forget","\n")

BUT IT IS NOT WORKING FOR ME.

Please help:-)

-- 
Oscar
Oscar A. Linares, MD
Translational Medicine Unit
LaPlaisance Bay, Bolles Harbor
Monroe, Michigan

[[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.


[R] Rcmdr

2009-09-19 Thread oscar linares
Is there a UseR! manual in the works for the outstanding Rcmdr?

-- 
Oscar
Oscar A. Linares, MD
Translational Medicine Unit
Bolles Harbor
Monroe, Michigan

[[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.


[R] STACK

2009-04-01 Thread oscar linares
Dear Rxperts

I have a data.frame as follows

ABCD
14 710
25 811
36 912

I want to convert it to a data frame with a single row (i.e., stack the
columns without the heading)
1
2
3
4
5
6
7
8
9
10
11
12

Any suggestions please.

Thanks in advance!

-- 
Oscar
Oscar A. Linares
Molecular Medicine Unit
Bolles Harbor
Monroe, Michigan

[[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.


[R] data management

2009-01-25 Thread oscar linares
Dear Rxperts,

I would like to convert the following:

StudyStudy.NameParameterDestSrcFormValueMin
MaxFSD
1NT_1-0BFK(03)03A0.128510.0E+001.
0.41670E-01
1NT_1-0BFL(00,03)0003D0.36577
1NT_1-0BFL(00,02)0002D0.9
1NT_1-0BFL(00,04)0004D0.9
1NT_1-0BFP(01)01A0.365770.0E+00100.00
0.36880E-01
1NT_1-0BFP(02)02A28.2690.0E+00100.00
0.58489E-01
1NT_1-0BFP(03)03A68.14410.0001000.0
0.27806E-01
1NT_1-0BFP(05)05D0.9
1NT_1-0BFP(31)31D26.316
1NT_1-0BFP(32)32D29.483
1NT_1-0BFP(22)22D7.7813
StudyStudy.NameParameterDestSrcFormValueMin
MaxFSD
1NT_1-1BFK(03)03A0.128520.0E+001.
0.39727E-01
1NT_1-1BFL(00,03)0003D0.36577
1NT_1-1BFL(00,02)0002D0.9
1NT_1-1BFL(00,04)0004D0.9
1NT_1-1BFP(01)01A0.365770.0E+00100.00
0.35166E-01
1NT_1-1BFP(02)02A28.2800.0E+00100.00
0.55760E-01
1NT_1-1BFP(03)03A68.13410.0001000.0
0.26508E-01
1NT_1-1BFP(05)05D0.9
1NT_1-1BFP(22)22D7.7811
StudyStudy.NameParameterDestSrcFormValueMin
MaxFSD
1NT_1-2BFK(03)03A0.128510.0E+001.
0.90167E-01
1NT_1-2BFL(00,03)0003D0.36575
1NT_1-2BFL(00,02)0002D0.9
1NT_1-2BFL(00,04)0004D0.9
1NT_1-2BFP(01)01A0.365750.0E+00100.00
0.79794E-01
1NT_1-2BFP(02)02A23.8900.0E+00100.00
0.13385
1NT_1-2BFP(03)03A76.29710.0001000.0
0.68931E-01
1NT_1-2BFP(05)05D0.9
1NT_1-2BFP(22)22D7.7815

To look like the following stata output

 | study   studyn~e K3P1   P2   P3   P5P11
P23  P31  P32  P33 |

|--|
  1. | 1  NT_16   .125   .35   35.903   8.6815   .83195 58
.13793   26.316   4.7181   13.211 |
  2. | 2   NT_1   .125   .35   23.173   9.4882   .75125   66.7
.11994   26.316   4.042711.32 |
  3. | 3   NT_2   .125   .35   48.229   7.1296   .68354   66.7
.11994   26.316   4.9101   13.748 |
  4. | 4   NT_3   .125   .35   8.0027   15.967   1.1438
80.1   26.316   .37137   1.0398 |
  5. | 5   NT_4   .125   .35   24.468   4.4256   .65408
40.2   26.316   2.1901   6.1322 |

|--|

Any suggestions for doing this in R?

Many thanks in advance for your help.

-- 
Oscar
Oscar A. Linares
Molecular Medicine Unit
Bolles Harbor
Monroe, Michigan

[[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.


[R] ?grep

2009-01-18 Thread oscar linares
Dear Rxperts,

I have the following data:

Study Study.Name C Category TC Time   QC   QO SD FSD   Theta
 1   NONE 0P(22)  0 0.00   7.5596   0  0 8.0361e-03 0
 1   NONE 6G(50)  0 0.00   1.   0  0 0.e+00 0
 1   NONE 2F(02)  0 0.00 100.   0  0 0.e+00 0
 1   NONE 3F(03)  0 0.00  13.2280   0  0 1.6732e-02 0
 1   NONE 2F(02)  0 0.00 100. 100  1 0.e+00 0
 1   NONE 6G(50)  0 0.01   1.0001   0  0 5.6765e-07 0
 1   NONE 6G(50)  0 0.02   1.0003   0  0 7.5677e-07 0
 1   NONE 6G(50)  0 0.03   1.0004   0  0 1.5133e-06 0
 1   NONE 6G(50)  0 0.04   1.0005   0  0 1.8914e-06 0
 1   NONE 6G(50)  0 0.05   1.0007   0  0 2.2694e-06 0
 1   NONE 6G(50)  0 0.06   1.0008   0  0 2.6463e-06 0
 1   NONE 6G(50)  0 0.07   1.0009   0  0 3.2126e-06 0
 1   NONE 6G(50)  0 0.08   1.0011   0  0 3.5901e-06 0
 1   NONE 6G(50)  0 0.09   1.0012   0  0 4.1564e-06 0
 1   NONE 6G(50)  0 0.10   1.0013   0  0 4.5348e-06 0
 1   NONE 2F(02)  0 0.10  99.6310   0  0 1.2637e-05 0
 1   NONE 3F(03)  0 0.10  13.2090   0  0 1.6720e-02 0
# END

I need to extract the elements labelled G(50) under Category heading with
the corresponding col values in cols labeled Time and QC.

Please help:-)

Thank you in advance for excellent help!
-- 
Oscar
Oscar A. Linares
Molecular Medicine Unit
Bolles Harbor
Monroe, Michigan

[[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.


Re: [R] read a xls file

2009-01-18 Thread oscar linares
use

install.package(RODBC)

library("RODBC")

cnct <- odbcConnectExcel("filename.xls")

hope this helps



On Sun, Jan 18, 2009 at 9:15 AM, Michele Santacatterina
wrote:

> Hello,
>
> i have a xls file. I will read it in r, what library-command i use for
> this??
>
> any ideas??
>
> Thanks
>
> Michele
>
>[[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.
>



-- 
Oscar
Oscar A. Linares
Molecular Medicine Unit
Bolles Harbor
Monroe, Michigan

[[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.


[R] data management

2009-01-18 Thread oscar linares
Dear Rxperts,

I have a varaibles data file that looks like this

p(1) 10
p(1) 3
p(1) 4
p(2) 20
p(2) 30
p(2) 40
p(3) 4
p(3) 1
p(1) 2

I cannot process these data with R because it does not like the parentheses.
How can I get these to look like:

p1 10
p1 3
p1 4
p2 20
p2 30
p2 40
p3 4
p3 1
p3 2

The data is in a tab delimited text file and I want to get it into a
data.frame().

Many thanks in advance.

OAL
p1
p1

-- 
Oscar
Oscar A. Linares
Molecular Medicine Unit
Bolles Harbor
Monroe, Michigan

[[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.


Re: [R] install.views()

2009-01-10 Thread oscar linares
Thanks! Your suggestion did it:-)

OAL

On Sat, Jan 10, 2009 at 3:00 PM, oscar linares  wrote:

>
> Dear Rxperts,
>
> Using R 2.8.1 and trying
>
> install.views("Cluster")
>
> getting error
>
> Error: could not find function "install.views"
>
>
> Please help:-(
>
>
> --
> Oscar
> Oscar A. Linares
> Molecular Medicine Unit
> Bolles Harbor
> Monroe, Michigan
>



-- 
Oscar
Oscar A. Linares
Molecular Medicine Unit
Bolles Harbor
Monroe, Michigan

[[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.


[R] install.views()

2009-01-10 Thread oscar linares
Dear Rxperts,

Using R 2.8.1 and trying

install.views("Cluster")

getting error

Error: could not find function "install.views"


Please help:-(


-- 
Oscar
Oscar A. Linares
Molecular Medicine Unit
Bolles Harbor
Monroe, Michigan

[[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.


[R] Converting english words to numeric equivalents

2008-07-27 Thread oscar Linares
Hello,

I am trying to convert english words to numeric equivalents, e.g., abc to 123. 
Is there a function or library or package for doing this in R? If not, can it 
be done easily in R?

Thanks,

Oscar



  
[[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.


Re: [R] Manipulate Data (with regular expressions)

2008-07-08 Thread oscar Linares
Check out sedit() in the Hmisc package

Cheers!



--- On Tue, 7/8/08, Kunzler, Andreas <[EMAIL PROTECTED]> wrote:

> From: Kunzler, Andreas <[EMAIL PROTECTED]>
> Subject: [R] Manipulate Data (with regular expressions)
> To: r-help@r-project.org
> Date: Tuesday, July 8, 2008, 7:11 AM
> Dear Everyone,
> 
>  
> 
> I try to automatically manipulate the data of a variable
> (class =
> factor) like
> 
>  
> 
> x
> 
> 220
> 
> 220a
> 
> 221
> 
> 221b
> 
> B221
> 
>  
> 
> Into two variables (class = numeric) like
> 
>  
> 
> x y
> 
> 220   0
> 
> 220   1
> 
> 221   0
> 
> 221   1
> 
> 221   1
> 
>  
> 
> y has to carry the information about the class (number or
> string) of the
> former x-Variable.
> 
>  
> 
> I could do it by hand like
> 
>  
> 
> x[x == "220a"] <- 220
> 
> y[x == "220a"] <- 1
> 
>  
> 
> but x has way to many expressions.
> 
>  
> 
> So I wondered if I could use a regular expression like OR
> ANY OTHER WAY
> 
>  
> 
> x[x == [0-9]{3}a] <- regular expression
> 
> y[x == [0-9]{3}] <- 1
> 
>  
> 
>  
> 
> Thanks a lot
> 
>  
> 
> 
>   [[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.

__
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.