Re: [R] Statet on Eclipse: ${project_path} is empty

2010-03-11 Thread Tobias Verbeke

Hi Paul,

Paul wrote:

I'm tryign to use Statet on Eclipse on my Kubuntu Karmic PC.  I've set 
everything up and I can start the R configuration, but the working 
directory is set to my home directory.  If I set the start in directory 
to ${worspace_loc}/${project_path} I can't start the console, with an 
error that project_path is empty.


Personally I always use (nothing more than) ${resource_loc} to set
the R working directory. Before launching R, you select a *directory*
in the Project Explorer, then launch the R Console Run Configuration
and that particular directory will be used as the working directory.

An alternative (some people prefer) is to use ${resource_container}.
In that case you select the R script you want to work with, then launch
the R Console Run Configuration of your choice and it will have the
directory (containing the file you selected) as the working directory.

As mentioned, for me selecting a directory to become the working
directory is more natural, but this is merely a matter of taste and
habit.

HTH,
Tobias

__
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] please, cant install rodbc into R-project

2010-03-11 Thread maysider

I have working unixODBC (tested isql), but rodbc does not want to
installIve read the manual how to install rodbc, but I am not linux user
so I do not understand well. Can anyone write me the necessary steps?

thank you

m

> install.packages(c("RODBC"))
--- Please select a CRAN mirror for use in this session ---
Loading Tcl/Tk interface ... done
trying URL 'http://mirrors.softliste.de/cran/src/contrib/RODBC_1.3-1.tar.gz'
Content type 'application/x-gzip' length 990220 bytes (967 Kb)
opened URL
==
downloaded 967 Kb

* installing *source* package ‘RODBC’ ...
/usr/lib64/R/bin/config: line 143: make: command not found
/usr/lib64/R/bin/config: line 144: make: command not found
/usr/lib64/R/bin/config: line 220: make: command not found
/usr/lib64/R/bin/config: line 143: make: command not found
/usr/lib64/R/bin/config: line 144: make: command not found
/usr/lib64/R/bin/config: line 220: make: command not found
/usr/lib64/R/bin/config: line 143: make: command not found
/usr/lib64/R/bin/config: line 144: make: command not found
/usr/lib64/R/bin/config: line 220: make: command not found
/usr/lib64/R/bin/config: line 143: make: command not found
/usr/lib64/R/bin/config: line 144: make: command not found
/usr/lib64/R/bin/config: line 220: make: command not found
checking for gcc... no
checking for cc... no
checking for cc... no
checking for cl... no
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details.
ERROR: configuration failed for package ‘RODBC’
* removing ‘/usr/lib64/R/library/RODBC’

The downloaded packages are in
‘/tmp/Rtmp8YrphM/downloaded_packages’
Updating HTML index of packages in '.Library'
Warning message:
In install.packages(c("RODBC")) :
  installation of package 'RODBC' had non-zero exit status
> 

-- 
View this message in context: 
http://n4.nabble.com/please-cant-install-rodbc-into-R-project-tp1590213p1590213.html
Sent from the R help mailing list archive at Nabble.com.

__
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] How to format dates (with no century)?

2010-03-11 Thread johannes rara
Actually I found it:

> as.Date(strptime(dates, "%d.%m.%y"), "%Y-%m-%d")
 [1] "2007-04-06" "1998-12-29" "1991-10-19" "1992-06-20" "2003-09-02"
"2003-06-23" "1993-07-13" "2007-03-23" "1995-06-26" "2010-02-15"

-J

2010/3/12 johannes rara :
> Hi,
>
> I have dates in this kind of format (day, month, year):
>
>> dput(head(dates, 10))
> c("6.4.7", "29.12.98", "19.10.91", "20.6.92", "2.9.3", "23.6.3",
> "13.7.93", "23.3.7", "26.6.95", "15.2.10")
>
> So, as you can see, there is no century. How can I change this
> character data into dates? Any help would be most appreciated.
>
> -J
>

__
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] How to format dates (with no century)?

2010-03-11 Thread johannes rara
Hi,

I have dates in this kind of format (day, month, year):

> dput(head(dates, 10))
c("6.4.7", "29.12.98", "19.10.91", "20.6.92", "2.9.3", "23.6.3",
"13.7.93", "23.3.7", "26.6.95", "15.2.10")

So, as you can see, there is no century. How can I change this
character data into dates? Any help would be most appreciated.

-J

__
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] Question regarding to maxNR

2010-03-11 Thread Bill.Venables
PS there is a better option still.  Replace

log(prod(dcauchy(x,mu,s)))

with

sum(dcauchy(x,mu,s, log = TRUE))

For huge samples this will me milliseconds faster...

Bill Venables
CSIRO/CMIS Cleveland Laboratories


-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of bill.venab...@csiro.au
Sent: Friday, 12 March 2010 4:23 PM
To: yh...@illinois.edu; r-help@r-project.org
Subject: [ExternalEmail] Re: [R] Question regarding to maxNR

Your problem is numerical.

Try replacing

log(prod(dcauchy(x,mu,s)))

by

sum(log(dcauchy(x,mu,s)))

and see the difference.  Here's what I get:

> mu <- 2
> s <- 1
> n <- 300
> library(maxLik)
> set.seed(1004)
> x <- rcauchy(n,mu,s)
> loglik <- function(mu) {
+   sum(log(dcauchy(x,mu,s)))
+ }
> maxNR(loglik,start=median(x))$estimate 
[1] 2.075059

which looks about right to me.

Bill Venables
CSIRO/CMIS Cleveland Laboratories


-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of kate
Sent: Friday, 12 March 2010 3:21 PM
To: r-help@r-project.org
Subject: [R] Question regarding to maxNR

Hi R-users,

Recently, I use maxNR function to find maximizer. I have error appears as 
follows
Error in maxNRCompute(fn = fn, grad = grad, hess = hess, start = start,  : 
  NA in the initial gradient

My code is 

mu=2
s=1
n=300
library(maxLik)
set.seed(1004)
x<-rcauchy(n,mu,s)
loglik<-function(mu)
{
log(prod(dcauchy(x,mu,s)))
}
maxNR(loglik,start=median(x))$estimate 


Does anyone know how to solve this problem?

Thanks,

Kate


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

__
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] generic function body display

2010-03-11 Thread Martin Morgan
Hi Alok --

On 03/11/2010 06:59 PM, Alok Jadhav wrote:
> 
> I recently restructured my R project to make use of S4 class objects. I
> converted some of the functions to generic functions. If I type the name of
> the function i can see the body for non generic functions. I am not able to
> retrieve the code for Generic functions. It is very convinient for users to
> use these functions when they can see the function body.
> 
> See the output for generic function "QueryAgora" which is defined for
> classes "jp", "hk", "au", "kr"
> 
> 
>> QueryAgora
> standardGeneric for "QueryAgora" defined from package ".GlobalEnv"
> 
> function (object, sql, ..., uat = FALSE, gen2 = FALSE, as.is = FALSE) 
> standardGeneric("QueryAgora")
> 
> Methods may be defined for arguments: object, sql, uat, gen2, as.is
> Use  showMethods("QueryAgora")  for currently available ones.
> 
> 
>> showMethods("QueryAgora")
> Function: QueryAgora (package .GlobalEnv)
> object="au"
> object="hk"
> object="jp"
> object="kr"

showMethods(QueryAgora, classes="au", includeDef=TRUE)

or

selectMethod(QueryAgora, "au")

Martin

> 
>> showMlist(MethodsList("QueryAgora"))
> 
> 
>> showMlist(MethodsList("jp"))
> 
> 
> Could someone please tell me how can I explore the function body for the
> above function. Any help will be appreciated.
> 
> 
> Regards, Alok
> 
> 
> 


-- 
Martin Morgan
Computational Biology / Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N.
PO Box 19024 Seattle, WA 98109

Location: Arnold Building M1 B861
Phone: (206) 667-2793

__
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] Question regarding to maxNR

2010-03-11 Thread Bill.Venables
Your problem is numerical.

Try replacing

log(prod(dcauchy(x,mu,s)))

by

sum(log(dcauchy(x,mu,s)))

and see the difference.  Here's what I get:

> mu <- 2
> s <- 1
> n <- 300
> library(maxLik)
> set.seed(1004)
> x <- rcauchy(n,mu,s)
> loglik <- function(mu) {
+   sum(log(dcauchy(x,mu,s)))
+ }
> maxNR(loglik,start=median(x))$estimate 
[1] 2.075059

which looks about right to me.

Bill Venables
CSIRO/CMIS Cleveland Laboratories


-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of kate
Sent: Friday, 12 March 2010 3:21 PM
To: r-help@r-project.org
Subject: [R] Question regarding to maxNR

Hi R-users,

Recently, I use maxNR function to find maximizer. I have error appears as 
follows
Error in maxNRCompute(fn = fn, grad = grad, hess = hess, start = start,  : 
  NA in the initial gradient

My code is 

mu=2
s=1
n=300
library(maxLik)
set.seed(1004)
x<-rcauchy(n,mu,s)
loglik<-function(mu)
{
log(prod(dcauchy(x,mu,s)))
}
maxNR(loglik,start=median(x))$estimate 


Does anyone know how to solve this problem?

Thanks,

Kate


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Question regarding to maxNR

2010-03-11 Thread Arne Henningsen
Hi Kate!

On Fri, Mar 12, 2010 at 6:20 AM, kate  wrote:
> Hi R-users,
>
> Recently, I use maxNR function to find maximizer. I have error appears as 
> follows
> Error in maxNRCompute(fn = fn, grad = grad, hess = hess, start = start,  :
>  NA in the initial gradient
>
> My code is
>
> mu=2
> s=1
> n=300
> library(maxLik)
> set.seed(1004)
> x<-rcauchy(n,mu,s)
> loglik<-function(mu)
> {
> log(prod(dcauchy(x,mu,s)))
> }
> maxNR(loglik,start=median(x))$estimate
>
>
> Does anyone know how to solve this problem?

Yes :-)

Algebraically, "log(prod(z))" is equal to "sum(log(z))" but these two
expressions might return different numbers on digital computers:

R> ll<-function(mu) { sum(log(dcauchy(x,mu,s))) }
R> ll(2)
[1] -754.4928
R> loglik(2)
[1] -Inf

R> maxNR(ll,start=median(x))$estimate
[1] 2.075059

Best wishes from Copenhagen,
Arne

-- 
Arne Henningsen
http://www.arne-henningsen.name

__
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] rmaxwell in C

2010-03-11 Thread 王杰彪
Hi R useRs:

How can I generate a random sample from Maxwell Distribution in C language?
Since I know the function rmaxwell {VGAM}, I tried the function r2c {r2c}.
But I still cannot find the source code.

Thanks for your kind help.

RegaRds,

2010-03-12



Randel
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] construct a list that consists of lists

2010-03-11 Thread Zhongyi Yuan
Dear R users:

I am hoping that someone can help with constructing a list that consists of
list with the number of lists variable.
i.e. to find a convenient express(or loop sentences) to realize the
following:
list( list(para1=p1, para2=p2), list(para1=p1, para2=p2), ,
list(para1=p1,para2=p2) )

I appreciate your help.

best,
Zhongyi

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] How (and where) to get aligned tRNA sequences (and import/align it using R)

2010-03-11 Thread Tal Galili
Hi all,
I already posted this to seqinr-fo...@lists.r-forge.r-project.org but since
(so far) no reply was given, I decided to try my luck in this list too.


Dear list.

I wish (for my thesis work), to import tRNA data into R and have it aligned.

My questions are:
1) What resources can I use for the data.
2) What commands might help me with the import/alignment.

So far, I found two nice repositories that holds such data:
1) 
http://trnadb.bioinf.uni-leipzig.de/Result
2) 
http://gtrnadb.ucsc.edu/download.html

And also the  readFASTA command from Biostrings, that does basic importing
of the data into R.

My problem still remains with *how to handle the alignment* of the tRNA.

Since I am not from the field, I might be missing a very basic answer (like
where I should download the data from, what command to use or even where to
ask).
If you might be willing to advice me, that would be most helpful.

Many thanks in advance,
Tal


Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Installing R cmdr

2010-03-11 Thread Ista Zahn
Hi Taleb,
You might have better luck posting this to the mac-specific mailing
list: https://stat.ethz.ch/mailman/listinfo/r-sig-mac

In fact I think this issue has come up there before. See
https://stat.ethz.ch/pipermail/r-sig-mac/2010-January/007007.html

Best,
Ista

On Thu, Mar 11, 2010 at 10:37 PM, Taleb Alkhajah
 wrote:
> Dear John Fox,
>
> I am using Snowleopard with a Intel Core 2 Duo processor.  I have installed 
> the R console and followed your steps at:
>
> http://socserv.mcmaster.ca/jfox/Misc/Rcmdr/installation-notes.html
>
> but every time I try "library(Rcmdr)" it loads Tcl/tk infinitely.  I have 
> tried loading "library(tcltk)" by itself and it does the same thing.  I have 
> tried with X11 running to no avail.  I have even tried downloading a 
> snowleopard build from http://r.research.att.com/ with no new results.
>
> Any advice would be greatly appreciated.
>
> Thanks,
>
> Taleb Alkhajah
> __
> 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.
>



-- 
Ista Zahn
Graduate student
University of Rochester
Department of Clinical and Social Psychology
http://yourpsyche.org

__
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] Question regarding to maxNR

2010-03-11 Thread kate
Hi R-users,

Recently, I use maxNR function to find maximizer. I have error appears as 
follows
Error in maxNRCompute(fn = fn, grad = grad, hess = hess, start = start,  : 
  NA in the initial gradient

My code is 

mu=2
s=1
n=300
library(maxLik)
set.seed(1004)
x<-rcauchy(n,mu,s)
loglik<-function(mu)
{
log(prod(dcauchy(x,mu,s)))
}
maxNR(loglik,start=median(x))$estimate 


Does anyone know how to solve this problem?

Thanks,

Kate


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] NAs and row/column calculations

2010-03-11 Thread David Winsemius


On Mar 11, 2010, at 11:28 PM, David Winsemius wrote:



On Mar 11, 2010, at 6:20 PM, Jim Bouldin wrote:





On 12/03/2010, at 11:25 AM, Jim Bouldin wrote:



I continue to have great frustrations with NA values--in particular

making
summary calculations on rows or cols of a matrix containing  
them.  For

example, why does:


a = matrix(1:30,nrow=5)
is.na(a[c(1:2),c(3:4)]);a

  [,1] [,2] [,3] [,4] [,5] [,6]
[1,]16   NA   NA   21   26
[2,]27   NA   NA   22   27
[3,]38   13   18   23   28
[4,]49   14   19   24   29
[5,]5   10   15   20   25   30

apply(a[!is.na(a)],2,sum)


give me this:

"Error in apply(a[!is.na(a)], 2, sum) : dim(X) must have a positive

length"


when


dim(a)

[1] 5 6

What is the trick to calculating summary values from rows or  
columns

containing NAs?  Drives me nuts.  More nuts that is.


When you do a[!is.na(a)] you get a ***vector*** --- not a matrix.
``Obviously''!!!


Well, obvious to you maybe, or someone who's done it before, but  
not to me.


The non-missing values of a cannot be arranged in

a 5 x 6 matrix; there are only 26 of them.  So (as my late Uncle
Stanley would have said) ``What the hell do you expect?''.


Silly me, I expected, based on (1) previous experience doing  
summary calcs
on subsets of a matrix using exactly that style of command, and (2)  
the
fact that dim(a) returns: [1] 5 6, and (3) the fact that a help  
search
under the "apply" function gives NO INDICATION of any possible use  
of the

na.rm command,


Not really true. You may be at a stage where you are not paying  
attention to what the , ...) arguments to functions are doing, so  
you may have passed over the fact that it is described as "optional  
arguments to FUN." Now in fairness to the apply help page authors it  
would be impossible to list all of the possible optional arguments  
because the range of possible functions is, while countable, still  
extremely large. I think it would be useful to describe on that help  
page a bit more about what restrictions may exist here and to  
include an example that uses that facility, but I am not part of R  
Core.




AND (4) a help search on "na.action" does not even mention
na.rm, that:


apply(a[!is.na(a)],2,sum)


would sum the non-NA elements of matrix a, by columns.  Terribly  
faulty

reasoning on my part, obviously.


What, may I inquire, happens when you look at the help page for  
"sum"? While you are at it, you may want to acquaint yourself with  
the "na.rm="  parameter in other functions, because it is also  
essential for productive use of several other useful functions, like  
median and density.


AS a further exercise you may want to follow this path. (I learned new  
bits.)  After getting annoyed that neither ""na.rm", nor ??"na.rm"  
provided any 'help',  I tried the sos package:


> ??"na.rm"
No help files found matching ‘na.rm’ using regexp matching
> library(sos)
Loading required package: brew

Attaching package: 'sos'


The following object(s) are masked from package:utils :

 ?

> ???"na.rm"
found 476 matches;  retrieving 20 pages, 400 matches.
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20








The ``trick'' is to remove the NAs at the summing stage:

apply(a,2,sum,na.rm=TRUE)

Not all that tricky.

cheers,

Rolf Turner


David Winsemius, MD
West Hartford, CT

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


David Winsemius, MD
West Hartford, CT

__
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] parse an HTML page with verbose error message (using XML)

2010-03-11 Thread Duncan Temple Lang
Hi Yihui

  It took me a moment to see the error message as the latest
development version of the XML package suppresses/hides them by default
for htmlParse().

 You can provide your own function via the error parameter.
If you just want to see more detailed error messages on the console
you can use a function like the following


fullInfoErrorHandler =
function(msg, code, domain, line, col, level, file)
{
   # level tells how significant the error is
   #   These are 0, 1, 2, 3 for WARNING, ERROR, FATAL
   # meaning simple warning, recoverable error and fatal/unrecoverable 
error.
   #  See XML:::xmlErrorLevel
   #
   # code is an error code, See the values in XML:::xmlParserErrors
   #  XML_HTML_UNKNOWN_TAG, XML_ERR_DOCUMENT_EMPTY
   #
   # domain tells what part of the library raised this error.
   #  See XML:::xmlErrorDomain

  codeMsg = switch(level, "warning", "recoverable error", "fatal error")
  cat("There was a", codeMsg, "in the", file, "at line", line, "column",
 col, "\n", msg, "\n")
}

doc = htmlParse("~/htmlErrors.html", error = fullInfoErrorHandler)

And of course you can mimic xmlErrorCumulator() to form a closure that
collects the different details of each message into an object.  If you
look in the error.R and xmlErrorEnums.R files within the R code of the
XML package, you'll find some additional functions that give us further
support for working with errors in the XML/HTML parsers.

 Best,
   D.

