[R] R studio server vs R server and Small computer to run R

2017-01-18 Thread John Sorkin
Please forgive my resending this help request. I sent it two days ago. To date 
I have not received any responses.
Thank you,
John
 
 
I am looking for a small computer low power that I make available on the web 
that will run R studio server or R server

1) can anyone recommend a computer?

2) can anyone let me know the advantages and disadvantages of R studio server 
and R server?

Thank you

John


John David Sorkin M.D., Ph.D.

Professor of Medicine

Chief, Biostatistics and Informatics


University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine


Baltimore VA Medical Center


10 North Greene Street


GRECC (BT/18/GR)


Baltimore, MD 21201-1524


(Phone) 410-605-7119

(Fax) 410-605-7913 (Please call phone number above prior to faxing)
John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 

Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@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.


[R] R studio server vs R server and Small computer to run R

2017-01-16 Thread John Sorkin
I am looking for a small computer low power that I make available on the web 
that will run R studio server or R server
1) can anyone recommend a computer?
2) can anyone let me know the advantages and disadvantages of R studio server 
and R server?
Thank you
John

> John David Sorkin M.D., Ph.D.
> Professor of Medicine
> Chief, Biostatistics and Informatics
> University of Maryland School of Medicine Division of Gerontology and 
> Geriatric Medicine
> Baltimore VA Medical Center
> 10 North Greene Street
> GRECC (BT/18/GR)
> Baltimore, MD 21201-1524
> (Phone) 410-605-7119
> (Fax) 410-605-7913 (Please call phone number above prior to faxing)

Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@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.


Re: [R] R in raspberry Pi

2017-01-02 Thread John Sorkin
Robin,
Your chapter sounds very interesting. Unfortunately it appears that it is not 
available, at least not to me.
John

> John David Sorkin M.D., Ph.D.
> Professor of Medicine
> Chief, Biostatistics and Informatics
> University of Maryland School of Medicine Division of Gerontology and 
> Geriatric Medicine
> Baltimore VA Medical Center
> 10 North Greene Street
> GRECC (BT/18/GR)
> Baltimore, MD 21201-1524
> (Phone) 410-605-7119
> (Fax) 410-605-7913 (Please call phone number above prior to faxing)


> On Jan 2, 2017, at 5:57 PM, robinbt2  wrote:
> 
> One of the additional free online chapters to my book provides a step by
> step guide to downloading and running R on the Raspberry Pi:
> http://www.floppybunny.org/robin/web/rbook/online_chapters/r_and_the_raspber
> ry_pi.pdf
> 
> All the best robin beaumont
> 
> For details of the entire book go to:
> http://www.amazon.co.uk/dp/190790431X
> Books website: http://www.floppybunny.org/robin/web/rbook/ 
> producible code.
> 
> __
> R-help@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.

Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@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.


Re: [R] Log plus one transformation in R

2016-12-13 Thread John Sorkin
Duncan,
Thank you. You are correct no one answered my question , despite the fact that 
several people reply to my email, until you replied. Your exclamation is quite 
clear and I thank you for your kindness. I did not pursue my question any 
further as I was concerned that I would be flamed.
John

> John David Sorkin M.D., Ph.D.
> Professor of Medicine
> Chief, Biostatistics and Informatics
> University of Maryland School of Medicine Division of Gerontology and 
> Geriatric Medicine
> Baltimore VA Medical Center
> 10 North Greene Street
> GRECC (BT/18/GR)
> Baltimore, MD 21201-1524
> (Phone) 410-605-7119
> (Fax) 410-605-7913 (Please call phone number above prior to faxing)


> On Dec 13, 2016, at 12:12 PM, Duncan Murdoch  wrote:
> 
>> On 12/12/2016 12:26 PM, John Sorkin wrote:
>> David,
>> 
>> I did read the help page. All it says is
>> log1p(x) computes log(1+x) accurately also for |x| << 1 (and less
>> accurately when x is approximately -1).
>> This gives me pause. Does it mean that log(x) does not give accurate
>> results? If log1p gives more accurate values than log, why is the log
>> function not written to use the more accurate computation performed by
>> log1p.
> 
> I don't think anyone has directly answered these questions.  The problem 
> isn't with log(), it's with the representation of floating point numbers 
> in R.  The log of 1 + 10^(-100) is very close to 10^(-100), but since 1 
> + 1e-100 evaluates to 1 (we only keep 15 or 16 digits of precision), 
> log(1 + 1e-100) will come out as zero.  On the other hand, log1p(1e-100) 
> evaluates correctly to 1e-100.
> 
>>  I don't believe I can look directly at the code for log and
>> log1p,
> 
> R is open source, so you could, but those are likely coming from system 
> libraries, so it isn't easy to see how the approximations are being done.
> 
> Duncan Murdoch
>>  so I need to rely on the kindness of others to explain the
>> differences between the computations performed by the functions. I guess
>> the test I ran, log1p(0.01)/log(0.01+1), did not have enough
>> precision to demonstrate a difference between the two functions.
>> John
>> 
>> 
>> 
>> John David Sorkin M.D., Ph.D.
>> Professor of Medicine
>> Chief, Biostatistics and Informatics
>> University of Maryland School of Medicine Division of Gerontology and
>> Geriatric Medicine
>> Baltimore VA Medical Center
>> 10 North Greene Street
>> GRECC (BT/18/GR)
>> Baltimore, MD 21201-1524
>> (Phone) 410-605-7119
>> (Fax) 410-605-7913 (Please call phone number above prior to faxing)
>>>>> David Winsemius  12/12/16 12:05 PM >>>
>> 
>>> On Dec 12, 2016, at 8:53 AM, John Sorkin 
>> wrote:
>>> 
>>> At the risk of being flamed . . .
>>> What is the difference between log1p(x) and log(x+1)?
>>> The two methods appear to give the same results:
>>>> log1p(0.01)/log(0.01+1)
>>> [1] 1
>>> John
>> 
>> Read the help page more carefully.
>> 
> 

Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@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.


Re: [R] Log plus one transformation in R

2016-12-12 Thread John Sorkin
David,
 
I did read the help page. All it says is
log1p(x) computes log(1+x) accurately also for |x| << 1 (and less
accurately when x is approximately -1). 
This gives me pause. Does it mean that log(x) does not give accurate
results? If log1p gives more accurate values than log, why is the log
function not written to use the more accurate computation performed by
log1p. I don't believe I can look directly at the code for log and
log1p, so I need to rely on the kindness of others to explain the
differences between the computations performed by the functions. I guess
the test I ran, log1p(0.01)/log(0.01+1), did not have enough
precision to demonstrate a difference between the two functions.
John



John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and
Geriatric Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 
>>> David Winsemius  12/12/16 12:05 PM >>>

> On Dec 12, 2016, at 8:53 AM, John Sorkin 
wrote:
> 
> At the risk of being flamed . . .
> What is the difference between log1p(x) and log(x+1)?
> The two methods appear to give the same results:
>> log1p(0.01)/log(0.01+1)
> [1] 1
> John

Read the help page more carefully.

-- 
David.
> 
> 
> John David Sorkin M.D., Ph.D.
> Professor of Medicine
> Chief, Biostatistics and Informatics
> University of Maryland School of Medicine Division of Gerontology and
> Geriatric Medicine
> Baltimore VA Medical Center
> 10 North Greene Street
> GRECC (BT/18/GR)
> Baltimore, MD 21201-1524
> (Phone) 410-605-7119
> (Fax) 410-605-7913 (Please call phone number above prior to faxing) 
>>>> William Dunlap via R-help  12/12/16 11:38 AM
>>>> 
> log1p(x), in the base package computes log(1+x) accurately for small x
> (and
> large).
> 
> E.g.,
>> options(digits=16)
>> base::log1p(1e-14)
> [1] 9.95e-15
>> base::log1p(1e-14) - base::log(1+1e-14)
> [1] 7.992778373591124e-18
>> as.numeric(log(Rmpfr::mpfr(1,precBits=1000) + Rmpfr::mpfr(1e-14,
> precBits=1000))) - log1p(1e-14)
> [1] 0
> 
> 
> Bill Dunlap
> TIBCO Software
> wdunlap tibco.com
> 
> On Mon, Dec 12, 2016 at 8:23 AM, Faradj Koliev 
> wrote:
> 
>> Hi all,
>> 
>> How do I perform log(x+1) in R?
>> 
>> log1p_trans() from the package ”scales" doesn’t seem to work for me.
>> 
>> Best,
>> Faradj
>> __
>> R-help@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]]
> 
> __
> R-help@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.
> Confidentiality Statement:
> This email message, including any attachments, is for the sole use of
> the intended recipient(s) and may contain confidential and privileged
> information. Any unauthorized use, disclosure or distribution is
> prohibited. If you are not the intended recipient, please contact the
> sender by reply email and destroy all copies of the original message. 
> __
> R-help@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.

David Winsemius
the intended recipient(s) and may contain confidential and privileged
information. Any unauthorized use, disclosure or distribution is
prohibited. If you are not the intended recipient, please contact the
sender by reply email and destroy all copies of the original message. 
__
R-help@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.

Re: [R] Log plus one transformation in R

2016-12-12 Thread John Sorkin
At the risk of being flamed . . .
What is the difference between log1p(x) and log(x+1)?
The two methods appear to give the same results:
> log1p(0.01)/log(0.01+1)
[1] 1
John


John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and
Geriatric Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 
>>> William Dunlap via R-help  12/12/16 11:38 AM
>>>
log1p(x), in the base package computes log(1+x) accurately for small x
(and
large).

E.g.,
> options(digits=16)
> base::log1p(1e-14)
[1] 9.95e-15
> base::log1p(1e-14) - base::log(1+1e-14)
[1] 7.992778373591124e-18
> as.numeric(log(Rmpfr::mpfr(1,precBits=1000) + Rmpfr::mpfr(1e-14,
precBits=1000))) - log1p(1e-14)
[1] 0


Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Mon, Dec 12, 2016 at 8:23 AM, Faradj Koliev 
wrote:

> Hi all,
>
> How do I perform log(x+1) in R?
>
> log1p_trans() from the package ”scales" doesn’t seem to work for me.
>
> Best,
> Faradj
> __
> R-help@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]]

__
R-help@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.
Confidentiality Statement:
This email message, including any attachments, is for the sole use of
the intended recipient(s) and may contain confidential and privileged
information. Any unauthorized use, disclosure or distribution is
prohibited. If you are not the intended recipient, please contact the
sender by reply email and destroy all copies of the original message. 
__
R-help@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.

Re: [R] Log plus one transformation in R

2016-12-12 Thread John Sorkin
Faradj,
 
I all you need to do is
 
newvalue <- log(x+1)


John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and
Geriatric Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 
>>> Faradj Koliev  12/12/16 11:24 AM >>>
Hi all, 

How do I perform log(x+1) in R? 

log1p_trans() from the package ”scales" doesn’t seem to work for me. 

Best, 
Faradj
__
R-help@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.
Confidentiality Statement:
This email message, including any attachments, is for the sole use of
the intended recipient(s) and may contain confidential and privileged
information. Any unauthorized use, disclosure or distribution is
prohibited. If you are not the intended recipient, please contact the
sender by reply email and destroy all copies of the original message. 
__
R-help@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.

Re: [R] Write a function that allows access to columns of a passeddataframe.

2016-12-06 Thread John Sorkin
Over my almost 50 years programming, I have come to believe that if one wants a 
program to be useful, one should write the program to do as much work as 
possible and demand as little as possible from the user of the program. In my 
opinion, one should not ask the person who uses my function to remember to put 
the name of the data frame column in quotation marks. The function should be 
written so that all that needs to be passed is the name of the column; the 
function should take care of the quotation marks.
Jihny

> John David Sorkin M.D., Ph.D.
> Professor of Medicine
> Chief, Biostatistics and Informatics
> University of Maryland School of Medicine Division of Gerontology and 
> Geriatric Medicine
> Baltimore VA Medical Center
> 10 North Greene Street
> GRECC (BT/18/GR)
> Baltimore, MD 21201-1524
> (Phone) 410-605-7119
> (Fax) 410-605-7913 (Please call phone number above prior to faxing)


