Re: [R] simple main effect.

2009-12-20 Thread Tal Galili
Try going through this:
http://www.personality-project.org/r/r.anova.html

http://www.personality-project.org/r/r.anova.html


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




On Sat, Dec 19, 2009 at 7:27 PM, Or Duek ord...@gmail.com wrote:

 Hi, I'm a bit new to R and I would like to know how can I compare simple
 main effects when using the aov function.
 I'm doing a mixed model ANOVA with two between subjects variables and one
 within.
 When I get an interaction of two of the variables I don't know how to check
 for simple main effect of that interaction (A at B1 and A at B2 for
 example).
 The aov function is very simple but for some reason I can't find how to do
 this.
 Thank you very much.
 Or Duek.

[[alternative HTML version deleted]]

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


[[alternative HTML version deleted]]

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


Re: [R] read.table: mysterious line omissions

2009-12-20 Thread Peter Dalgaard

Jonathan wrote:

Tried deleting several line above and below line 362; did that and changed
the extension.  Still finds the same number of rows (362).

Strange!
Jonathan


The reason is quite apparent if you try page(temp)


Ovine lentivirus, Peanut chlorotic streak virus, Pelargonium vein 
banding virus,

Petunia vein clearing virus, Porcine endogenous retrovirus,
RD114 retrovirus, Reticuloendotheliosis virus, Rice tungro 
bacilliform virus,
Rosss goose hepatitis B virus\tNC_005888\nSnow goose hepatitis B 
virus\tNC_005950\nRous sarcoma virus\tNC_001407\nRudbeckia flower 
distortion virus\tNC_011920\nSheldgoose hepatitis B 
virus\tNC_005890\nSimian T-cell lymphotropic virus 6\tNC_011546\nSimian 
T-lymphotropic .



The single quote in Ross's is doing you in. Try adding quote=.

--
   O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - (p.dalga...@biostat.ku.dk)  FAX: (+45) 35327907

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

2009-12-20 Thread Martin Ivanov
 Dear R users,

I am running R version 2.10.0 (2009-10-26). I need to prepare an eps
graphic with a legend with cyrillic words. I tried setting the encoding
parameter of the postscript command, but in vain, nothing seems to work. I
tried with CP1251, KOI8-R, UTF-8 and Cyrillic (UTF-8 turned out to not be
available under /usr/lib/R/library/grDevices/enc). All I get is 
in the final inscription.

Has someone been successful in producing postscript legends with cyrillic
words and how? Is the encoding the only thing to be tweaked?

I would be glad if you share your experience.

Regards,
Martin

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


Re: [R] utf8 postscript cyrillic

2009-12-20 Thread Prof Brian Ripley

'Nothing seems to work' is not at all helpful, and you seem under the
misconception that PostScript supports UTF-8 (sic): life would be much 
easier for device writers if it did.


The postscript() help page says

 More details of font families and encodings and especially
 handling text in a non-Latin-1 encoding and embedding fonts can be
 found in

 Paul Murrell and Brian Ripley (2006) Non-standard fonts in
 PostScript and PDF graphics. _R News_, 6(2):41-47.  URL:
 http://cran.r-project.org/doc/Rnews/Rnews_2006-2.pdf.

which shows Cyrillic examples.  We can write documentation for you, 
but you have to read it for yourself 


On Sun, 20 Dec 2009, Martin Ivanov wrote:


Dear R users,

I am running R version 2.10.0 (2009-10-26). I need to prepare an eps
graphic with a legend with cyrillic words. I tried setting the encoding
parameter of the postscript command, but in vain, nothing seems to work. I
tried with CP1251, KOI8-R, UTF-8 and Cyrillic (UTF-8 turned out to not be
available under /usr/lib/R/library/grDevices/enc). All I get is 
in the final inscription.

Has someone been successful in producing postscript legends with cyrillic
words and how? Is the encoding the only thing to be tweaked?

I would be glad if you share your experience.

Regards,
Martin


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

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


[R] how to create three new variables? Thanks a lot!

2009-12-20 Thread jie feng
Dear R experts:

I have following data structure: student id, exam time and score. I want to
create three new columes: 1 st before, 2nd before and 3rd before.
For example, for student 1's 4th exam score is assumed to be influenced by
his previous three cloest  scores, which are 6, 9, and 10 in that order.
For student 2's 5th exam score is assumed to be inflenced by her previous
cloest three scores, which are 10, 10 and 8 in that order.
Note that for student 1, his first time score 10 can not be influenced by
other scores, thus has three empties in the three new columes.
for student 1, his second score 9 is only influenced by his first score
thus has two empties in the columes of 2nd before and 3rd before.
Now I only have 3 columes: id, time and score, and I want to create three
new columes: 1st before, 2nd before and 3rd before. How can I do that?
Thanks a lot.

Best

Jay



   id  timescore 1st before 2nd
before   3rd before
 1 1 10   1 2 9 10  1 3 6 9 10  1 4 10 6 9 10 1 5 5 10 6 9 2 1 7   2 2 8
7  2 3 10 8 7  2 4 10 10 8 7 2 5 5 10 10 8 2 6 9 5 10 10

[[alternative HTML version deleted]]

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


Re: [R] simple main effect.

2009-12-20 Thread Or Duek
Thanks.
But there is no simple main effect there.


On Sun, Dec 20, 2009 at 10:00 AM, Tal Galili tal.gal...@gmail.com wrote:

 Try going through this:
 http://www.personality-project.org/r/r.anova.html

 http://www.personality-project.org/r/r.anova.html


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

 --




 On Sat, Dec 19, 2009 at 7:27 PM, Or Duek ord...@gmail.com wrote:

 Hi, I'm a bit new to R and I would like to know how can I compare simple
 main effects when using the aov function.
 I'm doing a mixed model ANOVA with two between subjects variables and one
 within.
 When I get an interaction of two of the variables I don't know how to
 check
 for simple main effect of that interaction (A at B1 and A at B2 for
 example).
 The aov function is very simple but for some reason I can't find how to do
 this.
 Thank you very much.
 Or Duek.

[[alternative HTML version deleted]]

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




[[alternative HTML version deleted]]

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


Re: [R] how to count the total number of (INCLUDING overlapping) occurrences of a substring within a string?

2009-12-20 Thread Gabor Grothendieck
Use a zero lookaround expression.  It will not consume its match.  See ?regexp

 gregexpr(a(?=a), aaa, perl = TRUE)
[[1]]
[1] 1 2
attr(,match.length)
[1] 1 1


On Sun, Dec 20, 2009 at 1:43 AM, Jonathan jonsle...@gmail.com wrote:
 Last one for you guys:

 The command:

 length(gregexpr('cus','hocus pocus')[[1]])
 [1] 2

 returns the number of times the substring 'cus' appears in 'hocus pocus'
 (which is two)

 It's returning the number of **disjoint** matches.  So:

 length(gregexpr('aa','aaa')[[1]])
  [1] 1

 returns 1.

 **What I want to do:**
 I'm looking for a way to count all occurrences of the substring, including
 overlapping sets (so 'aa' would be found in 'aaa' two times, because the
 middle 'a' gets counted twice).

 Any ideas would be much appreciated!!

 Signing off and thanks for all the great assistance,
 Jonathan

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


Re: [R] how to count the total number of (INCLUDING overlapping) occurrences of a substring within a string?

2009-12-20 Thread Gabor Grothendieck
On Sun, Dec 20, 2009 at 5:33 AM, Gabor Grothendieck
ggrothendi...@gmail.com wrote:
 Use a zero lookaround expression.  It will not consume its match.  See ?regexp

That should be lookahead, not lookaround.


 gregexpr(a(?=a), aaa, perl = TRUE)
 [[1]]
 [1] 1 2
 attr(,match.length)
 [1] 1 1


 On Sun, Dec 20, 2009 at 1:43 AM, Jonathan jonsle...@gmail.com wrote:
 Last one for you guys:

 The command:

 length(gregexpr('cus','hocus pocus')[[1]])
 [1] 2

 returns the number of times the substring 'cus' appears in 'hocus pocus'
 (which is two)

 It's returning the number of **disjoint** matches.  So:

 length(gregexpr('aa','aaa')[[1]])
  [1] 1

 returns 1.

 **What I want to do:**
 I'm looking for a way to count all occurrences of the substring, including
 overlapping sets (so 'aa' would be found in 'aaa' two times, because the
 middle 'a' gets counted twice).

 Any ideas would be much appreciated!!

 Signing off and thanks for all the great assistance,
 Jonathan


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


[R] Res: how to create three new variables? Thanks a lot!

2009-12-20 Thread Rafael Moral
Hello!

Here is a way:

 mydata - data.frame(third_before=c(6,10), second_before=c(9,10), 
 first_before=c(10,8))
 mydata
  third_before second_before first_before
1    6 9   10
2   10    10    8

And if you already have a dataset and wants only to create three more columns, 
create the 3 variables independently and use cbind:

 third_before=c(6,10)
 second_before=c(9,10)
 first_before=c(10,8)
 cbind(your.dataset, third_before, second_before, first_before)

Hope this helps,
All the best!

Rafael




De: jie feng jiefeng...@gmail.com
Para: R-help@r-project.org
Enviadas: Domingo, 20 de Dezembro de 2009 6:34:20
[[elided Yahoo spam]]

Dear R experts:

I have following data structure: student id, exam time and score. I want to
create three new columes: 1 st before, 2nd before and 3rd before.
For example, for student 1's 4th exam score is assumed to be influenced by
his previous three cloest  scores, which are 6, 9, and 10 in that order.
For student 2's 5th exam score is assumed to be inflenced by her previous
cloest three scores, which are 10, 10 and 8 in that order.
Note that for student 1, his first time score 10 can not be influenced by
other scores, thus has three empties in the three new columes.
for student 1, his second score 9 is only influenced by his first score
thus has two empties in the columes of 2nd before and 3rd before.
Now I only have 3 columes: id, time and score, and I want to create three
new columes: 1st before, 2nd before and 3rd before. How can I do that?
Thanks a lot.

Best

Jay



              id          time        score        1st before    2nd
before  3rd before
    1 1 10  1 2 9 10  1 3 6 9 10  1 4 10 6 9 10 1 5 5 10 6 9 2 1 7  2 2 8
7  2 3 10 8 7  2 4 10 10 8 7 2 5 5 10 10 8 2 6 9 5 10 10

    [[alternative HTML version deleted]]

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



  

[[elided Yahoo spam]]

[[alternative HTML version deleted]]

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


Re: [R] how to count the total number of (INCLUDING overl apping) occurrences of a substring within a string ?

2009-12-20 Thread Hans W Borchers
Gabor Grothendieck ggrothendieck at gmail.com writes:
 
 Use a zero lookaround expression.  It will not consume its match.  See ?regexp
 
  gregexpr(a(?=a), aaa, perl = TRUE)
 [[1]]
 [1] 1 2
 attr(,match.length)
 [1] 1 1

I wonder how you would count the number of occurrences of, for example,
'aba' or 'a.a' (*) in the string ababacababab using simple lookahead?

In Perl, there is a modifier '/g' to do that, and in Python one could
apply the function 'findall'.

When I had this task, I wrote a small function findall(), see below, but
I would be glad to see a solution with lookahead only.

Regards
Hans Werner

(*) or anything more complex


findall - function(apat, atxt) {
  stopifnot(length(apat) == 1, length(atxt) == 1)
  pos - c()  # positions of matches
  i - 1; n - nchar(atxt)
  found - regexpr(apat, substr(atxt, i, n), perl=TRUE)
  while (found  0) {
pos - c(pos, i + found - 1)
i - i + found
found - regexpr(apat, substr(atxt, i, n), perl=TRUE)
  }
  return(pos)
}


 On Sun, Dec 20, 2009 at 1:43 AM, Jonathan jonsleepy at gmail.com wrote:
  Last one for you guys:
 
  The command:
 
  length(gregexpr('cus','hocus pocus')[[1]])
  [1] 2
 
  returns the number of times the substring 'cus' appears in 'hocus pocus'
  (which is two)
 
  It's returning the number of **disjoint** matches.  So:
 
  length(gregexpr('aa','aaa')[[1]])
   [1] 1
 
  returns 1.
 
  **What I want to do:**
  I'm looking for a way to count all occurrences of the substring, including
  overlapping sets (so 'aa' would be found in 'aaa' two times, because the
  middle 'a' gets counted twice).
 
  Any ideas would be much appreciated!!
 
  Signing off and thanks for all the great assistance,
  Jonathan
 


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


Re: [R] how to count the total number of (INCLUDING overlapping) occurrences of a substring within a string?

2009-12-20 Thread Gabor Grothendieck
Try this:

 findall(aba, ababacababab)
[1] 1 3 7 9
 gregexpr(a(?=ba), ababacababab, perl = TRUE)
[[1]]
[1] 1 3 7 9
attr(,match.length)
[1] 1 1 1 1

 findall(a.a, ababacababab)
[1] 1 3 5 7 9
 gregexpr(a(?=.a), ababacababab, perl = TRUE)
[[1]]
[1] 1 3 5 7 9
attr(,match.length)
[1] 1 1 1 1 1