Yihui Xie wrote:
> I'm using the function htmlParse() in the XML package, and I need a
> little bit help on error handling while parsing an HTML page. So far I
> can use either the default way:
> 
> # error = xmlErrorCumulator(), by default
> library(XML)
> doc = htmlParse("http://www.public.iastate.edu/~pdixon/stat500/";)
> # the error message is:
> # htmlParseStartTag: invalid element name
> 
> or the tryCatch() approach:
> 
> # error = NULL, errors to be caught by tryCatch()
> tryCatch({
> doc = htmlParse("http://www.public.iastate.edu/~pdixon/stat500/";,
> error = NULL)
> }, XMLError = function(e) {
> cat("There was an error in the XML at line", e$line, "column",
> e$col, "\n", e$message, "\n")
> })
> # verbose error message as:
> # There was an error in the XML at line 90 column 2
> # htmlParseStartTag: invalid element name
> 
> I wish to get the verbose error messages without really stopping the
> parsing process; the first approach cannot return detailed error
> messages, while the second one will stop the program...
> 
> Thanks!
> 
> Regards,
> Yihui
> --
> Yihui Xie 
> Phone: 515-294-6609 Web: http://yihui.name
> Department of Statistics, Iowa State University
> 3211 Snedecor Hall, Ames, IA
> 
> __
> 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.


[R] help about cluster package

2010-03-11 Thread Jie TANG
hello,everyone.
 I tried to use cluster analysis package by reading the manual "chapter 15
cluster package"
.But when I tried to use the function "agnes",the R said :there is no
function.Can
you tell me which package I should load? Can anyone give me some sample
scripts about
clustering analysis ?Thank you .

-- 
TANG Jie
Email: totang...@gmail.com
Tel: 0086-2154896104

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] NAs and row/column calculations

2010-03-11 Thread David Winsemius


On Mar 11, 2010, at 6:20 PM, Jim Bouldin wrote:





On 12/03/2010, at 11:25 AM, Jim Bouldin wrote:



I continue to have great frustrations with NA values--in particular

making
summary calculations on rows or cols of a matrix containing them.   
For

example, why does:


a = matrix(1:30,nrow=5)
is.na(a[c(1:2),c(3:4)]);a

   [,1] [,2] [,3] [,4] [,5] [,6]
[1,]16   NA   NA   21   26
[2,]27   NA   NA   22   27
[3,]38   13   18   23   28
[4,]49   14   19   24   29
[5,]5   10   15   20   25   30

apply(a[!is.na(a)],2,sum)


give me this:

"Error in apply(a[!is.na(a)], 2, sum) : dim(X) must have a positive

length"


when


dim(a)

[1] 5 6

What is the trick to calculating summary values from rows or columns
containing NAs?  Drives me nuts.  More nuts that is.


When you do a[!is.na(a)] you get a ***vector*** --- not a matrix.
``Obviously''!!!


Well, obvious to you maybe, or someone who's done it before, but not  
to me.


The non-missing values of a cannot be arranged in

a 5 x 6 matrix; there are only 26 of them.  So (as my late Uncle
Stanley would have said) ``What the hell do you expect?''.


Silly me, I expected, based on (1) previous experience doing summary  
calcs
on subsets of a matrix using exactly that style of command, and (2)  
the

fact that dim(a) returns: [1] 5 6, and (3) the fact that a help search
under the "apply" function gives NO INDICATION of any possible use  
of the

na.rm command,


Not really true. You may be at a stage where you are not paying  
attention to what the , ...) arguments to functions are doing, so you  
may have passed over the fact that it is described as "optional  
arguments to FUN." Now in fairness to the apply help page authors it  
would be impossible to list all of the possible optional arguments  
because the range of possible functions is, while countable, still  
extremely large. I think it would be useful to describe on that help  
page a bit more about what restrictions may exist here and to include  
an example that uses that facility, but I am not part of R Core.




AND (4) a help search on "na.action" does not even mention
na.rm, that:


apply(a[!is.na(a)],2,sum)


would sum the non-NA elements of matrix a, by columns.  Terribly  
faulty

reasoning on my part, obviously.


What, may I inquire, happens when you look at the help page for "sum"?  
While you are at it, you may want to acquaint yourself with the  
"na.rm="  parameter in other functions, because it is also essential  
for productive use of several other usueful functions, like median and  
density.







The ``trick'' is to remove the NAs at the summing stage:

apply(a,2,sum,na.rm=TRUE)

Not all that tricky.

cheers,

Rolf Turner


David Winsemius, MD
West Hartford, CT

__
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] Installing R cmdr

2010-03-11 Thread Taleb Alkhajah
Dear John Fox,

I am using Snowleopard with a Intel Core 2 Duo processor.  I have installed the 
R console and followed your steps at:

http://socserv.mcmaster.ca/jfox/Misc/Rcmdr/installation-notes.html

but every time I try "library(Rcmdr)" it loads Tcl/tk infinitely.  I have tried 
loading "library(tcltk)" by itself and it does the same thing.  I have tried 
with X11 running to no avail.  I have even tried downloading a snowleopard 
build from http://r.research.att.com/ with no new results.

Any advice would be greatly appreciated.

Thanks,

Taleb Alkhajah
__
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] Can't convert list to matrix properly

2010-03-11 Thread David Winsemius


On Mar 11, 2010, at 11:16 AM, anna wrote:



so I was getting ones because it converted the characters into  
numeric?


No, it did not. The internal representation of the factors is of type  
integer and those values were used with no reference to the factor  
levels.




-
Anna Lippel
--
View this message in context: 
http://n4.nabble.com/Can-t-convert-list-to-matrix-properly-tp1589187p1589211.html
Sent from the R help mailing list archive at Nabble.com.

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


David Winsemius, MD
West Hartford, CT

__
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] generic function body display

2010-03-11 Thread Alok Jadhav

I recently restructured my R project to make use of S4 class objects. I
converted some of the functions to generic functions. If I type the name of
the function i can see the body for non generic functions. I am not able to
retrieve the code for Generic functions. It is very convinient for users to
use these functions when they can see the function body.

See the output for generic function "QueryAgora" which is defined for
classes "jp", "hk", "au", "kr"


> QueryAgora
standardGeneric for "QueryAgora" defined from package ".GlobalEnv"

function (object, sql, ..., uat = FALSE, gen2 = FALSE, as.is = FALSE) 
standardGeneric("QueryAgora")

Methods may be defined for arguments: object, sql, uat, gen2, as.is
Use  showMethods("QueryAgora")  for currently available ones.


> showMethods("QueryAgora")
Function: QueryAgora (package .GlobalEnv)
object="au"
object="hk"
object="jp"
object="kr"

> showMlist(MethodsList("QueryAgora"))


> showMlist(MethodsList("jp"))


Could someone please tell me how can I explore the function body for the
above function. Any help will be appreciated.


Regards, Alok



-- 
View this message in context: 
http://n4.nabble.com/generic-function-body-display-tp1590075p1590075.html
Sent from the R help mailing list archive at Nabble.com.

__
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] big panel: filehash, bigmemory or other

2010-03-11 Thread Johan Jackson
Hello Eric,

If you can do a project like this (that manages huge datasets) in SAS, I'd
recommend to just do them in SAS rather than use R. I've sadly come to the
conclusion that R isn't very good at working with large datasets, and until
the powers that be try to do something about to help users like us (e.g.,
help us get around the damn 2^31-1 limit on vectors), R will remain a great
language that is very awkward to use with large datasets. I've used
bigmemory and ff - and I have the greatest respect and appreciation for the
authors of these packages - but they ultimately are awkward to work with
compared to doing things natively in R. For example, there is still a 2^31-1
limit on objects in ff, and bigmemory has been buggy when I tried to use it.
Good luck!

JJ



On Mon, Feb 22, 2010 at 3:13 PM, Eric Fail  wrote:

> Dear R-list
>
> I'm on my way to start a new project on a rather big panel, consisting of
> approximately 8 million observations in 30 waves of data and about 15
> variables. I have a similar data set that is approximately 7 gigabytes in
> size.
>
> Until now I have done my data management in SAS, and Stata, mostly
> identifying spells, counting events in intervals, and a like, but I would
> like to do the data management-and fitting my models-in R.
>
> Though R can't handle the data in a normal R-way, it's simply too big. So I
> thought of trying either filehash, bigmemory or some other similar package I
> haven't heard of (yet). In the documentation to 'bigmemory' is says  that
> the package is capable of ``basic manipulation '' on ``manageable subsets of
> the data '', but what does that actually mean?
>
> Since learning this in R is a rather time consuming process, and I know SAS
> is capable of doing the data management, and have the proc mixed module, I
> wanted to ask on the list, before I set out on this odyssey.
>
> Does anyone out there have any practical experience with data sets (panels)
> that size and maybe some experience fitting a model, presumably using the
> lmer package or alike, using filehash or bigmemory, that they would be
> willing to share?
>
> Thanks in advance,
> Eric
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
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] Dicrete Laplace distribution

2010-03-11 Thread Moshe Olshansky
Dear Nicolette,

You can always use the bruit force solution which works for every discrete 
distribution with finite number of states: let p0,p1,...,pK be the 
probabilities of 0,1,...,K (such that they sum up to 1).
Let P <- c(p0,p1,...,pK) and P1 <- c(cumsum(P),1)
Now let x = runif() (uniform in (0,1)) and k <- which(P1 >= x)[1] has the 
desired distribution.

Regards,
Moshe.

--- On Fri, 12/3/10, Raquel Nicolette  wrote:

> From: Raquel Nicolette 
> Subject: [R] Dicrete Laplace distribution
> To: r-help@r-project.org
> Received: Friday, 12 March, 2010, 2:47 AM
>  
> 
> Hello,
> 
>  
> 
>   
> Could
> anybody tell me how to generate discrete Laplacian
> distribution? 
> 
>  
> 
> I need to sample  uma discretised Laplacian density
> like this:
> 
>  
> 
>   J(  g -> g´)  ~ exp (-lambda | g´ - g
> |)  g in {0,…, gmax} 
> 
>  
> 
> Thanks,
> 
>  
> 
> Nicolette
> 
> 
>     [[alternative HTML version deleted]]
> 
> 
> -Inline Attachment Follows-
> 
> __
> 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.


Re: [R] Append to outfile in R CMD BATCH mode

2010-03-11 Thread Turchin, Michael
So I have a semi-answer for myself. I don't think this way is preferable, but 
if you're going through the same thing as me, maybe it'll help.

If you pass your desired outfile as an argument in '--args filename', you can 
redirect the output the following way:


cmd_args = commandArgs()
print (cmd_args) #To figure out which number argument your outfile is
sink(cmd_args[2], append=TRUE) #Or whatever number argument your filename is
|
|
code
|
|
sink() #at the end of your script

Stderr I think still gets directed to your outfile location in the R CMD 
BATCH... command (see start of thread), but Stdout should now go to wherever 
you directed it with sink, plus, now you can append.