> On Dec 6, 2016, at 3:17 AM, Rui Barradas  wrote:
> 
> Hello,
> 
> Just to say that I wouldn't write the function as John did. I would get 
> rid of all the deparse/substitute stuff and instinctively use a quoted 
> argument as a column name. Something like the following.
> 
> myfun <- function(frame, var){
>[...]
>col <- frame[, var]  # or frame[[var]]
>[...]
> }
> 
> myfun(mydf, "age")  # much better, simpler, no promises.
> 
> Rui Barradas
> 
> Em 05-12-2016 21:49, Bert Gunter escreveu:
>> Typo: "lazy evaluation" not "lay evaluation."
>> 
>> -- Bert
>> 
>> 
>> 
>> Bert Gunter
>> 
>> "The trouble with having an open mind is that people keep coming along
>> and sticking things into it."
>> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>> 
>> 
>>> On Mon, Dec 5, 2016 at 1:46 PM, Bert Gunter  wrote:
>>> Sorry, hit "Send" by mistake.
>>> 
>>> Inline.
>>> 
>>> 
>>> 
>>>> On Mon, Dec 5, 2016 at 1:34 PM, Bert Gunter  wrote:
>>>> Inline.
>>>> 
>>>> -- Bert
>>>> 
>>>> 
>>>> Bert Gunter
>>>> 
>>>> "The trouble with having an open mind is that people keep coming along
>>>> and sticking things into it."
>>>> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>>>> 
>>>> 
>>>>> On Mon, Dec 5, 2016 at 9:53 AM, Rui Barradas  wrote:
>>>>> Hello,
>>>>> 
>>>>> Inline.
>>>>> 
>>>>> Em 05-12-2016 17:09, David Winsemius escreveu:
>>>>>> 
>>>>>> 
>>>>>>> On Dec 5, 2016, at 7:29 AM, John Sorkin 
>>>>>>> wrote:
>>>>>>> 
>>>>>>> Rui,
>>>>>>> I appreciate your suggestion, but eliminating the deparse statement does
>>>>>>> not solve my problem. Do you have any other suggestions? See code below.
>>>>>>> Thank you,
>>>>>>> John
>>>>>>> 
>>>>>>> 
>>>>>>> mydf <-
>>>>>>> data.frame(id=c(1,2,3,4,5),sex=c("M","M","M","F","F"),age=c(20,34,43,32,21))
>>>>>>> mydf
>>>>>>> class(mydf)
>>>>>>> 
>>>>>>> 
>>>>>>> myfun <- function(frame,var){
>>>>>>>   call <- match.call()
>>>>>>>   print(call)
>>>>>>> 
>>>>>>> 
>>>>>>>   indx <- match(c("frame","var"),names(call),nomatch=0)
>>>>>>>   print(indx)
>>>>>>>   if(indx[1]==0) stop("Function called without sufficient arguments!")
>>>>>>> 
>>>>>>> 
>>>>>>>   cat("I can get the name of the dataframe as a text string!\n")
>>>>>>>   #xx <- deparse(substitute(frame))
>>>>>>>   print(xx)
>>>>>>> 
>>>>>>> 
>>>>>>>   cat("I can get the name of the column as a text string!\n")
>>>>>>>   #yy <- deparse(substitute(var))
>>>>>>>   print(yy)
>>>>>>> 
>>>>>>> 
>>>>>>>   # This does not work.
>>>>>>>   print(frame[,var])
>>>>>>> 
>>>>>>> 

Re: [R] Write a function that allows access to columns of a passed dataframe.

2016-12-05 Thread John Sorkin
Rui,
I appreciate your suggestion, but eliminating the deparse statement does not 
solve my problem. Do you have any other suggestions? See code below.
Thank you,
John


mydf <- 
data.frame(id=c(1,2,3,4,5),sex=c("M","M","M","F","F"),age=c(20,34,43,32,21))
mydf
class(mydf)


myfun <- function(frame,var){
  call <- match.call()
  print(call)


  indx <- match(c("frame","var"),names(call),nomatch=0)
  print(indx)
  if(indx[1]==0) stop("Function called without sufficient arguments!")


  cat("I can get the name of the dataframe as a text string!\n")
  #xx <- deparse(substitute(frame))
  print(xx)


  cat("I can get the name of the column as a text string!\n")
  #yy <- deparse(substitute(var))
  print(yy)


  # This does not work.
  print(frame[,var])


  # This does not work.
  print(frame[,"var"])




  # This does not work.
  col <- xx[,"yy"]


  # Nor does this work.
  col <- xx[,yy]
  print(col)
}


myfun(mydf,age)




myfun()














John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 

>>> Rui Barradas  12/05/16 10:17 AM >>>
Hello,

You don't need xx <- deparse(substitute(...)), since you are passing the 
data.frame to your function. Just use


myfun <- function(frame,var){

   [...]

   # Nor does this work.
   col <- frame[,yy]
   print(col)
}

myfun(mydf,age)
myfun(frame = mydf, var = age)
[1] 2 3
I can get the name of the dataframe as a text string!
[1] "mydf"
I can get the name of the column as a text string!
[1] "age"
[1] 20 34 43 32 21


Hope this helps,

Rui Barradas



Em 05-12-2016 14:44, John Sorkin escreveu:
> I am trying to write a function which, when passed the name of a dataframe 
> and the name of a column of the dataframe, will allow me to work on the 
> columns of a dataframe. I can not get my code to work. Please see the code 
> below. Any help in getting the function to work would be appreciated.
>
>
>
>
> mydf <- 
> data.frame(id=c(1,2,3,4,5),sex=c("M","M","M","F","F"),age=c(20,34,43,32,21))
> mydf
> class(mydf)
>
>
> myfun <- function(frame,var){
>call <- match.call()
>print(call)
>
>
>indx <- match(c("frame","var"),names(call),nomatch=0)
>print(indx)
>if(indx[1]==0) stop("Function called without sufficient arguments!")
>
>
>cat("I can get the name of the dataframe as a text string!\n")
>xx <- deparse(substitute(frame))
>print(xx)
>
>
>cat("I can get the name of the column as a text string!\n")
>yy <- deparse(substitute(var))
>print(yy)
>
>
># This does not work.
>col <- xx[,"yy"]
>
>
># Nor does this work.
>col <- xx[,yy]
>print(col)
> }
>
>
> myfun(mydf,age)
>
> John David Sorkin M.D., Ph.D.
> Professor of Medicine
> Chief, Biostatistics and Informatics
> University of Maryland School of Medicine Division of Gerontology and 
> Geriatric Medicine
> Baltimore VA Medical Center
> 10 North Greene Street
> GRECC (BT/18/GR)
> Baltimore, MD 21201-1524
> (Phone) 410-605-7119
> (Fax) 410-605-7913 (Please call phone number above prior to faxing)
>
>
>
>
> John David Sorkin M.D., Ph.D.
> Professor of Medicine
> Chief, Biostatistics and Informatics
> University of Maryland School of Medicine Division of Gerontology and 
> Geriatric Medicine
> Baltimore VA Medical Center
> 10 North Greene Street
> GRECC (BT/18/GR)
> Baltimore, MD 21201-1524
> (Phone) 410-605-7119
> (Fax) 410-605-7913 (Please call phone number above prior to faxing)
>
>
>
>
>
> Confidentiality Statement:
> This email message, including any attachments, is for the sole use of the 
> intended recipient(s) and may contain confidential and privileged 
> information. Any unauthorized use, disclosure or distribution is prohibited. 
> If you are not the intended recipient, please contact the sender by reply 
> email and destroy all copies of the original message.
> __
> R-help@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.
>

[R] Write a function that allows access to columns of a passed dataframe.

2016-12-05 Thread John Sorkin
I am trying to write a function which, when passed the name of a dataframe and 
the name of a column of the dataframe, will allow me to work on the columns of 
a dataframe. I can not get my code to work. Please see the code below. Any help 
in getting the function to work would be appreciated.




mydf <- 
data.frame(id=c(1,2,3,4,5),sex=c("M","M","M","F","F"),age=c(20,34,43,32,21))
mydf
class(mydf)


myfun <- function(frame,var){
  call <- match.call()
  print(call)


  indx <- match(c("frame","var"),names(call),nomatch=0)
  print(indx)
  if(indx[1]==0) stop("Function called without sufficient arguments!")


  cat("I can get the name of the dataframe as a text string!\n")
  xx <- deparse(substitute(frame))
  print(xx)


  cat("I can get the name of the column as a text string!\n")
  yy <- deparse(substitute(var))
  print(yy)


  # This does not work.
  col <- xx[,"yy"]


  # Nor does this work.
  col <- xx[,yy]
  print(col)
}


myfun(mydf,age)

John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 




John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 





Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@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.


[R] Produce multiple line graphs

2016-09-25 Thread John Sorkin
I have a data frame that contains data for multiple (seven) subjects. Each 
subject is represented by a new value of PID.
I would like to plot the data for all seven subjects. For each subject I want 
to plot a line showing CT as a function of Nit, with the dots for each subject 
joined. I have tried to accomplish this using the by function. I get an error 
message, 
Error in match.fun(panel) : 
  'xx[, "CT"]' is not a function, character or symbol
I have no idea what is causing the error, nor how to correct the error, nor how 
to get the dots for each point be connected by a line.


Any help would be appreciated!


PID <- c( 1 ,  1   ,  1   , 1   , 2, 2, 2, 2, 3   ,   3  ,  3   ,  3   ,  4   , 
 4,  4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7   ,  7   ,7  , 7)
Nit <- c(NA , -9.23,-11.61,-7.88,NA,NA,NA,NA,-5.59,  0.73,-10.55, -9.13,  3.67, 
NA, NA,-13.26,NA,NA,NA,NA,NA,NA,NA,NA,-9.36,  5.08,  -5.73, 2.02)
CT  <- c(544,459   ,432   ,NA   ,NA,NA,NA,NA,1398 ,1287  ,1049  , NA   ,543   
,474,507,NA,NA,NA,NA,NA,NA,NA,NA,NA,992  ,992   ,1078   ,NA)
xx  <- data.frame(PID=PID,Nit=Nit,CT=CT)
xx
by(xx,as.factor(xx[,"PID"]),plot,xx[,"Nit"],xx[,"CT"])




John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 


Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@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.


[R] nlme: fewer observations than random effects in all level 1 groups

2016-08-25 Thread John Sorkin
I am getting a warning message when I run lme:
 
Warning message:
In lme.formula(fixed = value ~ CorT + time + CorT * time, data = GD) :
  fewer observations than random effects in all level 1 groups
I don't know what the message means, nor if I need to be concerned about the 
message. I would be
grateful if someone could explain the message to me, and tell me if I need to 
have concern.
My data and code follows. You should be able to copy, paste and run the code. 
(n.b. you will need nlme).
Thank you,
John

library(nlme)
data10 <- structure(list(SS = c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 
  11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 
22L, 23L, 
  24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 33L, 34L, 
35L, 36L, 
  37L, 38L, 39L, 40L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 
10L, 
  11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 
22L, 23L, 
  24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 33L, 34L, 
35L, 36L, 
  37L, 38L, 39L, 40L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 
10L, 
  11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 
22L, 23L, 
  24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 33L, 34L, 
35L, 36L, 
  37L, 38L, 39L, 40L), 
  group = structure(c(1L, 1L, 1L, 1L, 1L, 
  1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 2L, 
  2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
2L, 2L, 
  2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 
  1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
2L, 2L, 
  2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 
1L, 1L, 
  1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 2L, 
  2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
2L, 2L, 
  2L, 2L, 2L), .Label = c("Cont", "Inte"), class = 
"factor"), 
  time = c(0L,0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
0L, 0L, 0L, 0L, 0L, 
  0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
0L, 0L, 
  0L, 0L, 0L, 0L, 0L, 0L, 0L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
3L, 3L, 
  3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
3L, 3L, 
  3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
3L, 6L, 
  6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 
6L, 6L, 
  6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 
6L, 6L, 
  6L, 6L, 6L, 6L, 6L, 6L, 6L),
  value = c(2, 1, 3, 6, 1, 5, 4, 4, 
  3, 4, 5, 8, 4, 4, 0, 10, 3, 0, 4, 6, 7.86633577663451, 
14.8276520497166, 
  5.82301333779469, 6.28030818421394, 7.63550981180742, 
7.12941627483815, 
  14.4640282960609, 8.45473791006953, 9.05422623036429, 
10.3654135158285, 
  7.75828687706962, 9.05671408865601, 9.35509188333526, 
8.22054158896208, 
  5.03435689257458, 14.7296907380223, 6.12912589916959, 
10.4857219522819, 
  13.7229738035239, 13.6259456002153, 7.28073637914354, 
5.54352982843898, 
  8.01713229269774, 13.2061931600758, 3.76887153466896, 
10.7523541087606, 
  9.6018583095559, 9.62481826991277, 8.90923221009558, 
8.85276119502607, 
  10.9778885179292, 13.4521386035968, 9.95012926745246, 
7.78767098907235, 
  5.47606805783807, 16.266090481022, 8.10664718517709, 
3.98960108796381, 
  10.1788924241439, 9.16177207287154, 11.6541174116198, 
19.055363149052, 
  10.4729343696394, 12.9615216852694, 10.3448541992752, 
12.1246619594601, 
  17.9078516870675, 14.1546013378432, 14.3556335566072, 
13.7020998307993, 
  12.2669613611438, 13.6968944583291, 16.0242423205925, 
14.1618907899469, 
  11.6571628686932, 20.6208065318508, 10.5981108892906, 
16.506205140693, 
  19.8382587955876, 18.8215423103255, 13.6293066791555, 
10.679427547606, 
  14.5715854764237, 18.0672964438053, 8.64819129644325, 
16.5046323205086, 
  14.933146372713, 13.0224731390702, 13.1364074268251, 
12.7299140722498, 
  16.3687231173825, 17.3307585790136, 14.8835947338426, 
13.7832964561028, 
  8.18806783970065, 20.4643754783345, 13.927444172043, 
7.95214003187942, 
  15.8500600646401, 14.863828811346, 16.3418851303983, 
23.9363727442689, 
  15.6973592017088, 16.8376901116903, 16.4265975193717, 
18.3862045830691, 
  23.7260777608949, 19.67

[R] lme to determine if there is a group effect

2016-08-24 Thread John Sorkin
I apologize for sending this message again. The last time I sent it, the 
subject line was not correct. I have corrected the subject line.
 
I am trying to run a repeated measures analysis of data in which each subject 
(identified by SS) has 3 observations at three different times (0, 3, and 6). 
There are two groups of subjects (identified by group). I want to know if the 
response differs in the two groups. I have tried to used lme. Lme tell me if 
there is a time effect, but does not tell me if there is a group effect. Once I 
get this to work I will want to know if there is a significant group*time 
effect. Can someone tell me how to get an estimate for group. Once I get that, 
I believe getting an estimate for group*time should be straight forward. The 
code I have tired to use follows.
Thank you,
John
 
> # This is my data
> data1
   SS group time value baseline
1   1  Cont0  9.00 9.00
2   2  Cont0  3.00 3.00
3   3  Cont0  8.00 8.00
4   4  Inte0  5.690702 5.690702
5   5  Inte0  7.409493 7.409493
6   6  Inte0  7.428018 7.428018
7   1  Cont3 13.713148 9.00
8   2  Cont3  9.841107 3.00
9   3  Cont3 12.843236 8.00
10  4  Inte3  9.300899 5.690702
11  5  Inte3 10.936389 7.409493
12  6  Inte3 12.358499 7.428018
13  1  Cont6 18.952390 9.00
14  2  Cont6 15.091527 3.00
15  3  Cont6 17.578812 8.00
16  4  Inte6 12.325499 5.690702
17  5  Inte6 15.486513 7.409493
18  6  Inte6 18.284965 7.428018
> # Create a grouped data object. SS identifies each subject
> # group indentifies group, intervention or control.
> GD<- groupedData(value~time|SS/group,data=data1,FUN=mean)
> # Fit the model.
> fit1 <- lme(GD)
> cat("The results give information about time, but does not say if the gruops 
> are different\n")
The results give information about time, but does not say if the gruops are 
different
> summary(fit1)
Linear mixed-effects model fit by REML
 Data: GD 
   AIC  BIClogLik
  74.59447 81.54777 -28.29724

Random effects:
 Formula: ~time | SS
 Structure: General positive-definite
StdDevCorr  
(Intercept) 1.3875111 (Intr)
time0.2208046 -0.243

 Formula: ~time | group %in% SS
 Structure: General positive-definite
StdDevCorr  
(Intercept) 1.3875115 (Intr)
time0.2208051 -0.243
Residual0.3800788   

Fixed effects: value ~ time 
   Value Std.Error DF   t-value p-value
(Intercept) 6.747442 0.8135067 11  8.294268   0
time1.588653 0.1326242 11 11.978601   0
 Correlation: 
 (Intr)
time -0.268

Standardized Within-Group Residuals:
Min  Q1 Med  Q3 Max 
-1.11412947 -0.44986535  0.08034174  0.34615610  1.29943887 

Number of Observations: 18
Number of Groups: 
   SS group %in% SS 
6 6 



> 
John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 

Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@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.


Re: [R] function that converts data into a form that can be included in a question to mailing list

2016-08-24 Thread John Sorkin
I am trying to run a repeated measures analysis of data in which each subject 
(identified by SS) has 3 observations at three different times (0, 3, and 6). 
There are two groups of subjects (identified by group). I want to know if the 
response differs in the two groups. I have tried to used lme. Lme tell me if 
there is a time effect, but does not tell me if there is a group effect. Once I 
get this to work I will want to know if there is a significant group*time 
effect. Can someone tell me how to get an estimate for group. Once I get that, 
I believe getting an estimate for group*time should be straight forward. The 
code I have tired to use follows.
Thank you,
John
 
> data1
   SS group time value  baseline
1   1  Cont0  6.00  6.00
2   2  Cont0  3.00  3.00
3   3  Cont0  5.00  5.00
4   4  Inte0 14.132312 14.132312
5   5  Inte0  8.868808  8.868808
6   6  Inte0 14.602672 14.602672
7   1  Cont3 10.706805  6.00
8   2  Cont3  8.469477  3.00
9   3  Cont3  9.337411  5.00
10  4  Inte3 16.941940 14.132312
11  5  Inte3 13.872662  8.868808
12  6  Inte3 20.465614 14.602672
13  1  Cont6 16.687028  6.00
14  2  Cont6 13.177752  3.00
15  3  Cont6 14.276398  5.00
16  4  Inte6 23.453808 14.132312
17  5  Inte6 18.229053  8.868808
18  6  Inte6 25.334664 14.602672
> # Create a grouped data object. SS identifies each subject
> # group indentifies group, intervention or control.
> GD<- groupedData(value~time|SS/group,data=data1,FUN=mean)
> # Fit the model.
> fit1 <- lme(GD)
> cat("The results give information about time, but does not say if the gruops 
> are different\n")
The results give information about time, but does not say if the gruops are 
different
> summary(fit1)
Linear mixed-effects model fit by REML
 Data: GD 
   AIC  BIClogLik
  81.38094 88.33424 -31.69047

Random effects:
 Formula: ~time | SS
 Structure: General positive-definite
StdDev  Corr  
(Intercept) 3.371776404 (Intr)
time0.009246535 1 

 Formula: ~time | group %in% SS
 Structure: General positive-definite
StdDev Corr  
(Intercept) 3.34070367 (Intr)
time0.00915754 1 
Residual0.61279061   

Fixed effects: value ~ time 
   Value Std.Error DF   t-value p-value
(Intercept) 8.512446 1.9511580 11  4.362766  0.0011
time1.654303 0.0592047 11 27.942107  0.
 Correlation: 
 (Intr)
time -0.001

Standardized Within-Group Residuals:
   Min Q1Med Q3Max 
-1.9691671 -0.4876710  0.1559464  0.4637269  1.6069444 

Number of Observations: 18
Number of Groups: 
   SS group %in% SS 
6 6 

 
John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 

Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@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.


Re: [R] function that converts data into a form that can be included in a question to mailing list

2016-08-24 Thread John Sorkin
Jim,
Yes, you are correct!
Give yourself a pat on the back and a gold start
THANK YOU,
John


John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 
>>> Jim Lemon  08/24/16 6:05 PM >>>
Hi John,
I think it is "dput".

Jim


On Thu, Aug 25, 2016 at 8:00 AM, John Sorkin
 wrote:
>
> There is a function that can be used to convert data structures such as a 
> data frame into a different format that allows the data to be sent to the 
> mailing list. The structure that is created can be used to easily reconstruct 
> the data structure. Unfortunately, I don't remember the function that is 
> called on the data structure. Can someone remind me?
> Thank you
> John
> John David Sorkin M.D., Ph.D.
> Professor of Medicine
> Chief, Biostatistics and Informatics
> University of Maryland School of Medicine Division of Gerontology and 
> Geriatric Medicine
> Baltimore VA Medical Center
> 10 North Greene Street
> GRECC (BT/18/GR)
> Baltimore, MD 21201-1524
> (Phone) 410-605-7119
> (Fax) 410-605-7913 (Please call phone number above prior to faxing)
>
> Confidentiality Statement:
> This email message, including any attachments, is for the sole use of the 
> intended recipient(s) and may contain confidential and privileged 
> information. Any unauthorized use, disclosure or distribution is prohibited. 
> If you are not the intended recipient, please contact the sender by reply 
> email and destroy all copies of the original message.
> __
> R-help@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.
Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@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.


[R] function that converts data into a form that can be included in a question to mailing list

2016-08-24 Thread John Sorkin

There is a function that can be used to convert data structures such as a data 
frame into a different format that allows the data to be sent to the mailing 
list. The structure that is created can be used to easily reconstruct the data 
structure. Unfortunately, I don't remember the function that is called on the 
data structure. Can someone remind me?
Thank you
John
John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 

Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@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.


[R] function for over dispersed poisson regression in the setting of a random effects model

2016-06-25 Thread John Sorkin
Is there a function that will run a model appropriate for over dispersed data 
(such as a negative binomial or quasipoisson)
with a random effects (or mixed effects) model in R? GLMER will not accept:  
family=quasipoisson(link="log") or
family=negbinomial(link="log") 
 
I want to run something like the following:
fit0 <- glmer(Fall ~ 
Group+(1|PID)+offset(log(TimeYrs)),family=quasipoisson(link="log"),data=data)
Thank  you
John
John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 

Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@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.


[R] Add column to the output of summary(glht).

2016-06-24 Thread John Sorkin

I am trying to make the leap from an R users to an R aficionado . . .
 
I am trying to understand how add a column to the output of summary (and to 
understand how summary() works).
 
I have run a glmer
fit0 <- glmer(Fall ~ 
Group+(1|PID),family=poisson(link="log"),data=data[data[,"Group"]!=0,])
 
and I want to perform adjusted multiple comparisons:
 
SumTukey <- summary(glht(fit0, linfct= mcp(Group="Tukey")))
 
which gives beautiful output:
 
> SumTukey Simultaneous Tests for General Linear HypothesesMultiple Comparisons 
> of Means: Tukey ContrastsFit: glmer(formula = Fall ~ Group + (1 | PID), data 
> = data[data[, "Group"] != 0, ], family = poisson(link = "log"))Linear 
> Hypotheses:   Estimate Std. Error z value Pr(>|z|)2 - 1 == 0   0.5320 
> 0.5075   1.0480.7173 - 1 == 0   0.6554 0.5000   1.3110.5514 - 
> 1 == 0   0.9357 0.4655   2.0100.1813 - 2 == 0   0.1234 0.4174   
> 0.2960.9914 - 2 == 0   0.4037 0.3754   1.0750.7004 - 3 == 0   
> 0.2803 0.3651   0.7680.867(Adjusted p values reported -- single-step 
> method)
 
I want to add a column to the output (unadjusted p-values), but I don't see how 
this might be done. The output
is not a dataframe, nor is it a matix. 
> class(SumTukey)[1] "summary.glht" "glht"  

It is some class of objects that I don't understand and know nothing
about. How can I add a column to the output of SumTukey [a.k.a. 
summary(glht(fit0, linfct= mcp(Group="Tukey")))] ?
 
Thank you
John
 
 



John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 





Call

Call from mobile

Send SMS

Add to Skype

You'll need Skype CreditFree via Skype
John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 

Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@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.


[R] Add column to the output of summary(glht).

2016-06-24 Thread John Sorkin

I am trying to make the leap from an R users to an R aficionado . . .
 
I am trying to understand how add a column to the output of summary (and to 
understand how summary() works).
 
I have run a glmer
fit0 <- glmer(Fall ~ 
Group+(1|PID),family=poisson(link="log"),data=data[data[,"Group"]!=0,])
 
and I want to perform adjusted multiple comparisons:
 
SumTukey <- summary(glht(fit0, linfct= mcp(Group="Tukey")))
 
which gives beautiful output:
 
> SumTukey

 Simultaneous Tests for General Linear Hypotheses

Multiple Comparisons of Means: Tukey Contrasts


Fit: glmer(formula = Fall ~ Group + (1 | PID), data = data[data[, 
"Group"] != 0, ], family = poisson(link = "log"))

Linear Hypotheses:
   Estimate Std. Error z value Pr(>|z|)
2 - 1 == 0   0.5320 0.5075   1.0480.717
3 - 1 == 0   0.6554 0.5000   1.3110.551
4 - 1 == 0   0.9357 0.4655   2.0100.181
3 - 2 == 0   0.1234 0.4174   0.2960.991
4 - 2 == 0   0.4037 0.3754   1.0750.700
4 - 3 == 0   0.2803 0.3651   0.7680.867
(Adjusted p values reported -- single-step method)
 
I want to add a column to the output (unadjusted p-values), but I don't see how 
this might be done. The output
is not a dataframe, nor is it a matix. 
> class(SumTukey)
[1] "summary.glht" "glht"  

It is some class of objects that I don't understand and know nothing
about. How can I add a column to the output of SumTukey [a.k.a. 
summary(glht(fit0, linfct= mcp(Group="Tukey")))] ?
 
Thank you
John
 
 
John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 

Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@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.


[R] meaning of lm( y~., data=mydat ), is it a language feature, is it documented, is it supported?

2016-05-23 Thread John Sorkin
 
The syntax
mydat <- data.frame( y,x )
fit1 <- lm( y~., data=mydat )
appears to perform a multivariable regression of y on every non-y variable in 
the data frame mydat. I can not find this syntax (y~.) in R documentation. Is 
y~. a supported feature of the R language? Where can I find it documented? I 
would hate to write code that is dependent on a non-supported, non-documented 
language feature.
Thank you,
John
John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 

Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@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.


Re: [R] Antwort: Re: Re: sink(): Cannot open file

2016-05-10 Thread John Sorkin
George,
I do not know what operating system you are working with, but when I use sink() 
under windows, I need to specify a valid path which I don't see in your code. I 
might, for example specify:

sink("c:\myfile.txt")
 R code goes here
sink()

with the expectation that I would create a file myfile.txt that would contain 
the output of my R program.
 
John


John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 
>>>  05/10/16 11:10 AM >>>
Hi Jim,

I tried:

sink("all.Rout")
try(log("a"))
sink()

The program executes without warning or error. The file "all.Rout" is 
begin created. Nothing will be written to it. The file is accessable 
rights after the execution of the program by notepad.exe.

The program

zz <- file("all.Rout", open = "wt")
sink(zz, type = "message")
try(log("a"))
sink()
close(zz)
unlink(zz)

creates the file, does not write anything to it and is not accessable 
after program execution in R with notepad.exe.

Any ideas what happens behind the szenes?

Kind regards

Georg




Von: Jim Lemon 
An: g.maub...@weinwolf.de, 
Kopie: r-help mailing list 
Datum: 10.05.2016 13:16
Betreff: Re: Re: [R] sink(): Cannot open file



Have you tried:

sink("all.Rout")
try(log("a"))
sink()

Jim

On Tue, May 10, 2016 at 9:05 PM,  wrote:
> Hi Jim,
>
> thanks for your reply.
>
> ad 1)
> "all.Rout" was created in the correct directory. It exists properly with
> correct file properties on Windows, e.g. creation date and time and file
> size information.
>
> ad 2)
> I can not access the file with Notepad.exe directly after it was created
> by R. The error message is (translated):
>
> "Cannot access file "all.Rout". The file is opened by another process."
>
> ad 3)
> If I close R completely the file access is released. Then I can read the
> file using Notepad.exe. The contents is:
>
> Error in log("a") : non-numeric argument to mathematical function
>
> I tried
>
> close(zz)
>
> but the error persists.
>
> To me it looks like R is still accessing the file and not releasing the
> connection for other programs. close(zz) should have solved the problem
> but unfortantely it doesn't.
>
> What else could I try?
>
> Kind regards
>
> Georg
>
>
>
>
> Von: Jim Lemon 
> An: g.maub...@weinwolf.de,
> Kopie: r-help mailing list 
> Datum: 10.05.2016 12:50
> Betreff: Re: [R] sink(): Cannot open file
>
>
>
> Hi Georg,
> I don't suppose that you have:
>
> 1) checked that the file "all.Rout" exists somewhere?
>
> 2) if so, looked at the file with Notepad, perhaps?
>
> 3) let us in on the secret by pasting the contents of "all.Rout" into
> your message if it is not too big?
>
> At a guess, trying:
>
> close(zz)
>
> might get you there.
>
> Jim
>
> On Tue, May 10, 2016 at 5:25 PM,  wrote:
>> Hi All,
>>
>> I would like to route the output to a file using sink(). When using the
>> example from the ?sink documentation:
>>
>> sink("sink-examp.txt")
>> i <- 1:10
>> outer(i, i, "*")
>> sink()
>> unlink("sink-examp.txt")
>>
>> ## capture all the output to a file.
>> zz <- file("all.Rout", open = "wt")
>> sink(zz)
>> sink(zz, type = "message")
>> try(log("a"))
>> ## back to the console
>> sink(type = "message")
>> sink()
>> file.show("all.Rout")
>>
>> I can not open the file in Windows Explorer. The error message is:
>>
>> "Cannot open file. File is in use be another proces."
>>
>> How can I close the file in a manner that I can open it right after it
> was
>> created?
>>
>> Kind regards
>>
>> Georg
>>
>> __
>> R-help@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.
>
>

__
R-help@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.
Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@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, m

Re: [R] Trying to understand cut

2016-04-16 Thread John Sorkin
Jeff,
Perhaps I was sloppy with my notation:
I want groups
>=0 <10
>=10 <20
>=20<30
..
>=90 <100
 
In any event, my question remains, why did the four different versions of cut 
give me the same results? I hope someone can explain to me the function of 
include.lowest and right in the call to cut. As demonstrated in my example 
below, the parameters do not seem to alter the results of using cut.
Thank you,
John
 
 
P.S. How do I find FAQ 7.31?
Thank you,
John
 
I 



John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 
>>> Jeff Newmiller  04/16/16 11:07 PM >>>
Have you read FAQ 7.31 recently, John? Your whole premise is flawed. You should 
be thinking of ranges [0,10), [10,20), and so on because numbers ending in 0.9 
are never going to be exact. 
-- 
Sent from my phone. Please excuse my brevity.


On April 16, 2016 7:38:50 PM PDT, John Sorkin  
wrote:
I am trying to understand cut so I can divide a list of numbers into 10 group:
  0-9.0
10-10.9
20-20.9
30-30.9,
40-40.9,
50-50.9
60-60.9
70-70.9
80-80.9
90-90.9
 
As I try to do this, I have been playing with the cut function. Surprising the 
following for applications of cut give me the exact same groups. This surprises 
me given that I have varied parameters include.lowest and right. Can someone 
help me understand what include.lowest and right do? I have looked at the help 
page, but I don't seem to understand what I am being told!
Thank you,
John

values <- c((0:99),c(0.9:99.9))
sort(values)
c1<-cut(values,10,include.lowest=FALSE,right=TRUE)
c2<-cut(values,10,include.lowest=FALSE,right=FALSE)
c3<-cut(values,10,include.lowest=TRUE,right=TRUE)
c4<-cut(values,10,include.lowest=TRUE,right=FALSE)
cbind(min=aggregate(values,list(c1),min),max=aggregate(values,list(c1),max))
cbind(min=aggregate(values,list(c2),min),max=aggregate(values,list(c2),max))
cbind(min=aggregate(values,list(c3),min),max=aggregate(values,list(c3),max))
cbind(min=aggregate(values,list(c4),min),max=aggregate(values,list(c4),max))

You can run the code below, or inspect the results I got which are reproduced 
below:
 
 cbind(min=aggregate(values,list(c1),min),max=aggregate(values,list(c1),max))

  min.Group.1 min.xmax.Group.1 max.x
1  (-0.0999,9.91] 0 (-0.0999,9.91]   9.9
2 (9.91,19.9]10(9.91,19.9]  19.9
3 (19.9,29.9]20(19.9,29.9]  29.9
4 (29.9,39.9]30(29.9,39.9]  39.9
5   (39.9,50]40  (39.9,50]  49.9
6 (50,60]50(50,60]  59.9
7 (60,70]60(60,70]  69.9
8 (70,80]70(70,80]  79.9
9 (80,90]80(80,90]  89.9
10   (90,100]90   (90,100]  99.9
 cbind(min=aggregate(values,list(c2),min),max=aggregate(values,list(c2),max))

  min.Group.1 min.xmax.Group.1 max.x
1  [-0.0999,9.91) 0 [-0.0999,9.91)   9.9
2 [9.91,19.9)10[9.91,19.9)  19.9
3 [19.9,29.9)20[19.9,29.9)  29.9
4 [29.9,39.9)30[29.9,39.9)  39.9
5   [39.9,50)40  [39.9,50)  49.9
6 [50,60)50[50,60)  59.9
7 [60,70)60[60,70)  69.9
8 [70,80)70[70,80)  79.9
9 [80,90)80[80,90)  89.9
10   [90,100)90   [90,100)  99.9
 cbind(min=aggregate(values,list(c3),min),max=aggregate(values,list(c3),max))

  min.Group.1 min.xmax.Group.1 max.x
1  [-0.0999,9.91] 0 [-0.0999,9.91]   9.9
2 (9.91,19.9]10(9.91,19.9]  19.9
3 (19.9,29.9]20(19.9,29.9]  29.9
4 (29.9,39.9]30(29.9,39.9]  39.9
5   (39.9,50]40  (39.9,50]  49.9
6 (50,60]50(50,60]  59.9
7 (60,70]60(60,70]  69.9
8 (70,80]70(70,80]  79.9
9 (80,90]80(80,90]  89.9
10   (90,100]90   (90,100]  99.9
 cbind(min=aggregate(values,list(c4),min),max=aggregate(values,list(c4),max))

  min.Group.1 min.xmax.Group.1 max.x
1 [-0.0999,9.91) 0 [-0.0999,9.91)   9.9
2 [9.91,19.9)10[9.91,19.9)  19.9
3 [19.9,29.9)20[19.9,29.9)  29.9
4 [29.9,39.9)30[29.9,39.9)  39.9
5   [39.9,50)40  [39.9,50)  49.9
6 [50,60)50[50,60)  59.9
7 [60,70)60[60,70)  69.9
8 [70,80)70[70,80)  79.9
9 [80,90)80[80,90)  89.9
10   [90,100]90   [90,100]  99.9
John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore,

[R] Trying to understand cut

2016-04-16 Thread John Sorkin
I am trying to understand cut so I can divide a list of numbers into 10 group:
  0-9.0
10-10.9
20-20.9
30-30.9,
40-40.9,
50-50.9
60-60.9
70-70.9
80-80.9
90-90.9
 
As I try to do this, I have been playing with the cut function. Surprising the 
following for applications of cut give me the exact same groups. This surprises 
me given that I have varied parameters include.lowest and right. Can someone 
help me understand what include.lowest and right do? I have looked at the help 
page, but I don't seem to understand what I am being told!
Thank you,
John

values <- c((0:99),c(0.9:99.9))
sort(values)
c1<-cut(values,10,include.lowest=FALSE,right=TRUE)
c2<-cut(values,10,include.lowest=FALSE,right=FALSE)
c3<-cut(values,10,include.lowest=TRUE,right=TRUE)
c4<-cut(values,10,include.lowest=TRUE,right=FALSE)
cbind(min=aggregate(values,list(c1),min),max=aggregate(values,list(c1),max))
cbind(min=aggregate(values,list(c2),min),max=aggregate(values,list(c2),max))
cbind(min=aggregate(values,list(c3),min),max=aggregate(values,list(c3),max))
cbind(min=aggregate(values,list(c4),min),max=aggregate(values,list(c4),max))

You can run the code below, or inspect the results I got which are reproduced 
below:
 
> cbind(min=aggregate(values,list(c1),min),max=aggregate(values,list(c1),max))
  min.Group.1 min.xmax.Group.1 max.x
1  (-0.0999,9.91] 0 (-0.0999,9.91]   9.9
2 (9.91,19.9]10(9.91,19.9]  19.9
3 (19.9,29.9]20(19.9,29.9]  29.9
4 (29.9,39.9]30(29.9,39.9]  39.9
5   (39.9,50]40  (39.9,50]  49.9
6 (50,60]50(50,60]  59.9
7 (60,70]60(60,70]  69.9
8 (70,80]70(70,80]  79.9
9 (80,90]80(80,90]  89.9
10   (90,100]90   (90,100]  99.9
> cbind(min=aggregate(values,list(c2),min),max=aggregate(values,list(c2),max))
  min.Group.1 min.xmax.Group.1 max.x
1  [-0.0999,9.91) 0 [-0.0999,9.91)   9.9
2 [9.91,19.9)10[9.91,19.9)  19.9
3 [19.9,29.9)20[19.9,29.9)  29.9
4 [29.9,39.9)30[29.9,39.9)  39.9
5   [39.9,50)40  [39.9,50)  49.9
6 [50,60)50[50,60)  59.9
7 [60,70)60[60,70)  69.9
8 [70,80)70[70,80)  79.9
9 [80,90)80[80,90)  89.9
10   [90,100)90   [90,100)  99.9
> cbind(min=aggregate(values,list(c3),min),max=aggregate(values,list(c3),max))
  min.Group.1 min.xmax.Group.1 max.x
1  [-0.0999,9.91] 0 [-0.0999,9.91]   9.9
2 (9.91,19.9]10(9.91,19.9]  19.9
3 (19.9,29.9]20(19.9,29.9]  29.9
4 (29.9,39.9]30(29.9,39.9]  39.9
5   (39.9,50]40  (39.9,50]  49.9
6 (50,60]50(50,60]  59.9
7 (60,70]60(60,70]  69.9
8 (70,80]70(70,80]  79.9
9 (80,90]80(80,90]  89.9
10   (90,100]90   (90,100]  99.9
> cbind(min=aggregate(values,list(c4),min),max=aggregate(values,list(c4),max))
  min.Group.1 min.xmax.Group.1 max.x
