Re: [R] how do I plot a regression curve with the data?

2009-10-27 Thread Peter Ehlers


Ken Ervin wrote:
I have a data set of 6 or so ordered pairs, and I've been able to graph 
them and have decided to use a high-order polynomial regression.  I've 
used the following piece of code:


regression <- function(x,y) {
   x <- c(insert_numbers_here)
   y <- c(insert_other_numbers_here)
   fit <- lm(y ~ x + I(x^2) + I(x^3) + I(x^4) + I(x^5) + I(x^6) + I(x^7) 
+ I(x^8) + I(x^9))

   summary(fit)

This gives me the coefficients for the regression very nicely, but I 
would like to plot both the data and the regression curve together.  How 
do I plot that regression curve as a function, and can I put it on the 
same set of axes as my data scatter plot?



Are you sure that fitting such a high-degree polynomial makes
sense? Is there any theory to support the model? If you really
want to do this, then use predict.lm():

## with xmin, xmax as the limits of your scatterplot
 xx <- seq(xmin, xmax, length=51)
 yy <- predict(fit, newdata=list(x=xx))
 lines(xx, yy)  ## add to scatterplot

 -Peter Ehlers



Thanks in advance for your help!

-KE

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

2009-10-27 Thread Ulrike Groemping

Charles,

not quite in response to your question, but I think a better message in R
2.10 would be to suggest use of help_type="html" (which can of course be
included in Rprofile.site). While chm is no longer supported, html has been
substantially improved and provides new linking facilities between packages.

Regards, 
Ulrike


Charles Annis, P.E. wrote:
> 
> R-insiders:
> 
> While trying to be clever I inserted these lines in ..\Rprofile.site
> (which
> works in R2.9.2 and earlier)
> 
> # to prefer Compiled HTML help
>   options(chmhelp=TRUE)
> 
> but upon re-starting R2.10.0 I learned that
> 
> chmhelp = TRUE is no longer supported: use help_type ="text"
> 
> I'm sure this was explained elsewhere but I missed it. Could someone
> explain
> why the compiled html help is no longer supported?
> 
> Thanks.
> 
> Charles Annis, P.E.
> 
> charles.an...@statisticalengineering.com
> phone: 561-352-9699
> eFax:  614-455-3265
> http://www.StatisticalEngineering.com
>  
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
> On
> Behalf Of Ulrike Groemping
> Sent: Tuesday, October 27, 2009 4:17 PM
> To: r-help@r-project.org
> Subject: Re: [R] Cannot activate chm help in R 2.10
> 
> 
> 
> 
> Uwe Ligges-3 wrote:
>> 
>> 
>> 
>> Duncan Murdoch wrote:
>>> On 10/27/2009 10:56 AM, Ulrike Groemping wrote:


 Duncan Murdoch-2 wrote:
>
> Ulrike Groemping wrote:
> ...
>> My system is Windows XP, German locale computer. On installation, I
>> was
>> asked to decide for text or html help and chose html (there was no 
>> radio
>> button for chm help).  
> ...
>
> If you set
>
> options(help_type="html")
>
> you'll get HTML help with links in your default browser.
>
> Duncan Murdoch
>
>

 Thank you very much, this works. But I am very surprised that it is 
 not the
 default. Having chosen html help during installation, I would have 
 expected
 this to be active without having to change an option.
>>> 
>>> Yes, it should have been, but there was a bug in the installer, and the 
>>> preference indicated there was ignored. This is why it's useful to have 
>>> people doing testing during the beta test period:  things like this are 
>>> easy to fix, but they need to be noticed first.
>> 
>>> Duncan Murdoch
>> 
>> And let me add:
>> 
>> The whole statistics department has been on two pre-release versions 
>> (beta and release-candidate) and nobody reported any error. The 
>> installer problem has not been found because I installed from sources 
>> anyway. This shows it makes sense to have more than just 400+ beta 
>> testers. ;-)
>> 
>> Uwe
>> 
>> 
> 
> Two more comments: For those of us who have already installed the version
> with this installer bug: If you do not want to change the option each time
> you call R, it is easy to change it permanently in the file
> R_HOME/etc/Rprofile.site (where R_HOME stands for the directory in which
> your R is installed, e.g. c:\programs\r\r-2.10.0).  
> 
> Regarding beta testing (yes, I admit, I usually leave that to others, and
> am
> nevertheless looking for beta testers of my package RcmdrPlugin.DoE),
> maybe
> it would be time for an experimental design that specifies characteristics
> of beta testers to ensure some diversity there, perhaps package DoE.base
> or
> FrF2 could help there (half-, but only half-jokingly) ;-) 
> 
> Regards, Ulrike
> -- 
> View this message in context:
> http://www.nabble.com/Cannot-activate-chm-help-in-R-2.10-tp26067423p26084237
> .html
> Sent from the R help mailing list archive at Nabble.com.
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Cannot-activate-chm-help-in-R-2.10-tp26067423p26090080.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] "ipredknn" - How may I find values?

2009-10-27 Thread David Winsemius


On Oct 27, 2009, at 8:37 PM, Grzes wrote:



I'm sorry David, this is my code once again:

library(klaR)
library(ipred)
library(mlbench)
data(PimaIndiansDiabetes2)
dane=na.omit(PimaIndiansDiabetes2)[,c(2,5,9)]
dane[,2]=log(dane[,2])
dane[,1:2]=scale(dane[,1:2])
zbior.uczacy=sample(1:nrow(dane),nrow(dane)/2,F)

klasyfikatorKNN=ipredknn(diabetes~glucose 
+insulin,data=dane,subset=zbior.uczacy,k=3)


oceny=predict(klasyfikatorKNN,dane[-zbior.uczacy,],"class")

df=data.frame(glucose=c(klasyfikatorKNN$learn$X[, 
1]),insulin=klasyfikatorKNN$learn$X[,2],diabetes=c(klasyfikatorKNN 
$learn$y))

df$diabetes=factor(df$diabetes)

drawparti(df$diabetes, df$glucose, df$insulin, method = "sknn", prec  
= 100,

xlab = NULL, ylab = NULL)


If this had used lattice/grid graphics you would have gotten an  
object, but this was done with base graphics. If you type drawparti,   
you get the code. Seems fairly likely that this section could be  
modified to return the vector that has the information about a  
particular run:


 colorw <- grouping != khead
err <- round(mean(colorw), 3)
color <- ifelse(colorw, col.wrong, col.correct)

Why not try adding return(color) or return( matrix( c(color,grouping),  
ncol=2) ) after that section? I then get this


> draw.obj <- drawparti(df$diabetes, df$glucose, df$insulin, method =  
"sknn", prec = 100,  xlab = NULL, ylab = NULL)

> head(draw.obj)
 [,1][,2]
[1,] "red"   "1"
[2,] "black" "1"
[3,] "black" "1"
[4,] "black" "2"
[5,] "black" "1"
[6,] "red"   "1"

That seems to capture the information you are requesting. Appears that  
a red "1" is in one of the red areas, a black "2" is in red.


--
David



But in my computer everything is ok. The "drawparti" is in "klaR"  
package.

Or maybe try like this:

drawparti(klasyfikatorKNN$learn$y, df$glucose, klasyfikatorKNN$learn 
$X[,2],

method = "sknn", prec = 100, xlab = NULL, ylab = NULL)





David Winsemius wrote:



On Oct 27, 2009, at 10:18 AM, Grzes wrote:



Yes, I want to know which points in my picture are in red or green
area.
For example:
.glucose..insulin.diabetes
609  0.95177272  1.139969011   - I want to know that it's  
for

example: black point in red area


red area?



253 -1.05724970 -1.158814331   - it's for example: black
point in
green area


green area?


319 -0.24716002  0.184830541
302  0.69254402  0.132529652

If it's impossible plese give me any package or function which can
do it.


I already asked what was different about your code that was able to  
do

plotting without error on your machine.

--
David



Max Kuhn wrote:


I think we are having some difficulty understanding what you are
looking for. If you are looking to find which of the training  
samples
were closest to the prediction sample, I don't think that you can  
get

it from this function.

If this is what you want, I use the dist function in the proxy
package.

Max

On Tue, Oct 27, 2009 at 8:46 AM, David Winsemius 


wrote:


On Oct 27, 2009, at 6:02 AM, Grzes wrote:



Hi everybody!

I want to find a closer neighbourins observation. This is my  
code:

##
library(klaR)
library(ipred)
library(mlbench)
data(PimaIndiansDiabetes2)
dane=na.omit(PimaIndiansDiabetes2)[,c(2,5,9)]
dane[,2]=log(dane[,2])
dane[,1:2]=scale(dane[,1:2])
zbior.uczacy=sample(1:nrow(dane),nrow(dane)/2,F)


klasyfikatorKNN=ipredknn(diabetes~glucose
+insulin,data=dane,subset=zbior.uczacy,k=3)

oceny=predict(klasyfikatorKNN,dane[-zbior.uczacy,],"class")

#data frames with my result from klasyfikatorKNN

df=data.frame(glucose=c(klasyfikatorKNN$learn$X[,
1]),insulin=klasyfikatorKNN$learn$X[, 
2],diabetes=c(klasyfikatorKNN

$learn$y))
#And picture
drawparti(as.factor(df$diabetes), df$glucose, df$insulin,  
method =

"sknn",
prec = 100, xlab = NULL, ylab = NULL)


I get an error: Error: could not find function "drawparti"



##
My question is:  How or where may I find correct or wrong values
which
were
drawn (found,classification) in this picture?


No picture resulted.


It means I'm looking for  x, y
values.


Not sure exactly what you are asking. Does this modification to df
and
fairly obvious the cross table help?



df=data.frame(glucose=c(klasyfikatorKNN$learn$X[,
1]),insulin=klasyfikatorKNN$learn$X[,
2],pred.diabetes=klasyfikatorKNN$learn$y,
trueDiab=dane[,3])

Warning message:
In data.frame(glucose = c(klasyfikatorKNN$learn$X[, 1]), insulin =
klasyfikatorKNN$learn$X[,  :
row names were found from a short variable and have been discarded

with( df, table(pred.diabetes, trueDiab))

   trueDiab
pred.diabetes neg pos
neg 174  86
pos  88  44






--
View this message in context:
http://www.nabble.com/%22ipredknn%22---How-may-I-find-values--tp26074994p26074994.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-hel

[R] need help explain the routine input parameters for seROC and cROC found in the R archive

2009-10-27 Thread Waverley @ Palo Alto
Please help.

I found the code in the archive.

The author of this script says: "The first function (seROC) calculate
the standard error of ROC curve, the second function (cROC) compare
ROC curves."


Can some one explain to me what are the na, nn and r parameters which
are used as the input to the following two functions?

Thanks much in advance.

> From: Bernardo Rangel Tura
> Date: Thu 16 Dec 2004 - 07:30:37 EST
>
> seROC<-function(AUC,na,nn){
> a<-AUC
> q1<-a/(2-a)
> q2<-(2*a^2)/(1+a)
> se<-sqrt((a*(1-a)+(na-1)*(q1-a^2)+(nn-1)*(q2-a^2))/(nn*na))
> se
> }
>
> cROC<-function(AUC1,na1,nn1,AUC2,na2,nn2,r){
> se1<-seROC(AUC1,na1,nn1)
> se2<-seROC(AUC2,na2,nn2)
>
> sed<-sqrt(se1^2+se2^2-2*r*se1*se2)
> zad<-(AUC1-AUC2)/sed
> p<-dnorm(zad)
> a<-list(zad,p)
> a
> }
>

-- 
Waverley @ Palo Alto

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


Re: [R] Help - Probability scale on an ECDF plot

2009-10-27 Thread Don MacQueen
You need to tell the mailing list what you have tried. That way you 
will get better help.


Here is one solution.


 foo <- rnorm(1000)
 probs <- seq(0,1,.1)
 foo <- rnorm(1000)
 bah <- quantile(foo,probs)
 plot(bah,probs)


But it turns out that
   ?ecdf
tells you there is an ecdf function. And then
   plot(ecdf(foo))
gives an ECDF plot with a probability scale on the y axis.
(So it's hard to imagine what you were doing that didn't give you a 
probability axis)


-Don


At 5:22 PM -0700 10/27/09, Jessica Goin wrote:

Hello;

Can anyone tell me how to set my y-axis to a probability scale on an ECDF
plot?  Or alternatively, how to generate a plot of percent cumulative
probability against concentration?  DASplusR does this and calls it a CP
plot, but I would like to be able to generate this outside of DASplusR-

Thank you!

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



--
-
Don MacQueen
Lawrence Livermore National Laboratory
Livermore, CA, USA
925-423-1062
m...@llnl.gov

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

2009-10-27 Thread jim holtman
FIRST:

PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

If you expect an answer, please provide the data.  Here is one way of doing it:

> N <- 30
> x <- data.frame(A=sample(1:3, N, TRUE), B=sample(1:2, N, TRUE),
+ C=sample(1:2, N, TRUE), D=sample(1:4, N, TRUE), data=runif(N))
> require(reshape)
> x.m <- melt(x, measure='data')
> cast(x.m, A+B+C~D, mean)
   A B C  1 2 3  4
1  1 1 1 0.51473265 0.7396417 0.0853110NaN
2  1 1 2 0.07246063 0.2939918   NaNNaN
3  1 2 1NaN   NaN 0.5297180 0.10505014
4  1 2 2NaN 0.8383841   NaNNaN
5  2 1 1NaN   NaN 0.8016877 0.04152843
6  2 1 2 0.34448739   NaN   NaN 0.35757999
7  2 2 1 0.87943330   NaN 0.1431666 0.92051784
8  2 2 2NaN   NaN 0.5008505NaN
9  3 1 1 0.48216957 0.4230986   NaN 0.53786492
10 3 1 2NaN 0.7602803   NaN 0.33989081
11 3 2 1 0.43471764   NaN 0.2642490NaN
12 3 2 2NaN 0.3665636   NaN 0.37875944



On Tue, Oct 27, 2009 at 8:32 PM, Jonathan Greenberg
 wrote:
> R-helpers:
>
>   I have a data frame containing 4 factor variables (let's say A,B,C, and D)
> and 1 numerical variable (N).  I would like to produce a cross-tabulated
> data frame in which A,B,C are individual columns, each factor of D is its
> own column, and the field is calculated as a given function of N (I would
> like to have two output data frames, one with the mean(N) and one with the
> sum(N), e.g.:
>
> A,    B,    C,    D1,                                        D2,
>                           ...,        DM
> A1   B1   C1   mean(N{A1,B1,C1,D1)})   mean(N{A1,B1,C1,D2)})
> mean(N{A1,B1,C1,DM)})
> A2   B1   C1   mean(N{A2,B1,C1,D1)})   mean(N{A2,B1,C1,D2)})
> mean(N{A2,B1,C1,DM)})
> etc...
>
> I can mostly do this with aggregate, e.g.
> output = aggregate(N,list(A,B,C,D),mean), but I can't get that last step of
> cross-tabulating the Ds to column headers.  table() and xtabs() appear to
> just count, rather than giving me access to sum() and mean().  Any ideas?
>  Ideally I'd like to do this in a single step, as the aggregate output
> (above) produces a much larger data frame than a cross-tabulated output
> would (in my particular case).
>
> --j
>
> --
>
> Jonathan A. Greenberg, PhD
> Postdoctoral Scholar
> Center for Spatial Technologies and Remote Sensing (CSTARS)
> University of California, Davis
> One Shields Avenue
> The Barn, Room 250N
> Davis, CA 95616
> Phone: 415-763-5476
> AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



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

What is the problem that you are trying to solve?

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

2009-10-27 Thread William Dunlap
> -Original Message-
> From: r-help-boun...@r-project.org 
> [mailto:r-help-boun...@r-project.org] On Behalf Of Rnewb
> Sent: Tuesday, October 27, 2009 6:44 PM
> To: r-help@r-project.org
> Subject: [R] re gression with multiple dependent variables?
> 
> 
> i have a series of regressions i need to run where everything 
> is the same
> except for the dependent variable, e.g.:
> 
> lm(y1 ~ x1+x2+x3+x4+x5, data=data)
> lm(y2 ~ x1+x2+x3+x4+x5, data=data)
> lm(y3 ~ x1+x2+x3+x4+x5, data=data)

You can do
   with(data, lm.fit(x=cbind(Intercept=1,x1,x2,x3), y=cbind(y1,y2,y3)))
lm.fit is the numerical code behind lm().

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com 

> 
> is it possible to run all these regs with a single command?  
> given that the
> bulk of the work for linear regressions is inverting a matrix 
> that depends
> only on the independent variables, it seems like a waste to 
> do it over and
> over for each new dependent variable.
> 
> thanks,
> Rnewb
> -- 
> View this message in context: 
> http://www.nabble.com/regression-with-multiple-dependent-varia
bles--tp26088025p26088025.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 

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


Re: [R] re gression with multiple dependent variables?

2009-10-27 Thread Daniel Malter
Hi, cbind the dependent variables such as in:

x=rnorm(100)
e1=rnorm(100)
e2=rnorm(100)
e3=rnorm(100)

y1=2*x+e1
y2=-1*x+e2
y3=0.7*x+e3

reg=lm(cbind(y1,y2,y3)~x)
summary(reg)

Cheers,
Daniel 


-
cuncta stricte discussurus
-

-Ursprüngliche Nachricht-
Von: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Im
Auftrag von Rnewb
Gesendet: Tuesday, October 27, 2009 9:44 PM
An: r-help@r-project.org
Betreff: [R] re gression with multiple dependent variables?


i have a series of regressions i need to run where everything is the same
except for the dependent variable, e.g.:

lm(y1 ~ x1+x2+x3+x4+x5, data=data)
lm(y2 ~ x1+x2+x3+x4+x5, data=data)
lm(y3 ~ x1+x2+x3+x4+x5, data=data)

is it possible to run all these regs with a single command?  given that the
bulk of the work for linear regressions is inverting a matrix that depends
only on the independent variables, it seems like a waste to do it over and
over for each new dependent variable.

thanks,
Rnewb
--
View this message in context:
http://www.nabble.com/regression-with-multiple-dependent-variables--tp260880
25p26088025.html
Sent from the R help mailing list archive at Nabble.com.

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

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


Re: [R] cox regression extract strata as numeric

2009-10-27 Thread Steven McKinney

> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
> project.org] On Behalf Of ?e???da? ?pa?t??
> Sent: Tuesday, October 27, 2009 3:51 PM
> To: r-help@r-project.org
> Subject: [R] cox regression extract strata as numeric
> 
> 
> Hi there,
> 
> I perform a stratified cox and then I need the strata as a  numeric
> array "straft.ln"
> ft.ln <-
> coxph(Surv(times,deaths)~ages+chemos+chemos:f1+chemos:f2+horms+horms:f1
> +horms:f2+grades+grades:f1+grades:f2+positives+positives:f1+positives:f
> 2+sizes+sizes:f1+sizes:f2+strata(stra),data=ddd)
> 
> basehazzft.ln=basehaz(ft.ln,centered=FALSE)
> H0ft.ln=c(basehazzft.ln[,1])
> timeft.ln=c(basehazzft.ln[,2])
> straft.ln=c(basehazzft.ln[,3])
> 
> I notice that basehazzft.ln[,3] is not the same with straft.ln with
> respect to the values i.e.:
> 
> (basehazzft.ln$stra[1])
> [1] stra=1
> 134 Levels: stra=1 stra=10 stra=100 stra=101 stra=102 ... stra=99
> > c(basehazzft.ln$stra[1])
> [1] 1
> 
> 
> so far so good but:
> 
> (basehazzft.ln$stra[285])
> [1] stra=2
> 134 Levels: stra=1 stra=10 stra=100 stra=101 stra=102 ... stra=99
> > c(basehazzft.ln$stra[285])
> [1] 47
> 
> while the desired value is 2, I get a 47. What am I doing wrong? I
> tried the as.numeric function but I have the same problem..
> 
> I just want instead of the [ "stra=1" "stra=1" "stra=1" etc]  the
> [1,1,1 etc]
> 
> Thanx in advance for any answers!