HTH (and if you're aware of a better way, please let me know!)
~Michael Turchin
Children's Hospital Boston
The Broad Institute



From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On Behalf Of 
Turchin, Michael [michael.turc...@childrens.harvard.edu]
Sent: Thursday, March 11, 2010 5:27 PM
To: r-help@r-project.org
Subject: [R] Append to outfile in R CMD BATCH mode

Is there a way to append to the outfile when using R CMD BATCH? My code, right 
now, is:

R CMD BATCH --slave --vanilla '--args place .2 -.1 .9 .6' 
StratificationSimulation example.output

Everything else is working the way I'd like it. The first few lines of code of 
my script file are:

options(echo=FALSE)
cmd_args = commandArgs()
print (cmd_args)
#d <- read.table("/dev/stdin")

if that helps any. However, I cannot currently change the output to append, 
rather than override, the designated outfile. Maybe I could potentially use 
sink(__, append=TRUE) if I could somehow reference the outfile from within the 
script (and assuming my understanding of sink() is correct)?

Any thoughts, or help? They're all greatly appreciated.
Thanks!
~Michael
Children's Hospital Boston
The Broad Institute
__
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.


Re: [R] help about solving two equations

2010-03-11 Thread Shaoqiong Zhao
Hello Professor Ravi,

I tried to load BB into R, but I got the following message:
 library("BB")
Error in library("BB") : there is no package called 'BB'
> library(BB)
Error in library(BB) : there is no package called 'BB'

Can you tell me why?

Thanks a lot.

Annie


- Original Message -
From: "Ravi Varadhan" 
To: "Shaoqiong Zhao" 
Cc: r-help@r-project.org
Sent: Wednesday, March 10, 2010 9:03:25 PM GMT -06:00 US/Canada Central
Subject: Re: [R] help about solving two equations

Here is how you can solve:

fn <- function(x, s){
f <- rep(NA, length(x))
f[1] <- digamma(x[1]) - digamma(x[1]+x[2]) - s[1]
f[2] <- digamma(x[2]) - digamma(x[1]+x[2]) - s[2]
f
}

require(BB) # load this package for the nonlinear solver

s <- c(-2, -4)  # one row of s1 and s2

ans <- dfsane(par=c(1,1), fn=fn, s=s)

ans$par  # solutions for p and q

You can then loop through for each row of s1 and s2 and solve it to get 
corresponding p and q.

Ravi.


Ravi Varadhan, Ph.D.
Assistant Professor,
Division of Geriatric Medicine and Gerontology
School of Medicine
Johns Hopkins University

Ph. (410) 502-2619
email: rvarad...@jhmi.edu


- Original Message -
From: Shaoqiong Zhao 
Date: Wednesday, March 10, 2010 8:19 pm
Subject: [R] help about solving two equations
To: r-help@r-project.org


> I have two matrix s1 and s2, each of them is 1000*1.
>  and I have two equations:
>  digamma(p)-digamma(p+q)=s1,
>  digamma(q)-digamma(p+q)=s2,
>  and I want to sovle these two equations to get the value of x and y, 
> which are also two 1000*1 matrices.
>  
>  I write a program like this:
>  
>  f <- function(x) {
>  p<- x[1]; q <- x[2]; 
>   ((digamma(p)-digamma(p+q)-s1[2,]) )^2 
> +((digamma(q)-digamma(p+q)-s2[2,]) )^2
>   }
>  s <- 1:10/10
>  g <- expand.grid(p = s, q = s)
>  idx <- which.min(apply(g, 1, f))
>  idx
>  g[idx,] 
>  
>  I am not sure if this is correct and also this can only solve one 
> row. How to get the whole 1000 rows of p and q?
>  
>  Thanks.
>  
>  Annie
>  
>  __
>  R-help@r-project.org mailing list
>  
>  PLEASE do read the posting guide 
>  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.


Re: [R] help about solving two equations

2010-03-11 Thread Ravi Varadhan
You have to install it from CRAN before you can load it into your session.



Ravi Varadhan, Ph.D.
Assistant Professor,
Division of Geriatric Medicine and Gerontology
School of Medicine
Johns Hopkins University

Ph. (410) 502-2619
email: rvarad...@jhmi.edu


- Original Message -
From: Shaoqiong Zhao 
Date: Thursday, March 11, 2010 9:00 pm
Subject: Re: [R] help about solving two equations
To: Ravi Varadhan 
Cc: r-help@r-project.org


> Hello Professor Ravi,
>  
>  I tried to load BB into R, but I got the following message:
>   library("BB")
>  Error in library("BB") : there is no package called 'BB'
>  > library(BB)
>  Error in library(BB) : there is no package called 'BB'
>  
>  Can you tell me why?
>  
>  Thanks a lot.
>  
>  Annie
>  
>  
>  - Original Message -
>  From: "Ravi Varadhan" 
>  To: "Shaoqiong Zhao" 
>  Cc: r-help@r-project.org
>  Sent: Wednesday, March 10, 2010 9:03:25 PM GMT -06:00 US/Canada Central
>  Subject: Re: [R] help about solving two equations
>  
>  Here is how you can solve:
>  
>  fn <- function(x, s){
>  f <- rep(NA, length(x))
>  f[1] <- digamma(x[1]) - digamma(x[1]+x[2]) - s[1]
>  f[2] <- digamma(x[2]) - digamma(x[1]+x[2]) - s[2]
>  f
>  }
>  
>  require(BB) # load this package for the nonlinear solver
>  
>  s <- c(-2, -4)  # one row of s1 and s2
>  
>  ans <- dfsane(par=c(1,1), fn=fn, s=s)
>  
>  ans$par  # solutions for p and q
>  
>  You can then loop through for each row of s1 and s2 and solve it to 
> get corresponding p and q.
>  
>  Ravi.
>  
>  
>  Ravi Varadhan, Ph.D.
>  Assistant Professor,
>  Division of Geriatric Medicine and Gerontology
>  School of Medicine
>  Johns Hopkins University
>  
>  Ph. (410) 502-2619
>  email: rvarad...@jhmi.edu
>  
>  
>  - Original Message -
>  From: Shaoqiong Zhao 
>  Date: Wednesday, March 10, 2010 8:19 pm
>  Subject: [R] help about solving two equations
>  To: r-help@r-project.org
>  
>  
>  > I have two matrix s1 and s2, each of them is 1000*1.
>  >  and I have two equations:
>  >  digamma(p)-digamma(p+q)=s1,
>  >  digamma(q)-digamma(p+q)=s2,
>  >  and I want to sovle these two equations to get the value of x and 
> y, 
>  > which are also two 1000*1 matrices.
>  >  
>  >  I write a program like this:
>  >  
>  >  f <- function(x) {
>  >  p<- x[1]; q <- x[2]; 
>  >   ((digamma(p)-digamma(p+q)-s1[2,]) )^2 
>  > +((digamma(q)-digamma(p+q)-s2[2,]) )^2
>  >   }
>  >  s <- 1:10/10
>  >  g <- expand.grid(p = s, q = s)
>  >  idx <- which.min(apply(g, 1, f))
>  >  idx
>  >  g[idx,] 
>  >  
>  >  I am not sure if this is correct and also this can only solve one 
> 
>  > row. How to get the whole 1000 rows of p and q?
>  >  
>  >  Thanks.
>  >  
>  >  Annie
>  >  
>  >  __
>  >  R-help@r-project.org mailing list
>  >  
>  >  PLEASE do read the posting guide 
>  >  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.


Re: [R] argument is of length zero

2010-03-11 Thread jim holtman
Test for the condition you are looking for.  If the grep does not match, it
returns a vector of length zero

> a='hello world'
> if (length(grep('hellow',a)) != 0) {
+ print("wow")
+ } else {
+ print("wow2")
+}
[1] "wow2"
>


On Thu, Mar 11, 2010 at 6:59 PM, Dan Joo  wrote:

> I am new to R, so I beg your indulgence.
> > a='hello world'
> > if (grep('hellow',a)) {
> print("wow")
> } else {
> print("wow2")
>}
> Error in if (grep("hellow", a)) { : argument is of length zero
>
> What is the proper syntax to ensure that "wow2" gets printed?
>
> Thank you for your help!
>
> Dan
>
>[[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.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] as.integer and indexes error

2010-03-11 Thread jim holtman
another way:

> x <- c(1.1,2.1,3.1,4.1,5.1)
> as.integer((x - round(x)) * 10)
[1] 1 1 1 0 0
> as.integer((10 * x - round(10 * x, -1)))
[1] 1 1 1 1 1
>


2010/3/11 Lilia Leticia Ramírez Ramírez 

> Hello All,
>
> I would like to report the following bug or maybe you can explain if I am
> wrong.
>
> I am sampling from two different populations with weights. The two
> populations have the same age groups and I want to distinguish where I am
> sampling from. That is why I am using a matrix such as:
> matrix
> age.group  Male  Females   Weight.Males Weight.Females
> 1   1.11.2
> 3  4
> 2   2.12.2
> 6   5
> 3   3.1 3.2
> 3 5
> 4   4.1 4.2
> 9  2
>
> If a sample a element:
> uno<-sample(matrix[,2:3],1,prob=matrix[,4:5])
> I want to be able to recover from wich age.group and sex the individual is,
> but
>
> as.integer((uno-round(uno))*10)  is equal to 0 when uno is male, while it
> is
> 2 when a female. That is, for example:
>
> as.integer((4.1-round(4.1))*10) is equal to 0 (instead of 1)
>
> The rounding error is eliminated for
> as.integer((uno[j,2]-round(uno))*11)  since it is equal to 1 when male and
> 2 when female.
>
> I noticed this problem when trying to use
>
> other.matrix[j, (uno[j,2]-round(uno))*10)]
>
> for a matrix with information with first information about males and second
> column about females.
>
> Thank you kindly.
> Lilia
>
>[[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.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] as.integer and indexes error

2010-03-11 Thread jim holtman
FAQ 7.31



2010/3/11 Lilia Leticia Ramírez Ramírez 

> Hello All,
>
> I would like to report the following bug or maybe you can explain if I am
> wrong.
>
> I am sampling from two different populations with weights. The two
> populations have the same age groups and I want to distinguish where I am
> sampling from. That is why I am using a matrix such as:
> matrix
> age.group  Male  Females   Weight.Males Weight.Females
> 1   1.11.2
> 3  4
> 2   2.12.2
> 6   5
> 3   3.1 3.2
> 3 5
> 4   4.1 4.2
> 9  2
>
> If a sample a element:
> uno<-sample(matrix[,2:3],1,prob=matrix[,4:5])
> I want to be able to recover from wich age.group and sex the individual is,
> but
>
> as.integer((uno-round(uno))*10)  is equal to 0 when uno is male, while it
> is
> 2 when a female. That is, for example:
>
> as.integer((4.1-round(4.1))*10) is equal to 0 (instead of 1)
>
> The rounding error is eliminated for
> as.integer((uno[j,2]-round(uno))*11)  since it is equal to 1 when male and
> 2 when female.
>
> I noticed this problem when trying to use
>
> other.matrix[j, (uno[j,2]-round(uno))*10)]
>
> for a matrix with information with first information about males and second
> column about females.
>
> Thank you kindly.
> Lilia
>
>[[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.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] simple plot in ggplot2, wrong error bars

2010-03-11 Thread hpdutra

I was wondering if anyone  could help me with this, simple problem. 

I am essentially following the example on Hadley's  webpage
(http://had.co.nz/ggplot2/geom_errorbar.html), but it still doesn't make any
sense to me. 


df <- data.frame(trt = factor(c("intact", "intact", "removed", "removed")),
coon = c(0.093, 0.06, 0.057, 0.09), group = factor(c("veget", "fruit",
"veget", "fruit")), se = c(0.01, 0.01, 0.02, 0.026))
 limits <- aes(ymax = coon + se, ymin=coon - se)
 p<-ggplot(df, aes(fill=group, y=coon, x=trt))
p+geom_bar(position="dodge",stat="identity")
dodge <- position_dodge(width=0.9)
> p + geom_bar(position="dodge") + geom_errorbar(limits, position="dodge",
> width=0.5)

as you noticed the code above gets the error bars in the wrong columns. 
So I used the code below (I replaced position_dodge w/ a negative value and
geom_errorbarr with dodge no quote marks)

df <- data.frame(trt = factor(c("intact", "intact", "removed", "removed")),
coon = c(0.093, 0.06, 0.057, 0.09), group = factor(c("veget", "fruit",
"veget", "fruit")), se = c(0.01, 0.01, 0.02, 0.026))
limits <- aes(ymax = coon + se, ymin=coon - se)
p<-ggplot(df, aes(fill=group, y=coon, x=trt))
p+geom_bar(position="dodge",stat="identity")
dodge <- position_dodge(width=-0.9)
> p + geom_bar(position="dodge") + geom_errorbar(limits, position=dodge,
> width=0.5)


Why do I need to use negative values to get the right errorbar structure,
why do I need use doge without quote marks?
Thanks

Beto



-- 
View this message in context: 
http://n4.nabble.com/simple-plot-in-ggplot2-wrong-error-bars-tp1589994p1589994.html
Sent from the R help mailing list archive at Nabble.com.

__
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] as.integer and indexes error

2010-03-11 Thread Lilia Leticia Ramírez Ramírez
Hello All,

I would like to report the following bug or maybe you can explain if I am
wrong.

I am sampling from two different populations with weights. The two
populations have the same age groups and I want to distinguish where I am
sampling from. That is why I am using a matrix such as:
matrix
age.group  Male  Females   Weight.Males Weight.Females
1   1.11.2
3  4
2   2.12.2
6   5
3   3.1 3.2
3 5
4   4.1 4.2
9  2

If a sample a element:
uno<-sample(matrix[,2:3],1,prob=matrix[,4:5])
I want to be able to recover from wich age.group and sex the individual is,
but

as.integer((uno-round(uno))*10)  is equal to 0 when uno is male, while it is
2 when a female. That is, for example:

as.integer((4.1-round(4.1))*10) is equal to 0 (instead of 1)

The rounding error is eliminated for
as.integer((uno[j,2]-round(uno))*11)  since it is equal to 1 when male and
2 when female.

I noticed this problem when trying to use

other.matrix[j, (uno[j,2]-round(uno))*10)]

for a matrix with information with first information about males and second
column about females.

Thank you kindly.
Lilia

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] argument is of length zero

2010-03-11 Thread Dan Joo
I am new to R, so I beg your indulgence.
> a='hello world'
> if (grep('hellow',a)) {
print("wow")
} else {
print("wow2")
}
Error in if (grep("hellow", a)) { : argument is of length zero

What is the proper syntax to ensure that "wow2" gets printed?

Thank you for your help!

Dan

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Problem installing new packages

2010-03-11 Thread Jim Burke

Never mind, thanks

Jim Burke wrote:

Hi everyone,

Using R 2.10.1 on Windows Vista.
DOWNLOADED PACKAGES DO NOT INSTALL. I expect to see them in C:\Program 
Files\R\R-2.10.1\library  These files download (see below). And they 
are all in zip format. What am I doing wrong? Please help. All 
suggestions appreciated.


trying URL 
'http://cran.cnr.Berkeley.edu/bin/windows/contrib/2.10/RColorBrewer_1.0-2.zip' 


Content type 'application/zip' length 23875 bytes (23 Kb)
opened URL
downloaded 23 Kb

package 'mnormt' successfully unpacked and MD5 sums checked
package 'mvtnorm' successfully unpacked and MD5 sums checked
package 'scatterplot3d' successfully unpacked and MD5 sums checked
package 'sn' successfully unpacked and MD5 sums checked
package 'pspline' successfully unpacked and MD5 sums checked
package 'akima' successfully unpacked and MD5 sums checked
package 'lme4' successfully unpacked and MD5 sums checked
package 'latticeExtra' successfully unpacked and MD5 sums checked
package 'copula' successfully unpacked and MD5 sums checked
package 'ellipse' successfully unpacked and MD5 sums checked
package 'gridBase' successfully unpacked and MD5 sums checked
package 'locfit' successfully unpacked and MD5 sums checked
package 'logspline' successfully unpacked and MD5 sums checked
package 'mapproj' successfully unpacked and MD5 sums checked
package 'maps' successfully unpacked and MD5 sums checked
package 'MEMSS' successfully unpacked and MD5 sums checked
package 'mlmRev' successfully unpacked and MD5 sums checked
package 'RColorBrewer' successfully unpacked and MD5 sums checked

The downloaded packages are in
   C:\Users\Owner\AppData\Local\Temp\RtmpvYKBW7\downloaded_packages

Thanks,
Jim Burke

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


[R] Problem installing new packages

2010-03-11 Thread Jim Burke

Hi everyone,

Using R 2.10.1 on Windows Vista. 

DOWNLOADED PACKAGES DO NOT INSTALL. I expect to see them in C:\Program 
Files\R\R-2.10.1\library  These files download (see below). And they are 
all in zip format. What am I doing wrong? Please help. All suggestions 
appreciated.


trying URL 
'http://cran.cnr.Berkeley.edu/bin/windows/contrib/2.10/RColorBrewer_1.0-2.zip'

Content type 'application/zip' length 23875 bytes (23 Kb)
opened URL
downloaded 23 Kb

package 'mnormt' successfully unpacked and MD5 sums checked
package 'mvtnorm' successfully unpacked and MD5 sums checked
package 'scatterplot3d' successfully unpacked and MD5 sums checked
package 'sn' successfully unpacked and MD5 sums checked
package 'pspline' successfully unpacked and MD5 sums checked
package 'akima' successfully unpacked and MD5 sums checked
package 'lme4' successfully unpacked and MD5 sums checked
package 'latticeExtra' successfully unpacked and MD5 sums checked
package 'copula' successfully unpacked and MD5 sums checked
package 'ellipse' successfully unpacked and MD5 sums checked
package 'gridBase' successfully unpacked and MD5 sums checked
package 'locfit' successfully unpacked and MD5 sums checked
package 'logspline' successfully unpacked and MD5 sums checked
package 'mapproj' successfully unpacked and MD5 sums checked
package 'maps' successfully unpacked and MD5 sums checked
package 'MEMSS' successfully unpacked and MD5 sums checked
package 'mlmRev' successfully unpacked and MD5 sums checked
package 'RColorBrewer' successfully unpacked and MD5 sums checked

The downloaded packages are in
   C:\Users\Owner\AppData\Local\Temp\RtmpvYKBW7\downloaded_packages

Thanks,
Jim Burke

__
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] VAR with contemporaneous effects

2010-03-11 Thread Downey, Patrick
Hi,

I would like to estimate a VAR of the form:

Ay_t = By_t-1 + Cy_t-2 + ... + Dx_t + e_t

Where A is a non-diagonal matrix of coefficients, B and C are matricies of
coefficients and D is a matrix of coefficients for the exogenous variables.

I don't think the package {vars} can do this because I want to include
contemporaneous cross-variable impacts. 

So I want y1_t to affect y2_t and I think in {vars} I can only have y1_t-1
affect y2_t. 

{vars} will only allow VARs of the form:

y_t = By_t-1 + Cy_t-2 + ... + Dx_t + e_t

Solutions? Maybe another package? Or maybe I'm thinking about this wrong?

(And I know that I have to put constraints on A to get identification - I'm
willing to do that).

Thanks,
Mitch Downey

__
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] NAs and row/column calculations

2010-03-11 Thread RICHARD M. HEIBERGER
Jim,

The next step for understanding what happens is to subset a complicated
expression
 and see what its sub-pieces are doing.
Since
  apply(a[!is.na(a)],2,sum)
doesn't work, start by looking at each of the arguments to apply.
You already verified that
  !is.na(a)
gives what you want.  Now take the next step and see that
  a[!is.na(a)]
doesn't give what you want.

Looking at nested sets of sub-expressions is the key to learning R.

Rich

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] NAs and row/column calculations

2010-03-11 Thread Jim Bouldin

> 
> On 12/03/2010, at 11:25 AM, Jim Bouldin wrote:
> 
> > 
> > I continue to have great frustrations with NA values--in particular
> making
> > summary calculations on rows or cols of a matrix containing them.  For
> > example, why does:
> > 
> >> a = matrix(1:30,nrow=5)
> >> is.na(a[c(1:2),c(3:4)]);a
> > [,1] [,2] [,3] [,4] [,5] [,6]
> > [1,]16   NA   NA   21   26
> > [2,]27   NA   NA   22   27
> > [3,]38   13   18   23   28
> > [4,]49   14   19   24   29
> > [5,]5   10   15   20   25   30
> >> apply(a[!is.na(a)],2,sum)
> > 
> > give me this:
> > 
> > "Error in apply(a[!is.na(a)], 2, sum) : dim(X) must have a positive
> length"
> > 
> > when
> > 
> >> dim(a)
> > [1] 5 6
> > 
> > What is the trick to calculating summary values from rows or columns
> > containing NAs?  Drives me nuts.  More nuts that is.
> 
> When you do a[!is.na(a)] you get a ***vector*** --- not a matrix.
> ``Obviously''!!!  

Well, obvious to you maybe, or someone who's done it before, but not to me.

The non-missing values of a cannot be arranged in
> a 5 x 6 matrix; there are only 26 of them.  So (as my late Uncle
> Stanley would have said) ``What the hell do you expect?''.

Silly me, I expected, based on (1) previous experience doing summary calcs
on subsets of a matrix using exactly that style of command, and (2) the
fact that dim(a) returns: [1] 5 6, and (3) the fact that a help search
under the "apply" function gives NO INDICATION of any possible use of the
na.rm command, AND (4) a help search on "na.action" does not even mention
na.rm, that:
 
> apply(a[!is.na(a)],2,sum)

would sum the non-NA elements of matrix a, by columns.  Terribly faulty
reasoning on my part, obviously.


> 
> The ``trick'' is to remove the NAs at the summing stage:
> 
> apply(a,2,sum,na.rm=TRUE)
> 
> Not all that tricky.
> 
>   cheers,
> 
>   Rolf Turner
> 
> ##
> Attention: 
> This e-mail message is privileged and confidential. If you are not the 
> intended recipient please delete the message and notify the sender. 
> Any views or opinions presented are solely those of the author.
> 
> This e-mail has been scanned and cleared by MailMarshal 
> www.marshalsoftware.com
> ##
> 

Jim Bouldin, PhD
Research Ecologist
Department of Plant Sciences, UC Davis
Davis CA, 95616
530-554-1740

__
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] NAs and row/column calculations

2010-03-11 Thread Rolf Turner

On 12/03/2010, at 11:25 AM, Jim Bouldin wrote:

> 
> I continue to have great frustrations with NA values--in particular making
> summary calculations on rows or cols of a matrix containing them.  For
> example, why does:
> 
>> a = matrix(1:30,nrow=5)
>> is.na(a[c(1:2),c(3:4)]);a
> [,1] [,2] [,3] [,4] [,5] [,6]
> [1,]16   NA   NA   21   26
> [2,]27   NA   NA   22   27
> [3,]38   13   18   23   28
> [4,]49   14   19   24   29
> [5,]5   10   15   20   25   30
>> apply(a[!is.na(a)],2,sum)
> 
> give me this:
> 
> "Error in apply(a[!is.na(a)], 2, sum) : dim(X) must have a positive length"
> 
> when
> 
>> dim(a)
> [1] 5 6
> 
> What is the trick to calculating summary values from rows or columns
> containing NAs?  Drives me nuts.  More nuts that is.

When you do a[!is.na(a)] you get a ***vector*** --- not a matrix.
``Obviously''!!!  The non-missing values of a cannot be arranged in
a 5 x 6 matrix; there are only 26 of them.  So (as my late Uncle
Stanley would have said) ``What the hell do you expect?''.

The ``trick'' is to remove the NAs at the summing stage:

apply(a,2,sum,na.rm=TRUE)

Not all that tricky.

cheers,

Rolf Turner

##
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}

__
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] NAs and row/column calculations

2010-03-11 Thread Greg Snow
What do you expect a[!is.na(a)] to be?

The a matrix has 30 elements, 5 rows, and 6 columns.  You tell R to throw away 
4 elements leaving you with 26, the computer (and most of the rest of us) 
doesn't know how to make a 5x6 matrix with only 26 elements.  It could make a 
2x13 or 13x2, but that is unlikely what you want, so it just returns a vector 
without dimensions which then confuses the apply function.

Instead try:

> apply(a,2,sum, na.rm=TRUE)

Or

> apply(a, 2, function(x) sum( x[!is.na(x)] ) )

Hope this helps,

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
> project.org] On Behalf Of Jim Bouldin
> Sent: Thursday, March 11, 2010 3:26 PM
> To: R help
> Subject: [R] NAs and row/column calculations
> 
> 
> I continue to have great frustrations with NA values--in particular
> making
> summary calculations on rows or cols of a matrix containing them.  For
> example, why does:
> 
> > a = matrix(1:30,nrow=5)
> > is.na(a[c(1:2),c(3:4)]);a
>  [,1] [,2] [,3] [,4] [,5] [,6]
> [1,]16   NA   NA   21   26
> [2,]27   NA   NA   22   27
> [3,]38   13   18   23   28
> [4,]49   14   19   24   29
> [5,]5   10   15   20   25   30
> > apply(a[!is.na(a)],2,sum)
> 
> give me this:
> 
> "Error in apply(a[!is.na(a)], 2, sum) : dim(X) must have a positive
> length"
> 
> when
> 
> > dim(a)
> [1] 5 6
> 
> What is the trick to calculating summary values from rows or columns
> containing NAs?  Drives me nuts.  More nuts that is.
> 
> Thanks.
> 
> 
> 
> 
> Jim Bouldin, PhD
> Research Ecologist
> Department of Plant Sciences, UC Davis
> Davis CA, 95616
> 530-554-1740
> 
> __
> 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.


[R] parse an HTML page with verbose error message (using XML)

2010-03-11 Thread Yihui Xie
I'm using the function htmlParse() in the XML package, and I need a
little bit help on error handling while parsing an HTML page. So far I
can use either the default way:

# error = xmlErrorCumulator(), by default
library(XML)
doc = htmlParse("http://www.public.iastate.edu/~pdixon/stat500/";)
# the error message is:
# htmlParseStartTag: invalid element name

or the tryCatch() approach:

# error = NULL, errors to be caught by tryCatch()
tryCatch({
doc = htmlParse("http://www.public.iastate.edu/~pdixon/stat500/";,
error = NULL)
}, XMLError = function(e) {
cat("There was an error in the XML at line", e$line, "column",
e$col, "\n", e$message, "\n")
})
# verbose error message as:
# There was an error in the XML at line 90 column 2
# htmlParseStartTag: invalid element name

I wish to get the verbose error messages without really stopping the
parsing process; the first approach cannot return detailed error
messages, while the second one will stop the program...

Thanks!

Regards,
Yihui
--
Yihui Xie 
Phone: 515-294-6609 Web: http://yihui.name
Department of Statistics, Iowa State University
3211 Snedecor Hall, Ames, IA

__
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] tm[,-1]

