Re: [R] curvedarrow (some graphics problem)

2009-06-25 Thread casperyc

Hi there,

This is now the code

%
library(grid)

vp -  viewport(
x = unit(0, npc),
y = unit(0, npc),
just = c(left, bottom),
xscale = c(-1, 1) ,
yscale = c(-1, 1))

vp2 -  viewport( # probably not needed but I had trouble placing the xaxis
x = unit(0,npc),
y = unit(0.5,  npc),
just = c(left, bottom),
xscale = c(-1, 1) ,
yscale = c(-1, 1))


pushViewport(vp)
grid.xaxis(at=seq(-1, 1, by=0.2), label=FALSE,  vp=vp2)
grid.points(x=0.3, y=0.5, gp=gpar(col=NA), default.units = npc,   
name=h1, vp=vp)
grid.points(x=0.7, y=0.5, gp=gpar(col=NA), default.units = npc,   
name=h2, vp=vp)
grid.text(s, x=0.3, y=unit(-1, lines), vp=vp2)
grid.text(t, 0.7, unit(-1, lines), gp=gpar(col=red), vp=vp2)
grid.text(mu(s,t), 0.5, unit(5, lines), vp=vp2)

grid.curve(grobX(h2, 180),
grobY(h2, 180),
grobX(h1, 180),
grobY(h1, 180),
shape=1, ncp=10,
square=FALSE,
curvature=.4,
arrow=arrow(angle=20,ends=first) )

upViewport()



%

for this line:
grid.text(mu(s,t), 0.5, unit(5, lines), vp=vp2)

how do I change mu(s,t) to the expression mu?
I have tried 
grid.text(expression=mu(s,t), 0.5, unit(5, lines), vp=vp2)
grid.text(expression(mu(s,t)), 0.5, unit(5, lines), vp=vp2)

both didnt work

AND

when I tried to save the output as PDF file

it returns:

Error in function (name)  : Grob 'h2' not found

I have no idea what to do?


-- 
View this message in context: 
http://www.nabble.com/curvedarrow-%28some-graphics-problem%29-tp24158796p24196544.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] List subsetting

2009-06-25 Thread Dieter Menne



Ivo Shterev wrote:
 
 
 I have a question about list indexing. Lets say we have a list of 3 lists,
 each containing 3 different type elements:
 
 

(Details of your nice example code removed)


a=replicate(3, list(list(c(1,1,1), diag(3), c(2,2,2 
str(a) # I prefer this to print(a) because it shows the structure better

# in steps
b = lapply(a,function(x){
# print(str(a)) # put this here to know what you are doing
x[2:3]
  }
)
#... mmm, not yet what  you wanted. Another try
b[1:2]

# I leave it as a easy exercise to jam this into a one-liner

---
Dieter

-- 
View this message in context: 
http://www.nabble.com/List-subsetting-tp24194764p24198222.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] adf.test Vs ADF.test...

2009-06-25 Thread DongHongwei


Hi, R users,
I'm using R to test the unit root for my time series data. I just compared the 
ADF.test in uroot package and the adf.test in tseries package. It seems 
it is difficult to define the time trend and intercept in adf.test. But it is 
easy to do these in ADF.test. ADF.test also help you find the number of 
lags that need to be included in the model to remove the serial correlation. I 
do not not see adf.test be able to do this too. You need to define the number 
of lags for adf.test. 
  I'm a new R user and I could be wrong. I'll appreciate it very much if 
someone familiar with time series in R can give me some comments and 
suggestions. Thanks in advance.

  Harry


 From: dongh...@hotmail.com
 To: patrick.richard...@vai.org; r-help@r-project.org
 Date: Wed, 24 Jun 2009 19:22:46 +
 Subject: Re: [R] Why can't I use ADF.test?
 
 
 Thanks! I tried these, but I got the following messages:Warning message:In 
 getDependencies(pkgs, dependencies, available, lib) :  package 
 ‘uroot’ is not available
 Error in library(uroot) : there is no package called 'uroot'
 
 
 I download a package called uroot and put it into: C:\Program 
 Files\R\R-2.9.0\library. But still got the same error. Any further 
 suggestions?
   Hongwei 
 
 
  From: patrick.richard...@vai.org
  To: dongh...@hotmail.com; r-help@r-project.org
  Date: Wed, 24 Jun 2009 15:12:22 -0400
  Subject: RE: [R] Why can't I use ADF.test?
  
  Since you provided no code, the following is just a guess,  Try:
  
  install.packages(uroot)
  library(uroot)
  
  Then try your analysis again.
  
  
  -Original Message-
  From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
  Behalf Of DongHongwei
  Sent: Wednesday, June 24, 2009 3:06 PM
  To: r-help@r-project.org
  Subject: [R] Why can't I use ADF.test?
  
  
  Greetings!
  I'm trying to use R to test the unit root for a univariate data. By this 
  link: 
  http://rss.acs.unt.edu/Rdoc/library/uroot/html/ADF.test.html
   it tells me that I can use the function ADF.test(). However, when I tried 
  this in R, I got this message:
  Error: could not find function ADF.test.
  I'm confused by this. Anyone could give me some hints? Thanks.
  Hongwei
  
  
  
  _
  ´ò¹¤£¬ÕõÇ®£¬Âò·¿×Ó£¬¿ìÀ´MClubÒ»Æ𡱽ðÎݲؽ¿¡±£¡
  
  [[alternative HTML version deleted]]
  
  This email message, including any attachments, is for the sole use of the 
  intended recipient(s) and may contain confidential information.  Any 
  unauthorized review, use, disclosure or distribution is prohibited.  If you 
  are not the intended recipient(s) please contact the sender by reply email 
  and destroy all copies of the original message.  Thank you.
 
 _
 Messenger安全保护中心,免费修复系统漏洞,保护Messenger安全!
 http://im.live.cn/safe/
   [[alternative HTML version deleted]]
 

_
打工,挣钱,买房子,快来MClub一起”金屋藏娇”!
http://club.msn.cn/?from=10
[[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] change the height or scale of the y axis

2009-06-25 Thread Dieter Menne



legen wrote:
 
 
 I have a question about changing the height or scale of the y axis. When I
 use following two R codes, I can get two plots. Please look at the y axes,
 the number of indices (x1, x2, …) on the y axis in the first plot is
 smaller than that in the second plot, and hence the space between any two
 indices in the first plot is wider than that in the second plot. As the
 number of indices increases, the space will vanish and the indices will
 overlap. I want to display all the indices on the y axis in the second
 plot, just look like that in the first plot. How to separate the indices
 on the y axis in the second plot? I guess maybe changing the height or
 scale of y axis is a way to solve my problem, but I failed to do it after
 several trails. Anybody can help me? Thank you in advance.
 
 

You really put a lot of typing work into your example code, but it work, so
it's fine. As a first attempt, put the following before the second plot(). 

par(las=1,cex=0.5)

And think about the paper size. I suggest to have a look at lattice graphics
for this type of work as a more elegant alternative. And Hadley Wickham can
certainly tell you how to do this in ggplot47



-- 
View this message in context: 
http://www.nabble.com/change-the-height-or-scale-of-the-y-axis-tp24187351p24198429.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] Apply as.factor (or as.numeric etc) to multiple columns

2009-06-25 Thread SIES 73
Hi Mark,

I frequently need to do that when importing data. This one-liner works:

 data.frame(mapply(as, x, c(integer, character, factor), 
 SIMPLIFY=FALSE), stringsAsFactors=FALSE);

but it has two problems:

1) as() is an S4 method that does not always work 
2) writting the vector of classes for 60 variables is rather tedious.

Both issues can be solved with the following two helper functions. The first 
function tries to use as(x, class); if it doesn't work, tries as.class(x); If 
it still doesn't work, tries class(x). The second function tranforms a single 
string to a character vector of classes, by transforming each letter in the 
string to a class name (i.e. D is tranformed to Date, i to integer, 
etc.), so that writting 60 classes is fast.

doCoerce - function(x, class) {
if (canCoerce(x, class)) 
as(x, class)
else {
result - try(match.fun(paste(as, class, sep=.))(x), 
silent=TRUE);
if (inherits(result, try-error))
result - match.fun(class)(x)
result; 
}
}

expandClasses - function (x) {
unknowns - character(0)
result - lapply(strsplit(as.character(x), NULL, fixed = TRUE), 
function(y) {
sapply(y, function(z) switch(z, 
i = integer, n = numeric, 
l = logical, c = character, x = complex, 
r = raw, f = factor, D = Date, P = POSIXct, 
t = POSIXlt, N = NA_character_, {
  unknowns - c(unknowns, z)
  NA_character_
}), USE.NAMES = FALSE)
})
if (length(unknowns)) {
unknowns - unique(unknowns)
warning(sprintf(ngettext(length(unknowns), code %s not recognized, 
codes %s not recognized), dqMsg(unknowns)))
}
result
}

An example:

 x - data.frame(X=2008-01-01, Y=1.1:3.1, Z=letters[1:3])
 data.frame(mapply(doCoerce, x, expandClasses(Dif)[[1L]], SIMPLIFY=FALSE), 
 stringsAsFactors=FALSE);

Regards,

Enrique


--

Message: 99
Date: Tue, 23 Jun 2009 15:23:54 -0600
From: Mark Na mtb...@gmail.com
Subject: [R] Apply as.factor (or as.numeric etc) to multiple columns
To: r-help@r-project.org
Message-ID:
e40d78ce0906231423m4c3da14i2f6270f92463c...@mail.gmail.com
Content-Type: text/plain; charset=ISO-8859-1

Hi R-helpers,

I have a dataframe with 60columns and I would like to convert several
columns to factor, others to numeric, and yet others to dates. Rather
than having 60 lines like this:

data$Var1-as.factor(data$Var1)

I wonder if it's possible to write one line of code (per data type,
e.g. factor) that would apply a function (e.g., as.factor) to several
(non-contiguous) columns. So, I could then use 3 or 4 lines of code
(for 3 or 4 data types) instead of 60.

I have tried writing an apply function, but it failed.

Thanks for any help you might be able to provide.

Mark Na

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 avoid ifelse statement converting factor to character

2009-06-25 Thread Patrick Burns

This sort of experience is why 'The R Inferno'
came into existence.


Patrick Burns
patr...@burns-stat.com
+44 (0)20 8525 0696
http://www.burns-stat.com
(home of The R Inferno and A Guide for the Unwilling S User)

Craig P. Pyrame wrote:


Dear Stavros,

What you discuss below is somewhat scary to me as an R newbie.  Is this 
just an incident, a bug perhaps, or rather the way things typically go 
in R, as your Welcome to R! seems to suggest?  I have just started to 
learn R, and my initial euphoria of the I can do anything with it! 
sort is gradually turning into an I can't get why it doesn't work and 
I can't get how to make this work depression.  I would be happy to 
blame this on my incompetence and incapability, but would also like to 
hear if it is not R itself that causes me to fail.


Best regards,
Craig


Stavros Macrakis wrote:

On Wed, Jun 24, 2009 at 12:34 PM, Mark Namtb...@gmail.com wrote:
 
The problem is that after running the ifelse statement, 
data$SOCIAL_STATUS

is converted from a factor to a character.
Is there some way I can avoid this conversion?



I'm afraid that ifelse has very bizarre semantics when the yes and no
arguments don't have the same, atomic vector, type.

The quick workaround for the bizarre semantics (though it can have a
significant efficiency cost) is this:

   unlist( ifelse ( condition, as.list( yes ), as.list( no ) ) )

(This isn't perfect, either, but...)

Take a look at the man page for details and the warning:

 The mode of the result may depend on the value of 'test', and the
 class attribute of the result is taken from 'test' and may be
 inappropriate for the values selected from 'yes' and 'no'.

Some consequences of the definition of ifelse are:

Even if the classes of the yes and no arguments are identical, the
result does not necessarily have that class:

ifelse(TRUE,as.raw(4),as.raw(5)) = error

ifelse(TRUE,factor('x'),factor('x')) = 1  (integer)

dates - as.POSIXct(c('1990-1-1','2000-1-1'))
ifelse(c(TRUE,FALSE),dates,dates)  =  63117 946702800  (double)

ifelse(c(TRUE,FALSE),factor(c('x','y')),factor(c('y','x'))) = 1 1

If they have different classes, things get stranger:

ifelse(c(TRUE,FALSE),c(a,b),factor(c(c,d)))  =  a 2

ifelse(c(TRUE,FALSE),list(1,2),as.raw(4))
[[1]]
[1] 1

[[2]]
[1] 04

Result is order-dependent:

ifelse(c(TRUE,FALSE),as.raw(4),list(1,2))
Error in ans[test  !nas] - rep(yes, length.out = 
length(ans))[test   :

incompatible types (from raw to logical) in subassignment type fix

Welcome to R!



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] error: compiling R package

2009-06-25 Thread Stein, Luba (AIM SE)
Hello,

I tried to build an own R package on Windows XP but get an error which I can't 
solve.
I called my package pack. It works to creat the file pack with 
package.skeleton().

But when I try to compile it with Rcmd build --binary pack I obtain the 
following error:

IO::Seekable::seek missing at C:/R/R-2.9.0/share/perl/FileHandle.pm line 59.
Compilation failed in require at C:/R/R-2.9.0/share/perl/R/Dcf.pm line 49.
BEGIN failed--compilation aborted at C:/R/R-2.9.0/share/perl/R/Dcf.pm line 49.
Compilation failed in require at C:\R\R-2.9.0/bin/build line 28.
BEGIN failed--compilation aborted at C:\R\R-2.9.0/bin/build line 28.

So if someone could help me on this I would be very greatful.

Best,

Luba Stein



Luba Stein
AIM SE

Koeniginstr. 28
80802 Munich, Germany

E-Mail luba.st...@allianz.commailto:luba.st...@allianz.com


Allianz Investment Management SE
Vorsitzender des Verwaltungsrates: Dr. Paul Achleitner
Geschäftsführende Direktoren: Dr. Karl-Hermann Lowe, Dr. Bernd Gutting

Sitz der Gesellschaft: München, Deutschland, Registergericht: München HRB 
162748
Für Umsatzsteuerzwecke: Ust-ID-Nr.: DE 251 168 597





[[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] Lose of decimal when using write.table to text file

2009-06-25 Thread Dieter Menne
Bob Ly robertly at vfemail.net writes:

 I have the following:
  Date-c(08/05/08,08/06/08,08/07/08)
  Weight-c(209.4,211.8,210.0)
  planned.meal-cbind(Date,Weight)
  planned.meal
DateWeight
 1  08/05/08,  209.4
 2  08/06/08,  211.8
 3  08/07/08,  210.0

This is strange. When I run your code, I get

 planned.meal 
 Date   Weight 
[1,] 08/05/08 209.4
[2,] 08/06/08 211.8
[3,] 08/07/08 210  

This could be a global date format setting, but it show part of the problem:
everything is converted to string as the common denominator.

Better use a data frame. And (from docs)

For finer control, use format to make a character matrix/data frame, and call
write.table on that

Dieter


Date-c(08/05/08,08/06/08,08/07/08)
Weight-c(209.4,211.8,210.0)
planned.meal-cbind(Date,Weight)
planned.meal 

str(planned.meal)

planned.meal-data.frame(Date=Date,Weight=Weight)
planned.meal 
str(planned.meal)

options(digits=1)
planned.meal.format =  format(planned.meal,nsmall=1)
planned.meal.format 

write.table(planned.meal.format, 
  file=plannedMeal1.txt, quote=FALSE, row.names=FALSE)

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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: compiling R package

2009-06-25 Thread Prof Brian Ripley

On Thu, 25 Jun 2009, Stein, Luba (AIM SE) wrote:


Hello,

I tried to build an own R package on Windows XP but get an error which I can't 
solve.
I called my package pack. It works to creat the file pack with 
package.skeleton().

But when I try to compile it with Rcmd build --binary pack I obtain the 
following error:


Hmm, at least use Rcmd INSTALL first, and Rcmd build --binary is never 
preferred to Rcmd INSTALL --build on Windows.



IO::Seekable::seek missing at C:/R/R-2.9.0/share/perl/FileHandle.pm line 59.


That's an error message from Perl.
You need to mend your broken Perl installation.


Compilation failed in require at C:/R/R-2.9.0/share/perl/R/Dcf.pm line 49.
BEGIN failed--compilation aborted at C:/R/R-2.9.0/share/perl/R/Dcf.pm line 49.
Compilation failed in require at C:\R\R-2.9.0/bin/build line 28.
BEGIN failed--compilation aborted at C:\R\R-2.9.0/bin/build line 28.

So if someone could help me on this I would be very greatful.

Best,

Luba Stein


--
Brian D. Ripley,  rip...@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] curvedarrow (some graphics problem)

2009-06-25 Thread baptiste auguie


This will give you a greek character, see ?plotmath

grid.text(expression(mu*(s,t)), 0.5, unit(5, lines), vp=vp2)

The following works for me, it may be that you're using an outdated 
version of R,



vp -  viewport(
x = unit(0, npc),
y = unit(0, npc),
just = c(left, bottom),
xscale = c(-1, 1) ,
yscale = c(-1, 1))

vp2 -  viewport( # probably not needed but I had trouble placing the xaxis
x = unit(0,npc),
y = unit(0.5,  npc),
just = c(left, bottom),
xscale = c(-1, 1) ,
yscale = c(-1, 1))


pdf() # open the pdf device

pushViewport(vp)
grid.xaxis(at=seq(-1, 1, by=0.2), label=FALSE,  vp=vp2)
grid.points(x=0.3, y=0.5, gp=gpar(col=NA), default.units = npc,  
name=h1, vp=vp)
grid.points(x=0.7, y=0.5, gp=gpar(col=NA), default.units = npc,  
name=h2, vp=vp)

grid.text(s, x=0.3, y=unit(-1, lines), vp=vp2)
grid.text(t, 0.7, unit(-1, lines), gp=gpar(col=red), vp=vp2)
grid.text(expression(mu*(s,t)), 0.5, unit(5, lines), vp=vp2)

grid.curve(grobX(h2, 180),
grobY(h2, 180),
grobX(h1, 180),
grobY(h1, 180),
shape=1, ncp=10,
square=FALSE,
curvature=.4,
arrow=arrow(angle=20,ends=first) )

upViewport()

dev.off() # close the device


casperyc wrote:

Hi there,

This is now the code

%
library(grid)

vp -  viewport(
x = unit(0, npc),
y = unit(0, npc),
just = c(left, bottom),
xscale = c(-1, 1) ,
yscale = c(-1, 1))

vp2 -  viewport( # probably not needed but I had trouble placing the xaxis
x = unit(0,npc),
y = unit(0.5,  npc),
just = c(left, bottom),
xscale = c(-1, 1) ,
yscale = c(-1, 1))


pushViewport(vp)
grid.xaxis(at=seq(-1, 1, by=0.2), label=FALSE,  vp=vp2)
grid.points(x=0.3, y=0.5, gp=gpar(col=NA), default.units = npc,   
name=h1, vp=vp)
grid.points(x=0.7, y=0.5, gp=gpar(col=NA), default.units = npc,   
name=h2, vp=vp)

grid.text(s, x=0.3, y=unit(-1, lines), vp=vp2)
grid.text(t, 0.7, unit(-1, lines), gp=gpar(col=red), vp=vp2)
grid.text(mu(s,t), 0.5, unit(5, lines), vp=vp2)

grid.curve(grobX(h2, 180),
grobY(h2, 180),
grobX(h1, 180),
grobY(h1, 180),
shape=1, ncp=10,
square=FALSE,
curvature=.4,
arrow=arrow(angle=20,ends=first) )

upViewport()



%

for this line:
grid.text(mu(s,t), 0.5, unit(5, lines), vp=vp2)

how do I change mu(s,t) to the expression mu?
I have tried 
grid.text(expression=mu(s,t), 0.5, unit(5, lines), vp=vp2)

grid.text(expression(mu(s,t)), 0.5, unit(5, lines), vp=vp2)

both didnt work

AND

when I tried to save the output as PDF file

it returns:

Error in function (name)  : Grob 'h2' not found

I have no idea what to do?





__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] JRI - problem to access stats package

2009-06-25 Thread GRAN

Hello,

I am a new R user. More precisely, I am working with JRI (on a Eclipse 
Java6 project under Ubuntu9).


I have difficulties to access some R packages (For example: package 
stats, object Normal, function pnorm).


I have tried many solutions to set the right path but nothing have succeed:
For example:  LD_LIBRARY_PATH=${R_HOME}/lib:${R_HOME}/bin:${R_HOME}/library

Inside the  java code, I have also tried such methods:
Note that r is the REngine object coming from the connection to R

  
r.eval(dyn.load(\/home/gran/workspace/R-2.9.0/library/stats/libs/stats.so\, 
local = TRUE, now = TRUE));

  r.eval(require(stats));
  r.eval(autoload(\Normal\, \stats\));
  r.eval(search());
  r.eval(ls(\Autoloads\));
  System.out.println(r.eval(.Autoloaded));
  r.eval(zval = .95);
  System.out.println(r.eval(print(zval)));
  r.eval(p3 = pnorm(3*zval));
  System.out.println(r.eval(print(p3)));

It gives as a result:

  [STRING stats]
  [REAL* (0.95)]
  null   -- p3 = null because pnorm is unknown

Do you know how to use the stats package with JRI ?
Thanks in advance,
Antoine

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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-pkgs] RODBC 1.2-6 on CRAN, future directions

2009-06-25 Thread Prof Brian Ripley
Version 1.2.6 of RODBC is now on CRAN.  This has a number of bug fixes and many 
workarounds for ODBC driver quirks--I've set up further testbeds for SQL Server 
2008, Oracle and DB2.


More visibly, the documentation has been expanded in several ways, in 
particular in collecting together advice on using 'schemas' and 'catalogs' in 
the ?RODBC overview.


There is also a test suite which although mainly useful for the maintainer 
provides some more detailed examples of working with the quirks of various 
backends (and has examples for Oracle's own Windows ODBC driver). 
Contributions of adaptations of those examples to other drivers would be 
welcome (especially for Sybase and other ODBC drivers for Oracle).


In the next version much of the documentation will be moved from the help pages 
to a package manual: a draft of that manual appropriate to RODBC 1.2-6 can be 
found at http://www.stats.ox.ac.uk/pub/bdr/RODBC-manual.pdf


Other planned changes are speed-ups for Oracle (currently 4x on the test 
suite), more support for schemas (that in 1.2-6 is just a first step, but the 
behaviour of the ODBC drivers is remarkably inconsistent) and support for R's 
'raw' type.


--
Brian D. Ripley,  rip...@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

___
R-packages mailing list
r-packa...@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-packages

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] JRI - problem to access stats package

2009-06-25 Thread Geoff Gibbs
Hi Antoine,

I have got this to work on Windows, the process should be the same for
Linux.

For an eclipse plugin you will need to add the following to your
MANIFEST.MF file: 

Bundle-ClassPath: whatever you normally have,
 lib/JRI.jar
Bundle-NativeCode: /lib/jri.dll; osname=winxp; processor=x86

You will also need to ensure that the R executable is in your path and
that R_HOME is set.

I did this by creating a simple batch file containing the following in a
directory called rootfiles within our feature, the same should work for
a .sh :

 set PATH=%CD%\R install\exe;%PATH%
 set R_HOME=%CD%\R install
 eclipse.exe

I then added the following line to the build.properties file of the
feature:
root=rootfiles

This tells eclipse to copy the content of the directory to the root of
the application on install.

If you then run eclipse from the batch file, it should work.

--

Geoff Gibbs
mangosolutions
data analysis that delivers

Tel +44 (0)1249 767 700

Mob +44 (0)7791 855 620


-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of GRAN
Sent: 25 June 2009 09:40
To: r-help@r-project.org
Subject: [R] JRI - problem to access stats package

Hello,

I am a new R user. More precisely, I am working with JRI (on a Eclipse
Java6 project under Ubuntu9).

I have difficulties to access some R packages (For example: package
stats, object Normal, function pnorm).

I have tried many solutions to set the right path but nothing have
succeed:
For example:
LD_LIBRARY_PATH=${R_HOME}/lib:${R_HOME}/bin:${R_HOME}/library

Inside the  java code, I have also tried such methods:
Note that r is the REngine object coming from the connection to R

   
r.eval(dyn.load(\/home/gran/workspace/R-2.9.0/library/stats/libs/stats
.so\,
local = TRUE, now = TRUE));
   r.eval(require(stats));
   r.eval(autoload(\Normal\, \stats\));
   r.eval(search());
   r.eval(ls(\Autoloads\));
   System.out.println(r.eval(.Autoloaded));
   r.eval(zval = .95);
   System.out.println(r.eval(print(zval)));
   r.eval(p3 = pnorm(3*zval));
   System.out.println(r.eval(print(p3)));

It gives as a result:

   [STRING stats]
   [REAL* (0.95)]
   null   -- p3 = null because pnorm is unknown

Do you know how to use the stats package with JRI ?
Thanks in advance,
Antoine

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] adf.test Vs ADF.test...