Here's one way to do it (using the example on coxph help page):

> require("survival")
Loading required package: survival
Loading required package: splines
> bladder1 <- bladder[bladder$enum < 5, ] 
> m1 <- coxph(Surv(stop, event) ~ (rx + size + number) * strata(enum) + 
> cluster(id), bladder1)
> basehazzft.ln=basehaz(m1,centered=FALSE)
> (basehazzft.ln$stra[1])
[1] enum=1
Levels: enum=1 enum=2 enum=3 enum=4
> basehazzft.ln$stra
 [1] enum=1 enum=1 enum=1 enum=1 enum=1 enum=1 enum=1 enum=1 enum=1 enum=1 
enum=1 enum=1 enum=1
[14] enum=1 enum=1 enum=1 enum=1 enum=1 enum=1 enum=1 enum=1 enum=2 enum=2 
enum=2 enum=2 enum=2
[27] enum=2 enum=2 enum=2 enum=2 enum=2 enum=2 enum=2 enum=2 enum=2 enum=2 
enum=2 enum=2 enum=2
[40] enum=2 enum=3 enum=3 enum=3 enum=3 enum=3 enum=3 enum=3 enum=3 enum=3 
enum=3 enum=3 enum=3
[53] enum=3 enum=3 enum=3 enum=3 enum=3 enum=4 enum=4 enum=4 enum=4 enum=4 
enum=4 enum=4 enum=4
[66] enum=4 enum=4 enum=4
Levels: enum=1 enum=2 enum=3 enum=4
> as.character(basehazzft.ln$stra)
 [1] "enum=1" "enum=1" "enum=1" "enum=1" "enum=1" "enum=1" "enum=1" "enum=1" 
"enum=1" "enum=1"
[11] "enum=1" "enum=1" "enum=1" "enum=1" "enum=1" "enum=1" "enum=1" "enum=1" 
"enum=1" "enum=1"
[21] "enum=1" "enum=2" "enum=2" "enum=2" "enum=2" "enum=2" "enum=2" "enum=2" 
"enum=2" "enum=2"
[31] "enum=2" "enum=2" "enum=2" "enum=2" "enum=2" "enum=2" "enum=2" "enum=2" 
"enum=2" "enum=2"
[41] "enum=3" "enum=3" "enum=3" "enum=3" "enum=3" "enum=3" "enum=3" "enum=3" 
"enum=3" "enum=3"
[51] "enum=3" "enum=3" "enum=3" "enum=3" "enum=3" "enum=3" "enum=3" "enum=4" 
"enum=4" "enum=4"
[61] "enum=4" "enum=4" "enum=4" "enum=4" "enum=4" "enum=4" "enum=4" "enum=4"
> substr(as.character(basehazzft.ln$stra), 6, 999)
 [1] "1" "1" "1" "1" "1" "1" "1" "1" "1" "1" "1" "1" "1" "1" "1" "1" "1" "1" 
"1" "1" "1" "2" "2" "2"
[25] "2" "2" "2" "2" "2" "2" "2" "2" "2" "2" "2" "2" "2" "2" "2" "2" "3" "3" 
"3" "3" "3" "3" "3" "3"
[49] "3" "3" "3" "3" "3" "3" "3" "3" "3" "4" "4" "4" "4" "4" "4" "4" "4" "4" 
"4" "4"
> as.numeric(substr(as.character(basehazzft.ln$stra), 6, 999))
 [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 
2 2 2 3 3 3 3 3 3 3 3
[49] 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 4
>

HTH

Steven McKinney
Statistician
Molecular Oncology and Breast Cancer Program
British Columbia Cancer Research Centre



> 
> 
> 
> 
> 
> ___
> ×ñçóéìïðïéåßôå Yahoo!;
> ÂáñåèÞêáôå ôá åíï÷ëçôéêÜ ìçíýìáôá (spam); Ôï Yahoo! Mail
> äéáèÝôåé ôçí êáëýôåñç äõíáôÞ ðñïóôáóßá êáôÜ ôùí åíï÷ëçôéêþí
> ìçíõìÜôùí http://login.yahoo.com/config/mail?.intl=gr
> 
>   [[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] automatically adjusting axis limits

2009-10-27 Thread Greg Snow
If you really want to update the range of the plot axes after plotting, there 
is the zoomplot function in the TeachingDemos package.  You will need to update 
the y-range each time through the loop and pass that to zoomplot.  But, matplot 
is the better overall solution as has been pointed out already.

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


> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
> project.org] On Behalf Of Servet Ahmet Cizmeli
> Sent: Tuesday, October 27, 2009 12:13 PM
> To: r-help@r-project.org
> Subject: [R] automatically adjusting axis limits
> 
> Dear R users,
> 
> I am a newbie. Just switched from MATLAB. So thanks a lot for your
> patience.
> 
> I have 5 spectra collected in field. Each spectra has two columns :
> Wavelength (56) and the actual measurement.
> 
> Each measurement came in a different .txt file on disk (5 files in
> total). I wrote a script that reads every spectra in a for loop and
> constructs two variables :
> 
> Wavelength (56) and Reflectance (56x5). I would like to plot
> Reflectance vs Wavelength i.e. overlay 5 spectra one one top of the
> other.
> 
> plot(Wavelength, Reflectance) does not work (Matlab would do it):
> 
> Error in xy.coords(x, y, xlabel, ylabel, log) :
> 'x' and 'y' lengths differ
> 
> 
> I then tried to construct the two matrices so that they have the same
> size
> (56x5) and plot it all at once with the command "plot". This works
> but
> it is such a computationally inefficient way that I do not want to do
> this
> Why redundantly store wavelength data? Later I will have to process
> much
> more spectra so this is not a good practice for me.
> 
> I then decided to draw the first spectra on the first run of the for
> loop
> with the command "plot" and add the subsequent graphs with the command
> "lines". This works but the y-axes limits do not adjust automatically,
> leaving many spectra out of the axis limits  ;(
> 
> I don't want to set the axis limits by hand as I need this script to be
> completely autonomous. I don't want to program lines of code to
> calculate
> those limits myself either I am sure the mighty R can do it... BUT
> HOW (Matlab would easily do it with a single command)
> 
> What I need is a command that will redraw the graph by automatically
> adjusting the axis limits. I have been searching for many days on the
> web,
> forums and mailing list archives but I still don't know how to do it.
> Please help
> 
> thanks a lot from advance for your kindly help
> Servet
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Porting Custom Packages from Linux to Windows

2009-10-27 Thread David Lubbers
You guys are awesome, thanks!

On Tue, 2009-10-27 at 20:40 -0500, Marc Schwartz wrote:
> On Oct 27, 2009, at 8:32 PM, Duncan Murdoch wrote:
> 
> > Marc Schwartz wrote:
> >> On Oct 27, 2009, at 6:20 PM, David Lubbers wrote:
> >>
> >>
> >>> On my linux workstation I have a nice, very little project in a
> >>> directory called "mystuff"
> >>>
> >>> I installed "mystuff" into site-library with R CMD build, R CMD  
> >>> check
> >>> and R CMD install.  This was all with the file mystuff.tar.gz.
> >>>
> >>> Now I want to install "mystuff" on my windows workstation.  Can I  
> >>> use
> >>> the same file mystuff.tar.gz.  Do I need to do something  
> >>> different  with
> >>> R CMD build?
> >>>
> >>> Ideally somebody has a tutorial for porting from linux to windows  
> >>> this
> >>> way.
> >>>
> >>>
> >>> Thanks for your time.
> >>>
> >>
> >>
> >>
> >> The package source tar file is not directly installable on Windows.
> >
> > That's not true.  You just need to install the tools, and then it's  
> > similar to Linux.  The tools are available from 
> > http://www.murdoch-sutherland.com/Rtools 
> > .
> >
> > Duncan Murdoch
> 
> 
> Right, which I point to below Duncan. I was referring to a typical R  
> install on Windows, where your tools would not normally be available.
> 
> :-)
> 
> Regards,
> 
> Marc
> 
> 
> >> You need to create a .zip 'binary' package file.
> >>
> >> There is a cross-building document here by Rossini and Yan:
> >>
> >>   http://cran.r-project.org/doc/contrib/cross-build.pdf
> >>
> >> and the associated makefile here:
> >>
> >>   http://cran.r-project.org/doc/contrib/Makefile-rcb
> >>
> >>
> >> I have not looked at them in detail relative to their applicability  
> >> to  current versions of R, as they are a rather dated (circa 2003).  
> >> So  caveat emptor.
> >>
> >> If you might consider just directly building the packages on your   
> >> Windows system, Duncan provides an easy Windows installation that   
> >> contains the requisite tools (C and FORTRAN compilers, vanilla  
> >> Perl,  etc.) here:
> >>
> >>   http://www.murdoch-sutherland.com/Rtools/
> >>
> >> along with others that are referenced in the R-Admin Manual  
> >> Windows  Toolset Appendix:
> >>
> >>   http://cran.r-project.org/doc/manuals/R-admin.html#The-Windows-  
> >> toolset
> >>
> >> would enable you to build your package on Windows, including any C  
> >> or  FORTRAN code that you might have in the package.
> >>
> >> 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-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] running aov() and lme() on 64-bit

2009-10-27 Thread Emily Deomano
Good day,
I'm ran aov () and lme() on a split-plot using a 64-bit machine.  For aov() I 
don't see the values for ErrorA, F-value and p-value in the output.  For lme(), 
output is different from results from a 32-bit.  Please see codes used and 
corresponding output.  Is my code wrong and/or not sufficient or is this a 
compatibility issue?


**
model1<-aov(Y~Main*Sub + Error(Block/Main),data=splitplot)
anova(model1)

Output:
Error: Block
  Df Sum Sq Mean Sq F value Pr(>F)
Residuals  1 4.9116  4.9116

Error: Block:Main
  Df  Sum Sq Mean Sq
Main  5 27.4793  5.4959

Error: Within
 Df Sum Sq Mean Sq F value Pr(>F)
Main 5  14.352.87  1.2704 0.2757
Sub   2   3.891.95  0.8620 0.4231
Main:Sub  10  14.771.48  0.6541 0.7669
Residuals 408 921.432.26


*
model1 <- lme(y~Main*Sub, random=~1|Block/Sub,data=splitplot)
anova(model1)
Output:
  numDF denDF   F-value p-value
(Intercept)   1   405 150.84639  <.0001
Main  5   405   3.74269  0.0025
Sub2 6   0.55782  0.5995
Main:Sub   10   405   0.69772  0.7268



Regards,
Emily


Emily Deomano
Biometrician
BSES Limited
Postal Address: PO Box 86
Street Address: 50 Meiers Road
Indooroopilly QLD 4068 Australia
Ph: +61 (0) 7 3331 3306
Mobile:  +61 (0) 408 656 452
Fax: +61 (0) 7 38710383
Email: edeom...@bses.org.aumailto:jstrin...@bses.org.au>
Web: www.bses.org.au


BSES Limited Disclaimer



This email and any files transmitted with it are confide...{{dropped:15}}

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

2009-10-27 Thread Charles Annis, P.E.
R-insiders:

While trying to be clever I inserted these lines in ..\Rprofile.site (which
works in R2.9.2 and earlier)

# to prefer Compiled HTML help
  options(chmhelp=TRUE)

but upon re-starting R2.10.0 I learned that

chmhelp = TRUE is no longer supported: use help_type ="text"

I'm sure this was explained elsewhere but I missed it. Could someone explain
why the compiled html help is no longer supported?

Thanks.

Charles Annis, P.E.

charles.an...@statisticalengineering.com
phone: 561-352-9699
eFax:  614-455-3265
http://www.StatisticalEngineering.com
 
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Ulrike Groemping
Sent: Tuesday, October 27, 2009 4:17 PM
To: r-help@r-project.org
Subject: Re: [R] Cannot activate chm help in R 2.10




Uwe Ligges-3 wrote:
> 
> 
> 
> Duncan Murdoch wrote:
>> On 10/27/2009 10:56 AM, Ulrike Groemping wrote:
>>>
>>>
>>> Duncan Murdoch-2 wrote:

 Ulrike Groemping wrote:
 ...
> My system is Windows XP, German locale computer. On installation, I
> was
> asked to decide for text or html help and chose html (there was no 
> radio
> button for chm help).  
 ...

 If you set

 options(help_type="html")

 you'll get HTML help with links in your default browser.

 Duncan Murdoch


>>>
>>> Thank you very much, this works. But I am very surprised that it is 
>>> not the
>>> default. Having chosen html help during installation, I would have 
>>> expected
>>> this to be active without having to change an option.
>> 
>> Yes, it should have been, but there was a bug in the installer, and the 
>> preference indicated there was ignored. This is why it's useful to have 
>> people doing testing during the beta test period:  things like this are 
>> easy to fix, but they need to be noticed first.
> 
>> Duncan Murdoch
> 
> And let me add:
> 
> The whole statistics department has been on two pre-release versions 
> (beta and release-candidate) and nobody reported any error. The 
> installer problem has not been found because I installed from sources 
> anyway. This shows it makes sense to have more than just 400+ beta 
> testers. ;-)
> 
> Uwe
> 
> 

Two more comments: For those of us who have already installed the version
with this installer bug: If you do not want to change the option each time
you call R, it is easy to change it permanently in the file
R_HOME/etc/Rprofile.site (where R_HOME stands for the directory in which
your R is installed, e.g. c:\programs\r\r-2.10.0).  

Regarding beta testing (yes, I admit, I usually leave that to others, and am
nevertheless looking for beta testers of my package RcmdrPlugin.DoE), maybe
it would be time for an experimental design that specifies characteristics
of beta testers to ensure some diversity there, perhaps package DoE.base or
FrF2 could help there (half-, but only half-jokingly) ;-) 

Regards, Ulrike
-- 
View this message in context:
http://www.nabble.com/Cannot-activate-chm-help-in-R-2.10-tp26067423p26084237
.html
Sent from the R help mailing list archive at Nabble.com.

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

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


Re: [R] PDF Corrupted?

2009-10-27 Thread p_connolly

Quoting rkevinbur...@charter.net:

I am running R 2.9.2 and creating a PDF that I am trying to open with 
Adobe Reader 9.2 but when I try to open it the reader responds with


"There was an error opening this document. The file is damaged and 
cannot be repaired.:


I am using the R command(s):

pdf(file="cat.pdf", title="Historical Sales By Category")
for(j in 1:length(master))
{
d <- as.Date(master[[j]]$Period[1], format="%m/%d/%Y")
fit <- ets(ts(master[[j]]$Quantity, start=c(1900 + 
as.POSIXlt(d)$year, 1 + as.POSIXlt(d)$mon), frequency=12))

plot(fit, col.axis = "sky blue", col.lab = "thistle")
title(master[[j]]$Category,
  cex.main = 2,   font.main= 4, col.main= "blue")
}

Any idea what I am doing wrong?


try dev.off() at the end.  Yous is an FAQ.

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

2009-10-27 Thread Rnewb

i have a series of regressions i need to run where everything is the same
except for the dependent variable, e.g.:

lm(y1 ~ x1+x2+x3+x4+x5, data=data)
lm(y2 ~ x1+x2+x3+x4+x5, data=data)
lm(y3 ~ x1+x2+x3+x4+x5, data=data)

is it possible to run all these regs with a single command?  given that the
bulk of the work for linear regressions is inverting a matrix that depends
only on the independent variables, it seems like a waste to do it over and
over for each new dependent variable.

thanks,
Rnewb
-- 
View this message in context: 
http://www.nabble.com/regression-with-multiple-dependent-variables--tp26088025p26088025.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] "ipredknn" - How may I find values?

2009-10-27 Thread Grzes

I'm sorry David, this is my code once again:

 library(klaR)
 library(ipred)
 library(mlbench)
 data(PimaIndiansDiabetes2)
 dane=na.omit(PimaIndiansDiabetes2)[,c(2,5,9)]
 dane[,2]=log(dane[,2])
 dane[,1:2]=scale(dane[,1:2])
 zbior.uczacy=sample(1:nrow(dane),nrow(dane)/2,F)
 
klasyfikatorKNN=ipredknn(diabetes~glucose+insulin,data=dane,subset=zbior.uczacy,k=3)

oceny=predict(klasyfikatorKNN,dane[-zbior.uczacy,],"class")

df=data.frame(glucose=c(klasyfikatorKNN$learn$X[,1]),insulin=klasyfikatorKNN$learn$X[,2],diabetes=c(klasyfikatorKNN$learn$y))
 df$diabetes=factor(df$diabetes)

drawparti(df$diabetes, df$glucose, df$insulin, method = "sknn", prec = 100,
xlab = NULL, ylab = NULL) 

But in my computer everything is ok. The "drawparti" is in "klaR" package.
Or maybe try like this: 

drawparti(klasyfikatorKNN$learn$y, df$glucose, klasyfikatorKNN$learn$X[,2],
method = "sknn", prec = 100, xlab = NULL, ylab = NULL)

 



David Winsemius wrote:
> 
> 
> On Oct 27, 2009, at 10:18 AM, Grzes wrote:
> 
>>
>> Yes, I want to know which points in my picture are in red or green  
>> area.
>> For example:
>> .glucose..insulin.diabetes
>> 609  0.95177272  1.139969011   - I want to know that it's for
>> example: black point in red area
> 
> red area?
> 
> 
>> 253 -1.05724970 -1.158814331   - it's for example: black  
>> point in
>> green area
> 
> green area?
> 
>> 319 -0.24716002  0.184830541
>> 302  0.69254402  0.132529652
>>
>> If it's impossible plese give me any package or function which can  
>> do it.
> 
> I already asked what was different about your code that was able to do  
> plotting without error on your machine.
> 
> -- 
> David
>>
>>
>> Max Kuhn wrote:
>>>
>>> I think we are having some difficulty understanding what you are
>>> looking for. If you are looking to find which of the training samples
>>> were closest to the prediction sample, I don't think that you can get
>>> it from this function.
>>>
>>> If this is what you want, I use the dist function in the proxy  
>>> package.
>>>
>>> Max
>>>
>>> On Tue, Oct 27, 2009 at 8:46 AM, David Winsemius >> >
>>> wrote:

 On Oct 27, 2009, at 6:02 AM, Grzes wrote:

>
> Hi everybody!
>
> I want to find a closer neighbourins observation. This is my code:
> ##
> library(klaR)
> library(ipred)
> library(mlbench)
> data(PimaIndiansDiabetes2)
> dane=na.omit(PimaIndiansDiabetes2)[,c(2,5,9)]
> dane[,2]=log(dane[,2])
> dane[,1:2]=scale(dane[,1:2])
> zbior.uczacy=sample(1:nrow(dane),nrow(dane)/2,F)
>
>
> klasyfikatorKNN=ipredknn(diabetes~glucose 
> +insulin,data=dane,subset=zbior.uczacy,k=3)
>
> oceny=predict(klasyfikatorKNN,dane[-zbior.uczacy,],"class")
>
> #data frames with my result from klasyfikatorKNN
>
> df=data.frame(glucose=c(klasyfikatorKNN$learn$X[, 
> 1]),insulin=klasyfikatorKNN$learn$X[,2],diabetes=c(klasyfikatorKNN 
> $learn$y))
> #And picture
> drawparti(as.factor(df$diabetes), df$glucose, df$insulin, method =
> "sknn",
> prec = 100, xlab = NULL, ylab = NULL)

 I get an error: Error: could not find function "drawparti"