1  [-0.0999,9.91) 0 [-0.0999,9.91)   9.9
2 [9.91,19.9)10[9.91,19.9)  19.9
3 [19.9,29.9)20[19.9,29.9)  29.9
4 [29.9,39.9)30[29.9,39.9)  39.9
5   [39.9,50)40  [39.9,50)  49.9
6 [50,60)50[50,60)  59.9
7 [60,70)60[60,70)  69.9
8 [70,80)70[70,80)  79.9
9 [80,90)80[80,90)  89.9
10   [90,100]90   [90,100]  99.9
John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 

Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@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.


[R] Microsoft R Server

2016-04-14 Thread John Sorkin
Has anyone ever heard of or used Microsoft R server? Does the product work? 
What are requirements for running it? How much does it cost and is it supported 
by the R community?
Thank you,
John
Confidentiality Statement:
This email message, including any attachments, is for th...{{dropped:6}}

__
R-help@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.


[R] Using a function with apply Error: undefined columns selected

2016-04-07 Thread John Sorkin
I am trying to write a function that can be used to apply to process all the 
columns of a data.frame. If you will run the code below, you will get the error 
message undefined columns selected. I hope someone will be able to teach me 
what I am doing wrong.
Thank you,
John 
 
# create data frame.
guppy
 
fract2 <- function(col,data) {
  cat("Prove we have passed the data frame\n")
  print(data)
  
  # Get the name of the column being processed.
  zz<-deparse(substitute(col))
  cat("Column being processed\n")
  print(zz)
  p<-sum(data[,zz]!="")/length(data[,zz])
  return(p)
}
 
apply(guppy,2,fract2,data=guppy)
John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 

Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@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.


[R] using apply to a data frame

2016-04-07 Thread John Sorkin

‪‪I would like to apply a function, fract, to the columns of a
dataframe. I tried the following 
apply(data5NonEventEpochs,2,fract)
but, no surprise it did not work as apply works on matrices not data
frames. How can I apply a fuction to the columns of a data frame? (I
can't covert data5NonEventsEpochs to a matrix as it contains character
data).
Thank you,
John
John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and
Geriatric Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 

Confidentiality Statement:
This email message, including any attachments, is for the sole use of
the intended recipient(s) and may contain confidential and privileged
information. Any unauthorized use, disclosure or distribution is
prohibited. If you are not the intended recipient, please contact the
sender by reply email and destroy all copies of the original message. 
__
R-help@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.

[R] Specifying path to a windows server

2016-04-05 Thread John Sorkin
Windows 7 (local computer)
Windows server (server I am trying to reach)
 
I need to read a file whose windows path is of the form
 
\\Theserver\mydirectory\data.csv
 
You will note that as per windows standards the server name is preceded by two 
backslashes.
 
I am not sure how to specify this in R.  One usually needs to specify an escape 
characters in a path new which would suggest my path should be
 
 
\\\Theserver\\mydirectory\\data.csv
 
This does not work; the file is not found.
 
What is the correct way to specify a path to a server
 
Thanks,
John

 
John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 

Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@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.


[R] p values from GLM

2016-04-01 Thread John Sorkin
How can I get the p values from a glm ? I want to get the p values so I can add 
them to a custom report
 
 
 fitwean<- glm(data[,"JWean"]~data[,"Group"],data=data,family=binomial(link 
="logit"))
 summary(fitwean) # This lists the coefficeints, SEs, z and p 
values, but I can't isolate the pvalues.
 names(summary(fitwean))  # I see the coefficients, but not the p values
 names(fitmens)  # p values are not found here.
 
Thank you!
John
 
John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 

Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@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.


Re: [R] Calculate negative log of the E-Values in R

2016-02-26 Thread John Sorkin
Actually  E is not "just a computer way of saying 0". The E represents a power 
of 10, thus E-1 = 0.1 e-2=0.01; E therefore is not zero. Because computers 
generally can not perform exact calculations (for reasons including the fact 
that our number system is base 10 and a computer's is generally base 2) what 
might otherwise be a zero is often represented by a very small number such as 
the one you listed. 4E-108 would be 4x10^-108, a very small number indeed that 
is (for most but not all purposes) the same as zero.
John 

> John David Sorkin M.D., Ph.D.
> Professor of Medicine
> Chief, Biostatistics and Informatics
> University of Maryland School of Medicine Division of Gerontology and 
> Geriatric Medicine
> Baltimore VA Medical Center
> 10 North Greene Street
> GRECC (BT/18/GR)
> Baltimore, MD 21201-1524
> (Phone) 410-605-7119
> (Fax) 410-605-7913 (Please call phone number above prior to faxing)


> On Feb 26, 2016, at 12:29 PM, Francesco Romano 
>  wrote:
> 
> Sema, E is just a computer way of saying 0. For the purpose of statistical
> analysis, if you can't compute a calculation with E values (i.e. 0),
> substitute all E values with a usable constant, say 50. I stumbled across a
> few websites lately that did this.
> 
> Frank Romano Ph.D.
> 
> *Academia.edu*
> https://sheffield.academia.edu/FrancescoRomano
> 
> 
> On Fri, Feb 26, 2016 at 10:53 AM, Sema Atasever 
> wrote:
> 
>> Dear Authorized Sir / Madam,
>> 
>> If you don't mind, I want to ask how can i calculate negative log of the
>> E-Values in R.
>> 
>> *For Example: *
>> What is the negative log of the 4e-108?
>> 
>> I would appreciate if you could advise me some methods.
>> 
>> Thanks in advance.
>> 
>>[[alternative HTML version deleted]]
>> 
>> __
>> R-help@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]]
> 
> __
> R-help@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.

Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@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.


[R] normalmixEM gives widely divergent results.

2016-01-27 Thread John Sorkin
I am running normalmixEM:
mixmdlscaled <- normalmixEM(data$FCWg)
summary(mixmdlscaled)
plot(mixmdlscaled,which=2)
 
If I run the program multiple times, I get widely different results:
 
> mixmdlscaled <- normalmixEM(data$FCWg)
number of iterations= 41 
> summary(mixmdlscaled)
summary of normalmixEM object:
  comp 1   comp 2
lambda 0.0818928 0.918107
mu 0.6575938 0.740870
sigma  0.0070562 0.178410
loglik at estimate:  56.87445 
> plot(mixmdlscaled,which=2)
> mixmdlscaled <- normalmixEM(data$FCWg)
number of iterations= 357 
> summary(mixmdlscaled)
summary of normalmixEM object:
 comp 1comp 2
lambda 0.959912 0.0400879
mu 0.722022 1.0220719
sigma  0.165454 0.0131391
loglik at estimate:  53.66051 
> plot(mixmdlscaled,which=2)

 
 
I understand that when run without specifying various parameters (e.g. mu, or 
sigma) values are chosen randomly from a normal distribution with center(s) 
determined from binning the data. Despite this, would not one expect the 
results to be similar? If one is not to expect similar results, how can I get a 
solution in which I can have confidence? Should I run the program multiple 
times and take the average of the results? Should I look for the solution with 
the best log likelihood?  
 
Thank you,
John
John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 

Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@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.


Re: [R] R-help mailing list activity / R-not-help?

2016-01-25 Thread John Sorkin
I submit it is up to list members to maintain civility. If we politely point 
out. off-line, to people who post questionable posts what they are doing, I am 
sure their behavior will quickly change.John 


John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 

>>> Peter Alspach  01/25/16 5:33 PM >>>
I think this would be re-defining the role of the moderators for list, which is 
essentially to filter out spam.  Only new members are subject to this 
moderation, and if a message is genuine then their moderator flag is cleared 
(i.e., they are no longer subject to moderation).  Thus the list isn't 
moderated in the 'usual' sense.

That said, I have occasionally asked a new poster to reword their question (or 
simply add a subject line) and explained that this helps ensure they get a good 
answer, and not a rude one.  Mostly people seem to appreciate that.

Peter Alspach
(one of the 'moderators')

-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Oliver Keyes
Sent: Tuesday, 26 January 2016 10:23 a.m.
To: Duncan Murdoch 
Cc: r-help 
Subject: Re: [R] R-help mailing list activity / R-not-help?

Sorry, poor phrasing on my part; on the occasions where someone is rude, all I 
see is...

I agree the public cautioning should be done by moderators, yes.

On 25 January 2016 at 16:13, Duncan Murdoch  wrote:
> On 25/01/2016 3:33 PM, Hasan Diwan wrote:
>>
>> There exists a fine line between being unintentionally rude, but 
>> helpful and purposely putting someone down. -- H
>
>
> I'm afraid I don't think your point is relevant.  I didn't claim all 
> the people who were rude did it unintentionally.  However,  I don't 
> know anyone on the list who is always rude and never helpful. Oliver 
> claimed almost everyone is like that.
>
> I actually agree with a weaker version of John's proposal (which I cut 
> out of my reply to Oliver).  I can imagine a public reprimand from one 
> of the moderators would be appropriate.  It would never be appropriate 
> from general list members; that's what leads to flame wars.
>
> I'm not a moderator, so I would not publicly "remind the poster to 
> reply in a more moderate tone", and neither should you (unless you're a 
> moderator).
> It would be much better if one or both of us posted a more helpful 
> response when we saw a rude, unhelpful one.
>
> Duncan Murdoch
>
>
>>
>> On 25 January 2016 at 12:07, Duncan Murdoch 
>> 
>> wrote:
>>
>> > On 25/01/2016 2:45 PM, Oliver Keyes wrote:
>> >
>> >> I disagree, and would argue that fails to take a systemic view of 
>> >> this kind of behaviour.
>> >>
>> >> If individual commentators are acerbic and are only privately 
>> >> reprimanded, from the perspective of everyone else it looks like 
>> >> the acerbic reply was A-OK. Someone said something unnecessarily 
>> >> hostile and the response was...nada. That creates an environment 
>> >> where there are no clear examples of what crosses a line and no 
>> >> clear expectation that moderation is even a thing that happens. 
>> >> Indeed, I was shocked to discover this list _was_ moderated 
>> >> precisely because all I see is people being mean and nothing much else 
>> >> happening.
>> >>
>> >
>> > Why would you bother to read it if that's all you see?  I think 
>> > there are examples of posts here which are not at all helpful, and 
>> > others which are rude, but the majority are actually helpful (even 
>> > some of the rude ones).
>> >
>> > Duncan Murdoch
>> >
>> >
>> > __
>> > R-help@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.
>> >
>>
>>
>>
>
> __
> R-help@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.



--
Oliver Keyes
Count Logula
Wikimedia Foundation

__
R-help@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.
The contents of this e-mail are confidential and may be ...{{dropped:14}}

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
htt

Re: [R] R-help mailing list activity / R-not-help?

2016-01-25 Thread John Sorkin
When we read acerbic replies we should remind the poster to reply in a more 
moderate tone. On the other hand  noting that the list is not intended to be a 
source of answers to home work questions is 100% appropriate. This philosophy 
is intended both to keep the list from being flooded with questions and to make 
sure that no student has an unfair advantage.
John 

> John David Sorkin M.D., Ph.D.
> Professor of Medicine
> Chief, Biostatistics and Informatics
> University of Maryland School of Medicine Division of Gerontology and 
> Geriatric Medicine
> Baltimore VA Medical Center
> 10 North Greene Street
> GRECC (BT/18/GR)
> Baltimore, MD 21201-1524
> (Phone) 410-605-7119
> (Fax) 410-605-7913 (Please call phone number above prior to faxing)


> On Jan 25, 2016, at 12:17 PM, Ted Harding  wrote:
> 
> My feelings exactly! (And since quite some time ago).
> Ted.
> 
>> On 25-Jan-2016 12:23:16 Fowler, Mark wrote:
>> I'm glad to see the issue of negative feedback addressed. I can especially
>> relate to the 'cringe' feeling when reading some authoritarian backhand to a
>> new user. We do see a number of obviously inappropriate or overly lazy
>> postings, but I encounter far more postings where I don't feel competent to
>> judge their merit. It might be better to simply disregard a posting one does
>> not like for some reason. It might also be worthwhile to actively counter
>> negative feedback when we experience that 'cringing' moment. I'm not thinking
>> to foster contention, but simply to provide some tangible reassurance to new
>> users, and not just the ones invoking the negative feedback, that a
>> particular respondent may not represent the perspective of the list.
>> 
>> -Original Message-
>> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Michael
>> Friendly
>> Sent: January 24, 2016 5:43 PM
>> To: Jean-Luc Dupouey; r-help@r-project.org
>> Subject: Re: [R] R-help mailing list activity / R-not-help?
>> 
>> 
>>> On 1/23/2016 7:28 AM, Jean-Luc Dupouey wrote:
>>> Dear members,
>>> 
>>> Not a technical question:
>> But one worth raising...
>>> 
>>> The number of threads in this mailing list, following a long period of 
>>> increase, has been regularly and strongly decreasing since 2010, 
>>> passing from more than 40K threads to less than 11K threads last year. 
>>> The trend is similar for most of the "ancient" mailing lists of the
>>> R-project.
>> [snip ...]
>>> 
>>> I hope it is the wright place to ask this question. Thanks in advance,
>> 
>> In addition to the other replies, there is another trend I've seen that has
>> actively worked to suppress discussion on R-help and move it elsewhere. The
>> general things:
>> - R-help was too unwieldy and so it was a good idea to hive-off specialized
>> topics to various sub lists, R-SIG-Mac, R-SIG-Geo, etc.
>> - Many people posted badly-formed questions to R-help, and so it was a good
>> idea to develop and refer to the posting guide to mitigate the number of
>> purely junk postings.
>> 
>> 
>> Yet, the trend I've seen is one of increasing **R-not-help**, in that there
>> are many posts, often by new R users who get replies that not infrequently
>> range from just mildly off-putting to actively hostile:
>> 
>> - Is this homework? We don't do homework (sometimes false alarms, where the
>> OP has to reply to say it is not)
>> - Didn't you bother to do your homework, RTFM, or Google?
>> - This is off-topic because XXX (e.g., it is not strictly an R programming
>> question).
>> - You asked about doing XXX, but this is a stupid thing to want to do.
>> - Don't ask here; you need to talk to a statistical consultant.
>> 
>> I find this sad in a public mailing list sent to all R-help subscribers and I
>> sometimes cringe when I read replies to people who were actually trying to
>> get help with some R-related problem, but expressed it badly, didn't know
>> exactly what to ask for, or how to format it, or somehow motivated a
>> frequent-replier to publicly dis the OP.
>> 
>> On the other hand, I still see a spirit of great generosity among some people
>> who frequently reply to R-help, taking a possibly badly posed or
>> ill-formatted question, and going to some lengths to provide a a helpful
>> answer of some sort.  I applaud those who take the time and effort to do
>> this.
>> 
>> I use R in a number of my courses, and used to advise students to post to
>> R-help for general programming questions (not just homework) they couldn't
>> solve. I don't do this any more, because several of them reported a negative
>> experience.
>> 
>> In contrast, in the Stackexchange model, there are numerous sublists
>> cross-classified by their tags.  If I have a specific knitr, ggplot2, LaTeX,
>> or statistical modeling question, I'm now more likely to post it there, and
>> the worst that can happen is that no one "upvotes" it or someone (helpfully)
>> marks it as a duplicate of a similar question.
>> But comments there are not propagated to all subscribers, and th

[R] Trying to use name of difference variable created in a function in call to wilcox.test function.

2016-01-12 Thread John Sorkin
I am trying to write a function which will allow me to analyze many variables 
all of which have the same form, Base.stem and Disch.stem, where stem varies 
from variable to variable, e.g. Base.rolling and Disch.rolling, Base.standing, 
Disch.standing. 
 
I want to pass a dataframe and the stem of the name of the pre and post 
intervention variables. In my function I create the full pre and post 
intervention Base.stem and Disch.stem variables names (by using the paste 
function, varpre=paste("Base.",stem,sep="") and 
varpost=paste("Disch.",stem,sep="")). I also create and add to the dataframe 
the change variable (i.e. post-pre) formed as ch<-paste("Change.",stem,sep="") 
and compute the change in the variable:
data[,ch]=data[,varpo]-data[,varpre]. 
 
If, for example, I run the function doit(rolling, data), the function creates 
the full pre-intervention variable name Base.rolling, the post-intervention 
variable name Disch.rolling, and computes Change.rolling = 
Disch.rolling-Base.rolling. I want to use Change.rolling in a function, but I 
don't want to have to expressly specify the name of the outcome variable, i.e.
 
  fitwilcox<-wilcox.test(Change.rolling~RANDOMIZED,data=data,na.action=na.omit)
 
I want to specify the constructed variable, i.e.
 
 fitwilcox<-wilcox.test(ch~RANDOMIZED,data=data,na.action=na.omit)
 
This does not work because ch is not in the dataframe, but Change.rolling is. 
How can I modify the call to the Wilcox.test function so I can specify the 
change variable constructor. I tried the following but it does not work:
 
 fitwilcox<-wilcox.test(eval(ch, 
parent.frame())~RANDOMIZED,data=data,na.action=na.omit) 
 
DATA:
 
> dput(data2)structure(list(Subj = c(115, 116, 117, 118, 119, 120, 121, 122, 
> 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 
> 138, 139, 140, 141, 142, 143, 144, 145, 146, 147), RANDOMIZED = c(1, 1, 
> 2, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 2, 1, 1, 2, 2, 1, 2, 1, 1, 2, 2, 1, 2, 
> 1, 2, 2, 2, 2, 2, 2), Base.rolling = c(0, 6, 6, 3, 3, 1, 4, 6, 4, 6, 4, 
> 1, 3, NA, 1, 2, 4, 1, 4, 4, 4, 1, 5, 3, 2, 3, 1, 4, 0, 4, 1, NA, 3), 
> Disch.rolling = c(6, NA, NA, 6, 6, 3, 6, 6, 6, NA, NA, 6, 1, NA, 6, 6, 6, 
> NA, 6, 6, 6, NA, 4, NA, 6, 6, NA, 6, NA, 6, 6, NA, NA)), .Names = 
> c("Subj", "RANDOMIZED", "Base.rolling", "Disch.rolling"), class = 
> "data.frame", row.names = c(NA, -33L))

 
CODE:

doit <- function(var,data){
  var <-deparse(substitute(var))
  print(var)
  # Create name for basline variable.
  varpre<-paste("Base.",var,sep="")
  # Create name for post variable.
  varpo<-paste("Disch.",var,sep="")
  # Create a name for the change variable.
  ch<-paste("Change.",var,sep="")
  print(ch)
  # Compute change.
  data[,ch]=data[,varpo]-data[,varpre]
  
  cat("\nData used in the analyses\n")
  print(data[,c("Subj","RANDOMIZED",ch)])
  # This works when I expressly specify the change variable.
  cat("This works, expressly specify change variable\n")
  fitwilcox1<-wilcox.test(Change.rolling~RANDOMIZED,data=data,na.action=na.omit)
  print(fitwilcox1)
  
  # This does not work.
  cat("This does NOT work, try to use created change variable.\n")
  fitwilcox2<-wilcox.test(eval(ch, 
parent.frame())~RANDOMIZED,data=data,na.action=na.omit)
  print(fitwilcox2)
  # Compute wilcoxon statistic.
}
doit(rolling,data2)
 
 
Thank you,
John
John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 

Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@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.


[R] error using by(goop[, c("a", "b", "c")], goop[, "Arm"], mySD) was Re: by gives no results, gives warning that data are non-numeric, but the data appears to be numeric.

2015-12-28 Thread John Sorkin

I am  trying to use the by function to get the SD of each column of a data 
frame, stratified by ARM. Using a suggestion provided by both William Dunlap 
and Rolf Turner, I have written the code below which fails with the error:
Error in match.fun(FUN) :   'sqrt(var(x))' is not a function, character or 
symbol

 
code:
mySD <- function(x) {sapply(x,sqrt(var(x)))}
class(mySD)
by(goop[,c("a","b","c")],goop[,"Arm"],mySD)
 
Below I include code which will create goop (thank you Bill for suggesting I 
use dput), which will run will recreate mmy error. Any thoughts on why the by 
function fails and how to fix it would be appreciated.
 
Thank you,
John
 
goop <- structure(c(180L, 153L, 149L, 218L, 217L, 147L, 141L, 141L, 174L, 
162L, 163L, 206L, 168L, 227L, 142L, 179L, 270L, 206L, 243L, 
134L, 
131L, 222L, 142L, 119L, 149L, 190L, 196L, 145L, 185L, 235L, 
165L, 
246L, 152L, 186L, 222L, 248L, 125L, 149L, 233L, 145L, 154L, 
231L, 
146L, 161L, 150L, 133L, 115L, 145L, 180L, 202L, 158L, 210L, 
153L, 
136L, 265L, 255L, 199L, 131L, 110L, 169L, 147L, 133L, 108L, 
203L, 
185L, 153L, 154L, 207L, 167L, 233L, 135L, 127L, 197L, 245L, 
124L, 
125L, 146L, 139L, 158L, 211L, 183L, 169L, 137L, 114L, 176L, 
143L, 
156L, 209L, 163L, 194L, 151L, 238L, 253L, 293L, 208L, 147L, 
186L, 
179L, 150L, 203L, 112L, 185L, 156L, 127L, 132L, 243L, 177L, 
242L, 
144L, 140L, 194L, 249L, 109L, 91L, 10163L, 10987L, 19882L, 
19899L, 
20104L, 20105L, 20167L, 20318L, 20338L, 20392L, 20453L, 
20454L, 
20467L, 20500L, 20682L, 20687L, 20692L, 20744L, 20750L, 
20751L, 
20806L, 20848L, 20856L, 20959L, 21023L, 21048L, 21114L, 
21134L, 
21135L, 21320L, 21329L, 21349L, 21353L, 21521L, 21663L, 
21784L, 
22031L, 22081L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 2L, 
2L, 
2L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 2L, 
1L, 
2L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 2L, 2L), .Dim = c(38L, 5L), 
.Dimnames = list(
  NULL, c("a", "b", "c", "ID", "Arm")), na.action = 
structure(37, class = "omit"))
goop
mySD <- function(x) {sapply(x,sqrt(var(x)))}
class(mySD)
by(goop[,c("a","b","c")],goop[,"Arm"],mySD)

 
 
 


 
John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 

Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@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.


Re: [R] by gives no results, gives warning that data are non-numeric, but the data appears to be numeric.

2015-12-28 Thread John Sorkin
Thank you,
John



John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 
>>> William Dunlap  12/28/15 12:55 AM >>>

by(dataFrame, groupId, FUN) applies FUN a bunch of data.frames (row subsetsof 
the dataFrame input).  mean() returns NA for data.frames.  You could use
FUN=colMeans if you wanted column means or FUN=function(x)mean(colMeans(x))
or FUN=function(x)mean(unlist(x)) if you wanted some version of a grand mean
over all the columns.

If you want column means, you may find aggregate() more suited to the job, as it
applies FUN to each column in each row subset of the data and returns a 
data.frame
instead of a list of outputs of FUN.
  > aggregate(mtcars[,3:5], mtcars[,2,drop=FALSE], mean)
cyl disphp drat
  1   4 105.1364  82.63636 4.070909
  2   6 183.3143 122.28571 3.585714
  3   8 353.1000 209.21429 3.229286







Bill Dunlap
TIBCO Software
wdunlap tibco.com



On Sun, Dec 27, 2015 at 6:55 PM, John Sorkin  
wrote:

When I run by, I get an error message and no results. Any help in understanding 
what is wrong would be appreciated.

Error message:
Warning messages:
1: In mean.default(data[x, , drop = FALSE], ...) :
  argument is not numeric or logical: returning NA
2: In mean.default(data[x, , drop = FALSE], ...) :
  argument is not numeric or logical: returning NA


Results:
Arm: MUFA
[1] NA
---
Arm: PUFA
[1] NA

Code:
by(hold,Arm,mean,na.rm=TRUE)

I don't understand why I am getting the error message, and why I am not getting 
any results. I don't believe my data are non-numeric.

BY str works fine and confirms that the data are numeric
> by(hold,Arm,str)
'data.frame':   23 obs. of  3 variables:
 $ Wtscr: num  97.2 103.9 58.2 130.9 135 ...
 $ Wt0  : num  96.2 106.1 56.7 127.4 133.1 ...
 $ Wt6  : num  93.8 101.7 55.5 127.6 130.9 ...
'data.frame':   16 obs. of  3 variables:
 $ Wtscr: num  120.2 104.6 100.1 74.8 112.6 ...
 $ Wt0  : num  117.2 105.3 99.5 75.7 110.7 ...
 $ Wt6  : num  114.6 104.8 84.5 77.7 107.4 ...
 Here is a listing of my data:
> hold
   Wtscr   Wt0Wt6