2009-06-25 Thread Pfaff, Bernhard Dr.
Dear Harry,

to complete the picture, for the packages installed on my machine help.search() 
yielded:

 help.search(Dickey)
Help files with alias or concept or title matching 'Dickey' using fuzzy
matching:


CADFtest::CADFtest  Hansen's Covariate-Augmented Dickey Fuller
(CADF) test
fUnitRoots::DickeyFullerPValues
Dickey-Fuller p Values
tseries::adf.test   Augmented Dickey-Fuller Test
urca::Raotbl1   Data set used by Dickey, Jansen  Thornton
(1994)
urca::Raotbl2   Data set used by Dickey, Jansen  Thornton
(1994)
urca::ur.df Augmented-Dickey-Fuller Unit Root Test
uroot::ADF.rectest  Augmented Dickey-Fuller Recursive Test
uroot::ADF.test Augmented Dickey-Fuller Test


Type '?PKG::FOO' to inspect entry 'PKG::FOO TITLE'.
 


At least ur.df() in urca and IIRC CADFtest() in CADFtest provide arguments for 
lag selection.

HTH,
Bernhard
 

-Ursprüngliche Nachricht-
Von: r-help-boun...@r-project.org 
[mailto:r-help-boun...@r-project.org] Im Auftrag von DongHongwei
Gesendet: Donnerstag, 25. Juni 2009 09:27
An: r-help@r-project.org
Betreff: Re: [R] adf.test Vs ADF.test...



Hi, R users,
I'm using R to test the unit root for my time series data. I 
just compared the ADF.test in uroot package and the 
adf.test in tseries package. It seems it is difficult to 
define the time trend and intercept in adf.test. But it is 
easy to do these in ADF.test. ADF.test also help you find 
the number of lags that need to be included in the model to 
remove the serial correlation. I do not not see adf.test be 
able to do this too. You need to define the number of lags for 
adf.test. 
  I'm a new R user and I could be wrong. I'll appreciate it 
very much if someone familiar with time series in R can give 
me some comments and suggestions. Thanks in advance.

  Harry


 From: dongh...@hotmail.com
 To: patrick.richard...@vai.org; r-help@r-project.org
 Date: Wed, 24 Jun 2009 19:22:46 +
 Subject: Re: [R] Why can't I use ADF.test?
 
 
 Thanks! I tried these, but I got the following 
messages:Warning message:In getDependencies(pkgs, 
dependencies, available, lib) :  package ‘uroot’ 
is not available
 Error in library(uroot) : there is no package called 'uroot'
 
 
 I download a package called uroot and put it into: 
C:\Program Files\R\R-2.9.0\library. But still got the same 
error. Any further suggestions?
   Hongwei 
 
 
  From: patrick.richard...@vai.org
  To: dongh...@hotmail.com; r-help@r-project.org
  Date: Wed, 24 Jun 2009 15:12:22 -0400
  Subject: RE: [R] Why can't I use ADF.test?
  
  Since you provided no code, the following is just a guess,  Try:
  
  install.packages(uroot)
  library(uroot)
  
  Then try your analysis again.
  
  
  -Original Message-
  From: r-help-boun...@r-project.org 
[mailto:r-help-boun...@r-project.org] On Behalf Of DongHongwei
  Sent: Wednesday, June 24, 2009 3:06 PM
  To: r-help@r-project.org
  Subject: [R] Why can't I use ADF.test?
  
  
  Greetings!
  I'm trying to use R to test the unit root for a univariate 
data. By this link: 
  http://rss.acs.unt.edu/Rdoc/library/uroot/html/ADF.test.html
   it tells me that I can use the function ADF.test(). 
However, when I tried this in R, I got this message:
  Error: could not find function ADF.test.
  I'm confused by this. Anyone could give me some hints? Thanks.
  Hongwei
  
  
  
  _
  
´ò¹¤£¬ÕõÇ®£¬Âò·
¿×Ó£¬¿ìÀ´MClubÒ»Æ
𡱽ðÎݲؽ¿¡±£¡
  
 [[alternative HTML version deleted]]
  
  This email message, including any attachments, is for the 
sole use of the intended recipient(s) and may contain 
confidential information.  Any unauthorized review, use, 
disclosure or distribution is prohibited.  If you are not the 
intended recipient(s) please contact the sender by reply email 
and destroy all copies of the original message.  Thank you.
 
 _
 Messenger安全保æŠ
¤ä¸­å¿ƒï¼Œå…è´¹ä¿®å¤ç³»ç»Ÿæ¼
洞,保护Messenger安全!
 http://im.live.cn/safe/
  [[alternative HTML version deleted]]
 

_
打工,挣钱,买房子,快来MClub一起”金屋藏娇”!
http://club.msn.cn/?from=10
   [[alternative HTML version deleted]]


*
Confidentiality Note: The information contained in this message,
and any attachments, may contain confidential and/or privileged
material. It is intended solely for the person(s) or entity to
which it is addressed. Any review, retransmission, dissemination,
or taking of any action in reliance upon 

[R] random sampling or random replacement

2009-06-25 Thread Joanne Demmler

Dear R users,

I'm trying to randomly recreate a real dataset with missing data and I'm 
not quite sure if I can use the sample command for this. I think it 
might be better to do it in 2 steps and randomly replace the sampled 
data with missing data...


So something like this

x - sample(1:2, 100) #without replacement

Now I want x to contain to 20% missing data (NA). Could anyone help me 
how to do this?


Thanks
Joanne

--


Joanne Demmler Ph.D.
Research Assistant
School of Medicine
Swansea University
Singleton Park
Swansea SA2 8PP
UK  


tel:+44 (0)1792 295674
fax:+44 (0)1792 513430
email:  j.demm...@swansea.ac.uk
DECIPHer:   www.decipher.uk.net

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] grid.polygon() + color gradient

2009-06-25 Thread baptiste auguie

Hi,

I don't think the fill parameter can be a colour gradient. You'll need 
to create small polygons, each with its own fill (200, say). Try this,


x= c(0, 0.5, 1)
y= c(0.5, 1, 0.5)
grid.polygon(x=x, y=y, gp=gpar(fill=grey90, col=grey90))

xx - seq(range(x)[1],range(x)[2], length=100)
yy - rep(max(y), length(xx))
cols - colorRampPalette(c(green, lightgray))(length(xx))

for(ii in seq_along(xx[-length(xx)])) {

grid.clip(x=xx[ii], y=0.5,
width= xx[ii+1],
height=1,
just=bottom)

grid.polygon(x=c(0, 0.5, 1), y=c(0.5, 1, 0.5), gp=gpar(fill=cols[ii], 
col=NA))

}

Note that the situation would become rather more complicated for a 
gradient at some angle (see ?grobX if you need to).


If you're free to choose an external tool to produce this, the TeX 
package Tikz has good support for gradients and clipping.


HTH,

baptiste

Kexin Ji wrote:

Hi,

I wonder whether there is a way to generate a polygon (a triangle in  
my case) with color gradient using grid.polygon() in package grid?


I tried something like

library(grid)
grid.polygon(x=c(0, 0.5, 1), y=c(0.5, 1, 0.5), gp=gpar(col=NA,  
fill=colorRampPalette(c(green, lightgray),

space=Lab)(200)))

But am only getting a triangle filled with color green, whereas the  
aim is a triangle of color gradient from green to lightgray.


Can grid.polygon() generate a color gradient, or am I being mistaken?

Best to my knowledge, is it true that R currently doesn't contain any  
other function that might generate a polygon with color gradient?


Thank you!

Kexin


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

  



--
_

Baptiste Auguié

School of Physics
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK

Phone: +44 1392 264187

http://newton.ex.ac.uk/research/emag

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] lm

2009-06-25 Thread Oscar Bayona
Hi all,

I want to make multiple least squares estimation on two matrix (without
intercept)

imagine matrix a and matrix b, I want to regress each colum on matrix
a (dependent variable) on each column of matrix b, I mean, regress first
colum on a to first column on b. Second column on a to second column on b.

Imagine a and b have 200 columns. So I will have 200 estimated
coefficients.

Why this doesn´´ t function?