>
> ##
> My question is:  How or where may I find correct or wrong values  
> which
> were
> drawn (found,classification) in this picture?

 No picture resulted.

> It means I'm looking for  x, y
> values.

 Not sure exactly what you are asking. Does this modification to df  
 and
 fairly obvious the cross table help?

>
> df=data.frame(glucose=c(klasyfikatorKNN$learn$X[, 
> 1]),insulin=klasyfikatorKNN$learn$X[, 
> 2],pred.diabetes=klasyfikatorKNN$learn$y,
> trueDiab=dane[,3])
 Warning message:
 In data.frame(glucose = c(klasyfikatorKNN$learn$X[, 1]), insulin =
 klasyfikatorKNN$learn$X[,  :
  row names were found from a short variable and have been discarded
> with( df, table(pred.diabetes, trueDiab))
 trueDiab
 pred.diabetes neg pos
  neg 174  86
  pos  88  44



>
>
> --
> View this message in context:
> http://www.nabble.com/%22ipredknn%22---How-may-I-find-values--tp26074994p26074994.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

 David Winsemius, MD
 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

[R] cox regression extract strata as numeric

2009-10-27 Thread Λεωνίδας Μπαντής

Hi there,

I perform a stratified cox and then I need the strata as a  numeric array 
"straft.ln"
ft.ln <- 
coxph(Surv(times,deaths)~ages+chemos+chemos:f1+chemos:f2+horms+horms:f1+horms:f2+grades+grades:f1+grades:f2+positives+positives:f1+positives:f2+sizes+sizes:f1+sizes:f2+strata(stra),data=ddd)

basehazzft.ln=basehaz(ft.ln,centered=FALSE)
H0ft.ln=c(basehazzft.ln[,1])
timeft.ln=c(basehazzft.ln[,2])
straft.ln=c(basehazzft.ln[,3])

I notice that basehazzft.ln[,3] is not the same with straft.ln with respect to 
the values i.e.:

(basehazzft.ln$stra[1])
[1] stra=1
134 Levels: stra=1 stra=10 stra=100 stra=101 stra=102 ... stra=99
> c(basehazzft.ln$stra[1])
[1] 1


so far so good but:

(basehazzft.ln$stra[285])
[1] stra=2
134 Levels: stra=1 stra=10 stra=100 stra=101 stra=102 ... stra=99
> c(basehazzft.ln$stra[285])
[1] 47

while the desired value is 2, I get a 47. What am I doing wrong? I tried the 
as.numeric function but I have the same problem..

I just want instead of the [ "stra=1" "stra=1" "stra=1" etc]  the [1,1,1 etc]

Thanx in advance for any answers!




  
___ 
×ñçóéìïðïéåßôå Yahoo!; 
ÂáñåèÞêáôå ôá åíï÷ëçôéêÜ ìçíýìáôá (spam); Ôï Yahoo! Mail 
äéáèÝôåé ôçí êáëýôåñç äõíáôÞ ðñïóôáóßá êáôÜ ôùí åíï÷ëçôéêþí 
ìçíõìÜôùí http://login.yahoo.com/config/mail?.intl=gr

[[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] re gression with multiple dependent variables?

2009-10-27 Thread Ben Bolker



Rnewb wrote:
> 
> i have a series of regressions i need to run where everything is the same
> except for the dependent variable, e.g.:
> 
> lm(y1 ~ x1+x2+x3+x4+x5, data=data)
> lm(y2 ~ x1+x2+x3+x4+x5, data=data)
> lm(y3 ~ x1+x2+x3+x4+x5, data=data)
> 
> is it possible to run all these regs with a single command?  given that
> the bulk of the work for linear regressions is inverting a matrix that
> depends only on the independent variables, it seems like a waste to do it
> over and over for each new dependent variable.
> 
> thanks,
> Rnewb
> 

It's right there in TFM ... (?lm)

 If 'response' is a matrix a linear model is fitted separately by
 least-squares to each column of the matrix.

Y <- cbind(y1,y2,y3)

lm(Y~...)


-- 
View this message in context: 
http://www.nabble.com/regression-with-multiple-dependent-variables--tp26088025p26088139.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] Porting Custom Packages from Linux to Windows

2009-10-27 Thread Marc Schwartz


On Oct 27, 2009, at 8:32 PM, Duncan Murdoch wrote:


Marc Schwartz wrote:

On Oct 27, 2009, at 6:20 PM, David Lubbers wrote:



On my linux workstation I have a nice, very little project in a
directory called "mystuff"

I installed "mystuff" into site-library with R CMD build, R CMD  
check

and R CMD install.  This was all with the file mystuff.tar.gz.

Now I want to install "mystuff" on my windows workstation.  Can I  
use
the same file mystuff.tar.gz.  Do I need to do something  
different  with

R CMD build?

Ideally somebody has a tutorial for porting from linux to windows  
this

way.


Thanks for your time.





The package source tar file is not directly installable on Windows.


That's not true.  You just need to install the tools, and then it's  
similar to Linux.  The tools are available from http://www.murdoch-sutherland.com/Rtools 
.


Duncan Murdoch



Right, which I point to below Duncan. I was referring to a typical R  
install on Windows, where your tools would not normally be available.


:-)

Regards,

Marc



You need to create a .zip 'binary' package file.

There is a cross-building document here by Rossini and Yan:

  http://cran.r-project.org/doc/contrib/cross-build.pdf

and the associated makefile here:

  http://cran.r-project.org/doc/contrib/Makefile-rcb


I have not looked at them in detail relative to their applicability  
to  current versions of R, as they are a rather dated (circa 2003).  
So  caveat emptor.


If you might consider just directly building the packages on your   
Windows system, Duncan provides an easy Windows installation that   
contains the requisite tools (C and FORTRAN compilers, vanilla  
Perl,  etc.) here:


  http://www.murdoch-sutherland.com/Rtools/

along with others that are referenced in the R-Admin Manual  
Windows  Toolset Appendix:


  http://cran.r-project.org/doc/manuals/R-admin.html#The-Windows-  
toolset


would enable you to build your package on Windows, including any C  
or  FORTRAN code that you might have in the package.


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-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Porting Custom Packages from Linux to Windows

2009-10-27 Thread Duncan Murdoch

Marc Schwartz wrote:

On Oct 27, 2009, at 6:20 PM, David Lubbers wrote:

  

On my linux workstation I have a nice, very little project in a
directory called "mystuff"

I installed "mystuff" into site-library with R CMD build, R CMD check
and R CMD install.  This was all with the file mystuff.tar.gz.

Now I want to install "mystuff" on my windows workstation.  Can I use
the same file mystuff.tar.gz.  Do I need to do something different  
with

R CMD build?

Ideally somebody has a tutorial for porting from linux to windows this
way.


Thanks for your time.





The package source tar file is not directly installable on Windows.  
  


That's not true.  You just need to install the tools, and then it's 
similar to Linux.  The tools are available from 
http://www.murdoch-sutherland.com/Rtools.


Duncan Murdoch


You need to create a .zip 'binary' package file.

There is a cross-building document here by Rossini and Yan:

   http://cran.r-project.org/doc/contrib/cross-build.pdf

and the associated makefile here:

   http://cran.r-project.org/doc/contrib/Makefile-rcb


I have not looked at them in detail relative to their applicability to  
current versions of R, as they are a rather dated (circa 2003). So  
caveat emptor.


If you might consider just directly building the packages on your  
Windows system, Duncan provides an easy Windows installation that  
contains the requisite tools (C and FORTRAN compilers, vanilla Perl,  
etc.) here:


   http://www.murdoch-sutherland.com/Rtools/

along with others that are referenced in the R-Admin Manual Windows  
Toolset Appendix:


   http://cran.r-project.org/doc/manuals/R-admin.html#The-Windows- 
toolset


would enable you to build your package on Windows, including any C or  
FORTRAN code that you might have in the package.


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-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] New variables "remember" how they were created?

2009-10-27 Thread Skipper Seabold
Hello all,

I hope this question is appropriate for this ML.

Basically, I am wondering if when you create a new variable, if the
variable holds some information about how it was created.

Let me explain, I have the following code to replicate an example in a
textbook (Greene's Econometric Analysis), using the systemfit package.

dta <- 
read.table('http://pages.stern.nyu.edu/~wgreene/Text/Edition6/TableF5-1.txt',
header = TRUE)
attach(dta)
library(systemfit)
demand <- realcons + realinvs + realgovt
c.1 <- realcons[-204]
y.1 <- demand[-204]
yd <- demand[-1] - y.1
eqConsump <- realcons[-1] ~ demand[-1] + c.1
eqInvest <- realinvs[-1] ~ tbilrate[-1] + yd
system <- list( Consumption = eqConsump, Investment = eqInvest)
instruments <- ~ realgovt[-1] + tbilrate[-1] + c.1 + y.1
# 2SLS
greene2sls <- systemfit( system, "2SLS", inst = instruments,
methodResidCov = "noDfCor" )

When I do the 2SLS fit, it seems that even though I declared y.1 as an
instrument that the estimator "knows" that yd was created using y1, so
it (correctly) transforms yd to use the instrument in the final
estimation.

So I'm wondering if yd somehow carries knowledge of how it was created.

Thanks,

Skipper

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 do I plot a regression curve with the data?

2009-10-27 Thread andrew
Hi Ken,

Perhaps something like

plot(x,y)
lines(sort(x), fit$fitted.values[order(x)])

should do what I think you want.  I think you have to be a bit careful
on the ordering of the fitted values so that they match up with the
order of the x variable, otherwise you get an odd looking line plot.

Regards,

Andrew

On Oct 28, 5:42 am, Ken Ervin  wrote:
> I have a data set of 6 or so ordered pairs, and I've been able to graph
> them and have decided to use a high-order polynomial regression.  I've
> used the following piece of code:
>
> regression <- function(x,y) {
>     x <- c(insert_numbers_here)
>     y <- c(insert_other_numbers_here)
>     fit <- lm(y ~ x + I(x^2) + I(x^3) + I(x^4) + I(x^5) + I(x^6) +
> I(x^7) + I(x^8) + I(x^9))
>     summary(fit)
>
> This gives me the coefficients for the regression very nicely, but I
> would like to plot both the data and the regression curve together.  How
> do I plot that regression curve as a function, and can I put it on the
> same set of axes as my data scatter plot?
>
> Thanks in advance for your help!
>
> -KE
>
> __
> r-h...@r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guidehttp://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] PDF Corrupted?

2009-10-27 Thread Simon Blomberg
Try doing dev.off() after you finish the plot. That will close the
device and should make it available for viewing.

Cheers,

Simon.

On Tue, 2009-10-27 at 17:42 -0700, rkevinbur...@charter.net wrote:
> I am running R 2.9.2 and creating a PDF that I am trying to open with Adobe 
> Reader 9.2 but when I try to open it the reader responds with 
> 
> "There was an error opening this document. The file is damaged and cannot be 
> repaired.:
> 
> I am using the R command(s):
> 
> pdf(file="cat.pdf", title="Historical Sales By Category")
> for(j in 1:length(master))
> {
> d <- as.Date(master[[j]]$Period[1], format="%m/%d/%Y")
> fit <- ets(ts(master[[j]]$Quantity, start=c(1900 + as.POSIXlt(d)$year, 1 
> + as.POSIXlt(d)$mon), frequency=12))
> plot(fit, col.axis = "sky blue", col.lab = "thistle")
> title(master[[j]]$Category,
>   cex.main = 2,   font.main= 4, col.main= "blue")
> }
> 
> Any idea what I am doing wrong?
> 
> Thank you.
> 
> Kevin
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.


-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
School of Biological Sciences
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506
http://www.uq.edu.au/~uqsblomb
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

Statistics is the grammar of science - Karl Pearson

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

2009-10-27 Thread Jorge Ivan Velez
Hi Kevin,

Close the device once the plot is completed:

pdf(...)
plots go here
dev.off()

HTH,
Jorge

On Tue, Oct 27, 2009 at 8:42 PM, <> wrote:

> I am running R 2.9.2 and creating a PDF that I am trying to open with Adobe
> Reader 9.2 but when I try to open it the reader responds with
>
> "There was an error opening this document. The file is damaged and cannot
> be repaired.:
>
> I am using the R command(s):
>
> pdf(file="cat.pdf", title="Historical Sales By Category")
> for(j in 1:length(master))
> {
>d <- as.Date(master[[j]]$Period[1], format="%m/%d/%Y")
>fit <- ets(ts(master[[j]]$Quantity, start=c(1900 + as.POSIXlt(d)$year, 1
> + as.POSIXlt(d)$mon), frequency=12))
>plot(fit, col.axis = "sky blue", col.lab = "thistle")
>title(master[[j]]$Category,
>  cex.main = 2,   font.main= 4, col.main= "blue")
> }
>
> Any idea what I am doing wrong?
>
> Thank you.
>
> Kevin
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] PDF Corrupted?

2009-10-27 Thread Bryan Hanson
Looks like you need to do dev.off() after the plot to properly close the
file.

Bryan
*
Bryan Hanson
Acting Chair
Professor of Chemistry & Biochemistry
DePauw University, Greencastle IN USA



On 10/27/09 8:42 PM, "rkevinbur...@charter.net" 
wrote:

> I am running R 2.9.2 and creating a PDF that I am trying to open with Adobe
> Reader 9.2 but when I try to open it the reader responds with
> 
> "There was an error opening this document. The file is damaged and cannot be
> repaired.:
> 
> I am using the R command(s):
> 
> pdf(file="cat.pdf", title="Historical Sales By Category")
> for(j in 1:length(master))
> {
> d <- as.Date(master[[j]]$Period[1], format="%m/%d/%Y")
> fit <- ets(ts(master[[j]]$Quantity, start=c(1900 + as.POSIXlt(d)$year, 1 +
> as.POSIXlt(d)$mon), frequency=12))
> plot(fit, col.axis = "sky blue", col.lab = "thistle")
> title(master[[j]]$Category,
>   cex.main = 2,   font.main= 4, col.main= "blue")
> }
> 
> Any idea what I am doing wrong?
> 
> Thank you.
> 
> Kevin
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] PDF Corrupted?

2009-10-27 Thread Marc Schwartz


On Oct 27, 2009, at 7:42 PM, rkevinbur...@charter.net wrote:

I am running R 2.9.2 and creating a PDF that I am trying to open  
with Adobe Reader 9.2 but when I try to open it the reader responds  
with


"There was an error opening this document. The file is damaged and  
cannot be repaired.:


I am using the R command(s):

pdf(file="cat.pdf", title="Historical Sales By Category")
for(j in 1:length(master))
{
   d <- as.Date(master[[j]]$Period[1], format="%m/%d/%Y")
   fit <- ets(ts(master[[j]]$Quantity, start=c(1900 + as.POSIXlt(d) 
$year, 1 + as.POSIXlt(d)$mon), frequency=12))

   plot(fit, col.axis = "sky blue", col.lab = "thistle")
   title(master[[j]]$Category,
 cex.main = 2,   font.main= 4, col.main= "blue")
}

Any idea what I am doing wrong?

Thank you.

Kevin




You are not closing the PDF file with dev.off() when you are done  
plotting...


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] [BioC] Is there a package similar to mogene10stprobeset.db by for Affymetrix Exon Arrays?

2009-10-27 Thread Peng Yu
mogene10stprobeset.db is generated with AnnotationDbi for mouse gene
array. I don't find a package that seems generated by AnnotationDbi
for exon arrays on the webpage you mentioned. Is it correct?

On Tue, Oct 27, 2009 at 7:00 PM, Marc Carlson  wrote:
> Hi Peng,
>
> I am not completely clear from your post what you want.  But most of our
> annotation packages can be found here:
>
> http://www.bioconductor.org/packages/devel/data/annotation/
>
> If you don't find what you want, and you have gene accessions mapped
> onto probes (something that should still be possible for an
> exon-oriented platform), then you can use SQLForge in AnnotationDbi to
> generate an annotation package.  To do so see the SQLForge vignette
> which can be found in the AnnotationDbi package right here:
>
> http://www.bioconductor.org/packages/devel/bioc/html/AnnotationDbi.html
>
>
>  Marc
>
>
>
>
> Peng Yu wrote:
>> There are gene level annotation for Gene Array mogene10stprobeset.db.
>> I'm wondering if there are any package available for Exon Arrays?
>>
>> ___
>> Bioconductor mailing list
>> bioconduc...@stat.math.ethz.ch
>> https://stat.ethz.ch/mailman/listinfo/bioconductor
>> Search the archives: 
>> http://news.gmane.org/gmane.science.biology.informatics.conductor
>>
>>
>
>

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

2009-10-27 Thread rkevinburton
I am running R 2.9.2 and creating a PDF that I am trying to open with Adobe 
Reader 9.2 but when I try to open it the reader responds with 

"There was an error opening this document. The file is damaged and cannot be 
repaired.:

I am using the R command(s):

pdf(file="cat.pdf", title="Historical Sales By Category")
for(j in 1:length(master))
{
d <- as.Date(master[[j]]$Period[1], format="%m/%d/%Y")
fit <- ets(ts(master[[j]]$Quantity, start=c(1900 + as.POSIXlt(d)$year, 1 + 
as.POSIXlt(d)$mon), frequency=12))
plot(fit, col.axis = "sky blue", col.lab = "thistle")
title(master[[j]]$Category,
  cex.main = 2,   font.main= 4, col.main= "blue")
}

Any idea what I am doing wrong?

Thank you.

Kevin

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Porting Custom Packages from Linux to Windows

2009-10-27 Thread Rolf Turner


On 28/10/2009, at 12:20 PM, David Lubbers wrote:


On my linux workstation I have a nice, very little project in a
directory called "mystuff"

I installed "mystuff" into site-library with R CMD build, R CMD check
and R CMD install.  This was all with the file mystuff.tar.gz.

Now I want to install "mystuff" on my windows workstation.  Can I use
the same file mystuff.tar.gz.  Do I need to do something different  
with

R CMD build?

Ideally somebody has a tutorial for porting from linux to windows this
way.


If the package ``mystuff'' does not involve compiling any Fortran or C
code then it's simple:

Go to the directory, i.e. library, where ``mystuff'' is installed.
(NB:  You want the *installed* version, not the source version.)
Executed

zip -r mystuff.zip mystuff

Transport mystuff.zip to the Windoze machine.  Then do the usual
clickety-click thing to ``install from local zip files''  (I forget
the actual wording.) And there you go.

If there is C or Fortran code to be dynamically loaded then this code
must be compiled under Windoze.  This is possible, but tricky and
you need to make sure that all sorts of non-standard tools are
installed on your Windoze machine.  Duncan Murdoch has produced
a set of instructions for getting through the maze, but I forget
where.  Doing an RSiteSearch() will probably turn it up for you.

Alternatively you can use the facility:

http://win-builder.r-project.org

which is provided by Uwe Ligges, bless his heart.  Remember this
is necessary only if ``mystuff'' depends on C or Fortran code.

cheers,

Rolf Turner

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

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


Re: [R] Porting Custom Packages from Linux to Windows

2009-10-27 Thread Marc Schwartz

On Oct 27, 2009, at 6:20 PM, David Lubbers wrote:


On my linux workstation I have a nice, very little project in a
directory called "mystuff"

I installed "mystuff" into site-library with R CMD build, R CMD check
and R CMD install.  This was all with the file mystuff.tar.gz.