2010-03-11 Thread Ted Harding
On 11-Mar-10 22:12:47, Greg Snow wrote:
>> -Original Message-
>> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
>> project.org] On Behalf Of ManInMoon
>> Sent: Thursday, March 11, 2010 4:22 AM
>> To: r-help@r-project.org
>> Subject: [R] tm[,-1]
> [snip]
>> Please don't tell me to check the manual - I tried and failed
>> dismally...
>>
[snip]
> There seems to be more and more people that feel a quick answer
> on the list is preferable to trying to understand the manuals.
> What if someone asked about the best shape for a wheel and did
> not want to read the manual, they mention that they have a square
> wheel that doesn't work, and when they tried a triangle it was
> even worse. Someone else then replies that they have had better
> luck with pentagons and hexagons look promising. Someone else
> mentions that they tried and octagon and it worked even better.
> Then someone comes in with the theory that a decagon would be
> even better, provided you can create a regular decagon, but
> they unfortunately have only succeeded at creating irregular
> ones that don't work as well as the octagon. A side branch then
> develops discussing smooth shapes of constant radius that would
> work as rollers, but don't quite work as wheels. All this time
> the manual has a good description of circles used as wheels
> including a simple way to make them, but!
> you won't look there, so you are doomed to a suboptimal solution.
[snip]

I have had good success recently with wheels based on the outline
of the Mandelbrot Set. These are perfectly adapted to the fractal
distribution of potholes in my local roads, following our recent
spell of very cold and snowy weather. However, I could not find
this in the manual, and was reduced to rolling my own ...
Ted.


E-Mail: (Ted Harding) 
Fax-to-email: +44 (0)870 094 0861
Date: 11-Mar-10   Time: 22:34:33
-- XFMail --

__
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] Help Files Now Load in the Internet Browser?

2010-03-11 Thread Carl Witthoft

On 11/03/2010 12:21 PM, David Bapst wrote:
> Hello,
> I recently had to reinstall R on my windows machine, because MASS
> mysteriously vanished from my packages list. Before, when I used
> help(), the files would load in a Windows help window. Now, the help
> files load in my internet browser, which actually is problematic
> because I always made use of the contents/topics list to browse the
> help files in the Windows Help window. ("I don't remember the name of
> the function, but it was in MASS, so I'll just open a help file for a
> different function in MASS...").
>
> I looked in the updates list and read that the help files had been
> converted. Is there still any way to get the help files to load again
> in the windows html help with the topics list?

No, there isn't. You can get an equivalent list to the index (same 
information, different format) by running help.start() and clicking on 
the "Packages" link.


Duncan Murdoch


Well, careful there.  If you were to use OSX, you could indeed get the 
R.app gui's help window to display help files.


__
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] Append to outfile in R CMD BATCH mode

2010-03-11 Thread Turchin, Michael
Is there a way to append to the outfile when using R CMD BATCH? My code, right 
now, is:

R CMD BATCH --slave --vanilla '--args place .2 -.1 .9 .6' 
StratificationSimulation example.output

Everything else is working the way I'd like it. The first few lines of code of 
my script file are:

options(echo=FALSE)
cmd_args = commandArgs()
print (cmd_args)
#d <- read.table("/dev/stdin")

if that helps any. However, I cannot currently change the output to append, 
rather than override, the designated outfile. Maybe I could potentially use 
sink(__, append=TRUE) if I could somehow reference the outfile from within the 
script (and assuming my understanding of sink() is correct)?

Any thoughts, or help? They're all greatly appreciated.
Thanks!
~Michael
Children's Hospital Boston
The Broad Institute
__
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] NAs and row/column calculations

2010-03-11 Thread Jim Bouldin

I continue to have great frustrations with NA values--in particular making
summary calculations on rows or cols of a matrix containing them.  For
example, why does:

> a = matrix(1:30,nrow=5)
> is.na(a[c(1:2),c(3:4)]);a
 [,1] [,2] [,3] [,4] [,5] [,6]
[1,]16   NA   NA   21   26
[2,]27   NA   NA   22   27
[3,]38   13   18   23   28
[4,]49   14   19   24   29
[5,]5   10   15   20   25   30
> apply(a[!is.na(a)],2,sum)

give me this:

"Error in apply(a[!is.na(a)], 2, sum) : dim(X) must have a positive length"

when

> dim(a)
[1] 5 6

What is the trick to calculating summary values from rows or columns
containing NAs?  Drives me nuts.  More nuts that is.

Thanks.




Jim Bouldin, PhD
Research Ecologist
Department of Plant Sciences, UC Davis
Davis CA, 95616
530-554-1740

__
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] Statet on Eclipse: ${project_path} is empty

2010-03-11 Thread Paul

Hello,

I'm tryign to use Statet on Eclipse on my Kubuntu Karmic PC.  I've set 
everything up and I can start the R configuration, but the working 
directory is set to my home directory.  If I set the start in directory 
to ${worspace_loc}/${project_path} I can't start the console, with an 
error that project_path is empty.


Am I doing something wrong.  I feel that Eclipse and Statet will be the 
best way to use R, but it's so hard to setup at the moment.


Regards,

Paul.

__
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] tm[,-1]

2010-03-11 Thread Greg Snow
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
> project.org] On Behalf Of ManInMoon
> Sent: Thursday, March 11, 2010 4:22 AM
> To: r-help@r-project.org
> Subject: [R] tm[,-1]
> 

[snip]

> 
> 
> Please don't tell me to check the manual - I tried and failed
> dismally...
> 

But often the best answer is to read the manual, or reread the manual, there is 
nothing wrong with asking for suggestions on which parts of the manual to read 
(there is a lot out there now), or for clarifications of parts that you do not 
understand.  If you can tell why you failed, then that gives others information 
that can be used to improve the manuals, but what you said is very unhelpful.

There seems to be more and more people that feel a quick answer on the list is 
preferable to trying to understand the manuals.  What if someone asked about 
the best shape for a wheel and did not want to read the manual, they mention 
that they have a square wheel that doesn't work, and when they tried a triangle 
it was even worse.  Someone else then replies that they have had better luck 
with pentagons and hexagons look promising.  Someone else mentions that they 
tried and octagon and it worked even better.  Then someone comes in with the 
theory that a decagon would be even better, provided you can create a regular 
decagon, but they unfortunately have only succeeded at creating irregular ones 
that don't work as well as the octagon.  A side branch then develops discussing 
smooth shapes of constant radius that would work as rollers, but don't quite 
work as wheels.  All this time the manual has a good description of circles 
used as wheels including a simple way to make them, but!
  you won't look there, so you are doomed to a suboptimal solution.

Let's look at the replies you received for the tm[,-1] query.  They were of 2 
general types: "go read the manual anyway" (which I would consider the best 
answer) and "it means the matrix without the 1st column" which is a dodecagon 
type answer, consider the following:

> tm <- matrix(1:12, ncol=3)
> tm
 [,1] [,2] [,3]
[1,]159
[2,]26   10
[3,]37   11
[4,]48   12
> tm[,-1]
 [,1] [,2]
[1,]59
[2,]6   10
[3,]7   11
[4,]8   12


OK, tm is a matrix and tm[,-1] looks like the same matrix without the 1st 
column.  But what if we change the example a little bit:

> tm <- matrix(1:8, ncol=2)
> tm
 [,1] [,2]
[1,]15
[2,]26
[3,]37
[4,]48
> tm[,-1]
[1] 5 6 7 8

This result looks different, what happened? And what should you do if you want 
results more like the first example?  The answer is in the manual ?"[".


-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111

 


-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111

__
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] Ubunut + Eclipse + StatET: Console terminates upon error

2010-03-11 Thread Tom La Bone

I don't want to hijack the thread here, but since you mentioned "hover pop-up
help" can you suggest a way to turn it OFF, totally and completely?

Tom LaBone
-- 
View this message in context: 
http://n4.nabble.com/Ubunut-Eclipse-StatET-Console-terminates-upon-error-tp1589479p1589800.html
Sent from the R help mailing list archive at Nabble.com.

__
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] combinations/ indexing a matrix

2010-03-11 Thread RICHARD M. HEIBERGER
res <- combn(4,2)
result <- LETTERS[res]
dim(result) <- dim(res)
result


## Rich

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] combinations/ indexing a matrix

2010-03-11 Thread Michael Friendly
For a package application, I want to generate all 1-way, or 2-way, ... 
combinations of factors, symbolically, as a matrix.

E.g., all two-way terms among 4 factors.

> factors <- LETTERS[1:4]
> combn(4,2)
[,1] [,2] [,3] [,4] [,5] [,6]
[1,]111223
[2,]234344

But I want to replace the numbers I  in the above by factors[I].  I know 
I can do this with gtools::combinations:


> t(combinations(4,2,factors))
[,1] [,2] [,3] [,4] [,5] [,6]
[1,] "A"  "A"  "A"  "B"  "B"  "C"
[2,] "B"  "C"  "D"  "C"  "D"  "D"

But I'd prefer not to have to require an extra package if there is a 
simpler way using base R, e.g., by indexing
the result of combn() using factors.  I tried, among other non-working 
things:


> res <- combn(4,2)
> res[] <- LETTERS[1:4]
> res
[,1] [,2] [,3] [,4] [,5] [,6]
[1,] "A"  "C"  "A"  "C"  "A"  "C"
[2,] "B"  "D"  "B"  "D"  "B"  "D"

right shape, but wrong result.  What is the magic incantation here?




--
Michael Friendly Email: friendly AT yorku DOT ca 
Professor, Psychology Dept.

York University  Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele Streethttp://www.math.yorku.ca/SCS/friendly.html
Toronto, ONT  M3J 1P3 CANADA

__
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] cut.POSIXt misconception/feature/bug?

2010-03-11 Thread Brian Diggs

On 3/11/2010 11:52 AM, Brian Diggs wrote:

I've included a patch against cut.POSIXt.Rd with these proposed changes.


Apparently the patch didn't make it through, so I'm just pasting it below.


--
Brian Diggs, Ph.D.
Senior Research Associate, Department of Surgery, Oregon Health & Science 
University


Index: cut.POSIXt.Rd
===
--- cut.POSIXt.Rd   (revision 51247)
+++ cut.POSIXt.Rd   (working copy)
@@ -20,8 +20,10 @@
 \arguments{
   \item{x}{an object inheriting from class \code{"POSIXt"} or 
\code{"Date"}.}

   \item{breaks}{
-a vector of cut points \emph{or} number giving the number of
-intervals which \code{x} is to be cut into \emph{or} an
+either a \code{POSIXt} or \code{Date} vector of two or
+more cut points \emph{or} a single number (greater than
+or equal to 2) giving the number of intervals into which
+\code{x} is to be cut \emph{or} an
 interval specification, one of \code{"sec"}, \code{"min"},
 \code{"hour"}, \code{"day"}, \code{"DSTday"}, \code{"week"},
 \code{"month"}, \code{"quarter"} or \code{"year"}, optionally
@@ -42,7 +44,7 @@
 }
 \details{
   Using both \code{right = TRUE} and \code{include.lowest = TRUE}
-  will include both ends of the range of dates.
+  will include both ends of the range of \code{breaks}.

   Using \code{breaks = "quarter"} will create intervals of 3 calendar
   months, with the intervals beginning on January 1, April 1,

__
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] Searching for option explanations

2010-03-11 Thread Turchin, Michael
Yep, looks like that is what I'm asking about. Didn't realize it! Thank you, 
exactly what I needed.

~Michael

From: Charles C. Berry [cbe...@tajo.ucsd.edu]
Sent: Thursday, March 11, 2010 3:37 PM
To: Turchin, Michael
Cc: r-help@r-project.org
Subject: Re: [R] Searching for option explanations

On Thu, 11 Mar 2010, Turchin, Michael wrote:

> Hey all,
>
> Sorry if this is redundant, but I can't figure out a good search query
> for either the mailing list, or google, to find an answer to this.
>
> Let's say I have a couple of R options I'm interested in learning more
> about, but their details aren't explained in the command's help file.
> For example, for R CMD BATCH --help, it discusses the use of --restore,
> --save and --no-readline. But there are no in depth details about those
> options themselves.
>
> If I wanted to learn more about what --no-readline is, or --restore or
> --save, is there some basic R resource I can use to find this? I tried
> exploring options(), but I don't necessarily see what I'm looking for
> there. And google searching "R '--restore'" is not providing much of
> value in return. Am I missing something obvious on how to do this?

What you are asking about is startup options, right?

See Intro to R Appendix B Invoking R

HTH,

Chuck

>
> Any thoughts would be greatly appreciated. Thanks for your help!
> ~Michael
> Children's Hospital Boston
> The Broad Institute
> __
> 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.
>

Charles C. Berry(858) 534-2098
 Dept of Family/Preventive Medicine
E mailto:cbe...@tajo.ucsd.edu   UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901

__
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] Importing Time Series Data for an R Beginner

2010-03-11 Thread ManInMoon

z<-read.table("C:/yourfile.txt",header=TRUE,as.is=TRUE);
zdates<-as.POSIXct(strptime(paste(z[,2],z[,3]), "%m/%d/%Y
%H:%M:%S"),origin="1970-01-01" );

I would then convert z from a dataframe to a numeric matrix, and put zdates
in there as numeric too.

zm<-cbind(z[,1],as.numeric(zdates),z[,4])

I am a beginner too - but have just been through this.
-- 
View this message in context: 
http://n4.nabble.com/Importing-Time-Series-Data-for-an-R-Beginner-tp1589685p1589696.html
Sent from the R help mailing list archive at Nabble.com.

__
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] colname of ... arguments

2010-03-11 Thread ManInMoon

Thanks Duncan - that works perfectly.
-- 
View this message in context: 
http://n4.nabble.com/colname-of-arguments-tp1588146p1589687.html
Sent from the R help mailing list archive at Nabble.com.

__
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] Importing Time Series Data for an R Beginner

2010-03-11 Thread Cedrick W. Johnson
Actually I just learned something myself that you can do on the dataset 
*without* the additional step in Excel.. I changed the format in 
strptime to match the format (d'oh) and whala:


 x
  Subject  Date Time Value
1   1 7/23/2003 13:05:0084
2   1 7/23/2003 13:10:0087
3   1 7/23/2003 13:15:0095
4   2 9/25/2004 14:34:0095
5   2 9/25/2004 14:39:0081
6   2 9/25/2004 14:44:0093
7   3  3/2/2004 16:34:0072
8   3  3/2/2004 16:39:0067
9   3  3/2/2004 16:44:0083
> dates = as.POSIXct(strptime(paste(x[,2], x[,3], sep=" "), 
format="%m/%d/%Y %H:%M:%S"))

> dates
[1] "2003-07-23 13:05:00 EDT" "2003-07-23 13:10:00 EDT" "2003-07-23 
13:15:00 EDT"
[4] "2004-09-25 14:34:00 EDT" "2004-09-25 14:39:00 EDT" "2004-09-25 
14:44:00 EDT"
[7] "2004-03-02 16:34:00 EST" "2004-03-02 16:39:00 EST" "2004-03-02 
16:44:00 EST"


> data = xts(x[,c(1,4)], order.by=dates)
> data
Subject Value
2003-07-23 13:05:00   184
2003-07-23 13:10:00   187
2003-07-23 13:15:00   195
2004-03-02 16:34:00   372
2004-03-02 16:39:00   367
2004-03-02 16:44:00   383
2004-09-25 14:34:00   295
2004-09-25 14:39:00   281
2004-09-25 14:44:00   293



hth,
c

ps: my first message didn't make it to the list... apparently i had a 
bad header??

=
Cedrick W. Johnson
aolim) cedrickjcvgr
www.cedrickjohnson.com
New York - Chicago


On 3/11/2010 3:34 PM, Cedrick W. Johnson (CJ) wrote:

Hi Clay-

You may want to look at both the XTS package, in addition to 'strptime'
and 'as.POSIXct'

When I get datasets in Excel, what I normally do is change the date
(column) format to -mm-dd.. But that's due to my own shortcomings
with date formatting in R.

Here's a quick example:

 > x = read.csv('TestData.csv')
 > x
Subject Date Time Value
1 1 2003-07-23 13:05:00 84
2 1 2003-07-23 13:10:00 87
3 1 2003-07-23 13:15:00 95
4 2 2004-09-25 14:34:00 95
5 2 2004-09-25 14:39:00 81
6 2 2004-09-25 14:44:00 93
7 3 2004-03-02 16:34:00 72
8 3 2004-03-02 16:39:00 67
9 3 2004-03-02 16:44:00 83

dates = as.POSIXct(strptime(paste(x[,2], x[,3], sep=" "),
format="%Y-%m-%d %H:%M:%S"))


 > dates
[1] "2003-07-23 13:05:00 EDT" "2003-07-23 13:10:00 EDT" "2003-07-23
13:15:00 EDT"
[4] "2004-09-25 14:34:00 EDT" "2004-09-25 14:39:00 EDT" "2004-09-25
14:44:00 EDT"
[7] "2004-03-02 16:34:00 EST" "2004-03-02 16:39:00 EST" "2004-03-02
16:44:00 EST"

 > data = xts(x[,c(1,4)], order.by=dates)
 > data
Subject Value
2003-07-23 13:05:00 1 84
2003-07-23 13:10:00 1 87
2003-07-23 13:15:00 1 95
2004-03-02 16:34:00 3 72
2004-03-02 16:39:00 3 67
2004-03-02 16:44:00 3 83
2004-09-25 14:34:00 2 95
2004-09-25 14:39:00 2 81
2004-09-25 14:44:00 2 93


HTH

-cedrick

=
Cedrick Johnson
aolim) cedrickjcvgr
www.cedrickjohnson.com
New York - Chicago


On 3/11/2010 3:13 PM, Clay Heaton wrote:

Hi, I'm trying to learn R for a project I'm working on. I know several
programming languages, so I'm comfortable with the syntax. What I
can't figure out is how to import the file of time series data that I
have and parse it into individual series. The data was given to me in
Excel, but I can output it to tab-delimited or csv. I've been able to
pull in the entire table with read.table(), but I can't figure out how
to parse it into distinct groups.

It looks like this:

Subject Date Time Value
1 7/23/03 13:05:00 84
1 7/23/03 13:10:00 87
1 7/23/03 13:15:00 95

1 9/25/04 14:34:00 95
1 9/25/04 14:39:00 81
1 9/25/04 14:44:00 93
...
2 3/02/04 16:34:00 72
2 3/02/04 16:39:00 67
2 3/02/04 16:44:00 83
...
2 3/21/05 11:15:00 121
2 3/21/05 11:20:00 125
2 3/21/05 11:25:00 120
...

There are ~ 100,000 rows of data. There are 86 subjects and each of
them have multiple traces. For each trace, the times are in uniform
increments of 5 minutes. Some subjects have multiple traces, some have
a single trace. Some traces include up to 500 values and others only 40.