On Sun, Dec 20, 2009 at 7:22 AM, Hans W Borchers
hwborch...@googlemail.com wrote:
 Gabor Grothendieck ggrothendieck at gmail.com writes:

 Use a zero lookaround expression.  It will not consume its match.  See 
 ?regexp

  gregexpr(a(?=a), aaa, perl = TRUE)
 [[1]]
 [1] 1 2
 attr(,match.length)
 [1] 1 1

 I wonder how you would count the number of occurrences of, for example,
 'aba' or 'a.a' (*) in the string ababacababab using simple lookahead?

 In Perl, there is a modifier '/g' to do that, and in Python one could
 apply the function 'findall'.

 When I had this task, I wrote a small function findall(), see below, but
 I would be glad to see a solution with lookahead only.

 Regards
 Hans Werner

 (*) or anything more complex

 
    findall - function(apat, atxt) {
      stopifnot(length(apat) == 1, length(atxt) == 1)
      pos - c()  # positions of matches
      i - 1; n - nchar(atxt)
      found - regexpr(apat, substr(atxt, i, n), perl=TRUE)
      while (found  0) {
        pos - c(pos, i + found - 1)
        i - i + found
        found - regexpr(apat, substr(atxt, i, n), perl=TRUE)
      }
      return(pos)
    }
 

 On Sun, Dec 20, 2009 at 1:43 AM, Jonathan jonsleepy at gmail.com wrote:
  Last one for you guys:
 
  The command:
 
  length(gregexpr('cus','hocus pocus')[[1]])
  [1] 2
 
  returns the number of times the substring 'cus' appears in 'hocus pocus'
  (which is two)
 
  It's returning the number of **disjoint** matches.  So:
 
  length(gregexpr('aa','aaa')[[1]])
   [1] 1
 
  returns 1.
 
  **What I want to do:**
  I'm looking for a way to count all occurrences of the substring, including
  overlapping sets (so 'aa' would be found in 'aaa' two times, because the
  middle 'a' gets counted twice).
 
  Any ideas would be much appreciated!!
 
  Signing off and thanks for all the great assistance,
  Jonathan



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


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


Re: [R] read.table: mysterious line omissions

2009-12-20 Thread jim holtman
Most likely an unbalanced quote.  put the following option in the
read.table:

quote='', comment.char=''