Now I want to install "mystuff" on my windows workstation.  Can I use
the same file mystuff.tar.gz.  Do I need to do something different  
with

R CMD build?

Ideally somebody has a tutorial for porting from linux to windows this
way.


Thanks for your time.




The package source tar file is not directly installable on Windows.  
You need to create a .zip 'binary' package file.


There is a cross-building document here by Rossini and Yan:

  http://cran.r-project.org/doc/contrib/cross-build.pdf

and the associated makefile here:

  http://cran.r-project.org/doc/contrib/Makefile-rcb


I have not looked at them in detail relative to their applicability to  
current versions of R, as they are a rather dated (circa 2003). So  
caveat emptor.


If you might consider just directly building the packages on your  
Windows system, Duncan provides an easy Windows installation that  
contains the requisite tools (C and FORTRAN compilers, vanilla Perl,  
etc.) here:


  http://www.murdoch-sutherland.com/Rtools/

along with others that are referenced in the R-Admin Manual Windows  
Toolset Appendix:


  http://cran.r-project.org/doc/manuals/R-admin.html#The-Windows- 
toolset


would enable you to build your package on Windows, including any C or  
FORTRAN code that you might have in the package.


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] Aggregate and cross tabulation

2009-10-27 Thread Jonathan Greenberg

R-helpers:

   I have a data frame containing 4 factor variables (let's say A,B,C, 
and D) and 1 numerical variable (N).  I would like to produce a 
cross-tabulated data frame in which A,B,C are individual columns, each 
factor of D is its own column, and the field is calculated as a given 
function of N (I would like to have two output data frames, one with the 
mean(N) and one with the sum(N), e.g.:


A,B,C,D1,D2,
   ...,DM
A1   B1   C1   mean(N{A1,B1,C1,D1)})   mean(N{A1,B1,C1,D2)})
   mean(N{A1,B1,C1,DM)})
A2   B1   C1   mean(N{A2,B1,C1,D1)})   mean(N{A2,B1,C1,D2)})
   mean(N{A2,B1,C1,DM)})

etc...

I can mostly do this with aggregate, e.g.
output = aggregate(N,list(A,B,C,D),mean), but I can't get that last step 
of cross-tabulating the Ds to column headers.  table() and xtabs() 
appear to just count, rather than giving me access to sum() and mean().  
Any ideas?  Ideally I'd like to do this in a single step, as the 
aggregate output (above) produces a much larger data frame than a 
cross-tabulated output would (in my particular case).


--j

--

Jonathan A. Greenberg, PhD
Postdoctoral Scholar
Center for Spatial Technologies and Remote Sensing (CSTARS)
University of California, Davis
One Shields Avenue
The Barn, Room 250N
Davis, CA 95616
Phone: 415-763-5476
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 - Probability scale on an ECDF plot

2009-10-27 Thread Jessica Goin
Hello;

Can anyone tell me how to set my y-axis to a probability scale on an ECDF
plot?  Or alternatively, how to generate a plot of percent cumulative
probability against concentration?  DASplusR does this and calls it a CP
plot, but I would like to be able to generate this outside of DASplusR-

Thank you!

[[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] Antropometrics with R

2009-10-27 Thread David Winsemius


On Oct 27, 2009, at 7:27 PM, Orvalho Augusto wrote:


Hey greate ones, is there any way to have something similar to stata
zanthro on R?


I suppose it is possible that someone will know what is in that stata  
package, but it would make more sense if you were to summarize what  
features would be of use.




I want a package that contains functions to give antropometric values,
at least for the children.


You are perhaps trying to map ht, weight, and head circumference to  
age-specific percentiles???


http://www.cdc.gov/growthcharts/percentile_data_files.htm

--

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] Porting Custom Packages from Linux to Windows

2009-10-27 Thread David Lubbers
On my linux workstation I have a nice, very little project in a
directory called "mystuff"

I installed "mystuff" into site-library with R CMD build, R CMD check
and R CMD install.  This was all with the file mystuff.tar.gz.

Now I want to install "mystuff" on my windows workstation.  Can I use
the same file mystuff.tar.gz.  Do I need to do something different with
R CMD build?

Ideally somebody has a tutorial for porting from linux to windows this
way.


Thanks for your time.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] option to control the spac between columns in data frame

2009-10-27 Thread David Winsemius


On Oct 27, 2009, at 3:51 PM, Subodh Acharya wrote:


Hello,
I have a question regarding a way to control the appreance of output
exported by R
when I use capture.output( x, file = "Directory/file.txt") , I get a  
text
file which when I paste to a word file looks like the first table  
below.


The following table has its clumns spaced closely so when I paste it  
to a
word file it looks continuous. Is there any option in R to make the  
outputs

like the second table?


> ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14)
> trt <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69)
> group <- gl(2,10,20, labels=c("Ctl","Trt"))
> weight <- c(ctl, trt)
> print(anova(lm.D9 <- lm(weight ~ group)) )
Analysis of Variance Table

Response: weight
  Df Sum Sq Mean Sq F value Pr(>F)
group  1 0.6882  0.6882  1.4191  0.249
Residuals 18 8.7292  0.4850

> print(anova(lm.D9 <- lm(weight ~ group)), print.gap=6)
Analysis of Variance Table

Response: weight
   Df  Sum Sq  Mean Sq  F value  Pr(>F)
group   1  0.6882   0.6882   1.4191   0.249
Residuals  18  8.7292   0.4850



Any help will be highly appreciated.


Thank you very much in advance.


Model 1
4/70-3/80 Year 2

  Source Area Runoff Nitrogen Phosphorus
V1 LDR_imperv  203   52.6   1496.0  190.0
V2   LDR_perv   11475.7489.6  163.6
V3 MDR_imperv  281  52.6   4141.7  654.7
V4   MDR_Perv  6545.7511.8  227.4
V5 IND_imperv   97   52.6   1604.4  226.0
V6   IND_perv   425.7  17.9   7.1
V7 COM_imperv  158   52.6   2613.4  368.1
V8   COM_perv  1575.7 67.0   26.6
Total 10942  1302.2

 Source Area Runoff Nitrogen Phosphorus
V1 LDR_imperv   20352.6   1496.0
190.0
V2   LDR_perv1147   5.7 489.6
163.6
V3 MDR_imperv 281 52.64141.7
654.7
V4   MDR_Perv  654 5.7  511.8
227.4
V5 IND_imperv   97  52.6 1604.4
226.0

--
Acharya, Subodh

[[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] column names of a correlation matrix

2009-10-27 Thread David Winsemius


On Oct 27, 2009, at 10:54 AM, Lee William wrote:


Hi! All,
I am working on a correlation matrix of 4217x4217 named 'cor_expN'.  
I wish

to obtain pairs with highest correlation values. So, I did this

b=matrix(data=NA,nrow=4217,ncol=1)
rownames(b)=rownames(cor_expN)
for(i in 1:4217){b[i,]=max(cor_expN[i,])}
head(b)

  [,1]
aaeA_b3241_14 0.7181912
aaeB_b3240_15 0.7513084
aaeR_b3243_15 0.7681684
aaeX_b3242_12 0.5230587
aas_b2836_14   0.6615927
aat_b0885_140.6344144

Now I want the corresponding columns for the above values. For that  
I tried

this

c=matrix(data=NA,nrow=4217,ncol=1)
for(i in 1:4217){b[i,]=colnames(max(cor_expN[i,]))}


And got the following error:
Error in b[i, ] = colnames(max(cor_expN[i, ])) : number of items to  
replace

is not a multiple of replacement length
Any thoughts?


Make a smaller toy example?

--
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] "ipredknn" - How may I find values?

2009-10-27 Thread David Winsemius


On Oct 27, 2009, at 10:18 AM, Grzes wrote:



Yes, I want to know which points in my picture are in red or green  
area.

For example:
.glucose..insulin.diabetes
609  0.95177272  1.139969011   - I want to know that it's for
example: black point in red area


red area?


253 -1.05724970 -1.158814331   - it's for example: black  
point in

green area


green area?


319 -0.24716002  0.184830541
302  0.69254402  0.132529652

If it's impossible plese give me any package or function which can  
do it.


I already asked what was different about your code that was able to do  
plotting without error on your machine.


--
David



Max Kuhn wrote:


I think we are having some difficulty understanding what you are
looking for. If you are looking to find which of the training samples
were closest to the prediction sample, I don't think that you can get
it from this function.

If this is what you want, I use the dist function in the proxy  
package.


Max

On Tue, Oct 27, 2009 at 8:46 AM, David Winsemius >

wrote:


On Oct 27, 2009, at 6:02 AM, Grzes wrote:



Hi everybody!

I want to find a closer neighbourins observation. This is my code:
##
library(klaR)
library(ipred)
library(mlbench)
data(PimaIndiansDiabetes2)
dane=na.omit(PimaIndiansDiabetes2)[,c(2,5,9)]
dane[,2]=log(dane[,2])
dane[,1:2]=scale(dane[,1:2])
zbior.uczacy=sample(1:nrow(dane),nrow(dane)/2,F)


klasyfikatorKNN=ipredknn(diabetes~glucose 
+insulin,data=dane,subset=zbior.uczacy,k=3)


oceny=predict(klasyfikatorKNN,dane[-zbior.uczacy,],"class")

#data frames with my result from klasyfikatorKNN

df=data.frame(glucose=c(klasyfikatorKNN$learn$X[, 
1]),insulin=klasyfikatorKNN$learn$X[,2],diabetes=c(klasyfikatorKNN 
$learn$y))

#And picture
drawparti(as.factor(df$diabetes), df$glucose, df$insulin, method =
"sknn",
prec = 100, xlab = NULL, ylab = NULL)


I get an error: Error: could not find function "drawparti"



##
My question is:  How or where may I find correct or wrong values  
which

were
drawn (found,classification) in this picture?


No picture resulted.


It means I'm looking for  x, y
values.


Not sure exactly what you are asking. Does this modification to df  
and

fairly obvious the cross table help?



df=data.frame(glucose=c(klasyfikatorKNN$learn$X[, 
1]),insulin=klasyfikatorKNN$learn$X[, 
2],pred.diabetes=klasyfikatorKNN$learn$y,

trueDiab=dane[,3])

