Re: [R] Assigning a function to the 'times' argument of rep()

2012-02-12 Thread Berend Hasselman

On 13-02-2012, at 06:37, Berend Hasselman wrote:

> 
> On 13-02-2012, at 04:56, z2.0 wrote:
> 
>> Question: 
>> 
>> I'm trying to use paste() with rep() to reformat a series of values as zip
>> codes. e.g., if column 1 looks like:
>> 
>> 52775
>> 83111
>> 99240
>> 4289
>> 112
>> 57701
>> 20001
>> 
>> I want rows 4 and 5 to read,
>> 
>> "04289"
>> "00112"
> 
> This might help
> 
> x <- c(52775, 83111, 99240, 4289, 112, 57701, 20001)
> 
>> formatC(x,format="d", flag="0", width=5)
> [1] "52775" "83111" "99240" "04289" "00112" "57701" "20001"

or

sprintf("%05d", x)

Berend

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


Re: [R] Assigning a function to the 'times' argument of rep()

2012-02-12 Thread Jorge I Velez
?formatC

HTH,
Jorge.-*
*

On Sun, Feb 12, 2012 at 10:56 PM, z2.0 <> wrote:

> Question:
>
> I'm trying to use paste() with rep() to reformat a series of values as zip
> codes. e.g., if column 1 looks like:
>
> 52775
> 83111
> 99240
> 4289
> 112
> 57701
> 20001
>
> I want rows 4 and 5 to read,
>
> "04289"
> "00112"
>
> My thought was this:
>
> > perry_frame$zip <- ifelse(nchar(as.character(perry_frame$zip))<5,
>
>
> paste(rep("0",times=(5-nchar(as.character(perry_frame$zip,perry_frame$zip,sep=''),
>  as.character(perry_frame$zip))
>
> But R throws the following:
>
> Error in rep("0", times = (5 - nchar(as.character(perry_frame$zip :
>  invalid 'times' argument
>
> Is there a reason this doesn't work?
>
> Thanks,
>
> Zack
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/Assigning-a-function-to-the-times-argument-of-rep-tp4382849p4382849.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] Assigning a function to the 'times' argument of rep()

2012-02-12 Thread Berend Hasselman

On 13-02-2012, at 04:56, z2.0 wrote:

> Question: 
> 
> I'm trying to use paste() with rep() to reformat a series of values as zip
> codes. e.g., if column 1 looks like:
> 
> 52775
> 83111
> 99240
> 4289
> 112
> 57701
> 20001
> 
> I want rows 4 and 5 to read,
> 
> "04289"
> "00112"

This might help

x <- c(52775, 83111, 99240, 4289, 112, 57701, 20001)

> formatC(x,format="d", flag="0", width=5)
[1] "52775" "83111" "99240" "04289" "00112" "57701" "20001"

Berend

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Assigning a function to the 'times' argument of rep()

2012-02-12 Thread z2.0
Question: 

I'm trying to use paste() with rep() to reformat a series of values as zip
codes. e.g., if column 1 looks like:

52775
83111
99240
4289
112
57701
20001

I want rows 4 and 5 to read,

"04289"
"00112"

My thought was this:

> perry_frame$zip <- ifelse(nchar(as.character(perry_frame$zip))<5,
 
paste(rep("0",times=(5-nchar(as.character(perry_frame$zip,perry_frame$zip,sep=''),
  as.character(perry_frame$zip))

But R throws the following:

Error in rep("0", times = (5 - nchar(as.character(perry_frame$zip : 
  invalid 'times' argument

Is there a reason this doesn't work?

Thanks,

Zack

--
View this message in context: 
http://r.789695.n4.nabble.com/Assigning-a-function-to-the-times-argument-of-rep-tp4382849p4382849.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] Any package for best subset selection on random effects model?

2012-02-12 Thread zbleach
Hi Pros,
 I know leaps() computes the best subset selection for linear model, and
the bestglm() computes the best subset selection for generalized linear
model. Is there any package for best subset selection on random effects
model, or mixed effects model?

Thank you so much.

--
View this message in context: 
http://r.789695.n4.nabble.com/Any-package-for-best-subset-selection-on-random-effects-model-tp4382771p4382771.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] best subset selection on random effects model

2012-02-12 Thread Tao Zhang
Hi,
 I know leaps() computes the best subset selection for linear model,
and the bestglm() computes the best subset selection for generalized linear
model.
Is there any package for best subset selection on random effects model, or
mixed effects model?

Thank you so much.

Tao

[[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] Writing output into a file

2012-02-12 Thread Suranga Kasthurirathne
Hi,

Thank you very much for sharing these ideas. I really appreciate them. Let
me go try them out :-)



On Mon, Feb 13, 2012 at 4:37 AM, Rui Barradas  wrote:

> Hello
>
> One way is
>
> # Write the file
> save(myList, file="test1.bin")
>
> # Reload the data, under the same name, 'myList'
> load(file="test1.bin")
>
> Another way is a bit more complicated
>
> # Open a file connection and write the list to it (using  comma as
> separator)
> fileCon <- file("test2.txt", open="wt")
> lapply(myList, function(x) writeLines(paste(x, collapse=","), con=fileCon))
> close(fileCon)
>
> # Load the data, maybe under another name
> strsplit(readLines(con="test2.txt"), split=",")
>
> If you use the first method, the list is retrieved as it was.
> If you use the second, you lose the list's members' names.
>
> Hope this helps,
>
> Rui Barradas
>
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/Writing-output-into-a-file-tp4382243p4382310.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.
>



-- 
Best Regards,

Suranga

[[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] Is it possible or has it been done?

2012-02-12 Thread R. Michael Weylandt
This might be a little astray, but it's certainly doable on Android
devices: 
http://rwiki.sciviews.org/doku.php?id=getting-started:installation:android

Michael

On Sun, Feb 12, 2012 at 6:35 PM, Steve Lianoglou
 wrote:
> Hi,
>
> On Sun, Feb 12, 2012 at 6:24 PM, Keith Weintraub  wrote:
>> A port of R to iOS?
>
> Technically it is certainly possible.
>
> Legally, I don't think so.
>
> This question has been posed several times already, so you can find
> discussions about this issue by searching this list as well as
> R-sig-mac (gmane is handy for that).
>
> Here are some:
>
> https://stat.ethz.ch/pipermail/r-help/2010-May/240669.html
> https://stat.ethz.ch/pipermail/r-help/2010-June/240901.html
>
> Not sure if Apple's terms have changed since 2010, I'd be on "no."
>
> My guess is that a port of R on iOS would likely only work on a
> jailbroken device.
>
> -steve
> --
> Steve Lianoglou
> Graduate Student: Computational Systems Biology
>  | Memorial Sloan-Kettering Cancer Center
>  | Weill Medical College of Cornell University
> Contact Info: http://cbio.mskcc.org/~lianos/contact
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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 extract p values in svyglm

2012-02-12 Thread David Winsemius


On Feb 12, 2012, at 6:39 PM, Tanu Soni wrote:


summary(result)

Call:
svyglm(Injury ~ seat, sD, family = quasibinomial(link = "logit"))

Survey design:
svydesign(~1, prob = NULL, strata = Data[, 1], weights = Data[,
   4], data = Data, fpc = ~fPc)

Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -4.256875   0.001421 -2996.7   <2e-16 ***
seatbad  0.681504   0.001689   403.4   <2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

(Dispersion parameter for quasibinomial family taken to be 1.95)

Number of Fisher Scoring iterations: 6



Have you examined the output of str(summary(result))? Most versions of  
summary will retrun as one of theor list elements a matrix and you can  
generally access those matrices by name with "[[" and name, followed  
by extracting that result with "[" using a column name of "Pr(>|t|)".


--
David Winsemius, MD
West Hartford, CT

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


Re: [R] ANCOVA post-hoc test

2012-02-12 Thread David Winsemius


On Feb 12, 2012, at 7:39 AM, Evagelopoulos Thanasis wrote:


Could you please help me on the following ANCOVA issue?

This is a part of my dataset:

sampling dist h
1wi  200 0.8687212
2wi  200 0.8812909
3wi  200 0.8267464
4wi0 0.8554508
5wi0 0.9506721
6wi0 0.8112781
7wi  400 0.8687212
8wi  400 0.8414646
9wi  400 0.7601675
10   wi  900 0.6577048
11   wi  900 0.6098403
12   wi  900 0.5574382
13   sp  200 0.9149264
14   sp  200 0.9149264
15   sp  200 0.9248187
16   sp0 0.9974016
17   sp0 0.9997114
18   sp0 0.8812909
...

h is the dependent variable, distance the covariate and sampling the  
factor.


the slopes for h~distance linear regressions are significantly  
different from 0 for all samplings


In order to compare the regression slopes for each sampling, i did  
an ANCOVA with the ancova() function of the HH package:



mod<-ancova(h~sampling*dist,data)


There was a significant interaction term:



Barely. A borderline interaction may be of trivial importance when  
interpreted in the context of a model which has much stronger "main  
effects". Just using the anova table will hide the magnitude of the  
interaction effects. Was this an effect that was predicted by theory  
or even one which has interpretation in an experimental setting that  
leads to actionable conclusions?



Analysis of Variance Table

Response: h
 Df  Sum Sq Mean Sq F valuePr(>F)
sampling   3 0.22822 0.07607 13.7476 2.624e-06 ***
dist   1 0.51291 0.51291 92.6908 5.703e-12 ***
sampling:dist  3 0.05112 0.01704  3.0792   0.03822 *
Residuals 40 0.22134 0.00553

Because there exist significantly different regression slopes, I did  
a post hoc test with glht() to find out between which samplings:



summary(glht(mod, linfct=mcp(sampling="Tukey")))


The results seem to say that there are no significantly different  
slopes for any of the pair-wise comparisons of factor levels:


 Simultaneous Tests for General Linear Hypotheses

Multiple Comparisons of Means: Tukey Contrasts


Fit: aov(formula = h ~ sampling * dist, data = data)

Linear Hypotheses:
Estimate Std. Error z value Pr(>|z|)
sp - au == 0  0.066960.04562   1.4680.457
su - au == 0 -0.022380.04562  -0.4910.961
wi - au == 0  0.012030.04562   0.2640.994
su - sp == 0 -0.089340.04562  -1.9580.204
wi - sp == 0 -0.054930.04562  -1.2040.624
wi - su == 0  0.034410.04562   0.7540.875
(Adjusted p values reported -- single-step method)

Warning message:
In mcp2matrix(model, linfct = linfct) :
 covariate interactions found -- default contrast might be  
inappropriate




My questions are:

- Did I make a mistake somewhere? (I probably did!)


(I did a search for prior questions of this sort (post-hoc testing in  
models with interactions)  and found many fewer than I would have  
expected and many that I found had no answers offered, which I found  
surprising.)


You called the multiple comparisons function without specifying the  
"level" at which the multiple comparisons should be conducted and the  
function warned you that it might not be returning the results you  
expect under such conditions. I've looked at multcomp::glht's help  
page and it wasn't immediately evident to me how one would request  
comparisons just among the second-order interactions. It appears there  
are both matrix and "symbolic" options, but the exact syntax for  
specifying the symbolic options is not to my reading well described.  
The description in the help page texts seems at odds within the  
example on the same page.


A vignette is cited on the help page. Looking through the vignette,  
"Simultaneous Inference in General Parametric Models", I see that  
there is an example of the application of `glht` to an interaction  
model (section 6.3). It uses the matrix formulation but unfortunately  
does not include the code used to create the "K" matrix for that  
model. I tried using the code offered earlier in the vignette for that  
purpose but it doesn't agree with the offered K matrix in that  
section. So ...


K <- read.table( text="(Icpt) s<10 s10-20 s>20 gMale s<10:gMale  
s10-20:gMale s>20:gMale

None:Female 1 0 0 0 0 0 0 0
<10:Female 1 1 0 0 0 0 0 0
10-20:Female 1 0 1 0 0 0 0 0
>20:Female 1 0 0 1 0 0 0 0
None:Male 1 0 0 0 1 0 0 0
<10:Male 1 1 0 0 1 1 0 0
10-20:Male 1 0 1 0 1 0 1 0
>20:Male 1 0 0 1 1 0 0 1 ", header=TRUE, check.names=FALSE)

K <- as.matrix(K)

(And then I get the same output as in the vignette. Unfortunately the  
mechanical process of constructing that matrix did not leave me with  
the theoretical understanding of how it was created.


##---

Another option might be to simply use TukeyHSD specifying the second  
argument as "sampling:dist". When used with the example on TukeyHSD on  
this model I get what seem to me to be interpretable results:


Re: [R] finding and describing missing data runs in a time series

2012-02-12 Thread R. Michael Weylandt
Not at a computer to test this but perhaps

rle(is.na(x))

might help. 

Michael

On Feb 12, 2012, at 7:36 PM, "Durant, James T. (ATSDR/DTEM/PRMSB)" 
 wrote:

> Hi -
> 
> I am trying to find and describe missing data in a time series. For instance, 
> in the library openair, there is a data frame called "mydata":
> library(openair)
> head(mydata)
> 
>  date   ws  wd nox no2 o3 pm10so2  co pm25
> 1 1998-01-01 00:00:00 0.60 280 285  39  1   29 4.7225  3.3725   NA
> 2 1998-01-01 01:00:00 2.16 230  NA  NA NA   37 NA  NA   NA
> 3 1998-01-01 02:00:00 2.76 190  NA  NA  3   34 6.8300  9.6025   NA
> 4 1998-01-01 03:00:00 2.16 170 493  52  3   35 7.6625 10.2175   NA
> 5 1998-01-01 04:00:00 2.40 180 468  78  2   34 8.0700  8.9125   NA
> 6 1998-01-01 05:00:00 3.00 190 264  42  0   16 5.5050  3.0525   NA
> 
> 
> So for example, I would like to be able to detect for pm25, I would like to 
> be able to detect that there are NA's starting at 1998-01-01 0:00:00 and runs 
> for 2887 hourly observations.  Then I would be able to know that there is an 
> NA at 2910 and so on. The key information I am looking for is when the NA's 
> start and their length. The closest thing I can use that I know about is 
> timePlot in the openair package with statistic="frequency" but it only gives 
> monthly summary data, and does not tell me if the missing data are clumped 
> together or are dispersed.
> 
> VR
> 
> Jim
> 
> 
> James T. Durant, MSPH CIH
> Emergency Response Coordinator
> US Agency for Toxic Substances and Disease Registry
> Atlanta, GA 30341
> 770-378-1695
> 
> 
> 
> 
> 
>[[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] ANCOVA post-hoc test

2012-02-12 Thread Richard M. Heiberger
I am at my machine now.  The subset of the data you sent has only two
groups and doesn't
have a significant interaction.  Therefore I can't talk about specifics for
your example.

The glht test you did compared the means of the sampling factor ignoring
the dist covariate.  Your description
said you wanted to compare the slopes.

I would start by looking at the slopes of the four sampling values in the
graph.
You can probably see on the graph what is happening since you have the full
dataset available.

calculating the glht comparisons will be much more difficult than looking
at the plot.

On Sun, Feb 12, 2012 at 3:11 PM, Rmh  wrote:

> ancova in HH is a wrapper for aov
> that displays a set of lattice plots.
>
> the problem you are seeing is probably that glht ignores covariates (with
> an appropriate message) unless you specify an optional argument.
> I will reply in more detail when i am at
> my computer.
>
> in the meantime, look at ?glht in the multcomp package and at
> ?mmc in the HH package for examples.
>
> Sent from my iPhone
>
> On Feb 12, 2012, at 13:28, peter dalgaard  wrote:
>
> > Inline below
> >
> > On Feb 12, 2012, at 13:39 , Evagelopoulos Thanasis wrote:
> > [...]
> >>
> >> Because there exist significantly different regression slopes, I did a
> post hoc test with glht() to find out between which samplings:
> >>
> >>> summary(glht(mod, linfct=mcp(sampling="Tukey")))
> >>
> >
> > I believe this compares the intercepts, not slopes. Slope differences
> are in the sampling:dist interaction terms.
> >
> >> The results seem to say that there are no significantly different
> slopes for any of the pair-wise comparisons of factor levels:
> >>
> >> Simultaneous Tests for General Linear Hypotheses
> >>
> >> Multiple Comparisons of Means: Tukey Contrasts
> >>
> >>
> >> Fit: aov(formula = h ~ sampling * dist, data = data)
> >>
> >> Linear Hypotheses:
> >>Estimate Std. Error z value Pr(>|z|)
> >> sp - au == 0  0.066960.04562   1.4680.457
> >> su - au == 0 -0.022380.04562  -0.4910.961
> >> wi - au == 0  0.012030.04562   0.2640.994
> >> su - sp == 0 -0.089340.04562  -1.9580.204
> >> wi - sp == 0 -0.054930.04562  -1.2040.624
> >> wi - su == 0  0.034410.04562   0.7540.875
> >> (Adjusted p values reported -- single-step method)
> >>
> >
> > We don't have coefficients for your model, so it is a bit hard to tell
> what the parameter functions are, but I would expect those NOT to be the
> slope differences.
> >
> >> Warning message:
> >> In mcp2matrix(model, linfct = linfct) :
> >> covariate interactions found -- default contrast might be inappropriate
> >>
> >>
> >>
> >> My questions are:
> >>
> >> - Did I make a mistake somewhere? (I probably did!)
> >
> > You need to figure out how to get glht to look at the appropriate linear
> hypothesis (and mcp(sampling=...) is not right). I'd do a straight lm()
> analysis so that I'd know exactly what the parameters mean -- aov() can be
> a little too good at hiding technical details from the user!
> >
> >> - Could I do pairwise ANCOVAs and thus have just two factor levels
> (=two regression slopes) to compare each time?
> >
> > Possibly, but you'd lose the multiple comparison features of glht.
> >
> >> What does the warning message "covariate interactions found -- default
> contrast might be inappropriate" mean?
> >>
> >
> > That you likely don't want to look at intercepts (or whatever the
> "sampling" parameters represent --- I'm not familiar with that ancova()
> function) in the presence of interactions...
> >
> >> Thank you!
> >> Athanasios Evagelopoulos
> >> __
> >> R-help@r-project.org mailing list
> >> https://stat.ethz.ch/mailman/listinfo/r-help
> >> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> >> and provide commented, minimal, self-contained, reproducible code.
> >
> > --
> > Peter Dalgaard, Professor,
> > Center for Statistics, Copenhagen Business School
> > Solbjerg Plads 3, 2000 Frederiksberg, Denmark
> > Phone: (+45)38153501
> > Email: pd@cbs.dk  Priv: pda...@gmail.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] Error in apply(x2, 1, diff) : dim(X) must have a positive length

2012-02-12 Thread David Winsemius


On Feb 12, 2012, at 7:05 PM, hithit168 wrote:

Anyone knows hat might be the cause of this error? Thanks for any  
help!



library(MASS)
dif.mns = function(x2,tr1=.2,tr2=.3){

+ #generates four different 'means' using
+ #difference scores from x2, an n x 2 matrix
+ #for use w/ bootstrap comparisons
+ diffs = apply(x2,1,diff)
+ mn1=mean(diffs)
+ mn2=mean(diffs,tr=.2)
+ mn3=mean(diffs,tr=.3)
+ mn4=median(diffs)
+ mns=c(mn1,mn2,mn3,mn4)
+ list(mnds=round(mns,3)) }


dif.mns(shoes)

Error in apply(x2, 1, diff) : dim(X) must have a positive length



You have given apply a list.

--

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] Warnings from script - where?

2012-02-12 Thread R. Michael Weylandt
options(error=browser) or options(error=recover) will be of great help if you 
don't know them already. 

Michael 

On Feb 12, 2012, at 7:41 PM, Noah Silverman  wrote:

> Solved my own question:
> 
> options(warnings=2)  will turn all warnings into errors.  That should halt 
> execution and allow me to examine what happened.
> 
> --
> Noah Silverman
> UCLA Department of Statistics
> 8208 Math Sciences Building
> Los Angeles, CA 90095
> 
> On Feb 12, 2012, at 4:38 PM, Noah Silverman wrote:
> 
>> Hi,
>> 
>> Next challenge today.
>> 
>> I have a script that I call within R:  source("foo.R")
>> When it finishes, I get the dreaded output:  "There were 50 or more warnings 
>> (use warnings() to see the first 50)"
>> 
>> So, I type warnings() and get a nice list.  (Same error repeatedly, so 
>> probably something I'm using in a loop.)
>> 
>> The difficult part is I have no idea *where* the warning is being generated. 
>>  Is there a way to get R to either halt on warning, or give me more detail 
>> when listing warnings after execution?
>> 
>> Thanks!
>> 
>> --
>> Noah Silverman
>> UCLA Department of Statistics
>> 8208 Math Sciences Building
>> Los Angeles, CA 90095
>> 
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
> 
> 
>[[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] How to see a R function's code

2012-02-12 Thread Duncan Murdoch

On 12-02-11 5:19 PM, Colstat wrote:

I was wondering how do I actually see what's inside a function, say,
density of t distribution, dt()?

I know for some, I can type the function name inside R and the code will be
displayed.  But for dt(), I get

dt

function (x, df, ncp, log = FALSE)
{
 if (missing(ncp))
 .Internal(dt(x, df, log))
 else .Internal(dnt(x, df, ncp, log))
}


I am curious because I am doing rejection sampling and want to find a
"bigger" distribution.


See Uwe Ligges' article, "Accessing the sources", in

http://cran.r-project.org/doc/Rnews/Rnews_2006-4.pdf

This link and other good ones are in the "Technical papers" section on 
the HTML help page.


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] Warnings from script - where?

2012-02-12 Thread Noah Silverman
Solved my own question:

options(warnings=2)  will turn all warnings into errors.  That should halt 
execution and allow me to examine what happened.

--
Noah Silverman
UCLA Department of Statistics
8208 Math Sciences Building
Los Angeles, CA 90095

On Feb 12, 2012, at 4:38 PM, Noah Silverman wrote:

> Hi,
> 
> Next challenge today.
> 
> I have a script that I call within R:  source("foo.R")
> When it finishes, I get the dreaded output:  "There were 50 or more warnings 
> (use warnings() to see the first 50)"
> 
> So, I type warnings() and get a nice list.  (Same error repeatedly, so 
> probably something I'm using in a loop.)
> 
> The difficult part is I have no idea *where* the warning is being generated.  
> Is there a way to get R to either halt on warning, or give me more detail 
> when listing warnings after execution?
> 
> Thanks!
> 
> --
> Noah Silverman
> UCLA Department of Statistics
> 8208 Math Sciences Building
> Los Angeles, CA 90095
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.


[[alternative HTML version deleted]]

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


[R] Warnings from script - where?

2012-02-12 Thread Noah Silverman
Hi,

Next challenge today.

I have a script that I call within R:  source("foo.R")
When it finishes, I get the dreaded output:  "There were 50 or more warnings 
(use warnings() to see the first 50)"

So, I type warnings() and get a nice list.  (Same error repeatedly, so probably 
something I'm using in a loop.)

The difficult part is I have no idea *where* the warning is being generated.  
Is there a way to get R to either halt on warning, or give me more detail when 
listing warnings after execution?

Thanks!

--
Noah Silverman
UCLA Department of Statistics
8208 Math Sciences Building
Los Angeles, CA 90095

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


Re: [R] Reading in csv with footer

2012-02-12 Thread Rolf Turner

On 13/02/12 13:05, Noah Silverman wrote:

Hi,

I have a CSV file that is formatted well, except that the last line is a 
"summary" not is CSV format.

Toy example:

label_1, label_2, label_3
1,2,3
3,2,4
2,3,4
Total Rows: 3


When I try to import this into R with:  d<- read.table("foo.csv", header=T, 
sep=",")
It fails to import properly because of the last line.

Currently, I have a shell script that strips the last line from the file, then 
it imports to R cleanly.  I don't like this extra layer of processing.

Is there a way to import something like this cleanly in R.


How clean is clean?

You need to count the number of lines in the file, and then set the nrows
argument of read.csv() to be two less.  (*Two* r.t. one, because of the 
header.)


Counting the lines --- three possibilities that I can see:

(1) nlines() from the "parser" package
(2) countLines() from the "R.utils" package
(3) brute force:
x <- readLines()
n <- length(x)

Having determined n, do:

y <- read.csv(,nrows=n-2)

cheers,

Rolf Turner

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] finding and describing missing data runs in a time series

2012-02-12 Thread Durant, James T. (ATSDR/DTEM/PRMSB)
Hi -

 I am trying to find and describe missing data in a time series. For instance, 
in the library openair, there is a data frame called "mydata":
library(openair)
head(mydata)

  date   ws  wd nox no2 o3 pm10so2  co pm25
1 1998-01-01 00:00:00 0.60 280 285  39  1   29 4.7225  3.3725   NA
2 1998-01-01 01:00:00 2.16 230  NA  NA NA   37 NA  NA   NA
3 1998-01-01 02:00:00 2.76 190  NA  NA  3   34 6.8300  9.6025   NA
4 1998-01-01 03:00:00 2.16 170 493  52  3   35 7.6625 10.2175   NA
5 1998-01-01 04:00:00 2.40 180 468  78  2   34 8.0700  8.9125   NA
6 1998-01-01 05:00:00 3.00 190 264  42  0   16 5.5050  3.0525   NA


So for example, I would like to be able to detect for pm25, I would like to be 
able to detect that there are NA's starting at 1998-01-01 0:00:00 and runs for 
2887 hourly observations.  Then I would be able to know that there is an NA at 
2910 and so on. The key information I am looking for is when the NA's start and 
their length. The closest thing I can use that I know about is timePlot in the 
openair package with statistic="frequency" but it only gives monthly summary 
data, and does not tell me if the missing data are clumped together or are 
dispersed.

VR

Jim


James T. Durant, MSPH CIH
Emergency Response Coordinator
US Agency for Toxic Substances and Disease Registry
Atlanta, GA 30341
770-378-1695





[[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] Reading in csv with footer

2012-02-12 Thread William Dunlap
That prints nicely, but the first column in the
result got turned into a factor:
  > d <- head(read.csv(textConnection(Lines)), -1)
  > str(d)
  'data.frame':   3 obs. of  3 variables:
   $ label_1: Factor w/ 4 levels "1","2","3","Total Rows: 3": 1 3 2
   $ label_2: int  2 2 3
   $ label_3: int  3 4 4
(Remove the call to head and you will see why.)

You could use head(,-1) on the output of readLines so
read.csv never sees the last value:
  > d2 <- read.csv(textConnection(head(readLines(textConnection(Lines)), -1)))
  > str(d2)
  'data.frame':   3 obs. of  3 variables:
   $ label_1: int  1 3 2
   $ label_2: int  2 2 3
   $ label_3: int  3 4 4
or you could use a pipe connection that called the shell script.

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com 
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
> Behalf Of Henrique
> Dallazuanna
> Sent: Sunday, February 12, 2012 4:27 PM
> To: Noah Silverman
> Cc: r-help
> Subject: Re: [R] Reading in csv with footer
> 
> This works for me:
> 
> Lines <- "label_1, label_2, label_3
> 1,2,3
> 3,2,4
> 2,3,4
> Total Rows: 3"
> 
> d <- head(read.csv(textConnection(Lines)), -1)
> closeAllConnections()
> 
> On Sun, Feb 12, 2012 at 10:05 PM, Noah Silverman 
> wrote:
> 
> > Hi,
> >
> > I have a CSV file that is formatted well, except that the last line is a
> > "summary" not is CSV format.
> >
> > Toy example:
> >
> > label_1, label_2, label_3
> > 1,2,3
> > 3,2,4
> > 2,3,4
> > Total Rows: 3
> >
> >
> > When I try to import this into R with:  d <- read.table("foo.csv",
> > header=T, sep=",")
> > It fails to import properly because of the last line.
> >
> > Currently, I have a shell script that strips the last line from the file,
> > then it imports to R cleanly.  I don't like this extra layer of processing.
> >
> > Is there a way to import something like this cleanly in R.
> >
> > Thanks!
> >
> > --
> > Noah
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> > http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
> 
> 
> 
> --
> Henrique Dallazuanna
> Curitiba-Paraná-Brasil
> 25° 25' 40" S 49° 16' 22" O
> 
>   [[alternative HTML version deleted]]

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


Re: [R] Reading in csv with footer

2012-02-12 Thread Noah Silverman
Nice one!!!

Tanks.

--
Noah Silverman
UCLA Department of Statistics
8208 Math Sciences Building
Los Angeles, CA 90095

On Feb 12, 2012, at 4:26 PM, Henrique Dallazuanna wrote:

> This works for me:
> 
> Lines <- "label_1, label_2, label_3
> 1,2,3
> 3,2,4
> 2,3,4
> Total Rows: 3"
> 
> d <- head(read.csv(textConnection(Lines)), -1)
> closeAllConnections()
> 
> On Sun, Feb 12, 2012 at 10:05 PM, Noah Silverman  
> wrote:
> Hi,
> 
> I have a CSV file that is formatted well, except that the last line is a 
> "summary" not is CSV format.
> 
> Toy example:
> 
> label_1, label_2, label_3
> 1,2,3
> 3,2,4
> 2,3,4
> Total Rows: 3
> 
> 
> When I try to import this into R with:  d <- read.table("foo.csv", header=T, 
> sep=",")
> It fails to import properly because of the last line.
> 
> Currently, I have a shell script that strips the last line from the file, 
> then it imports to R cleanly.  I don't like this extra layer of processing.
> 
> Is there a way to import something like this cleanly in R.
> 
> Thanks!
> 
> --
> Noah
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 
> 
> -- 
> Henrique Dallazuanna
> Curitiba-Paraná-Brasil
> 25° 25' 40" S 49° 16' 22" O


[[alternative HTML version deleted]]

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


Re: [R] Reading in csv with footer

2012-02-12 Thread Noah Silverman
Thanks Steve,

Your suggestion about nrows seems like the easiest. 

Thanks!

--
Noah Silverman
UCLA Department of Statistics
8208 Math Sciences Building
Los Angeles, CA 90095

On Feb 12, 2012, at 4:23 PM, Steve Lianoglou wrote:

> Hi,
> 
> On Sun, Feb 12, 2012 at 7:05 PM, Noah Silverman  
> wrote:
>> Hi,
>> 
>> I have a CSV file that is formatted well, except that the last line is a 
>> "summary" not is CSV format.
>> 
>> Toy example:
>> 
>> label_1, label_2, label_3
>> 1,2,3
>> 3,2,4
>> 2,3,4
>> Total Rows: 3
>> 
>> When I try to import this into R with:  d <- read.table("foo.csv", header=T, 
>> sep=",")
>> It fails to import properly because of the last line.
>> 
>> Currently, I have a shell script that strips the last line from the file, 
>> then it imports to R cleanly.  I don't like this extra layer of processing.
>> 
>> Is there a way to import something like this cleanly in R.
> 
> This is arguably the file's problem, so I'm not sure how many "clean"
> solutions you will find, but one thing you can do is perhaps count the
> number of lines in the file, then set the `nrows` argument in your
> call to read.table to be 1 less than that.
> 
> How to count the lines, though? Assuming you're on *nix (or have
> cygwin), you can do something like:
> 
> N <- system("wc -l /path/to/file.csv")
> 
> (you'll have to do some parsing on N)
> 
> You could also first call `readLines` and find the length of the
> result, but this would require you to read the file twice, so ... pick
> your poison.
> 
> Too bad the person authoring the file doesn't prefix those lines with
> some comment character ...
> 
> -steve
> 
> -- 
> Steve Lianoglou
> Graduate Student: Computational Systems Biology
>  | Memorial Sloan-Kettering Cancer Center
>  | Weill Medical College of Cornell University
> Contact Info: http://cbio.mskcc.org/~lianos/contact


[[alternative HTML version deleted]]

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


[R] Error in apply(x2, 1, diff) : dim(X) must have a positive length

2012-02-12 Thread hithit168
Anyone knows hat might be the cause of this error? Thanks for any help!

>library(MASS)
> dif.mns = function(x2,tr1=.2,tr2=.3){ 
+ #generates four different 'means' using 
+ #difference scores from x2, an n x 2 matrix
+ #for use w/ bootstrap comparisons 
+ diffs = apply(x2,1,diff)  
+ mn1=mean(diffs) 
+ mn2=mean(diffs,tr=.2) 
+ mn3=mean(diffs,tr=.3) 
+ mn4=median(diffs) 
+ mns=c(mn1,mn2,mn3,mn4)  
+ list(mnds=round(mns,3)) } 

> dif.mns(shoes)
Error in apply(x2, 1, diff) : dim(X) must have a positive length

--
View this message in context: 
http://r.789695.n4.nabble.com/Error-in-apply-x2-1-diff-dim-X-must-have-a-positive-length-tp4382435p4382435.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] Reading in csv with footer

2012-02-12 Thread Henrique Dallazuanna
This works for me:

Lines <- "label_1, label_2, label_3
1,2,3
3,2,4
2,3,4
Total Rows: 3"

d <- head(read.csv(textConnection(Lines)), -1)
closeAllConnections()

On Sun, Feb 12, 2012 at 10:05 PM, Noah Silverman wrote:

> Hi,
>
> I have a CSV file that is formatted well, except that the last line is a
> "summary" not is CSV format.
>
> Toy example:
>
> label_1, label_2, label_3
> 1,2,3
> 3,2,4
> 2,3,4
> Total Rows: 3
>
>
> When I try to import this into R with:  d <- read.table("foo.csv",
> header=T, sep=",")
> It fails to import properly because of the last line.
>
> Currently, I have a shell script that strips the last line from the file,
> then it imports to R cleanly.  I don't like this extra layer of processing.
>
> Is there a way to import something like this cleanly in R.
>
> Thanks!
>
> --
> Noah
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



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

[[alternative HTML version deleted]]

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


[R] dotplots with error bars

2012-02-12 Thread Colin Wahl
Does anyone have any recommendations for producing dotplots with error
bars? Are there packages available for this? I searched far and wide
and cannot find a suitable option.

I am trying to produce publication-quality figures for my thesis
results. Dotplots (Cleveland dotplots) are a much better form of
summarizing barchart-type data. It does not appear that any of the
main plotting packages in r support dotplots with error bars.
Considering the benefit of these plots, I find it difficult to believe
that they have not been fully integrated into R.

I did find a function "dotplots.errors" available here:
http://agrobiol.sggw.waw.pl/~cbcs/articles/CBCS_5_2_2.pdf.

However, I have found this function absurdly difficult to use when
customizing figures (ordering displays properly, or just simple
getting the function to work.)

I've been struggling for the last few hours to figure out the error:
"error using packet 1 sum not meaningful for factors." Unlike other
packages, this function doesnt have a ?dotplots.errors to help guide
troubleshooting. I presume this is a technicality due to the a numeric
variable being identified as a factor. However, I've double checked
that all the numeric columns in the data frame are not factors, and
the error persists.

I'd really prefer not just calling it quits and resorting to
old-school sloppy bar charts, but if thats what I need to do to finish
this in a timely manner, then so be it.

Thank you,
Colin
M.S. candidate
WWU, Biology dept.

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


Re: [R] Writing output into a file

2012-02-12 Thread Rui Barradas
Hello

One way is

# Write the file
save(myList, file="test1.bin")

# Reload the data, under the same name, 'myList'
load(file="test1.bin")

Another way is a bit more complicated

# Open a file connection and write the list to it (using  comma as
separator)
fileCon <- file("test2.txt", open="wt")
lapply(myList, function(x) writeLines(paste(x, collapse=","), con=fileCon))
close(fileCon)

# Load the data, maybe under another name
strsplit(readLines(con="test2.txt"), split=",")

If you use the first method, the list is retrieved as it was.
If you use the second, you lose the list's members' names.

Hope this helps,

Rui Barradas


--
View this message in context: 
http://r.789695.n4.nabble.com/Writing-output-into-a-file-tp4382243p4382310.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] Reading in csv with footer

2012-02-12 Thread Steve Lianoglou
Hi,

On Sun, Feb 12, 2012 at 7:05 PM, Noah Silverman  wrote:
> Hi,
>
> I have a CSV file that is formatted well, except that the last line is a 
> "summary" not is CSV format.
>
> Toy example:
>
> label_1, label_2, label_3
> 1,2,3
> 3,2,4
> 2,3,4
> Total Rows: 3
>
> When I try to import this into R with:  d <- read.table("foo.csv", header=T, 
> sep=",")
> It fails to import properly because of the last line.
>
> Currently, I have a shell script that strips the last line from the file, 
> then it imports to R cleanly.  I don't like this extra layer of processing.
>
> Is there a way to import something like this cleanly in R.

This is arguably the file's problem, so I'm not sure how many "clean"
solutions you will find, but one thing you can do is perhaps count the
number of lines in the file, then set the `nrows` argument in your
call to read.table to be 1 less than that.

How to count the lines, though? Assuming you're on *nix (or have
cygwin), you can do something like:

N <- system("wc -l /path/to/file.csv")

(you'll have to do some parsing on N)

You could also first call `readLines` and find the length of the
result, but this would require you to read the file twice, so ... pick
your poison.

Too bad the person authoring the file doesn't prefix those lines with
some comment character ...

-steve

-- 
Steve Lianoglou
Graduate Student: Computational Systems Biology
 | Memorial Sloan-Kettering Cancer Center
 | Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact

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

2012-02-12 Thread Duncan Murdoch

On 12-02-11 9:07 PM, Jonas Stein wrote:

Wrong? Nothing. You told R to put the legend at c(1,3)
so it did. If you want it elsewhere you need to specify that.
legend(-1,3, legend=c("one", "two"), inset=-1, xpd=NA)
maybe, or some other location?


ok that works fine. Now i understand how to use it.
If i create several plots it would be nice if all legends would
have the same distance to plots with different scaling.

Can the legend be placed vertically centered, 1cm right to the plot aera?


I'm not sure what position you mean, but legend("top", ...) puts it on 
the top edge of the plot, and the inset argument gives detailed 
positioning.  The units aren't cm, but the grDevices package (or is it 
grid?) has functions to convert between units.


Duncan Murdoch




Can i include a legend like this in a standard plot like
plot(1:10) too?
http://www.r-bloggers.com/wp-content/uploads/2011/03/heatmap.png


Yes.

What part of that do you want to duplicate?


The coloured squares.
for the reader who got to this article and had the same question:
I have just found another nice solution for a colour legend a minute ago
http://www.r-bloggers.com/rethinking-loess-for-binomial-response-pitch-fx-strike-zone-maps/


You can specify colors, symbols, labels, etc. in legend().


can i even invent my own symbols?


Also, please link to the original blog post, not just the figure, so that
the author gets some credit and we can see the code used.


sure
http://www.r-bloggers.com/ggheat-a-ggplot2-style-heatmap-function/

kind regards,



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

2012-02-12 Thread Noah Silverman
Hi,

I have a CSV file that is formatted well, except that the last line is a 
"summary" not is CSV format.

Toy example:

label_1, label_2, label_3
1,2,3
3,2,4
2,3,4
Total Rows: 3


When I try to import this into R with:  d <- read.table("foo.csv", header=T, 
sep=",")
It fails to import properly because of the last line.

Currently, I have a shell script that strips the last line from the file, then 
it imports to R cleanly.  I don't like this extra layer of processing.

Is there a way to import something like this cleanly in R.

Thanks!

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

2012-02-12 Thread Tanu Soni
summary(result)

Call:
svyglm(Injury ~ seat, sD, family = quasibinomial(link = "logit"))

Survey design:
svydesign(~1, prob = NULL, strata = Data[, 1], weights = Data[,
4], data = Data, fpc = ~fPc)

Coefficients:
 Estimate Std. Error t value Pr(>|t|)
(Intercept) -4.256875   0.001421 -2996.7   <2e-16 ***
seatbad  0.681504   0.001689   403.4   <2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

(Dispersion parameter for quasibinomial family taken to be 1.95)

Number of Fisher Scoring iterations: 6

[[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] Is it possible or has it been done?

2012-02-12 Thread Steve Lianoglou
Hi,

On Sun, Feb 12, 2012 at 6:24 PM, Keith Weintraub  wrote:
> A port of R to iOS?

Technically it is certainly possible.

Legally, I don't think so.

This question has been posed several times already, so you can find
discussions about this issue by searching this list as well as
R-sig-mac (gmane is handy for that).

Here are some:

https://stat.ethz.ch/pipermail/r-help/2010-May/240669.html
https://stat.ethz.ch/pipermail/r-help/2010-June/240901.html

Not sure if Apple's terms have changed since 2010, I'd be on "no."

My guess is that a port of R on iOS would likely only work on a
jailbroken device.

-steve
-- 
Steve Lianoglou
Graduate Student: Computational Systems Biology
 | Memorial Sloan-Kettering Cancer Center
 | Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact

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


Re: [R] Is it possible or has it been done?

2012-02-12 Thread Roy Mendelssohn
http://tolstoy.newcastle.edu.au/R/e11/help/10/08/6132.html

HTH,

-Roy

On Feb 12, 2012, at 3:24 PM, Keith Weintraub wrote:

> A port of R to iOS?
> 
> Thanks for your time,
> KW
> 
> --
> 
> 
>   [[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.

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

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

"Old age and treachery will overcome youth and skill."
"From those who have been given much, much will be expected" 
"the arc of the moral universe is long, but it bends toward justice" -MLK Jr.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Is it possible or has it been done?

2012-02-12 Thread Keith Weintraub
A port of R to iOS?

Thanks for your time,
KW

--


[[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] Writing output into a file

2012-02-12 Thread Alfredo Alessandrini
Hi,

could you paste the results?


Alfredo

2012/2/12 Suranga Kasthurirathne :
> Hi everyone,
>
> I'm an R newbie working with the poLCA module. I achieved my target without
> having to bother anyone, but It seems that I've got stuck at the last
> minute.
>
> My problem is simple. I need to write my results into a file.
> My results are in the shape of a list (unbalanced columns)
> I've considered several methods (sink(), write.file) etc. etc.
> Unfortunately, I'm not the best brains in the market on this subject.
> I've also faced some difficulty in converting the list so that it can be
> written using write.file().
>
> Therefore, I'm wondering if anyone can point me towards a good example that
> shows me how to write a list into a file safely.
>
>
> --
> Thanks and Best Regards,
>
> Suranga
>
>        [[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] Writing output into a file

2012-02-12 Thread Suranga Kasthurirathne
Hi everyone,

I'm an R newbie working with the poLCA module. I achieved my target without
having to bother anyone, but It seems that I've got stuck at the last
minute.

My problem is simple. I need to write my results into a file.
My results are in the shape of a list (unbalanced columns)
I've considered several methods (sink(), write.file) etc. etc.
Unfortunately, I'm not the best brains in the market on this subject.
I've also faced some difficulty in converting the list so that it can be
written using write.file().

Therefore, I'm wondering if anyone can point me towards a good example that
shows me how to write a list into a file safely.


-- 
Thanks and Best Regards,

Suranga

[[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] object not found - Can not figure out why I get this error: Error in NROW(yCoordinatesOfLines) : object 'low' not found

2012-02-12 Thread ilai
Ah, scoping rules...
Consider:
f <- function(x,...) plot(x,xlim=c(low,high),...)
f(1:10,low=2,high=9)  # "Error ...  object 'low' not found "

But:

f <- function(x,low,high,...) plot(x,xlim=c(low,high),...)
f(1:10,2,9,col=2)  # beautiful red points [low,high]

Sorry I can't be more specific but never heard of quantmod.
Hope this helps anyway.


On Sat, Feb 11, 2012 at 7:43 AM, Samo Pahor  wrote:
> Hi,
>
> I have been using R for over a year now. I am a very happy user. Thank you
> for making this happen.
>
> This is my first question to this list.
>
> I trying to add some functions to quantmod that would enable me to draw
> arbitrary lines and text and make sure they are redrawn. I have created
> following function:
>
> require(quantmod)
>
> # Add horizontal line to graph produced by quantmod::chart_Series()
> add_HorizontalLine<-function(yCoordinatesOfLines, on=1, ...) {
>    lenv <- new.env()
>    lenv$add_horizontalline <- function(x, yCoordinatesOfLines, ...) {
>        xdata <- x$Env$xdata
>        xsubset <- x$Env$xsubset
>
>        x0coords <- rep(1, NROW(yCoordinatesOfLines))
>        x1coords <- rep(NROW(xdata[xsubset]), NROW(yCoordinatesOfLines))
>
>        if ((NROW(x0coords) > 0) & (NROW(x1coords) > 0)) {
>            segments(x0coords,
>                     yCoordinatesOfLines,
>                     x1coords,
>                     yCoordinatesOfLines, ...)
> #            abline(h=yCoordinatesOfLines, ...)
>        }
>    }
>    mapply(function(name, value) {assign(name,value,envir=lenv)},
> names(list(yCoordinatesOfLines=yCoordinatesOfLines,...)),
> list(yCoordinatesOfLines=yCoordinatesOfLines,...))
>    exp <- parse(text=gsub("list","add_horizontalline",
> as.expression(substitute(list(x=current.chob(),
>
> yCoordinatesOfLines=yCoordinatesOfLines, ..., srcfile=NULL)
>    plot_object <- current.chob()
>    lenv$xdata <- plot_object$Env$xdata
> #    plot_object$set_frame(sign(on)*abs(on)+1L)
>    plot_object$set_frame(2*on)
>    plot_object$add(exp,env=c(lenv, plot_object$Env),expr=TRUE)
>    plot_object
> }
>
> # Short test function that uses add_HorizontalLine
> test<-function(series, low=20, high=80) {
>    chart_Series(SPX, subset="2012")
>    add_TA(RSI(Cl(SPX)))
>    plot(add_HorizontalLine(c(low, high), on=2, col=c('green', 'red'),
> lwd=2))
> }
>
> # Actual test
> SPX <- getSymbols("^GSPC", from="2000-01-01", auto.assign=FALSE)
> dev.new()
> test(SPX)
>
> This gives me the following error:
>> test(SPX)
> Error in NROW(yCoordinatesOfLines) : object 'low' not found
>
> What am I doing wrong here? Any hints highly appreciated.
>
> The funniest thing is that this was working and somehow broke it...
>
> Best,
> Samo
>
>        [[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] Install the rugarch-package

2012-02-12 Thread nserdar
Without space 'rugarch'

--
View this message in context: 
http://r.789695.n4.nabble.com/Install-the-rugarch-package-tp3911903p4381876.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] Counting the loop-round of a "for"-loop

2012-02-12 Thread jolo999
It seems to work. Simple and effective!

Thanks!

--
View this message in context: 
http://r.789695.n4.nabble.com/Counting-the-loop-round-of-a-for-loop-tp4381319p4381780.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] [R-sig-DB] Reading data from a worksheet on the Internet

2012-02-12 Thread CIURANA EUGENE (R)
  

On Sun, 12 Feb 2012 16:24:58 -0200, Nilza BARROS wrote: 

> I
really appreciate your help. I definitively need a reusable program
since
> I have been asking to someone to extract these data from the
Internet
> everyday. That's the reason why I am trying to do a program
to do that
> Related to the url I sent, I have just realized that
although I had written
> the one related to only worksheet (PLANILHA2)
when I copy it to my browse
> it is showed the link with both
worksheets.
> 
> I am going to read about Rcurl and XML libraries but I
hope you can help me
> too.

Hi again, Nilza. 

I looked over this to
see if there was some simpler way of doing this; I couldn't find one.


The main issue I see is that this is "HTML" generated from Excel. That
means it's got a lot of "features" for navigation, formatting, and such
built into the script that make it a pain to parse. I tried parsing it
with both the XML R package (look at the htmlTreeParse() function) and
with other non-R tools like scrapy and llxml in Python. 

If you read
this post after you had a peek at the XML package, my next explanation
will make more sense. 

The main issue is that the DOM you're analyzing
has child nodes that are either generated or repopulated from the Excel
data dumped onto the file system. Walking this DOM requires not only
XML, but perhaps even having a JavaScript parser resolve some of the
nodes before you get the information you want. That's why, doing it from
the main page, is a nasty issue. 

My suggestion, at this time, would be
to focus on seeing if you can parse the individual sub-sheets. Although
you may to load each manually, their DOM appears simpler and with less
crap specific to JavaScript/CSS/Excel/Internet Explorer. Being cleaner,
they should be easier to parse with XML or any other tool. I'll take
another look at the individual sheets to check if they in fact have a
simpler document model. 

Cheers! 

pr3d4t0r 

-- 
pr3d4t0r at #R,
##java, #awk, #pyton
irc.freeenode.net
  
[[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] ANCOVA post-hoc test

2012-02-12 Thread Rmh
ancova in HH is a wrapper for aov
that displays a set of lattice plots.

the problem you are seeing is probably that glht ignores covariates (with an 
appropriate message) unless you specify an optional argument.
I will reply in more detail when i am at
my computer.

in the meantime, look at ?glht in the multcomp package and at
?mmc in the HH package for examples.

Sent from my iPhone

On Feb 12, 2012, at 13:28, peter dalgaard  wrote:

> Inline below
> 
> On Feb 12, 2012, at 13:39 , Evagelopoulos Thanasis wrote:
> [...]
>> 
>> Because there exist significantly different regression slopes, I did a post 
>> hoc test with glht() to find out between which samplings:
>> 
>>> summary(glht(mod, linfct=mcp(sampling="Tukey")))
>> 
> 
> I believe this compares the intercepts, not slopes. Slope differences are in 
> the sampling:dist interaction terms.
> 
>> The results seem to say that there are no significantly different slopes for 
>> any of the pair-wise comparisons of factor levels:
>> 
>> Simultaneous Tests for General Linear Hypotheses
>> 
>> Multiple Comparisons of Means: Tukey Contrasts
>> 
>> 
>> Fit: aov(formula = h ~ sampling * dist, data = data)
>> 
>> Linear Hypotheses:
>>Estimate Std. Error z value Pr(>|z|)
>> sp - au == 0  0.066960.04562   1.4680.457
>> su - au == 0 -0.022380.04562  -0.4910.961
>> wi - au == 0  0.012030.04562   0.2640.994
>> su - sp == 0 -0.089340.04562  -1.9580.204
>> wi - sp == 0 -0.054930.04562  -1.2040.624
>> wi - su == 0  0.034410.04562   0.7540.875
>> (Adjusted p values reported -- single-step method)
>> 
> 
> We don't have coefficients for your model, so it is a bit hard to tell what 
> the parameter functions are, but I would expect those NOT to be the slope 
> differences.
> 
>> Warning message:
>> In mcp2matrix(model, linfct = linfct) :
>> covariate interactions found -- default contrast might be inappropriate
>> 
>> 
>> 
>> My questions are:
>> 
>> - Did I make a mistake somewhere? (I probably did!)
> 
> You need to figure out how to get glht to look at the appropriate linear 
> hypothesis (and mcp(sampling=...) is not right). I'd do a straight lm() 
> analysis so that I'd know exactly what the parameters mean -- aov() can be a 
> little too good at hiding technical details from the user! 
> 
>> - Could I do pairwise ANCOVAs and thus have just two factor levels (=two 
>> regression slopes) to compare each time?
> 
> Possibly, but you'd lose the multiple comparison features of glht.
> 
>> What does the warning message "covariate interactions found -- default 
>> contrast might be inappropriate" mean?
>> 
> 
> That you likely don't want to look at intercepts (or whatever the "sampling" 
> parameters represent --- I'm not familiar with that ancova() function) in the 
> presence of interactions... 
> 
>> Thank you!
>> Athanasios Evagelopoulos
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
> 
> -- 
> Peter Dalgaard, Professor,
> Center for Statistics, Copenhagen Business School
> Solbjerg Plads 3, 2000 Frederiksberg, Denmark
> Phone: (+45)38153501
> Email: pd@cbs.dk  Priv: pda...@gmail.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] Sample function in R

2012-02-12 Thread Petr Savicky
On Sun, Feb 12, 2012 at 01:57:18PM -0500, SUPAKORN LAOHAPITAKVORN wrote:
> This is what I got:
> 
> > sessionInfo()
> R version 2.14.1 (2011-12-22)
> Platform: x86_64-pc-mingw32/x64 (64-bit)
> 
> locale:
> [1] LC_COLLATE=English_United States.1252
> [2] LC_CTYPE=English_United States.1252
> [3] LC_MONETARY=English_United States.1252
> [4] LC_NUMERIC=C
> [5] LC_TIME=English_United States.1252
> 
> attached base packages:
> [1] stats graphics  grDevices utils datasets  methods   base
> > ls()
> [1] "a"  "sample"

Hi.

The standard R base function sample() is not shown
by ls() command. So, the above is something different
as others already suggested. You can see, what it
is, by typing "sample" without quotation marks and
without (). The standard sample prints as the following

  > sample
  function (x, size, replace = FALSE, prob = NULL) 
  {
  if (length(x) == 1L && is.numeric(x) && x >= 1) {
  if (missing(size)) 
  size <- x
  .Internal(sample(x, size, replace, prob))
  }
  else {
  if (missing(size)) 
  size <- length(x)
  x[.Internal(sample(length(x), size, replace, prob))]
  }
  }
  

Start new session or delete the wrong sample by rm(sample).
If it comes from a script, which you run, the situation
may repeat. In this case, look into the scripts for
commands like "sample <- ...".

Hope this helps.

Petr Savicky.

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


Re: [R] Sample function in R

2012-02-12 Thread Etienne B. Racine
Supakorn,

Try:
rm(sample)
#then
sample(x)

Etienne

2012/2/12 SUPAKORN LAOHAPITAKVORN 

> This is what I got:
>
> > sessionInfo()
> R version 2.14.1 (2011-12-22)
> Platform: x86_64-pc-mingw32/x64 (64-bit)
>
> locale:
> [1] LC_COLLATE=English_United States.1252
> [2] LC_CTYPE=English_United States.1252
> [3] LC_MONETARY=English_United States.1252
> [4] LC_NUMERIC=C
> [5] LC_TIME=English_United States.1252
>
> attached base packages:
> [1] stats graphics  grDevices utils datasets  methods   base
> > ls()
> [1] "a"  "sample"
>
> On Sun, Feb 12, 2012 at 12:52 PM, SUPAKORN LAOHAPITAKVORN <
> klangklang2...@gmail.com> wrote:
>
> > Hi,
> > Can anyone help me with the sample () in R?
> >
> > If I sample from x, I should get one integer.  Can anyone tell me what's
> > wrong here?
> > > x =1:12
> > > sample(x)
> > [1] 6.5
> >
> > And, I cannot get the sample with size = 2
> > > sample(x, size = 2)
> > Error in sample(x, size = 2) : unused argument(s) (size = 2)
> > > sample(x, 2)
> > [1] 54.16667
> >
> > Thank you in advance
> >
>
>[[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] Sample function in R

2012-02-12 Thread SUPAKORN LAOHAPITAKVORN
This is what I got:

> sessionInfo()
R version 2.14.1 (2011-12-22)
Platform: x86_64-pc-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base
> ls()
[1] "a"  "sample"

On Sun, Feb 12, 2012 at 12:52 PM, SUPAKORN LAOHAPITAKVORN <
klangklang2...@gmail.com> wrote:

> Hi,
> Can anyone help me with the sample () in R?
>
> If I sample from x, I should get one integer.  Can anyone tell me what's
> wrong here?
> > x =1:12
> > sample(x)
> [1] 6.5
>
> And, I cannot get the sample with size = 2
> > sample(x, size = 2)
> Error in sample(x, size = 2) : unused argument(s) (size = 2)
> > sample(x, 2)
> [1] 54.16667
>
> Thank you in advance
>

[[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] Get identical results for parallel and sequential?

2012-02-12 Thread slbfelix
Sorry. That was my first time to post, I was not sure if it worked or not.

Libo

--
View this message in context: 
http://r.789695.n4.nabble.com/Get-identical-results-for-parallel-and-sequential-tp4380110p4381648.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] How to import time-series data

2012-02-12 Thread Gabor Grothendieck
On Sun, Feb 12, 2012 at 12:35 PM, RichardSmith
 wrote:
>
> Gabor Grothendieck wrote
>>
>> Something seems to have gone wrong in the posting since we can't see
>> the sample data that seems to be intended to be part of the post.
> Sorry, I posted via Nabble using the 'raw' command, which got stripped out
> it seems. Here's a small sample of the data...
> plant,aphid,1,2,3,4
> pumpkin,1-2,0.065566,0.057844,0.08,0.086879
> pumpkin,1-3,0.107612,0.097272,0.11663,0.160499
> squash,1-4,0.126939,0.115003,0.140275,0.188829
>
> columns named 1,2,3,4 etc. correspond to the weight of an aphid after that
> many days on that plant. I want to be able to plot the growth of all aphids
> on one plot, grouped by plant.
>

Try this xyplot.zoo lattice graph.   Time series are represented in
columns so we transpose the data and convert it to zoo.  The screen=
argument available in xyplot.zoo groups series into panels:

Lines <- "plant,aphid,1,2,3,4
pumpkin,1-2,0.065566,0.057844,0.08,0.086879
pumpkin,1-3,0.107612,0.097272,0.11663,0.160499
squash,1-4,0.126939,0.115003,0.140275,0.188829"

library(zoo)
library(lattice)
DF <- read.csv(text = Lines)
z <- zoo(t(DF[3:6]))
colnames(z) <- DF$aphid
xyplot(z, screen = DF$plant)

-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.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] DF grouping

2012-02-12 Thread karthicklakshman
Dear Petr Savicky,

Thank you very much for the solution.
your script really worked for my DF,  and yes as per your guess , its always
---> DF[i, "col2"] == DF[i+1, "col1"]

Regards,
karthick

--
View this message in context: 
http://r.789695.n4.nabble.com/DF-grouping-tp4381310p4381646.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] Install the rugarch-package

2012-02-12 Thread Prof Brian Ripley

On 12/02/2012 18:19, nserdar wrote:

I got the same error on MAC Lion

Error in as.environment(pos) :
   no item called "newtable" on the search list
In addition: Warning message:
In objects(newtable, all.names = TRUE) :
   ‘newtable’ converted to character string
Error: package/namespace load failed for 'rug arch'


With a space?  Very unlikely.

This is a symptom of a persistent bug in the 'methods' package: it is 
usually cured by re-installing the package concerned (which can be hard 
to find, but it often XML).



Regards,
Serdar



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

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


Re: [R] Get identical results for parallel and sequential?

2012-02-12 Thread Dirk Eddelbuettel

On 12 February 2012 at 19:13, Uwe Ligges wrote:
| Please do not double post.

And also do not cross-post: the same questions had been sent to (as well as
answered at) the R-SIG-HPC list.  Double-posting and cross-posting is impolite.

Dirk

-- 
"Outside of a dog, a book is a man's best friend. Inside of a dog, it is too
dark to read." -- Groucho Marx

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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-sig-DB] Reading data from a worksheet on the Internet

2012-02-12 Thread Henrique Dallazuanna
Try the readHTMLTable function in package XML:

sheet2 <- readHTMLTable("
http://www.mar.mil.br/dhn/chm/meteo/prev/dados/pnboia/sc1201_arquivos/sheet002.htm";,
skip.rows = 2)

head(sheet2[[1]])

On Sun, Feb 12, 2012 at 4:24 PM, Nilza BARROS  wrote:

> Hi,
>
> I really appreciate your help. I definitively need a reusable program since
> I have been asking to  someone to extract these data from the Internet
> everyday.  That's the reason why I am trying to do a program to do that
> Related to the url I sent, I have just realized that although I had written
>  the one related to only worksheet (PLANILHA2) when I copy it to my browse
> it is showed the link with both worksheets.
>
>
> I am going to read about Rcurl and XML libraries but I hope you can help me
> too.
>
> Thanks in advance
> Nilza Barros
>
>
> On Sun, Feb 12, 2012 at 10:42 AM, CIURANA EUGENE (R)  >wrote:
>
> > **
> >
> > On Sat, 11 Feb 2012 22:49:07 -0200, Nilza BARROS wrote:
> >
> > I have to read data from a worksheet that is available on the Internet. I
> > have been doing this by copying the worksheet from the browser.
> > But I would like to be able to copy the data automatically using the url
> > command.
> >
> > But when using  "url" command the result is the source code, I mean, a
> html
> > code.
> > I see that the data I need is in the source code but before thinking
> about
> > reading the data from the html code I wonder if there is a package or
> > anoher way to extract these data since reading  from the code will demand
> > many work and it can be not so accurate.
> >
> > Below one can see the from where I am trying to export the data:
> >
> > dadoshttp://
> www.mar.mil.br/dhn/chm/meteo/prev/dados/pnboia/sc1201_arquivos/sheet002.htm
> ","r
> > ")
> >
> >
> >
> > Hi Nilza,
> >
> > The URL that you posted points at a document that has another document
> > within it, in a frame.  These files are Excel dumps into HTML.  To view
> the
> > actual data you need the URIs for each data set.  Those appear at the
> > bottom of the listing, under sc1201_arquivos/sheet001.htm and
> sheet002.htm.
> >  Your code must fetch these files, not the one at
> > http://www.mar.mil.br/dhn/chm/meteo/prev/dados/pnboia/sc1202.htm which
> > only "wraps" them.  Most of what you see on the file that you linked
> isn't
> > HTML - it's JavaScript and style information for the data living on the
> two
> > separate HTML documents.
> >
> > You can do this in R using the RCurl and XML libraries, by pulling the
> > specific files for each data source.  If this is a one-time thing, I'd
> > suggest just coding something simple that loads the data for each file.
>  If
> > this is something you'll execute periodically, you'll need a bit more
> code
> > to extract the internal data sheets (e.g. the "planhilas" at the bottom),
> > then extracting the actual data.
> >
> > Let me know if you want this as a one-time thing, or as a reusable
> > program.  If you don't know how to use RCurl and XML to parse HTML I'll
> be
> > happy to help with that too.  I'd just like to know more about the scope
> of
> > your question.
> >
> > Cheers,
> >
> > pr3d
> >
> > --
> > pr3d4t0r at #R, ##java, #awk, #pytonirc.freeenode.net
> >
> >
>
>
> --
> Abraço,
> Nilza Barros
>
>[[alternative HTML version deleted]]
>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>


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

[[alternative HTML version deleted]]

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


Re: [R] updating one's own package

2012-02-12 Thread Wet Bell Diver


Thanks Uwe, that is really helpful.

-Peter


Op 11-2-2012 19:20, Uwe Ligges schreef:



On 11.02.2012 13:49, Wet Bell Diver wrote:

Win7 x64, R2.14.1

Dear list,

I would like to get into the habbit of creating a package for each
project. That way I can package my project-specific functions and data
together and load or unload that at will. Also, it will allow easy
navigation through all the functions I will have available for each
project, since I can then use ?myfunction and immediately see the
details of that function (esp. useful when revisiting a project after
several months).
Anyway, I have been successful in constructing a package, using the
package.skeleton. My question is how to easily update the package when I
write an additional function or rewrite an existing function. Do I then
need to again build the package fully, or is there an "incremental
update" option somewhere? This I can not find anywhere, maybe I am
overlooking something?



You can use package.skeleton with force = FALSE in order not to 
overwrite existing files. Anyway, I typically edit the files of the 
package directly, without using any helper functions.
And if you add a new function, you can use prompt() to prepare a 
corresponding Rd file.


Uwe Ligges






Thanks,
Peter

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


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


Re: [R] Sample function in R

2012-02-12 Thread Jorge I Velez
Hi,

The following is what I get:

> x =1:12
> x
 [1]  1  2  3  4  5  6  7  8  9 10 11 12
> sample(x)
 [1]  9  6 12  5  3  4  1 11  8  7 10  2
> sample(x, size = 2)
[1] 9 4

What's the output of sessionInfo() and ls() ?   Perhaps you have a
different "sample" function in your workspace?

HTH,
Jorge.-


On Sun, Feb 12, 2012 at 12:52 PM, SUPAKORN LAOHAPITAKVORN <> wrote:

> Hi,
> Can anyone help me with the sample () in R?
>
> If I sample from x, I should get one integer.  Can anyone tell me what's
> wrong here?
> > x =1:12
> > sample(x)
> [1] 6.5
>
> And, I cannot get the sample with size = 2
> > sample(x, size = 2)
> Error in sample(x, size = 2) : unused argument(s) (size = 2)
> > sample(x, 2)
> [1] 54.16667
>
> Thank you in advance
>
>[[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] ANCOVA post-hoc test

2012-02-12 Thread peter dalgaard
Inline below

On Feb 12, 2012, at 13:39 , Evagelopoulos Thanasis wrote:
[...]
> 
> Because there exist significantly different regression slopes, I did a post 
> hoc test with glht() to find out between which samplings:
> 
>> summary(glht(mod, linfct=mcp(sampling="Tukey")))
> 

I believe this compares the intercepts, not slopes. Slope differences are in 
the sampling:dist interaction terms.

> The results seem to say that there are no significantly different slopes for 
> any of the pair-wise comparisons of factor levels:
> 
>  Simultaneous Tests for General Linear Hypotheses
> 
> Multiple Comparisons of Means: Tukey Contrasts
> 
> 
> Fit: aov(formula = h ~ sampling * dist, data = data)
> 
> Linear Hypotheses:
> Estimate Std. Error z value Pr(>|z|)
> sp - au == 0  0.066960.04562   1.4680.457
> su - au == 0 -0.022380.04562  -0.4910.961
> wi - au == 0  0.012030.04562   0.2640.994
> su - sp == 0 -0.089340.04562  -1.9580.204
> wi - sp == 0 -0.054930.04562  -1.2040.624
> wi - su == 0  0.034410.04562   0.7540.875
> (Adjusted p values reported -- single-step method)
> 

We don't have coefficients for your model, so it is a bit hard to tell what the 
parameter functions are, but I would expect those NOT to be the slope 
differences.

> Warning message:
> In mcp2matrix(model, linfct = linfct) :
>  covariate interactions found -- default contrast might be inappropriate
> 
> 
> 
> My questions are:
> 
> - Did I make a mistake somewhere? (I probably did!)

You need to figure out how to get glht to look at the appropriate linear 
hypothesis (and mcp(sampling=...) is not right). I'd do a straight lm() 
analysis so that I'd know exactly what the parameters mean -- aov() can be a 
little too good at hiding technical details from the user! 

> - Could I do pairwise ANCOVAs and thus have just two factor levels (=two 
> regression slopes) to compare each time?

Possibly, but you'd lose the multiple comparison features of glht.

> What does the warning message "covariate interactions found -- default 
> contrast might be inappropriate" mean?
> 

That you likely don't want to look at intercepts (or whatever the "sampling" 
parameters represent --- I'm not familiar with that ancova() function) in the 
presence of interactions... 

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

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd@cbs.dk  Priv: pda...@gmail.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] Sample function in R

2012-02-12 Thread R. Michael Weylandt
sessionInfo()?

Can you replicate this behavior in a R --vanilla session? This seems
very odd and I presume you've overwritten sample() somewhere in your
workspace.

Michael

On Sun, Feb 12, 2012 at 12:52 PM, SUPAKORN LAOHAPITAKVORN
 wrote:
> Hi,
> Can anyone help me with the sample () in R?
>
> If I sample from x, I should get one integer.  Can anyone tell me what's
> wrong here?
>> x =1:12
>> sample(x)
> [1] 6.5
>
> And, I cannot get the sample with size = 2
>> sample(x, size = 2)
> Error in sample(x, size = 2) : unused argument(s) (size = 2)
>> sample(x, 2)
> [1] 54.16667
>
> Thank you in advance
>
>        [[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] [R-sig-DB] Reading data from a worksheet on the Internet

2012-02-12 Thread Nilza BARROS
Hi,

I really appreciate your help. I definitively need a reusable program since
I have been asking to  someone to extract these data from the Internet
everyday.  That's the reason why I am trying to do a program to do that
Related to the url I sent, I have just realized that although I had written
 the one related to only worksheet (PLANILHA2) when I copy it to my browse
it is showed the link with both worksheets.


I am going to read about Rcurl and XML libraries but I hope you can help me
too.

Thanks in advance
Nilza Barros


On Sun, Feb 12, 2012 at 10:42 AM, CIURANA EUGENE (R) wrote:

> **
>
> On Sat, 11 Feb 2012 22:49:07 -0200, Nilza BARROS wrote:
>
> I have to read data from a worksheet that is available on the Internet. I
> have been doing this by copying the worksheet from the browser.
> But I would like to be able to copy the data automatically using the url
> command.
>
> But when using  "url" command the result is the source code, I mean, a html
> code.
> I see that the data I need is in the source code but before thinking about
> reading the data from the html code I wonder if there is a package or
> anoher way to extract these data since reading  from the code will demand
> many work and it can be not so accurate.
>
> Below one can see the from where I am trying to export the data:
>
> dadoshttp://www.mar.mil.br/dhn/chm/meteo/prev/dados/pnboia/sc1201_arquivos/sheet002.htm","r
> ")
>
>
>
> Hi Nilza,
>
> The URL that you posted points at a document that has another document
> within it, in a frame.  These files are Excel dumps into HTML.  To view the
> actual data you need the URIs for each data set.  Those appear at the
> bottom of the listing, under sc1201_arquivos/sheet001.htm and sheet002.htm.
>  Your code must fetch these files, not the one at
> http://www.mar.mil.br/dhn/chm/meteo/prev/dados/pnboia/sc1202.htm which
> only "wraps" them.  Most of what you see on the file that you linked isn't
> HTML - it's JavaScript and style information for the data living on the two
> separate HTML documents.
>
> You can do this in R using the RCurl and XML libraries, by pulling the
> specific files for each data source.  If this is a one-time thing, I'd
> suggest just coding something simple that loads the data for each file.  If
> this is something you'll execute periodically, you'll need a bit more code
> to extract the internal data sheets (e.g. the "planhilas" at the bottom),
> then extracting the actual data.
>
> Let me know if you want this as a one-time thing, or as a reusable
> program.  If you don't know how to use RCurl and XML to parse HTML I'll be
> happy to help with that too.  I'd just like to know more about the scope of
> your question.
>
> Cheers,
>
> pr3d
>
> --
> pr3d4t0r at #R, ##java, #awk, #pytonirc.freeenode.net
>
>


-- 
Abraço,
Nilza Barros

[[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] Install the rugarch-package

2012-02-12 Thread nserdar
I got the same error on MAC Lion 

Error in as.environment(pos) : 
  no item called "newtable" on the search list
In addition: Warning message:
In objects(newtable, all.names = TRUE) :
  ‘newtable’ converted to character string
Error: package/namespace load failed for 'rug arch'

Regards,
Serdar

--
View this message in context: 
http://r.789695.n4.nabble.com/Install-the-rugarch-package-tp3911903p4381634.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] Sample function in R

2012-02-12 Thread SUPAKORN LAOHAPITAKVORN
Hi,
Can anyone help me with the sample () in R?

If I sample from x, I should get one integer.  Can anyone tell me what's
wrong here?
> x =1:12
> sample(x)
[1] 6.5

And, I cannot get the sample with size = 2
> sample(x, size = 2)
Error in sample(x, size = 2) : unused argument(s) (size = 2)
> sample(x, 2)
[1] 54.16667

Thank you in advance

[[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] Diallele codes

2012-02-12 Thread Brijesh Angira
Howdy!!!
I am a plant breeding Ph.D. student. I am trying to solve a diallele cross with 
R. Can anyone help with codes?
Thank you
Brijesh
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] How to import time-series data

2012-02-12 Thread RichardSmith

Gabor Grothendieck wrote
> 
> Something seems to have gone wrong in the posting since we can't see
> the sample data that seems to be intended to be part of the post. 
Sorry, I posted via Nabble using the 'raw' command, which got stripped out
it seems. Here's a small sample of the data...
plant,aphid,1,2,3,4
pumpkin,1-2,0.065566,0.057844,0.08,0.086879
pumpkin,1-3,0.107612,0.097272,0.11663,0.160499
squash,1-4,0.126939,0.115003,0.140275,0.188829

columns named 1,2,3,4 etc. correspond to the weight of an aphid after that
many days on that plant. I want to be able to plot the growth of all aphids
on one plot, grouped by plant.


Gabor Grothendieck wrote
> At any rate read.zoo in the zoo package can read series.  You may need to
> use the split= argument if your file defines multiple series tagged by
> an id column.  See ?read.zoo and the Reading Data in Zoo vignette
> which is online here
> http://cran.r-project.org/web/packages/zoo/index.html
> and is an entire document devoted to reading time series.  Alternately
> its available in R through the vignette("zoo-read") command.
> 
Thanks for the link. I can't see any example in the zoo.read vignette which
looks similar. Do I need to transpose my data first, so dates are in one
column? If I do that, how do I keep the plant grouping associated with each
aphid?

Many thanks


--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-import-time-series-data-tp4381372p4381558.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] Longitudinal Factor Analysis

2012-02-12 Thread ilai
?factanal
There is also package sem (structural equations model) by John Fox.

I'm sure there are more (maybe more fitting your situation) but these
two came to mind first...

Cheers


On Sun, Feb 12, 2012 at 6:51 AM, Gregory Gilbert
 wrote:
> I have a data set in the format below. I would like to perform a factor
> analysis on BM1-BM20 as they are 20 biomechanical measurements of the trial
> (hitting a baseball). However, my observations are not independent and, I
> assume, I have to account for this. I have consulted the R literature via
> RSeek and Google (and I have consulted some very knowledgeable colleagues)
> and cannot find any method of doing this in R. Is someone aware of a method
> of reducing the 20 biomechanical measurements?
>
> Thank you for your help.
>
> Greg
>
> ID    PitchType    Location    SwingNumber      BM1...BM20      Hit
> Velocity
> 1     Fastball        1            1            xx  ... xx       1
> 62
> 1     Fastball        1            2            xx  ... xx       1
> 68
> 1     Fastball        1            3            xx  ... xx       0
> 1     Fastball        1            4            xx  ... xx       0
> 1     Fastball        1            5            xx  ... xx       1
> 71
> 1     Fastball        2            1            xx  ... xx       0
> 1     Fastball        2            2            xx  ... xx       1
> 61
> 1     Fastball        2            3            xx  ... xx       1
> 64
> 1     Fastball        2            4            xx  ... xx       1
> 59
> 1     Fastball        2            5            xx  ... xx       0
> 1     Fastball        2            6            xx  ... xx       0
> 1     Fastball        2            7            xx  ... xx       0
> 1     Fastball        2            8            xx  ... xx       0
> 1     Fastball        3            1            xx  ... xx       1
> 78
> 1     Fastball        3            2            xx  ... xx       0
> 1     Fastball        3            3            xx  ... xx       1
> 74
> 1     Fastball        4            1            xx  ... xx       0
> 1     Fastball        4            2            xx  ... xx       1
> 69
> 1     Fastball        4            3            xx  ... xx       1
> 72
> 1     Fastball        4            4            xx  ... xx       1
> 65
> 1     Fastball        4            5            xx  ... xx       0
> 1     Fastball        4            6            xx  ... xx       0
> 1     Fastball        4            7            xx  ... xx       0
> 1     Fastball        4            8            xx  ... xx       1
> 74
> 1     Fastball        4            9            xx  ... xx       1
> 78
> 1     Fastball        4            10           xx  ... xx       1
> 76
> 1     Fastball        5            1            xx  ... xx       0
> 1     Fastball        5            2            xx  ... xx       1
> 53
> 1     Fastball        5            3            xx  ... xx       0
> 1     Fastball        5            4            xx  ... xx       1
> 51
> 1     Fastball        5            5            xx  ... xx       0
> 1     Fastball        5            6            xx  ... xx       1
> 55
> .
> .
> .
> 40    Fastball        5            1            xx  ... xx       0
> 40    Fastball        5            2            xx  ... xx       0
> 40    Fastball        5            3            xx  ... xx       1
> 60
> 40    Fastball        5            4            xx  ... xx       0
> 40    Fastball        5            5            xx  ... xx       0
>
>
>
>
>
> --
> Gregory E. Gilbert, EdD, MSPH, PStat®
> ASA Accredited Professional Statistician™
>
>        [[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] plotting dates, incorrectly scaled x-axis?

2012-02-12 Thread Uwe Ligges



On 12.02.2012 11:09, Christof Kluß wrote:

Hi,

I want to plot with axis.Date(), but something is scaled incorrectly.
The red vertical line in is put on a totally wrong position. (sample below)

Do you have an idea what I'm doing wrong?

Thx
Christof


x11(width=30, height=20)

x<-seq(as.Date("2010-02-27"), as.Date("2011-03-28"),"month")
y<- seq(0,100,length=length(x))

plot(y ~ x, type="o", tck=1, xaxt="n")

axis.Date(1, at=x, labels=format(x,"%b\n%Y"), padj=0.5)

abline(v=as.Date("2011-01-01"), col="red", lty="dashed")



Works fine for me.
See
abline(v=as.Date("2011-01-27"), col="red", lty="dashed")
which is exactly on the date.

Uwe Ligges




plot.png




__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Get identical results for parallel and sequential?

2012-02-12 Thread Uwe Ligges

Please do not double post.

Uwe Ligges


On 11.02.2012 23:20, slbfelix wrote:

Hi All,

I have a question about R parallel computing by using snowfall.

How can I set the seeds on parallel workers to get the same result as
sequential mode?

For example:


sfSapply(c(1,1),rnorm)

[1]  1.823082 -2.222052

rnorm(2)

[1] -0.5179967 -1.0807196

How to get the identical result?

Thanks.
Libo

--
View this message in context: 
http://r.789695.n4.nabble.com/Get-identical-results-for-parallel-and-sequential-tp4380110p4380110.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] R Parallel question

2012-02-12 Thread Uwe Ligges



On 11.02.2012 23:12, slbfelix wrote:

Hi All,

I have a question about R parallel computing by using snowfall.

How can I set the seeds on parallel workers to get the same result as
sequential mode?

For example:


sfSapply(c(1,1),rnorm)

[1]  1.823082 -2.222052

rnorm(2)

[1] -0.5179967 -1.0807196

How to get the identical result?


I don't think you easily can do it, since each node in a cluster has its 
own stream. Repoducing this on a different number of nodes would mean to 
jump around in the RNG stream whcih would be slow (and probably needs 
some programming work).


For a start, read ?RNG

Uwe Ligges





Thanks.
Libo Sun

Graduate Student,
Department of Statistics,
Colorado State University
Fort Collins, CO


--
View this message in context: 
http://r.789695.n4.nabble.com/R-Parallel-question-tp4380098p4380098.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] Vector manipulation

2012-02-12 Thread syrvn
Great Dimitris. It helps indeed! Thanks a lot!

--
View this message in context: 
http://r.789695.n4.nabble.com/Vector-manipulation-tp4381586p4381614.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] Vector manipulation

2012-02-12 Thread Jorge I Velez
Hi mentor_,

Try

c(sapply(vec[-1], function(x) c(vec[1], x)))
# [1]  2  4  2  6  2  9  2 10

HTH,
Jorge.-


On Sun, Feb 12, 2012 at 12:54 PM, syrvn <> wrote:

> Hello,
>
>
> I am stuck with the following problem. Consider the vector:
>
> vec <- c(2,4,6,9,10)
>
> I now want to use R to manipulate the vector as follows:
>
> [1] 2, 4, 2, 6, 2, 9, 2, 10
>
> In words, the first element of the vector should be placed in front of each
> following number.
>
> Which R commands do I need to achieve that?
>
>
> Cheers
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/Vector-manipulation-tp4381586p4381586.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] Vector manipulation

2012-02-12 Thread Dimitris Rizopoulos

One way is:

vec <- c(2,4,6,9,10)
c(rbind(vec[1], vec[-1]))


I hope it helps.

Best,
Dimitris


On 2/12/2012 6:54 PM, syrvn wrote:

Hello,


I am stuck with the following problem. Consider the vector:

vec<- c(2,4,6,9,10)

I now want to use R to manipulate the vector as follows:

[1] 2, 4, 2, 6, 2, 9, 2, 10

In words, the first element of the vector should be placed in front of each
following number.

Which R commands do I need to achieve that?


Cheers

--
View this message in context: 
http://r.789695.n4.nabble.com/Vector-manipulation-tp4381586p4381586.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.



--
Dimitris Rizopoulos
Assistant Professor
Department of Biostatistics
Erasmus University Medical Center

Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
Tel: +31/(0)10/7043478
Fax: +31/(0)10/7043014
Web: http://www.erasmusmc.nl/biostatistiek/

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

2012-02-12 Thread syrvn
Hello,


I am stuck with the following problem. Consider the vector:

vec <- c(2,4,6,9,10)

I now want to use R to manipulate the vector as follows:

[1] 2, 4, 2, 6, 2, 9, 2, 10

In words, the first element of the vector should be placed in front of each
following number.

Which R commands do I need to achieve that?


Cheers

--
View this message in context: 
http://r.789695.n4.nabble.com/Vector-manipulation-tp4381586p4381586.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] DF grouping

2012-02-12 Thread Petr Savicky
On Sun, Feb 12, 2012 at 07:07:26AM -0800, karthicklakshman wrote:
> Hello Members,
> 
> I need to group a data.frame in a a specific way, like shown below,
> 
> DF raw is like this,
> 
> id col1 col2 score
> 1  A  B   40
> 2  B  C   55
> 3  C  D   4000
> 4  D  E100
> 5  E   F300
> 
> I want the out put as
> 
> List
> [1]
> A B C
> [2]
> D E
> [3]
> F
> Basically the split should be based on the DF$score > 200, and all the col1
> and col2 values should be aggrigated.

Hi.

Is it always true that DF[i, "col2"] == DF[i+1, "col1"]?
If yes, then try the following

  # dput() of DF
  DF <- structure(list(col1 = structure(1:5, .Label = c("A", "B", "C",
  "D", "E"), class = "factor"), col2 = structure(1:5, .Label = c("B",
  "C", "D", "E", "F"), class = "factor"), score = c(40L, 55L, 4000L,
  100L, 300L)), .Names = c("col1", "col2", "score"), class = "data.frame",
  row.names = c(NA, -5L))
 
  # linearize col1, col2
  objects <- c(as.character(DF[1, "col1"]), as.character(DF[, "col2"]))
  scores <- c(0, DF[, "score"])
 
  # output as list of vectors
  out1 <- split(objects, cumsum(scores > 200))
  out1

  $`0`
  [1] "A" "B" "C"
  
  $`1`
  [1] "D" "E"
  
  $`2`
  [1] "F"

  # output as list of character strings
  out2 <- lapply(out1, paste, collapse=" ")
  out2

  $`0`
  [1] "A B C"
  
  $`1`
  [1] "D E"
  
  $`2`
  [1] "F"

Hope this helps.

Petr Savicky.

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

2012-02-12 Thread ilai
On Sat, Feb 11, 2012 at 9:10 PM, David Winsemius  wrote:
>
> On Feb 11, 2012, at 6:25 PM, Adel ESSAFI wrote:
>
>>
>>
>> Le 11 février 2012 02:33, David Winsemius  a écrit
>> :
>>
>> On Feb 10, 2012, at 7:05 PM, Adel ESSAFI wrote:
>>
>>
>> what can I do to draw to figures together using lattice?
>
>
> You need to describe what you mean by "together". It is possible that the
> goup parameter is what you want but that's just a guess. It's also possible
> that the formular operator "+" will give you what you desire. Perhaps:
>
> xyplot( law[,67] + law[,66] ~ law[,3]|
> interaction(law[,1],law[,2]),type='l')
>
>
>>
>> it draws multiple histograms but by selecting distinct values of  law[,1]
>> The deal is to make the same thing but for a couple of columns
>
>
> That doesn't make any sense to me. But then I do apologize for the English
> language. It's horribly complex and syntactically a mess.
>

English language aside, do you want histograms (count frequency) or
scatterplots (y~x) ? as David suggested the group argument or '+'
combined with allow.multiple is useful, but not trivial for
histograms. A simple solution is to consider alternatives such density
curves:

densityplot(~as.numeric(volcano[,c(2:5)])|cut(volcano[,1],4),
groups=gl(4,nrow(volcano)),
key=simpleKey(as.character(2:5),points=F,lines=T,columns=4))

In the future, a minimal working example and clear statement of your
goal may reduce the need for multiple posts.

Regards

>
>>
>> Thanks in advance for help
>>
>> Adel
>>
>>
>> --
>>
>> David Winsemius, MD
>> West Hartford, CT
>>
>> --
>> PhD candidate in Computer Science
>> Address
>> 3 avenue lamine, cité ezzahra, Sousse 4000
>> Tunisia
>> tel: +216 97 246 706 (+33640302046 jusqu'au 15/6)
>> fax: +216 71 391 166
>
>
> David Winsemius, MD
> West Hartford, CT
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] Counting the loop-round of a "for"-loop

2012-02-12 Thread Ista Zahn
Hi,

You can initialize a counter and update it in the loop. An silly example 
(unrelated to yours because it was not reproducible) of this technique is:


x <- matrix( , ncol = 2, nrow = 26)

n <- 0
for(i in letters) {
  n <- n+1
  x[n,] <- c(i, n)
}


Best,
Ista


On Sunday, February 12, 2012 07:17:33 AM jolo999 wrote:
> Dear all,
> 
> i have daily stock prices for more than 10 years and want to compute annual
> volatilities for certain dates during this period.  Since i have found no
> "easy" way to work with time data, the data presents itself in the structure
> 
> TIme Index - Stock Price
> 1 - 15,6
> 2 - 17
> ...
> ...
> 2010 - 28
> 2011- 28,5
> ...
> 4500 - 23
> 
> Since I want to have the volatility only for certain dates, I define these
> dates in a vector
> 
> Deal_Dates <- c(500,600,700,805)
> 
> and use the for-command to calculate these specific volatities via
> 
> for(i in Deal_Dates){Volatility(i)}
> 
> My problem is now, that I want to save the results in a new matrix which i
> created in the structure
> 
> results <- matrix(rep(NA,4*2),4,2) in a way that
> 
> Time Index - Volatility
> 500 - 0.55
> 600 - 0.44
> 700 - 0.45
> 805 - 0.66
> is stored in the results matrix.
> 
> How can I save the result of each for-loop  in the matrix? I want the
> respective Time-Index of the loop to be put in the first column and the
> volatility in the second column. Since my vector for the for-loop consists
> of "random" values for the Time-Index, i can't write
> 
> resultsl[i,1] = Time Index and
> results[i,2] = Volatility
> 
> I am looking for something that gives me the current round or iteration of
> the for-loop in order to replace the "i" in adressing the cells of the
> result matrix.
> 
> Hope you can help!
> 
> 
> --
> View this message in context:
> http://r.789695.n4.nabble.com/Counting-the-loop-round-of-a-for-loop-tp43813
> 19p4381319.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] AMOVA error: 'bin' must be numeric or a factor

2012-02-12 Thread Ben Bolker
Hanne Ballestad  bio.uio.no> writes:

>  I am trying to analyse my data using amova 
>  (http://www.oga-lab.net/RGM2/func.php?rd_id=pegas:amova):
> 
>  My input to R is a DNA sequence file, format=fasta
>   dna<- read.dna("XX.fasta", format="fasta") #left other options as 
>  default
>   d<- dist.dna(dna, model="raw")
>   g<- read.table("XXX.design")
> 
>  Load necessary libraries:
>   library(pegas)

  [snip]

>  Running Amova:
>  amova(d ~ g, nperm = 100)
>  Error in FUN(X[[1L]], ...) : 'bin' must be numeric or a factor
> 
>  How can I solve this "bin" problem?

  [snip]

>  My input file for g looks like this:
> 
>  sequenceA1
>  sequenceB1
>  sequenceC1

 [snip]
> 

  I think the "proper manual" you're looking for is actually the
introductory R material -- try looking at the Introduction to R
that comes with R.  You can look up specific commands such as
"c" and "rep" by using ?c or ?rep .

I'm not sure of the structure of your
data, but I think you probably want g[[2]] (i.e. the second
column of g) as your predictor variable. 

  You might get more specific help on the bioconductor mailing
list.

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


Re: [R] How to import time-series data

2012-02-12 Thread Gabor Grothendieck
On Sun, Feb 12, 2012 at 10:52 AM, RichardSmith
 wrote:
> Sorry for this very basic question. I have time-series data, laid out as a
> table (in csv) like this:
>
>
>
> That is, the first column is the sample ID, and subsequent columns are the
> data at time interval in days since the start. In Excel, this is a very
> normal way to lay out time-series data, but I can't find any way to work
> with it in R. I want to import the data to R so I can, for example, plot the
> data for each sample. If I import as a matrix or table, R renames the day
> numbers to e.g. X20 instead of 20. What is the correct way to do this?
>
> Many thanks,
> Richard

Something seems to have gone wrong in the posting since we can't see
the sample data that seems to be intended to be part of the post.  At
any rate read.zoo in the zoo package can read series.  You may need to
use the split= argument if your file defines multiple series tagged by
an id column.  See ?read.zoo and the Reading Data in Zoo vignette
which is online here
http://cran.r-project.org/web/packages/zoo/index.html
and is an entire document devoted to reading time series.  Alternately
its available in R through the vignette("zoo-read") command.

-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.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] plotting dates, incorrectly scaled x-axis?

2012-02-12 Thread Ted Harding
On 12-Feb-2012 Ted Harding wrote:
> On 12-Feb-2012 Christof Kluß wrote:
>> Hi,
>> 
>> I want to plot with axis.Date(), but something is scaled incorrectly.
>> The red vertical line in is put on a totally wrong position.
>> (sample below)
>> 
>> Do you have an idea what I'm doing wrong?
>> 
>> Thx
>> Christof
>> 
>> 
>> x11(width=30, height=20)
>> 
>> x<-seq(as.Date("2010-02-27"), as.Date("2011-03-28"),"month")
>> y <- seq(0,100,length=length(x))
>> 
>> plot(y ~ x, type="o", tck=1, xaxt="n")
>> 
>> axis.Date(1, at=x, labels=format(x,"%b\n%Y"), padj=0.5)
>> 
>> abline(v=as.Date("2011-01-01"), col="red", lty="dashed")
> 
> I don't think it is in the wrong position! What is happening
> is that your month labels on the X-axis are not at the dates
> one would intuitively expect.
> 
>   x
>   #  [1] "2010-02-27" "2010-03-27" "2010-04-27" "2010-05-27"
>   #  [5] "2010-06-27" "2010-07-27" "2010-08-27" "2010-09-27"
>   #  [9] "2010-10-27" "2010-11-27" "2010-12-27" "2011-01-27"
>   # [13] "2011-02-27" "2011-03-27"
> 
> so the labels "Feb 2010", "Mar 2010",  etc., are placed on
> tick-marks which occur on the 27th day of each month.
> 
> Your abline() is dated "2011-01-01", which is five days
> after "2010-12-27" = x[11], fourth from the end.
> 
> If you look at the plot, you will see that the read line
> is a little bit to the right of the fourth tick from the
> end "Dec 2010", which is just where it should be, given
> that you have placed the month names at the 27th of each month.
> 
> One solution would be to use
> 
>   x<-seq(as.Date("2010-02-01"), as.Date("2011-03-01"),"month")
> 
> which would place these on the first of each month. But you
> may have other reasons for wanting to choose the 27th, in which
> case life may get a little more complicated!
> 
> Hopiung this helps,
> Ted.

Having now had another look at this, it would seem that, instead
of your original code:

# x11(width=30, height=20)
# x<-seq(as.Date("2010-02-27"), as.Date("2011-03-28"),"month")
# y <- seq(0,100,length=length(x))
# plot(y ~ x, type="o", tck=1, xaxt="n")
# axis.Date(1, at=x, labels=format(x,"%b\n%Y"), padj=0.5)
# abline(v=as.Date("2011-01-01"), col="red", lty="dashed")

the following gives what you apparently expect:

x11(width=30, height=20)
x<-seq(as.Date("2010-02-27"), as.Date("2011-03-28"),"month")
y <- seq(0,100,length=length(x))
months<-seq(as.Date("2010-02-01"), as.Date("2011-03-02"),"month")
plot(y ~ x, type="o", tck=1, xaxt="n")
axis.Date(1, at=months, labels=format(months,"%b\n%Y"), padj=0.5)
abline(v=as.Date("2011-01-01"), col="red", lty="dashed")

Ted.


-
E-Mail: (Ted Harding) 
Date: 12-Feb-2012  Time: 16:18:08
This message was sent by XFMail

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


[R] DF grouping

2012-02-12 Thread karthicklakshman
Hello Members,

I need to group a data.frame in a a specific way, like shown below,

DF raw is like this,

id col1 col2 score
1  A  B   40
2  B  C   55
3  C  D   4000
4  D  E100
5  E   F300

I want the out put as

List
[1]
A B C
[2]
D E
[3]
F
Basically the split should be based on the DF$score > 200, and all the col1
and col2 values should be aggrigated.

Request your kind help,

Regards,
karthick

--
View this message in context: 
http://r.789695.n4.nabble.com/DF-grouping-tp4381310p4381310.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] How to import time-series data

2012-02-12 Thread RichardSmith
Sorry for this very basic question. I have time-series data, laid out as a
table (in csv) like this:



That is, the first column is the sample ID, and subsequent columns are the
data at time interval in days since the start. In Excel, this is a very
normal way to lay out time-series data, but I can't find any way to work
with it in R. I want to import the data to R so I can, for example, plot the
data for each sample. If I import as a matrix or table, R renames the day
numbers to e.g. X20 instead of 20. What is the correct way to do this?

Many thanks,
Richard

--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-import-time-series-data-tp4381372p4381372.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] Install the rugarch-package

2012-02-12 Thread liweichen0817
Yes, I have updated all my packages.

My initial guess was that there may be some packages conflicting with rug
arch so I uninstalled R and all the bundles I had. I reinstalled R and
installed rugarch first, but I still got the same error message.

--
View this message in context: 
http://r.789695.n4.nabble.com/Install-the-rugarch-package-tp3911903p4381367.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] Longitudinal Factor Analysis

2012-02-12 Thread Gregory Gilbert
I have a data set in the format below. I would like to perform a factor
analysis on BM1-BM20 as they are 20 biomechanical measurements of the trial
(hitting a baseball). However, my observations are not independent and, I
assume, I have to account for this. I have consulted the R literature via
RSeek and Google (and I have consulted some very knowledgeable colleagues)
and cannot find any method of doing this in R. Is someone aware of a method
of reducing the 20 biomechanical measurements?

Thank you for your help.

Greg

IDPitchTypeLocationSwingNumber  BM1...BM20  Hit
Velocity
1 Fastball11xx  ... xx   1
62
1 Fastball12xx  ... xx   1
68
1 Fastball13xx  ... xx   0
1 Fastball14xx  ... xx   0
1 Fastball15xx  ... xx   1
71
1 Fastball21xx  ... xx   0
1 Fastball22xx  ... xx   1
61
1 Fastball23xx  ... xx   1
64
1 Fastball24xx  ... xx   1
59
1 Fastball25xx  ... xx   0
1 Fastball26xx  ... xx   0
1 Fastball27xx  ... xx   0
1 Fastball28xx  ... xx   0
1 Fastball31xx  ... xx   1
78
1 Fastball32xx  ... xx   0
1 Fastball33xx  ... xx   1
74
1 Fastball41xx  ... xx   0
1 Fastball42xx  ... xx   1
69
1 Fastball43xx  ... xx   1
72
1 Fastball44xx  ... xx   1
65
1 Fastball45xx  ... xx   0
1 Fastball46xx  ... xx   0
1 Fastball47xx  ... xx   0
1 Fastball48xx  ... xx   1
74
1 Fastball49xx  ... xx   1
78
1 Fastball410   xx  ... xx   1
76
1 Fastball51xx  ... xx   0
1 Fastball52xx  ... xx   1
53
1 Fastball53xx  ... xx   0
1 Fastball54xx  ... xx   1
51
1 Fastball55xx  ... xx   0
1 Fastball56xx  ... xx   1
55
.
.
.
40Fastball51xx  ... xx   0
40Fastball52xx  ... xx   0
40Fastball53xx  ... xx   1
60
40Fastball54xx  ... xx   0
40Fastball55xx  ... xx   0





-- 
Gregory E. Gilbert, EdD, MSPH, PStat®
ASA Accredited Professional Statistician™

[[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] Counting the loop-round of a "for"-loop

2012-02-12 Thread jolo999
Dear all,

i have daily stock prices for more than 10 years and want to compute annual
volatilities for certain dates during this period.  Since i have found no
"easy" way to work with time data, the data presents itself in the structure

TIme Index - Stock Price
1 - 15,6
2 - 17
...
...
2010 - 28
2011- 28,5
...
4500 - 23

Since I want to have the volatility only for certain dates, I define these
dates in a vector

Deal_Dates <- c(500,600,700,805)  

and use the for-command to calculate these specific volatities via 

for(i in Deal_Dates){Volatility(i)}

My problem is now, that I want to save the results in a new matrix which i
created in the structure

results <- matrix(rep(NA,4*2),4,2) in a way that

Time Index - Volatility
500 - 0.55
600 - 0.44
700 - 0.45
805 - 0.66
is stored in the results matrix.

How can I save the result of each for-loop  in the matrix? I want the
respective Time-Index of the loop to be put in the first column and the
volatility in the second column. Since my vector for the for-loop consists
of "random" values for the Time-Index, i can't write

resultsl[i,1] = Time Index and
results[i,2] = Volatility

I am looking for something that gives me the current round or iteration of
the for-loop in order to replace the "i" in adressing the cells of the
result matrix.

Hope you can help!


--
View this message in context: 
http://r.789695.n4.nabble.com/Counting-the-loop-round-of-a-for-loop-tp4381319p4381319.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] readLines vs scan

2012-02-12 Thread Gabor Grothendieck
On Sun, Feb 12, 2012 at 10:35 AM, Bert Gunter  wrote:
> Folks:
>
> Suppose I wish to input a text file with variable length lines and
> possible whitespace as is and then parse the resulting character
> vector in R. Each line of text is terminated with "\n" (newline
> character).
>
> Is there any reason to prefer one or the other of:
>
> scan (filename, what ="a",sep ="\n")  ##or
> readLines(filename)
>
> If it makes a difference, I'm on Windows.
>
> Many thanks for any advice/insight.

It depends on whether we need to retain the information regarding
which elements were on the same line or not.  In the first case we
retain that info and in the second case we lose it:

> lapply(readLines(textConnection(text)), function(x) scan(text = x))
Read 2 items
Read 3 items
[[1]]
[1] 1 2

[[2]]
[1] 3 4 5

> text <- "1 2\n3 4 5"
> out <- scan(text = text); out
Read 5 items
[1] 1 2 3 4 5

If we did want to get back the info we lost in the last instance we
need to re-read it:

> num.flds <- count.fields(textConnection(text))
> tapply(out, rep(seq_along(num.flds), num.flds), c)
$`1`
[1] 1 2

$`2`
[1] 3 4 5


-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.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] Install the rugarch-package

2012-02-12 Thread Uwe Ligges

Have you run update.packages() already?

Uwe Ligges


On 11.02.2012 23:02, liweichen0817 wrote:

I have problem installing rugarch, too.

I use R 2.14.1 on Mac OS X 10.7.3.  When I tried to load rugauch, I got the
bellowing error message:

Loading required package: Rcpp
Loading required package: RcppArmadillo
Loading required package: numDeriv
Loading required package: chron
Loading required package: Rsolnp
Loading required package: truncnorm
Rsolnp (version 1.11) initialized.
Package rugarch (1.0-7) loaded.  To cite, see citation("rugarch")

Error in as.environment(pos) :
   no item called "newtable" on the search list
In addition: Warning message:
In objects(newtable, all.names = TRUE) :
   ‘newtable’ converted to character string
Error: package/namespace load failed for ‘rug arch’

I have tried removing all related packages and reinstalling them but the
error still exists. I appreciate if someone can help me resolve this issue.

--
View this message in context: 
http://r.789695.n4.nabble.com/Install-the-rugarch-package-tp3911903p4380077.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.


[R] readLines vs scan

2012-02-12 Thread Bert Gunter
Folks:

Suppose I wish to input a text file with variable length lines and
possible whitespace as is and then parse the resulting character
vector in R. Each line of text is terminated with "\n" (newline
character).

Is there any reason to prefer one or the other of:

scan (filename, what ="a",sep ="\n")  ##or
readLines(filename)

If it makes a difference, I'm on Windows.

Many thanks for any advice/insight.

-- 
Best,

Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm

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

2012-02-12 Thread John Kane
Have a lookt at the package ggplot2

I believe it will give you something like the image you link to.

Simple example:
--
library(ggplot2)
mydata <- data.frame(a=1:10, b=1:10, c=letters[1:10])
ggplot(mydata, aes(a,b, colour=c)) + geom_point()
--


John Kane
Kingston ON Canada


> -Original Message-
> From: n...@jonasstein.de
> Sent: Sun, 12 Feb 2012 02:07:06 +0100
> To: r-h...@stat.math.ethz.ch
> Subject: Re: [R] how to plot a nice legend?
> 
>> There are various alternatives available; you can also write your own,
>> by modifying the standard one.
> 
>> Generally there are lots of possibilities for customizing within the
>> standard one; e.g. y.intersp will affect the line spacing, using a
>> negative value for inset (together with xpd=NA) will allow the legend to
>> be moved outside the plot.
> 
> i tried without success:
> 
> plot(1:10)
> legend(1,3, legend=c("one", "two"), inset=-1, xpd=NA)
> 
> The legend is still placed inside the plot on point (1,3)
> 
> What could i have done wrong?
> 
> Can i include a legend like this in a standard plot like
> plot(1:10) too?
> http://www.r-bloggers.com/wp-content/uploads/2011/03/heatmap.png
> 
> kind regards,
> 
> --
> Jonas Stein 
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.


FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop!

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

2012-02-12 Thread Evagelopoulos Thanasis
Could you please help me on the following ANCOVA issue?

This is a part of my dataset:

sampling dist h
1wi  200 0.8687212
2wi  200 0.8812909
3wi  200 0.8267464
4wi0 0.8554508
5wi0 0.9506721
6wi0 0.8112781
7wi  400 0.8687212
8wi  400 0.8414646
9wi  400 0.7601675
10   wi  900 0.6577048
11   wi  900 0.6098403
12   wi  900 0.5574382
13   sp  200 0.9149264
14   sp  200 0.9149264
15   sp  200 0.9248187
16   sp0 0.9974016
17   sp0 0.9997114
18   sp0 0.8812909
...

h is the dependent variable, distance the covariate and sampling the factor.

the slopes for h~distance linear regressions are significantly different from 0 
for all samplings

In order to compare the regression slopes for each sampling, i did an ANCOVA 
with the ancova() function of the HH package:

>mod<-ancova(h~sampling*dist,data)

There was a significant interaction term:

Analysis of Variance Table

Response: h
  Df  Sum Sq Mean Sq F valuePr(>F)
sampling   3 0.22822 0.07607 13.7476 2.624e-06 ***
dist   1 0.51291 0.51291 92.6908 5.703e-12 ***
sampling:dist  3 0.05112 0.01704  3.0792   0.03822 *
Residuals 40 0.22134 0.00553

Because there exist significantly different regression slopes, I did a post hoc 
test with glht() to find out between which samplings:

>summary(glht(mod, linfct=mcp(sampling="Tukey")))

The results seem to say that there are no significantly different slopes for 
any of the pair-wise comparisons of factor levels:

  Simultaneous Tests for General Linear Hypotheses

Multiple Comparisons of Means: Tukey Contrasts


Fit: aov(formula = h ~ sampling * dist, data = data)

Linear Hypotheses:
 Estimate Std. Error z value Pr(>|z|)
sp - au == 0  0.066960.04562   1.4680.457
su - au == 0 -0.022380.04562  -0.4910.961
wi - au == 0  0.012030.04562   0.2640.994
su - sp == 0 -0.089340.04562  -1.9580.204
wi - sp == 0 -0.054930.04562  -1.2040.624
wi - su == 0  0.034410.04562   0.7540.875
(Adjusted p values reported -- single-step method)

Warning message:
In mcp2matrix(model, linfct = linfct) :
  covariate interactions found -- default contrast might be inappropriate



My questions are:

- Did I make a mistake somewhere? (I probably did!)
- Could I do pairwise ANCOVAs and thus have just two factor levels (=two 
regression slopes) to compare each time?
What does the warning message "covariate interactions found -- default contrast 
might be inappropriate" mean?

Thank you!
Athanasios Evagelopoulos
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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-sig-DB] Reading data from a worksheet on the Internet

2012-02-12 Thread CIURANA EUGENE (R)
  

On Sat, 11 Feb 2012 22:49:07 -0200, Nilza BARROS wrote: 

> I have
to read data from a worksheet that is available on the Internet. I
>
have been doing this by copying the worksheet from the browser.
> But I
would like to be able to copy the data automatically using the url
>
command.
> 
> But when using "url" command the result is the source
code, I mean, a html
> code.
> I see that the data I need is in the
source code but before thinking about
> reading the data from the html
code I wonder if there is a package or
> anoher way to extract these
data since reading from the code will demand
> many work and it can be
not so accurate.
> 
> Below one can see the from where I am trying to
export the data:
> 
>
dadoshttp://www.mar.mil.br/dhn/chm/meteo/prev/dados/pnboia/sc1201_arquivos/sheet002.htm","r
>
")

Hi Nilza, 

The URL that you posted points at a document that has
another document within it, in a frame. These files are Excel dumps into
HTML. To view the actual data you need the URIs for each data set. Those
appear at the bottom of the listing, under sc1201_arquivos/sheet001.htm
and sheet002.htm. Your code must fetch these files, not the one at
http://www.mar.mil.br/dhn/chm/meteo/prev/dados/pnboia/sc1202.htm [1]
which only "wraps" them. Most of what you see on the file that you
linked isn't HTML - it's JavaScript and style information for the data
living on the two separate HTML documents. 

You can do this in R using
the RCurl and XML libraries, by pulling the specific files for each data
source. If this is a one-time thing, I'd suggest just coding something
simple that loads the data for each file. If this is something you'll
execute periodically, you'll need a bit more code to extract the
internal data sheets (e.g. the "planhilas" at the bottom), then
extracting the actual data. 

Let me know if you want this as a one-time
thing, or as a reusable program. If you don't know how to use RCurl and
XML to parse HTML I'll be happy to help with that too. I'd just like to
know more about the scope of your question. 

Cheers, 

pr3d 

--

pr3d4t0r at #R, ##java, #awk, #pyton
irc.freeenode.net

-- 
pr3d4t0r at
#R, ##java, #awk, #pyton
irc.freeenode.net
  

Links:
--
[1]
http://www.mar.mil.br/dhn/chm/meteo/prev/dados/pnboia/sc1202.htm

[[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 plot a nice legend

2012-02-12 Thread Bretschneider SIG-R
Dear Jonas Stein,


You may add a line defining a large margin to harbour the legend,
such as:

par(mai=c(0.5, 0.5, 0.5, 1.8))   #  enlarged right margin
plot(1:10)
legend("right", legend=c("one", "two"), inset=-0.2, xpd=NA)


Kind regards,



Franklin Bretschneider
--
Dept Biologie
Kruytgebouw W711
Padualaan 8
3584 CH Utrecht
The Netherlands

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


Re: [R] Counting occurences of variables in a dataframe

2012-02-12 Thread Kai Mx
Amazing. Thanks everybody for the help. I have about 12,000 rows of data
with up to 50 reccurrences, but it seems to work like a charm.

Best,

Kai


On Sun, Feb 12, 2012 at 8:11 AM, Petr Savicky  wrote:

> On Sat, Feb 11, 2012 at 04:05:25PM -0500, David Winsemius wrote:
> >
> > On Feb 11, 2012, at 1:17 PM, Kai Mx wrote:
> >
> > >Hi everybody,
> > >I have a large dataframe similar to this one:
> > >knames <-c('ab', 'aa', 'ac', 'ad', 'ab', 'ac', 'aa', 'ad','ae', 'af')
> > >kdate <- as.Date( c('20111001', '2002', '20101001', '20100315',
> > >'20101201', '20110105', '20101001', '20110504', '20110603',
> > >'20110201'),
> > >format="%Y%m%d")
> > >kdata <- data.frame (knames, kdate)
> >
> > >  ave(unclass(kdate), knames, FUN=order )
> >  [1] 2 2 1 1 1 2 1 2 1 1
> >
> >
> > That was actually not using the dataframe values but you could also do
> > this:
> >
> > > kdata$ord <- with(kdata, ave(unclass(kdate), knames, FUN=order ))
> > > kdata
> >knames  kdate ord
> > 1  ab 2011-10-01   2
> > 2  aa 2011-11-02   2
> > 3  ac 2010-10-01   1
> > 4  ad 2010-03-15   1
> > 5  ab 2010-12-01   1
> > 6  ac 2011-01-05   2
> > 7  aa 2010-10-01   1
> > 8  ad 2011-05-04   2
> > 9  ae 2011-06-03   1
> > 10 af 2011-02-01   1
>
> Hi.
>
> This is a good solution, if there are at most two occurrences
> of each name. If there are more occurrences, then function "order"
> should be replaced by "rank". Replacing name "aa" at row 2 by "ab",
> we get
>
>  knames <-c('ab', 'ab', 'ac', 'ad', 'ab', 'ac', 'aa', 'ad','ae', 'af')
>   kdate <- as.Date( c('20111001', '2002', '20101001', '20100315',
>  '20101201', '20110105', '20101001', '20110504', '20110603', '20110201'),
>  format="%Y%m%d")
>  kdata <- data.frame (knames, kdate)
>
>   kdata$ord <- with(kdata, ave(unclass(kdate), knames, FUN=order))
>   kdata$rank <- with(kdata, ave(unclass(kdate), knames, FUN=rank))
>  kdata
>
> knames  kdate ord rank
>  1  ab 2011-10-01   32
>  2  ab 2011-11-02   13
>  3  ac 2010-10-01   11
>  4  ad 2010-03-15   11
>  5  ab 2010-12-01   21
>  6  ac 2011-01-05   22
>  7  aa 2010-10-01   11
>  8  ad 2011-05-04   22
>  9  ae 2011-06-03   11
>  10 af 2011-02-01   11
>
> The names "ab" occur in the order row 5, row 1, row 2, so
> row 1 should get index 2, row 2 index 3.
>
> If some of the dates repeat, then rank() by default computes
> the average index. In this case, the following function f()
> may be used
>
>  knames <-c('ab', 'ab', 'ac', 'ad', 'ab', 'ac', 'aa', 'ad','ae', 'af')
>  kdate <- as.Date( c('20111001', '20111001', '20101001', '20100315',
>   '20101201', '20110105', '20101001', '20110504', '20110603', '20110201'),
>  format="%Y%m%d")
>  kdata <- data.frame (knames, kdate)
>
>   kdata$rank <- with(kdata, ave(unclass(kdate), knames, FUN=rank))
>  f <- function(x) rank(x, ties.method="first")
>  kdata$f <- with(kdata, ave(unclass(kdate), knames, FUN=f))
>  kdata
>
> knames  kdate rank f
>  1  ab 2011-10-01  2.5 2
>  2  ab 2011-10-01  2.5 3
>  3  ac 2010-10-01  1.0 1
>  4  ad 2010-03-15  1.0 1
>  5  ab 2010-12-01  1.0 1
>  6  ac 2011-01-05  2.0 2
>  7  aa 2010-10-01  1.0 1
>  8  ad 2011-05-04  2.0 2
>  9  ae 2011-06-03  1.0 1
>  10 af 2011-02-01  1.0 1
>
> Hope this helps.
>
> Petr Savicky.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] plotting dates, incorrectly scaled x-axis?

2012-02-12 Thread Ted Harding
On 12-Feb-2012 Christof Kluß wrote:
> Hi,
> 
> I want to plot with axis.Date(), but something is scaled incorrectly.
> The red vertical line in is put on a totally wrong position.
> (sample below)
> 
> Do you have an idea what I'm doing wrong?
> 
> Thx
> Christof
> 
> 
> x11(width=30, height=20)
> 
> x<-seq(as.Date("2010-02-27"), as.Date("2011-03-28"),"month")
> y <- seq(0,100,length=length(x))
> 
> plot(y ~ x, type="o", tck=1, xaxt="n")
> 
> axis.Date(1, at=x, labels=format(x,"%b\n%Y"), padj=0.5)
> 
> abline(v=as.Date("2011-01-01"), col="red", lty="dashed")

I don't think it is in the wrong position! What is happening
is that your month labels on the X-axis are not at the dates
one would intuitively expect.

  x
  #  [1] "2010-02-27" "2010-03-27" "2010-04-27" "2010-05-27"
  #  [5] "2010-06-27" "2010-07-27" "2010-08-27" "2010-09-27"
  #  [9] "2010-10-27" "2010-11-27" "2010-12-27" "2011-01-27"
  # [13] "2011-02-27" "2011-03-27"

so the labels "Feb 2010", "Mar 2010",  etc., are placed on
tick-marks which occur on the 27th day of each month.

Your abline() is dated "2011-01-01", which is five days
after "2010-12-27" = x[11], fourth from the end.

If you look at the plot, you will see that the read line
is a little bit to the right of the fourth tick from the
end "Dec 2010", which is just where it should be, given
that you have placed the month names at the 27th of each month.

One solution would be to use

  x<-seq(as.Date("2010-02-01"), as.Date("2011-03-01"),"month")

which would place these on the first of each month. But you
may have other reasons for wanting to choose the 27th, in which
case life may get a little more complicated!

Hopiung this helps,
Ted.

-
E-Mail: (Ted Harding) 
Date: 12-Feb-2012  Time: 11:15:43
This message was sent by XFMail

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


[R] plotting dates, incorrectly scaled x-axis?

2012-02-12 Thread Christof Kluß
Hi,

I want to plot with axis.Date(), but something is scaled incorrectly.
The red vertical line in is put on a totally wrong position. (sample below)

Do you have an idea what I'm doing wrong?

Thx
Christof


x11(width=30, height=20)

x<-seq(as.Date("2010-02-27"), as.Date("2011-03-28"),"month")
y <- seq(0,100,length=length(x))

plot(y ~ x, type="o", tck=1, xaxt="n")

axis.Date(1, at=x, labels=format(x,"%b\n%Y"), padj=0.5)

abline(v=as.Date("2011-01-01"), col="red", lty="dashed")
<>__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] plotting dates, incorrectly scaled x-axis?

2012-02-12 Thread Christof Kluß
Hi,

I want to plot with axis.Date(), but something is scaled incorrectly.
The red vertical line in is put on a totally wrong position. (sample below)

Do you have an idea what I'm doing wrong?

Thx
Christof


x11(width=30, height=20)

x<-seq(as.Date("2010-02-27"), as.Date("2011-03-28"),"month")
y <- seq(0,100,length=length(x))

plot(y ~ x, type="o", tck=1, xaxt="n")

axis.Date(1, at=x, labels=format(x,"%b\n%Y"), padj=0.5)

abline(v=as.Date("2011-01-01"), col="red", lty="dashed")

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


Re: [R] Embed R code in online database

2012-02-12 Thread Barry Rowlingson
On Sat, Feb 11, 2012 at 5:49 PM, Jokel Meyer  wrote:
> Dear R-List!
>
> I would like to embed R code in an online database such as i.e. a google
> spreadsheet in way that users can add data to the database and that R's
> calculations are updated automatically and i.e. given out in the
> spreadsheet. Maybe even graphs could be updated online? Is there a way to
> implement this?

 There's no way to integrate R into a google spreadsheet as tightly
as, say, letting you put R expressions into formulae for cells.

 There's also, I think, no way to trigger an external action when a
spreadsheet is modified or saved.

 So, I think the only thing you can do, is to periodically check if
the spreadsheet is modified, run an R script, and upload the modified
data to Google.

 I'm not sure what the current state-of-the-art interface from R to
google docs is. Maybe
http://r-forge.r-project.org/projects/rgoogledata/

Barry

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


[R] The forecasting of images

2012-02-12 Thread Ross Bowden
Hi everyone. Are there any packages in R that can be used for short-term 
forecasting of a sequence of images? Black and white photos of the 
visible sky are taken say every 5 minutes indicating the presence or 
otherwise of clouds in each pixel. There doesn't appear to be an obvious 
modelling solution in R's spatial statistics packages and I have tried 
querying r-sig-Geo without success (apologies for cross posting).


--

Ross Bowden
PhD Candidate, Murdoch University, Western Australia
Statistical and Pricing Consultant
ross.bowden at iinet.net.au

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