On Sat, Dec 19, 2009 at 11:42 PM, Jonathan jonsle...@gmail.com wrote:

 Hello again,
 I am simply trying to import a rectangular table of strings.  The
 table's dimensions are 1990 x 2, yet my read.table() command can only find
 362 of the rows (and they're not the first 362).  I would've taken the time
 to figure out how to use scan, readLines, or some other tool that can read
 in character strings, and then parse and input to a table, but that seems
 like overkill, and probably it would be good to understand what's wrong
 with
 my text file.

 The file is here.

 https://regtransfers-sth-se.diino.com/download/jonsleepy/_mydropbox_/finalInput.xls

 The code is here:
 temp - as.matrix(read.table('finalInput.xls', header=FALSE, sep = \t))
 dim(temp) #expect 1990 x 2; but find 362 x 2

 Sorry to require a download (this probably won't make people happy), but
 since my problem is file-specific, the file is needed for troubleshooting.

 I generated it with some grep, gawk commands using Cygwin in a Windows
 environment (though subsequently converted it to Windows format - R loads
 it
 exactly the same way, regardless of whether it's in linux or windows
 format)

 Regards,
 Jonathan

[[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.htmlhttp://www.r-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.




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

What is the problem that you are trying to solve?

[[alternative HTML version deleted]]

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


Re: [R] simple main effect.

2009-12-20 Thread Tal Galili
Hi Or,

Maybe I didn't understand you.

Are you asking how can I read the output of a fitted (complex within and
between) model for finding the simple main effect ?


Tal





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




On Sun, Dec 20, 2009 at 11:56 AM, Or Duek ord...@gmail.com wrote:

 Thanks.
 But there is no simple main effect there.



 On Sun, Dec 20, 2009 at 10:00 AM, Tal Galili tal.gal...@gmail.com wrote:

 Try going through this:
 http://www.personality-project.org/r/r.anova.html

 http://www.personality-project.org/r/r.anova.html


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

 --




 On Sat, Dec 19, 2009 at 7:27 PM, Or Duek ord...@gmail.com wrote:

 Hi, I'm a bit new to R and I would like to know how can I compare simple
 main effects when using the aov function.
 I'm doing a mixed model ANOVA with two between subjects variables and one
 within.
 When I get an interaction of two of the variables I don't know how to
 check
 for simple main effect of that interaction (A at B1 and A at B2 for
 example).
 The aov function is very simple but for some reason I can't find how to
 do
 this.
 Thank you very much.
 Or Duek.

[[alternative HTML version deleted]]

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





[[alternative HTML version deleted]]

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


Re: [R] simple main effect.

2009-12-20 Thread Or Duek
I don't think so.
I'm asking how can I see/analyse the simple main effect. I don't think it
shows in the summary report of the aov() function.
On Sun, Dec 20, 2009 at 3:35 PM, Tal Galili tal.gal...@gmail.com wrote:

 Hi Or,

 Maybe I didn't understand you.

 Are you asking how can I read the output of a fitted (complex within and
 between) model for finding the simple main effect ?


 Tal





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

 --




 On Sun, Dec 20, 2009 at 11:56 AM, Or Duek ord...@gmail.com wrote:

 Thanks.
 But there is no simple main effect there.



 On Sun, Dec 20, 2009 at 10:00 AM, Tal Galili tal.gal...@gmail.comwrote:

 Try going through this:
 http://www.personality-project.org/r/r.anova.html

 http://www.personality-project.org/r/r.anova.html


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

 --




 On Sat, Dec 19, 2009 at 7:27 PM, Or Duek ord...@gmail.com wrote:

 Hi, I'm a bit new to R and I would like to know how can I compare simple
 main effects when using the aov function.
 I'm doing a mixed model ANOVA with two between subjects variables and
 one
 within.
 When I get an interaction of two of the variables I don't know how to
 check
 for simple main effect of that interaction (A at B1 and A at B2 for
 example).
 The aov function is very simple but for some reason I can't find how to
 do
 this.
 Thank you very much.
 Or Duek.

[[alternative HTML version deleted]]

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






[[alternative HTML version deleted]]

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


Re: [R] how to create three new variables? Thanks a lot!

2009-12-20 Thread David Winsemius


On Dec 20, 2009, at 4:34 AM, jie feng wrote:


Dear R experts:

I have following data structure: student id, exam time and score. I  
want to

create three new columes: 1 st before, 2nd before and 3rd before.
For example, for student 1's 4th exam score is assumed to be  
influenced by
his previous three cloest  scores, which are 6, 9, and 10 in that  
order.
For student 2's 5th exam score is assumed to be inflenced by her  
previous

cloest three scores, which are 10, 10 and 8 in that order.
Note that for student 1, his first time score 10 can not be  
influenced by

other scores, thus has three empties in the three new columes.
for student 1, his second score 9 is only influenced by his first  
score

thus has two empties in the columes of 2nd before and 3rd before.
Now I only have 3 columes: id, time and score, and I want to create  
three

new columes: 1st before, 2nd before and 3rd before. How can I do that?
Thanks a lot.


The combination of your choice of text editors and your use of HTML  
mail format (contrary to the Posting Guide ... please read it more  
carefully)  has completely mangled your posting of the data. As a  
result it is not possible for ordinary humans to figure out what your  
starting point really is. It's possible that the answer lies in the  
help page for lag:


?lag

Future postings on this matter ought to include the data in parse-able  
R format (also described in the Posting Guide.)




Best

Jay

  id  timescore 1st before 2nd
before   3rd before
1 1 10   1 2 9 10  1 3 6 9 10  1 4 10 6 9 10 1 5 5 10 6 9 2 1  
7   2 2 8

7  2 3 10 8 7  2 4 10 10 8 7 2 5 5 10 10 8 2 6 9 5 10 10




 http://www.R-project.org/posting-guide.html


--
David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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


Re: [R] simple main effect.

2009-12-20 Thread Tal Galili
Could you please write the aov formula you are using ?



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




On Sun, Dec 20, 2009 at 3:36 PM, Or Duek ord...@gmail.com wrote:


 I don't think so.
 I'm asking how can I see/analyse the simple main effect. I don't think it
 shows in the summary report of the aov() function.

 On Sun, Dec 20, 2009 at 3:35 PM, Tal Galili tal.gal...@gmail.com wrote:

 Hi Or,

 Maybe I didn't understand you.

 Are you asking how can I read the output of a fitted (complex within and
 between) model for finding the simple main effect ?


 Tal





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

 --




 On Sun, Dec 20, 2009 at 11:56 AM, Or Duek ord...@gmail.com wrote:

 Thanks.
 But there is no simple main effect there.



 On Sun, Dec 20, 2009 at 10:00 AM, Tal Galili tal.gal...@gmail.comwrote:

 Try going through this:
 http://www.personality-project.org/r/r.anova.html

 http://www.personality-project.org/r/r.anova.html


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

 --




 On Sat, Dec 19, 2009 at 7:27 PM, Or Duek ord...@gmail.com wrote:

 Hi, I'm a bit new to R and I would like to know how can I compare
 simple
 main effects when using the aov function.
 I'm doing a mixed model ANOVA with two between subjects variables and
 one
 within.
 When I get an interaction of two of the variables I don't know how to
 check
 for simple main effect of that interaction (A at B1 and A at B2 for
 example).
 The aov function is very simple but for some reason I can't find how to
 do
 this.
 Thank you very much.
 Or Duek.

[[alternative HTML version deleted]]

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







[[alternative HTML version deleted]]

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


Re: [R] simple main effect.

2009-12-20 Thread Or Duek
No problem.
If I have a mixed model with A as within subject (A is exposure, has 2
levels) and drug(2 levels between subject) and strain(2 levels between
subject).
I reshape the data to fit the R aov() function.
thus instead of looking like this:
subjectdrug  strain  exposure_1   exposure2
1   1   1  34 25
22  1  26 22
etc.

it looks like this:
subject  drug   strain   exposure  dependent
1 1 1 1  34
1  1 1 2 25
etc.

and the I do:
aov(dependent~(exposure*strain*drug) + Error(subject/exposure) +
(drug*strain), data)

Thank you very much for your help.
Or.


On Sun, Dec 20, 2009 at 4:18 PM, Tal Galili tal.gal...@gmail.com wrote:

 Could you please write the aov formula you are using ?



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

 --




 On Sun, Dec 20, 2009 at 3:36 PM, Or Duek ord...@gmail.com wrote:


 I don't think so.
 I'm asking how can I see/analyse the simple main effect. I don't think it
 shows in the summary report of the aov() function.

 On Sun, Dec 20, 2009 at 3:35 PM, Tal Galili tal.gal...@gmail.com wrote:

 Hi Or,

 Maybe I didn't understand you.

 Are you asking how can I read the output of a fitted (complex within and
 between) model for finding the simple main effect ?


 Tal





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

 --




 On Sun, Dec 20, 2009 at 11:56 AM, Or Duek ord...@gmail.com wrote:

 Thanks.
 But there is no simple main effect there.



 On Sun, Dec 20, 2009 at 10:00 AM, Tal Galili tal.gal...@gmail.comwrote:

 Try going through this:
 http://www.personality-project.org/r/r.anova.html

 http://www.personality-project.org/r/r.anova.html


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

 --




 On Sat, Dec 19, 2009 at 7:27 PM, Or Duek ord...@gmail.com wrote:

 Hi, I'm a bit new to R and I would like to know how can I compare
 simple
 main effects when using the aov function.
 I'm doing a mixed model ANOVA with two between subjects variables and
 one
 within.
 When I get an interaction of two of the variables I don't know how to
 check
 for simple main effect of that interaction (A at B1 and A at B2 for
 example).
 The aov function is very simple but for some reason I can't find how
 to do
 this.
 Thank you very much.
 Or Duek.

[[alternative HTML version deleted]]

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








[[alternative HTML version deleted]]

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


Re: [R] how to count the total number of (INCLUDING overl apping) occurrences of a substring within a string ?

2009-12-20 Thread Hans W Borchers
Gabor Grothendieck ggrothendieck at gmail.com writes:
 
 Try this:
 
  findall(aba, ababacababab)
 [1] 1 3 7 9
  gregexpr(a(?=ba), ababacababab, perl = TRUE)
 [[1]]
 [1] 1 3 7 9
 attr(,match.length)
 [1] 1 1 1 1
 
  findall(a.a, ababacababab)
 [1] 1 3 5 7 9
  gregexpr(a(?=.a), ababacababab, perl = TRUE)
 [[1]]
 [1] 1 3 5 7 9
 attr(,match.length)
 [1] 1 1 1 1 1


Thanks --- somehow I did not realize that the expression in  ?=...
can also be regular.

My original problem was to find all three character matches where the
first and the last one are the same.  With  findall()  it works like:

findall((.).\\1, ababacababab)
# [1]  1  2  3  5  7  8  9 10

I am still not able to reproduce this with lookahead. Attempts with

gregexpr((.)?=.\\1, ababacababab, perl = TRUE)

do not work as the lookahead expression apparently does not know about
the captured group from before.

Regards
Hans Werner

Correction: I meant the '\G' metacharacter in Perl, not a modifier.


 On Sun, Dec 20, 2009 at 7:22 AM, Hans W Borchers
 hwborchers at googlemail.com wrote:
  Gabor Grothendieck ggrothendieck at gmail.com writes:
 
  [Sorry; Gmane forces me to delete more quoted text.]
 
  
     findall - function(apat, atxt) {
       stopifnot(length(apat) == 1, length(atxt) == 1)
       pos - c()  # positions of matches
       i - 1; n - nchar(atxt)
       found - regexpr(apat, substr(atxt, i, n), perl=TRUE)
       while (found  0) {
         pos - c(pos, i + found - 1)
         i - i + found
         found - regexpr(apat, substr(atxt, i, n), perl=TRUE)
       }
       return(pos)
     }
  
 

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 count the total number of (INCLUDING overlapping) occurrences of a substring within a string?

2009-12-20 Thread Gabor Grothendieck
Try this:

 findall((.).\\1, ababacababab)
[1]  1  2  3  5  7  8  9 10

 gregexpr((.)(?=.\\1), ababacababab, perl = TRUE)
[[1]]
[1]  1  2  3  5  7  8  9 10
attr(,match.length)
[1] 1 1 1 1 1 1 1 1



On Sun, Dec 20, 2009 at 9:33 AM, Hans W Borchers
hwborch...@googlemail.com wrote:
 Gabor Grothendieck ggrothendieck at gmail.com writes:

 Try this:

  findall(aba, ababacababab)
 [1] 1 3 7 9
  gregexpr(a(?=ba), ababacababab, perl = TRUE)
 [[1]]
 [1] 1 3 7 9
 attr(,match.length)
 [1] 1 1 1 1

  findall(a.a, ababacababab)
 [1] 1 3 5 7 9
  gregexpr(a(?=.a), ababacababab, perl = TRUE)
 [[1]]
 [1] 1 3 5 7 9
 attr(,match.length)
 [1] 1 1 1 1 1


 Thanks --- somehow I did not realize that the expression in  ?=...
 can also be regular.

 My original problem was to find all three character matches where the
 first and the last one are the same.  With  findall()  it works like:

    findall((.).\\1, ababacababab)
    # [1]  1  2  3  5  7  8  9 10

 I am still not able to reproduce this with lookahead. Attempts with

    gregexpr((.)?=.\\1, ababacababab, perl = TRUE)

 do not work as the lookahead expression apparently does not know about
 the captured group from before.

 Regards
 Hans Werner

 Correction: I meant the '\G' metacharacter in Perl, not a modifier.


 On Sun, Dec 20, 2009 at 7:22 AM, Hans W Borchers
 hwborchers at googlemail.com wrote:
  Gabor Grothendieck ggrothendieck at gmail.com writes:
 
  [Sorry; Gmane forces me to delete more quoted text.]
 
  
     findall - function(apat, atxt) {
       stopifnot(length(apat) == 1, length(atxt) == 1)
       pos - c()  # positions of matches
       i - 1; n - nchar(atxt)
       found - regexpr(apat, substr(atxt, i, n), perl=TRUE)
       while (found  0) {
         pos - c(pos, i + found - 1)
         i - i + found
         found - regexpr(apat, substr(atxt, i, n), perl=TRUE)
       }
       return(pos)
     }
  
 

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

2009-12-20 Thread kapo coulibaly
Duncan Murdoch helped me sort it out last Friday. Thanks to all who
responded.

On Fri, Dec 18, 2009 at 11:20 AM, Don MacQueen m...@llnl.gov wrote:

 However, source code is available at
  http://water.usgs.gov/nrp/gwsoftware/modflow2005/modflow2005.html
 so it would seem that the details are available.

 -Don


 At 4:35 PM -0500 12/17/09, kapo coulibaly wrote:

 Duncan,
 I couldn't find clear details about the way fortran writes the binaries. I
 was hoping someone here has done it before. But the hexView package seems
 like a great idea i'll give it a shot.

 Thanks a bunch

 On Thu, Dec 17, 2009 at 4:02 PM, Duncan Murdoch murd...@stats.uwo.ca
 wrote:

   On 17/12/2009 3:48 PM, kapo coulibaly wrote:

   Is it possible to read fortran binaries with R? I tried unsucessfully
 and
  my
  understanding is that fortran write binaries with leading and trailing
  bytes. I get numbers but not the right ones.
  Thanks

  ps: the binary I'm interested in reading is a MODFLOW output with a mix
 of
  character, double and integers.


  One other thing:  the hexView package does a very nice job of displaying
  the file, so you can work out what the structure is if the documentation
 is
  unclear (or nonexistent).

  Duncan Murdoch


[[alternative HTML version deleted]]

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



 --
 --
 Don MacQueen
 Environmental Protection Department
 Lawrence Livermore National Laboratory
 Livermore, CA, USA
 925-423-1062
 --


[[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] simple main effect.

2009-12-20 Thread Tal Galili
Thanks Or,
So I am failing to understand,
When you put that aov expression into the summary() Why isn't what you are
getting what you need ?

Tal


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




On Sun, Dec 20, 2009 at 4:30 PM, Or Duek ord...@gmail.com wrote:

 No problem.
 If I have a mixed model with A as within subject (A is exposure, has 2
 levels) and drug(2 levels between subject) and strain(2 levels between
 subject).
 I reshape the data to fit the R aov() function.
 thus instead of looking like this:
 subjectdrug  strain  exposure_1   exposure2
 1   1   1  34 25
 22  1  26 22
 etc.

 it looks like this:
 subject  drug   strain   exposure  dependent
 1 1 1 1  34
 1  1 1 2 25
 etc.

 and the I do:
 aov(dependent~(exposure*strain*drug) + Error(subject/exposure) +
 (drug*strain), data)

 Thank you very much for your help.
 Or.



 On Sun, Dec 20, 2009 at 4:18 PM, Tal Galili tal.gal...@gmail.com wrote:

 Could you please write the aov formula you are using ?



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

 --




 On Sun, Dec 20, 2009 at 3:36 PM, Or Duek ord...@gmail.com wrote:


 I don't think so.
 I'm asking how can I see/analyse the simple main effect. I don't think it
 shows in the summary report of the aov() function.

 On Sun, Dec 20, 2009 at 3:35 PM, Tal Galili tal.gal...@gmail.comwrote:

 Hi Or,

 Maybe I didn't understand you.

 Are you asking how can I read the output of a fitted (complex within
 and between) model for finding the simple main effect ?


 Tal





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

 --




 On Sun, Dec 20, 2009 at 11:56 AM, Or Duek ord...@gmail.com wrote:

 Thanks.
 But there is no simple main effect there.



 On Sun, Dec 20, 2009 at 10:00 AM, Tal Galili tal.gal...@gmail.comwrote:

 Try going through this:
 http://www.personality-project.org/r/r.anova.html

 http://www.personality-project.org/r/r.anova.html


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

 --




 On Sat, Dec 19, 2009 at 7:27 PM, Or Duek ord...@gmail.com wrote:

 Hi, I'm a bit new to R and I would like to know how can I compare
 simple
 main effects when using the aov function.
 I'm doing a mixed model ANOVA with two between subjects variables and
 one
 within.
 When I get an interaction of two of the variables I don't know how to
 check
 for simple main effect of that interaction (A at B1 and A at B2 for
 example).
 The aov function is very simple but for some reason I can't find how
 to do
 this.
 Thank you very much.
 Or Duek.

[[alternative HTML version deleted]]

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









[[alternative HTML version deleted]]

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


Re: [R] simple main effect.

2009-12-20 Thread Tal Galili
Also, do you have any missing data ?

Tal



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




On Sun, Dec 20, 2009 at 5:52 PM, Tal Galili tal.gal...@gmail.com wrote:

 Thanks Or,
 So I am failing to understand,
 When you put that aov expression into the summary() Why isn't what you
 are getting what you need ?

 Tal


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

 --




 On Sun, Dec 20, 2009 at 4:30 PM, Or Duek ord...@gmail.com wrote:

 No problem.
 If I have a mixed model with A as within subject (A is exposure, has 2
 levels) and drug(2 levels between subject) and strain(2 levels between
 subject).
 I reshape the data to fit the R aov() function.
 thus instead of looking like this:
 subjectdrug  strain  exposure_1   exposure2
 1   1   1  34 25
 22  1  26 22
 etc.

 it looks like this:
 subject  drug   strain   exposure  dependent
 1 1 1 1  34
 1  1 1 2 25
 etc.

 and the I do:
 aov(dependent~(exposure*strain*drug) + Error(subject/exposure) +
 (drug*strain), data)

 Thank you very much for your help.
 Or.



 On Sun, Dec 20, 2009 at 4:18 PM, Tal Galili tal.gal...@gmail.com wrote:

 Could you please write the aov formula you are using ?



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

 --




 On Sun, Dec 20, 2009 at 3:36 PM, Or Duek ord...@gmail.com wrote:


 I don't think so.
 I'm asking how can I see/analyse the simple main effect. I don't think
 it shows in the summary report of the aov() function.

 On Sun, Dec 20, 2009 at 3:35 PM, Tal Galili tal.gal...@gmail.comwrote:

 Hi Or,

 Maybe I didn't understand you.

 Are you asking how can I read the output of a fitted (complex within
 and between) model for finding the simple main effect ?


 Tal





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

 --




 On Sun, Dec 20, 2009 at 11:56 AM, Or Duek ord...@gmail.com wrote:

 Thanks.
 But there is no simple main effect there.



 On Sun, Dec 20, 2009 at 10:00 AM, Tal Galili tal.gal...@gmail.comwrote:

 Try going through this:
 http://www.personality-project.org/r/r.anova.html

 http://www.personality-project.org/r/r.anova.html


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

 --




 On Sat, Dec 19, 2009 at 7:27 PM, Or Duek ord...@gmail.com wrote:

 Hi, I'm a bit new to R and I would like to know how can I compare
 simple
 main effects when using the aov function.
 I'm doing a mixed model ANOVA with two between subjects variables
 and one
 within.
 When I get an interaction of two of the variables I don't know how
 to check
 for simple main effect of that interaction (A at B1 and A at B2 for
 example).
 The aov function is very simple but for some reason I can't find how
 to do
 this.
 Thank you very much.
 Or Duek.

[[alternative HTML version deleted]]

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










[[alternative HTML version deleted]]

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


Re: [R] simple main effect.

2009-12-20 Thread Or Duek
I don't have missing data.
about what I need.
Lets say the drug*strain interaction is significant - now I want to check
for drug under the levels of strain - compare drug 1 and 2 only on strain 1
and then only on strain 2.
Or I'd like to compare the strains under levels of exposure.
This is the kind of data I fail to see in summary() but it is important to
understand the interactions.
thank you.

On Sun, Dec 20, 2009 at 5:52 PM, Tal Galili tal.gal...@gmail.com wrote:

 Also, do you have any missing data ?

 Tal



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

 --




 On Sun, Dec 20, 2009 at 5:52 PM, Tal Galili tal.gal...@gmail.com wrote:

 Thanks Or,
 So I am failing to understand,
 When you put that aov expression into the summary() Why isn't what you
 are getting what you need ?

 Tal


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

 --




 On Sun, Dec 20, 2009 at 4:30 PM, Or Duek ord...@gmail.com wrote:

 No problem.
 If I have a mixed model with A as within subject (A is exposure, has 2
 levels) and drug(2 levels between subject) and strain(2 levels between
 subject).
 I reshape the data to fit the R aov() function.
 thus instead of looking like this:
 subjectdrug  strain  exposure_1   exposure2
 1   1   1  34 25
 22  1  26 22
 etc.

 it looks like this:
 subject  drug   strain   exposure  dependent
 1 1 1 1  34
 1  1 1 2 25
 etc.

 and the I do:
 aov(dependent~(exposure*strain*drug) + Error(subject/exposure) +
 (drug*strain), data)

 Thank you very much for your help.
 Or.



 On Sun, Dec 20, 2009 at 4:18 PM, Tal Galili tal.gal...@gmail.comwrote:

 Could you please write the aov formula you are using ?



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

 --




 On Sun, Dec 20, 2009 at 3:36 PM, Or Duek ord...@gmail.com wrote:


 I don't think so.
 I'm asking how can I see/analyse the simple main effect. I don't think
 it shows in the summary report of the aov() function.

 On Sun, Dec 20, 2009 at 3:35 PM, Tal Galili tal.gal...@gmail.comwrote:

 Hi Or,

 Maybe I didn't understand you.

 Are you asking how can I read the output of a fitted (complex within
 and between) model for finding the simple main effect ?


 Tal





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

 --




 On Sun, Dec 20, 2009 at 11:56 AM, Or Duek ord...@gmail.com wrote:

 Thanks.
 But there is no simple main effect there.



 On Sun, Dec 20, 2009 at 10:00 AM, Tal Galili 
 tal.gal...@gmail.comwrote:

 Try going through this:
 http://www.personality-project.org/r/r.anova.html

 http://www.personality-project.org/r/r.anova.html


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

 --




 On Sat, Dec 19, 2009 at 7:27 PM, Or Duek ord...@gmail.com wrote:

 Hi, I'm a bit new to R and I would like to know how can I compare
 simple
 main effects when using the aov function.
 I'm doing a mixed model ANOVA with two between subjects variables
 and one
 within.
 When I get an interaction of two of the variables I don't know how
 to check
 for simple main effect of that interaction (A at B1 and A at B2 for
 example).
 The aov function is very simple but for some reason I can't find
 how to do
 this.
 Thank you very much.
 Or Duek.

[[alternative HTML version deleted]]

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

[R] expression()

2009-12-20 Thread Kim Jung Hwa
Hi All,

I'm wondering if its possible to write degree in symbol.

I would like y-label as Temperature (degreeF). where degree should be in
symbols. Thanks in advance,

#R Code
library(lattice)
data(barley)
barchart(yield ~ variety | site, data = barley,
 groups = year, layout = c(1,6),
 ylab = Temperature (degreeF),
 scales = list(x = list(abbreviate = TRUE,
   minlength = 5)))
~Kim Jung Hwa

[[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] simple main effect.

2009-12-20 Thread S Devriese
On 12/20/2009 04:56 PM, Or Duek wrote:
 I don't have missing data.
 about what I need.
 Lets say the drug*strain interaction is significant - now I want to check
 for drug under the levels of strain - compare drug 1 and 2 only on strain 1
 and then only on strain 2.
 Or I'd like to compare the strains under levels of exposure.
 This is the kind of data I fail to see in summary() but it is important to
 understand the interactions.
 thank you.
 

Do you main pairwise multiple comparison tests like Tukey Honest
Significant Difference tests? Then you could use TukeyHSD in the stats
package or see the DTK package (Dunnett-Tukey-Kramer Pairwise Multiple
Comparison Test Adjusted for Unequal Variances and Unequal Sample Sizes)

Stephan

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


Re: [R] expression()

2009-12-20 Thread baptiste auguie
Hi,

try this,

ylab = expression(Temperature~(degree*F))

?plotmath

baptiste

2009/12/20 Kim Jung Hwa kimhwamaill...@gmail.com:
 Hi All,

 I'm wondering if its possible to write degree in symbol.

 I would like y-label as Temperature (degreeF). where degree should be in
 symbols. Thanks in advance,

 #R Code
 library(lattice)
 data(barley)
 barchart(yield ~ variety | site, data = barley,
         groups = year, layout = c(1,6),
         ylab = Temperature (degreeF),
         scales = list(x = list(abbreviate = TRUE,
                       minlength = 5)))
 ~Kim Jung Hwa

        [[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] simple main effect.

2009-12-20 Thread Or Duek
For some reasion I wasn't able to use TukeyHSD - I think because I need to
set the different levels under a second variable.
Tukey only helps me when I have more than 2 levels of same variable.
Thanl you.
On Sun, Dec 20, 2009 at 6:32 PM, S Devriese sdmaill...@gmail.com wrote:

 On 12/20/2009 04:56 PM, Or Duek wrote:
  I don't have missing data.
  about what I need.
  Lets say the drug*strain interaction is significant - now I want to check
  for drug under the levels of strain - compare drug 1 and 2 only on strain
 1
  and then only on strain 2.
  Or I'd like to compare the strains under levels of exposure.
  This is the kind of data I fail to see in summary() but it is important
 to
  understand the interactions.
  thank you.
 

 Do you main pairwise multiple comparison tests like Tukey Honest
 Significant Difference tests? Then you could use TukeyHSD in the stats
 package or see the DTK package (Dunnett-Tukey-Kramer Pairwise Multiple
 Comparison Test Adjusted for Unequal Variances and Unequal Sample Sizes)

 Stephan


[[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] basic proto question

2009-12-20 Thread baptiste auguie
Dear list,

I made the following example of a proto object that contains some data
and a spline interpolation. I don't understand why test$predict()
fails with this error message:

Error: evaluation nested too deeply: infinite recursion / options(expressions=)?

Best regards,

baptiste

test - proto(source = data.frame(x=1:10, y=rnorm(10)),
  raw = function(.){
data.frame(xx=.$source$x, yy=.$source$y)
  },
  spline = function(.){
with(.$raw(), smooth.spline(xx, yy))
  },
  predict = function(., range=NULL, n=100){
if(is.null(range))
  range - range(.$raw()$xx)

x.fine - seq(from=range[1], to=range[2], length=n)

predict(.$spline(), x.fine)

  }
  )

test$source
test$raw()
test$spline() # OK so far
test$predict() # fails

sessionInfo()
R version 2.10.1 RC (2009-12-06 r50690)
i386-apple-darwin9.8.0

locale:
[1] en_GB.UTF-8/en_GB.UTF-8/C/C/en_GB.UTF-8/en_GB.UTF-8

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

other attached packages:
[1] lattice_0.17-26 ggplot2_0.8.5   digest_0.4.1reshape_0.8.3
[5] plyr_0.1.9  proto_0.3-8 constants_1.0   gtools_2.6.1

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


Re: [R] basic proto question

2009-12-20 Thread Gabor Grothendieck
The free variables in a proto method are looked up in the object that
the method was defined in so by referencing predict within
test$predict you are referring back to test$predict whereas you mean
to refer to stats::predict.  Change the line that calls predict to:

stats::predict(.$spline(), x.fine)

On Sun, Dec 20, 2009 at 11:49 AM, baptiste auguie
baptiste.aug...@googlemail.com wrote:
 Dear list,

 I made the following example of a proto object that contains some data
 and a spline interpolation. I don't understand why test$predict()
 fails with this error message:

 Error: evaluation nested too deeply: infinite recursion / 
 options(expressions=)?

 Best regards,

 baptiste

 test - proto(source = data.frame(x=1:10, y=rnorm(10)),
              raw = function(.){
                data.frame(xx=.$source$x, yy=.$source$y)
              },
              spline = function(.){
                with(.$raw(), smooth.spline(xx, yy))
                  },
              predict = function(., range=NULL, n=100){
                if(is.null(range))
                  range - range(.$raw()$xx)

                x.fine - seq(from=range[1], to=range[2], length=n)

                predict(.$spline(), x.fine)

              }
              )

 test$source
 test$raw()
 test$spline() # OK so far
 test$predict() # fails

 sessionInfo()
 R version 2.10.1 RC (2009-12-06 r50690)
 i386-apple-darwin9.8.0

 locale:
 [1] en_GB.UTF-8/en_GB.UTF-8/C/C/en_GB.UTF-8/en_GB.UTF-8

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

 other attached packages:
 [1] lattice_0.17-26 ggplot2_0.8.5   digest_0.4.1    reshape_0.8.3
 [5] plyr_0.1.9      proto_0.3-8     constants_1.0   gtools_2.6.1

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

2009-12-20 Thread MAL
All!

This piece of code:

zzz1 - as.POSIXct(1999-03-18, tz=CET)
zzz2 - as.POSIXlt(1999-03-18, tz=CET)
zzz1 == zzz2
as.Date(zzz1)
as.Date(zzz2)

yields TRUE for zzz1==zzz2, but the two dates returned by as.Date are 
different:

 as.Date(zzz1)
[1] 1999-03-17
 as.Date(zzz2)
[1] 1999-03-18

I'm using R 2.10.0.

Would be glad for any clarifications. Thanks!
[[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] simple main effect.

2009-12-20 Thread Ista Zahn
Hi Or,
I understand your question (and am not sure what the confusion is
about actually). Just like you said, you want to know the effect of A
at B=1, and the effect of A at B=2. In this case, you want to know if
drug has a significant effect for those with strain one, and whether
drug has a significant effect for those with strain two. So the good
part is, I understand the question.


The bad part is that unfortunately I don't know how to do it with
aov(). Also, I'm not a stats guru and could easily be wrong about the
following advice. You've been warned!

If you didn't have a mixed model, I would tell you to run the model
using lm() twice, setting drug = 1 as the reference group the first
time, and drug = 2 as the reference group the second time, but this
won't work in your case. The best I can offer is a suggestion to run
the model separately for each level of drug. Note that you can and
should use the error term from the overall model though -- you will
have to do this by hand (just divide  MS_effect from the subset
model by MS_error from the full model, and evaluate using df_error
from the overall model). So basically, I'm suggesting that you do

Data.drug1 - subset(Data, drug == 1)
aov.model.drug.1 - aov(dependent~(exposure*strain) +
Error(subject/exposure) + (strain), data=Data.drug1)
summary(aov.model.drug.1)

Data.drug2 - subset(Data, drug == 2)
aov.model.drug.2 - aov(dependent~(exposure*strain) +
Error(subject/exposure) + (strain), data=Data.drug2)
summary(aov.model.drug.2)

Good luck!

-Ista

On Sun, Dec 20, 2009 at 11:35 AM, Or Duek ord...@gmail.com wrote:
 For some reasion I wasn't able to use TukeyHSD - I think because I need to
 set the different levels under a second variable.
 Tukey only helps me when I have more than 2 levels of same variable.
 Thanl you.
 On Sun, Dec 20, 2009 at 6:32 PM, S Devriese sdmaill...@gmail.com wrote:

 On 12/20/2009 04:56 PM, Or Duek wrote:
  I don't have missing data.
  about what I need.
  Lets say the drug*strain interaction is significant - now I want to check
  for drug under the levels of strain - compare drug 1 and 2 only on strain
 1
  and then only on strain 2.
  Or I'd like to compare the strains under levels of exposure.
  This is the kind of data I fail to see in summary() but it is important
 to
  understand the interactions.
  thank you.
 

 Do you main pairwise multiple comparison tests like Tukey Honest
 Significant Difference tests? Then you could use TukeyHSD in the stats
 package or see the DTK package (Dunnett-Tukey-Kramer Pairwise Multiple
 Comparison Test Adjusted for Unequal Variances and Unequal Sample Sizes)

 Stephan


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




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

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


[R] Problem with sequence in loop

2009-12-20 Thread Muhammad Rahiz

Hi all,

I've got a list of files from 1914 to 2000. For each file, I can call the 
read.table function as follows.


file - read.table(1914.txt)



But I want to make a script so that at the end of the loop, the script selects 
the file 1915.txt, 1916.txt and so on.

I've used seq() to create the increment

seq - paste(seq(1914, 2006, by=1), *.txt.h, sep=.)

But it didn't work.

Below is the script;

seq - paste(seq(1914, 2006, by=1), *.txt, sep=.)

for (i in 1:93){
list - list.files(~/ukcp09/txt/x.djf, seq)
file - lapply(list, read.table)

mean - (Reduce(+, file))/3
}

When I call

 objects()
 list
[1] 2006.01.txt.h 2006.02.txt.h 2006.12.txt.h

The listed files are the last files in the sequence.

Am I doing the loop correctly?

--
Muhammad Rahiz  |  Doctoral Student in Regional Climate Modeling

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

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

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


Re: [R] basic proto question

2009-12-20 Thread baptiste auguie
Thanks, it seems so obvious now!

baptiste

2009/12/20 Gabor Grothendieck ggrothendi...@gmail.com:
 The free variables in a proto method are looked up in the object that
 the method was defined in so by referencing predict within
 test$predict you are referring back to test$predict whereas you mean
 to refer to stats::predict.  Change the line that calls predict to:

 stats::predict(.$spline(), x.fine)

 On Sun, Dec 20, 2009 at 11:49 AM, baptiste auguie
 baptiste.aug...@googlemail.com wrote:
 Dear list,

 I made the following example of a proto object that contains some data
 and a spline interpolation. I don't understand why test$predict()
 fails with this error message:

 Error: evaluation nested too deeply: infinite recursion / 
 options(expressions=)?

 Best regards,

 baptiste

 test - proto(source = data.frame(x=1:10, y=rnorm(10)),
              raw = function(.){
                data.frame(xx=.$source$x, yy=.$source$y)
              },
              spline = function(.){
                with(.$raw(), smooth.spline(xx, yy))
                  },
              predict = function(., range=NULL, n=100){
                if(is.null(range))
                  range - range(.$raw()$xx)

                x.fine - seq(from=range[1], to=range[2], length=n)

                predict(.$spline(), x.fine)

              }
              )

 test$source
 test$raw()
 test$spline() # OK so far
 test$predict() # fails

 sessionInfo()
 R version 2.10.1 RC (2009-12-06 r50690)
 i386-apple-darwin9.8.0

 locale:
 [1] en_GB.UTF-8/en_GB.UTF-8/C/C/en_GB.UTF-8/en_GB.UTF-8

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

 other attached packages:
 [1] lattice_0.17-26 ggplot2_0.8.5   digest_0.4.1    reshape_0.8.3
 [5] plyr_0.1.9      proto_0.3-8     constants_1.0   gtools_2.6.1

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

2009-12-20 Thread Jason Morgan
Hello,

On 2009.12.20 18:06:17, MAL wrote:
 All!
 
 This piece of code:
 
 zzz1 - as.POSIXct(1999-03-18, tz=CET)
 zzz2 - as.POSIXlt(1999-03-18, tz=CET)
 zzz1 == zzz2
 as.Date(zzz1)
 as.Date(zzz2)
 
 yields TRUE for zzz1==zzz2, but the two dates returned by as.Date are 
 different:
 
  as.Date(zzz1)
 [1] 1999-03-17
  as.Date(zzz2)
 [1] 1999-03-18
 
 I'm using R 2.10.0.
 
 Would be glad for any clarifications. Thanks!

I don't know why as.Date() is giving different results, but if look at
the value of the variables, they are equal:

 zzz1 - as.POSIXct(1999-03-18, tz=CET)
 zzz2 - as.POSIXlt(1999-03-18, tz=CET)
 zzz1 == zzz2
[1] TRUE
 as.Date(zzz1)
[1] 1999-03-17
 as.Date(zzz2)
[1] 1999-03-18
 zzz1
[1] 1999-03-18 CET
 zzz2
[1] 1999-03-18 CET

Maybe someone here can explain the behavior of as.Date().

Cheers,
~Jason


-- 
Jason W. Morgan
Graduate Student
Department of Political Science
*The Ohio State University*
154 North Oval Mall
Columbus, Ohio 43210

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

2009-12-20 Thread MAL

All!

This piece of code:

zzz1 - as.POSIXct(1999-03-18, tz=CET)
zzz2 - as.POSIXlt(1999-03-18, tz=CET)
zzz1 == zzz2
as.Date(zzz1)
as.Date(zzz2)

yields TRUE for zzz1==zzz2, but the two dates returned by as.Date are 
different:



as.Date(zzz1)

[1] 1999-03-17

as.Date(zzz2)

[1] 1999-03-18

I'm using R 2.10.0.

Would be glad for any clarifications. Thanks!

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


Re: [R] simple main effect.

2009-12-20 Thread Or Duek
Thank you very much Ista.
Can you please be a bit more specific as to using the overall error. I don't
know how to actually do it in R.
thank you,
Or.

On Sun, Dec 20, 2009 at 7:09 PM, Ista Zahn istaz...@gmail.com wrote:

 Hi Or,
 I understand your question (and am not sure what the confusion is
 about actually). Just like you said, you want to know the effect of A
 at B=1, and the effect of A at B=2. In this case, you want to know if
 drug has a significant effect for those with strain one, and whether
 drug has a significant effect for those with strain two. So the good
 part is, I understand the question.


 The bad part is that unfortunately I don't know how to do it with
 aov(). Also, I'm not a stats guru and could easily be wrong about the
 following advice. You've been warned!

 If you didn't have a mixed model, I would tell you to run the model
 using lm() twice, setting drug = 1 as the reference group the first
 time, and drug = 2 as the reference group the second time, but this
 won't work in your case. The best I can offer is a suggestion to run
 the model separately for each level of drug. Note that you can and
 should use the error term from the overall model though -- you will
 have to do this by hand (just divide  MS_effect from the subset
 model by MS_error from the full model, and evaluate using df_error
 from the overall model). So basically, I'm suggesting that you do

 Data.drug1 - subset(Data, drug == 1)
 aov.model.drug.1 - aov(dependent~(exposure*strain) +
 Error(subject/exposure) + (strain), data=Data.drug1)
 summary(aov.model.drug.1)

 Data.drug2 - subset(Data, drug == 2)
 aov.model.drug.2 - aov(dependent~(exposure*strain) +
 Error(subject/exposure) + (strain), data=Data.drug2)
 summary(aov.model.drug.2)

 Good luck!

 -Ista

 On Sun, Dec 20, 2009 at 11:35 AM, Or Duek ord...@gmail.com wrote:
  For some reasion I wasn't able to use TukeyHSD - I think because I need
 to
  set the different levels under a second variable.
  Tukey only helps me when I have more than 2 levels of same variable.
  Thanl you.
  On Sun, Dec 20, 2009 at 6:32 PM, S Devriese sdmaill...@gmail.com
 wrote:
 
  On 12/20/2009 04:56 PM, Or Duek wrote:
   I don't have missing data.
   about what I need.
   Lets say the drug*strain interaction is significant - now I want to
 check
   for drug under the levels of strain - compare drug 1 and 2 only on
 strain
  1
   and then only on strain 2.
   Or I'd like to compare the strains under levels of exposure.
   This is the kind of data I fail to see in summary() but it is
 important
  to
   understand the interactions.
   thank you.
  
 
  Do you main pairwise multiple comparison tests like Tukey Honest
  Significant Difference tests? Then you could use TukeyHSD in the stats
  package or see the DTK package (Dunnett-Tukey-Kramer Pairwise Multiple
  Comparison Test Adjusted for Unequal Variances and Unequal Sample Sizes)
 
  Stephan
 
 
 [[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.
 



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


[[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] Recall: Problem with sequence in loop

2009-12-20 Thread Muhammad Rahiz
I recall the above problem. It works. Just error on my part in the file 
output.


Here is the script that works.

-
seq - paste(seq(1914, 1916, by=1), *.y, sep=.)

for (i in 1:3){
list - list.files(~/ukcp09/txt/x.djf, seq[[i]])
file - lapply(list, read.table)

mean - (Reduce(+, file))

myfile1 - paste(strsplit(seq[[i]], \\.)[[1]][1], sum.txt, sep=.)
write.table(mean, file=myfile1, row.names=FALSE, col.names=FALSE)
}

-


Muhammad Rahiz wrote:

Hi all,

I've got a list of files from 1914 to 2000. For each file, I can call the 
read.table function as follows.

  

file - read.table(1914.txt)




But I want to make a script so that at the end of the loop, the script selects 
the file 1915.txt, 1916.txt and so on.

I've used seq() to create the increment

seq - paste(seq(1914, 2006, by=1), *.txt.h, sep=.)

But it didn't work.

Below is the script;

seq - paste(seq(1914, 2006, by=1), *.txt, sep=.)

for (i in 1:93){
list - list.files(~/ukcp09/txt/x.djf, seq)
file - lapply(list, read.table)

mean - (Reduce(+, file))/3
}

When I call

  objects()
  list
[1] 2006.01.txt.h 2006.02.txt.h 2006.12.txt.h

The listed files are the last files in the sequence.

Am I doing the loop correctly?




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


Re: [R] simple main effect.

2009-12-20 Thread Ista Zahn
Well, the F value is just MS_effect/MS_error. So you run the original
model, run the subset models, but disregard the F values. To calculate
the correct F values, divide MS_effect from the subset model by the
MS_error term from the original (full) model. It's not really a matter
of learning how to do it in R -- you're just doing simple division.

-Ista

On Sun, Dec 20, 2009 at 12:28 PM, Or Duek ord...@gmail.com wrote:
 Thank you very much Ista.
 Can you please be a bit more specific as to using the overall error. I don't
 know how to actually do it in R.
 thank you,
 Or.

 On Sun, Dec 20, 2009 at 7:09 PM, Ista Zahn istaz...@gmail.com wrote:

 Hi Or,
 I understand your question (and am not sure what the confusion is
 about actually). Just like you said, you want to know the effect of A
 at B=1, and the effect of A at B=2. In this case, you want to know if
 drug has a significant effect for those with strain one, and whether
 drug has a significant effect for those with strain two. So the good
 part is, I understand the question.


 The bad part is that unfortunately I don't know how to do it with
 aov(). Also, I'm not a stats guru and could easily be wrong about the
 following advice. You've been warned!

 If you didn't have a mixed model, I would tell you to run the model
 using lm() twice, setting drug = 1 as the reference group the first
 time, and drug = 2 as the reference group the second time, but this
 won't work in your case. The best I can offer is a suggestion to run
 the model separately for each level of drug. Note that you can and
 should use the error term from the overall model though -- you will
 have to do this by hand (just divide  MS_effect from the subset
 model by MS_error from the full model, and evaluate using df_error
 from the overall model). So basically, I'm suggesting that you do

 Data.drug1 - subset(Data, drug == 1)
 aov.model.drug.1 - aov(dependent~(exposure*strain) +
 Error(subject/exposure) + (strain), data=Data.drug1)
 summary(aov.model.drug.1)

 Data.drug2 - subset(Data, drug == 2)
 aov.model.drug.2 - aov(dependent~(exposure*strain) +
 Error(subject/exposure) + (strain), data=Data.drug2)
 summary(aov.model.drug.2)

 Good luck!

 -Ista

 On Sun, Dec 20, 2009 at 11:35 AM, Or Duek ord...@gmail.com wrote:
  For some reasion I wasn't able to use TukeyHSD - I think because I need
  to
  set the different levels under a second variable.
  Tukey only helps me when I have more than 2 levels of same variable.
  Thanl you.
  On Sun, Dec 20, 2009 at 6:32 PM, S Devriese sdmaill...@gmail.com
  wrote:
 
  On 12/20/2009 04:56 PM, Or Duek wrote:
   I don't have missing data.
   about what I need.
   Lets say the drug*strain interaction is significant - now I want to
   check
   for drug under the levels of strain - compare drug 1 and 2 only on
   strain
  1
   and then only on strain 2.
   Or I'd like to compare the strains under levels of exposure.
   This is the kind of data I fail to see in summary() but it is
   important
  to
   understand the interactions.
   thank you.
  
 
  Do you main pairwise multiple comparison tests like Tukey Honest
  Significant Difference tests? Then you could use TukeyHSD in the stats
  package or see the DTK package (Dunnett-Tukey-Kramer Pairwise Multiple
  Comparison Test Adjusted for Unequal Variances and Unequal Sample
  Sizes)
 
  Stephan
 
 
         [[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.
 



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





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

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


[R] How to rotate an axis?

2009-12-20 Thread Etienne Stockhausen

Hi everybody,
I'm trying to build a trilineare coordinate system with R. For that, I 
need to rotate an axis. Does anybody know, if it is possible to rotate 
an axis, created with the command axis(), about for instance 60 degrees?


I'm looking foward  to any ideas and hints and want to wish everybody a 
merry merry christmas.


Thanks in advance.

Etienne Stockhausen

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

2009-12-20 Thread Amit
Dear All,
I am trying to plot polynomial regression line to a scatterplot. I did
following so far:

x=c(1:9335)
y=read.table(gp.txt,header=T,sep=\t)
 length(y$PCC) # y$PCC has values between 1 to 0 in decreasing order
[1] 9335
 plot(x,y$PCC,col=red) #scatterplot between x and y$PCC
 reg=lm(y$PCC~poly(x,6)) # calculating polynomial fit with degree 6
 abline(reg,col=blue)
Warning message:
In abline(reg, col = blue) :
  only using the first two of 7regression coefficients

After the above warning a line is drawn in the graph parallel to the
y-axis. But I was expecting a curve line through the scatterplot.
Am I doing something wrong? Please help!

Best
Amit

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

2009-12-20 Thread Uwe Ligges



On 20.12.2009 19:06, Etienne Stockhausen wrote:

Hi everybody,
I'm trying to build a trilineare coordinate system with R. For that, I
need to rotate an axis. Does anybody know, if it is possible to rotate
an axis, created with the command axis(), about for instance 60 degrees?



You cannot with base graphics. You could switch to the grid framework 
which allows such things.


Best wishes,
Uwe Ligges




I'm looking foward to any ideas and hints and want to wish everybody a
merry merry christmas.

Thanks in advance.

Etienne Stockhausen

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

2009-12-20 Thread David Winsemius


On Dec 20, 2009, at 1:06 PM, Etienne Stockhausen wrote:


Hi everybody,
I'm trying to build a trilineare coordinate system with R. For that,  
I need to rotate an axis. Does anybody know, if it is possible to  
rotate an axis, created with the command axis(), about for instance  
60 degrees?


I'm looking foward  to any ideas and hints and want to wish  
everybody a merry merry christmas.




I think that answer about rotating what gets plotted by axis() is  
no, but perhaps you are unaware of the persp() or wireframe()  
functions in package:lattice or the facilities offer by package:rgl?




Thanks in advance.

Etienne Stockhausen


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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


Re: [R] plotting polynomial regression line

2009-12-20 Thread Uwe Ligges



On 20.12.2009 19:35, Amit wrote:

Dear All,
I am trying to plot polynomial regression line to a scatterplot. I did
following so far:


x=c(1:9335)
y=read.table(gp.txt,header=T,sep=\t)
length(y$PCC) # y$PCC has values between 1 to 0 in decreasing order

[1] 9335

plot(x,y$PCC,col=red) #scatterplot between x and y$PCC
reg=lm(y$PCC~poly(x,6)) # calculating polynomial fit with degree 6
abline(reg,col=blue)

Warning message:
In abline(reg, col = blue) :
   only using the first two of 7regression coefficients



abline() draws straight lines.



After the above warning a line is drawn in the graph parallel to the
y-axis. But I was expecting a curve line through the scatterplot.
Am I doing something wrong? Please help!



You can predict() some points along your x values and connect them via 
lines().


Best wishes,
Uwe Ligges




Best
Amit

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


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


Re: [R] plotting polynomial regression line

2009-12-20 Thread Jason Morgan
Hello Amit,

On 2009.12.20 19:35:09, Amit wrote:
 Dear All,
 I am trying to plot polynomial regression line to a scatterplot. I did
 following so far:
 
 x=c(1:9335)
 y=read.table(gp.txt,header=T,sep=\t)
  length(y$PCC) # y$PCC has values between 1 to 0 in decreasing order
 [1] 9335
  plot(x,y$PCC,col=red) #scatterplot between x and y$PCC
  reg=lm(y$PCC~poly(x,6)) # calculating polynomial fit with degree 6
  abline(reg,col=blue)
 Warning message:
 In abline(reg, col = blue) :
   only using the first two of 7regression coefficients
 
 After the above warning a line is drawn in the graph parallel to the
 y-axis. But I was expecting a curve line through the scatterplot.
 Am I doing something wrong? Please help!

Take a look at ?predict. Briefly, I think this will give you what you
want:

 reg - lm(y$PCC ~ poly(x,6))
 plot(x, y$PCC, col=red)
 lines(x, predict(reg), col=blue)

Cheers,
Jason


-- 
Jason W. Morgan
Graduate Student
Department of Political Science
*The Ohio State University*
154 North Oval Mall
Columbus, Ohio 43210

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


Re: [R] birats example with R2WinBugs

2009-12-20 Thread Uwe Ligges



On 18.12.2009 17:29, M JH wrote:


Hello,

I am trying, and failing, to do the birats example from the WinBugs manual
with R2Winbugs.

I can manage the rats example OK. Also, I can manage birats in WinBugs.

Here is the code I am running, the .bug program, and the error message. Any
help would be gratefully received.

Thank you,
Mike


library(R2WinBUGS)

data = list(x = c(8.0, 15.0, 22.0, 29.0, 36.0), N = 30, T = 5,
Omega = structure(.Data = c(200, 0, 0, 0.2), .Dim = c(2, 2)),   
mean = c(0,0),
prec = structure(.Data = c(1.0E-6, 0, 0, 1.0E-6), .Dim = c(2, 
2)),
Y = structure(
.Data =   c(151, 199, 246, 283, 320,
 145, 199, 249, 293, 
354,
 147, 214, 263, 312, 
328,
 155, 200, 237, 272, 
297,
 135, 188, 230, 280, 
323,
 159, 210, 252, 298, 
331,
 141, 189, 231, 275, 
305,
 159, 201, 248, 297, 
338,
 177, 236, 285, 350, 
376,
 134, 182, 220, 260, 
296,
 160, 208, 261, 313, 
352,
 143, 188, 220, 273, 
314,
 154, 200, 244, 289, 
325,
 171, 221, 270, 326, 
358,
 163, 216, 242, 281, 
312,
 160, 207, 248, 288, 
324,
 142, 187, 234, 280, 
316,
 156, 203, 243, 283, 
317,
 157, 212, 259, 307, 
336,
 152, 203, 246, 286, 
321,
 154, 205, 253, 298, 
334,
 139, 190, 225, 267, 
302,
 146, 191, 229, 272, 
302,
 157, 211, 250, 285, 
323,
 132, 185, 237, 286, 
331,
 160, 207, 257, 303, 
345,
 169, 216, 261, 295, 
333,
 157, 205, 248, 289, 
316,
 137, 180, 219, 258, 
291,
 153, 200, 244, 286, 
324),
.Dim = c(30,5)))

inits- list(mu.beta = c(0,0), tauC = 1,
  beta = structure(
.Data = c(100,6,100,6,100,6,100,6,100,6,
   100,6,100,6,100,6,100,6,100,6,
   100,6,100,6,100,6,100,6,100,6,
   100,6,100,6,100,6,100,6,100,6,
   100,6,100,6,100,6,100,6,100,6,
   100,6,100,6,100,6,100,6,100,6),
.Dim = c(30, 2)),
  R = structure(.Data = c(1,0,0,1), .Dim = c(2, 2)))





Although I do not know why you specify the inits in such an R-unlike 
way, I know what is going wrong here. You could do as well after reading 
?bugs:


inits must be a list of list(s), one list for each chain. You do not 
have a list of lists but a list of the values, i.e. wrap the whole thing 
in another list() and you are fine. That one will contain one list for 
your one chain.


Uwe Ligges



  names(inits)
  inits$R
  is.matrix(inits$beta)
  is.matrix(inits$R)

mhbirats = bugs(data, inits, model.file = birats.bug,

   parameters.to.save = c(beta, R, tauC,  mu.beta),

n.chains = 1, n.iter=1, n.burnin=1000, n.thin=1,

bugs.directory = c:/Program Files/WinBUGS14/,  debug = TRUE)

### birats example from winbugs

model
{
for( i in 1 : N ) {
beta[i , 1:2] ~ dmnorm(mu.beta[], R[ , ])   
for( j in 1 : T ) {
Y[i , j] ~ dnorm(mu[i , j], tauC)   

mu[i , j]- beta[i , 1] + beta[i , 2] * x[j]
 

Re: [R] plotting polynomial regression line

2009-12-20 Thread Kim Jung Hwa
Amit, please provide gp.txt file.

On Sun, Dec 20, 2009 at 1:47 PM, Jason Morgan jwm-r-h...@skepsi.net wrote:

 Hello Amit,

 On 2009.12.20 19:35:09, Amit wrote:
  Dear All,
  I am trying to plot polynomial regression line to a scatterplot. I did
  following so far:
 
  x=c(1:9335)
  y=read.table(gp.txt,header=T,sep=\t)
   length(y$PCC) # y$PCC has values between 1 to 0 in decreasing order
  [1] 9335
   plot(x,y$PCC,col=red) #scatterplot between x and y$PCC
   reg=lm(y$PCC~poly(x,6)) # calculating polynomial fit with degree 6
   abline(reg,col=blue)
  Warning message:
  In abline(reg, col = blue) :
only using the first two of 7regression coefficients
 
  After the above warning a line is drawn in the graph parallel to the
  y-axis. But I was expecting a curve line through the scatterplot.
  Am I doing something wrong? Please help!

 Take a look at ?predict. Briefly, I think this will give you what you
 want:

  reg - lm(y$PCC ~ poly(x,6))
  plot(x, y$PCC, col=red)
  lines(x, predict(reg), col=blue)

 Cheers,
 Jason


 --
 Jason W. Morgan
 Graduate Student
 Department of Political Science
 *The Ohio State University*
 154 North Oval Mall
 Columbus, Ohio 43210

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


[[alternative HTML version deleted]]

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


Re: [R] plotting polynomial regression line

2009-12-20 Thread David Winsemius


On Dec 20, 2009, at 1:35 PM, Amit wrote:


Dear All,
I am trying to plot polynomial regression line to a scatterplot. I did
following so far:


x=c(1:9335)
y=read.table(gp.txt,header=T,sep=\t)
length(y$PCC) # y$PCC has values between 1 to 0 in decreasing order

[1] 9335

plot(x,y$PCC,col=red) #scatterplot between x and y$PCC
reg=lm(y$PCC~poly(x,6)) # calculating polynomial fit with degree 6
abline(reg,col=blue)

Warning message:
In abline(reg, col = blue) :
 only using the first two of 7regression coefficients

After the above warning a line is drawn in the graph parallel to the
y-axis. But I was expecting a curve line through the scatterplot.
Am I doing something wrong? Please help!


abline is designed to draw lines of the form y=a+bx, ... hence the  
name. (And as documented on its help page for regression objects).


An effective method would be with lines and predict:

 plot(cars, main=Stopping Distance versus Speed)
 lines(cars$speed, predict(lm(dist~poly(speed, 6) ,data=cars) ),  
col=red)




Best
Amit

___


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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


Re: [R] read.table: mysterious line omissions

2009-12-20 Thread Jonathan
Thanks everyone!  The problem was definitely with the apostrophe being
interpreted as a single quote.

Jonathan

On Sun, Dec 20, 2009 at 7:49 AM, jim holtman jholt...@gmail.com wrote:

 Most likely an unbalanced quote.  put the following option in the
 read.table:

 quote='', comment.char=''

 On Sat, Dec 19, 2009 at 11:42 PM, Jonathan jonsle...@gmail.com wrote:

 Hello again,
 I am simply trying to import a rectangular table of strings.  The
 table's dimensions are 1990 x 2, yet my read.table() command can only find
 362 of the rows (and they're not the first 362).  I would've taken the
 time
 to figure out how to use scan, readLines, or some other tool that can read
 in character strings, and then parse and input to a table, but that seems
 like overkill, and probably it would be good to understand what's wrong
 with
 my text file.

 The file is here.

 https://regtransfers-sth-se.diino.com/download/jonsleepy/_mydropbox_/finalInput.xls

 The code is here:
 temp - as.matrix(read.table('finalInput.xls', header=FALSE, sep = \t))
 dim(temp) #expect 1990 x 2; but find 362 x 2

 Sorry to require a download (this probably won't make people happy), but
 since my problem is file-specific, the file is needed for troubleshooting.

 I generated it with some grep, gawk commands using Cygwin in a Windows
 environment (though subsequently converted it to Windows format - R loads
 it
 exactly the same way, regardless of whether it's in linux or windows
 format)

 Regards,
 Jonathan

[[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.htmlhttp://www.r-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.




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

 What is the problem that you are trying to solve?


[[alternative HTML version deleted]]

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


[R] How to put text outside an xyplot?

2009-12-20 Thread Marius Hofert
Dear R-users,

I have a plot created with the code below. I tried to put some text to the 
right of the color key. I worked with grid.text and also viewport(), but 
couldn't achieve this. I know this should be simple, but I just couldn't figure 
out how to do it. How does this work?

Cheers,

Marius

library(lattice) 
library(grid)
myvec=1:10
data=data.frame(x=myvec,y=myvec)
mygray=function(l) gray(seq(0.2,0.8,length=l))
colors=level.colors(data[1:10,2],at=do.breaks(c(1,10),10),col.regions=mygray)
colorvec=colors[1:10]
#trellis.device(postscript,color=F,horizontal=F,onefile=F)
xyplot(data[,2]~data[,1],aspect=1,
panel=function(...){
panel.xyplot(...,type=n)
lpoints(data[,1],data[,2],pch=1,col=colorvec)
grid.text(text to the right of the color 
key,1.2,0.5,rot=90)#does not work.
},
xlab=x,ylab=y,

legend=list(right=list(fun=draw.colorkey,args=list(key=list(col=mygray(10),at=1:10
)
#dev.off() 

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

2009-12-20 Thread baptiste auguie
Hi,

Do you want a ternary plot?
http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=34

It's easy to rotate an axis with Grid graphics,

library(grid)
pushViewport(viewport(0.5,0.5, width=0.5, height=unit(3, lines)))
grid.xaxis(at=seq(-0.5,0.5,by=0.1), vp=viewport(x=1, angle=-60))

HTH,

baptiste

2009/12/20 Etienne Stockhausen einohr2...@web.de:
 Hi everybody,
 I'm trying to build a trilineare coordinate system with R. For that, I need
 to rotate an axis. Does anybody know, if it is possible to rotate an axis,
 created with the command axis(), about for instance 60 degrees?

 I'm looking foward  to any ideas and hints and want to wish everybody a
 merry merry christmas.

 Thanks in advance.

 Etienne Stockhausen

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Object of type 'closure' not subsettable

2009-12-20 Thread Muhammad Rahiz

Hi all,

How can I overcome the error object of type 'closure' not subsettable

I ran the following script
seq - paste(seq(1914, 1916, by=1), *.y, sep=.) # make sequence
c - 3 # total number of files
d2 - file # creates dummy file

# Input sequence in loop
for (i in 1:3){
list - list.files(~/ukcp09/txt/x.djf, seq[[i]])
file - lapply(list, read.table)

# Calculations
mean - (Reduce(+, file))/c
d2[[i]] - file[[i]] - mean

Apparently, the following command is the source of the error.

d2[[i]] - file[[i]] - mean

It works OK when I typed into the terminal the following after running 
the script.


 for (j in 1:3) print (file[[j]]-mean)


Thanks.

Muhammad

--
Muhammad Rahiz  |  Doctoral Student in Regional Climate Modeling

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

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

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


Re: [R] Object of type 'closure' not subsettable

2009-12-20 Thread Barry Rowlingson
On Sun, Dec 20, 2009 at 7:40 PM, Muhammad Rahiz
muhammad.ra...@ouce.ox.ac.uk wrote:
 Hi all,

 How can I overcome the error object of type 'closure' not subsettable

 I ran the following script
 seq - paste(seq(1914, 1916, by=1), *.y, sep=.) # make sequence
 c - 3 # total number of files
 d2 - file # creates dummy file

 No it doesn't. It copies the object called 'file' into an object
called 'd2'. What's the object called 'file'? If you've not created
one already, its the 'file' function that R uses to read stuff from
files. So when you do:


 d2[[i]] - file[[i]] - mean

 you are trying to subset from d2 (and from 'file'). If I do this:

  file[[2]]

 I get your error message:

Error in file[[2]] : object of type 'closure' is not subsettable

 So clearly you aren't doing what you think you're doing.

 Some hints:

1. Read a good introduction to R. You are making a number of
fundamental mistakes here.

2. Run each line separately and check what value you get back by printing it.

3. Don't give your objects the same name as R functions (you're using
'seq', 'file', and 'mean'). Although this may work, it will confuse
people later...

Barry

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


Re: [R] Object of type 'closure' not subsettable

2009-12-20 Thread David Winsemius


On Dec 20, 2009, at 2:40 PM, Muhammad Rahiz wrote:


Hi all,

How can I overcome the error object of type 'closure' not  
subsettable


I ran the following script
seq - paste(seq(1914, 1916, by=1), *.y, sep=.) # make sequence
c - 3 # total number of files
d2 - file # creates dummy file

# Input sequence in loop
for (i in 1:3){
list - list.files(~/ukcp09/txt/x.djf, seq[[i]])
file - lapply(list, read.table)

# Calculations
mean - (Reduce(+, file))/c
d2[[i]] - file[[i]] - mean

Apparently, the following command is the source of the error.

d2[[i]] - file[[i]] - mean

It works OK when I typed into the terminal the following after  
running the script.


 for (j in 1:3) print (file[[j]]-mean)


Generally R is able to keep straight what is a vector and what is a  
function but you are using quite a few names for vectors and lists  
which should be reserved (at least in your head) for functions. Here  
is a list of function names to avoid as object names:


c
file
list
seq
mean

Why not try being so ambiguous? ObF: Would you call your dog dog?


--
David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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


Re: [R] Run time error when executing sqlQuery using the 64-bit version of R with 64-bit RODBC package in a Solaris 10 Sparc machine.

2009-12-20 Thread Marc Schwartz

On Dec 19, 2009, at 11:39 AM, Alex Chelminsky wrote:



I have compiled and linked a 64 bit version of R (R 2.9.2) and the
corresponding unix ODBC 64 bit package

The red highlighted text below is the error I'm getting trying to when
invoking a sqlQuery


library(RODBC)
channel - odbcConnect(OraLSH, user, password)
sqlQuery(channel,select sysdate from dual)

Error in .Call(C_RODBCFetchRows, attr(channel, handle_ptr), max,
buffsize,  :
 negative length vectors are not allowed

close(channel)
q()


Any suggestions are greatly appreciated.




Given that you were able to connect to your server successfully, it  
tends to narrow the possible issues.


Try using:

  sqlQuery(channel, select sysdate from dual, rows_at_time = 1)

If you are using RODBC version 1.3-0 or newer, the default for  
rows_at_time is now 100, which has caused some problems with query  
results. Setting it to 1 (the former default value) seems to help.


Also, if you are using Oracle (presumption based upon using OraLSH),  
you might try using 'case = toupper' in the sqlQuery() call as well.


If the above does not help and you are using Oracle and have the  
InstantClient installed, try your queries using that from the CLI. If  
that works, then the underlying Oracle system configuration has been  
set correctly and helps to further isolate the problem to the R/RODBC  
combination. If not, then you have some underlying configuration issue  
to resolve.


BTW, we won't see the 'red highlighted text' here, as the list is  
plain text only, not HTML or RTF.


Last, but not least, R version 2.10.1 is the currently supported  
stable release of R.


HTH,

Marc Schwartz

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


[R] Problems in installing MCMCglmm package

2009-12-20 Thread Sunny Srivastava
Dear R-Helpers,
I am having troubles with installing with MCMCglmm package and I get the
following error with a package Matrix

Warning in library(pkg, character.only = TRUE, logical.return = TRUE,
lib.loc = lib.loc) :
  there is no package called 'Matrix'
Error: package 'Matrix' could not be loaded
Execution halted
ERROR: lazy loading failed for package 'MCMCglmm'

I tried installing the package Matrix - but it was unavailable.

I am not able to understand why am I encountering this error - Any help is
appreciated


Thx,
S.


R version 2.8.1 (2008-12-22)
x86_64-pc-linux-gnu

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

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

other attached packages:
[1] lattice_0.17-26 MASS_7.2-45

loaded via a namespace (and not attached):
[1] grid_2.8.1  tools_2.8.1

[[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] insert a dot to the numbers

2009-12-20 Thread rusers.sh
Hi,
  Anybody can give me some hints on the following problem?
s-c(110,112321)
  I want to insert a dot . after the third number and get the following
results.
110.
112.321

  Thanks a lot.

-- 
-
Jane Chang
Queen's

[[alternative HTML version deleted]]

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


Re: [R] insert a dot to the numbers

2009-12-20 Thread Marc Schwartz

On Dec 20, 2009, at 3:50 PM, rusers.sh wrote:


Hi,
 Anybody can give me some hints on the following problem?
s-c(110,112321)
 I want to insert a dot . after the third number and get the  
following

results.
110.
112.321

 Thanks a lot.




s - c(110, 112321)

 s / (10 ^ (nchar(s) - 3))
[1] 110. 112.3210


See ?nchar
 nchar(s)
[1] 7 6


HTH,

Marc Schwartz

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


Re: [R] simple main effect.

2009-12-20 Thread Richard M. Heiberger

For simple effects in the presence of interaction there are several
options included in the HH package.  If you don't already have the HH
package, you can get it with
  install.packages(HH)

Graphically, you can plot them with the function
  interaction2wt(..., simple=TRUE)
See the examples in
  ?HH::interaction2wt

For tests on the simple effect of A conditional on a level of B, you
can use the model formula B/A and look at the partition of the sums of
squares using the split= argument
  summary(mymodel.aov, split=put your details here)

For multiple comparisons from designs with Error() terms, you need to
specify the same sums of squares with an equivalent formula that doesn't 
use the Error() function.  See the maiz example in

  ?HH::MMC
Read the example all the way to the end of the help file.

Rich

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


Re: [R] forecasting

2009-12-20 Thread DispersionMap

Very good patrick, lol.


does anyone have any useful ideas


Patrick Burns wrote:
 
 DispersionMap wrote:
 
 What about validating forecasting results. I have 5 years of data and
 have
 been forecasting the following three years i.e. 2010 to 2012.
 
 How can i check my forecast.
 
 Why types of tests are out there that can be implemented in R??
 
 isbn 9780553213515
 
 Sorry, couldn't resist,
 
 Pat
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
View this message in context: 
http://n4.nabble.com/forecasting-tp974326p975920.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] insert a dot to the numbers

2009-12-20 Thread Ted Harding
On 20-Dec-09 21:50:58, rusers.sh wrote:
 Hi,
   Anybody can give me some hints on the following problem?
 s-c(110,112321)
   I want to insert a dot . after the third number and get the
 following
 results.
 110.
 112.321
 
   Thanks a lot.
 -
 Jane Chang
 Queen's

  s-c(110,112321)
# [A]
  s/(10^(floor(log10(s))-2))
  # [1] 110. 112.3210

# [B]
  sub(([0-9]{3}),\\1.,as.character(s))
  [1] 110. 112.321

# [C]
  as.double(sub(([0-9]{3}),\\1.,as.character(s)))
  # [1] 110. 112.3210

Not sure exactly what you are asking; but these should give some ideas.
Ted.


E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk
Fax-to-email: +44 (0)870 094 0861
Date: 20-Dec-09   Time: 22:23:26
-- XFMail --

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


[R] Object is not a matrix Error

2009-12-20 Thread John Paul Telthorst
I'm trying to follow this guide here:
http://www.ats.ucla.edu/stat/r/modules/dummy_vars.htm

In which I'm creating categorical variables using the factor function.

I am able to go through the example listed above and have everything work,
however, when I try to input my own numbers, I get an error.  I input the
following:


 hits = read.csv(file.choose())

 attach(hits)

 day.f - factor(day)

 lm(write ~ (day.f))

lm(write ~ (day.f))

Error in model.frame.default(formula = write ~ (day.f), drop.unused.levels =
 TRUE) :
   object is not a matrix


So I import hits = read.csv(file.choose()) a .csv file, which has the
columns visits and day where visits is the number of hits to a
website, and day is a number 1-7, for example 1 corresponds to Sunday and
7 corresponds to Saturday.  I understand that the day variable needs to be a
categorical variable, and I'm trying to use the factor function to do this.
 I would like to be able to run a regression that will correlate the day
with the number of hits.

Any help would be much appreciated.

[[alternative HTML version deleted]]

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


Re: [R] Object is not a matrix Error

2009-12-20 Thread jim holtman
Where is the object 'write'?  SHouldn't you be using:

 lm(visits ~ (day.f))


On Sun, Dec 20, 2009 at 5:59 PM, John Paul Telthorst
jpteltho...@gmail.comwrote:

 I'm trying to follow this guide here:
 http://www.ats.ucla.edu/stat/r/modules/dummy_vars.htm

 In which I'm creating categorical variables using the factor function.

 I am able to go through the example listed above and have everything work,
 however, when I try to input my own numbers, I get an error.  I input the
 following:


  hits = read.csv(file.choose())

  attach(hits)

  day.f - factor(day)

  lm(write ~ (day.f))

 lm(write ~ (day.f))

 Error in model.frame.default(formula = write ~ (day.f), drop.unused.levels
 =
  TRUE) :
object is not a matrix
 

 So I import hits = read.csv(file.choose()) a .csv file, which has the
 columns visits and day where visits is the number of hits to a
 website, and day is a number 1-7, for example 1 corresponds to Sunday and
 7 corresponds to Saturday.  I understand that the day variable needs to be
 a
 categorical variable, and I'm trying to use the factor function to do this.
  I would like to be able to run a regression that will correlate the day
 with the number of hits.

 Any help would be much appreciated.

[[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.htmlhttp://www.r-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.




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

What is the problem that you are trying to solve?

[[alternative HTML version deleted]]

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


Re: [R] Object is not a matrix Error

2009-12-20 Thread Joe King
When you imported did you not import the headers?

Joe King
206-913-2912
j...@joepking.com
Never throughout history has a man who lived a life of ease left a name
worth remembering. --Theodore Roosevelt

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of jim holtman
Sent: Sunday, December 20, 2009 3:11 PM
To: John Paul Telthorst
Cc: r-help@r-project.org
Subject: Re: [R] Object is not a matrix Error

Where is the object 'write'?  SHouldn't you be using:

 lm(visits ~ (day.f))


On Sun, Dec 20, 2009 at 5:59 PM, John Paul Telthorst
jpteltho...@gmail.comwrote:

 I'm trying to follow this guide here:
 http://www.ats.ucla.edu/stat/r/modules/dummy_vars.htm

 In which I'm creating categorical variables using the factor function.

 I am able to go through the example listed above and have everything work,
 however, when I try to input my own numbers, I get an error.  I input the
 following:


  hits = read.csv(file.choose())

  attach(hits)

  day.f - factor(day)

  lm(write ~ (day.f))

 lm(write ~ (day.f))

 Error in model.frame.default(formula = write ~ (day.f), drop.unused.levels
 =
  TRUE) :
object is not a matrix
 

 So I import hits = read.csv(file.choose()) a .csv file, which has the
 columns visits and day where visits is the number of hits to a
 website, and day is a number 1-7, for example 1 corresponds to Sunday
and
 7 corresponds to Saturday.  I understand that the day variable needs to be
 a
 categorical variable, and I'm trying to use the factor function to do
this.
  I would like to be able to run a regression that will correlate the day
 with the number of hits.

 Any help would be much appreciated.

[[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.htmlhttp://www.r-project.org/posting
-guide.html
 and provide commented, minimal, self-contained, reproducible code.




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

What is the problem that you are trying to solve?

[[alternative HTML version deleted]]

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

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] CRAN (and crantastic) updates this week

2009-12-20 Thread Crantastic
CRAN (and crantastic) updates this week

New packages



Updated packages





New reviews
---

* deal, by newfuntek
  http://crantastic.org/reviews/45

* bnlearn, by newfuntek
  http://crantastic.org/reviews/44

* gRain, by newfuntek
  http://crantastic.org/reviews/43



This email provided as a service for the R community by
http://crantastic.org.

Like it?  Hate it?  Please let us know: crana...@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] insert a dot to the numbers

2009-12-20 Thread Henrique Dallazuanna
Try this also:

sapply(s, function(x)format(x, big.interval = nchar(x) - 3, big.mark = .))

On Sun, Dec 20, 2009 at 7:50 PM, rusers.sh rusers...@gmail.com wrote:
 Hi,
  Anybody can give me some hints on the following problem?
 s-c(110,112321)
  I want to insert a dot . after the third number and get the following
 results.
 110.
 112.321

  Thanks a lot.

 --
 -
 Jane Chang
 Queen's

        [[alternative HTML version deleted]]

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




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

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


[R] Limit on number of times Realloc can be called?

2009-12-20 Thread Adam Waldemar Kowalewski
Hello,

I've been writing a program in C that will be called by R. I seem to have
stumbled upon an odd error that seems to suggest there is a limit on the
number of times Realloc (the R version as defined in the manual
R-extenstions not the C version realloc) when I try to use the
following program:

#include R.h
#include Rinternals.h

SEXP test_mem_alloc(SEXP z) {
double *t = Calloc(sizeof(double), double);
*t = 2;
SEXP end_product;
int i = 0;
for(i=1; i  20; i++) {
t = Realloc(t, sizeof(t) + sizeof(double), double);
t[i] = i;
}
PROTECT(end_product = allocVector(REALSXP,6));
for(i = 0; i  20; i++) {
REAL(end_product)[i] = t[i];
}
UNPROTECT(1);
Free(t);
return end_product;
}

I call it from R using the following script:

z - 1

test_mem_alloc - function(z) {
if(!(is.loaded(test_mem_alloc_v6))) dyn.load(test_mem_alloc_v6.dll)
out - .Call(test_mem_alloc,
as.double(z))
return(out)
dyn.unload(test_mem_alloc_v6.dll)
}

Basically I get the following error messages:

First:

Runtime Error!

Program: C:\Program Files\R\R-2.10.0\bin\Rgui.exe

This application has requested the Runtime to terminate it in an unusual
way. Please contact the application's support team for more information.

The second error message is:

The instruction at 0x002c. The memory could not be read.

Now, if change the number of times the program goes through the for loop
from 20 to say 6, and hence calls Realloc fewer times, then the program
runs without any problems. It does not seem to have anything to do with
the size of the memory being allocated as I changed the size of the total
memory being allocated with a for loop with only 6 iterations to
something that is substantially larger than the memory being allocated in
the for loop when calling Realloc twenty times and the program ran
successfully. Has anyone else come across this problem or knows about some
sort of limitation on using Realloc that is not specified in the R
documentation?

Any help would be greatly appreciated.

Yours sincerely

Adam Kowalewski

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


Re: [R] Limit on number of times Realloc can be called?

2009-12-20 Thread Duncan Murdoch

Adam Waldemar Kowalewski wrote:

Hello,

I've been writing a program in C that will be called by R. I seem to have
stumbled upon an odd error that seems to suggest there is a limit on the
number of times Realloc (the R version as defined in the manual
R-extenstions not the C version realloc) when I try to use the
following program:

#include R.h
#include Rinternals.h

SEXP test_mem_alloc(SEXP z) {
double *t = Calloc(sizeof(double), double);
*t = 2;
SEXP end_product;
int i = 0;
for(i=1; i  20; i++) {
t = Realloc(t, sizeof(t) + sizeof(double), double);
  


The second argument to Realloc is supposed to be the number of elements 
to allocate.  sizeof(t) is 4 or 8 (32 bit or 64 bit), sizeof double is 
8, so you always allocate 12 or 16 elements.  Then in the next line you 
write out of bounds.


Duncan Murdoch


t[i] = i;
}
PROTECT(end_product = allocVector(REALSXP,6));
for(i = 0; i  20; i++) {
REAL(end_product)[i] = t[i];
}
UNPROTECT(1);
Free(t);
return end_product;
}

I call it from R using the following script:

z - 1

test_mem_alloc - function(z) {
if(!(is.loaded(test_mem_alloc_v6))) dyn.load(test_mem_alloc_v6.dll)
out - .Call(test_mem_alloc,
as.double(z))
return(out)
dyn.unload(test_mem_alloc_v6.dll)
}

Basically I get the following error messages:

First:

Runtime Error!

Program: C:\Program Files\R\R-2.10.0\bin\Rgui.exe

This application has requested the Runtime to terminate it in an unusual
way. Please contact the application's support team for more information.

The second error message is:

The instruction at 0x002c. The memory could not be read.

Now, if change the number of times the program goes through the for loop
from 20 to say 6, and hence calls Realloc fewer times, then the program
runs without any problems. It does not seem to have anything to do with
the size of the memory being allocated as I changed the size of the total
memory being allocated with a for loop with only 6 iterations to
something that is substantially larger than the memory being allocated in
the for loop when calling Realloc twenty times and the program ran
successfully. Has anyone else come across this problem or knows about some
sort of limitation on using Realloc that is not specified in the R
documentation?

Any help would be greatly appreciated.

Yours sincerely

Adam Kowalewski

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Can you delete me from the list I don't want to receive the emails from the forum anymore, thank you!

2009-12-20 Thread lippel anna



 Date: Mon, 21 Dec 2009 12:33:26 +1100
 From: a.kowalew...@ugrad.unimelb.edu.au
 To: r-help@r-project.org
 Subject: [R] Limit on number of times Realloc can be called?
 
 Hello,
 
 I've been writing a program in C that will be called by R. I seem to have
 stumbled upon an odd error that seems to suggest there is a limit on the
 number of times Realloc (the R version as defined in the manual
 R-extenstions not the C version realloc) when I try to use the
 following program:
 
 #include R.h
 #include Rinternals.h
 
 SEXP test_mem_alloc(SEXP z) {
   double *t = Calloc(sizeof(double), double);
   *t = 2;
   SEXP end_product;
   int i = 0;
   for(i=1; i  20; i++) {
   t = Realloc(t, sizeof(t) + sizeof(double), double);
   t[i] = i;
   }
   PROTECT(end_product = allocVector(REALSXP,6));
   for(i = 0; i  20; i++) {
   REAL(end_product)[i] = t[i];
   }
   UNPROTECT(1);
   Free(t);
   return end_product;
 }
 
 I call it from R using the following script:
 
 z - 1
 
 test_mem_alloc - function(z) {
   if(!(is.loaded(test_mem_alloc_v6))) dyn.load(test_mem_alloc_v6.dll)
   out - .Call(test_mem_alloc,
   as.double(z))
   return(out)
   dyn.unload(test_mem_alloc_v6.dll)
 }
 
 Basically I get the following error messages:
 
 First:
 
 Runtime Error!
 
 Program: C:\Program Files\R\R-2.10.0\bin\Rgui.exe
 
 This application has requested the Runtime to terminate it in an unusual
 way. Please contact the application's support team for more information.
 
 The second error message is:
 
 The instruction at 0x002c. The memory could not be read.
 
 Now, if change the number of times the program goes through the for loop
 from 20 to say 6, and hence calls Realloc fewer times, then the program
 runs without any problems. It does not seem to have anything to do with
 the size of the memory being allocated as I changed the size of the total
 memory being allocated with a for loop with only 6 iterations to
 something that is substantially larger than the memory being allocated in
 the for loop when calling Realloc twenty times and the program ran
 successfully. Has anyone else come across this problem or knows about some
 sort of limitation on using Realloc that is not specified in the R
 documentation?
 
 Any help would be greatly appreciated.
 
 Yours sincerely
 
 Adam Kowalewski
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
  
_

ail you.

cial-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_3:092
[[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] Can you delete me from the list I don't want to receive the emails from the forum anymore, thank you!

2009-12-20 Thread Gary Miller
A couple of week back someone posted this. It applies to you too:

None of the people reading this at the moment can do this for you. Read the
information on the page where you subscribed.:

https://stat.ethz.ch/mailman/listinfo/r-help

Q: How many psychiatrists does it take to unscrew a light bulb?
A: Only one, but the lightbulb must truly want to become unscrewed.

On Sun, Dec 20, 2009 at 9:00 PM, lippel anna lippelann...@hotmail.comwrote:




  Date: Mon, 21 Dec 2009 12:33:26 +1100
  From: a.kowalew...@ugrad.unimelb.edu.au
  To: r-help@r-project.org
  Subject: [R] Limit on number of times Realloc can be called?
 
  Hello,
 
  I've been writing a program in C that will be called by R. I seem to have
  stumbled upon an odd error that seems to suggest there is a limit on the
  number of times Realloc (the R version as defined in the manual
  R-extenstions not the C version realloc) when I try to use the
  following program:
 
  #include R.h
  #include Rinternals.h
 
  SEXP test_mem_alloc(SEXP z) {
double *t = Calloc(sizeof(double), double);
*t = 2;
SEXP end_product;
int i = 0;
for(i=1; i  20; i++) {
t = Realloc(t, sizeof(t) + sizeof(double), double);
t[i] = i;
}
PROTECT(end_product = allocVector(REALSXP,6));
for(i = 0; i  20; i++) {
REAL(end_product)[i] = t[i];
}
UNPROTECT(1);
Free(t);
return end_product;
  }
 
  I call it from R using the following script:
 
  z - 1
 
  test_mem_alloc - function(z) {
if(!(is.loaded(test_mem_alloc_v6)))
 dyn.load(test_mem_alloc_v6.dll)
out - .Call(test_mem_alloc,
as.double(z))
return(out)
dyn.unload(test_mem_alloc_v6.dll)
  }
 
  Basically I get the following error messages:
 
  First:
 
  Runtime Error!
 
  Program: C:\Program Files\R\R-2.10.0\bin\Rgui.exe
 
  This application has requested the Runtime to terminate it in an unusual
  way. Please contact the application's support team for more information.
 
  The second error message is:
 
  The instruction at 0x002c. The memory could not be read.
 
  Now, if change the number of times the program goes through the for loop
  from 20 to say 6, and hence calls Realloc fewer times, then the program
  runs without any problems. It does not seem to have anything to do with
  the size of the memory being allocated as I changed the size of the total
  memory being allocated with a for loop with only 6 iterations to
  something that is substantially larger than the memory being allocated in
  the for loop when calling Realloc twenty times and the program ran
  successfully. Has anyone else come across this problem or knows about
 some
  sort of limitation on using Realloc that is not specified in the R
  documentation?
 
  Any help would be greatly appreciated.
 
  Yours sincerely
 
  Adam Kowalewski
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.

 _

 ail you.

 cial-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_3:092
[[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.htmlhttp://www.r-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


[[alternative HTML version deleted]]

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


[R] Signif. codes

2009-12-20 Thread John Paul Telthorst
My question is about the Signif. codes and the p-value, specifically, the
output when I run

summary(nameofregression.lm)


So you get this little key:

Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

And on a regression I ran, next to the intercept data, I get '***'

Coefficients:

 Estimate Std. Error t value Pr(|t|)

 (Intercept)  7.956520.59993  13.262   2e-16 ***

 day.f2  -0.043480.84843  -0.0510.959

 day.f3  -0.130430.84843  -0.1540.878

 day.f4  -0.217390.84843  -0.2560.798

 day.f5   0.021740.84843   0.0260.980

 day.f6  -0.152170.84843  -0.1790.858

 day.f7   0.149860.84390   0.1780.859


Does this mean that these numbers have a 0% chance of being wrong?  Is there
a way to change this to the .05 level of significance?

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


[R] Reading multiple Input Files

2009-12-20 Thread Maithili Shiva
Dear R helpers,
 
Suppose I am dealing with no of interest rates at a time and the no of interest 
rates I am selecting for my analysis is random i.e. it can be 2, can be 10 or 
even higher. The R-code I had written (with the guidance of R helpers obviously 
and I am really grateful to all of you) as of now is sort of hard coding when 
it comes to reading interest rates as an input e.g.
 
## INPUT
 
rate_1   = read.csv('rate1_range.csv')
rate_2   = read.csv('rate2_range.csv')
rate_3   = read.csv('rate3_range.csv')
rate_4   = read.csv('rate4_range.csv')
 
prob_1   = read.csv('rate1_probs.csv')
prob_2   = read.csv('rate2_probs.csv')
prob_3   = read.csv('rate3_probs.csv')
prob_4   = read.csv('rate4_probs.csv')

However, since I am not sure how many interest rates I will be dealing with to 
begin with, I have tried to call these inputs using a loop as follows.
 
In my R working directory, following files are there which are to be read as 
input..
 
 
rate1_range.csv
rate2_range.csv
rate3_range.csv
rate4_range.csv
 
rate1_probs.csv
rate2_probs.csv
rate3_probs.csv
rate4_probs.csv
 
My R Code
 
# ___
 
n = no_of_Interest_Rates  # This 'n' will be suppllied separately can be 
anything.
 
n= 4   # As mentioned, this input will be added seperately.
 
for (i in 1:n)
 
 {
 rate_[i]    = read.csv('rate[i]_range.csv')
 prob_[i]   = read.csv('rate[i]_probs.csv')
 }
 
# End of code.
 
However when I excute this code (here, n = 4), I get following error.
 
Error in file(file, r) : cannot open the connection
In addition: Warning message:
In file(file, r) :
  cannot open file 'rate[i]_range.csv': No such file or directory
 
Obviously as usual I have written some stupid code.
 
Please guide
 
Regards
 
Maithili
 
 
 


  The INTERNET now has a personality. YOURS! See your Yahoo! Homepage. 
[[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] Signif. codes

2009-12-20 Thread Joe King
There will always be uncertainty in your estimates so you don't have 0
percent chance of being wrong, but remember that's your intercept, your
regressors are not significant. Although you can say it is less than ..05, I
mean if its significant at .001 (or something like that), that's
less than .05, so its not unethical to say p  .05, but it sounds like you
need to understand the regression model a little better.

Joe King
206-913-2912
j...@joepking.com
Never throughout history has a man who lived a life of ease left a name
worth remembering. --Theodore Roosevelt


-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of John Paul Telthorst
Sent: Sunday, December 20, 2009 10:13 PM
To: r-help@r-project.org
Subject: [R] Signif. codes

My question is about the Signif. codes and the p-value, specifically, the
output when I run

summary(nameofregression.lm)


So you get this little key:

Signif. codes:  0 *** 0.001 ** 0.01 * 0.05 . 0.1   1

And on a regression I ran, next to the intercept data, I get '***'

Coefficients:

 Estimate Std. Error t value Pr(|t|)

 (Intercept)  7.956520.59993  13.262   2e-16 ***

 day.f2  -0.043480.84843  -0.0510.959

 day.f3  -0.130430.84843  -0.1540.878

 day.f4  -0.217390.84843  -0.2560.798

 day.f5   0.021740.84843   0.0260.980

 day.f6  -0.152170.84843  -0.1790.858

 day.f7   0.149860.84390   0.1780.859


Does this mean that these numbers have a 0% chance of being wrong?  Is there
a way to change this to the .05 level of significance?

Thanks,
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] Signif. codes

2009-12-20 Thread Joe King
No, so the probability means that's the probability of getting that data by
chance, so a p-value of .9997 means there is a .9997 probability that the
data could be acquired by chance. This is a very simplistic view and you
should study the regression model better.

 

Joe King

206-913-2912

j...@joepking.com

Never throughout history has a man who lived a life of ease left a name
worth remembering. --Theodore Roosevelt

 

From: John Paul Telthorst [mailto:jpteltho...@gmail.com] 
Sent: Sunday, December 20, 2009 10:36 PM
To: Joe King
Subject: Re: [R] Signif. codes

 

Thanks for the reply, I definitely do need to understand the regression
model better.  I got a p-value of .9997, so that would be  .05?  I guess
I'm confused about the significance part you talked about.

 

John

On Mon, Dec 21, 2009 at 12:27 AM, Joe King j...@joepking.com wrote:

There will always be uncertainty in your estimates so you don't have 0
percent chance of being wrong, but remember that's your intercept, your
regressors are not significant. Although you can say it is less than ..05, I
mean if its significant at .001 (or something like that), that's
less than .05, so its not unethical to say p  .05, but it sounds like you
need to understand the regression model a little better. Joe King
206-913-2912 j...@joepking.com Never throughout history has a man who lived a
life of ease left a name worth remembering. --Theodore Roosevelt
-Original Message- From: r-help-boun...@r-project.org
[mailto:r-help-boun...@r-project.org] On Behalf Of John Paul Telthorst Sent:
Sunday, December 20, 2009 10:13 PM To: r-help@r-project.org Subject: [R]
Signif. codes My question is about the Signif. codes and the p-value,
specifically, the output when I run summary(nameofregression.lm) So you get
this little key: Signif. codes:  0   0.001   0.01   0.05   0.1  And on a
regression I ran, next to the intercept data, I get '***' Coefficients: 
Estimate Std. Error t value Pr(|t|)  (Intercept)  7.956520.59993
13.262   2e-16 ***  day.f2  -0.043480.84843  -0.0510.959 
day.f3  -0.130430.84843  -0.1540.878  day.f4  -0.21739
0.84843  -0.2560.798  day.f5   0.021740.84843   0.0260.980
 day.f6  -0.152170.84843  -0.1790.858  day.f7   0.14986
0.84390   0.1780.859 Does this mean that these numbers have a 0% chance
of being wrong?  Is there a way to change this to the .05 level of
significance? Thanks, 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. 




-- 
John Telthorst, MHRIR
University of Illinois Alumnus


[[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] Hello all, How can I get corss-validation MSE of SVM in e1071?

2009-12-20 Thread bbslover

Hello, Max
  The caret package is so good, I am learning it, but one problem is that 
nearZeroVar function can be used to identify near zero–variance variables and 
it only identify, how can I remove those variables that were identify, because 
I have many zero- or near zero- ones, it is not realistic to removel it by 
hand, can this function can identify and removel those ones automatically?
 
looking for your reply.
 
kevin



在2009-12-19,Max Kuhn [via R] ml-node+975038-1351220...@n4.nabble.com 
写道: -原始邮件-
发件人:Max Kuhn [via R] ml-node+975038-1351220...@n4.nabble.com
发送时间:2009年12月19日 星期六
收件人:bbslover dlu...@yeah.net
主题:Re: [R] Hello all, How can I get corss-validation MSE of SVM in e1071?

You can get this using the caret package. There are a few package 
vignettes that come with the package and a JSS article 

 http://www.jstatsoft.org/v28/i05/paper

about the package. 

Max 

On Fri, Dec 18, 2009 at 12:26 PM, bbslover [hidden email] wrote: 

 
 as known, svm need tune some parameters like  cost,gamma and epsilon to get 
 better performance,but one question appear, how can i monitor the 
 performance . generally speaking ,we chose the cross-validation MSE in the 
 training set, but It seems svm can not return the cross-validation MSE 
 value, we just get it from summary model.svm, if I write a loop, have no 
 idear call the cros-validate MSE, and no way to monitor this performance 
 ,how can I do? 
 
 
 -- 
 View this message in 
 context:http://n4.nabble.com/Hello-all-How-can-I-get-corss-validation-MSE-of-SVM-in-e1071-tp974942p974942.html
 Sent from the R help mailing list archive at Nabble.com. 
 
 __ 
[hidden email]mailing list 
https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code. 
 



-- 

Max 

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



View message 
@http://n4.nabble.com/Hello-all-How-can-I-get-corss-validation-MSE-of-SVM-in-e1071-tp974942p975038.html
To unsubscribe from Hello all, How can I get corss-validation MSE of SVM in 
e1071?,click here. 


-- 
View this message in context: 
http://n4.nabble.com/Hello-all-How-can-I-get-corss-validation-MSE-of-SVM-in-e1071-tp974942p975955.html
Sent from the R help mailing list archive at Nabble.com.

[[alternative HTML version deleted]]

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


[R] what is criterion of removing independence?

2009-12-20 Thread bbslover

Hello, all
I have a lot of independents and one dependent, finally, I want to build
one model using them, and predict the new samples value, that is regression.

   before it, I must remove some independents according to  some criterion: 
1. constant values independent. 2. variant near zero. 3. percentage of zero
values  what?? 4. have other critorion?

for 3. and 4. 

3.  I have no idea,  generally sepeaking, the corresponding independent with
what is percentage of zero values should be removed (20% or 50% or others,
have paper support?).

4.  statistical, have any critorions that are used to removed independent? 
give me a hand.

Actually, my questions is about feature selections, it is so complex, I hope
any friends can give me a guidance.

how can I leave those independent which is good to correlate to
dependent.(i.e. high correlation coefficent R and small predictive error
etc.). And removel bad independents.

thank  you!
-- 
View this message in context: 
http://n4.nabble.com/what-is-criterion-of-removing-independence-tp975987p975987.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.