1  120.2 117.2 114.60
2  104.6 105.3 104.80
3   97.2  96.2  93.80
4  103.9 106.1 101.70
5   58.2  56.7  55.50
6  130.9 127.4 127.60
7  135.0 133.1 130.90
8  100.1  99.5  84.50
9  130.3 115.3 115.80
10 150.5 148.7 133.40
11  74.8  75.7  77.70
12 112.6 110.7 107.40
13  90.0  91.0  83.40
14 139.1 138.5 126.70
15  99.1  96.4  95.70
16 108.3 107.5 109.30
17  75.1  72.9  72.20
18  97.5 102.1  98.50
19 202.2  90.1  90.60
20  91.7  89.4  93.40
21 102.1 102.2 100.80
22 116.9 118.9 118.00
23  94.6  95.3  90.30
24 122.2 117.0 117.00
25 105.6 103.3 103.60
26  96.9  96.8  98.80
27 102.9 100.3  89.00
28 115.8 118.5 117.30
29  95.7  96.2  95.40
30  88.2  86.9  88.30
31 108.7 108.8 108.80
32  89.2  88.6  81.20
33  86.8  86.5  82.70
34 135.5 130.1 125.40
35 112.5 113.9 111.45
36 111.0 105.3 109.50
37 103.4 100.5  95.50
38 117.6 117.4 101.40
39 116.7 118.5 101.80

The INDEX is clearly a factor:
> Arm
 [1] PUFA PUFA MUFA MUFA MUFA MUFA MUFA PUFA MUFA MUFA PUFA PUFA PUFA MUFA MUFA 
PUFA PUFA PUFA MUFA MUFA MUFA MUFA MUFA PUFA MUFA MUFA PUFA MUFA PUFA MUFA PUFA
[32] MUFA MUFA MUFA MUFA MUFA PUFA PUFA PUFA
Levels: MUFA PUFA

The data and the index have the same length:
> cbind(hold,Arm)
   Wtscr   Wt0Wt6  Arm
1  120.2 117.2 114.60 PUFA
2  104.6 105.3 104.80 PUFA
3   97.2  96.2  93.80 MUFA
4  103.9 106.1 101.70 MUFA
5   58.2  56.7  55.50 MUFA
6  130.9 127.4 127.60 MUFA
7  135.0 133.1 130.90 MUFA
8  100.1  99.5  84.50 PUFA
9  130.3 115.3 115.80 MUFA
10 150.5 148.7 133.40 MUFA
11  74.8  75.7  77.70 PUFA
12 112.6 110.7 107.40 PUFA
13  90.0  91.0  83.40 PUFA
14 139.1 138.5 126.70 MUFA
15  99.1  96.4  95.70 MUFA
16 108.3 107.5 109.30 PUFA
17  75.1  72.9  72.20 PUFA
18  97.5 102.1  98.50 PUFA
19 202.2  90.1  90.60 MUFA
20  91.7  89.4  93.40 MUFA
21 102.1 102.2 100.80 MUFA
22 116.9 118.9 118.00 MUFA
23  94.6  95.3  90.30 MUFA
24 122.2 117.0 117.00 PUFA
25 105.6 103.3 103.60 MUFA
26  96.9  96.8  98.80 MUFA
27 102.9 100.3  89.00 PUFA
28 115.8 118.5 117.30 MUFA
29  95.7  96.2  95.40 PUFA
30  88.2  86.9  88.30 MUFA
31 108.7 108.8 108.80 PUFA
32  89.2  88.6  81.20 MUFA
33  86.8  86.5  82.70 MUFA
34 135.5 130.1 125.40 MUFA
35 112.5 113.9 111.45 MUFA
36 111.0 105.3 109.50 MUFA
37 103.4 100.5  95.50 PUFA
38 117.6 117.4 101.40 PUFA
39 116.7 118.5 101.80 PUFA

But the by function does not work!
> by(hold,Arm,mean,na.rm=TRUE)
Arm: MUFA
[1] NA
---
Ar

Re: [R] by gives no results, gives warning that data are non-numeric, but the data appears to be numeric.

2015-12-27 Thread John Sorkin
Rolf,
Thank you!
John

> John David Sorkin M.D., Ph.D.
> Professor of Medicine
> Chief, Biostatistics and Informatics
> University of Maryland School of Medicine Division of Gerontology and 
> Geriatric Medicine
> Baltimore VA Medical Center
> 10 North Greene Street
> GRECC (BT/18/GR)
> Baltimore, MD 21201-1524
> (Phone) 410-605-7119
> (Fax) 410-605-7913 (Please call phone number above prior to faxing)


> On Dec 27, 2015, at 10:40 PM, Rolf Turner  wrote:
> 
> 
> You are trying to take the mean of data frames.  There is no 
> "data.frame" method for mean().
> 
> Try:
> 
> by(hold,Arm,function(x){sapply(x,mean)})
> 
> 
> BTW what's the point of "na.rm=TRUE" in your call?  There are no missing 
> values in the data that you present.
> 
> In future, please use dput() to present your data; it makes life a lot 
> easier for respondents.
> 
> cheers,
> 
> Rolf
> 
> -- 
> Technical Editor ANZJS
> Department of Statistics
> University of Auckland
> Phone: +64-9-373-7599 ext. 88276
> 
>> On 28/12/15 15:55, John Sorkin wrote:
>> When I run by, I get an error message and no results. Any help in 
>> understanding what is wrong would be appreciated.
>> 
>> Error message:
>> Warning messages:
>> 1: In mean.default(data[x, , drop = FALSE], ...) :
>>   argument is not numeric or logical: returning NA
>> 2: In mean.default(data[x, , drop = FALSE], ...) :
>>   argument is not numeric or logical: returning NA
>> 
>> 
>> Results:
>> Arm: MUFA
>> [1] NA
>> ---
>> Arm: PUFA
>> [1] NA
>> 
>> Code:
>> by(hold,Arm,mean,na.rm=TRUE)
>> 
>> I don't understand why I am getting the error message, and why I am not 
>> getting any results. I don't believe my data are non-numeric.
>> 
>> BY str works fine and confirms that the data are numeric
>>> by(hold,Arm,str)
>> 'data.frame':23 obs. of  3 variables:
>>  $ Wtscr: num  97.2 103.9 58.2 130.9 135 ...
>>  $ Wt0  : num  96.2 106.1 56.7 127.4 133.1 ...
>>  $ Wt6  : num  93.8 101.7 55.5 127.6 130.9 ...
>> 'data.frame':16 obs. of  3 variables:
>>  $ Wtscr: num  120.2 104.6 100.1 74.8 112.6 ...
>>  $ Wt0  : num  117.2 105.3 99.5 75.7 110.7 ...
>>  $ Wt6  : num  114.6 104.8 84.5 77.7 107.4 ...
>>  Here is a listing of my data:
>>> hold
>>Wtscr   Wt0Wt6
>> 1  120.2 117.2 114.60
>> 2  104.6 105.3 104.80
>> 3   97.2  96.2  93.80
>> 4  103.9 106.1 101.70
>> 5   58.2  56.7  55.50
>> 6  130.9 127.4 127.60
>> 7  135.0 133.1 130.90
>> 8  100.1  99.5  84.50
>> 9  130.3 115.3 115.80
>> 10 150.5 148.7 133.40
>> 11  74.8  75.7  77.70
>> 12 112.6 110.7 107.40
>> 13  90.0  91.0  83.40
>> 14 139.1 138.5 126.70
>> 15  99.1  96.4  95.70
>> 16 108.3 107.5 109.30
>> 17  75.1  72.9  72.20
>> 18  97.5 102.1  98.50
>> 19 202.2  90.1  90.60
>> 20  91.7  89.4  93.40
>> 21 102.1 102.2 100.80
>> 22 116.9 118.9 118.00
>> 23  94.6  95.3  90.30
>> 24 122.2 117.0 117.00
>> 25 105.6 103.3 103.60
>> 26  96.9  96.8  98.80
>> 27 102.9 100.3  89.00
>> 28 115.8 118.5 117.30
>> 29  95.7  96.2  95.40
>> 30  88.2  86.9  88.30
>> 31 108.7 108.8 108.80
>> 32  89.2  88.6  81.20
>> 33  86.8  86.5  82.70
>> 34 135.5 130.1 125.40
>> 35 112.5 113.9 111.45
>> 36 111.0 105.3 109.50
>> 37 103.4 100.5  95.50
>> 38 117.6 117.4 101.40
>> 39 116.7 118.5 101.80
>> 
>> The INDEX is clearly a factor:
>>> Arm
>>  [1] PUFA PUFA MUFA MUFA MUFA MUFA MUFA PUFA MUFA MUFA PUFA PUFA PUFA MUFA 
>> MUFA PUFA PUFA PUFA MUFA MUFA MUFA MUFA MUFA PUFA MUFA MUFA PUFA MUFA PUFA 
>> MUFA PUFA
>> [32] MUFA MUFA MUFA MUFA MUFA PUFA PUFA PUFA
>> Levels: MUFA PUFA
>> 
>> The data and the index have the same length:
>>> cbind(hold,Arm)
>>Wtscr   Wt0Wt6  Arm
>> 1  120.2 117.2 114.60 PUFA
>> 2  104.6 105.3 104.80 PUFA
>> 3   97.2  96.2  93.80 MUFA
>> 4  103.9 106.1 101.70 MUFA
>> 5   58.2  56.7  55.50 MUFA
>> 6  130.9 127.4 127.60 MUFA
>> 7  135.0 133.1 130.90 MUFA
>> 8  100.1  99.5  84.50 PUFA
>> 9  130.3 115.3 115.80 MUFA
>> 10 150.5 148.7 133.40 MUFA
>> 11  74.8  75.7  77.70 PUFA
>> 12 112.6 110.7 107.40 PUFA
>> 13  90.0  91.0  83.40 PUFA
>> 14 139.1 138.5 126.70 MUFA
>> 15  99.1  96.4  95.70 MUFA
>> 16 

[R] by gives no results, gives warning that data are non-numeric, but the data appears to be numeric.

2015-12-27 Thread John Sorkin
When I run by, I get an error message and no results. Any help in understanding 
what is wrong would be appreciated.
 
Error message:
Warning messages:
1: In mean.default(data[x, , drop = FALSE], ...) :
  argument is not numeric or logical: returning NA
2: In mean.default(data[x, , drop = FALSE], ...) :
  argument is not numeric or logical: returning NA

 
Results:
Arm: MUFA
[1] NA
---
 
Arm: PUFA
[1] NA

Code:
by(hold,Arm,mean,na.rm=TRUE)

I don't understand why I am getting the error message, and why I am not getting 
any results. I don't believe my data are non-numeric. 

BY str works fine and confirms that the data are numeric
> by(hold,Arm,str)
'data.frame':   23 obs. of  3 variables:
 $ Wtscr: num  97.2 103.9 58.2 130.9 135 ...
 $ Wt0  : num  96.2 106.1 56.7 127.4 133.1 ...
 $ Wt6  : num  93.8 101.7 55.5 127.6 130.9 ...
'data.frame':   16 obs. of  3 variables:
 $ Wtscr: num  120.2 104.6 100.1 74.8 112.6 ...
 $ Wt0  : num  117.2 105.3 99.5 75.7 110.7 ...
 $ Wt6  : num  114.6 104.8 84.5 77.7 107.4 ...
 Here is a listing of my data:
> hold
   Wtscr   Wt0Wt6
1  120.2 117.2 114.60
2  104.6 105.3 104.80
3   97.2  96.2  93.80
4  103.9 106.1 101.70
5   58.2  56.7  55.50
6  130.9 127.4 127.60
7  135.0 133.1 130.90
8  100.1  99.5  84.50
9  130.3 115.3 115.80
10 150.5 148.7 133.40
11  74.8  75.7  77.70
12 112.6 110.7 107.40
13  90.0  91.0  83.40
14 139.1 138.5 126.70
15  99.1  96.4  95.70
16 108.3 107.5 109.30
17  75.1  72.9  72.20
18  97.5 102.1  98.50
19 202.2  90.1  90.60
20  91.7  89.4  93.40
21 102.1 102.2 100.80
22 116.9 118.9 118.00
23  94.6  95.3  90.30
24 122.2 117.0 117.00
25 105.6 103.3 103.60
26  96.9  96.8  98.80
27 102.9 100.3  89.00
28 115.8 118.5 117.30
29  95.7  96.2  95.40
30  88.2  86.9  88.30
31 108.7 108.8 108.80
32  89.2  88.6  81.20
33  86.8  86.5  82.70
34 135.5 130.1 125.40
35 112.5 113.9 111.45
36 111.0 105.3 109.50
37 103.4 100.5  95.50
38 117.6 117.4 101.40
39 116.7 118.5 101.80

The INDEX is clearly a factor: 
> Arm
 [1] PUFA PUFA MUFA MUFA MUFA MUFA MUFA PUFA MUFA MUFA PUFA PUFA PUFA MUFA MUFA 
PUFA PUFA PUFA MUFA MUFA MUFA MUFA MUFA PUFA MUFA MUFA PUFA MUFA PUFA MUFA PUFA
[32] MUFA MUFA MUFA MUFA MUFA PUFA PUFA PUFA
Levels: MUFA PUFA

The data and the index have the same length:
> cbind(hold,Arm)
   Wtscr   Wt0Wt6  Arm
1  120.2 117.2 114.60 PUFA
2  104.6 105.3 104.80 PUFA
3   97.2  96.2  93.80 MUFA
4  103.9 106.1 101.70 MUFA
5   58.2  56.7  55.50 MUFA
6  130.9 127.4 127.60 MUFA
7  135.0 133.1 130.90 MUFA
8  100.1  99.5  84.50 PUFA
9  130.3 115.3 115.80 MUFA
10 150.5 148.7 133.40 MUFA
11  74.8  75.7  77.70 PUFA
12 112.6 110.7 107.40 PUFA
13  90.0  91.0  83.40 PUFA
14 139.1 138.5 126.70 MUFA
15  99.1  96.4  95.70 MUFA
16 108.3 107.5 109.30 PUFA
17  75.1  72.9  72.20 PUFA
18  97.5 102.1  98.50 PUFA
19 202.2  90.1  90.60 MUFA
20  91.7  89.4  93.40 MUFA
21 102.1 102.2 100.80 MUFA
22 116.9 118.9 118.00 MUFA
23  94.6  95.3  90.30 MUFA
24 122.2 117.0 117.00 PUFA
25 105.6 103.3 103.60 MUFA
26  96.9  96.8  98.80 MUFA
27 102.9 100.3  89.00 PUFA
28 115.8 118.5 117.30 MUFA
29  95.7  96.2  95.40 PUFA
30  88.2  86.9  88.30 MUFA
31 108.7 108.8 108.80 PUFA
32  89.2  88.6  81.20 MUFA
33  86.8  86.5  82.70 MUFA
34 135.5 130.1 125.40 MUFA
35 112.5 113.9 111.45 MUFA
36 111.0 105.3 109.50 MUFA
37 103.4 100.5  95.50 PUFA
38 117.6 117.4 101.40 PUFA
39 116.7 118.5 101.80 PUFA

But the by function does not work!
> by(hold,Arm,mean,na.rm=TRUE)
Arm: MUFA
[1] NA
---
 
Arm: PUFA
[1] NA
Warning messages:
1: In mean.default(data[x, , drop = FALSE], ...) :
  argument is not numeric or logical: returning NA
2: In mean.default(data[x, , drop = FALSE], ...) :
  argument is not numeric or logical: returning NA


Perhaps this is a hint, print does not give two separate group:
> by(hold,Arm,print)
   Wtscr   Wt0Wt6
3   97.2  96.2  93.80
4  103.9 106.1 101.70
5   58.2  56.7  55.50
6  130.9 127.4 127.60
7  135.0 133.1 130.90
9  130.3 115.3 115.80
10 150.5 148.7 133.40
14 139.1 138.5 126.70
15  99.1  96.4  95.70
19 202.2  90.1  90.60
20  91.7  89.4  93.40
21 102.1 102.2 100.80
22 116.9 118.9 118.00
23  94.6  95.3  90.30
25 105.6 103.3 103.60
26  96.9  96.8  98.80
28 115.8 118.5 117.30
30  88.2  86.9  88.30
32  89.2  88.6  81.20
33  86.8  86.5  82.70
34 135.5 130.1 125.40
35 112.5 113.9 111.45
36 111.0 105.3 109.50
   Wtscr   Wt0   Wt6
1  120.2 117.2 114.6
2  104.6 105.3 104.8
8  100.1  99.5  84.5
11  74.8  75.7  77.7
12 112.6 110.7 107.4
13  90.0  91.0  83.4
16 108.3 107.5 109.3
17  75.1  72.9  72.2
18  97.5 102.1  98.5
24 122.2 117.0 117.0
27 102.9 100.3  89.0
29  95.7  96.2  95.4
31 108.7 108.8 108.8
37 103.4 100.5  95.5
38 117.6 117.4 101.4
39 116.7 118.5 101.8
Arm: MUFA
   Wtscr   Wt0Wt6
3   97.2  96.2  93.80
4  103.9 106.1 101.70
5   58.2  56.7  55.50
6  130.9 127.4 127.60

Re: [R] R studio installation and running

2015-12-23 Thread John Sorkin
If you want to run Rstudio locally, install the desktop edition. If you want to 
be able to run Rstudio from a remote machine which will connect to your desktop 
via the web, install the server edition. If you are unsure which to use, or are 
having trouble, start with the desktop edition. You must install R before you 
install either edition of RStudio. Once RStudio is installed, enter rstudio , 
possibly RStudio at the command line to run the program


> John David Sorkin M.D., Ph.D.
> Professor of Medicine
> Chief, Biostatistics and Informatics
> University of Maryland School of Medicine Division of Gerontology and 
> Geriatric Medicine
> Baltimore VA Medical Center
> 10 North Greene Street
> GRECC (BT/18/GR)
> Baltimore, MD 21201-1524
> (Phone) 410-605-7119
> (Fax) 410-605-7913 (Please call phone number above prior to faxing)


> On Dec 23, 2015, at 10:24 AM, John Kane  wrote:
> 
> Desktop but you would be better off asking this in an RStudio forum. It is a 
> bit off-topic here.
> 
> John Kane
> Kingston ON Canada
> 
> 
>> -Original Message-
>> From: ragi...@hotmail.com
>> Sent: Tue, 22 Dec 2015 23:10:58 +0200
>> To: r-help@r-project.org
>> Subject: [R] R studio installation and running
>> 
>> Dear group
>> I used to run Rstudio on windows.
>> currently  I want to run Rstudio on Ubuntu server, start its GUI .
>> kindly, is there a guide on how to do this step by step, I already
>> searched and installed R .. but confused ..should I install Rstudio for
>> desktop or server ? how to start it?, I am the server admin.
>> 
>> thanks in advance
>> Ragia
>> 
>> 
>> __
>> R-help@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.
> 
> 
> FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop!
> 
> __
> R-help@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.

Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@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.


Re: [R] Make a box-whiskers plot in R with 5 variables, color coded.

2015-12-15 Thread John Sorkin
On this side of the Atlantic, the symbols ( or ) are properly called 
parenthesis not brackets. Consider the expression parenthetical expression, 
which means something enclosed in parentheses.
John


> John David Sorkin M.D., Ph.D.
> Professor of Medicine
> Chief, Biostatistics and Informatics
> University of Maryland School of Medicine Division of Gerontology and 
> Geriatric Medicine
> Baltimore VA Medical Center
> 10 North Greene Street
> GRECC (BT/18/GR)
> Baltimore, MD 21201-1524
> (Phone) 410-605-7119
> (Fax) 410-605-7913 (Please call phone number above prior to faxing)


> On Dec 15, 2015, at 12:23 PM, David Winsemius  wrote:
> 
> 
>> On Dec 15, 2015, at 8:54 AM, Clint Bowman  wrote:
>> 
>> Martin,
>> 
>> I grew up in the Midwest of the United States--about as native English 
>> speaker as you could find.  I was taught exactly the same as you have 
>> learned.
> 
> As with your experience, Clint and Martin, but my online experience is that 
> those speaking "English English" often refer to "(" as "brackets". As a 
> result I generally now call them square-brackets to avoid ambiguity.
> 
> -- 
> David.
> 
>> 
>> Clint
>> 
>> Clint BowmanINTERNET:cl...@ecy.wa.gov
>> Air Quality ModelerINTERNET:cl...@math.utah.edu
>> Department of EcologyVOICE:(360) 407-6815
>> PO Box 47600FAX:(360) 407-7534
>> Olympia, WA 98504-7600
>> 
>>   USPS:   PO Box 47600, Olympia, WA 98504-7600
>>   Parcels:300 Desmond Drive, Lacey, WA 98503-1274
>> 
>>> On Tue, 15 Dec 2015, Martin Maechler wrote:
>>> 
>>> 
>>> 
>>> []
>>> 
 You are missing the closing bracket on the boxplot()
 command.  Just finish with a ')'
>>> 
>>> Hmm... I once learned
>>> 
>>> '()' =: parenthesis/es
>>> '[]' =: bracket(s)
>>> '{}' =: brace(s)
>>> 
>>> Of course, I'm not a native English speaker, and my teacher(s) /
>>> teaching material may have been biased ... but, as all three
>>> symbol pairs play an important role in R, I think it would be
>>> really really helpful,  if we could agree on using the same
>>> precise English here.
>>> 
>>> I'm happy to re-learn, but I'd really like to end up with three
>>> different simple English words, if possible.
>>> (Yes, I know and have seen/heard "curly braces", "round
>>> parentheses", ... but I'd hope we can do without the extra adjective.)
>>> 
>>> Thank you, well versed English (or "American") learned readers
>>> of R-help, for wise guidance on this ...
>>> 
>>> Martin
>>> 
>>> __
>>> R-help@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.
>> 
>> __
>> R-help@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.
> 
> David Winsemius
> Alameda, CA, USA
> 
> __
> R-help@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.

Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@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.


Re: [R] Make a box-whiskers plot in R with 5 variables, color coded.

2015-12-15 Thread John Sorkin
Just as there are several types of punctuation marks, 
, ; : .
also called comma, semi-colon, colon, period (or full stop on the east side of 
the Atlantic),
so to are there two types of brackets
[   )  
also called square brackets, parenthesis.
 
It is clear that a ) although is a type of bracket it is called a parenthesis, 
just as , is called a comma, which is a type of punctuation mark.
John
 
 
 



John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 
>>> Berend Hasselman  12/15/15 12:59 PM >>>

> On 15 Dec 2015, at 18:49, John Sorkin  wrote:
> 
> On this side of the Atlantic, the symbols ( or ) are properly called 
> parenthesis not brackets. Consider the expression parenthetical expression, 
> which means something enclosed in parentheses.
> John
> 


According to http://www.oxforddictionaries.com/words/brackets
I gather that to avoid ambiguity and/or confusion one could/would use round 
brackets for () (parentheses).


Berend
Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@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.


[R] Function calling a function, column name not passed properly

2015-12-01 Thread John Sorkin
David has  told me that my problem is because there is not column varscr
in my dataframe. I know this. My question is how can I modify my code so
that the second call to SmallFn will in fact access the column Wstscr
which does, in fact exist in the dataframe.
John
 
Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] 

> On Dec 1, 2015, at 2:57 PM, John Sorkin  wrote:> > I am trying to write a function that
calls a function. The first call to SmallFn works without any problem,
printing both the passed data and the column Wstscr. The second call
does not work (error, Error in d[, column] : subscript out of bounds). >
> The first call shows what I am trying to do with the second call. I am
passing to the outer function doit12 the beginning of the name of the
column that I want to access (Wst). doit12 creates the full name of the
column (Wstscr) by using varxx <- deparse(susbstitute(variable)) and
varscr <- paste(varxx,"scr",sep=""). I can access the column in doit12
as seen by the results of   print(data[,varscr]).> > SmallFn works when
it is called using SmallFn(Wstscr,data), but fails when called with
SmallFn(varscr,data). I don't understand why the second call fails.
varscr was shown to represent Wstscr.> > Please tell my why the second
call is not working, please put me out of one-full day of misery!It’s
telling you there is no column in that dataframe with the name “varscr”.—
David.

 
 
 
I am trying to write a function that calls a function. The first call to
SmallFn works without any problem, printing both the passed data and the
column Wstscr. The second call does not work (error, Error in d[,
column] : subscript out of bounds). 
 
The first call shows what I am trying to do with the second call. I am
passing to the outer function doit12 the beginning of the name of the
column that I want to access (Wst). doit12 creates the full name of the
column (Wstscr) by using varxx <- deparse(susbstitute(variable)) and
varscr <- paste(varxx,"scr",sep=""). I can access the column in doit12
as seen by the results of   print(data[,varscr]).
 
SmallFn works when it is called using SmallFn(Wstscr,data), but fails
when called with SmallFn(varscr,data). I don't understand why the second
call fails. varscr was shown to represent Wstscr.
 
Please tell my why the second call is not working, please put me out of
one-full day of misery!
 
Thank you,
John
 
 
 

mydata <- cbind(  
patient_id=c(10163,10987,19882,19899,20104,20105,20167,20318,20338,20392),
  
Wstscr=c(139.00,NA,101.80,103.00,76.40,116.00,139.80,111.31,NA,150.00)) 
  
mydata 
 