For now, what I'm looking to do is to be able to generate summary
statistics for each trace, and then for each subject. Hence, I need a
way to aggregate by value or subject, where the criteria for
aggregating traces are that the values were collected on the same day
and all are within 5 minutes of each other. I would like to be able to
iterate through the data to plot each trace independently.

Any suggestions to help me get started would be appreciated. I'm
looking to learn, so I'd appreciate pointers to good tutorials or code
examples of dealing with time series data.

Thanks!
Clay
__
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
P

Re: [R] Importing Time Series Data for an R Beginner

2010-03-11 Thread Cedrick W. Johnson (CJ)

Hi Clay-

You may want to look at both the XTS package, in addition to 'strptime' 
and 'as.POSIXct'


When I get datasets in Excel, what I normally do is change the date 
(column) format to -mm-dd.. But that's due to my own shortcomings 
with date formatting in R.


Here's a quick example:

> x = read.csv('TestData.csv')
> x
  Subject   Date Time Value
1   1 2003-07-23 13:05:0084
2   1 2003-07-23 13:10:0087
3   1 2003-07-23 13:15:0095
4   2 2004-09-25 14:34:0095
5   2 2004-09-25 14:39:0081
6   2 2004-09-25 14:44:0093
7   3 2004-03-02 16:34:0072
8   3 2004-03-02 16:39:0067
9   3 2004-03-02 16:44:0083

dates = as.POSIXct(strptime(paste(x[,2], x[,3], sep=" "), 
format="%Y-%m-%d %H:%M:%S"))



> dates
[1] "2003-07-23 13:05:00 EDT" "2003-07-23 13:10:00 EDT" "2003-07-23 
13:15:00 EDT"
[4] "2004-09-25 14:34:00 EDT" "2004-09-25 14:39:00 EDT" "2004-09-25 
14:44:00 EDT"
[7] "2004-03-02 16:34:00 EST" "2004-03-02 16:39:00 EST" "2004-03-02 
16:44:00 EST"


> data = xts(x[,c(1,4)], order.by=dates)
> data
Subject Value
2003-07-23 13:05:00   184
2003-07-23 13:10:00   187
2003-07-23 13:15:00   195
2004-03-02 16:34:00   372
2004-03-02 16:39:00   367
2004-03-02 16:44:00   383
2004-09-25 14:34:00   295
2004-09-25 14:39:00   281
2004-09-25 14:44:00   293


HTH

-cedrick

=
Cedrick Johnson
aolim) cedrickjcvgr
www.cedrickjohnson.com
New York - Chicago


On 3/11/2010 3:13 PM, Clay Heaton wrote:

Hi, I'm trying to learn R for a project I'm working on. I know several 
programming languages, so I'm comfortable with the syntax. What I can't figure 
out is how to import the file of time series data that I have and parse it into 
individual series.  The data was given to me in Excel, but I can output it to 
tab-delimited or csv. I've been able to pull in the entire table with 
read.table(), but I can't figure out how to parse it into distinct groups.

It looks like this:

Subject DateTime   Value
1 7/23/03  13:05:00   84
1 7/23/03  13:10:00   87
1 7/23/03  13:15:00   95

1 9/25/04  14:34:00   95
1 9/25/04  14:39:00   81
1 9/25/04  14:44:00   93
...
2 3/02/04  16:34:00   72
2 3/02/04  16:39:00   67
2 3/02/04  16:44:00   83
...
2 3/21/05  11:15:00   121
2 3/21/05  11:20:00   125
2 3/21/05  11:25:00   120
...

There are ~ 100,000 rows of data. There are 86 subjects and each of them have 
multiple traces. For each trace, the times are in uniform increments of 5 
minutes. Some subjects have multiple traces, some have a single trace. Some 
traces include up to 500 values and others only 40.

For now, what I'm looking to do is to be able to generate summary statistics 
for each trace, and then for each subject. Hence, I need a way to aggregate by 
value or subject, where the criteria for aggregating traces are that the values 
were collected on the same day and all are within 5 minutes of each other. I 
would like to be able to iterate through the data to plot each trace 
independently.

Any suggestions to help me get started would be appreciated. I'm looking to 
learn, so I'd appreciate pointers to good tutorials or code examples of dealing 
with time series data.

Thanks!
Clay
__
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.


Re: [R] Searching for option explanations

2010-03-11 Thread Charles C. Berry

On Thu, 11 Mar 2010, Turchin, Michael wrote:


Hey all,

Sorry if this is redundant, but I can't figure out a good search query 
for either the mailing list, or google, to find an answer to this.


Let's say I have a couple of R options I'm interested in learning more 
about, but their details aren't explained in the command's help file. 
For example, for R CMD BATCH --help, it discusses the use of --restore, 
--save and --no-readline. But there are no in depth details about those 
options themselves.


If I wanted to learn more about what --no-readline is, or --restore or 
--save, is there some basic R resource I can use to find this? I tried 
exploring options(), but I don't necessarily see what I'm looking for 
there. And google searching "R '--restore'" is not providing much of 
value in return. Am I missing something obvious on how to do this?


What you are asking about is startup options, right?

See Intro to R Appendix B Invoking R

HTH,

Chuck



Any thoughts would be greatly appreciated. Thanks for your help!
~Michael
Children's Hospital Boston
The Broad Institute
__
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.



Charles C. Berry(858) 534-2098
Dept of Family/Preventive Medicine
E mailto:cbe...@tajo.ucsd.edu   UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901

__
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] logistic model diagnostics residuals.lrm {design}, residuals()

2010-03-11 Thread Chaudhari, Bimal
I am working on applying Sequential Multiple Decision Procedure to
genetic association studies of complex disease.  Province in 2000
(http://www.ncbi.nlm.nih.gov/pubmed/11108641) developed the method for
QTL linkage and Province and Zhang extended it to association with
quantitative traits in 2005.  My interest is in binary outcomes.

The original formulation of the SMDP (Bechhofer, Kiefer and Sobel, 1968)
was predicated on comparing parameters from Koopman-Darmois
distributions.  In that text, they present solutions for normal,
exponential, Bernoulli, poisson and negative binomial distributions.
Province and Zhang exploited the fact that residuals from linear
regression are normally distributed to apply SMDP to the analysis of
these residuals (specifically, they use the case of comparing the
variances of several random variables drawn from normal distributions
with the same known mean, 0, and unknown, unequal variances to identify
the set of random variables/residuals with the smallest variance).

My hope initially had been that I might be able to essentially replicate
this approach with an analogous measure/residual, but this has proven to
be more difficult than anticipated.


-bimal

> -Original Message-
> From: Frank E Harrell Jr [mailto:f.harr...@vanderbilt.edu]
> Sent: Thursday, March 11, 2010 12:25 PM
> To: Chaudhari, Bimal
> Cc: r-help@r-project.org
> Subject: Re: [R] logistic model diagnostics residuals.lrm {design},
> residuals()
> 
> Chaudhari, Bimal wrote:
> > I am interested in a model diagnostic for logistic regression which
> is normally distributed (much like the residuals in linear regression
> with are ~ N(0,variance unknown).
> >
> > My understanding is that most (all?) of the residuals returned by
> residuals.lrm {design} either don't have a well defined distribution
or
> are distributed as Chi-Square.
> >
> > Have I overlooked a residual measure or would it be possible to
> transform one of the residual measures into something reasonably
> 'normal' while retaining information from the residual so I could
> compare between models (obviously I could blom transform any of the
> measures, but then I'd always get a standard normal)?
> >
> > Cheers,
> > bimal
> 
> Hi Bimal,
> 
> What would make it necessary for the residuals to have a certain
> distribution?  Why would you expect a categorical Y variable to give
> risk to residuals with a nice distributions?
> 
> You can do residual diagnostics without worrying about the
> distribution.
> 
> Frank
> 
> >
> > Bimal P Chaudhari, MPH
> > MD Candidate, 2011
> > Boston University
> > MS Candidate, 2010
> > Washington University in St Louis
> >
> >
> > [[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.
> >
> 
> 
> --
> Frank E Harrell Jr   Professor and ChairmanSchool of Medicine
>   Department of Biostatistics   Vanderbilt
> University

__
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] Searching for option explanations

2010-03-11 Thread Turchin, Michael
Hey all,

Sorry if this is redundant, but I can't figure out a good search query for 
either the mailing list, or google, to find an answer to this.

Let's say I have a couple of R options I'm interested in learning more about, 
but their details aren't explained in the command's help file. For example, for 
R CMD BATCH --help, it discusses the use of --restore, --save and 
--no-readline. But there are no in depth details about those options 
themselves. 

If I wanted to learn more about what --no-readline is, or --restore or --save, 
is there some basic R resource I can use to find this? I tried exploring 
options(), but I don't necessarily see what I'm looking for there. And google 
searching "R '--restore'" is not providing much of  value in return. Am I 
missing something obvious on how to do this?

Any thoughts would be greatly appreciated. Thanks for your help!
~Michael
Children's Hospital Boston
The Broad Institute
__
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] Importing Time Series Data for an R Beginner

2010-03-11 Thread Clay Heaton
Hi, I'm trying to learn R for a project I'm working on. I know several 
programming languages, so I'm comfortable with the syntax. What I can't figure 
out is how to import the file of time series data that I have and parse it into 
individual series.  The data was given to me in Excel, but I can output it to 
tab-delimited or csv. I've been able to pull in the entire table with 
read.table(), but I can't figure out how to parse it into distinct groups.

It looks like this:

Subject DateTime   Value
1 7/23/03  13:05:00   84
1 7/23/03  13:10:00   87
1 7/23/03  13:15:00   95

1 9/25/04  14:34:00   95
1 9/25/04  14:39:00   81
1 9/25/04  14:44:00   93
...
2 3/02/04  16:34:00   72
2 3/02/04  16:39:00   67
2 3/02/04  16:44:00   83
...
2 3/21/05  11:15:00   121
2 3/21/05  11:20:00   125
2 3/21/05  11:25:00   120
...

There are ~ 100,000 rows of data. There are 86 subjects and each of them have 
multiple traces. For each trace, the times are in uniform increments of 5 
minutes. Some subjects have multiple traces, some have a single trace. Some 
traces include up to 500 values and others only 40.

For now, what I'm looking to do is to be able to generate summary statistics 
for each trace, and then for each subject. Hence, I need a way to aggregate by 
value or subject, where the criteria for aggregating traces are that the values 
were collected on the same day and all are within 5 minutes of each other. I 
would like to be able to iterate through the data to plot each trace 
independently.

Any suggestions to help me get started would be appreciated. I'm looking to 
learn, so I'd appreciate pointers to good tutorials or code examples of dealing 
with time series data.

Thanks!
Clay
__
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] Group by

2010-03-11 Thread ManInMoon

My point is this:

if we do

temp<-tDates

aggregate(DF[,c('V2', 'V3')], 
  list(format(temp, "%H:%M:00")), 
  FUN = sum) 

Does agrregate still know it's refering to DF$V1 - and if so- how?

-- 
View this message in context: 
http://n4.nabble.com/Group-by-tp1588694p1589600.html
Sent from the R help mailing list archive at Nabble.com.

__
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] cut.POSIXt misconception/feature/bug?

2010-03-11 Thread Brian Diggs
On 3/10/2010 11:26 PM, Petr PIKAL wrote:
> Hi
> 
> Thanks for clarification. Actually I knew that with first case I get some 
> data with NAs at the beginning and at the end. Maybe my English is not 
> good enough to understand that to get vector of dates split to several 
> chunks I need to put also end date and last date to get the whole vector.
> 
> This is what help page for cut.POSIXt says about breaks and although I 
> read it carefully I did not find any mention that at least 2 values are 
> necessary. I did not connected it with information from cut help page, 
> sorry
> 
> breaks: a vector of cut points _or_ number giving the number of
> ^^
> which can be vector of length one. However thinking about it more 
> thoroughly vector of length one is probably the same as one number with 
> respect of its interpretation. 

Since everything is a vector, even a single number is technically a vector of 
length 1.  But that is a somewhat subtle point.  I think the description from 
cut is better: "either a numeric vector of two or more cut points or a single 
number (greater than or equal to 2) giving the number of intervals into which x 
is to be cut"

> Therefore I also missed the clue that I need not only
> 
> Details:
> 
>  Using both ‘right = TRUE’ and ‘include.lowest = TRUE’ will
>  include both ends of the range of dates.
> 
> but also
> 
>  br<-dat[c(1, 23, 42,60)]
> 
> To get the whole vector of cut dates without NAs in both ends.
> 
> Maybe
> 
> breaks: a vector of 2 or more cut points _or_ number giving the number 
> of...
> 
> Using both ‘right = TRUE’ and ‘include.lowest = TRUE’ together with 
> starting and ending date will include both ends of the range of dates.
> 
> could make help page more digestable.

I think that the comment in details has more to do with how to include the 
endpoints of breaks in the included ranges rather than the extremes of the 
dates (x).  I think a better clarification would be to say "Using both ‘right = 
TRUE’ and ‘include.lowest = TRUE’ will include both ends of the range of 
breaks".  That makes it clear that the dates that are referred to there are the 
breaks, not x.

> Thank you.
> 
> Petr

I've included a patch against cut.POSIXt.Rd with these proposed changes.


--
Brian Diggs, Ph.D.
Senior Research Associate, Department of Surgery, Oregon Health & Science 
University




__
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] how does R compute Std. Error's?

2010-03-11 Thread Rnewb

ah yes, my mistake was dividing by sigma instead of multiplying... thank you
very much

sincerely,
Rnewb
-- 
View this message in context: 
http://n4.nabble.com/how-does-R-compute-Std-Error-s-tp1588537p1589657.html
Sent from the R help mailing list archive at Nabble.com.

__
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] Ubunut + Eclipse + StatET: Console terminates upon error

2010-03-11 Thread Ted Harding
On 11-Mar-10 19:19:26, Janko Thyson wrote:
> [...]
> First of, I'm still confused about Ubuntu's "sudo" way of doing things.
> Not knowing how to authorize me as "root" when installing packages from
> a R-script, I can't write on "/usr/local/lib/R/site-library" or
> "/usr/lib/R/site-library".

On this particular point: If, logged in as a user (whatever user
you are), you enter the command into a terminal window:

  su -

and then enter the root password when prompted, you will be logged
in as root -- fair and square, and no nonsense. You will also be
placed in root's home directory as well (not that of the user you
previously were).

Thereafter, you can do whatever you are used to doing as root.

However, becoming root in the above way limits you to root access
solely from the terminal window that you used for "su -" (though
you could do the same in more than one terminal). All other windows,
and the desktop itself, remain under the influence of the original
user.

The only way to take over an entire session as root would be to
shut down the session (choosing "Restart"), and then log in as
root at the initial login window for the new session. Then you
would have to shut that down too when you wanted to resume normal
life!

Ted.


E-Mail: (Ted Harding) 
Fax-to-email: +44 (0)870 094 0861
Date: 11-Mar-10   Time: 19:42:46
-- XFMail --

__
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] How to take out the content of character string

2010-03-11 Thread Thomas Lumley

On Wed, 10 Mar 2010, Henrique Dallazuanna wrote:


On Wed, Mar 10, 2010 at 7:50 PM, Thomas Lumley  wrote:

On Wed, 10 Mar 2010, baptiste auguie wrote:


Hi,

it's generally considered a bad practice but try this,

eval(parse(text=AA))

library(fortunes)
fortune(106)

HTH,

baptiste

On 10 March 2010 07:46, jq81  wrote:


My question is represented by the following example.

For example, I have a character string a, which is defined as

AA="list(x=1, y=2)"

I want to take out the content of AA by using some function, so that I
can
obtain the following expression automatically.

list(x=1, y=2)



This is the situation where it isn't considered bad practice.  If someone
hands you a string with code in it, the only way to parse it is with
parse().


I think that Is there another way:

source(textConnection(AA))$value
closeAllConnections()



And if you look at the code for source(), you will see that it uses parse() and 
eval().

-thomas

Thomas Lumley   Assoc. Professor, Biostatistics
tlum...@u.washington.eduUniversity of Washington, Seattle
__
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] Ubunut + Eclipse + StatET: Console terminates upon error

2010-03-11 Thread Tobias Verbeke

Hi Janko,

I'm not an rJava install expert (on all but my own system
I often end up setting the appropriate environment variables
related to Java manually before launching the R CMD
INSTALL for the package), but with respect to the choice
Rterm vs. RJ Console, I would strongly advise to use the
RJ Console. It allows for a much richer IDE experience,
particularly through the Object Browser and Content Assist
(Content Assist corresponds in non-Eclipse lingo to command
completion and hover pop-ups in the editors and R Console).

Best,
Tobias

Janko Thyson wrote:

Thanks for the quick reply. I was following your hint with "rJava", but I'm 
still a little lost.

I maybe should have added that the console terminating happens when launching it as "Rterm", it 
works fine when running it as "RJ". However, I would like to use "Rterm". Here is what I 
did so far:

First of, I'm still confused about Ubuntu's "sudo" way of doing things. Not knowing how to authorize me as "root" when installing packages from a R-script, I can't write on "/usr/local/lib/R/site-library" or "/usr/lib/R/site-library". So I turned to Synaptics, found and installed the CRAN package "rJava" that enables me to run the R console with Launch Type "RJ" within Eclipse. "rJava" went into "/usr/lib". 

Then, launching R as "RJ" and trying to execute an "install.packages()", Ubuntu prompted me for the specification of a valid library directory and offered to create "/home//i486-pc-linux-gnu-library/2.10". 


So ".libPaths()" would give me:
R> .libPaths()
[1] "/home//i486-pc-linux-gnu-library/2.10" "/usr/lib/R/site-library"   
[3] "/usr/lib/R/library"   
R>


I then tried to "re-install" the package "rJava" by "install.packages()" which 
got me the following output:

+

install.packages("rJava", repos=repos.cran, 
lib="/home//R/i486-pc-linux-gnu-library/2.10")
trying URL 'http://cran.at.r-project.org/src/contrib/rJava_0.8-2.tar.gz'
Content type 'application/x-gzip' length 471971 bytes (460 Kb)
opened URL
==
downloaded 460 Kb

* installing *source* package ‘rJava’ ...
checking for gcc... gcc -std=gnu99
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables... 
checking for suffix of object files... o