Warning message:
In data.frame(glucose = c(klasyfikatorKNN$learn$X[, 1]), insulin =
klasyfikatorKNN$learn$X[,  :
 row names were found from a short variable and have been discarded

with( df, table(pred.diabetes, trueDiab))

trueDiab
pred.diabetes neg pos
 neg 174  86
 pos  88  44






--
View this message in context:
http://www.nabble.com/%22ipredknn%22---How-may-I-find-values--tp26074994p26074994.html
Sent from the R help mailing list archive at Nabble.com.

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


David Winsemius, MD
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.





--

Max

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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/%22ipredknn%22---How-may-I-find-values--tp26074994p26078505.html
Sent from the R help mailing list archive at Nabble.com.

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


David Winsemius, MD
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] Antropometrics with R

2009-10-27 Thread Orvalho Augusto
Hey greate ones, is there any way to have something similar to stata
zanthro on R?

I want a package that contains functions to give antropometric values,
at least for the children.

Caveman

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

2009-10-27 Thread Henrique Dallazuanna
Try unname also.



On Tue, Oct 27, 2009 at 8:09 PM, Peng Yu  wrote:
> I only see how to assign values to colnames() in help. Is there a way
> to remove colnames?
>
> colnames(x) <- value
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



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

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


[R] Rjava, RImageJ, and/or S4 question.

2009-10-27 Thread Robert Baer
I am out of my league with this question.   The following code starts the java 
imaging program ImageJ from within R, and displays an image (assuming ImageJ is 
installed on your computer).

library(RImageJ)
img  <-  IJ$openImage( file.choose() )   #pick an available .tif file
img$show()#  make the image object visible 
# An image is now displayed

# find out about the objects involved
> str(IJ)
Formal class 'jobjRef' [package "rJava"] with 2 slots
  ..@ jobj  : 
  ..@ jclass: chr "ij/IJ"

> str(img)
Formal class 'jobjRef' [package "rJava"] with 2 slots
  ..@ jobj  : 
  ..@ jclass: chr "java/lang/Object"
 
# now use an IJ java method to find out existing screen size
IJ$getScreenSize()
[1] "Java-Object{java.awt.Dimension[width=1680,height=1050]}"

> str(IJ$getScreenSize())
Formal class 'jobjRef' [package "rJava"] with 2 slots
  ..@ jobj  : 
  ..@ jclass: chr "java/lang/Object"

I am gathering that the RJava library (which is required by the RImageJ 
library) is using 'slots' which are related to S4  My question is whether 
there is any way to extract the width and height information from the 
IJ$getScreenSize() command which has the vague appearance of being a string 
vector or list but is obviously something far more complex like a java str 
object?

Question 2.  Is there recommended reading on how one coerces objects back and 
forth in this type of situation.  For example the ImageJ documentation for the 
IJ class shows the following for the makeOval method:
static void makeOval(int x, int y, int width, int height)

Creates an elliptical selection.

Here is what happens in R:

> IJ$makeOval(694, 265, 274, 129);
Error in .jrcall(x, name, ...) : 
  Cannot find Java method `makeOval' matching the supplied parameters.


Can anyone point me in the direction of much-needed self-education :-)

Thanks for any insight.

Rob



-
Robert W. Baer, Ph.D.
Professor of Physiology
Kirksville College of Osteopathic Medicne
A. T. Still University of Health Sciences
800 W. Jefferson St.
Kirksville, MO 63501
[[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 express a tree?

2009-10-27 Thread Duncan Temple Lang


Jim Lemon wrote:
> On 10/28/2009 04:06 AM, Hesen Peng wrote:
>> Hello everybody,
>>
>> I'm write a function whose output represents a tree. Can anyone please
>> recommend me some data structure in R which are good for expressing a
>> tree? The possible idea I'm having in my mind is to represent the
>> whole tree as a list in which a sublist (an element to the main list)
>> contains all its corresponding branches. Is there any simpler way of
>> doing this? Thank you very much.
>>
> Hi Hesen,
> This is the approach used in the listBuilder function in the crank
> package. It may be of use to you.

Lists of lists is very natural. It is "hard" to find
the parent and ancestors give a particular sub-tree,
i.e. walk up the tree, should that be an issue.

The XML package also provides various implementations of trees
in R (as well as in C) using

   list of lists
   environments
   parallel vectors of
  nodes, parent indices, child indices.

It might be worth a look to see alternatives.

 D.

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

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

2009-10-27 Thread Jim Lemon

On 10/28/2009 04:06 AM, Hesen Peng wrote:

Hello everybody,

I'm write a function whose output represents a tree. Can anyone please
recommend me some data structure in R which are good for expressing a
tree? The possible idea I'm having in my mind is to represent the
whole tree as a list in which a sublist (an element to the main list)
contains all its corresponding branches. Is there any simpler way of
doing this? Thank you very much.
   

Hi Hesen,
This is the approach used in the listBuilder function in the crank 
package. It may be of use to you.


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] Why I get this error? Error in close.connection(f) : invalid connection

2009-10-27 Thread baptiste auguie
Hi,

>From ?read.csv

"Alternatively, file can be a readable text-mode connection (which
will be opened for reading if necessary, and if so closed (and hence
destroyed) at the end of the function call)"

HTH,

baptiste



2009/10/27 Peng Yu :
> I don't understand why I can not close 'f'. This may be very simple,
> but I don't see why. Could somebody let me know?
>
> $ cat gzfile.csv
> "","V1","V2","V3","V4","V5"
> "1",1,5,9,13,17
> "2",2,6,10,14,18
> "3",3,7,11,15,19
> "4",4,8,12,16,20
> $ Rscript gzfile.R
>> f = file("gzfile.csv")
>> A = read.csv(f)
>> A
>  X V1 V2 V3 V4 V5
> 1 1  1  5  9 13 17
> 2 2  2  6 10 14 18
> 3 3  3  7 11 15 19
> 4 4  4  8 12 16 20
>> close(f)
> Error in close.connection(f) : invalid connection
> Calls: close -> close.connection
> Execution halted
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Why I get this error? Error in close.connection(f) : invalidconnection

2009-10-27 Thread William Dunlap
> -Original Message-
> From: r-help-boun...@r-project.org 
> [mailto:r-help-boun...@r-project.org] On Behalf Of Peng Yu
> Sent: Tuesday, October 27, 2009 3:22 PM
> To: r-h...@stat.math.ethz.ch
> Subject: [R] Why I get this error? Error in 
> close.connection(f) : invalidconnection
> 
> I don't understand why I can not close 'f'. This may be very simple,
> but I don't see why. Could somebody let me know?

The short answer is that f is not an open connection.
Use f <- file(..., open="r") if you want to open it
(and then read.csv should not close it).

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com 
> 
> $ cat gzfile.csv
> "","V1","V2","V3","V4","V5"
> "1",1,5,9,13,17
> "2",2,6,10,14,18
> "3",3,7,11,15,19
> "4",4,8,12,16,20
> $ Rscript gzfile.R
> > f = file("gzfile.csv")
> > A = read.csv(f)
> > A
>   X V1 V2 V3 V4 V5
> 1 1  1  5  9 13 17
> 2 2  2  6 10 14 18
> 3 3  3  7 11 15 19
> 4 4  4  8 12 16 20
> > close(f)
> Error in close.connection(f) : invalid connection
> Calls: close -> close.connection
> Execution halted
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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 clear colnames?

2009-10-27 Thread Daniel Malter
x=rnorm(100)
y=rnorm(100)
mydata=data.frame(x,y)
names(mydata)=("I.am.x","I.am.y")
head(mydata)
names(mydata)=c(NULL,NULL)
head(mydata)
names(mydata)

They technically don't exist if you null them.

Daniel

-
cuncta stricte discussurus
-

-Ursprüngliche Nachricht-
Von: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Im
Auftrag von Benilton Carvalho
Gesendet: Tuesday, October 27, 2009 6:21 PM
An: Peng Yu
Cc: r-h...@stat.math.ethz.ch
Betreff: Re: [R] How to clear colnames?

colnames(x) <- NULL

On Oct 27, 2009, at 8:09 PM, Peng Yu wrote:

> I only see how to assign values to colnames() in help. Is there a way 
> to remove colnames?
>
> colnames(x) <- value
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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

2009-10-27 Thread Peng Yu
'all_annotation' is a data.frame. Somehow, rownames can not be clear.
Why is it like that?

> rownames(all_annotation)<-NULL
> rownames(all_annotation)
 [1] "1"  "2"  "3"  "4"  "5"  "6"  "7"  "8"  "9"  "10"
> class(all_annotation)
[1] "data.frame"


On Tue, Oct 27, 2009 at 5:20 PM, Benilton Carvalho  wrote:
> colnames(x) <- NULL
>
> On Oct 27, 2009, at 8:09 PM, Peng Yu wrote:
>
>> I only see how to assign values to colnames() in help. Is there a way
>> to remove colnames?
>>
>> colnames(x) <- value
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Why I get this error? Error in close.connection(f) : invalid connection

2009-10-27 Thread Peng Yu
I don't understand why I can not close 'f'. This may be very simple,
but I don't see why. Could somebody let me know?

$ cat gzfile.csv
"","V1","V2","V3","V4","V5"
"1",1,5,9,13,17
"2",2,6,10,14,18
"3",3,7,11,15,19
"4",4,8,12,16,20
$ Rscript gzfile.R
> f = file("gzfile.csv")
> A = read.csv(f)
> A
  X V1 V2 V3 V4 V5
1 1  1  5  9 13 17
2 2  2  6 10 14 18
3 3  3  7 11 15 19
4 4  4  8 12 16 20
> close(f)
Error in close.connection(f) : invalid connection
Calls: close -> close.connection
Execution halted

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

2009-10-27 Thread Benilton Carvalho

colnames(x) <- NULL

On Oct 27, 2009, at 8:09 PM, Peng Yu wrote:


I only see how to assign values to colnames() in help. Is there a way
to remove colnames?

colnames(x) <- value

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


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

2009-10-27 Thread Peng Yu
I only see how to assign values to colnames() in help. Is there a way
to remove colnames?

colnames(x) <- value

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


Re: [R] Non-normal residuals.

2009-10-27 Thread Ben Bolker
  [Taking the liberty of posting back to r-help]

  I'd be curious what the particular objections were.
  I have one of those annoying "it depends" answers.

   In general, transformation can

  (1) change [(de)stabilize] variance across groups/gradients;
  (2) (non)normalize residuals;
  (3) change [(non)linearize] relationships with gradients or time;
  (4) modify interaction terms;
  (5) change the interpretation of responses.

 The problem is that sometimes these goals conflict.
"AVAS" (acepack, Hmisc packages) attempts to do #1 and #3 at the
same time.

  If transforming your data brings you closer to satisfying
the assumptions of your analytic methods and having a sensible
analysis, then that's good.  If it makes things worse, that's bad.
Other choices, depending on the situation, include robust methods
(for "outlier" problems); generalized linear models etc. (for
discrete data from standard distributions); models using t- instead
of normally distributed residuals; generalized estimating equations;
etc etc etc ...  transformation (if it works) is simple and (sometimes)
interpretable.

rkevinbur...@charter.net wrote:
> That seems to be a general consensus to transform the data through
> sqrt, log, diff, etc. I was particularly intrigued when I considered
> Box-Cox transformation but there were other time-series gurus that
> recommended against it. Particularly with seasonal or data with a
> trend. Would you have any reservations?
> 
> Thank you.
> 
> Kevin
> 
>  Ben Bolker  wrote:
>> 
>> 
>> rkevinburton wrote:
>>> Hello,
>>> 
>>> I asked a question about what the most likely process to follow
>>> if after a time-series fit is performed the residuals are found
>>> to be non-normal. One peron responded and offered to help if I
>>> supplied a sample data set. Unfortunately now that I have a
>>> sample I have lost the emai addressl. If you are that person or
>>> have some ideas please email me back at rkevinbur...@charter.net.
>>> 
>>> 
>>> 
>> It wasn't me, but ... transform the data? See e.g. ?MASS::boxcox
>> 
>> 
>> -- View this message in context:
>> http://www.nabble.com/Non-normal-residuals.-tp26083746p26084836.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.
> 


-- 
Ben Bolker
Associate professor, Biology Dep't, Univ. of Florida
bol...@ufl.edu / www.zoology.ufl.edu/bolker
GPG key: www.zoology.ufl.edu/bolker/benbolker-publickey.asc



signature.asc
Description: OpenPGP digital signature
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Year and Month extraction from Date object.

2009-10-27 Thread Prof Brian Ripley

?weekdays contains

Note:

 Other components such as the day of the month or the year are very
 easy to compute: just use ‘as.POSIXlt’ and extract the relevant
 component.

(d <- Sys.Date())
1900 + as.POSIXlt(d)$year
1 + as.POSIXlt(d)$mon

should get you started.

On Tue, 27 Oct 2009, rkevinbur...@charter.net wrote:


Hello,

I have seen much discussion on Date. But I can't seem to do this 
simple operation. I can convert a string to a date:


d <- as.Date(DATE, format="%m/%d/%Y")

But what I want to do is extract the year and month so I can 
construct an element in a ts object. Ideally I would like to see 
d$year but that doesn't seem to be available. Once I have a Date 
object how can I get an integer year?


Thank you.

Kevin


--
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] explalinig the output of my linear model analysis

2009-10-27 Thread Tal Galili
I second Rolf.



On Tue, Oct 27, 2009 at 8:48 PM, Rolf Turner wrote:

>
> On 27/10/2009, at 7:58 PM, Peter Ehlers wrote:
>
>  ... if one doesn't understand the output of lm(), then one's
>>
>> knowledge of statistics is insufficient to warrant using lm().
>>
>
> I nominate this as a fortune.
>
>cheers,
>
>Rolf Turner
>
>
>
> ##
> Attention:\ This e-mail message is privileged and confid...{{dropped:9}}
>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[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] Year and Month extraction from Date object.

2009-10-27 Thread rkevinburton
Hello,

I have seen much discussion on Date. But I can't seem to do this simple 
operation. I can convert a string to a date:

d <- as.Date(DATE, format="%m/%d/%Y")

But what I want to do is extract the year and month so I can construct an 
element in a ts object. Ideally I would like to see d$year but that doesn't 
seem to be available. Once I have a Date object how can I get an integer year?

Thank you.

Kevin

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] tk_choose.files without multiple selection?

2009-10-27 Thread Prof Brian Ripley

This depends on the version of Tk you have installed.  The Tk 8.5.7
ChangeLog has

2008-08-25  Todd M. Helfter 

The patch is associated with the bug tracker id: 1936220
library/tkfbox.tcl : fix the multiple selection error for
tk_getOpenFile -multiple 1 which fails on all unix platforms since
the adoption of ttk widgets.

for just after 8.5.4.

So I suggest you update your OS's Tcl/Tk if it is older than that 
(and that fix is 14 months old, so one would hope that your OS has 
updates available).


R for Windows ships with 8.5.6, R for Mac OS X with 8.5.5.

On Tue, 27 Oct 2009, Eger, Marcus wrote:


Dear all,

I compared tk_choose.files on linux with choose.files or
tk_choose.files on windows and found that tk_choose.files does not 
allow multiple selection on linux - independent on keyword setting 
"multi".



tk_choose.files(default=paste(path.original,"",sep=""),caption="Select file(s)")


On linux I get the error message:
   File  does not exist.
I have to click "cancel" to get out of the dialog.
Any ideas?

Regards
Marcus

Windows XP:
---
platform   i386-pc-mingw32
arch   i386
os mingw32
system i386, mingw32
status
major  2
minor  9.2
year   2009
month  08
day24
svn rev49384
language   R
version.string R version 2.9.2 (2009-08-24)


Linux Ubuntu 8.04.3:

platform   i486-pc-linux-gnu
arch   i486
os linux-gnu
system i486, linux-gnu
status
major  2
minor  9.2
year   2009
month  08
day24
svn rev49384
language   R
version.string R version 2.9.2 (2009-08-24)


--
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] Cbind() on the right-side of a formula in xYplot()

2009-10-27 Thread Dylan Beaudette
On Monday 26 October 2009, Frank E Harrell Jr wrote:
> Dylan Beaudette wrote:
> > Hi,
> >
> > Using the latest rms package I am able to make nice plots of model
> > predictions +/- desired confidence intervals like this:
> >
> > # need this
> > library(rms)
> >
> > # setup data
> > d <- data.frame(x=rnorm(100), y=rnorm(100))
> > dd <- datadist(d)
> > options(datadist='dd')
> >
> > # fit model
> > l <- ols(y ~ rcs(x), data=d)
> >
> > # predict along original limits of data
> > l.pred <- Predict(l)
> >
> > # plot of fit and conf. int.
> > xYplot(Cbind(yhat, lower, upper) ~ x, data=l.pred, method='filled',
> > col.fill=grey(0.9), col=1, type='l')
> >
> > Is there any way in which I can turn this figure on its side, by plotting
> > x ~ y... something like this:
> >
> > # doesn't work
> > xYplot(x ~ Cbind(yhat, lower, upper), data=l.pred, method='filled',
> > lable.curves=FALSE, col.fill=grey(0.9), col=1, type='l')
> >
> > # standard lattice, but without the fancy filled area
> > xyplot(x ~ yhat + lower + upper, data=l.pred, type='l', lty=c(1,2,2),
> > col=1)
> >
> > Any suggestions? If it is not possible, then I will try and manually make
> > the figure with basic lattice functions.
> >
> > Cheers,
> > Dylan
>
> Dylan,
>
> Cbind is for the left hand side of the formula.  I suggest you look at
> one of the books that covers lattice graphics, or the online resources
> for lattice to customize this.  The output from Predict is suitable for
> several graphics models.
>
> Frank

Thanks Frank. I was able to cobble together a replacement; note that it 
depends on the original structure of my data, and is therefore not a general 
solution.

Cheers,
Dylan

panel.yx <- function(x, y, subscripts, groups, upper, lower, ...) {

# extract this panel's data
d <- data.frame(yhat=x, top=y, upper=upper[subscripts], 
lower=lower[subscripts], groups=groups[subscripts])

# levels in the groups, for color matching
ll <- levels(d$groups)

# add grid
panel.grid(h=-1, v=-1, lty=3, col=1)

# add conf. intervals
by(d, d$groups, function(d_i) {
# make conf.int polygon
panel.polygon(x=c(d_i$lower, rev(d_i$upper)), y=c(d_i$top, rev(d_i$top)), 
col=grey(0.85), border=NA, alpha=0.5)
})

# add main lines
by(d, d$groups, function(d_i) {
# lookup color
m <- match(unique(d_i$group), ll)
# add line
panel.lines(d_i$yhat, d_i$top, lwd=trellis.par.get('superpose.line')$lwd, 
col=trellis.par.get('superpose.line')$col[m])
})


}



-- 
Dylan Beaudette
Soil Resource Laboratory
http://casoilresource.lawr.ucdavis.edu/
University of California at Davis
530.754.7341

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

2009-10-27 Thread Ben Bolker



rkevinburton wrote:
> 
> Hello,
> 
> I asked a question about what the most likely process to follow if after a
> time-series fit is performed the residuals are found to be non-normal. One
> peron responded and offered to help if I supplied a sample data set.
> Unfortunately now that I have a sample I have lost the emai addressl. If
> you are that person or have some ideas please email me back at
> rkevinbur...@charter.net.
> 
> 

It wasn't me, but ... transform the data?
See e.g. ?MASS::boxcox


-- 
View this message in context: 
http://www.nabble.com/Non-normal-residuals.-tp26083746p26084836.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] Warning message when Loading package svMisc in R 2.10.0

2009-10-27 Thread Uwe Ligges



Richardson, Patrick wrote:

svMisc was built and submitted to CRAN under 2.9.2. If you are trying to use it 
within TINN, TINN will still work. The package needs to be built under 2.10 and 
resubmitted. I'm sure Phillipe will get to it in due time.



No, that's nonsense. It does *not* need to be resubmitted, but do be 
rebuilt, and that is done for a new major release.


Just say

update.packages(checkBuilt=TRUE)

Best,
Uwe Ligges








Best regards,

Patrick

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Orvalho Augusto
Sent: Tuesday, October 27, 2009 3:14 AM
To: r-help@r-project.org
Subject: Re: [R] Warning message when Loading package svMisc in R 2.10.0

I did not try. But you try to update all the packages with:
update.packages()

Good luck
Caveman

On Tue, Oct 27, 2009 at 6:28 AM, Qi Li  wrote:

Hi,

I have a problem when using R 2.10.0,

Loading required package: svMisc
Warning message:
package 'svMisc' was built under R version 2.9.1 and help will not work 
correctly

HOW to fix it?
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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.
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.


[R] anova interaction contrasts: crossing helmert and linear contrasts

2009-10-27 Thread Katie Surrence
I am new to statistics, R, and this list, so apologies in advance for
the errors etiquette I am certain to make (in spite of reading the
posting guide, help on
various commands, etc.).  Any help is greatly appreciated.

Here is my data:

fatigue = 
c(3,2,2,3,2,3,4,3,2,4,5,3,3,2,4,5,4,5,5,6,4,6,9,8,4,3,5,5,6,6,6,7,9,10,12,9)
n <- 3
train <- gl(3, 4*n, labels=c("6wks", "4wks", "2wks"))
dist <- rep(gl(4,n,labels=c("1mi","2mi","3mi","4mi")),3)

What I would like to do is test two interaction contrasts that cross linear
coefficients of the variable "dist" with the two sets of helmert contrasts of
the variable "train".

I have tried so many things I think are wrong I won't reproduce them all here.
Here is a representative example:

My code:


contrasts(dist) = c(-3, -1, 1, 3)
contrasts(train) = contr.helmert(3)
aov1 = aov(fatigue~dist*train)
summary(aov1, intercept = T, split=list(train=1:2), expand.split = T)


My output:

              Df Sum Sq Mean Sq  F value    Pr(>F)
(Intercept)       1 890.03  890.03 801.0250 < 2.2e-16 ***
dist              3  85.19   28.40  25.5583 1.199e-07 ***
train             2  88.39   44.19  39.7750 2.403e-08 ***
 train: C1       1  18.38   18.38  16.5375 0.0004452 ***
 train: C2       1  70.01   70.01  63.0125 3.621e-08 ***
dist:train        6  18.72    3.12   2.8083 0.0325092 *
 dist:train: C1  3   3.46    1.15   1.0375 0.3938042
 dist:train: C2  3  15.26    5.09   4.5792 0.0113201 *
Residuals        24  26.67    1.11
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Among the reasons this seems wrong to me is that I want 1 df
interaction contrasts. "dist:train: C1" and "dist:train: C2" seem (to
my naive eye) to be testing respectively whether my first and second
helmert contrast of train differ significantly across levels of dist.
I want to test the significance of two contrasts of linear trend over
dist--the slope of linear trend at 6wks and  4wks against each other,
and the average of the slopes at 6wks and 4wks against the slope at
2wks.  I don't know how to do this.

Thanks for any help you can offer.

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

2009-10-27 Thread Ulrike Groemping



Uwe Ligges-3 wrote:
> 
> 
> 
> Duncan Murdoch wrote:
>> On 10/27/2009 10:56 AM, Ulrike Groemping wrote:
>>>
>>>
>>> Duncan Murdoch-2 wrote:

 Ulrike Groemping wrote:
 ...
> My system is Windows XP, German locale computer. On installation, I
> was
> asked to decide for text or html help and chose html (there was no 
> radio
> button for chm help).  
 ...

 If you set

 options(help_type="html")

 you'll get HTML help with links in your default browser.

 Duncan Murdoch


>>>
>>> Thank you very much, this works. But I am very surprised that it is 
>>> not the
>>> default. Having chosen html help during installation, I would have 
>>> expected
>>> this to be active without having to change an option.
>> 
>> Yes, it should have been, but there was a bug in the installer, and the 
>> preference indicated there was ignored. This is why it's useful to have 
>> people doing testing during the beta test period:  things like this are 
>> easy to fix, but they need to be noticed first.
> 
>> Duncan Murdoch
> 
> And let me add:
> 
> The whole statistics department has been on two pre-release versions 
> (beta and release-candidate) and nobody reported any error. The 
> installer problem has not been found because I installed from sources 
> anyway. This shows it makes sense to have more than just 400+ beta 
> testers. ;-)
> 
> Uwe
> 
> 

Two more comments: For those of us who have already installed the version
with this installer bug: If you do not want to change the option each time
you call R, it is easy to change it permanently in the file
R_HOME/etc/Rprofile.site (where R_HOME stands for the directory in which
your R is installed, e.g. c:\programs\r\r-2.10.0).  

Regarding beta testing (yes, I admit, I usually leave that to others, and am
nevertheless looking for beta testers of my package RcmdrPlugin.DoE), maybe
it would be time for an experimental design that specifies characteristics
of beta testers to ensure some diversity there, perhaps package DoE.base or
FrF2 could help there (half-, but only half-jokingly) ;-) 

Regards, Ulrike
-- 
View this message in context: 
http://www.nabble.com/Cannot-activate-chm-help-in-R-2.10-tp26067423p26084237.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] MLE for lambda of Poisson distribution using fitdistr

2009-10-27 Thread Peter Ehlers


Ankush Bhargava wrote:

Thank you everyone for responding.

David,
3.75 in my example was equivalent to the mean of the values, which i thought 
was too much a coincidence...
What do you think the significance of "(0.03343)". What is this value?

Kjetil,
Are you saying that mean(x) is same as the MLE  for the poisson lambda?


Yes, the mle for lambda is mean(x) [easy to derive from the
likelihood function] and the estimated sd for the mle is
sqrt(mean(x)/length(x)) which is 0.03343 in your case.

Cheers,

 -Peter Ehlers



Thanks again!
Ankush





From: Peter Ehlers 
To: Kjetil Halvorsen 
Cc: r-h...@stat.math.ethz.ch; ankush...@yahoo.com
Sent: Tue, October 27, 2009 10:15:31 AM
Subject: Re: [R] MLE for lambda of Poisson distribution using fitdistr



Kjetil Halvorsen wrote:

What is wrong with using
mean(x)
to get the MLE of the poisson lambda?


and

  mean(x)/length(x)

to get its estimated variance.

  -Peter Ehlers


Kjetil

On Tue, Oct 27, 2009 at 9:17 AM, David Winsemius  wrote:

On Oct 26, 2009, at 11:25 PM, ankush...@yahoo.com wrote:


Hi,

I am using the fitdistr of MASS to get the MLE for the lambda of a Poisson
distribution.
When i run the fitdistr command, i get an output that looks like -

   lambda
   3.75
   (0.03343)

Couple of questions -
1. is the MLE 0.03343 for the lambda of the given distribution then?
2. How would I calculate the variance of the MLE for the lambda?

It would be more typical statistical usage to have output of the form:
 estimate ( se(estimate) )  so I was expecting 3.75 to be the estimate.
Looking at the help page and running str(.) on the fitdistr object of the
first example confirms my expectations. Why did you think the help page was
suggesting otherwise?

--

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-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] newbie: grading an histogram for several classes of the same discipline

2009-10-27 Thread Mauricio Ortiz Calvao

Hi there

Sorry for the simple question, but I have been unable to find an answer.

I am the coordinator of a basic discipline in a university; we have 
several classes taking this discipline and I would like to compare the 
grades, via a histogram for the distinct classes.


Concretely, I have five ascii files (named according to each class: EC, 
EE, EM, EP, EQ) with three columns each, named according to the exams 
(P1, P2 and PF: first, second and final). Each one of the files has a 
different number of columns, owing to the DIFFERENT number of students 
in each class; example:


EC:

P1  P2  PF
3.4 4.0 5.9
4.3 7.0 2.0
7.8 5.8 7.0


EE:

P1  P2  PF
6.3 5.0 7.4
4.9 4.9 8.5
7.7 2.5 5.3
4.6 7.8 5.7
7.7 7.0 5.6
2.4 3.8 5.4


EM:

...


I would like to create a certain R data type/object/class such that it 
kind of stores all five (5) files into it [dataframe??]; then I would 
give a command that would create five histograms in five distinct 
subplots of the same figure, so that we could visually compare the 
performance of the different classes in each exam...


Thanks for any guidance!

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 quit unwanted execution immediately?

2009-10-27 Thread Peng Yu
Occasionally, I start a command (taking long time to finish) that I
did not really want to start. I type 'ctrl+C' to try to quit the
execution. However, R does not quit the execution of the command
immediately. I'm wondering if R could response to ctrl+C immediately.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] option to control the spac between columns in data frame

2009-10-27 Thread Subodh Acharya
Hello,
 I have a question regarding a way to control the appreance of output
exported by R
when I use capture.output( x, file = "Directory/file.txt") , I get a text
file which when I paste to a word file looks like the first table below.

The following table has its clumns spaced closely so when I paste it to a
word file it looks continuous. Is there any option in R to make the outputs
like the second table?

Any help will be highly appreciated.


Thank you very much in advance.


Model 1
4/70-3/80 Year 2

   Source Area Runoff Nitrogen Phosphorus
V1 LDR_imperv  203   52.6   1496.0  190.0
V2   LDR_perv   11475.7489.6  163.6
V3 MDR_imperv  281  52.6   4141.7  654.7
V4   MDR_Perv  6545.7511.8  227.4
V5 IND_imperv   97   52.6   1604.4  226.0
V6   IND_perv   425.7  17.9   7.1
V7 COM_imperv  158   52.6   2613.4  368.1
V8   COM_perv  1575.7 67.0   26.6
Total 10942  1302.2

  Source Area Runoff Nitrogen Phosphorus
V1 LDR_imperv   20352.6   1496.0
190.0
V2   LDR_perv1147   5.7 489.6
 163.6
V3 MDR_imperv 281 52.64141.7
 654.7
V4   MDR_Perv  654 5.7  511.8
 227.4
V5 IND_imperv   97  52.6 1604.4
 226.0

-- 
Acharya, Subodh

[[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] sm.regression

2009-10-27 Thread Peter Ehlers


Val wrote:

Hi all,
I was looking for a non parametric survival analysis and I came up with the
following sample from the web.

However, I could not run it.  Which library or function does
"sm.regression"  require?


Time to install package 'sos'. It would quickly tell you that
you'll find sm.regression in pkg:sm (Bowman and Azzalini's smoothing
methods).

 -Peter Ehlers



x <- runif(100,-2, 2)
y <- x^2 + rnorm(50)
sm.regression(x, y, h=0.5)

Error: could not find function "sm.regression"

Thanks

Val

[[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] Non-normal residuals.

2009-10-27 Thread rkevinburton
Hello,

I asked a question about what the most likely process to follow if after a 
time-series fit is performed the residuals are found to be non-normal. One 
peron responded and offered to help if I supplied a sample data set. 
Unfortunately now that I have a sample I have lost the emai addressl. If you 
are that person or have some ideas please email me back at 
rkevinbur...@charter.net.

Thank you.

Kevin

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

2009-10-27 Thread marcos carvajalino
Yup you're right, after posting i took a better look at the
subsetting, found the problem and post again, my bad...

2009/10/27 Duncan Murdoch :
> On 27/10/2009 2:58 PM, marcos carvajalino wrote:
>>
>> Dear ms.
>>
>> The most possible reason for this:
>>
>>> Dear all
>>> I am trying to learn R
>>> I was trying to calculate standard deviation
>>> here are the commands and outputs in R

 sd(Ht_cm[type=='SD'])[1] 3.283605> sd(Ht_cm[from_treeline=='above'])[1]
 16.83289> >sd(Ht_cm[type=='SD'][from_treeline=='above'])[1] NA>
>>
>>> the problem is that, i could not understand why the third command could
>>> not give any >result.
>>
>>> please help me out
>>
>>> thanking you
>>
>>> Regard
>>> MS
>>> Nepal
>>
>> is that you're trying to calculate sd over a vector where a NA (Not
>> available) value is contained, that is, you have an empty cell, a
>> different type of data or no data satisfies your condition, try:
>>
>>> sd(Ht_cm[type=='SD'][from_treeline=='above'],na.rm=T)
>>
>> That should do it...
>
> That's legal syntax, but it is very unlikely to be correct.  Hadley gave
> good advice (modulo his typo).
>
> Duncan Murdoch
>



-- 
Marcos Antonio Carvajalino Fernández
Estudiante de Ingeniería Ambiental y Sanitaria
Universidad del Magdalena, Colombia

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] explalinig the output of my linear model analysis

2009-10-27 Thread Kingsford Jones
...which would complement the apropos fortune from John Fox:


> library(fortunes)
> fortune('dangerous')

If you give people a linear model function you give them something dangerous.
   -- John Fox
  useR! 2004, Vienna (May 2004)



On Tue, Oct 27, 2009 at 12:48 PM, Rolf Turner  wrote:
>
> On 27/10/2009, at 7:58 PM, Peter Ehlers wrote:
>
>> ... if one doesn't understand the output of lm(), then one's
>> knowledge of statistics is insufficient to warrant using lm().
>
> I nominate this as a fortune.
>
>        cheers,
>
>                Rolf Turner
>
>
>
> ##
> Attention:\ This e-mail message is privileged and confid...{{dropped:9}}
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

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

2009-10-27 Thread Duncan Murdoch

On 27/10/2009 2:58 PM, marcos carvajalino wrote:

Dear ms.

The most possible reason for this:


Dear all
I am trying to learn R
I was trying to calculate standard deviation
here are the commands and outputs in R

sd(Ht_cm[type=='SD'])[1] 3.283605> sd(Ht_cm[from_treeline=='above'])[1] 16.83289> 
>sd(Ht_cm[type=='SD'][from_treeline=='above'])[1] NA>



the problem is that, i could not understand why the third command could not give 
any >result.



please help me out



thanking you



Regard
MS
Nepal   


is that you're trying to calculate sd over a vector where a NA (Not
available) value is contained, that is, you have an empty cell, a
different type of data or no data satisfies your condition, try:


sd(Ht_cm[type=='SD'][from_treeline=='above'],na.rm=T)


That should do it...


That's legal syntax, but it is very unlikely to be correct.  Hadley gave 
good advice (modulo his typo).


Duncan Murdoch

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


Re: [R] Detection Times and Poisson Distribution

2009-10-27 Thread Ben Bolker



Lorenzo Isella wrote:
> 
> Dear All,
> Apologies if my questions are too basic for this list.
> I am given a set of data corresponding to list of detection times (real, 
> non-integer numbers in general) for some events, let us say nuclear 
> decays to fix the ideas.
> It is a small dataset, corresponding to about 400 nuclear decay times.
> I would like to test the hypothesis that these decay times are 
> Poissonian-distributed.
> What is the best day of dealing with the data? Should I consider the 
> cumulative number of detections vs time, the time intervals between two 
> consecutive detections vs time or something else?
> Many thanks
> 
> 

Perhaps:

sort data, compute inter-event times (should be exponentially
distributed), and compare with an exponential distribution?

difft = diff(sort(times))
ks.test(difft,"pexp",rate=1/difft)

This is not quite right because we have estimated the
rate from the data -- from ?ks.test

 If a single-sample test is used, the parameters specified in '...'
 must be pre-specified and not estimated from the data. There is
 some more refined distribution theory for the KS test with
 estimated parameters (see Durbin, 1973), but that is not
 implemented in 'ks.test'.

But perhaps not a bad start.

-- 
View this message in context: 
http://www.nabble.com/Detection-Times-and-Poisson-Distribution-tp26080592p26083370.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] Exclude rows in xyplot

2009-10-27 Thread Dieter Menne



Joel Fürstenberg-Hägg wrote:
> 
> 
> 
> Now I'm trying to make xyplots to compare the result from three different
> categories:
> 
> # Plot Pro against Glc for each of the three categories
> xyplot(Pro ~ Glc | Categories_BBCH_ID, data=fieldTrial0809, pch="°",
> layout=c(1, 3), aspect=1, index.cond=list(3:1))
> 
> I would like to exlude outliers like above. I've found that limits can be
> used in a similar manner as with xlim and ylim, but though I've read about
> them I don't understand how to solve it... Anyone who can help me?
> 
> 

I use "subset" of xyplot.

Dieter


-- 
View this message in context: 
http://www.nabble.com/Exclude-rows-in-xyplot-tp26082760p26083286.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] MLE for lambda of Poisson distribution using fitdistr

2009-10-27 Thread Ankush Bhargava
Thank you everyone for responding.

David,
3.75 in my example was equivalent to the mean of the values, which i thought 
was too much a coincidence...
What do you think the significance of "(0.03343)". What is this value?

Kjetil,
Are you saying that mean(x) is same as the MLE  for the poisson lambda?

Thanks again!
Ankush





From: Peter Ehlers 
To: Kjetil Halvorsen 

Sent: Tue, October 27, 2009 10:15:31 AM
Subject: Re: [R] MLE for lambda of Poisson distribution using fitdistr



Kjetil Halvorsen wrote:
> What is wrong with using
> mean(x)
> to get the MLE of the poisson lambda?
> 
and

  mean(x)/length(x)

to get its estimated variance.

  -Peter Ehlers

> Kjetil
> 
> On Tue, Oct 27, 2009 at 9:17 AM, David Winsemius  
> wrote:

>>
>>> Hi,
>>>
>>> I am using the fitdistr of MASS to get the MLE for the lambda of a Poisson
>>> distribution.
>>> When i run the fitdistr command, i get an output that looks like -
>>>
>>>lambda
>>>3.75
>>>(0.03343)
>>>
>>> Couple of questions -
>>> 1. is the MLE 0.03343 for the lambda of the given distribution then?
>>> 2. How would I calculate the variance of the MLE for the lambda?
>> It would be more typical statistical usage to have output of the form:
>>  estimate ( se(estimate) )  so I was expecting 3.75 to be the estimate.
>> Looking at the help page and running str(.) on the fitdistr object of the
>> first example confirms my expectations. Why did you think the help page was
>> suggesting otherwise?
>>
>> --
>>
>> 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-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] how do I plot a regression curve with the data?

2009-10-27 Thread Ken Ervin
I have a data set of 6 or so ordered pairs, and I've been able to graph 
them and have decided to use a high-order polynomial regression.  I've 
used the following piece of code:


regression <- function(x,y) {
   x <- c(insert_numbers_here)
   y <- c(insert_other_numbers_here)
   fit <- lm(y ~ x + I(x^2) + I(x^3) + I(x^4) + I(x^5) + I(x^6) + 
I(x^7) + I(x^8) + I(x^9))

   summary(fit)

This gives me the coefficients for the regression very nicely, but I 
would like to plot both the data and the regression curve together.  How 
do I plot that regression curve as a function, and can I put it on the 
same set of axes as my data scatter plot?


Thanks in advance for your help!

-KE

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

2009-10-27 Thread marcos carvajalino
Hi ms.

also try this:

sd(Ht_cm[type=='SD' && from_treeline=='above'])

cause i think you can't use [][] two apply 2 conditions to a data
frame, in that cases you should use an AND (&&) conector like above

2009/10/27 marcos carvajalino :
> Dear ms.
>
> The most possible reason for this:
>
>>Dear all
>>I am trying to learn R
>>I was trying to calculate standard deviation
>>here are the commands and outputs in R
>>> sd(Ht_cm[type=='SD'])[1] 3.283605> sd(Ht_cm[from_treeline=='above'])[1] 
>>> 16.83289> >sd(Ht_cm[type=='SD'][from_treeline=='above'])[1] NA>
>
>>the problem is that, i could not understand why the third command could not 
>>give any >result.
>
>>please help me out
>
>>thanking you
>
>>Regard
>>MS
>>Nepal
>
> is that you're trying to calculate sd over a vector where a NA (Not
> available) value is contained, that is, you have an empty cell, a
> different type of data or no data satisfies your condition, try:
>
>>sd(Ht_cm[type=='SD'][from_treeline=='above'],na.rm=T)
>
> That should do it...
>
> --
> Marcos Antonio Carvajalino Fernández
> Estudiante de Ingeniería Ambiental y Sanitaria
> Universidad del Magdalena, Colombia
>



-- 
Marcos Antonio Carvajalino Fernández
Estudiante de Ingeniería Ambiental y Sanitaria
Universidad del Magdalena, Colombia

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Print several xyplots to the same page in a pdf file

2009-10-27 Thread Dieter Menne



Joel Fürstenberg-Hägg wrote:
> 
> 
> I'm using the lattice package and the xyplot to make several graphs like
> below. However, I can just print the three grouped plots onto one page as
> I'm putting them into a pdf-file, which gives me a huge amount 

Check the documentation and examples for print.trellis; I prefer the "split"
version, but other are possible. And do not forget that it is best to do an
explicit print.

p1 = xyplot()
p2 = xyplot()

print(p1,split=c(1,1,2,1))
print(p2,split=c(2,1,2,1))

Dieter



-- 
View this message in context: 
http://www.nabble.com/Print-several-xyplots-to-the-same-page-in-a-pdf-file-tp26083087p26083254.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] automatically adjusting axis limits

2009-10-27 Thread John Kane
PLEASE provide commented, minimal, self-contained, reproducible code.
 particularly a sample data.set.  At the moment it sounds like you have one 
variable (Wavelength) with a length of 56 and Reflectance with a length of 
5,000.  What format(s) are the data in?  Data.frames?

 Clearly this is not the case but I don't understand the data layout at all 


--- On Tue, 10/27/09, Servet Ahmet Cizmeli  wrote:

> From: Servet Ahmet Cizmeli 
> Subject: [R] automatically adjusting axis limits
> To: r-help@r-project.org
> Received: Tuesday, October 27, 2009, 2:12 PM
> Dear R users,
> 
> I am a newbie. Just switched from MATLAB. So thanks a lot
> for your
> patience.
> 
> I have 5 spectra collected in field. Each spectra has
> two columns :
> Wavelength (56) and the actual measurement.  
> 
> Each measurement came in a different .txt file on disk
> (5 files in
> total). I wrote a script that reads every spectra in a for
> loop and
> constructs two variables :
> 
> Wavelength (56) and Reflectance (56x5). I would like to
> plot
> Reflectance vs Wavelength i.e. overlay 5 spectra one
> one top of the
> other.
> 
> plot(Wavelength, Reflectance) does not work (Matlab would
> do it): 
> 
> Error in xy.coords(x, y, xlabel, ylabel, log) : 
> 'x' and 'y' lengths differ
> 
> 
> I then tried to construct the two matrices so that they
> have the same size
> (56x5) and plot it all at once with the command "plot".
> This works but
> it is such a computationally inefficient way that I do not
> want to do this
> Why redundantly store wavelength data? Later I will have to
> process much
> more spectra so this is not a good practice for me.
> 
> I then decided to draw the first spectra on the first run
> of the for loop
> with the command "plot" and add the subsequent graphs with
> the command
> "lines". This works but the y-axes limits do not adjust
> automatically,
> leaving many spectra out of the axis limits  ;( 
> 
> I don't want to set the axis limits by hand as I need this
> script to be
> completely autonomous. I don't want to program lines of
> code to calculate
> those limits myself either I am sure the mighty R can
> do it... BUT
> HOW (Matlab would easily do it with a single command) 
> 
> What I need is a command that will redraw the graph by
> automatically
> adjusting the axis limits. I have been searching for many
> days on the web,
> forums and mailing list archives but I still don't know how
> to do it.
> Please help
> 
> thanks a lot from advance for your kindly help
> Servet
> 
> __
> R-help@r-project.org
> mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained,
> reproducible code.
> 


  __
Looking for the perfect gift? Give the gift of Flickr! 

http://www.flickr.com/gift/

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

2009-10-27 Thread Ben Bolker



Sac-6 wrote:
> 
> Dear R users,
> 
> I am a newbie. Just switched from MATLAB. So thanks a lot for your
> patience.
> 
> I have 5 spectra collected in field. Each spectra has two columns :
> Wavelength (56) and the actual measurement.  
> 
> Each measurement came in a different .txt file on disk (5 files in
> total). I wrote a script that reads every spectra in a for loop and
> constructs two variables :
> 
> Wavelength (56) and Reflectance (56x5). I would like to plot
> Reflectance vs Wavelength i.e. overlay 5 spectra one one top of the
> other.
> 
> plot(Wavelength, Reflectance) does not work (Matlab would do it): 
> 
> Error in xy.coords(x, y, xlabel, ylabel, log) : 
> 'x' and 'y' lengths differ
> 
> 
> I then tried to construct the two matrices so that they have the same size
> (56x5) and plot it all at once with the command "plot". This works but
> it is such a computationally inefficient way that I do not want to do this
> Why redundantly store wavelength data? Later I will have to process much
> more spectra so this is not a good practice for me.
> 
> I then decided to draw the first spectra on the first run of the for loop
> with the command "plot" and add the subsequent graphs with the command
> "lines". This works but the y-axes limits do not adjust automatically,
> leaving many spectra out of the axis limits  ;( 
> 
> I don't want to set the axis limits by hand as I need this script to be
> completely autonomous. I don't want to program lines of code to calculate
> those limits myself either I am sure the mighty R can do it... BUT
> HOW (Matlab would easily do it with a single command) 
> 
> What I need is a command that will redraw the graph by automatically
> adjusting the axis limits. I have been searching for many days on the web,
> forums and mailing list archives but I still don't know how to do it.
> Please help
> 
> thanks a lot from advance for your kindly help
> Servet
> 
> 

oops, I wasn't reading carefully enough, you've already done all the hard
work.

matplot(Wavelength,Reflectance)

-- 
View this message in context: 
http://www.nabble.com/automatically-adjusting-axis-limits-tp26082508p26083157.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] automatically adjusting axis limits

2009-10-27 Thread Ben Bolker



Sac-6 wrote:
> 
> Dear R users,
> 
> I am a newbie. Just switched from MATLAB. So thanks a lot for your
> patience.
> 
> I have 5 spectra collected in field. Each spectra has two columns :
> Wavelength (56) and the actual measurement.  
> 
> Each measurement came in a different .txt file on disk (5 files in
> total). I wrote a script that reads every spectra in a for loop and
> constructs two variables :
> 
> Wavelength (56) and Reflectance (56x5). I would like to plot
> Reflectance vs Wavelength i.e. overlay 5 spectra one one top of the
> other.
> 
> plot(Wavelength, Reflectance) does not work (Matlab would do it): 
> 
> Error in xy.coords(x, y, xlabel, ylabel, log) : 
> 'x' and 'y' lengths differ
> 
> 
> I then tried to construct the two matrices so that they have the same size
> (56x5) and plot it all at once with the command "plot". This works but
> it is such a computationally inefficient way that I do not want to do this
> Why redundantly store wavelength data? Later I will have to process much
> more spectra so this is not a good practice for me.
> 
> I then decided to draw the first spectra on the first run of the for loop
> with the command "plot" and add the subsequent graphs with the command
> "lines". This works but the y-axes limits do not adjust automatically,
> leaving many spectra out of the axis limits  ;( 
> 
> I don't want to set the axis limits by hand as I need this script to be
> completely autonomous. I don't want to program lines of code to calculate
> those limits myself either I am sure the mighty R can do it... BUT
> HOW (Matlab would easily do it with a single command) 
> 
> What I need is a command that will redraw the graph by automatically
> adjusting the axis limits. I have been searching for many days on the web,
> forums and mailing list archives but I still don't know how to do it.
> Please help
> 
> thanks a lot from advance for your kindly help
> Servet
> 
> 

Are all the wavelengths the same?
The best answer is matplot(), but you need to reformat your data a bit.

for example:

files <- list.files(pattern=[something appropriate])
datlist <- lapply(files,read.table,...[other arguments such as header=TRUE])
wavelens <- datlist[[1]][,1]
datlist2 <- lapply(datlist,"[[","vals"]]  ## assuming second column is
called "vals"
datmat <- do.call(datlist2,cbind)
matplot(wavelens,datmat)

-- 
View this message in context: 
http://www.nabble.com/automatically-adjusting-axis-limits-tp26082508p26083141.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] Sandard deviation calculation

2009-10-27 Thread marcos carvajalino
Dear ms.

The most possible reason for this:

>Dear all
>I am trying to learn R
>I was trying to calculate standard deviation
>here are the commands and outputs in R
>> sd(Ht_cm[type=='SD'])[1] 3.283605> sd(Ht_cm[from_treeline=='above'])[1] 
>> 16.83289> >sd(Ht_cm[type=='SD'][from_treeline=='above'])[1] NA>

>the problem is that, i could not understand why the third command could not 
>give any >result.

>please help me out

>thanking you

>Regard
>MS
>Nepal  

is that you're trying to calculate sd over a vector where a NA (Not
available) value is contained, that is, you have an empty cell, a
different type of data or no data satisfies your condition, try:

>sd(Ht_cm[type=='SD'][from_treeline=='above'],na.rm=T)

That should do it...

-- 
Marcos Antonio Carvajalino Fernández
Estudiante de Ingeniería Ambiental y Sanitaria
Universidad del Magdalena, Colombia

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Print several xyplots to the same page in a pdf file

2009-10-27 Thread Joel Fürstenberg-Hägg

Hello everybody,

I'm using the lattice package and the xyplot to make several graphs like below. 
However, I can just print the three grouped plots onto one page as I'm putting 
them into a pdf-file, which gives me a huge amount of pages... Is it possible 
to put them all, or at least more than one on the same page, for instance put 
three groups beside each other like columns?

...
xyplot(Pro ~ Glc | Categories_BBCH_ID, data=fieldTrial0809, pch="°", 
layout=c(1, 3), aspect=1, index.cond=list(3:1))
xyplot(Pro ~ Raf | Categories_BBCH_ID, data=fieldTrial0809, pch="°", 
layout=c(1, 3), aspect=1, index.cond=list(3:1))
xyplot(Pro ~ Suc | Categories_BBCH_ID, data=fieldTrial0809, pch="°", 
layout=c(1, 3), aspect=1, index.cond=list(3:1))
xyplot(Fum ~ Aa | Categories_BBCH_ID, data=fieldTrial0809, pch="°", layout=c(1, 
3), aspect=1, index.cond=list(3:1))
xyplot(Fum ~ Pro | Categories_BBCH_ID, data=fieldTrial0809, pch="°", 
layout=c(1, 3), aspect=1, index.cond=list(3:1))
etc...

All the best,

Joel
  
_
Nya Windows 7 - Hitta en dator som passar dig! Mer information.
http://windows.microsoft.com/shop
[[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] explalinig the output of my linear model analysis

2009-10-27 Thread Rolf Turner


On 27/10/2009, at 7:58 PM, Peter Ehlers wrote:


... if one doesn't understand the output of lm(), then one's
knowledge of statistics is insufficient to warrant using lm().


I nominate this as a fortune.

cheers,

Rolf Turner



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

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


[R] Exclude rows in xyplot

2009-10-27 Thread Joel Fürstenberg-Hägg

Hi all,

I'm searching for a way to exclude outliers from my dataset while making 
xyplots. While plotting using pairs(), I exclude specific row in my data frame 
and save the settings as a variable which I later include as an argument:

# Discard outliers and save settings as idx
idx=with(fieldTrial0809, which(Pro>0 & Pro<0.95 & Fum>0 & Fum<0.4  & Mal>0.1 & 
Mal<2.5 & Glc>2 & Glc<20 & Fru>1 & Fru<30 & Raf>0 & Raf<3 & Suc>1 & Suc<14))

#Plot the numerical and ranked columns pair wise using pairs()
pdf("ranked.pdf", height=20, width=20)
pairs(fieldTrial0809[idx, c(21,26,30,32,34,36,38,40,42,44,46,48,50)], 
main="Ranked", col="blue", pch="°", gap=0.2)
dev.off()

Now I'm trying to make xyplots to compare the result from three different 
categories:

# Plot Pro against Glc for each of the three categories
xyplot(Pro ~ Glc | Categories_BBCH_ID, data=fieldTrial0809, pch="°", 
layout=c(1, 3), aspect=1, index.cond=list(3:1))

I would like to exlude outliers like above. I've found that limits can be used 
in a similar manner as with xlim and ylim, but though I've read about them I 
don't understand how to solve it... Anyone who can help me?

All the best,

Joel


  
_
Hitta hetaste singlarna på MSN Dejting!
http://dejting.se.msn.com/channel/index.aspx?trackingid=1002952
[[alternative HTML version deleted]]

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


Re: [R] lasso plot using LARS

2009-10-27 Thread Kingsford Jones
Within the plot.lars code, change the type argument to matplot from 'b' to 'l':

library(lars)
myplot.lars <- edit(plot.lars)
#change type = 'b' to type = 'l' in the call to matplot
data(diabetes)
object <- with(diabetes,  lars(x,y))
myplot.lars(object, lty = 1, breaks = FALSE)


hth,
Kingsford Jones


On Tue, Oct 27, 2009 at 11:11 AM, Russell Ivory
 wrote:
> When plotting a lars object, I cannot find a way to plot solid lines.
> Even when the arguments breaks=F and lty="solid" are used, the vertical
> lines at the break points do not plot but asterisks indicating the
> breaks still plot as part of each path leaving solid lines broken up by
> asterisks at the break points.  I'm using the following code.
>
>
>
> larsfit <- lars(X,y,type="lasso")
>
> larsfit
>
> plot(larsfit,breaks=F,lty="solid")
>
>
>
> Any suggestions in removing the asterisks and plotting truly solid
> lines?
>
>
>
> Thanks
>
>
>
> Russell Ivory
>
> AVP Senior Modeling Manager
>
> Merrick Bank
>
> 10705 South Jordan Gateway
>
> South Jordan, UT 84095
>
> 801 545-6640 office
>
> 801 545-6340 fax
>
>
>
>
>
>
>
>
>
> This
>  e-mail and any files transmitted with it are confidential and are intended 
> solely for the use of the individual or entity to whom it is addressed. If 
> you are not the intended recipient or the person responsible for delivering 
> the e-mail to the intended recipient, be advised that you have received this 
> e-mail in error, and that any use, dissemination, forwarding, printing, or 
> copying of this e-mail is strictly prohibited. If you received this e-mail in 
> error, please return the e-mail to the sender at Merrick Bank and delete it 
> from your computer. Although Merrick Bank attempts to sweep e-mail and 
> attachments for viruses, it does not guarantee that either are virus-free and 
> accepts no liability for any damage sustained as a result of viruses.
>
>        [[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] User input when running R code in batch mode

2009-10-27 Thread Martin Maechler
> Barry Rowlingson 
> on Tue, 27 Oct 2009 10:17:24 +0100 writes:

> On Tue, Oct 27, 2009 at 9:20 AM, Kaushik Krishnan
>  wrote:

>> $ r --vanilla < test.r
>>> a <- scan(what='character',n=1); a
>> 1: Read 0 items
>> character(0)
>> 
>> Now it's not working.

> Assuming this is a unix environment, the syntax '< test.r' means 'my
> standard input stream is the file test.r'. That's not what you want.
> Give R the file name as an argument and let the standard input stream
> remain user input:

> $ r --vanilla  test.r
> 1: hello
> Read 1 item
> [1] "hello"

> Note that this is 'r' and not 'R'. For me this comes from the
> 'littler' package in Ubuntu Linux. The same thing with 'R' doesn't
> work:

> $ R --vanilla  test.r
> ARGUMENT 'test.r' __ignored__
> [banner]
>> [the R prompt appears]



>  Maybe there's a way of doing this with big R, but I think
> littler is designed for this kind of thing.

yes, and it was historically the first, and maybe still the most efficient
way to do so.
The "big R" way is to use  'Rscript'  which comes with R,
e.g.,

 Rscript --vanilla -e 'cat("a string please: "); a <- readLines("stdin",n=1); 
str(a)' 
input a string please: Foobar
 chr "Foobar"

(Note that here I use  -e ''  instead of an R script file
 which of course is possible too).

Martin Maechler, ETH Zurich

 >> Is there any way to make R stop for the user to enter
 >> values when running in batch mode either by changing the
 >> way I invoke scan() or readLines() or by using any other
 >> function?

>  An alternative is to use the tcltk package to make a
> dialog for user input.

> Barry

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

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Stack overflow in R 2.10.0 with sub()

2009-10-27 Thread Kenneth Roy Cabrera Torres
El mar, 27-10-2009 a las 10:47 -0700, Phil Spector escribió:
> What happens if you type
> 
> Sys.setlocale('LC_ALL','C')
> 
> before using gsub or grep?

When I do that, R hangs and  don't show any message.
> 
>   - Phil Spector
>Statistical Computing Facility
>Department of Statistics
>UC Berkeley
>spec...@stat.berkeley.edu
> 
> 
> On Tue, 27 Oct 2009, Kenneth Roy Cabrera Torres wrote:
> 
> > Thank you very much for your interest.
> >
> > I make this:
> > x <- as.character(alumnos$AL_NUME_ID)
> > x <- x[-seq_len(length(x)/2)]
> > save(x, file="x.RData")
> >
> > I exit form R, and then restart R and I make this:
> >
> > load("x.RData")
> > y <- gsub("(^ +)|( +$)","",x)
> >
> > It shows me:
> >
> > Error en gsub("(^ +)|( +$)", "", x) :
> >  input string 66644 is invalid in this locale
> >
> > I delete that string (it is a string with a non usual character (Ñ))
> >
> > So, I retype without that observation.
> >
> > y <- gsub("(^ +)|( +$)","",x[-c(66644)])
> >
> > I got this:
> > Error en gsub("(^ +)|( +$)", "", x[-c(66644)]) :
> >  input string 160689 is invalid in this locale
> >
> > I retype again with this invalid string this way (I use the
> >  160690 position, because the lag of the x vector)
> >
> >> y <- gsub("(^ +)|( +$)","",x[-c(66644,160690)])
> > Error: C produce desborde de pila en 'segfault'
> >
> > And it fails.
> >
> > I also repeat all the process with this conversion first.
> >
> > x <- iconv(as.character(alumnos$AL_NUME_ID),"latin1","UTF-8")
> > x <- x[-seq_len(length(x)/2)]
> > save(x, file="x.RData")
> >
> > And I exit, and restart R, and then I type
> >
> > load("x.RData")
> > y <- gsub("(^ +)|( +$)","",x)
> >
> > And it fails again without showing me the "invalid string" errors.
> >
> > I then make this:
> >
> > load("x.RData")
> > y <- gsub("(^ +)|( +$)","",x[1:160690])
> >
> > and it works, then I type
> >
> > y <- gsub("(^ +)|( +$)","",x[1:20]) #(x length is 454035)
> >
> > and it works...
> >
> > But I start to make a manual binary search,
> > I found something that stills puzzle me.
> >
> > y <- gsub("(^ +)|( +$)","",x[1:261570])
> >
> > works, but sometimes fails (after I restart R),
> > it always fails with index greather than 262000.
> >
> > I see that there are not something inusual arround 261570.
> >
> > x[261560:261580]
> > [1] "21444777 " "1147585  " "255202522
> > "
> > [4] "25852100 " "24258550 " "A8D0251207
> > "
> > [7] "34681811 " "19121345 " "16921329
> > "
> > [10] "20442195 " "14506482 " "44332211
> > "
> > [13] "35049122 " "34326340 " "35182366
> > "
> > [16] "33288742 " "34958795 " "1017147202
> > "
> > [19] "3306985  " "33048501 " "33295073
> > "
> >
> > I am sending you the x.Rdata file to see if you can
> > reproduce my problem.
> >
> > This infomation may be useful:
> >
> > sessionInfo()
> >
> > R version 2.10.0 (2009-10-26)
> > x86_64-unknown-linux-gnu
> >
> > locale:
> > [1] LC_CTYPE=es_CO.UTF-8   LC_NUMERIC=C
> > [3] LC_TIME=es_CO.UTF-8LC_COLLATE=es_CO.UTF-8
> > [5] LC_MONETARY=C  LC_MESSAGES=es_CO.UTF-8
> > [7] LC_PAPER=es_CO.UTF-8   LC_NAME=C
> > [9] LC_ADDRESS=C   LC_TELEPHONE=C
> > [11] LC_MEASUREMENT=es_CO.UTF-8 LC_IDENTIFICATION=C
> >
> > attached base packages:
> > [1] stats graphics  grDevices utils datasets  methods   base
> >
> > R.Version()
> >
> > $platform
> > [1] "x86_64-unknown-linux-gnu"
> > $arch
> > [1] "x86_64"
> > $os
> > [1] "linux-gnu"
> > $system
> > [1] "x86_64, linux-gnu"
> > $status
> > [1] ""
> > $major
> > [1] "2"
> > $minor
> > [1] "10.0"
> > $year
> > [1] "2009"
> > $month
> > [1] "10"
> > $day
> > [1] "26"
> > $`svn rev`
> > [1] "50208"
> > $language
> > [1] "R"
> > $version.string
> > [1] "R version 2.10.0 (2009-10-26)"
> >
> > gcc --version and g++ --verision shows me:
> >
> > gcc (Ubuntu 4.3.3-5ubuntu4) 4.3.3
> > Copyright (C) 2008 Free Software Foundation, Inc.
> > Esto es software libre; vea el código para las condiciones de copia.  NO
> > hay
> > garantía; ni siquiera para MERCANTIBILIDAD o IDONEIDAD PARA UN PROPÓSITO
> > EN
> > PARTICULAR
> >
> > When I compile R I use this option in configuration (nothing more)
> >
> > ./configure --enable-R-shlib
> > make
> > sudo make install
> >
> > At the moment I have 22Gb of swap partition (keeping monitor tracking
> > the systems is not using it) and 4GB of RAM.
> >
> > Again, thank you very much for your help.
> >
> > Kenneth
> >
> >
> >
> >
> >
> >

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commente

[R] automatically adjusting axis limits

2009-10-27 Thread Servet Ahmet Cizmeli
Dear R users,

I am a newbie. Just switched from MATLAB. So thanks a lot for your
patience.

I have 5 spectra collected in field. Each spectra has two columns :
Wavelength (56) and the actual measurement.  

Each measurement came in a different .txt file on disk (5 files in
total). I wrote a script that reads every spectra in a for loop and
constructs two variables :

Wavelength (56) and Reflectance (56x5). I would like to plot
Reflectance vs Wavelength i.e. overlay 5 spectra one one top of the
other.

plot(Wavelength, Reflectance) does not work (Matlab would do it): 

Error in xy.coords(x, y, xlabel, ylabel, log) : 
'x' and 'y' lengths differ


I then tried to construct the two matrices so that they have the same size
(56x5) and plot it all at once with the command "plot". This works but
it is such a computationally inefficient way that I do not want to do this
Why redundantly store wavelength data? Later I will have to process much
more spectra so this is not a good practice for me.

I then decided to draw the first spectra on the first run of the for loop
with the command "plot" and add the subsequent graphs with the command
"lines". This works but the y-axes limits do not adjust automatically,
leaving many spectra out of the axis limits  ;( 

I don't want to set the axis limits by hand as I need this script to be
completely autonomous. I don't want to program lines of code to calculate
those limits myself either I am sure the mighty R can do it... BUT
HOW (Matlab would easily do it with a single command) 

What I need is a command that will redraw the graph by automatically
adjusting the axis limits. I have been searching for many days on the web,
forums and mailing list archives but I still don't know how to do it.
Please help

thanks a lot from advance for your kindly help
Servet

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] operations on sparse matrices, and dense intermediary steps

2009-10-27 Thread Martin Maechler
Hi Jose,

> "JQ" == Jose Quesada 
> on Sat, 24 Oct 2009 23:49:08 +0200 writes:

JQ> -BEGIN PGP SIGNED MESSAGE-
JQ> Hash: SHA1

JQ> Hi,

JQ> I'm doing some basic operations on large sparse matrices, for example
JQ> getting a row.
JQ> it takes  close to 30 seconds on a 3Ghz machine, and shots the memory
JQ> usage up to the sky.

Hmm, I can hardly beleave the memory shooting, are you sure about
that ?? .. see below

JQ> I suspect there are dense intermediary steps (which, if true would
JQ> defeat the purpose of trying to use sparse representaitons).

JQ> As much as I try understanding the hierarchy of Matrix classes, it's a
JQ> mystery to me.
JQ> Is subsetting sparse matrices memory-intensive? Does it have to do with
JQ> features of the language, such as pass-by-value bu default?
JQ> Or am I doing something inneficent without knowing?

JQ> (Note: example below would only work with 64bit R and lots of memory;
JQ> reduce size of matrix 2-3 orders of magnitude for 32-bit R)

[... rSpMatrix()  from  help(spMatrix) .. ]

JQ> ## (original ir a term x doc matrix of the entire wikipedia)
JQ> mm <- rSpMatrix(793251, 1027355, nnz = 205746204)

JQ> # make it column based:
JQ> mm <- as(mm, "CsparseMatrix")

{ Note that the above Tsparse -> Csparse is not really beneficial,
  if your main issue is things like  subsetting and sub-assignment:
  these are implemented to go via TsparseMatrix operations.
  However, this is really a side-issue }


JQ> a=mm[1,,drop=F]#this takes close to 30 seconds on a 3Ghz machine

Well, you have nnz := 205 million non-zero entries  in your matrix.
This is quite substantial, also with lots of RAM.

The subsetting indeed uses several dense vectors of size 'nnz'
and it's just these operations (vector operations only) that use
the time (and memory) you see.
Most of these vectors are logical or integers --> ~ 800 MB each,
but of course the x slot of M is 8 * 205 = 1.6 GB alone.
So even thought you have a sparse matrix, it *is* large in
itself, and dealing with it and its components is not inexpensive.

Note that in R  m[i,,]  needs to work for very general i,
e.g., for  i <- c(1,1,1,2:7, 1:10100)
or i a logical vector of length nrow(m), or even a character
vector of rownames ... all these work for 'Matrix' as for
traditional R matrices, so, the function that does the
subsetting needs to be written generally enough.

But of course, we are happy for improvement patches to the Matrix
package, and this part of the code could probably be sped up
by a factor of 10 or 20, e.g., by moving that part of the code
to C; it's currently the code starting at around 
line 194 in  Matrix/R/Tsparse.R, 

setMethod("[", signature(x = "TsparseMatrix", i = "index", j = "missing",
 drop = "logical"),
  function (x, i, j, ..., drop) { ## select rows
...
...
...
  })

which you seem to offer to improve ;-)

{{ A less nice alternative to moving it to C,
   might be to special case  M[i,] , M[i,j]  etc 
   for the special case where  i (and j) is just of length 1. }}

Thank you for the reproducible code, 
and thanks in advance for your improvement patches 
or other propositions...


Best regards,
Martin Maechler, ETH Zurich

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

2009-10-27 Thread christiaan pauw
Update to R 2.9
As far as I know the RPostgreSQL package doesn't work in R 2.8

2009/9/14 Lore M 

>
> It still doesn't work. Now, R is asking me for the SSLEAY32.dll. If I
> download it from the internet, and then put it in the file
> \R-2.8.1\library\RPostgreSQL\libs, now they ask me for the VSINIT.dll file !
> it's like an infinite loop... I've tried to intall again the RPostgreSQL
> library but nothing's changed. I don't understand because Postgres is fine,
> it works. Should I install it again ? :s
> Thanks everyone.
>
> > Date: Fri, 11 Sep 2009 08:21:59 -0700
> > From: m...@joeconway.com
> > To: tchiba...@hotmail.com
> > CC: r-help@r-project.org
> > Subject: Re: [R] RPostgreSQL package and libpq.dll file
> >
> > Lore M wrote:
> > > Dear all, I'd like to use the package RPostgreSQL. I'm using R
> > > version 2.8.1 and I've download the last version RPostgreSQL. When I
> > > load the package, I get something like "the file LIBPQ.DLL is
> > > missing". Do you have any idea about what I'm suppose to do ? Thanks
> > > everyone.
> >
> > libpq.dll is the PostgreSQL client library. You should be able to get it
> > here: http://www.postgresql.org/download/windows
> >
> > HTH
> >
> > Joe
> >
>
> _
> [[elided Hotmail 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.
>

[[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] sm.regression

2009-10-27 Thread Val
Hi all,
I was looking for a non parametric survival analysis and I came up with the
following sample from the web.

However, I could not run it.  Which library or function does
"sm.regression"  require?

x <- runif(100,-2, 2)
y <- x^2 + rnorm(50)
sm.regression(x, y, h=0.5)

Error: could not find function "sm.regression"

Thanks

Val

[[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] Stack overflow in R 2.10.0 with sub()

2009-10-27 Thread Kenneth Roy Cabrera Torres
Thank you very much for your interest.

I make this:
x <- as.character(alumnos$AL_NUME_ID)
x <- x[-seq_len(length(x)/2)]
save(x, file="x.RData")

I exit form R, and then restart R and I make this:

load("x.RData")
y <- gsub("(^ +)|( +$)","",x)

It shows me:

Error en gsub("(^ +)|( +$)", "", x) : 
  input string 66644 is invalid in this locale

I delete that string (it is a string with a non usual character (Ñ))

So, I retype without that observation.

y <- gsub("(^ +)|( +$)","",x[-c(66644)])

I got this:
Error en gsub("(^ +)|( +$)", "", x[-c(66644)]) : 
  input string 160689 is invalid in this locale

I retype again with this invalid string this way (I use the
  160690 position, because the lag of the x vector)

> y <- gsub("(^ +)|( +$)","",x[-c(66644,160690)])
Error: C produce desborde de pila en 'segfault'

And it fails.

I also repeat all the process with this conversion first.

x <- iconv(as.character(alumnos$AL_NUME_ID),"latin1","UTF-8")
x <- x[-seq_len(length(x)/2)]
save(x, file="x.RData")

And I exit, and restart R, and then I type

load("x.RData")
y <- gsub("(^ +)|( +$)","",x)

And it fails again without showing me the "invalid string" errors.

I then make this:

 load("x.RData")
 y <- gsub("(^ +)|( +$)","",x[1:160690])

and it works, then I type

 y <- gsub("(^ +)|( +$)","",x[1:20]) #(x length is 454035)

and it works...

But I start to make a manual binary search,
I found something that stills puzzle me.

y <- gsub("(^ +)|( +$)","",x[1:261570])

works, but sometimes fails (after I restart R),
it always fails with index greather than 262000.

I see that there are not something inusual arround 261570.

x[261560:261580]
 [1] "21444777 " "1147585  " "255202522
"
 [4] "25852100 " "24258550 " "A8D0251207
"
 [7] "34681811 " "19121345 " "16921329
"
[10] "20442195 " "14506482 " "44332211
"
[13] "35049122 " "34326340 " "35182366
"
[16] "33288742 " "34958795 " "1017147202
"
[19] "3306985  " "33048501 " "33295073
"

I am sending you the x.Rdata file to see if you can
reproduce my problem.

This infomation may be useful:

 sessionInfo()

R version 2.10.0 (2009-10-26) 
x86_64-unknown-linux-gnu 

locale:
 [1] LC_CTYPE=es_CO.UTF-8   LC_NUMERIC=C  
 [3] LC_TIME=es_CO.UTF-8LC_COLLATE=es_CO.UTF-8
 [5] LC_MONETARY=C  LC_MESSAGES=es_CO.UTF-8   
 [7] LC_PAPER=es_CO.UTF-8   LC_NAME=C 
 [9] LC_ADDRESS=C   LC_TELEPHONE=C
[11] LC_MEASUREMENT=es_CO.UTF-8 LC_IDENTIFICATION=C   

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

 R.Version()

$platform
[1] "x86_64-unknown-linux-gnu"
$arch
[1] "x86_64"
$os
[1] "linux-gnu"
$system
[1] "x86_64, linux-gnu"
$status
[1] ""
$major
[1] "2"
$minor
[1] "10.0"
$year
[1] "2009"
$month
[1] "10"
$day
[1] "26"
$`svn rev`
[1] "50208"
$language
[1] "R"
$version.string
[1] "R version 2.10.0 (2009-10-26)"

gcc --version and g++ --verision shows me:

gcc (Ubuntu 4.3.3-5ubuntu4) 4.3.3
Copyright (C) 2008 Free Software Foundation, Inc.
Esto es software libre; vea el código para las condiciones de copia.  NO
hay
garantía; ni siquiera para MERCANTIBILIDAD o IDONEIDAD PARA UN PROPÓSITO
EN
PARTICULAR

When I compile R I use this option in configuration (nothing more)

./configure --enable-R-shlib
make 
sudo make install

At the moment I have 22Gb of swap partition (keeping monitor tracking
the systems is not using it) and 4GB of RAM.

Again, thank you very much for your help.

Kenneth





__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] New vector based on if/else statement within for loop?

2009-10-27 Thread Duncan Murdoch

On 10/27/2009 1:14 PM, Douglas M. Hultstrand wrote:

Hello,

I am trying to create a new vector (w) that is based on comparing two 
vectors (P and Z).  The compaison is simple (I  created a for loop that 
reassigns w based on if statement), all Z values >= 24 and P values <=1, 
w=88 else w=77.   I am not getting the correct results for w, see 
example code below.  Any thoughts or suggestions on the correct  method.


Use ifelse(), not if ... else.  It's ideal for tests like these.



Thank you,
Doug

P <- c(0,1,2,3,4,5,0,1,5)
Z <- c(25,23,28,29,30,31,28,29,22)
w <- P

for (i in length(w)) {


That only sets i to one value, length(w).  You could fix it by

for (i in seq_along(w))

but ifelse() is better:

w <- ifelse( Z >= 24 & P <= 1, 88, 77 )

Duncan Murdoch


if(Z[i]>=24 && P[i]<=1) {
w[i] = 88
} else {
w[i] = 77}
}

d.f <- data.frame(Z,P,w)
d.f
   Z P  w
1 25 0  0
2 23 1  1
3 28 2  2
4 29 3  3
5 30 4  4
6 31 5  5
7 28 0  0
8 29 1  1
9 22 5 77



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


Re: [R] What is the difference between anova {stats} and aov?

2009-10-27 Thread Chuck Cleland
On 10/27/2009 1:06 PM, Peng Yu wrote:
> There are anova {stats} and aov in R. It seems that anova takes an
> object returned by a model fitting function. But I don't see any
> examples for anova. Can somebody give me a simple example on anova?
> What is the difference between anova and aov?

http://finzi.psych.upenn.edu/Rhelp08/2009-January/184619.html

fm1 <- aov(breaks ~ tension + wool, data=warpbreaks)
fm2 <- aov(breaks ~ tension * wool, data=warpbreaks)

anova(fm1)
anova(fm2)
anova(fm1, fm2)

  See ?anova.lm and ?anova.glm for more anova() examples.

> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Stack overflow in R 2.10.0 with sub()

2009-10-27 Thread Duncan Murdoch

On 10/27/2009 1:05 PM, Kenneth Roy Cabrera Torres wrote:

Thank you very much for your interest.

I make this:
x <- as.character(alumnos$AL_NUME_ID)
x <- x[-seq_len(length(x)/2)]
save(x, file="x.RData")

I exit form R, and then restart R and I make this:

load("x.RData")
y <- gsub("(^ +)|( +$)","",x)

It shows me:

Error en gsub("(^ +)|( +$)", "", x) : 
  input string 66644 is invalid in this locale


I'm working on Windows, so I don't have the locale problem, but I do get 
the segfault.  I'll see if I can track down what is going wrong.


Duncan Murdoch


I delete that string (it is a string with a non usual character (Ñ))

So, I retype without that observation.

y <- gsub("(^ +)|( +$)","",x[-c(66644)])

I got this:
Error en gsub("(^ +)|( +$)", "", x[-c(66644)]) : 
  input string 160689 is invalid in this locale


I retype again with this invalid string this way (I use the
  160690 position, because the lag of the x vector)


y <- gsub("(^ +)|( +$)","",x[-c(66644,160690)])

Error: C produce desborde de pila en 'segfault'

And it fails.

I also repeat all the process with this conversion first.

x <- iconv(as.character(alumnos$AL_NUME_ID),"latin1","UTF-8")
x <- x[-seq_len(length(x)/2)]
save(x, file="x.RData")

And I exit, and restart R, and then I type

load("x.RData")
y <- gsub("(^ +)|( +$)","",x)

And it fails again without showing me the "invalid string" errors.

I then make this:

 load("x.RData")
 y <- gsub("(^ +)|( +$)","",x[1:160690])

and it works, then I type

 y <- gsub("(^ +)|( +$)","",x[1:20]) #(x length is 454035)

and it works...

But I start to make a manual binary search,
I found something that stills puzzle me.

y <- gsub("(^ +)|( +$)","",x[1:261570])

works, but sometimes fails (after I restart R),
it always fails with index greather than 262000.

I see that there are not something inusual arround 261570.

x[261560:261580]
 [1] "21444777 " "1147585  " "255202522
"
 [4] "25852100 " "24258550 " "A8D0251207
"
 [7] "34681811 " "19121345 " "16921329
"
[10] "20442195 " "14506482 " "44332211
"
[13] "35049122 " "34326340 " "35182366
"
[16] "33288742 " "34958795 " "1017147202
"
[19] "3306985  " "33048501 " "33295073
"

I am sending you the x.Rdata file to see if you can
reproduce my problem.

This infomation may be useful:

 sessionInfo()

R version 2.10.0 (2009-10-26) 
x86_64-unknown-linux-gnu 


locale:
 [1] LC_CTYPE=es_CO.UTF-8   LC_NUMERIC=C  
 [3] LC_TIME=es_CO.UTF-8LC_COLLATE=es_CO.UTF-8
 [5] LC_MONETARY=C  LC_MESSAGES=es_CO.UTF-8   
 [7] LC_PAPER=es_CO.UTF-8   LC_NAME=C 
 [9] LC_ADDRESS=C   LC_TELEPHONE=C
[11] LC_MEASUREMENT=es_CO.UTF-8 LC_IDENTIFICATION=C   


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


 R.Version()

$platform
[1] "x86_64-unknown-linux-gnu"
$arch
[1] "x86_64"
$os
[1] "linux-gnu"
$system
[1] "x86_64, linux-gnu"
$status
[1] ""
$major
[1] "2"
$minor
[1] "10.0"
$year
[1] "2009"
$month
[1] "10"
$day
[1] "26"
$`svn rev`
[1] "50208"
$language
[1] "R"
$version.string
[1] "R version 2.10.0 (2009-10-26)"

gcc --version and g++ --verision shows me:

gcc (Ubuntu 4.3.3-5ubuntu4) 4.3.3
Copyright (C) 2008 Free Software Foundation, Inc.
Esto es software libre; vea el código para las condiciones de copia.  NO
hay
garantía; ni siquiera para MERCANTIBILIDAD o IDONEIDAD PARA UN PROPÓSITO
EN
PARTICULAR

When I compile R I use this option in configuration (nothing more)

./configure --enable-R-shlib
make 
sudo make install


At the moment I have 22Gb of swap partition (keeping monitor tracking
the systems is not using it) and 4GB of RAM.

Again, thank you very much for your help.

Kenneth







__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] New vector based on if/else statement within for loop?

2009-10-27 Thread Douglas M. Hultstrand

Hello,

I am trying to create a new vector (w) that is based on comparing two 
vectors (P and Z).  The compaison is simple (I  created a for loop that 
reassigns w based on if statement), all Z values >= 24 and P values <=1, 
w=88 else w=77.   I am not getting the correct results for w, see 
example code below.  Any thoughts or suggestions on the correct  method.


Thank you,
Doug

P <- c(0,1,2,3,4,5,0,1,5)
Z <- c(25,23,28,29,30,31,28,29,22)
w <- P

for (i in length(w)) {
   if(Z[i]>=24 && P[i]<=1) {
   w[i] = 88
   } else {
   w[i] = 77}
}

d.f <- data.frame(Z,P,w)
d.f
  Z P  w
1 25 0  0
2 23 1  1
3 28 2  2
4 29 3  3
5 30 4  4
6 31 5  5
7 28 0  0
8 29 1  1
9 22 5 77

--
-
Douglas M. Hultstrand, MS
Senior Hydrometeorologist
Metstat, Inc. Windsor, Colorado
voice: 970.686.1253
email: dmhul...@metstat.com
web: http://www.metstat.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] lasso plot using LARS

2009-10-27 Thread Russell Ivory
When plotting a lars object, I cannot find a way to plot solid lines.
Even when the arguments breaks=F and lty="solid" are used, the vertical
lines at the break points do not plot but asterisks indicating the
breaks still plot as part of each path leaving solid lines broken up by
asterisks at the break points.  I'm using the following code.

 

larsfit <- lars(X,y,type="lasso")

larsfit

plot(larsfit,breaks=F,lty="solid")

 

Any suggestions in removing the asterisks and plotting truly solid
lines?

 

Thanks

 

Russell Ivory

AVP Senior Modeling Manager

Merrick Bank

10705 South Jordan Gateway

South Jordan, UT 84095

801 545-6640 office

801 545-6340 fax

 

 

 

 

This
 e-mail and any files transmitted with it are confidential and are intended 
solely for the use of the individual or entity to whom it is addressed. If you 
are not the intended recipient or the person responsible for delivering the 
e-mail to the intended recipient, be advised that you have received this e-mail 
in error, and that any use, dissemination, forwarding, printing, or copying of 
this e-mail is strictly prohibited. If you received this e-mail in error, 
please return the e-mail to the sender at Merrick Bank and delete it from your 
computer. Although Merrick Bank attempts to sweep e-mail and attachments for 
viruses, it does not guarantee that either are virus-free and accepts no 
liability for any damage sustained as a result of viruses.

[[alternative HTML version deleted]]

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


[R] How to express a tree?

2009-10-27 Thread Hesen Peng
Hello everybody,

I'm write a function whose output represents a tree. Can anyone please
recommend me some data structure in R which are good for expressing a
tree? The possible idea I'm having in my mind is to represent the
whole tree as a list in which a sublist (an element to the main list)
contains all its corresponding branches. Is there any simpler way of
doing this? Thank you very much.

Best wishes,

-- 
Hesen Peng
http://hesen.peng.googlepages.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] What is the difference between anova {stats} and aov?

2009-10-27 Thread Peng Yu
There are anova {stats} and aov in R. It seems that anova takes an
object returned by a model fitting function. But I don't see any
examples for anova. Can somebody give me a simple example on anova?
What is the difference between anova and aov?

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

2009-10-27 Thread Lorenzo Isella

Dear All,
Apologies if my questions are too basic for this list.
I am given a set of data corresponding to list of detection times (real, 
non-integer numbers in general) for some events, let us say nuclear 
decays to fix the ideas.

It is a small dataset, corresponding to about 400 nuclear decay times.
I would like to test the hypothesis that these decay times are 
Poissonian-distributed.
What is the best day of dealing with the data? Should I consider the 
cumulative number of detections vs time, the time intervals between two 
consecutive detections vs time or something else?

Many thanks

Lorenzo

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

2009-10-27 Thread Sebastien Bihorel

Hi Baptisti,

Sorry for the late reply. I wanted to thank you for putting me on the 
right track. I finally got something to work not really by extracting 
the legend from a xyplot call, but by building my own legend grid.frame 
and passing it to my low-level function. Understanding Grobs and 
grid.pack took me some time, but now, it is working like a charm.


Thank again to you (and to Paul Murrell for the grid package!)

Sebastien

baptiste auguie wrote:

Hi,

I don't know if it helps, but looking at the output of xyplot you can
extract the legend (a grid.frame) as follows,

library(grid)
library(lattice)

p = xyplot(x~y, group=x,data=data.frame(x=1:10,y=1:10),
auto.key=list(space="right"))
legend = with(p$legend$right, do.call(lattice:::drawSimpleKey, args))
grid.draw(legend)

and lattice::draw.key might also help if you need to customize the legend.


HTH,

baptiste


2009/10/22 Sebastien Bihorel :
  

Dear R-Users,

I would like to have the opinion of the list on the following matter. I have
this generic function that creates multiple lattice scatterplots per page
based upon different subsets of the same dataset. The use of different
line/point colors/symbols  in each plot is based upon a 'group' variable',
which is the same for all plots. My goal is to create a main legend per
page:
1- because the 'group' variable' is the same for all plots, one legend per
page is sufficient;
2- because the subset of data used for a particular scatterplot does not
have to contain all unique elements of the group variable in the whole
dataset, the graphical settings need to be adjusted for each plot based upon
a general list of settings created from the whole dataset prior to the
creation of the plots;
3- for the same reason, I cannot use the key argument of xyplot to create a
legend from the first scatterplot.

Another piece of info is that this generic function could be used to create
very different categories of graphs, which each require a different legend
design.

At the moment, I am creating the legend based upon the general graph
settings and the category of plot. Prior to the creation of the graphs, I
store grid objects (text, point, line, or rectangle) into a list, with also
some information about the number of lines that the legend will use, and the
category of the plot. After the plots are printed to the device, I open a
 viewport at the bottom of my page and split it according to the type of the
graph and the number of lines it needs. Finally, I just loop through the
content of the list and draw the grid objects.

Overall, this is all fine but a bit 'brute force'. Also the final
'open-a-viewport-and-draw-inside' step is a big messy code within a generic
graph function, because one specific piece of code is needed per category of
plot, and because of additional subtleties (conditional argument, etc... )

Based upon the behavior of the xyplot function, I understand that it would
be possible to store the fully formatted legend directly at its creation and
then just 'print' the stored object within my legend viewport. Could anybody
advise me on the process to follow to accomplish that or maybe a few
functions to look at?

As always, any help would be greatly appreciated.

Sebastien

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

2009-10-27 Thread Uwe Ligges



Duncan Murdoch wrote:

On 10/27/2009 10:56 AM, Ulrike Groemping wrote:



Duncan Murdoch-2 wrote:


Ulrike Groemping wrote:
...

My system is Windows XP, German locale computer. On installation, I was
asked to decide for text or html help and chose html (there was no 
radio
button for chm help).  

...

If you set

options(help_type="html")

you'll get HTML help with links in your default browser.

Duncan Murdoch




Thank you very much, this works. But I am very surprised that it is 
not the
default. Having chosen html help during installation, I would have 
expected

this to be active without having to change an option.


Yes, it should have been, but there was a bug in the installer, and the 
preference indicated there was ignored. This is why it's useful to have 
people doing testing during the beta test period:  things like this are 
easy to fix, but they need to be noticed first.



And let me add:

The whole statistics department has been on two pre-release versions 
(beta and release-candidate) and nobody reported any error. The 
installer problem has not been found because I installed from sources 
anyway. This shows it makes sense to have more than just 400+ beta 
testers. ;-)


Uwe




Duncan Murdoch

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html

and provide commented, minimal, self-contained, reproducible code.


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


Re: [R] User input when running R code in batch mode

2009-10-27 Thread Bernd Kreuss
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Kaushik Krishnan wrote:
> Is there any way to make R stop for the user to enter values when
> running in batch mode either by changing the way I invoke scan() or
> readLines() or by using any other function?

At least on linux this works:

be...@t40:~/r-test $ cat test.R

readline2 = function(prompt=""){
cat(prompt)
readLines("stdin", 1)
}

print(readline2("enter a number: "))

be...@t40:~/r-test $ Rscript test.R
enter a number: 42
[1] "42"


-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iD8DBQFK5xUSxT6R4jlFoh0RAkhTAKCB4qUjPlULL9vjUaLLxarTor2z1QCeNGHA
4B2VmkqtyEKMKKGUnt8sjiY=
=VYJs
-END PGP SIGNATURE-

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