Re: [R] Are there free R webinar recordings somewhere ?

2009-12-07 Thread Tal Galili
Thanks D .




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




On Mon, Dec 7, 2009 at 11:31 PM, D Kelly O'Day wrote:

>
> Tal
>
> I have a series of basic introduction tutorials for new R users at this
> link.
>
> http://processtrends.com/Learn_R_Toolkit.htm
> http://processtrends.com/Learn_R_Toolkit.htm
>
>
> These videos are geared to Excel users who want to learn about R and see it
> in action.
>
> D Kelly O'Day
> http://procestrends.com
> http://chartsgraphs.wordpress.com
>
>
>
>
> Tal Galili wrote:
> >
> > Hi all,
> > A friend just sent me this:
> >
> http://www.mathworks.com/company/events/webinars/index.html?id=&language=en
> > <
> http://www.mathworks.com/company/events/webinars/index.html?id=&language=en
> >And
> > asked me if there is something of the like in the R community.
> > Does anyone know of such a think ?
> >
> > Cheers,
> > Tal
> >
> >
> > Contact
> > Details:---
> > Contact me: tal.gal...@gmail.com |  972-52-7275845
> > Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
> > www.r-statistics.com/ (English)
> >
> --
> >
> >   [[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> > http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
> >
>
> --
> View this message in context:
> http://n4.nabble.com/Are-there-free-R-webinar-recordings-somewhere-tp954706p954772.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


Re: [R] How to get last day of a month?

2009-12-07 Thread Alex Brussee

To get the last day of the month, I used the following statement:

as.Date(format(as.Date(format(as.Date("20090323","%Y%m%d"), "%Y%m01"),
"%Y%m%d")+31,"%Y%m01"), "%Y%m%d")-1

Of course, "20090323" is the original mmdd input date here. It's not
very sophisticated, but gets the job done in a simple way


Diethelm Wuertz wrote:
> 
> jim holtman wrote:
> 
> just use timeDate from Rmetrics, there you will find several functions 
> like ...
> 
> #  timeLastDayInMonthComputes the last day in a given month and
> year
> #  timeFirstDayInMonth   Computes the first day in a given month and 
> year
> #  timeLastDayInQuarter  Computes the last day in a given quarter 
> and year
> #  timeFirstDayInQuarter Computes the first day in a given quarter 
> and year
> 
> #  timeNthNdayInMonthComputes n-th ocurrance of a n-day in 
> year/month
> #  timeLastNdayInMonth   Computes the last n-day in year/month
> 
> and many more ...
> 
> Diethelm Wuertz
> 
> 
>> Does this help.  Shows how to use the basic functions to get at the
>> answer:
>>
>>   
>>> # add first day of month to make it valid
>>> x <- as.POSIXct(paste('1', 'sep2009', sep=''), format="%d%b%Y")
>>> # now advance one month and then go back one day for the end of the
>>> month
>>> next.mon <- seq(x, length=2, by='1 month')[2]
>>> last.day <- seq(next.mon, length=2, by='-1 day')[2]
>>> last.day
>>> 
>> [1] "2009-09-30 GMT"
>>   
>>
>>
>> On Sun, Sep 13, 2009 at 2:18 PM, megh  wrote:
>>   
>>> Is there any R function to calculate automatically the last day of a
>>> particular month? For example "sep2009" should be converted to last day
>>> of
>>> September of 2009?
>>>
>>> Thanks
>>> --
>>> View this message in context:
>>> http://www.nabble.com/How-to-get-last-day-of-a-month--tp25425645p25425645.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://n4.nabble.com/How-to-get-last-day-of-a-month-tp890694p955034.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] Help with Nested loop - very slow, can I use an apply?

2009-12-07 Thread Nikhil Kaza

From an old post by Gabor
http://tolstoy.newcastle.edu.au/R/help/04/01/0147.html

  
apply 
(outer 
(landmark_c,t(store_c),"-"),c(1,4),function(x)sqrt(sum(diag(x*x


On 7 Dec 2009, at 10:58PM, dolar wrote:



Hi there

I have two tables, with longitudinal and latitudinal coordinates.  
what I
want is a cross table between each coordinate, to find the distance  
between

each building and different landmarks


I currently have this nested loop which is fine for when i have 10  
stores of

interest, against 200 other landmarks and uses pythagarus to find the
distance


for(i in 1:nrow(store_c)){
landmark_store_cross_tab$foo=landmark_c$landmark_name
for (j in 1:nrow(landmark_c)){
landmark_store_cross_tab[j,i+1]=sqrt((landmark_c$x[j]-store_c$x[i])^2
+(landmark_c$y[j]-store_c$y[i])^2)/1000
}
names(landmark_store_cross_tab)[i+1]=store_c$store_name[i]
}

can someone suggest how I can make this faster?


I am hoping to use one of the apply functions

Thanks

--
View this message in context: 
http://n4.nabble.com/Help-with-Nested-loop-very-slow-can-I-use-an-apply-tp954979p954979.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] Simplex Density Plots

2009-12-07 Thread Duncan Murdoch

On 07/12/2009 11:12 PM, Graham Neubig wrote:

Hello,

I have just started using R, and have found it quite easy to make
plots of probability densities for normal and beta distributions, etc.

Now, I'm looking at trying to make a simplex plot of a Dirichlet
density, but have gotten stuck and was hoping that someone could help.
Ideally, the plot would look something like the 3d plots on Wikipedia here:
http://en.wikipedia.org/wiki/File:Dirichlet_distributions.png

Although if these are impossible, a color-coded 2d simplex would work as well.

Does anyone have an idea or link about how to make simplex plots?


RSiteSearch("simplex") turns up some simplex plots in the klaR package; 
I don't know if they're the sort you want.


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 with Nested loop - very slow, can I use an apply?

2009-12-07 Thread dolar

Hi there

I have two tables, with longitudinal and latitudinal coordinates. what I
want is a cross table between each coordinate, to find the distance between
each building and different landmarks


I currently have this nested loop which is fine for when i have 10 stores of
interest, against 200 other landmarks and uses pythagarus to find the
distance


for(i in 1:nrow(store_c)){
landmark_store_cross_tab$foo=landmark_c$landmark_name
for (j in 1:nrow(landmark_c)){
landmark_store_cross_tab[j,i+1]=sqrt((landmark_c$x[j]-store_c$x[i])^2
+(landmark_c$y[j]-store_c$y[i])^2)/1000
}
names(landmark_store_cross_tab)[i+1]=store_c$store_name[i]
}

can someone suggest how I can make this faster?


I am hoping to use one of the apply functions

Thanks

-- 
View this message in context: 
http://n4.nabble.com/Help-with-Nested-loop-very-slow-can-I-use-an-apply-tp954979p954979.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] Serial Correlation in panel data regression

2009-12-07 Thread sayan dasgupta
Dear R users,
I have a question here

library(AER)
library(plm)
library(sandwich)
## take the following data
data("Gasoline", package="plm")
Gasoline$f.year=as.factor(Gasoline$year)

Now I run the following regression

rhs <- "-1 + f.year + lincomep+lrpmg+lcarpcap"
m1<- lm(as.formula(paste("lgaspcar ~", rhs)), data=Gasoline)
###Now I want to find the autocorrelation,heteroskedasticity adjusted
standard errors as a part of coeftest
### Basically I would like to take care of the within country serial
correlaion

###that is I want to do
coeftest(m1, vcov=function(x) vcovHAC(x,order.by=...))

Please suggest what should be the argument of order.by and whether that will
give me the desired result

[[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] Simplex Density Plots

2009-12-07 Thread Graham Neubig
Hello,

I have just started using R, and have found it quite easy to make
plots of probability densities for normal and beta distributions, etc.

Now, I'm looking at trying to make a simplex plot of a Dirichlet
density, but have gotten stuck and was hoping that someone could help.
Ideally, the plot would look something like the 3d plots on Wikipedia here:
http://en.wikipedia.org/wiki/File:Dirichlet_distributions.png

Although if these are impossible, a color-coded 2d simplex would work as well.

Does anyone have an idea or link about how to make simplex plots?

Thanks in advance,
Graham

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

2009-12-07 Thread Airey, David C
In using SSfpl() recently with nlsList(), I came across a data set of mine that 
failed, because the call to nls() inside SSfpl() exceeded 50 iterations. 
nlsList converges with my own starting values and extra allowed iterations. Has 
anyone else experienced this with SSfpl() and what do you do about this if you 
want to use SSfpl()? How do you give SSfpl() a chance at more iterations? Do I 
rewrite SSfpl() with use of control=list(maxiter=1000)?
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] lm: RME vs. ML

2009-12-07 Thread John Sorkin
windows XP
R 2.10

As pointed out by Prof. Venables and Ripley (MASS 4th edition, p275), the 
results obtained from lme using method="ML" and method="REML" are often 
different, especially for small datasets. Is there any way to determine which 
method is preferable for a given set of data?
Thanks,
john


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

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

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


Re: [R] R-squared for ANOVA model

2009-12-07 Thread David Winsemius


On Dec 7, 2009, at 8:12 PM, ZeMajik wrote:


Hey,

In SAS after doing an ANOVA you also get the aptness of fit as R- 
squared in

the ANOVA table.
I've tried getting the R-squared from R but have failed miserably.  
I've

tried searching google and the manual as well

Is it possible to extract R-squared from ANOVA models in R?


Part of the help page for lm() suggests that you also look at:

?summmary.lm

--

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] Multiple regression script

2009-12-07 Thread GlenB


Joel Fürstenberg-Hägg said:
"Multiple linear regression [...] I would like to check every possible
combination of factors, evalute the results based for instance on their p
values, and then choose the best regression model."

By "every possible combination of factors", I assume you mean that for k
factors, you want
to consider all 2^k models where each factor is either present in the model
or absent from it
as a main effect, (or do you mean to include interactions as well?),
selected by p-value?

Speaking from a statistical practice point of view, this is probably not a
good idea.

If you really want to do a "best subset" type regression, there's the
package bestglm at CRAN.
http://cran.r-project.org/web/packages/bestglm/index.html - it doesn't do it
by p-values
and if your factors have more than two levels it does it via complete
enumeration rather
than using something efficient like the leaps and bounds algorithm, but it's
close to the
sort of thing you want.

Doubtless there are other packages that also implement this sort of
exhaustive model selection.

-- 
View this message in context: 
http://n4.nabble.com/Multiple-regression-script-tp954567p954940.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] {Lattice} help.

2009-12-07 Thread Xin Ge
Hi All,

I have a 4-dimensional data. I'm using barchart() function from lattice
package. The R code and data are below - code includes one for stack=TRUE
and other for stack=FALSE.

I would like to present the data in another form which would be plotting
Factor3 levels (P, Q, R, S) as two stacked bars (side by side). Like, for
each level of Factor1 there should be two bars: first bar showing stacked
values of "P" and "Q" and the adjacent bar showing stacked values of "R" and
"S". Is it possible using barchart() function?

OR, if someone can give me some suggestions on the best way to present
such data. Any help would be highly appreciated.

# Reading data in object "foo"

barchart(foo$Value ~ foo$Factor1 | foo$Factor2, data = foo,
 groups = foo$Factor3, stack = TRUE,
 auto.key = list(points = FALSE, rectangles = TRUE, space =
"right"))
barchart(foo$Value ~ foo$Factor1 | foo$Factor2, data = foo,
 groups = foo$Factor3, stack = FALSE,
 auto.key = list(points = FALSE, rectangles = TRUE, space =
"right"))

# Data

Factor1Factor2Factor3Value
AXP10
AXQ20
AXR10
AXS20
AYP20
AYQ5
AYR20
AYS5
BXP  20
BXQ10
BXR20
BXS10
BYP30
BYQ50
BYR30
BYS50
Thanks,
~Xin

[[alternative HTML version deleted]]

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


[R] data manipulation/subsetting and relation matrix

2009-12-07 Thread Juliet Hannah
Hi List,

Here is some example data.

myDat <- read.table(textConnection("group id
1 101
1 201
1 301
2 401
2 501
2 601
3 701
3 801
3 901"),header=TRUE)
closeAllConnections()

corr_mat <-read.table(textConnection("1 1   .5  0   0   0   0   0   0   0
2 .5   1  0   0   0   0   0   0   0
3 00  1.0   0   0   0   0   0   0
4 00  0   1   .5  .5  0   0   0
5 00  0   .5  1.5  0   0   0
6 00  0   .5  .5   1 00   0
7 00  0   00   0  1   0  0
8 0   0   0   00   0   0  1  .5
9 0   0   0   0   00   0  .5 1"),header=FALSE)
closeAllConnections()

corr_mat <- corr_mat[,-1]
colnames(corr_mat) <- myDat$id
rownames(corr_mat) <- myDat$id

I need to subset this data such that observations within a group are not
related, which is indicated by a 0 in corr_mat.

For example, within group 1, 101 and 201 are related, so one of these
has to be selected, say
101. 301 is not related to 101 or 201, so the final set for group 1
consists of 101 and 301. There will always be at least 2 members in
each group. I need to carry this task on all groups.

One possible final data set looks like:

  group  id
1 1 101
3 1 301
4 2 401
7 3 701
8 3 801

Any suggestions? Thanks!

Juliet

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


Re: [R] Starting estimates for nls Exponential Fit

2009-12-07 Thread dave fournier
Thanks to Dennis Murphy who pointed out that ExponCycles
is undefined. It is an R gotcha. I had shortened the name but R still
remembered it so the script worked but only on my computer.
This should fix that.

ExponValues=c(2018.34,2012.54,2018.85,2023.52,2054.58,2132.61,2247.17,2468.32,27
78.47)
Expon=c(17,18,19,20,21,22,23,24,25)
# Example starting estimate calculation
E=1000.0
y1=2018
yn=2778.47
nobs=9


#keep y1 and yn fixed and get initial value for E
Esp1 <- optim(c(E=E),method ="BFGS",
  function(x)
  {
E=x[1]
a=(yn-y1)/(E^Expon[nobs]-E^Expon[1])
Y0=y1-a*E^Expon[1];
diff=ExponValues-(Y0+a*E^Expon)
return(1000*sum(diff*diff))
  })$par

E=Esp1[1]

Esp <- optim(c(y1=y1,yn=yn,E=E),method ="BFGS",
  function(x)
  {
E=x[3]
a=(x[2]-x[1])/(E^Expon[nobs]-E^Expon[1])
Y0=x[1]-a*E^Expon[1];
diff=ExponValues-(Y0+a*E^Expon)
return(1000*sum(diff*diff))
  })$par

y1=Esp[1]
y2=Esp[2]
E=Esp[3]

a=(y2-y1)/(E^Expon[nobs]-E^Expon[1])
Y0=y1-a*E^Expon[1];




-- 
David A. Fournier
P.O. Box 2040,
Sidney, B.C. V8l 3S3
Canada
Phone/FAX 250-655-3364
http://otter-rsch.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] R-squared for ANOVA model

2009-12-07 Thread ZeMajik
Hey,

In SAS after doing an ANOVA you also get the aptness of fit as R-squared in
the ANOVA table.
I've tried getting the R-squared from R but have failed miserably. I've
tried searching google and the manual as well

Is it possible to extract R-squared from ANOVA models in R?

[[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] Label individual points in lattice by and ID

2009-12-07 Thread Felix Andrews
xyplot(y~x | f1 + f2, data= dat,
groups=ID,
type="l",
panel= function(x, y,groups, subscripts, ...){
panel.xyplot(x, y, groups = groups, subscripts = subscripts, ...)
panel.text(x, y, groups[subscripts])
})


2009/12/8 Pat Schmitz :
> Thanks
>
> This works, but I lose the ability to say plot a line by group connecting
> the numbered points,
> how do I recover this, or say color the groups by ID..
>
> xyplot(y~x | f1 + f2, data= dat,
> groups=ID,
> type="l",
> panel= function(x, y,groups, subscripts, ...){
>     panel.text(x, y, groups[subscripts])
>     })
>
> Pat
>
> On Mon, Dec 7, 2009 at 3:18 AM, Felix Andrews  wrote:
>>
>> If you want to plot each point as the text of its ID, use a panel
>> function:
>> panel = function(x, y, groups, subscripts, ...) panel.text(x, y,
>> groups[subscripts])
>>
>> If you want to add labels interactively to selected points:
>> xyplot(y~x | f1 + f2, groups=ID,dat)
>> ## repeat for each panel:
>> trellis.focus(); panel.identify(); trellis.unfocus()
>>
>>
>> 2009/12/7 Pat Schmitz :
>> > Sorry.  My previous code didn't quite display my problem correctly.  To
>> > make
>> > my point more clear, I want to use my "groups" as the label for the
>> > point,
>> > or rather the point itself.  The key becomes illegible with many groups.
>> >
>> > x<-as.factor(1:5)
>> > y<-rnorm(1:10)
>> > f1<-c("a","b")
>> > f2<-c("x","y")
>> >
>> > dat<-expand.grid(x=x, y=y, f1=f1, f2=f2)
>> > dat$ID <- 1:dim(dat)[1]
>> >
>> > xyplot(y~x | f1 + f2, groups=ID,dat)
>> >
>> > xyplot(y~x | f1 + f2, groups=ID,auto.key=TRUE,dat)  # more accurate rep
>> > of
>> > problem with key
>> >
>> >
>> > Thanks
>> > Pat
>> >
>> >
>> > On Sun, Dec 6, 2009 at 9:58 PM, Pat Schmitz 
>> > wrote:
>> >
>> >> I am using a plot to inspect data points, and I would like to identify
>> >> each
>> >> point with respect to an ID. At issue is that I am producing a faceted
>> >> plot
>> >> with many IDs (96) and the key is far to large to accurately identify
>> >> points
>> >> by color.
>> >>
>> >> 1) Can you direct me on labeling or printing data points by an ID
>> >> instead
>> >> of a point, as in "ID" in this toy example
>> >> 2) alternately is there method for printing a key for each panel which
>> >> shows only those IDs which appear in the panel at hand?
>> >>
>> >> x<-as.factor(1:5)
>> >> y<-rnorm(1:10)
>> >> ID<-1:5
>> >> f1<-c("a","b")
>> >> f2<-c("x","y")
>> >>
>> >> dat<-expand.grid(x=x, y=y, id=ID, f1=f1, f2=f2)
>> >>
>> >> xyplot(y~x | f1 + f2, dat)
>> >>
>> >>
>> >>
>> >> Thanks
>> >> Pat
>> >>
>> >> --
>> >> Patrick Schmitz
>> >> Graduate Student
>> >> Plant Biology
>> >> 1206 West Gregory Drive
>> >> RM 1500
>> >>
>> >
>> >
>> >
>> > --
>> > Patrick Schmitz
>> > Graduate Student
>> > Plant Biology
>> > 1206 West Gregory Drive
>> > RM 1500
>> >
>> >        [[alternative HTML version deleted]]
>> >
>> > __
>> > R-help@r-project.org mailing list
>> > https://stat.ethz.ch/mailman/listinfo/r-help
>> > PLEASE do read the posting guide
>> > http://www.R-project.org/posting-guide.html
>> > and provide commented, minimal, self-contained, reproducible code.
>> >
>>
>>
>>
>> --
>> Felix Andrews / 安福立
>> Postdoctoral Fellow
>> Integrated Catchment Assessment and Management (iCAM) Centre
>> Fenner School of Environment and Society [Bldg 48a]
>> The Australian National University
>> Canberra ACT 0200 Australia
>> M: +61 410 400 963
>> T: + 61 2 6125 4670
>> E: felix.andr...@anu.edu.au
>> CRICOS Provider No. 00120C
>> --
>> http://www.neurofractal.org/felix/
>
>
>
> --
> Patrick Schmitz
> Graduate Student
> Plant Biology
> 1206 West Gregory Drive
> RM 1500
>



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

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


Re: [R] Starting estimates for nls Exponential Fit

2009-12-07 Thread dave fournier

I thought maybe my suggestion for reparameterizing this simple problem
was ignored because I didn't supply R code for the problem.
Here it is using optim for the optimization. It converges trivially with
an initial value for E of 1000.
As I stated before, there is nothing at all difficult about this
problem. You simply need to parameterize it properly. Of course that is
not to say that rescaling is not useful as well, but the important thing
is to parameterize the model properly.

ExponValues=c(2018.34,2012.54,2018.85,2023.52,2054.58,2132.61,2247.17,2468.32,27
78.47)
Expon=c(17,18,19,20,21,22,23,24,25)
# Example starting estimate calculation
E=1000.0
y1=2018
yn=2778.47
nobs=9


#keep y1 and yn fixed and get initial value for E
Esp1 <- optim(c(E=E),method ="BFGS",
  function(x)
  {
E=x[1]
a=(yn-y1)/(E^Expon[nobs]-E^Expon[1])
Y0=y1-a*E^Expon[1];
diff=ExponValues-(Y0+a*E^ExponCycles)
return(1000*sum(diff*diff))
  })$par

E=Esp1[1]

Esp <- optim(c(y1=y1,yn=yn,E=E),method ="BFGS",
  function(x)
  {
E=x[3]
a=(x[2]-x[1])/(E^Expon[nobs]-E^Expon[1])
Y0=x[1]-a*E^Expon[1];
diff=ExponValues-(Y0+a*E^ExponCycles)
return(1000*sum(diff*diff))
  })$par

y1=Esp[1]
y2=Esp[2]
E=Esp[3]

a=(y2-y1)/(E^Expon[nobs]-E^Expon[1])
Y0=y1-a*E^Expon[1];





-- 
David A. Fournier
P.O. Box 2040,
Sidney, B.C. V8l 3S3
Canada
Phone/FAX 250-655-3364
http://otter-rsch.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] histbackback function

2009-12-07 Thread Katie N

Hi,
I'm trying to recreate a sensitivity-specificity graph using the
histbackback function.  The only problem is that these graphs are typically
drawn with vertical rather than horizontal bar plots (and the histbackback
function only seems to work with horiz=TRUE argument, using "horiz=FALSE"
doesn't work).  Does anyone know if:
1) there's a different graphing function that would accomplish this graph?
2) if there isn't, is there a way to rotate the graph 90 degrees clockwise?
3) with the histbackback function, is there a way to display percent instead
of proportion on the x-axis?
4) with the histbackback function, is there a way to set the width of the
bins (ie I want bars in increments of 10 or 20 instead of 50 , "bin=10"
didn't work)
5) with the histbackback function, is there a way to display the y-axis
values where the two histograms are back to back, rather than on the y-axis?

Below, I've pasted the graph that I'm trying to recreate, as well as the
code and graph from my current (unsuccessful) attempt.  

options(digits=1)
require(Hmisc)
out <- histbackback(split(data8$TB144, data8$PRES), probability=TRUE,
main="Back to Back Histogram", ylab="TB144 1min rates")
barplot(-out$left, col="ivory2", horiz=TRUE, space=0, add=TRUE, axes=FALSE)
barplot(out$right, col="ivory4", horiz=TRUE, space=0, add=TRUE, axes=FALSE)
grid(nx=NULL, ny = NULL, col = "lightgray", lty = "dotted", lwd =
par("lwd"), equilogs = TRUE)

http://n4.nabble.com/file/n954888/sens-spec%2Bgraph.jpg 

http://n4.nabble.com/file/n954888/back-to-back%2Bhistogram%2B2.jpg 

Thanks!
Katie
-- 
View this message in context: 
http://n4.nabble.com/histbackback-function-tp954888p954888.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] multiple plots using summary in rms package

2009-12-07 Thread Frank E Harrell Jr

Mike,

You are not using rms functions in your example; you are using Hmisc's 
summary.formula function and its plot method.  For method='reverse', 
multiple plots may be produced by the plot method so par(mfrow=c( )) is 
not well defined.  There is also a problem with the dotchart2 function 
(called by plot.summary.formula.reverse) in this context, as it wants to 
call plot.new().


Frank

Mike Babyak wrote:

Dear All,

I wonder if someone can point me in the right direction here.  I'm working
with the rms library, R 2.9.2 under Windows XP.

I'm trying to arrange two plots side by side for a colleague.  mfrow or
mfcol do not seem to work, however, so I am obviously missing something
important.  I know that there have been changes in the graphics from Design
to rms, but am just not sure where to find specific documentation about this
particular issue.

Below is the code I'm using.  If I run the code except for the last plot
call, the first plot is correctly produces in the first column with empty
space for the second plot in col 2.  But when I add the second plot call, it
just overwrites the first plot in col1 on the left.

If I run the code below using something like plot(x~y) and plot(a~b) instead
of the two rms summary objects, it works fine, so I am assuming there is
something about rms I am missing.

I'd be happy to provide some data if that would help.

Any guidance would be greatly appreciated.

Thanks,

Mike Babyak
Duke University Medical Center



#summary of dietary variables broken out by Groups A, B, and C
sumfc<-summary(Group~fcgrain+fcveg+fcfruit+fcmeat+fcdairy+fcnsl+
fcfat+fcsatfat+fcsweet+fcsod,
method='reverse', overall=F,  test=F)

sumpc<-summary(Group~pcgrain+pcveg+pcfruit+pcmeat+pcdairy+
pcnsl+pcfat+pcsatfat+pcsweet+pcsod,
method='reverse', overall=F,  test=F)

par(mfcol=c(1,2),oma=c(1,0,4,0))
plot(sumfc, which='categorical',
main='Full Compliance',pch=c('A','B','C'))
 Key(0,-.1)

plot(sumpc, which='categorical',
main='At Least Partial Compliance',pch=c('A','B','C'))
mtitle("Dietary Adherence")



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

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


Re: [R] Regular expression help

2009-12-07 Thread Gabor Grothendieck
If I understand correctly you wish to extract strings of digits more
than 5 characters long:

s <- c("UV7C11-F9-E1 MCS#9831019", "MCS Lot #9512516")
library(gsubfn)
strapply(s, "\\d{6,}", c)

Depending on what you want to get back you might wish to add the
simplify=TRUE argument to strapply, as well.  See
http://gsubfn.googlecode.com


On Mon, Dec 7, 2009 at 6:04 PM, Ramya  wrote:
>
> Hi  there
>
> I have a string like this i want to extract 9831019 from this string i used
> a regular expresion \d+ by which i can only make it to see 7 and returns.
> This type of number(9831019)  appears in any part of the string and is
> definitely more than 5 digits all the time and i want to give that as a
> condition
>
> UV7C11-F9-E1 MCS#9831019
> MCS Lot #9512516"
>
>
> how do i go abt it
>
> Ramya
> --
> View this message in context: 
> http://n4.nabble.com/Regular-expression-help-tp954834p954834.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] Regular expression help

2009-12-07 Thread Phil Spector

Ramya -
   Try


strings = c('UV7C11-F9-E1 MCS#9831019','MCS Lot #9512516')
sub('^.*?(\\d{5,}).*?$','\\1',strings,perl=TRUE)

[1] "9831019" "9512516"

The regular expression finds the first string of five or 
more numbers in the strings.  Since you said the numbers could
occur anywhere in the string, you could have provided some 
examples where the numbers weren't the last part of the string.


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


On Mon, 7 Dec 2009, Ramya wrote:



Hi  there

I have a string like this i want to extract 9831019 from this string i used
a regular expresion \d+ by which i can only make it to see 7 and returns.
This type of number(9831019)  appears in any part of the string and is
definitely more than 5 digits all the time and i want to give that as a
condition

UV7C11-F9-E1 MCS#9831019
MCS Lot #9512516"


how do i go abt it

Ramya
--
View this message in context: 
http://n4.nabble.com/Regular-expression-help-tp954834p954834.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] Regular expression help

2009-12-07 Thread Marc Schwartz

On Dec 7, 2009, at 5:04 PM, Ramya wrote:



Hi  there

I have a string like this i want to extract 9831019 from this string  
i used
a regular expresion \d+ by which i can only make it to see 7 and  
returns.

This type of number(9831019)  appears in any part of the string and is
definitely more than 5 digits all the time and i want to give that  
as a

condition

UV7C11-F9-E1 MCS#9831019
MCS Lot #9512516"


how do i go abt it

Ramya



Is the double quote actually part of your data or just a typo?

I am not sure that it might matter in the end, but here is one approach:

> x
[1] "UV7C11-F9-E1 MCS#9831019" "MCS Lot #9512516\""

Note that I have the double quote included in the second value, which  
is escaped when printed here.


> gsub("^.*#([0-9]*).*$", "\\1", x)
[1] "9831019" "9512516"


This uses gsub() to extract the value within the parens in the regex  
using a back reference.


Any characters from the beginning of the line to the '#' are dropped,  
as are any characters after the numeric sequence to the end of the line.


See ?gsub for more information.

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] data.frame to "stacked frame"

2009-12-07 Thread Ista Zahn
One option is

library(reshape)
dfr <- melt(dfw, id.vars="group")

-Ista

On Mon, Dec 7, 2009 at 8:20 AM, Christian Schulz  wrote:
> Hi,
>
> have anybody a hint how i could avoid the cumbersome way (..especially the
> value part)
> change the data representation from  n column data.frame to an stacked
> representation.
>
> many thanks
> Christian
>
> #example data
> dfw <- as.data.frame(matrix(runif(10*10),ncol=10))
> dfw$group <- sample(c("X","Z"),nrow(dfw),replace=T,prob=c(0.75,0.25))
>
> # change
> var   <- rep(names(dfw)[-length(dfw)],nrow(dfw))
> group <- rep(dfw$group,nrow(dfw))
>
> #cumbersome
> value <- vector()
> z=1
> for(i in 1:(length(dfw)-1)){
> for(j in 1:nrow(dfw)){
> value[z] <-   dfw[j,i]
> z=z+1
> }
> }
>
> dfr <- cbind(var,group,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.
>



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

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


[R] Regular expression help

2009-12-07 Thread Ramya

Hi  there

I have a string like this i want to extract 9831019 from this string i used
a regular expresion \d+ by which i can only make it to see 7 and returns.
This type of number(9831019)  appears in any part of the string and is
definitely more than 5 digits all the time and i want to give that as a
condition 

UV7C11-F9-E1 MCS#9831019
MCS Lot #9512516"


how do i go abt it

Ramya
-- 
View this message in context: 
http://n4.nabble.com/Regular-expression-help-tp954834p954834.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] RandomForest - getTree status code

2009-12-07 Thread NCS
Not the entire tree - I just selected a few rows.  On the first tree, the only 
status codes I saw were -1 and -3, which makes sense.  I am guessing the final 
tree should never have a status of -2, which looks like an intermediate status, 
unless I am missing something.  Thanks for the response.

ncs



- Original Message 
From: "Liaw, Andy" 
To: NCS ; r-help@r-project.org
Sent: Mon, December 7, 2009 5:46:24 AM
Subject: RE: [R] RandomForest - getTree status code

Is that the entire tree?  If so there's a problem.  The node status is
defined as follows in rf.h of the source code:

#define NODE_TERMINAL -1
#define NODE_TOSPLIT  -2
#define NODE_INTERIOR -3

i.e., "-3" means "non-terminal" node.

Andy


> -Original Message-
> From: r-help-boun...@r-project.org 
> [mailto:r-help-boun...@r-project.org] On Behalf Of NCS
> Sent: Friday, December 04, 2009 4:53 PM
> To: r-help@r-project.org
> Subject: [R] RandomForest - getTree status code
> 
> 
> What does a status value of -3 mean when I do a regression 
> with RF and use the getTree function?
> 
>  left daughter right daughter split var  split point 
> status prediction
> 12  311 4.721000e+03
> -3 15.8489576
> 24  5 5 6.50e+00
> -3 11.3240895
> 36  710 6.790674e+02
> -3 23.7250079
> 48  911 1.562500e+03
> -3  9.6885129
> 5   10 11 7 7.085000e+02
> -3 15.2126457
> 6   12 13 3 1.105000e+02
> -3 22.3736330
> 7   14 1511 2.249400e+04
> -3 37.9011956
> 8   16 17 2 6.805105e+00
> -3  5.0804247
> 9   18 19 7 6.775000e+02
> -3 11.9877469
> 10  20 21 5 1.45e+01
> -3 12.6068710
> 
> Thanks
> ncs
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Announce: edtdbg, integrating R's debug() with your text editor

2009-12-07 Thread Norm Matloff
The files seem to be inaccessible, and I can't see why.  Neither can my
department Web technician.

So, for the time being, simply go to

http://heather.cs.ucdavis.edu/~matloff/R/edtdbg/

and then download the 3 files as directed.

Meanwhile, I've thought of an interesting enhancement, and a couple of
people have made suggestions as well.  I'll post an enhanced version in
a day or so.

Norm

> Date: Sun, 6 Dec 2009 23:39:06 -0800
> From: Norm Matloff 
> Subject: [R] Announce:  edtdbg, integrating R's debug() with your text
>   editor
> To: r-help@r-project.org
> 
> I've just developed edtdbg, a small package that integrates R's debug()
> with one's text editor.
> 
> Excerpt from the README file:
...
> I'm placing the current version of the package at:
> 
> http://heather.cs.ucdavis.edu/~matloff/R/edtdbg/edtdbg.tar.gz
> 
> http://heather.cs.ucdavis.edu/~matloff/R/edtdbg/edtdbg.zip

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


Re: [R] Label individual points in lattice by and ID

2009-12-07 Thread Pat Schmitz
Thanks

This works, but I lose the ability to say plot a line by group connecting
the numbered points,
how do I recover this, or say color the groups by ID..

xyplot(y~x | f1 + f2, data= dat,
groups=ID,
type="l",
panel= function(x, y,groups, subscripts, ...){
panel.text(x, y, groups[subscripts])
})

Pat

On Mon, Dec 7, 2009 at 3:18 AM, Felix Andrews  wrote:

> If you want to plot each point as the text of its ID, use a panel function:
> panel = function(x, y, groups, subscripts, ...) panel.text(x, y,
> groups[subscripts])
>
> If you want to add labels interactively to selected points:
> xyplot(y~x | f1 + f2, groups=ID,dat)
> ## repeat for each panel:
> trellis.focus(); panel.identify(); trellis.unfocus()
>
>
> 2009/12/7 Pat Schmitz :
> > Sorry.  My previous code didn't quite display my problem correctly.  To
> make
> > my point more clear, I want to use my "groups" as the label for the
> point,
> > or rather the point itself.  The key becomes illegible with many groups.
> >
> > x<-as.factor(1:5)
> > y<-rnorm(1:10)
> > f1<-c("a","b")
> > f2<-c("x","y")
> >
> > dat<-expand.grid(x=x, y=y, f1=f1, f2=f2)
> > dat$ID <- 1:dim(dat)[1]
> >
> > xyplot(y~x | f1 + f2, groups=ID,dat)
> >
> > xyplot(y~x | f1 + f2, groups=ID,auto.key=TRUE,dat)  # more accurate rep
> of
> > problem with key
> >
> >
> > Thanks
> > Pat
> >
> >
> > On Sun, Dec 6, 2009 at 9:58 PM, Pat Schmitz 
> wrote:
> >
> >> I am using a plot to inspect data points, and I would like to identify
> each
> >> point with respect to an ID. At issue is that I am producing a faceted
> plot
> >> with many IDs (96) and the key is far to large to accurately identify
> points
> >> by color.
> >>
> >> 1) Can you direct me on labeling or printing data points by an ID
> instead
> >> of a point, as in "ID" in this toy example
> >> 2) alternately is there method for printing a key for each panel which
> >> shows only those IDs which appear in the panel at hand?
> >>
> >> x<-as.factor(1:5)
> >> y<-rnorm(1:10)
> >> ID<-1:5
> >> f1<-c("a","b")
> >> f2<-c("x","y")
> >>
> >> dat<-expand.grid(x=x, y=y, id=ID, f1=f1, f2=f2)
> >>
> >> xyplot(y~x | f1 + f2, dat)
> >>
> >>
> >>
> >> Thanks
> >> Pat
> >>
> >> --
> >> Patrick Schmitz
> >> Graduate Student
> >> Plant Biology
> >> 1206 West Gregory Drive
> >> RM 1500
> >>
> >
> >
> >
> > --
> > Patrick Schmitz
> > Graduate Student
> > Plant Biology
> > 1206 West Gregory Drive
> > RM 1500
> >
> >[[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
>
>
>
> --
> Felix Andrews / 安福立
> Postdoctoral Fellow
> Integrated Catchment Assessment and Management (iCAM) Centre
> Fenner School of Environment and Society [Bldg 48a]
> The Australian National University
> Canberra ACT 0200 Australia
> M: +61 410 400 963
> T: + 61 2 6125 4670
> E: felix.andr...@anu.edu.au
> CRICOS Provider No. 00120C
> --
> http://www.neurofractal.org/felix/
>



-- 
Patrick Schmitz
Graduate Student
Plant Biology
1206 West Gregory Drive
RM 1500

[[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] problem in labeling the nodes of tree drawn by rpart

2009-12-07 Thread kaida ning
Hi all,

I used rpart to fit a model, where the covariates in the model are
categorical variables.
Then I plotted the tree (mytree) and used the command "text" to add labels
to the tree.

In the nodes of the tree, the values of the covariates are represented with
a, b or c.
Is there a way to show the real value(s) of the variable in the nodes
instead of a, b or c ?
I found that the command "labels(mytree,minlength=3)" can give me the
desired label, but I don't know how to add it to the tree.


Best,
Kaida


tree.pdf
Description: Adobe PDF document
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] zelig logit survey

2009-12-07 Thread Frank Lawrence
When I use zelig to compute parameter estimates with "model = logit.survey",
I receive the following error:
Nicholas Carnes. 2007. "logt.surveyWarning message:
In eval(expr, envir, enclose) : non-integer #successes in a binomial glm!

I believe this is because the model is not using "quasibinomial" (see R-News
2003, Analyzing Survey Data in R, by Thomas Lumley).  Is there a way to
change the model to use "quasibinomial"?

Reproducible example:

library(Zelig)
library(survey)
data(api)
z.out <- zelig(form = yr.rnd ~ api00, data = apistrat, model =
'logit.survey', id = ~1, strata = ~ stype, weight = ~pw, fpc = ~fpc)
summary(z.out)

Respectfully,

Frank Lawrence

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] сЛyЖБа PAcCЫЛoK

2009-12-07 Thread Наталия
E-MAIL РАССЫЛКИ
Доступные цены - высокое качество
Наш прайс-лист:

Рассылка по всей Москве - 5 000 руб., 4 рассылки по Всей Москве - 10 000 руб.
Рассылка по всей России - 10 000 руб., 4 рассылки по всей России - 20 000 руб.
Рассылка по России и СНГ - 15 000 руб. , 4 рассылки по России и СНГ - 30 000 
руб.

У нас:
- Самые низкие цены на рынке.
- Самое современное программное обеспечение.
- Регулярно-обновляемые базы email адресов.
- Высокий отклик от рассылок.

Контакты:
Тел.: (Ч95)5О7 2 67З 
ICQ: 5-975-2209-7

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


Re: [R] SAS

2009-12-07 Thread Jonathan Lisic
Marshall Feldman  uri.edu> writes:

> 
> Regarding the various methods people have suggested, what if a typical 
> tab-delimited data line looks like:
> 
>   SMS11001 1990 M01 688.0
> 
> and the SAS INPUT statement is
> 
> INPUT survey $ 1-2 seasonal $ 3 state $ 4-5 area $ 6-10 supersector 
> $ 11-12 @13 industry $8. datatype $ 21-22  year period $ value footnote $ ;
> 
> Note that most data lines have no footnote item, as in the sample.
> 
> Here (I think) we'd want all the character variables to be read as 
> factors, possibly "year" as a date, and "value" as numeric.
> 
> Marsh


Hi Marshall, 

Maybe I'm missing the point, but wouldn't read.fwf do most of what you want?

Cheers,

Jonathan

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


Re: [R] yeroon.net/ggplot2 web application v0.11

2009-12-07 Thread Jeroen Ooms
Hi Felipe,

my apps are completely webbased, so you cannot use them offline,
unless you are hosting a mirror locally or in your LAN (which can be
arranged if you are interested).

Jeroen



2009/12/7 Felipe Carrillo :
> Hi Jeroen:
> This is great for someone who is point and click oriented. Can this program 
> be downloaded to be used offline or its just web based? My field crew usually 
> take toughbooks to the field and since they don't know how to program it will 
> be nice to make the graphics just by pointing and clicking. Thanks
>
>
> Felipe D. Carrillo
> Supervisory Fishery Biologist
> Department of the Interior
> US Fish & Wildlife Service
> California, USA
>
>
> --- On Sun, 12/6/09, Jeroen Ooms  wrote:
>
>> From: Jeroen Ooms 
>> Subject: [R] yeroon.net/ggplot2 web application v0.11
>> To: r-help@r-project.org
>> Date: Sunday, December 6, 2009, 5:07 PM
>> A new version of the ggplot2 web
>> application is available at
>> http://www.yeroon.net/ggplot2. New features include 1D
>> geom’s
>> (histogram, density, freqpoly), syntax mode (by clicking
>> the tiny
>> arrow at the bottom), and some additional facet options.
>> Furthermore
>> some minor improvements and fixes, most notably for
>> Internet Explorer.
>>
>> As usual, a little demo video that shows how to use the new
>> features:
>> http://www.youtube.com/watch?v=7XGN6OSCq6E&hd=1 (watch
>> in full
>> screen). The datafile from the demo is available at
>> http://www.yeroon.net/ggplot2/myMovies.csv.
>>
>> The data upload has not been improved yet, I am working on
>> that. For
>> now, it supports .csv, .sav (spss), and tab delimited data.
>> Please
>> make sure your filename has the appropriate extension and
>> every column
>> has a header in your data. If you export a dataframe from
>> R, use:
>> write.csv(mydf, ”mydf.csv” , row.names=F). If you
>> upload an spss
>> datafile, none of this should be a concern.
>>
>> Supported browsers are IE6-8, FF, Safari, and Chrome, but a
>> recent
>> browser is highly recommended. As always, feedback is more
>> than
>> welcome.
>>
>> Jeroen
>>
>> __
>> R-help@r-project.org
>> mailing list
>> https://stat.ethz.ch/mailman/listinfo/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 required with NLME syntax

2009-12-07 Thread Surujbally, Bernie
Hi there,
 
I am attempting to analyse data from a crossover study using a mixed
effect Emax model in R using nlme. I am having problems ascertaining how
to fit the model.
 
Subjects are randomly assigned to 1 of 4 treatments in a complete block
design. The response variable of interest is recorded once within each
period. So, subjects have a response for each period.
 
Specifically, I want to fit fixed effects: two continuous baseline
covariates (base1 and base2) and period which has levels 1-4. Subject
will be fitted as a random variable.
 
I have started with the 3 parameter Emax model using nls, with no other
covariates and no random term. The syntax of this I know to be correct.
When I progress to nlme, firstly fitting subject as random, I get
nonsensical answers for Emax and ED50. Even if I was getting reasonable
answers at this point, I am not sure how I specify period, a co-factor
in the model?
 
Hoping someone can help.
 
Many thanks in advance.
 
B Surujbally
 
 

 LEGAL NOTICE 
 
 Unless expressly stated otherwise, this message is confidential and
 may be privileged. It is intended for the addressee(s) only. Access
to 
 this e-mail by anyone else is unauthorised. If you are not an 
 addressee, any disclosure or copying of the contents of this e-mail
or 
 any action taken (or not taken) in reliance on it is unauthorised
and 
 may be unlawful. If you are not an addressee, please inform the
sender 
 immediately. 
 
 Pfizer Limited is registered in England under No. 526209 with its 
 registered office at Ramsgate Road, Sandwich, Kent CT13 9NJ  

 

[[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] bootstrap help

2009-12-07 Thread Marek Janad
If I read your question now, I think, that I didn't understand you
correctly, but...

My code generates 50 bootstrap samples (50 tables) and for each
calculates mean of column x and mean of column y, so the final result
is matrix with means.

If you don't want to calculate means, code below generates list of 50
bootstrap samples.

lapply(1:50,function(i){data[sample(nrow(data),size=nrow(data),replace=TRUE),]})

Please check help if some functions aren't understandable.

2009/12/7 casperyc :
>
> Hi there,
>
> This seems to 'simple' for that. ( I mean the codes are too good)
> Can I ask for a bit explaination? or some simplier (maybe few more line
> codes) to archieve that goal?
>
> And the codes you gave here,
> first line give a table with x and y , random normal values,
> but  the second line, what does that do?
>
> I totally can't follow that line.
> the result is a 50 by 2 table.
> what is that? is a sample?
>
> Thanks.
>
> casper
>
>
>
>
> Marek Janad wrote:
>>
>> data<-data.frame(x=rnorm(49), y=rnorm(49))
>> t(sapply(1:50,function(i){colMeans(data[sample(nrow(data),size=nrow(data),replace=TRUE),])}))
>>
>>
>> r-help@r-project.org
>>
>> 2009/12/7 casperyc :
>>>
>>> Hi there,
>>>
>>> i think that's not what i was aiming for...
>>>
>>> i was aked to
>>>
>>> Generate 50 Bootstrap samples and corresponding estimates
>>>
>>> if i do data[sample(nrow(data),size=50,replace=TRUE),]
>>> it will give me a table of 50 rows ( 50 sets of x and y)
>>> then how do i estimate the mean? ( mean was esitmated by the
>>> bar{x}/bar{y} )
>>>
>>> i mis undertood that too.
>>> but now, i think what i actually need is
>>>
>>> 50 sets of this kind (49 rows) of tables from bootstrapping
>>> so that i can have 50 different 'bar{x}/bar{y}' s
>>> then to estimate the mean...
>>>
>>> Thanks.
>>>
>>> casper
>>>
>>>
>>>
>>> Ben Bolker wrote:

 casperyc  hotmail.co.uk> writes:

> I have 49 pairs in my data.frame 'data'
>
> x    y
> 76   80
> ...  ...
>
> how do I get a bootstrap sample of size n=50?
>

 data[sample(nrow(data),size=50,replace=TRUE),]

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


>>>
>>> --
>>> View this message in context:
>>> http://n4.nabble.com/bootstrap-help-tp949807p954053.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.
>>>
>>
>>
>>
>> --
>> Marek
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>>
>
> --
> View this message in context: 
> http://n4.nabble.com/bootstrap-help-tp949807p954088.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.
>



-- 
Marek

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


Re: [R] SAS "datalines" or "cards" statement equivalent in R?

2009-12-07 Thread David Winsemius


On Dec 7, 2009, at 12:37 PM, Marshall Feldman wrote:


I totally agree with Barry, although it's sometimes convenient to
include data with analysis code for debugging and/or documentation  
purposes.


However, the example actually applies equally to separate data  
files. In

fact, the example is from the U.S. Bureau of Labor Statistics at
ftp://ftp.bls.gov/pub/time.series/sm/, which contains nothing but data
and documentation files. At issue is not where the data come from, but
rather how to parse relatively complex data organized inconsistently.
SAS has built-in the ability to parse five different organizations of
data: list (delimited), modified list, column, formatted, and mixed  
(see

http://www.masil.org/sas/input.html). It seems R can parse such data,
but only with considerable work by the user. It would be great to  
have a

function/package that implements something with as easy (hah!) and
flexible as SAS.



   Marsh

Barry Rowlingson wrote:
On Mon, Dec 7, 2009 at 3:53 PM, Marshall Feldman   
wrote:


Regarding the various methods people have suggested, what if a  
typical

tab-delimited data line looks like:

   SMS11001 1990 M01 688.0

and the SAS INPUT statement is

 INPUT survey $ 1-2 seasonal $ 3 state $ 4-5 area $ 6-10  
supersector $
11-12 @13 industry $8. datatype $ 21-22  year period $ value  
footnote $ ;


I was thinking of passing a FWF "chopped" input to scan to handle the  
tabs but discovered that read.fwf will parse trailing tab-separated  
fields.


First a bit of experimentation:
> testdat <- "45678\t567\t45\t6"
> read.fwf(textConnection(testdat), c(5,100))
 V1 V2  V3 V4 V5
1 45678 NA 567 45  6

Then the test on your data source:

> testin <- read.fwf(url("ftp://ftp.bls.gov/pub/time.series/sm/sm.data.1.Alabama 
", open="r"), c(2,1,2,5,2,8,2,100 ), header=F,  n=100, skip=1)


#Need to throw away the header, since the fields no longer match after  
parsing what you communicated were the divisions within of the  
"series_id" field.


> str(testin)
'data.frame':   100 obs. of  12 variables:
 $ V1 : Factor w/ 1 level "SM": 1 1 1 1 1 1 1 1 1 1 ...
 $ V2 : Factor w/ 1 level "S": 1 1 1 1 1 1 1 1 1 1 ...
 $ V3 : int  1 1 1 1 1 1 1 1 1 1 ...
 $ V4 : int  0 0 0 0 0 0 0 0 0 0 ...
 $ V5 : int  0 0 0 0 0 0 0 0 0 0 ...
 $ V6 : int  1 1 1 1 1 1 1 1 1 1 ...
 $ V7 : logi  NA NA NA NA NA NA ...
 $ V8 : logi  NA NA NA NA NA NA ...
 $ V9 : int  1990 1990 1990 1990 1990 1990 1990 1990 1990 1990 ...
 $ V10: Factor w/ 12 levels "M01","M02","M03",..: 1 2 3 4 5 6 7 8 9  
10 ...

 $ V11: num  1625 1625 1624 1635 1639 ...
 $ V12: logi  NA NA NA NA NA NA ...

Noted that the leading 7 fwf fields were parse and followed by  
trailing tab separated fields, and the floating point field is also  
complete:


> testin$V11
  [1] 1625.0 1625.1 1623.7 1634.8 1639.1 1643.5 1641.0 1639.4 1641.2  
1636.9 1639.8 1639.3 1636.2
 [14] 1633.8 1637.0 1635.5 1638.3 1639.5 1643.5 1645.3 1647.0 1648.2  
1649.3 1650.5 1657.9 1660.4

snipped
--
David


Note that most data lines have no footnote item, as in the sample.

Here (I think) we'd want all the character variables to be read as  
factors,

possibly "year" as a date, and "value" as numeric.



Actually I'm surprised that nobody has yet said what a clearly
bonkers thing it is to mix up your data and your analysis code in a
single file. Now suppose you have another set of data you want to
analyse with the same code? Are you going to create a new file and
paste the new data in? You've now got two copies of your analysis  
code

- good luck keeping corrections to that code synchronised.

This just seems like horrendously bad practice, which is one reason
it's kludgy in R. If it was good practice, someone would surely have
written a way to do it neatly.

Keep your data in data files, and your functions in .R function
files. You'll thank me later.

Barry




[[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] Are there free R webinar recordings somewhere ?

2009-12-07 Thread D Kelly O'Day

Tal

I have a series of basic introduction tutorials for new R users at this
link.

http://processtrends.com/Learn_R_Toolkit.htm
http://processtrends.com/Learn_R_Toolkit.htm 


These videos are geared to Excel users who want to learn about R and see it
in action.

D Kelly O'Day
http://procestrends.com
http://chartsgraphs.wordpress.com




Tal Galili wrote:
> 
> Hi all,
> A friend just sent me this:
> http://www.mathworks.com/company/events/webinars/index.html?id=&language=en
> And
> asked me if there is something of the like in the R community.
> Does anyone know of such a think ?
> 
> Cheers,
> Tal
> 
> 
> Contact
> Details:---
> Contact me: tal.gal...@gmail.com |  972-52-7275845
> Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
> www.r-statistics.com/ (English)
> --
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 

-- 
View this message in context: 
http://n4.nabble.com/Are-there-free-R-webinar-recordings-somewhere-tp954706p954772.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] SAS "datalines" or "cards" statement equivalent in R?

2009-12-07 Thread Barry Rowlingson
On Mon, Dec 7, 2009 at 8:54 PM, Marshall Feldman  wrote:
>
>
> Barry Rowlingson wrote:
>>
>>  I'd love to duplicate this functionality of SAS, however, I fear:
>>
>> http://www.sas.com/news/preleases/SASsuit.html
>>
>>
>
> Amazing, since input statements in SAS bear an uncanny resemblance to how
> PL/I handles input from text files.
>

 The lawsuit appears to not be for copying behaviour of SAS per se,
but in using an Educational License version of SAS to test and
benchmark the WPS version.

Barry

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


Re: [R] MLE in R

2009-12-07 Thread Francisco J. Zagmutt

Hello Liang,

Besides looking at ?optim, you may also want to look into this nice 
working example www.mayin.org/ajayshah/KB/R/documents/mle/mle.html


Regards,

Francisco

Francisco J. Zagmutt
Vose Consulting
1643 Spruce St., Boulder
Boulder, CO, 80302
USA
www.voseconsulting.com

Liang Wang wrote:

Hi, dear R users

I am a newbie in R and I need to use the method of meximum likelihood to fit a Weibull 
distribution to my survival data. I use "optim" as follows:


optim(c(1.14,0.25),weibull.like,mydata=mydata,method="L-BFGS-B",hessian = TRUE)

My question is: how do I setup the constraints that the two parametrs of 
Weibull to be pisotive?

Many thanks! Any comments are greatly appreciated!

Steven
[[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] SAS "datalines" or "cards" statement equivalent in R?

2009-12-07 Thread Marshall Feldman



Barry Rowlingson wrote:

 I'd love to duplicate this functionality of SAS, however, I fear:

http://www.sas.com/news/preleases/SASsuit.html

  


Amazing, since input statements in SAS bear an uncanny resemblance to 
how PL/I handles input from text files.


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


[R] Reminder: ASA Stat Comp/Graph Student Paper Competition Deadline 12/14

2009-12-07 Thread Fei Chen









Just a gentle reminder that the deadline for submission to the Student Paper 
Competition is fast approaching. All application materials must be received by 
5:00 PM EST, Monday,
December 14, 2009.

For submission guidelines, please visit
http://stat-computing.org/awards/student/announcement.html

  
_
Get gifts for them and cashback for you. Try Bing now.
http://www.bing.com/shopping/search?q=xbox+games&scope=cashback&form=MSHYCB&publ=WLHMTAG&crea=TEXT_MSHYCB_Shopping_Giftsforthem_cashback_1x1
[[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] Reminder: ASA Stat Comp/Graph Student Paper Competition Deadline 12/15

2009-12-07 Thread Fei Chen

Just a gentle reminder that the deadline for submission to the Student Paper 
Competition is fast approaching. All application materials must be received by 
5:00 PM EST, Monday,
December 14, 2009.

For submission guidelines, please visit
http://stat-computing.org/awards/student/announcement.html

  
_
Windows Live Hotmail is faster and more secure than ever.
http://www.microsoft.com/windows/windowslive/hotmail_bl1/hotmail_bl1.aspx?ocid=PID23879::T:WLMTAGL:ON:WL:en-ww:WM_IMHM_1:092009
[[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] Are there free R webinar recordings somewhere ?

2009-12-07 Thread Thomas Adams

Tal,

You might look here: http://www.fort.usgs.gov/brdscience/LearnR.htm

I just googled "r stats webinar"

Tom

Tal Galili wrote:

Hi all,
A friend just sent me this:
http://www.mathworks.com/company/events/webinars/index.html?id=&language=en
And
asked me if there is something of the like in the R community.
Does anyone know of such a think ?

Cheers,
Tal


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

[[alternative HTML version deleted]]

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



--
Thomas E Adams
National Weather Service
Ohio River Forecast Center
1901 South State Route 134
Wilmington, OH 45177

EMAIL:  thomas.ad...@noaa.gov

VOICE:  937-383-0528
FAX:937-383-0033

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Are there free R webinar recordings somewhere ?

2009-12-07 Thread Tal Galili
Hi all,
A friend just sent me this:
http://www.mathworks.com/company/events/webinars/index.html?id=&language=en
And
asked me if there is something of the like in the R community.
Does anyone know of such a think ?

Cheers,
Tal


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

[[alternative HTML version deleted]]

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


Re: [R] [GGPLOT] Legends at different layers

2009-12-07 Thread hadley wickham
You mean:

dat <- data.frame(x = rnorm(100))
dat1 <- data.frame(
  x = c(0,0),
  y = c(1,0),
  Label = c("Point1", "Point2")
)


ggplot(dat, aes(x)) +
  geom_histogram(aes(fill = ..count..)) +
  geom_point(aes(x, y, colour = Label), data = dat1, size = 4) +
  scale_fill_gradient("Count", low = "green", high = "red")


Unfortunately not.  In the future, you will be able to do +
scale_colour_discrete(legend = F)

Hadley

On Mon, Dec 7, 2009 at 11:17 AM, Megh  wrote:
>
> Here I have following code :
>
> dat = rnorm(100)
> ggplot() + geom_histogram(aes(dat, fill=..count..)) +
> scale_fill_gradient("Count", low="green", high="red") +
> opts(legend.position="none")
> # Above is without any legend
>
> ## Now I want to place two points with legends
> dat1 <- data.frame(c(0,0), c(1,0)); Label <- c("Point1", "Point2")
> last_plot() + geom_point(aes(dat1[,1], dat1[,2], colour=Label), size=4)
> # Here I am not getting any legend for "points"
>
> I want GGPLOT should show the legend for "points" NOT for "histogram". Is
> there any option?
>
> Thanks,
>
> --
> View this message in context: 
> http://n4.nabble.com/GGPLOT-Legends-at-different-layers-tp954527p954527.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.
>



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

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


[R] Convert a list of N dataframes to N dataframes

2009-12-07 Thread Mark Na
Hello,

I have used the following command:

datalist<-list(data1,data2,data3,data4,data5,data6)

to make a list of my dataframes, which I then manipulated with these
commands:

datalist<-llply(datalist,"LogDepth")
datalist<-llply(datalist,"LogArea")
datalist<-llply(datalist,"p")
datalist<-llply(datalist,"Exp")
datalist<-llply(datalist,"s")

This worked very nicely (thanks for plyr, Hadley) but now I would like to
"unlist" my list into the individual dataframes, preferably with their
original names (data1, etc).

I've tried to do this with:

> ldply(datalist,unlist)

but that's not working. Any help with this would be much appreciated.

Thanks, Mark

[[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] SAS "datalines" or "cards" statement equivalent in R?

2009-12-07 Thread Rolf Turner


On 8/12/2009, at 5:43 AM, Barry Rowlingson wrote:

On Mon, Dec 7, 2009 at 3:53 PM, Marshall Feldman   
wrote:
Regarding the various methods people have suggested, what if a  
typical

tab-delimited data line looks like:

SMS11001 1990 M01 688.0

and the SAS INPUT statement is

  INPUT survey $ 1-2 seasonal $ 3 state $ 4-5 area $ 6-10  
supersector $
11-12 @13 industry $8. datatype $ 21-22  year period $ value  
footnote $ ;


Note that most data lines have no footnote item, as in the sample.

Here (I think) we'd want all the character variables to be read as  
factors,

possibly "year" as a date, and "value" as numeric.


 Actually I'm surprised that nobody has yet said what a clearly
bonkers thing it is to mix up your data and your analysis code in a
single file. Now suppose you have another set of data you want to
analyse with the same code? Are you going to create a new file and
paste the new data in? You've now got two copies of your analysis code
- good luck keeping corrections to that code synchronised.

 This just seems like horrendously bad practice, which is one reason
it's kludgy in R. If it was good practice, someone would surely have
written a way to do it neatly.

 Keep your data in data files, and your functions in .R function
files. You'll thank me later.


Indeed.  The idea of keeping data and code in the same file is a symptom
of blinkered SAS orientation.  Get out of the SAS way of thinking and
get into the R way of thinking.  You'll be glad you did!

To paraphrase Eric Blair:  ``SAS-thinkers unbellyfeel R-speak.''

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] Very basic R workflow question for Windows users

2009-12-07 Thread Duncan Murdoch

On 07/12/2009 1:31 PM, Mark Na wrote:

Hi all,

If you use the R Editor (not another text editor), please read on...

So, my usual R workflow involves having two windows open (R Console, R
Editor), writing a line of code in the R Editor and then typing Ctrl-R to
run that line. Then, quite frequently, I want to run a new command to check
my output (e.g., dim(dataframe) or str(dataframe) or head(dataframe)) but I
*do not want* to write that command in the R Editor, rather I want to edit
it directly in the R Console.

My (basic) question is: how do you use the keyboard (not mouse) to move the
cursor from the Editor to the Console. The only (cumbersome) way I know is
to type Alt-Tab and then Tab-Tab-Tab to get to the Console.

Is there a better way?


If you use the MDI layout, Ctrl-Tab will get you there without such a 
long list of windows to choose from.  But I usually use the mouse.


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] Sweave and license message when loading mclust package

2009-12-07 Thread Achim Zeileis



On Mon, 7 Dec 2009, Titus von der Malsburg wrote:


When loading mclust, it shows a license agreement message.  This
message shows up in my document when I use Sweave.  I did the
following:

<>=
 library(mclust)
@

Is this a problem with mclust, Sweave or with me?  How can it be fixed?


By ?RweaveLatex ;-) Try:

<>=
library("mclust")
@

hth,
Z


Thanks for any suggestions!

 Titus

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Sweave and license message when loading mclust package

2009-12-07 Thread Titus von der Malsburg
When loading mclust, it shows a license agreement message.  This
message shows up in my document when I use Sweave.  I did the
following:

<>=
  library(mclust)
@

Is this a problem with mclust, Sweave or with me?  How can it be fixed?

Thanks for any suggestions!

  Titus

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


Re: [R] yeroon.net/ggplot2 web application v0.11

2009-12-07 Thread Felipe Carrillo
Hi Jeroen:
This is great for someone who is point and click oriented. Can this program be 
downloaded to be used offline or its just web based? My field crew usually take 
toughbooks to the field and since they don't know how to program it will be 
nice to make the graphics just by pointing and clicking. Thanks


Felipe D. Carrillo  
Supervisory Fishery Biologist  
Department of the Interior  
US Fish & Wildlife Service  
California, USA


--- On Sun, 12/6/09, Jeroen Ooms  wrote:

> From: Jeroen Ooms 
> Subject: [R] yeroon.net/ggplot2 web application v0.11
> To: r-help@r-project.org
> Date: Sunday, December 6, 2009, 5:07 PM
> A new version of the ggplot2 web
> application is available at
> http://www.yeroon.net/ggplot2. New features include 1D
> geom’s
> (histogram, density, freqpoly), syntax mode (by clicking
> the tiny
> arrow at the bottom), and some additional facet options.
> Furthermore
> some minor improvements and fixes, most notably for
> Internet Explorer.
> 
> As usual, a little demo video that shows how to use the new
> features:
> http://www.youtube.com/watch?v=7XGN6OSCq6E&hd=1 (watch
> in full
> screen). The datafile from the demo is available at
> http://www.yeroon.net/ggplot2/myMovies.csv.
> 
> The data upload has not been improved yet, I am working on
> that. For
> now, it supports .csv, .sav (spss), and tab delimited data.
> Please
> make sure your filename has the appropriate extension and
> every column
> has a header in your data. If you export a dataframe from
> R, use:
> write.csv(mydf, ”mydf.csv” , row.names=F). If you
> upload an spss
> datafile, none of this should be a concern.
> 
> Supported browsers are IE6-8, FF, Safari, and Chrome, but a
> recent
> browser is highly recommended. As always, feedback is more
> than
> welcome.
> 
> Jeroen
> 
> __
> R-help@r-project.org
> mailing list
> https://stat.ethz.ch/mailman/listinfo/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] [Ann] R brush for SyntaxHighlighter

2009-12-07 Thread Demitri Muna

Hi,

On Dec 5, 2009, at 2:43 AM, Romain Francois wrote:

There is also the R package "highlight" [1,2] serving the same  
purpose but based on information from the R parser, not a static list.


Thanks for the pointer - I wasn't aware of that package. I'll make a  
mention of it on my web page. Hopefully mine can be useful to others  
as well.


Cheers,
Demitri

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Very basic R workflow question for Windows users

2009-12-07 Thread Mark Na
Hi all,

If you use the R Editor (not another text editor), please read on...

So, my usual R workflow involves having two windows open (R Console, R
Editor), writing a line of code in the R Editor and then typing Ctrl-R to
run that line. Then, quite frequently, I want to run a new command to check
my output (e.g., dim(dataframe) or str(dataframe) or head(dataframe)) but I
*do not want* to write that command in the R Editor, rather I want to edit
it directly in the R Console.

My (basic) question is: how do you use the keyboard (not mouse) to move the
cursor from the Editor to the Console. The only (cumbersome) way I know is
to type Alt-Tab and then Tab-Tab-Tab to get to the Console.

Is there a better way?

Thanks, Mark

[[alternative HTML version deleted]]

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


Re: [R] [ggplot2] Wind rose orientation

2009-12-07 Thread Thomas S. Dye

On Dec 7, 2009, at 7:00 AM, hadley wickham wrote:

>> The idea of plotting a wind rose must be fairly common.  I wonder  
>> if it
>> would make sense to have a switch that would wrap data around the  
>> ends of a
>> continuous scale?
>
> Probably - but it requires a lot of work, because ggplot2 doesn't
> currently support circular scales, which is what you really want.
>

Thanks, the grammar of graphics is a conceptual help here.

When the Springer book makes its 2nd edition, it would help readers at  
my level of comprehension to mention the distinction between linear(?)  
and circular scales in 6.4.2 Position scales (p. 98), and to carry  
this distinction forward into 7.3.4 Non-Cartesian coordinate systems,  
especially under Polar coordinates, where wind roses are mentioned.

I'm enjoying the chance to develop a grammatical view of graphics, and  
really appreciate your excellent book and the detailed help you've  
provided me.

All the best,
Tom


Thomas S. Dye, Ph.D.
T. S. Dye & Colleagues, Archaeologists, Inc.
Phone: (808) 529-0866 Fax: (808) 529-0884
http://www.tsdye.com



[[alternative HTML version deleted]]

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


Re: [R] Output multiple files

2009-12-07 Thread David Winsemius


On Dec 7, 2009, at 12:42 PM, Muhammad Rahiz wrote:


Hello,

I want the ouput to take the name of the original file. I have the  
following code - but the problem is that the output overrides the  
original file which I desire not.


So given an input file called File1.txt, I want the ouput to be  
called File1.out.txt, or something along this line. I'm working with  
many files, fyi.


out=c("file1.txt", "file2.txt", "file3.txt")


Take a look at this:

> paste(strsplit(out[1], "\\.")[[1]][1], "out.txt", sep=".")
[1] "file1.out.txt"


for (i in 1:3){   # where 3 is the number of files
file[[i]] <- file[[i]] * 3   # just a simple calculation to multiply  
the matrix by 3

write.table(file[[i]],out[i], row.names=FALSE, col.names=FALSE)


perhaps something like this (untested in absence of data) :

write.table(file[[i]],file=paste(strsplit(out[i], "\\.")[[1]][1],  
"out.txt", sep="."), row.names=FALSE, col.names=FALSE)

}



Thanks.

--
Muhammad Rahiz  |  Doctoral Student in Regional Climate Modeling

Climate Research Laboratory, School of Geography & the Environment  
Oxford University Centre for the Environment
South Parks Road, Oxford, OX1 3QY, United Kingdom Tel: +44  
(0)1865-285194	 Mobile: +44 (0)7854-625974

Email: muhammad.ra...@ouce.ox.ac.uk

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] SAS "datalines" or "cards" statement equivalent in R?

2009-12-07 Thread David Winsemius


On Dec 7, 2009, at 12:37 PM, Marshall Feldman wrote:


I totally agree with Barry, although it's sometimes convenient to
include data with analysis code for debugging and/or documentation  
purposes.


However, the example actually applies equally to separate data  
files. In

fact, the example is from the U.S. Bureau of Labor Statistics at
ftp://ftp.bls.gov/pub/time.series/sm/, which contains nothing but data
and documentation files. At issue is not where the data come from, but
rather how to parse relatively complex data organized inconsistently.
SAS has built-in the ability to parse five different organizations of
data: list (delimited), modified list, column, formatted, and mixed  
(see

http://www.masil.org/sas/input.html). It seems R can parse such data,
but only .


It is hard to know what you mean, because you have not specified what  
you mean by "with considerable work by the user."



It would be great to have a
function/package that implements something with as easy (hah!) and
flexible as SAS.


In particular it is not clear whether you were anticipating using  
read.fwf() and why you think that requires "considerable more work"  
than a SAS INPUT statement. The output of read.fwf gets passed to  
read.table, so that help page would document your options regarding  
definition of classes of input variables.


--
David




   Marsh

Barry Rowlingson wrote:
On Mon, Dec 7, 2009 at 3:53 PM, Marshall Feldman   
wrote:


Regarding the various methods people have suggested, what if a  
typical

tab-delimited data line looks like:

   SMS11001 1990 M01 688.0

and the SAS INPUT statement is

 INPUT survey $ 1-2 seasonal $ 3 state $ 4-5 area $ 6-10  
supersector $
11-12 @13 industry $8. datatype $ 21-22  year period $ value  
footnote $ ;


Note that most data lines have no footnote item, as in the sample.

Here (I think) we'd want all the character variables to be read as  
factors,

possibly "year" as a date, and "value" as numeric.



Actually I'm surprised that nobody has yet said what a clearly
bonkers thing it is to mix up your data and your analysis code in a
single file. Now suppose you have another set of data you want to
analyse with the same code? Are you going to create a new file and
paste the new data in? You've now got two copies of your analysis  
code

- good luck keeping corrections to that code synchronised.

This just seems like horrendously bad practice, which is one reason
it's kludgy in R. If it was good practice, someone would surely have
written a way to do it neatly.

Keep your data in data files, and your functions in .R function
files. You'll thank me later.

Barry




[[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] SAS "datalines" or "cards" statement equivalent in R?

2009-12-07 Thread Gabor Grothendieck
strapply in the gsubfn package can parse any input format that can be
described using a regular expression and generally requires only one
line of code to do the parsing.  See:  http://gsubfn.googlecode.com

On Mon, Dec 7, 2009 at 12:37 PM, Marshall Feldman  wrote:
> I totally agree with Barry, although it's sometimes convenient to
> include data with analysis code for debugging and/or documentation purposes.
>
> However, the example actually applies equally to separate data files. In
> fact, the example is from the U.S. Bureau of Labor Statistics at
> ftp://ftp.bls.gov/pub/time.series/sm/, which contains nothing but data
> and documentation files. At issue is not where the data come from, but
> rather how to parse relatively complex data organized inconsistently.
> SAS has built-in the ability to parse five different organizations of
> data: list (delimited), modified list, column, formatted, and mixed (see
> http://www.masil.org/sas/input.html). It seems R can parse such data,
> but only with considerable work by the user. It would be great to have a
> function/package that implements something with as easy (hah!) and
> flexible as SAS.
>
>    Marsh
>
> Barry Rowlingson wrote:
>> On Mon, Dec 7, 2009 at 3:53 PM, Marshall Feldman  wrote:
>>
>>> Regarding the various methods people have suggested, what if a typical
>>> tab-delimited data line looks like:
>>>
>>>     SMS11001 1990 M01 688.0
>>>
>>> and the SAS INPUT statement is
>>>
>>>   INPUT survey $ 1-2 seasonal $ 3 state $ 4-5 area $ 6-10 supersector $
>>> 11-12 @13 industry $8. datatype $ 21-22  year period $ value footnote $ ;
>>>
>>> Note that most data lines have no footnote item, as in the sample.
>>>
>>> Here (I think) we'd want all the character variables to be read as factors,
>>> possibly "year" as a date, and "value" as numeric.
>>>
>>
>>  Actually I'm surprised that nobody has yet said what a clearly
>> bonkers thing it is to mix up your data and your analysis code in a
>> single file. Now suppose you have another set of data you want to
>> analyse with the same code? Are you going to create a new file and
>> paste the new data in? You've now got two copies of your analysis code
>> - good luck keeping corrections to that code synchronised.
>>
>>  This just seems like horrendously bad practice, which is one reason
>> it's kludgy in R. If it was good practice, someone would surely have
>> written a way to do it neatly.
>>
>>  Keep your data in data files, and your functions in .R function
>> files. You'll thank me later.
>>
>> Barry
>>
>
>
>        [[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] Multiple regression script

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

Hi all,

I'm doing Multiple linear regression for a data set. However, it takes a lot of 
time, as I would like to check every possible combination of factors, evalute 
the results based for instance on their p values, and then choose the best 
regression model.

So, I wonder if anyone might have a script for that? Or if not, do you have 
some suggestions how to create such a script?

I've been told there is a similar function in SAS, but I'm not sure how it 
works. Furthermore, I'm not sure how to deal with the evaluation of the 
results, are there any other factors I should consider, such as R square etc?

All the best,

Joel
  
_
Hitta kärleken i vinter!
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] SAS "datalines" or "cards" statement equivalent in R?

2009-12-07 Thread Barry Rowlingson
On Mon, Dec 7, 2009 at 5:37 PM, Marshall Feldman  wrote:
> I totally agree with Barry, although it's sometimes convenient to include
> data with analysis code for debugging and/or documentation purposes.
>
> However, the example actually applies equally to separate data files. In
> fact, the example is from the U.S. Bureau of Labor Statistics at
> ftp://ftp.bls.gov/pub/time.series/sm/, which contains nothing but data and
> documentation files. At issue is not where the data come from, but rather
> how to parse relatively complex data organized inconsistently. SAS has
> built-in the ability to parse five different organizations of data: list
> (delimited), modified list, column, formatted, and mixed (see
> http://www.masil.org/sas/input.html). It seems R can parse such data, but
> only with considerable work by the user. It would be great to have a
> function/package that implements something with as easy (hah!) and flexible
> as SAS.

 I'd love to duplicate this functionality of SAS, however, I fear:

http://www.sas.com/news/preleases/SASsuit.html

 but yes, some kind of declarative, template-driven data definition
system might be useful. Such a thing may already exist, and be based
on XML instead of what looks like line noise:

INPUT #1 No 7.0 #2 name $CHAR15. / address $CHAR50. #4 phone $CHAR12.;

Barry

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


Re: [R] SAS "datalines" or "cards" statement equivalent in R?

2009-12-07 Thread Seeliger . Curt
> [stuff about SAS CARDS statement, I think]
> >   INPUT survey $ 1-2 seasonal $ 3 state $ 4-5 area $ 6-10 supersector 
$
> > 11-12 @13 industry $8. datatype $ 21-22  year period $ value footnote 
$ ;
> ...
>  This just seems like horrendously bad practice, which is one reason
> it's kludgy in R. If it was good practice, someone would surely have
> written a way to do it neatly.
> 
>  Keep your data in data files, and your functions in .R function
> files. You'll thank me later.

Actually, it's really helpful to be able to do this when you're writing 
unit tests.  I've spent a fair bit of time writing R code to create 
dataframes of artificial data to this end.  There's more than one way to 
do it, sure, they're all kludgey.

cur
[[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] Output multiple files

2009-12-07 Thread Muhammad Rahiz

Hello,

I want the ouput to take the name of the original file. I have the following 
code - but the problem is that the output overrides the original file which I 
desire not.

So given an input file called File1.txt, I want the ouput to be called 
File1.out.txt, or something along this line. I'm working with many files, fyi.

out=c("file1.txt", "file2.txt", "file3.txt")
for (i in 1:3){   # where 3 is the number of files
file[[i]] <- file[[i]] * 3   # just a simple calculation to multiply the matrix 
by 3
write.table(file[[i]],out[i], row.names=FALSE, col.names=FALSE)
}

Thanks.

--
Muhammad Rahiz  |  Doctoral Student in Regional Climate Modeling

Climate Research Laboratory, School of Geography & the Environment  
Oxford University Centre for the Environment
South Parks Road, Oxford, OX1 3QY, United Kingdom 
Tel: +44 (0)1865-285194	 Mobile: +44 (0)7854-625974

Email: muhammad.ra...@ouce.ox.ac.uk

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


Re: [R] Setting Repositories in the .Rprofile file

2009-12-07 Thread David Winsemius


On Dec 7, 2009, at 12:18 PM, Richardson, Patrick wrote:

Is there any way to select (during startup) all repositories by  
modifying the Rprofile.site file? If so, could someone let me know  
the syntax to use (or direct me to where I can find it)?




?options

options(repos=c(CRAN = "http://lib.stat.cmu.edu/R/CRAN";  ) )

For my system after this I (still)  see:
> getOption("repos")
CRAN
"http://lib.stat.cmu.edu/R/CRAN";


Thank you,

Patrick

--

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] SAS "datalines" or "cards" statement equivalent in R?

2009-12-07 Thread Marshall Feldman
I totally agree with Barry, although it's sometimes convenient to 
include data with analysis code for debugging and/or documentation purposes.

However, the example actually applies equally to separate data files. In 
fact, the example is from the U.S. Bureau of Labor Statistics at 
ftp://ftp.bls.gov/pub/time.series/sm/, which contains nothing but data 
and documentation files. At issue is not where the data come from, but 
rather how to parse relatively complex data organized inconsistently. 
SAS has built-in the ability to parse five different organizations of 
data: list (delimited), modified list, column, formatted, and mixed (see 
http://www.masil.org/sas/input.html). It seems R can parse such data, 
but only with considerable work by the user. It would be great to have a 
function/package that implements something with as easy (hah!) and 
flexible as SAS.

Marsh

Barry Rowlingson wrote:
> On Mon, Dec 7, 2009 at 3:53 PM, Marshall Feldman  wrote:
>   
>> Regarding the various methods people have suggested, what if a typical
>> tab-delimited data line looks like:
>>
>> SMS11001 1990 M01 688.0
>>
>> and the SAS INPUT statement is
>>
>>   INPUT survey $ 1-2 seasonal $ 3 state $ 4-5 area $ 6-10 supersector $
>> 11-12 @13 industry $8. datatype $ 21-22  year period $ value footnote $ ;
>>
>> Note that most data lines have no footnote item, as in the sample.
>>
>> Here (I think) we'd want all the character variables to be read as factors,
>> possibly "year" as a date, and "value" as numeric.
>> 
>
>  Actually I'm surprised that nobody has yet said what a clearly
> bonkers thing it is to mix up your data and your analysis code in a
> single file. Now suppose you have another set of data you want to
> analyse with the same code? Are you going to create a new file and
> paste the new data in? You've now got two copies of your analysis code
> - good luck keeping corrections to that code synchronised.
>
>  This just seems like horrendously bad practice, which is one reason
> it's kludgy in R. If it was good practice, someone would surely have
> written a way to do it neatly.
>
>  Keep your data in data files, and your functions in .R function
> files. You'll thank me later.
>
> Barry
>   


[[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] Subset of time observations where timediff > 60 secs

2009-12-07 Thread Gabor Grothendieck
There is an example at the end of the Prices and Returns section of
the zoo-quickref vignette in the zoo package.

library(zoo)
vignette("zoo-quickref")

If speed is your main concern check this recent thread that was posted
on R-sig-finance:
http://n4.nabble.com/SUMMARY-Reducing-an-intra-day-dataset-into-one-obs-per-second-td949612.html

On Mon, Dec 7, 2009 at 10:57 AM, Karl Ove Hufthammer  wrote:
> Dear list members
>
> I have a rather large vector (part of a data frame) giving the time
> (date + time, POSIXct) of observations. The times are irregular (with
> both small and large jumps) but increasing, and there are several
> millions of them.
>
> I now wish to reduce my data set, so that I only have observations which
> are at least (for example) 60 seconds apart. Basically, I need (all) the
> indices of my time variable where the difference in times are at least
> 60 seconds.
>
> I thought this would be a rather simple task, but perhaps I'm tired, for
> I couldn't figure out how to do it in a even moderately elegant way (not
> looping over all the values, which is quite slow).
>
> This solution seemed sensible:
>
> x=cumsum(diff(timevar) %/% 60)
> ind=c(1,cumsum(rle(x)$lengths)+1) # And perhaps removing the last value
>
> but doesn't work, as it only captures the 'first times' in each
> 60-second interval following the first time value, and thus may include
> times with values that are closer than 60 seconds.
>
> I also considered round.POSIXct and trunc.POSIXct, but these are not
> appropriate either, for obvious reasons.
>
> So, any ideas how to do this in an elegant and efficient way?
>
> --
> Karl Ove Hufthammer
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Setting Repositories in the .Rprofile file

2009-12-07 Thread Richardson, Patrick
Is there any way to select (during startup) all repositories by modifying the 
Rprofile.site file? If so, could someone let me know the syntax to use (or 
direct me to where I can find it)?

Thank you,

Patrick


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

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


Re: [R] SAS "datalines" or "cards" statement equivalent in R?

2009-12-07 Thread Gabor Grothendieck
On Mon, Dec 7, 2009 at 11:43 AM, Barry Rowlingson
 wrote:
>  This just seems like horrendously bad practice, which is one reason
> it's kludgy in R. If it was good practice, someone would surely have
> written a way to do it neatly.
>
>  Keep your data in data files, and your functions in .R function
> files. You'll thank me later.

It can be useful from a deployment point of view if you have to send
it around.  Posting questions on the r-help list is a good example.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] [GGPLOT] Legends at different layers

2009-12-07 Thread Megh

Here I have following code :

dat = rnorm(100)
ggplot() + geom_histogram(aes(dat, fill=..count..)) +
scale_fill_gradient("Count", low="green", high="red") +
opts(legend.position="none")
# Above is without any legend

## Now I want to place two points with legends
dat1 <- data.frame(c(0,0), c(1,0)); Label <- c("Point1", "Point2")
last_plot() + geom_point(aes(dat1[,1], dat1[,2], colour=Label), size=4)
# Here I am not getting any legend for "points"

I want GGPLOT should show the legend for "points" NOT for "histogram". Is
there any option? 

Thanks,

-- 
View this message in context: 
http://n4.nabble.com/GGPLOT-Legends-at-different-layers-tp954527p954527.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] SAS "datalines" or "cards" statement equivalent in R?

2009-12-07 Thread Barry Rowlingson
On Mon, Dec 7, 2009 at 3:53 PM, Marshall Feldman  wrote:
> Regarding the various methods people have suggested, what if a typical
> tab-delimited data line looks like:
>
>     SMS11001 1990 M01 688.0
>
> and the SAS INPUT statement is
>
>   INPUT survey $ 1-2 seasonal $ 3 state $ 4-5 area $ 6-10 supersector $
> 11-12 @13 industry $8. datatype $ 21-22  year period $ value footnote $ ;
>
> Note that most data lines have no footnote item, as in the sample.
>
> Here (I think) we'd want all the character variables to be read as factors,
> possibly "year" as a date, and "value" as numeric.

 Actually I'm surprised that nobody has yet said what a clearly
bonkers thing it is to mix up your data and your analysis code in a
single file. Now suppose you have another set of data you want to
analyse with the same code? Are you going to create a new file and
paste the new data in? You've now got two copies of your analysis code
- good luck keeping corrections to that code synchronised.

 This just seems like horrendously bad practice, which is one reason
it's kludgy in R. If it was good practice, someone would surely have
written a way to do it neatly.

 Keep your data in data files, and your functions in .R function
files. You'll thank me later.

Barry

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


Re: [R] anova/factor

2009-12-07 Thread David Winsemius


On Dec 7, 2009, at 11:38 AM, oscar linares wrote:


Dear Wiza[R]ds,

I have the following data in a data.frame. I need to do an anova with
multiple comparison but I don't know how to factor the groups for  
analysis.
There are 3 groups, 1,2 and 3 labelled in column 1. Help appreciated  
with

thanks in advance.


Wouldn't it just be:

dfrm$Group <- factor(dfrm$Group)

?factor

--
David


  Group   SI  Sif  SG   Io I2   
lol2

 1 9.08e-05 9.08e+00 0.060842287  1.798556446  32.574500  34.37306
 1 2.65e-05 2.65e+00 0.003231478  2.655825884  65.929661  68.58549
 1 0.00e+00 0.00e+00 0.0  3.522121885  73.543024  77.06515
 1 1.68e-05 1.68e+00 0.002958672  4.655116799  53.436267  58.09138
 1 1.06e-06 1.06e-01 0.000483373  2.020228717   3.458982   5.47921
 1 0.00e+00 0.00e+00 0.097785539  4.148313577  87.560551  91.70887
 2 3.27e-05 3.27e+00 0.020160681  3.506062628  45.229857  48.73592
 2 1.63e-05 1.63e+00 0.016336170  3.824083293  71.139331  74.96341
2 4.47e-05 4.47e+00 0.021202062  7.895615485  57.452354  65.34797
2 4.38e-05 4.38e+00 0.018721502  4.243604679 110.506859 114.75046
2 0.00e+00 0.00e+00 0.044930944 13.552492860  88.273415 101.82591
2 4.30e-05 4.30e+00 0.027125295  6.426449035  55.102468  61.52892
2 3.80e-05 3.80e+00 0.029939680  0.007273809  92.734675  92.74195
2 3.65e-06 3.65e-01 0.029382519  0.000221684 103.705858 103.70608
2 6.36e-06 6.36e-01 0.023179423  1.228886505 127.803373 129.03226
2 5.86e-13 5.86e-08 0.032732405  1.379044031 104.847896 106.22694
2 5.71e-06 5.71e-01 0.011643722  2.680653511  77.883436  80.56409
2 5.86e-13 5.86e-08 0.021973461  1.094195321  49.400687  50.49488
2 5.86e-13 5.86e-08 0.020197172  2.084520515  51.311323  53.39584
2 3.07e-06 3.07e-01 0.0  2.308138714 121.203022 123.51116
3 5.26e-05 5.26e+00 0.012185655  3.348526610  35.880625  39.22915
3 4.23e-05 4.23e+00 0.028480923  1.709440176  54.767838  56.47728
3 5.56e-05 5.56e+00 0.0  1.429574183  41.604787  43.03436
3 9.12e-06 9.12e-01 0.035704097  0.124131665  45.062952  45.18708
3 2.99e-05 2.99e+00 0.010169719  1.261369666  51.920969  53.18234
3 4.32e-05 4.32e+00 0.000490530  0.0  16.030226  16.03023


Oscar
--
Oscar
Oscar A. Linares, MD
Translational Medicine Unit
LaPlaisance Bay, Bolles Harbor
Monroe, Michigan 48161

Department of Medicine,
University of Toledo College of Medicine
Toledo, OH 43606-3390

Department of Internal Medicine,
The Detroit Medical Center (DMC)
Harper University Hospital
Wayne State University School of Medicine
Detroit, Michigan 48201

[[alternative HTML version deleted]]

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


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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


[R] anova/factor

2009-12-07 Thread oscar linares
Dear Wiza[R]ds,

I have the following data in a data.frame. I need to do an anova with
multiple comparison but I don't know how to factor the groups for analysis.
There are 3 groups, 1,2 and 3 labelled in column 1. Help appreciated with
thanks in advance.

   Group   SI  Sif  SG   Io I2  lol2
  1 9.08e-05 9.08e+00 0.060842287  1.798556446  32.574500  34.37306
  1 2.65e-05 2.65e+00 0.003231478  2.655825884  65.929661  68.58549
  1 0.00e+00 0.00e+00 0.0  3.522121885  73.543024  77.06515
  1 1.68e-05 1.68e+00 0.002958672  4.655116799  53.436267  58.09138
  1 1.06e-06 1.06e-01 0.000483373  2.020228717   3.458982   5.47921
  1 0.00e+00 0.00e+00 0.097785539  4.148313577  87.560551  91.70887
  2 3.27e-05 3.27e+00 0.020160681  3.506062628  45.229857  48.73592
  2 1.63e-05 1.63e+00 0.016336170  3.824083293  71.139331  74.96341
 2 4.47e-05 4.47e+00 0.021202062  7.895615485  57.452354  65.34797
 2 4.38e-05 4.38e+00 0.018721502  4.243604679 110.506859 114.75046
 2 0.00e+00 0.00e+00 0.044930944 13.552492860  88.273415 101.82591
 2 4.30e-05 4.30e+00 0.027125295  6.426449035  55.102468  61.52892
 2 3.80e-05 3.80e+00 0.029939680  0.007273809  92.734675  92.74195
 2 3.65e-06 3.65e-01 0.029382519  0.000221684 103.705858 103.70608
 2 6.36e-06 6.36e-01 0.023179423  1.228886505 127.803373 129.03226
 2 5.86e-13 5.86e-08 0.032732405  1.379044031 104.847896 106.22694
 2 5.71e-06 5.71e-01 0.011643722  2.680653511  77.883436  80.56409
 2 5.86e-13 5.86e-08 0.021973461  1.094195321  49.400687  50.49488
 2 5.86e-13 5.86e-08 0.020197172  2.084520515  51.311323  53.39584
 2 3.07e-06 3.07e-01 0.0  2.308138714 121.203022 123.51116
 3 5.26e-05 5.26e+00 0.012185655  3.348526610  35.880625  39.22915
 3 4.23e-05 4.23e+00 0.028480923  1.709440176  54.767838  56.47728
 3 5.56e-05 5.56e+00 0.0  1.429574183  41.604787  43.03436
 3 9.12e-06 9.12e-01 0.035704097  0.124131665  45.062952  45.18708
 3 2.99e-05 2.99e+00 0.010169719  1.261369666  51.920969  53.18234
 3 4.32e-05 4.32e+00 0.000490530  0.0  16.030226  16.03023


Oscar
-- 
Oscar
Oscar A. Linares, MD
Translational Medicine Unit
LaPlaisance Bay, Bolles Harbor
Monroe, Michigan 48161

Department of Medicine,
University of Toledo College of Medicine
Toledo, OH 43606-3390

Department of Internal Medicine,
The Detroit Medical Center (DMC)
Harper University Hospital
Wayne State University School of Medicine
Detroit, Michigan 48201

[[alternative HTML version deleted]]

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


Re: [R] [ggplot2] Wind rose orientation

2009-12-07 Thread hadley wickham
> The idea of plotting a wind rose must be fairly common.  I wonder if it
> would make sense to have a switch that would wrap data around the ends of a
> continuous scale?

Probably - but it requires a lot of work, because ggplot2 doesn't
currently support circular scales, which is what you really want.

Hadley

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

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


Re: [R] optim with constraints

2009-12-07 Thread JPO
Steven,

A quick trick to deal with problems of this nature (i.e. forcing
parameters to stay positive although the parameter search isn't bound
to non-negatives or positives) without resorting to another package is
to re-parametrize the density function.

Notice,
x \in (-\infty,\infty) for x \in (-\infty, \infty) but,
exp(x) \in (0, \infty) for x \in (\-infty, \infty).

Thus, you could replace your "scale" and "shape" parameters with "exp^
(notscale)" and "exp^(notshape)". You goal would be to optimize over
possible values of "notshape" and "notscale". Of course, the output is
giving you values of "notshape" and "notscale", which aren't the
quantities of interest. As such, "scale=exp^(notscale)" and "shape=exp^
(notshape)".

To be fair, this approach may not be desirable. It changes some things
with regard to the sampling distributions. Whereas you would have
immediately talked about the standard error for, say, the scale
parameter and you could have said that the sampling distribution of it
was asymptotically Normal, your sampling distribution of notscale is
asy. Normal, but scale=exp^(notscale) is not dist. asy. Normal.

Hope that is of some use,
JPO

On Dec 6, 5:53 am, Steven  wrote:
> Hi, dear R users
>
> I am a newbie in R and I wantto use the method of meximum likelihood
> to fit a Weibull distribution to my survival data. I use "optim" as
> follows:
>
> optim(c(1, 0.25),weibull.like,mydata=mydata,method="L-BFGS-B",hessian
> = TRUE)
>
> My question is: how do I setup the constraints so that the two
> parametrs of Weibull to be pisotive? Or should I use other function
> like"nlm"?
>
> Many thanks! Any comments are greatly appreciated!
>
> Steven
>
> __
> 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] [ggplot2] Wind rose orientation

2009-12-07 Thread Thomas S. Dye
Hi Hadley,

Thank you very much!

The idea of plotting a wind rose must be fairly common.  I wonder if  
it would make sense to have a switch that would wrap data around the  
ends of a continuous scale?

All the best,
Tom

On Dec 6, 2009, at 7:51 PM, hadley wickham wrote:

> Hi Tom,
>
> The problem was that the bars have width 22.5, so setting the limits
> to c(0, 360) chopped off the last bar.  To get around that, you needed
> to add half a bar width (11.25) to the start and end limits, and then
> rotate the polar coordinate system so that 0 lines up again.
>
> ggplot(wind.data, aes(x = degree, y = time, fill = wind)) +
> geom_bar(stat = "identity", aes(width = 22.5)) +
> scale_x_continuous(limits = c(0 + 11.25, 360 + 11.25), breaks = c(90,
> 180, 270, 360)) +
> coord_polar(start = 11.25 / 180 * pi) +
> scale_fill_brewer(pal = "Blues")
>
> Or now I've correctly identified the problem, we don't need to
> manually set the limits:
>
> ggplot(wind.data, aes(x = degree, y = time, fill = wind)) +
> geom_bar(stat = "identity", aes(width = 22.5)) +
> scale_x_continuous(breaks = c(90, 180, 270, 360)) +
> coord_polar(start = 11.25 / 180 * pi) +
> scale_fill_brewer(pal = "Blues")
>
>
> Hadley
>
> On Sun, Dec 6, 2009 at 7:30 PM, Thomas S. Dye  wrote:
>> Hi Hadley,
>> I don't know if you saw the message below.  I've worked with
>> scale_continuous() a bit in the interim to see if changing the  
>> limits would
>> bring back the 16th bar, but without success.  If I don't add in
>> scale_continuous(), then the 16th bar is shown.
>> Is this a ggplot2 bug?
>> I apologize for my persistence on this, but I'm working under a  
>> project
>> deadline.  I'm captivated by the grammar of graphics and would like  
>> to produce
>> all my graphs with ggplot2.  If there is a bug that swallows the  
>> 16th bar,
>> though, then I'll make my wind rose with another package and wait  
>> patiently
>> until ggplot2 plots the full compass.
>> Thanks again for a terrific software package.
>> All the best,
>> Tom
>> Begin forwarded message:
>>
>> From: "Thomas S. Dye" 
>> Date: December 3, 2009 9:42:27 PM HST
>> To: hadley wickham 
>> Cc: "r-help@r-project.org" 
>> Subject: Re: [R] [ggplot2] Wind rose orientation
>> Hi Hadley,
>>
>> That solved a lot of problems.  Thanks!
>>
>> Do you get a vertically oriented bar?  Here I get 15 bars with a  
>> space where
>> the north bar, the 16th bar, should be.
>>
>> All the best,
>> Tom
>>
>> On Dec 3, 2009, at 8:16 PM, hadley wickham wrote:
>>
>> Hi Thomas,
>>
>> Ok, the key thing that you were missing was:
>>
>> scale_x_continuous(limits = c(0, 360))
>>
>> Since you don't have any data at 0, and because ggplot2 doesn't know
>>
>> that your variable had intrinsic meaning as a degree, it was starting
>>
>> zero degrees at 22.5.
>>
>> A few other tweaks below:
>>
>> wind.data$wind <- factor(wind.data$wind,
>>
>> c("calm", "< 3", "4 - 12", "13 - 24", "> 25"))
>>
>> ggplot(wind.data, aes(x = degree, y = time, fill = wind)) +
>>
>> xlab(NULL) + ylab(NULL) +
>>
>> geom_bar(stat = "identity", aes(width = 22.5)) +
>>
>> scale_x_continuous(limits = c(0, 360), breaks = c(0, 90, 180, 270)) +
>>
>> coord_polar() +
>>
>> scale_fill_brewer(pal = "Blues")
>>
>> Regards,
>>
>> Hadley
>>
>> On Fri, Dec 4, 2009 at 12:02 AM, Thomas S. Dye  wrote:
>>
>> Aloha Hadley,
>>
>> Thanks very much for ggplot.  It's a terrific piece of work.   
>> Specifying
>>
>> width = 1 in the call to geom_bar didn't change the orientation of  
>> the
>>
>> coordinates.  If you run the example, you'll see that 100 is  
>> horizontal,
>>
>> where 90 would be on the compass.
>>
>> Here is a reproducible example.  The data are shown here as the  
>> results of
>>
>> evaluating the read-data source code block, displayed as an Org- 
>> mode table.
>>
>> A csv file is also attached (if it makes it through the list).
>>
>> #+srcname: read-data
>>
>> #+begin_src R :session
>>
>> wind.data <- read.csv("pmrf_windrose_info_new.csv")
>>
>> #+end_src
>>
>> #+resname: read-data
>>
>> | "E"   |90 | 4.9 | "calm"|
>>
>> | "ENE" |  67.5 | 4.9 | "calm"|
>>
>> | "NE"  |45 | 4.9 | "calm"|
>>
>> | "NNE" |  22.5 | 4.9 | "calm"|
>>
>> | "N"   |   360 | 4.9 | "calm"|
>>
>> | "NNW" | 337.5 | 4.9 | "calm"|
>>
>> | "NW"  |   315 | 4.9 | "calm"|
>>
>> | "WNW" | 292.5 | 4.9 | "calm"|
>>
>> | "W"   |   270 | 4.9 | "calm"|
>>
>> | "WSW" | 247.5 | 4.9 | "calm"|
>>
>> | "SW"  |   225 | 4.9 | "calm"|
>>
>> | "SSW" | 202.5 | 4.9 | "calm"|
>>
>> | "S"   |   180 | 4.9 | "calm"|
>>
>> | "SSE" | 157.5 | 4.9 | "calm"|
>>
>> | "SE"  |   135 | 4.9 | "calm"|
>>
>> | "ESE" | 112.5 | 4.9 | "calm"|
>>
>> | ""|90 |   9 | "< 3" |
>>
>> | ""|  67.5 |   3 | "< 3" |
>>
>> | ""|45 |   3 | "< 3" |
>>
>> | ""|  22.5 |   1 | "< 3" |
>>
>> | ""|   360 |   1 | "< 3" |
>>
>> | ""| 337.5 | 0.5 | "< 3" |
>>
>> | ""|   315 |   1 | "< 3" |
>>
>> | ""| 292.5 | 0.5

[R] multiple plots using summary in rms package

2009-12-07 Thread Mike Babyak
Dear All,

I wonder if someone can point me in the right direction here.  I'm working
with the rms library, R 2.9.2 under Windows XP.

I'm trying to arrange two plots side by side for a colleague.  mfrow or
mfcol do not seem to work, however, so I am obviously missing something
important.  I know that there have been changes in the graphics from Design
to rms, but am just not sure where to find specific documentation about this
particular issue.

Below is the code I'm using.  If I run the code except for the last plot
call, the first plot is correctly produces in the first column with empty
space for the second plot in col 2.  But when I add the second plot call, it
just overwrites the first plot in col1 on the left.

If I run the code below using something like plot(x~y) and plot(a~b) instead
of the two rms summary objects, it works fine, so I am assuming there is
something about rms I am missing.

I'd be happy to provide some data if that would help.

Any guidance would be greatly appreciated.

Thanks,

Mike Babyak
Duke University Medical Center



#summary of dietary variables broken out by Groups A, B, and C
sumfc<-summary(Group~fcgrain+fcveg+fcfruit+fcmeat+fcdairy+fcnsl+
fcfat+fcsatfat+fcsweet+fcsod,
method='reverse', overall=F,  test=F)

sumpc<-summary(Group~pcgrain+pcveg+pcfruit+pcmeat+pcdairy+
pcnsl+pcfat+pcsatfat+pcsweet+pcsod,
method='reverse', overall=F,  test=F)

par(mfcol=c(1,2),oma=c(1,0,4,0))
plot(sumfc, which='categorical',
main='Full Compliance',pch=c('A','B','C'))
 Key(0,-.1)

plot(sumpc, which='categorical',
main='At Least Partial Compliance',pch=c('A','B','C'))
mtitle("Dietary Adherence")

[[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] different model performance because of nlevels()???

2009-12-07 Thread LWF
Hello everybody,

I came across a problem when building a randomForest model. Maybe someone can 
help me.
I have a training- and a testdataset with a discrete response and ten 
predictors (numeric and factor variables). The two datasets are similar in 
terms of number of predictor, name of variables and datatype of variables 
(factor, numeric) except that only one predictor has got 20 levels in the 
training dataset and only 19 levels in the test dataset.
I found that the model performance is different when train and test a model 
with the unchanged datasets on the one hand and after assigning the levels of 
the training dataset on the testdataset. I only assign the levels and do not 
change the dataset itself however the models perform different.
Why???

Here is my code:
> library(randomForest)
> load("datasets.RData")  # import traindat and testdat
> nlevels(traindat$predictor1)
[1] 20
> nlevels(testdat$predictor1)
[1] 19
> nrow(traindat)
[1] 9838
> nrow(testdat)
[1] 3841
> set.seed(10)
> rf_orig <- randomForest(x=traindat[,-1], y=traindat[,1], xtest=testdat[,-1], 
> ytest=testdat[,1],ntree=100)
> data.frame(rf_orig$test$err.rate)[100,1]  # Error on test-dataset
[1] 0.3082531

# assign the levels of the training dataset th the test dataset for predictor 1
> levels(testdat$predictor1) <- levels(traindat$predictor1)  
> nlevels(traindat$predictor1)
[1] 20
> nlevels(testdat$predictor1)
[1] 20
> nrow(traindat)
[1] 9838
> nrow(testdat)
[1] 3841
> set.seed(10)
> rf_mod <- randomForest(x=traindat[,-1], y=traindat[,1], xtest=testdat[,-1], 
> ytest=testdat[,1],ntree=100)
> data.frame(rf_mod$test$err.rate)[100,1]   # Error on test-dataset
[1] 0.4808644  # is different

Cheers,
TIM

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


Re: [R] latex.table for table with character and numeric columns

2009-12-07 Thread Gerrit Draisma

Ha Charlie,
It helped.
It is just what i was looking for.
Gerrit.


Gerrit Draisma wrote:


Hallo,
I have a dataset with one or two columns with character data
and the rest with numeric data.
Using latex.table from the quantreg package produced a table,
but I cannot set the decimals.
For instance:
---
 > x<-data.frame(Name=c("Jan","Piet","Jan"), V=c(1,2.991,3))
 > latex.table(as.matrix(x),file="x",caption="x")
 > latex.table(as.matrix(x),file="x",caption="x",dec=2)
Error in round(x, dec) : Non-numeric argument to mathematical function
 >
---
Am I not using the right command, or is there a way around?
Thanks,
Gerrit.




Hi Gerrit,

I haven't used latex.table from quantreg so I can't comment on this
approach. However, I would recommend using the xtable package to format your
data.frame into LaTeX:

  require( xtable )

  x<-data.frame(Name=c("Jan","Piet","Jan"), V=c(1,2.991,3))

  # Create a table object from the data.frame
  latexTable <- xtable( x )

  # Set the number of digits in each column. Your example has two columns,
  # but we must specify three digits since the rownames count as a column.
  digits( latexTable ) <- c( 0, 0, 2 )

  # Print the table object in order to produce the LaTeX code.
  print( latexTable )

You should also read the help page for print.xtable() as it discusses many
options that can affect the final LaTeX output.

Hope this helps!

-Charlie


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


[R] Subset of time observations where timediff > 60 secs

2009-12-07 Thread Karl Ove Hufthammer
Dear list members

I have a rather large vector (part of a data frame) giving the time 
(date + time, POSIXct) of observations. The times are irregular (with 
both small and large jumps) but increasing, and there are several 
millions of them.

I now wish to reduce my data set, so that I only have observations which 
are at least (for example) 60 seconds apart. Basically, I need (all) the 
indices of my time variable where the difference in times are at least 
60 seconds.

I thought this would be a rather simple task, but perhaps I'm tired, for 
I couldn't figure out how to do it in a even moderately elegant way (not 
looping over all the values, which is quite slow).

This solution seemed sensible:

x=cumsum(diff(timevar) %/% 60)
ind=c(1,cumsum(rle(x)$lengths)+1) # And perhaps removing the last value

but doesn't work, as it only captures the 'first times' in each 
60-second interval following the first time value, and thus may include 
times with values that are closer than 60 seconds.

I also considered round.POSIXct and trunc.POSIXct, but these are not 
appropriate either, for obvious reasons.

So, any ideas how to do this in an elegant and efficient way?

-- 
Karl Ove Hufthammer

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


Re: [R] SAS "datalines" or "cards" statement equivalent in R?

2009-12-07 Thread Marshall Feldman
Regarding the various methods people have suggested, what if a typical 
tab-delimited data line looks like:


 SMS11001 1990 M01 688.0

and the SAS INPUT statement is

   INPUT survey $ 1-2 seasonal $ 3 state $ 4-5 area $ 6-10 supersector 
$ 11-12 @13 industry $8. datatype $ 21-22  year period $ value footnote $ ;


Note that most data lines have no footnote item, as in the sample.

Here (I think) we'd want all the character variables to be read as 
factors, possibly "year" as a date, and "value" as numeric.


   Marsh

On Sat, Dec 5, 2009 at 8:11 PM, Gary Miller <> wrote:





>>  Hi R Users,
>>
>> Is there a equivalent command in R where I can read in raw data? For
>> example
>> I'm looking for equivalent R code for following SAS code:
>>
>> DATA survey;
>>   INPUT id sex $ age inc r1 r2 r3 ;
>>   DATALINES;
>>  1  F  35 17  7 2 2
>> 17  M  50 14  5 5 3
>> 33  F  45  6  7 2 7
>> 49  M  24 14  7 5 7
>> 65  F  52  9  4 7 7
>> 81  M  44 11  7 7 7
>> 2   F  34 17  6 5 3
>> 18  M  40 14  7 5 2
>> 34  F  47  6  6 5 6
>> 50  M  35 17  5 7 5
>> ;
>>
>> Any help would be highly appreciated,
>> Gary


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

2009-12-07 Thread choonhong ang
Hi,

I have a set of data (total number of record = 144,122), and I would like to
use gamma-glm with log link to set up a model.

IC is number of records
IL is paid amount

The table below shows that I have
30.578% of the data in the level of "1 - 1000" paid amount
20.320% of the data in the level of "1001 - 2000" paid amount
and so on

My question is could i use the whole data set to model ?
or may be i have to use the data up to 10,000 paid amount ?

 Level IL  Avg IL  Sum IC  1-1000539.60 44,069 30.578% 1001
- 2000  1,444.81 29,285 20.320% 2001 - 3000  2,457.72 15,343
10.646% 3001 - 4000  3,473.40   8,497 5.896% 4001 - 5000  4,496.47
  5,838 4.051% 5001 - 6000  5,476.28   3,831 2.658% 6001 -
7000
6,482.82   2,889 2.005% 7001 - 8000  7,500.97   2,323 1.612% 8001
- 9000  8,492.07   1,772 1.230% 9001 - 1  9,542.60   1,736
1.205% 10001 - 1100010,490.19   1,291 0.896% 11001 - 1200011,516.00
  1,104 0.766% 12001 - 1300012,508.65 915 0.635% 13001 -
1400013,501.24 869 0.603% 14001 - 1500014,562.99 876
0.608% 15001 - 1600015,502.50 650 0.451% 16001 - 1700016,498.90
585 0.406% 17001 - 1800017,511.23 573 0.398% 18001 -
1900018,529.04 512 0.355% 19001 - 219,605.73 615
0.427% 21001 - 2200021,518.71 448 0.311% 22001 - 2300022,489.74
389 0.270% 23001 - 2400023,493.52 340 0.236% 24001 -
2500024,603.33 413 0.287% 25001 - 2600025,516.57 324
0.225% 26001 - 2700026,514.70 297 0.206% 27001 - 2800027,509.62
272 0.189% 28001 - 2900028,486.77 238 0.165% 29001 -
329,591.02 312 0.216% 30001 - 3100030,460.08 238
0.165% 31001 - 3200031,527.67 240 0.167% 32001 - 3300032,526.25
213 0.148% 33001 - 3400033,496.41 208 0.144% 34001 -
3500034,556.44 235 0.163% 35001 - 3600035,476.62 190
0.132% 36001 - 3700036,512.92 155 0.108% 37001 - 3800037,524.77
191 0.133% 38001 - 3900038,469.21 152 0.105% 39001 -
439,554.93 176 0.122% 40001 - 4100040,501.28 171
0.119% 41001 - 4200041,521.06 182 0.126% 42001 - 4300042,525.54
156 0.108% 43001 - 4400043,541.32 118 0.082% 44001 -
4500044,549.38 131 0.091% 45001 - 4600045,513.78 125
0.087% 46001 - 4700046,532.88 128 0.089% 47001 - 4800047,528.92
121 0.084% 48001 - 4900048,472.52 115 0.080% 49001 -
549,684.14 191 0.133% 50001 - 5100050,556.99 104
0.072% 51001 - 5200051,527.56 119 0.083% 52001 - 5300052,519.82
120 0.083% 53001 - 5400053,504.29 105 0.073% 54001 -
5500054,527.36 126 0.087% 55001 - 5600055,566.20   94
0.065% 56001 - 5700056,533.86   98 0.068% 57001 - 58000
57,494.78
112 0.078% 58001 - 5900058,555.27 100 0.069% 59001 -
659,592.80 134 0.093% 60001 - 6100060,540.90   94
0.065% 61001 - 6200061,488.11   93 0.065% 62001 - 63000
62,543.60
  95 0.066% 63001 - 6400063,509.94   95 0.066% 64001 -
6500064,578.59   97 0.067% 65001 - 6600065,486.95   82
0.057% 66001 - 6700066,518.80   72 0.050% 67001 - 68000
67,507.95
  85 0.059% 68001 - 6900068,516.98   86 0.060% 69001 -
769,541.52   89 0.062% 70001 - 7100070,519.49   77
0.053% 71001 - 7200071,488.88   74 0.051% 72001 - 73000
72,483.43
  72 0.050% 73001 - 7400073,489.59   82 0.057% 74001 -
7500074,601.14   92 0.064% 75001 - 7600075,467.29   78
0.054% 76001 - 7700076,550.53   74 0.051% 77001 - 78000
77,525.18
  76 0.053% 78001 - 7900078,481.88   74 0.051% 79001 -
879,555.44   78 0.054% 80001 - 8100080,443.24   72
0.050% 81001 - 8200081,504.18   67 0.046% 82001 - 83000
82,510.68
  78 0.054% 83001 - 8400083,483.89   78 0.054% 84001 -
8500084,566.99   84 0.058% 85001 - 8600085,504.36   86
0.060% 86001 - 8700086,584.49   67 0.046% 87001 - 88000
87,540.17
  60 0.042% 88001 - 8900088,483.13   73 0.051% 89001 -
989,532.23   70 0.049% 90001 - 9100090,521.94   73
0.051% 91001 - 9200091,597.56   62 0.043% 92001 - 93000
92,499.65
  75 0.052% 93001 - 9400093,515.79   64 0.044% 94001 -
9500094,524.84   76 0.053% 95001 - 9600095,469.49   81
0.056% 96001 - 9700096,492.13   55 0.038% 97001 - 98000
97,454.56
  62 0.043% 98001 - 9900098,493.23   57 0.040% 99001 -

Re: [R] How to apply five lines of code to ten dataframes?

2009-12-07 Thread guohao.huang


For example,
tt1 = 2:4
ind = 1
evalstr = paste("xx = tt", ind, sep = "")
eval(parse(text=evalstr))
==> x = 2, 3, 4

It's easy for you to write a for loop to solve your problems


   Guo-Hao Huang


--
From: "Mark Na" 
Sent: Monday, December 07, 2009 11:07 PM
To: 
Subject: [R] How to apply five lines of code to ten dataframes?


Hello R-helpers,

I have 10 dataframes (named data1, data2, ... data10) and I would like to
add 5 new columns to each dataframe using the following code:

data1$LogDepth<-log10(data1[,2]/data1[,4])
data1$LogArea<-log10(data1[,3]/data1[,5])
data1$p<-2*data1[,6]/data1[,7]
data1$Exp<-data1[,2]^(2/data1[,8])
data1$s<-data1[,3]/data1[,9]

...but I would prefer not to repeat this chunk of code 10 times!

I have struggled with setting up a loop to apply these 5 lines of code to
each of the 10 dataframes, but I'm not having much luck.

Any help would be much appreciated.

Thank you, Mark

[[alternative HTML version deleted]]

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

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



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


Re: [R] How to apply five lines of code to ten dataframes?

2009-12-07 Thread baptiste auguie
Hi,

You could define a function that does the calculations for a given
data.frame and apply it to all your data.frames,


d1 <- data.frame(a=1:10, b=rnorm(10))
d2 <- data.frame(a=-(1:10), b=rnorm(10))

calculations <- function(d){

  if(is.character(d)) d <- get(d)

  transform(d,
c = a^2,
d = d[, 1] + d$b)
}


calculations(d1)

lapply(paste("d", 1:2, sep=""), calculations)

HTH,

baptiste

2009/12/7 Mark Na :
> Hello R-helpers,
>
> I have 10 dataframes (named data1, data2, ... data10) and I would like to
> add 5 new columns to each dataframe using the following code:
>
> data1$LogDepth<-log10(data1[,2]/data1[,4])
> data1$LogArea<-log10(data1[,3]/data1[,5])
> data1$p<-2*data1[,6]/data1[,7]
> data1$Exp<-data1[,2]^(2/data1[,8])
> data1$s<-data1[,3]/data1[,9]
>
> ...but I would prefer not to repeat this chunk of code 10 times!
>
> I have struggled with setting up a loop to apply these 5 lines of code to
> each of the 10 dataframes, but I'm not having much luck.
>
> Any help would be much appreciated.
>
> Thank you, Mark
>
>        [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

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


[R] How to apply five lines of code to ten dataframes?

2009-12-07 Thread Mark Na
Hello R-helpers,

I have 10 dataframes (named data1, data2, ... data10) and I would like to
add 5 new columns to each dataframe using the following code:

data1$LogDepth<-log10(data1[,2]/data1[,4])
data1$LogArea<-log10(data1[,3]/data1[,5])
data1$p<-2*data1[,6]/data1[,7]
data1$Exp<-data1[,2]^(2/data1[,8])
data1$s<-data1[,3]/data1[,9]

...but I would prefer not to repeat this chunk of code 10 times!

I have struggled with setting up a loop to apply these 5 lines of code to
each of the 10 dataframes, but I'm not having much luck.

Any help would be much appreciated.

Thank you, Mark

[[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] Subset sum problem.

2009-12-07 Thread guohao.huang

The problem is NP-Complete and the real problem is how you can solve it.
According to the wiki page, you can use the bottom algorithm(Polynomial time 
approximate algorithm) to solve your problems.

If you had trouble with writing R code, you can read ``R-introduction''.

regards



   Guo-Hao Huang



--
From: "Geert Janssens" 
Sent: Monday, December 07, 2009 10:56 PM
To: 
Subject: [R] Subset sum problem.


Hi,

I'm quite new to the R-project. I was suggested to look into it because I 
am

trying to solve the "Subset sum" problem", which basically is:
Given a set of integers and an integer s, does any non-empty subset sum to 
s?

(See http://en.wikipedia.org/wiki/Subset_sum_problem)

I have been searching the web for quite some time now (which is how I
eventually discovered that my problem is called subset sum), but I can't 
seem
to find an easily applicable implementation. I did search the list 
archive,

the R website and used the help.search and apropos function. I'm afraid
nothing obvious showed up for me.

Has anybody tackled this issue before in R ? If so, I would be very 
grateful

if you could share your solution with me.

Thank you very much.

Geert

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

2009-12-07 Thread Geert Janssens
Hi,

I'm quite new to the R-project. I was suggested to look into it because I am 
trying to solve the "Subset sum" problem", which basically is:
Given a set of integers and an integer s, does any non-empty subset sum to s?
(See http://en.wikipedia.org/wiki/Subset_sum_problem)

I have been searching the web for quite some time now (which is how I 
eventually discovered that my problem is called subset sum), but I can't seem 
to find an easily applicable implementation. I did search the list archive, 
the R website and used the help.search and apropos function. I'm afraid 
nothing obvious showed up for me.

Has anybody tackled this issue before in R ? If so, I would be very grateful 
if you could share your solution with me.

Thank you very much.

Geert

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


Re: [R] Forest Plot

2009-12-07 Thread Viechtbauer Wolfgang (STAT)
If you just want a forest plot, then the forest() function.

If you have the betas and corresponding variances, then you can create a forest 
plot with:

forest(betas, varbetas)

And yes, estimate +/- 1.96*sqrt(variance of estimate) would be an *approximate* 
95% CI.

Best,

--
Wolfgang Viechtbauerhttp://www.wvbauer.com/
Department of Methodology and StatisticsTel: +31 (0)43 388-2277
School for Public Health and Primary Care   Office Location:
Maastricht University, P.O. Box 616 Room B2.01 (second floor)
6200 MD Maastricht, The Netherlands Debyeplein 1 (Randwyck)


Original Message
From: Xin Ge [mailto:xingemaill...@gmail.com]
Sent: Sunday, December 06, 2009 00:40
To: Viechtbauer Wolfgang (STAT)
Cc: r-help@r-project.org
Subject: Re: [R] Forest Plot

> Thanks for your reply. Which function I should explore in "metafor"
> package for this kind of plot.
>
> Also I have to do a forest plot for "regressions estimates" (betas)
> and corresponding "sqrt(var)". I hope in this case there is no
> difference between std. error and std. deviation? So, a 95%
> confidence interval would be [estimate +/- 1.96*sqrt(variance of
> estimate)]. Am I correct in saying this?
>
> Thanks again,
> Xin
>
>
> On Sat, Dec 5, 2009 at 6:21 PM, Viechtbauer Wolfgang (STAT)
>  wrote:
>
> The figure that you linked to was produced with the "metafor"
> package. It can also be used to produce a forest plot if you have
> means and corresponding standard errors of the means. The standard
> error of a mean is equal to SD / sqrt(n), so as long as you also know
> the sample sizes (n), you can convert those standard deviations to
> the standard errors.
>
> Best,
>
> --
> Wolfgang Viechtbauerhttp://www.wvbauer.com/
> Department of Methodology and StatisticsTel: +31 (0)43 388-2277
> School for Public Health and Primary Care   Office Location:
> Maastricht University, P.O. Box 616 Room B2.01 (second floor)
> 6200 MD Maastricht, The Netherlands Debyeplein 1 (Randwyck)
> 
> From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On
> Behalf Of Xin Ge [xingemaill...@gmail.com]
> Sent: Sunday, December 06, 2009 12:11 AM
> To: r-help@r-project.org
> Subject: [R] Forest Plot
>
>
> Hi All,
>
> I want to produce a similar "Forest Plot" as it is on the following
> link, but my data would be having only two columns (one for
> "Estimate" and other for "Std. Dev"). Can anyone suggest some
> function() {Package} which can take such file as an input and give
> following forest plot:
>
> http://bm2.genes.nig.ac.jp/RGM2/R_current/library/metafor/man/images/big_plot.rma.uni_001.png
>
> Thanks,
> Xin

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


Re: [R] outputting functions in lapply

2009-12-07 Thread baptiste auguie
Hi,

I was about to send the exact same answer as you just received, so
I'll add a note instead. Your problem looks a bit like Currying,

Curry <-  # original from roxygen
function (f, ..., .left=TRUE)
{
.orig = list(...)
function(...){
if(.left) {args <- c(.orig, list(...))} else {args <- c(list(...), 
.orig)}
 do.call(f, args)
}
}

Curry( function(k, r) print(paste(r, "<- r | k ->", k)), k=2)(1)
# "1 <- r | k -> 2"

Best,

baptiste



2009/12/7 Rune Schjellerup Philosof :
> How come the k is 3 in all of this output?
> I expected it to be equal to r.
>
>> tmp3 <- lapply(1:3, function(k) function(r) print(paste(r, "<- r | k
> ->", k)))
>> for (i in 1:3) { tmp3[[i]](i) }
> [1] "1 <- r | k -> 3"
> [1] "2 <- r | k -> 3"
> [1] "3 <- r | k -> 3"
>
> --
> Med venlig hilsen
>
> Rune Schjellerup Philosof
> Ph.d-stipendiat, Forskningsenheden for Biostatistik
>
> Telefon: 6550 3607
> E-mail:  rphilo...@health.sdu.dk
> Adresse: J.B. Winsløwsvej 9, 5000 Odense C
>
> SYDDANSK UNIVERSITET
> ___
> * Campusvej 55 * 5230 * Odense M * 6550 1000 * www.sdu.dk
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] optim with constraints

2009-12-07 Thread Ravi Varadhan
Steven,

You haven't given us much information to help you.  Are you `maximizing' the
log-likelihood or are you `minimizing' the negative log-likelihood?  If it
is the former, you have to specify the control argument, control$fnscale =
-1.  This is a common mistake when using optim for likelihood estimation.

Ravi.


---

Ravi Varadhan, Ph.D.

Assistant Professor, The Center on Aging and Health

Division of Geriatric Medicine and Gerontology 

Johns Hopkins University

Ph: (410) 502-2619

Fax: (410) 614-9625

Email: rvarad...@jhmi.edu

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

 





-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Prof. John C Nash
Sent: Monday, December 07, 2009 9:01 AM
To: r-help@r-project.org
Subject: Re: [R] optim with constraints


Without the data / script, I'm guessing that it is likely an attempt to
evaluate the loss 
function at an inadmissible point e.g., at the constraint where there is a
log(0). 
Different optimization tools handle things differently, and there are a
couple of us 
working (very slowly due to other things) on trying to provide a nice
wrapper to catch 
these exceptions so that they can be handled better.

JN


> Message: 56
> Date: Sun, 6 Dec 2009 17:32:54 -0800 (PST)
> From: Steven 
> Subject: Re: [R] optim with constraints
> To: r-help@r-project.org
> Message-ID:
>   <88d5c01d-c30c-4e91-900c-2b825d5e3...@z4g2000prh.googlegroups.com>
> Content-Type: text/plain; charset=ISO-8859-1
> 
> Hi, Prof Nash
> 
> Thanks for your comment!
> 
> I modified my code to be (added an extra parametr):
> 
> optim(c(1.14,0.25,0.06), weibull.like, mydata=mydata, method="L-BFGS-
> B", hessian = TRUE, lower = c(0, 0, 0), upper = c(Inf, Inf, 1))
> 
> But I had the following error:
> 
> Error in optim(c(1.14, 0.25, 0.06), weibull.like, mydata = mydata,
> method = "L-BFGS-B",  :
>   non-finite finite-difference value [2]
> 
> What does that mean? Much appreciate your help!
> 
> Steven
>

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

2009-12-07 Thread Duncan Murdoch

On 07/12/2009 8:53 AM, Rune Schjellerup Philosof wrote:

How come the k is 3 in all of this output?
I expected it to be equal to r.

> tmp3 <- lapply(1:3, function(k) function(r) print(paste(r, "<- r | k
->", k)))
> for (i in 1:3) { tmp3[[i]](i) }
[1] "1 <- r | k -> 3"
[1] "2 <- r | k -> 3"
[1] "3 <- r | k -> 3"

  
Because of lazy evaluation.  The argument k never gets evaluated in the 
lapply loop.  Add "force(k)" before you create the function, and you'll 
get the expected output:


> tmp3 <- lapply(1:3, function(k) { force(k); function(r) 
print(paste(r, "<- r | k ->", k))} )

> for (i in 1:3) { tmp3[[i]](i) }
[1] "1 <- r | k -> 1"
[1] "2 <- r | k -> 2"
[1] "3 <- r | k -> 3"

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] savePlot for Mac and / or Linux?

2009-12-07 Thread James W. MacDonald

Hi Christophe,

No, there isn't anything close to savePlot() on either Linux or MacOS. 
But the difference is that savePlot() is used to save something that has 
already been plotted. Since your function appears to be intended to give 
the user the ability to save something that has yet to be plotted, you 
could simply use a switch() statement in the body of your function:



switch(type, pdf = {
pdf("plotname.pdf")
plot()
dev.off()
},
jpeg = {
jpeg("plotname.jpg")
plot()
dev.off()
},
png = {
png("plotname.png")
plot()
dev.off()
})

You can also plot things first and use recordPlot() and replayPlot() to 
emulate savePlot(). In addition, you can get tricky and check to see if 
the version of R being used is capable of doing a particular plot type 
using capabilities() and then trapping errors where the end user wants 
to create a plot that their R installation won't do.


Best,

Jim



Christophe Genolini wrote:

Hi all,

In the package rtlu, I use the function savePlot. It is convenient since 
it let the user decide in which graphic format he wants his graph to be 
export.

But when I run R CMD check, I get the following message :

 rtlu(V1,fileOutput="First.tex",textBefore="\\section{Variable 1 to 

3}",graphName="V1")
Error in savePlot(filename = nomBarplot, type = type) : can only copy 
from 'windows' devices

Calls: rtlu ... r2lUniv -> r2lUniv.factor -> r2lBarplot -> savePlot
Execution halted

I guess this is a compatibility problem with Linux/Mac? Is there 
something close to savePlot for Mac / Linux?


Christophe

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

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


--
James W. MacDonald, M.S.
Biostatistician
Douglas Lab
University of Michigan
Department of Human Genetics
5912 Buhl
1241 E. Catherine St.
Ann Arbor MI 48109-5618
734-615-7826
**
Electronic Mail is not secure, may not be read every day, and should not be used for urgent or sensitive issues 


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


Re: [R] Passing arguments to gpar

2009-12-07 Thread Sebastien Bihorel

Hi,

Yes, that is exactly it. Charlie Sharpsteen gave me the same solution 
last week but he probably just replied to me, so his email did not go to 
the list. Thanks for the reply, I appreciate it I always forget 
about this do.call function.



Paul Murrell wrote:

Hi


Sebastien Bihorel wrote:

Dear R-users,

I would like to know how to pass arguments to gpar() without 
hard-coding them. I tried to store my arguments in a list and passed 
this list to gpar(), but it did find the way to do it properly. Any 
help would be appreciated.


a<- list(fontisze=8,col=3)
gpar(fontsize=8,col=3)
gpar(a)
gpar(unlist(a))



Are you looking for this ... ?

do.call("gpar", a)

Paul



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

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




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


Re: [R] optim with constraints

2009-12-07 Thread Prof. John C Nash


Without the data / script, I'm guessing that it is likely an attempt to evaluate the loss 
function at an inadmissible point e.g., at the constraint where there is a log(0). 
Different optimization tools handle things differently, and there are a couple of us 
working (very slowly due to other things) on trying to provide a nice wrapper to catch 
these exceptions so that they can be handled better.


JN



Message: 56
Date: Sun, 6 Dec 2009 17:32:54 -0800 (PST)
From: Steven 
Subject: Re: [R] optim with constraints
To: r-help@r-project.org
Message-ID:
<88d5c01d-c30c-4e91-900c-2b825d5e3...@z4g2000prh.googlegroups.com>
Content-Type: text/plain; charset=ISO-8859-1

Hi, Prof Nash

Thanks for your comment!

I modified my code to be (added an extra parametr):

optim(c(1.14,0.25,0.06), weibull.like, mydata=mydata, method="L-BFGS-
B", hessian = TRUE, lower = c(0, 0, 0), upper = c(Inf, Inf, 1))

But I had the following error:

Error in optim(c(1.14, 0.25, 0.06), weibull.like, mydata = mydata,
method = "L-BFGS-B",  :
  non-finite finite-difference value [2]

What does that mean? Much appreciate your help!

Steven



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

2009-12-07 Thread Rune Schjellerup Philosof
How come the k is 3 in all of this output?
I expected it to be equal to r.

> tmp3 <- lapply(1:3, function(k) function(r) print(paste(r, "<- r | k
->", k)))
> for (i in 1:3) { tmp3[[i]](i) }
[1] "1 <- r | k -> 3"
[1] "2 <- r | k -> 3"
[1] "3 <- r | k -> 3"

-- 
Med venlig hilsen

Rune Schjellerup Philosof
Ph.d-stipendiat, Forskningsenheden for Biostatistik

Telefon: 6550 3607
E-mail:  rphilo...@health.sdu.dk
Adresse: J.B. Winsløwsvej 9, 5000 Odense C

SYDDANSK UNIVERSITET
___
* Campusvej 55 * 5230 * Odense M * 6550 1000 * www.sdu.dk

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


Re: [R] RandomForest - getTree status code

2009-12-07 Thread Liaw, Andy
Is that the entire tree?  If so there's a problem.  The node status is
defined as follows in rf.h of the source code:

#define NODE_TERMINAL -1
#define NODE_TOSPLIT  -2
#define NODE_INTERIOR -3

i.e., "-3" means "non-terminal" node.

Andy
 

> -Original Message-
> From: r-help-boun...@r-project.org 
> [mailto:r-help-boun...@r-project.org] On Behalf Of NCS
> Sent: Friday, December 04, 2009 4:53 PM
> To: r-help@r-project.org
> Subject: [R] RandomForest - getTree status code
> 
> 
> What does a status value of -3 mean when I do a regression 
> with RF and use the getTree function?
> 
>  left daughter right daughter split var  split point 
> status prediction
> 12  311 4.721000e+03 
> -3 15.8489576
> 24  5 5 6.50e+00 
> -3 11.3240895
> 36  710 6.790674e+02 
> -3 23.7250079
> 48  911 1.562500e+03 
> -3  9.6885129
> 5   10 11 7 7.085000e+02 
> -3 15.2126457
> 6   12 13 3 1.105000e+02 
> -3 22.3736330
> 7   14 1511 2.249400e+04 
> -3 37.9011956
> 8   16 17 2 6.805105e+00 
> -3  5.0804247
> 9   18 19 7 6.775000e+02 
> -3 11.9877469
> 10  20 21 5 1.45e+01 
> -3 12.6068710
> 
> Thanks
> ncs
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
Notice:  This e-mail message, together with any attachme...{{dropped:10}}

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


Re: [R] Installing RandomForest on SuSe Linux - warnings

2009-12-07 Thread Liaw, Andy
Those are the same warnings I get when I test the package (before submitting to 
CRAN) and have been that way for a long time.  They stemmed from conditional 
allocation of arrays in C.  gcc -wall seems to always pick on that.  As far as 
I know, they are harmless.

Andy 

> -Original Message-
> From: r-help-boun...@r-project.org 
> [mailto:r-help-boun...@r-project.org] On Behalf Of NCS
> Sent: Friday, December 04, 2009 5:45 PM
> To: r-help@r-project.org
> Subject: [R] Installing RandomForest on SuSe Linux - warnings
> 
> 
> 
> I installed RF on Linux OpenSuSe 11.1 and while it did 
> install and did run a model I had created on Windows 
> correctly, it gave me a lot of "uninitialized" warnings.  I 
> don't know if these are significant and so am a little 
> concerned even though my model ran.  Any thoughts?
> 
> Thanks
> 
> R version 2.10.0 (2009-10-26)
> Copyright (C) 2009 The R Foundation for Statistical Computing
> ISBN 3-900051-07-0
> 
> R is free software and comes with ABSOLUTELY NO WARRANTY.
> You are welcome to redistribute it under certain conditions.
> Type 'license()' or 'licence()' for distribution details.
> 
>   Natural language support but running in an English locale
> 
> R is a collaborative project with many contributors.
> Type 'contributors()' for more information and
> 'citation()' on how to cite R or R packages in publications.
> 
> Type 'demo()' for some demos, 'help()' for on-line help, or
> 'help.start()' for an HTML browser interface to help.
> Type 'q()' to quit R.
> 
> > install.packages("randomForest")
> --- Please select a CRAN mirror for use in this session ---
> CRAN mirror
> 
>  1: Argentina (Buenos Aires)   2: Australia
>  3: Austria4: Belarus
>  5: Belgium6: Brazil (PR)
>  7: Brazil (RJ)8: Brazil (SP 1)
>  9: Brazil (SP 2) 10: Canada (BC)
> 11: Canada (ON)   12: Canada (QC)
> 13: Chile 14: China (Beijing 1)
> 15: China (Beijing 2) 16: China (Hong Kong)
> 17: Colombia  18: Denmark
> 19: France (Toulouse) 20: France (Lyon)
> 21: France (Paris)22: Germany (Berlin)
> 23: Germany (Goettingen)  24: Germany (Hannover)
> 25: Germany (Muenchen)26: Germany (Wiesbaden)
> 27: Iran  28: Ireland
> 29: Italy (Milano)30: Italy (Padua)
> 31: Italy (Palermo)   32: Japan (Aizu)
> 33: Japan (Hyogo) 34: Japan (Tokyo)
> 35: Japan (Tsukuba)   36: Korea
> 37: Netherlands   38: New Zealand
> 39: Norway40: Poland (Oswiecim)
> 41: Poland (Wroclaw)  42: Portugal
> 43: Russia44: Singapore 1
> 45: Singapore 2   46: Slovakia
> 47: South Africa  48: Spain (Madrid)
> 49: Sweden50: Switzerland
> 51: Taiwan (Taichung) 52: Taiwan (Taipeh)
> 53: Thailand  54: UK (Bristol)
> 55: UK (London)   56: USA (AZ)
> 57: USA (CA 1)58: USA (CA 2)
> 59: USA (IA)  60: USA (MA)
> 61: USA (MD)  62: USA (MI)
> 63: USA (MO)  64: USA (NC)
> 65: USA (OH)  66: USA (PA 1)
> 67: USA (PA 2)68: USA (TN)
> 69: USA (TX 1)70: USA (TX 3)
> 71: USA (WA)
> 
> Selection: 57
> trying URL 
> 'http://cran.cnr.Berkeley.edu/src/contrib/randomForest_4.5-33.tar.gz'
> Content type 'application/x-gzip' length 71745 bytes (70 Kb)
> opened URL
> ==
> downloaded 70 Kb
> 
> * installing *source* package ârandomForestâ ...
> ** libs
> gcc -std=gnu99 -I/usr/lib64/R/include  -I/usr/local/include   
>  -fpic  -fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 
> -fstack-protector -funwind-tables 
> -fasynchronous-unwind-tables -c classTree.c -o classTree.o
> classTree.c: In function âpredictClassTreeâ:
> classTree.c:414: warning: âcbestsplitâ may be used 
> uninitialized in this function
> gcc -std=gnu99 -I/usr/lib64/R/include  -I/usr/local/include   
>  -fpic  -fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 
> -fstack-protector -funwind-tables 
> -fasynchronous-unwind-tables -c regTree.c -o regTree.o
> regTree.c: In function âpredictRegTreeâ:
> regTree.c:294: warning: âcbestsplitâ may be used 
> uninitialized in this function
> gcc -std=gnu99 -I/usr/lib64/R/include  -I/usr/local/include   
>  -fpic  -fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 
> -fstack-protector -funwind-tables 
> -fasynchronous-unwind-tables -c regrf.c -o regrf.o
> regrf.c: In function âregRFâ:
> regrf.c:61: warning: ânodextsâ may be used uninitialized in 
> this function
> regrf.c:55: warning: âytreeâ may be used uninitialized in 
> this function
> gcc -std=gnu99 -I/usr/lib64/R/include  -I/usr/local/include   
>  -fpic  -fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 
> -fstack-protector -funwind-tables 
> -fasynchronous-unwind-tables -c rf.c -o rf.o
> rf.c: In func

Re: [R] data.frame to "stacked frame"

2009-12-07 Thread Henrique Dallazuanna
Try this:

cbind(stack(dfw, select = -group), dfw$group)

On Mon, Dec 7, 2009 at 11:20 AM, Christian Schulz  wrote:
> Hi,
>
> have anybody a hint how i could avoid the cumbersome way (..especially the
> value part)
> change the data representation from  n column data.frame to an stacked
> representation.
>
> many thanks
> Christian
>
> #example data
> dfw <- as.data.frame(matrix(runif(10*10),ncol=10))
> dfw$group <- sample(c("X","Z"),nrow(dfw),replace=T,prob=c(0.75,0.25))
>
> # change
> var   <- rep(names(dfw)[-length(dfw)],nrow(dfw))
> group <- rep(dfw$group,nrow(dfw))
>
> #cumbersome
> value <- vector()
> z=1
> for(i in 1:(length(dfw)-1)){
> for(j in 1:nrow(dfw)){
> value[z] <-   dfw[j,i]
> z=z+1
> }
> }
>
> dfr <- cbind(var,group,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] data.frame to "stacked frame"

2009-12-07 Thread Christian Schulz

Hi,

have anybody a hint how i could avoid the cumbersome way (..especially 
the value part)
change the data representation from  n column data.frame to an stacked 
representation.


many thanks
Christian

#example data
dfw <- as.data.frame(matrix(runif(10*10),ncol=10))
dfw$group <- sample(c("X","Z"),nrow(dfw),replace=T,prob=c(0.75,0.25))

# change
var   <- rep(names(dfw)[-length(dfw)],nrow(dfw))
group <- rep(dfw$group,nrow(dfw))

#cumbersome
value <- vector()
z=1
for(i in 1:(length(dfw)-1)){
for(j in 1:nrow(dfw)){
value[z] <-   dfw[j,i]
z=z+1
}
}

dfr <- cbind(var,group,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] regression tests still fail for R version 2.10.0

2009-12-07 Thread Gavin Simpson
Do you have R_LIBS set to you library of packages? I got this error
without fail when trying to R CMD check on my hand compiled R
2.10-patched. R_LIBS was set to my own library and it was full of 2.9.x
packages. When I looked in ./tests/reg-tests-1.Rout I got the error
about out of date packages or similar.

It would be useful to see the output from

tail -n 20 ./tests/reg-tests-1.Rout

to see what the problem is. Did you look there?

HTH

G

On Sun, 2009-12-06 at 19:44 +, Oliver Kullmann wrote:
> On Sat, Dec 05, 2009 at 01:39:03PM -0500, David Winsemius wrote:
> > The question lacks so many specifics that would be needed to address  
> > problem that I suspect persons with sufficient knowledge to address it  
> > (and I am probably not among that group) simply passed it over and  
> > waited for you to get sufficiently motivated to actually  read the  
> > Posting Guide.
> 
> Thanks for your answer!
> 
> I'm for quite some time now on that mailing list, and I read quite a few
> of the e-mails: Most of the e-mails are far worse, but get quite a lot
> of attention. I can't find anything in the posting guidelines which
> speakes about installation; I also can't find something on what are
> "OS specifics", and how to obtain them from R. There is this session-info,
> which as described seems to be not applicable here, but on the other
> hand seems to be the only thing which yields some output:
> 
> > sessionInfo()
> R version 2.9.2 (2009-08-24)
> x86_64-unknown-linux-gnu
> 
> locale:
> LC_CTYPE=en_GB.UTF-8;LC_NUMERIC=C;LC_TIME=en_GB.UTF-8;LC_COLLATE=en_GB.UTF-8;LC_MONETARY=C;LC_MESSAGES=en_GB.UTF-8;LC_PAPER=en_GB.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_GB.UTF-8;LC_IDENTIFICATION=C
> 
> attached base packages:
> [1] stats graphics  grDevices utils datasets  methods   base
> 
> 
> This is of course the old version (where the regression tests didn't fail).
> What else could be relevant? Linux was already mentioned (Suse 10.0), 64-bit 
> AMD machine.
> 
> Installation by "./configure --prefix=/path_to_local_directory; make; make 
> check".
> 
> > gcc --version
> gcc (GCC) 4.1.2
> Copyright (C) 2006 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions.  There is NO
> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
> 
> I'm not aware that there are different source-packages of R around? Other than
> R-2.10.0.tar.gz.
> 
> > md5sum R-2.10.0.tar.gz
> 4486934883b1dbcd5400135e22b26a75  R-2.10.0.tar.gz
> 
> 
> Why I am building from sources? Shouldn't this be irrelevant --- in my
> e-mail I just try to *help* R, and any information on problems should be
> relevant, irrespective of the person who submits such information?
> Anyway, I am redistributing R in a open-source package which provides a kind 
> of
> "complete" environment for some form of scientific investigations; not
> unlike Sage in some sense. See
> http://www.ok-sat-library.org/
> As such I feel responsible to install only software which is correct (and
> I need to install from sources).
> 
> Hope this helps a bit --- feel free to ask!
> 
> Oliver
> 
> 
> 
> > Among the missing items are OS specifics, why you need  
> > to install from sources, which version of the source bundle, (perhaps)  
> > which mirror, etc, etc.
> > 
> > (I surely would not report a bug with so much missing information.)
> > 
> > -- 
> > David.
> > On Dec 5, 2009, at 1:25 PM, Oliver Kullmann wrote:
> > 
> > >Hello,
> > >
> > >on Mon Nov 9 17:57:04 CET 2009 I've sent
> > >an e-mail to the R mailing list (see below),
> > >about a failing regression test. Yet nobody
> > >replied, while (obviously) the situation didn't
> > >change (installation still fails, and might
> > >continue to do so in the future).
> > >
> > >I wonder whether somebody has to say something here?
> > >Shall a bug report be submitted?
> > >Or will R 2.10.1 have fixed the bug?
> > >
> > >Oliver
> > >
> > >--
> > >
> > >Hello,
> > >
> > >I have installed R version 2.9.2, and everything
> > >works fine, but when attempting to install version 2.10.0
> > >I get:
> > >
> > >running code in 'datasets.R' ... OK
> > >comparing 'datasets.Rout' to './datasets.Rout.save' ... OK
> > >make[4]: Leaving directory `/home/csoliver/SAT-Algorithmen/ 
> > >OKplatform/ExternalSources/builds/R/R-2.10.0/tests'
> > >make[3]: Leaving directory `/home/csoliver/SAT-Algorithmen/ 
> > >OKplatform/ExternalSources/builds/R/R-2.10.0/tests'
> > >make[3]: Entering directory `/home/csoliver/SAT-Algorithmen/ 
> > >OKplatform/ExternalSources/builds/R/R-2.10.0/tests'
> > >running regression tests ...
> > >make[4]: Entering directory `/home/csoliver/SAT-Algorithmen/ 
> > >OKplatform/ExternalSources/builds/R/R-2.10.0/tests'
> > >running code in 'reg-tests-1.R' ...make[4]: *** [reg-tests-1.Rout]  
> > >Error 1
> > >make[4]: Leaving directory `/home/csoliver/SAT-Algorithmen/ 
> > >OKplatform/ExternalSources/builds/R/R-2.10.0/

Re: [R] Filtering a zoo object based on index of another object

2009-12-07 Thread Gabor Grothendieck
Since DATE2 is a subset of time(myzoo) either of these should work

   window(myzoo, DATE2)

myzoo[DATE2]


If DATE2 were not a subset of time(myzoo) then you could do this:

   myzoo2 <- na.locf(merge(myzoo, zoo(, DATE2)))

and now use either of the first two expressions with myzoo2 in place of
myzoo.

On Mon, Dec 7, 2009 at 7:22 AM, Subodh Acharya  wrote:

> Hello everybody,
> I have two datasets, observed and predicted.
>  Since my observed dataset is not in regular intervals, I need to filter my
> predicted dataset based on the measurement date of my observed data.
> Here, is an example similar to what  I have
>
> library(chron);library(zoo)
>  DATE<- seq(as.Date("2009-01-01"), as.Date("2009-05-01"), by = 1)
>  mydat<- rnorm(length(DATE), 20,5)
> myzoo<- zoo(mydat, order.by = DATE)
> DATE2<- seq(as.Date("2009-01-01"), as.Date("2009-01-30"), by = 7)
>
> Now I need to create a new zoo object with index as DATE2 and corresponding
> data values.
>
> Any kind of help will be highly appreciated.
>
> Thanks in advance you very much
>
> --
> 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.
>

[[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] Filtering a zoo object based on index of another object

2009-12-07 Thread Achim Zeileis

On Mon, 7 Dec 2009, Subodh Acharya wrote:


Hello everybody,
I have two datasets, observed and predicted.
Since my observed dataset is not in regular intervals, I need to filter my
predicted dataset based on the measurement date of my observed data.
Here, is an example similar to what  I have

library(chron);library(zoo)
DATE<- seq(as.Date("2009-01-01"), as.Date("2009-05-01"), by = 1)
mydat<- rnorm(length(DATE), 20,5)
myzoo<- zoo(mydat, order.by = DATE)
DATE2<- seq(as.Date("2009-01-01"), as.Date("2009-01-30"), by = 7)

Now I need to create a new zoo object with index as DATE2 and corresponding
data values.


window(myzoo, DATE2)

See the vignettes for more details.
Best,
Z


Any kind of help will be highly appreciated.

Thanks in advance you very much

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




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


Re: [R] Announce: edtdbg, integrating R's debug() with your text editor

2009-12-07 Thread Duncan Murdoch

On 07/12/2009 2:39 AM, Norm Matloff wrote:

I've just developed edtdbg, a small package that integrates R's debug()
with one's text editor.

Excerpt from the README file:

   Goal
   
   The debug() function in R is primitive.   My goal was to make it more

   usable by integrating it with one's text editor.  Hence I wrote the
   package here, edtdbg.  Its features include:
   
   * As one steps from line to line of code using the debugger, the

 cursor in the editor will always follow, i.e. it will alway be on
 whatever line the debugger is on.
   * One can enable automatic display of user-specified variables.
   * One can quickly and conveniently set "breakpoints."
   
   Currently the package is implemented only for Vim.  In addition, the

   second and third features require the vim-r plugin for Vim.  Emacs/ESS
   users should easily be able to convert the code; some of the machinery
   is already in the code and in the instructions below.

I'm placing the current version of the package at:

http://heather.cs.ucdavis.edu/~matloff/R/edtdbg/edtdbg.tar.gz

http://heather.cs.ucdavis.edu/~matloff/R/edtdbg/edtdbg.zip

Please give me your comments.  I probably will upload to CRAN at some
point, possibly after an ESS guru contributes the ESS code. :-)

A note on my Rdsm package for parallel R:  The new, much improved
version is just about ready.  I'll be uploading Rdsm to CRAN very soon.


I haven't tried it yet, but it looks good from the writeup.  One 
suggestion:  you could use the setBreakpoint function to set 
breakpoints, rather than re-sourcing the breakpoint.  An advantage of 
this is that it lets you set breakpoints in packages.


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] Filtering a zoo object based on index of another object

2009-12-07 Thread Subodh Acharya
Hello everybody,
I have two datasets, observed and predicted.
 Since my observed dataset is not in regular intervals, I need to filter my
predicted dataset based on the measurement date of my observed data.
Here, is an example similar to what  I have

library(chron);library(zoo)
 DATE<- seq(as.Date("2009-01-01"), as.Date("2009-05-01"), by = 1)
 mydat<- rnorm(length(DATE), 20,5)
myzoo<- zoo(mydat, order.by = DATE)
DATE2<- seq(as.Date("2009-01-01"), as.Date("2009-01-30"), by = 7)

Now I need to create a new zoo object with index as DATE2 and corresponding
data values.

Any kind of help will be highly appreciated.

Thanks in advance you very much

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


  1   2   >