checking whether we are using the GNU C compiler... yes
checking whether gcc -std=gnu99 accepts -g... yes
checking for gcc -std=gnu99 option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -std=gnu99 -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/wait.h that is POSIX.1 compatible... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for string.h... (cached) yes
checking sys/time.h usability... yes
checking sys/time.h presence... yes
checking for sys/time.h... yes
checking for unistd.h... (cached) yes
checking for an ANSI C-conforming const... yes
checking whether time.h and sys/time.h may both be included... yes
configure: checking whether gcc -std=gnu99 supports static inline...
yes
checking whether setjmp.h is POSIX.1 compatible... yes
checking whether sigsetjmp is declared... yes
checking whether siglongjmp is declared... yes
checking Java support in R... present:
interpreter : '/usr/bin/java'
archiver: '/usr/bin/jar'
compiler: '/usr/bin/javac'
header prep.: '/usr/bin/javah'
cpp flags   : ''
java libs   : '-L/usr/lib/jvm/java-6-openjdk/jre/lib/i386/server 
-L/usr/lib/jvm/java-6-openjdk/jre/lib/i386 
-L/usr/lib/jvm/java-6-openjdk/jre/../lib/i386 -L -L/usr/java/packages/lib/i386 
-L/usr/lib/jni -L/lib -L/usr/lib -ljvm'
configure: error: One or more Java configuration variables are not set.
Make sure R is configured with full Java support (including JDK). Run
R CMD javareconf
as root to add Java support to R.

If you don't have root privileges, run
R CMD javareconf -e
to set all Java-related variables and then install rJava.

ERROR: configuration failed for package ‘rJava’
* removing ‘/home//R/i486-pc-linux-gnu-library/2.10/rJava’

The downloaded packages are in
‘/tmp/RtmpbGKuzS/downloaded_packages’
Warning message:
In install.packages("rJava", repos = repos.cran, lib = 
"/home//R/i486-pc-linux-gnu-library/2.10") :
  installation of package 'rJava' had non-zero exit status

+

So I ran "sudo R CMD javareconf", but still get the same error.

Any hints from here on?

Thanks a lot!

Janko

-Ursprüngliche Nachricht-
Von: Dirk Eddelbuettel [mailto:e...@debian.org] 
Gesendet: Donnerstag, 11. März 2010 19:40

An: Janko Thyson
Cc: r-help@r-project.or

Re: [R] Ubunut + Eclipse + StatET: Console terminates upon error

2010-03-11 Thread Tobias Verbeke

Hi Dirk, Janko,

Dirk Eddelbuettel wrote:


On 11 March 2010 at 19:19, Janko Thyson wrote:
| I'm trying to set up Eclispe (3.5.1) with the StatET-Plugin (0.8.1) under
| Ubuntu (Karmic) and found it strange that my console terminates every time
| something in a script produces an arbitrary error (e.g. just calling a
| missing variable, trying to perform an illegal operation etc.). Can anyone
| tell me why this happens or even better how to fix this?


I never experienced such behaviour and use Eclipse/StatET daily on
Ubuntu Karmic. I did experience weird UI behaviour once (related to
a GTK bug) and currently use this

#!/bin/bash
export GDK_NATIVE_WINDOWS=1
/opt/eclipse/eclipse -debug -consolelog -vmargs -Xms1024m -Xmx2048m 
-XX:MaxPermSize=2048m


to launch eclipse (never mind the insane vmargs ;-)

While we're at it: if you have the choice, you can upgrade to Eclipse 
3.5.2 (i.e. Galileo SR2) and to StatET 0.8.2 (which is available via the 
update site at


http://download.walware.de/eclipse-3.5

)


It so happens that I help a colleague recently to triage this.  The problem
there was that a recent rJava was needed + and installed -- and on Ubuntu and
Debian this goes into 


   /usr/local/lib/R/site-library/

and StatET -- as shipped -- does not look there.  I don't use Eclipse so I
don't recall where to set this, but in essence you need to make sure that
StatET looks where R puts things. And that tends to be


The libraries can be set (and auto-detected) when defining an R 
environment in the Preferences under StatET > Run/Debug > R

Environments.

The R environment for a particular R Console Run Configuration
is in turn set in the R Config tab (of the named Run Configuration).


R> .libPaths()
[1] "/usr/local/lib/R/site-library" "/usr/lib/R/site-library"   
[3] "/usr/lib/R/library"   
R> 


CCing Tobias just in case.


Don't hesitate if there would be further questions. There
also is a dedicated StatET user list at

https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/statet-user

HTH,
Tobias

__
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] Ubunut + Eclipse + StatET: Console terminates upon error

2010-03-11 Thread Janko Thyson
Thanks for the quick reply. I was following your hint with "rJava", but I'm 
still a little lost.

I maybe should have added that the console terminating happens when launching 
it as "Rterm", it works fine when running it as "RJ". However, I would like to 
use "Rterm". Here is what I did so far:

First of, I'm still confused about Ubuntu's "sudo" way of doing things. Not 
knowing how to authorize me as "root" when installing packages from a R-script, 
I can't write on "/usr/local/lib/R/site-library" or "/usr/lib/R/site-library". 
So I turned to Synaptics, found and installed the CRAN package "rJava" that 
enables me to run the R console with Launch Type "RJ" within Eclipse. "rJava" 
went into "/usr/lib". 

Then, launching R as "RJ" and trying to execute an "install.packages()", Ubuntu 
prompted me for the specification of a valid library directory and offered to 
create "/home//i486-pc-linux-gnu-library/2.10". 

So ".libPaths()" would give me:
R> .libPaths()
[1] "/home//i486-pc-linux-gnu-library/2.10" "/usr/lib/R/site-library"   

[3] "/usr/lib/R/library"   
R>

I then tried to "re-install" the package "rJava" by "install.packages()" which 
got me the following output:

+

install.packages("rJava", repos=repos.cran, 
lib="/home//R/i486-pc-linux-gnu-library/2.10")
trying URL 'http://cran.at.r-project.org/src/contrib/rJava_0.8-2.tar.gz'
Content type 'application/x-gzip' length 471971 bytes (460 Kb)
opened URL
==
downloaded 460 Kb

* installing *source* package ‘rJava’ ...
checking for gcc... gcc -std=gnu99
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables... 
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc -std=gnu99 accepts -g... yes
checking for gcc -std=gnu99 option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -std=gnu99 -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/wait.h that is POSIX.1 compatible... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for string.h... (cached) yes
checking sys/time.h usability... yes
checking sys/time.h presence... yes
checking for sys/time.h... yes
checking for unistd.h... (cached) yes
checking for an ANSI C-conforming const... yes
checking whether time.h and sys/time.h may both be included... yes
configure: checking whether gcc -std=gnu99 supports static inline...
yes
checking whether setjmp.h is POSIX.1 compatible... yes
checking whether sigsetjmp is declared... yes
checking whether siglongjmp is declared... yes
checking Java support in R... present:
interpreter : '/usr/bin/java'
archiver: '/usr/bin/jar'
compiler: '/usr/bin/javac'
header prep.: '/usr/bin/javah'
cpp flags   : ''
java libs   : '-L/usr/lib/jvm/java-6-openjdk/jre/lib/i386/server 
-L/usr/lib/jvm/java-6-openjdk/jre/lib/i386 
-L/usr/lib/jvm/java-6-openjdk/jre/../lib/i386 -L -L/usr/java/packages/lib/i386 
-L/usr/lib/jni -L/lib -L/usr/lib -ljvm'
configure: error: One or more Java configuration variables are not set.
Make sure R is configured with full Java support (including JDK). Run
R CMD javareconf
as root to add Java support to R.

If you don't have root privileges, run
R CMD javareconf -e
to set all Java-related variables and then install rJava.

ERROR: configuration failed for package ‘rJava’
* removing ‘/home//R/i486-pc-linux-gnu-library/2.10/rJava’

The downloaded packages are in
‘/tmp/RtmpbGKuzS/downloaded_packages’
Warning message:
In install.packages("rJava", repos = repos.cran, lib = 
"/home//R/i486-pc-linux-gnu-library/2.10") :
  installation of package 'rJava' had non-zero exit status

+

So I ran "sudo R CMD javareconf", but still get the same error.

Any hints from here on?

Thanks a lot!

Janko

-Ursprüngliche Nachricht-
Von: Dirk Eddelbuettel [mailto:e...@debian.org] 
Gesendet: Donnerstag, 11. März 2010 19:40
An: Janko Thyson
Cc: r-help@r-project.org; tobias.verb...@openanalytics.eu
Betreff: Re: [R] Ubunut + Eclipse + StatET: Console terminates upon error


On 11 March 2010 at 19:19, Janko Thyson wrote:
| I'm trying to set up Eclispe (3.5.1) with the StatET-Plugin (0.8.1) under
| Ubuntu (Karmic) and found it strange that my console terminates every time
| something in a script produces an arbitrary error (e.g. just calling a
| missing variable, trying to perform an illegal operation etc.). Can anyone
| tell me why this happens or even better how to fix this?

It so happens that I help a colleague recen

Re: [R] Calculate mean slope of a function

2010-03-11 Thread Rolf Turner

On 12/03/2010, at 4:27 AM, Antje Steller wrote:

> Hallo,
> hope you can help me with this question:
> 
> I have calculated a function using f<-smooth.spline(data) and
> approxfun(f). Now I want to calculate the mean slope of the resulting
> function.
> 
> Haven't found the right R command yet, maybe you can give me a hint.


(1) You haven't found the right anything.  It's time you learned some
mathematics if you are going to deal with mathematical concepts
like ``slope''.  And ``mean''.

(2) Is this a homework question?

(3) Define clearly what you mean by ``mean slope''.  Write down a mathematical
expression for this.  The answer is then obvious.

No R function required.

cheers,

Rolf Turner
##
Attention: 
This e-mail message is privileged and confidential. If you are not the 
intended recipient please delete the message and notify the sender. 
Any views or opinions presented are solely those of the author.

This e-mail has been scanned and cleared by MailMarshal 
www.marshalsoftware.com
##

__
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] ggplot2: "varwidth"-equivalent for geom_boxplot?

2010-03-11 Thread hadley wickham
No this currently isn't possible - it would require changes to
stat_boxplot to work.

Hadley

On Wed, Mar 10, 2010 at 9:12 AM, Johannes Graumann
 wrote:
> Apologies.
>
> from the "boxplot" documentation:
> "... if varwidth is TRUE, the boxes are drawn with widths proportional to the
> square-roots of the number of observations in the groups."
>
> I find this option often very useful.
>
> Thanks for any insight into how to achieve this with geom_boxplot.
>
> Joh
>
> On Wednesday 10 March 2010 16:12:49 hadley wickham wrote:
>> What is varwidth?
>>
>> Hadley
>>
>> On Wed, Mar 10, 2010 at 1:55 PM, Johannes Graumann
>>
>>  wrote:
>> > Hi,
>> >
>> > Is there such a thing? If no: is it easily simulated?
>> >
>> > thanks, Joh
>> >
>> > __
>> > 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.
>>
>



-- 
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/

__
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] about IRT simulation

2010-03-11 Thread JLucke
Helen

Your program makes no sense. 

Try the following script

I <- 10
J <- 5
response <- matrix(0, 10, 5)

#function for probability of response
#revised but equivalent version of Helen's formula

pij <- function(a,b,theta) {1/(1+exp(-a*(theta-b)))} 

a <- rnorm(J, 0.8, 0.04)
a
b <- rnorm(J, 0, 1)
b
theta <- rnorm(I, 0,1)
theta

for( i in 1:I ) {
 for( j in 1:J ) {
  response[i,j]<-ifelse(pij(a=a[j], b=b[j], theta[i]) < runif(1) , 0 ,1)
 }
}

response





Helena  
Sent by: r-help-boun...@r-project.org
03/10/2010 11:03 PM

To
r-h...@stat.math.ethz.ch
cc

Subject
[R] about IRT simulation






hello R:
we have a two-parameter IRT simulation code. The goal is to generate a 
response matrix.But the "for" part doesn't run. we don't know what is 
wrong 
with it.

Thanks so much~~~

I <- 10
J <- 5
response <- matrix(0, 10, 5)
pij <- function(a,b,theta)
{
a <- rnorm(J, 0.8, 0.04)
a
b <- rnorm(J, 0, 1)
b
theta <- rnorm(I, 0,1)
theta
for( i in 1:I ) {
 for( j in 1:J ) {
ptemp <- runif(1)
 pij <- 
exp(a[j]*(theta[i]-b[j]))/(1+exp(a[j]*(theta[i]-b[j])))
 response[i,j]<-ifelse(pij(b=b[j], a=a[j], theta[i]) < 
ptemp , 0 ,1)

}
}
}
response 



helena

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[[alternative HTML version deleted]]

__
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] Multiple comparisons with a mixed effects model

2010-03-11 Thread Sean Henderson
Hello,

I have used R in the past to conduct multiple comparisons on standard linear 
models, but am a bit confused as to how to go about doing it with a mixed 
effects model.

I am conducting a bioindication study using carabid beetles in which I have 
four treatment types (forest harvest types with varying levels of canopy 
structure retention), and am using canopy closure percent as a covariate in my 
ANCOVA model. The response variable is species diversity (richness).

I am wanting to use a mixed effects model because there are only two replicates 
of each treatment type, and within each of those blocks there were 3 sites 
established - far enough apart that they should be independent based on 
literature but there is still potentially site-to-site variation that I'd like 
to account for.

My question is, how would I go about doing a protected t-test on the treatments 
to see if there are significant differences between them? Is it even possible 
to do this? I have tried doing it the same way I've done with linear models in 
the past, but instead of a t-value I get a z-value? 

Below is the code for what I have done.

Thank you very much for any help!

Sean


>
fm1 <- lme(Diversity ~ Canopy + Treatment, data=data, random = ~ 1 | Site)
>
anova(fm1)
numDF denDF   F-value p-value
(Intercept) 118 310.32845  <.0001
Canopy  118  28.38084  <.0001
Treatment   318   4.46571  0.0164
>
summary(fm1)
Linear
mixed-effects model fit by REML
 Data: data 
   AIC BIClogLik
  86.00919 92.2418 -36.00459
 
Random
effects:
 Formula: ~1 | Site
(Intercept) Residual
StdDev:1.086125 0.407297
 
Fixed
effects: Diversity ~ Canopy + Treatment 
Value Std.Error DFt-value p-value
(Intercept) 2.9941329 1.3470256 18  2.2227735  0.0393
Canopy  0.0312745 0.0157384 18  1.9871455  0.0623
TreatmentGap0.4884026 0.6742472 18  0.7243672  0.4782
TreatmentOpen  -1.9764646 0.9016932 18 -2.1919479  0.0418
TreatmentSemi-open
-1.8719043 0.7405578 18 -2.5276952  0.0211
 Correlation: 
   (Intr) Canopy TrtmnG TrtmnO
Canopy -0.936 
TreatmentGap   -0.355  0.116  
TreatmentOpen  -0.772  0.627  0.441   
TreatmentSemi-open
-0.624  0.427  0.499  0.603
 
Standardized
Within-Group Residuals:
   Min Q1Med Q3Max 
-0.5770339
-0.1937237 -0.1051985  0.1503428  0.9151522 
 
Number
of Observations: 23
Number
of Groups: 23 
>
comparisons <- glht(fm1, linfct=mcp(Treatment="Tukey"))
>
summary(comparisons, test=adjusted("none"))
 
 Simultaneous Tests for General Linear
Hypotheses
 
Multiple
Comparisons of Means: Tukey Contrasts
 
 
Fit:
lme.formula(fixed = Diversity ~ Canopy + Treatment, data = data, 
random = ~1 | Site)
 
Linear
Hypotheses:
Estimate Std. Error z
value Pr(>|z|)
Gap
- Closed == 0 0.4884 0.6742   0.724 0.468840
Open
- Closed == 0   -1.9765 0.9017  -2.192 0.028383 *  
Semi-open
- Closed == 0  -1.8719 0.7406  -2.528 0.011481 *  
Open
- Gap == 0  -2.4649 0.8549  -2.883 0.003937 ** 
Semi-open
- Gap == 0 -2.3603 0.7108  -3.321 0.000898 ***
Semi-open
- Open == 0 0.1046 0.7453   0.140 0.888435
---
Signif.
codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05
‘.’ 0.1 ‘ ’ 1 
(Adjusted
p values reported -- none method)



  __
Make your browsing faster, safer, and easier with the new Internet Explorer® 8. 
Optimized for Yahoo! Get it Now for Free! at 
http://downloads.yahoo.com/ca/internetexplorer/

__
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] Robust estimation of variance components for a nested design

2010-03-11 Thread Liaw, Andy
I believe Pinhiero et al published a paper in JCGS a few years back on
the subject, modeling the random effects with t distributions.  No
software were publicly available, as far as I know.

Andy 

From: S Ellison
> Sent: Thursday, March 11, 2010 9:56 AM
> To: r-help@r-project.org
> Subject: [R] Robust estimation of variance components for a 
> nested design
> 
> One of my colleagues has a data set from a two-level nested 
> design from
> which we would like to estimate variance components. But we'd 
> like some
> idea of what the inevitable outliers are doing, so we were looking for
> something in R that uses robust (eg Huber) treatment and 
> returns robust
> estimates of variance.
> 
> Nothing in my collection of R robust estimation packages (robust,
> robustbase and MASS being the obvious three) or on the Robust 
> task view
> seems to cover this, though it's entirely possible I've missed
> something. 
> 
> Any pointers (to R packages or literature) gratefully accepted.
> 
> S Ellison
> Lab of the Government Chemist, UK
> 
> 
> 
> 
> ***
> This email and any attachments are confidential. Any=2...{{dropped:20}}

__
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] Ubunut + Eclipse + StatET: Console terminates upon error

2010-03-11 Thread Dirk Eddelbuettel

On 11 March 2010 at 19:19, Janko Thyson wrote:
| I'm trying to set up Eclispe (3.5.1) with the StatET-Plugin (0.8.1) under
| Ubuntu (Karmic) and found it strange that my console terminates every time
| something in a script produces an arbitrary error (e.g. just calling a
| missing variable, trying to perform an illegal operation etc.). Can anyone
| tell me why this happens or even better how to fix this?

It so happens that I help a colleague recently to triage this.  The problem
there was that a recent rJava was needed + and installed -- and on Ubuntu and
Debian this goes into 

   /usr/local/lib/R/site-library/

and StatET -- as shipped -- does not look there.  I don't use Eclipse so I
don't recall where to set this, but in essence you need to make sure that
StatET looks where R puts things. And that tends to be

R> .libPaths()
[1] "/usr/local/lib/R/site-library" "/usr/lib/R/site-library"   
[3] "/usr/lib/R/library"   
R> 

CCing Tobias just in case.

Dirk

-- 
  Registration is open for the 2nd International conference R / Finance 2010
  See http://www.RinFinance.com for details, and see you in Chicago in April!

__
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] logistic model diagnostics residuals.lrm {design}, residuals()

2010-03-11 Thread Frank E Harrell Jr

Chaudhari, Bimal wrote:

