[R] Extract variance from dist(cluster.data)

2009-12-17 Thread Philip Silva
Hi!

I am currently clustering data that is read out of a csv file. The code is:

file <- read.table("/tmp/cluster_input.tmp")
cluster.data <- as.matrix(file[,2:39040])
cluster.dist <- dist(cluster.data)
cluster.hclust <- hclust(cluster.dist)
cluster.hcut <- cutree(cluster.hclust,10) # 10 == number of clusters!
write.table(cluster.hcut, "/tmp/cluster_result.csv")

Now I would like to know the Variance of each cluster in hcut. Is it correct 
that the variances are already encoded in dist(cluster.data)? How can I get it?

Thanks a lot in advance.

Best regards
Philip Silva
-- 
Preisknaller: GMX DSL Flatrate für nur 16,99 Euro/mtl.!
http://portal.gmx.net/de/go/dsl02

__
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] Error for making packages under windows XP-Error in library.dynam(lib, package, package.lib)

2009-12-17 Thread Duncan Murdoch

rusers.sh wrote:

Hi,
  I have installed the necessary tools for making a R package under windows
and am sure these tool have been correctly configured. I am very new to try
writing a package, so the error may be very obvious for you. Forgive me if
it is too easy.
  My package name is *stam*, and i put it under the folder
"D:/StatSoft/R/MyPackage/". I have two folders,*R* and *man*. Besides, i
also have *description* and *namespace** *files. It is a very simple beta
package.
  


The DESCRIPTION and NAMESPACE files should be specified in upper case, 
but that's probably not your problem.  I would guess you have a command 
that says to load a shared library, e.g. a useDynLib statement in your 
NAMESPACE, or a library.dynam in a .First() function.  Just delete it, 
without compiled code (which would be kept in the src directory) you 
don't need it.


Duncan Murdoch

  Following is the error after using "R CMD check mypackage". Thanks very
much.
#
* using log directory 'D:/StatSoft/R/MyPackage/stam.Rcheck'
* using R version 2.10.0 (2009-10-26)
* using session charset: ISO8859-1
* checking for file 'stam/DESCRIPTION' ... OK
* this is package 'stam' version '1.0-0'
* checking package name space information ... OK
* checking package dependencies ... OK
* checking if this is a source package ... OK
* checking for executable files ... OK
* checking whether package 'stam' can be installed ... OK
* checking package directory ... OK
* checking for portable file names ... OK
* checking DESCRIPTION meta-information ... OK
* checking top-level files ... OK
* checking index information ... OK
* checking package subdirectories ... OK
* checking R files for non-ASCII characters ... OK
* checking R files for syntax errors ... OK
* checking whether the package can be loaded ... ERROR
Error in library.dynam(lib, package, package.lib) :
  shared library 'stam' not found
Error: package/namespace load failed for 'stam'
Execution halted

It looks like this package has a loading problem: see the messages for
details.

#




__
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] CORRECTION - Generation of Random numbers in a loop

2009-12-17 Thread Gray Calhoun
Hi Maithili,
  This is probably easiest if you think in terms of functions.  Just
apply 'runif' along the right vectors

