Re: [R] How to assign height value on bar plot?

2012-05-26 Thread Greg Snow
Did you look at the help page that Uwe directed you to?  At least one
of the examples on that page demonstrates adding text to a barplot.
But before you do that you should read through the discussion here:
http://tolstoy.newcastle.edu.au/R/e2/help/07/08/22858.html on why you
might not want to add text to the top of the bars and some of the
alternatives.

On Sat, May 26, 2012 at 12:30 PM, Manish Gupta
 wrote:
> My Question is how to write height length on each bar.
>
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/How-to-assign-height-value-on-bar-plot-tp4631457p4631468.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.



-- 
Gregory (Greg) L. Snow Ph.D.
538...@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] How to assign height value on bar plot?

2012-05-26 Thread Jim Lemon

On 05/27/2012 04:30 AM, Manish Gupta wrote:

My Question is how to write height length on each bar.


Hi Manish,
If don't have stacked bars, it is fairly simple:

barpos<-barplot(height,...)
text(barpos,height,labels=height)

usually with a bit of fooling around with the cex argument. If you want 
each value in a little box, try boxed.labels in plotrix.


Jim

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


Re: [R] how to check given number seq. is time series or not?

2012-05-26 Thread Jeff Newmiller
could be. how would you know?
---
Jeff NewmillerThe .   .  Go Live...
DCN:Basics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
--- 
Sent from my phone. Please excuse my brevity.

sagarnikam123  wrote:

>is this is time series ?
>
>
>   x
>1  2
>2  2
>3  2
>4  2
>5  2
>6  2
>7  2
>8  2
>9  2
>10 2
>11 2
>12 2
>
>
>--
>View this message in context:
>http://r.789695.n4.nabble.com/how-to-check-given-number-seq-is-time-series-or-not-tp4631434p4631483.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] how to check given number seq. is time series or not?

2012-05-26 Thread sagarnikam123
is this is time series ?


   x
1  2
2  2
3  2
4  2
5  2
6  2
7  2
8  2
9  2
10 2
11 2
12 2


--
View this message in context: 
http://r.789695.n4.nabble.com/how-to-check-given-number-seq-is-time-series-or-not-tp4631434p4631483.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 measure level of similarity of two data frames

2012-05-26 Thread Lamke
Thanks Ozgur.  I will definitely try them out.

Cheers,
Kel

--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-measure-level-of-similarity-of-two-data-frames-tp4631466p4631478.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] Problem with readHTMLTable

2012-05-26 Thread arun
Hi Sven,

The function is working perfectly fine for me.  Could it be due to package 
masking the function?  Sometimes, these problems will get solved by restarting 
R console.  It happened to me a couple of times.

A.K.



- Original Message -
From: Sven D 
To: r-help@r-project.org
Cc: 
Sent: Saturday, May 26, 2012 10:17 AM
Subject: [R] Problem with readHTMLTable

Hello All,

i was trying to simply run the readHTMLTable on the example published in the
package. And on a page I was working on. So running:

u = "http://en.wikipedia.org/wiki/List_of_countries_by_population";
tables = readHTMLTable(u)

returns the following error:

Error in tb[["thead"]] : subscript out of bounds


looking up this error on the web, didnt give me any hint. Is something wrong
with this function?


this is my sessioninfo:

> sessionInfo()
R version 2.14.1 (2011-12-22)
Platform: i386-pc-mingw32/i386 (32-bit)

locale:
[1] LC_COLLATE=English_United Kingdom.1252  LC_CTYPE=English_United
Kingdom.1252    LC_MONETARY=English_United Kingdom.1252
[4] LC_NUMERIC=C                            LC_TIME=English_United
Kingdom.1252    

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

other attached packages:
[1] XML_3.9-4.1                  RCurl_1.91-1.1              
bitops_1.0-4.1               PerformanceAnalytics_1.0.3.2
[5] quantstrat_0.6.4             blotter_0.8.4              
FinancialInstrument_0.13.6   quantmod_0.3-17            
[9] Defaults_1.1-1               TTR_0.21-0                   xts_0.8-2         
         
zoo_1.7-6                  

loaded via a namespace (and not attached):
[1] grid_2.14.1    IBrokers_0.9-3 lattice_0.20-0 tools_2.14.1  

Many thanks 



Sven




--
View this message in context: 
http://r.789695.n4.nabble.com/Problem-with-readHTMLTable-tp4631439.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] how to check given number seq. is time series or not?

2012-05-26 Thread sagarnikam123
Yes,sir index of above/below numbers is time (both dataset are same)

x
1   0.8890464
2   1.2272616
3   1.2272616
4   1.3578511
5   1.3578511
6   1.1070461
7   1.4424190
8   1.2277843
9   1.3578511
10  0.9708839
11  0.8221709
12  1.3578511
13  0.3588158
14  0.7742342
15  0.8221709
16  0.8221709
17  0.7259998
18  0.6715839
19  0.8132233
20  0.7742342
21  1.0018480
22  1.4424190
23  1.2272616
24  0.9708839
25  0.3588158
26  1.3101684
27  0.9708839
28  1.4424190
29  0.8890464
30  4.9167998
31  1.2277843
32  1.2160533
33  0.3698620
34  0.7747481
35  0.3698620
36  1.4424190
37  1.2272616
38  1.4424190
39  1.2272616
40  1.1629110
41  2.3386331
42  0.7742342
43  4.9167998
44  0.9670581
45  0.9708839
46  0.9670581
47  1.1070461
48  4.9167998
49  1.4424190
50  1.0541099
51  1.2272616
52  1.2160533
53  1.3578511
54  0.8221709
55  1.4424190
56  0.9708839
57  0.8354292
58  0.7742342
59  1.6132899
60  0.9708839
61  1.2277843
62  1.2272616
63  0.9708839
64  1.1070461
65  1.1070461
66  1.1070461
67  1.4424190
68  1.2272616
69  1.4424190
70  1.3578511
71  0.9670581
72  0.9670581
73  0.8854192
74  1.1629110
75  0.3698620
76  0.9670581
77  0.7747481
78  1.2272616
79  1.4424190
80  1.2272616
81  1.3101684
82  0.8132233
83  1.4424190
84  0.8221709
85  1.0541099
86  0.8530141
87  1.3245534
88  0.7742342
89  0.7742342
90  1.2272616
91  0.8890464
92  1.4424190
93  0.8426226
94  0.8890464
95  0.8890464
96  1.3189847
97  1.4424190
98  1.3578511
99  0.6826173
100 0.9651803

kindly tell me is this is time series or not ?
if yes,how can i find by coding/programming?


--
View this message in context: 
http://r.789695.n4.nabble.com/how-to-check-given-number-seq-is-time-series-or-not-tp4631434p4631482.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] Assessing interaction effects in GLMMs

2012-05-26 Thread arun
HI Luke,

It would be better to ask this question on R mixed models 
(r-sig-mixed-mod...@r-project.org).  Just for curiosity (as I am doing a 
similar kind of light/dark response in insects), I am interested in the 
response variable (y) using cbind().  If I understand it correctly, you are 
using kind of a quasibinomial type of reponse (cbind(counts_in_sun, 
12-counts_in_sun)).  I might be wrong.  It would be also great to have a 
workable small dataset using "dput".

A.K.





- Original Message -
From: Luke Duncan 
To: r-help@r-project.org
Cc: 
Sent: Saturday, May 26, 2012 6:19 AM
Subject: [R] Assessing interaction effects in GLMMs

Dear R gurus

I am running a GLMM that looks at whether chimpanzees spend time in shade
more than sun (response variable 'y': used cbind() on counts in the sun and
shade) based on the time of day (Time) and the availability of shade
(Tertile). I've included some random factors too which are the chimpanzee
in question (Individual) and where they are in a given area (Zone). There
are also two continuous predictors (Minimum daily temperature: Min; Maximum
daily temperature: Max). I have run my GLMM and I know that Time and Min
are significant predictors of the patterns of shade use while Tertile and
Max are not. In addition, a Time*Tertile interaction effect is a good
predictor as well.

I now need to assess how the specific interaction effect conditions differ
to one another. So, for example, how does shade use differ between 10h00 at
low shade and 10h00 at high shade? I tried using the package multcomp, but
that will only allow me to work out the contrasts for the first-order
effects (Time, Tertile) but won't allow me to do so for the interaction
effects. Any ideas?

My code:

> m1 <- lmer(y ~ Time*Tertile + (1|Individual) + (1|Zone) + Max +
Min,family=binomial,REML=F)
> Anova(m1,type=3,test="Wald")
Analysis of Deviance Table (Type III tests)

Response: y
               Chisq Df Pr(>Chisq)
(Intercept)   0.9511  1     0.3294
Time         60.7807  4  1.988e-12 ***
Tertile       0.3391  1     0.5603
Max           1.3198  1     0.2506
Min          77.7736  1  < 2.2e-16 ***
Time:Tertile 38.9038  4  7.292e-08 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
> summary(m1)
Generalized linear mixed model fit by the Laplace approximation
Formula: y ~ Time * Tertile + (1 | Individual) + (1 | Zone) + Max + Min
  AIC  BIC logLik deviance
1168 1224 -569.9     1140
Random effects:
Groups     Name        Variance Std.Dev.
Zone       (Intercept) 0.81949  0.90526
Individual (Intercept) 0.36417  0.60347
Number of obs: 412, groups: Zone, 8; Individual, 7

Fixed effects:
                     Estimate Std. Error z value Pr(>|z|)
(Intercept)           0.77498    0.79465   0.975 0.329439
Time11h00            -1.54259    0.24351  -6.335 2.38e-10 ***
Time12h00             0.01695    0.77829   0.022 0.982627
Time13h00            -4.26913    0.78217  -5.458 4.81e-08 ***
Time14h00            -1.34503    0.43831  -3.069 0.002150 **
TertileLow            0.32614    0.56003   0.582 0.560323
Max                   0.03751    0.03265   1.149 0.250630
Min                  -0.30912    0.03505  -8.819  < 2e-16 ***
Time11h00:TertileLow  1.03079    0.28579   3.607 0.000310 ***
Time12h00:TertileLow -2.26187    0.79930  -2.830 0.004658 **
Time13h00:TertileLow  2.38129    0.79214   3.006 0.002646 **
Time14h00:TertileLow  1.72263    0.49397   3.487 0.000488 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Correlation of Fixed Effects:
            (Intr) Tm1100 Tm1200 Tm1300 Tm1400 TrtlLw Max    Min    T1100:
Time11h00   -0.026
Time12h00   -0.035  0.177
Time13h00   -0.004  0.223  0.068
Time14h00   -0.073  0.259  0.081  0.103
TertileLow  -0.450  0.153  0.043  0.051  0.097
Max         -0.711 -0.169 -0.004 -0.061 -0.023  0.019
Min          0.146  0.186  0.014  0.055  0.099 -0.036 -0.455
Tm11h00:TrL  0.059 -0.851 -0.153 -0.190 -0.222 -0.198  0.096 -0.155
Tm12h00:TrL  0.095 -0.160 -0.974 -0.062 -0.081 -0.067 -0.079  0.012  0.192
Tm13h00:TrL  0.026 -0.208 -0.067 -0.983 -0.099 -0.075  0.024 -0.026  0.229
Tm14h00:TrL  0.126 -0.215 -0.069 -0.088 -0.876 -0.185 -0.047  0.006  0.254
            T1200: T1300:
Time11h00
Time12h00
Time13h00
Time14h00
TertileLow
Max
Min
Tm11h00:TrL
Tm12h00:TrL
Tm13h00:TrL  0.081
Tm14h00:TrL  0.098  0.116