I am interested in a model diagnostic for logistic regression which is normally 
distributed (much like the residuals in linear regression with are ~ 
N(0,variance unknown).

My understanding is that most (all?) of the residuals returned by residuals.lrm 
{design} either don't have a well defined distribution or are distributed as 
Chi-Square.

Have I overlooked a residual measure or would it be possible to transform one 
of the residual measures into something reasonably 'normal' while retaining 
information from the residual so I could compare between models (obviously I 
could blom transform any of the measures, but then I'd always get a standard 
normal)?

Cheers,
bimal


Hi Bimal,

What would make it necessary for the residuals to have a certain 
distribution?  Why would you expect a categorical Y variable to give 
risk to residuals with a nice distributions?


You can do residual diagnostics without worrying about the distribution.

Frank



Bimal P Chaudhari, MPH
MD Candidate, 2011
Boston University
MS Candidate, 2010
Washington University in St Louis


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




--
Frank E Harrell Jr   Professor and ChairmanSchool of Medicine
 Department of Biostatistics   Vanderbilt University

__
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] logistic model diagnostics residuals.lrm {design}, residuals()

2010-03-11 Thread Greg Snow
Why do you need a diagnostic that has properties from the normal?  Logistic 
regression is based on binary (binomial distribution) data, not continuous 
data.  Any transform that forced normality (even just under a given null 
hypothesis) would probably distort any real information that might be gleaned. 

What are you really trying to accomplish?  It is probably easier to address 
that then to do an artificial 'normalization'.

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
> project.org] On Behalf Of Chaudhari, Bimal
> Sent: Thursday, March 11, 2010 10:10 AM
> To: r-help@r-project.org
> Subject: [R] logistic model diagnostics residuals.lrm {design},
> residuals()
> 
> I am interested in a model diagnostic for logistic regression which is
> normally distributed (much like the residuals in linear regression with
> are ~ N(0,variance unknown).
> 
> My understanding is that most (all?) of the residuals returned by
> residuals.lrm {design} either don't have a well defined distribution or
> are distributed as Chi-Square.
> 
> Have I overlooked a residual measure or would it be possible to
> transform one of the residual measures into something reasonably
> 'normal' while retaining information from the residual so I could
> compare between models (obviously I could blom transform any of the
> measures, but then I'd always get a standard normal)?
> 
> Cheers,
> bimal
> 
> Bimal P Chaudhari, MPH
> MD Candidate, 2011
> Boston University
> MS Candidate, 2010
> Washington University in St Louis
> 
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Ubunut + Eclipse + StatET: Console terminates upon error

2010-03-11 Thread Janko Thyson
Dear List,

 

I'm trying to set up Eclispe (3.5.1) with the StatET-Plugin (0.8.1) under
Ubuntu (Karmic) and found it strange that my console terminates every time
something in a script produces an arbitrary error (e.g. just calling a
missing variable, trying to perform an illegal operation etc.). Can anyone
tell me why this happens or even better how to fix this?

 

Thanks a lot,

Janko


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Failed install of package xlsReadWrite

2010-03-11 Thread Hans-Peter Suter
> Hi, all. I too got this error, and when I went to register the correct DLL
> (thinking the one downloaded but not installed might have been the
> development version) I got an error that the registration had failed.
>
> What I typed:
>
> C:\Program Files\R\R-2.10.0\library\xlsReadWrite\libs>regsvr32
> xlsReadWrite.dll

Executing regsvr32 is absolutely _not_ necessary. It suffice to copy
the dll to the correct place (C:\Program
Files\R\R-2.10.0\library\xlsReadWrite\libs).

Unfortunately there is/was a bug in xlsReadWrite 1.5.1 such that with
a custom R_Libs path the existing dll was not replaced (iirc). This
and the relative-path bug has been fixed in the devel version.

If you download the full version, the package is supposed to work
right away. I currently still use XP (but don't know of any problems
related with Windows 7 or Vista).

Links (full, i.e. non-cran version, R2.10.x):
1.5.1: 
http://dl.dropbox.com/u/2602516/swissrpkg/bin/win32/2.10/xlsReadWrite_1.5.1.zip
devel: 
http://dl.dropbox.com/u/2602516/swissrpkg/bin/win32/2.10/xlsReadWrite_0.0.0.zip

Hope this helps!
(Otherwise feel free to contact me by email (gchappi  gmail), this
really must work).

Cheers,
Hans-Peter

__
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] Bug in Cairo?

2010-03-11 Thread Lorenzo Isella

Dear All,
I am not really an expert about visualization and plotting, but consider 
the code snippet at the end of this email.
On my machine ((X)Ubuntu for the amd64 bit architecture, Cairo installed 
from Cran, R 2.10),  the two plots (one with R basic graphics, the other 
generated using Cairo) do look pretty different.
To be precise, the one by Cairo seems to have a few misplaced characters 
and also the size of the axis label looks different from those in the 
plot I generate via pdf().
I posted something along these lines on the ggplot2 list (I thought this 
had something to do with the ggplot2 library at the time) and I was told 
that these problems are about to disappear with the next R release.
Can anyone else running R 2.11 confirm this? Is anyone else experiencing 
these minor glitches in Cairo?

Many thanks

Lorenzo



###

#



rm(list=ls())

library(ggplot2)
library(Cairo)

set.seed(1234)

time <- seq(0,40,length=200)

delta <- runif(200,-2e-3,1e-3)
delta_2 <- runif(200,-2e-3,1e-3)

pdf("test_cairo.pdf")

par( mar = c(4.5,5, 2, 1) + 0.1)

plot(time, delta,col="blue","p",lwd=2,lty=1,pch=1,xlab = "Dimensionless 
time t",

ylab=expression(paste("(",R[g],"[0]-",R[g],"[t])/",R[g],"[0]")),cex.axis=1.4,cex.lab=1.6,

ylim=range(c(-2e-3,1e-3)),yaxt="n")
lines(time, delta_2, "p",col="red",lwd=2,lty=1,pch=5 )
axis(side=2, at=c(-2e-3,-1e-3,0,1e-3),
labels=expression(-2%*%10^-3, -1%*%10^-3,0, 
1%*%10^-3),cex.lab=1.4,cex.axis=1.4)
legend("bottomleft",cex=1.2,c(expression(paste(Delta,"t")),expression(paste(Delta,"t/4") 
))

,lwd=c(2,2), lty=c(-1,-1),pch = c(1,5),col=c("blue", "red")
,xjust = 1, yjust = 1
  ,box.lwd=0,box.lty=0)

dev.off()


CairoPDF("test_cairo_2.pdf")

par( mar = c(4.5,5, 2, 1) + 0.1)

plot(time, delta,col="blue","p",lwd=2,lty=1,pch=1,xlab = "Dimensionless 
time t",

ylab=expression(paste("(",R[g],"[0]-",R[g],"[t])/",R[g],"[0]")),cex.axis=1.4,cex.lab=1.6,

ylim=range(c(-2e-3,1e-3)),yaxt="n")
lines(time, delta_2, "p",col="red",lwd=2,lty=1,pch=5 )
axis(side=2, at=c(-2e-3,-1e-3,0,1e-3),
labels=expression(-2%*%10^-3, -1%*%10^-3,0, 
1%*%10^-3),cex.lab=1.4,cex.axis=1.4)
legend("bottomleft",cex=1.2,c(expression(paste(Delta,"t")),expression(paste(Delta,"t/4") 
))

,lwd=c(2,2), lty=c(-1,-1),pch = c(1,5),col=c("blue", "red")
,xjust = 1, yjust = 1
  ,box.lwd=0,box.lty=0)

dev.off()

__
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] console window always on top

2010-03-11 Thread Robert M. Flight
I don't remember inputting anything like that previously, but that
worked perfectly. Thank you.

-Robert

On Thu, Mar 11, 2010 at 13:12, Duncan Murdoch  wrote:
> On 11/03/2010 11:59 AM, Robert M. Flight wrote:
>>
>> In R on Windows (ver 7) I have somehow set the preferences for the R
>> console window to be always on top. I'm sure at the time I did this it
>> seemed like a good idea, but in practice it is not. Unfortunately, I
>> cannot remember where the setting is changed, and thus it is stuck
>> this way. Does anyone know how to modify this setting?
>
> That was probably done via the bringToTop() function.  Call it again as
> bringToTop(which = -1, stay = FALSE).
>
> It's possible you did it with some kind of call to arrangeWindows(), but I
> don't see how that would happen.  If so, it might be fixed by
> arrangeWindows("restore").
>
> Duncan Murdoch
>

__
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] Forecasting with Panel Data

2010-03-11 Thread Matthew Dowle
Ricardo,

I see you got no public answer so far, on either of the two lists you posted 
to at the same time yesterday.  You are therefore unlikely to ever get a 
reply.

I also see you've been having trouble getting answers in the past, back to 
Nov 09,  at least.  For example no reply to "Credit Migration Matrix" (Jan 
2010) and no reply to "Help with a Loop in function" (Nov 2009).

For your information, this is a public place and it took me about 10 seconds 
to assess you. Anyone else on the planet can do this too.

Please read the posting guide AND the links from it, especially the last 
link.  I suggest you read it fully, and slowly.  I think its just that you 
didn't know about it, or somehow missed it by accident.  You were told to 
read it though, at the time you subscribed to this list, at least.  Don't 
worry,  this is not a huge problem. You can build up your reputation again 
very quickly.

With the kindest of regards,

Matthew


"Ricardo Gonçalves Silva"  wrote in message 
news:df406bd9dbe644a9b8c0642a3c3f8...@ricardopc...
> Dear Users,
>
> Can I perform panel data (fixed effects model) out of sample forecasts 
> using R?
>
> Thanks in advance,
>
> Ricardo.
> [[alternative HTML version deleted]]
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Help Files Now Load in the Internet Browser?

2010-03-11 Thread Duncan Murdoch

On 11/03/2010 12:21 PM, David Bapst wrote:

Hello,
I recently had to reinstall R on my windows machine, because MASS
mysteriously vanished from my packages list. Before, when I used
help(), the files would load in a Windows help window. Now, the help
files load in my internet browser, which actually is problematic
because I always made use of the contents/topics list to browse the
help files in the Windows Help window. ("I don't remember the name of
the function, but it was in MASS, so I'll just open a help file for a
different function in MASS...").

I looked in the updates list and read that the help files had been
converted. Is there still any way to get the help files to load again
in the windows html help with the topics list?


No, there isn't.  You can get an equivalent list to the index (same 
information, different format) by running help.start() and clicking on 
the "Packages" link.


Duncan Murdoch

__
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] console window always on top

2010-03-11 Thread Duncan Murdoch

On 11/03/2010 11:59 AM, Robert M. Flight wrote:

In R on Windows (ver 7) I have somehow set the preferences for the R
console window to be always on top. I'm sure at the time I did this it
seemed like a good idea, but in practice it is not. Unfortunately, I
cannot remember where the setting is changed, and thus it is stuck
this way. Does anyone know how to modify this setting?


That was probably done via the bringToTop() function.  Call it again as 
bringToTop(which = -1, stay = FALSE).


It's possible you did it with some kind of call to arrangeWindows(), but 
I don't see how that would happen.  If so, it might be fixed by 
arrangeWindows("restore").


Duncan Murdoch

__
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] Fwd: function to create multiple matrices

2010-03-11 Thread Lanna Jin
Jim Holtman's solution generates a data frame that can be easily indexed by
year:
 setwd("/r-help/2010-03-10")
x <- read.csv("restored.csv", as.is=TRUE)

require(reshape)
x.m <- melt(x, id=c('Year', 'LocationID', 'SpeciesCode'),
measure='PlotFreq')
x.binary <- cast(x.m, Year + LocationID ~ SpeciesCode, length)


  On Thu, Mar 11, 2010 at 10:55 AM, Lanna Jin wrote:

> Hi Jim,
>
> Here's an example of what I mean by a binary matrix ( 1 = species
> presence, 0 = species absence, cols = species, rows = location).  This is
> just a sample of data from the Year 1998
>
>   ACMI2 ALLIUM ALST AMAR2 AMCA6 AMPS ANCA8 ANCA9 ANCY ANEMONE
> ANGE ANNE APCA ARLU ASCA11 ASER3 ASLA5 ASNO ASOV ASSY ASVE BOCU BREU CAREX
> CASE13
>   PIPE_15 0  00 0 00 0 00
> 00000  0 0 0000000
> 0  0
>   PIPE_16 0  00 0 00 0 00
> 00000  0 0 0000000
> 0  0
>   PIPE_17 0  00 0 00 0 00
> 00000  0 0 0000000
> 0  0
>   PIPE_7  0  00 0 00 0 00
> 00000  0 0 0000000
> 0  0
>   PIPE_8  0  00 0 00 0 00
> 00000  0 0 0000000
> 0  0
>   PIPE_9  0  00 0 00 0 00
> 00000  0 0 0000000
> 0  0
>   PIPE_11 1  00 0 10 1 01
> 00011  0 1 1011010
> 1  0
>   PIPE_12 1  10 0 00 1 00
> 01011  0 0 0001000
> 1  0
>   PIPE_13 0  00 0 10 1 00
> 01000  0 1 0001000
> 1  0
>   PIPE_14 1  00 0 11 1 01
> 00001  0 0 1001110
> 1  0
> To give you a better idea of what the data looks like:
>
> > head(data)
>Type Year Location Species
> 66 Restored 1998   PIPE_7   ACMI2
> 67 Restored 1998   PIPE_7   AMAR2
> 68 Restored 1998   PIPE_7   AMCA6
> 69 Restored 1998   PIPE_7ANCY
> 70 Restored 1998   PIPE_7ASVE
> 71 Restored 1998   PIPE_7BOCU
> > unique(data$Year)
> [1] 1998 1999 2001 2005 2006 2009
> > unique(data$Type)
> [1] "Restored" "Native"
> > length(unique(data$Species))
> [1] 107
>
> I've managed to individually pull out each matrix for each type (also,
> for some reason when I do as.matrix, it converts the 1's to -1's. Not sure
> why, but I've corrected it...).
>
> dataT<-table(data$Location,data$Species,data$Year,data$Type)
>
> # For Natives:
> N98<--as.matrix(dataT[,,1,"Native"]);N98[which(N98<0)]<-1
> N99<--as.matrix(dataT[,,2,"Native"]);N99[which(N99<0)]<-1
> etc... etc...
> N09<--as.matrix(dataT[,,6,"Native"]);N09[which(N09<0)]<-1
>
> # For Restored:
> R98<--as.matrix(dataT[,,1,"Restored"]);R98[which(R98<0)]<-1
> R99<--as.matrix(dataT[,,2,"Restored"]);R99[which(R99<0)]<-1
> etc... etc...
> R09<--as.matrix(dataT[,,6,"Restored"]);R09[which(R09<0)]<-1
>
> Do you know of a way to efficiently do this in a function?  For some
> reason, I can't figure out how to generate unique dataframes/matrices for
> each unique i in a for loop function...
>
> Thanks,
>   Lanna
>
>
>
>>   On Wed, Mar 10, 2010 at 12:07 PM, Lanna Jin >>> > wrote:

>  Hi All,
>
> If given a dataframe (long form) with Year, Species, and Location,
> How would I write a function that would create a unique matrix of
> Species &
> Location for each Year?
>
> What I've tried doing is the following:
>
> data #dataframe
> dataT<-table(data$Species,data$Location,data$Year) #creates tables
> of
> Species vs Location for each Year
>
> But I'm encountering issues individually indexing the tables and
> converting
> them into matrices in one fell swoop.
>
> r1997<-as.matrix(tableT[,,"1997"]) #How I would do it individually;
> but I
> can I make matrices for each year as a function?
>
> Thanks in advance for your suggestions!
>
> --
> Lanna Jin
>
> lanna...@gmail.com
> 510-898-8525
>
>

>>

Re: [R] see the example and help me

2010-03-11 Thread Jonathan Christensen
Hi,

On Thu, Mar 11, 2010 at 3:46 AM, chinna  wrote:

>
> Hi Peter konings,
> Sorry man the forecasted values i have given wrong 
> once again see my question and please give me the answer.
>
> 

>
> This is the forecasted report that i get using the reporting tool cognos(BI
> Reporting Tool).
> is this is possible with the R project.
> If possible can u please tell me the way.
>

Certainly. Here's a really simple solution:

Load the data into R using read.table (this may involve cleaning up the
dollar amounts). It looks linear (scatterplot of revenue and quarter_index),
so fit a linear model (Revenue ~ quarter_index) with lm(). Use the object
created and a dataframe of what values you want to predict (probably
quarter_index=seq(1,16)) with the predict() command.

For a bit more information, see

http://cran.r-project.org/doc/manuals/R-intro.html#Linear-models

and the following section. Also try ?lm, ?predict.

(On a side note, my predicted values are consistently about $50,000 higher
than the ones you got from what were using. Since I don't know what exactly
your tool is doing, I can't tell you why that is).

If you want to take into account the fact that it's actually a time series,
R has plenty of tools for that too.

Jonathan



>
> Thanks in advance
> chinna.
> --
> View this message in context:
> http://n4.nabble.com/see-the-example-and-help-me-tp1587229p1588761.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
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] Problem with rcmd SHLIB

2010-03-11 Thread denise xifaras
Thank you Duncan,

the paths were first so that wasn't the problem, but when I changed to the 
directory of the file and then typed rcmd SHLIB it did work, like you said. 
Great news.

Best,
Denise

--- On Thu, 3/11/10, Duncan Murdoch  wrote:

From: Duncan Murdoch 
Subject: Re: [R] Problem with rcmd SHLIB
To: "denise xifaras" 
Cc: r-help@r-project.org
Date: Thursday, March 11, 2010, 8:03 AM

On 11/03/2010 10:57 AM, denise xifaras wrote:
> Hi all,
> 
> I am trying to call a C function from R (version 2.10.1) on a windows machine.
> 
> The C code is in a .c file, I have pasted the code below although I'm very 
> confident that it does not contain any errors (it is not my code), but also, 
> the problem that I have occurs with every .c file that I have tried this with.
> 
> I have installed Rtools and included: C:\Rtools\bin; C:\Rtools\perl; 
> C:\Rtools\MinGW\bin;"C:\Program Files\R\R-2.10.1\bin"
> in my path from My Computer.
>   

That is not sufficient:  those need to be first, not just "included".   There 
are often other versions of make or find or the other tools installed on 
Windows systems.
> I would like to create a .dll file in order to load it in R and call the C 
> function.
> 
> In the command prompt I type:
> rcmd SHLIB C:\...\filename.c     (or R CMD SHLIB C:\...\filename.c)
> and I get the message:
> make: nothing to be done for 'all'
>   

I would recommend switching to that directory, then using Rcmd SHLIB 
filename.c.  Windows pathnames sometimes have spaces in them which can mess up 
the tools.