zza2-function(){

a-read.table(a.txt)
b-read.table(b.txt)

mrp -lm(as.matrix(cbind(a)) ~ 0+as.matrix(cbind(b)))
mr22p-coefficients(mrp)

plot(mr22p)

[[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] grid.polygon() + color gradient

2009-06-25 Thread baptiste auguie

[I neglected to check some details in the previous post]

This one should work better,

library(grid)

x= c(0, 0.5, 1)
y= c(0.5, 1, 0.5)
grid.polygon(x=x, y=y, gp=gpar(fill=NA, col=grey90)) # outer shell

xx - seq(range(x)[1],range(x)[2], length=100)
dx - diff(xx) # width of clipped triangles
cols - colorRampPalette(c(green, lightgray))(length(dx))

for(ii in seq_along(xx[-length(xx)])){
grid.clip(x=xx[ii], y=0.5,
width= 1.2*dx[ii], # fudge factor to overlap well
height=1,
just=bottom)
# if(ii%%2)# testing with every other masked
grid.polygon(x=c(0, 0.5, 1), y=c(0.5, 1, 0.5), gp=gpar(fill=cols[ii], 
col=cols[ii]))

}





HTH,

baptiste

Kexin Ji wrote:

Hi,

I wonder whether there is a way to generate a polygon (a triangle in  
my case) with color gradient using grid.polygon() in package grid?


I tried something like

library(grid)
grid.polygon(x=c(0, 0.5, 1), y=c(0.5, 1, 0.5), gp=gpar(col=NA,  
fill=colorRampPalette(c(green, lightgray),

space=Lab)(200)))

But am only getting a triangle filled with color green, whereas the  
aim is a triangle of color gradient from green to lightgray.


Can grid.polygon() generate a color gradient, or am I being mistaken?

Best to my knowledge, is it true that R currently doesn't contain any  
other function that might generate a polygon with color gradient?


Thank you!

Kexin


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

  



--
_

Baptiste Auguié

School of Physics
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK

Phone: +44 1392 264187

http://newton.ex.ac.uk/research/emag

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


[R] ANOVA with means and SDs as input

2009-06-25 Thread Sebastian Stegmann
Dear R-community,

I'm struggling with a paper that reports only fragmented results of a
2by2by3 experimental design. However, Means and SDs for all cells are given.

Does anyone know a package/function that helps computing an ANOVA with only
Means and SDs as input (resulting in some sort of effect size and
significance test)?

The reason why I'm interested is simple: I'm conducting a meta-analysis. If
I included only what the authors would like to show the world, the results
would be somewhat biased...

I've combed through the web and my various books on R, but it's not that
easy to find. Or is it?

Thanks for your help!
Sebastian

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] random sampling or random replacement

2009-06-25 Thread Paul Chatfield

If you want to average 20% missing values then you could try it in 1 step,
viz:

sample(c(1:2, rep(NA, 2000)),100)

Otherwise, 2 steps is preferable.  Use code as below:

sample(1:2,100)-kk
kk[sample(1:100,20)]-NA

Paul
-- 
View this message in context: 
http://www.nabble.com/random-sampling-or-random-replacement-tp24199695p24200736.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] random sampling or random replacement

2009-06-25 Thread Girish A.R.

Joanne,


[...snip...]

x - sample(1:2, 100) #without replacement

Now I want x to contain to 20% missing data (NA). Could anyone help me 
how to do this?

See if this helps:
n - length(x)
x[sample(n, 0.2*n)] - NA

cheers,
-Girish
-- 
View this message in context: 
http://www.nabble.com/random-sampling-or-random-replacement-tp24199695p24200909.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] ANOVA with means and SDs as input

2009-06-25 Thread Ted Harding
On 25-Jun-09 10:15:30, Sebastian Stegmann wrote:
 Dear R-community,
 I'm struggling with a paper that reports only fragmented results
 of a 2by2by3 experimental design. However, Means and SDs for all
 cells are given.
 
 Does anyone know a package/function that helps computing an ANOVA
 with only Means and SDs as input (resulting in some sort of effect
 size and significance test)?

No hope of that, unless you also have the numbers (N) of observations
in each cell (which of course may be equal across cells). You can get
a mean and an SD with anything from N=2 upwards.

If you do have the Ns, then one way is to construct an artificial
sample for each cell, such that the mean and the SD of each is equal
to the given mean and SD for the cell. Then you can submit the
resulting reconstructed data to a standard lm() in R. and carry
on from there.

The basic construct is:
Let a given cell have N data, mean=M, SD=S.

  X0 - rnorm(N)
  X - M + S*(X0 - mean(X0))/sd(X0)

Assuming you are going to do a standard normal ANOVA, the result
of operating with the above artificial data is algebraically the
same as if you had the true original data.

Hoping this helps!
Ted.

 The reason why I'm interested is simple: I'm conducting a
 meta-analysis. If I included only what the authors would like to
 show the world, the results would be somewhat biased...
 
 I've combed through the web and my various books on R, but it's not
 that easy to find. Or is it?
 
 Thanks for your help!
 Sebastian


E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk
Fax-to-email: +44 (0)870 094 0861
Date: 25-Jun-09   Time: 11:51:38
-- XFMail --

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


[R] normalization in wavelet analysis

2009-06-25 Thread Irina Foss
Dear,

I am using wavelet function from library(dplR), I would like to have a 
normalised spectrum as an output (power relative to white noise).
I was wondering if anyone can help me with that.

Thank you.

irina

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Removed from email list

2009-06-25 Thread Whoriskey, Sophie

Hi,

Could I please be removed from the email list!

Thank you,

Sophie

[[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] RODBC: Trying to read an Excel file

2009-06-25 Thread John Sorkin
R 2.8
Windows XP
Excel 2003

I am trying to read an Excel spread sheet. I have looked at the RODBC help 
pages and am having trouble setting up code that will work. My code and the 
results are pasted below:


 jo-odbcConnectExcel(i:\\all\\sorkinjohn\\stats\\silvermannatalie\\NEMOcombined06-24-09.xls,readOnly
  = TRUE)
 mo-sqlGetResults(jo)
 mo
[1] -1

I have tried to set up the connection string using odbcConnectExcel and then 
have tried to read the file using sqlGetResults. Can someone tell me what I am 
doing wrong?

Thanks,
John

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

Confidentiality Statement:
This email message, including any attachments, is for 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.


[R] variable driven summary of one column

2009-06-25 Thread Anne Skoeries

Hello,

how can I get a variable driven summary of one column of my data.frame?

Usually I would do
 summary(data$columnname) to get a summary of column named  
columnname of my data.frame named data.


In my case the columnname is not static but can be set dynamically.
So I save the chosen columname in something like
variable - columnname
but how can I now get the summary of the specified column?

summary(data$get(variable)) doesn't work.
summary(paste(data$, variable, sep=) doesn't work either!
and if I try
summary(data[get(variable)] it gives me back a different result since  
the data isn't a factor anymore but a list.


Thanks for the help,
Anne

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] stringsAsFactors has no impact in expand.grid()?

2009-06-25 Thread Rainer M Krug
Hi

I have the feeling, that the argument stringsAsFactors has no impact in the
function expand.grid:

a - c(PR, NC, A2, BS)
b - c(1, 0.5, 0.25, 0.125, 0.0625, 0.03125)

class(expand.grid(css, fscs, stringsAsFactors=FALSE)[[1]])
[1] factor
class(expand.grid(css, fscs, stringsAsFactors=TRUE)[[1]])
[1] factor

Also, when I look at the code of expand.grid,  stringsAsFactors does not
occur in the code.

Am I missing something?

 version
   _
platform   i486-pc-linux-gnu
arch   i486
os linux-gnu
system i486, linux-gnu
status
major  2
minor  9.0
year   2009
month  04
day17
svn rev48333
language   R
version.string R version 2.9.0 (2009-04-17)

Cheers,

Rainer
-- 
Rainer M. Krug, Centre of Excellence for Invasion Biology, Stellenbosch
University, South Africa

[[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] List subsetting

2009-06-25 Thread Henrique Dallazuanna
Another options is:

head(lapply(a, tail, 2), 2)

On Wed, Jun 24, 2009 at 8:42 PM, Ivo Shterev idc...@yahoo.com wrote:


 Hello,

 I have a question about list indexing. Lets say we have a list of 3 lists,
 each containing 3 different type elements:

  a=replicate(3, list(list(c(1,1,1), diag(3), c(2,2,2
  a
 [[1]]
 [[1]][[1]]
 [1] 1 1 1

 [[1]][[2]]
 [,1] [,2] [,3]
 [1,]100
 [2,]010
 [3,]001

 [[1]][[3]]
 [1] 2 2 2


 [[2]]
 [[2]][[1]]
 [1] 1 1 1

 [[2]][[2]]
 [,1] [,2] [,3]
 [1,]100
 [2,]010
 [3,]001

 [[2]][[3]]
 [1] 2 2 2


 [[3]]
 [[3]][[1]]
 [1] 1 1 1

 [[3]][[2]]
 [,1] [,2] [,3]
 [1,]100
 [2,]010
 [3,]001

 [[3]][[3]]
 [1] 2 2 2


 If anyone can point a direction as to how to obtain (subset) the following
 list from list a:
  b
 [[1]]
 [[1]][[1]]
 [,1] [,2] [,3]
 [1,]100
 [2,]010
 [3,]001

 [[1]][[2]]
 [1] 2 2 2


 [[2]]
 [[2]][[1]]
 [,1] [,2] [,3]
 [1,]100
 [2,]010
 [3,]001

 [[2]][[2]]
 [1] 2 2 2

 Also, suppose that one wishes to assign the list b to the corresponding
 subset of list a. Is there a way of doing so?

 Thanks for the help.
 Ivo

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




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

[[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] variable driven summary of one column

2009-06-25 Thread Henrique Dallazuanna
Try:

data[,variable]

On Thu, Jun 25, 2009 at 6:44 AM, Anne Skoeries h...@anne-skoeries.dewrote:

 Hello,

 how can I get a variable driven summary of one column of my data.frame?

 Usually I would do
  summary(data$columnname) to get a summary of column named columnname of
 my data.frame named data.

 In my case the columnname is not static but can be set dynamically.
 So I save the chosen columname in something like
 variable - columnname
 but how can I now get the summary of the specified column?

 summary(data$get(variable)) doesn't work.
 summary(paste(data$, variable, sep=) doesn't work either!
 and if I try
 summary(data[get(variable)] it gives me back a different result since the
 data isn't a factor anymore but a list.

 Thanks for the help,
 Anne

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




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

[[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] Using by() and stacking back sub-data frames to one data frame

2009-06-25 Thread jim holtman
One thing you might consider when working with large dataframes is that
instead of partitioning the dataframe into smaller ones, create a list of
indices and use that to access the subset.  Works especially well when using
'lapply' to cromp through many segments of a data frame:

 y
  suid month esr
1  107403412   6
2  1074034 1   2
3  1074034 2   2
4  1074034 3   2
5  107403412   1
6  1074034 1   1
7  1074034 2   1
8  1074034 3   1
9  107403412   2
10 1074034 1   2
11 1074034 2   2
12 1074034 3   2
13 107403412   9
14 1074034 1   9
15 1074034 2   9
16 1074034 3   9
17 112300312   2
18 1123003 1   2
19 1123003 2   2
20 1123003 3   2
 y.ind - split(seq(nrow(y)), y$month)
 y.ind
$`1`
[1]  2  6 10 14 18
$`2`
[1]  3  7 11 15 19
$`3`
[1]  4  8 12 16 20
$`12`
[1]  1  5  9 13 17
 # a subset
 y[y.ind[['12']],]
  suid month esr
1  107403412   6
5  107403412   1
9  107403412   2
13 107403412   9
17 112300312   2



On Wed, Jun 24, 2009 at 11:34 PM, Stephan Lindner lindn...@umich.eduwrote:

 Dear all,


 I have a code where I subset a data frame to match entries within
 levels of an factor (actually, the full script uses three difference
 factors do do that). I'm very happy with the precision with which I can
 work with R, but since I loop over factor levels, and the data frame is
 big, the process is slow. So I've been trying to speed up the process
 using by(), but I got stuck at the point where I want to stack back
 the sub- data frames, and I was wondering whether someone could help me
 out.

 Here is an example:

 --

  y - data.frame(suid  = c(rep(1074034,16),rep(1123003,4)),
 month = rep(c(12,1,2,3),5),
 esr   = c(6,2,2,2,1,1,1,1,2,2,2,2,9,9,9,9,2,2,2,2))


  by(y,y$month,function(x)return(x))

 y$month: 1
  suid month esr
 2  1074034 1   2
 6  1074034 1   1
 10 1074034 1   2
 14 1074034 1   9
 18 1123003 1   2
 
 y$month: 2
  suid month esr
 3  1074034 2   2
 7  1074034 2   1
 11 1074034 2   2
 15 1074034 2   9
 19 1123003 2   2
 
 y$month: 3
  suid month esr
 4  1074034 3   2
 8  1074034 3   1
 12 1074034 3   2
 16 1074034 3   9
 20 1123003 3   2
 
 y$month: 12
  suid month esr
 1  107403412   6
 5  107403412   1
 9  107403412   2
 13 107403412   9
 17 112300312   2

 --

 What I would like to do is stacking these four data frames back to one
 data frame, which in this simple example would just be y. I tried
 unlist(), unclass() and rbind(), but none of them would work.


 Thanks a lot,



Stephan










 --
 ---
 Stephan Lindner
 University of Michigan

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.htmlhttp://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] stringsAsFactors has no impact in expand.grid()?

2009-06-25 Thread Henrique Dallazuanna
I also not find this in the source code, but you can rewrite the function
with this:

expand.grid -
function (..., KEEP.OUT.ATTRS = TRUE, stringsAsFactors = FALSE)
{
nargs - length(args - list(...))
if (!nargs)
return(as.data.frame(list()))
if (nargs == 1L  is.list(a1 - args[[1L]]))
nargs - length(args - a1)
if (nargs == 0L)
return(as.data.frame(list()))
cargs - args
iArgs - seq_len(nargs)
nmc - paste(Var, iArgs, sep = )
nm - names(args)
if (is.null(nm))
nm - nmc
else if (any(ng0 - nzchar(nm)))
nmc[ng0] - nm[ng0]
names(cargs) - nmc
rep.fac - 1L
d - sapply(args, length)
if (KEEP.OUT.ATTRS) {
dn - vector(list, nargs)
names(dn) - nmc
}
orep - prod(d)
if (orep == 0L) {
for (i in iArgs) cargs[[i]] - args[[i]][FALSE]
}
else {
for (i in iArgs) {
x - args[[i]]
if (KEEP.OUT.ATTRS)
dn[[i]] - paste(nmc[i], =, if (is.numeric(x))
  format(x)
else x, sep = )
nx - length(x)
orep - orep/nx
x - x[rep.int(rep.int(seq_len(nx), rep.int(rep.fac,
nx)), orep)]
if(stringsAsFactors){
if (!is.factor(x)  is.character(x))
x - factor(x, levels = unique(x))
}else{
x
}
cargs[[i]] - x
rep.fac - rep.fac * nx
}
}
if (KEEP.OUT.ATTRS)
attr(cargs, out.attrs) - list(dim = d, dimnames = dn)
rn - .set_row_names(as.integer(prod(d)))
structure(cargs, class = data.frame, row.names = rn)
}

On Thu, Jun 25, 2009 at 8:21 AM, Rainer M Krug r.m.k...@gmail.com wrote:

 Hi

 I have the feeling, that the argument stringsAsFactors has no impact in the
 function expand.grid:

 a - c(PR, NC, A2, BS)
 b - c(1, 0.5, 0.25, 0.125, 0.0625, 0.03125)

 class(expand.grid(css, fscs, stringsAsFactors=FALSE)[[1]])
 [1] factor
 class(expand.grid(css, fscs, stringsAsFactors=TRUE)[[1]])
 [1] factor

 Also, when I look at the code of expand.grid,  stringsAsFactors does not
 occur in the code.

 Am I missing something?

  version
   _
 platform   i486-pc-linux-gnu
 arch   i486
 os linux-gnu
 system i486, linux-gnu
 status
 major  2
 minor  9.0
 year   2009
 month  04
 day17
 svn rev48333
 language   R
 version.string R version 2.9.0 (2009-04-17)

 Cheers,

 Rainer
 --
 Rainer M. Krug, Centre of Excellence for Invasion Biology, Stellenbosch
 University, South Africa

[[alternative HTML version deleted]]

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




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

[[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] Apply as.factor (or as.numeric etc) to multiple columns

2009-06-25 Thread Gabor Grothendieck
That's quite nice.   Three comments:

- colClasses() in R.utils is similar, except for the particular
codes and classes supported, to expandClasses() here.

- not sure if this is important but if as() were the last
possibility tried rather than the first then in most
cases (in fact all cases handled by expandClasses() )
there would be no use of the methods package.

- paste(as, ...) handles all the common cases including
all cases handled by expandClasses() except NA_character_
and could be used as a poor man's doCoerce().

On Thu, Jun 25, 2009 at 3:43 AM, Bengoechea Bartolomé Enrique (SIES
73)enrique.bengoec...@credit-suisse.com wrote:
 Hi Mark,

 I frequently need to do that when importing data. This one-liner works:

 data.frame(mapply(as, x, c(integer, character, factor), 
 SIMPLIFY=FALSE), stringsAsFactors=FALSE);

 but it has two problems:

 1) as() is an S4 method that does not always work
 2) writting the vector of classes for 60 variables is rather tedious.

 Both issues can be solved with the following two helper functions. The first 
 function tries to use as(x, class); if it doesn't work, tries as.class(x); 
 If it still doesn't work, tries class(x). The second function tranforms a 
 single string to a character vector of classes, by transforming each letter 
 in the string to a class name (i.e. D is tranformed to Date, i to 
 integer, etc.), so that writting 60 classes is fast.

 doCoerce - function(x, class) {
        if (canCoerce(x, class))
                as(x, class)
        else {
                result - try(match.fun(paste(as, class, sep=.))(x), 
 silent=TRUE);
                if (inherits(result, try-error))
                        result - match.fun(class)(x)
                result;
    }
 }

 expandClasses - function (x) {
    unknowns - character(0)
    result - lapply(strsplit(as.character(x), NULL, fixed = TRUE),
        function(y) {
            sapply(y, function(z) switch(z,
                        i = integer, n = numeric,
                l = logical, c = character, x = complex,
                r = raw, f = factor, D = Date, P = POSIXct,
                t = POSIXlt, N = NA_character_, {
                  unknowns - c(unknowns, z)
                  NA_character_
                }), USE.NAMES = FALSE)
        })
    if (length(unknowns)) {
        unknowns - unique(unknowns)
        warning(sprintf(ngettext(length(unknowns), code %s not recognized,
            codes %s not recognized), dqMsg(unknowns)))
    }
    result
 }

 An example:

 x - data.frame(X=2008-01-01, Y=1.1:3.1, Z=letters[1:3])
 data.frame(mapply(doCoerce, x, expandClasses(Dif)[[1L]], SIMPLIFY=FALSE), 
 stringsAsFactors=FALSE);

 Regards,

 Enrique


 --

 Message: 99
 Date: Tue, 23 Jun 2009 15:23:54 -0600
 From: Mark Na mtb...@gmail.com
 Subject: [R] Apply as.factor (or as.numeric etc) to multiple columns
 To: r-help@r-project.org
 Message-ID:
        e40d78ce0906231423m4c3da14i2f6270f92463c...@mail.gmail.com
 Content-Type: text/plain; charset=ISO-8859-1

 Hi R-helpers,

 I have a dataframe with 60columns and I would like to convert several
 columns to factor, others to numeric, and yet others to dates. Rather
 than having 60 lines like this:

 data$Var1-as.factor(data$Var1)

 I wonder if it's possible to write one line of code (per data type,
 e.g. factor) that would apply a function (e.g., as.factor) to several
 (non-contiguous) columns. So, I could then use 3 or 4 lines of code
 (for 3 or 4 data types) instead of 60.

 I have tried writing an apply function, but it failed.

 Thanks for any help you might be able to provide.

 Mark Na

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] RODBC: Trying to read an Excel file

2009-06-25 Thread Jorge Ivan Velez
Dear John,
Try this:

require(RODBC)
spreadsheet - Sheet1  # please change this to your needs
channel -
odbcConnectExcel(i:\\all\\sorkinjohn\\stats\\silvermannatalie\\NEMOcombined06-24-09.xls)
mydata - sqlFetch(channel, spreadsheet)
odbcClose(channel)
# attach(mydata)
mydata

HTH,

Jorge


On Thu, Jun 25, 2009 at 7:20 AM, John Sorkin jsor...@grecc.umaryland.eduwrote:

 R 2.8
 Windows XP
 Excel 2003

 I am trying to read an Excel spread sheet. I have looked at the RODBC help
 pages and am having trouble setting up code that will work. My code and the
 results are pasted below:


 
 jo-odbcConnectExcel(i:\\all\\sorkinjohn\\stats\\silvermannatalie\\NEMOcombined06-24-09.xls,readOnly
 = TRUE)
  mo-sqlGetResults(jo)
  mo
 [1] -1

 I have tried to set up the connection string using odbcConnectExcel and
 then have tried to read the file using sqlGetResults. Can someone tell me
 what I am doing wrong?

 Thanks,
 John

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

 Confidentiality Statement:
 This email message, including any attachments, is for ...{{dropped:13}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] get, put, post implementation

2009-06-25 Thread Thomas . Bock
Dear List,

I'm searching for a way (package, function or something) providing
the http PUT, GET POST ... methods in R. httpRequest and RCurl
seems to have a lack of the PUT method.

Regards
Thomas



|| Thomas Bock c/o Physikalisch-Technische Bundesanstalt
|| Abbestr. 2-12, D-10587 Berlin, Germany
|| Tel/Fax: ++49-30-3481-7354/7490, email: thomas.b...@ptb.de
[[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] RODBC: Trying to read an Excel file

2009-06-25 Thread Rodrigo Aluizio
Try the function sqlFetch to import the data in the spreadsheet.

jo-odbcConnectExcel(i:\\all\\sorkinjohn\\stats\\silvermannatalie\\NEMOcomb
ined06-24-09.xls,readOnly = TRUE)
mo-sqlFetch(jo,'Your Sheet Name or Number',colnames=F,rownames=F)
mo

Hope it helps.


-
MSc. Rodrigo Aluizio
Centro de Estudos do Mar/UFPR
Laboratório de Micropaleontologia
Avenida Beira Mar s/n - CEP 83255-000
Pontal do Paraná - PR - Brasil


-Mensagem original-
De: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Em
nome de John Sorkin
Enviada em: quinta-feira, 25 de junho de 2009 08:21
Para: r-help@r-project.org
Assunto: [R] RODBC: Trying to read an Excel file

R 2.8
Windows XP
Excel 2003

I am trying to read an Excel spread sheet. I have looked at the RODBC help
pages and am having trouble setting up code that will work. My code and the
results are pasted below:



jo-odbcConnectExcel(i:\\all\\sorkinjohn\\stats\\silvermannatalie\\NEMOcomb
ined06-24-09.xls,readOnly = TRUE)
 mo-sqlGetResults(jo)
 mo
[1] -1

I have tried to set up the connection string using odbcConnectExcel and then
have tried to read the file using sqlGetResults. Can someone tell me what I
am doing wrong?

Thanks,
John

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

Confidentiality Statement:
This email message, including any attachments, is for th...{{dropped:9}}

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


Re: [R] change the height or scale of the y axis

2009-06-25 Thread Jim Lemon

legen wrote:

Hallo, All,

I have a question about changing the height or scale of the y axis. When I
use following two R codes, I can get two plots. Please look at the y axes,
the number of indices (x1, x2, …) on the y axis in the first plot is smaller
than that in the second plot, and hence the space between any two indices in
the first plot is wider than that in the second plot. As the number of
indices increases, the space will vanish and the indices will overlap. I
want to display all the indices on the y axis in the second plot, just look
like that in the first plot. How to separate the indices on the y axis in
the second plot? I guess maybe changing the height or scale of y axis is a
way to solve my problem, but I failed to do it after several trails. Anybody
can help me? Thank you in advance.

Legen

The first R code:
x-c(x1,x2,x3,x4,x5,x6,x7,x8,x9,x10)
y-sample(0:100,10,replace=F)
d-data.frame(y)
rownames(d)-x
r-nrow(d)
i-1:r
plot(d$y,i,xlab=,ylab=,axes=F)
axis(1)
axis(2,at=i,labels=x)

The second R code:
x-c(x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,
 x11,x12,x13,x14,x15,x16,x17,x18,x19,x20,
 x21,x22,x23,x24,x25,x26,x27,x28,x29,x30,
 x31,x32,x33,x34,x35,x36,x37,x38,x39,x40,
 x41,x42,x43,x44,x45,x46,x47,x48,x49,x50,
 x51,x52,x53,x54,x55,x56,x57,x58,x59,x60,
 x61,x62,x63,x64,x65,x66,x67,x68,x69,x70,
 x71,x72,x73,x74,x75,x76,x77,x78,x79,x80,
 x81,x82,x83,x84,x85,x86,x87,x88,x89,x90,
 x91,x92,x93,x94,x95,x96,x97,x98,x99,x100,
 x101,x102,x103,x104,x105,x106,x107,x108,x109,x110,
 x111,x112,x113,x114,x115,x116,x117,x118,x119,x120,
 x121,x122,x123,x124,x125,x126,x127,x128,x129,x130,
 x131,x132,x133,x134,x135,x136,x137,x138,x139,x140,
 x141,x142,x143,x144,x145,x146,x147,x148,x149,x150,
 x151,x152,x153,x154,x155,x156,x157,x158,x159,x160,
 x161,x162,x163,x164,x165,x166,x167,x168,x169,x170,
 x171,x172,x173,x174,x175,x176,x177,x178,x179,x180,
 x181,x182,x183,x184,x185,x186,x187,x188,x189,x190,
 x191,x192,x193,x194,x195,x196,x197,x198,x199,x200)
y-sample(0:300,200,replace=F)
d-data.frame(y)
rownames(d)-x
r-nrow(d)
i-1:r
plot(d$y,i,xlab=,ylab=,axes=F)
axis(1)
axis(2,at=i,labels=x)

  

Hi legen,
Your problem centers about the fact that you have about 3 times the 
vertical scale on the second plot and 20 times the number of ticks and 
labels. You could make the second plot 3 times the height of the first 
one, and you would get approximately the same spacing of equal 
intervals, but the intervals on the second plot are likely to be about 
1.5 times those of the first. I can't work out why you are trying to do 
what you say you want to do. Maybe some more explanation would help.


Jim

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Apply as.factor (or as.numeric etc) to multiple columns

2009-06-25 Thread SIES 73
Very good points  :-)

 - colClasses() in R.utils is similar, except for the particular codes and 
 classes supported, to expandClasses() here.

In fact I saw colClasses() once and got the idea from it, but when I needed the 
functionallity I did not remember where had I seen it and rewrote it. Now with 
your hint I can reuse colClasses() instead.  I also use a similar function to 
facilitate writting long logical vectors: expandLogical(TFTFNFFFTN)

So, with your suggestions:

 x - data.frame(X=2008-01-01, Y=1.1:3.1, Z=letters[1:3]) 
 data.frame(mapply(function(x, class) match.fun(paste(as, class, 
 sep=.))(x), x, colClasses(Dif), SIMPLIFY=FALSE), stringsAsFactors=FALSE)

Enrique

-Original Message-
From: Gabor Grothendieck [mailto:ggrothendi...@gmail.com] 
Sent: jueves, 25 de junio de 2009 13:41
To: Bengoechea Bartolomé Enrique (SIES 73)
Cc: r-help@r-project.org; mtb...@gmail.com
Subject: Re: [R] Apply as.factor (or as.numeric etc) to multiple columns

That's quite nice.   Three comments:

- colClasses() in R.utils is similar, except for the particular codes and 
classes supported, to expandClasses() here.

- not sure if this is important but if as() were the last possibility tried 
rather than the first then in most cases (in fact all cases handled by 
expandClasses() ) there would be no use of the methods package.

- paste(as, ...) handles all the common cases including all cases handled by 
expandClasses() except NA_character_ and could be used as a poor man's 
doCoerce().

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] lm

2009-06-25 Thread Jorge Ivan Velez
Dear Oscar,
Try this:

# Some data
set.seed(123)
a - matrix(rnorm(100*200), ncol = 200)
b - matrix(rnorm(100*200), ncol = 200)

# Auxiliar function to extract the coefficient
# after fitting models without intercept
mycoef - function(x, y) coefficients( lm(y ~ x - 1) )

# Results
res - sapply(1:200, function(i){
   y - a[,i]
   x - b[,i]
  mycoef(x,y)
   }
)

plot(res)

HTH,

Jorge


On Thu, Jun 25, 2009 at 5:46 AM, Oscar Bayona osba...@gmail.com wrote:

 Hi all,

 I want to make multiple least squares estimation on two matrix (without
 intercept)

 imagine matrix a and matrix b, I want to regress each colum on matrix
 a (dependent variable) on each column of matrix b, I mean, regress first
 colum on a to first column on b. Second column on a to second column on b.

 Imagine a and b have 200 columns. So I will have 200 estimated
 coefficients.

 Why this doesn´´ t function?


 zza2-function(){

 a-read.table(a.txt)
 b-read.table(b.txt)

 mrp -lm(as.matrix(cbind(a)) ~ 0+as.matrix(cbind(b)))
 mr22p-coefficients(mrp)

 plot(mr22p)

[[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] stringsAsFactors has no impact in expand.grid()?

2009-06-25 Thread Rainer M Krug
On Thu, Jun 25, 2009 at 1:38 PM, Henrique Dallazuanna www...@gmail.comwrote:

 I also not find this in the source code, but you can rewrite the function
 with this:


That's true - but this should be fixed in the package itself. I have just
converted the factor to characters.

Cheers

Rainer



 expand.grid -
 function (..., KEEP.OUT.ATTRS = TRUE, stringsAsFactors = FALSE)
 {
 nargs - length(args - list(...))
 if (!nargs)
 return(as.data.frame(list()))
 if (nargs == 1L  is.list(a1 - args[[1L]]))
 nargs - length(args - a1)
 if (nargs == 0L)
 return(as.data.frame(list()))
 cargs - args
 iArgs - seq_len(nargs)
 nmc - paste(Var, iArgs, sep = )
 nm - names(args)
 if (is.null(nm))
 nm - nmc
 else if (any(ng0 - nzchar(nm)))
 nmc[ng0] - nm[ng0]
 names(cargs) - nmc
 rep.fac - 1L
 d - sapply(args, length)
 if (KEEP.OUT.ATTRS) {
 dn - vector(list, nargs)
 names(dn) - nmc
 }
 orep - prod(d)
 if (orep == 0L) {
 for (i in iArgs) cargs[[i]] - args[[i]][FALSE]
 }
 else {
 for (i in iArgs) {
 x - args[[i]]
 if (KEEP.OUT.ATTRS)
 dn[[i]] - paste(nmc[i], =, if (is.numeric(x))
   format(x)
 else x, sep = )
 nx - length(x)
 orep - orep/nx
 x - x[rep.int(rep.int(seq_len(nx), rep.int(rep.fac,
 nx)), orep)]
 if(stringsAsFactors){
 if (!is.factor(x)  is.character(x))
 x - factor(x, levels = unique(x))
 }else{
 x
 }
 cargs[[i]] - x
 rep.fac - rep.fac * nx
 }
 }
 if (KEEP.OUT.ATTRS)
 attr(cargs, out.attrs) - list(dim = d, dimnames = dn)
 rn - .set_row_names(as.integer(prod(d)))
 structure(cargs, class = data.frame, row.names = rn)
 }

 On Thu, Jun 25, 2009 at 8:21 AM, Rainer M Krug r.m.k...@gmail.com wrote:

 Hi

 I have the feeling, that the argument stringsAsFactors has no impact in
 the
 function expand.grid:

 a - c(PR, NC, A2, BS)
 b - c(1, 0.5, 0.25, 0.125, 0.0625, 0.03125)

 class(expand.grid(css, fscs, stringsAsFactors=FALSE)[[1]])
 [1] factor
 class(expand.grid(css, fscs, stringsAsFactors=TRUE)[[1]])
 [1] factor

 Also, when I look at the code of expand.grid,  stringsAsFactors does not
 occur in the code.

 Am I missing something?

  version
   _
 platform   i486-pc-linux-gnu
 arch   i486
 os linux-gnu
 system i486, linux-gnu
 status
 major  2
 minor  9.0
 year   2009
 month  04
 day17
 svn rev48333
 language   R
 version.string R version 2.9.0 (2009-04-17)

 Cheers,

 Rainer
 --
 Rainer M. Krug, Centre of Excellence for Invasion Biology, Stellenbosch
 University, South Africa

[[alternative HTML version deleted]]

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




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




-- 
Rainer M. Krug, Centre of Excellence for Invasion Biology, Stellenbosch
University, South Africa

[[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] Coxph frailty model counting process error X matrix deemed singular

2009-06-25 Thread Terry Therneau
...
 Occasionally, (about 1 in every 100 simulations) I get the following warning: 
 Error in coxph(Surv(start, end, censorind) ~ binary + uniform  : 
 X matrix deemed to be singular; variable 2

   It is not uncommon for the X matrix in a Cox model to be close enough to 
singular that the program thinks it is singular, i.e., one of the pivot 
elements 
falls below the tolerance threshold while performing a Cholesky decomposition.  
To understand your case better you need to capture one of the offending data 
sets and look at the X matrix.  I am not going to be able to guess.
   
   I normally ignore this (the indeterminate coefficient is set to NA) and  go 
on.  You however have chosen to override the default and set singular.ok=FALSE 
so that the program fails with an error message.  You get what you asked for.
   
  Last, I am always surprised when people chose method='breslow' in coxph.  Why 
substitute an inferior approximation for the better one?  Of course with 
simulated data there are no ties, in which case all the methods are identical.
   
Terry Therneau

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] variable driven summary of one column

2009-06-25 Thread Chuck Cleland
On 6/25/2009 5:44 AM, Anne Skoeries wrote:
 Hello,
 
 how can I get a variable driven summary of one column of my data.frame?
 
 Usually I would do
 summary(data$columnname) to get a summary of column named columnname
 of my data.frame named data.
 
 In my case the columnname is not static but can be set dynamically.
 So I save the chosen columname in something like
 variable - columnname
 but how can I now get the summary of the specified column?
 
 summary(data$get(variable)) doesn't work.
 summary(paste(data$, variable, sep=) doesn't work either!
 and if I try
 summary(data[get(variable)] it gives me back a different result since
 the data isn't a factor anymore but a list.

vname - Species

summary(subset(iris, select=vname))
   Species
 setosa:50
 versicolor:50
 virginica :50

vname - Sepal.Width

summary(subset(iris, select=vname))
  Sepal.Width
 Min.   :2.000
 1st Qu.:2.800
 Median :3.000
 Mean   :3.057
 3rd Qu.:3.300
 Max.   :4.400

 Thanks for the help,
 Anne
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] GeoXp package

2009-06-25 Thread epoizot



Zeljko Vrba wrote:
 
 On Wed, Jun 10, 2009 at 08:21:06AM +0200, Poizot Emmanuel wrote:
 Error in fun(...) :
GDAL Error 1: libgrass_I.so: Ne peut ouvrir le fichier d'objet 
 partagé: Aucun fichier ou dossier de ce type  (sorry  for the french :) )
 
 
 It would have been far more useful had you translated the error message to
 english than to have apologized.
 
 Try doing
 
 export LD_LIBRARY_PATH=/path/to/dir/where/so/is/located
 
 before starting R from the shell.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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,

I tried this but with no success. Still enable to load the library rgdal and
so GeoXp.
This problem of for me now of high importance as I need to export
interpolated data sets to grids. and rgdal allows that kind of operations.
Regards
-- 
View this message in context: 
http://www.nabble.com/GeoXp-package-tp23964536p24201943.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] stringsAsFactors has no impact in expand.grid()?

2009-06-25 Thread Gabor Grothendieck
It works for me.  Try a more recent version of R.

 a - c(PR, NC, A2, BS)
 b - c(1, 0.5, 0.25, 0.125, 0.0625, 0.03125)

 class(expand.grid(a, b, stringsAsFactors=FALSE)[[1]])
[1] character
 class(expand.grid(a, b, stringsAsFactors=TRUE)[[1]])
[1] factor

 R.version.string
[1] R version 2.9.1 RC (2009-06-19 r48804)


On Thu, Jun 25, 2009 at 7:21 AM, Rainer M Krugr.m.k...@gmail.com wrote:
 Hi

 I have the feeling, that the argument stringsAsFactors has no impact in the
 function expand.grid:

 a - c(PR, NC, A2, BS)
 b - c(1, 0.5, 0.25, 0.125, 0.0625, 0.03125)

 class(expand.grid(css, fscs, stringsAsFactors=FALSE)[[1]])
 [1] factor
 class(expand.grid(css, fscs, stringsAsFactors=TRUE)[[1]])
 [1] factor

 Also, when I look at the code of expand.grid,  stringsAsFactors does not
 occur in the code.

 Am I missing something?

 version
               _
 platform       i486-pc-linux-gnu
 arch           i486
 os             linux-gnu
 system         i486, linux-gnu
 status
 major          2
 minor          9.0
 year           2009
 month          04
 day            17
 svn rev        48333
 language       R
 version.string R version 2.9.0 (2009-04-17)

 Cheers,

 Rainer
 --
 Rainer M. Krug, Centre of Excellence for Invasion Biology, Stellenbosch
 University, South Africa

        [[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] Using by() and stacking back sub-data frames to one data frame

2009-06-25 Thread hadley wickham
Have a look at ddply from the plyr package, http://had.co.nz/plyr.
It's made for exactly this type of operation.

Hadley

On Wed, Jun 24, 2009 at 10:34 PM, Stephan Lindnerlindn...@umich.edu wrote:
 Dear all,


 I have a code where I subset a data frame to match entries within
 levels of an factor (actually, the full script uses three difference
 factors do do that). I'm very happy with the precision with which I can
 work with R, but since I loop over factor levels, and the data frame is
 big, the process is slow. So I've been trying to speed up the process
 using by(), but I got stuck at the point where I want to stack back
 the sub- data frames, and I was wondering whether someone could help me
 out.

 Here is an example:

 --

 y - data.frame(suid  = c(rep(1074034,16),rep(1123003,4)),
                 month = rep(c(12,1,2,3),5),
                 esr   = c(6,2,2,2,1,1,1,1,2,2,2,2,9,9,9,9,2,2,2,2))


 by(y,y$month,function(x)return(x))

 y$month: 1
      suid month esr
 2  1074034     1   2
 6  1074034     1   1
 10 1074034     1   2
 14 1074034     1   9
 18 1123003     1   2
 
 y$month: 2
      suid month esr
 3  1074034     2   2
 7  1074034     2   1
 11 1074034     2   2
 15 1074034     2   9
 19 1123003     2   2
 
 y$month: 3
      suid month esr
 4  1074034     3   2
 8  1074034     3   1
 12 1074034     3   2
 16 1074034     3   9
 20 1123003     3   2
 
 y$month: 12
      suid month esr
 1  1074034    12   6
 5  1074034    12   1
 9  1074034    12   2
 13 1074034    12   9
 17 1123003    12   2

 --

 What I would like to do is stacking these four data frames back to one
 data frame, which in this simple example would just be y. I tried
 unlist(), unclass() and rbind(), but none of them would work.


 Thanks a lot,



        Stephan










 --
 ---
 Stephan Lindner
 University of Michigan

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




-- 
http://had.co.nz/

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


Re: [R] stringsAsFactors has no impact in expand.grid()?

2009-06-25 Thread Rainer M Krug
On Thu, Jun 25, 2009 at 2:55 PM, Gabor Grothendieck ggrothendi...@gmail.com
 wrote:

 It works for me.  Try a more recent version of R.


Good to see that it is fixed in 2.9.1. I am using the latest release and am
going to wait till 2.9.1 is released.

Thanks,

Rainer



  a - c(PR, NC, A2, BS)
  b - c(1, 0.5, 0.25, 0.125, 0.0625, 0.03125)
 
  class(expand.grid(a, b, stringsAsFactors=FALSE)[[1]])
 [1] character
  class(expand.grid(a, b, stringsAsFactors=TRUE)[[1]])
 [1] factor

  R.version.string
 [1] R version 2.9.1 RC (2009-06-19 r48804)


 On Thu, Jun 25, 2009 at 7:21 AM, Rainer M Krugr.m.k...@gmail.com wrote:
  Hi
 
  I have the feeling, that the argument stringsAsFactors has no impact in
 the
  function expand.grid:
 
  a - c(PR, NC, A2, BS)
  b - c(1, 0.5, 0.25, 0.125, 0.0625, 0.03125)
 
  class(expand.grid(css, fscs, stringsAsFactors=FALSE)[[1]])
  [1] factor
  class(expand.grid(css, fscs, stringsAsFactors=TRUE)[[1]])
  [1] factor
 
  Also, when I look at the code of expand.grid,  stringsAsFactors does not
  occur in the code.
 
  Am I missing something?
 
  version
_
  platform   i486-pc-linux-gnu
  arch   i486
  os linux-gnu
  system i486, linux-gnu
  status
  major  2
  minor  9.0
  year   2009
  month  04
  day17
  svn rev48333
  language   R
  version.string R version 2.9.0 (2009-04-17)
 
  Cheers,
 
  Rainer
  --
  Rainer M. Krug, Centre of Excellence for Invasion Biology, Stellenbosch
  University, South Africa
 
 [[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.
 




-- 
Rainer M. Krug, Centre of Excellence for Invasion Biology, Stellenbosch
University, South Africa

[[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] Using by() and stacking back sub-data frames to one data frame

2009-06-25 Thread David Winsemius
Your request for a more general approach is precisely the reason that  
Hadley Wickham wrote the plyr package. He describes a split-apply- 
combine strategy for a variety of data structures and tools to  
implement those strategies here:


http://had.co.nz/plyr/plyr-intro-090510.pdf

The argument to the by stp is a column name rather than a list or  
object as it would be in tapply or split. I is just the identity  
function which doubles for return(x) in your code.


library(plyr)
 ddply(y, month, fun=I)
  suid month esr
1  1074034 1   2
2  1074034 1   1
3  1074034 1   2
4  1074034 1   9
5  1123003 1   2
6  1074034 2   2
7  1074034 2   1
8  1074034 2   2
9  1074034 2   9
10 1123003 2   2
11 1074034 3   2
12 1074034 3   1
13 1074034 3   2
14 1074034 3   9
15 1123003 3   2
16 107403412   6
17 107403412   1
18 107403412   2
19 107403412   9
20 112300312   2

On Jun 24, 2009, at 11:34 PM, Stephan Lindner wrote:


Dear all,


I have a code where I subset a data frame to match entries within
levels of an factor (actually, the full script uses three difference
factors do do that). I'm very happy with the precision with which I  
can
work with R, but since I loop over factor levels, and the data frame  
is

big, the process is slow. So I've been trying to speed up the process
using by(), but I got stuck at the point where I want to stack back
the sub- data frames, and I was wondering whether someone could help  
me

out.

Here is an example:

--


y - data.frame(suid  = c(rep(1074034,16),rep(1123003,4)),

month = rep(c(12,1,2,3),5),
esr   = c(6,2,2,2,1,1,1,1,2,2,2,2,9,9,9,9,2,2,2,2))



by(y,y$month,function(x)return(x))


y$month: 1
 suid month esr
2  1074034 1   2
6  1074034 1   1
10 1074034 1   2
14 1074034 1   9
18 1123003 1   2

y$month: 2
 suid month esr
3  1074034 2   2
7  1074034 2   1
11 1074034 2   2
15 1074034 2   9
19 1123003 2   2

y$month: 3
 suid month esr
4  1074034 3   2
8  1074034 3   1
12 1074034 3   2
16 1074034 3   9
20 1123003 3   2

y$month: 12
 suid month esr
1  107403412   6
5  107403412   1
9  107403412   2
13 107403412   9
17 112300312   2

--

What I would like to do is stacking these four data frames back to one
data frame, which in this simple example would just be y. I tried
unlist(), unclass() and rbind(), but none of them would work.


Thanks a lot,



Stephan










--
---
Stephan Lindner
University of Michigan

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] get a dataframe subset based on time interval

2009-06-25 Thread Paulo E. Cardoso
Hi,

I have a big dataframe with a POSIXct column and I'd like to extract a
subset contained in a given time interval, from Date 1 to Date 2.


Paulo E. Cardoso

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] ANOVA with means and SDs as input

2009-06-25 Thread Richard M. Heiberger

Look at the anova.mean function in the HH package.
It does what you are asking, although limited to one-way ANOVA.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Efficient lookup on a two-dimensional table

2009-06-25 Thread Rama Ramakrishnan
Dear R-Users,
I need to lookup values from a 2-d table using the row names and column
names as indices. I was wondering if there's a way to do this without an
explicit loop.

Example:
#x is the 2-d table that holds the values

x - matrix(rnorm(26*12),nrow=26)

rownames(x) - letters

colnames(x) - month.name


#y is a data frame that has the keys I want to use as indices into x

y - data.frame(ltrs=sample(letters,5),mnths=sample(month.name,5),values=0)


#I want to fill in the values column using the ltrs and mnths columns
as keys to look up

# the associated value from x

#One way to do this is with a FOR loop

for (i in 1:nrow(y)) {y$val[i] - x[y$ltrs[i],y$mnths[i]]}


My question: Is there a more efficient way (e.g., one without using an
explicit loop) to do this?


Thanks in advance!


-Rama Ramakrishnan

[[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] Fwd: Efficient lookup on a two-dimensional table

2009-06-25 Thread Rama Ramakrishnan
Resending after fixing a mistake in the earlier email ... sorry for the
confusion.

**
Dear R-Users,
I need to lookup values from a 2-d table using the row names and column
names as indices. I was wondering if there's a way to do this without an
explicit loop.

Example:
#x is the 2-d table that holds the values

x - matrix(rnorm(26*12),nrow=26)

rownames(x) - letters

colnames(x) - month.name


#y is a data frame that has the keys I want to use as indices into x

y - data.frame(ltrs=sample(letters,5),mnths=sample(month.name,5),values=0)


#I want to fill in the values column using the ltrs and mnths columns
as keys to look up

# the associated value from x

#One way to do this is with a FOR loop


for (i in 1:nrow(y)) {y$values[i] - x[as.character(y$ltrs[i]),as.character(
y$mnths[i])]}


My question: Is there a more efficient way (e.g., one without using an
explicit loop) to do this?


Thanks in advance!


-Rama Ramakrishnan

[[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] Efficient lookup on a two-dimensional table

2009-06-25 Thread Rama Ramakrishnan
That works!! Very nice way to do it! Thank you, Henrique!
Rama Ramakrishnan

On Thu, Jun 25, 2009 at 10:11 AM, Henrique Dallazuanna www...@gmail.comwrote:

 Try this:

 y$values - diag(x[y$ltrs, y$mnths])

 On Thu, Jun 25, 2009 at 11:02 AM, Rama Ramakrishnan r...@alum.mit.eduwrote:

 Dear R-Users,
 I need to lookup values from a 2-d table using the row names and column
 names as indices. I was wondering if there's a way to do this without an
 explicit loop.

 Example:
 #x is the 2-d table that holds the values

 x - matrix(rnorm(26*12),nrow=26)

 rownames(x) - letters

 colnames(x) - month.name


 #y is a data frame that has the keys I want to use as indices into x

 y - data.frame(ltrs=sample(letters,5),mnths=sample(month.name
 ,5),values=0)


 #I want to fill in the values column using the ltrs and mnths
 columns
 as keys to look up

 # the associated value from x

 #One way to do this is with a FOR loop

 for (i in 1:nrow(y)) {y$val[i] - x[y$ltrs[i],y$mnths[i]]}


 My question: Is there a more efficient way (e.g., one without using an
 explicit loop) to do this?


 Thanks in advance!


 -Rama Ramakrishnan

[[alternative HTML version deleted]]

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




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


[[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] Efficient lookup on a two-dimensional table

2009-06-25 Thread Henrique Dallazuanna
Try this:

y$values - diag(x[y$ltrs, y$mnths])

On Thu, Jun 25, 2009 at 11:02 AM, Rama Ramakrishnan r...@alum.mit.eduwrote:

 Dear R-Users,
 I need to lookup values from a 2-d table using the row names and column
 names as indices. I was wondering if there's a way to do this without an
 explicit loop.

 Example:
 #x is the 2-d table that holds the values

 x - matrix(rnorm(26*12),nrow=26)

 rownames(x) - letters

 colnames(x) - month.name


 #y is a data frame that has the keys I want to use as indices into x

 y - data.frame(ltrs=sample(letters,5),mnths=sample(month.name
 ,5),values=0)


 #I want to fill in the values column using the ltrs and mnths columns
 as keys to look up

 # the associated value from x

 #One way to do this is with a FOR loop

 for (i in 1:nrow(y)) {y$val[i] - x[y$ltrs[i],y$mnths[i]]}


 My question: Is there a more efficient way (e.g., one without using an
 explicit loop) to do this?


 Thanks in advance!


 -Rama Ramakrishnan

[[alternative HTML version deleted]]

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




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

[[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] [e1071] Inconsistent results when using matrix.csr for svm() - possibly scaling problem

2009-06-25 Thread Eva May

Dear all,

I'm training an SVM with default settings on a matrix csr (SparseM 
package). I realized that if I train
the SVM with the (hopefully) equivalent matrix (Matrix package) 
representation, the returned models and predictions
sometimes differ. I expected both representations of the same data 
to lead to the same results though.
It could be that it is a scaling problem, because unscaled  results are 
equal(see below).

I'm using the SparseM_0.80 and e1071_1.5-19.

This is what I do (details can be found below):

 #run model on csr matrixes
 model - svm(matrixcsrTraining,classfactorTraining)
 predict(model, matrixcsrTest)
1
0.944625

 #run model on matrix representation (Matrix) of the csr matrix from above
 model - svm(as.matrix(matrixcsrTraining),classfactorTraining)
 predict(model, as.matrix(matrixcsrTest))
 1
0.8325838

Possibly this is a scaling problem with sparse matrices, because 
results are equal,
if scaling is disabled.

 #run model on csr matrixes without scaling
 model - svm(matrixcsrTraining,classfactorTraining, scale = FALSE)
 predict(model, matrixcsrTest)
1
0.944625
 #run model on normal matrixes without scaling
 model - svm(as.matrix(matrixcsrTraining),classfactorTraining, scale = FALSE)
 predict(model, as.matrix(matrixcsrTest))
1
0.944625

Is scaling different for both formats? Or is there no scaling for SparseM?

Thank you very much for your help,

Eva
CS bachelor student

---
---
Details:

Code below, files attached

#read in data
coordinates - read.csv('vector.data',head=TRUE)
j - subset(coordinates,select=c(j))
ja - as.integer(j[1:dim(j)[1],])
i-subset(coordinates,select=c(i))
ia - as.integer(i[1:dim(i)[1],])
classes - read.csv(classes.data,head=TRUE)
classfactorTraining - classes[1:(max(ia)),]

#build matrixcoo first, then matrixcsr for training
dim - as.integer(c(max(ia),max(ja)))
matrixcoo = new(matrix.coo,ra=rep(1,dim(j)[1]),ja=ja,ia=ia,dim=dim)
matrixcsrTraining = as.matrix.csr(matrixcoo)

#build a simple matrix for testing
matrixcoo = 
new(matrix.coo,ra=rep(1,1),ja=as.integer(c(13)),ia=as.integer(c(1)),dim=as.integer(c(1,max(ja
matrixcsrTest = as.matrix.csr(matrixcoo)

#run model on csr matrixes
model - svm(matrixcsrTraining,classfactorTraining, scale = FALSE)
predict(model, matrixcsrTest)
#run model on normal matrixes
model - svm(as.matrix(matrixcsrTraining),classfactorTraining, scale = FALSE)
predict(model, as.matrix(matrixcsrTest))

--
Masked Methods:

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

 model.response


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

 backsolve,
 chol


-
Session info:

 sessionInfo()
R version 2.9.0 (2009-04-17)
x86_64-pc-linux-gnu

locale:
LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=C;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C

attached base packages:
[1] methods   stats graphics  grDevices utils datasets  base

other attached packages:
[1] SparseM_0.80 e1071_1.5-19 class_7.2-47


-- 
Be Yourself @ mail.com!
Choose From 200+ Email Addresses
Get a Free Account at www.mail.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] Efficient lookup on a two-dimensional table

2009-06-25 Thread Rama Ramakrishnan
Follow-on question: is there a way to do this for higher-dimensional (i.e.
more than 2 dimensions) arrays?


On Thu, Jun 25, 2009 at 10:17 AM, Rama Ramakrishnan r...@alum.mit.eduwrote:

 That works!! Very nice way to do it! Thank you, Henrique!
 Rama Ramakrishnan


 On Thu, Jun 25, 2009 at 10:11 AM, Henrique Dallazuanna 
 www...@gmail.comwrote:

 Try this:

 y$values - diag(x[y$ltrs, y$mnths])

 On Thu, Jun 25, 2009 at 11:02 AM, Rama Ramakrishnan r...@alum.mit.eduwrote:

 Dear R-Users,
 I need to lookup values from a 2-d table using the row names and column
 names as indices. I was wondering if there's a way to do this without an
 explicit loop.

 Example:
 #x is the 2-d table that holds the values

 x - matrix(rnorm(26*12),nrow=26)

 rownames(x) - letters

 colnames(x) - month.name


 #y is a data frame that has the keys I want to use as indices into x

 y - data.frame(ltrs=sample(letters,5),mnths=sample(month.name
 ,5),values=0)


 #I want to fill in the values column using the ltrs and mnths
 columns
 as keys to look up

 # the associated value from x

 #One way to do this is with a FOR loop

 for (i in 1:nrow(y)) {y$val[i] - x[y$ltrs[i],y$mnths[i]]}


 My question: Is there a more efficient way (e.g., one without using an
 explicit loop) to do this?


 Thanks in advance!


 -Rama Ramakrishnan

[[alternative HTML version deleted]]

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




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




[[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] Efficient lookup on a two-dimensional table

2009-06-25 Thread David Winsemius


On Jun 25, 2009, at 10:02 AM, Rama Ramakrishnan wrote:


Dear R-Users,
I need to lookup values from a 2-d table using the row names and  
column
names as indices. I was wondering if there's a way to do this  
without an

explicit loop.

Example:
#x is the 2-d table that holds the values

x - matrix(rnorm(26*12),nrow=26)

rownames(x) - letters

colnames(x) - month.name


#y is a data frame that has the keys I want to use as indices into x

y - data.frame(ltrs=sample(letters,5),mnths=sample(month.name, 
5),values=0)



#I want to fill in the values column using the ltrs and mnths  
columns

as keys to look up

# the associated value from x



?apply

x$value - apply(y, 1, function(z) x[ z['ltrs'], z['mnths'] ])


#One way to do this is with a FOR loop

for (i in 1:nrow(y)) {y$val[i] - x[y$ltrs[i],y$mnths[i]]}


My question: Is there a more efficient way (e.g., one without using an
explicit loop) to do this?


Thanks in advance!


-Rama Ramakrishnan

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


Re: [R] RODBC: Trying to read an Excel file

2009-06-25 Thread Duncan Murdoch

On 6/25/2009 7:20 AM, John Sorkin wrote:

R 2.8
Windows XP
Excel 2003

I am trying to read an Excel spread sheet. I have looked at the RODBC help 
pages and am having trouble setting up code that will work. My code and the 
results are pasted below:



jo-odbcConnectExcel(i:\\all\\sorkinjohn\\stats\\silvermannatalie\\NEMOcombined06-24-09.xls,readOnly
 = TRUE)
mo-sqlGetResults(jo)


You set up a connection, but didn't submit a query, so there are no 
results to get.


You need to do something like sqlQuery(select * from tablename), where 
tablename is a table within your spreadsheet.  The ?odbcConnectExcel 
page links to 
http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q195951 which 
describes how to specify one.


Duncan Murdoch


mo

[1] -1

I have tried to set up the connection string using odbcConnectExcel and then 
have tried to read the file using sqlGetResults. Can someone tell me what I am 
doing wrong?

Thanks,
John

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

Confidentiality Statement:
This email message, including any attachments, is for 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.


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Efficient lookup on a two-dimensional table

2009-06-25 Thread David Winsemius


On Jun 25, 2009, at 10:24 AM, Rama Ramakrishnan wrote:

Follow-on question: is there a way to do this for higher-dimensional  
(i.e.

more than 2 dimensions) arrays?


The apply method I just posted generalizes to higher dimensional arrays.

--
DW




On Thu, Jun 25, 2009 at 10:17 AM, Rama Ramakrishnan  
r...@alum.mit.eduwrote:



That works!! Very nice way to do it! Thank you, Henrique!
Rama Ramakrishnan


On Thu, Jun 25, 2009 at 10:11 AM, Henrique Dallazuanna www...@gmail.com 
wrote:



Try this:

y$values - diag(x[y$ltrs, y$mnths])

On Thu, Jun 25, 2009 at 11:02 AM, Rama Ramakrishnan r...@alum.mit.edu 
wrote:



Dear R-Users,
I need to lookup values from a 2-d table using the row names and  
column
names as indices. I was wondering if there's a way to do this  
without an

explicit loop.

Example:
#x is the 2-d table that holds the values

x - matrix(rnorm(26*12),nrow=26)

rownames(x) - letters

colnames(x) - month.name


#y is a data frame that has the keys I want to use as indices  
into x


y - data.frame(ltrs=sample(letters,5),mnths=sample(month.name
,5),values=0)


#I want to fill in the values column using the ltrs and mnths
columns
as keys to look up


snip





[[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] Make functions aware of theyr own slots.

2009-06-25 Thread Vitalie S.

Hello,

 Is there a way to access function's slots from inside the function? I  
want to make functions slot dependent without recurring to generic  
function mechanism.
  Probably this goes a bit against R philosophy, but otherwise I don't  
really see the use of extending functions in R.


Would be nice to have something like:

setClass(myFunc,list(type=numeric),contains=function)
foo-new(myFunc,
function(x) m...@type^x,type=0)


Many thanks,
Vitalie.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Efficient lookup on a two-dimensional table

2009-06-25 Thread Gabor Grothendieck
Try this (shown for stated problem but generalizes by just adding
additional arguments):

mapply([, list(x), ltrs, mnths)


On Thu, Jun 25, 2009 at 10:24 AM, Rama Ramakrishnanr...@alum.mit.edu wrote:
 Follow-on question: is there a way to do this for higher-dimensional (i.e.
 more than 2 dimensions) arrays?


 On Thu, Jun 25, 2009 at 10:17 AM, Rama Ramakrishnan r...@alum.mit.eduwrote:

 That works!! Very nice way to do it! Thank you, Henrique!
 Rama Ramakrishnan


 On Thu, Jun 25, 2009 at 10:11 AM, Henrique Dallazuanna 
 www...@gmail.comwrote:

 Try this:

 y$values - diag(x[y$ltrs, y$mnths])

 On Thu, Jun 25, 2009 at 11:02 AM, Rama Ramakrishnan 
 r...@alum.mit.eduwrote:

 Dear R-Users,
 I need to lookup values from a 2-d table using the row names and column
 names as indices. I was wondering if there's a way to do this without an
 explicit loop.

 Example:
 #x is the 2-d table that holds the values

 x - matrix(rnorm(26*12),nrow=26)

 rownames(x) - letters

 colnames(x) - month.name


 #y is a data frame that has the keys I want to use as indices into x

 y - data.frame(ltrs=sample(letters,5),mnths=sample(month.name
 ,5),values=0)


 #I want to fill in the values column using the ltrs and mnths
 columns
 as keys to look up

 # the associated value from x

 #One way to do this is with a FOR loop

 for (i in 1:nrow(y)) {y$val[i] - x[y$ltrs[i],y$mnths[i]]}


 My question: Is there a more efficient way (e.g., one without using an
 explicit loop) to do this?


 Thanks in advance!


 -Rama Ramakrishnan

        [[alternative HTML version deleted]]

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




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




        [[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] exportation of xml file from R

2009-06-25 Thread guillaume Le Ray
Hello everybody,

I have programed a function to translate the R object structure into a XML
data structure but I haven't found a function in the XML package to export
this data in an XML file!

my data look like that:
FactorAssessor:codec/Factor
Sum Sq 33.98159/Sum Sq
Df  28/Df
F value  6.510894/F value
Pr(F) 1.725149e-22/Pr(F)
   /line
   line
6
FactorAssessor:Sample/Factor
Sum Sq 33.82264/Sum Sq
Df 126/Df
F value  1.440098/F value
Pr(F) 1.752742e-03/Pr(F)
   /line
   line
7
Factorcodec:Sample/Factor
Sum Sq253.04055/Sum Sq
Df  18/Df
F value 75.417587/F value
Pr(F)4.055009e-180/Pr(F)
   /line
   line
8
FactorResiduals/Factor
Sum Sq214.73234/Sum Sq
Df1152/Df
F valueNA/F value
Pr(F)NA/Pr(F)
   /line
  /anova:2
 /anova

for data I basically used the function xmlNode,addChildren,xmlchildren. I
don't know if it's sufficient to recognise a xml file


So thanks for your help!


Regards,

Guillaume

[[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: system is computationally singular: reciprocal condition number

2009-06-25 Thread Moumita Das
I get this error while computing partial correlation.


*Error in solve.default(Szz) :
  system is computationally singular: reciprocal condition number =
4.90109e-18*

Why is it?Can anyone give me some idea ,how do i get rid it it?

This is the function i use for calculating partial correlation.


pcor.mat - function(x,y,z,method=p,na.rm=T){


x - c(x)
y - c(y)
z - as.data.frame(z)



if(dim(z)[2] == 0){
stop(There should be given data\n)
}

data - data.frame(x,y,z)

if(na.rm == T){
data = na.omit(data)
}

xdata - na.omit(data.frame(data[,c(1,2)]))
Sxx - cov(xdata,xdata,m=method)

xzdata - na.omit(data)
xdata - data.frame(xzdata[,c(1,2)])
zdata - data.frame(xzdata[,-c(1,2)])
Sxz - cov(xdata,zdata,m=method)

zdata - na.omit(data.frame(data[,-c(1,2)]))
Szz - cov(zdata,zdata,m=method)


# is Szz positive definite?
zz.ev - eigen(Szz)$values
if(min(zz.ev)[1]0){

stop(\'Szz\' is not positive definite!\n)
}

# partial correlation
Sxx.z - Sxx - Sxz %*% solve(Szz) %*% t(Sxz)

print(Sxx.z) # this gets printed

rxx.z - cov2cor(Sxx.z)[1,2] #some problem in this function
function (V)
{
   print(cov2cor)
   p - (d - dim(V))[1]
if (!is.numeric(V) || length(d) != 2L || p != d[2L])
stop('V' is not a square numeric matrix)
Is - sqrt(1/diag(V))
if (any(!is.finite(Is)))
warning(diag(.) had 0 or NA entries; non-finite result is
doubtful)
r - V
r[] - Is * V * rep(Is, each = p)
r[cbind(1L:p, 1L:p)] - 1
r
}
return(rxx.z)
}

-- 
Thanks
Moumita

[[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] exportation of xml file from R

2009-06-25 Thread Gabor Grothendieck
See the StatDataML package.

On Thu, Jun 25, 2009 at 10:54 AM, guillaume Le
Rayleray.guilla...@gmail.com wrote:
 Hello everybody,

 I have programed a function to translate the R object structure into a XML
 data structure but I haven't found a function in the XML package to export
 this data in an XML file!

 my data look like that:
    FactorAssessor:codec/Factor
    Sum Sq 33.98159/Sum Sq
    Df  28/Df
    F value  6.510894/F value
    Pr(F) 1.725149e-22/Pr(F)
   /line
   line
    6
    FactorAssessor:Sample/Factor
    Sum Sq 33.82264/Sum Sq
    Df 126/Df
    F value  1.440098/F value
    Pr(F) 1.752742e-03/Pr(F)
   /line
   line
    7
    Factorcodec:Sample/Factor
    Sum Sq253.04055/Sum Sq
    Df  18/Df
    F value 75.417587/F value
    Pr(F)4.055009e-180/Pr(F)
   /line
   line
    8
    FactorResiduals/Factor
    Sum Sq214.73234/Sum Sq
    Df1152/Df
    F valueNA/F value
    Pr(F)NA/Pr(F)
   /line
  /anova:2
  /anova

 for data I basically used the function xmlNode,addChildren,xmlchildren. I
 don't know if it's sufficient to recognise a xml file


 So thanks for your help!


 Regards,

 Guillaume

        [[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] exportation of xml file from R

2009-06-25 Thread Duncan Temple Lang


Hi Guillaume


Once you have created an XML representation using any of the various 
ways to represent XML in R via the XML package (e.g. internal nodes, 
lists of lists, hash trees), you can use the saveXML() function:


  saveXML(myXML, fileName.xml)

Personally, I use newXMLNode() and friends and build the tree with
internal nodes.

 D.



guillaume Le Ray wrote:

Hello everybody,

I have programed a function to translate the R object structure into a XML
data structure but I haven't found a function in the XML package to export
this data in an XML file!

my data look like that:
FactorAssessor:codec/Factor
Sum Sq 33.98159/Sum Sq
Df  28/Df
F value  6.510894/F value
Pr(F) 1.725149e-22/Pr(F)
   /line
   line
6
FactorAssessor:Sample/Factor
Sum Sq 33.82264/Sum Sq
Df 126/Df
F value  1.440098/F value
Pr(F) 1.752742e-03/Pr(F)
   /line
   line
7
Factorcodec:Sample/Factor
Sum Sq253.04055/Sum Sq
Df  18/Df
F value 75.417587/F value
Pr(F)4.055009e-180/Pr(F)
   /line
   line
8
FactorResiduals/Factor
Sum Sq214.73234/Sum Sq
Df1152/Df
F valueNA/F value
Pr(F)NA/Pr(F)
   /line
  /anova:2
 /anova

for data I basically used the function xmlNode,addChildren,xmlchildren. I
don't know if it's sufficient to recognise a xml file


So thanks for your help!


Regards,

Guillaume

[[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] Efficient lookup on a two-dimensional table

2009-06-25 Thread Rama Ramakrishnan
Thanks, David, that works too!


On Thu, Jun 25, 2009 at 10:30 AM, David Winsemius dwinsem...@comcast.netwrote:


 On Jun 25, 2009, at 10:24 AM, Rama Ramakrishnan wrote:

  Follow-on question: is there a way to do this for higher-dimensional (i.e.
 more than 2 dimensions) arrays?


 The apply method I just posted generalizes to higher dimensional arrays.

 --
 DW



 On Thu, Jun 25, 2009 at 10:17 AM, Rama Ramakrishnan r...@alum.mit.edu
 wrote:

  That works!! Very nice way to do it! Thank you, Henrique!
 Rama Ramakrishnan


 On Thu, Jun 25, 2009 at 10:11 AM, Henrique Dallazuanna www...@gmail.com
 wrote:

  Try this:

 y$values - diag(x[y$ltrs, y$mnths])

 On Thu, Jun 25, 2009 at 11:02 AM, Rama Ramakrishnan r...@alum.mit.edu
 wrote:

  Dear R-Users,
 I need to lookup values from a 2-d table using the row names and column
 names as indices. I was wondering if there's a way to do this without
 an
 explicit loop.

 Example:
 #x is the 2-d table that holds the values

 x - matrix(rnorm(26*12),nrow=26)

 rownames(x) - letters

 colnames(x) - month.name


 #y is a data frame that has the keys I want to use as indices into x

 y - data.frame(ltrs=sample(letters,5),mnths=sample(month.name
 ,5),values=0)


 #I want to fill in the values column using the ltrs and mnths
 columns
 as keys to look up

  snip




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



[[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-pkgs] WriteXLS - New Version 1.8.1

2009-06-25 Thread Marc Schwartz
The updated package has been submitted to CRAN and will propagate to  
mirrors over the next day or so.


It is maintained on R-Forge at http://r-forge.r-project.org/projects/writexls 
, where downloads will be available as well. There is a transient  
problem at the moment with R-Forge and the build system, so there may  
be delays using R-Forge to get the updated package builds.


Package: WriteXLS

Version: 1.8.1

Description: Cross-platform perl based R function to create Excel  
(XLS) files from one or more data frames. Each data frame will be  
written to a separate named worksheet in the Excel spreadsheet. The  
worksheet name will be the name of the data frame it contains or can  
be specified by the user.


Author(s): Marc Schwartz marc_schwa...@me.com
Maintainer: Marc Schwartz marc_schwa...@me.com

License: GPL (=2)


Changes since version 1.8.0:

The data frames will be written to the Excel file in the order that  
they appear in 'x'. Note that this is a change in the default  
behavior, where due to Perl's file globbing, they would previously  
have been written in alpha sort order. The prior default behavior  
could result in a mis-match between the data frames written to the  
Excel worksheets and the user specified worksheet names as indicated  
in the 'SheetNames' argument (added recently in version 1.7.1), if  
present.


As a result of the above change, File::Glob is no longer used and has  
been removed as a required Perl module for the package. References to  
File::Glob have been removed from the testPerl() function and all  
supporting files.


The INSTALL file has been copied to the 'inst' package folder, so that  
it is installed in the main package directory. It will therefore be  
available both on the CRAN mirror page for the package and on the  
user's system as referenced in the help files.


___
R-packages mailing list
r-packa...@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-packages

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] exportation of xml file from R

2009-06-25 Thread Duncan Temple Lang


BTW, the XML you show is not legal XML.
For instance, the element

  Pr(F)NA/Pr(F)

is not a legal XML element name.

Similarly

 /anova:2

is not a legal name since it is 2.
And anova:2 means an element with name 2 with (XML) name space prefix
anova (which must be declared previously)

As Gabor mentioned, StatDataML is one approach to generating
an XML representation of an R object.
Since the objects look related to fitted models, you might
also want to look at PMML (Predictive Model Markup Language)
as that is a more widely used standard.

 D.


guillaume Le Ray wrote:

Hello everybody,

I have programed a function to translate the R object structure into a XML
data structure but I haven't found a function in the XML package to export
this data in an XML file!

my data look like that:
FactorAssessor:codec/Factor
Sum Sq 33.98159/Sum Sq
Df  28/Df
F value  6.510894/F value
Pr(F) 1.725149e-22/Pr(F)
   /line
   line
6
FactorAssessor:Sample/Factor
Sum Sq 33.82264/Sum Sq
Df 126/Df
F value  1.440098/F value
Pr(F) 1.752742e-03/Pr(F)
   /line
   line
7
Factorcodec:Sample/Factor
Sum Sq253.04055/Sum Sq
Df  18/Df
F value 75.417587/F value
Pr(F)4.055009e-180/Pr(F)
   /line
   line
8
FactorResiduals/Factor
Sum Sq214.73234/Sum Sq
Df1152/Df
F valueNA/F value
Pr(F)NA/Pr(F)
   /line
  /anova:2
 /anova

for data I basically used the function xmlNode,addChildren,xmlchildren. I
don't know if it's sufficient to recognise a xml file


So thanks for your help!


Regards,

Guillaume

[[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] How do I define the method for gcheckboxgroup in gWidgets?

2009-06-25 Thread Bryan Hanson
Hi All...

I¹m trying to build a small demo using gWidgets which permits interactive
scaling and selection among different things to plot.  I can get the widgets
for scaling to work just fine.  I am using gcheckboxgroup to make the
(possibly multiple) selections.  However, I can¹t seem to figure out how to
properly define the gcheckboxgroup; I can draw the widget properly, I think
my handler would use the svalue right if it actually received it.  Part of
the problem is using the index of the possible values rather than the values
themselves, but I'm pretty sure this is not all of the problem.  I've been
unable to find an example like this in any of the various resources I've
come across.

BTW,  report.which is really only there for troubleshooting.  It works to
return the values, I can't get it to return the indices, which are probably
what I need in this case.

A demo script is at the bottom and the error is just below.

 tmp - gcheckboxgroup(stuff, handler = report.which, index = TRUE,
+ checked = c(TRUE, FALSE, FALSE, FALSE, FALSE), container = leftPanel)
 add(tmp, value = 1, expand = TRUE)
Error in function (classes, fdef, mtable)  :
  unable to find an inherited method for function .add, for signature
gCheckboxgroupRGtk, guiWidgetsToolkitRGtk2, numeric

This error suggests that I don't have a method - I agree, but I don't know
what goes into the method for gcheckboxgroup.

For the sliders, it's clear to me how the actions and drawing of the widgets
differ, but not so for gcheckboxgroup.

A big TIA, Bryan
*
Bryan Hanson
Professor of Chemistry  Biochemistry
DePauw University, Greencastle IN USA

Full Script:

x - 1:10
y1 - x
y2 - x^2
y3 - x^0.5
y4 - y^3
df - as.data.frame(cbind(x, y1, y2, y3, y4))
stuff - c(y = x, y = x^2, y = x^0.5, y = x^3)
which.y - 2 # inital value, to be changed later by the widget

# Define a function for the widget handlers

update.Plot - function(h,...) {
plot(df[,1], df[,svalue(which.y)], type = l,
ylim = c(0, svalue(yrange)), main = Interactive Selection  Scaling,
xlab = x values, ylab = y values)
} 

report.which - function(h, ...) { print(svalue(h$obj), index = TRUE) }

# Define the actions  type of widget, along with returned values.
# Must be done before packing widgets.

yrange - gslider(from = 0, to = max(y), by = 1.0,
value = max(y), handler = update.Plot)
which.y - gcheckboxgroup(stuff, handler = report.which, index = TRUE,
checked = c(TRUE, FALSE, FALSE, FALSE, FALSE))

# Assemble the graphics window  groups of containers

mainWin - gwindow(Interactive Plotting)
bigGroup - ggroup(cont = mainWin)
leftPanel - ggroup(horizontal = FALSE, container = bigGroup)

# Format and pack the widgets,  link to their actions/type

tmp - gframe(y range, container = leftPanel)
add(tmp, yrange, expand = TRUE)
tmp - gcheckboxgroup(stuff, handler = report.which, index = TRUE,
checked = c(TRUE, FALSE, FALSE, FALSE, FALSE), container = leftPanel)
add(tmp, value = 1, expand = TRUE)


# Put it all together

add(mainWin, ggraphics()) # puts the active graphic window w/i mainWin

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Efficient lookup on a two-dimensional table

2009-06-25 Thread Rama Ramakrishnan
Thanks, Gabor. Works great!


On Thu, Jun 25, 2009 at 10:38 AM, Gabor Grothendieck 
ggrothendi...@gmail.com wrote:

 Try this (shown for stated problem but generalizes by just adding
 additional arguments):

 mapply([, list(x), ltrs, mnths)


 On Thu, Jun 25, 2009 at 10:24 AM, Rama Ramakrishnanr...@alum.mit.edu
 wrote:
  Follow-on question: is there a way to do this for higher-dimensional
 (i.e.
  more than 2 dimensions) arrays?
 
 
  On Thu, Jun 25, 2009 at 10:17 AM, Rama Ramakrishnan r...@alum.mit.edu
 wrote:
 
  That works!! Very nice way to do it! Thank you, Henrique!
  Rama Ramakrishnan
 
 
  On Thu, Jun 25, 2009 at 10:11 AM, Henrique Dallazuanna 
 www...@gmail.comwrote:
 
  Try this:
 
  y$values - diag(x[y$ltrs, y$mnths])
 
  On Thu, Jun 25, 2009 at 11:02 AM, Rama Ramakrishnan r...@alum.mit.edu
 wrote:
 
  Dear R-Users,
  I need to lookup values from a 2-d table using the row names and
 column
  names as indices. I was wondering if there's a way to do this without
 an
  explicit loop.
 
  Example:
  #x is the 2-d table that holds the values
 
  x - matrix(rnorm(26*12),nrow=26)
 
  rownames(x) - letters
 
  colnames(x) - month.name
 
 
  #y is a data frame that has the keys I want to use as indices into x
 
  y - data.frame(ltrs=sample(letters,5),mnths=sample(month.name
  ,5),values=0)
 
 
  #I want to fill in the values column using the ltrs and mnths
  columns
  as keys to look up
 
  # the associated value from x
 
  #One way to do this is with a FOR loop
 
  for (i in 1:nrow(y)) {y$val[i] - x[y$ltrs[i],y$mnths[i]]}
 
 
  My question: Is there a more efficient way (e.g., one without using an
  explicit loop) to do this?
 
 
  Thanks in advance!
 
 
  -Rama Ramakrishnan
 
 [[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 
 
 
  --
  Henrique Dallazuanna
  Curitiba-Paraná-Brasil
  25° 25' 40 S 49° 16' 22 O
 
 
 
 
 [[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] Problems with subsets in NLME

2009-06-25 Thread Rebecca Sela
I am trying to estimate models with subsets using the NLME package.  However, I 
am getting an error in the case below (among others):
 subset - c(rep(TRUE, 107), FALSE)
 fm2 - lme(distance ~ age + Sex, data = Orthodont, random = ~ 1, 
 subset=subset)
Error in xj[i] : invalid subscript type 'closure'
 fm2 - lme(distance ~ age + Sex, data = Orthodont, random = ~ 1, subset=1:107)

The second estimation works.

Does anyone know if there is another work-around?  (I have also e-mailed the 
package maintainers, but one of the e-mails bounced, so I am trying this list 
as well.)

Thank you!

Rebecca

--
Rebecca Sela
IOMS/Statistics Group
Stern School of Business
New York 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] crr - computationally singular

2009-06-25 Thread Laura Bonnett
Dear R-help,

I'm very sorry to ask 2 questions in a week.  I am using the package
'crr' and it does exactly what I need it to when I use the dataset a.
However, when I use dataset b I get the following error message:
Error in drop(.Call(La_dgesv, a, as.matrix(b), tol, PACKAGE = base)) :
  system is computationally singular: reciprocal condition number = 1.28654e-24

This is obviously as a result of a problem with the data but apart
from dataset a having 1674 rows and dataset b having 701 rows there is
really no difference between them.

The code I am using is as follows where covaea and covaeb are matrices
of covarites, all coded as binary variables.
In case a:
 covaea - 
 cbind(sexa,fsha,fdra,nsigna,eega,th1a,th2a,stype1a,stype2a,stype3a,pgu1a,pgu2a,log(agea),firstinta/1000,totsezbasea)
 fita - crr(snearma$with.Withtime,csaea,covaea,failcode=2,cencode=0)

and in case b:
 covaeb - 
 cbind(sexb,fshb,fdrb,nsignb,eegb,th1b,th2b,stype1b,stype2b,stype3b,stype4b,stype5b,pgu1b,pgu2b,(ageb/10)^(-1),firstintb,log(totsezbaseb))
 fitb - crr(snearmb$with.Withtime,csaeb,covaeb,failcode=2,cencode=0)

csaea and csaeb are the censoring indicators for a and b respectively
which equal 1 for the event of interest, 2 for the competing risks
event and 0 otherwise.

Can anyone suggest a reason for the error message?  I've tried running
fitb with variants of covaeb and irrespective of the order of the
covariates in the matrix, the code runs fine with 16 of the 17
covariates included but then produces an error message when the 17th
is added.

Thank you for your help,

Laura

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Problems with subsets in NLME

2009-06-25 Thread David Winsemius


On Jun 25, 2009, at 11:35 AM, Rebecca Sela wrote:

I am trying to estimate models with subsets using the NLME package.   
However, I am getting an error in the case below (among others):

subset - c(rep(TRUE, 107), FALSE)
fm2 - lme(distance ~ age + Sex, data = Orthodont, random = ~ 1,  
subset=subset)

Error in xj[i] : invalid subscript type 'closure'
fm2 - lme(distance ~ age + Sex, data = Orthodont, random = ~ 1,  
subset=1:107)


The second estimation works.

Does anyone know if there is another work-around?  (I have also e- 
mailed the package maintainers, but one of the e-mails bounced, so I  
am trying this list as well.)


Hard to tell. Closure is a type of function. It appears that R might  
be mistaking its own function subset for the object that you  
intended to pass. Perhaps if you stopped calling your dogs, Dog?


 library(fortunes)
 fortune(dog)


Thank you!

Rebecca

--
Rebecca Sela
IOMS/Statistics Group
Stern School of Business
New York 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.


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.


Re: [R] Problems with subsets in NLME

2009-06-25 Thread apjaworski
Rebecca,

I think the problem is that subset is a nume of an R function.  If you do 
something like

subs - c(rep(TRUE, 107), FALSE)
fm2 - lme(distance ~ age + Sex, data = Orthodont, random = ~ 1, 
subset=subs)

everything works fine.

Hope this helps,

Andy

__
Andy Jaworski
518-1-01
Process Laboratory
3M Corporate Research Laboratory
-
E-mail: apjawor...@mmm.com
Tel:  (651) 733-6092
Fax:  (651) 736-3122



Rebecca Sela rs...@stern.nyu.edu 
Sent by: r-help-boun...@r-project.org
06/25/2009 10:37 AM

To
r-help r-help@r-project.org
cc

Subject
[R] Problems with subsets in NLME






I am trying to estimate models with subsets using the NLME package. 
However, I am getting an error in the case below (among others):
 subset - c(rep(TRUE, 107), FALSE)
 fm2 - lme(distance ~ age + Sex, data = Orthodont, random = ~ 1, 
subset=subset)
Error in xj[i] : invalid subscript type 'closure'
 fm2 - lme(distance ~ age + Sex, data = Orthodont, random = ~ 1, 
subset=1:107)

The second estimation works.

Does anyone know if there is another work-around?  (I have also e-mailed 
the package maintainers, but one of the e-mails bounced, so I am trying 
this list as well.)

Thank you!

Rebecca

--
Rebecca Sela
IOMS/Statistics Group
Stern School of Business
New York 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.



[[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] crr - computationally singular

2009-06-25 Thread Ravi Varadhan
This means that your design matrix or model matrix is rank deficient, i.e it
does not have linearly independent columns.  Your predictors are collinear!


Just take your design matrices covaea or covaeb with 17 predcitors and
compute their rank or try to invert them.  You will see the problem.

Ravi.


---

Ravi Varadhan, Ph.D.

Assistant Professor, The Center on Aging and Health

Division of Geriatric Medicine and Gerontology 

Johns Hopkins University

Ph: (410) 502-2619

Fax: (410) 614-9625

Email: rvarad...@jhmi.edu

Webpage:
http://www.jhsph.edu/agingandhealth/People/Faculty_personal_pages/Varadhan.h
tml

 





-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Laura Bonnett
Sent: Thursday, June 25, 2009 11:39 AM
To: r-help@r-project.org
Subject: [R] crr - computationally singular

Dear R-help,

I'm very sorry to ask 2 questions in a week.  I am using the package 'crr'
and it does exactly what I need it to when I use the dataset a.
However, when I use dataset b I get the following error message:
Error in drop(.Call(La_dgesv, a, as.matrix(b), tol, PACKAGE = base)) :
  system is computationally singular: reciprocal condition number =
1.28654e-24

This is obviously as a result of a problem with the data but apart from
dataset a having 1674 rows and dataset b having 701 rows there is really no
difference between them.

The code I am using is as follows where covaea and covaeb are matrices of
covarites, all coded as binary variables.
In case a:
 covaea - 
 cbind(sexa,fsha,fdra,nsigna,eega,th1a,th2a,stype1a,stype2a,stype3a,pgu
 1a,pgu2a,log(agea),firstinta/1000,totsezbasea)
 fita - crr(snearma$with.Withtime,csaea,covaea,failcode=2,cencode=0)

and in case b:
 covaeb - 
 cbind(sexb,fshb,fdrb,nsignb,eegb,th1b,th2b,stype1b,stype2b,stype3b,sty
 pe4b,stype5b,pgu1b,pgu2b,(ageb/10)^(-1),firstintb,log(totsezbaseb))
 fitb - crr(snearmb$with.Withtime,csaeb,covaeb,failcode=2,cencode=0)

csaea and csaeb are the censoring indicators for a and b respectively which
equal 1 for the event of interest, 2 for the competing risks event and 0
otherwise.

Can anyone suggest a reason for the error message?  I've tried running fitb
with variants of covaeb and irrespective of the order of the covariates in
the matrix, the code runs fine with 16 of the 17 covariates included but
then produces an error message when the 17th is added.

Thank you for your help,

Laura

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] How to avoid ifelse statement converting factor to character

2009-06-25 Thread Stavros Macrakis
On Wed, Jun 24, 2009 at 9:04 PM, Rolf Turnerr.tur...@auckland.ac.nz wrote:
  Do not get your knickers in a twist.  R works simply and straightforwardly
  in simple straightforward situations.

Though I find R an incredibly useful tool, alas, it is simply not true
that R works simply and straightforwardly in simple straightforward
situations.  No doubt this is for understandable historical reasons
and backwards compatibility, but there it is.

Some examples of simple straightforward situations:

I think it is reasonable to expect that appending a list/vector of
class X to another list/vector of class X would result in a
list/vector of class X.  Similarly for the union of a list/vector of
class X. But in fact, not only is this not true for some of R's
important classes (factors, date/time, and delta-date/time), but the
result class is inconsistent by function and by class:

ff - factor(b)
c(ff,ff)= 1 1# class integer
union(ff,ff) = b# class character

tt - as.POSIXct('2009-01-01')
c(tt,tt) = 2009-01-01 EST 2009-01-01 EST # class POSIXt/POSIXct
union(tt,tt) 1230786000# class numeric

dt - tt - tt   # class difftime
c(dt,dt)  = 0 0  # class numeric
union(dt,dt) =  0  # class numeric

Similarly, the simplest, most straightforward situation I can think of
for ifelse is when the yes and no arguments are identical, and in that
case, I would (I think reasonably) expect that the result is of the
same class as the arguments, but it is not:

 ifelse(TRUE,factor(b),factor(b)) = 1 (integer)
 ifelse(TRUE,dd,dd) = 1230786000 (class numeric)

I hope you will agree that all of these are very simple and
straightforward situations, and that R is not working simply and
straightforwardly in them.

The less simple and less straightforward situations are of course more
complicated.

  In respect of the current discussion of ifelse() --- the original problem 
 arose
  because the values of ``yes'' and ``no'' were of different modes. It is 
 obvious
  that in such instances a decision will have to be made about the mode
  of the result.  The appropriateness of the designers' decision may be
 disputed,

Indeed.

 If you don't understand what's going on, then just stick to using
 ifelse() only when ``yes'' and ``no'' have the same mode.

That's not enough.  They have to be of a basic class as well.  See above.

 Bottom line:  R is easy to use at any level, but in order to use it a
 ``high'' level you need to understand the high level.  Don't attempt
 to run before you can crawl.

Bottom line: Some very basic things in R violate users' reasonable
expectations and moreover are internally inconsistent.  You have to be
careful about this whenever you work in R, even at an elementary
level.

   -s

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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: system is computationally singular: reciprocal conditionnumber

2009-06-25 Thread Ravi Varadhan
Your covariance matrix Szz is not positive definite.   It is singular.  The
following test that you are doing is neither necessary nor useful:

zz.ev - eigen(Szz)$values
if(min(zz.ev)[1]0){

stop(\'Szz\' is not positive definite!\n)
}


You may want to use Moore-Penrose inverse, also known as generalized inverse
or pseudoinverse to overcome this problem.  This approach uses
singular-value decomposition (SVD).  Take a look at the corpcor package.

Ravi.


---

Ravi Varadhan, Ph.D.

Assistant Professor, The Center on Aging and Health

Division of Geriatric Medicine and Gerontology 

Johns Hopkins University

Ph: (410) 502-2619

Fax: (410) 614-9625

Email: rvarad...@jhmi.edu

Webpage:
http://www.jhsph.edu/agingandhealth/People/Faculty_personal_pages/Varadhan.h
tml

 





-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Moumita Das
Sent: Thursday, June 25, 2009 10:59 AM
To: r-help@r-project.org
Subject: [R] Error: system is computationally singular: reciprocal
conditionnumber

I get this error while computing partial correlation.


*Error in solve.default(Szz) :
  system is computationally singular: reciprocal condition number =
4.90109e-18*

Why is it?Can anyone give me some idea ,how do i get rid it it?

This is the function i use for calculating partial correlation.


pcor.mat - function(x,y,z,method=p,na.rm=T){


x - c(x)
y - c(y)
z - as.data.frame(z)



if(dim(z)[2] == 0){
stop(There should be given data\n)
}

data - data.frame(x,y,z)

if(na.rm == T){
data = na.omit(data)
}

xdata - na.omit(data.frame(data[,c(1,2)]))
Sxx - cov(xdata,xdata,m=method)

xzdata - na.omit(data)
xdata - data.frame(xzdata[,c(1,2)])
zdata - data.frame(xzdata[,-c(1,2)])
Sxz - cov(xdata,zdata,m=method)

zdata - na.omit(data.frame(data[,-c(1,2)]))
Szz - cov(zdata,zdata,m=method)


# is Szz positive definite?
zz.ev - eigen(Szz)$values
if(min(zz.ev)[1]0){

stop(\'Szz\' is not positive definite!\n)
}

# partial correlation
Sxx.z - Sxx - Sxz %*% solve(Szz) %*% t(Sxz)

print(Sxx.z) # this gets printed

rxx.z - cov2cor(Sxx.z)[1,2] #some problem in this function function (V)
{
   print(cov2cor)
   p - (d - dim(V))[1]
if (!is.numeric(V) || length(d) != 2L || p != d[2L])
stop('V' is not a square numeric matrix)
Is - sqrt(1/diag(V))
if (any(!is.finite(Is)))
warning(diag(.) had 0 or NA entries; non-finite result is
doubtful)
r - V
r[] - Is * V * rep(Is, each = p)
r[cbind(1L:p, 1L:p)] - 1
r
}
return(rxx.z)
}

--
Thanks
Moumita

[[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] How to avoid ifelse statement converting factor to character

2009-06-25 Thread Stavros Macrakis
Erratum:
     ifelse(TRUE,dd,dd) = 1230786000 (class numeric)
should be
 ifelse(TRUE,tt,tt) = 1230786000 (class numeric)

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Software lifecycle for R releases (aka practical limits of support for older versions)

2009-06-25 Thread Rowe, Brian Lee Yung (Portfolio Analytics)
Hello useRs:

Does anyone have thoughts on the lifecycle of older releases of R? I
know that currently the 2.8.x and 2.9.x releases seem to be actively
supported on the mailing lists, but what about older releases, say
2.4.x? Curious to hear when people think older versions of R become
obsolete and unsupportable on the lists (or other venues). 

Regards,
Brian


--
This message w/attachments (message) may be privileged, ...{{dropped:27}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Long memory residuals

2009-06-25 Thread Ana Ramos
Hi,

How can I obtain the residuals of my long memory model:

x.fd = fracdiff(dif, nar=1, nma=2, M=30)

There is no function as acf() as for arima or garch models...

Many thanks
Ana

[[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] How to avoid ifelse statement converting factor to character

2009-06-25 Thread Craig P. Pyrame

Dear Rolf,

Rolf Turner wrote:


On 25/06/2009, at 12:27 PM, Craig P. Pyrame wrote:



Dear Stavros,

What you discuss below is somewhat scary to me as an R newbie.  Is this
just an incident, a bug perhaps, or rather the way things typically go
in R, as your Welcome to R! seems to suggest?  I have just started to
learn R, and my initial euphoria of the I can do anything with it!
sort is gradually turning into an I can't get why it doesn't work and
I can't get how to make this work depression.  I would be happy to
blame this on my incompetence and incapability, but would also like to
hear if it is not R itself that causes me to fail.


Do not get your knickers in a twist.  R works simply and 
straightforwardly
in simple straightforward situations.  In less simple and less 
straightforward
situations life gets more complicated.  Don't dive into such 
situations
without making sure you understand them.  Check your results to 
make sure

you have not overlooked a subtlety.



Yes, sure, but this sounds to me almost like what some others seem to 
have already suggested on this list - use R for tasks where you can 
simply apply any of the numerous excellent package functions (for 
example, to fit a model), but avoid using it for programming, because it 
inevitably leads to problems - is this what you are saying?


In respect of the current discussion of ifelse() --- the original 
problem arose
because the values of ``yes'' and ``no'' were of different modes.  
It is obvious
that in such instances a decision will have to be made about the 
mode of the
result.  The appropriateness of the designers' decision may be 
disputed, but
you have to admit that some decision had to be made.  Recognize 
that and all

the mystery goes away.



I wasn't really updated on the original example, but yes, creating a 
programming language involves numerous difficult decisions that have to 
be made, often in a relatively ad hoc fashion.  But once you point me to 
the original example, I have looked into what Stavros wrote, and the 
following strikes me as one of those cases where I would feel that 
either me or R is wrong:


   ifelse(TRUE,factor('x'),factor('x')) = 1  (integer)

The man page Stavros quotes states that the class attribute of the 
result is taken from 'test', which clearly is not the case:


   class(TRUE) = logical
   class(ifelse(TRUE,factor('x'),factor('x'))) = integer

And also, I find myself incapable of making sense of the may in the 
mode of the result may depend on the value of 'test' - may in what 
sense?  Will in 2.9 but not in 2.8?  Will if test is logical but not if 
it is raw?  I am not particularly into programming languages, and 
especially their semantics, so it may be my fault that I don't know what 
such may may mean, but I am not quite sure.  Could you help me?


If you don't understand what's going on, then just stick to using 
ifelse() only

when ``yes'' and ``no'' have the same mode.


Yes, in my poor R programming I make efforts to avoid involving myself 
in tricky situations, but it is not always helpful enough, I assure you.




Using things like as.raw() or taking one of ``yes'' and ``no'' to 
be a list is getting
into territory where you need to be quite sophisticated and quite 
careful.  Unless
you are both, don't go there.  I consider myself to be both (in 
respect of R at

least) and I *still* would be very reluctant to go there.



I am not sure, is this supposed to be an argument in favor of using R?


Bottom line:  R is easy to use at any level, but in order to use 
it a ``high'' level
you need to understand the high level.  Don't attempt to run 
before you can crawl.


I am a bit reluctant to tell you this, Rolf, as there is likely much my 
own fault involved, but I attempt to crawl, not to run, and this is 
where I get into pains with R.  Examples such as those of Stavros have 
no place in my code, and yet I find it surprisingly difficult to 
understand why large parts of my code don't work as expected - having 
read the man pages carefully enough, I'd think.


Best regards,
Craig

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Software lifecycle for R releases (aka practical limits of support for older versions)

2009-06-25 Thread Thomas Lumley

On Thu, 25 Jun 2009, Rowe, Brian Lee Yung (Portfolio Analytics) wrote:


Does anyone have thoughts on the lifecycle of older releases of R? I
know that currently the 2.8.x and 2.9.x releases seem to be actively
supported on the mailing lists, but what about older releases, say
2.4.x? Curious to hear when people think older versions of R become
obsolete and unsupportable on the lists (or other venues).


Opinions vary, but:

- reporting bugs (or asking if something is a bug) based on any older version 
of R than 2.9.x would likely get you flamed.

- if your problem could be solved by updating to the current version, I think 
you would be expected to do so.

My personal feeling is that you can just about get away with updating R only 
annually. Since you can easily keep an archive of previous versions available, 
there's no need to avoid updating on that account.

Based just on R itself a longer update delay might be ok, but CRAN doesn't 
supply binaries of new or updated packages for old versions of R. Many packages 
will become seriously outdated much faster than base R.

-thomas

Thomas Lumley   Assoc. Professor, Biostatistics
tlum...@u.washington.eduUniversity of Washington, Seattle

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


Re: [R] Software lifecycle for R releases (aka practical limits of support for older versions)

2009-06-25 Thread David M Smith
On Thu, Jun 25, 2009 at 9:38 AM, Rowe, Brian Lee Yung (Portfolio
Analytics)b_r...@ml.com wrote:
 Hello useRs:

 Does anyone have thoughts on the lifecycle of older releases of R? I
 know that currently the 2.8.x and 2.9.x releases seem to be actively
 supported on the mailing lists, but what about older releases, say
 2.4.x? Curious to hear when people think older versions of R become
 obsolete and unsupportable on the lists (or other venues).

 Regards,
 Brian

This is actually a fairly common question from R users at commercial
institutions, where for various reasons upgrading to the latest
release of R isn't always possible. This might be for regulatory
reasons (only a certain distribution of R has been validated), because
of IT policies, of because R is incorporated into a production
application where the risk of breaking the application outweighs the
potential benefits of an upgrade.

This is actually one of the main reasons why the release cycle for
REvolution R isn't as frequent as that for CRAN R. The beneficial side
effect is that we can therefore provide support for older versions of
R in our distributions. We support R 2.7.2 through our distribution of
REvolution R Enterprise, for example. More info here:
http://www.revolution-computing.com/products/revolution-enterprise.php

# David Smith

-- 
David M Smith da...@revolution-computing.com
Director of Community, REvolution Computing www.revolution-computing.com
Tel: +1 (206) 577-4778 x3203 (San Francisco, USA)

Check out our upcoming events schedule at www.revolution-computing.com/events

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Software lifecycle for R releases (aka practical limits of support for older versions)

2009-06-25 Thread stephen sefick
There is an archive for all packages for older versions of R, but if
you want up-to-date  functionality of packages then you need the
newest versions.
my 2 cents

stephen

On Thu, Jun 25, 2009 at 12:38 PM, Rowe, Brian Lee Yung (Portfolio
Analytics)b_r...@ml.com wrote:
 Hello useRs:

 Does anyone have thoughts on the lifecycle of older releases of R? I
 know that currently the 2.8.x and 2.9.x releases seem to be actively
 supported on the mailing lists, but what about older releases, say
 2.4.x? Curious to hear when people think older versions of R become
 obsolete and unsupportable on the lists (or other venues).

 Regards,
 Brian


 --
 This message w/attachments (message) may be privileged...{{dropped:21}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Problems with help

2009-06-25 Thread Leandro Marino
 Hi,
I was trying to read some help of functions and in all functions I try to see 
is giving me this error:
 ?write.table
Erro em 
print.help_files_with_topic(C:/ARQUIV~1/R/R-29~1.0/library/utils/chm/write.table)
 : 
  CHM file could not be displayed

Anybody knows what is happening?

Atenciosamente,
Leandro Lins Marino
Centro de Avaliação
Fundação CESGRANRIO
Rua Santa Alexandrina, 1011 - 2º andar
Rio de Janeiro, RJ - CEP: 20261-903
R (21) 2103-9600 R.:236 
( (21) 8777-7907
( lean...@cesgranrio.org.br

Aquele que suporta o peso da sociedade
é precisamente aquele que obtém
 as menores vantagens. (SMITH, Adam)

  Antes de imprimir pense em sua responsabilidade e compromisso com o MEIO 
AMBIENTE 

Esta mensagem, incluindo seus anexos, pode conter informacoes privilegiadas 
e/ou de carater confidencial, nao podendo ser retransmitida sem autorizacao do 
remetente. Se voce nao e o destinatario ou pessoa autorizada a recebe-la, 
informamos que o seu uso, divulgacao, copia ou arquivamento sao proibidos. 
Portanto, se você recebeu esta mensagem por engano, por favor, nos informe 
respondendo imediatamente a este e-mail e em seguida apague-a.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Software lifecycle for R releases (aka practical limits of support for older versions)

2009-06-25 Thread Rowe, Brian Lee Yung (Portfolio Analytics)
Good to know. I know that other software projects (whether languages,
OSes, applications) tend to keep recent versions in maintenance mode for
a certain period of time prior to retiring them. I wonder if that
would happen with R, either by design or out of necessity of an
increasing user base.

Brian

-Original Message-
From: Thomas Lumley [mailto:tlum...@u.washington.edu] 
Sent: Thursday, June 25, 2009 12:50 PM
To: Rowe, Brian Lee Yung (Portfolio Analytics)
Cc: r-h...@stat.math.ethz.ch
Subject: Re: [R] Software lifecycle for R releases (aka practical limits
of support for older versions)


On Thu, 25 Jun 2009, Rowe, Brian Lee Yung (Portfolio Analytics) wrote:

 Does anyone have thoughts on the lifecycle of older releases of R? I
 know that currently the 2.8.x and 2.9.x releases seem to be actively
 supported on the mailing lists, but what about older releases, say
 2.4.x? Curious to hear when people think older versions of R become
 obsolete and unsupportable on the lists (or other venues).

Opinions vary, but:

- reporting bugs (or asking if something is a bug) based on any older
version of R than 2.9.x would likely get you flamed.

- if your problem could be solved by updating to the current version, I
think you would be expected to do so.

My personal feeling is that you can just about get away with updating R
only annually. Since you can easily keep an archive of previous versions
available, there's no need to avoid updating on that account.

Based just on R itself a longer update delay might be ok, but CRAN
doesn't supply binaries of new or updated packages for old versions of
R. Many packages will become seriously outdated much faster than base R.

 -thomas

Thomas Lumley   Assoc. Professor, Biostatistics
tlum...@u.washington.eduUniversity of Washington, Seattle



--
This message w/attachments (message) may be privileged, confidential or 
proprietary, and if you are not an intended recipient, please notify the 
sender, do not use or share it and delete it. Unless specifically indicated, 
this message is not an offer to sell or a solicitation of any investment 
products or other financial product or service, an official confirmation of any 
transaction, or an official statement of Merrill Lynch. Subject to applicable 
law, Merrill Lynch may monitor, review and retain e-communications (EC) 
traveling through its networks/systems. The laws of the country of each 
sender/recipient may impact the handling of EC, and EC may be archived, 
supervised and produced in countries other than the country in which you are 
located. This message cannot be guaranteed to be secure or error-free. 
References to Merrill Lynch are references to any company in the Merrill 
Lynch  Co., Inc. group of companies, which are wholly-owned by Bank of America 
Corporation. Secu!
 rities and Insurance Products: * Are Not FDIC Insured * Are Not Bank 
Guaranteed * May Lose Value * Are Not a Bank Deposit * Are Not a Condition to 
Any Banking Service or Activity * Are Not Insured by Any Federal Government 
Agency. Attachments that are part of this E-communication may have additional 
important disclosures and disclaimers, which you should read. This message is 
subject to terms available at the following link: 
http://www.ml.com/e-communications_terms/. By messaging with Merrill Lynch you 
consent to the foregoing.
--

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Software lifecycle for R releases (aka practical limits of support for older versions)

2009-06-25 Thread Marc Schwartz
On Jun 25, 2009, at 11:38 AM, Rowe, Brian Lee Yung (Portfolio  
Analytics) wrote:



Hello useRs:

Does anyone have thoughts on the lifecycle of older releases of R? I
know that currently the 2.8.x and 2.9.x releases seem to be actively
supported on the mailing lists, but what about older releases, say
2.4.x? Curious to hear when people think older versions of R become
obsolete and unsupportable on the lists (or other venues).

Regards,
Brian


For a description of R's formal SDLC, read:

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

While that document is targeted to R users in the domain of regulated  
clinical trials, much of the content is relevant to other general use  
domains.


From the perspective of getting community support on R-Help, if you  
are using version 2.4.0 and you post a version independent query to  
the list, you will get a helpful reply, especially if you don't  
include in the post that you are running version 2.4.0.


However, it is possible that in the replies, there may be references  
to functions, function arguments or packages that are part of or are  
designed for newer versions of R. Upon reading that reply, you may end  
up scratching your head, wondering why you cannot find them in your  
version, which may prompt you to reply requesting clarification. That  
may lead you down the path to the next scenario...


If you include in your post (or a follow up) that you are actually  
using version 2.4.0, you will get a series of rather curt  
recommendations to update to the current release version of R included  
in any responses to your query.


However, if you post a query pertaining to what you perceive as a bug  
in 2.4.0 or a more recent version (possibly even 2.9.0 with 2.9.1  
imminent), you will get a pretty rapid stream of replies, with a level  
of hostility (flaming) included. Those replies will tell you in no  
uncertain terms, that you better upgrade to the most recent version of  
R (which may include a patched version) before reporting bugs  
against versions that from a development standpoint, are no longer  
supported. You would be expected to check the most recent version that  
you can install to see if the behavior that you perceive as a bug is  
still present.


The worst case scenario perhaps, in terms of being on the receiving  
end of flames, would be to actually submit a formal bug report on an  
older version of R, as that requires a **volunteer** member of R Core  
to have to stop what they are doing and spend time manually  
administering that report.


Finally, a good reference to go along with this general discussion, is  
the Posting Guide, listed at the bottom of all e-mails coming from the  
list:


  http://www.r-project.org/posting-guide.html

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] interaction terms formula error

2009-06-25 Thread Alejandra Solis Herrera
Hi,

 

I'm trying to fit a binary logistic regression model, and would like to 
consider certain characteristics B and C only for people with variable A=1 and 
not for those with variable A=0, so I'm trying to do the following:

 

model- lrm(formula= y ~  A: (B+C) + D + E +...)

 

I've had no problem with adding interaction terms using  * , but every time I 
try to use  : , as in my example, I get an error message like:

 

Error in if (!length(fname) || !any(fname == zname)) { : 

Missing value where TRUE/FALSE needed

 

I would really appreciate any advice on how to solve this, I don't know what in 
the notation should be different for different operators.

 

Thanks in advance, kind regards, 

 

Alejandra Solí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.


Re: [R] interaction terms formula error

2009-06-25 Thread Frank E Harrell Jr

Alejandra Solis Herrera wrote:

Hi,

 


I'm trying to fit a binary logistic regression model, and would like to 
consider certain characteristics B and C only for people with variable A=1 and 
not for those with variable A=0, so I'm trying to do the following:

 


model- lrm(formula= y ~  A: (B+C) + D + E +...)

 


I've had no problem with adding interaction terms using  * , but every time I try to 
use  : , as in my example, I get an error message like:



The Design package doesn't support that.  It uses the (highly 
recommended) hierarchy principle so it assumes you will use * for 
interactions.


Frank

 

Error in if (!length(fname) || !any(fname == zname)) { : 


Missing value where TRUE/FALSE needed

 


I would really appreciate any advice on how to solve this, I don't know what in 
the notation should be different for different operators.

 

Thanks in advance, kind regards, 

 

Alejandra Solí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.



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

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


[R] How to draw a line in plot when I know the start point(x1, y1) and end point(x2, y2)?

2009-06-25 Thread Lesandro
Hello all,

How to draw a line in plot when I know the start point(x1,y1) and end 
point(x2,y2)? I need make this as additional information in the graph:

plot(wl2[[1]],wl2[[2]])

I think that is possible make this with the function abline(), is possible? I 
looked the function lines() too, but don't understand as make.


Thanks!
Lesandro



  Veja quais são os assuntos do momento no Yahoo! +Buscados

[[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] How to draw a line in plot when I know the start point(x1, y1) and end point(x2, y2)?

2009-06-25 Thread Jorge Ivan Velez
Dear Lesandro,
Take a look at

?segments

HTH,

Jorge


On Thu, Jun 25, 2009 at 2:30 PM, Lesandro lesand...@yahoo.com.br wrote:

 Hello all,

 How to draw a line in plot when I know the start point(x1,y1) and end
 point(x2,y2)? I need make this as additional information in the graph:

 plot(wl2[[1]],wl2[[2]])

 I think that is possible make this with the function abline(), is possible?
 I looked the function lines() too, but don't understand as make.


 Thanks!
 Lesandro



  Veja quais são os assuntos do momento no Yahoo! +Buscados

[[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] How to draw a line in plot when I know the start point(x1, y1) and end point(x2, y2)?

2009-06-25 Thread Marc Schwartz

On Jun 25, 2009, at 1:30 PM, Lesandro wrote:


Hello all,

How to draw a line in plot when I know the start point(x1,y1) and  
end point(x2,y2)? I need make this as additional information in the  
graph:


plot(wl2[[1]],wl2[[2]])

I think that is possible make this with the function abline(), is  
possible? I looked the function lines() too, but don't understand as  
make.



Thanks!
Lesandro



See ?segments which does just what you are looking for.

lines() is more designed for a series of connected lines (eg. a  
polygon) rather than a single line segment.


abline() can draw a straight line, at a given vertical or horizontal  
position, or if given a linear model object, the fitted line.


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] How to draw a line in plot when I know the start point(x

2009-06-25 Thread Ted Harding
On 25-Jun-09 18:38:37, Marc Schwartz wrote:
 On Jun 25, 2009, at 1:30 PM, Lesandro wrote:
 Hello all,
 How to draw a line in plot when I know the start point(x1,y1)
 and end point(x2,y2)? I need make this as additional information
 in the graph:

 plot(wl2[[1]],wl2[[2]])

 I think that is possible make this with the function abline(), is  
 possible? I looked the function lines() too, but don't understand
 as make.

 Thanks!
 Lesandro
 
 See ?segments which does just what you are looking for.
 
 lines() is more designed for a series of connected lines (eg. a  
 polygon) rather than a single line segment.
 
 abline() can draw a straight line, at a given vertical or horizontal  
 position, or if given a linear model object, the fitted line.
 HTH,
 Marc Schwartz

Hmm ... for this particular purpose I don't see what is wrong with

  plot(wl2[[1]],wl2[[2]])
  lines(c(x1,x2),c(y1,y2))

along with any additional paramaters to lines() for line-type,
colour, etc. -- I do this all the time ...
Ted.


E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk
Fax-to-email: +44 (0)870 094 0861
Date: 25-Jun-09   Time: 19:51:20
-- XFMail --

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


[R] LaTeX references inside R code using SweaveListingUtils

2009-06-25 Thread Frank E Harrell Jr
I have sent a note to  Peter Ruckdeschel who wrote the excellent 
SweaveListingUtils package but find myself up against a deadline in 
preparing a handout for useR! 2009.


The following is supposed to work:

=
plot(x, y)   # Figure `\ref{myfig}`
@

Where the back tick ` is an escape character and \ref{myfig} will be 
replaced by LaTeX with the correct figure number that was created by a 
\label{myfig} command.  I have not been able to get this to work.  I 
just get `\ref{myfig}` verbatim on the R output.


Does anyone know of a way to do this?

Thanks
Frank

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

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


Re: [R] How to draw a line in plot when I know the start point(x

2009-06-25 Thread Marc Schwartz


On Jun 25, 2009, at 1:51 PM, Ted Harding wrote:


On 25-Jun-09 18:38:37, Marc Schwartz wrote:

On Jun 25, 2009, at 1:30 PM, Lesandro wrote:

Hello all,
How to draw a line in plot when I know the start point(x1,y1)
and end point(x2,y2)? I need make this as additional information
in the graph:

plot(wl2[[1]],wl2[[2]])

I think that is possible make this with the function abline(), is
possible? I looked the function lines() too, but don't understand
as make.

Thanks!
Lesandro


See ?segments which does just what you are looking for.

lines() is more designed for a series of connected lines (eg. a
polygon) rather than a single line segment.

abline() can draw a straight line, at a given vertical or horizontal
position, or if given a linear model object, the fitted line.
HTH,
Marc Schwartz


Hmm ... for this particular purpose I don't see what is wrong with

 plot(wl2[[1]],wl2[[2]])
 lines(c(x1,x2),c(y1,y2))

along with any additional paramaters to lines() for line-type,
colour, etc. -- I do this all the time ...
Ted.


Nothing wrong at all Ted. It will of course work.

For example:

plot(1:10)
lines(c(2, 4), c(6, 8))

That will give you the same result as:

plot(1:10)
segments(2, 6, 4, 8)


In this case, it may be a matter of choice. For single lines, I tend  
to use segments().


As is frequently the case with R, there is more than one way to skin  
the feline...


Regards,

Marc

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] (Resolved) How to draw a line in plot when I know the start point(x1, y1) and end point(x2, y2)?

2009-06-25 Thread lesandrop
Thanks Jorge and Marc,

I drew the line using the function:

segments(x0, y0, x1, y1)

Lesandro

  

--- Em qui, 25/6/09, Marc Schwartz marc_schwa...@me.com escreveu:

De: Marc Schwartz marc_schwa...@me.com
Assunto: Re: [R] How to draw a line in plot when I know the start point(x1, y1) 
and end point(x2, y2)?

Cc: r-help@r-project.org
Data: Quinta-feira, 25 de Junho de 2009, 15:38

On Jun 25, 2009, at 1:30 PM, Lesandro wrote:

 Hello all,
 
 How to
 draw a line in plot when I know the start point(x1,y1) and end point(x2,y2)? I 
need make this as additional information in the graph:
 
 plot(wl2[[1]],wl2[[2]])
 
 I think that is possible make this with the function abline(), is possible? I 
 looked the function lines() too, but don't understand as make.
 
 
 Thanks!
 Lesandro


See ?segments which does just what you are looking for.

lines() is more designed for a series of connected lines (eg. a polygon) rather 
than a single line segment.

abline() can draw a straight line, at a given vertical or horizontal position, 
or if given a linear model object, the fitted line.

HTH,

Marc Schwartz




[[elided Yahoo spam]]

[[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] what happened to the xlsReadWrite package

2009-06-25 Thread Andrew Yee
A naive question:  what happened to the xlsReadWrite package?
http://cran.r-project.org/web/packages/xlsReadWrite/

It says that it was removed from the CRAN repository.  Are there any plans
for it be available again?

Thanks,
Andrew

[[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] grid.polygon() + color gradient

2009-06-25 Thread baptiste auguie
Glad if it helps.

check out this page of examples for tikz,

http://www.texample.net/tikz/examples/feature/shadings/

If you do choose this route, you could perhaps read the new wiki page on
importing graphics in a R plot,

http://wiki.r-project.org/rwiki/doku.php?id=tips:graphics-misc:display-images

(you'll want to convert the result of Tikz into a bitmap format first, with
imagemagick for example).


As for the pure R graphics solution, you'll have to play with Grid viewports
(and perhaps the gridBase package if your Figure is using base graphics).
Can you post a minimal, self-contained, reproducible example of what you're
trying to achieve to the list?

baptiste





2009/6/25 Kexin Ji kex...@gmail.com

 Hi,

 The triangle looks great!!
 And thanks for mentioning the TeX package Tikz! Maybe I'll check it out
 later.
 The only problem is that I need to append this color-gradient triangle into
 a another Figure I'm working on. But when I try to do that, this wonderful
 triangle overwrites the other one. Have tried to append it with not much
 luck..
 Much appreciation to your help though!!!

 Kexin


 On 6/25/09, baptiste auguie baptiste.aug...@gmail.com wrote:

 Hi,

 I don't think the fill parameter can be a colour gradient. You'll need to
 create small polygons, each with its own fill (200, say). Try this,

 x= c(0, 0.5, 1)
 y= c(0.5, 1, 0.5)
 grid.polygon(x=x, y=y, gp=gpar(fill=grey90, col=grey90))

 xx - seq(range(x)[1],range(x)[2], length=100)
 yy - rep(max(y), length(xx))
 cols - colorRampPalette(c(green, lightgray))(length(xx))

 for(ii in seq_along(xx[-length(xx)])) {

 grid.clip(x=xx[ii], y=0.5,
 width= xx[ii+1],
 height=1,
 just=bottom)

 grid.polygon(x=c(0, 0.5, 1), y=c(0.5, 1, 0.5), gp=gpar(fill=cols[ii],
 col=NA))
 }

 Note that the situation would become rather more complicated for a
 gradient at some angle (see ?grobX if you need to).

 If you're free to choose an external tool to produce this, the TeX package
 Tikz has good support for gradients and clipping.

 HTH,

 baptiste

 Kexin Ji wrote:

 Hi,

 I wonder whether there is a way to generate a polygon (a triangle in  my
 case) with color gradient using grid.polygon() in package grid?

 I tried something like

 library(grid)
 grid.polygon(x=c(0, 0.5, 1), y=c(0.5, 1, 0.5), gp=gpar(col=NA,
  fill=colorRampPalette(c(green, lightgray),
space=Lab)(200)))

 But am only getting a triangle filled with color green, whereas the  aim
 is a triangle of color gradient from green to lightgray.

 Can grid.polygon() generate a color gradient, or am I being mistaken?

 Best to my knowledge, is it true that R currently doesn't contain any
  other function that might generate a polygon with color gradient?

 Thank you!

 Kexin


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





 --
 _

 Baptiste Auguié

 School of Physics
 University of Exeter
 Stocker Road,
 Exeter, Devon,
 EX4 4QL, UK

 Phone: +44 1392 264187

 http://newton.ex.ac.uk/research/emag
 __





-- 

_

Baptiste Auguié

School of Physics
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK

Phone: +44 1392 264187

http://newton.ex.ac.uk/research/emag
__

[[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] change the height or scale of the y axis

2009-06-25 Thread legen

Hi, Jim,

Thank you for your reply. I just want to increase the height of y axis in
the second plot in order to show all the indices (x1, x2, ...). Can you help
me? Thank you again.

Legen



Jim Lemon-2 wrote:
 
 legen wrote:
 Hallo, All,

 I have a question about changing the height or scale of the y axis. When
 I
 use following two R codes, I can get two plots. Please look at the y
 axes,
 the number of indices (x1, x2, …) on the y axis in the first plot is
 smaller
 than that in the second plot, and hence the space between any two indices
 in
 the first plot is wider than that in the second plot. As the number of
 indices increases, the space will vanish and the indices will overlap. I
 want to display all the indices on the y axis in the second plot, just
 look
 like that in the first plot. How to separate the indices on the y axis in
 the second plot? I guess maybe changing the height or scale of y axis is
 a
 way to solve my problem, but I failed to do it after several trails.
 Anybody
 can help me? Thank you in advance.

 Legen

 The first R code:
 x-c(x1,x2,x3,x4,x5,x6,x7,x8,x9,x10)
 y-sample(0:100,10,replace=F)
 d-data.frame(y)
 rownames(d)-x
 r-nrow(d)
 i-1:r
 plot(d$y,i,xlab=,ylab=,axes=F)
 axis(1)
 axis(2,at=i,labels=x)

 The second R code:
 x-c(x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,
  x11,x12,x13,x14,x15,x16,x17,x18,x19,x20,
  x21,x22,x23,x24,x25,x26,x27,x28,x29,x30,
  x31,x32,x33,x34,x35,x36,x37,x38,x39,x40,
  x41,x42,x43,x44,x45,x46,x47,x48,x49,x50,
  x51,x52,x53,x54,x55,x56,x57,x58,x59,x60,
  x61,x62,x63,x64,x65,x66,x67,x68,x69,x70,
  x71,x72,x73,x74,x75,x76,x77,x78,x79,x80,
  x81,x82,x83,x84,x85,x86,x87,x88,x89,x90,
  x91,x92,x93,x94,x95,x96,x97,x98,x99,x100,
 
 x101,x102,x103,x104,x105,x106,x107,x108,x109,x110,
 
 x111,x112,x113,x114,x115,x116,x117,x118,x119,x120,
 
 x121,x122,x123,x124,x125,x126,x127,x128,x129,x130,
 
 x131,x132,x133,x134,x135,x136,x137,x138,x139,x140,
 
 x141,x142,x143,x144,x145,x146,x147,x148,x149,x150,
 
 x151,x152,x153,x154,x155,x156,x157,x158,x159,x160,
 
 x161,x162,x163,x164,x165,x166,x167,x168,x169,x170,
 
 x171,x172,x173,x174,x175,x176,x177,x178,x179,x180,
 
 x181,x182,x183,x184,x185,x186,x187,x188,x189,x190,
 
 x191,x192,x193,x194,x195,x196,x197,x198,x199,x200)
 y-sample(0:300,200,replace=F)
 d-data.frame(y)
 rownames(d)-x
 r-nrow(d)
 i-1:r
 plot(d$y,i,xlab=,ylab=,axes=F)
 axis(1)
 axis(2,at=i,labels=x)

   
 Hi legen,
 Your problem centers about the fact that you have about 3 times the 
 vertical scale on the second plot and 20 times the number of ticks and 
 labels. You could make the second plot 3 times the height of the first 
 one, and you would get approximately the same spacing of equal 
 intervals, but the intervals on the second plot are likely to be about 
 1.5 times those of the first. I can't work out why you are trying to do 
 what you say you want to do. Maybe some more explanation would help.
 
 Jim
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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://www.nabble.com/change-the-height-or-scale-of-the-y-axis-tp24187351p24206583.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] change the height or scale of the y axis

2009-06-25 Thread legen

Hi, Dieter Menne,

Thank you for your help. I tried par(las=1,cex=0.5), but it changed only
the size of indices on the y axis in the second plot relative to the
default. I really want to increase the height of y axis in order to show all
the indices (x1, x2, ...). In the genetic study, we aften draw plots of
chromosomes with lots of genes (x1, x2, ...) and their positons on the
chromosome (numerical values). 

Legen



Dieter Menne wrote:
 
 
 
 legen wrote:
 
 
 I have a question about changing the height or scale of the y axis. When
 I use following two R codes, I can get two plots. Please look at the y
 axes, the number of indices (x1, x2, …) on the y axis in the first plot
 is smaller than that in the second plot, and hence the space between any
 two indices in the first plot is wider than that in the second plot. As
 the number of indices increases, the space will vanish and the indices
 will overlap. I want to display all the indices on the y axis in the
 second plot, just look like that in the first plot. How to separate the
 indices on the y axis in the second plot? I guess maybe changing the
 height or scale of y axis is a way to solve my problem, but I failed to
 do it after several trails. Anybody can help me? Thank you in advance.
 
 
 
 You really put a lot of typing work into your example code, but it work,
 so it's fine. As a first attempt, put the following before the second
 plot(). 
 
 par(las=1,cex=0.5)
 
 And think about the paper size. I suggest to have a look at lattice
 graphics for this type of work as a more elegant alternative. And Hadley
 Wickham can certainly tell you how to do this in ggplot47
 
 
 
 

-- 
View this message in context: 
http://www.nabble.com/change-the-height-or-scale-of-the-y-axis-tp24187351p24206684.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] Calculating home ranges using mcp in adehabitat

2009-06-25 Thread Tom Mason

Hello,

I've been trying to calculate home range sizes (for Icelandic geese!) using
minimum convex polygons with the adehabitat package. I've tried to use the R
code shown by demo(homerange) in adehabitat and when that didn't work I've
fiddled around with it but to no avail...Below is the output of the demo
that I've attempted to follow, followed by a subset of my data (for one
individual) and the code I've been trying. Can anyone tell me where I may be
going wrong???


#Demo output...

 data(puechabon)

 xy-puechabon$locs[,c(X,Y)]

 id-puechabon$locs$Name

 ## The data are:
 xy[1:4,] ## relocations coordinates
   X   Y
1 699889 3161559
2 700046 3161541
3 698840 3161033
4 699809 3161496

 id[1:4]  ## ID
[1] Brock Brock Brock Brock
Levels: Brock Calou Chou Jean

 ###
 ###
 ###
 ### Home ranges
 
 ## MCP
 hr-mcp(xy, id) ## home range estimation



# My attempts...

 mydata
   Name XY
1  XDRY -21.98389 64.06457
2  XDRY -21.99759 64.08291
3  XDRY -21.98784 64.06467
4  XDRY -21.98333 64.06058
5  XDRY -21.97889 64.06257
6  XDRY -21.98284 64.06044
7  XDRY -21.97886 64.06358
8  XDRY -21.99741 64.08124
9  XDRY -21.99715 64.08330
10 XDRY -22.00397 64.09331
11 XDRY -21.99811 64.08239
12 XDRY -22.00453 64.09337
13 XDRY -21.99713 64.08299
14 XDRY -21.99608 64.08307
15 XDRY -21.99646 64.08352
16 XDRY -21.99326 64.08361
17 XDRY -22.00770 64.09090
18 XDRY -21.98160 64.06400
19 XDRY -21.97966 64.06367

 xy-mydata$locs[,c(X,Y)]
 id-mydata$locs$Name

 xy[1:19,]
NULL
 id[1:19,]
NULL

 mcp(xy,id,percent=95)
Error in if (length(id) != nrow(xy)) stop(xy and id should be of the same
length) : 
  argument is of length zero


#I've also tried things like the code below. But didn't know how to
incorporate 'locs' into this...

 xy-cbind(X,Y)
 id-Name[1:19]

 xy[1:19,]
  XY
 [1,] -21.98389 64.06457
 [2,] -21.99759 64.08291
 [3,] -21.98784 64.06467
 [4,] -21.98333 64.06058
 [5,] -21.97889 64.06257
 [6,] -21.98284 64.06044
 [7,] -21.97886 64.06358
 [8,] -21.99741 64.08124
 [9,] -21.99715 64.08330
[10,] -22.00397 64.09331
[11,] -21.99811 64.08239
[12,] -22.00453 64.09337
[13,] -21.99713 64.08299
[14,] -21.99608 64.08307
[15,] -21.99646 64.08352
[16,] -21.99326 64.08361
[17,] -22.00770 64.09090
[18,] -21.98160 64.06400
[19,] -21.97966 64.06367

 id-Name[1:19]
 id[1:19]
 [1] XDRY XDRY XDRY XDRY XDRY XDRY XDRY XDRY XDRY XDRY XDRY
[12] XDRY XDRY XDRY XDRY XDRY XDRY XDRY XDRY
Levels: XDRY

 mcp(xy,id,percent=95)
Error in apply(xy, 2, mean) : dim(X) must have a positive length

 xy1-xy[1:19,]
 id1-id[1:19]
 mcp(xy1,id1,percent=95)
Error in apply(xy, 2, mean) : dim(X) must have a positive length


Would be most grateful for any suggestions to where I'm going wrong!


Tom Mason,
University of Exeter,
UK.








-- 
View this message in context: 
http://www.nabble.com/Calculating-home-ranges-using-mcp-in-adehabitat-tp24207532p24207532.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] Converting S-plus project folders to R

2009-06-25 Thread dbosley

I have many S-plus project folders that I need to convert to R workspaces.
For the smaller project folders ( 200MB), using data.dump with oldStyle
= T and data.restore (in the foreign package) within R seems to work
fine. However, I have several project folders that are quite large (~ 4GB).
When I use this procedure to try to convert these project folders, R always
crashes when I perform the data.restore command. Does anyone have any
suggestions?
Thanks,
Dave Bosley



-- 
View this message in context: 
http://www.nabble.com/Converting-S-plus-project-folders-to-R-tp24209758p24209758.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.


  1   2   >