## gives you one data frame with the min and max
limits <- read.table(textConnection("name min max
A111.05  1.30
A121.30  1.60
A131.60  1.99"), header = TRUE)
d <- merge(ONS, limits)

cbind(randomdraw = unlist(mapply(runif, d$number, d$min, d$max)), name
= rep(d$name, d$number))

## now save it to a csv file, etc.


On Wed, Dec 16, 2009 at 10:35 PM, Maithili Shiva
 wrote:
> Dear R helpers, please ignore my earlier mail. Here is the corrected mail. 
> Please forgive me for the lapses on my part. Extremely sorry.
>
> Here is the corrected mail.
>
>
> Dear R helpers
>
> I am having following data
>
> Name   Numbers
> A11  12
> A12  17
> A13   0
> A11  11
> A12   6
> A13   0
> A11   8
> A12   4
> A13   3
>
> CONDITIONS
>
> If Name is A11, min_val = 1.05, max_val = 1.30
> If Name is A12, min_val = 1.30, max_val = 1.60
> If Name is A13, min_val = 1.60, max_val = 1.99
>
> TASK
>
> To generate the Uniform random nos for each of these Names (Equal to the 
> corresponding no. e.g. the 5th Name is A12, so I need to generate 6 uniform 
> random numbers in the range (1.30 - 1.99). Also I need to arrange these 
> random numbers one by one in a single csv file i.e. say 12 random numbers in 
> teh range (1.05-1.30) followed by 17 random numbers in the range (1.30-1.60) 
> and so on.
>
> # ___
>
> Here is the R code I have tried
>
> ONS <- read.table(textConnection("name number
> A11    12
> A12    17
> A13 0
> A11    11
> A12  6
> A13  0
> A11  8
> A12  4
> A13  3"), header = TRUE)
>
> X = as.character(ONS$name)
> Y = ONS$number
>
> Z = NULL
>
> for (i in 1:length(X))
>    {
>    if(X[i] == 'A11')
>    {
>    min_val = 1.05
>    max_val = 1.30
>    Z = runif(Y[i], min_val, max_val)
>    }
>    else
>    {
>    if(X[i] == 'A12')
>    {
>    min_val = 1.30
>    max_val = 1.60
>    Z = runif(Y[i], min_val, max_val)
>    }
>    else
>    {
>    if(X[i] == 'A13')
>    {
>    min_val = 1.60
>    max_val = 1.99
>    Z = runif(Y[i], min_val, max_val)
>    }
>    }
>    }
>    }
>
> # End of Code
>
> ## _
>
> PROBLEM
>
> I need to get 61 random numbers which is total of all the numbers (1st 12 fo 
> A, 3 random numbers for B, 13 for C, 5 again fo A and so on). The result 
> whcih I got is
>
>> Z
> [1] 1.740443 1.761758 1.797222
>
> which is pertaining to the last name C where 3 random numbers are generated 
> i.e. Z instaed of getting added, is overwritten.
>
> Please help me to rectify my code so that in the end I will get 61 random 
> numbers as desired i.e. 12 for A in the range (1.05 - 1.30), 3 for B in the 
> range (1.30 - 1.60), 13 for C in the range (1.60-1.99), again 5 for A in the 
> range (1.05 - 1.30).
>
> Thanking in advance. I also sincerely apologize for writing such a long mail, 
> as I wanted to be clear as possible in my communication.
>
> Regards
>
> Maithili
>
>
>      The INTERNET now has a personality. YOURS! See your Yahoo! Homepage.
>        [[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.
>
>



-- 
Gray Calhoun

Assistant Professor of Economics
Iowa State 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] What is the fastest way to see what are in an RData file?

2009-12-17 Thread Gustaf Rydevik
On Wed, Dec 16, 2009 at 10:13 PM, Peng Yu  wrote:
>
> Currently, I load the RData file then ls() and str(). But loading the file
> takes too long if the file is big. Most of the time, I only interested what
> the variables are in the the file and the attributes of the variables (like
> if it is a data.frame, matrix, what are the colnames/rownames, etc.)
>
> I'm wondering if there is any facility in R to help me avoid loading the
> whole file.


I thought this was interesting as well, so i did a bit of searching
through the R-help list archives and found this answer by Simon
Urbanek:
https://stat.ethz.ch/pipermail/r-devel/2007-August/046724.html
The link to a c-routine that does what you want still works, but for
future reference I'm pasting the code below.

Regards,
Gustaf


/*  rdcopy v0.1-0 - extract objects or display contents of RData RDX2 files
 *
 *  Copyright (C) 2007    Simon Urbanek
 *  based in part on src/main/serialize.c and src/main/saveload.c from R:
 *  Copyright (C) 1995, 1996  Robert Gentleman and Ross Ihaka
 *  Copyright (C) 1997--2007  Robert Gentleman, Ross Ihaka and the
 *    R Development Core Team
 *  License: GPL v2
 *
 *  Although R includes are needed to compile this (for constants),
 *  libR does NOT have to be linked.
 */

#include 
#include 
#include 
#include 
#include 

#ifndef _
#define _(X) X
#endif

#undef error
void error(char *fmt, ...) {
  va_list(ap);

  va_start(ap, fmt);
  vprintf(fmt, ap);
  va_end(ap);
  exit(1);
}

/* .RData:

 byte 0..4  XDR2. - file magic ("XDR2\n"=XDR ver2)
 byte 5..6  X.    - format ("A\n"=ASCII, "B\n"=binary, "X\n"=XDR)
 byte 7...  RXDR2 stream.

 Note: RXDR2 format in NOT a valid XDR format! Strings and
   raw bytes are not padded and thus cannot be read
   using XDR alone.
*/

/* we need to override this so that we don't have to really use libR */
SEXP R_NilValue = 0;

/*  those are directly from serialize.c */
#define REFSXP    255
#define NILVALUE_SXP  254
#define GLOBALENV_SXP 253
#define UNBOUNDVALUE_SXP  252
#define MISSINGARG_SXP    251
#define BASENAMESPACE_SXP 250
#define NAMESPACESXP  249
#define PACKAGESXP    248
#define PERSISTSXP    247
#define CLASSREFSXP   246
#define GENERICREFSXP 245
#define BCREPDEF  244
#define BCREPREF  243
#define EMPTYENV_SXP  242
#define BASEENV_SXP   241

/* map type to a name */
static const char *nameSEXP(int type) {
  switch (type) {
  case REFSXP: return "REF";
  case NILVALUE_SXP: return "NULL";
  case GLOBALENV_SXP: return ".GlobalEnv";
  case UNBOUNDVALUE_SXP: return "";
  case MISSINGARG_SXP: return "";
  case BASENAMESPACE_SXP: return "<>";
  case NAMESPACESXP: return "NAMESPACE";
  case PACKAGESXP: return "PACKAGE";
  case PERSISTSXP: return "PERSIST";
  case CLASSREFSXP: return "CLASSREF";
  case GENERICREFSXP: return "GENERICREF";
  case BCREPDEF: return "BC-REP-DEF";
  case BCREPREF: return "BC-REP-REF";
  case EMPTYENV_SXP: return "";
  case BASEENV_SXP: return "";
  case NILSXP: return "NIL";
  case SYMSXP: return "SYM";
  case LISTSXP: return "LIST";
  case CLOSXP: return "CLO";
  case ENVSXP: return "ENV";
  case PROMSXP: return "PROM";
  case LANGSXP: return "LANG";
  case SPECIALSXP: return "SPECIAL";
  case BUILTINSXP: return "BUILTIN";
  case CHARSXP: return "CHAR";
  case LGLSXP: return "LGL";
  case INTSXP: return "INT";
  case REALSXP: return "REAL";
  case CPLXSXP: return "CPLX";
  case STRSXP: return "STR";
  case DOTSXP: return "...";
  case ANYSXP: return "ANY";
  case VECSXP: return "VEC";
  case EXPRSXP: return "EXPR";
  case BCODESXP: return "BCODE";
  case EXTPTRSXP: return "EXTPTR";
  case WEAKREFSXP: return "WEAKREF";
  case RAWSXP: return "RAW";
  case S4SXP: return "S4";
  }
  return "?";
}

/* again from serialize.c */

#define IS_OBJECT_BIT_MASK (1 << 8)
#define HAS_ATTR_BIT_MASK (1 << 9)
#define HAS_TAG_BIT_MASK (1 << 10)
#define ENCODE_LEVELS(v) (v << 12)
#define DECODE_LEVELS(v) (v >> 12)
#define DECODE_TYPE(v) (v & 255)

/* this structure is passed acros all functions. it encapsulates both
the reading an book-keeping */

typedef struct {
  XDR xdrs;
  char *buf;
  long bs;
  FILE *f;
  int lev;
  char *flag;
  int refs;
  long *ref; /* reference offsets */
  int maxrefs; /* length of the refes vector */
  int verb;
  int mode;
  int flags;
  long target;
  FILE *copyf;
} SaveLoadData;

#define M_Read 0
#define M_NonRefCopy   1
#define M_Copy 2
#define M_NonRefSelect 3
#define F_NOREF  1

/* the following is partially based on src/main/saveload.c from R */

static void XdrInInit(FILE *fp, SaveLoadData *d, long sbsize)
{
  xdrstdio_create(&d->xdrs, fp, XDR_DECODE);
  d->buf = (char*) malloc(sbsize);
  if (!(d->buf))
    error(_("cannot allocate memory for a string buffer"));
  d->bs = sbsize;
  d->f = fp;
  d->lev = 0;
  d->flag = 0;
  d->flags = 0;
  d->refs = 0;
  d->maxrefs = 2048;
  d->ref = (long*) malloc(sizeof

[R] issue with using rm: cannot generate on-the-fly list

2009-12-17 Thread Cormac Long
Hello,

I have the following problem when trying to use rm:

In a top level script file I have a loop iterating over some index. The loop
is not contained within a function, so the scope of variables declared in
the loop is global. Within this loop I generate several variables which
should be removed at the end of each iteration. To do this, I wrote a
function to clean up the workspace. An example is included here:

cleanUpWorkspace<-function()
{
#Remove key data sructures, if they have been declared:
delList<-list()
for(varname in c("rv1","rv2", "rv3", "rv4")) {
if(exists(varname)) {
delList<-append(delList, varname)
}
}
if(length(delList)>0) {
rm(list=delList, pos=-1)
#rm(list=delList, envir=parent.env(environment()))
#rm(list=delList, envir=globalenv())
}
}

Unfortunately, this fails to work - it aborts with the following error:
Error in rm(list = delList, pos = -1) : invalid first argument
if I use rm(list=delList, pos=-1)

Or with the following error:
Error in rm(list = delList, evir = parent.env(environment())) :
  ... must contain names or character strings
if I use rm(list=delList, envir=parent.env(environment())) or
rm(list=delList, envir=globalenv())

I get the same errors if I bypass rm entirely and use
.Internal(remove(delList, globalenv(),FALSE)).

I am using R version 2.10.0 running on a windows 7 box.

I want to declare the clean-up within a function for design purposes. The
full project is spread over several files and I am trying to keep the main
loop as simple as possible.

Sincerly,
Cormac Long.

[[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] Fishers exact test at < 2.2e-16

2009-12-17 Thread Søren Faurby

In an effort to select the most appropriate number of clusters in a
mixture analysis I am comparing the expected and actual membership of
individuals in various clusters using the Fisher?s exact test. I aim
for the model with the lowest possible p-value, but I frequently get
p-values below 2.2e-16 and therefore does not get exact p-values with
standard Fisher?s exact tests in R.

Does anybody know if there is a version of Fisher?s exact test in
any package which can handle lower probabilities, or have other  
suggestions as to how I can compare the probabilities?


I am for instance comparing the following two:

dat2<-matrix(c(29,0,29,0,12,0,18,0,0,29,0,16,0,19), nrow=2)
fisher.test(dat2, workspace=3000)

dat3<-matrix(c(29,0,0,29,0,0,12,0,0,17,0,1,0,29,0,0,15,1,0,0,19),
nrow=3)
fisher.test(dat3, workspace=3000)

Which both result in p-value < 2.2e-16

Kind regards, Søren

__
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] Fishers exact test at < 2.2e-16

2009-12-17 Thread Ben Bolker
Søren Faurby  biology.au.dk> writes:

> 
> In an effort to select the most appropriate number of clusters in a
> mixture analysis I am comparing the expected and actual membership of
> individuals in various clusters using the Fisher?s exact test. I aim
> for the model with the lowest possible p-value, but I frequently get
> p-values below 2.2e-16 and therefore does not get exact p-values with
> standard Fisher?s exact tests in R.
> 

  The p<2.2e-16 is a printing issue, not a precision issue.

> ff = fisher.test(dat3, workspace=3000)
> ff

Fisher's Exact Test for Count Data

data:  dat3 
p-value < 2.2e-16
alternative hypothesis: two.sided 

> str(ff)
List of 4
 $ p.value: num 5.88e-58
 $ alternative: chr "two.sided"
 $ method : chr "Fisher's Exact Test for Count Data"
 $ data.name  : chr "dat3"
 - attr(*, "class")= chr "htest"

So just use ff$p.value

__
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] issue with using rm: cannot generate on-the-fly list

2009-12-17 Thread Romain Francois
The list argument of rm is supposed to be a character vector, as 
indicated in ?rm. not a list.


You can do something like this:

rm( list = Filter( exists, c("rv1","rv2", "rv3", "rv4") ) )

or, considering rm only warns when you attempt to remove objects, you 
could:


suppressWarnings( rm( list = c("rv1","rv2", "rv3", "rv4") ) )

Romain

On 12/17/2009 11:33 AM, Cormac Long wrote:


Hello,

I have the following problem when trying to use rm:

In a top level script file I have a loop iterating over some index. The loop
is not contained within a function, so the scope of variables declared in
the loop is global. Within this loop I generate several variables which
should be removed at the end of each iteration. To do this, I wrote a
function to clean up the workspace. An example is included here:

cleanUpWorkspace<-function()
{
 #Remove key data sructures, if they have been declared:
 delList<-list()
 for(varname in c("rv1","rv2", "rv3", "rv4")) {
 if(exists(varname)) {
 delList<-append(delList, varname)
 }
 }
 if(length(delList)>0) {
 rm(list=delList, pos=-1)
 #rm(list=delList, envir=parent.env(environment()))
 #rm(list=delList, envir=globalenv())
 }
}

Unfortunately, this fails to work - it aborts with the following error:
Error in rm(list = delList, pos = -1) : invalid first argument
if I use rm(list=delList, pos=-1)

Or with the following error:
Error in rm(list = delList, evir = parent.env(environment())) :
   ... must contain names or character strings
if I use rm(list=delList, envir=parent.env(environment())) or
rm(list=delList, envir=globalenv())

I get the same errors if I bypass rm entirely and use
.Internal(remove(delList, globalenv(),FALSE)).

I am using R version 2.10.0 running on a windows 7 box.

I want to declare the clean-up within a function for design purposes. The
full project is spread over several files and I am trying to keep the main
loop as simple as possible.

Sincerly,
Cormac Long.




--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://tr.im/HlX9 : new package : bibtex
|- http://tr.im/Gq7i : ohloh
`- http://tr.im/FtUu : new package : highlight

__
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] issue with using rm: cannot generate on-the-fly list

2009-12-17 Thread Duncan Murdoch

On 17/12/2009 5:33 AM, Cormac Long wrote:

Hello,

I have the following problem when trying to use rm:

In a top level script file I have a loop iterating over some index. The loop
is not contained within a function, so the scope of variables declared in
the loop is global. Within this loop I generate several variables which
should be removed at the end of each iteration. To do this, I wrote a
function to clean up the workspace. An example is included here:

cleanUpWorkspace<-function()
{
#Remove key data sructures, if they have been declared:
delList<-list()
for(varname in c("rv1","rv2", "rv3", "rv4")) {
if(exists(varname)) {
delList<-append(delList, varname)
}
}
if(length(delList)>0) {
rm(list=delList, pos=-1)
#rm(list=delList, envir=parent.env(environment()))
#rm(list=delList, envir=globalenv())
}
}

Unfortunately, this fails to work - it aborts with the following error:
Error in rm(list = delList, pos = -1) : invalid first argument
if I use rm(list=delList, pos=-1)


Your delList is a list.  Despite the name of the argument, it doesn't 
want a list, it wants a character vector.  So create it as character(0),

and append elements using delList <- c(delList, varname).

BTW, I'd recommend using the envir=globalenv() version of your rm() 
call, as it says most clearly that your function is messing with the 
global environment.  But first I'd recommend not messing with the global 
environment; think of some other way to share data between functions, 
e.g. defining them all in the same environment, etc.


Duncan Murdoch



Or with the following error:
Error in rm(list = delList, evir = parent.env(environment())) :
  ... must contain names or character strings
if I use rm(list=delList, envir=parent.env(environment())) or
rm(list=delList, envir=globalenv())

I get the same errors if I bypass rm entirely and use
.Internal(remove(delList, globalenv(),FALSE)).

I am using R version 2.10.0 running on a windows 7 box.

I want to declare the clean-up within a function for design purposes. The
full project is spread over several files and I am trying to keep the main
loop as simple as possible.

Sincerly,
Cormac Long.

[[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] Fishers exact test at < 2.2e-16

2009-12-17 Thread Robin Hankin

The aylmer package has some functionality in this regard
which you may find useful.

In particular, you can use good() to get a feel for the
number of tableaux that are consistent with the
specified marginal totals:




> good(dat2)
[1] 42285210
> good(dat3)
[1] 2.756286e+12
>


HTH

rksh


Søren Faurby wrote:

In an effort to select the most appropriate number of clusters in a
mixture analysis I am comparing the expected and actual membership of
individuals in various clusters using the Fisher?s exact test. I aim
for the model with the lowest possible p-value, but I frequently get
p-values below 2.2e-16 and therefore does not get exact p-values with
standard Fisher?s exact tests in R.

Does anybody know if there is a version of Fisher?s exact test in
any package which can handle lower probabilities, or have other 
suggestions as to how I can compare the probabilities?


I am for instance comparing the following two:

dat2<-matrix(c(29,0,29,0,12,0,18,0,0,29,0,16,0,19), nrow=2)
fisher.test(dat2, workspace=3000)

dat3<-matrix(c(29,0,0,29,0,0,12,0,0,17,0,1,0,29,0,0,15,1,0,0,19),
nrow=3)
fisher.test(dat3, workspace=3000)

Which both result in p-value < 2.2e-16

Kind regards, Søren

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



--
Robin K. S. Hankin
Uncertainty Analyst
University of Cambridge
19 Silver Street
Cambridge CB3 9EP
01223-764877

__
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 with spliting a dataframe values

2009-12-17 Thread venkata kirankumar
Hi all,
Hi this is kiran
I am facing a problem to split a dataframe

that is..
 i have a string like:"a,b,c|1,2,3|4,5,6|7,8,8"
first I have to split  with respect to   "|"
I did it with  command

unlist(strsplit("a,b,c|1,2,3|4,5,6|7,8,8", "\\,"))


after getting that set i made it as a dataframe and it comes like

a,b,c
1,2,3
4,5,6
7,8,8

now i have to split this dataframe with respect to ","  and i have to get it
like


a b c
1 2 3
4 5 6
7 8 8


this one i am not able to findout
can any one help me to get it done

thanks in advance
kiran

[[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] Fishers exact test at < 2.2e-16

2009-12-17 Thread Peter Dalgaard
Søren Faurby wrote:
> In an effort to select the most appropriate number of clusters in a
> mixture analysis I am comparing the expected and actual membership of
> individuals in various clusters using the Fisher?s exact test. I aim
> for the model with the lowest possible p-value, but I frequently get
> p-values below 2.2e-16 and therefore does not get exact p-values with
> standard Fisher?s exact tests in R.
> 
> Does anybody know if there is a version of Fisher?s exact test in
> any package which can handle lower probabilities, or have other
> suggestions as to how I can compare the probabilities?
> 
> I am for instance comparing the following two:
> 
> dat2<-matrix(c(29,0,29,0,12,0,18,0,0,29,0,16,0,19), nrow=2)
> fisher.test(dat2, workspace=3000)
> 
> dat3<-matrix(c(29,0,0,29,0,0,12,0,0,17,0,1,0,29,0,0,15,1,0,0,19),
> nrow=3)
> fisher.test(dat3, workspace=3000)
> 
> Which both result in p-value < 2.2e-16
> 
> Kind regards, Søren

The direct answer is that it is primarily an issue of printing conventions:

> fisher.test(dat2, workspace=3000)$p.value
[1] 5.384278e-44
> fisher.test(dat3, workspace=3000)$p.value
[1] 5.883133e-58

However, I'm not sure (a) what is the influence of underflow in the
calculation of such tiny p-values, or (b) whether the p-value is a
sensible metric for comparing clustering models at all.

-- 
   O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - (p.dalga...@biostat.ku.dk)  FAX: (+45) 35327907

__
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] Fishers exact test at < 2.2e-16

2009-12-17 Thread Christian Hennig
I know that you didn't ask for this but to me this seems to be a very 
dodgy method to select a "best number of clusters" with no proper basis at 
all. All of these tests are data dependent, so the p-values cannot be 
interpreted in the usual way. It is actually not clear how they can be 
interpreted, and the freedom in the data to find a clustering depends on 
the number of clusters, so there is no reason to expect that comparing 
p-values for different numbers tells you anything meaningful. Do you 
really think that it is an informative difference if one clustering gives

you p=10^{-58} and another one 10^{-30}?

Christian

On Thu, 17 Dec 2009, Søren Faurby wrote:


In an effort to select the most appropriate number of clusters in a
mixture analysis I am comparing the expected and actual membership of
individuals in various clusters using the Fisher?s exact test. I aim
for the model with the lowest possible p-value, but I frequently get
p-values below 2.2e-16 and therefore does not get exact p-values with
standard Fisher?s exact tests in R.

Does anybody know if there is a version of Fisher?s exact test in
any package which can handle lower probabilities, or have other suggestions 
as to how I can compare the probabilities?


I am for instance comparing the following two:

dat2<-matrix(c(29,0,29,0,12,0,18,0,0,29,0,16,0,19), nrow=2)
fisher.test(dat2, workspace=3000)

dat3<-matrix(c(29,0,0,29,0,0,12,0,0,17,0,1,0,29,0,0,15,1,0,0,19),
nrow=3)
fisher.test(dat3, workspace=3000)

Which both result in p-value < 2.2e-16

Kind regards, Søren

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


*** --- ***
Christian Hennig
University College London, Department of Statistical Science
Gower St., London WC1E 6BT, phone +44 207 679 1698
chr...@stats.ucl.ac.uk, www.homepages.ucl.ac.uk/~ucakche__
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] nonlinear (especially logistic) regression accounting for spatially correlated errors

2009-12-17 Thread Seth J Myers
 Hello,

Sorry to be a bit longwinded, but I've struggled quite a bit with the following 
over the last few days.  I've read all entries related to spatial 
autocorrelation in R help and haven't found what I'm after.  If it's okay, I'm 
going to first describe my general understanding of the process by which a 
mixed model can account for correlated errors.  If possible, please briefly 
point out any misunderstanding I have to help my work overall (the literature 
I've found on this area does not go into extensive explanation).

I'm aware that mixed models are currently in use to fit fixed effects while 
controlling for correlation among residuals.  I believe this is often done by 
specifying a theoretical variogram that one believes describes the spatial 
structure of the error correlation and which is then used to modify the 
variance-covariance error matrix that is used in model fitting (which I think 
in this case would be block diagonal with distance input into chosen variogram 
model determining matrix element value).  So, as the fixed effects are adjusted 
algorithmically to maximize likelihood, simultaneously the parameters of the 
theoretical variogram (which enter as a random effect) are similarly adjusted 
which in turn influences the variance-covariance error matrix.  The combined 
goal of these two parallel adjustments (I believe) would be to maximize overall 
model likelihood.

I have been looking for an example of R code that uses a nonlinear mixed model 
in this way.  I've only found this so far.

http://www.ats.ucla.edu/stat/r/faq/spatial_regression.htm

It seems that in the example given in this link, the incorporated correlation 
structure is not specifically on the error term but instead on the reponse 
itself.  Therefore, it seems that the effect of the explanatory variable is 
diluted by this approach.  For instance, if you had a 'true' model where 
temperature was only a function of elevation but elevation was strongly 
autocorrelated, the approach in the link would likely leave elevation as a 
nonsignificant part of the model.  Versus, if the correlation structure was 
assigned to model error this would not happen.  Is this true or am I speaking 
of 6 of one and half dozen of the other (that in practice it makes no 
difference to results)?

If the above example is not an example of modeling the correlation among model 
errors, is there a good example of R code somewhere that does this that I can 
reference?

Thanks, Seth Myers

PS I plan to read all the excellent books suggested in other threads, but ask 
this now to help me digest this material more quickly.

[[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] Exchange NAs for mean

2009-12-17 Thread Joel Fürstenberg-Hägg

Hi all,

 

I'm have a matrix (X) with observations as rows and parameters as columns. I'm 
trying to exchange all missing values in a column by the column mean using the 
code below, but so far, nothing happens with the NAs... Can anyone see where 
the problem is?

 

N<-nrow(X) # Calculate number of rows = 108
p<-ncol(X) # Calculate number of columns = 88
   

# Replace by columnwise mean
for (i in colnames(X)) # Do for all columns in the matrix
{ 
   for (j in rownames(X)) # Go through all rows
   {
  if(is.na(X[j,i])) # Search for missing value in the given position
  {
 X[j,i]=mean(X[1:p, i]) # Change missing value to the mean of the column
  }
   }
} 

 

All the best,

 

Joel

 


 
  
_
Hitta hetaste singlarna på MSN Dejting!
http://dejting.se.msn.com/channel/index.aspx?trackingid=1002952
[[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] Exchange NAs for mean

2009-12-17 Thread Barry Rowlingson
2009/12/17 Joel Fürstenberg-Hägg :
>
> Hi all,
>
>
>
> I'm have a matrix (X) with observations as rows and parameters as columns. 
> I'm trying to exchange all missing values in a column by the column mean 
> using the code below, but so far, nothing happens with the NAs... Can anyone 
> see where the problem is?
>
>
>
> N<-nrow(X) # Calculate number of rows = 108
> p<-ncol(X) # Calculate number of columns = 88
>
>
> # Replace by columnwise mean
> for (i in colnames(X)) # Do for all columns in the matrix
> {
>   for (j in rownames(X)) # Go through all rows
>   {
>      if(is.na(X[j,i])) # Search for missing value in the given position
>      {
>         X[j,i]=mean(X[1:p, i]) # Change missing value to the mean of the 
> column
>      }
>   }
> }
>


 mean(anything with an NA in it) == NA. You want mean(X[1:p,i],na.rm=TRUE)

 > mean(c(1,2,3,NA,4))
 [1] NA
 > mean(c(1,2,3,NA,4),na.rm=TRUE)
 [1] 2.5

I'll leave it to someone else to show you how to speed this code up by
removing the loops...

Barry

__
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] Exchange NAs for mean

2009-12-17 Thread Chuck Cleland
On 12/17/2009 9:31 AM, Joel Fürstenberg-Hägg wrote:
> Hi all,
> 
>  
> 
> I'm have a matrix (X) with observations as rows and parameters as columns. 
> I'm trying to exchange all missing values in a column by the column mean 
> using the code below, but so far, nothing happens with the NAs... Can anyone 
> see where the problem is?
> 
>  
> 
> N<-nrow(X) # Calculate number of rows = 108
> p<-ncol(X) # Calculate number of columns = 88
>
> 
> # Replace by columnwise mean
> for (i in colnames(X)) # Do for all columns in the matrix
> { 
>for (j in rownames(X)) # Go through all rows
>{
>   if(is.na(X[j,i])) # Search for missing value in the given position
>   {
>  X[j,i]=mean(X[1:p, i]) # Change missing value to the mean of the 
> column
>   }
>}
> } 

> mymat <- matrix(runif(50), ncol=5)

> mymat[c(3,4,9),c(1,2,5)] <- NA

> mymat
[,1]   [,2]   [,3]   [,4]  [,5]
 [1,] 0.05863667 0.23545794 0.25549983 0.96275422 0.1015316
 [2,] 0.66107818 0.15846239 0.05112992 0.09081990 0.6097318
 [3,] NA NA 0.86474629 0.73186676NA
 [4,] NA NA 0.26226776 0.31987242NA
 [5,] 0.78472732 0.09072242 0.24557669 0.57100857 0.1568413
 [6,] 0.42431343 0.37551338 0.86085073 0.62782597 0.5090823
 [7,] 0.44609972 0.90125504 0.52285650 0.41298482 0.3192929
 [8,] 0.27676684 0.17200162 0.70648140 0.86983249 0.2035595
 [9,] NA NA 0.34956846 0.07070571NA
[10,] 0.01482263 0.20074897 0.41553916 0.82367719 0.9674044

> apply(mymat, 2, function(x){x <- replace(x, is.na(x), mean(x,
na.rm=TRUE))})
[,1]   [,2]   [,3]   [,4]  [,5]
 [1,] 0.05863667 0.23545794 0.25549983 0.96275422 0.1015316
 [2,] 0.66107818 0.15846239 0.05112992 0.09081990 0.6097318
 [3,] 0.38092069 0.30488025 0.86474629 0.73186676 0.4096348
 [4,] 0.38092069 0.30488025 0.26226776 0.31987242 0.4096348
 [5,] 0.78472732 0.09072242 0.24557669 0.57100857 0.1568413
 [6,] 0.42431343 0.37551338 0.86085073 0.62782597 0.5090823
 [7,] 0.44609972 0.90125504 0.52285650 0.41298482 0.3192929
 [8,] 0.27676684 0.17200162 0.70648140 0.86983249 0.2035595
 [9,] 0.38092069 0.30488025 0.34956846 0.07070571 0.4096348
[10,] 0.01482263 0.20074897 0.41553916 0.82367719 0.9674044

> All the best,
> 
>  
> 
> Joel
> 
>  
> 
> 
>  
> 
> _
> Hitta hetaste singlarna på MSN Dejting!
> http://dejting.se.msn.com/channel/index.aspx?trackingid=1002952
>   [[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.


-- 
Chuck Cleland, Ph.D.
NDRI, Inc. (www.ndri.org)
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 512-0171 (M, W, F)
fax: (917) 438-0894

__
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] Exchange NAs for mean

2009-12-17 Thread Paul Hiemstra

Barry Rowlingson wrote:

2009/12/17 Joel Fürstenberg-Hägg :
  

Hi all,



I'm have a matrix (X) with observations as rows and parameters as columns. I'm 
trying to exchange all missing values in a column by the column mean using the 
code below, but so far, nothing happens with the NAs... Can anyone see where 
the problem is?



N<-nrow(X) # Calculate number of rows = 108
p<-ncol(X) # Calculate number of columns = 88


# Replace by columnwise mean
for (i in colnames(X)) # Do for all columns in the matrix
{
  for (j in rownames(X)) # Go through all rows
  {
 if(is.na(X[j,i])) # Search for missing value in the given position
 {
X[j,i]=mean(X[1:p, i]) # Change missing value to the mean of the column
 }
  }
}





 mean(anything with an NA in it) == NA. You want mean(X[1:p,i],na.rm=TRUE)

 > mean(c(1,2,3,NA,4))
 [1] NA
 > mean(c(1,2,3,NA,4),na.rm=TRUE)
 [1] 2.5

I'll leave it to someone else to show you how to speed this code up by
removing the loops...

Barry

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

Hi,

To replace all the NA's in the columns by the column mean do:

# Make example set
X = matrix(runif(25), 5, 5)
# Add some NA's
X[X>0.6] = NA

# Use an apply function, is shorthand for a loop
# Loops over the columns
X2 = apply(X,2,function(column) {
   column[is.na(column)]  = mean(column, na.rm = TRUE)
   return(column)
   })

X
X2

Is this ok barry :).

cheers,
Paul

--
Drs. Paul Hiemstra
Department of Physical Geography
Faculty of Geosciences
University of Utrecht
Heidelberglaan 2
P.O. Box 80.115
3508 TC Utrecht
Phone:  +3130 274 3113 Mon-Tue
Phone:  +3130 253 5773 Wed-Fri
http://intamap.geo.uu.nl/~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.


[R] unable to run JGR in windows 7

2009-12-17 Thread Krishna
Hi,

I installed JGR as decribed on website along with all supporting packages. But 
when i start R-software JGR doesnt start. if i type "library(JGR)" in front r 
prompt, the following error is displayed.

> library(JGR)
Loading required package: iplots
Error in .jinit() : unable to find the basic String class
Error: package 'iplots' could not be loaded

I checked and re-installed iplots but still the same message is being 
displayed. i am from a non-it background intend to use for my financial data 
analysis purposes. I am using windows 7 home premium.
request for the attention and support for installin and using JGR
thanks and regards,
krishna
[[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] What is the fastest way to see what are in an RData file?

2009-12-17 Thread Peng Yu
On Thu, Dec 17, 2009 at 5:33 AM, Gustaf Rydevik
 wrote:
> On Wed, Dec 16, 2009 at 10:13 PM, Peng Yu  wrote:
>>
>> Currently, I load the RData file then ls() and str(). But loading the file
>> takes too long if the file is big. Most of the time, I only interested what
>> the variables are in the the file and the attributes of the variables (like
>> if it is a data.frame, matrix, what are the colnames/rownames, etc.)
>>
>> I'm wondering if there is any facility in R to help me avoid loading the
>> whole file.
>
>
> I thought this was interesting as well, so i did a bit of searching
> through the R-help list archives and found this answer by Simon
> Urbanek:
> https://stat.ethz.ch/pipermail/r-devel/2007-August/046724.html
> The link to a c-routine that does what you want still works, but for
> future reference I'm pasting the code below.

It doesn't work for the RData file that I saved by "save(list='test',
file='test.RData')".

$ rdcopy test.RData
Format version 3ec, R version = 23813.88.84, release = f9db1dba
Sorry, this tool supported RXDR version 2 format only

__
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 spliting a dataframe values

2009-12-17 Thread David Winsemius


On Dec 17, 2009, at 8:11 AM, venkata kirankumar wrote:


Hi all,
Hi this is kiran
I am facing a problem to split a dataframe

that is..
i have a string like:"a,b,c|1,2,3|4,5,6|7,8,8"
first I have to split  with respect to   "|"
I did it with  command

unlist(strsplit("a,b,c|1,2,3|4,5,6|7,8,8", "\\,"))


Removes all the commas, leaves the "pipes".



after getting that set i made it as a dataframe and it comes like

a,b,c
1,2,3
4,5,6
7,8,8


Some other code might have done that, but not the code you offered.  
Why don't you explain why you want to manipulate your data this way  
and provide a self-contained session transcript. Then the helpeRs can  
figure out how to offer sensible alternatives.


--
David.


now i have to split this dataframe with respect to ","  and i have  
to get it

like


a b c
1 2 3
4 5 6
7 8 8


this one i am not able to findout
can any one help me to get it done

thanks in advance
kiran

[[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] cross-product

2009-12-17 Thread Chuck White
Hello -- I am trying to create a dataframe whose rows are the cross product of 
rows in two other dataframes. Here's an example:

A = data.frame(F1=c('1','2','3','2'))
B = data.frame(F2=c('4','5'))
C = data.frame()
for (x in unique(A[,'F1'])) {
C = rbind(C, cbind(F1=x,B))
}

How can I achieve this without the for loop?  Thanks.

__
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] SPLUS Seqtrial vs. R Packages for sequential clinical trials designs

2009-12-17 Thread Paul Miller
Hello Everyone,
 
I’m a SAS user who has recently become interested in sequential clinical 
trials designs. I’ve discovered that the SAS based approaches for these 
designs are either too costly or are “experimental.” So now I’m looking 
for alternative software. Two programs that seem promising are SPLUS Seqtrial 
and R.
 
I recently obtained a 30 day trial for the SPLUS Seqtrial add-on and have 
worked my way through most of the examples in the manual. I’ve also gotten 
access to R, installed a package called gsDesign, and worked through most of 
the examples in its documentation. 
 
Although I don’t yet have a good understanding of the various approaches to 
sequential clinical trials designs, I thought that the gsDesign package seemed 
very impressive. I also understand that there are several other R packages that 
relate to sequential clinical trials designs, such as AGSDest , GroupSeq, 
ldbounds, MChtest, PwrGSD, and Seqmon. Some of these seem fairly comprehensive 
while others seem to focus on a single approach. 
 
My questions center on the adequacy of SPLUS Seqtrial and the R Packages. I was 
wondering if there is anyone out there who would be familiar enough with these 
to comment on their relative merits. Will SPLUS Seqtrial or the R packages 
allow me to do all the designs I’m ever likely to need? If I pay for SPLUS 
Seqtrial, will I get anything that I can’t get using the various R packages? 
Are any of the R packages comprehensive? Or would it at least be possible to 
cover all the types of designs that are commonly used by employing a variety of 
R packages? What kind of validation work generally goes into an R package and 
how would this likely compare to the sort of validation work that has gone into 
Seqtrial?
 
There may be other questions that I should be asking but haven’t thought of. 
 
At any rate, if some of you would be willing to share some advice or insights 
I’d greatly appreciate it.
 
Thanks,
 
Paul


  __
The new Internet Explorer® 8 - Faster, safer, easier.  Optimized for Y
er/
[[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] cross-product

2009-12-17 Thread Marc Schwartz

On Dec 17, 2009, at 9:47 AM, Chuck White wrote:

Hello -- I am trying to create a dataframe whose rows are the cross  
product of rows in two other dataframes. Here's an example:


A = data.frame(F1=c('1','2','3','2'))
B = data.frame(F2=c('4','5'))
C = data.frame()
for (x in unique(A[,'F1'])) {
   C = rbind(C, cbind(F1=x,B))
}

How can I achieve this without the for loop?  Thanks.




See ?merge

> merge(unique(A), B)
  F1 F2
1  1  4
2  2  4
3  3  4
4  1  5
5  2  5
6  3  5


BTW, avoid using 'C' as the name of an object, as C() is a function in  
R. R will typically know the difference, but it is a good defensive  
programming habit to avoid assigning objects to pre-existing function  
names.


HTH,

Marc Schwartz

__
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] StructTS standard errors

2009-12-17 Thread Giovanni Petris

Hello,

Does anybody know if (and how) it is possible to obtain standard errors of 
estimated variances from StructTS? (R 2.10.0).

Thank you in advance,
Giovanni

__
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] Error for making packages under windows XP-Error in library.dynam(lib, package, package.lib)

2009-12-17 Thread rusers.sh
Dear Duncan,
  I just followed an example to try making a package. The problem is really
on the useDynLib. It works after i delete it.
 Thanks a lot.

2009/12/17 Duncan Murdoch 

> rusers.sh wrote:
>
>> Hi,
>>  I have installed the necessary tools for making a R package under windows
>> and am sure these tool have been correctly configured. I am very new to
>> try
>> writing a package, so the error may be very obvious for you. Forgive me if
>> it is too easy.
>>  My package name is *stam*, and i put it under the folder
>> "D:/StatSoft/R/MyPackage/". I have two folders,*R* and *man*. Besides, i
>> also have *description* and *namespace** *files. It is a very simple beta
>> package.
>>
>>
>
> The DESCRIPTION and NAMESPACE files should be specified in upper case, but
> that's probably not your problem.  I would guess you have a command that
> says to load a shared library, e.g. a useDynLib statement in your NAMESPACE,
> or a library.dynam in a .First() function.  Just delete it, without compiled
> code (which would be kept in the src directory) you don't need it.
>
> Duncan Murdoch
>
>   Following is the error after using "R CMD check mypackage". Thanks very
>> much.
>> #
>> * using log directory 'D:/StatSoft/R/MyPackage/stam.Rcheck'
>> * using R version 2.10.0 (2009-10-26)
>> * using session charset: ISO8859-1
>> * checking for file 'stam/DESCRIPTION' ... OK
>> * this is package 'stam' version '1.0-0'
>> * checking package name space information ... OK
>> * checking package dependencies ... OK
>> * checking if this is a source package ... OK
>> * checking for executable files ... OK
>> * checking whether package 'stam' can be installed ... OK
>> * checking package directory ... OK
>> * checking for portable file names ... OK
>> * checking DESCRIPTION meta-information ... OK
>> * checking top-level files ... OK
>> * checking index information ... OK
>> * checking package subdirectories ... OK
>> * checking R files for non-ASCII characters ... OK
>> * checking R files for syntax errors ... OK
>> * checking whether the package can be loaded ... ERROR
>> Error in library.dynam(lib, package, package.lib) :
>>  shared library 'stam' not found
>> Error: package/namespace load failed for 'stam'
>> Execution halted
>>
>> It looks like this package has a loading problem: see the messages for
>> details.
>>
>> #
>>
>>
>>
>
>


-- 
-
Jane Chang
Queen's

[[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 to import data from excel to R

2009-12-17 Thread sta_2279
Hi,
   I am using R and I want to know how data can be transferred from Excel
Spread sheet to R for analyzing. I have done like this

mydata<-read.table("C:\Documents and Settings\admin\Desktop\data.txt");


but its not working how can i do it

  regards

Sarath Sankar V
   Spectrum Softtech Solution

__
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] SPLUS Seqtrial vs. R Packages for sequential clinical trials designs

2009-12-17 Thread David Freedman

You'll probably want to take a look at the CRAN Task View, 
http://cran.r-project.org/web/views/ClinicalTrials.html

david freedman

Paul Miller wrote:
> 
> Hello Everyone,
>  
> I’m a SAS user who has recently become interested in sequential clinical
> trials designs. I’ve discovered that the SAS based approaches for these
> designs are either too costly or are “experimental.” So now I’m
> looking for alternative software. Two programs that seem promising are
> SPLUS Seqtrial and R.
>  
> I recently obtained a 30 day trial for the SPLUS Seqtrial add-on and have
> worked my way through most of the examples in the manual. I’ve also
> gotten access to R, installed a package called gsDesign, and worked
> through most of the examples in its documentation. 
>  
> Although I don’t yet have a good understanding of the various approaches
> to sequential clinical trials designs, I thought that the gsDesign package
> seemed very impressive. I also understand that there are several other R
> packages that relate to sequential clinical trials designs, such as
> AGSDest , GroupSeq, ldbounds, MChtest, PwrGSD, and Seqmon. Some of these
> seem fairly comprehensive while others seem to focus on a single approach. 
>  
> My questions center on the adequacy of SPLUS Seqtrial and the R Packages.
> I was wondering if there is anyone out there who would be familiar enough
> with these to comment on their relative merits. Will SPLUS Seqtrial or the
> R packages allow me to do all the designs I’m ever likely to need? If I
> pay for SPLUS Seqtrial, will I get anything that I can’t get using the
> various R packages? Are any of the R packages comprehensive? Or would it
> at least be possible to cover all the types of designs that are commonly
> used by employing a variety of R packages? What kind of validation work
> generally goes into an R package and how would this likely compare to the
> sort of validation work that has gone into Seqtrial?
>  
> There may be other questions that I should be asking but haven’t thought
> of. 
>  
> At any rate, if some of you would be willing to share some advice or
> insights I’d greatly appreciate it.
>  
> Thanks,
>  
> Paul
> 
> 
>   __
> The new Internet Explorer® 8 - Faster, safer, easier.  Optimized for Y
> er/
>   [[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.
> 
> 

-- 
View this message in context: 
http://n4.nabble.com/SPLUS-Seqtrial-vs-R-Packages-for-sequential-clinical-trials-designs-tp966071p966780.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 import data from excel to R

2009-12-17 Thread Richardson, Patrick
Well, first of all it doesn't look like you're trying to read an excel file as 
the file you are trying you specify is "data.txt" not "data.xls".

Try:

library(gdata)
?read.xls

HTH,

Patrick




-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of sta_2...@spectrum.net.in
Sent: Thursday, December 17, 2009 12:25 PM
To: r-help@r-project.org
Subject: [R] how to import data from excel to R

Hi,
   I am using R and I want to know how data can be transferred from Excel
Spread sheet to R for analyzing. I have done like this

mydata<-read.table("C:\Documents and Settings\admin\Desktop\data.txt");


but its not working how can i do it

  regards

Sarath Sankar V
   Spectrum Softtech Solution

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
This email message, including any attachments, is for th...{{dropped:6}}

__
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 import data from excel to R

2009-12-17 Thread Joshua Wiley
Hey,

If you want to read it in as a text file, make sure to have Excel save it as
a text file first.  For instance, a tab delimited text file.  Then you could
read it in with

mydata <- read.table("myfile.txt", sep="\t")

HTH,

Josh

On Thu, Dec 17, 2009 at 9:24 AM,  wrote:

> Hi,
>   I am using R and I want to know how data can be transferred from Excel
> Spread sheet to R for analyzing. I have done like this
>
> mydata<-read.table("C:\Documents and Settings\admin\Desktop\data.txt");
>
>
> but its not working how can i do it
>
>  regards
>
>Sarath Sankar V
>   Spectrum Softtech Solution
>
> __
> 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.
>



-- 
Joshua Wiley
Senior in Psychology
University of California, Riverside
http://www.joshuawiley.com/

[[alternative HTML version deleted]]

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


[R] R on amazon's EC2 "cloud"?

2009-12-17 Thread Blair Christian
Hi All,

I was wondering if anybody had experience running R on amazon's ec2
"cloud"?  More specifically, has anybody created an "amazon machine
image" (AMI) for use with it?  I was wondering if there was a quantian
type image available as an amazon machine image, maybe running debian
or ubuntu?   It supports open MPI among other libs which is nice.

It would be nice to put together a hardware optimized image that the
community could use (eg lapack with openmp blas support that kind of
thing), maybe a debian with no X installed, but including R + all
packages?

http://aws.amazon.com/ec2/#pricing

I'm at the point where it's almost easier/cost effective to outsource
the hardware...

I bring this up because I saw that they were going to start a spot
market for cycles- useful for things like MCMC chains that need lots
of runs...
http://bit.ly/8A2e1g

__
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 import data from excel to R

2009-12-17 Thread milton ruser
Hi Sarath, try

"C:\\Documents and Settings\\admin\\Desktop\\data.txt"
or
"C:/Documents and Settings/admin/Desktop/data.txt"

or yet

setwd("your path")
mydata<-read.table("data.txt")
cheers

miltinho

On Thu, Dec 17, 2009 at 12:24 PM,  wrote:

> Hi,
>   I am using R and I want to know how data can be transferred from Excel
> Spread sheet to R for analyzing. I have done like this
>
> mydata<-read.table("C:\Documents and Settings\admin\Desktop\data.txt");
>
>
> but its not working how can i do it
>
>  regards
>
>Sarath Sankar V
>   Spectrum Softtech Solution
>
> __
> 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] R on amazon's EC2 "cloud"?

2009-12-17 Thread Roy Mendelssohn
Go to:

http://biocep-distrib.r-forge.r-project.org/


Choose "documentation", scroll own you will see a section called:

"Biocep-R on Amazon's Cloud"

-roy M.

On Dec 17, 2009, at 9:55 AM, Blair Christian wrote:

> Hi All,
> 
> I was wondering if anybody had experience running R on amazon's ec2
> "cloud"?  More specifically, has anybody created an "amazon machine
> image" (AMI) for use with it?  I was wondering if there was a quantian
> type image available as an amazon machine image, maybe running debian
> or ubuntu?   It supports open MPI among other libs which is nice.
> 
> It would be nice to put together a hardware optimized image that the
> community could use (eg lapack with openmp blas support that kind of
> thing), maybe a debian with no X installed, but including R + all
> packages?
> 
> http://aws.amazon.com/ec2/#pricing
> 
> I'm at the point where it's almost easier/cost effective to outsource
> the hardware...
> 
> I bring this up because I saw that they were going to start a spot
> market for cycles- useful for things like MCMC chains that need lots
> of runs...
> http://bit.ly/8A2e1g
> 
> __
> 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.

**
"The contents of this message do not reflect any position of the U.S. 
Government or NOAA."
**
Roy Mendelssohn
Supervisory Operations Research Analyst
NOAA/NMFS
Environmental Research Division
Southwest Fisheries Science Center
1352 Lighthouse Avenue
Pacific Grove, CA 93950-2097

e-mail: roy.mendelss...@noaa.gov (Note new e-mail address)
voice: (831)-648-9029
fax: (831)-648-8440
www: http://www.pfeg.noaa.gov/

"Old age and treachery will overcome youth and skill."
"From those who have been given much, much will be expected" 

__
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] R on amazon's EC2 "cloud"?

2009-12-17 Thread Dirk Eddelbuettel

On 17 December 2009 at 12:55, Blair Christian wrote:
| Hi All,
| 
| I was wondering if anybody had experience running R on amazon's ec2
| "cloud"?  More specifically, has anybody created an "amazon machine
| image" (AMI) for use with it?  I was wondering if there was a quantian
| type image available as an amazon machine image, maybe running debian
| or ubuntu?   It supports open MPI among other libs which is nice.
| 
| It would be nice to put together a hardware optimized image that the
| community could use (eg lapack with openmp blas support that kind of
| thing), maybe a debian with no X installed, but including R + all
| packages?

Ubuntu has been supporting AMIs for a while, one decent link may be

   https://help.ubuntu.com/community/EC2StartersGuide

The most recent Ubuntu release contains the REvolution R + Canonical
cooperation comprising the Intel MKLs which should be faster than Atlas.

Dirk

-- 
Three out of two people have difficulties with fractions.

__
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 import data from excel to R

2009-12-17 Thread David Winsemius


On Dec 17, 2009, at 11:24 AM, sta_2...@spectrum.net.in wrote:


Hi,
  I am using R and I want to know how data can be transferred from  
Excel

Spread sheet to R for analyzing. I have done like this

mydata<-read.table("C:\Documents and Settings\admin\Desktop 
\data.txt");



but its not working how can i do it


You've gotten three distinct suggestions, all of which are probably  
needed and none of which would completely fill in the missing aspects  
of your R-knowledge needed for success:


a) reading xls formatted files is possible with quite a few special  
functions possibly requiring importing packages.

b) reading exported tab or comma delimited files is possible.
c) your file specification would not have succeeded.
d) you did not report the full error message which suggests the you  
should now read the Posting Guide more thoroughly.
e) you should read the documentation in the Import Export Manual.  
(This is probably also illustrated in several of the introductory  
manuals, and we expect you to read at least one before posting  
questions.


Do some homework and then you should have an increase in your store of  
knowledge.


--
David.



 regards

   Sarath Sankar V
  Spectrum Softtech  
Solution


__
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] SPLUS Seqtrial vs. R Packages for sequential clinical trials designs

2009-12-17 Thread Marc Schwartz

On Dec 17, 2009, at 9:58 AM, Paul Miller wrote:


Hello Everyone,

I’m a SAS user who has recently become interested in sequential  
clinical trials designs. I’ve discovered that the SAS based  
approaches for these designs are either too costly or are  
“experimental.” So now I’m looking for alternative software. Two  
programs that seem promising are SPLUS Seqtrial and R.


I recently obtained a 30 day trial for the SPLUS Seqtrial add-on and  
have worked my way through most of the examples in the manual. I’ve  
also gotten access to R, installed a package called gsDesign, and  
worked through most of the examples in its documentation.


Although I don’t yet have a good understanding of the various  
approaches to sequential clinical trials designs, I thought that the  
gsDesign package seemed very impressive. I also understand that  
there are several other R packages that relate to sequential  
clinical trials designs, such as AGSDest , GroupSeq, ldbounds,  
MChtest, PwrGSD, and Seqmon. Some of these seem fairly comprehensive  
while others seem to focus on a single approach.


My questions center on the adequacy of SPLUS Seqtrial and the R  
Packages. I was wondering if there is anyone out there who would be  
familiar enough with these to comment on their relative merits. Will  
SPLUS Seqtrial or the R packages allow me to do all the designs I’m  
ever likely to need? If I pay for SPLUS Seqtrial, will I get  
anything that I can’t get using the various R packages? Are any of  
the R packages comprehensive? Or would it at least be possible to  
cover all the types of designs that are commonly used by employing a  
variety of R packages? What kind of validation work generally goes  
into an R package and how would this likely compare to the sort of  
validation work that has gone into Seqtrial?


There may be other questions that I should be asking but haven’t  
thought of.


At any rate, if some of you would be willing to share some advice or  
insights I’d greatly appreciate it.


Thanks,

Paul




In addition to David's pointer to the relevant CRAN Task View, I would  
point you to the following document, which is applicable to R ("Base  
R" and "Recommended Packages" only):


  http://www.r-project.org/doc/R-FDA.pdf

It does not however, apply to user contributed packages (on CRAN or  
elsewhere).


When it comes to validation, the majority of the burden is on you and  
not on the vendor. The vendor can document their own SDLC and the  
document above covers R's, within the regulatory domain of clinical  
trials (eg. 21 CFR 11, etc.). However, you cannot validate software in  
a vacuum, so you must implement that process as appropriate for your  
own shop.


For user contributed packages, you will want to consider communicating  
with the package authors/maintainers on their SDLC. Some will no doubt  
be better than others and only you can make the risk/benefit  
assessment along with your implementing the requisite internal IQ/OQ/ 
PQ procedures.


From purely a functional comparison perspective, you would need to  
list the functionality of the S+ SeqTrial product and then compare it  
with the functionality available in R and the user contributed  
packages. Only you can make the 'value judgement' as to cost versus  
functionality.


It is impossible to project into the future to know what potential  
trial designs you may encounter in your work. It is also impossible to  
know what new techniques (especially for adaptive designs) may become  
available moving forward.


If you search the list archives, using keywords such as SAS or FDA,  
you will find a plethora of discussions on the general topics of R  
versus SAS, etc. You will also see many discussions on R and clinical  
trials, including many of the misconceptions regarding validation and  
the FDA (which BTW, uses R internally).


As a SAS user, on a more general level, you may find the following  
book to be helpful in moving to R:


  R for SAS and SPSS Users
  Robert A. Muenchen
  http://www.amazon.com/SAS-SPSS-Users-Statistics-Computing/dp/0387094172/


HTH,

Marc Schwartz

__
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] user-written splits in rpart

2009-12-17 Thread Verspagen B (ALGEC)
--- begin original message ---
I am trying to write my own split function for rpart. The aim is to do,
instead of anova, a linear regression to determine the split (minimize
some criterion like sum of rss left and right of the split). The
regression (lm) should simply use the dependent and independent
variables passed to rpart.

I am aware of the example provided in the rpart source code, but
stumbled on similar problems that I saw reported on this list (no final
solution posted, as far as I could see). The problem is, broadly
speaking, that I do not see a way to access the full set of x and y
variables in the user-written split-function.
 end original message ---

 begin reply ---
The rpart routine provides the x variables to a user-written split
function one at a time.  Since the entire structure of rpart --
printing, plotting, tree representation, etc --- is based on the premise
of a single variable driving each split,  what you are asking for would
require an entirely different program.
 end reply ---

I have been reflecting a little bit on this. Perhaps I have been unclear. 
It is fine with me that a single variable "drives" the split, i.e., that we 
partition the data based on the ranking of a single variable. I am not looking 
to change that. 
What I would like to change is the evaluation of that split. In the anova 
implementation of rpart, this evaluation is now done by taking the average of 
the dependent variable (left and right of the split) as a predictor. Instead of 
that, I would like to run a linear regression (left and right of the split) 
involving all x-variabels that were supplied in the call to rpart, and take the 
predictive power of those regressions as the evaluation of the split.
I can't see how that would change the structure of the entire module.

Best regards,

Bart Verspagen

__
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 import data from excel to R

2009-12-17 Thread Gabor Grothendieck
Check out these notes:

http://wiki.r-project.org/rwiki/doku.php?id=tips:data-io:ms_windows

and note that within quotes you must double each backslash so one
writes "c:\\mydirectory\\abc.xls" for example.

On Thu, Dec 17, 2009 at 12:24 PM,   wrote:
> Hi,
>   I am using R and I want to know how data can be transferred from Excel
> Spread sheet to R for analyzing. I have done like this
>
> mydata<-read.table("C:\Documents and Settings\admin\Desktop\data.txt");
>
>
> but its not working how can i do it
>
>                                                      regards
>
>                                                    Sarath Sankar V
>                                               Spectrum Softtech Solution
>
> __
> 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] Remove duplicates from a data frame but with some special requirements

2009-12-17 Thread gcam

Thanks Gray,

This helps, I'd completely forgotten about the subset command.  However, it
doesn't quite get me where I need.  Perhaps an example will help.  I will
simplify my dataframe to the three important variables:

ESR_ref   ESR_ref_editLoaded
1.1  1.1  Y
1.1.11.1  NC
1.1.21.1 Y
2.1   2.1  N
2.1.1 2.1 Y
2.1.22.1  PU
2.1.32.1   Y
3.1   3.1  Y
4.1   4.1  N
4.1.14.1   PU

So I've created the "edit" variable so I can test for duplicates (i.e.
samples with more than one sub-sample) because this is not of interest at
this point.  I just want one subsample per sample.  However, if we consider
2.1 - this would result in a subset (if duplicates were removed) with the
first line which has an "N".  But it is of interest to me the if at least
one of the subsamples has a "Y" then I want that line rather than a
subsample with another code.  1.1 in this example works by default because
the first subsample is a "Y" so it will retain that information.

Thanks

Gareth


Gray Calhoun-2 wrote:
> 
> Hi,
> Try:
> 
> subset(Samps, !duplicated(Samps$ESR_ref_edit) | Samps$Loaded == "Y")
> 
> I'd need specific code to be sure that this is exactly what you want
> (ie you specify input and desired output), but indexing with a logical
> vector is probably going to be the solution.
> 
> Best,
> Gray
> 
> On Wed, Dec 16, 2009 at 7:55 PM, gcam  wrote:
>>
>> Hi all.
>>
>> So I have a data frame with multiple columns/variables.  The first
>> variable
>> is a major sample name for which there are some sub-samples.  Currently I
>> have used the following command to remove the duplicates:
>>
>> Samps_working<-Samps[-c(which(duplicated(Samps$ESR_Ref_edit))),]
>>
>> This removes all of the duplicated sample rows.
>>
>> However, I just realised that, of course, this removes the first
>> observation
>> of each duplicated set.  However, I wish to retain any that have the code
>> "Y" in another variable Samps$Loaded.  I'm at a bit of a loss as to how
>> best
>> to approach this problem.
>>
>> Just to reiterate.  I want to remove all duplicate lines based on sample
>> name, but, I want the lines to be removed with a preference given to
>> those
>> that do not include a "Y" in the Loaded variable column.
>> --
>> View this message in context:
>> http://n4.nabble.com/Remove-duplicates-from-a-data-frame-but-with-some-special-requirements-tp965745p965745.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.
>>
> 
> 
> 
> -- 
> Gray Calhoun
> 
> Assistant Professor of Economics
> Iowa State 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.
> 
> 

-- 
View this message in context: 
http://n4.nabble.com/Remove-duplicates-from-a-data-frame-but-with-some-special-requirements-tp965745p974312.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] forecasting

2009-12-17 Thread DispersionMap


I have some data that i ran a regression on and got the usual r output, with
the a intercept and b coefficient for my independent variable.

i want to forecast the number of future events using these parameters.


What function / packages in R would you recommend to be used in good effect
for these purposes??
-- 
View this message in context: 
http://n4.nabble.com/forecasting-tp974326p974326.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] forecasting

2009-12-17 Thread Stephan Kolassa

?predict

HTH
Stephan

DispersionMap schrieb:


I have some data that i ran a regression on and got the usual r output, with
the a intercept and b coefficient for my independent variable.

i want to forecast the number of future events using these parameters.


What function / packages in R would you recommend to be used in good effect
for these purposes??


__
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 import data from excel to R

2009-12-17 Thread Charlie Sharpsteen
On Thu, Dec 17, 2009 at 9:24 AM,  wrote:
>
> Hi,
>   I am using R and I want to know how data can be transferred from Excel
> Spread sheet to R for analyzing. I have done like this
>
> mydata<-read.table("C:\Documents and Settings\admin\Desktop\data.txt");
>
>
> but its not working how can i do it


The "R Data Import/Export" manual covers this topic in general:

  http://cran.r-project.org/doc/manuals/R-data.html

Chapter 8 concerns getting data into and out of excel.  This post on
the Learning R blog also covers many available options for importing
directly from Excel files:

  
http://learnr.wordpress.com/2009/10/06/export-data-frames-to-multi-worksheet-excel-file/

Hope this helps!

-Charlie

__
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] Sweave Makefile issue

2009-12-17 Thread Luc Villandré

Dear R-specialists,

I am trying to create a Makefile that will first convert all my .Rnw 
files into .tex files and then, that will run the LaTeX compiler to 
produce a pdf document. This issue has been discussed before. Hence, 
I've basically adapted a Makefile I found at 
http://n4.nabble.com/R-Sweave-R-and-complex-latex-projects-td810020.html#a810023 
to make it compatible with a Windows XP environment. You will find my 
version of it at the end of this message.


However, it's not doing what I expect it to do. Instead of only using 
pdfTeX on "total_article.tex" (which is the file with the necessary 
headers and \include's), it tries to convert all my tex files into pdf, 
which of course cannot be done since only total_article.tex has the 
necessary structure to be understood by the compiler.


What's wrong then with this Makefile (I am using GNU Make 3.81)?

I will be grateful for any help you can provide.
_

MASTER = total_article.pdf

# the master document depends on all of the tex files
Rfile = prepareScript.R
RNWFILES = $(wildcard *.Rnw)
TEXFILES = $(wildcard *.tex)
DEPENDS = $(patsubst %.Rnw,%.tex,$(RNWFILES)) $(TEXFILES)

RERUN = "(There were undefined references|Rerun to get 
(citations|cross-references|the bars) (correct|right)|Table widths have 
changed. Rerun LaTeX.|Linenumber reference failed)"

RERUNBIB = "No file.*\.bbl|Citation.*undefined"

all : $(MASTER)

$(MASTER) : $(DEPENDS)

%.tex : %.Rnw

   SWEAVE '$<'

%.pdf : %.tex

   @pdflatex $<
   @egrep -c $(RERUNBIB) $*.log && (bibtex $*;pdflatex $<); true
   @egrep $(RERUN) $*.log && (pdflatex $<) ; true
   @egrep $(RERUN) $*.log && (pdflatex $<) ; true

clean:
   @del *.aux *.log *.bbl *.blg *.brf *.cb *.ind *.idx *.ilg  \
 *.inx *.ps *.dvi *.toc *.out *.lot *~ *.lof *.ttt *.fff \
 *.eps *.pdf
   @del -f $(patsubst %.Rnw,%.tex,$(RNWFILES))
  
script :

   Rcmd BATCH $(Rfile)

--

*Luc Villandré*
/Biostatistician
MUHC-MCH Research 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] Problem reading binaries created with fortran

2009-12-17 Thread kapo coulibaly
Is it possible to read fortran binaries with R? I tried unsucessfully and my
understanding is that fortran write binaries with leading and trailing
bytes. I get numbers but not the right ones.
Thanks

ps: the binary I'm interested in reading is a MODFLOW output with a mix of
character, double and integers.

[[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 reading binaries created with fortran

2009-12-17 Thread Duncan Murdoch

On 17/12/2009 3:48 PM, kapo coulibaly wrote:

Is it possible to read fortran binaries with R? I tried unsucessfully and my
understanding is that fortran write binaries with leading and trailing
bytes. I get numbers but not the right ones.
Thanks

ps: the binary I'm interested in reading is a MODFLOW output with a mix of
character, double and integers.


R can read most binary files, as long as you tell it the right format to 
read.  You need to consult the documentation of the program that 
produced the file to find out the format.  If it adds leading or 
trailing bytes, just tell R to skip over those --- but you need to know 
how much to skip.


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] Problem reading binaries created with fortran

2009-12-17 Thread Duncan Murdoch

On 17/12/2009 3:48 PM, kapo coulibaly wrote:

Is it possible to read fortran binaries with R? I tried unsucessfully and my
understanding is that fortran write binaries with leading and trailing
bytes. I get numbers but not the right ones.
Thanks

ps: the binary I'm interested in reading is a MODFLOW output with a mix of
character, double and integers.


One other thing:  the hexView package does a very nice job of displaying 
the file, so you can work out what the structure is if the documentation 
is unclear (or nonexistent).


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] ROracle on Windows Vista?

2009-12-17 Thread cstrato

Dear All,

Does anybody know whether the package ROracle_0.5-9 does compile and run 
on Windows Vista?

(Since I do not have Oracle I am not able to test this myself.)

I have tried to contact the maintainer of ROracle but it seems that the 
email address is no longer valid.


Best regards
Christian
_._._._._._._._._._._._._._._._._._
C.h.r.i.s.t.i.a.n   S.t.r.a.t.o.w.a
V.i.e.n.n.a   A.u.s.t.r.i.a
e.m.a.i.l:cstrato at aon.at
_._._._._._._._._._._._._._._._._._

__
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 import data from excel to R

2009-12-17 Thread Steve Taylor
Or copy a rectangle of data in Excel, then grab it from the clipboard in R as 
follows:
 
  my.data <- read.table("clipboard",head=TRUE,sep='\t')
cheers,
   Steve
 

[[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] Sweave Makefile issue

2009-12-17 Thread Gray Calhoun
Hi Luc,

  I haven't been actively participating in this list for that long, so
I may be wrong here... but I suspect that debugging makefiles is a bit
off topic.  Two quick points that might help: You probably want to use
"R CMD texi2dvi" on your tex files instead of pdflatex; and you'll
probably have better luck finding the dependency error in your
Makefile if you remove all of the variables (especially with
$(wildcard ...)) and create a simplistic directory structure.  Once
you get that working, you can build back up.  Using Sweave generated
LaTeX files as dependencies for other LaTeX files may be problematic
even when you get this issue sorted out (I'm not familiar enough with
Sweave to know if you can strip out the preamble, etc.)

Best,
Gray


On Thu, Dec 17, 2009 at 2:19 PM, Luc Villandré
 wrote:
> Dear R-specialists,
>
> I am trying to create a Makefile that will first convert all my .Rnw files
> into .tex files and then, that will run the LaTeX compiler to produce a pdf
> document. This issue has been discussed before. Hence, I've basically
> adapted a Makefile I found at
> http://n4.nabble.com/R-Sweave-R-and-complex-latex-projects-td810020.html#a810023
> to make it compatible with a Windows XP environment. You will find my
> version of it at the end of this message.
>
> However, it's not doing what I expect it to do. Instead of only using pdfTeX
> on "total_article.tex" (which is the file with the necessary headers and
> \include's), it tries to convert all my tex files into pdf, which of course
> cannot be done since only total_article.tex has the necessary structure to
> be understood by the compiler.
>
> What's wrong then with this Makefile (I am using GNU Make 3.81)?
>
> I will be grateful for any help you can provide.
> _
>
> MASTER = total_article.pdf
>
> # the master document depends on all of the tex files
> Rfile = prepareScript.R
> RNWFILES = $(wildcard *.Rnw)
> TEXFILES = $(wildcard *.tex)
> DEPENDS = $(patsubst %.Rnw,%.tex,$(RNWFILES)) $(TEXFILES)
>
> RERUN = "(There were undefined references|Rerun to get
> (citations|cross-references|the bars) (correct|right)|Table widths have
> changed. Rerun LaTeX.|Linenumber reference failed)"
> RERUNBIB = "No file.*\.bbl|Citation.*undefined"
>
> all : $(MASTER)
>
> $(MASTER) : $(DEPENDS)
>
> %.tex : %.Rnw
>
>   SWEAVE '$<'
>
> %.pdf : %.tex
>
>   @pdflatex $<
>   @egrep -c $(RERUNBIB) $*.log && (bibtex $*;pdflatex $<); true
>   @egrep $(RERUN) $*.log && (pdflatex $<) ; true
>   @egrep $(RERUN) $*.log && (pdflatex $<) ; true
>
> clean:
>   @del *.aux *.log *.bbl *.blg *.brf *.cb *.ind *.idx *.ilg  \
>         *.inx *.ps *.dvi *.toc *.out *.lot *~ *.lof *.ttt *.fff \
>         *.eps *.pdf
>   @del -f $(patsubst %.Rnw,%.tex,$(RNWFILES))
>  script :
>   Rcmd BATCH $(Rfile)
>
> --
>
> *Luc Villandré*
> /Biostatistician
> MUHC-MCH Research 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.
>



-- 
Gray Calhoun

Assistant Professor of Economics
Iowa State 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] (no subject)

2009-12-17 Thread Jadoon, Ayesha
Hi

I am really struggling jsut putting the labels on the leaves of my dendrogram.

I have a dendrogram that i create using the hclust/as.dendrogram commands.

I then plot it...but i want to feed a file/list that contains all the labels of 
the leaves of a dendrogram and others

that way if R finds what it is looking for in the left hand column, it will 
simply replace it with what is in the right hand column (the protein 
name/label) under the attribute ("label")...


Please help!

Thanks!
Ayesha
__
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 reading binaries created with fortran (More infos)

2009-12-17 Thread kapo coulibaly
The structure of the file is clear (see below) the first line is made of
integers and doubles with the fifth being a text string followed by arrays
of double precision number.:
int1 int2 double1 double2 text int3 int4 int5
(array of double)

here is an example of file:
1 1 1.0 1.0 "HEAD" 160 224 3
23.4  34.5 ..


I tried to read the first line with readBin (results are copied below):

> zz <- file("heads.hds", "rb")
> readBin(zz,what="integer",n=2)
[1] 1 1
> readBin(zz,what="double",n=2)
[1]  7.812502e-03 6.013470e-154
> readBin(zz,what="character",n=1)
[1] "HEAD "
> readBin(zz,what="integer",n=3)
[1] 14680064655360
>


Thanks





On Thu, Dec 17, 2009 at 3:52 PM, Phil Spector wrote:

> Kapo -
>   You'll get a better response if you tell us what you've already tried,
> and an even better response if you
> can provide a reproducible example.
>
>- Phil Spector
> Statistical Computing Facility
> Department of Statistics
> UC Berkeley
> spec...@stat.berkeley.edu
>
>
>
> On Thu, 17 Dec 2009, kapo coulibaly wrote:
>
>  Is it possible to read fortran binaries with R? I tried unsucessfully and
>> my
>> understanding is that fortran write binaries with leading and trailing
>> bytes. I get numbers but not the right ones.
>> Thanks
>>
>> ps: the binary I'm interested in reading is a MODFLOW output with a mix of
>> character, double and integers.
>>
>>[[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.


Re: [R] Problem reading binaries created with fortran

2009-12-17 Thread kapo coulibaly
Duncan,
I couldn't find clear details about the way fortran writes the binaries. I
was hoping someone here has done it before. But the hexView package seems
like a great idea i'll give it a shot.

Thanks a bunch

On Thu, Dec 17, 2009 at 4:02 PM, Duncan Murdoch wrote:

> On 17/12/2009 3:48 PM, kapo coulibaly wrote:
>
>> Is it possible to read fortran binaries with R? I tried unsucessfully and
>> my
>> understanding is that fortran write binaries with leading and trailing
>> bytes. I get numbers but not the right ones.
>> Thanks
>>
>> ps: the binary I'm interested in reading is a MODFLOW output with a mix of
>> character, double and integers.
>>
>
> One other thing:  the hexView package does a very nice job of displaying
> the file, so you can work out what the structure is if the documentation is
> unclear (or nonexistent).
>
> Duncan Murdoch
>

[[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] Do a log rank test of two group in a fit more with more than 2 groups

2009-12-17 Thread Anh Tran
Hi all,

I'm trying to find a way to get a log-rank and Wilcoxon p-value of two
single groups in a survfit() of coxph model (2 strata covariates). Is there
a quick way to this information? survdiff() does not work with coxph model.

-- 
Regards,
Anh Tran

[[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] Sweave Makefile issue

2009-12-17 Thread Duncan Murdoch

On 17/12/2009 3:19 PM, Luc Villandré wrote:

Dear R-specialists,

I am trying to create a Makefile that will first convert all my .Rnw 
files into .tex files and then, that will run the LaTeX compiler to 
produce a pdf document. This issue has been discussed before. Hence, 
I've basically adapted a Makefile I found at 
http://n4.nabble.com/R-Sweave-R-and-complex-latex-projects-td810020.html#a810023 
to make it compatible with a Windows XP environment. You will find my 
version of it at the end of this message.


It doesn't exactly address your question, but you might also want to 
look at the patchDVI package on R-forge.  It takes a Rnw file as input, 
runs Sweave and some version of latex, then patches the result so that 
reverse search (from the .dvi or a .pdf with synctex) goes back to the 
Rnw file instead of going to the .tex file.


It doesn't address the problem of an output file depending on multiple 
.Rnw files, but it does at least handle the case of one .Rnw being 
included by a master .tex file.  For example, I use something close to 
this in a batch file to process one .Rnw and display the whole thing:


echo library(patchDVI);SweaveMiktex('%2', '%3.tex') | Rterm --slave
yap -1 -s"%1%2" %3.dvi

The arguments are
%1=line number,
%2=filename of .Rnw file,
%3=basename of master file (or of the filename)

Duncan Murdoch



However, it's not doing what I expect it to do. Instead of only using 
pdfTeX on "total_article.tex" (which is the file with the necessary 
headers and \include's), it tries to convert all my tex files into pdf, 
which of course cannot be done since only total_article.tex has the 
necessary structure to be understood by the compiler.


What's wrong then with this Makefile (I am using GNU Make 3.81)?

I will be grateful for any help you can provide.
_

MASTER = total_article.pdf

# the master document depends on all of the tex files
Rfile = prepareScript.R
RNWFILES = $(wildcard *.Rnw)
TEXFILES = $(wildcard *.tex)
DEPENDS = $(patsubst %.Rnw,%.tex,$(RNWFILES)) $(TEXFILES)

RERUN = "(There were undefined references|Rerun to get 
(citations|cross-references|the bars) (correct|right)|Table widths have 
changed. Rerun LaTeX.|Linenumber reference failed)"

RERUNBIB = "No file.*\.bbl|Citation.*undefined"

all : $(MASTER)

$(MASTER) : $(DEPENDS)

%.tex : %.Rnw

SWEAVE '$<'

%.pdf : %.tex

@pdflatex $<
@egrep -c $(RERUNBIB) $*.log && (bibtex $*;pdflatex $<); true
@egrep $(RERUN) $*.log && (pdflatex $<) ; true
@egrep $(RERUN) $*.log && (pdflatex $<) ; true

clean:
@del *.aux *.log *.bbl *.blg *.brf *.cb *.ind *.idx *.ilg  \
  *.inx *.ps *.dvi *.toc *.out *.lot *~ *.lof *.ttt *.fff \
  *.eps *.pdf
@del -f $(patsubst %.Rnw,%.tex,$(RNWFILES))
   
script :

Rcmd BATCH $(Rfile)



__
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 reading binaries created with fortran (More infos)

2009-12-17 Thread Duncan Murdoch

On 17/12/2009 4:30 PM, kapo coulibaly wrote:

The structure of the file is clear (see below) the first line is made of
integers and doubles with the fifth being a text string followed by arrays
of double precision number.:
int1 int2 double1 double2 text int3 int4 int5
(array of double)

here is an example of file:
1 1 1.0 1.0 "HEAD" 160 224 3
23.4  34.5 ..


That's not the file that readBin is reading, that's the output from 
something that knows how to read it.  If you show us the hex dump from 
hexView, it's likely we can suggest what to do to read it, especially 
knowing the above output.


Duncan Murdoch




I tried to read the first line with readBin (results are copied below):


zz <- file("heads.hds", "rb")
readBin(zz,what="integer",n=2)

[1] 1 1

readBin(zz,what="double",n=2)

[1]  7.812502e-03 6.013470e-154

readBin(zz,what="character",n=1)

[1] "HEAD "

readBin(zz,what="integer",n=3)

[1] 14680064655360


Thanks





On Thu, Dec 17, 2009 at 3:52 PM, Phil Spector wrote:


Kapo -
  You'll get a better response if you tell us what you've already tried,
and an even better response if you
can provide a reproducible example.

   - Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
spec...@stat.berkeley.edu



On Thu, 17 Dec 2009, kapo coulibaly wrote:

 Is it possible to read fortran binaries with R? I tried unsucessfully and

my
understanding is that fortran write binaries with leading and trailing
bytes. I get numbers but not the right ones.
Thanks

ps: the binary I'm interested in reading is a MODFLOW output with a mix of
character, double and integers.

   [[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@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] poly() with unnormalized values

2009-12-17 Thread Michael Friendly
How can I get the result of, e.g., poly(1:3. degree=2) to give me the 
unnormalized integer coefficients

usually used to explain orthogonal polynomial contrasts, e.g,

-1   1
0  -2
1   1

As I understand things, the columns of x^{1:degree} are first centered 
and then

are normalized by 1/sqrt(col sum of squares), but I can't
see how to relate this to what is returned by poly(). 
> poly(1:3, degree=2)

1  2
[1,] -7.071068e-01  0.4082483
[2,] -9.073264e-17 -0.8164966
[3,]  7.071068e-01  0.4082483
attr(,"degree")
[1] 1 2
attr(,"coefs")
attr(,"coefs")$alpha
[1] 2 2

attr(,"coefs")$norm2
[1] 1.000 3.000 2.000 0.667

attr(,"class")
[1] "poly"   "matrix"
>

I've read the code for poly(), but $alpha and $norm2 are undocumented, 
and I still still can't see the inverse

transformation

-Michael

--
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] Problem with spliting a dataframe values

2009-12-17 Thread jim holtman
Does this do what you want.

> x <- "a,b,c|1,2,3|4,5,6|7,8,8"
> x.1 <- strsplit(x, "[|]")
> x.1
[[1]]
[1] "a,b,c" "1,2,3" "4,5,6" "7,8,8"
> x.2 <- lapply(x.1, strsplit, ',')
> x.2
[[1]]
[[1]][[1]]
[1] "a" "b" "c"
[[1]][[2]]
[1] "1" "2" "3"
[[1]][[3]]
[1] "4" "5" "6"
[[1]][[4]]
[1] "7" "8" "8"

> do.call(rbind, x.2[[1]])
 [,1] [,2] [,3]
[1,] "a"  "b"  "c"
[2,] "1"  "2"  "3"
[3,] "4"  "5"  "6"
[4,] "7"  "8"  "8"
>


On Thu, Dec 17, 2009 at 9:11 AM, venkata kirankumar
wrote:

> Hi all,
> Hi this is kiran
> I am facing a problem to split a dataframe
>
> that is..
>  i have a string like:"a,b,c|1,2,3|4,5,6|7,8,8"
> first I have to split  with respect to   "|"
> I did it with  command
>
> unlist(strsplit("a,b,c|1,2,3|4,5,6|7,8,8", "\\,"))
>
>
> after getting that set i made it as a dataframe and it comes like
>
> a,b,c
> 1,2,3
> 4,5,6
> 7,8,8
>
> now i have to split this dataframe with respect to ","  and i have to get
> it
> like
>
>
> a b c
> 1 2 3
> 4 5 6
> 7 8 8
>
>
> this one i am not able to findout
> can any one help me to get it done
>
> thanks in advance
> kiran
>
>[[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] to remove an error with log(zero)

2009-12-17 Thread Moohwan Kim
Dear R family

I have an arbitrary column vector.
1
2
4
0
7
5
0
0
0
9
11
12
When I attempt to take natural logarithm of the series, as you guess
there is an error message. To overcome this problem, my idea is to
replace a zero or zeros in a row with appropriate numbers.
In order to implement it, I need to detect where zeros are.
Then I am going to take the average of two adjacent neighbors. In the
case of zeros in a row, I guess I might apply the above idea
sequentially.

Would you help me out to escape from this jungle?
Thanks in advance.

Best
Moohwan

__
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] to remove an error with log(zero)

2009-12-17 Thread jim holtman
Does this do what you want:

> x
 [1]  1  2  4  0  7  5  0  0  0  9 11 12
> # create a matrix with the first column being a sequence number
> x.mat <- cbind(seq(length(x)), x)
> # remove zeros in second column
> x.mat <- x.mat[x.mat[,2] != 0,]
> x.mat
 x
[1,]  1  1
[2,]  2  2
[3,]  3  4
[4,]  5  7
[5,]  6  5
[6,] 10  9
[7,] 11 11
[8,] 12 12
> # now create an approxfun to interprete missing values
> x.fun <- approxfun(x.mat[,1], x.mat[,2])
> # now fill out a new matrix with interpreted values
> x.new <- cbind(seq(length(x)), x.fun(seq(length(x
> x.new
  [,1] [,2]
 [1,]1  1.0
 [2,]2  2.0
 [3,]3  4.0
 [4,]4  5.5
 [5,]5  7.0
 [6,]6  5.0
 [7,]7  6.0
 [8,]8  7.0
 [9,]9  8.0
[10,]   10  9.0
[11,]   11 11.0
[12,]   12 12.0
>


On Thu, Dec 17, 2009 at 8:16 PM, Moohwan Kim  wrote:

> Dear R family
>
> I have an arbitrary column vector.
> 1
> 2
> 4
> 0
> 7
> 5
> 0
> 0
> 0
> 9
> 11
> 12
> When I attempt to take natural logarithm of the series, as you guess
> there is an error message. To overcome this problem, my idea is to
> replace a zero or zeros in a row with appropriate numbers.
> In order to implement it, I need to detect where zeros are.
> Then I am going to take the average of two adjacent neighbors. In the
> case of zeros in a row, I guess I might apply the above idea
> sequentially.
>
> Would you help me out to escape from this jungle?
> Thanks in advance.
>
> Best
> Moohwan
>
> __
> 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] Remove duplicates from a data frame but with some special requirements

2009-12-17 Thread Gray Calhoun
The easiest thing might be to just sort on the Loaded column:

 start of example
d <- read.table(textConnection("ESR_ref   ESR_ref_editLoaded
1.1  1.1  Y
1.1.11.1  NC
1.1.21.1 Y
2.1   2.1  N
2.1.1 2.1 Y
2.1.22.1  PU
2.1.32.1   Y
3.1   3.1  Y
4.1   4.1  N
4.1.14.1   PU"), header = TRUE)

d$Loaded <- ordered(d$Loaded, levels = c("Y", "NC", "PU", "N"))
dSorted <- d[order(d$Loaded),]
subset(dSorted, !duplicated(dSorted$ESR_ref_edit))
 end of code

You could also try using tapply.

--Gray

On Thu, Dec 17, 2009 at 11:31 AM, gcam  wrote:
>
> Thanks Gray,
>
> This helps, I'd completely forgotten about the subset command.  However, it
> doesn't quite get me where I need.  Perhaps an example will help.  I will
> simplify my dataframe to the three important variables:
>
> ESR_ref   ESR_ref_edit    Loaded
> 1.1          1.1                  Y
> 1.1.1        1.1                  NC
> 1.1.2        1.1                 Y
> 2.1           2.1                  N
> 2.1.1         2.1                 Y
> 2.1.2        2.1                  PU
> 2.1.3        2.1                   Y
> 3.1           3.1                  Y
> 4.1           4.1                  N
> 4.1.1        4.1                   PU
>
> So I've created the "edit" variable so I can test for duplicates (i.e.
> samples with more than one sub-sample) because this is not of interest at
> this point.  I just want one subsample per sample.  However, if we consider
> 2.1 - this would result in a subset (if duplicates were removed) with the
> first line which has an "N".  But it is of interest to me the if at least
> one of the subsamples has a "Y" then I want that line rather than a
> subsample with another code.  1.1 in this example works by default because
> the first subsample is a "Y" so it will retain that information.
>
> Thanks
>
> Gareth
>
>
> Gray Calhoun-2 wrote:
>>
>> Hi,
>> Try:
>>
>> subset(Samps, !duplicated(Samps$ESR_ref_edit) | Samps$Loaded == "Y")
>>
>> I'd need specific code to be sure that this is exactly what you want
>> (ie you specify input and desired output), but indexing with a logical
>> vector is probably going to be the solution.
>>
>> Best,
>> Gray
>>
>> On Wed, Dec 16, 2009 at 7:55 PM, gcam  wrote:
>>>
>>> Hi all.
>>>
>>> So I have a data frame with multiple columns/variables.  The first
>>> variable
>>> is a major sample name for which there are some sub-samples.  Currently I
>>> have used the following command to remove the duplicates:
>>>
>>> Samps_working<-Samps[-c(which(duplicated(Samps$ESR_Ref_edit))),]
>>>
>>> This removes all of the duplicated sample rows.
>>>
>>> However, I just realised that, of course, this removes the first
>>> observation
>>> of each duplicated set.  However, I wish to retain any that have the code
>>> "Y" in another variable Samps$Loaded.  I'm at a bit of a loss as to how
>>> best
>>> to approach this problem.
>>>
>>> Just to reiterate.  I want to remove all duplicate lines based on sample
>>> name, but, I want the lines to be removed with a preference given to
>>> those
>>> that do not include a "Y" in the Loaded variable column.
>>> --
>>> View this message in context:
>>> http://n4.nabble.com/Remove-duplicates-from-a-data-frame-but-with-some-special-requirements-tp965745p965745.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.
>>>
>>
>>
>>
>> --
>> Gray Calhoun
>>
>> Assistant Professor of Economics
>> Iowa State 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.
>>
>>
>
> --
> View this message in context: 
> http://n4.nabble.com/Remove-duplicates-from-a-data-frame-but-with-some-special-requirements-tp965745p974312.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.
>



-- 
Gray Calhoun

Assistant Professor of Economics
Iowa State 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.

[R] ggplot2 / lattice

2009-12-17 Thread Gary Miller
Hi R Users,

Is there a equivalent function for the following R code in Lattice package.
I want to plot a grouped box plots (grouped by two factors).

g <- rep.int(c("A", "B", "C", "D"), 125)
t <- rnorm(5000)
a <- sample(t, 500, replace=TRUE)
b <- sample(t, 500, replace=TRUE)
dta <- data.frame(val = sample(t,1000), g = gl(4, 250, labels=c("A", "B",
"C", "D")) , G2 = gl(2,1, labels=c("XX", "YY")))
# ggplot2 package required
p <- ggplot(dta, aes(factor(G2), val))
p + geom_boxplot(aes(fill = factor(g)))

Any suggestion would be highly appreciated!
Gary

[[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] ggplot2 / lattice

2009-12-17 Thread Gabor Grothendieck
Try this:

bwplot(val ~ g | G2, dta)


On Thu, Dec 17, 2009 at 9:34 PM, Gary Miller  wrote:
> Hi R Users,
>
> Is there a equivalent function for the following R code in Lattice package.
> I want to plot a grouped box plots (grouped by two factors).
>
> g <- rep.int(c("A", "B", "C", "D"), 125)
> t <- rnorm(5000)
> a <- sample(t, 500, replace=TRUE)
> b <- sample(t, 500, replace=TRUE)
> dta <- data.frame(val = sample(t,1000), g = gl(4, 250, labels=c("A", "B",
> "C", "D")) , G2 = gl(2,1, labels=c("XX", "YY")))
> # ggplot2 package required
> p <- ggplot(dta, aes(factor(G2), val))
> p + geom_boxplot(aes(fill = factor(g)))
>
> Any suggestion would be highly appreciated!
> Gary
>
>        [[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] ggplot2 / lattice

2009-12-17 Thread Gary Miller
@ Gabor: Thanks, it worked.

@ All: Which options I should explore to change the appearance of boxes.
Like,

1. Color change.
2. Fill-in boxes with colors.
3. Change dot to line (used to represent median)
4. No gaps between boxplots in each category.

# R Code:
g <- rep.int(c("A", "B", "C", "D"), 125)
t <- rnorm(5000)
a <- sample(t, 500, replace=TRUE)
b <- sample(t, 500, replace=TRUE)
dta <- data.frame(val = sample(t,1000), g = gl(4, 250, labels=c("A", "B",
"C", "D")) , G2 = gl(2,1, labels=c("XX", "YY")))
library(lattice)
bwplot(val ~ g | G2, dta)

Thanks,
Gary

On Thu, Dec 17, 2009 at 10:09 PM, Gabor Grothendieck <
ggrothendi...@gmail.com> wrote:

> Try this:
>
> bwplot(val ~ g | G2, dta)
>
>
> On Thu, Dec 17, 2009 at 9:34 PM, Gary Miller 
> wrote:
> > Hi R Users,
> >
> > Is there a equivalent function for the following R code in Lattice
> package.
> > I want to plot a grouped box plots (grouped by two factors).
> >
> > g <- rep.int(c("A", "B", "C", "D"), 125)
> > t <- rnorm(5000)
> > a <- sample(t, 500, replace=TRUE)
> > b <- sample(t, 500, replace=TRUE)
> > dta <- data.frame(val = sample(t,1000), g = gl(4, 250, labels=c("A", "B",
> > "C", "D")) , G2 = gl(2,1, labels=c("XX", "YY")))
> > # ggplot2 package required
> > p <- ggplot(dta, aes(factor(G2), val))
> > p + geom_boxplot(aes(fill = factor(g)))
> >
> > Any suggestion would be highly appreciated!
> > Gary
> >
> >[[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.


Re: [R] ggplot2 / lattice

2009-12-17 Thread Felix Andrews
Look at ?panel.bwplot specifically 'fill', 'pch', and 'box.width'.



2009/12/18 Gary Miller :
> @ Gabor: Thanks, it worked.
>
> @ All: Which options I should explore to change the appearance of boxes.
> Like,
>
> 1. Color change.
> 2. Fill-in boxes with colors.
> 3. Change dot to line (used to represent median)
> 4. No gaps between boxplots in each category.
>
> # R Code:
> g <- rep.int(c("A", "B", "C", "D"), 125)
> t <- rnorm(5000)
> a <- sample(t, 500, replace=TRUE)
> b <- sample(t, 500, replace=TRUE)
> dta <- data.frame(val = sample(t,1000), g = gl(4, 250, labels=c("A", "B",
> "C", "D")) , G2 = gl(2,1, labels=c("XX", "YY")))
> library(lattice)
> bwplot(val ~ g | G2, dta)
>
> Thanks,
> Gary
>
> On Thu, Dec 17, 2009 at 10:09 PM, Gabor Grothendieck <
> ggrothendi...@gmail.com> wrote:
>
>> Try this:
>>
>> bwplot(val ~ g | G2, dta)
>>
>>
>> On Thu, Dec 17, 2009 at 9:34 PM, Gary Miller 
>> wrote:
>> > Hi R Users,
>> >
>> > Is there a equivalent function for the following R code in Lattice
>> package.
>> > I want to plot a grouped box plots (grouped by two factors).
>> >
>> > g <- rep.int(c("A", "B", "C", "D"), 125)
>> > t <- rnorm(5000)
>> > a <- sample(t, 500, replace=TRUE)
>> > b <- sample(t, 500, replace=TRUE)
>> > dta <- data.frame(val = sample(t,1000), g = gl(4, 250, labels=c("A", "B",
>> > "C", "D")) , G2 = gl(2,1, labels=c("XX", "YY")))
>> > # ggplot2 package required
>> > p <- ggplot(dta, aes(factor(G2), val))
>> > p + geom_boxplot(aes(fill = factor(g)))
>> >
>> > Any suggestion would be highly appreciated!
>> > Gary
>> >
>> >        [[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.
>



-- 
Felix Andrews / 安福立
Postdoctoral Fellow
Integrated Catchment Assessment and Management (iCAM) Centre
Fenner School of Environment and Society [Bldg 48a]
The Australian National University
Canberra ACT 0200 Australia
M: +61 410 400 963
T: + 61 2 6125 4670
E: felix.andr...@anu.edu.au
CRICOS Provider No. 00120C
-- 
http://www.neurofractal.org/felix/

__
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] Getting Rd pages right for redefined S3 generic

2009-12-17 Thread S Ellison
I'm writing a package, and would appreciate advice on controlling the
help documentation cross-references for a redefined generic.

I wanted to define a cbind equivalent for an object that mostly behaves
like a data frame. base::cbind dispatches to a data frame method if
_any_ parameter is a data frame, so I defined a new S3 cbind and
cbind.default to handle dispatch on first object only. Though I confess
that redefining cbind leaves me a tad nervous, that all works OK so far.

However, R cmd tells me (rightly) that I haven't documented the generic
and new default. But I don't want to; I want ?cbind to point to the base
package help pages, not to mine.

Assuming that's not unwise (?), what do I have to do to tell R cmd that
it should not look for Rd docs for cbind and cbind.default in my package
whilst still having my generic handle dispatch correctly?

It looks like one answer _might_ be not to export my redefined cbind  -
but will a local generic still work properly if it's not exported?
 
Steve Ellison


***
This email and any attachments are confidential. Any use...{{dropped:8}}

__
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] poly() with unnormalized values

2009-12-17 Thread Gray Calhoun
Hi Michael,
  If I remember right, this question has been asked several times on
this mailing list in the past.  The reference listed in the help page
for poly explain how to get the un-orthogonalized coefficients, but
those coefficients aren't needed for prediction.  For more details,
though, search the mailing list archives (especially since I may be
forgetting something).
Best,
Gray

On Thu, Dec 17, 2009 at 2:29 PM, Michael Friendly  wrote:
> How can I get the result of, e.g., poly(1:3. degree=2) to give me the
> unnormalized integer coefficients
> usually used to explain orthogonal polynomial contrasts, e.g,
>
> -1   1
> 0  -2
> 1   1
>
> As I understand things, the columns of x^{1:degree} are first centered and
> then
> are normalized by 1/sqrt(col sum of squares), but I can't
> see how to relate this to what is returned by poly(). > poly(1:3, degree=2)
>                1          2
> [1,] -7.071068e-01  0.4082483
> [2,] -9.073264e-17 -0.8164966
> [3,]  7.071068e-01  0.4082483
> attr(,"degree")
> [1] 1 2
> attr(,"coefs")
> attr(,"coefs")$alpha
> [1] 2 2
>
> attr(,"coefs")$norm2
> [1] 1.000 3.000 2.000 0.667
>
> attr(,"class")
> [1] "poly"   "matrix"
>>
>
> I've read the code for poly(), but $alpha and $norm2 are undocumented, and I
> still still can't see the inverse
> transformation
>
> -Michael
>
> --
> Michael Friendly     Email: friendly AT yorku DOT ca Professor, Psychology
> Dept.
> York University      Voice: 416 736-5115 x66249 Fax: 416 736-5814
> 4700 Keele Street    http://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.
>



-- 
Gray Calhoun

Assistant Professor of Economics
Iowa State 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] Covariate adjusted survival curves

2009-12-17 Thread Lakshmi Venkitachalam
Hello,

We are using frailty models to estimate risk of one year death. Is there a
way to generate survival curves adjusted for covariates and also include
frailty term?

Any help will be much appreciated!
Thanks!
LV

[[alternative HTML version deleted]]

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


[R] data download from metastock into r-software

2009-12-17 Thread SNV Krishna
Hi All,

is there a way to download data from metastock to R-software. most of my data 
is in date,OHLC format downloaded from reuters to metastock software in my 
local pc. 

many thanks for the help.,

krishna

[[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] Covariate adjusted survival curves

2009-12-17 Thread David Winsemius


On Dec 17, 2009, at 11:47 PM, Lakshmi Venkitachalam wrote:


Hello,

We are using frailty models to estimate risk of one year death. Is  
there a
way to generate survival curves adjusted for covariates and also  
include

frailty term?


Is there really only _one_ way to generate such estimates?




Any help will be much appreciated!
Thanks!
LV

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


David Winsemius, MD
Heritage Laboratories
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] Plot with a factor variable which has large values

2009-12-17 Thread changzhu

I wanted to do a simple plot: Death Rate vs Clinical Site, and then draw a
confidence interval of Death Rate at each clinical site, which is a factor
variable with 100 levels. I used the following code:

plot(Site, Rate, col="red", type="o")

However, the graph was a short line at each site instead of points, and the
color was not red at all. Seem to me for factor variable all options are not
working ! Could anybody help me on how  to draw points at each site, with
specific color? if possible, how to further draw confidence interval at each
site? 

I appreciate!


-- 
View this message in context: 
http://n4.nabble.com/Plot-with-a-factor-variable-which-has-large-values-tp974321p974321.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] Testing equality of regression model on multiple groups

2009-12-17 Thread Clara Yuan
Hello,

I'm trying to test for the joint equality of coefficients of the same model 
across different subsets of the data (ie, is it necessary to estimate the same 
model on these different populations, or can I just estimate the model once on 
the whole dataset?).

My plan is to use the F-test on the reduced model and the full model. By full 
model, I mean a specification that mimics my regressions on separate subsets of 
data, but I have found that the full model's coefficient estimates don't 
correspond to my original model's estimates. I was under the impression that 
they would be identical.

Original model:
> lm.separate = by(data.ex, data.ex$t, function(x) lm(y ~ x1 * x2, data = x))

Full model:
> lm.together = lm(y ~ t * x1 * x2, data = data.ex)

The data are grouped by t.

When I examine the coefficients, I find that they are roughly in the same 
ballpark, but not nearly identical:
> sapply(lm.separate, coef)
  12 3 4
(Intercept) 2.691272263 1.7153565472  1.8797914048  1.9282332240
x1  0.107520721 0.0472488208  0.0440171489  0.0198376096
x2  0.054694784 0.0396246366  0.0603665574  0.0300886164
x1:x2   0.002180749 0.0003653858 -0.0001488267 -0.0007409421

> coef(lm.together)
  (Intercept)   t.L   t.Q   t.Cx1
 2.0536633597 -0.4750933962  0.5121787674 -0.2809269719  0.0546560750
   x2t.L:x1t.Q:x1t.C:x1t.L:x2
 0.0461936485 -0.0595422428  0.0180461803 -0.0174386682 -0.0118682844
   t.Q:x2t.C:x2 x1:x2 t.L:x1:x2 t.Q:x1:x2
-0.0076038969 -0.0194162097  0.0004140914 -0.0020749112  0.0006116237
t.C:x1:x2
-0.0003083657

(Also, why are the coefficients renamed to t.L, t.Q, etc instead of t.1, t.2?)

What am I missing?

Thanks for the help,
Clara

__
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] Ryacas: problem with "Sym"

2009-12-17 Thread Gavin Steininger
I have been trying to get the Ryacas package to work without any 
success. I do not seem to be able to the "Sym" function work, for 
example:

> library(XML)
> library(Ryacas)
> a=Sym("a")
> a
Error in summary.connection(x) : invalid connection

I am windows XP  with R 2.10 

Thanks for you help

gavin amw steininger

__
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] Compare two repeated measures mixed models

2009-12-17 Thread Chunhao

Hi R users,
I have a statistical question. If I have two repeated measures models such
as,
m1, y=u+a+time+a:time+e
m2, y=u+b+time+b:time+e
How can I compare these two models (such as which one is the better
predictor, a or b)?

Many Thanks In Advance.
Chunhao
-- 
View this message in context: 
http://n4.nabble.com/Compare-two-repeated-measures-mixed-models-tp974511p974511.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] some help regarding combining columns from different files

2009-12-17 Thread Harikrishnadhar
Dear all,

Here is my code which am using to combine 5th column from different data
sets.

Here is the function  to do my job


genesymbol.append.file <-NULL
gene.column <- NULL
readGeneSymbol <- function(files,genesymbol.column=5){
for(i in fnames){
 temp <- read.table(fnames,header=T,sep="\t",stringsAsFactors=F,quote="\"")
 gene.column<-cbind(gene.column,temp[,genesymbol.column])
 genesymbol.append.file$genecolumns <- gene.column
 genesymbol.append.file
 }
}




test <- readGeneSymbol(fnames,genesymbol.column=5)

Here is the warning message  am getting only the 5th column from the first
column is taken


Warning messages:
1: In file(file, "r") : only first element of 'description' argument used
2: In file(file, "r") : only first element of 'description' argument used
>

Please help me to solve this







-- 
Thanks
Hari
215-385-4122






















"If there is anyone out there who still doubts that America is a place where
all things are possible"

[[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] Error using step.gam from the gam library

2009-12-17 Thread McEachron, Luke
I am running multiple GAMs using the step.gam function and am receiving an 
error. I have copied my code and bolded the error at the bottom. Any help is 
greatly appreciated.


trout.gam2<-gam(cpue~s(lat,7)+as.factor(gear)+as.factor(bottom)+s(depth,7)+s(do,7)+s(sal,7)+s(temp,7),family=quasipoisson,data=trout)

trout.gam3<-step.gam(trout.gam2,scope=list(+ "lat"=~1+lat+s(lat,3)+s(lat,7), 
"gear"=~1+as.factor(gear),"bottom"=~1+as.factor(bottom), 
"depth"=~1+depth+s(depth,3)+s(depth,7), "do"=~1+do+s(do,3)+s(do,7),  
"sal"=~1+sal+s(sal,3)+s(sal,7), "temp"=~1+temp+s(temp,3)+s(temp,7)))

Start:  cpue ~ s(lat, 7) + as.factor(gear) + as.factor(bottom) + s(depth,  
7) + s(do, 7) + s(sal, 7) + s(temp, 7); AIC= NA
Error in while (bAIC < AIC & steps > 0) { :   missing value where TRUE/FALSE 
needed



Luke McEachron
Assistant Research Scientist
Florida Fish and Wildlife Research Institute
100 8th Ave SE
St. Petersburg, FL 33701
(727) 896-8626 x. 3046





[[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 to run several scripts?

2009-12-17 Thread kayj

Hi All,

I am a windows user and I would like to run several R scripts one after the
other, I was wondering if that is possible to do on windows instead of
clicking on each script to run it.

Thanks 

-- 
View this message in context: 
http://n4.nabble.com/How-to-run-several-scripts-tp972862p972862.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] mantel test and NAs

2009-12-17 Thread marciarocha

Dear R users,

I am having a problem performing the mantel test (both with functions mantel
{vegan} and mantel.test {ape}) due to I believe the presence of NAs on my
distance matrices, which look like e.g.:

NA
12
12   3
NA  4   5  6

and 

1
1   2
2   3   4
5   6   7  8

Would any of you have a solution for that?

Thank you for much for your help!

Marcia Rocha


-- 
View this message in context: 
http://n4.nabble.com/mantel-test-and-NAs-tp966682p966682.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] Which hist cell each value falls in?

2009-12-17 Thread Doug Hill

Hi, all. I'm using hist() to obtain a vector of break values in an interval.
I then want to be able to identify which cell any value from another vector
falls in.

E.g. applying

> breaks
 [1] -3.5 -3.0 -2.5 -2.0 -1.5 -1.0 -0.5  0.0  0.5  1.0  1.5  2.0

to

> x
 [1] -3.74519666 -0.38183630 -1.22884247 -0.20971824 -0.30533939 -0.36271207
[7] -2.27513499 -2.23688653 -1.98827155 -1.48666274 -1.26155084 -0.15234555
[13] -0.09497287  0.34488440

would give

> xcells
 [1] 1  8  6  8  8  8  4  4  5  6  6  8  8  9

where:
  x <= breaks[1] -> cell 1
breaks[1] < x <= breaks[2] -> cell 2
breaks[2] < x <= breaks[3] -> cell 3, etc.

I'm sure there's either a built-in function or a concise way to do this, but
I've not figured it out.

Thanks,

Doug
-- 
View this message in context: 
http://n4.nabble.com/Which-hist-cell-each-value-falls-in-tp974316p974316.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] write.csv and col.names=F

2009-12-17 Thread kayj

Hi All,

I always have a problem with write.csv when I want the column names to be
ignored, when I specify col.names=F, I get a header of V1 V2 V3 V4 etc.

for example I tried

write.csv(mydata, file="data.csv", quote=FALSE, row.names=F, col.names=F) 
Warning message:
In write.csv(mydata, file = "data.csv", quote = FALSE,  :
  attempt to set 'col.names' ignored
> 

how can I get rid of this problem ? I do not want the header of V1 V2 V3...
to appear in my output file,

Thanks
-- 
View this message in context: 
http://n4.nabble.com/write-csv-and-col-names-F-tp974477p974477.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 run several scripts?

2009-12-17 Thread guohao.huang

Write a new script as the following
source("path/1.R")
source("path/2.R")

R will execute these scripts in sequence.


   Guo-Hao Huang

--
From: "kayj" 
Sent: Friday, December 18, 2009 3:01 AM
To: 
Subject: [R]  How to run several scripts?



Hi All,

I am a windows user and I would like to run several R scripts one after 
the

other, I was wondering if that is possible to do on windows instead of
clicking on each script to run it.

Thanks

--
View this message in context: 
http://n4.nabble.com/How-to-run-several-scripts-tp972862p972862.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-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] write.csv and col.names=F

2009-12-17 Thread milton ruser
?write.table

On Thu, Dec 17, 2009 at 6:52 PM, kayj  wrote:

>
> Hi All,
>
> I always have a problem with write.csv when I want the column names to be
> ignored, when I specify col.names=F, I get a header of V1 V2 V3 V4 etc.
>
> for example I tried
>
> write.csv(mydata, file="data.csv", quote=FALSE, row.names=F, col.names=F)
> Warning message:
> In write.csv(mydata, file = "data.csv", quote = FALSE,  :
>  attempt to set 'col.names' ignored
> >
>
> how can I get rid of this problem ? I do not want the header of V1 V2 V3...
> to appear in my output file,
>
> Thanks
> --
> View this message in context:
> http://n4.nabble.com/write-csv-and-col-names-F-tp974477p974477.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] Which hist cell each value falls in?

2009-12-17 Thread Jim Lemon

On 12/18/2009 06:35 AM, Doug Hill wrote:

Hi, all. I'm using hist() to obtain a vector of break values in an interval.
I then want to be able to identify which cell any value from another vector
falls in.

E.g. applying

   

breaks
 

  [1] -3.5 -3.0 -2.5 -2.0 -1.5 -1.0 -0.5  0.0  0.5  1.0  1.5  2.0

to

   

x
 

  [1] -3.74519666 -0.38183630 -1.22884247 -0.20971824 -0.30533939 -0.36271207
[7] -2.27513499 -2.23688653 -1.98827155 -1.48666274 -1.26155084 -0.15234555
[13] -0.09497287  0.34488440

would give

   

xcells
 

  [1] 1  8  6  8  8  8  4  4  5  6  6  8  8  9

where:
   x<= breaks[1] ->  cell 1
breaks[1]<  x<= breaks[2] ->  cell 2
breaks[2]<  x<= breaks[3] ->  cell 3, etc.

   

Hi Doug,
The function below does more or less what you want, except that the bins 
are numbered from zero (meaning that a value is below the range of bins 
as x[1] is) to length(breaks) (meaning that a value is above the range 
of bins).


whichBin<-function(x,breaks,right=TRUE) {
 lenx<-length(x)
 # any leftovers must be out of range
 wb<-rep(lenx,lenx)
 if(right) wb[x<=breaks[1]]<-0
 else wb[xbreaks[bin] & x<=breaks[bin+1]]<-bin
  else wb[x>=breaks[bin] & xhttps://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.