Duncan Murdoch
> I understand that this message means that the particular file has already 
> been compiled and no changes have been made and so the .dll file must already 
> exist. The problem is that this hasn't happened. I have never compiled a .c 
> file this way on this computer and there definitely aren't any .dll files as 
> compiling hasn't ever actually worked.
> 
> Any ideas about why this is happening?
> 
> Thank you all in advance for the help and any feedback,
> 
> Best,
> Denise
> 
> C code:
> 
> void convolve1(double *a, int *na,
> double *b, int *nb, double *ab)
> {
> int i, j, nab = *na + *nb -
>  1;
> for (i = 0; i < nab; i++) ab[i] = 0.0;
> for (i = 0; i < *na; i++)
> for (j = 0; j < *nb; j++)
> ab[i + j] += a[i] + b[j];
> }
> 
> 
> 
>       [[alternative HTML version deleted]]
> 
>   
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>   




  
[[alternative HTML version deleted]]

__
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 Files Now Load in the Internet Browser?

2010-03-11 Thread David Bapst
Hello,
I recently had to reinstall R on my windows machine, because MASS
mysteriously vanished from my packages list. Before, when I used
help(), the files would load in a Windows help window. Now, the help
files load in my internet browser, which actually is problematic
because I always made use of the contents/topics list to browse the
help files in the Windows Help window. ("I don't remember the name of
the function, but it was in MASS, so I'll just open a help file for a
different function in MASS...").

I looked in the updates list and read that the help files had been
converted. Is there still any way to get the help files to load again
in the windows html help with the topics list?
-Dave Bapst, UChicago

__
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 Files Now Load in the Internet Browser?

2010-03-11 Thread David Bapst
Hello,
I recently had to reinstall R on my windows machine, because MASS
mysteriously vanished from my packages list. Before, when I used
help(), the files would load in a Windows help window. Now, the help
files load in my internet browser, which actually is problematic
because I always made use of the contents/topics list to browse the
help files in the Windows Help window. ("I don't remember the name of
the function, but it was in MASS, so I'll just open a help file for a
different function in MASS...").

I looked in the updates list and read that the help files had been
converted. Is there still any way to get the help files to load again
in the windows html help with the topics list?
-Dave Bapst, UChicago

__
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] using sprintf to pass a variable to a RMySQL query

2010-03-11 Thread alison waller
Hi all,

I re-installed R and tcltk.  I find some of the documentation misleading
as it indicates that tcltk is included with R.  And when you type
library() it shows tcltk, even though it hasn't been installed.

Anyways, I've decided to go with sprintf.
I am having errors with my query criteria.

I have slightly changed by criteria as I want to match 'MGi.' (so that I
match MG1. and MG10. if I did %MGi% won't I match MG1. and MG10.
I tried to escape the period with a backslash,quotes and double period. 
I think that R is fine with the syntax, but SQL doesn't like it.

Can anyone please help me with the syntax.

thank you,



## Error##
Error in mysqlExecStatement(conn, statement, ...) :
  RS-DBI driver: (could not run statement: You have an error in your SQL
syntax; check the manual that corresponds to your MySQL server version
for the right syntax to use near '1' at line 2
)
Calls: dbGetQuery ... .valueClassTest -> is -> is -> mysqlExecStatement
-> .Call
Execution halted
Script#


library(RMySQL)
mysql<-dbDriver("MySQL")
con<-dbConnect(mysql,username="u",host="g",password="s",port=,dbname="M")

i<-1
k<-0

while (k<=17) {
 while (i<=72) {

sqlcmd_ScaffLen<-sprintf('SELECT scaffold.length
FROM scaffold,scaffold2contig,contig2read
WHERE scaffold.scaffold_id=scaffold2contig.scaffold_id AND
scaffold2contig.contig_id=contig2read.contig_id AND
contig2read.read_id LIKE
\'%%MG%d..%%\'' ,i)

sqlcmd_contigs<-sprintf('SELECT length FROM contig WHERE external_id
 LIKE\'%%MG%d..%%\'',i)

sqlcmd_singletons<-paste('SELECT COUNT(*) FROM contig WHERE
read_count=1 AND external_id LIKE \'%%MG%d..%%\'',i)

MG_ScaffoldLen<-dbGetQuery(con,sqlcmd_ScaffLen)

MG_ContigsLen<-dbGetQuery(con,sqlcmd_contigs)

MG_SingletonsCount<-dbGetQuery(con,sqlcmd_singletons)

   
MG_ScaffoldLen_Summ<-as.data.frame(c(summary(MG_ScaffoldLen$length),MG_SingletonsCount))
MG_ContigsLen_Summ<-summary(MG_ContigsLen$length)

   
write.table(MG_ScaffoldLen_Summ,file="ScaffoldLen_SummStats.txt",append=TRUE,sep='\t')

   
write.table(MG_ContigsLen_Summ,file="ContigsLen_SummStats.txt",append=TRUE,sep='\t')

# Keep names for 4 of them so we can do summary plots for each treatment
# (ie combine all 4 reps)

MG_ScaffoldLen<-assign(paste('MG_ScaffoldLen',i,sep=''),MG_ScaffoldLen)

MG_ContigsLen<-assign(paste('MG_ContigsLen',i,sep=''),MGContigsLen)

i<-i+18
}
### Summary Plots For each Treatment ##

  jpeg(file=sprintf("Boxplots%dSanger_Virus.jpeg",k))
 
sprintf("boxplot(MG_ScaffoldLen(1+%d)$length,MG_ScaffoldLen(18+%d)$length,MG_ScaffoldLen(36+%d)$length,MG_ScaffoldLen(54+%d)$length)",k)
  dev.off()

  jpeg(file=sprintf("Scaffold_histograms%dSanger_Virus.jpeg",k))
  par(mfrow=c(1,3))
  sprintf("hist(MG_ScaffoldLen(1+%d)$length)",k)
  sprintf("hist(MG_ScaffoldLen(18+%d)$length)",k)
  sprintf("hist(MG_ScaffoldLen(36+%d)$length)",k)
  sprintf("hist(MG_ScaffoldLen(54+%d)$length)",k)
  dev.off()

  jpeg(file=sprintf("Contig_histograms%dSanger_Virus.jpeg",k))
  par(mfrow=c(1,3))
  sprintf("hist(MG_ContigsLen(1+%d)$length)",k)
  sprintf("hist(MG_ContigsLen(18+%d)$length)",k)
  sprintf("hist(MG_ContigsLen(36+%d)$length)",k)
  sprintf("hist(MG_ContigsLen(54+%d)$length)",k)
  dev.off()

  k<-k+1
  i<-1+k
  }


On 03/11/10 16:01, Uwe Ligges wrote:
> On 10.03.2010 12:45, alison waller wrote:
>> Thanks Gabor,
>>
>> As I said I would like to use gsubfn, but I am having problems
>> installing it, which I assume are due to some conflict with the current
>> tcltk package
>>
>> Below is the error I got after issuing install.packages("gsubfn")
>>
>> Any advice?
>
>
> Re-install R including the tcltk package?
>
> Uwe Ligges
>
>
>> ###
>> * Installing *source* package 'gsubfn' ...
>> ** R
>> ** demo
>> ** inst
>> ** preparing package for lazy loading
>> Warning: S3 methods '$.tclvar', '$<-.tclvar', 'as.character.tclObj',
>> 'as.character.tclVar', 'as.double.tclObj', 'as.integer.tclObj',
>> 'as.logical.tclObj', 'print.tclObj', '[[.tclArray', '[[<-.tclArray',
>> '$.tclArray', '$<-.tclArray', 'names.tclArray', 'names<-.tclArray',
>> 'length.tclArray', 'length<-.tclArray', 'tclObj.tclVar',
>> 'tclObj<-.tclVar', 'tclvalue.default', 'tclvalue.tclObj',
>> 'tclvalue.tclVar', 'tclvalue<-.default', 'tclvalue<-.tclVar' were
>> declared in NAMESPACE but not found
>> Error in namespaceExport(ns, exports) :
>>undefined exports: addTclPath, as.tclObj, is.tclObj, is.tkwin
>> Error : package 'tcltk' could not be loaded
>> ERROR: lazy loading failed for package 'gsubfn'
>> * Removing '/g/bork3/x86_64/lib64/R/library/gsubfn'
>>
>> The downloaded packages are in
>>  '/tmp/RtmpkfvT5f/downloaded_packages'
>> Updating HTML index of packages in '.Library'
>> Warning message:
>> In install.packages("gsubfn", lib = "/g/bork3/x86_64/lib64/R/library") :
>>installation of package 'gsubfn' had non-zero exit status
>>
>> ## this

[R] console window always on top

2010-03-11 Thread Robert M. Flight
In R on Windows (ver 7) I have somehow set the preferences for the R
console window to be always on top. I'm sure at the time I did this it
seemed like a good idea, but in practice it is not. Unfortunately, I
cannot remember where the setting is changed, and thus it is stuck
this way. Does anyone know how to modify this setting?

Thanks,

-Robert

Robert M. Flight, Ph.D.
Bioinformatics and Biomedical Computing Laboratory
University of Louisville
Louisville, KY

PH 502-852-0467
EM robert.fli...@louisville.edu
EM rfligh...@gmail.com

Williams and Holland's Law:
   If enough data is collected, anything may be proven by
statistical methods.

__
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] which coefficients for a gam(mgcv) model equation?

2010-03-11 Thread Darren Norris

I have spent a few days trying to figure this from the reply out but am still
stuck!
I need the equation to reply to a request from a referee that was to: "show
the specific estimating equation associated with the fitted line".
the model I am running is (I hope the data frame is not necessary as I think
I am just not getting some basic concept, but it can be provided off list):
gam1<-gam(LR~s(Property_lg),data=property) ## use default family
gaussian(link = "identity")

coef(gam1) returns:
 (Intercept) s(Property_lg).1 s(Property_lg).2 s(Property_lg).3
s(Property_lg).4 s(Property_lg).5 
  44.1777350   -9.4673457   -1.57438770.5658906   
2.22194340.4118942 
s(Property_lg).6 s(Property_lg).7 s(Property_lg).8 s(Property_lg).9 
   2.4477335   -0.6590291   14.61423653.4184510 

so is the "estimating equation":
E(y_i) ~ 44.1777 + f_1(-9.467) + f_2(-1.574) + f_3(0.565) +f_4(2.221) +
f_5(0.411) + f_6(2.447) + f_7(-0.659) +f_8(14.614)+f_9(3.418)

>From the “predict” function I know the fitted value at x = 0 (intercept) is
-25.5256255 and at x = 1 is -1.3417508. How do I calculate these values from
the “estimating equation” above?
For x=1, I am doing the calculation below which is obviously incorrect, but
how do I calculate the predicted values by hand, I must be missing something
incredibly obvious?
 44.1777 + (1*-9.467) + (1*-1.574) + (1*0.565) + (1*2.221) + (1*0.411) +
(1*2.447) + (1*-1*0.659) + (1*4.614)+ (1*3.418) 

Many thanks for any further guidance,
Darren



coef(b)

will give you the coefficients for the smooth terms + the intercept for
that model. ?gamObject describes thus a little.

The coefficients for the smooth/spline terms here are of length 9 each,
and each set of 9 coefficients pertains to an f(), so the model in the R
code you gave would be something like

E(y_i) ~ alpha + f_1(x0_i) + f_2(x1_i) + f_3(x2_i) +f_4(x3_i) 

or

E(y_i) = alpha + f_1(x0_i) + f_2(x1_i) + f_3(x2_i) +f_4(x3_i) + e, where
e ~ N(0, sigma)


If so, perhaps you could provide more details on why you want the
equation for the model?


-- 
View this message in context: 
http://n4.nabble.com/which-coefficients-for-a-gam-mgcv-model-equation-tp1578925p1589223.html
Sent from the R help mailing list archive at Nabble.com.

__
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] Obtaining name of data frame used in a function argument

2010-03-11 Thread Henrique Dallazuanna
Try this:

foo <- function(data)print(deparse(substitute(data)))
foo(DF)

On Thu, Mar 11, 2010 at 2:31 PM, Jason Baucom  wrote:
> I'm writing a function that can take a data.frame as an argument. I'd
> like to be able to obtain the name of the data.frame and print it out
> within the function. My current function looks like this:
>
>
>
> examineIt<-function(x) {
>
> print(nrow(x))
>
> print(x[ceiling(runif(10)*nrow(x)),])
>
> print(summary(x))
>
> }
>
>
>
> examineIt(myDataFrame)
>
>
>
> I'd like for the function to also output "myDataFrame". Is there any way
> to do this? I'm running this function several times in a row and need to
> be able to identify which data.frame was analyzed.
>
>
>
> Thanks!
>
> Jason
>
>
>        [[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.
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O

__
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] Obtaining name of data frame used in a function argument

2010-03-11 Thread Jason Baucom
I'm writing a function that can take a data.frame as an argument. I'd
like to be able to obtain the name of the data.frame and print it out
within the function. My current function looks like this:

 

examineIt<-function(x) {

print(nrow(x))

print(x[ceiling(runif(10)*nrow(x)),])

print(summary(x))

}

 

examineIt(myDataFrame)

 

I'd like for the function to also output "myDataFrame". Is there any way
to do this? I'm running this function several times in a row and need to
be able to identify which data.frame was analyzed.

 

Thanks!

Jason


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Help with aggregate and cor

2010-03-11 Thread James Marca
On Wed, Mar 10, 2010 at 07:48:45PM +, hadley wickham wrote:
> > Run that function hourly with plyr
> >
> > output.hourly <- dlply(df.i1,"tshour",cor.dat)
> 
> Why not
> 
> output.hourly <- ddply(df.i1,"tshour",cor.dat)

Doh!  Because I didn't read the docs properly and missed it.
Thanks, much nicer than hacking around with lists.

thanks,
James Marca
> 
> ?  Generally you want to work with data frames in R, if at all possible.
> 
> Hadley
> 
> -- 
> Assistant Professor / Dobelman Family Junior Chair
> Department of Statistics / Rice University
> http://had.co.nz/
> 
> 
> 
> --===1710152797==
> Content-Type: message/rfc822
> MIME-Version: 1.0

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

__
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] mixed-effects survival

2010-03-11 Thread HAKAN DEMIRTAS
Hi,

What R libraries should I use to implement mixed effects models with continuous 
time and discrete-time survival data? What if I have two crossed random 
effects? I'd appreciate any help.

Regards,
Hakan Demirtas
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] logistic model diagnostics residuals.lrm {design}, residuals()

2010-03-11 Thread Chaudhari, Bimal
I am interested in a model diagnostic for logistic regression which is normally 
distributed (much like the residuals in linear regression with are ~ 
N(0,variance unknown).

My understanding is that most (all?) of the residuals returned by residuals.lrm 
{design} either don't have a well defined distribution or are distributed as 
Chi-Square.

Have I overlooked a residual measure or would it be possible to transform one 
of the residual measures into something reasonably 'normal' while retaining 
information from the residual so I could compare between models (obviously I 
could blom transform any of the measures, but then I'd always get a standard 
normal)?

Cheers,
bimal

Bimal P Chaudhari, MPH
MD Candidate, 2011
Boston University
MS Candidate, 2010
Washington University in St Louis


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Can't convert list to matrix properly

2010-03-11 Thread Miguel Porto
see for yourself - AFAIK it'll just concatenate eveverything which is
"atomic" into a vector, thus losing all the structure associated.
Miguel


On Thu, Mar 11, 2010 at 4:14 PM, anna  wrote:

>
> Yes, definitely! so unlist() turns the list components into a vector? What
> if
> the component are vectors, matrices etc? Thank you Miguel!
>
> -
> Anna Lippel
> --
> View this message in context:
> http://n4.nabble.com/Can-t-convert-list-to-matrix-properly-tp1589187p1589209.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
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] Can't convert list to matrix properly

2010-03-11 Thread anna

ok guys, thanks a lot!

-
Anna Lippel
-- 
View this message in context: 
http://n4.nabble.com/Can-t-convert-list-to-matrix-properly-tp1589187p1589246.html
Sent from the R help mailing list archive at Nabble.com.

__
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] Can't convert list to matrix properly

2010-03-11 Thread Ivan Calandra

I would say so; it would make sense.

Le 3/11/2010 17:16, anna a écrit :

so I was getting ones because it converted the characters into numeric?

-
Anna Lippel
   


--
Ivan CALANDRA
PhD Student
University of Hamburg
Biozentrum Grindel und Zoologisches Museum
Abt. Säugetiere
Martin-Luther-King-Platz 3
D-20146 Hamburg, GERMANY
+49(0)40 42838 6231
ivan.calan...@uni-hamburg.de

**
http://www.for771.uni-bonn.de
http://webapp5.rrz.uni-hamburg.de/mammals/eng/mitarbeiter.php

__
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] Can't convert list to matrix properly

2010-03-11 Thread anna

so I was getting ones because it converted the characters into numeric?

-
Anna Lippel
-- 
View this message in context: 
http://n4.nabble.com/Can-t-convert-list-to-matrix-properly-tp1589187p1589211.html
Sent from the R help mailing list archive at Nabble.com.

__
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] Can't convert list to matrix properly

2010-03-11 Thread anna

Yes, definitely! so unlist() turns the list components into a vector? What if
the component are vectors, matrices etc? Thank you Miguel!

-
Anna Lippel
-- 
View this message in context: 
http://n4.nabble.com/Can-t-convert-list-to-matrix-properly-tp1589187p1589209.html
Sent from the R help mailing list archive at Nabble.com.

__
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] Can't convert list to matrix properly

2010-03-11 Thread Ivan Calandra

Hi!

Try:  myMatrix <- as.matrix(myDataFrame)

Looking at ?data.matrix: "Return the matrix obtained by converting all 
the variables in a data frame to numeric mode".


You could also do directly: myMatrix <- as.matrix(myList)
Though you might need to transpose (see ?t)

HTH,
Ivan


Le 3/11/2010 17:03, anna a écrit :

Hi guys, here is a list of names that I have:

MyList:
   

myList<-list("A", "B","C","D")
myList
 

[[1]]
[1] "A"

[[2]]
[1] "B"

[[3]]
[1] "C"

[[4]]
[1] "D"

I want to turn this list into a matrix of 1 row and 4 columns with those
four components (A, B, C, D) so here is what I do:

myDataFrame<- data.frame(myList) and here is how myDataFrame looks like:
   

myDataFrame
 

  X.A. X.B. X.C. X.D.
1ABCD

Until that point everything is ok because if I want to retrieve one element
I make
   

myDataFrame[[1]]
 

[1]  A
Levels: A

But when I try to convert into matrix by doing this:

   

myMatrix<- data.matrix(myDataFrame) I get this:
myMatrix
 

  X.A. X.B. X.C. X.D.
[1,]1111
He just keeps the names and delete the components...What am I doing wrong?
Thanks in advance!













-
Anna Lippel
   


--
Ivan CALANDRA
PhD Student
University of Hamburg
Biozentrum Grindel und Zoologisches Museum
Abt. Säugetiere
Martin-Luther-King-Platz 3
D-20146 Hamburg, GERMANY
+49(0)40 42838 6231
ivan.calan...@uni-hamburg.de

**
http://www.for771.uni-bonn.de
http://webapp5.rrz.uni-hamburg.de/mammals/eng/mitarbeiter.php

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