doit12 <-function(variable,data) {
  
  varxx <- deparse(substitute(variable))
  cat("varxx created from first deparse substitute=",varxx,"\n")
  varscr <- paste(varxx,"scr",sep="")
  cat("1varscr=",varscr,"\n")
  cat("Data inside doit12\n")
  print(data)
  cat("Print the Wstscr column of data. varscr created using paste after
deparse substitute\n")
  print(data[,varscr])
  cat("\n\n")
  
  SmallFn <- function(v,d) {
cat("\nInside SmallFn\n")
zz <-match.call()
column <- deparse(substitute(v))
cat("column=",column,"\n")
cat("The results of match.call\n")
print(zz)
print("Hello world!")
print(d)
print(d[,column])
  }
  SmallFn(Wstscr,data)
  SmallFn(varscr,data)
}
doit12(Wst,mydata)



John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and
Geriatric Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 





Call

Call from mobile

Send SMS

Add to Skype

You'll need Skype CreditFree via Skype
John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of MedicineBaltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 

Confidentiality Statement:
This email message, including any attachments, is for the sole use of
the intended recipient(s) and may contain confidential and privileged
information. Any unauthorized use, disclosure or distribution is
prohibited. If you are not the intended recipient, please contact the
sender by reply email and destroy all copies of the original message. 
__
R-help@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.

[R] What URL do I go to manage my subscription to the r-help? Please respond directly to me, not to this list!!!!

2015-12-01 Thread John Sorkin
Please respond directly to me jsor...@grecc.umaryland.edu. If you respond to 
the list I will not get your response. There is a problem with my subscription. 
It has been changed to digest. I need to set it back to no digest (i.e. get 
messages as soon as they are posted)
John


John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 




Call

Call from mobile

Send SMS

Add to Skype

You'll need Skype CreditFree via Skype
John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 

Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@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.


[R] What URL do I go to manage my subscription to the list? Please respond directly to me, not to this list!!!!

2015-12-01 Thread John Sorkin


John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 

Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@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.


[R] Function calling a function, column name not passed properly

2015-12-01 Thread John Sorkin
I am trying to write a function that calls a function. The first call to 
SmallFn works without any problem, printing both the passed data and the column 
Wstscr. The second call does not work (error, Error in d[, column] : subscript 
out of bounds). 
 
The first call shows what I am trying to do with the second call. I am passing 
to the outer function doit12 the beginning of the name of the column that I 
want to access (Wst). doit12 creates the full name of the column (Wstscr) by 
using varxx <- deparse(susbstitute(variable)) and varscr <- 
paste(varxx,"scr",sep=""). I can access the column in doit12 as seen by the 
results of   print(data[,varscr]).
 
SmallFn works when it is called using SmallFn(Wstscr,data), but fails when 
called with SmallFn(varscr,data). I don't understand why the second call fails. 
varscr was shown to represent Wstscr.
 
Please tell my why the second call is not working, please put me out of 
one-full day of misery!
 
Thank you,
John
 
 
 

mydata <- cbind(   
patient_id=c(10163,10987,19882,19899,20104,20105,20167,20318,20338,20392),
   
Wstscr=c(139.00,NA,101.80,103.00,76.40,116.00,139.80,111.31,NA,150.00)) 
   
mydata 
 
doit12 <-function(variable,data) {
  
  varxx <- deparse(substitute(variable))
  cat("varxx created from first deparse substitute=",varxx,"\n")
  varscr <- paste(varxx,"scr",sep="")
  cat("1varscr=",varscr,"\n")
  cat("Data inside doit12\n")
  print(data)
  cat("Print the Wstscr column of data. varscr created using paste after 
deparse substitute\n")
  print(data[,varscr])
  cat("\n\n")
  
  SmallFn <- function(v,d) {
cat("\nInside SmallFn\n")
zz <-match.call()
column <- deparse(substitute(v))
cat("column=",column,"\n")
cat("The results of match.call\n")
print(zz)
print("Hello world!")
print(d)
print(d[,column])
  }
  SmallFn(Wstscr,data)
  SmallFn(varscr,data)
}
doit12(Wst,mydata)
John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 

Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@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.


[R] SWEAVE - a gentle introduction

2015-11-17 Thread John Sorkin
I am looking for a gentle introduction to SWEAVE, and would appreciate 
recommendations. 
I have an R program that I want to run and have the output and plots in one 
document. I believe this can be accomplished with SWEAVE. Unfortunately I don't 
know HTML, but am willing to learn. . . as I said I need a gentle introduction 
to SWEAVE.
Thank you,
John



John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 
John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 

Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@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.


Re: [R] [FORGED] Re: How to correct documentation?

2015-10-24 Thread John Sorkin
Bert
Talking about Loglan and problems with the imprecise nature of English, which 
sense of sanction do you mean

to authorize, approve, or allow: an expression now sanctioned by educated usage.
to ratify or confirm: to sanction a law.
to impose a sanction on; penalize, especially by way of discipline

> John David Sorkin M.D., Ph.D.
> Professor of Medicine
> Chief, Biostatistics and Informatics
> University of Maryland School of Medicine Division of Gerontology and 
> Geriatric Medicine
> Baltimore VA Medical Center
> 10 North Greene Street
> GRECC (BT/18/GR)
> Baltimore, MD 21201-1524
> (Phone) 410-605-7119
> (Fax) 410-605-7913 (Please call phone number above prior to faxing)


> On Oct 24, 2015, at 7:43 PM, Bert Gunter  wrote:
> 
> I sanction this discussion.
> 
> (Google on "auto-antonyms")
> 
> Cheers,
> Bert
> Bert Gunter
> 
> "Data is not information. Information is not knowledge. And knowledge
> is certainly not wisdom."
>   -- Clifford Stoll
> 
> 
> On Sat, Oct 24, 2015 at 4:26 PM, Duncan Murdoch
>  wrote:
>> On 24/10/2015 6:07 PM, Rolf Turner wrote:
 On 24/10/15 21:10, Jim Lemon wrote:
 Hi Ming,
 In fact, the notation lb/1000 is correct, as the values represent the
 weight of the cars in pounds (lb) divided by 1000. I am not sure why this
 particular transformation of the measured values was used, but I'm sure it
 has caused confusion previously.
>>> 
>>> I disagree --- and agree with Ming.  The notation is incorrect.  Surely
>>> "lb/1000" means thousandths of pounds.  E.g. 12345 lb/1000 is equal to
>>> 12.345 lb.
>>> 
>>> I'm sure that others will come up with all sorts of convoluted lawyerish
>>> arguments that the case is otherwise, but as far as I am concerned, any
>>> *sane* person would interpret "lb/1000" to mean thousandths of pounds.
>> 
>> And we insane ones would read "lb/1000" literally as "pounds divided by
>> one thousand".
>> 
>> The problem is that English is ambiguous.  In many, many ways.  We
>> should rewrite all the help files in Loglan.
>> 
>> Duncan Murdoch
>> 
>>> If in the unlikely event that the documentation for some data set said
>>> "Weight (gm/1000)", I'm pretty sure that this would be interpreted to
>>> mean milligrams and *not* kilograms!
>>> 
>>> Since the description of the data was presumably taken from that given
>>> in the original source ("Motor Trend" magazine) it would probably be
>>> inappropriate to "correct" it.  However a note/warning should be added
>>> to the mtcars help file indicating that Motor Trend got things upside-down.
>> 
>> __
>> R-help@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.
> 
> __
> R-help@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.

Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@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.


[R] Add sequence numbers to lines with the same ID: How can this be accomplished?

2015-10-24 Thread John Sorkin
I have a file that has (1) Line numbers, (2) IDs. A given ID number can appear 
in more than one row. For each row with a repeated ID, I want to add a number 
that gives the sequence number of the repeated ID number. The R code below 
demonstrates what I want to have, without any attempt to produce the result, as 
I have no idea how to accomplish my goal.


line <- c(1,2,3,4,5,6,7,8,9,10)
ID<-c(1,1,2,3,4,5,6,7,8,8)
cat("Note lines 1 and 2 both contain ID 1; lines 9 and 10 both contain ID 8")
cbind(line,ID)
Seq <-  c(1,2,1,1,1,1,1,1,1,2)
cat("Sequence numbers within ID added to the data")
cbind(line,ID,Seq)



John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 


Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@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.


[R] writing a function that will refer to the elements of a dataframe much as is done by lm

2015-10-12 Thread John Sorkin
I am trying to learn how  to write R functions (really to program in R). I want 
to write a function that will allow me to refer to the elements of a data frame 
by column name, much as is done in lm. I can't seem to get the syntax correct. 
I want the function to print the elements of data2[,"Mo6MONO"]
 
data2 <- data.frame(POSTHHMONO=c(1,2,3,4),Mo6MON=c(10,11,12,13))
data2
doit<- function(pre,post,data) {
  element <- deparse(substitute(pre))
  print(element)
  frame <- deparse(substitute(data))
  print(frame)
  print(frame$element)
}
doit(Mo6MONO,POSTHHMONO,data2)
 
results of running function:
Browse[1]> doit(Mo6MONO,POSTHHMONO,data2)
[1] "Mo6MONO"
[1] "data2"
Error during wrapup: $ operator is invalid for atomic vectors

 
 
I have looked at lm, but don't understand the syntax, and have tried to run lm 
so as to learn the syntax by just don't understand . . . .
 
HELP
 
Thanks 
John
John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 

Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@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.


Re: [R] Comparing two populations based on the percentile values calculated from two independent samples

2015-09-24 Thread John Sorkin
Mohamed,
You probably should seek the help of a local statistician, and should read 
about Pearson's chi square test and Fisher's exact test.
John


John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 
>>> "Mohamed A.Abdel-Fattah Mansour via R-help"  09/24/15 
>>> 2:42 PM >>>
Dear AllI Have the data for two samples drawn from two different populations
| 

| 

| 

| 

| 

| Percentiles

|
| 

| Mean

| STD

| Min

| Max

| 5th

| 25th

| 50th

| 75th

| 95th

|
| Sample 1

| 25

| 2

| 16

| 30

| 18

| 20

| 26

| 27

| 29

|
| Sample 2

| 26

| 2.1

| 21

| 32

| 17

| 21

| 27

| 28

| 30

|


I need to test the equivalence of the two samples regarding percentiles.
Dr. Mohamed A.Abdel-Fattah Mansour Associate Prof. of Industrial Engineering 
Industrial Engineering Department Faculty of Engineering KKU
[[alternative HTML version deleted]]

__
R-help@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.
Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@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.


Re: [R] Compare two normal to one normal

2015-09-22 Thread John Sorkin
Charles,
I am not sure the answer to me question, given a dataset, how can one compare 
the fit of a model of the fits the data to a mixture of two normal 
distributions to the fit of a model that uses a single normal distribution, can 
be based on the glm model you suggest. 


I have used normalmixEM to fit the data to a mixture of two normal curves. The 
model estimates four (perhaps five) parameters: mu1, sd^2 1, mu2, sd^2, (and 
perhaps lambda, the mixing proportion. The mixing proportion may not need to be 
estimated, it may be determined once once specifies mu1, sd^2 1, mu2, and 
sd^2.) Your model fits the data to a model that contains only the mean, and 
estimates 2 parameters mu0 and sd0^2.  I am not sure that your model and mine 
can be considered to be nested. If I am correct I can't compare the log 
likelihood values from the two models. I  may be wrong. If I am, I should be 
able to perform a log likelihood test with 2 (or 3, I am not sure which) DFs. 
Are you suggesting the models are nested? If so, should I use 3 or 2 DFs?


May thanks,
John





John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 

>>> "Charles C. Berry"  09/22/15 6:23 PM >>>
On Tue, 22 Sep 2015, John Sorkin wrote:

>
> In any event, I still don't know how to fit a single normal distribution 
> and get a measure of fit e.g. log likelihood.
>

Gotta love R:

> y <- rnorm(10)
> logLik(glm(y~1))
'log Lik.' -17.36071 (df=2)

HTH,

Chuck





Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@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.


Re: [R] Compare two normal to one normal

2015-09-22 Thread John Sorkin
Bert
I am surprised by your response. Statistics serves two purposes: estimation and 
hypothesis testing. Sometimes we are fortunate and theory, physiology, physics, 
or something else tell us what is the correct, or perhaps I should same most 
adequate model. Sometimes theory fails us and we wish to choose between two 
competing models. This is my case.  The cell sizes may come from one normal 
distribution (theory 1) or two (theory 2). Choosing between the models will 
help us postulate about physiology. I want to use statistics to help me decide 
between the two competing models, and thus inform my understanding of 
physiology. It is true that statistics can't tell me which model is the 
"correct" or "true" model, but it should be able to help me select the more 
"adequate" or "appropriate" or "closer to he truth" model.


In any event, I still don't know how to fit a single normal distribution and 
get a measure of fit e.g. log likelihood.


John


John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 

>>> Bert Gunter  09/22/15 4:48 PM >>>
I'll be brief in my reply to you both, as this is off topic.

So what?  All this statistical stuff is irrelevant baloney(and of
questionable accuracy, since based on asymptotics and strong
assumptions, anyway) . The question of interest is whether a mixture
fit better suits the context, which only the OP knows and which none
of us can answer.

I know that many will disagree with this -- maybe a few might agree --
but please send all replies, insults, praise, and learned discourse to
me privately,  as I have already occupied more space on the list than
I should.

Cheers,
Bert


Bert Gunter

"Data is not information. Information is not knowledge. And knowledge
is certainly not wisdom."
   -- Clifford Stoll


On Tue, Sep 22, 2015 at 1:35 PM, Mark Leeds  wrote:
> That's true but if he uses some AIC or BIC criterion that penalizes the
> number of parameters,
> then he might see something else ? This ( comparing mixtures to not mixtures
> ) is not something I deal with so I'm just throwing it out there.
>
>
>
>
> On Tue, Sep 22, 2015 at 4:30 PM, Bert Gunter  wrote:
>>
>> Two normals will **always** be a better fit than one, as the latter
>> must be a subset of the former (with identical parameters for both
>> normals).
>>
>> Cheers,
>> Bert
>>
>>
>> Bert Gunter
>>
>> "Data is not information. Information is not knowledge. And knowledge
>> is certainly not wisdom."
>>-- Clifford Stoll
>>
>>
>> On Tue, Sep 22, 2015 at 1:21 PM, John Sorkin
>>  wrote:
>> > I have data that may be the mixture of two normal distributions (one
>> > contained within the other) vs. a single normal.
>> > I used normalmixEM to get estimates of parameters assuming two normals:
>> >
>> >
>> > GLUT <- scale(na.omit(data[,"FCW_glut"]))
>> > GLUT
>> > mixmdl = normalmixEM(GLUT,k=1,arbmean=TRUE)
>> > summary(mixmdl)
>> > plot(mixmdl,which=2)
>> > lines(density(data[,"GLUT"]), lty=2, lwd=2)
>> >
>> >
>> >
>> >
>> >
>> > summary of normalmixEM object:
>> >comp 1   comp 2
>> > lambda  0.7035179 0.296482
>> > mu -0.0592302 0.140545
>> > sigma   1.1271620 0.536076
>> > loglik at estimate:  -110.8037
>> >
>> >
>> >
>> > I would like to see if the two normal distributions are a better fit
>> > that one normal. I have two problems
>> > (1) normalmixEM does not seem to what to fit a single normal (even if I
>> > address the error message produced):
>> >
>> >
>> >> mixmdl = normalmixEM(GLUT,k=1)
>> > Error in normalmix.init(x = x, lambda = lambda, mu = mu, s = sigma, k =
>> > k,  :
>> >   arbmean and arbvar cannot both be FALSE
>> >> mixmdl = normalmixEM(GLUT,k=1,arbmean=TRUE)
>> > Error in normalmix.init(x = x, lambda = lambda, mu = mu, s = sigma, k =
>> > k,  :
>> >   arbmean and arbvar cannot both be FALSE
>> >
>> >
>> >
>> > (2) Even if I had the loglik from a single normal, I am not sure how
>> > many DFs to use when computing the -2LL ratio test.
>> >
>> >
>> > Any suggestions for 

Re: [R] Compare two normal to one normal

2015-09-22 Thread John Sorkin
I am not sure AIC or BIC would be needed as the two normal distribution has at 
least two additional parameters to estimate; mean 1, var1, mean 2, var 2 where 
as the one normal has to estimate only var1 and var2.In any event, I don't know 
how to fit the single normal and get values for the loglik let alone AIC or BIC
John



John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 

>>> Mark Leeds  09/22/15 4:36 PM >>>
That's true but if he uses some AIC or BIC criterion that penalizes the number 
of parameters,

then he might see something else ? This ( comparing mixtures to not mixtures ) 
is not something I deal with so I'm just throwing it out there.






On Tue, Sep 22, 2015 at 4:30 PM, Bert Gunter  wrote:
Two normals will **always** be a better fit than one, as the latter
 must be a subset of the former (with identical parameters for both
 normals).
 
 Cheers,
 Bert
 
 
 Bert Gunter
 
 "Data is not information. Information is not knowledge. And knowledge
 is certainly not wisdom."
-- Clifford Stoll
 
 
 On Tue, Sep 22, 2015 at 1:21 PM, John Sorkin
  wrote:
 > I have data that may be the mixture of two normal distributions (one 
 > contained within the other) vs. a single normal.
 > I used normalmixEM to get estimates of parameters assuming two normals:
 >
 >
 > GLUT <- scale(na.omit(data[,"FCW_glut"]))
 > GLUT
 > mixmdl = normalmixEM(GLUT,k=1,arbmean=TRUE)
 > summary(mixmdl)
 > plot(mixmdl,which=2)
 > lines(density(data[,"GLUT"]), lty=2, lwd=2)
 >
 >
 >
 >
 >
 > summary of normalmixEM object:
 >comp 1   comp 2
 > lambda  0.7035179 0.296482
 > mu -0.0592302 0.140545
 > sigma   1.1271620 0.536076
 > loglik at estimate:  -110.8037
 >
 >
 >
 > I would like to see if the two normal distributions are a better fit that 
 > one normal. I have two problems
 > (1) normalmixEM does not seem to what to fit a single normal (even if I 
 > address the error message produced):
 >
 >
 >> mixmdl = normalmixEM(GLUT,k=1)
 > Error in normalmix.init(x = x, lambda = lambda, mu = mu, s = sigma, k = k,  :
 >   arbmean and arbvar cannot both be FALSE
 >> mixmdl = normalmixEM(GLUT,k=1,arbmean=TRUE)
 > Error in normalmix.init(x = x, lambda = lambda, mu = mu, s = sigma, k = k,  :
 >   arbmean and arbvar cannot both be FALSE
 >
 >
 >
 > (2) Even if I had the loglik from a single normal, I am not sure how many 
 > DFs to use when computing the -2LL ratio test.
 >
 >
 > Any suggestions for comparing the two-normal vs. one normal distribution 
 > would be appreciated.
 >
 >
 > Thanks
 > John
 >
 >
 >
 >
 >
 >
 >
 >
 >
 > John David Sorkin M.D., Ph.D.
 > Professor of Medicine
 > Chief, Biostatistics and Informatics
 > University of Maryland School of Medicine Division of Gerontology and 
 > Geriatric Medicine
 > Baltimore VA Medical Center
 > 10 North Greene Street
 > GRECC (BT/18/GR)
 > Baltimore, MD 21201-1524
 > (Phone) 410-605-7119410-605-7119
 > (Fax) 410-605-7913 (Please call phone number above prior to faxing)
 >
 >
 > Confidentiality Statement:
 

> This email message, including any attachments, is for ...{{dropped:12}}
 
 __
 R-help@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.






Call
Send SMS
Call from mobile
Add to Skype
You'll need Skype CreditFree via Skype



Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@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.


Re: [R] Compare two normal to one normal

2015-09-22 Thread John Sorkin
Bert,Better, perhaps, but will something like the LR test be significant? 
Adding an extra parameter to a linear regression almost always improves the R2, 
the if one compares models, the model with the extra parameter is not always 
significantly better.
John
P.S. Please forgive the appeal to "significantly better" . . .


John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 

>>> Bert Gunter  09/22/15 4:30 PM >>>
Two normals will **always** be a better fit than one, as the latter
must be a subset of the former (with identical parameters for both
normals).

Cheers,
Bert


Bert Gunter

"Data is not information. Information is not knowledge. And knowledge
is certainly not wisdom."
   -- Clifford Stoll


On Tue, Sep 22, 2015 at 1:21 PM, John Sorkin
 wrote:
> I have data that may be the mixture of two normal distributions (one 
> contained within the other) vs. a single normal.
> I used normalmixEM to get estimates of parameters assuming two normals:
>
>
> GLUT <- scale(na.omit(data[,"FCW_glut"]))
> GLUT
> mixmdl = normalmixEM(GLUT,k=1,arbmean=TRUE)
> summary(mixmdl)
> plot(mixmdl,which=2)
> lines(density(data[,"GLUT"]), lty=2, lwd=2)
>
>
>
>
>
> summary of normalmixEM object:
>comp 1   comp 2
> lambda  0.7035179 0.296482
> mu -0.0592302 0.140545
> sigma   1.1271620 0.536076
> loglik at estimate:  -110.8037
>
>
>
> I would like to see if the two normal distributions are a better fit that one 
> normal. I have two problems
> (1) normalmixEM does not seem to what to fit a single normal (even if I 
> address the error message produced):
>
>
>> mixmdl = normalmixEM(GLUT,k=1)
> Error in normalmix.init(x = x, lambda = lambda, mu = mu, s = sigma, k = k,  :
>   arbmean and arbvar cannot both be FALSE
>> mixmdl = normalmixEM(GLUT,k=1,arbmean=TRUE)
> Error in normalmix.init(x = x, lambda = lambda, mu = mu, s = sigma, k = k,  :
>   arbmean and arbvar cannot both be FALSE
>
>
>
> (2) Even if I had the loglik from a single normal, I am not sure how many DFs 
> to use when computing the -2LL ratio test.
>
>
> Any suggestions for comparing the two-normal vs. one normal distribution 
> would be appreciated.
>
>
> Thanks
> John
>
>
>
>
>
>
>
>
>
> John David Sorkin M.D., Ph.D.
> Professor of Medicine
> Chief, Biostatistics and Informatics
> University of Maryland School of Medicine Division of Gerontology and 
> Geriatric Medicine
> Baltimore VA Medical Center
> 10 North Greene Street
> GRECC (BT/18/GR)
> Baltimore, MD 21201-1524
> (Phone) 410-605-7119410-605-7119
> (Fax) 410-605-7913 (Please call phone number above prior to faxing)
>
>
> Confidentiality Statement:
> This email message, including any attachments, is for the sole use of the 
> intended recipient(s) and may contain confidential and privileged 
> information. Any unauthorized use, disclosure or distribution is prohibited. 
> If you are not the intended recipient, please contact the sender by reply 
> email and destroy all copies of the original message.
> __
> R-help@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.


Call
Send SMS
Call from mobile
Add to Skype
You'll need Skype CreditFree via Skype


Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@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.


[R] Compare two normal to one normal

2015-09-22 Thread John Sorkin
I have data that may be the mixture of two normal distributions (one contained 
within the other) vs. a single normal. 
I used normalmixEM to get estimates of parameters assuming two normals:


GLUT <- scale(na.omit(data[,"FCW_glut"]))
GLUT
mixmdl = normalmixEM(GLUT,k=1,arbmean=TRUE)
summary(mixmdl)
plot(mixmdl,which=2)
lines(density(data[,"GLUT"]), lty=2, lwd=2)





summary of normalmixEM object:
   comp 1   comp 2
lambda  0.7035179 0.296482
mu -0.0592302 0.140545
sigma   1.1271620 0.536076
loglik at estimate:  -110.8037 



I would like to see if the two normal distributions are a better fit that one 
normal. I have two problems 
(1) normalmixEM does not seem to what to fit a single normal (even if I address 
the error message produced):


> mixmdl = normalmixEM(GLUT,k=1)
Error in normalmix.init(x = x, lambda = lambda, mu = mu, s = sigma, k = k,  : 
  arbmean and arbvar cannot both be FALSE
> mixmdl = normalmixEM(GLUT,k=1,arbmean=TRUE)
Error in normalmix.init(x = x, lambda = lambda, mu = mu, s = sigma, k = k,  : 
  arbmean and arbvar cannot both be FALSE



(2) Even if I had the loglik from a single normal, I am not sure how many DFs 
to use when computing the -2LL ratio test. 


Any suggestions for comparing the two-normal vs. one normal distribution would 
be appreciated.


Thanks
John









John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 


Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@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.


[R] getting means by group within time point for data on multiple lines (long rather than wide file)

2015-09-17 Thread John Sorkin
I have a long (rather than wide file), i.e. the data for each subject is on 
multiple lines rather than one line. Each line has the following layout:
subject group time value
I have two groups, multiple subjects, each subject can be seen up to three 
times a time 0, and at most once at times 4 and 8.
An example of the data follows:

1 control 0 100
1 control 0 NA
1 control 0 55
1 control 4 100
1 control 8 100

2 exp 0 99
2 exp 0 67
2 exp 0 66
2 exp 4 110
2 exp 8 200

I need to get means by group (control vs. exp) within time (0,4,8). The means 
should include only those subjects who have at least one observation at each 
time point (0, 4, 8). I also need to determine the number of subjects who 
contribute data at each time-point by group. Any suggestion on how to get them 
means would be appreciated. Sad to say I worked on this for four hours last 
night without coming to any understanding how this can be done. UGG!  

Thank you,
John




> John David Sorkin M.D., Ph.D.
> Professor of Medicine
> Chief, Biostatistics and Informatics
> University of Maryland School of Medicine Division of Gerontology and 
> Geriatric Medicine
> Baltimore VA Medical Center
> 10 North Greene Street
> GRECC (BT/18/GR)
> Baltimore, MD 21201-1524
> (Phone) 410-605-7119
> (Fax) 410-605-7913 (Please call phone number above prior to faxing)

Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@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.


[R] finding those elements of listA that are found in listB

2015-09-16 Thread John Sorkin
I have two structures. I think they are lists, but I am not sure. Both 
structures contain integers. I am trying to find those members of list b that 
are found in list a. I have tried to perform the search using grep, but I get 
an error. Please see code below. I would appreciate knowing how to search listB 
for any element in listA
Thanks
John


> str(listA)
 int [1:42] 13083 13705 14123 14168 14382 14652 14654 14678 14817 14822 ...
> str(listB)
 int [1:633] 13083 13083 13083 13083 13083 13083 13705 13705 13705 13705 ...
> grep(listA,listB)
[1] 1 2 3 4 5 6
Warning message:
In grep(listA, listB) :
  argument 'pattern' has length > 1 and only the first element will be used







 

John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 


Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@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.


[R] Simulate skewed data if 2.5, 25th 50th and 75 centile are known

2015-08-05 Thread John Sorkin
Colleagues,
I need to simulate skewed data so I can run a sample size calculation.
 
I know the 2.5th, 25th, 50th, and 75th centiles of the data (32, 43, 48, 250).
 
data <- matrix(c(75,250,50,48,25,43,2.5,32),nrow=4,ncol=2,byrow=TRUE)
dimnames(data) <- list(NULL,c("x","y"))
data

Is there a way I can use these values to generate simulations of the original 
data? Of course if the data were normally distributed this would be a piece of 
cake, but given the skewness, I don't know how to go about the generating the 
values that would be expected from a distribution having the observed values at 
the four centiles.
Thank you,
John
John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 

Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@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.


[R] degrees of freedom (and hence p values) from lme and lmer don't agree . . . Why?????????

2015-07-07 Thread John Sorkin
I am trying to fit data from 23 subjects using random effects
regression, and am comparing the results of lme and lmer. The point
estimates and the SEs are the same in both models, however the degrees
of freedom are widely different. lme reports 88 DF, lmer approximately
22. Can someone help me understand why the DFs are not the same? I have
23 subjects, each of whom is studied in up to five different
experimental conditions (i.e. Amp). For each condition multiple
measurements are made for each subject (i.e. X).
Thank you,
John
 
 

# lme: Random intercept, random slope.
cat("This analysis has 88 degrees of freedom\n")
fit0X.new <- groupedData(X~Amp|SS,data=data,order.groups=FALSE)
xx <- lme(fit0X.new,random=~1+Amp)
summary(xx)
cat("\n\n")
 
 
# lmer: Random intercept, random slope.
cat("*This analysis has ~22 degrees of freedom\n")
fit0X <- lmer(X~Amp+(1+Amp|SS),data=data)
print(summary(fit0X))
fit0XSum<-summary(fit0X)$coefficients
 
 
 
This analysis has 88 degrees of freedom
Linear mixed-effects model fit by REML
 Data: fit0X.new 
   AIC  BIClogLik
  331.7688 347.9717 -159.8844
Random effects:
 Formula: ~1 + Amp | SS
 Structure: General positive-definite, Log-Cholesky parametrization
StdDevCorr  
(Intercept) 1.3515911 (Intr)
Amp 2.5619953 -0.366
Residual0.6139429   
Fixed effects: X ~ Amp 
   Value Std.Error DF   t-value p-value
(Intercept) 1.718376 0.3609133 88  4.761188   0
Amp 6.890429 0.5978236 88 11.525856   0
 Correlation: 
(Intr)
Amp -0.526
Standardized Within-Group Residuals:
   Min Q1Med Q3Max 
-2.2177007 -0.5770388 -0.1249565  0.5247444  4.1150164 
Number of Observations: 112
Number of Groups: 23 

*This analysis has ~22 degrees of freedom
Linear mixed model fit by REML t-tests use Satterthwaite approximations
to degrees of freedom [merModLmerTest]
Formula: X ~ Amp + (1 + Amp | SS)
   Data: data
REML criterion at convergence: 319.8
Scaled residuals: 
Min  1Q  Median  3Q Max 
-2.2177 -0.5770 -0.1250  0.5247  4.1150 
Random effects:
 Groups   NameVariance Std.Dev. Corr 
 SS   (Intercept) 1.8268   1.3516
  Amp 6.5638   2.5620   -0.37
 Residual 0.3769   0.6139
Number of obs: 112, groups:  SS, 23
Fixed effects:
Estimate Std. Error  df t value Pr(>|t|)
(Intercept)   1.7184 0.3609 21.1150   4.761 0.000104 ***
Amp   6.8904 0.5978 22.0460  11.526 8.37e-11 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Correlation of Fixed Effects:
(Intr)
Amp -0.526
John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and
Geriatric Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 

Confidentiality Statement:
This email message, including any attachments, is for the sole use of
the intended recipient(s) and may contain confidential and privileged
information. Any unauthorized use, disclosure or distribution is
prohibited. If you are not the intended recipient, please contact the
sender by reply email and destroy all copies of the original message. 
__
R-help@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.

Re: [R] Greek letters in column titles.

2015-07-05 Thread John Sorkin


  To clarify, what I would like to do is have the letter b in the column
titles below print as the Greek letter beta.


  dimnames(results) <-
list(dimnames(results)[[1]],c("b0","SEb0","pb0","bRM0","SERMb0","pRMb0"))
 
  print(results)


  John



John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and
Geriatric Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 

>>> Bert Gunter  07/05/15 5:07 PM >>>
Warning: The following may be baloney, so confirmation or correction
by those more knowledgeable is required. But maybe this will get you
started/prove useful. Just beware.

1. First of all, as Ista said, this can be done, but it is heavily
system dependent as to how. Basically I think you want access to UTF-8
encodings, which any modern OS should support, but that access is
dependent on your system.

2. It also depends on where you want to display the results -- on
screen, into a pdf, or ? .

3. See also The man pages on ?unicode and ?iconv , as these may also
be relevant.

Cheers,
Bert
Bert Gunter

"Data is not information. Information is not knowledge. And knowledge
is certainly not wisdom."
   -- Clifford Stoll


On Sun, Jul 5, 2015 at 1:37 PM, Ista Zahn  wrote:
> x = data.frame( β =1)
>
> seems to work fine for me. Perhaps you need to give some more details
about
> what exactly the problem is.
>
> Best,
> Ista
> On Jul 5, 2015 3:36 PM, "John Sorkin" 
wrote:
>
>> I would like to include a Greek letter in a column title, viz.  pB
where B
>> should be the Greek letter beta, but I don't know how to do this. I
know
>> about dimnames, but I don't know how to create the Greek letter.
>> Thank you,
>> John
>>
>> John David Sorkin M.D., Ph.D.
>> Professor of Medicine
>> Chief, Biostatistics and Informatics
>> University of Maryland School of Medicine Division of Gerontology and
>> Geriatric Medicine
>> Baltimore VA Medical Center
>> 10 North Greene Street
>> GRECC (BT/18/GR)
>> Baltimore, MD 21201-1524
>> (Phone) 410-605-7119410-605-7119
>> (Fax) 410-605-7913 (Please call phone number above prior to faxing)
>>
>>
>> Confidentiality Statement:
>> This email message, including any attachments, is for
...{{dropped:16}}
>
> __
> R-help@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.


Call
Send SMS
Call from mobile
Add to Skype
You'll need Skype CreditFree via Skype


Confidentiality Statement:
This email message, including any attachments, is for the sole use of
the intended recipient(s) and may contain confidential and privileged
information. Any unauthorized use, disclosure or distribution is
prohibited. If you are not the intended recipient, please contact the
sender by reply email and destroy all copies of the original message. 
__
R-help@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.

[R] Greek letters in column titles.

2015-07-05 Thread John Sorkin
I would like to include a Greek letter in a column title, viz.  pB where B 
should be the Greek letter beta, but I don't know how to do this. I know about 
dimnames, but I don't know how to create the Greek letter.
Thank you,
John

John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 


Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@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.


[R] mixtools? Fitting two-normal distributions to data where one of the two normal distributions (the one corresponding to lower values of x) is a left-truncated normal distribution.

2015-06-30 Thread John Sorkin
I am trying to model the mixture of two normal distributions, where x values 
are in the range of zero to some positive value. I know about mixtools and 
would use it save for the fact that the the y values from the normal 
distribution corresponding to the lower values of x (i.e. from zero to x/n) are 
from what appears to be a left-truncated normal distribution (i.e. the y values 
are all from the upper half of a normal distribution). The y values from higher 
values of x (i.e. from x/n to x) all appear to come from a normal distribution. 
Can someone suggest how to fit two normal distributions where one of the two 
distributions is left-truncated? Can this be done using mixtools?
Thank you,
John 

John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 


Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@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.


Re: [R] Blank spaces are replaced by period in read.csv, I want to replace blacks with an underline

2015-06-08 Thread John Sorkin
Sarah, 
Many, many thanks.
John

> John David Sorkin M.D., Ph.D.
> Professor of Medicine
> Chief, Biostatistics and Informatics
> University of Maryland School of Medicine Division of Gerontology and 
> Geriatric Medicine
> Baltimore VA Medical Center
> 10 North Greene Street
> GRECC (BT/18/GR)
> Baltimore, MD 21201-1524
> (Phone) 410-605-7119
> (Fax) 410-605-7913 (Please call phone number above prior to faxing)


> On Jun 8, 2015, at 11:04 AM, Sarah Goslee  wrote:
> 
> I've taken the liberty of copying this back to the list, so that others can 
> participate in or benefit from the discussion.
> 
>> On Mon, Jun 8, 2015 at 10:49 AM, John Sorkin  
>> wrote:
>> Sarah,
>> I am not sure how I use check.names to replace every space in the names of 
>> my variables with an underline. Can you show me how to do this? My current 
>> code is as follows:
> 
> check.names just tells R not to reformat your column names. If they aren't 
> already what you want, you'll need to do something else. 
>  
>> data <- read.csv("C:\\Users\\john\\Dropbox 
>> (Personal)\\HanlonMatt\\fullgenus3.csv")
>> 
>> The problem I has is that my column names are not unique, e.g., I have 
>> multiple columns whose column names are (in CSV format):
>> X Y, X Y, X Y, X Y
>> R reads the names as follows:
>> X.Y, X.Y.1, X.Y.2, X.Y.3
>> I need to have the names look like:
>> X_Y, X_Y.1, X_Y.2, X_Y.3
> 
> You've been saying that you want to replace every space with an underscore, 
> but that's not what your example shows. Instead, you want to let R import the 
> names and add the identifying number (though if you do it yourself you can 
> get the number to match the column number, which is neater), then change the 
> FIRST underscore to a period.
> 
> I'd import them with check.names=FALSE, then modify them explicitly:
> 
> 
> > mynames <- c("x y", "x y", "x y", "x y")
> > mynames
> [1] "x y" "x y" "x y" "x y"
> > mynames <- sub(" ", ".", mynames)
> > mynames
> [1] "x.y" "x.y" "x.y" "x.y"
> > mynames <- paste(mynames, seq_along(mynames), sep="_")
> > mynames
> [1] "x.y_1" "x.y_2" "x.y_3" "x.y_4"
> 
> 
> You could also let R modify them, then use sub() to change the first 
> underscore to a period and leave the rest alone.
> 
> Sarah

Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@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.


Re: [R] Blank spaces are replaced by period in read.csv, I want to replace blacks with an underline

2015-06-08 Thread John Sorkin
David,I appreciate you suggestion, but it won't work for me. I need to replace 
the space for a period at the time the data are read, not afterward. My 
variables names have periods I want to keep, if I use your suggestion I will 
replace the period inserted when the data are read, as well as the period that 
I want to keep.
Thank you,
John 



John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 

>>> David L Carlson  06/08/15 10:21 AM >>>
You can use gsub() to change the names:

> dat <- data.frame("Var 1"=rnorm(5, 10), "Var 2"=rnorm(5, 15))
> dat
  Var.1Var.2
1  9.627122 14.15376
2 10.741617 16.92937
3  8.492926 15.23767
4 12.226146 15.19834
5  8.829982 14.46957
> names(dat) <- gsub("\\.", "_", names(dat))
> dat
  Var_1Var_2
1  9.627122 14.15376
2 10.741617 16.92937
3  8.492926 15.23767
4 12.226146 15.19834
5  8.829982 14.46957

-
David L Carlson
Department of Anthropology
Texas A&M University
College Station, TX 77840-4352



-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of John Sorkin
Sent: Monday, June 8, 2015 9:16 AM
Cc: r-help@r-project.org
Subject: [R] Blank spaces are replaced by period in read.csv, I want to replace 
blacks with an underline

I am reading a csv file. The column headers have spaces in them. The spaces are 
replaced by a period. I want to replace the space by another character (e.g. 
the underline) rather than the period. Can someone tell me how to accomplish 
this?Thank you,
John

John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 


Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@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.


Call
Send SMS
Call from mobile
Add to Skype
You'll need Skype CreditFree via Skype



Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@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.


[R] Blank spaces are replaced by period in read.csv, I want to replace blacks with an underline

2015-06-08 Thread John Sorkin
I am reading a csv file. The column headers have spaces in them. The spaces are 
replaced by a period. I want to replace the space by another character (e.g. 
the underline) rather than the period. Can someone tell me how to accomplish 
this?Thank you,
John

John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 


Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@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.


[R] Finite mixture model: truncated normal and a normal distribution

2015-06-04 Thread John Sorkin
I am looking for software that will take data what appears to come from a 
series of low numbers coming from a left-truncated normal distribution and a 
series of higher numbers coming from a normal distribution and produce the 
mean, SD, and mixing proportion of the two source distributions. I have looked 
at mixtoolsmixtools but it is not exactly what I am looking for as it models 
two-normal distributions (i.e. the lower of the two distributions is NOT 
truncated).

Any suggestions for a package, or an analysis plan would be appreciated.

Thank you,
John


John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 


Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@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.


Re: [R] [R-sig-ME] different results from lme and lmer function

2015-05-26 Thread John Sorkin
Ben,
I doubt the very small difference in log likelihood gives much, if any
information about which model is a better fit. Even if we overlook the
limited precision of the estimate of the REML criterion, the difference
is so small as to me of minimal importance.
John

> John David Sorkin M.D., Ph.D.
> Professor of Medicine
> Chief, Biostatistics and Informatics
> University of Maryland School of Medicine Division of Gerontology and
Geriatric Medicine
> Baltimore VA Medical Center
> 10 North Greene Street
> GRECC (BT/18/GR)
> Baltimore, MD 21201-1524
> (Phone) 410-605-7119
> (Fax) 410-605-7913 (Please call phone number above prior to faxing)


> On May 26, 2015, at 8:03 PM, Ben Bolker  wrote:
> 
>  These actually aren't terribly different from each other.  I suspect
> that lmer is slightly closer to the correct answer, because lme
> reports a "log-likelihood" (really -1/2 times the REML criterion) of
> 49.30021, while lmer reports a REML criterion of  -98.8 -> slightly
> better fit at -R/2 = 49.4.  The residual sds are 0.0447 (lme) vs.
> 0.0442 (lmer); the intercept sd estimate is 0.016 vs 0.0089,
> admittedly a bit low, and both month sds are very small.  lmer
> indicates a singular fit (correlation of -1).If you look at the
> confidence intervals on these estimates (confint(fitted_model) in
> lme4; intervals(fitted_model) in lme) I think you'll find that the
> confidence intervals are much wider than these differences (you may
> even find that lme reports that it can't give you the intervals
> because the Hessian [curvature] matrix is not positive definite).
> 
>  Both should be comparable to SAS PROC MIXED results, I think, if
> you get the syntax right ...
> 
>> On Tue, May 26, 2015 at 7:09 PM, li li  wrote:
>> Hi all,
>>  I am fitting a random slope and random intercept model using R. I
>> used both lme and lmer funciton for the same model. However I got
>> different results as shown below (different variance component
>> estimates and so on). I think that is really confusing. They should
>> produce close results. Anyone has any thoughts or suggestions. Also,
>> which one should be comparable to sas results?
>> Thanks!
>>  Hanna
>> 
>> ## using lme function
>>> mod_lme <- lme(ti  ~ type*months, random=~ 1+months|lot,
na.action=na.omit,
>> + data=one, control = lmeControl(opt = "optim"))
>>> summary(mod_lme)
>> Linear mixed-effects model fit by REML
>> Data: one
>>AIC   BIC   logLik
>>  -82.60042 -70.15763 49.30021
>> 
>> Random effects:
>> Formula: ~1 + months | lot
>> Structure: General positive-definite, Log-Cholesky parametrization
>>StdDev   Corr
>> (Intercept) 8.907584e-03 (Intr)
>> months  6.039781e-05 -0.096
>> Residual4.471243e-02
>> 
>> Fixed effects: ti ~ type * months
>> Value   Std.Error DF   t-value p-value
>> (Intercept) 0.25831245 0.016891587 31 15.292373  0.
>> type0.13502089 0.026676101  4  5.061493  0.0072
>> months  0.00804790 0.001218941 31  6.602368  0.
>> type:months -0.00693679 0.002981859 31 -2.326329  0.0267
>> Correlation:
>>   (Intr) typPPQ months
>> type   -0.633
>> months -0.785  0.497
>> type:months  0.321 -0.762 -0.409
>> 
>> Standardized Within-Group Residuals:
>>  MinQ1   MedQ3   Max
>> -2.162856e+00 -1.962972e-01 -2.771184e-05  3.749035e-01  2.088392e+00
>> 
>> Number of Observations: 39
>> Number of Groups: 6
>> 
>> 
>> 
>> 
>> ###Using lmer function
>>> mod_lmer <-lmer(ti  ~ type*months+(1+months|lot), na.action=na.omit,
data=one)
>>> summary(mod_lmer)
>> Linear mixed model fit by REML t-tests use Satterthwaite
approximations to
>>  degrees of freedom [merModLmerTest]
>> Formula: ti ~ type * months + (1 + months | lot)
>>   Data: one
>> 
>> REML criterion at convergence: -98.8
>> 
>> Scaled residuals:
>>Min  1Q  Median  3Q Max
>> -2.1347 -0.2156 -0.0067  0.>> lot  (Intercept) 2.870e-04 0.0169424
>>  months  4.135e-07 0.0006431 -1.00
>> Residual 1.950e-03 0.0441644
>> Number of obs: 39, groups:  lot, 6
>> 
>> Fixed effects:
>>Estimate Std. Errordf t value Pr(>|t|)
>> (Intercept) 0.258312   0.018661  4.82  13.842 4.59e-05 ***
>> type 0.135021   0.028880  6.802000   4.675  0.00245 **
>> months  0.008048   0.001259 11.943000   6.390 3.53e-05 ***
>> type:months -0.006937   0.002991 28.91  -2.319  0.02767 *
>> ---
>> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
>> 
>> Correlation of Fixed Effects:
>>(Intr) typPPQ months
>> type -0.646
>> months  -0.825  0.533
>> type:month  0.347 -0.768 -0.421
>> 
>> ___
>> r-sig-mixed-mod...@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> ht

Re: [R] Heatmap

2015-04-28 Thread John Sorkin
Look at the heatmap function 

> John David Sorkin M.D., Ph.D.
> Professor of Medicine
> Chief, Biostatistics and Informatics
> University of Maryland School of Medicine Division of Gerontology and 
> Geriatric Medicine
> Baltimore VA Medical Center
> 10 North Greene Street
> GRECC (BT/18/GR)
> Baltimore, MD 21201-1524
> (Phone) 410-605-7119
> (Fax) 410-605-7913 (Please call phone number above prior to faxing)


> On Apr 28, 2015, at 3:41 AM, John Wasige  wrote:
> 
> Dear all,
> 
> I need to make a heapmap of SPI results for a monthly timeseies of 30
> years. Does anybody know to do it?
> 
> Thanks for your help
> 
> John
> 
>[[alternative HTML version deleted]]
> 
> __
> R-help@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.

Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@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.


[R] error using by, Error in tapply(response, list(x.factor, trace.factor), fun) : argument "trace.factor" is missing, with no default

2015-04-20 Thread John Sorkin


I am receiving an error message from the by function that I don't understand:
Error in tapply(response, list(x.factor, trace.factor), fun) : 
  argument "trace.factor" is missing, with no default



My code follows:


> summary(ipd)
 group  valuestime  subjects weaned disp  
 1:55   Min.   :0.   Min.   :0   Min.   :115.0   1:65   2:45  
 2:35   1st Qu.:0.1950   1st Qu.:1   1st Qu.:121.0   2:25   3: 5  
Median :0.3400   Median :2   Median :126.0  4:20  
Mean   :0.3479   Mean   :2   Mean   :127.6  5:20  
3rd Qu.:0.5000   3rd Qu.:3   3rd Qu.:134.0
Max.   :0.7300   Max.   :4   Max.   :144.0
NA's   :48
> by(ipd[,c("time","subjects","values")],ipd[,"group"],interaction.plot)
Error in tapply(response, list(x.factor, trace.factor), fun) : 
  argument "trace.factor" is missing, with no default




These are my data.
> ipd
   group values time subjects weaned disp
1  1   0.000  115  12
2  1   0.001  115  12
3  1   0.182  115  12
4  1   0.173  115  12
5  1 NA4  115  12
6  1   0.620  116  12
7  1 NA1  116  12
8  1 NA2  116  12
9  1 NA3  116  12
10 1 NA4  116  12
11 1   0.000  118  12
12 1   0.211  118  12
13 1   0.342  118  12
14 1   0.493  118  12
15 1 NA4  118  12
16 2   0.520  119  24
17 2 NA1  119  24
18 2 NA2  119  24
19 2 NA3  119  24
20 2 NA4  119  24
21 2   0.350  121  23
22 2   0.531  121  23
23 2   0.352  121  23
24 2   0.443  121  23
25 2   0.564  121  23
26 1   0.160  122  15
27 1   0.221  122  15
28 1 NA2  122  15
29 1 NA3  122  15
30 1 NA4  122  15
31 1   0.190  123  25
32 1 NA1  123  25
33 1 NA2  123  25
34 1 NA3  123  25
35 1 NA4  123  25
36 2   0.290  124  14
37 2   0.221  124  14
38 2 NA2  124  14
39 2 NA3  124  14
40 2 NA4  124  14
41 1   0.380  125  14
42 1   0.451  125  14
43 1 NA2  125  14
44 1 NA3  125  14
45 1 NA4  125  14
46 1   0.220  127  12
47 1   0.371  127  12
48 1   0.282  127  12
49 1   0.503  127  12
50 1 NA4  127  12
51 1   0.300  130  12
52 1   0.491  130  12
53 1 NA2  130  12
54 1 NA3  130  12
55 1 NA4  130  12
56 1   0.700  131  12
57 1 NA1  131  12
58 1 NA2  131  12
59 1 NA3  131  12
60 1 NA4  131  12
61 2   0.000  133  12
62 2   0.501  133  12
63 2   0.562  133  12
64 2   0.733  133  12
65 2 NA4  133  12
66 1   0.220  134  12
67 1   0.651  134  12
68 1 NA2  134  12
69 1 NA3  134  12
70 1 NA4  134  12
71 2   0.340  135  12
72 2   0.731  135  12
73 2   0.712  135  12
74 2 NA3  135  12
75 2 NA4  135  12
76 2   0.260  139  25
77 2 NA1  139  25
78 2 NA2  139  25
79 2 NA3  139  25
80 2 NA4  139  25
81 1   0.000  140  15
82 1   0.191  140  15
83 1 NA2  140  15
84 1 NA3  140  15
85 1 NA4  140  15
86 2   0.190  144  24
87 2 NA1  144  24
88 2 NA2  144  24
89 2 NA3  144  24
90 2 NA4  144  24


John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Balti

[R] generate a list as follows: 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, . . . . ., n, n, n, n

2015-04-20 Thread John Sorkin
Windows 7 64-bit
R 3.1.3
RStudio 0.98.1103


I am trying to generate a list of  length 4n which consists of the integers 1 
to n repeated in groups of four, i.e.

1,1,1,1,  2,2,2,2,  3,3,3,3, . . . . , n,n,n,n

(The spaces in the list are added only for clarity.)

 I can generate the list as follows, but the code must be modified for any 
value n, and the code is UGLY!

c(rep(1,4), rep(2,4), rep(3,4), . . . ,c(n,4))

Can anyone help me?

Thank you,
John

John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 


Call
Send SMS
Add to Skype
You'll need Skype CreditFree via Skype

John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 




Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@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.


[R] generate a list as follows: 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, . . . . ., n, n, n, n

2015-04-20 Thread John Sorkin
Windows 7 64-bit
R 3.1.3
RStudio 0.98.1103


I am trying to generate a list of  length 4n which consists of the integers 1 
to n repeated in groups of four, i.e.

1,1,1,1,  2,2,2,2,  3,3,3,3, . . . . , n,n,n,n

(The spaces in the list are added only for clarity.)

 I can generate the list as follows, but the code must be modified for any 
value n, and the code is UGLY!

c(rep(1,4), rep(2,4), rep(3,4), . . . ,c(n,4))

Can anyone help me?

Thank you,
John

John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 


Call
Send SMS
Add to Skype
You'll need Skype CreditFree via Skype


John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 


Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@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.


[R] generate a list as follows: 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, . . . . ., n, n, n, n

2015-04-20 Thread John Sorkin
Windows 7 64-bit
R 3.1.3
RStudio 0.98.1103



I am trying to generate a list of  length 4n which consists of the integers 1 
to n repeated in groups of four, i.e.


1,1,1,1,  2,2,2,2,  3,3,3,3, . . . . , n,n,n,n


(The spaces in the list are added only for clarity.)


 I can generate the list as follows, but the code must be modified for any 
value n, and the code is UGLY!


c(rep(1,4), rep(2,4), rep(3,4), . . . ,c(n,4))


Can anyone help me?


Thank you,
John

John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 


Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@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.


[R] error using by, Error in tapply(response, list(x.factor, trace.factor), fun) : argument "trace.factor" is missing, with no default

2015-04-20 Thread John Sorkin


I am receiving an error message from the by function that I don't understand:
Error in tapply(response, list(x.factor, trace.factor), fun) : 
  argument "trace.factor" is missing, with no default



My code follows:


> summary(ipd)
 group  valuestime  subjects weaned disp  
 1:55   Min.   :0.   Min.   :0   Min.   :115.0   1:65   2:45  
 2:35   1st Qu.:0.1950   1st Qu.:1   1st Qu.:121.0   2:25   3: 5  
Median :0.3400   Median :2   Median :126.0  4:20  
Mean   :0.3479   Mean   :2   Mean   :127.6  5:20  
3rd Qu.:0.5000   3rd Qu.:3   3rd Qu.:134.0
Max.   :0.7300   Max.   :4   Max.   :144.0
NA's   :48
> by(ipd[,c("time","subjects","values")],ipd[,"group"],interaction.plot)
Error in tapply(response, list(x.factor, trace.factor), fun) : 
  argument "trace.factor" is missing, with no default




These are my data.
> ipd
   group values time subjects weaned disp
1  1   0.000  115  12
2  1   0.001  115  12
3  1   0.182  115  12
4  1   0.173  115  12
5  1 NA4  115  12
6  1   0.620  116  12
7  1 NA1  116  12
8  1 NA2  116  12
9  1 NA3  116  12
10 1 NA4  116  12
11 1   0.000  118  12
12 1   0.211  118  12
13 1   0.342  118  12
14 1   0.493  118  12
15 1 NA4  118  12
16 2   0.520  119  24
17 2 NA1  119  24
18 2 NA2  119  24
19 2 NA3  119  24
20 2 NA4  119  24
21 2   0.350  121  23
22 2   0.531  121  23
23 2   0.352  121  23
24 2   0.443  121  23
25 2   0.564  121  23
26 1   0.160  122  15
27 1   0.221  122  15
28 1 NA2  122  15
29 1 NA3  122  15
30 1 NA4  122  15
31 1   0.190  123  25
32 1 NA1  123  25
33 1 NA2  123  25
34 1 NA3  123  25
35 1 NA4  123  25
36 2   0.290  124  14
37 2   0.221  124  14
38 2 NA2  124  14
39 2 NA3  124  14
40 2 NA4  124  14
41 1   0.380  125  14
42 1   0.451  125  14
43 1 NA2  125  14
44 1 NA3  125  14
45 1 NA4  125  14
46 1   0.220  127  12
47 1   0.371  127  12
48 1   0.282  127  12
49 1   0.503  127  12
50 1 NA4  127  12
51 1   0.300  130  12
52 1   0.491  130  12
53 1 NA2  130  12
54 1 NA3  130  12
55 1 NA4  130  12
56 1   0.700  131  12
57 1 NA1  131  12
58 1 NA2  131  12
59 1 NA3  131  12
60 1 NA4  131  12
61 2   0.000  133  12
62 2   0.501  133  12
63 2   0.562  133  12
64 2   0.733  133  12
65 2 NA4  133  12
66 1   0.220  134  12
67 1   0.651  134  12
68 1 NA2  134  12
69 1 NA3  134  12
70 1 NA4  134  12
71 2   0.340  135  12
72 2   0.731  135  12
73 2   0.712  135  12
74 2 NA3  135  12
75 2 NA4  135  12
76 2   0.260  139  25
77 2 NA1  139  25
78 2 NA2  139  25
79 2 NA3  139  25
80 2 NA4  139  25
81 1   0.000  140  15
82 1   0.191  140  15
83 1 NA2  140  15
84 1 NA3  140  15
85 1 NA4  140  15
86 2   0.190  144  24
87 2 NA1  144  24
88 2 NA2  144  24
89 2 NA3  144  24
90 2 NA4  144  24


John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Balti

[R] generate a list as follows: 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, . . . . ., n, n, n, n

2015-04-20 Thread John Sorkin
Windows 7 64-bit
R 3.1.3
RStudio 0.98.1103


I am trying to generate a list of  length 4n which consists of the integers 1 
to n repeated in groups of four, i.e.

1,1,1,1,  2,2,2,2,  3,3,3,3, . . . . , n,n,n,n

(The spaces in the list are added only for clarity.)

 I can generate the list as follows, but the code must be modified for any 
value n, and the code is UGLY!

c(rep(1,4), rep(2,4), rep(3,4), . . . ,c(n,4))

Can anyone help me?

Thank you,
John

John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 


Call
Send SMS
Add to Skype
You'll need Skype CreditFree via Skype

John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 



John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 




John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 


Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@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.


[R] generate a list as follows: 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, . . . . ., n, n, n, n

2015-04-19 Thread John Sorkin
Windows 7 64-bit
R 3.1.3
RStudio 0.98.1103


I am trying to generate a list of  length 4n which consists of the integers 1 
to n repeated in groups of four, i.e.

1,1,1,1,  2,2,2,2,  3,3,3,3, . . . . , n,n,n,n

(The spaces in the list are added only for clarity.)

 I can generate the list as follows, but the code must be modified for any 
value n, and the code is UGLY!

c(rep(1,4), rep(2,4), rep(3,4), . . . ,c(n,4))

Can anyone help me?

Thank you,
John

John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 


Call
Send SMS
Add to Skype
You'll need Skype CreditFree via Skype

John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 




John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 


Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@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.


[R] library(xlsx) fails with an error: Error: package ‘rJava’ could not be loaded

2015-04-18 Thread John Sorkin
Windows 7 64-bit
R 3.1.3
RStudio 0.98.1103


I am having difficulty loading and installing the xlsx package. The
loading occurred without any problem, however the library command
library(xlsx) produced an error related to rJava. I tried to install
rJava seperately, re-loaded the xlsx package, and entered the
library(xlsx) command but received the same error message about rJave.
Please see terminal messages below. Any suggestion that would allow me
to load and run xlsx would be appreciated.
Thank you,
John


> install.packages("xlsx")
Installing package into ‘C:/Users/John/Documents/R/win-library/3.1’
(as ‘lib’ is unspecified)
trying URL
'http://cran.rstudio.com/bin/windows/contrib/3.1/xlsx_0.5.7.zip'
Content type 'application/zip' length 400944 bytes (391 KB)
opened URL
downloaded 391 KB


package ‘xlsx’ successfully unpacked and MD5 sums checked


The downloaded binary packages are in
C:\Users\John\AppData\Local\Temp\Rtmp4CO5m7\downloaded_packages
> library(xlsx)
Loading required package: rJava
Error : .onLoad failed in loadNamespace() for 'rJava', details:
  call: inDL(x, as.logical(local), as.logical(now), ...)
  error: unable to load shared object
'C:/Users/John/Documents/R/win-library/3.1/rJava/libs/x64/rJava.dll':
  LoadLibrary failure:  The specified module could not be found.


Error: package ‘rJava’ could not be loaded
> install.packages("rJava")
Installing package into ‘C:/Users/John/Documents/R/win-library/3.1’
(as ‘lib’ is unspecified)
trying URL
'http://cran.rstudio.com/bin/windows/contrib/3.1/rJava_0.9-6.zip'
Content type 'application/zip' length 759396 bytes (741 KB)
opened URL
downloaded 741 KB


package ‘rJava’ successfully unpacked and MD5 sums checked


The downloaded binary packages are in
C:\Users\John\AppData\Local\Temp\Rtmp4CO5m7\downloaded_packages
> library(rJava)
Error : .onLoad failed in loadNamespace() for 'rJava', details:
  call: inDL(x, as.logical(local), as.logical(now), ...)
  error: unable to load shared object
'C:/Users/John/Documents/R/win-library/3.1/rJava/libs/x64/rJava.dll':
  LoadLibrary failure:  The specified module could not be found.


Error: package or namespace load failed for ‘rJava’
> library(xlsx)
Loading required package: rJava
Error : .onLoad failed in loadNamespace() for 'rJava', details:
  call: inDL(x, as.logical(local), as.logical(now), ...)
  error: unable to load shared object
'C:/Users/John/Documents/R/win-library/3.1/rJava/libs/x64/rJava.dll':
  LoadLibrary failure:  The specified module could not be found.


Error: package ‘rJava’ could not be loaded


John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and
Geriatric Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 


Confidentiality Statement:
This email message, including any attachments, is for the sole use of
the intended recipient(s) and may contain confidential and privileged
information. Any unauthorized use, disclosure or distribution is
prohibited. If you are not the intended recipient, please contact the
sender by reply email and destroy all copies of the original message. 
__
R-help@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.

Re: [R] Running R Remotely on LINUX

2015-04-14 Thread John Sorkin
 I suggest that you investigate installing RStudio server on the Linux
Box. If you do this, you can logon to RStudio (on the Linux server), and
it will look exactly like RStudio running on a windows box. You may need
some help configuring the Linux box to allow access to port 8787, which
is the default port that RStudio Server uses. You may also have to set
port forwarding on your cable modem or firewall.
John  


John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and
Geriatric Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 
>>> Jeff Newmiller  04/14/15 2:54 PM >>>
You should investigate using the parallel package. You have to have R
installed on the Linux machine along with any contributed packages you
use, but you can delegate tasks to it from within an Rgui or RStudio
session running on your Windows box. There are even tutorials online
that step you through setting up a "cloud" computer to serve this
purpose.

It is possible to install R under your own account on a Linux server,
but there are more hiccups to overcome in doing so. There is a small
charge for using cloud servers, but if you use it right then the cost
can be quite cheap.

Note that while you can set up Windows servers in the cloud, they are
not as well suited to this remote use as Linux servers are, so it is
worth the effort to learn enough to do that.
---
Jeff Newmiller The . . Go Live...
DCN: Basics: ##.#. ##.#. Live Go...
 Live: OO#.. Dead: OO#.. Playing
Research Engineer (Solar/Batteries O.O#. #.O#. with
/Software/Embedded Controllers) .OO#. .OO#. rocks...1k
---

Sent from my phone. Please excuse my brevity.

On April 14, 2015 9:57:28 AM PDT, Michael Haenlein
 wrote:
>Dear all,
>
>I am used to running R locally on my Windows-based PC. Since some of my
>computations are taking a lot of time I am now trying to move to a
>remote R
>session on a LINUX server but I am having trouble to getting things
>work.
>
>I am able to access the LINUX server using PuTTY and SSH. Once I have
>access I can log in with my username and password (which is asked
>through
>keyboard-interactive authentication). I can then open an R session.
>
>Since I am not used to working with LINUX, I have several questions:
>
>(1) Ideally I am looking for a Windows-based software that would allow
>me
>to work on R as I am used to with the difference that the computations
>are
>run remotely on the LINUX server. Does a software like this exist?
>Please
>note that I do not think that I can install any software on the LINUX
>server. But I can install stuff on my Windows-based PC.
>
>(2) I am running an extensive simulation that takes about one week to
>run.
>Right now it seems that when I log out of R on LINUX and close PuTTY,
>the R
>session closes as well. Is there a way to let R run in the background
>for
>the week and just check into the progress 1-2 times a day?
>
>(3) Can I open several instances of R in parallel? On my PC I sometimes
>have 2-3 windows open in parallel that work on different calculations
>to
>save time. Not sure to which extent this is possible on LINUX.
>
>I assume that this questions are very naïve. But since I’m only used to
>working with Windows I’m quite stuck at the moment. Any help would be
>very
>appreciated!
>
>Thanks in advance,
>
>Michael
>
>
>
>
>Michael Haenlein
>Professor of Marketing
>ESCP Europe
>
>[[alternative HTML version deleted]]
>
>__
>R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/m>and provide commented, minimal, self-contained, 
>reproducible code.

__
R-help@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.
Confidentiality Statement:
This email message, including any attachments, is for the sole use of
the intended recipient(s) and may contain confidential and privileged
information. Any unauthorized use, disclosure or distribution is
prohibited. If you are not the intended recipient, please contact the
sender by reply email and destroy all copies of the original message. 
__
R-help@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.

[R] Trying to understand a function passed to lapply

2015-03-30 Thread John Sorkin
Colleagues,
I am trying to understand the syntax of a function passed to apply. The code 
below generates a matrix, and passes the matrix to a function that is called by 
apply. I don't understand the syntax of the function. In some way the function 
computes data[,"delta"]/data[,"SE"]. I can't understand how the body of the 
function, x[c1]/x[c2] refers to the columns "data" and "SE" of the matrix data. 
Can someone help me understand the syntax? 
Thank you,
John

myfun <- function(x, c1, c2) x[c1]/x[c2]
apply(data,1,myfun,c1="delta",c2="SE")

CODE:

data<-matrix(data=c(-0.70 ,-0.90, -0.50, 20, 20,
-0.30 ,-0.43, -0.17, 43, 43,
-0.50 ,-1.05,  0.05, 16, 18,
 0.00 ,-0.21,  0.21, 22, 23,
-1.30 ,-1.48, -1.12, 28, 32,
-0.90 ,-1.01, -0.79, 18, 15,
-0.20 ,-0.47,  0.07, 39, 39,
-0.30 ,-0.83,  0.23, 27, 27),
 nrow=8,ncol=5,byrow=TRUE)
dimnames(data) <- list(NULL,c("delta","low","high","n1","n2"))
data
CI <- data[,"high"]-data[,"low"]
data <- cbind(data,CI)
data
data <- cbind(data,SE=data[,"CI"]/(4*1.96))
data
data <- cbind(data,SD=data[,"SE"]*sqrt(data[,"n1"]+data[,"n2"]))
data
myfun <- function(x, c1, c2) x[c1]/x[c2]
apply(data,1,myfun,c1="delta",c2="SE")

John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 

Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@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.


Re: [R] multiple imputation of longitudinal, time-unstructured data

2015-02-17 Thread John Sorkin
Pam,
Please let me know what you discover. I just started looking at a similar 
problem. I understand
 that a Kalman filter can sometimes be applied to this problem,
but at this time I don't know how to accomplish this.
John


John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 


>>> Pam Dopart  2/17/2015 4:02 PM >>>
Hello!

I have a longitudinal dataset of radiation exposures of an occupational
cohort. A percentage of the exposure values are missing and I would like to
multiply impute the missing values (it is one option of several we are
comparing). The data are recorded in long format (one row for each exposure
entry) and there are multiple exposure measurements per worker. However,
the data are time-unstructured (different data collection schedules for
each worker) and unbalanced.

I want to account for the correlation between repeated measurements on the
same worker. However, because of the time-unstructured nature of the
dataset, I am unable to convert my dataset into wide format and impute that
way. I have begun reading about about using multilevel imputation for such
a scenario, but I rather unfamiliar with this approach, including within R.
Is this an appropriate method to investigate?

Any advice on how to get started would be greatly appreciated!

Thank you!

Pam

[[alternative HTML version deleted]]

__
R-help@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.

Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@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.


[R] lme: Can not find groupData object in a function could this be a scoping problem?

2015-02-13 Thread John Sorkin
I resolved my program by restating RStudio . . .
Thanks you,
John


R 3.1.0, RStudio  0.98.95
Windows 7

I have written a function that uses lme:

doit<- function(TS,rho,premean,presd,RxEffect) {
.
.
.
  # Prepare data frames for regression analyses.
  data <- data.frame(group=c(rep("Cont",SS),rep("Exp",SS)),
   pre=pre,post=post)  
.
.
.
  
previous<-data.frame(time=c("pre","post"),cbind(subject=i,group=data[i,"group"],t(data[i,c("pre","post")])))
. 

.
.
  inter<-groupedData(value~as.integer(time)+as.integer(group)+
 as.integer(time)*as.integer(group)|subject,
 inner=~group,data=previous)

  print(inter)
  lmeinter<-lme(inter)
.
.
.
}

When I run the code, at the statement,lmeinter<-lme(inter)  I get a message:
Error in is.data.frame(data) : object 'inter' not found.
Please note that the print statement, print(inter) prints the groupedData 
object!
The code works fine when it is not in a function, i.e. 


  inter<-groupedData(value~as.integer(time)+as.integer(group)+
 as.integer(time)*as.integer(group)|subject,
 inner=~group,data=previous)

  lmeinter<-lme(inter)



runs and has no problem finding inter.


Can someone suggest what I might change to fix the problem? I think I may have 
a scoping problem but I am not knowledgeable enough to know (1) how to check 
this and (2) what to do to fix it.


Thanks,
John




John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 



John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 


Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@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.


[R] lme: Can not find groupData object in a function could this be a scoping problem?

2015-02-13 Thread John Sorkin
R 3.1.0, RStudio  0.98.95
Windows 7


I have written a function that uses lme:


doit<- function(TS,rho,premean,presd,RxEffect) {
.
.
.
  # Prepare data frames for regression analyses.
  data <- data.frame(group=c(rep("Cont",SS),rep("Exp",SS)),
   pre=pre,post=post)  
.
.
.
  
previous<-data.frame(time=c("pre","post"),cbind(subject=i,group=data[i,"group"],t(data[i,c("pre","post")])))
. 

.
.
  inter<-groupedData(value~as.integer(time)+as.integer(group)+
 as.integer(time)*as.integer(group)|subject,
 inner=~group,data=previous)

  print(inter)
  lmeinter<-lme(inter)
.
.
.
}


When I run the code, at the statement,lmeinter<-lme(inter)  I get a message:
Error in is.data.frame(data) : object 'inter' not found.
Please note that the print statement, print(inter) prints the groupedData 
object!
The code works fine when it is not in a function, i.e. 


  inter<-groupedData(value~as.integer(time)+as.integer(group)+
 as.integer(time)*as.integer(group)|subject,
 inner=~group,data=previous)

  lmeinter<-lme(inter)



runs and has no problem finding inter.


Can someone suggest what I might change to fix the problem? I think I may have 
a scoping problem but I am not knowledgeable enough to know (1) how to check 
this and (2) what to do to fix it.


Thanks,
John




John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 


Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@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.


[R] Installing RStudio

2015-02-12 Thread John Sorkin
Windows 7, 64-bit.
 
I am trying to install RStudio. Before installing RStudio, I installed R 3.1.2. 
During the installation or R, I installled (as per the default) 32- and 64-bit 
packages. When I tried to install RStudio, I received the message
R does not appear to be installed. Please install R before using RStudio.
I know R is installed, beacuse I am able to run R.
Can anyone suggest what I can do to get RStudio installed?
Thank you
John
 
John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 

Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@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.


[R] Impute time-series data, perhaps with a Kalman filter - do you know of any R code?

2015-02-11 Thread John Sorkin
Does anyone have code that uses a Kalman filter to impute time-series data? If 
not, do you know of any software that can be used to impute time-series data?
Thank you,
John
John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 

Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@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.


[R] aov and Error function

2015-01-31 Thread John Sorkin
I am trying to understand the Error function and its use in ANOVA. In 
particular I want to understand the difference between two models that differ 
only with respect to the Error statement:


aovsubj<- aov(value~group+time+Error(subject),data=dataRMANOVA)
and
aovsubjgroup<-aov(value~group+time+Error(subject/group),data=dataRMANOVA)
 
You will note that in my data I have two subject identifiers, subject and 
subject2. I am also trying to trying to understand how I should identify 
subjects, within group (i.e. intervention vs. control) or within time 
(0=baseline, 1=post)


> dataRMANOVA
   value time group subject subject2
1   1.000   int   11
2   2.000   int   22
3   3.000   int   33
4   4.000   int   44
5   5.000   int   55
6   6.000   int   66
7   7.000   int   77
8   8.000   int   88
9   9.000   int   99
10 10.000   int  10   10
11 11.000   int  11   11
12 12.000   int  12   12
13 13.000   int  13   13
14 14.000   int  14   14
15 15.000   int  15   15
16 16.000   int  16   16
17 17.000   int  17   17
18 18.000   int  18   18
19 19.000   int  19   19
20 20.000   int  20   20
21 21.000  cont   1   21
22 22.000  cont   2   22
23 23.000  cont   3   23
24 24.000  cont   4   24
25 25.000  cont   5   25
26 26.000  cont   6   26
27 27.000  cont   7   27
28 28.000  cont   8   28
29 29.000  cont   9   29
30 30.000  cont  10   30
31 31.000  cont  11   31
32 32.000  cont  12   32
33 33.000  cont  13   33
34 34.000  cont  14   34
35 35.000  cont  15   35
36 36.000  cont  16   36
37 37.000  cont  17   37
38 38.000  cont  18   38
39 39.000  cont  19   39
40 40.000  cont  20   40
41  2.8791311   int   11
42  1.5336511   int   22
43  2.4877561   int   33
44  3.4460681   int   44
45  5.1798541   int   55
46  5.7758191   int   66
47  6.9239791   int   77
48  8.1637341   int   88
49  9.5459741   int   99
50  8.7921861   int  10   10
51 11.6575031   int  11   11
52 12.6813931   int  12   12
53 15.0586881   int  13   13
54 13.7576731   int  14   14
55 15.4590291   int  15   15
56 15.5355491   int  16   16
57 16.4332371   int  17   17
58 17.2473301   int  18   18
59 19.0619271   int  19   19
60 21.1650031   int  20   20
61 20.4367051  cont   1   21
62 23.1432301  cont   2   22
63 23.4569461  cont   3   23
64 23.1322841  cont   4   24
65 24.9020171  cont   5   25
66 26.4503991  cont   6   26
67 27.3569431  cont   7   27
68 27.4020231  cont   8   28
69 29.7598831  cont   9   29
70 27.9696281  cont  10   30
71 30.0614751  cont  11   31
72 32.5324271  cont  12   32
73 33.3788771  cont  13   33
74 34.8522441  cont  14   34
75 34.9585941  cont  15   35
76 35.6732251  cont  16   36
77 37.9082081  cont  17   37
78 37.9824711  cont  18   38
79 39.0169171  cont  19   39
80 39.5075831  cont  20   40


Thank you,
John


John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 


Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@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.


[R] repeated measures ANOVA

2015-01-30 Thread John Sorkin
Windows 7, R 3.1.0
 
How does one run repeated measures ANOVA using R for
(1) A balanced design
(2) An unbalanced design.
so that one will get an ANOVA table?
I have seen references to the Anova function in the car package, but this seems 
to have been deprecated.
Thank you,
John


John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 

Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@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.


[R] RStudio connection to server: Safari cannot open page because it could not connect to the server

2015-01-15 Thread John Sorkin
I set up Rstudio, and can access it from within my lan using 
http:/192.168.108:8787.
I looked up my external IP address using one of the websites that returns an ip 
addresses and tried to connect from outside my LAN using
http://73.213.144.65:8787
and received a message:
Safari cannot open the page because the page because it could not connect to 
the server. 
I can ping the 73.213.144.65

My LAN connects to the WWW through a wireless router which connects to a cable 
model.

Can anyone help me connect?
Thank you,
John


John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 

Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@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.


[R] Install R on linux Mint

2015-01-14 Thread John Sorkin
I am trying to install R on Linux mint 17.1. I followed the instructions found 
on CRAN and got a messages about unmet dependencies. I detail below the steps I 
took:

I added deb http://lib.stat.cmu.edu/R/CRAN/bin/linux/ubuntu utopic/
to /etc/apt/sources.list
As can be seen below:

john-OptiPlex-GX270 apt # more sources.list
#deb cdrom:[Linux Mint 17.1 _Rebecca_ - Release i386 20141126]/ trusty contrib 
main non-free
deb http://lib.stat.cmu.edu/R/CRAN/bin/linux/ubuntu utopic/

And then followed the instructions on CRAN:

sudo apt-get update
AND RECEIVED THE FOLLOWING MESSAGE:

Fetched 316 kB in 8s (39.5 kB/s)   
Reading package lists... Done
W: GPG error: http://lib.stat.cmu.edu utopic/ Release: The following signatures 
couldn't be verified because the public key is not available: NO_PUBKEY 
51716619E084DAB9

sudo apt-get install r-base
AND RECEIVED THE FOLLOWING MESSAGE:

The following packages have unmet dependencies:
 r-base : Depends: r-base-core (>= 3.1.2-1utopic0) but 3.0.2-1ubuntu1 is to be 
installed
  Depends: r-recommended (= 3.1.2-1utopic0) but it is not going to be 
installed
E: Unable to correct problems, you have held broken packages.

John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 

Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@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.


Re: [R] R vs. RStudio?

2015-01-10 Thread John Sorkin
I urge you to try it.
John


John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 


>>> Bert Gunter  1/10/2015 9:46 PM >>>
That is what websites are for. Go to rstudio.com and make your own judgment
. I have found that they provide much useful functionality above and beyond
R's bare bones GUI.

Bert

On Saturday, January 10, 2015, Boris Steipe 
wrote:

> Could someone kindly enlighten me whether there are currently advantages
> to use R Studio vs. the normal R GUI? On the Mac I can't seem to find
> anything compelling, on Windows (which I don't use myself) I noticed last
> year that there seems to be no syntax highlighting available for the R GUI
> but R Studio had it.
>
> Surely there must be some value proposition in that project, what am I
> missing?
>
> Thanks,
> Boris
> __
> R-help@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.
>


-- 

Bert Gunter
Genentech Nonclinical Biostatistics
(650) 467-7374

"Data is not information. Information is not knowledge. And knowledge is
certainly not wisdom."
Clifford Stoll

[[alternative HTML version deleted]]

__
R-help@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.

Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@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.


Re: [R] Getting column names in the titles of histograms generated automatically

2015-01-07 Thread John Sorkin
Richard,
WOW! A totally new way to think about loop indices, many, many, thanks!John



John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 

>>> "Richard M. Heiberger"  01/07/15 10:27 PM >>>
tmp <- data.frame(a=rnorm(10), b=rnorm(10))
for (i in names(tmp)) hist(tmp[[i]], main=paste("histogram of", i))


On Wed, Jan 7, 2015 at 10:13 PM, John Sorkin
 wrote:
> I am trying to automatically produce a series of histograms from every column 
> of data frame with many columns.
> The columns names of a shortened from of the data frame follow:
>
>
> colnames<-names(smdata)
> colnames
> [1] "X13594_pre" "X15568_pre"
>
>
> I want to have
> X13594_pre in the title of the first histogram and
> X15568_pre in the title of the second histogram.
>
>
> I use the following code to automatically generate my histograms:
>
>
> for (i in 1:2){hist(smdata[,colnames[i]])}
>
>
> The titles of the histograms produced are:
> Histogram of smdata[,colnames[i]]
> and
> Histogram of smdata[,colnames[i]]
>
>
> How can I get the titles
> Histogram of smdata[,X13594_pre]
> and
> Histogram of smdata[,X15568_pre]
>
>
> John David Sorkin M.D., Ph.D.
> Professor of Medicine
> Chief, Biostatistics and Informatics
> University of Maryland School of Medicine Division of Gerontology and 
> Geriatric Medicine
> Baltimore VA Medical Center
> 10 North Greene Street
> GRECC (BT/18/GR)
> Baltimore, MD 21201-1524
> (Phone) 410-605-7119
> (Fax) 410-605-7913 (Please call phone number above prior to faxing)
>
>
> Confidentiality Statement:
> This email message, including any attachments, is for the sole use of the 
> intended recipient(s) and may contain confidential and privileged 
> information. Any unauthorized use, disclosure or distribution is prohibited. 
> If you are not the intended recipient, please contact the sender by reply 
> email and destroy all copies of the original message.
> __
> R-help@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.




Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@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.


[R] Getting column names in the titles of histograms generated automatically

2015-01-07 Thread John Sorkin
I am trying to automatically produce a series of histograms from every column 
of data frame with many columns.
The columns names of a shortened from of the data frame follow:


colnames<-names(smdata)
colnames
[1] "X13594_pre" "X15568_pre"


I want to have 
X13594_pre in the title of the first histogram and 
X15568_pre in the title of the second histogram.


I use the following code to automatically generate my histograms:


for (i in 1:2){hist(smdata[,colnames[i]])}


The titles of the histograms produced are:
Histogram of smdata[,colnames[i]]
and
Histogram of smdata[,colnames[i]]


How can I get the titles 
Histogram of smdata[,X13594_pre]
and
Histogram of smdata[,X15568_pre]


John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 


Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@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.


[R] normalmixEM does not produce the same results when run twice using the same data.

2014-12-31 Thread John Sorkin
Windows 7


I am running normalmixEM to fit two normal curves to my data. For some reason, 
that I don't understand, the results of running the function twice, on the same 
data, results in two different (although similar) sets of values. I would 
expect the function run twice on the same data would give exactly the same 
results!


I ran the program below and got the following results:


lambda1 mu1 lambda1 lambda2 lambda2 mu2 
  0.5030387  31.5172824   0.5030387   0.4969613   0.4969613 104.9249404 
> run2
lambda1 mu1 lambda1 lambda2 lambda2 mu2 
  0.5030406  31.5174149   0.5030406   0.4969594   0.4969594 104.9251556 





#Define data
John<-c(9.181 ,9.464 ,9.464 ,10.265 ,11.477 ,11.477 ,11.477 ,12.361,
12.361 ,12.361 ,12.361 ,12.985 ,12.985 ,13.384 ,13.384 ,13.962,
14.517 ,14.698 ,14.698 ,14.698 ,14.698 ,15.398 ,15.398 ,16.231,
16.231 ,16.552 ,16.552 ,16.711 ,16.711 ,17.481 ,17.481 ,17.481,
17.927 ,18.506 ,18.506 ,18.928 ,18.928 ,18.928 ,19.612 ,19.612,
19.745 ,19.745 ,20.530 ,20.530 ,21.162 ,21.162 ,21.162 ,21.162,
21.162 ,21.776 ,21.776 ,22.607 ,22.607 ,22.723 ,22.954 ,23.408,
23.632 ,25.353 ,25.353 ,25.663 ,25.663 ,25.663 ,25.969 ,26.171,
26.171 ,26.171 ,26.768 ,27.544 ,27.640 ,27.640 ,27.735 ,28.761,
29.215 ,29.840 ,30.190 ,30.881 ,30.881 ,31.220 ,31.220 ,31.220,
31.888 ,31.888 ,32.135 ,32.461 ,32.461 ,32.623 ,33.104 ,34.123,
35.855 ,35.928 ,35.928 ,36.293 ,36.293 ,37.012 ,37.366 ,37.366,
37.366 ,37.647 ,37.850 ,37.856 ,37.856 ,38.202 ,38.202 ,38.954,
39.021 ,39.089 ,39.089 ,39.223 ,39.491 ,39.624 ,40.153 ,40.609,
40.868 ,41.380 ,41.380 ,42.200 ,42.324 ,42.324 ,42.324 ,43.126,
43.853 ,43.853 ,44.152 ,44.568 ,45.213 ,45.446 ,45.562 ,46.193,
46.193 ,46.421 ,47.320 ,48.203 ,48.257 ,49.284 ,49.656 ,50.550,
50.550 ,51.938 ,52.342 ,52.342 ,52.342 ,52.393 ,53.586 ,53.733,
54.560 ,55.184 ,55.280 ,56.691 ,57.384 ,57.384 ,57.522 ,59.856,
59.856 ,60.599 ,61.975 ,65.004 ,68.861 ,69.052 ,69.811 ,70.897,
71.267 ,71.489 ,73.056 ,74.485 ,74.732 ,75.189 ,76.439 ,77.126,
77.670 ,77.975 ,78.514 ,80.338 ,80.600 ,83.173 ,83.205 ,83.553,
84.181 ,84.960 ,86.160 ,86.405 ,86.618 ,87.646 ,89.284 ,89.401,
89.989 ,90.456 ,90.892 ,90.892 ,90.950 ,91.412 ,91.729 ,92.072,
92.273 ,92.330 ,92.529 ,92.870 ,93.661 ,94.194 ,94.640 ,94.807,
95.029 ,95.112 ,95.885 ,96.132 ,96.869 ,97.438 ,97.600 ,98.567,
99.020 ,99.020 ,99.127 ,100.683 ,100.683 ,101.231 ,102.266 ,102.498,
102.883 ,103.113 ,103.291 ,103.800 ,103.927 ,104.332 ,104.685 ,104.685,
104.710 ,105.911 ,106.333 ,107.073 ,107.123 ,107.172 ,107.172 ,107.907,
107.907 ,108.272 ,108.272 ,108.345 ,108.564 ,108.758 ,109.338 ,110.201,
110.201 ,110.559 ,111.130 ,111.438 ,111.556 ,112.004 ,112.004 ,112.004,
112.684 ,112.940 ,112.940 ,113.034 ,113.661 ,113.661 ,113.962 ,113.985,
114.031 ,114.607 ,114.607 ,114.768 ,115.249 ,115.797 ,116.069 ,116.160,
117.041 ,117.154 ,117.983 ,118.473 ,118.473 ,118.495 ,118.495 ,118.762,
119.027 ,120.501 ,120.959 ,122.000 ,122.022 ,123.396 ,123.609 ,123.737,
124.035 ,124.416 ,124.818 ,124.881 ,124.881 ,125.071 ,125.387 ,125.576,
127.636 ,128.089 ,128.233 ,132.675 ,133.566 ,134.509 ,134.666 ,135.037,
135.504 ,136.589 ,138.675 ,141.961 ,144.608 ,155.222 ,158.646 ,168.502)


# First run of normalmixEM
mixmdl = normalmixEM(John)
run1<-c(lambda1=mixmdl$lambda[1],mu1=mixmdl$mu[1],lambda=mixmdl$lambda,lambda2=mixmdl$lambda[2],mu2=mixmdl$mu[2])
#Second run of normalmixEM
mixmdl = normalmixEM(John)


# Results are not the same!
run2<-c(lambda1=mixmdl$lambda[1],mu1=mixmdl$mu[1],lambda=mixmdl$lambda,lambda2=mixmdl$lambda[2],mu2=mixmdl$mu[2])
run1
run2








John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 


Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@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.


Re: [R] Can not save files

2014-12-31 Thread John Sorkin
David,
I checked getwd()
and tried to save to the directory. It did not work:


> getwd()
[1] "C:/Users/John/Documents"
> save(TheResults,file="c:\\users\\john\\documents")
Error in gzfile(file, "wb") : cannot open the connection
In addition: Warning message:
In gzfile(file, "wb") :
  cannot open compressed file 'c:\users\john\documents', probable reason
'Permission denied'
> 


Any thoughts?


Thanks,
John





John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and
Geriatric Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 

>>> David Winsemius  12/31/14 8:52 PM >>>

On Dec 31, 2014, at 3:29 PM, John Sorkin wrote:

> When I try to save a file, I get "Permission denied". 

Because your OS does not allow you to save things there. Since you are
specifying an absolute path, R is not using your working directory. You
may want to read the help pages for:

?normalizePath
?getwd

> Can someone let me know why this happens?
> 
> 
> I am running under Windows 7, Rstudio
> 
> 
>> save(TheResults,file="c:\\data")
> Error in gzfile(file, "wb") : cannot open the connection
> In addition: Warning message:
> In gzfile(file, "wb") :
>  cannot open compressed file 'c:\data', probable reason 'Permission
> denied'
> 

Permissions are not available on your machine at the Windows equivalent
of the "root". You should educate yourself about your operating system.


> 
>> save(TheResults,file="c:/data")
> Error in gzfile(file, "wb") : cannot open the connection
> In addition: Warning message:
> In gzfile(file, "wb") :
>  cannot open compressed file 'c:/data', probable reason 'Permission
> denied'
> 
> 
>> sessionInfo()
> R version 3.1.0 (2014-04-10)
> Platform: i386-w64-mingw32/i386 (32-bit)
> 
>> library(rstudio)
>> versionInfo()
> $version
> [1] ‘0.98.953’
> 
> $mode
> [1] "desktop"
> 
> 
> Thank you
> John
> 
> 
> John David Sorkin M.D., Ph.D.
> Professor of Medicine
> Chief, Biostatistics and Informatics
> University of Maryland School of Medicine Division of Gerontology and
> snipped

David Winsemius
Alameda, CA, USA




Confidentiality Statement:
This email message, including any attachments, is for the sole use of
the intended recipient(s) and may contain confidential and privileged
information. Any unauthorized use, disclosure or distribution is
prohibited. If you are not the intended recipient, please contact the
sender by reply email and destroy all copies of the original message. 
__
R-help@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.


[R] Can not save files

2014-12-31 Thread John Sorkin
When I try to save a file, I get "Permission denied". 
Can someone let me know why this happens?


I am running under Windows 7, Rstudio


> save(TheResults,file="c:\\data")
Error in gzfile(file, "wb") : cannot open the connection
In addition: Warning message:
In gzfile(file, "wb") :
  cannot open compressed file 'c:\data', probable reason 'Permission
denied'


> save(TheResults,file="c:/data")
Error in gzfile(file, "wb") : cannot open the connection
In addition: Warning message:
In gzfile(file, "wb") :
  cannot open compressed file 'c:/data', probable reason 'Permission
denied'


> sessionInfo()
R version 3.1.0 (2014-04-10)
Platform: i386-w64-mingw32/i386 (32-bit)

> library(rstudio)
> versionInfo()
$version
[1] ‘0.98.953’

$mode
[1] "desktop"


Thank you
John


John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and
Geriatric Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 





John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and
Geriatric Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 


Confidentiality Statement:
This email message, including any attachments, is for the sole use of
the intended recipient(s) and may contain confidential and privileged
information. Any unauthorized use, disclosure or distribution is
prohibited. If you are not the intended recipient, please contact the
sender by reply email and destroy all copies of the original message. 
__
R-help@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.


[R] Saving an edited R function - RStudio and R

2014-12-31 Thread John Sorkin
Windows 7
 
Colleagues,
I used the fix() function to edit an existing function when using RStudio. 
After editing the function, I am given the option to SAVE the modified 
function. I would like to know (1) where the modified function is stored (the 
save button does not have an option to specify where the modified function will 
be saved), and (2) how I can access the modified function in other RStudio or R 
sessions, and (3) how I can make the function accessible to R and RStudio 
sessions run on other computers.
Thank you,
John 
 
John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 

Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@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.


Re: [R] please please unsubscribe!!!!!!!!!!!!!!!!

2014-12-01 Thread John Sorkin
Can the Gods of the mailing list please end this long email thread? All that 
needs to be done is to add an unsubscribe link to messages sent by the server. 
If this is technically feasible, please do it. If it is not let us know so we 
can get on to other issues!
John


John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 
>>> Jeff Newmiller  12/01/14 9:31 AM >>>
I disagree that this message belongs at the top... That is rare in bulk mail I 
receive, and seems unnecessarily intrusive. Addition of the word "Unsubscribe" 
to clarify the function of the link seems in line with current use.
---
Jeff Newmiller The . . Go Live...
DCN: Basics: ##.#. ##.#. Live Go...
 Live: OO#.. Dead: OO#.. Playing
Research Engineer (Solar/Batteries O.O#. #.O#. with
/Software/Embedded Controllers) .OO#. .OO#. rocks...1k
---
Sent from my phone. Please excuse my brevity.

On December 1, 2014 6:15:47 AM PST, Martin Maechler 
 wrote:
>Thank you for all the thoughts about alleviating these problems,
>both to us and the "newbies" (or otherwise e-mail clueless
>subscribers).
>
>> Ranjan Maitra 
>> on Sun, 30 Nov 2014 20:37:22 -0600 writes:
>
>> Following on Rich and Peter, is it practical for the list to put it
>at the top then, before the R-message?
> > Something like:
>
>> TO UNSUBSCRIBE from the list: see
>https://stat.ethz.ch/mailman/listinfo/r-help
>
>Indeed, that is possible for mailman lists as I see.
>It looks ugly to me but I have been brought up in the age where
>civilized letters started (in English) with 'Dear ..' and
>e-mails were electronic letters.. and that age has gone...
>
>Shall we do that in spite of esthetic reasons? 
>and keep the current footer?
>
>Martin
>
>> And then continue on for each R message. Because top-posting has
>pretty much taken over, the best efforts of puritans notwithstanding,
>putting stuff at the bottom is unlikely to evoke much attention, and
>especially so in our 140-character-3-second attention-span world.
>
>> As an aside, if I were the OP, and wanted to unsubscribe, the volume
>of the e-mail messages on this topic alone would have been punishment
>enough for the original post:-)
>
> > Best wishes,
> > Ranjan
>
>__
>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.
Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
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] please please unsubscribe!!!!!!!!!!!!!!!!

2014-11-30 Thread John Sorkin
The headers listed below as being part of the ״raw" email messages are
not seen, at least not in the messages I receive.
John

> John David Sorkin M.D., Ph.D.
> Professor of Medicine
> Chief, Biostatistics and Informatics
> University of Maryland School of Medicine Division of Gerontology and
Geriatric Medicine
> Baltimore VA Medical Center
> 10 North Greene Street
> GRECC (BT/18/GR)
> Baltimore, MD 21201-1524
> (Phone) 410-605-7119
> (Fax) 410-605-7913 (Please call phone number above prior to faxing)


> On Nov 29, 2014, at 11:22 PM, Henrik Bengtsson 
wrote:
> 
> On Sat, Nov 29, 2014 at 7:32 PM, Jeff Newmiller
>  wrote:
>> To be fair, Rolf, they have already found difficulty and are trying
to find their way out of this torrent, and impeding their way is not in
anyone's interest.
>> 
>> John: I agree that adding the word "unsubscribe" to the footer would
probably help those lost enough to be mailing the list. The existing web
page does have that word on it, though.
>> 
>> Fabio: I was unaware of the unsubscribe header... looks interesting,
though I would be concerned that it seems like it might bypass the
password protection currently in place, making it susceptible to abuse.
However, there seem to be quite a lot of organizations using it so it
may work better than my initial impression tells me it does.
> 
> FYI, if you look at the raw email messages, they all have the
> following in the header:
> 
> X-Mailman-Version: 2.1.18-1
> Precedence: list
> List-Id: "Main R Mailing List: Primary help" 
> List-Unsubscribe: <https://stat.ethz.ch/mailman/options/r-help>,
> <mailto:r-help-requ...@r-project.org?subject=unsubscribe>
> List-Archive: <https://stat.ethz.ch/pipermail/r-help/>
> List-Post: <mailto:r-help@r-project.org>
> List-Help: <mailto:r-help-requ...@r-project.org?subject=help>
> List-Subscribe: <https://stat.ethz.ch/mailman/listinfo/r-help>,
> <mailto:r-help-requ...@r-project.org?subject=subscribe>
> 
> Note that "List-Unsubscribe" field
> [http://www.faqs.org/rfcs/rfc2369.html].  That does not seem to be
> enough to have Gmail add a "unsubscribe" button/link (which is indeed
> a useful UX feature).  Google mention some more requirements in
> https://support.google.com/mail/answer/81126#unsub, particularly
> "'Precedence: bulk'", which I find on since mailing lists typically
> use "list" just as r-help does.  I also found a mentioning on "DKIM
> key signature" being required
>
[http://blog.mailchimp.com/gmails-new-unsubscribe-link-and-feedback-loop/].
> So, not sure how easy it is to enable all this for the list(s) (which
> are handled by Mailman).
> 
> My $.02
> 
> /Henrik
> 
> 
>> 
>> 
>>
---
>> Jeff NewmillerThe .   .  Go
Live...
>> DCN:Basics: ##.#.   ##.#.  Live
Go...
>>  Live:   OO#.. Dead: OO#.. 
Playing
>> Research Engineer (Solar/Batteries    O.O#.   #.O#.  with
>> /Software/Embedded Controllers)   .OO#.   .OO#. 
rocks...1k
>>
---
>> Sent from my phone. Please excuse my brevity.
>> 
>>> On November 29, 2014 6:14:11 PM PST, Rolf Turner
 wrote:
>>>> On 30/11/14 14:16, John Sorkin wrote:
>>>> I don't see a link that is labeled "unsubscribe".
>>> 
>>> 
>>> 
>>>>> On Nov 29, 2014, at 7:35 PM, Jeff Newmiller
>>> 
>>>> wrote:
>>>>> 
>>>>> In what way would that be unlike the link that is already there?
>>> 
>>> 
>>> 
>>>>> On November 29, 2014 4:09:29 PM PST, John Sorkin
>>>>  wrote:
>>>>>>> Requests like this appear from time to time. Would it make sense
>>> to
>>>>>> add a link to the bottom of the email messages generated by the
>>> mail
>>>>>> program that is labeled>>> Well, there is no "unsubscribe" page as such. 
>>>>>>  The link given, i.e.
>>> 
>>>https://stat.ethz.ch/mailman/listinfo/r-help
>>> 
>>> takes you to the primary help page. That provides a link to a
(password
>>> 
>>> protected) page where you can handle all matters pertaining to your
>>> r-help subscription, including unsubscribing.
>>> 
>>> I suppose that it might be possible to provide a link taking one
>>> directly 

Re: [R] please please unsubscribe!!!!!!!!!!!!!!!!

2014-11-29 Thread John Sorkin
I don't see a link that is labeled "unsubscribe".
John

> John David Sorkin M.D., Ph.D.
> Professor of Medicine
> Chief, Biostatistics and Informatics
> University of Maryland School of Medicine Division of Gerontology and
Geriatric Medicine
> Baltimore VA Medical Center
> 10 North Greene Street
> GRECC (BT/18/GR)
> Baltimore, MD 21201-1524
> (Phone) 410-605-7119
> (Fax) 410-605-7913 (Please call phone number above prior to faxing)


> On Nov 29, 2014, at 7:35 PM, Jeff Newmiller 
wrote:
> 
> In what way would that be unlike the link that is already there?
>
---
> Jeff NewmillerThe .   .  Go
Live...
> DCN:Basics: ##.#.   ##.#.  Live
Go...
>  Live:   OO#.. Dead: OO#.. 
Playing
> Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
> /Software/Embedded Controllers)   .OO#.   .OO#. 
rocks...1k
>
---

> Sent from my phone. Please excuse my brevity.
> 
> On November 29, 2014 4:09:29 PM PST, John Sorkin
 wrote:
>>> Requests like this appear from time to time. Would it make sense to
>> add a link to the bottom of the email messages generated by the mail
>> program that is labeled and goes directly to the unsubscribe page?
>>> John
>> 
>> 
>>> On Nov 29, 2014, at 8:26 AM, M. A. Parreño
>>  wrote:
>>> 
>>> i already sent this please unsusbscribe
>>> passoword: 33311986
>>> or 33311986dic
>>> 
>>> 
>>> please unsubscribe me
>>> 
>>>   [[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.
>> 
>> Confidentiality Statement:
>> This email message, including any attachments, is for the sole use of
>> the intended recipient(s) and may contain confidential and privileged
>> information. Any unauthorized use, disclosure or distribution is
>> prohibited. If you are not the intended recipient, please contact the
>> sender by reply email and destroy all copies of the original message.

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

Confidentiality Statement:
This email message, including any attachments, is for the sole use of
the intended recipient(s) and may contain confidential and privileged
information. Any unauthorized use, disclosure or distribution is
prohibited. If you are not the intended recipient, please contact the
sender by reply email and destroy all copies of the original message. 
__
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] please please unsubscribe!!!!!!!!!!!!!!!!

2014-11-29 Thread John Sorkin
> Requests like this appear from time to time. Would it make sense to
add a link to the bottom of the email messages generated by the mail
program that is labeled and goes directly to the unsubscribe page?
> John


> On Nov 29, 2014, at 8:26 AM, M. A. Parreño
 wrote:
> 
> i already sent this please unsusbscribe
> passoword: 33311986
> or 33311986dic
> 
> 
> please unsubscribe me
> 
>[[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.

Confidentiality Statement:
This email message, including any attachments, is for the sole use of
the intended recipient(s) and may contain confidential and privileged
information. Any unauthorized use, disclosure or distribution is
prohibited. If you are not the intended recipient, please contact the
sender by reply email and destroy all copies of the original message. 
__
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] Defining vectors with per-determined correlations

2014-09-04 Thread John Sorkin
I need to define three vectors x, y, z (each of length 100) such that the 
pair-wise correlations of the vectors have per-defined values r1 and r2. More 
specifically I need to define x, y, and z so that:
 
corr(x,y) = r1
corr(y,z) = r2
 
Is there any easy way to accomplish this with R?
 
Thank you,
John
John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 

Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
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] Cargar csv 16 GB en R

2014-06-01 Thread John Sorkin
Laura,
Si pudes escribir en Engles, vas a recibir mas ayuda; el mejor parte de
personas (incluendo yo) no podemos hablar Espanol.
 
Has tratado usando su programa con un parte pequeno de su dato? Si
haces esto todavia tienes su problema? Puedes enviarnos un copia de su
programa, y un subset (por ejemplo los premeros ciento lineas) de su
datos? 
 
Favor de desculpir me Espanol. Yo se solo palabras mas utiles, te amo,
te quiero, te hecho de menos . . .
 
John
 


John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and
Geriatric Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 


>>> laura tomé 6/1/2014 2:29 PM >>>
Hola,

Estoy todavía dando mis primeros pasos en R y una de las cosas que
tengo que hacer es trabajar con un csv de 16 GB. Consta de 10 columnas,
7 númericas
He probado varias cosas entre ellas  'colbycol' pero nada, mi ordenador
de queda frito.
Mi ordenador tiene 8GB de RAM y Windows 8

¿Debo trocear previamente el csv,me recomendais algún paquete en
especial, etc para trabajar con un fichero tan pesado? Estoy
desesperada...

Muchas gracias
[[alternative HTML version deleted]]


Confidentiality Statement:
This email message, including any attachments, is for the sole use of
the intended recipient(s) and may contain confidential and privileged
information.  Any unauthorized use, disclosure or distribution is
prohibited.  If you are not the intended recipient, please contact the
sender by reply email and destroy all copies of the original message. 
__
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] Spline regression (or any localized regression) in the setting of a random effects model.

2014-04-21 Thread John Sorkin
Colleagues,
Is there any R program that will allow me to run a localized regression (e.g. 
smoothing spline) in the context of a random effects model? I have data on the 
growth of animals and want to create growth curves. I am not certain what shape 
the growth curve would take, so I would like to start with some sort of 
smoothed (but not "linear") regression to determine the shape of the growth 
curves. I would like to use a random effects model because I have multiple 
pairs of observations (age and weight) for each animal. If the shape of the 
growth curves appear to fit some parametric distribution, I will switch to a 
parametric model.
Thank you,
John
John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 

Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information.  
Any unauthorized use, disclosure or distribution is prohibited.  If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
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.


  1   2   3   4   >