Luke Duncan

*Post-doctoral** Fellow*
*School of Animal, Plant and Environmental Sciences*
*University of the Witwatersrand*
*Johannesburg, South Africa*
**
*+27 72 312 0330*
*+27 11 717 6452*

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

Re: [R] How to assign height value on bar plot?

2012-05-26 Thread Manish Gupta
My Question is how to write height length on each bar.

--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-assign-height-value-on-bar-plot-tp4631457p4631468.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] subset columns from list with variable substitution

2012-05-26 Thread Jon Ween, MD
Thanks Don

Please forgive my poor mail-liost etiquette.

I had a couple of errors:

1) the counter logic in the loop was "i in name list", my typo in the post.
2) There were typos in the variable list that caused the loop to crash when 
they were encountered.

Thanks for your help, really appreciated.

Best

Jon

On 2012-05-25, at 1:43 PM, MacQueen, Don wrote:

> The select argument to subset() is supposed to name the columns you want
> to keep.
> So is the syntax I gave, table[,list1], and it is the correct way when
> list1 is a character vector (which it is).
> 
> Your error message says that at least one of the values in list1 is not
> the name of a column in your data frame.
> 
> 
> So, compare
>  names(table)
> with
>   list1
> (it looks like your data frame doesn't really have the column names you
> think it has)
> 
> If you just type
>  i %in% namelist
> by itself, what do you get? Is it what you are trying to loop over?
> Heck, what do you get from
>  print(i)
> ?
> 
> If you are trying to loop over the names in namelist, you MUST use
>  for (i in namelist)
> the expression  i %in% namelist
> will give you some combination of logical values TRUE and/or FALSE,
> depending on the value of i at the time when you use the expression.
> 
> So if it "doesn't work", it's for some other reason. Also, just saying it
> doesn't work isn't enough information. Please read and follow the posting
> guide (mentioned at the end of every R-help email)
> 
> You are using i as a loop index, not only in
> 
> If I do your i %in% namelist in a fresh R session, I get:
>> i %in% namelist
>  Error in match(x, table, nomatch = 0L) : object 'i' not found
> So you must already have i defined. This is probably confusing the issue.
> 
> 
> 
> 
> Also, since you are assigning a value to table2 inside the loop, the value
> when the loop is done will be whatever it was the last time through the
> loop.
> 
> By the way, table() is a built in R function, so 'table' not a good choice
> for other uses.
> 
> Just for understanding R terminology, a list in R has a special structure.
> You don't have any lists in your example. Your objects list1, list2,
> namelist, group1, and group2 are all character vectors.
> 
> The help page for subset() gives examples of how to use the select
> argument, and specifying a character vector is not one of the ways to use
> it.
> 
> 
> But given how you define list1, the correct "display" of it is
> 
>> list1
>  [1] "a" "b" "c" "d"
> 
> This appears to be what you want, so that's not the explanation.
> 
> Try
>  length(list1)
>  str(list1)
> to learn a little more.
> 
> 
> 
> -- 
> Don MacQueen
> 
> Lawrence Livermore National Laboratory
> 7000 East Ave., L-627
> Livermore, CA 94550
> 925-423-1062
> 
> 
> 
> 
> 
> On 5/25/12 12:32 PM, "jween"  wrote:
> 
>> Thanks Don
>> 
>> but 
>> 
>> table[,list1]
>> 
>> did not work either:
>> 
>> Error in `[.data.frame`(table, , list1) : undefined columns selected.
>> 
>> I'm guessing my list (list1) is not structured right? Displaying it has no
>> commas, so the whole list may be taken as a single variable rather than a
>> sequence of variables? I've tried various ways of reformatting (c(),
>> as.list(), etc), but no go.
>> 
>> also
>> 
>> "i in namelist" does not work while
>> "i %in% namelist" does. I don't really reference "i" in any function, only
>> using it in the conditional.
>> 
>> 
>> Any other suggestions?
>> 
>> Thanks
>> 
>> Jon
>> 
>> On 5/25/12 11:09 AM, "jween"  wrote:
>> 
>>> Hi there, I would like to use a list variable to select columns in a
>>> subset
>>> from a parent table:
>>> 
>>> I have a data frame "table" with column headers a,b,c,d,e,x,y,z
>>> 
>>> and list variables
>>> 
>>> list1=c("a","b","c","d")
>>> list2=c("a","b","x",y","z")
>>> namelist=c("peter","paul","mary","jane")
>>> group1=c("peter","paul")
>>> group2=c("mary","jane")
>>> 
>>> I would like to subset "table" based on the list variable in a for loop:
>>> 
>>> for (i %in% namelist){
>>>if (i %in% group1){table2<-subset(table, select=list1)}
>>>else {{table2<-subset(table, select=list2)}
>>> }
>>> 
>>> the "select=list1" syntax does not work. What would be the correct way
>>> to do
>>> this?
>>> 
>>> Many Thanks
>>> 
>>> Jon
>>> 
>>> 
> 
> 
> __
> This email has been scanned by the Symantec Email Security.cloud service.
> For more information please visit http://www.symanteccloud.com
> __


__
This email has been scanned by the Symantec Email Security.cloud service.
For more information please visit http://www.symanteccloud.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-containe

[R] How to measure level of similarity of two data frames

2012-05-26 Thread Lamke
Hi group,

I've been thinking of calculating euclidean distance between each column of
a data frames that each consists of standardized numerical columns. 
However, I don't know if there's a way of summarizing the overall distance
by some kind of metrics.  If anyone know a proper way of doing so and/or a
package I would greatly appreciate your suggestions.  Thanks very much!

Kel

--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-measure-level-of-similarity-of-two-data-frames-tp4631466.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] a simple mixed model

2012-05-26 Thread array chip
Hi, I was reviewing a manuscript where a linear mixed model was used. The data 
is simple: a response variable "y" was measured for each subject over 3 time 
points (visit 1, 2 and 3) that were about a week apart between 2 visits. The 
study is a non-drug study and one of the objectives was to evaluate the 
repeatability of response variable "y". 


The author wanted to estimate within-subject variance for that purpose. This is 
what he wrote "within-subject variance was generated from SAS 'Prog Mixed' 
procedure with study visit as fixed effect and subject as random effect". I 
know that the study visit was a factor variable, not a numeric variable. 
Because each subject has 3 repeated measurements from 3 visits, how can a model 
including subject as random effect still use visit as fixed factor? If I would 
do it in R, I would just use a simple model to get within-subject variance:

obj<-lmer(y~1+(1|subject),data=data)

What does a model "obj<-lmer(y~visit+(1|subject),data=data)" mean?

appreciate any thoughts!

John

[[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] barplot problem

2012-05-26 Thread R. Michael Weylandt
It sounds like you want something of the form

plot(distance, data, type = "h")

But the lines might be too thin: try adding lwd = NUM to increase the
thickness.

Hope this helps,
Michael

On Sat, May 26, 2012 at 11:26 PM, jack hietpas  wrote:
> Hello- I am having trouble making a barplot...
>
> The y-values are:
> data=c(-0.0002129061,0.00,-0.0002699561,0.0163883061,0.04).
>
> The x-values are distance=c(0, 71, 172, 206, 292).
> The desired x-range is 0 and ~300+ (kilometers), range=seq(0,300,1)
>
> I would like to make a bar plot with the bar locations along the x-axis
> spaced according to their distances.
>
> I have tried barplot(distance, data)... but this produces a very strange
> plot.
>
> plot(distance, data) is almost correct, except it is a scatter plot.
>
> Thanks for any help you can provide, I must be missing something very
> obvious.
>
> Take care,
>
> -jh
>
>        [[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] barplot problem

2012-05-26 Thread jack hietpas
Hello- I am having trouble making a barplot...

The y-values are:
data=c(-0.0002129061,0.00,-0.0002699561,0.0163883061,0.04).

The x-values are distance=c(0, 71, 172, 206, 292).
The desired x-range is 0 and ~300+ (kilometers), range=seq(0,300,1)

I would like to make a bar plot with the bar locations along the x-axis
spaced according to their distances.

I have tried barplot(distance, data)... but this produces a very strange
plot.

plot(distance, data) is almost correct, except it is a scatter plot.

Thanks for any help you can provide, I must be missing something very
obvious.

Take care,

-jh

[[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 do I modify sytem shell environment from within R?

2012-05-26 Thread Jeff Newmiller
You don't, at least not for building libraries. Do it at the command line 
before you invoke the R commands. If you are using Cygwin, then be sure to use 
the Bash shell export command to set the variables.
---
Jeff NewmillerThe .   .  Go Live...
DCN:Basics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
--- 
Sent from my phone. Please excuse my brevity.

Michael  wrote:

>Hi all,
>
>Could you please tell me how do I modify the environment variable (as
>below), from within R session?
>
>LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/mypath
>export LD_LIBRARY_PATH
>
>Thanks a lot!
>
>   [[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] path analysis and diagram (structural model)

2012-05-26 Thread Kristi Glover

Hi R- USER,
I have been struggling to compute path analysis in R. I installed package "sem" 
and I tried to run the analysis but could not get a diagram. 

I have very big data set, here I just copied a sample of my data and I wanted 
to see how I can do the path analysis and get the patch diagram (with r2 in 
each path). 

I have two tables;  1: num. of species - which is the depended variable and 2. 
env is the independent(predictors)  variable. 

I was trying to do multiple regression (num. of species vs env) and trying to 
see the path diagram (structural model). But I could not do it.

would you help me on how I can perform the analysis and show in diagram of the 
model?

dput(env)
structure(list(preci = c(45.145, 38.501, 32.631, 38.392, 44.807, 
45.774, 46.917, 44.384), wind = c(90L, 113L, 127L, 63L, 54L, 
43L, 31L, 38L), radiation = c(11.805, 18.31, 19.381, 13.154, 
9.752, 7.075, 5.558, 7.616), temp = c(12L, 15L, 21L, 20L, 14L, 
18L, 21L, 18L)), .Names = c("preci", "wind", "radiation", "temp"
), class = "data.frame", row.names = c(NA, -8L))

dput(num.of.species)
structure(list(S = c(4L, 7L, 9L, 10L, 10L, 8L, 8L, 1L)), .Names = "S", class = 
"data.frame", row.names = c(NA, 
-8L))

Sincerely,

Kristi

  
[[alternative HTML version deleted]]

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


[R] How do I modify sytem shell environment from within R?

2012-05-26 Thread Michael
Hi all,

Could you please tell me how do I modify the environment variable (as
below), from within R session?

LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/mypath
export LD_LIBRARY_PATH

Thanks a lot!

[[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] Assessing interaction effects in GLMMs

2012-05-26 Thread Ben Bolker
Luke Duncan  gmail.com> writes:

> 
> Dear R gurus
> 
> I am running a GLMM that looks at whether chimpanzees spend time in shade
> more than sun (response variable 'y': used cbind() on counts in the sun and
> shade) based on the time of day (Time) and the availability of shade
> (Tertile). I've included some random factors too which are the chimpanzee
> in question (Individual) and where they are in a given area (Zone). 

   How many zones are there? It could be a toss-up between treating
Zone as random vs fixed ...

> There
> are also two continuous predictors (Minimum daily temperature: Min; Maximum
> daily temperature: Max). I have run my GLMM and I know that Time and Min
> are significant predictors of the patterns of shade use while Tertile and
> Max are not. In addition, a Time*Tertile interaction effect is a good
> predictor as well.

  OK, be careful (this is a general point about interpreting models
in R, not specific to GLMMs); the main effects of Time and Tertile
are assessed **at the baseline level of the other** when the interaction
is present in the model.  You have to be very careful interpreting
the meaning of main effects in the presence of interactions.  The
Type III Wald test you use below probably only makes sense if you
have set sum-to-zero contrasts (options(contrasts="sum")).

> I now need to assess how the specific interaction effect conditions differ
> to one another. So, for example, how does shade use differ between 10h00 at
> low shade and 10h00 at high shade? I tried using the package multcomp, but
> that will only allow me to work out the contrasts for the first-order
> effects (Time, Tertile) but won't allow me to do so for the interaction
> effects. Any ideas?

  Are you trying to test a hypothesis, or just to ask about the values?
You can construct the values yourself, or (with the development version
of lme4) use the predict() method, to compute what the probabilities
will be in each of these situations.  By the way, the contrast you
have suggested above (10AM, low vs high shade) is not an interaction;
to test it, I would suggest that you relevel() your time variable
to 10 AM, then look at the estimated effect of Tertile for high vs low.
> 
> My code:
> 
> > m1 <- lmer(y ~ Time*Tertile + (1|Individual) + (1|Zone) + Max +
> Min,family=binomial,REML=F)

> > Anova(m1,type=3,test="Wald")
> Analysis of Deviance Table (Type III tests)
> 
> Response: y
>Chisq Df Pr(>Chisq)
> (Intercept)   0.9511  1 0.3294
> Time 60.7807  4  1.988e-12 ***
> Tertile   0.3391  1 0.5603
> Max   1.3198  1 0.2506
> Min  77.7736  1  < 2.2e-16 ***
> Time:Tertile 38.9038  4  7.292e-08 ***
> ---

> > summary(m1)
> Generalized linear mixed model fit by the Laplace approximation
> Formula: y ~ Time * Tertile + (1 | Individual) + (1 | Zone) + Max + Min
>   AIC  BIC logLik deviance
>  1168 1224 -569.9 1140
> Random effects:
>  Groups NameVariance Std.Dev.
>  Zone   (Intercept) 0.81949  0.90526
>  Individual (Intercept) 0.36417  0.60347
> Number of obs: 412, groups: Zone, 8; Individual, 7
> 

[snip]

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


Re: [R] Problem with readHTMLTable

2012-05-26 Thread R. Michael Weylandt
Odd... it doesn't throw an error for me.

Two things possibly come to mind, but I don't know enough of the XML
internals to know if they're reasonable. First is that something seems
funny about your version number -- mine is simply XML_3.9-4  (no added
"-1"); do you have any idea why yours would be different? Could you
reinstall the package with Prof Ripley's build (I believe the regular
install.packages() route should work after you uninstall with
remove.packages()) and see if that fixes it? It could also possibly be
an encoding/locale issue but that seems less likely.

Hope this gets you going in the right direction,

Michael

On Sat, May 26, 2012 at 10:17 AM, Sven D  wrote:
> Hello All,
>
> i was trying to simply run the readHTMLTable on the example published in the
> package. And on a page I was working on. So running:
>
> u = "http://en.wikipedia.org/wiki/List_of_countries_by_population";
> tables = readHTMLTable(u)
>
> returns the following error:
>
> Error in tb[["thead"]] : subscript out of bounds
>
>
> looking up this error on the web, didnt give me any hint. Is something wrong
> with this function?
>
>
> this is my sessioninfo:
>
>> sessionInfo()
> R version 2.14.1 (2011-12-22)
> Platform: i386-pc-mingw32/i386 (32-bit)
>
> locale:
> [1] LC_COLLATE=English_United Kingdom.1252  LC_CTYPE=English_United
> Kingdom.1252    LC_MONETARY=English_United Kingdom.1252
> [4] LC_NUMERIC=C                            LC_TIME=English_United
> Kingdom.1252
>
> attached base packages:
> [1] stats     graphics  grDevices utils     datasets  methods   base
>
> other attached packages:
>  [1] XML_3.9-4.1                  RCurl_1.91-1.1
> bitops_1.0-4.1               PerformanceAnalytics_1.0.3.2
>  [5] quantstrat_0.6.4             blotter_0.8.4
> FinancialInstrument_0.13.6   quantmod_0.3-17
>  [9] Defaults_1.1-1               TTR_0.21-0                   xts_0.8-2
> zoo_1.7-6
>
> loaded via a namespace (and not attached):
> [1] grid_2.14.1    IBrokers_0.9-3 lattice_0.20-0 tools_2.14.1
>
> Many thanks
>
>
>
> Sven
>
>
>
>
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/Problem-with-readHTMLTable-tp4631439.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 base package grid does not output raster image

2012-05-26 Thread Patrick Nicholson
Thanks Uwe, I had tried this before but hearing it again made me realize what I 
was doing incorrectly. I still can't get it to work with grid.draw(), but here 
is the solution with ggplot():


library(ggplot2)
library(grid)
library(maps)
library(mapproj)
library(png)
library(RgoogleMaps)

counties<- map_data("county", region="virginia")
states<- map_data("state")

tmp<- tempfile(fileext=".png")
bg<- GetMap.bbox(range(counties$long), range(counties$lat), destfile=tmp, 
maptype="satellite", format="png32")
background<- readPNG(tmp)
background<- rasterGrob(unclass(background))

p <- ggplot(counties, aes(long, lat)) +
   coord_map(xlim=c(bg$BBOX$ll[2], bg$BBOX$ur[2]), ylim=c(bg$BBOX$ll[1], 
bg$BBOX$ur[1])) +
   geom_path(aes(group=group), color="darkgrey") +
   geom_path(data=states, aes(group=group), color="white", size=1) +
   opts(axis.line=theme_blank(),
axis.text.x=theme_blank(),
axis.text.y=theme_blank(),
axis.ticks=theme_blank(),
axis.title.x=theme_blank(),
axis.title.y=theme_blank(),
axis.ticks.length=unit(0, "lines"),
axis.ticks.margin=unit(0, "lines"),
panel.border=theme_blank(),
panel.background=function(...)background,
panel.grid.major=theme_blank(),
panel.grid.minor=theme_blank(),
panel.margin=unit(0, "lines"),
legend.position="none",
legend.title=theme_blank(),
legend.background=theme_blank(),
plot.margin=unit(0*c(-1.5, -1.5, -1.5, -1.5), "lines"))

pdf("plot.pdf", height=7, width=7)
p
dev.off()

From: Uwe Ligges [lig...@statistik.tu-dortmund.de]
Sent: Saturday, May 26, 2012 11:43 AM
To: Patrick Nicholson
Cc: r-help@R-project.org
Subject: Re: [R] R base package grid does not output raster image

On 24.05.2012 23:04, Patrick Nicholson wrote:
> I am running 64-bit R 2.15.0 on a Windows Server 2008 R2 Amazon EC2 instance. 
> grid does not produce output. For example, the following code should print 
> the R logo to the window() device:
>
>
> library(grid)
> library(png)
>
> img.path<- system.file("img", "Rlogo.png", package="png")
> bg<- readPNG(img.path)
> background<- rasterGrob(unclass(bg))
>
> grid.draw(background)
>
>
> I, however, see nothing. Is there a flag or option I should be using on 
> Windows Server 2008 R2 to enable grid output?

This is a known issue with the Remote Desktop Connection. The raster
images are not shown via that setup. It works if you work locally at the
server or is you plot into another device (i.e. a pdf file or so).

Best,
Uwe Ligges


>
> For clarity, the following is how I am actually using images in R plots. This 
> code works on my laptop (R 2.15.0, ggplot2 0.8.9):
>
>
> library(ggplot2)
> library(grid)
> library(maps)
> library(mapproj)
> library(png)
> library(RgoogleMaps)
>
> counties<- map_data("county", region="virginia")
> states<- map_data("state")
>
> tmp<- tempfile(fileext=".png")
> bg<- GetMap.bbox(range(counties$long), range(counties$lat), destfile=tmp, 
> maptype="satellite", format="png32")
> background<- readPNG(tmp)
> background<- rasterGrob(unclass(background))
>
> ggplot(counties, aes(long, lat)) +
>coord_map(xlim=c(bg$BBOX$ll[2], bg$BBOX$ur[2]), ylim=c(bg$BBOX$ll[1], 
> bg$BBOX$ur[1])) +
>geom_path(aes(group=group), color="darkgrey") +
>geom_path(data=states, aes(group=group), color="white", size=1) +
>opts(axis.line=theme_blank(),
> axis.text.x=theme_blank(),
> axis.text.y=theme_blank(),
> axis.ticks=theme_blank(),
> axis.title.x=theme_blank(),
> axis.title.y=theme_blank(),
> axis.ticks.length=unit(0, "lines"),
> axis.ticks.margin=unit(0, "lines"),
> panel.border=theme_blank(),
> panel.background=function(...)background,
> panel.grid.major=theme_blank(),
> panel.grid.minor=theme_blank(),
> panel.margin=unit(0, "lines"),
> legend.position="none",
> legend.title=theme_blank(),
> legend.background=theme_blank(),
> plot.margin=unit(0*c(-1.5, -1.5, -1.5, -1.5), "lines"))
>
>
> Thank you,
> Patrick
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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 measure level of similarity of two data frames

2012-05-26 Thread Özgür Asar
Hi,

You can try 

rdist function under the package fields, or

dist package under stats package.

Best
Ozgur

-

Ozgur ASAR

Research Assistant
Middle East Technical University
Department of Statistics
06531, Ankara Turkey
Ph: 90-312-2105309
http://www.stat.metu.edu.tr/people/assistants/ozgur/
--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-measure-level-of-similarity-of-two-data-frames-tp4631466p4631470.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] avoid error within for loop, try, trycatch, while, move to next iteration, unlist

2012-05-26 Thread William Dunlap
You could encapsulate this idiom in a function:

untilOK <- function (expr, silent = TRUE, maxIter = 1000,
quotedExpr = substitute(expr),  envir = parent.frame()) 
{
while ((maxIter <- maxIter - 1) >= 0 && inherits(tmp <- 
try(eval(quotedExpr, 
envir = envir), silent = silent), "try-error")) {
}
if (maxIter < 0) {
stop("reached maxIter iterations, last error message is ", 
as.character(tmp))
}
tmp
}

E.g.,

  > f <- function(x){ stopifnot(x>0.9) ; x } # fails 90% of time
  > vapply(1:10, function(i)untilOK(f(runif(1))), FUN.VALUE=0.0)
   [1] 0.9460461 0.9670447 0.9306208 0.9122009 0.9495725 0.9619204 0.9031418 
0.9624259 0.9809273 0.9518705
  > untilOK(stopifnot(1==2)) # maxIter=1000 protects against inappropriate 
expressions.
  Error in untilOK(stopifnot(1 == 2)) : 
reached maxIter iterations, last error message is Error : 1 == 2 is not TRUE

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 William Dunlap
> Sent: Saturday, May 26, 2012 9:20 AM
> To: Λεωνίδας Μπαντής; r-help@r-project.org
> Subject: Re: [R] avoid error within for loop, try, trycatch, while, move to 
> next iteration,
> unlist
> 
> You could put the try() into a while loop, inside for for or lapply loop,
> as in:
> 
> > f <- function(x){ stopifnot(x>0.5) ; x }
> > o <- numeric(100); for(i in seq_along(o)) { while(inherits(try(tmp <- 
> > f(runif(1)),
> silent=TRUE), "try-error")) {} ; o[[i]] <- tmp }
> > range(o)
> [1] 0.5000588 0.9991261
> 
> 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 ?e???da? ?pa?t??
> > Sent: Saturday, May 26, 2012 6:15 AM
> > To: r-help@r-project.org
> > Subject: [R] avoid error within for loop, try, trycatch, while, move to 
> > next iteration,
> unlist
> >
> >
> >
> >
> > Hi there,
> >
> > I would like to ask something about how to avoid a possible error message 
> > within a for
> > loop. I am running a simulation and in some repetitions there may be an 
> > error that will
> > cause a crash and stop the whole procedure, what I want is to simply move 
> > on to the
> > next iteration automatically and discard the "bad" repetitions from my 
> > results. I used
> the
> > "try" function to do this and it partially works.
> >
> > Here is the thing:
> >
> > logitsboots <- function(x,y,Jbh) {
> > logitseb=0;logitspb=0;
> > for (j in 1:1) {
> >
> >
> > #some code here that has to do with random numbers that may or may not 
> > produce an
> > error and calculates the values of two scalar quantities: spboots  and 
> > seboots,
> >
> >
> >   logitspb=log(spboots/(1-spboots))
> >   logitseb=log(seboots/(1-seboots))
> >
> > #assume that I only care about logitseb for the moment
> > }
> > list(lse=logitseb)
> >
> > }
> >
> >
> >
> > # Now the following works just fine:
> >
> >
> > res=0
> > for(bb in 1:100) {
> > res[bb] <- try(logitsboots(x,y,Jbh), TRUE)
> >     }
> > az=unlist(res[sapply(res, function(x) !inherits(x, "try-error"))])
> >
> >
> >
> >
> > #So far, so good and everything is working fine with "az" having the values 
> > of lse having
> > also discarded the "bad" iterations.
> >
> >
> > However I would like to store (as an output) both values (logitse AND 
> > logitsp) in the
> > function logitsboots, that is the list would be as :
> >
> >
> > list(lse=logitseb,lsp=logitspb).
> >
> > This way the quantity "res" would have two arguments: res$lse and res$lsp 
> > each time it
> is
> > called. However when an error occures I just cannot seem to manage to 
> > "unlist" the
> "res"
> > properly since typing "res$lse" for example will warn me that the "$" 
> > operator will not
> > work (since it is not numeric anymore I guess). Something like the 
> > following would fail,
> > but I guess that clears what I want to do.
> >
> >
> > az1=unlist(res$lse[sapply(res$lse, function(x) !inherits(x, "try-error"))])
> >
> > az2=unlist(res$lsp[sapply(res$lsp, function(x) !inherits(x, "try-error"))])
> >
> > My final goal is to obtain 100 values of lse and 100 values of lsp. (Of 
> > course since the
> > iterations leading to an error would be discarded I will end up with less 
> > than 100
> > iterations. Any ideas of also using the "while" here in combination with 
> > the "try" to just
> > discard the bad iterations and replace them with new good ones would be 
> > great. This
> > way I would actually get exactly 100 values of lse and lsp).
> >
> > Most important is to manage to keep both values in a two column matrix or 
> > something.
> I
> > hope I was clear enough..
> >
> >
> >
> > Thanx in advance for any answers!
> >
> > Leo.
> > [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listin

Re: [R] How to assign height value on bar plot?

2012-05-26 Thread Uwe Ligges



On 26.05.2012 18:07, Manish Gupta wrote:

Hi,

How to assign height value on bar plot for each bar?


See ?barplot.

Uwe Ligges


http://r.789695.n4.nabble.com/file/n4631457/Barplot.png

--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-assign-height-value-on-bar-plot-tp4631457.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] avoid error within for loop, try, trycatch, while, move to next iteration, unlist

2012-05-26 Thread William Dunlap
You could put the try() into a while loop, inside for for or lapply loop,
as in:

> f <- function(x){ stopifnot(x>0.5) ; x }
> o <- numeric(100); for(i in seq_along(o)) { while(inherits(try(tmp <- 
> f(runif(1)), silent=TRUE), "try-error")) {} ; o[[i]] <- tmp }
> range(o)
[1] 0.5000588 0.9991261

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 ?e???da? ?pa?t??
> Sent: Saturday, May 26, 2012 6:15 AM
> To: r-help@r-project.org
> Subject: [R] avoid error within for loop, try, trycatch, while, move to next 
> iteration, unlist
> 
> 
> 
> 
> Hi there,
> 
> I would like to ask something about how to avoid a possible error message 
> within a for
> loop. I am running a simulation and in some repetitions there may be an error 
> that will
> cause a crash and stop the whole procedure, what I want is to simply move on 
> to the
> next iteration automatically and discard the "bad" repetitions from my 
> results. I used the
> "try" function to do this and it partially works.
> 
> Here is the thing:
> 
> logitsboots <- function(x,y,Jbh) {
> logitseb=0;logitspb=0;
> for (j in 1:1) {
> 
> 
> #some code here that has to do with random numbers that may or may not 
> produce an
> error and calculates the values of two scalar quantities: spboots  and 
> seboots,
> 
> 
>   logitspb=log(spboots/(1-spboots))
>   logitseb=log(seboots/(1-seboots))
> 
> #assume that I only care about logitseb for the moment
> }
> list(lse=logitseb)
> 
> }
> 
> 
> 
> # Now the following works just fine:
> 
> 
> res=0
> for(bb in 1:100) {
> res[bb] <- try(logitsboots(x,y,Jbh), TRUE)
>     }
> az=unlist(res[sapply(res, function(x) !inherits(x, "try-error"))])
> 
> 
> 
> 
> #So far, so good and everything is working fine with "az" having the values 
> of lse having
> also discarded the "bad" iterations.
> 
> 
> However I would like to store (as an output) both values (logitse AND 
> logitsp) in the
> function logitsboots, that is the list would be as :
> 
> 
> list(lse=logitseb,lsp=logitspb).
> 
> This way the quantity "res" would have two arguments: res$lse and res$lsp 
> each time it is
> called. However when an error occures I just cannot seem to manage to 
> "unlist" the "res"
> properly since typing "res$lse" for example will warn me that the "$" 
> operator will not
> work (since it is not numeric anymore I guess). Something like the following 
> would fail,
> but I guess that clears what I want to do.
> 
> 
> az1=unlist(res$lse[sapply(res$lse, function(x) !inherits(x, "try-error"))])
> 
> az2=unlist(res$lsp[sapply(res$lsp, function(x) !inherits(x, "try-error"))])
> 
> My final goal is to obtain 100 values of lse and 100 values of lsp. (Of 
> course since the
> iterations leading to an error would be discarded I will end up with less 
> than 100
> iterations. Any ideas of also using the "while" here in combination with the 
> "try" to just
> discard the bad iterations and replace them with new good ones would be 
> great. This
> way I would actually get exactly 100 values of lse and lsp).
> 
> Most important is to manage to keep both values in a two column matrix or 
> something. I
> hope I was clear enough..
> 
> 
> 
> Thanx in advance for any answers!
> 
> Leo.
>   [[alternative HTML version deleted]]

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


[R] How to assign height value on bar plot?

2012-05-26 Thread Manish Gupta
Hi,

How to assign height value on bar plot for each bar?

http://r.789695.n4.nabble.com/file/n4631457/Barplot.png 

--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-assign-height-value-on-bar-plot-tp4631457.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] Plotting interactions from lme with ggplot

2012-05-26 Thread dadrivr
I'm fitting a lme growth curve model with two predictors and their
interaction as predictors. The multilevel model is nested so that level 1 is
time within the individual, and level 2 is the individual.  I would like to
plot the mean group-level trajectories at plus and minus 1 SD from the mean
of the main effects composing the interaction term.  Thus, the plot should
have 4 lines (mean trajectories) representing all combinations of the two
predictors (where LO = -1sd from its mean, and HI = +1sd from its mean):
-LO predictor, LO moderator
-LO predictor, HI moderator
-HI predictor, LO moderator
-HI predictor, HI moderator

They are growth curves, so the plot should have 'time' on the x-axis and
'outcome' on the y-axis.  Here's a sample model:

library(nlme)

set.seed(123)

dataset <- NULL
dataset$id <- rep(1:100, each=10)
dataset$time <- rep(1:10,100)
dataset$outcome <- rnorm(1000, mean=100, sd=15)
dataset$predictor <- rnorm(1000, mean=10, sd=3)
dataset$moderator <- rnorm(1000, mean=5, sd=2)

dataset <- as.data.frame(dataset)
dataset[sample(1:1000, 400, replace=F),"outcome"] <- NA
dataset[sample(1:1000, 400, replace=F),"predictor"] <- NA
dataset[sample(1:1000, 400, replace=F),"moderator"] <- NA

model <- lme(outcome~ time + predictor + moderator + predictor*moderator,
random=~1 + time + predictor|id, data=dataset, na.action=na.omit)

How can I plot the interaction on the mean group-level trajectories using
ggplot?  Thanks in advance!

--
View this message in context: 
http://r.789695.n4.nabble.com/Plotting-interactions-from-lme-with-ggplot-tp4631454.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 check given number seq. is time series or not?

2012-05-26 Thread David Winsemius


On May 26, 2012, at 7:50 AM, R. Michael Weylandt wrote:


Thank you for your list of numbers. Next time I run out I'll know
where to find some.

Now what exactly is your question? Any series of data can be a time
series -- it's just a matter of interpretation.


After I stopped chuckling at Michael's response, I copied that list to  
my clipboard, clicked once on my Rconsole window, and typed:


vec <- scan()  # and hit return

I then pasted the clipboard contents to the console, watched as 100  
numeric values were passed on to 'vec' and hit enter to cause a double  
 to signal to scan() to stop entry. I then typed:


plot(vec)

And one can then see that most of the numbers lie between 0 and 1.5. I  
thought I saw a "hard ceiling" at around 1.5 and looking at the data I  
wondered if the several values of 1.442... were the same:


> vec[vec==1.4424189950435]
 [1] 1.442419 1.442419 1.442419 1.442419 1.442419 1.442419 1.442419  
1.442419 1.442419 1.442419

[11] 1.442419 1.442419 1.442419

There does seem to be a discrete process underlying this. There are  
only 32 discrete values, and here at the 10 most common:


> rev(table(vec)[order(table(vec))] )[1:10]
vec
  1.4424189950435  1.22726162946495  1.35785109728356  
0.970883941918588 0.774234247460432
   1311 7  
7 6
 1.10704609982913   0.9670580678417 0.889046409368551  
0.822170913920467  4.91679981837699
5 5 5  
5 3


Four values stand out as materially different. Three of them appear to  
have hit some sort of "secondary ceiling" at a value of 5 and another  
is sitting all alone at 2.3 (roughly).


Now as Michael asked  what WAS the question?

--
David.



Michael

On Sat, May 26, 2012 at 5:13 AM, sagarnikam123 > wrote:

i have following numbers

0.889046409368551
1.22726162946495
1.22726162946495
1.35785109728356
1.35785109728356
1.10704609982913
1.4424189950435
1.2277843378837
1.35785109728356
0.970883941918588
0.822170913920467
1.35785109728356
0.358815782262543
0.774234247460432
0.822170913920467
0.822170913920467
0.72599976881814
0.671583894425946
0.813223271443211
0.774234247460432
1.00184802593319
1.4424189950435
1.22726162946495
0.970883941918588
0.358815782262543
1.31016840948316
0.970883941918588
1.4424189950435
0.889046409368551
4.91679981837699
1.2277843378837
1.21605333196293
0.369861996166875
0.774748148811057
0.369861996166875
1.4424189950435
1.22726162946495
1.4424189950435
1.22726162946495
1.16291100715022
2.33863311242767
0.774234247460432
4.91679981837699
0.9670580678417
0.970883941918588
0.9670580678417
1.10704609982913
4.91679981837699
1.4424189950435
1.05410985855726
1.22726162946495
1.21605333196293
1.35785109728356
0.822170913920467
1.4424189950435
0.970883941918588
0.835429195630044
0.774234247460432
1.61328986496929
0.970883941918588
1.2277843378837
1.22726162946495
0.970883941918588
1.10704609982913
1.10704609982913
1.10704609982913
1.4424189950435
1.22726162946495
1.4424189950435
1.35785109728356
0.9670580678417
0.9670580678417
0.885419165744907
1.16291100715022
0.369861996166875
0.9670580678417
0.774748148811057
1.22726162946495
1.4424189950435
1.22726162946495
1.31016840948316
0.813223271443211
1.4424189950435
0.822170913920467
1.05410985855726
0.853014111520372
1.3245534157835
0.774234247460432
0.774234247460432
1.22726162946495
0.889046409368551
1.4424189950435
0.842622628771215
0.889046409368551
0.889046409368551
1.31898472833595
1.4424189950435
1.35785109728356
0.682617341489085
0.965180291004232

i don't want to check by plotting graph of above data(because i have
thousands of such data structures)
is there any function in R to check it ?
how can i check validity by programming?



--
View this message in context: 
http://r.789695.n4.nabble.com/how-to-check-given-number-seq-is-time-series-or-not-tp4631434.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 pro

[R] Problem with readHTMLTable

2012-05-26 Thread Sven D
Hello All,

i was trying to simply run the readHTMLTable on the example published in the
package. And on a page I was working on. So running:

u = "http://en.wikipedia.org/wiki/List_of_countries_by_population";
tables = readHTMLTable(u)

returns the following error:

Error in tb[["thead"]] : subscript out of bounds


looking up this error on the web, didnt give me any hint. Is something wrong
with this function?


this is my sessioninfo:

> sessionInfo()
R version 2.14.1 (2011-12-22)
Platform: i386-pc-mingw32/i386 (32-bit)

locale:
[1] LC_COLLATE=English_United Kingdom.1252  LC_CTYPE=English_United
Kingdom.1252LC_MONETARY=English_United Kingdom.1252
[4] LC_NUMERIC=CLC_TIME=English_United
Kingdom.1252

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

other attached packages:
 [1] XML_3.9-4.1  RCurl_1.91-1.1  
bitops_1.0-4.1   PerformanceAnalytics_1.0.3.2
 [5] quantstrat_0.6.4 blotter_0.8.4   
FinancialInstrument_0.13.6   quantmod_0.3-17 
 [9] Defaults_1.1-1   TTR_0.21-0   xts_0.8-2
   
zoo_1.7-6   

loaded via a namespace (and not attached):
[1] grid_2.14.1IBrokers_0.9-3 lattice_0.20-0 tools_2.14.1  

Many thanks 



Sven




--
View this message in context: 
http://r.789695.n4.nabble.com/Problem-with-readHTMLTable-tp4631439.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] avoid error within for loop, try, trycatch, while, move to next iteration, unlist

2012-05-26 Thread Λεωνίδας Μπαντής



Hi there,

I would like to ask something about how to avoid a possible error message 
within a for loop. I am running a simulation and in some repetitions there may 
be an error that will cause a crash and stop the whole procedure, what I want 
is to simply move on to the next iteration automatically and discard the "bad" 
repetitions from my results. I used the "try" function to do this and it 
partially works.

Here is the thing:

logitsboots <- function(x,y,Jbh) {
logitseb=0;logitspb=0;
for (j in 1:1) {


#some code here that has to do with random numbers that may or may not produce 
an error and calculates the values of two scalar quantities: spboots  and 
seboots,    


  logitspb=log(spboots/(1-spboots))
  logitseb=log(seboots/(1-seboots))
 
#assume that I only care about logitseb for the moment
}
list(lse=logitseb)

}



# Now the following works just fine:


res=0
for(bb in 1:100) {
res[bb] <- try(logitsboots(x,y,Jbh), TRUE)
    }
az=unlist(res[sapply(res, function(x) !inherits(x, "try-error"))])
    
    


#So far, so good and everything is working fine with "az" having the values of 
lse having also discarded the "bad" iterations.


However I would like to store (as an output) both values (logitse AND logitsp) 
in the function logitsboots, that is the list would be as : 


list(lse=logitseb,lsp=logitspb).

This way the quantity "res" would have two arguments: res$lse and res$lsp each 
time it is called. However when an error occures I just cannot seem to manage 
to "unlist" the "res" properly since typing "res$lse" for example will warn me 
that the "$" operator will not work (since it is not numeric anymore I guess). 
Something like the following would fail, but I guess that clears what I want to 
do.


az1=unlist(res$lse[sapply(res$lse, function(x) !inherits(x, "try-error"))])

az2=unlist(res$lsp[sapply(res$lsp, function(x) !inherits(x, "try-error"))])

My final goal is to obtain 100 values of lse and 100 values of lsp. (Of course 
since the iterations leading to an error would be discarded I will end up with 
less than 100 iterations. Any ideas of also using the "while" here in 
combination with the "try" to just discard the bad iterations and replace them 
with new good ones would be great. This way I would actually get exactly 100 
values of lse and lsp).

Most important is to manage to keep both values in a two column matrix or 
something. I hope I was clear enough..



Thanx in advance for any answers!

Leo.
[[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] Kolmogorov-Smirnov test and the plot of max distance between two ecdf curves

2012-05-26 Thread maxbre
Hi all, 

given this example 

#start 

a<-c(0,70,50,100,70,650,1300,6900,1780,4930,1120,700,190,940, 
   
760,100,300,36270,5610,249680,1760,4040,164890,17230,75140,1870,22380,5890,2430)
 
length(a)

b<-c(0,0,10,30,50,440,1000,140,70,90,60,60,20,90,180,30,90, 
 3220,490,20790,290,740,5350,940,3910,0,640,850,260) 
length(b)

out<-ks.test(log10(a+1),log10(b+1)) 

# max distance D 
out$statistic 

f.a<-ecdf(log10(a+1)) 
f.b<-ecdf(log10(b+1)) 

plot(f.a, verticals=TRUE, do.points=FALSE, col="red") 
plot(f.b, verticals=TRUE, do.points=FALSE, col="green", add=TRUE) 

#inverse of ecdf a
x.a<-get("x", environment(f.a))
y.a<-get("y", environment(f.a))

# inverse of ecdf b
x.b<-get("x", environment(f.b))
y.b<-get("y", environment(f.b))


#end

I want to plot the max distance between the two ecdf curves as in the above
given chart

Is that possible and how? 


Thanks for your help

PS: this is an amended version of a previous thread (but no reply followed)
that I’ve deleted from Nabble repository because I realised it was not
enough clear (now I hope it’s a little better, sorry for that)


--
View this message in context: 
http://r.789695.n4.nabble.com/Kolmogorov-Smirnov-test-and-the-plot-of-max-distance-between-two-ecdf-curves-tp4631437.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] Kolmogorov-Smirnov test and the plot of max distance between two ecdf curves

2012-05-26 Thread Rui Barradas
Hello,

Try the following.
(i've changed the color of the first ecdf.)


loga <- log10(a+1) # do this
logb <- log10(b+1) # only once

f.a <- ecdf(loga)
f.b <- ecdf(logb)
# (2) max distance D

x <- seq(min(loga, logb), max(loga, logb), length.out=length(loga))
x0 <- x[which( abs(f.a(x) - f.b(x)) == max(abs(f.a(x) - f.b(x))) )]
y0 <- f.a(x0)
y1 <- f.b(x0)

plot(f.a, verticals=TRUE, do.points=FALSE, col="blue")
plot(f.b, verticals=TRUE, do.points=FALSE, col="green", add=TRUE)
## alternatine, use standard R plot of ecdf
#plot(f.a, col="blue")
#lines(f.b, col="green")

points(c(x0, x0), c(y0, y1), pch=16, col="red")
segments(x0, y0, x0, y1, col="red", lty="dotted")
## alternative, down to x axis
#segments(x0, 0, x0, y1, col="red", lty="dotted")


Hope this helps,

Rui Barradas

maxbre wrote
> 
> Hi all, 
> 
> given this example 
> 
> #start 
> 
> a<-c(0,70,50,100,70,650,1300,6900,1780,4930,1120,700,190,940, 
>
> 760,100,300,36270,5610,249680,1760,4040,164890,17230,75140,1870,22380,5890,2430)
>  
> length(a)
> 
> b<-c(0,0,10,30,50,440,1000,140,70,90,60,60,20,90,180,30,90, 
>  3220,490,20790,290,740,5350,940,3910,0,640,850,260) 
> length(b)
> 
> out<-ks.test(log10(a+1),log10(b+1)) 
> 
> # max distance D 
> out$statistic 
> 
> f.a<-ecdf(log10(a+1)) 
> f.b<-ecdf(log10(b+1)) 
> 
> plot(f.a, verticals=TRUE, do.points=FALSE, col="red") 
> plot(f.b, verticals=TRUE, do.points=FALSE, col="green", add=TRUE) 
> 
> #inverse of ecdf a
> x.a<-get("x", environment(f.a))
> y.a<-get("y", environment(f.a))
> 
> # inverse of ecdf b
> x.b<-get("x", environment(f.b))
> y.b<-get("y", environment(f.b))
> 
> 
> #end
> 
> I want to plot the max distance between the two ecdf curves as in the
> above given chart
> 
> Is that possible and how? 
> 
> 
> Thanks for your help
> 
> PS: this is an amended version of a previous thread (but no reply
> followed) that I’ve deleted from Nabble repository because I realised it
> was not enough clear (now I hope it’s a little better, sorry for that)
> 


--
View this message in context: 
http://r.789695.n4.nabble.com/Kolmogorov-Smirnov-test-and-the-plot-of-max-distance-between-two-ecdf-curves-tp4631437p4631438.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 check given number seq. is time series or not?

2012-05-26 Thread Rui Barradas

Hello,

You can't.
A collection of observations does not make a time series, you need an 
index variable, such as time.


Rui Barradas

Em 26-05-2012 10:13, sagarnikam123 escreveu:

i have following numbers

 0.889046409368551
 1.22726162946495
 1.22726162946495
 1.35785109728356
 1.35785109728356
 1.10704609982913
 1.4424189950435
 1.2277843378837
 1.35785109728356
 0.970883941918588
 0.822170913920467
 1.35785109728356
 0.358815782262543
 0.774234247460432
 0.822170913920467
 0.822170913920467
 0.72599976881814
 0.671583894425946
 0.813223271443211
 0.774234247460432
 1.00184802593319
 1.4424189950435
 1.22726162946495
 0.970883941918588
 0.358815782262543
 1.31016840948316
 0.970883941918588
 1.4424189950435
 0.889046409368551
 4.91679981837699
 1.2277843378837
 1.21605333196293
 0.369861996166875
 0.774748148811057
 0.369861996166875
 1.4424189950435
 1.22726162946495
 1.4424189950435
 1.22726162946495
 1.16291100715022
 2.33863311242767
 0.774234247460432
 4.91679981837699
 0.9670580678417
 0.970883941918588
 0.9670580678417
 1.10704609982913
 4.91679981837699
 1.4424189950435
 1.05410985855726
 1.22726162946495
 1.21605333196293
 1.35785109728356
 0.822170913920467
 1.4424189950435
 0.970883941918588
 0.835429195630044
 0.774234247460432
 1.61328986496929
 0.970883941918588
 1.2277843378837
 1.22726162946495
 0.970883941918588
 1.10704609982913
 1.10704609982913
 1.10704609982913
 1.4424189950435
 1.22726162946495
 1.4424189950435
 1.35785109728356
 0.9670580678417
 0.9670580678417
 0.885419165744907
 1.16291100715022
 0.369861996166875
 0.9670580678417
 0.774748148811057
 1.22726162946495
 1.4424189950435
 1.22726162946495
 1.31016840948316
 0.813223271443211
 1.4424189950435
 0.822170913920467
 1.05410985855726
 0.853014111520372
 1.3245534157835
 0.774234247460432
 0.774234247460432
 1.22726162946495
 0.889046409368551
 1.4424189950435
 0.842622628771215
 0.889046409368551
 0.889046409368551
 1.31898472833595
 1.4424189950435
 1.35785109728356
 0.682617341489085
 0.965180291004232

i don't want to check by plotting graph of above data(because i have
thousands of such data structures)
is there any function in R to check it ?
how can i check validity by programming?



--
View this message in context: 
http://r.789695.n4.nabble.com/how-to-check-given-number-seq-is-time-series-or-not-tp4631434.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] change colors/ symbols of lda plots

2012-05-26 Thread Uwe Ligges


On 25.05.2012 21:50, dga...@huskers.unl.edu wrote:

Greetings R experts,

I am running a simple lda on some simulation data of mine to show an 
illustration of my multivariate response data, since it is a simulation I have 
a very large amount of data and the default on plot seems to plot the category 
names. This is very difficult to interpret even changing the abbreviations. At 
the expense of sounding naive, my question(s) are:

How can I color code my four categories?

and how can I change the unit display to something simple like a dot, and not 
the names or abbreviated names of the categories?


From what I read I believe there is code for doing this in the Modern Applied 
Statistics With S text but this is currently checked out of my local library. I 
hope this is simple and straightforward enough of a question I could provide 
example code if necessary.




Just read ?plot.lda.

Example:

 ldaobject <- lda(Species~., data=iris)
 plot(ldaobject, panel = function(x, y, ...) points(x, y, ...),
col = as.integer(iris$Species), pch = 20)

I think it is worth having a copy of MASS in your book shelf, not only 
in the local library


Best,
Uwe Ligges





Cheers,
-Dan

[[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 base package grid does not output raster image

2012-05-26 Thread Uwe Ligges

On 24.05.2012 23:04, Patrick Nicholson wrote:

I am running 64-bit R 2.15.0 on a Windows Server 2008 R2 Amazon EC2 instance. 
grid does not produce output. For example, the following code should print the 
R logo to the window() device:


library(grid)
library(png)

img.path<- system.file("img", "Rlogo.png", package="png")
bg<- readPNG(img.path)
background<- rasterGrob(unclass(bg))

grid.draw(background)


I, however, see nothing. Is there a flag or option I should be using on Windows 
Server 2008 R2 to enable grid output?


This is a known issue with the Remote Desktop Connection. The raster 
images are not shown via that setup. It works if you work locally at the 
server or is you plot into another device (i.e. a pdf file or so).


Best,
Uwe Ligges




For clarity, the following is how I am actually using images in R plots. This 
code works on my laptop (R 2.15.0, ggplot2 0.8.9):


library(ggplot2)
library(grid)
library(maps)
library(mapproj)
library(png)
library(RgoogleMaps)

counties<- map_data("county", region="virginia")
states<- map_data("state")

tmp<- tempfile(fileext=".png")
bg<- GetMap.bbox(range(counties$long), range(counties$lat), destfile=tmp, 
maptype="satellite", format="png32")
background<- readPNG(tmp)
background<- rasterGrob(unclass(background))

ggplot(counties, aes(long, lat)) +
   coord_map(xlim=c(bg$BBOX$ll[2], bg$BBOX$ur[2]), ylim=c(bg$BBOX$ll[1], 
bg$BBOX$ur[1])) +
   geom_path(aes(group=group), color="darkgrey") +
   geom_path(data=states, aes(group=group), color="white", size=1) +
   opts(axis.line=theme_blank(),
axis.text.x=theme_blank(),
axis.text.y=theme_blank(),
axis.ticks=theme_blank(),
axis.title.x=theme_blank(),
axis.title.y=theme_blank(),
axis.ticks.length=unit(0, "lines"),
axis.ticks.margin=unit(0, "lines"),
panel.border=theme_blank(),
panel.background=function(...)background,
panel.grid.major=theme_blank(),
panel.grid.minor=theme_blank(),
panel.margin=unit(0, "lines"),
legend.position="none",
legend.title=theme_blank(),
legend.background=theme_blank(),
plot.margin=unit(0*c(-1.5, -1.5, -1.5, -1.5), "lines"))


Thank you,
Patrick

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Selecting with mouse the lines drawn by matplot()

2012-05-26 Thread Uwe Ligges



On 25.05.2012 22:52, servet cizmeli wrote:

Dear all,

I have a dataset of spectral measurements of sunlight. One row for each
different observation, one column for each spectral channel.

I would like to select the spectral curves drawn with matplot() (I only
know matplot() as a way of easily drawing them) with the help of the
mouse and extract their row indexes :

a=url("http://ekumen.homelinux.net/spectra.RData";)
load(a)
matplot(lbd2, t(mySpectra), type="l",xlab="Wavelength
[nm]",ylab="Radiance")

I was hoping that identify() would work on such a graphic but
unfortunately it does not. I tried to the "identify" function of the
package playwith(), but still the same problem.

I think I will have to write a function that does the job. But before
that, I would like to have your opinions. What would be the easiest way
of accomplishing this task?



Write a little function that makes use of locator():

Take its x position and calculate (by interpolation) the y location of 
all paths at this x position, then take the minimal distance.

The idea in quick an dirty:


mat_identify <- function(x, y, ...){
l <- locator(1)
if(all(x <= l$x) || all(x >= l$x))
stop("not within data range")
index <- max(which(x <= l$x))
f <- (l$x - x[index]) / diff(x[index+(0:1)])
yi <- f * (y[index+1,] - y[index,] ) + y[index,]
result <- which.min(abs(yi-l$y))
lines(x, y[,result], lwd=2, col="red")
text(l, label=rownames(y)[result])
result
}

matplot(lbd2, t(mySpectra), type="l",xlab="Wavelength [nm]",ylab="Radiance")
mat_identify(lbd2, t(mySpectra))

Best,
Uwe Ligges





Thank you very much
Best regards
servet

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


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


Re: [R] Values in scatterplot??

2012-05-26 Thread Uwe Ligges



On 26.05.2012 08:17, Jhope wrote:

Hi R-listers,

I am having trouble plotting the values for the R2 line, lowess smooth,
smothered conditional spread, outlier identification.
I have tried the function text and legend but was unsuccessful. Please see
below.

Your help would be appreciated. Thanks in advance.

Jean



library(car)

SPHSHTL<- scatterplot(HSuccess ~ HTL,

+data = data.to.analyze,
+xlab = "Distance to high tide line (metres)",
+ylab = "Hatching success (%)")


legend("topright", bty="n", legend=paste("R2 is",

+
format(summary(SPHSHTL)$adj.r.squared, digits=4)))


scatterplot() does not return anything useful, and in particular it does 
not include any element called "adj.r.squared".

I think you want to fit a model using lm() or so and proceed from there?

Uwe Ligges







Error in summary(SPHSHTL)$adj.r.squared :
   $ operator is invalid for atomic vectors


text(SPHSHTL)

Error in text.default(SPHSHTL) : zero length 'labels'

--
View this message in context: 
http://r.789695.n4.nabble.com/Values-in-scatterplot-tp4631431.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] "shift" + "arrow" in getGraphicsEvent

2012-05-26 Thread Uwe Ligges



On 26.05.2012 00:33, cgenolin wrote:

Hi the list,

Do you know if getGraphicsEvent can detect the use of keys combinaison like
"shift+arrow" or "Crlt+arrow" ?


Some key combinations, but not those mentioned above.

Just write a simple test:

getGraphicsEvent(onKeybd = function(key) cat(key, "\n"))


Uwe Ligges




Best
Christophe

--
View this message in context: 
http://r.789695.n4.nabble.com/shift-arrow-in-getGraphicsEvent-tp4631419.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] How to draw y axis in horizontal bar plot?

2012-05-26 Thread R. Michael Weylandt
I'm not sure there's a direct way to do it, but you could most likely use

abline(v = 0)

to add one to a plot. E.g.,

barplot(sample(-5:5), horiz = TRUE); abline(v = 0, lwd = 3, col = 2)

Michael

On Fri, May 25, 2012 at 10:55 PM, Manish Gupta
 wrote:
> continued to previous mail ...
>
> http://r.789695.n4.nabble.com/file/n4631429/Image1.png
> After plotting y axis it will look like
>
>
>
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/How-to-draw-y-axis-in-horizontal-bar-plot-tp4631428p4631429.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] how to check given number seq. is time series or not?

2012-05-26 Thread R. Michael Weylandt
Thank you for your list of numbers. Next time I run out I'll know
where to find some.

Now what exactly is your question? Any series of data can be a time
series -- it's just a matter of interpretation.

Michael

On Sat, May 26, 2012 at 5:13 AM, sagarnikam123  wrote:
> i have following numbers
>
>         0.889046409368551
>         1.22726162946495
>         1.22726162946495
>         1.35785109728356
>         1.35785109728356
>         1.10704609982913
>         1.4424189950435
>         1.2277843378837
>         1.35785109728356
>         0.970883941918588
>         0.822170913920467
>         1.35785109728356
>         0.358815782262543
>         0.774234247460432
>         0.822170913920467
>         0.822170913920467
>         0.72599976881814
>         0.671583894425946
>         0.813223271443211
>         0.774234247460432
>         1.00184802593319
>         1.4424189950435
>         1.22726162946495
>         0.970883941918588
>         0.358815782262543
>         1.31016840948316
>         0.970883941918588
>         1.4424189950435
>         0.889046409368551
>         4.91679981837699
>         1.2277843378837
>         1.21605333196293
>         0.369861996166875
>         0.774748148811057
>         0.369861996166875
>         1.4424189950435
>         1.22726162946495
>         1.4424189950435
>         1.22726162946495
>         1.16291100715022
>         2.33863311242767
>         0.774234247460432
>         4.91679981837699
>         0.9670580678417
>         0.970883941918588
>         0.9670580678417
>         1.10704609982913
>         4.91679981837699
>         1.4424189950435
>         1.05410985855726
>         1.22726162946495
>         1.21605333196293
>         1.35785109728356
>         0.822170913920467
>         1.4424189950435
>         0.970883941918588
>         0.835429195630044
>         0.774234247460432
>         1.61328986496929
>         0.970883941918588
>         1.2277843378837
>         1.22726162946495
>         0.970883941918588
>         1.10704609982913
>         1.10704609982913
>         1.10704609982913
>         1.4424189950435
>         1.22726162946495
>         1.4424189950435
>         1.35785109728356
>         0.9670580678417
>         0.9670580678417
>         0.885419165744907
>         1.16291100715022
>         0.369861996166875
>         0.9670580678417
>         0.774748148811057
>         1.22726162946495
>         1.4424189950435
>         1.22726162946495
>         1.31016840948316
>         0.813223271443211
>         1.4424189950435
>         0.822170913920467
>         1.05410985855726
>         0.853014111520372
>         1.3245534157835
>         0.774234247460432
>         0.774234247460432
>         1.22726162946495
>         0.889046409368551
>         1.4424189950435
>         0.842622628771215
>         0.889046409368551
>         0.889046409368551
>         1.31898472833595
>         1.4424189950435
>         1.35785109728356
>         0.682617341489085
>         0.965180291004232
>
> i don't want to check by plotting graph of above data(because i have
> thousands of such data structures)
> is there any function in R to check it ?
> how can i check validity by programming?
>
>
>
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/how-to-check-given-number-seq-is-time-series-or-not-tp4631434.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] How to transform OLS covariance matrix to White standard errors?

2012-05-26 Thread David Winsemius


On May 26, 2012, at 3:09 AM, Dunken wrote:


Hi!

I am working with a regression of a log-log model that suffers from
heteroskedasticity. I have calculated the "White standard errors". I  
would
like to use these "White standard errors" in a RESET test instead of  
the

originally OLS standard errors calculated by the regression. How can I
transform the covariance matrix of a model?


labmodel2 <- lm(formula = log(L) ~ log(W) + log(K) + log(Y),  
data=labordat)

sumlabmodel2 <- summary(labmodel2)
sumlabmodel2

coeftest(labmodel2,vcov=vcovHC(labmodel2,type="HC0"

That is, I want to replace vcov with vcovHC in labmodel2 to perform  
a RESET

test with the robust White standard errors.


Have your read? :

"Econometric Computing with HC and HAC Covariance Matrix Estimators",
Achim Zeileis
http://www.jstatsoft.org/v11/i10/




Can anyone help?

Thank you!



--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-transform-OLS-covariance-matrix-to-White-standard-errors-tp4631432.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] quotes in Rscript -e through system

2012-05-26 Thread Uwe Ligges



On 24.05.2012 12:58, abhagwat wrote:

I figured out how to use quotes and parentheses when using Rscript -e (on a
bash shell):
Rscript -e write\(1,\"a.txt\"\)

-->  Question 1: why do the parentheses need to be escaped in the shell?
(More a shell than an R question)


Because the shell shopudl not interpret quotes and parantheses but pass 
all the string to R.





Then I figured out how to use quotes and parentheses when calling Rscript
through system:
system('Rscript -e write\\(1,\\\'a.txt\\\'\\)')

-->  Question 2: why exactly is it necessary to use double and triple
escapes? I kinda understand it, but not completely.


double: \ is a special character in R that escapes the second \

triple: actually a double \ for the reason geiven above, and then \' for 
protecting the ' to be evaluated (i.e. indicating the end of the former 
' before the Rscript).


Uwe Ligges







Thanks for your insights!

Adi





--
View this message in context: 
http://r.789695.n4.nabble.com/quotes-in-Rscript-e-through-system-tp4631186.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] Rolling Sample VAR

2012-05-26 Thread Uwe Ligges



On 26.05.2012 07:34, bantex wrote:

But after looking through rollapply I still don't seem to be able to
implement it to my problem.

Could you make it more explicit for me to understand?



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


Otherwise, it is unlikely you get more help. And don't forget to quote 
the original question and the rest of the thread. I do not keep old 
R-help mails around.


Uwe Ligges





B

--
View this message in context: 
http://r.789695.n4.nabble.com/Rolling-Sample-VAR-tp4631328p4631430.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] how a latent state matrix is updated using package R2WinBUGS

2012-05-26 Thread Uwe Ligges

On 23.05.2012 17:20, Jean V Adams wrote:

I'm trying to understand how a latent state matrix is updated by the MCMC
iterations in a WinBUGS model, using the package R2WinBUGS and an example
from Kery and Schaub's (2012) book, "Bayesian Population Analysis Using
WinBUGS".  The example I'm using is 7.3.1. from a chapter on the
Cormack-Jolly-Seber model.  Some excerpted code is included at the end of
this message; the full code is available at

http://www.vogelwarte.ch/downloads/files/publications/BPA/bpa-code.txt

The latent state of individual i on occasion t is stored in the z matrix
where rows index individuals (owls that are marked and released) and
columns index capture occasions.  Each value in the matrix represents the
latent state for individual i at occasion t: z[i,t]=0 if individual i is
dead at time t, and =1 if individual i is alive at time t.

In the example, a matrix of known values for z is created from the capture
histories and provided as data; I will call it known.z.  And a matrix of
initial values (where z is unknown) is also created and provided; I will
call it init.z.  The dimensions of these two matrices are 250 individuals
by 6 capture occasions.  However, if I save z as a parameter of interest,
the dimensions of the last saved z matrix from the last chain,
last.z<- cjs.c.c$last.values[[cjs.c.c$n.chains]]$z,
are 217 by 5.  Why are the dimensions different?  What happened to the
other 33 rows (individuals) and 1 column (occasion)?  I thought perhaps
that the missing rows corresponded to those rows where all the latent
states are known, but that does not appear to be the case.  There were no
individuals with 6 known latent states, and only 4 (not 33) with 5:
table(apply(!is.na(known.z), 1, sum))
   0   1   2   3   4   5
162  39  27  14   4   4

Also, how can I verify that the known values of z are maintained in the
iterated z matrices?  Even with the loss of 33 rows, those individuals
with 5 known 1=alive latent states don't seem to line up.
seq(known.z[,1])[apply(known.z[,-1], 1, paste, collapse="")=="1"]
[1]  2  6 17 46
seq(last.z[,1])[apply(last.z, 1, paste, collapse="")=="1"]
[1]   1  26 110 112 115 116

I would appreciate any insight you might have to offer.  I am experienced
with R, but relatively inexperienced with WinBUGS and the R2WinBUGS
package.  I am using R 2.15.0, R2WinBUGS 2.1-18, and WinBUGS 1.4.3 on
Windows 7.


R2WinBUGS is just an interface package for R that exports data, calls 
WinBUGS and imports the results.
For BUGS related questions, i.e. in particular the correct specification 
of the model (file), I'd recommend to ask on the BUGS related mailing lists.


Note that the new version of WinBUGS is called OpenBUGS and the is a 
more "direct" R interface called BRugs.


Best,
Uwe Ligges



Thanks.

Jean




init.z[1:10, ]

   [,1] [,2] [,3] [,4] [,5] [,6]
  [1,]   NA00000
  [2,]   NA   NA   NA   NA   NA   NA
  [3,]   NA   NA0000
  [4,]   NA00000
  [5,]   NA00000
  [6,]   NA   NA   NA   NA   NA   NA
  [7,]   NA00000
  [8,]   NA   NA0000
  [9,]   NA   NA   NA000
[10,]   NA   NA   NA000


known.z[1:10, ]

   [,1] [,2] [,3] [,4] [,5] [,6]
  [1,]   NA   NA   NA   NA   NA   NA
  [2,]   NA11111
  [3,]   NA1   NA   NA   NA   NA
  [4,]   NA   NA   NA   NA   NA   NA
  [5,]   NA   NA   NA   NA   NA   NA
  [6,]   NA11111
  [7,]   NA   NA   NA   NA   NA   NA
  [8,]   NA1   NA   NA   NA   NA
  [9,]   NA11   NA   NA   NA
[10,]   NA11   NA   NA   NA


last.z[1:10, ]

   [,1] [,2] [,3] [,4] [,5]
  [1,]11111
  [2,]00001
  [3,]00001
  [4,]00000
  [5,]00001
  [6,]11100
  [7,]00000
  [8,]00001
  [9,]00000
[10,]00000

model {
# Priors and constraints
for (i in 1:nind){
 for (t in f[i]:(n.occasions-1)){
 phi[i,t]<- mean.phi
 p[i,t]<- mean.p
 } #t
 } #i

mean.phi ~ dunif(0, 1)  # Prior for mean survival
mean.p ~ dunif(0, 1)# Prior for mean recapture
# Likelihood
for (i in 1:nind){
 # Define latent state at first capture
 z[i,f[i]]<- 1
 for (t in (f[i]+1):n.occasions){
 # State process
 z[i,t] ~ dbern(mu1[i,t])
 mu1[i,t]<- phi[i,t-1] * z[i,t-1]
 # Observation process
 y[i,t] ~ dbern(mu2[i,t])
 mu2[i,t]<- p[i,t-1] * z[i,t]
 } #t
 } #i
}

# Call WinBUGS from R
cjs.c.c<- bugs(
data = list(z = known.z,),
inits = list(z = init.z,),
parameters.to.save = c("z",),

)

[[alternative HTML version deleted]]

__
R-help@r-project.or

Re: [R] Multiple cbind according to filename

2012-05-26 Thread Uwe Ligges

On 25.05.2012 16:42, Ken wrote:

Matthew Ouellette  gmail.com>  writes:



Hi all,

I'm just a beginner with R but I have not been able to search for any
relevant answer to my problem.  I apologize if it has in fact been asked
before.

Recently I've realized that I need to combine hundreds of pairs of data
frames.  The filenames of the frames I need to combine have unique strings.
  This is my best guess as to the approach to take:

  filenames<-list.files()

filenames
[1] "a1.csv" "a2.csv" "b1.csv" "b2.csv" "c1.csv" "c2.csv"

alldata<-lapply(filenames, read.csv, header=TRUE)

  names(alldata)<-filenames
  summary(alldata)
Length Class  Mode
a1.csv 27 data.frame list
a2.csv 27 data.frame list
b1.csv 27 data.frame list
b2.csv 27 data.frame list
c1.csv 27 data.frame list
c2.csv 27 data.frame list

My next step would be to cbind files that share a common string at the
beginning, such as:
cbind(alldata[[1]],alldata[[2]])
cbind(alldata[[3]],alldata[[4]])
cbind(alldata[[5]],alldata[[6]])
...




I think the actual question is how to cbind() all data.frames. The 
answer for that is:


result <- do.call(cbind, alldata)

Best,
Uwe Ligges




but file list is hundreds of files long (but is sorted alphanumerically
such as in this example - not sure if this is relevant).  If I had to
guess, I'd do something like this:

which(names(alldata)==...), to identify which elements to combine based on
unique filename

OR
x<-seq(1,length(alldata), 2)
y=x+1
z<-cbind(x,y)
z
  x y
[1,] 1 2
[2,] 3 4
[3,] 5 6

to use the frame created in z to combine based on rows,

then use a looped cbind function (or *apply function with nested cbind
function?) using the previously returned indexes to create my new combined
data frames, including a step to write the frames to a new unique filename
(not sure how to do that step in this context).  These last steps I've
tried a lot of code but nothing worth mentioning as it has all failed
miserably.

I appreciate the help,

M

[[alternative HTML version deleted]]




Hi Matthew,

You could try using substr() if the cbind is based on a common string in the
file name just makes sure that the strings in filenames is in the same order as
the files are in list.files:

a1<- data.frame("col1" = seq(1,10, 1))
a2<- data.frame("col2" = seq(11,20, 1))
b1<- data.frame("col3" = seq(21,30, 1))
b2<- data.frame("col4" = seq(31,40, 1))

filenames<- c("a1", "a2", "b1", "b2")

list.files<- list(a1, a2, b1, b2)
first.letter<- substr(filenames, 1,1)
unique.first.letter<- unique(first.letter)

l.files<- list()
for(i in 1:length(unique.first.letter)){
   l.files[[i]] = as.data.frame(list.files[first.letter == 
unique.first.letter[i]])
}


HTH,
Ken

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] File format for single channel analysis of Agilent microarray data in Limma?

2012-05-26 Thread Uwe Ligges

Please ask BioC related questions on the BioC mailing list.

Best,
Uwe Ligges

On 23.05.2012 11:44, Parisa wrote:

Hi,

I am following the protocol outlined here for analysis of single channel
Agilent microarray data:

http://matticklab.com/index.php?title=Single_channel_analysis_of_Agilent_microarray_data_with_Limma

I keep getting the following error message when using Limma's read.maimages
function to load my data into an RGList object:

Error in RG[[a]][, i]<- obj[, columns[[a]]] :
   number of items to replace is not a multiple of replacement length

I think this may be due to my Agilent raw data txt files being in the wrong
format. I am having difficulty finding an example Agilent feature extraction
raw data txt file online to compare it to. I have attached a screen shot of
one of the files I am using below (as the file itself is too large to
upload). I would appreciate if someone could let me know if it is in the
correct format, and if not then what format it should be in to prevent the
above error message from coming up.

Thank you,

Parisa

http://r.789695.n4.nabble.com/file/n4631061/Screen_shot_2012-05-23_at_10.41.56.png
Screen_shot_2012-05-23_at_10.41.56.png

--
View this message in context: 
http://r.789695.n4.nabble.com/File-format-for-single-channel-analysis-of-Agilent-microarray-data-in-Limma-tp4631061.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] how to check given number seq. is time series or not?

2012-05-26 Thread sagarnikam123
i have following numbers 

 0.889046409368551 
 1.22726162946495 
 1.22726162946495 
 1.35785109728356 
 1.35785109728356 
 1.10704609982913 
 1.4424189950435 
 1.2277843378837 
 1.35785109728356 
 0.970883941918588 
 0.822170913920467 
 1.35785109728356 
 0.358815782262543 
 0.774234247460432 
 0.822170913920467 
 0.822170913920467 
 0.72599976881814 
 0.671583894425946 
 0.813223271443211 
 0.774234247460432 
 1.00184802593319 
 1.4424189950435 
 1.22726162946495 
 0.970883941918588 
 0.358815782262543 
 1.31016840948316 
 0.970883941918588 
 1.4424189950435 
 0.889046409368551 
 4.91679981837699 
 1.2277843378837 
 1.21605333196293 
 0.369861996166875 
 0.774748148811057 
 0.369861996166875 
 1.4424189950435 
 1.22726162946495 
 1.4424189950435 
 1.22726162946495 
 1.16291100715022 
 2.33863311242767 
 0.774234247460432 
 4.91679981837699 
 0.9670580678417 
 0.970883941918588 
 0.9670580678417 
 1.10704609982913 
 4.91679981837699 
 1.4424189950435 
 1.05410985855726 
 1.22726162946495 
 1.21605333196293 
 1.35785109728356 
 0.822170913920467 
 1.4424189950435 
 0.970883941918588 
 0.835429195630044 
 0.774234247460432 
 1.61328986496929 
 0.970883941918588 
 1.2277843378837 
 1.22726162946495 
 0.970883941918588 
 1.10704609982913 
 1.10704609982913 
 1.10704609982913 
 1.4424189950435 
 1.22726162946495 
 1.4424189950435 
 1.35785109728356 
 0.9670580678417 
 0.9670580678417 
 0.885419165744907 
 1.16291100715022 
 0.369861996166875 
 0.9670580678417 
 0.774748148811057 
 1.22726162946495 
 1.4424189950435 
 1.22726162946495 
 1.31016840948316 
 0.813223271443211 
 1.4424189950435 
 0.822170913920467 
 1.05410985855726 
 0.853014111520372 
 1.3245534157835 
 0.774234247460432 
 0.774234247460432 
 1.22726162946495 
 0.889046409368551 
 1.4424189950435 
 0.842622628771215 
 0.889046409368551 
 0.889046409368551 
 1.31898472833595 
 1.4424189950435 
 1.35785109728356 
 0.682617341489085 
 0.965180291004232 

i don't want to check by plotting graph of above data(because i have
thousands of such data structures)
is there any function in R to check it ?
how can i check validity by programming?



--
View this message in context: 
http://r.789695.n4.nabble.com/how-to-check-given-number-seq-is-time-series-or-not-tp4631434.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] Java problem - XLConnect/xlsx package

2012-05-26 Thread rhaidinger
Hello Martin,

thank you for your reply.

Yes, it is maybe an architecture clash, we run win 7 64 bit and java 32 bit.
But R is 32-bit and the path variable is set to the 32-bit java folder. So
maybe the problem don't lies there.

Best regards
Rainer

--
View this message in context: 
http://r.789695.n4.nabble.com/Java-problem-XLConnect-xlsx-package-tp4631304p4631433.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 transform OLS covariance matrix to White standard errors?

2012-05-26 Thread Dunken
Hi!

I am working with a regression of a log-log model that suffers from
heteroskedasticity. I have calculated the "White standard errors". I would
like to use these "White standard errors" in a RESET test instead of the
originally OLS standard errors calculated by the regression. How can I
transform the covariance matrix of a model?


labmodel2 <- lm(formula = log(L) ~ log(W) + log(K) + log(Y), data=labordat)
sumlabmodel2 <- summary(labmodel2)
sumlabmodel2

coeftest(labmodel2,vcov=vcovHC(labmodel2,type="HC0"

That is, I want to replace vcov with vcovHC in labmodel2 to perform a RESET
test with the robust White standard errors.

Can anyone help?

Thank you!



--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-transform-OLS-covariance-matrix-to-White-standard-errors-tp4631432.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] Values in scatterplot??

2012-05-26 Thread Jhope
Hi R-listers, 

I am having trouble plotting the values for the R2 line, lowess smooth,
smothered conditional spread, outlier identification. 
I have tried the function text and legend but was unsuccessful. Please see
below.

Your help would be appreciated. Thanks in advance.

Jean



library(car)
> SPHSHTL <- scatterplot(HSuccess ~ HTL,
+data = data.to.analyze,
+xlab = "Distance to high tide line (metres)",
+ylab = "Hatching success (%)")

> legend("topright", bty="n", legend=paste("R2 is",
+ 
format(summary(SPHSHTL)$adj.r.squared, digits=4)))
Error in summary(SPHSHTL)$adj.r.squared : 
  $ operator is invalid for atomic vectors

>text(SPHSHTL)
Error in text.default(SPHSHTL) : zero length 'labels'

--
View this message in context: 
http://r.789695.n4.nabble.com/Values-in-scatterplot-tp4631431.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] Assessing interaction effects in GLMMs

2012-05-26 Thread Luke Duncan
Dear R gurus

I am running a GLMM that looks at whether chimpanzees spend time in shade
more than sun (response variable 'y': used cbind() on counts in the sun and
shade) based on the time of day (Time) and the availability of shade
(Tertile). I've included some random factors too which are the chimpanzee
in question (Individual) and where they are in a given area (Zone). There
are also two continuous predictors (Minimum daily temperature: Min; Maximum
daily temperature: Max). I have run my GLMM and I know that Time and Min
are significant predictors of the patterns of shade use while Tertile and
Max are not. In addition, a Time*Tertile interaction effect is a good
predictor as well.

I now need to assess how the specific interaction effect conditions differ
to one another. So, for example, how does shade use differ between 10h00 at
low shade and 10h00 at high shade? I tried using the package multcomp, but
that will only allow me to work out the contrasts for the first-order
effects (Time, Tertile) but won't allow me to do so for the interaction
effects. Any ideas?

My code:

> m1 <- lmer(y ~ Time*Tertile + (1|Individual) + (1|Zone) + Max +
Min,family=binomial,REML=F)
> Anova(m1,type=3,test="Wald")
Analysis of Deviance Table (Type III tests)

Response: y
   Chisq Df Pr(>Chisq)
(Intercept)   0.9511  1 0.3294
Time 60.7807  4  1.988e-12 ***
Tertile   0.3391  1 0.5603
Max   1.3198  1 0.2506
Min  77.7736  1  < 2.2e-16 ***
Time:Tertile 38.9038  4  7.292e-08 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
> summary(m1)
Generalized linear mixed model fit by the Laplace approximation
Formula: y ~ Time * Tertile + (1 | Individual) + (1 | Zone) + Max + Min
  AIC  BIC logLik deviance
 1168 1224 -569.9 1140
Random effects:
 Groups NameVariance Std.Dev.
 Zone   (Intercept) 0.81949  0.90526
 Individual (Intercept) 0.36417  0.60347
Number of obs: 412, groups: Zone, 8; Individual, 7

Fixed effects:
 Estimate Std. Error z value Pr(>|z|)
(Intercept)   0.774980.79465   0.975 0.329439
Time11h00-1.542590.24351  -6.335 2.38e-10 ***
Time12h00 0.016950.77829   0.022 0.982627
Time13h00-4.269130.78217  -5.458 4.81e-08 ***
Time14h00-1.345030.43831  -3.069 0.002150 **
TertileLow0.326140.56003   0.582 0.560323
Max   0.037510.03265   1.149 0.250630
Min  -0.309120.03505  -8.819  < 2e-16 ***
Time11h00:TertileLow  1.030790.28579   3.607 0.000310 ***
Time12h00:TertileLow -2.261870.79930  -2.830 0.004658 **
Time13h00:TertileLow  2.381290.79214   3.006 0.002646 **
Time14h00:TertileLow  1.722630.49397   3.487 0.000488 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Correlation of Fixed Effects:
(Intr) Tm1100 Tm1200 Tm1300 Tm1400 TrtlLw MaxMinT1100:
Time11h00   -0.026
Time12h00   -0.035  0.177
Time13h00   -0.004  0.223  0.068
Time14h00   -0.073  0.259  0.081  0.103
TertileLow  -0.450  0.153  0.043  0.051  0.097
Max -0.711 -0.169 -0.004 -0.061 -0.023  0.019
Min  0.146  0.186  0.014  0.055  0.099 -0.036 -0.455
Tm11h00:TrL  0.059 -0.851 -0.153 -0.190 -0.222 -0.198  0.096 -0.155
Tm12h00:TrL  0.095 -0.160 -0.974 -0.062 -0.081 -0.067 -0.079  0.012  0.192
Tm13h00:TrL  0.026 -0.208 -0.067 -0.983 -0.099 -0.075  0.024 -0.026  0.229
Tm14h00:TrL  0.126 -0.215 -0.069 -0.088 -0.876 -0.185 -0.047  0.006  0.254
T1200: T1300:
Time11h00
Time12h00
Time13h00
Time14h00
TertileLow
Max
Min
Tm11h00:TrL
Tm12h00:TrL
Tm13h00:TrL  0.081
Tm14h00:TrL  0.098  0.116

Luke Duncan

*Post-doctoral** Fellow*
*School of Animal, Plant and Environmental Sciences*
*University of the Witwatersrand*
*Johannesburg, South Africa*
**
*+27 72 312 0330*
*+27 11 717 6452*

[[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 change width of bar when there are very few bars?

2012-05-26 Thread Jim Lemon

On 05/26/2012 12:26 PM, Manish Gupta wrote:

If i assign a vector with same small width for each bar (here) still both are
same broad. I think it takes ratio for whole area.  Is there any other
parameter to control it.? Any working example will help me.



Hi Manish,
If you are using the "barplot" function, you probably want to specify 
both "width" and "space". If you just want to specify a single number, 
look at the "barp" function in the plotrix package, where "width" is the 
parameter that controls the width of the bar as a proportion of the 
distance between bar centers. Note that you won't get different bar 
widths with barp.


Jim

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