Re: [R] outputing text colors

2010-03-19 Thread Jim Lemon

On 03/19/2010 12:37 PM, rtist wrote:


Hi all,

I was wondering if there is a way to output text tables with the color of
the text corresponding to a condition.

More specifically, Im outputting an time series table and want the console
colors to be green0 and red0.
This is very easy to do in excel using conditional formatting. Any ideas on
how to do it here?


Hi rtist,
If you want the whole table to be displayed in a color, you could do 
something like:


par(fg=ifelse(something  0,green,red))

before you display the table. I am assuming that you want this on a 
graphics device, not the console in which R is running.


Jim

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


Re: [R] Odp: language!!!

2010-03-19 Thread Petr PIKAL
Hi

I am not definitely expert in locales. It is a relict from time I worked 
with W95/98 where were some problems with locale setting and/or graphing. 
I would try just before reading in a file to change locale setting by

?Sys.setlocale

 Sys.getlocale()
[1] LC_COLLATE=Czech_Czech Republic.1250;LC_CTYPE=Czech_Czech 
Republic.1250;LC_MONETARY=Czech_Czech 
Republic.1250;LC_NUMERIC=C;LC_TIME=Czech_Czech Republic.1250
 Sys.setlocale(LC_ALL, Hebrew)
[1] 
LC_COLLATE=Hebrew_Israel.1255;LC_CTYPE=Hebrew_Israel.1255;LC_MONETARY=Hebrew_Israel.1255;LC_NUMERIC=C;LC_TIME=Hebrew_Israel.1255
 Sys.getlocale()
[1] 
LC_COLLATE=Hebrew_Israel.1255;LC_CTYPE=Hebrew_Israel.1255;LC_MONETARY=Hebrew_Israel.1255;LC_NUMERIC=C;LC_TIME=Hebrew_Israel.1255

and then try to read in the data.

Regards
Petr



Tal Galili tal.gal...@gmail.com napsal dne 18.03.2010 16:23:25:

 Hello Petr,
 
 Since you seem to understand about locals, maybe you could (and will be 
 willing) to help me.
 
 I wish to read in a simple file in Hebrew. It has just two lines:
 שלוםרבשובך
 ציפורהנחמדת
 
 But when I use:
 read.table(c:\\temp.txt)
 I get:
V1
 1  ùìåíøáùåáê
 2 öéôåøäðçîãú
 
 My output for:
 l10n_info()
 Is:
 $MBCS
 [1] FALSE
 
 $`UTF-8`
 [1] FALSE
 
 $`Latin-1`
 [1] TRUE
 
 $codepage
 [1] 1252
 And for:
 Sys.getlocale()
 
 Is:
 [1] LC_COLLATE=English_United States.1252;LC_CTYPE=English_United 
States.
 1252;LC_MONETARY=English_United States.
 1252;LC_NUMERIC=C;LC_TIME=English_United States.1252
 
 Can you suggest to me what to try and change to allow me to load the 
file correctly ?
 
 Thanks!
 
 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)
 
--
 
 
 

 2010/3/18 Petr PIKAL petr.pi...@precheza.cz
 Hi
 
 r-help-boun...@r-project.org napsal dne 18.03.2010 11:16:26:
 
 
  Hi,
 
 
 
  there´s something that really bothers me about R and after hours and
 hours of
  internet research, I´m still stuck with the same problem: I installed 
R
 and it
  is in Spanish, as the system on my work. I would really like it in
 English and
  there seems to be no way to change that!?! I´m doing an abroad
 internship, so
  my Spanish is far from perfect and my tutorial is in English.
 
 
 
  Is there any way that I´m not aware of to change the language
 environment of R?

 Maybe
 
 ?Sys.getlocale
 
 Sys.setlocale(LC_ALL, Czech) # for Czech locale
 
 Regards
 Petr
 
 
 
 
 
  Thanks a lot!
 
  Katharina
 
  _
  [[elided Hotmail spam]]
 
 [[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Please Post Planned Contrasts Example in lme {nlme}

2010-03-19 Thread Dieter Menne


Tobias Verbeke-2 wrote:
 
 I would have a look at the multcomp package which allows for
 defining contrasts in a very convenient way and can deal a.o.
 with lme (from nlme) and mer (from lme4) objects.
 
 

It's correct, but there is no example in the docs of glht for lmer, but
there is one in the vignette. Also have a look at Nicholas Levin-Koh's
elegant misuse of contrast/lm (reproduced below, typo corrected)

#-
#http://markmail.org/message/62knhcfupzyt2p6r
library(contrast) 
library(multcomp) 
library(mlmRev)  # for data
library(lme4) 
data(egsingle)

fm1 - lmer(math~year*size+female+(1|childid)+(1|schoolid), egsingle)
## Main effects to get contrast matrix, there is no method for lme4 objects
fm2 - lm(math~year*size+female, data=egsingle)

cc-contrast(fm2,
 a=list(year=c(.5,1.5,2.5),size=380, female=Male), 
 b=list(year=c(.5,1.5,2.5),size=800, female=Male))
 ## Plug in the contrast matrix from contrast, multcomp will use the
variance covariance matrix
summary(glht(fm1, linfct = cc$X))



-- 
View this message in context: 
http://n4.nabble.com/Please-Post-Planned-Contrasts-Example-in-lme-nlme-tp1598717p1599031.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] Odp: language!!!

2010-03-19 Thread Tal Galili
It worked !

Thank you very much Petr!

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 Fri, Mar 19, 2010 at 9:32 AM, Petr PIKAL petr.pi...@precheza.cz wrote:

 Hi

 I am not definitely expert in locales. It is a relict from time I worked
 with W95/98 where were some problems with locale setting and/or graphing.
 I would try just before reading in a file to change locale setting by

 ?Sys.setlocale

  Sys.getlocale()
 [1] LC_COLLATE=Czech_Czech Republic.1250;LC_CTYPE=Czech_Czech
 Republic.1250;LC_MONETARY=Czech_Czech
 Republic.1250;LC_NUMERIC=C;LC_TIME=Czech_Czech Republic.1250
  Sys.setlocale(LC_ALL, Hebrew)
 [1]

 LC_COLLATE=Hebrew_Israel.1255;LC_CTYPE=Hebrew_Israel.1255;LC_MONETARY=Hebrew_Israel.1255;LC_NUMERIC=C;LC_TIME=Hebrew_Israel.1255
  Sys.getlocale()
 [1]

 LC_COLLATE=Hebrew_Israel.1255;LC_CTYPE=Hebrew_Israel.1255;LC_MONETARY=Hebrew_Israel.1255;LC_NUMERIC=C;LC_TIME=Hebrew_Israel.1255

 and then try to read in the data.

 Regards
 Petr


 
 Tal Galili tal.gal...@gmail.com napsal dne 18.03.2010 16:23:25:

  Hello Petr,
 
  Since you seem to understand about locals, maybe you could (and will be
  willing) to help me.
 
  I wish to read in a simple file in Hebrew. It has just two lines:
  שלוםרבשובך
  ציפורהנחמדת
 
  But when I use:
  read.table(c:\\temp.txt)
  I get:
 V1
  1  ùìåíøáùåáê
  2 öéôåøäðçîãú
 
  My output for:
  l10n_info()
  Is:
  $MBCS
  [1] FALSE
 
  $`UTF-8`
  [1] FALSE
 
  $`Latin-1`
  [1] TRUE
 
  $codepage
  [1] 1252
  And for:
  Sys.getlocale()
 
  Is:
  [1] LC_COLLATE=English_United States.1252;LC_CTYPE=English_United
 States.
  1252;LC_MONETARY=English_United States.
  1252;LC_NUMERIC=C;LC_TIME=English_United States.1252
 
  Can you suggest to me what to try and change to allow me to load the
 file correctly ?
 
  Thanks!
 
  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)
 

 --
 
 
 

  2010/3/18 Petr PIKAL petr.pi...@precheza.cz
  Hi
 
  r-help-boun...@r-project.org napsal dne 18.03.2010 11:16:26:
 
  
   Hi,
  
  
  
   there´s something that really bothers me about R and after hours and
  hours of
   internet research, I´m still stuck with the same problem: I installed
 R
  and it
   is in Spanish, as the system on my work. I would really like it in
  English and
   there seems to be no way to change that!?! I´m doing an abroad
  internship, so
   my Spanish is far from perfect and my tutorial is in English.
  
  
  
   Is there any way that I´m not aware of to change the language
  environment of R?

  Maybe
 
  ?Sys.getlocale
 
  Sys.setlocale(LC_ALL, Czech) # for Czech locale
 
  Regards
  Petr
 
 
  
  
  
   Thanks a lot!
  
   Katharina
  
   _
   [[elided Hotmail spam]]
  
  [[alternative HTML version deleted]]
  
   __
   R-help@r-project.org mailing list
   https://stat.ethz.ch/mailman/listinfo/r-help
   PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.html
   and provide commented, minimal, self-contained, reproducible code.
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/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] Creating Rcpp RcppDatetime from string with millisecond

2010-03-19 Thread Romain Francois

Hello,

Rcpp has a dedicated mailing list where such questions are appropriate.
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

Please augment your email with some code examples of what you tried and 
repost on Rcpp-devel.


Romain


Le 19/03/10 00:45, R_help Help a écrit :


Hi,

I was trying to generate RcppDatetime from a string. The main problem
for me is that my string contains millisecond. I saw that RcppDatetime
takes in double of seconds since epoch. I try to generate a double
using boost but has no success. I'm wondering if you have any sample
snippet?

The string looks like:

2010-03-18 15:50:51.232

Secondly, what time zone RcppDatetime is based on? Is it local machine
time zone? And if I have a need to convert time zone, is there any
tool at hand I can use? Or I have to resort to something like boost
again? Thank you so much in advance.

Rob



--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://tr.im/OIXN : raster images and RImageJ
|- http://tr.im/OcQe : Rcpp 0.7.7
`- http://tr.im/O1wO : highlight 0.1-5

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


Re: [R] Odp: language!!!

2010-03-19 Thread Petr PIKAL
Hi

Thanks, I am surprised, as I tried it after Bill's post and it did not 
work on my machine W2000, So probably the success or failure is system 
specific.

Regards
Petr

Tal Galili tal.gal...@gmail.com napsal dne 19.03.2010 08:43:11:

 It worked !
 
 Thank you very much Petr!
 
 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 Fri, Mar 19, 2010 at 9:32 AM, Petr PIKAL petr.pi...@precheza.cz 
wrote:
 Hi
 
 I am not definitely expert in locales. It is a relict from time I worked
 with W95/98 where were some problems with locale setting and/or 
graphing.
 I would try just before reading in a file to change locale setting by
 
 ?Sys.setlocale
 
  Sys.getlocale()
 [1] LC_COLLATE=Czech_Czech Republic.1250;LC_CTYPE=Czech_Czech
 Republic.1250;LC_MONETARY=Czech_Czech
 Republic.1250;LC_NUMERIC=C;LC_TIME=Czech_Czech Republic.1250
  Sys.setlocale(LC_ALL, Hebrew)
 [1]
 LC_COLLATE=Hebrew_Israel.1255;LC_CTYPE=Hebrew_Israel.
 
1255;LC_MONETARY=Hebrew_Israel.1255;LC_NUMERIC=C;LC_TIME=Hebrew_Israel.1255
  Sys.getlocale()
 [1]
 LC_COLLATE=Hebrew_Israel.1255;LC_CTYPE=Hebrew_Israel.
 
1255;LC_MONETARY=Hebrew_Israel.1255;LC_NUMERIC=C;LC_TIME=Hebrew_Israel.1255
 
 and then try to read in the data.
 
 Regards
 Petr
 
 
 
 Tal Galili tal.gal...@gmail.com napsal dne 18.03.2010 16:23:25:
 
  Hello Petr,
 
  Since you seem to understand about locals, maybe you could (and will 
be
  willing) to help me.
 
  I wish to read in a simple file in Hebrew. It has just two lines:
  שלוםרבשובך
  ציפורהנחמדת
 
  But when I use:
  read.table(c:\\temp.txt)
  I get:
 V1
  1  ùìåíøáùåáê
  2 öéôåøäðçîãú
 
  My output for:
  l10n_info()
  Is:
  $MBCS
  [1] FALSE
 
  $`UTF-8`
  [1] FALSE
 
  $`Latin-1`
  [1] TRUE
 
  $codepage
  [1] 1252
  And for:
  Sys.getlocale()
 
  Is:
  [1] LC_COLLATE=English_United States.1252;LC_CTYPE=English_United
 States.
  1252;LC_MONETARY=English_United States.
  1252;LC_NUMERIC=C;LC_TIME=English_United States.1252
 
  Can you suggest to me what to try and change to allow me to load the
 file correctly ?
 
  Thanks!
 
  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)
 
 
--
 
 
 
 
  2010/3/18 Petr PIKAL petr.pi...@precheza.cz
  Hi
 
  r-help-boun...@r-project.org napsal dne 18.03.2010 11:16:26:
 
  
   Hi,
  
  
  
   there´s something that really bothers me about R and after hours and
  hours of
   internet research, I´m still stuck with the same problem: I 
installed
 R
  and it
   is in Spanish, as the system on my work. I would really like it in
  English and
   there seems to be no way to change that!?! I´m doing an abroad
  internship, so
   my Spanish is far from perfect and my tutorial is in English.
  
  
  
   Is there any way that I´m not aware of to change the language
  environment of R?
 
  Maybe
 
  ?Sys.getlocale
 
  Sys.setlocale(LC_ALL, Czech) # for Czech locale
 
  Regards
  Petr
 
 
  
  
  
   Thanks a lot!
  
   Katharina
  
   _
   [[elided Hotmail spam]]
  
  [[alternative HTML version deleted]]
  
   __
   R-help@r-project.org mailing list
   https://stat.ethz.ch/mailman/listinfo/r-help
   PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.html
   and provide commented, minimal, self-contained, reproducible code.
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/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] Odp: language!!!

2010-03-19 Thread Tal Galili
Hi Petr,

Please try:

Sys.setlocale(LC_ALL, Hebrew)
# And
a- read.table(http://www.talgalili.com/files/aa.txt,encoding=UTF-8;
,check.names=FALSE, header = T, sep = \t)   # Notice the use of encoding
a


And let me know if that works...


The only question I have left is how can you set
Sys.setlocale(LC_ALL, Hebrew)
As the default of R when it is being loaded.


Thanks again,

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 Fri, Mar 19, 2010 at 9:52 AM, Petr PIKAL petr.pi...@precheza.cz wrote:

 Hi

 Thanks, I am surprised, as I tried it after Bill's post and it did not
 work on my machine W2000, So probably the success or failure is system
 specific.

 Regards
 Petr

 Tal Galili tal.gal...@gmail.com napsal dne 19.03.2010 08:43:11:

  It worked !
 
  Thank you very much Petr!
 
  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 Fri, Mar 19, 2010 at 9:32 AM, Petr PIKAL petr.pi...@precheza.cz
 wrote:
  Hi
 
  I am not definitely expert in locales. It is a relict from time I worked
  with W95/98 where were some problems with locale setting and/or
 graphing.
  I would try just before reading in a file to change locale setting by
 
  ?Sys.setlocale
 
   Sys.getlocale()
  [1] LC_COLLATE=Czech_Czech Republic.1250;LC_CTYPE=Czech_Czech
  Republic.1250;LC_MONETARY=Czech_Czech
  Republic.1250;LC_NUMERIC=C;LC_TIME=Czech_Czech Republic.1250
   Sys.setlocale(LC_ALL, Hebrew)
  [1]
  LC_COLLATE=Hebrew_Israel.1255;LC_CTYPE=Hebrew_Israel.
 

 1255;LC_MONETARY=Hebrew_Israel.1255;LC_NUMERIC=C;LC_TIME=Hebrew_Israel.1255
   Sys.getlocale()
  [1]
  LC_COLLATE=Hebrew_Israel.1255;LC_CTYPE=Hebrew_Israel.
 

 1255;LC_MONETARY=Hebrew_Israel.1255;LC_NUMERIC=C;LC_TIME=Hebrew_Israel.1255
 
  and then try to read in the data.
 
  Regards
  Petr
 
 
  
  Tal Galili tal.gal...@gmail.com napsal dne 18.03.2010 16:23:25:
 
   Hello Petr,
  
   Since you seem to understand about locals, maybe you could (and will
 be
   willing) to help me.
  
   I wish to read in a simple file in Hebrew. It has just two lines:
   שלוםרבשובך
   ציפורהנחמדת
  
   But when I use:
   read.table(c:\\temp.txt)
   I get:
  V1
   1  ùìåíøáùåáê
   2 öéôåøäðçîãú
  
   My output for:
   l10n_info()
   Is:
   $MBCS
   [1] FALSE
  
   $`UTF-8`
   [1] FALSE
  
   $`Latin-1`
   [1] TRUE
  
   $codepage
   [1] 1252
   And for:
   Sys.getlocale()
  
   Is:
   [1] LC_COLLATE=English_United States.1252;LC_CTYPE=English_United
  States.
   1252;LC_MONETARY=English_United States.
   1252;LC_NUMERIC=C;LC_TIME=English_United States.1252
  
   Can you suggest to me what to try and change to allow me to load the
  file correctly ?
  
   Thanks!
  
   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)
  
 

 --
  
  
  
 
   2010/3/18 Petr PIKAL petr.pi...@precheza.cz
   Hi
  
   r-help-boun...@r-project.org napsal dne 18.03.2010 11:16:26:
  
   
Hi,
   
   
   
there´s something that really bothers me about R and after hours and
   hours of
internet research, I´m still stuck with the same problem: I
 installed
  R
   and it
is in Spanish, as the system on my work. I would really like it in
   English and
there seems to be no way to change that!?! I´m doing an abroad
   internship, so
my Spanish is far from perfect and my tutorial is in English.
   
   
   
Is there any way that I´m not aware of to change the language
   environment of R?
 
   Maybe
  
   ?Sys.getlocale
  
   Sys.setlocale(LC_ALL, Czech) # for Czech locale
  
   Regards
   Petr
  
  
   
   
   
Thanks a lot!
   
Katharina
   
_
[[elided Hotmail spam]]
   
   [[alternative HTML version deleted]]
   
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
   http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
  
   

Re: [R] How to read.table with “Hebrew” column names (in R)?

2010-03-19 Thread Tal Galili
Hello William, Ista and other R-help members,

The code you suggested:
read.table(http://www.talgalili.com/files/aa.txt,encoding=UTF-8;
,check.names=FALSE, header = T, sep = \t)
Works for me the same way it does for you: I can read the data in
(finally!), but some of the ways for using it fails (such as the printing,
and the attempt at including column names in lm)

So first thanks for the help!

Second, could you please supply your  sessionInfo() ?
I wonder how your locale is compared to that of Ista, since it looks as if
for Ista there is no problem with the Hebrew.

Thanks for helping!
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 Fri, Mar 19, 2010 at 12:42 AM, William Dunlap wdun...@tibco.com wrote:

 I tried this on R 2.11.0 unstable (2010-03-07 r51225) using
 encoding=UTF-8 and check.names=FALSE in read.table().
 It seemed to basically work, except that the data.frame/matrix printing
 routine wants to print the Unicode codes for the characters
 in the names:

data1 - read.table(http://www.talgalili.com/files/aa.txt;,
   header = TRUE, sep = \t, encoding=UTF-8, check.names=FALSE)
data1 # I see Unicode codes, presumably the correct ones
 U+05D0U+05D7U+05EA U+05E9U+05EAU+05D9U+05D9U+05DD
   1   12   97
   2  123  354
   361
 U+05E9U+05DCU+05D5U+05E9
   16
   2   44
   33
colnames(data1) # I see Hebrew strings (in R the first starts with
 aleph)
   [1] אחת   שתיים שלוש
colnames(data)[1]
   [1] אחת
strsplit(colnames(data)[1], )[[1]][1]
   [1] א
data1[,שתיים]
   [1]  97 354   1

 I'm writing this in Outlook in the English (American) locale
 and the copy-n-paste from the R gui window to the Outlook window
 of the Hebrew letters reversed the whole line of them (reversing
 the characters in each name and the names in the line), which I
 why I showed a subset of the names and a substring of the first name.

 However, when I try to use lm() with this data.frame then I run into
 trouble, which is probably the same problem as I see in the
 data.frame printing:

lm(`שתיים` ~ `שלוש`)
   Error: \u sequences not supported inside backticks (line 1)

 Bill Dunlap
 Spotfire, TIBCO Software
 wdunlap tibco.com

  -Original Message-
  From: r-help-boun...@r-project.org
  [mailto:r-help-boun...@r-project.org] On Behalf Of Tal Galili
  Sent: Thursday, March 18, 2010 2:41 PM
  To: r-help@r-project.org
  Subject: [R] How to read.table with “Hebrew” column names (in R)?
 
  (I am reposting this question after a few months without a
  solution...)
 
 
  Hi all,
 
  I am trying to read a .txt file, with Hebrew column names, but without
  success.
 
  I uploaded an example file to: http://www.talgalili.com/files/aa.txt
 
  And tried the command:
 
  read.table(http://www.talgalili.com/files/aa.txt;, header =
  T, sep = \t)
 
  This returns me with:
 
X.ª X...ª.. X...œ
  1  12  97 6
  2 123 35444
  3   6   1 3
 
  Instead of:
 
  × ×—×ª שתיי×שלוש
  12  97  6
  123 354 44
  6   1   3
 
 
   Trying to use something like:
 
  read.table(http://www.talgalili.com/files/aa.txt,fileEncodin
  g =iso8859-8)
 
  Has resulted in:
 
   V1
  1  ?
  Warning messages:
  1: In read.table(http://www.talgalili.com/files/aa.txt;, fileEncoding
  = iso8859-8) :
 
invalid input found on input connection
  'http://www.talgalili.com/files/aa.txt'
  2: In read.table(http://www.talgalili.com/files/aa.txt;, fileEncoding
  = iso8859-8) :
 
incomplete final line found by readTableHeader on
  'http://www.talgalili.com/files/aa.txt'
 
  While also trying this:
 
  Sys.setlocale(LC_ALL, en_US.UTF-8)
 
  Or this:
 
  Sys.setlocale(LC_ALL,
  en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8)
 
  Get's me this:
 
  [1] 
  Warning message:
  In Sys.setlocale(LC_ALL, en_US.UTF-8) :
 
OS reports request to set locale to en_US.UTF-8 cannot be honored
 
 
 
  My output for:
 
  l10n_info()
 
  Is:
 
  $MBCS
  [1] FALSE
 
  $`UTF-8`
  [1] FALSE
 
  $`Latin-1`
  [1] TRUE
 
  $codepage
  [1] 1252
 
  And for:
 
  Sys.getlocale()
 
  Is:
 
  [1] LC_COLLATE=English_United States.1252;LC_CTYPE=English_United
  States.1252;LC_MONETARY=English_United
  States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252
 
  Finally, here is the  sessionInfo()
 
  R version 2.10.1 (2009-12-14)
 
  

Re: [R] How to read.table with “Hebrew” column names (in R)?

2010-03-19 Thread Tal Galili
Hi William.

(Thanks to Petr Pikal)

Please try:

Sys.setlocale(LC_ALL, Hebrew)
# And
a- read.table(http://www.talgalili.com/files/aa.txt,encoding=UTF-8;
,check.names=FALSE, header = T, sep = \t)   # Notice the use of encoding
a


And let me know if that works...


The only question I have left is how can you set
Sys.setlocale(LC_ALL, Hebrew)
As the default of R when it is being loaded.

Cheers,
Tal

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




On Fri, Mar 19, 2010 at 9:35 AM, Tal Galili tal.gal...@gmail.com wrote:

 Hello William, Ista and other R-help members,

 The code you suggested:
 read.table(http://www.talgalili.com/files/aa.txt,encoding=UTF-8;
 ,check.names=FALSE, header = T, sep = \t)
 Works for me the same way it does for you: I can read the data in
 (finally!), but some of the ways for using it fails (such as the printing,
 and the attempt at including column names in lm)

 So first thanks for the help!

 Second, could you please supply your  sessionInfo() ?
 I wonder how your locale is compared to that of Ista, since it looks as if
 for Ista there is no problem with the Hebrew.

 Thanks for helping!
 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 Fri, Mar 19, 2010 at 12:42 AM, William Dunlap wdun...@tibco.comwrote:

 I tried this on R 2.11.0 unstable (2010-03-07 r51225) using
 encoding=UTF-8 and check.names=FALSE in read.table().
 It seemed to basically work, except that the data.frame/matrix printing
 routine wants to print the Unicode codes for the characters
 in the names:

data1 - read.table(http://www.talgalili.com/files/aa.txt;,
   header = TRUE, sep = \t, encoding=UTF-8, check.names=FALSE)
data1 # I see Unicode codes, presumably the correct ones
 U+05D0U+05D7U+05EA U+05E9U+05EAU+05D9U+05D9U+05DD
   1   12   97
   2  123  354
   361
 U+05E9U+05DCU+05D5U+05E9
   16
   2   44
   33
colnames(data1) # I see Hebrew strings (in R the first starts with
 aleph)
   [1] אחת   שתיים שלוש
colnames(data)[1]
   [1] אחת
strsplit(colnames(data)[1], )[[1]][1]
   [1] א
data1[,שתיים]
   [1]  97 354   1

 I'm writing this in Outlook in the English (American) locale
 and the copy-n-paste from the R gui window to the Outlook window
 of the Hebrew letters reversed the whole line of them (reversing
 the characters in each name and the names in the line), which I
 why I showed a subset of the names and a substring of the first name.

 However, when I try to use lm() with this data.frame then I run into
 trouble, which is probably the same problem as I see in the
 data.frame printing:

lm(`שתיים` ~ `שלוש`)
   Error: \u sequences not supported inside backticks (line 1)

 Bill Dunlap
 Spotfire, TIBCO Software
 wdunlap tibco.com

  -Original Message-
  From: r-help-boun...@r-project.org
  [mailto:r-help-boun...@r-project.org] On Behalf Of Tal Galili
  Sent: Thursday, March 18, 2010 2:41 PM
  To: r-help@r-project.org
  Subject: [R] How to read.table with “Hebrew” column names (in R)?
 
  (I am reposting this question after a few months without a
  solution...)
 
 
  Hi all,
 
  I am trying to read a .txt file, with Hebrew column names, but without
  success.
 
  I uploaded an example file to: http://www.talgalili.com/files/aa.txt
 
  And tried the command:
 
  read.table(http://www.talgalili.com/files/aa.txt;, header =
  T, sep = \t)
 
  This returns me with:
 
X.ª X...ª.. X...œ
  1  12  97 6
  2 123 35444
  3   6   1 3
 
  Instead of:
 
  × ×—×ª שתיי×שלוש
  12  97  6
  123 354 44
  6   1   3
 
 
   Trying to use something like:
 
  read.table(http://www.talgalili.com/files/aa.txt,fileEncodin
  g =iso8859-8)
 
  Has resulted in:
 
   V1
  1  ?
  Warning messages:
  1: In read.table(http://www.talgalili.com/files/aa.txt;, fileEncoding
  = iso8859-8) :
 
invalid input found on input connection
  'http://www.talgalili.com/files/aa.txt'
  2: In read.table(http://www.talgalili.com/files/aa.txt;, fileEncoding
  = iso8859-8) :
 
incomplete final 

Re: [R] outputing text colors

2010-03-19 Thread rtist

Hi Everyone,

And thanks for the replies.  I was more specifically referring to the
console table output itself.
I have a time series that has columns of months and rows of years, and each
row,col is a value.
I wanted the actual text output value to the console table r,c to have a
color corresponding to the value,
like ifelse(val0,txt=red,txt=green), so that I can quickly have an
overview of returns by color.

It looks like the only solution is to use a literal graphics object, and
that the above solution is not feasible.
I'll look into the graphical type objects.  It would be nice to have a
function that simply reads a time series
object table-f(ts.table) and outputs the above criteria.

Thanks again.
-- 
View this message in context: 
http://n4.nabble.com/outputing-text-colors-tp1598874p1599021.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] Odp: language!!!

2010-03-19 Thread Petr PIKAL
Hi Tal

Yes this was what I tried but it did not reveal hebrew  signs, therefore I 
assume it has something to do with OS.

put this line

Sys.setlocale(LC_ALL, Hebrew)

in your Rprofile.site file in etc folder of your R instalatiion

Regards
Petr


Tal Galili tal.gal...@gmail.com napsal dne 19.03.2010 09:01:20:

 Hi Petr,
 
 Please try:
 
 Sys.setlocale(LC_ALL, Hebrew)
 # And
 a- read.table(http://www.talgalili.com/files/aa.txt,encoding=UTF-8; 
 ,check.names=FALSE, header = T, sep = \t)   # Notice the use of 
encoding
 a
 
 And let me know if that works...
 
 The only question I have left is how can you set 
 Sys.setlocale(LC_ALL, Hebrew)
 As the default of R when it is being loaded.
 
 Thanks again,
 
 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 Fri, Mar 19, 2010 at 9:52 AM, Petr PIKAL petr.pi...@precheza.cz 
wrote:
 Hi
 
 Thanks, I am surprised, as I tried it after Bill's post and it did not
 work on my machine W2000, So probably the success or failure is system
 specific.
 
 Regards
 Petr
 
 Tal Galili tal.gal...@gmail.com napsal dne 19.03.2010 08:43:11:
 
  It worked !
 
  Thank you very much Petr!
 
  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 Fri, Mar 19, 2010 at 9:32 AM, Petr PIKAL petr.pi...@precheza.cz
 wrote:
  Hi
 
  I am not definitely expert in locales. It is a relict from time I 
worked
  with W95/98 where were some problems with locale setting and/or
 graphing.
  I would try just before reading in a file to change locale setting by
 
  ?Sys.setlocale
 
   Sys.getlocale()
  [1] LC_COLLATE=Czech_Czech Republic.1250;LC_CTYPE=Czech_Czech
  Republic.1250;LC_MONETARY=Czech_Czech
  Republic.1250;LC_NUMERIC=C;LC_TIME=Czech_Czech Republic.1250
   Sys.setlocale(LC_ALL, Hebrew)
  [1]
  LC_COLLATE=Hebrew_Israel.1255;LC_CTYPE=Hebrew_Israel.
 
 
1255;LC_MONETARY=Hebrew_Israel.1255;LC_NUMERIC=C;LC_TIME=Hebrew_Israel.1255
   Sys.getlocale()
  [1]
  LC_COLLATE=Hebrew_Israel.1255;LC_CTYPE=Hebrew_Israel.
 
 
1255;LC_MONETARY=Hebrew_Israel.1255;LC_NUMERIC=C;LC_TIME=Hebrew_Israel.1255
 
  and then try to read in the data.
 
  Regards
  Petr
 
 
  
  Tal Galili tal.gal...@gmail.com napsal dne 18.03.2010 16:23:25:
 
   Hello Petr,
  
   Since you seem to understand about locals, maybe you could (and will
 be
   willing) to help me.
  
   I wish to read in a simple file in Hebrew. It has just two lines:
   שלוםרבשובך
   ציפורהנחמדת
  
   But when I use:
   read.table(c:\\temp.txt)
   I get:
  V1
   1  ùìåíøáùåáê
   2 öéôåøäðçîãú
  
   My output for:
   l10n_info()
   Is:
   $MBCS
   [1] FALSE
  
   $`UTF-8`
   [1] FALSE
  
   $`Latin-1`
   [1] TRUE
  
   $codepage
   [1] 1252
   And for:
   Sys.getlocale()
  
   Is:
   [1] LC_COLLATE=English_United States.1252;LC_CTYPE=English_United
  States.
   1252;LC_MONETARY=English_United States.
   1252;LC_NUMERIC=C;LC_TIME=English_United States.1252
  
   Can you suggest to me what to try and change to allow me to load the
  file correctly ?
  
   Thanks!
  
   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)
  
 
 
--
  
  
  
 
   2010/3/18 Petr PIKAL petr.pi...@precheza.cz
   Hi
  
   r-help-boun...@r-project.org napsal dne 18.03.2010 11:16:26:
  
   
Hi,
   
   
   
there´s something that really bothers me about R and after hours 
and
   hours of
internet research, I´m still stuck with the same problem: I
 installed
  R
   and it
is in Spanish, as the system on my work. I would really like it in
   English and
there seems to be no way to change that!?! I´m doing an abroad
   internship, so
my Spanish is far from perfect and my tutorial is in English.
   
   
   
Is there any way that I´m not aware of to change the language
   environment of R?
 
   Maybe
  
   ?Sys.getlocale
  
   Sys.setlocale(LC_ALL, Czech) # for Czech locale
  
   Regards
   Petr
  
  
   
   
   
Thanks a lot!
   
Katharina
   
_
[[elided Hotmail spam]]
   
   [[alternative HTML version deleted]]
   

Re: [R] How to read.table with “Hebrew” c olumn names (in R)?

2010-03-19 Thread Petr PIKAL
Hi

 sessionInfo()
R version 2.11.0 Under development (unstable) (2010-03-09 r51229) 
i386-pc-mingw32 

locale:
[1] LC_COLLATE=Hebrew_Israel.1255  LC_CTYPE=Hebrew_Israel.1255 
[3] LC_MONETARY=Hebrew_Israel.1255 LC_NUMERIC=C 
[5] LC_TIME=Hebrew_Israel.1255 

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

other attached packages:
[1] reshape_0.8.3  plyr_0.1.9 proto_0.3-8lattice_0.18-3 fun_1.0  

loaded via a namespace (and not attached):
[1] ggplot2_0.8.3 tools_2.11.0

Regards
Petr


r-help-boun...@r-project.org napsal dne 19.03.2010 08:35:59:

 Hello William, Ista and other R-help members,
 
 The code you suggested:
 read.table(http://www.talgalili.com/files/aa.txt,encoding=UTF-8;
 ,check.names=FALSE, header = T, sep = \t)
 Works for me the same way it does for you: I can read the data in
 (finally!), but some of the ways for using it fails (such as the 
printing,
 and the attempt at including column names in lm)
 
 So first thanks for the help!
 
 Second, could you please supply your  sessionInfo() ?
 I wonder how your locale is compared to that of Ista, since it looks as 
if
 for Ista there is no problem with the Hebrew.
 
 Thanks for helping!
 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 Fri, Mar 19, 2010 at 12:42 AM, William Dunlap wdun...@tibco.com 
wrote:
 
  I tried this on R 2.11.0 unstable (2010-03-07 r51225) using
  encoding=UTF-8 and check.names=FALSE in read.table().
  It seemed to basically work, except that the data.frame/matrix 
printing
  routine wants to print the Unicode codes for the characters
  in the names:
 
 data1 - read.table(http://www.talgalili.com/files/aa.txt;,
header = TRUE, sep = \t, encoding=UTF-8, check.names=FALSE)
 data1 # I see Unicode codes, presumably the correct ones
  U+05D0U+05D7U+05EA U+05E9U+05EAU+05D9U+05D9U+05DD
1   12   97
2  123  354
361
  U+05E9U+05DCU+05D5U+05E9
16
2   44
33
 colnames(data1) # I see Hebrew strings (in R the first starts with
  aleph)
[1] אחת   שתיים שלוש
 colnames(data)[1]
[1] אחת
 strsplit(colnames(data)[1], )[[1]][1]
[1] א
 data1[,שתיים]
[1]  97 354   1
 
  I'm writing this in Outlook in the English (American) locale
  and the copy-n-paste from the R gui window to the Outlook window
  of the Hebrew letters reversed the whole line of them (reversing
  the characters in each name and the names in the line), which I
  why I showed a subset of the names and a substring of the first name.
 
  However, when I try to use lm() with this data.frame then I run into
  trouble, which is probably the same problem as I see in the
  data.frame printing:
 
 lm(`שתיים` ~ `שלוש`)
Error: \u sequences not supported inside backticks (line 1)
 
  Bill Dunlap
  Spotfire, TIBCO Software
  wdunlap tibco.com
 
   -Original Message-
   From: r-help-boun...@r-project.org
   [mailto:r-help-boun...@r-project.org] On Behalf Of Tal Galili
   Sent: Thursday, March 18, 2010 2:41 PM
   To: r-help@r-project.org
   Subject: [R] How to read.table with “Hebrew” column names (in 
R)?
  
   (I am reposting this question after a few months without a
   solution...)
  
  
   Hi all,
  
   I am trying to read a .txt file, with Hebrew column names, but 
without
   success.
  
   I uploaded an example file to: http://www.talgalili.com/files/aa.txt
  
   And tried the command:
  
   read.table(http://www.talgalili.com/files/aa.txt;, header =
   T, sep = \t)
  
   This returns me with:
  
 X.ª X...ª.. X...œ
   1  12  97 6
   2 123 35444
   3   6   1 3
  
   Instead of:
  
   × ×—×ª שתיי×שלוש
   12  97  6
   123 354 44
   6   1   3
  
  
Trying to use something like:
  
   read.table(http://www.talgalili.com/files/aa.txt,fileEncodin
   g =iso8859-8)
  
   Has resulted in:
  
V1
   1  ?
   Warning messages:
   1: In read.table(http://www.talgalili.com/files/aa.txt;, 
fileEncoding
   = iso8859-8) :
  
 invalid input found on input connection
   'http://www.talgalili.com/files/aa.txt'
   2: In read.table(http://www.talgalili.com/files/aa.txt;, 
fileEncoding
   = iso8859-8) :
  
 incomplete final line found by readTableHeader on
   'http://www.talgalili.com/files/aa.txt'
  
 

Re: [R] Odp: language!!!

2010-03-19 Thread Tal Galili
Thanks Petr,

Could you please share what is your
sessionInfo()

?




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 Fri, Mar 19, 2010 at 10:10 AM, Petr PIKAL petr.pi...@precheza.cz wrote:

 Hi Tal

 Yes this was what I tried but it did not reveal hebrew  signs, therefore I
 assume it has something to do with OS.

 put this line

 Sys.setlocale(LC_ALL, Hebrew)

 in your Rprofile.site file in etc folder of your R instalatiion

 Regards
 Petr


 Tal Galili tal.gal...@gmail.com napsal dne 19.03.2010 09:01:20:

  Hi Petr,
 
  Please try:
 
  Sys.setlocale(LC_ALL, Hebrew)
  # And
  a- read.table(http://www.talgalili.com/files/aa.txt,encoding=UTF-8;
  ,check.names=FALSE, header = T, sep = \t)   # Notice the use of
 encoding
  a
 
  And let me know if that works...
 
  The only question I have left is how can you set
  Sys.setlocale(LC_ALL, Hebrew)
  As the default of R when it is being loaded.
 
  Thanks again,
 
  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 Fri, Mar 19, 2010 at 9:52 AM, Petr PIKAL petr.pi...@precheza.cz
 wrote:
  Hi
 
  Thanks, I am surprised, as I tried it after Bill's post and it did not
  work on my machine W2000, So probably the success or failure is system
  specific.
 
  Regards
  Petr
 
  Tal Galili tal.gal...@gmail.com napsal dne 19.03.2010 08:43:11:
 
   It worked !
  
   Thank you very much Petr!
  
   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 Fri, Mar 19, 2010 at 9:32 AM, Petr PIKAL petr.pi...@precheza.cz
  wrote:
   Hi
  
   I am not definitely expert in locales. It is a relict from time I
 worked
   with W95/98 where were some problems with locale setting and/or
  graphing.
   I would try just before reading in a file to change locale setting by
  
   ?Sys.setlocale
  
Sys.getlocale()
   [1] LC_COLLATE=Czech_Czech Republic.1250;LC_CTYPE=Czech_Czech
   Republic.1250;LC_MONETARY=Czech_Czech
   Republic.1250;LC_NUMERIC=C;LC_TIME=Czech_Czech Republic.1250
Sys.setlocale(LC_ALL, Hebrew)
   [1]
   LC_COLLATE=Hebrew_Israel.1255;LC_CTYPE=Hebrew_Israel.
  
 

 1255;LC_MONETARY=Hebrew_Israel.1255;LC_NUMERIC=C;LC_TIME=Hebrew_Israel.1255
Sys.getlocale()
   [1]
   LC_COLLATE=Hebrew_Israel.1255;LC_CTYPE=Hebrew_Israel.
  
 

 1255;LC_MONETARY=Hebrew_Israel.1255;LC_NUMERIC=C;LC_TIME=Hebrew_Israel.1255
  
   and then try to read in the data.
  
   Regards
   Petr
  
  
   
   Tal Galili tal.gal...@gmail.com napsal dne 18.03.2010 16:23:25:
  
Hello Petr,
   
Since you seem to understand about locals, maybe you could (and will
  be
willing) to help me.
   
I wish to read in a simple file in Hebrew. It has just two lines:
שלוםרבשובך
ציפורהנחמדת
   
But when I use:
read.table(c:\\temp.txt)
I get:
   V1
1  ùìåíøáùåáê
2 öéôåøäðçîãú
   
My output for:
l10n_info()
Is:
$MBCS
[1] FALSE
   
$`UTF-8`
[1] FALSE
   
$`Latin-1`
[1] TRUE
   
$codepage
[1] 1252
And for:
Sys.getlocale()
   
Is:
[1] LC_COLLATE=English_United States.1252;LC_CTYPE=English_United
   States.
1252;LC_MONETARY=English_United States.
1252;LC_NUMERIC=C;LC_TIME=English_United States.1252
   
Can you suggest to me what to try and change to allow me to load the
   file correctly ?
   
Thanks!
   
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)
   
  
 

 --
   
   
   
  
2010/3/18 Petr PIKAL petr.pi...@precheza.cz
Hi
   
r-help-boun...@r-project.org napsal dne 18.03.2010 11:16:26:
   

 Hi,



 there´s something that really bothers me about R and after hours
 and
hours of
 internet research, I´m still stuck with the same problem: I
 

Re: [R] How to read.table with “Hebrew” column names (in R)?

2010-03-19 Thread Tal Galili
Thanks Petr.

This is my sessionInfo()

R version 2.10.1 (2009-12-14)
i386-pc-mingw32

locale:
[1] LC_COLLATE=Hebrew_Israel.1255  LC_CTYPE=Hebrew_Israel.1255
[3] LC_MONETARY=Hebrew_Israel.1255 LC_NUMERIC=C
[5] LC_TIME=Hebrew_Israel.1255

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


And for me it is working.

What else can we check ?
(The reason I am insisting, even that it is working for me, is that I know
of R users in Israel who are having a hard time with getting R to work with
Hebrew. So any insights we gain here will be for long term benefit to the
growing R community here)

Best,
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 Fri, Mar 19, 2010 at 10:12 AM, Petr PIKAL petr.pi...@precheza.cz wrote:

 Hi

  sessionInfo()
 R version 2.11.0 Under development (unstable) (2010-03-09 r51229)
 i386-pc-mingw32

 locale:
 [1] LC_COLLATE=Hebrew_Israel.1255  LC_CTYPE=Hebrew_Israel.1255
 [3] LC_MONETARY=Hebrew_Israel.1255 LC_NUMERIC=C
 [5] LC_TIME=Hebrew_Israel.1255

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

 other attached packages:
 [1] reshape_0.8.3  plyr_0.1.9 proto_0.3-8lattice_0.18-3 fun_1.0

 loaded via a namespace (and not attached):
 [1] ggplot2_0.8.3 tools_2.11.0

 Regards
 Petr


 r-help-boun...@r-project.org napsal dne 19.03.2010 08:35:59:

  Hello William, Ista and other R-help members,
 
  The code you suggested:
  read.table(http://www.talgalili.com/files/aa.txt,encoding=UTF-8;
  ,check.names=FALSE, header = T, sep = \t)
  Works for me the same way it does for you: I can read the data in
  (finally!), but some of the ways for using it fails (such as the
 printing,
  and the attempt at including column names in lm)
 
  So first thanks for the help!
 
  Second, could you please supply your  sessionInfo() ?
  I wonder how your locale is compared to that of Ista, since it looks as
 if
  for Ista there is no problem with the Hebrew.
 
  Thanks for helping!
  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 Fri, Mar 19, 2010 at 12:42 AM, William Dunlap wdun...@tibco.com
 wrote:
 
   I tried this on R 2.11.0 unstable (2010-03-07 r51225) using
   encoding=UTF-8 and check.names=FALSE in read.table().
   It seemed to basically work, except that the data.frame/matrix
 printing
   routine wants to print the Unicode codes for the characters
   in the names:
  
  data1 - read.table(http://www.talgalili.com/files/aa.txt;,
 header = TRUE, sep = \t, encoding=UTF-8, check.names=FALSE)
  data1 # I see Unicode codes, presumably the correct ones
   U+05D0U+05D7U+05EA U+05E9U+05EAU+05D9U+05D9U+05DD
 1   12   97
 2  123  354
 361
   U+05E9U+05DCU+05D5U+05E9
 16
 2   44
 33
  colnames(data1) # I see Hebrew strings (in R the first starts with
   aleph)
 [1] × ×—×Ş   שתיים שלוש
  colnames(data)[1]
 [1] × ×—×Ş
  strsplit(colnames(data)[1], )[[1]][1]
 [1] × 
  data1[,שתיים]
 [1]  97 354   1
  
   I'm writing this in Outlook in the English (American) locale
   and the copy-n-paste from the R gui window to the Outlook window
   of the Hebrew letters reversed the whole line of them (reversing
   the characters in each name and the names in the line), which I
   why I showed a subset of the names and a substring of the first name.
  
   However, when I try to use lm() with this data.frame then I run into
   trouble, which is probably the same problem as I see in the
   data.frame printing:
  
  lm(`שתיים` ~ `שלוש`)
 Error: \u sequences not supported inside backticks (line 1)
  
   Bill Dunlap
   Spotfire, TIBCO Software
   wdunlap tibco.com
  
-Original Message-
From: r-help-boun...@r-project.org
[mailto:r-help-boun...@r-project.org] On Behalf Of Tal Galili
Sent: Thursday, March 18, 2010 2:41 PM
To: r-help@r-project.org
Subject: [R] How to read.table with “Hebrew” column names 
(in
 R)?
   
(I 

[R] Odp: Dataframe manipulation

2010-03-19 Thread Petr PIKAL
Hi

maybe you shall be a little bit more clear what you really want. It is 
hard to copy your data o R without some extensive fiddling, so we need to 
rely on complicated text description.

It seems that 
?ave
could help you but it is hard to check.

Basically I would recode ARRIVE and DEPART as POSIX class as I suggested 
before. Then you can do some arithmetic with it.

At least you shall tell us what you want to be in second value for ARRIVE.

If your task is not repeating and size of your data is not too big 
probably some looping could be also suitable. Or also zoo and function 
na.locf can help but without data, shrug.

Sorry that I can not provide canned help but I am really not sure what the 
output shall be.

Regards
Petr



r-help-boun...@r-project.org napsal dne 18.03.2010 14:48:06:

 Hello R users,
 
 I spent most of my workday yesterday trying unsuccessfully to 
 write code that will perform a series of calculations on my 
 dataframe (partial copy is attached). What I need to do is
 multiply the 24 hr time in the 'DEPART' column by the time 
 (in the 'TRAVEL' column (travel time in minutes), and store this 
 result in the 'ARRIVE' column for the following 'SITE1' number. 
 Then I need to add the 'WAIT' time (minutes) for that site's row 
 to its 'ARRIVE' time to calculate the next 'DEPART' time and 
 then proceed down the dataframe independently for each unique 'MM' 
 by 'DD' combination. What I want to do I hope will be obvious after you 
 view the dataframe. Basically, for each unique 'MM' (month) by 'DD'(day) 
grouping 
 I have four sites that are surveyed sequentially, and the starting
 site for a survey day was chosen randomly. The route is circular,
 proceeding from site 101 to 104. I really hope someone can help 
 me with this, because I am so close to finishing it.
 
 BTW, the code that adds minutes to 24 hr time to create 24 hr time is as 
follows:
 
 addTime2-function(timeTxt,mins){
 orig.date-as.POSIXct(paste(2001-01-01,timeTxt))
 new.Date-orig.date+mins*60
 new.Date-strsplit(as.character(new.Date), )
 new.Time-(sapply(new.Date,[,2))
 return(new.Time)
 }
 SCHEDULE2$DEPART-addTime2(SCHEDULE2$ARRIVE,SCHEDULE2$WAIT)
 (code courtesy of Gustaf)
 
 Thank you,
 
 Mike
 [příloha Dataframe.pdf odstraněna uživatelem Petr PIKAL/CTCAP] 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] using RKWard for a function plot

2010-03-19 Thread Matthieu Stigler

Not that I know, you should write the function yourself:
g-1
f-2
beta-1
curve((-2*g*x*exp(-(x^ 2)/beta)/f))

But yes the idea to add such functionality within rkward is good :-)

Hope this helps

Mat



Is it possible to use the RKWard GUI to just plot a function?  I will have 
some exponential function, I need to plot u as a function of y where



  u=   -2yg  exp(-y2/beta)
-
f

   where everything else other than u and y are various constants.



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


Re: [R] chron package install fail in intel I7 - fedora 12

2010-03-19 Thread Uwe Ligges



On 19.03.2010 04:20, Juan Santiago Ramseyer wrote:

install packages chron fail in Fedora 12, cpu I7/860

See down.

Regard,

Juan S. Ramseyer.



install.packages()

Loading Tcl/Tk interface ... done
--- Please select a CRAN mirror for use in this session ---
Warning in install.packages() :
   argument 'lib' is missing: using '/usr/lib64/R/library'
tentando a URL
'http://www.vps.fmvz.usp.br/CRAN/src/contrib/chron_2.3-34.tar.gz'
Content type 'application/x-gzip' length 34135 bytes (33 Kb)
URL aberta
==
downloaded 33 Kb

* installing *source* package ‘chron’ ...
** libs
Warning: R include directory is empty -- perhaps need to install
R-devel.rpm or similar



Please read this very first warning and just do what it says.

Best,
Uwe Ligges






gcc -m64 -std=gnu99 -I/usr/include/R  -I/usr/local/include-fpic  -O2
-g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector
--param=ssp-buffer-size=4 -m64 -mtune=generic -c chron_strs.c -o
chron_strs.o
chron_strs.c:2:15: error: R.h: Arquivo ou diretório não encontrado
chron_strs.c:7: error: expected declaration specifiers or ‘...’ before
‘Sint’
chron_strs.c:7: error: expected declaration specifiers or ‘...’ before
‘Sint’
chron_strs.c:8: error: expected declaration specifiers or ‘...’ before
‘Sint’
chron_strs.c: In function ‘cnt_flds_str’:
chron_strs.c:10: error: ‘Sint’ undeclared (first use in this function)
chron_strs.c:10: error: (Each undeclared identifier is reported only
once
chron_strs.c:10: error: for each function it appears in.)
chron_strs.c:10: error: expected ‘;’ before ‘n’
chron_strs.c:11: error: expected ‘;’ before ‘i’
chron_strs.c:15: error: ‘whitespace’ undeclared (first use in this
function)
chron_strs.c:17: error: ‘i’ undeclared (first use in this function)
chron_strs.c:17: error: ‘n’ undeclared (first use in this function)
chron_strs.c:21: error: ‘nsep’ undeclared (first use in this function)
chron_strs.c:25: error: ‘counts’ undeclared (first use in this function)
make: ** [chron_strs.o] Erro 1
ERROR: compilation failed for package ‘chron’
* removing ‘/usr/lib64/R/library/chron’

The downloaded packages are in
‘/tmp/RtmpEdAwWY/downloaded_packages’
Updating HTML index of packages in '.Library'
Warning message:
In install.packages() :
   installation of package 'chron' had non-zero exit status

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Please Post Planned Contrasts Example in lme {nlme}

2010-03-19 Thread Liviu Andronic
On 3/18/10, Martin Turcotte mart.turco...@gmail.com wrote:
 Hi I am running some linear and non-linear mixed effect models and would like 
 to do some planned contrasts (a priori contrasts)

  I have looked in the help and in many forums and it seems possible to do so 
 but don't understand how to write the function and I couldn't find an example 
 in Pinheiro and Bates.

Did you try John Fox' appendix on mixed effects models [1]?
Liviu

[1] http://socserv.socsci.mcmaster.ca/jfox/Books/Companion/appendix.html

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


Re: [R] One main title and One legend for multiple lattice plots

2010-03-19 Thread Deepayan Sarkar
On Fri, Mar 19, 2010 at 8:37 AM, Kim Jung Hwa kimhwamaill...@gmail.com wrote:
 Hi David,

 Thank you for your reply. I'm sorry if I've misconveyed my question: here it
 goes again:

 *** I want a common main title and a common legend after I
 output/print four different lattice plots on a single .wmf or .pdf file***
 Somewhat as in this image:

 http://www.ncl.ucar.edu/Training/Workshops/Exercises/Images/panel_ex08.png

But this is also not a good example (assuming that you really want
what you claim you want) because it is precisely the type of plot
multipanel Trellis graphics are designed for. For example, see the
last example in example(levelplot). In the case of your toy example,

p2[c(1, 1)]

So you still need to convince us of the need for what you want.
However, if you do really need it, you will need to use some
lower-level grid functions (basically, create a viewport and put the
two lattice plots inside, then add the main title and legend using
grid directly).

-Deepayan

 # R code:
 library(lattice)
 p1 - xyplot(decrease ~ treatment, OrchardSprays, groups = rowpos,
     type = a, main=Remove this title and legend on right,
     auto.key = list(space = right, points = FALSE, lines = TRUE))
 p2 - xyplot(decrease ~ treatment, OrchardSprays, groups = rowpos,
     type = a, main=Need a single / legend,
     auto.key = list(space = right, points = FALSE, lines = TRUE))

 win.metafile(Rplot%02d.wmf, width=12, height=8)
 print(p1, split=c(1,1,2,2), more=TRUE)
 print(p2, split=c(1,2,2,2), more=TRUE)
 print(p1, split=c(2,1,2,2), more=TRUE)
 print(p2, split=c(2,2,2,2))
 dev.off()
 Thanks,
 Kim


 On Thu, Mar 18, 2010 at 10:21 PM, David Winsemius 
 dwinsem...@comcast.netwrote:


 On Mar 18, 2010, at 10:10 PM, Kim Jung Hwa wrote:

 Hi All,

 Can anyone please help me with getting a single title and legend for
 both the plots in the following R code. I'll eventually be using .wmf
 file.


 This is either incredibly simple or you have not explained what you reall
 want. Not being on windos I would not be making a win-metafile but this pdf
 appears to be doing what you ask:

  ttl - Some random text

 p1 - xyplot(decrease ~ treatment, OrchardSprays, groups = rowpos,
      type = a, main=ttl,

      auto.key = list(space = right, points = FALSE, lines = TRUE))
 p2 - xyplot(decrease ~ treatment, OrchardSprays, groups = rowpos,
      type = a, main=ttl,

      auto.key = list(space = right, points = FALSE, lines = TRUE))

 pdf(Rplot%02d.pdf, width=12, height=8)

 print(p1, split=c(1,1,2,2), more=TRUE)
 print(p2, split=c(1,2,2,2), more=TRUE)
 print(p1, split=c(2,1,2,2), more=TRUE)
 print(p2, split=c(2,2,2,2))
 dev.off()


 # R code:
 library(lattice)
 p1 - xyplot(decrease ~ treatment, OrchardSprays, groups = rowpos,
      type = a, main=Same title / legend,
      auto.key = list(space = right, points = FALSE, lines = TRUE))
 p2 - xyplot(decrease ~ treatment, OrchardSprays, groups = rowpos,
      type = a, main=Same title / legend,
      auto.key = list(space = right, points = FALSE, lines = TRUE))

 win.metafile(Rplot%02d.wmf, width=12, height=8)
 print(p1, split=c(1,1,2,2), more=TRUE)
 print(p2, split=c(1,2,2,2), more=TRUE)
 print(p1, split=c(2,1,2,2), more=TRUE)
 print(p2, split=c(2,2,2,2))
 dev.off()

 Thanks in advance,
 Kim

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


 David Winsemius, MD
 West Hartford, CT



        [[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] Howto get unnormalized eigenvectors?

2010-03-19 Thread Lucek, Kay
Hi,
I try to calculate the angle between two first eigenvectors of different 
covariance matrices of biological phenotypic traits for different populations. 
My issue here is, that all possibilities to do so seem to normalize the 
eigenvectors to length 1. Although the helpfile of eigen() states, that using 
eigen(, symmetric = FALSE, EISPACK =TRUE) skips normalization this is (I guess) 
not applicable for me as my matrices are symmetric.

x-eigen(cov(population1))$vectors[,1]
y-eigen(cov(population2))$vectors[,1]

angle (in degree):
((acos((x%*%y)/(sqrt(x%*%y)*sqrt(y%*%y*180)/pi
Thus by using normalized vectors, the divisor becomes meaningless being 1.

Does anybody have an idea to get raw eigenvectors?
Thanks a lot

Kay Lucek
Aquatic Ecology  Macroevolution
University of Bern
Baltzerstr. 6
3012 Bern
Switzerland
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Sequence of ordered variable to add as column

2010-03-19 Thread Duarte Viana
Hello all,

As an example, consider the following dataframe

 df-data.frame(id=c(b,b,a,a,a),ord=c(2,1,1,3,2))
 dates-as.Date(c(02/27/92, 02/27/92, 01/14/92, 02/28/92, 
 02/01/92),%m/%d/%y)
 df$dates-dates

which was ordered with

 df-df[order(df$id,df$dates),]

Now I would like to add a column containing a sequence (disregarding
ties) that represents the order of the variable
dates in each case of the variable id, resulting in this dataframe:

 seq.id-c(1,2,3,1,2)
 df$seq.id-seq.id

  id ord  dates seq.id
3  a   1 1992-01-14  1
5  a   2 1992-02-01  2
4  a   3 1992-02-28  3
1  b   2 1992-02-27  1
2  b   1 1992-02-27  2


Thanks in advance,

Duarte Viana

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


Re: [R] Howto get unnormalized eigenvectors?

2010-03-19 Thread Duncan Murdoch

Lucek, Kay wrote:

Hi,
I try to calculate the angle between two first eigenvectors of different 
covariance matrices of biological phenotypic traits for different populations. 
My issue here is, that all possibilities to do so seem to normalize the 
eigenvectors to length 1. Although the helpfile of eigen() states, that using 
eigen(, symmetric = FALSE, EISPACK =TRUE) skips normalization this is (I guess) 
not applicable for me as my matrices are symmetric.

x-eigen(cov(population1))$vectors[,1]
y-eigen(cov(population2))$vectors[,1]

angle (in degree):
((acos((x%*%y)/(sqrt(x%*%y)*sqrt(y%*%y*180)/pi
Thus by using normalized vectors, the divisor becomes meaningless being 1.

Does anybody have an idea to get raw eigenvectors?


I don't know what you mean by raw eigenvectors.  Any non-zero multiple 
of an eigenvector is an eigenvector.


For the angle, just skip the denominator, because it's guaranteed to be 1.

Duncan Murdoch

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


[R] Odp: Sequence of ordered variable to add as column

2010-03-19 Thread Petr PIKAL
Hi

r-help-boun...@r-project.org napsal dne 19.03.2010 11:25:12:

 Hello all,
 
 As an example, consider the following dataframe
 
  df-data.frame(id=c(b,b,a,a,a),ord=c(2,1,1,3,2))
  dates-as.Date(c(02/27/92, 02/27/92, 01/14/92, 02/28/92, 
02/01/
 92),%m/%d/%y)
  df$dates-dates
 
 which was ordered with
 
  df-df[order(df$id,df$dates),]
 
 Now I would like to add a column containing a sequence (disregarding
 ties) that represents the order of the variable
 dates in each case of the variable id, resulting in this dataframe:
 
  seq.id-c(1,2,3,1,2)
  df$seq.id-seq.id
 
   id ord  dates seq.id
 3  a   1 1992-01-14  1
 5  a   2 1992-02-01  2
 4  a   3 1992-02-28  3
 1  b   2 1992-02-27  1
 2  b   1 1992-02-27  2

Here is one option but I believe others will come with more clever one.

df$seq.id-unlist(tapply(as.numeric(df$id), df$id, order))

Regards
Petr



 
 
 Thanks in advance,
 
 Duarte Viana
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] lattice grob

2010-03-19 Thread baptiste auguie
Dear list,

I'm trying to arrange various grid objects on a page using a
frameGrob. It works fine with basic grobs (textGrob, gTree, etc.), and
also with ggplot2 objects using the ggplotGrob() function. I am
however stuck with lattice. As far as I understand, lattice produces a
list of class trellis, which is eventually displayed using the
plot.trellis method. I am not sure if/how one can convert this list
into a high-level grob. I tried the following,

latticeGrob - function(p, ...){
  grob(p=p, ..., cl=lattice)
}

drawDetails.lattice - function(x, recording=FALSE){
  lattice:::plot.trellis(x$p)
}

p1 - xyplot(1:10 ~ 1:10)
g1 - latticeGrob(p1)

grid.draw(g1) # works fine

but,

fg - frameGrob(layout = grid.layout(1,1))
fg - placeGrob(fg, g1, row = 1, col = 1)
grid.draw(fg)

Error in UseMethod(depth) :
  no applicable method for 'depth' applied to an object of class NULL

Ideas are most welcome,

Best regards,

baptiste

 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  methods   base

other attached packages:
[1] ggplot2_0.8.7   digest_0.4.1reshape_0.8.3   plyr_0.1.9
proto_0.3-8 gridExtra_0.5   lattice_0.17-26 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] One main title and One legend for multiple lattice plots

2010-03-19 Thread Kim Jung Hwa
Ohh I got your point Deepayan, thats a stupid question from me. I can
easilty rbind my four datasets, distuingusing them by a new variable, say
type, and then instead of plotting a 2D image, I can use a conditioning
variable to plot a 3D image and achieve what I what.

I'm sorry about this, thanks a lot!
Kim

On Fri, Mar 19, 2010 at 6:24 AM, Deepayan Sarkar
deepayan.sar...@gmail.comwrote:

 On Fri, Mar 19, 2010 at 8:37 AM, Kim Jung Hwa kimhwamaill...@gmail.com
 wrote:
  Hi David,
 
  Thank you for your reply. I'm sorry if I've misconveyed my question: here
 it
  goes again:
 
  *** I want a common main title and a common legend after I
  output/print four different lattice plots on a single .wmf or .pdf
 file***
  Somewhat as in this image:
 
 
 http://www.ncl.ucar.edu/Training/Workshops/Exercises/Images/panel_ex08.png

 But this is also not a good example (assuming that you really want
 what you claim you want) because it is precisely the type of plot
 multipanel Trellis graphics are designed for. For example, see the
 last example in example(levelplot). In the case of your toy example,

 p2[c(1, 1)]

 So you still need to convince us of the need for what you want.
 However, if you do really need it, you will need to use some
 lower-level grid functions (basically, create a viewport and put the
 two lattice plots inside, then add the main title and legend using
 grid directly).

 -Deepayan

  # R code:
  library(lattice)
  p1 - xyplot(decrease ~ treatment, OrchardSprays, groups = rowpos,
  type = a, main=Remove this title and legend on right,
  auto.key = list(space = right, points = FALSE, lines = TRUE))
  p2 - xyplot(decrease ~ treatment, OrchardSprays, groups = rowpos,
  type = a, main=Need a single / legend,
  auto.key = list(space = right, points = FALSE, lines = TRUE))
 
  win.metafile(Rplot%02d.wmf, width=12, height=8)
  print(p1, split=c(1,1,2,2), more=TRUE)
  print(p2, split=c(1,2,2,2), more=TRUE)
  print(p1, split=c(2,1,2,2), more=TRUE)
  print(p2, split=c(2,2,2,2))
  dev.off()
  Thanks,
  Kim
 
 
  On Thu, Mar 18, 2010 at 10:21 PM, David Winsemius 
 dwinsem...@comcast.netwrote:
 
 
  On Mar 18, 2010, at 10:10 PM, Kim Jung Hwa wrote:
 
  Hi All,
 
  Can anyone please help me with getting a single title and legend
 for
  both the plots in the following R code. I'll eventually be using .wmf
  file.
 
 
  This is either incredibly simple or you have not explained what you
 reall
  want. Not being on windos I would not be making a win-metafile but this
 pdf
  appears to be doing what you ask:
 
   ttl - Some random text
 
  p1 - xyplot(decrease ~ treatment, OrchardSprays, groups = rowpos,
   type = a, main=ttl,
 
   auto.key = list(space = right, points = FALSE, lines = TRUE))
  p2 - xyplot(decrease ~ treatment, OrchardSprays, groups = rowpos,
   type = a, main=ttl,
 
   auto.key = list(space = right, points = FALSE, lines = TRUE))
 
  pdf(Rplot%02d.pdf, width=12, height=8)
 
  print(p1, split=c(1,1,2,2), more=TRUE)
  print(p2, split=c(1,2,2,2), more=TRUE)
  print(p1, split=c(2,1,2,2), more=TRUE)
  print(p2, split=c(2,2,2,2))
  dev.off()
 
 
  # R code:
  library(lattice)
  p1 - xyplot(decrease ~ treatment, OrchardSprays, groups = rowpos,
   type = a, main=Same title / legend,
   auto.key = list(space = right, points = FALSE, lines = TRUE))
  p2 - xyplot(decrease ~ treatment, OrchardSprays, groups = rowpos,
   type = a, main=Same title / legend,
   auto.key = list(space = right, points = FALSE, lines = TRUE))
 
  win.metafile(Rplot%02d.wmf, width=12, height=8)
  print(p1, split=c(1,1,2,2), more=TRUE)
  print(p2, split=c(1,2,2,2), more=TRUE)
  print(p1, split=c(2,1,2,2), more=TRUE)
  print(p2, split=c(2,2,2,2))
  dev.off()
 
  Thanks in advance,
  Kim
 
 [[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
 http://www.r-project.org/posting-guide.html
   and provide commented, minimal, self-contained, reproducible code.
 
 
  David Winsemius, MD
  West Hartford, CT
 
 
 
 [[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] Arima forecasting

2010-03-19 Thread Matteo Bertini
Hello everyone,

I'm doing some benchmark comparing Arima [1] and SVR on time series data.

I'm using an out-of-sample one-step-ahead prediction from Arima using
the fitted method [2].

Do someone know how to have a two-steps-ahead forecast timeseries from Arima?


Thanks,
Matteo Bertini

[1] http://robjhyndman.com/software/forecast
[2] AirPassengers example on page 5

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


Re: [R] mboost: Interpreting coefficients from glmboost if center=TRUE

2010-03-19 Thread Benjamin Hofner
Sorry for the tardy reply but I just found your posting incidentally 
today. To make long things short:


You are right about the centering. We forgot to correct the intercept if 
center = TRUE. We lately found the problem ourself and fixed it in the 
current version (mboost 2.0-3). However the problem only occurred if you 
extracted the coefficients. As the intercept is rarely interpretable we 
didn't have a closer look and thus it took some time until we found this 
bug. The model predictions however always took care of the centering and 
thus were not affected (as you already pointed out).


As you realized centering is of hight importance if you use glmboost as 
it reduces the number of boosting iterations needed to estimate the 
model and furthermore often improves the estimates. Centering is also 
important if you use gamboost() and specify linear base-learners without 
intercept (e.g. bols(x, intercept=FALSE)). However, in this case you 
have to center the covariates yourself and take care of the intercept 
correction afterwards.


You wrote you weren't aware of a mailing list for mboost but you could 
write to the maintainer (see 
http://cran.at.r-project.org/package=mboost) for possible help and/or to 
report bugs.


HTH
 Benjamin

Kyle Werner wrote:

Thanks for your reply. In fact, I do use the predict method for model
assessment, and it shows that centering leads to a substantial
improvement using even the bluntest of assessments of 'goodness'
(i.e., binary categorization accuracy). So I agree that the package
authors must have internal tools to reverse the effects of centering
the variables, at least within the predict method. But it seems to me
that the coefficients that I get out should be related to the values
that I input, not to the centered values. In other words, centering
seems like it should be done invisibly; unless I center the
variables myself, I would expect the coefficients to be applicable to
the original data.

I extract the coefficients returned by the model and store them in a
database which is web accessible. I reconstruct models periodically,
and track various statistics associated with these models in the
database. This is why I highly value the fact that mboost has
glmboost, which can return linearly interpretable coefficients. It is
also why I do not directly call upon R every time I want to query a
model. (As an aside, if I were to use R directly, I might consider the
gamboost or blackboost methods, which do not return scalar
coefficients that are readily extractable.)



On Sun, Feb 7, 2010 at 6:31 PM, David Winsemius dwinsemius at 
comcast.net wrote:

 
  On Feb 7, 2010, at 5:03 PM, Kyle Werner wrote:
 
  I'm running R 2.10.1 with mboost 2.0 in order to build predictive
  models . I am performing prediction on a binomial outcome, using a
  linear function (glmboost). However, I am running into some confusion
  regarding centering. (I am not aware of an mboost-specific mailing
  list, so if the main R list is not the right place for this topic,
  please let me know.)
 
  The boost_control() function allows for the choice between center=TRUE
  and center=FALSE. If I select center=FALSE, I am able to interpret the
  coefficients just like those from standard logistic regression.
  However, if I select center=TRUE, this is no longer the case. In
  theory and in practice with my data, centering improves the
  predictions made by the model, so this is an issue worth pursuing for
  me.
 
  Below is output from running the exact same data in exactly the same
  way, only differing by whether the center bit is flipped or not:
 
  Output with center=TRUE:
  [(Intercept)] = -0.04543632
  [painscore] = 0.007553608
  [Offset] = -0.546520621809327
 
  Output with center=FALSE:
  [(Intercept)] = -0.989742
  [painscore] = 0.001342585
  [Offset] = -0.546520621809327
 
  The mean of painscore is 741. It seems to me that for center=FALSE,
  mboost should modify the intercept by subtracting 741*0.007553608 from
  it (thus intercept should = -11.285). If I manually do this, the
  output is credible, and in the ballpark of that given by other methods
  (e.g., lrm or glm with a Binomial link function). If I don't do this,
  then the inverse logistic interpretation of the output is off by
  orders of magnitude.
 
  In the end, with center=TRUE, and I want to make a prediction based
  on the coefficients returned by mboost, the results only make sense if
  I manually rescale my independent variables prior to making a
  prediction. Is this the desired behavior, or am I doing something
  wrong?
 
  I don't know, but my question is ... why aren't you using the predict 
method
  for that sort of object? Presumably the authors of the package know 
how to
  recognize the differences in the objects. Testing confirms this to be 
the

  case with the first example in the glmboost help page.
 
 
 
  Many thanks.
 
  __
  R-help at r-project.org mailing list
  

Re: [R] merge.zoo produces non unique chron time series

2010-03-19 Thread Gabor Grothendieck
Also, fyi, MATCH.times has been added to the development version of
zoo so in the future these workarounds will not be necessary.  That
is, in the next version of zoo one can simply write merge(zoo.ts.pot,
zoo.ts) here.

On Thu, Mar 18, 2010 at 6:37 PM, Gabor Grothendieck
ggrothendi...@gmail.com wrote:
 Here is a shorter and improved version:

 # 2
 Rnd - function(x) {
       time(x) - trunc(time(x), sec)
       x
 }
 zoo.ts.cor.2 - merge.zoo(Rnd(zoo.ts.pot), Rnd(zoo.ts))

 # 3
 MATCH.times - function(x, table, nomatch = NA, ...) match(trunc(x,
 sec), trunc(table, sec), nomatch = nomatch, ...)
 zoo.ts.cor.3 - merge.zoo(zoo.ts.pot, zoo.ts)




 On Thu, Mar 18, 2010 at 3:05 PM, Gabor Grothendieck
 ggrothendi...@gmail.com wrote:
 It occurs because the two series have times that are slightly
 different. For example, it may appear that the times at positions 909
 and 910 are the same but in fact they are different:

 tt - time(zoo.ts.cor)[909:910]; tt
 [1] (03/09/09 12:30:00) (03/09/09 12:30:00)
 diff(as.numeric(tt))
 [1] 1.818989e-12

 Here are two ways to deal with this:

 
 # 1. Use a different date/time class.
 

 
 # 2. Round off inputs to merge:
 

 rnd - function(x) round(24 * 3600 * x + 0.5) / (24 * 3600)
 Rnd - function(x) {
        time(x) - chron(rnd(as.numeric(time(x
        x
 }

 zoo.ts.cor.rnd - merge.zoo(Rnd(zoo.ts.pot), Rnd(zoo.ts))


 
 # 3. zoo provides a facility for the user to change how matching is done.
 #    Define a MATCH method for the class of interest.  In this case
 its done like this:
 

 # rnd function is from above
 MATCH.chron - function(x, table, nomatch = NA, ...) {
        match(rnd(as.numeric(x)), rnd(as.numeric(table)), nomatch = nomatch, 
 ...)
 }

 zoo.ts.cor.ok - merge.zoo(zoo.ts.pot, zoo.ts)


 On Thu, Mar 18, 2010 at 2:00 PM, Jan Schwanbeck jschw...@gmail.com wrote:
 Dear all,

 merge.zoo produces duplicated time indexes in the example stated below. Can
 anybody explain, what I am doing wrong?

 Many thanks!

 Jan

 (R 2.10.0, WindowsXP)

 require(chron)
 require(zoo)

 # create time series (zoo.ts) with no data from 31Aug2009 14:50 to 3Sep2009
 7:25
 t.st - chron(31/08/2009,09:20:00,format=c(d/m/Y,h:m:s))
 t.nd - chron(31/08/2009,14:50:00,format=c(d/m/Y,h:m:s))
 t.indexA-seq(t.st,t.nd,by=1/(24*12))

 t.st - chron(03/09/2009,07:25:00,format=c(d/m/Y,h:m:s))
 t.nd - chron(03/09/2009,23:55:00,format=c(d/m/Y,h:m:s))
 t.indexB-seq(t.st,t.nd,by=1/(24*12))

 t.index-c(t.indexA,t.indexB)

 zoo.ts - zoo(0,t.index)

 # create reference time series (zoo.ts.pot) without missing time steps
 t.st - head(time(zoo.ts),1)
 t.nd - tail(time(zoo.ts),1)
 t.index-seq(t.st,t.nd,by=1/(24*12))
 zoo.ts.pot - zoo(NA,t.index)

 # merge erroneous time series with reference time series
 zoo.ts.cor - merge.zoo(zoo.ts.pot,zoo.ts)

 
  Do not run: Results:
                              zoo.ts.pot zoo.ts
 (31/08/09 09:20:00)         NA      0
 (31/08/09 09:25:00)         NA      0
 (31/08/09 09:30:00)         NA      0
 ...
 (31/08/09 14:50:00)         NA      0
 (31/08/09 14:55:00)         NA     NA
 (31/08/09 15:00:00)         NA     NA
 (31/08/09 15:05:00)         NA     NA
 ...
 (03/09/09 07:15:00)         NA     NA
 (03/09/09 07:20:00)         NA     NA
 (03/09/09 07:25:00)         NA      0
 (03/09/09 07:30:00)         NA      0
 (03/09/09 07:35:00)         NA      0
 (03/09/09 07:40:00)         NA      0
 (03/09/09 07:45:00)         NA      0
 (03/09/09 07:50:00)         NA      0
 (03/09/09 07:55:00)         NA      0
 (03/09/09 08:00:00)         NA      0
 # everything o.k. up to here
 (03/09/09 08:00:00)         NA     NA
 # from here: every tenth time stamp is duplicated. Why?
 ...
 (03/09/09 08:45:00)         NA      0
 (03/09/09 08:45:00)         NA     NA
 ..
 (03/09/09 09:30:00)         NA      0
 (03/09/09 09:30:00)         NA     NA
 ...

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Sequence of ordered variable to add as column

2010-03-19 Thread jim holtman
Here is one way of doing it:

 df-data.frame(id=c(b,b,a,a,a),ord=c(2,1,1,3,2))
 dates-as.Date(c(02/27/92, 02/27/92, 01/14/92, 02/28/92,
+ 02/01/92),%m/%d/%y)
 df$dates-dates
 df$seq - ave(as.numeric(df$dates), df$id, FUN=order)
 df
  id ord  dates seq
1  b   2 1992-02-27   1
2  b   1 1992-02-27   2
3  a   1 1992-01-14   1
4  a   3 1992-02-28   3
5  a   2 1992-02-01   2


On Fri, Mar 19, 2010 at 6:25 AM, Duarte Viana viana.s...@gmail.com wrote:

 Hello all,

 As an example, consider the following dataframe

  df-data.frame(id=c(b,b,a,a,a),ord=c(2,1,1,3,2))
  dates-as.Date(c(02/27/92, 02/27/92, 01/14/92, 02/28/92,
 02/01/92),%m/%d/%y)
  df$dates-dates

 which was ordered with

  df-df[order(df$id,df$dates),]

 Now I would like to add a column containing a sequence (disregarding
 ties) that represents the order of the variable
 dates in each case of the variable id, resulting in this dataframe:

  seq.id-c(1,2,3,1,2)
  df$seq.id-seq.id

  id ord  dates seq.id
 3  a   1 1992-01-14  1
 5  a   2 1992-02-01  2
 4  a   3 1992-02-28  3
 1  b   2 1992-02-27  1
 2  b   1 1992-02-27  2


 Thanks in advance,

 Duarte Viana

 __
 R-help@r-project.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] Playwith with Linux Mint

2010-03-19 Thread Research
Hi,

I am having problems installing playwith on a Linux Mint ver. 8 (Helena) 
computer running R-2.10.1. src/base/R-2/R-2.10.1.tar.gz

Anybody facing similar problems?

Is it a GTK issue? I can not install the cairo related 
packages/libraries as well.

Any pointers very welcome.

Thanks + bestregards,
Costas

[[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] Playwith with Linux Mint

2010-03-19 Thread Liviu Andronic
Hello

On 3/19/10, Research risk2...@ath.forthnet.gr wrote:
  I am having problems installing playwith on a Linux Mint ver. 8 (Helena)
  computer running R-2.10.1. src/base/R-2/R-2.10.1.tar.gz

Linux Mint is Ubuntu-based, so a better venue would be r-sig-debian.


  Anybody facing similar problems?

  Is it a GTK issue? I can not install the cairo related
  packages/libraries as well.

Exactly, what issues? What commands do you issue? What errors do you
get? Did you read the posting guide (see below)? Without such info we
cannot really help. Regards
Liviu

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

2010-03-19 Thread Hosack, Michael
Hi everyone,

My question will probably seem simple to most of you, but I
have spent many hours trying to solve it. I need to perform
a series of sequential calculations on my dataframe that move
across rows and down columns, and then repeat themselves at
each unique 'MM' by 'DD' grouping. Specifically, I want to add
'DEPART' time (24 hr time) to 'TRAVEL'(minutes) in line 1 and
put the result in 'ARRIVE' (24 hr time) of line 2, then I want
to add 'WAIT' (minutes) to that 'ARRIVE' time of line 2 to
create 'DEPART', which will then be combined with 'TRAVEL'
(minutes) to yield the 'ARRIVE' time of line 3, etc. This
series of calc's will start anew beginning at each unique 'MM'
by 'DD' grouping. Any advice would be greatly appreciated.

Thank you,

Mike

SCHEDULE2 -
structure(list(MM = c(05, 05, 05, 05, 05, 05, 05,
05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 05,
05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 05,
05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 05,
05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 05,
05, 05, 05, 05, 05, 06, 06, 06, 06, 06, 06,
06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06,
06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06,
06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06,
06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06,
06, 06, 07, 07, 07, 07, 07, 07, 07, 07, 07,
07, 07, 07, 07, 07, 07, 07, 07, 07, 07, 07,
07, 07, 07, 07, 07, 07, 07, 07, 07, 07, 07,
07, 07, 07, 07, 07, 07, 07, 07, 07, 07, 07,
07, 07, 07, 07, 07, 07, 08, 08, 08, 08, 08,
08, 08, 08, 08, 08, 08, 08, 08, 08, 08, 08,
08, 08, 08, 08, 08, 08, 08, 08, 08, 08, 08,
08, 08, 08, 08, 08, 08, 08, 08, 08, 08, 08,
08, 08, 08, 08, 08, 08, 08, 08, 08, 08, 08,
08, 08, 08, 08, 08, 08, 08, 09, 09, 09, 09,
09, 09, 09, 09, 09, 09, 09, 09, 09, 09, 09,
09, 09, 09, 09, 09, 09, 09, 09, 09, 09, 09,
09, 09, 09, 09, 09, 09, 09, 09, 09, 09, 09,
09, 09, 09, 09, 09, 09, 09, 09, 09, 09, 09,
09, 09, 09, 09, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
10), DD = c(02, 02, 02, 02, 03, 03, 03, 03,
06, 06, 06, 06, 09, 09, 09, 09, 10, 10, 10,
10, 14, 14, 14, 14, 16, 16, 16, 16, 17, 17,
17, 17, 19, 19, 19, 19, 22, 22, 22, 22, 24,
24, 24, 24, 27, 27, 27, 27, 29, 29, 29, 29,
31, 31, 31, 31, 04, 04, 04, 04, 06, 06, 06,
06, 07, 07, 07, 07, 10, 10, 10, 10, 12, 12,
12, 12, 16, 16, 16, 16, 17, 17, 17, 17, 19,
19, 19, 19, 22, 22, 22, 22, 23, 23, 23, 23,
27, 27, 27, 27, 28, 28, 28, 28, 29, 29, 29,
29, 03, 03, 03, 03, 05, 05, 05, 05, 09, 09,
09, 09, 10, 10, 10, 10, 13, 13, 13, 13, 14,
14, 14, 14, 18, 18, 18, 18, 22, 22, 22, 22,
23, 23, 23, 23, 24, 24, 24, 24, 27, 27, 27,
27, 28, 28, 28, 28, 01, 01, 01, 01, 04, 04,
04, 04, 06, 06, 06, 06, 07, 07, 07, 07, 12,
12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14,
16, 16, 16, 16, 19, 19, 19, 19, 21, 21, 21,
21, 23, 23, 23, 23, 24, 24, 24, 24, 28, 28,
28, 28, 31, 31, 31, 31, 02, 02, 02, 02, 04,
04, 04, 04, 08, 08, 08, 08, 09, 09, 09, 09,
11, 11, 11, 11, 14, 14, 14, 14, 16, 16, 16,
16, 19, 19, 19, 19, 20, 20, 20, 20, 21, 21,
21, 21, 26, 26, 26, 26, 27, 27, 27, 27, 29,
29, 29, 29, 03, 03, 03, 03, 05, 05, 05, 05,
08, 08, 08, 08, 10, 10, 10, 10, 14, 14, 14,
14, 15, 15, 15, 15, 16, 16, 16, 16, 20, 20,
20, 20, 21, 21, 21, 21, 24, 24, 24, 24, 26,
26, 26, 26, 29, 29, 29, 29, 30, 30, 30, 30
), YEAR = c(2010, 2010, 2010, 2010, 2010, 2010, 2010,
2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010,
2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010,
2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010,
2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010,
2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010,
2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010,
2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010,
2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010,
2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010,
2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010,
2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010,
2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010,
2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010,
2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010,
2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010,
2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010,
2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010,
2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010,
2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010,
2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010,
2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010,
2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010,
2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010,
2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010,
2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010,
2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010,
2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010,
2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010,
2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010,
2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010,
2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010,
2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010,
2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010,
2010, 2010, 2010, 2010, 2010, 

Re: [R] How to plot two cumulative frequency graph together

2010-03-19 Thread David Winsemius


On Mar 18, 2010, at 11:00 PM, Gundala Viswanath wrote:


Dear masters,

I have data that looks like this:

#val  Freq1 Freq2
Get rid of the # at the beginning of the file. It wiil be interpreted  
as a comment rather than a header.



0.000 178 202
0.001 4611 5300
0.002 99 112
0.003 26 30
0.004 17 20
0.005 15 20
0.006 11 14
0.007 11 13
0.008 13 13
...many more lines..

Full data can be found here:
http://dpaste.com/173536/plain/

What I intend to do is to have a cumulative graph
with val as x-axis with Freq1  Freq2 as
y-axis, plot together in 1 graph.

What's the right way to approach this?


Not a very interesting plot because of that huge value of val at the  
end of that data. and it dose not look like a proper ECDF because the  
val values are not sorted.


conn= url(http://dpaste.com/173536/plain/;)
dfrm - read.table(file=conn, skip=1)
names(dfrm) - c(val,Freq1,Freq2)
 plot(dfrm$val,cumsum(dfrm$Freq1),type=s)

So I would clean up the data by ordering on val and maybe  
reconsidering the range of plotted data.


May also want to set the ylim on the basis of the sum of Freq2 because  
it is higher.


Use lines() with a step type for the second series.



--

David Winsemius, MD
West Hartford, CT

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


[R] How to handle missing value as first item in yearmon (zoo package)

2010-03-19 Thread Marshall Feldman

Hi,

Some time series have missing values in the time index. For example 
historical data on business cycles will typically date them from peak to 
trough, but some information may be missing. In most cases, this does 
not cause trouble,
but if the first date is missing (e.g., we know the date of the first 
trough but not the earlier peak), we want the first element in a list of 
dates to be NA. Using yearmon, this causes trouble. Consider this:


 x - as.yearmon(March 2010,%B %Y)
 y - c(x,NA)
 z - c(NA,x)
 y - yearmon(y)
 z - yearmon(z)
 y
[1] Mar 2010 NA
 z
Error in charToDate(x) :
  character string is not in a standard unambiguous format

Can someone explain how to make an object of type yearmon with a missing 
value in its first element?


Thanks.

Marsh Feldman

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 Specify An Improper Uniform Prior (Bayesian Analysis)

2010-03-19 Thread Ryan
Hi,

In Winbugs, one can assign a distribution called dflat(), which
corresponds to an improper uniform prior on the whole real line. What
would be the equivalent in R? I ask because I'm trying to run Winbugs
through R, and the model I've constructed in Winbugs includes a
dflat() distribution. For all of the normal priors in Winbugs, I've
been using rnorm in R.

Thanks,

Ryan

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

2010-03-19 Thread torgrims

Hey,

Anyone who knows what the following error report when calling lp() in
package lpSolve means?

Error: status 3 

JT
-- 
View this message in context: 
http://n4.nabble.com/lpSolve-tp1599380p1599380.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] (no subject)

2010-03-19 Thread Terry Therneau
The change has also been made to coxme.  I'm in the midst of another fix
(should be done by tomorrow) and will get posted to Rforge as soon as
that's done.
  Terry



On Thu, Mar 18, 2010 at 6:26 AM, Dieter Menne
dieter.me...@menne-biomed.de wrote:
 I am trying to use nlme and coxme in one Sweave document. I have read
the
 thread in r-devel on the subject,

 http://markmail.org/thread/snchg6ynofrzbf2v

 and nlme::fixef works, but I did not understand what workaround to use
when
 I am calling a function in a package that I do not want to change.

We discussed a fix for that which is to add a line to the NAMESPACE
file for any packages that want to define methods for the fixef or
ranef generic.  The line is simply

importFrom(nlme, fixef, ranef)

I thought Terry was going to add that in the coxme sources.

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

2010-03-19 Thread Randall Wrong
Dear R users,

?rgamma gives me :

   rgamma(n, shape, rate = 1, scale = 1/rate)

   rate: an alternative way to specify the scale.

   The Gamma distribution with parameters ‘shape’ = a and
   ‘scale’ = s has density
   f(x)= 1/(s^a Gamma(a)) x^(a-1) e^-(x/s)

Should I understand that scale=1/rate ? Is it written somewhere ?

Then rgamma(n, shape=a, scale = s) should be equivalent to rgamma(n,
shape=a, rate =1/s).

I don't find this very clear.

Thanks for your help.

Randall

[[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] Please Post Planned Contrasts Example in lme {nlme}

2010-03-19 Thread Max Kuhn
If these are contrasts of the fixed effects, the contrast package  
might do.


Max



On Mar 19, 2010, at 5:33 AM, Liviu Andronic landronim...@gmail.com  
wrote:



On 3/18/10, Martin Turcotte mart.turco...@gmail.com wrote:
Hi I am running some linear and non-linear mixed effect models and  
would like to do some planned contrasts (a priori contrasts)


I have looked in the help and in many forums and it seems possible  
to do so but don't understand how to write the function and I  
couldn't find an example in Pinheiro and Bates.



Did you try John Fox' appendix on mixed effects models [1]?
Liviu

[1] http://socserv.socsci.mcmaster.ca/jfox/Books/Companion/appendix.html

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 read.table with “Hebrew” c olumn names (in R)?

2010-03-19 Thread William Dunlap
 
 

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com 

 




From: Tal Galili [mailto:tal.gal...@gmail.com] 
Sent: Friday, March 19, 2010 12:36 AM
To: William Dunlap; istaz...@gmail.com
Cc: r-help@r-project.org
Subject: Re: [R] How to read.table with “Hebrew” column names (in R)?


Hello William, Ista and other R-help members,

The code you suggested:
read.table(http://www.talgalili.com/files/aa.txt,encoding=UTF-8; 
,check.names=FALSE, header = T, sep = \t)
Works for me the same way it does for you: I can read the data in 
(finally!), but some of the ways for using it fails (such as the printing, and 
the attempt at including column names in lm)

So first thanks for the help!

Second, could you please supply your  sessionInfo() ?
I wonder how your locale is compared to that of Ista, since it looks as 
if for Ista there is no problem with the Hebrew.

I was on Windows XP (American/English edition, if that makes
any difference) using a precompiled copy of R 2.11.0 downloaded
from CRAN (the Simon Fraser mirror) and sessionInfo() and
i10n_info() say:

   sessionInfo()
  R version 2.11.0 Under development (unstable) (2010-03-07 r51225) 
  i386-pc-mingw32 

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

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

  loaded via a namespace (and not attached):
  [1] tcltk_2.11.0
   l10n_info()
  $MBCS
  [1] FALSE

  $`UTF-8`
  [1] FALSE
  
  $`Latin-1`
  [1] TRUE

  $codepage
  [1] 1252

I cannot set the locale to Hebrew (nor to en_US or
en_US.utf8).
   Sys.setlocale(LC_ALL, Hebrew)
  [1] 
  Warning message:
  In Sys.setlocale(LC_ALL, Hebrew) :
OS reports request to set locale to Hebrew cannot be honored

I'd like to learn more about the issue since we've had problems
reading UTF-8 encoded XML files and using the results in R on
Windows.

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com 


Thanks for helping!
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 Fri, Mar 19, 2010 at 12:42 AM, William Dunlap wdun...@tibco.com 
wrote:


I tried this on R 2.11.0 unstable (2010-03-07 r51225) using
encoding=UTF-8 and check.names=FALSE in read.table().
It seemed to basically work, except that the data.frame/matrix 
printing
routine wants to print the Unicode codes for the characters
in the names:

   data1 - read.table(http://www.talgalili.com/files/aa.txt;,
  header = TRUE, sep = \t, encoding=UTF-8, 
check.names=FALSE)
   data1 # I see Unicode codes, presumably the correct ones
U+05D0U+05D7U+05EA 
U+05E9U+05EAU+05D9U+05D9U+05DD
  1   12
   97
  2  123
  354
  36
1
U+05E9U+05DCU+05D5U+05E9
  16
  2   44
  33
   colnames(data1) # I see Hebrew strings (in R the first 
starts with aleph)
  [1] אחת   שתיים שלוש
   colnames(data)[1]
  [1] אחת
   strsplit(colnames(data)[1], )[[1]][1]
  [1] א
   data1[,שתיים]
  [1]  97 354   1

I'm writing this in Outlook in the English (American) locale
and the copy-n-paste from the R gui window to the Outlook window
of the Hebrew letters reversed the whole line of them (reversing
the characters in each name and the names in the line), which I
why I showed a subset of the names and a substring of the first 
name.

However, when I try to use lm() with this data.frame then I run 
into
trouble, which is probably the same problem as I see in the
data.frame printing:

   lm(`שתיים` ~ `שלוש`)
  

Re: [R] How to handle missing value as first item in yearmon (zoo package)

2010-03-19 Thread Gabor Grothendieck
There is a bug in as.Date.yearmon and as.Date.yearqtr which is
triggered by certain NAs.  Its now fixed in the development version of
zoo on R-forge.  Note that in your code it only affecting printing of
the yearmon variable.  The yearmon variable itself is correct.

Try this:

source(http://r-forge.r-project.org/plugins/scmsvn/viewcvs.php/*checkout*/pkg/zoo/R/yearmon.R?rev=686root=zoo;)
x - as.yearmon(March 2010,%B %Y)
z - yearmon(c(NA, x))
z


On Fri, Mar 19, 2010 at 9:36 AM, Marshall Feldman ma...@uri.edu wrote:
 Hi,

 Some time series have missing values in the time index. For example
 historical data on business cycles will typically date them from peak to
 trough, but some information may be missing. In most cases, this does not
 cause trouble,
 but if the first date is missing (e.g., we know the date of the first trough
 but not the earlier peak), we want the first element in a list of dates to
 be NA. Using yearmon, this causes trouble. Consider this:

 x - as.yearmon(March 2010,%B %Y)
 y - c(x,NA)
 z - c(NA,x)
 y - yearmon(y)
 z - yearmon(z)
 y
        [1] Mar 2010 NA
 z
    Error in charToDate(x) :
      character string is not in a standard unambiguous format

 Can someone explain how to make an object of type yearmon with a missing
 value in its first element?

 Thanks.

    Marsh Feldman

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

2010-03-19 Thread Erich Neuwirth
with the following code

newvars()$ARRIVALS and newvars()$DEPARTURES
will give you the new variables you need.


-=-=-=


addDelays - function(arriveTime,waitVec,travelVec){
  start-as.POSIXct(arriveTime,format=%H:%M:%S)
  delays-as.vector(t(cbind(waitVec,travelVec)))
  newtimes-format(start+cumsum(delays)*60,format=%H:%M:%S)
  list(departs=c(arriveTime,(odds(newtimes))[-1]),
   arrives=evens(newtimes))
}

odds - function(inVec){
  indvec-0:(floor((length(inVec)-1)/2))
  inVec[2*indvec+1]
}

evens - function(inVec){
  odds(inVec[-1])
}


newvars - function(){
  DATE-with(SCHEDULE2,paste(YEAR,MM,DD,sep=))
  starts-as.list(with(SCHEDULE2,tapply(ARRIVE,DATE,function(x)x[1])))
  waits-with(SCHEDULE2,tapply(WAIT,DATE,function(x)x))
  travels-with(SCHEDULE2,tapply(TRAVEL,DATE,function(x)x))
  list(DEPARTURES=

as.vector(mapply(function(...)addDelays(...)$departs,starts,waits,travels)),
ARRIVALS=

as.vector(mapply(function(...)addDelays(...)$arrives,starts,waits,travels)))
}



-- 
Erich Neuwirth, University of Vienna
Faculty of Computer Science
Computer Supported Didactics Working Group
Visit our SunSITE at http://sunsite.univie.ac.at
Phone: +43-1-4277-39464 Fax: +43-1-4277-39459

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


Re: [R] Pedigree / Identifying Immediate Family of Index Animal

2010-03-19 Thread Terry Therneau
On Thu, 18 Mar 2010, Ben Bimber wrote:

 I have a data frame containing the Id, Mother, Father and Sex from
about
 10,000 animals in our colony.  I am interested in graphing simple
family
 trees for a given subject or small number of subjects.  The basic idea
is:
 start with data frame from entire colony and list of index animals.  I
need
 to identify all immediate relatives of these index animals and plot
the
 pedigree for them.  We're not trying to do any sort of real analysis,
just
 present a visualization of the family structure.  I have used the
kinship
 and pedigree packages to plot the pedigree.  My question relates to
 efficiently identifying the animals to include in the pedigree:


 Your basic idea is sound -- the drawing programs do the same type of
thing and it is very fast.  Your loop is only over 3 generations.  My
version of the function interleaves the up/down steps.
Terry Therneau
findKin - function(id, dadid, momid, index, generations=3) {
idrow - match(index, id)
if (any(is.na(idrow))) stop(Index subject not found)

for (i in 1:generations) {
# add parents
idrow - c(idrow, match(momid[idrow], id, nomatch=0),
  match(dadid[idrow], id, nomatch=0))
idrow - unique(idrow[idrow0])  # toss the zeros

# add children
idrow - c(idrow, which(match(momid, id[idrow], nomatch=0) 0),
  which(match(dadid, id[idrow], nomatch=0) 0))
idrow - unique(idrow[idrow0])
}
idrow
}

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

2010-03-19 Thread dc896148

Hello,
I have a simple question about breaking out of a For loop.
When I use the 'break' statement within a For loop, say on the first of
several iterations, does control return to the top of the loop for the next
iteration, or does the For loop stop completely and no further iterations
are processed?

Thanks!
-- 
View this message in context: 
http://n4.nabble.com/Breaking-from-For-loop-question-tp1599540p1599540.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] Different results from survreg with version 2.6.1 and 2.10.1

2010-03-19 Thread nathalcs
 Original Message 
Subject: Different results from survreg with version 2.6.1 and 2.10.1
From:natha...@ulrik.uio.no
Date:Fri, March 19, 2010 16:00
To:  r-help@r-project.org
--

 Dear all

I'm using survreg command in package survival.

sur2=survreg(Surv((levetid-364),status==2)~vekt.ind,control=list(maxiter=50),data=ord.mfr)

When using

R version 2.6.1 (2007-11-26)
i386-pc-mingw32

I get this result

 summary(sur2)

Call:
survreg(formula = Surv((levetid - 364), status == 2) ~ malder +
faar + gest + vekt.ind, data = ord.mfr, control = list(maxiter = 50))
   Value Std. Error   zp
(Intercept) 1.49e+011.73105  8.5993 8.02e-18
malder  9.22e-020.01955  4.7178 2.38e-06
faar2.78e-020.01308  2.1272 3.34e-02
gest3.79e-040.00528  0.0718 9.43e-01
vekt.ind8.46e-010.19575  4.3234 1.54e-05
Log(scale)  6.83e-010.03651 18.7086 4.22e-78

Scale= 1.98

Weibull distribution
Loglik(model)= -11108.6   Loglik(intercept only)= -11136.6
Chisq= 55.87 on 4 degrees of freedom, p= 2.1e-11
Number of Newton-Raphson Iterations: 13
n= 254572

while when using

R version 2.10.1 (2009-12-14)
i386-pc-mingw32

this is what I get

ummary(sur2)

Call:
survreg(formula = Surv((levetid - 364), status == 2) ~ malder +
faar + gest + vekt.ind, data = ord.mfr, control = list(maxiter = 50))
Value Std. Error z p
(Intercept)  -7.95477   2.83e-34 -2.81e+34 0
malder0.01635   2.61e-36  6.25e+33 0
faar  0.29213   2.60e-36  1.12e+35 0
gest -0.00275   7.54e-37 -3.64e+33 0
vekt.ind  0.28575   2.96e-35  9.64e+33 0
Log(scale)  -95.89809   5.88e-36 -1.63e+37 0

Scale= 2.25e-42

Weibull distribution
Loglik(model)= -82219.2   Loglik(intercept only)= -11136.6
Chisq= -142165.2 on 4 degrees of freedom, p= 1
Number of Newton-Raphson Iterations: 2
n= 254572

which is quite different results, with the result with version 2.6.1 being
 the most reasonable.

But if I for instance do a cox-regression on on the same data with the
same covariate with the two different versions I do get the same result,
which is how it should be

R version 2.6.1 (2007-11-26):
print(coxfit2)
Call:
coxph(formula = Surv(levetid, status == 2) ~ malder + faar +
gest + vekt.ind, data = ord.mfr)


  coef exp(coef) se(coef)  z   p
malder   -0.046320 0.955  0.00972 -4.767 1.9e-06
faar -0.040658 0.960  0.00639 -6.367 1.9e-10
gest -0.000211 1.000  0.00267 -0.079 9.4e-01
vekt.ind -0.427916 0.652  0.09765 -4.382 1.2e-05

Likelihood ratio test=102  on 4 df, p=0  n= 254572


R version 2.10.1 (2009-12-14):
 print(coxfit2)
Call:
coxph(formula = Surv(levetid, status == 2) ~ malder + faar +
gest + vekt.ind, data = ord.mfr)


  coef exp(coef) se(coef)  z   p
malder   -0.046320 0.955  0.00972 -4.767 1.9e-06
faar -0.040658 0.960  0.00639 -6.367 1.9e-10
gest -0.000211 1.000  0.00267 -0.079 9.4e-01
vekt.ind -0.427916 0.652  0.09765 -4.382 1.2e-05

Likelihood ratio test=102  on 4 df, p=0  n= 254572

My question is why do this happen with survreg?

Best regards
Nathalie Støer

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

2010-03-19 Thread Tord Snäll
Dear all,
We have a data base with huge amounts of data that we want analysts/scientists 
to be able to use. These data can be accessed through the internet thanks to a 
SOAP based web service that we have set up. We have also developed a web 
service client using Dot.NET framework, which is built into a .dll file. 

I now wonder, do you know of a way to execute the functions in .dll files from 
within R?

Thanks,
Tord

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


Re: [R] Gamma parametrization

2010-03-19 Thread G. Jay Kerns
Dear Randall,

On Fri, Mar 19, 2010 at 10:24 AM, Randall Wrong randall.wr...@gmail.com wrote:
 Dear R users,

 ?rgamma gives me :

               rgamma(n, shape, rate = 1, scale = 1/rate)

               rate: an alternative way to specify the scale.

               The Gamma distribution with parameters ‘shape’ = a and
               ‘scale’ = s has density
               f(x)= 1/(s^a Gamma(a)) x^(a-1) e^-(x/s)

 Should I understand that scale=1/rate ? Is it written somewhere ?

You are kidding, right?  It is written 8 lines above your question, by
my count.  :-)

Perhaps you meant rate = 1/scale.


 Then rgamma(n, shape=a, scale = s) should be equivalent to rgamma(n,
 shape=a, rate =1/s).

Yep:
dgamma(2, shape = 3, scale = 4)
dgamma(2, shape = 3, rate = 1/4)


 I don't find this very clear.

 Thanks for your help.

 Randall


The point is that some books (and software) parameterize by the
'scale', and a whole other bunch parameterize by the 'rate'.  The
reader (and user) always needs to be careful that the version used is
the one expected. And the help file says that S doesn't have a 'scale'
parameter at all.

Just be careful, and you should be fine.  And IMHO, given that the PDF
of the density is shown it is reasonably clear as-is.

Best,
Jay





***
G. Jay Kerns, Ph.D.
Associate Professor
Department of Mathematics  Statistics
Youngstown State University
Youngstown, OH 44555-0002 USA
Office: 1035 Cushwa Hall
Phone: (330) 941-3310 Office (voice mail)
-3302 Department
-3170 FAX
VoIP: gjke...@ekiga.net
E-mail: gke...@ysu.edu
http://people.ysu.edu/~gkerns/

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


Re: [R] Dataframe calculations

2010-03-19 Thread Hosack, Michael
Erich,

Thank you so much for the effort you put into writing this code.
 I ran it and then assigned the two variables you created to the
'ARRIVE' and 'DEPART' variables of my dataframe as you directed and
the resultant calculations were incorrect. I am not sure why it did
not work, I do not yet grasp the coding, I am still a novice.
Perhaps you or someone else could rerun your code on my original
dataframe and see why it did not yield the correct results.

Thank you,

Mike

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Erich Neuwirth
Sent: Friday, March 19, 2010 11:38 AM
To: r-help@r-project.org
Subject: Re: [R] Dataframe calculations

with the following code

newvars()$ARRIVALS and newvars()$DEPARTURES
will give you the new variables you need.


-=-=-=


addDelays - function(arriveTime,waitVec,travelVec){
  start-as.POSIXct(arriveTime,format=%H:%M:%S)
  delays-as.vector(t(cbind(waitVec,travelVec)))
  newtimes-format(start+cumsum(delays)*60,format=%H:%M:%S)
  list(departs=c(arriveTime,(odds(newtimes))[-1]),
   arrives=evens(newtimes))
}

odds - function(inVec){
  indvec-0:(floor((length(inVec)-1)/2))
  inVec[2*indvec+1]
}

evens - function(inVec){
  odds(inVec[-1])
}


newvars - function(){
  DATE-with(SCHEDULE2,paste(YEAR,MM,DD,sep=))
  starts-as.list(with(SCHEDULE2,tapply(ARRIVE,DATE,function(x)x[1])))
  waits-with(SCHEDULE2,tapply(WAIT,DATE,function(x)x))
  travels-with(SCHEDULE2,tapply(TRAVEL,DATE,function(x)x))
  list(DEPARTURES=

as.vector(mapply(function(...)addDelays(...)$departs,starts,waits,travels)),
ARRIVALS=

as.vector(mapply(function(...)addDelays(...)$arrives,starts,waits,travels)))
}



SCHEDULE2 -
structure(list(MM = c(05, 05, 05, 05, 05, 05, 05, 05, 05, 
05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 
05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 
05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 
05, 05, 05, 05, 05, 05, 05, 05, 06, 06, 06, 06, 06, 
06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 
06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 
06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 
06, 06, 06, 06, 06, 06, 06, 06, 07, 07, 07, 07, 07, 
07, 07, 07, 07, 07, 07, 07, 07, 07, 07, 07, 07, 07, 
07, 07, 07, 07, 07, 07, 07, 07, 07, 07, 07, 07, 07, 
07, 07, 07, 07, 07, 07, 07, 07, 07, 07, 07, 07, 07, 
07, 07, 07, 07, 08, 08, 08, 08, 08, !
 08, 08, 08, 08, 08, 08, 08, 08, 08, 08, 08, 08, 08, 
08, 08, 08, 08, 08, 08, 08, 08, 08, 08, 08, 08, 08, 
08, 08, 08, 08, 08, 08, 08, 08, 08, 08, 08, 08, 08, 
08, 08, 08, 08, 08, 08, 08, 08, 08, 08, 08, 08, 09, 
09, 09, 09, 09, 09, 09, 09, 09, 09, 09, 09, 09, 09, 
09, 09, 09, 09, 09, 09, 09, 09, 09, 09, 09, 09, 09, 
09, 09, 09, 09, 09, 09, 09, 09, 09, 09, 09, 09, 09, 
09, 09, 09, 09, 09, 09, 09, 09, 09, 09, 09, 09, 10, 
10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 
10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 
10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 
10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10), DD = 
c(02, 02, 02, 02, 03, 03, 03, 03, 06!
 , 06, 06, 06, 09, 09, 09, 09, 10, 10, 10, 10, 
14, 14, 14, 14, 16, 16, 16, 16, 17, 17, 17, 17, 19, 
19, 19, 19, 22, 22, 22, 22, 24, 24, 24, 24, 27, 27, 
27, 27, 29, 29, 29, 29, 31, 31, 31, 31, 04, 04, 04, 
04, 06, 06, 06, 06, 07, 07, 07, 07, 10, 10, 10, 10, 
12, 12, 12, 12, 16, 16, 16, 16, 17, 17, 17, 17, 19, 
19, 19, 19, 22, 22, 22, 22, 23, 23, 23, 23, 27, 27, 
27, 27, 28, 28, 28, 28, 29, 29, 29, 29, 03, 03, 03, 
03, 05, 05, 05, 05, 09, 09, 09, 09, 10, 10, 10, 10, 
13, 13, 13, 13, 14, 14, 14, 14, 18, 18, 18, 18, 22, 
22, 22, 22, 23, 23, 23, 23, 24, 24, 24, 24, 27, 27, 
27, 27, 28, 28, 28, 28, 01, 01, 01, 01, 04, 04, 04, 
04, 06, 06, 06, 06, 07, 07, 07, 07, 12, 12, 12, 12, 
13, 13, 13, 13, 14, 14, 14, 14, 16, !
 16, 16, 16, 19, 19, 19, 19, 21, 21, 21, 21, 23, 23, 
23, 23, 24, 24, 24, 24, 28, 28, 28, 28, 31, 31, 31, 
31, 02, 02, 02, 02, 04, 04, 04, 04, 08, 08, 08, 08, 
09, 09, 09, 09, 11, 11, 11, 11, 14, 14, 14, 14, 16, 
16, 16, 16, 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 
21, 21, 26, 26, 26, 26, 27, 27, 27, 27, 29, 29, 29, 
29, 03, 03, 03, 03, 05, 05, 05, 05, 08, 08, 08, 08, 
10, 10, 10, 10, 14, 14, 14, 14, 15, 15, 15, 15, 16, 
16, 16, 16, 20, 20, 20, 20, 21, 21, 21, 21, 24, 24, 
24, 24, 26, 26, 26, 26, 29, 29, 29, 29, 30, 30, 30, 
30
), YEAR = c(2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 
2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 
2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 
2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 
2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 
2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 
2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 
2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 
2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 
2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 
2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 

[R] execute functions in .dll

2010-03-19 Thread Tord Snäll
Dear all,
We have a data base with huge amounts of data that we want analysts/scientists 
to be able to use. These data can be accessed through the internet thanks to a 
SOAP based web service that we have set up. We have also developed a web 
service client using Dot.NET framework, which is built into a .dll file. 

I now wonder, do you know of a way to execute the functions in .dll files from 
within R?

Thanks,
Tord

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

2010-03-19 Thread Hadley Wickham
Hi all,

Does any one know of any encryption/decryption algorithms in R?  I'm
not looking for anything robust - I want some way of printing output
to the screen that the user can't read immediately, but can decrypt a
little later.  The main thing I don't want to the user to see is a
number, so (e.g.) ROT13 isn't appropriate.

Hadley

-- 
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/

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


Re: [R] Encrypt/decrypt in R

2010-03-19 Thread Barry Rowlingson
On Fri, Mar 19, 2010 at 5:00 PM, Hadley Wickham had...@rice.edu wrote:
 Hi all,

 Does any one know of any encryption/decryption algorithms in R?  I'm
 not looking for anything robust - I want some way of printing output
 to the screen that the user can't read immediately, but can decrypt a
 little later.  The main thing I don't want to the user to see is a
 number, so (e.g.) ROT13 isn't appropriate.

 You could just include the numbers in a ROT13-sort of algorithm. It
would end up being ROT-18 I guess...

 Would a single permutation of c(letters,0:9) be sufficient? Or you
could add other characters. And what about non-ascii encodings?
Hmmm...

 a bit of strsplit, match, paste magic should do it...

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] Encrypt/decrypt in R

2010-03-19 Thread Gabor Grothendieck
chartr?

On Fri, Mar 19, 2010 at 1:00 PM, Hadley Wickham had...@rice.edu wrote:
 Hi all,

 Does any one know of any encryption/decryption algorithms in R?  I'm
 not looking for anything robust - I want some way of printing output
 to the screen that the user can't read immediately, but can decrypt a
 little later.  The main thing I don't want to the user to see is a
 number, so (e.g.) ROT13 isn't appropriate.

 Hadley

 --
 Assistant Professor / Dobelman Family Junior Chair
 Department of Statistics / Rice University
 http://had.co.nz/

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


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] FW: New public-use Education Longitudinal Study of 2002 Base Year to 2006 Second Follow-up data set released

2010-03-19 Thread Art Burke
Colleagues ... The site identified below makes survey data available for public 
use.  Data may be downloaded in R format; the site also provides R syntax files 
to accompany the downloaded data. Registration is required.

On another matter, in anticipation of future projects, I would like to hear 
from readers of this list with expertise in using R for analysis of 
longitudinal data and interest in collaborating on educational studies.

Art
___
Art Burke
Associate
Education Northwest
101 SW Main St, Suite 500
Portland OR 97204-3213
art.bu...@educationnorthwest.org
Phone: 503-275-9592
www.educationnorthwest.org
__

-Original Message-
From: IES Newsflash Subscription Service [mailto:ieswebmas...@ed.gov] 
Sent: Friday, March 19, 2010 7:07 AM
To: Art Burke
Subject: New public-use Education Longitudinal Study of 2002 Base Year to 2006 
Second Follow-up data set released

The National Center for Education Statistics within the Institute of Education 
Sciences has just released a new public-use version of the Educational 
Longitudinal Study of 2002 Base Year to 2006 Second Follow-up data files. 

The data files are available for immediate download using a new EDAT 
application on the NCES website. This application allows users to select the 
data that they need to perform analyses in one of six statistical programming 
languages.

To access EDAT, please visit
http://nces.ed.gov/edat  

Once you arrive in the EDAT application, enter your email address and create a 
password.  This will give you access to the application and provide you with 
space for sharing tag files. 

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


Re: [R] Encrypt/decrypt in R

2010-03-19 Thread Marc Schwartz
On Mar 19, 2010, at 12:00 PM, Hadley Wickham wrote:

 Hi all,
 
 Does any one know of any encryption/decryption algorithms in R?  I'm
 not looking for anything robust - I want some way of printing output
 to the screen that the user can't read immediately, but can decrypt a
 little later.  The main thing I don't want to the user to see is a
 number, so (e.g.) ROT13 isn't appropriate.
 
 Hadley

I don't know of anything offhand in R and anything beyond very simple stuff 
would be rather slow in an interpreted language. You can always create 
character translations and such using functions such as chartr().

There is GnuPG (http://www.gnupg.org), which provides a broad range of 
algorithms via a CLI interface, which can be called via system().

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] Encrypt/decrypt in R

2010-03-19 Thread Henrique Dallazuanna
Perhaps, If is there a connection with mysql:

library(RMySQL)
#conn - dbConnect(...)
encStr - dbGetQuery(conn, SELECT AES_ENCRYPT('teste', 'password'))
dbGetQuery(conn, sprintf(SELECT AES_DECRYPT('%s', 'password'), encStr))


On Fri, Mar 19, 2010 at 2:00 PM, Hadley Wickham had...@rice.edu wrote:
 Hi all,

 Does any one know of any encryption/decryption algorithms in R?  I'm
 not looking for anything robust - I want some way of printing output
 to the screen that the user can't read immediately, but can decrypt a
 little later.  The main thing I don't want to the user to see is a
 number, so (e.g.) ROT13 isn't appropriate.

 Hadley

 --
 Assistant Professor / Dobelman Family Junior Chair
 Department of Statistics / Rice University
 http://had.co.nz/

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




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


Re: [R] Dataframe calculations

2010-03-19 Thread Erich Neuwirth
Sorry,
Oddly I got the use of odds and evens the wrong way round.

addDelays - function(arriveTime,waitVec,travelVec){
  start-as.POSIXct(arriveTime,format=%H:%M:%S)
  delays-as.vector(t(cbind(waitVec,travelVec)))
  newtimes-format(start+cumsum(delays)*60,format=%H:%M:%S)
  list(departs=c(arriveTime,(evens(newtimes))[-1]),
   arrives=odds(newtimes))
}

Using the new definition of addDelays above should do the trick.



On 3/19/2010 5:30 PM, Hosack, Michael wrote:
 Erich,
 
 Thank you so much for the effort you put into writing this code.
  I ran it and then assigned the two variables you created to the
 'ARRIVE' and 'DEPART' variables of my dataframe as you directed and
 the resultant calculations were incorrect. I am not sure why it did
 not work, I do not yet grasp the coding, I am still a novice.
 Perhaps you or someone else could rerun your code on my original
 dataframe and see why it did not yield the correct results.
 
 Thank you,
 
 Mike
 
 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
 Behalf Of Erich Neuwirth
 Sent: Friday, March 19, 2010 11:38 AM
 To: r-help@r-project.org
 Subject: Re: [R] Dataframe calculations
 
 with the following code
 
 newvars()$ARRIVALS and newvars()$DEPARTURES
 will give you the new variables you need.
 
 
 -=-=-=
 
 
 addDelays - function(arriveTime,waitVec,travelVec){
   start-as.POSIXct(arriveTime,format=%H:%M:%S)
   delays-as.vector(t(cbind(waitVec,travelVec)))
   newtimes-format(start+cumsum(delays)*60,format=%H:%M:%S)
   list(departs=c(arriveTime,(odds(newtimes))[-1]),
arrives=evens(newtimes))
 }
 
 odds - function(inVec){
   indvec-0:(floor((length(inVec)-1)/2))
   inVec[2*indvec+1]
 }
 
 evens - function(inVec){
   odds(inVec[-1])
 }
 
 
 newvars - function(){
   DATE-with(SCHEDULE2,paste(YEAR,MM,DD,sep=))
   starts-as.list(with(SCHEDULE2,tapply(ARRIVE,DATE,function(x)x[1])))
   waits-with(SCHEDULE2,tapply(WAIT,DATE,function(x)x))
   travels-with(SCHEDULE2,tapply(TRAVEL,DATE,function(x)x))
   list(DEPARTURES=
 
 as.vector(mapply(function(...)addDelays(...)$departs,starts,waits,travels)),
 ARRIVALS=
 
 as.vector(mapply(function(...)addDelays(...)$arrives,starts,waits,travels)))
 }
 
 
 
 SCHEDULE2 -
 structure(list(MM = c(05, 05, 05, 05, 05, 05, 05, 05, 05, 
 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 
 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 
 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 
 05, 05, 05, 05, 05, 05, 05, 05, 06, 06, 06, 06, 06, 
 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 
 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 
 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 
 06, 06, 06, 06, 06, 06, 06, 06, 07, 07, 07, 07, 07, 
 07, 07, 07, 07, 07, 07, 07, 07, 07, 07, 07, 07, 07, 
 07, 07, 07, 07, 07, 07, 07, 07, 07, 07, 07, 07, 07, 
 07, 07, 07, 07, 07, 07, 07, 07, 07, 07, 07, 07, 07, 
 07, 07, 07, 07, 08, 08, 08, 08, 08,
 !
  08, 08, 08, 08, 08, 08, 08, 08, 08, 08, 08, 08, 08, 
 08, 08, 08, 08, 08, 08, 08, 08, 08, 08, 08, 08, 08, 
 08, 08, 08, 08, 08, 08, 08, 08, 08, 08, 08, 08, 08, 
 08, 08, 08, 08, 08, 08, 08, 08, 08, 08, 08, 08, 09, 
 09, 09, 09, 09, 09, 09, 09, 09, 09, 09, 09, 09, 09, 
 09, 09, 09, 09, 09, 09, 09, 09, 09, 09, 09, 09, 09, 
 09, 09, 09, 09, 09, 09, 09, 09, 09, 09, 09, 09, 09, 
 09, 09, 09, 09, 09, 09, 09, 09, 09, 09, 09, 09, 10, 
 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 
 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 
 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 
 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10), DD = 
 c(02, 02, 02, 02, 03, 03, 03, 03, 
06!
  , 06, 06, 06, 09, 09, 09, 09, 10, 10, 10, 10, 
 14, 14, 14, 14, 16, 16, 16, 16, 17, 17, 17, 17, 19, 
 19, 19, 19, 22, 22, 22, 22, 24, 24, 24, 24, 27, 27, 
 27, 27, 29, 29, 29, 29, 31, 31, 31, 31, 04, 04, 04, 
 04, 06, 06, 06, 06, 07, 07, 07, 07, 10, 10, 10, 10, 
 12, 12, 12, 12, 16, 16, 16, 16, 17, 17, 17, 17, 19, 
 19, 19, 19, 22, 22, 22, 22, 23, 23, 23, 23, 27, 27, 
 27, 27, 28, 28, 28, 28, 29, 29, 29, 29, 03, 03, 03, 
 03, 05, 05, 05, 05, 09, 09, 09, 09, 10, 10, 10, 10, 
 13, 13, 13, 13, 14, 14, 14, 14, 18, 18, 18, 18, 22, 
 22, 22, 22, 23, 23, 23, 23, 24, 24, 24, 24, 27, 27, 
 27, 27, 28, 28, 28, 28, 01, 01, 01, 01, 04, 04, 04, 
 04, 06, 06, 06, 06, 07, 07, 07, 07, 12, 12, 12, 12, 
 13, 13, 13, 13, 14, 14, 14, 14, 16
, !
  16, 16, 16, 19, 19, 19, 19, 21, 21, 21, 21, 23, 
 23, 23, 23, 24, 24, 24, 24, 28, 28, 28, 28, 31, 31, 
 31, 31, 02, 02, 02, 02, 04, 04, 04, 04, 08, 08, 08, 
 08, 09, 09, 09, 09, 11, 11, 11, 11, 14, 14, 14, 14, 
 16, 16, 16, 16, 19, 19, 19, 19, 20, 20, 20, 20, 21, 
 21, 21, 21, 26, 26, 26, 26, 27, 27, 27, 27, 29, 29, 
 29, 29, 03, 03, 03, 03, 05, 05, 05, 05, 08, 08, 08, 
 08, 10, 10, 10, 10, 14, 14, 14, 14, 15, 15, 15, 15, 
 16, 16, 16, 16, 20, 20, 20, 20, 21, 21, 21, 21, 24, 
 24, 24, 24, 26, 26, 26, 26, 29, 29, 29, 29, 30, 30, 
 30, 30
 ), YEAR = c(2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 
 2010, 2010, 

Re: [R] Encrypt/decrypt in R

2010-03-19 Thread Barry Rowlingson
On Fri, Mar 19, 2010 at 5:10 PM, Barry Rowlingson
b.rowling...@lancaster.ac.uk wrote:
 On Fri, Mar 19, 2010 at 5:00 PM, Hadley Wickham had...@rice.edu wrote:
 Hi all,

 Does any one know of any encryption/decryption algorithms in R?  I'm
 not looking for anything robust - I want some way of printing output
 to the screen that the user can't read immediately, but can decrypt a
 little later.  The main thing I don't want to the user to see is a
 number, so (e.g.) ROT13 isn't appropriate.

  You could just include the numbers in a ROT13-sort of algorithm. It
 would end up being ROT-18 I guess...

 ROT-18 (?) using chartr:

  oldletters=c(letters,0:9)
  old=paste(oldletters,collapse=)
  new=paste(c(oldletters[19:36],oldletters[1:18]),collapse=)
  chartr(old,new,message)
 [1] g6c zsdw e65 kl.qr v633s9a
  chartr(old,new,chartr(old,new,message))
 [1] you have won 23.89 dollars

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] Breaking from For loop question

2010-03-19 Thread Duncan Murdoch

On 19/03/2010 11:32 AM, dc896148 wrote:

Hello,
I have a simple question about breaking out of a For loop.
When I use the 'break' statement within a For loop, say on the first of
several iterations, does control return to the top of the loop for the next
iteration, or does the For loop stop completely and no further iterations
are processed?

Thanks!
  

See ?Control.  (?break would also work.)

Duncan Murdoch

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


Re: [R] execute functions in .dll

2010-03-19 Thread Duncan Murdoch

On 19/03/2010 12:47 PM, Tord Snäll wrote:

Dear all,
We have a data base with huge amounts of data that we want analysts/scientists to be able to use. These data can be accessed through the internet thanks to a SOAP based web service that we have set up. We have also developed a web service client using Dot.NET framework, which is built into a .dll file. 


I now wonder, do you know of a way to execute the functions in .dll files from 
within R?



If you can call them from C, you can write a simple wrapper.  See 
Writing R Extensions for how to write the R to C interface.  Writing the 
interface from to your DLL is up to you.  (It's possible R could call 
your DLL directly, but it is somewhat limited in the kinds of interfaces 
it supports, so you usually need the wrapper.)


Duncan Murdoch

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


Re: [R] Dataframe calculations

2010-03-19 Thread Hosack, Michael
Unfortunately, that did not correct the problem. Times for 'ARRIVE' need to be 
either 07:00:00 or 14:30:00 for the first case of each unique 'MM' by 'DD' 
subgroup (the others will be calculated), and the code produces calculations 
that I can't interpret from the fixed numbers. Also, 'ARRIVE' and 'DEPART' 
incorrectly have the same value for the first case of each unique 'MM' by 'DD' 
subgroup. 'DEPART' should equal 'ARRIVE' plus the 'WAIT' time in minutes of the 
same line.

Thank you,

Mike

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Erich Neuwirth
Sent: Friday, March 19, 2010 1:33 PM
To: r-help@r-project.org
Subject: Re: [R] Dataframe calculations

Sorry,
Oddly I got the use of odds and evens the wrong way round.

addDelays - function(arriveTime,waitVec,travelVec){
  start-as.POSIXct(arriveTime,format=%H:%M:%S)
  delays-as.vector(t(cbind(waitVec,travelVec)))
  newtimes-format(start+cumsum(delays)*60,format=%H:%M:%S)
  list(departs=c(arriveTime,(evens(newtimes))[-1]),
   arrives=odds(newtimes))
}

Using the new definition of addDelays above should do the trick.



On 3/19/2010 5:30 PM, Hosack, Michael wrote:
 Erich,

 Thank you so much for the effort you put into writing this code.
  I ran it and then assigned the two variables you created to the
 'ARRIVE' and 'DEPART' variables of my dataframe as you directed and
 the resultant calculations were incorrect. I am not sure why it did
 not work, I do not yet grasp the coding, I am still a novice.
 Perhaps you or someone else could rerun your code on my original
 dataframe and see why it did not yield the correct results.

 Thank you,

 Mike

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
 Behalf Of Erich Neuwirth
 Sent: Friday, March 19, 2010 11:38 AM
 To: r-help@r-project.org
 Subject: Re: [R] Dataframe calculations

 with the following code

 newvars()$ARRIVALS and newvars()$DEPARTURES
 will give you the new variables you need.


 -=-=-=


 addDelays - function(arriveTime,waitVec,travelVec){
   start-as.POSIXct(arriveTime,format=%H:%M:%S)
   delays-as.vector(t(cbind(waitVec,travelVec)))
   newtimes-format(start+cumsum(delays)*60,format=%H:%M:%S)
   list(departs=c(arriveTime,(odds(newtimes))[-1]),
arrives=evens(newtimes))
 }

 odds - function(inVec){
   indvec-0:(floor((length(inVec)-1)/2))
   inVec[2*indvec+1]
 }

 evens - function(inVec){
   odds(inVec[-1])
 }


 newvars - function(){
   DATE-with(SCHEDULE2,paste(YEAR,MM,DD,sep=))
   starts-as.list(with(SCHEDULE2,tapply(ARRIVE,DATE,function(x)x[1])))
   waits-with(SCHEDULE2,tapply(WAIT,DATE,function(x)x))
   travels-with(SCHEDULE2,tapply(TRAVEL,DATE,function(x)x))
   list(DEPARTURES=

 as.vector(mapply(function(...)addDelays(...)$departs,starts,waits,travels)),
 ARRIVALS=

 as.vector(mapply(function(...)addDelays(...)$arrives,starts,waits,travels)))
 }



 SCHEDULE2 -
 structure(list(MM = c(05, 05, 05, 05, 05, 05, 05, 05, 05, 
 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 
 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 
 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 
 05, 05, 05, 05, 05, 05, 05, 05, 06, 06, 06, 06, 06, 
 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 
 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 
 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 
 06, 06, 06, 06, 06, 06, 06, 06, 07, 07, 07, 07, 07, 
 07, 07, 07, 07, 07, 07, 07, 07, 07, 07, 07, 07, 07, 
 07, 07, 07, 07, 07, 07, 07, 07, 07, 07, 07, 07, 07, 
 07, 07, 07, 07, 07, 07, 07, 07, 07, 07, 07, 07, 07, 
 07, 07, 07, 07, 08, 08, 08, 08, 08,
 !
  08, 08, 08, 08, 08, 08, 08, 08, 08, 08, 08, 08, 08, 
 08, 08, 08, 08, 08, 08, 08, 08, 08, 08, 08, 08, 08, 
 08, 08, 08, 08, 08, 08, 08, 08, 08, 08, 08, 08, 08, 
 08, 08, 08, 08, 08, 08, 08, 08, 08, 08, 08, 08, 09, 
 09, 09, 09, 09, 09, 09, 09, 09, 09, 09, 09, 09, 09, 
 09, 09, 09, 09, 09, 09, 09, 09, 09, 09, 09, 09, 09, 
 09, 09, 09, 09, 09, 09, 09, 09, 09, 09, 09, 09, 09, 
 09, 09, 09, 09, 09, 09, 09, 09, 09, 09, 09, 09, 10, 
 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 
 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 
 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 
 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10), DD = 
 c(02, 02, 02, 02, 03, 03, 03, 03, 
06!
  , 06, 06, 06, 09, 09, 09, 09, 10, 10, 10, 10, 
 14, 14, 14, 14, 16, 16, 16, 16, 17, 17, 17, 17, 19, 
 19, 19, 19, 22, 22, 22, 22, 24, 24, 24, 24, 27, 27, 
 27, 27, 29, 29, 29, 29, 31, 31, 31, 31, 04, 04, 04, 
 04, 06, 06, 06, 06, 07, 07, 07, 07, 10, 10, 10, 10, 
 12, 12, 12, 12, 16, 16, 16, 16, 17, 17, 17, 17, 19, 
 19, 19, 19, 22, 22, 22, 22, 23, 23, 23, 23, 27, 27, 
 27, 27, 28, 28, 28, 28, 29, 29, 29, 29, 03, 03, 03, 
 03, 05, 05, 05, 05, 09, 09, 09, 09, 10, 10, 10, 10, 
 13, 13, 13, 13, 14, 14, 14, 14, 18, 18, 18, 18, 22, 
 22, 22, 22, 23, 23, 23, 23, 24, 24, 24, 24, 27, 27, 
 27, 27, 28, 28, 28, 28, 01, 01, 01, 01, 04, 04, 04, 
 

Re: [R] Encrypt/decrypt in R

2010-03-19 Thread Hadley Wickham
On Fri, Mar 19, 2010 at 12:35 PM, Barry Rowlingson
b.rowling...@lancaster.ac.uk wrote:
 On Fri, Mar 19, 2010 at 5:10 PM, Barry Rowlingson
 b.rowling...@lancaster.ac.uk wrote:
 On Fri, Mar 19, 2010 at 5:00 PM, Hadley Wickham had...@rice.edu wrote:
 Hi all,

 Does any one know of any encryption/decryption algorithms in R?  I'm
 not looking for anything robust - I want some way of printing output
 to the screen that the user can't read immediately, but can decrypt a
 little later.  The main thing I don't want to the user to see is a
 number, so (e.g.) ROT13 isn't appropriate.

  You could just include the numbers in a ROT13-sort of algorithm. It
 would end up being ROT-18 I guess...

  ROT-18 (?) using chartr:

   oldletters=c(letters,0:9)
   old=paste(oldletters,collapse=)
   new=paste(c(oldletters[19:36],oldletters[1:18]),collapse=)
   chartr(old,new,message)
  [1] g6c zsdw e65 kl.qr v633s9a
   chartr(old,new,chartr(old,new,message))
  [1] you have won 23.89 dollars


Thanks all for the suggestions.  I ended up going with:

.old - c(LETTERS, letters, 0:9,  )
.new - sample(.old)

.old_string - paste(.old, collapse = )
.new_string - paste(.new, collapse = )

encrypt - function(message) {
  chartr(.old_string, .new_string, message)
}

decrypt - function(message) {
  chartr(.new_string, .old_string, message)
}

Hadley


-- 
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/

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


[R] relaimpo - dummy variable

2010-03-19 Thread Gabriela Bucini

Hi,

I have a question related to the function boot.relimp (package relaimpo).

I have a model with numerical predictors and one dummy (class) variable. I
would like to calculate the relative importance of the predictors but I have
some problems with the dummy variable.

The name of the linear model is lmbroadst.lc and the dummy variable is
datacon.landcover_gb (with 7 levels). I write the command as:

boot - boot.relimp(lmbroadst.lc, b = 500, type = c(lmg, last, first),
rank = TRUE, group = datacon.landcover_gb,
  diff = TRUE, rela = TRUE)

The error message is:

Error in boot.relimp.lm(lmbroadst.lc, b = 500, type = c(lmg, last,  :
  argument 5 matches multiple formal arguments


What is the correct syntax to include the dummy variable?

Thank you very much for your help!

Gabriela Bucini

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


Re: [R] Put square brackets as column name in a data frame

2010-03-19 Thread Paul-

names(nouvTable) = c(ID,X[m],Y[m],Z[m])

-- 
View this message in context: 
http://n4.nabble.com/Put-square-brackets-as-column-name-in-a-data-frame-tp1599725p1601142.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] how to drop fields by name when reading in data?

2010-03-19 Thread Peter Keller

I have a number of space separated files of weather data, with some
equivalent column names, and differing number of fields in each file.  Some
of the files have 40 or more vars, but I only want a subset of the fields. 
I can use colClasses with read.table to drop some of the fields, but only if
I know where those columns are in the first place, and they're not always in
the same place.   So I would like to be able to drop all unwanted columns on
import, by name.

In addition, most fields have a Q (quality) field next to them, and I need
to read of those as well, each Q next to its relevant field, such as
Temp, and rename to e.g., Temp.Q.

Some example data: 
Date HrMn I Type Dir Q I Spd Q Visby Q I Q Temp Q Dewpt Q Slp Q Pr Amt I Q
19450101 0900 4 SAO 315 1 N 1.0 1 024000 1 N 1 -37.0 1 -45.9 1 1031.8 1 99
999.9 9 9
19450101 1000 4 SAO 315 1 N 1.0 1 024000 1 N 1 -35.9 1 -43.1 1 1032.2 1 99
999.9 9 9
19450101 1100 4 SAO 360 1 N 1.0 1 024000 1 N 1 -35.9 1 -43.1 1 1032.5 1 99
999.9 9 9
19450101 1200 4 SAO 315 1 N 1.0 1 024000 1 N 1 -36.4 1 -50.9 1 1032.9 1 99
999.9 9 9
19450101 1300 4 SAO 360 1 N 1.0 1 024000 1 N 1 -36.4 1 -43.1 1 1032.9 1 99
999.9 9 9
19450101 1400 4 SAO 315 1 N 1.0 1 016000 1 N 1 -36.4 1 -42.0 1 1032.5 1 99
999.9 9 9
19450101 1500 4 SAO 180 1 N 1.0 1 016000 1 N 1 -36.4 1 -45.3 1 1032.5 1 99
999.9 9 9
19450101 1600 4 SAO 360 1 N 1.0 1 024000 1 N 1 -37.5 1 -45.9 1 1032.9 1 99
999.9 9 9

So if I want to extract Date, HrMn, Temp, and the Q following Temp: 
tmp1-read.table(ex.dat,  sep= , strip.white=TRUE,
colClasses=c(character,character,
rep(NULL,11),numeric,factor,rep(NULL,8)),na.strings=999.9,
header=T)

But having to alter colClasses for every file, the fields of which may
change when next year's data is retrieved, is no fun.  And is there a way to
specify na.strings per column?

-- 
View this message in context: 
http://n4.nabble.com/how-to-drop-fields-by-name-when-reading-in-data-tp1601166p1601166.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] odfWeave Error

2010-03-19 Thread Max Kuhn
Brock,

Open up a dos prompt (use the Run menu item and type cmd without the quotes).

Navigate to the odt file, then try using 7z x -tzip file.odt (where
file is the name of you file).

Also, below is a message that someone sent to RHelp that might be of use to you.

Thanks,

Max

Dear all,

I'm resurrecting this old post (about 6 monts old, reproduced thereafter)
because I have struggled against the same problem and found a solution
so that I found it was worth posting for the record.

The simple fix when you want to use odfWeave with 7-ZIP as a
compressing/decompressing utility under windows is to use the
'x' instead of the 'e' option so as to preserve the full hierachy
when decompressing. In the case of Udo's example that would be:

###
#R code
library(odfWeave)
#odfWeave call
odfWeave(c:/temp/odfWeave-test.odt, c:/temp/odfWeave-test-out.odt,
  control = odfWeaveControl(zipCmd = c(7z a -tzip $$file$$ .,
  7z x -tzip $$file$$)))
###

That's all!

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Put square brackets as column name in a data frame

2010-03-19 Thread Mathieu V

Hi everyone,

this is a pretty simple question, but I have not found any answer about this
in this forum.

I'm trying to make a data frame like this :

ID,X[m],Y[m],Z[m]
0,-4.32902,-3.5437,12.4441
1,-4.31887,-3.54278,12.4441
2,-4.33672,-3.54401,12.4615
3,-4.67554,-2.78566,13.4151
4,-4.71124,-2.79889,13.4204
...

Actually, with my code, I'm getting this :

ID,X.m.,Y.m.,Z.m.
0,-4.32902,-3.5437,12.4441
1,-4.31887,-3.54278,12.4441
2,-4.33672,-3.54401,12.4615
3,-4.67554,-2.78566,13.4151
4,-4.71124,-2.79889,13.4204
...

How can I put square brackets ([ ]) in column names?

this is my code :

nouvTable -
data.frame(ID=0:longueur,X[m]=colonneX,Y[m]=colonneY,Z[m]=colonneZ)

After, I'm putting this data frame in a text file

write.table(nouvTable, file = C:/txt, sep=,,quote=FALSE,row.names =
FALSE)

Everything work fine but I need the correct column names  

Thank you
-- 
View this message in context: 
http://n4.nabble.com/Put-square-brackets-as-column-name-in-a-data-frame-tp1599725p1599725.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] Can't setup rJava under ubuntu

2010-03-19 Thread fgrazi

When I try to install rJava, I get the following error:

 install.packages('rJava')
  ...
  checking whether siglongjmp is declared... yes
  checking Java support in R... present:
  interpreter : '/usr/bin/java'
  archiver: '/usr/bin/jar'
  compiler: '/usr/bin/javac'
  header prep.: '/usr/bin/javah'
  cpp flags   : '-I/usr/lib/jvm/java-6-openjdk/jre/../include'
  java libs   : '-L/usr/lib/jvm/java-6-openjdk/jre/lib/i386/client
-L/usr/lib/jvm/java-6-openjdk/jre/lib/i386
-L/usr/lib/jvm/java-6-openjdk/jre/../lib/i386 -L
-L/usr/java/packages/lib/i386 -L/usr/lib/jni -L/lib -L/usr/lib -ljvm'
  checking whether JNI programs can be compiled... configure: error: Cannot
compile a simple JNI program. See config.log for details.
e a simple JNI program. See config.log for details.
  
Well, there is no /usr/bin folder on my computer and I have
no idea of why install program tries to use it.

No way to use R CMD javareconf. As a superuser I get the
message that tere is no java interpreter, as a normal uset I
get the right configuration, but then 

So I manually edited /etc/R/Makeconf (

So install abends and I try to use R CMD javareconf and I still get the
error:
Cannot compile a simple JNI program. See config.log for details.
e a simple JNI program. See config.log for details.

But I can't find any config.log file so I am unable to understand what is
the
error! Can the log be redirected to console?

Any suggestion on how to find config.log?

Any suggestion on having R working with java under Ubuntu?

Any idea of where I can find some kind of documentation?


-- 
View this message in context: 
http://n4.nabble.com/Can-t-setup-rJava-under-ubuntu-tp1599640p1599640.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] Put square brackets as column name in a data frame

2010-03-19 Thread Ben Bolker
Paul- paul at aurynia.com writes:

 
 
 names(nouvTable) = c(ID,X[m],Y[m],Z[m])
 

  Or read the table with check.names=FALSE .
  Note that this can lead to later hassles with referencing the columns;
for example you would need nouvTable$`X[m]` rather than nouvTable$X[m]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] strange behavior, adds new field by non-existent field

2010-03-19 Thread Peter Keller


data:
 tmp1
  Date HrMn  Temp Q.4
1 19450101 0900 -37.0   1
2 19450101 1000 -35.9   2
3 19450101 1100 -35.9   3
4 19450101 1200 -36.4   4
5 19450101 1300 -36.4   5
6 19450101 1400 -36.4   6
7 19450101 1500 -36.4   7
8 19450101 1600 -37.5   9

Accidentally, I did this (I meant to write Q.4 instead of Q here)
 tmp1$Q[tmp1$Q!=1  tmp1$Q!= 5]-NA

I would have expected it to tank, but still got a new field with the the
values I wanted
 tmp1
  Date HrMn  Temp Q.4Q
1 19450101 0900 -37.0   11
2 19450101 1000 -35.9   2 NA
3 19450101 1100 -35.9   3 NA
4 19450101 1200 -36.4   4 NA
5 19450101 1300 -36.4   55
6 19450101 1400 -36.4   6 NA
7 19450101 1500 -36.4   7 NA
8 19450101 1600 -37.5   9 NA

Can someone explain this?
Peter

 sessionInfo()
R version 2.10.1 Patched (2010-03-16 r51294) 
i386-pc-mingw32 

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

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

other attached packages:
[1] lattice_0.18-3 fortunes_1.3-7 zoo_1.6-2 

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

-- 
View this message in context: 
http://n4.nabble.com/strange-behavior-adds-new-field-by-non-existent-field-tp1603563p1603563.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] Can't setup rJava under ubuntu

2010-03-19 Thread Romain Francois

Hi,

did you try to install rJava as an ubuntu package:
http://packages.ubuntu.com/lucid/math/r-cran-rjava

Romain

Le 19/03/10 17:38, fgrazi a écrit :



When I try to install rJava, I get the following error:


install.packages('rJava')

   ...
   checking whether siglongjmp is declared... yes
   checking Java support in R... present:
   interpreter : '/usr/bin/java'
   archiver: '/usr/bin/jar'
   compiler: '/usr/bin/javac'
   header prep.: '/usr/bin/javah'
   cpp flags   : '-I/usr/lib/jvm/java-6-openjdk/jre/../include'
   java libs   : '-L/usr/lib/jvm/java-6-openjdk/jre/lib/i386/client
-L/usr/lib/jvm/java-6-openjdk/jre/lib/i386
-L/usr/lib/jvm/java-6-openjdk/jre/../lib/i386 -L
-L/usr/java/packages/lib/i386 -L/usr/lib/jni -L/lib -L/usr/lib -ljvm'
   checking whether JNI programs can be compiled... configure: error: Cannot
compile a simple JNI program. See config.log for details.
 e a simple JNI program. See config.log for details.

Well, there is no /usr/bin folder on my computer and I have
no idea of why install program tries to use it.

No way to use R CMD javareconf. As a superuser I get the
message that tere is no java interpreter, as a normal uset I
get the right configuration, but then

So I manually edited /etc/R/Makeconf (

So install abends and I try to use R CMD javareconf and I still get the
error:
Cannot compile a simple JNI program. See config.log for details.
 e a simple JNI program. See config.log for details.

But I can't find any config.log file so I am unable to understand what is
the
error! Can the log be redirected to console?

Any suggestion on how to find config.log?

Any suggestion on having R working with java under Ubuntu?

Any idea of where I can find some kind of documentation?





--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://tr.im/OIXN : raster images and RImageJ
|- http://tr.im/OcQe : Rcpp 0.7.7
`- http://tr.im/O1wO : highlight 0.1-5

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

2010-03-19 Thread Noah Silverman

I'm just starting to learn about GAM models.

When using the lm function in R, any factors I have in my data set are 
automatically converted into a series of binomial variables.


For example, if I have a data.frame with a column named color and values 
red, green, blue.   The lm function automatically replaces it with 
3 variables colorred, colorgreen, colorblue which are binomial {0,1}


When I use the gam function, R doesn't do this so I get an error.

1) Is there a way to ask the gam function to do this conversion for me?
2) If not, is there some other tool or utility to make this data 
transformation easy?
3) Last option - can I use lm to transform the data and then extract it 
into a new data.frame to then pass to gam?


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.


[R] DESIGN OF EXPERIMENTS

2010-03-19 Thread ATANU

CAN ANYONE SUGGEST ME HOW TO DO A ANALYSIS OF ANY GIVEN DESIGN (OF EXPRIMENTS
)SAY BLOCK OR FACTORIAL OR PBIBD USING R?
-- 
View this message in context: 
http://n4.nabble.com/DESIGN-OF-EXPERIMENTS-tp1602530p1602530.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] Survreg function for loglogistic hazard estimation

2010-03-19 Thread akeras

I a trying to use survreg to fit a Weibull distribution. From the last few
messages I understand how to interpret the parameters. However, how do I get
the covariance of lambda and alpha? Is there a predict command for that?

Thanks
-- 
View this message in context: 
http://n4.nabble.com/Survreg-function-for-loglogistic-hazard-estimation-tp893503p1604918.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] Using substitute in a print method

2010-03-19 Thread Chris Stubben

I've defined a new class for some really large tables, and I'd like to use
substitute() in the print function.  For example, if I define a new class
below and create a print method for it, I can't figure out how to return the
object name by just typing d. 

d-diag(2)
class(d)-c(diag)
print.diag-function(x,...)
  {
# do something then
print(paste( A diagonal matrix,  substitute(x)) )
  }

 d
[1] A diagonal matrix 1 A diagonal matrix 0 A diagonal matrix 0 A
diagonal matrix 1

##  This prints what I'd want, but I'm not sure why its different.  
print.diag(d)
[1] A diagonal matrix d

Thanks for any help,

Chris Stubben

-- 
View this message in context: 
http://n4.nabble.com/Using-substitute-in-a-print-method-tp1606635p1606635.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] how to drop fields by name when reading in data?

2010-03-19 Thread David Winsemius


On Mar 19, 2010, at 3:03 PM, Peter Keller wrote:



I have a number of space separated files of weather data, with some
equivalent column names, and differing number of fields in each  
file.  Some
of the files have 40 or more vars, but I only want a subset of the  
fields.
I can use colClasses with read.table to drop some of the fields, but  
only if
I know where those columns are in the first place, and they're not  
always in
the same place.   So I would like to be able to drop all unwanted  
columns on

import, by name.

In addition, most fields have a Q (quality) field next to them,  
and I need

to read of those as well, each Q next to its relevant field, such as
Temp, and rename to e.g., Temp.Q.


Those will probably get changed to Q.1, Q.2, etc by check.names()



Some example data:
Date HrMn I Type Dir Q I Spd Q Visby Q I Q Temp Q Dewpt Q Slp Q Pr  
Amt I Q
19450101 0900 4 SAO 315 1 N 1.0 1 024000 1 N 1 -37.0 1 -45.9 1  
1031.8 1 99

999.9 9 9
19450101 1000 4 SAO 315 1 N 1.0 1 024000 1 N 1 -35.9 1 -43.1 1  
1032.2 1 99

999.9 9 9
19450101 1100 4 SAO 360 1 N 1.0 1 024000 1 N 1 -35.9 1 -43.1 1  
1032.5 1 99

999.9 9 9
19450101 1200 4 SAO 315 1 N 1.0 1 024000 1 N 1 -36.4 1 -50.9 1  
1032.9 1 99

999.9 9 9
19450101 1300 4 SAO 360 1 N 1.0 1 024000 1 N 1 -36.4 1 -43.1 1  
1032.9 1 99

999.9 9 9
19450101 1400 4 SAO 315 1 N 1.0 1 016000 1 N 1 -36.4 1 -42.0 1  
1032.5 1 99

999.9 9 9
19450101 1500 4 SAO 180 1 N 1.0 1 016000 1 N 1 -36.4 1 -45.3 1  
1032.5 1 99

999.9 9 9
19450101 1600 4 SAO 360 1 N 1.0 1 024000 1 N 1 -37.5 1 -45.9 1  
1032.9 1 99

999.9 9 9

So if I want to extract Date, HrMn, Temp, and the Q following Temp:
tmp1-read.table(ex.dat, sep= , strip.white=TRUE,
colClasses=c(character,character,
rep(NULL,11),numeric,factor,rep(NULL,8)),na.strings=999.9,
header=T)

But having to alter colClasses for every file, the fields of which may
change when next year's data is retrieved, is no fun.  And is there  
a way to

specify na.strings per column?


There might be if you wanted to write an as.Method for a new data  
type. There was a recent answer to an r-help currency conversion  
question that illustrated this approach.




--
View this message in context: 
http://n4.nabble.com/how-to-drop-fields-by-name-when-reading-in-data-tp1601166p1601166.html
Sent from the R help mailing list archive at Nabble.com.

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


David Winsemius, MD
West Hartford, CT

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


[R] Does S inherit the enhancements in R language?

2010-03-19 Thread Paul Johnson
I don't know anybody who has S-plus these days, but I expect some of
you might, and perhaps you won't mind telling me something.

I'm working on my presentation about R for the general audience.  As I
survey the suggestions from this list about that project, I find
myself wondering whether S-plus benefits from R.  Does S-plus syntax
change like R's does.  I can take code for S and run it through R, but
if I took some R code to an S-plus system, would it work?

Example 1. _, -, =

The old S documents I find emphasize assigment with _.

When I started with R, that was deprecated, then forbidden. _ was
not allowed in file names, now it is.  It was absolutely necessary to
use -. = caused errors.  Around the time of R-2.1 or so, it became
possible to run R code that has = for assignments. It's not encouraged
by R core team, but = is allowed.

Does S+ now accept either

-

or

=

?

For that matter, in S+ is it now forbidden to use underscore for
assignment, as it is in R?

Example 2. Semicolons now discouraged in R code.

We used to require ; to end commands.

Now the R parser is smart enough to spot line breaks and interpret
them accordingly. R's been that way for as long as I can remember, but
I think the ; was required in earliest R releases.

I rather liked the definitive ; at the end of every command.  That
looks right to me, probably because of my SAS and C background.

Would S+ have a panic attack?

Example 3.  Namespace.  Does S-plus get better as R does?

Years ago, I was modeling US Democrats and Republicans and I created
an indicator variable called rep.  regression models would not work
after that because the rep function had been blocked. It was very
frustrating to me.
Professor Ripley spotted the error and posed a message called Don't
use the names of R functions as variable names
http://www.mail-archive.com/r-h...@stat.math.ethz.ch/msg11585.html.

After that, I was terrified that any name I used might conflict with a
built in R function name.

Last month, i saw a student here with a political model and he used
rep as a variable in a regression model, it seemed to work just fine.
I surmise that the rise in usage of namespaces in R packages accounts
for that?

I'm sorry if this is too OT for r-help.

pj
-- 
Paul E. Johnson
Professor, Political Science
1541 Lilac Lane, Room 504
University of Kansas

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


Re: [R] Arima forecasting

2010-03-19 Thread Stephan Kolassa

Hi Matteo,

just use forecast.Arima() with h=2 to get forecasts up to 2 steps ahead. 
R will automatically use forecast.Arima() if you call forecast() with an 
Arima object.


library(forecast)
model - auto.arima(AirPassengers)
forecast(model,h=2)

HTH,
Stephan


Matteo Bertini schrieb:

Hello everyone,

I'm doing some benchmark comparing Arima [1] and SVR on time series data.

I'm using an out-of-sample one-step-ahead prediction from Arima using
the fitted method [2].

Do someone know how to have a two-steps-ahead forecast timeseries from Arima?


Thanks,
Matteo Bertini

[1] http://robjhyndman.com/software/forecast
[2] AirPassengers example on page 5

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

2010-03-19 Thread Ben Bolker
ATANU ata.sonu at gmail.com writes:

 
 
 CAN ANYONE SUGGEST ME HOW TO DO A ANALYSIS OF ANY GIVEN DESIGN (OF EXPRIMENTS
 )SAY BLOCK OR FACTORIAL OR PBIBD USING R?

  ?aov 
  ?lme

 Google r aov anova block or r aov anova factorial etc.

http://cran.r-project.org/doc/contrib/Faraway-PRA.pdf
http://www.statmethods.net/stats/anova.html
http://www.r-project.org/doc/bib/R-books.html especially

Pinheiro and Bates 2000
Fox 2002
Faraway 2004
Everitt and Hothorn  2006
Dalgaard 2008

  In general it is considered impolite to USE ALL CAPITAL LETTERS
IN MAILING LIST POSTS: IT IS TAKEN AS 'SHOUTING' ...

  good luck
Ben Bolker

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


Re: [R] Does S inherit the enhancements in R language?

2010-03-19 Thread Thomas Lumley

On Fri, 19 Mar 2010, Paul Johnson wrote:


I don't know anybody who has S-plus these days, but I expect some of
you might, and perhaps you won't mind telling me something.

I'm working on my presentation about R for the general audience.  As I
survey the suggestions from this list about that project, I find
myself wondering whether S-plus benefits from R.  Does S-plus syntax
change like R's does.  I can take code for S and run it through R, but
if I took some R code to an S-plus system, would it work?

Example 1. _, -, =

The old S documents I find emphasize assigment with _.

When I started with R, that was deprecated, then forbidden. _ was
not allowed in file names, now it is.  It was absolutely necessary to
use -. = caused errors.  Around the time of R-2.1 or so, it became
possible to run R code that has = for assignments. It's not encouraged
by R core team, but = is allowed.


I don't think that the R core team has any position on this. Some of them use 
=, some don't


Does S+ now accept either

-

or

=
?


Yes. This change happened in S4, then S-PLUS, then R.




Example 2. Semicolons now discouraged in R code.

We used to require ; to end commands.

Now the R parser is smart enough to spot line breaks and interpret
them accordingly. R's been that way for as long as I can remember, but
I think the ; was required in earliest R releases.



I really don't think so.  Now, I didn't use the *earliest* releases, but I did 
use R 0.16, which was quite a long time ago, and I don't remember semicolons 
being required or even encouraged.

They are permitted in both S and R, but most people seem to use them only when 
writing one-line functions.


Example 3.  Namespace.  Does S-plus get better as R does?

Years ago, I was modeling US Democrats and Republicans and I created
an indicator variable called rep.  regression models would not work
after that because the rep function had been blocked. It was very
frustrating to me.
Professor Ripley spotted the error and posed a message called Don't
use the names of R functions as variable names
http://www.mail-archive.com/r-h...@stat.math.ethz.ch/msg11585.html.

After that, I was terrified that any name I used might conflict with a
built in R function name.

Last month, i saw a student here with a political model and he used
rep as a variable in a regression model, it seemed to work just fine.
I surmise that the rise in usage of namespaces in R packages accounts
for that?


No, this was fixed much, much earlier than package namespaces.  Symbol lookup 
when a function is needed can specify that a function is desired.  I think this 
has also been true in S-PLUS for a long time, but I'm not completely sure.

There are just a few places where problems can occur, such as do.call() with an 
unquoted function name, where a user-defined variable can get in the way.

-thomas

Thomas Lumley   Assoc. Professor, Biostatistics
tlum...@u.washington.eduUniversity of Washington, Seattle

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


[R] Sweave and object of type 'closure' is not subsettable error

2010-03-19 Thread jose romero
Hello folks:

I have a data frame which includes two numeric vectors: Pa1 and Ingr (which 
represents income).  I run the following code on the R console:

ingreso - factor(ifelse(Ingr=3000,bajo,alto))
tapply(Pa1,ingreso,summary)
boxplot(Pa1~ingreso)

and it works fine.  However, when I Sweave through an rnw file containing 
that code, R gives me the following error:

Error:  chunk 19 (label=cod3.19) 
Error in object[[i]] : object of type 'closure' is not subsettable

What's going on here?

Thanks in advance,
jlrp


[[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] sapply, lattice functions

2010-03-19 Thread Santosh
Dear R-gurus

aa - data.frame(a1=rnorm(20),b1=rnorm(20,0.8),c1=rnorm(20,0.5))
sapply(aa,function(x) histogram(x,breaks=NULL))

or px - sapply(aa,function(x) histogram(x,breaks=NULL))
print(px,split=c(1,1,1,1),more=F)

The above code does not seem to work. am I missing something?

Thanks,
Santosh

[[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] Sweave and object of type 'closure' is not subsettable error

2010-03-19 Thread Ista Zahn
Hi Jose,
If you give us a reproducible example we can test it out and try to
help you find the problem.

-Ista

On Fri, Mar 19, 2010 at 5:38 PM, jose romero jlauren...@yahoo.com wrote:
 Hello folks:

 I have a data frame which includes two numeric vectors: Pa1 and Ingr 
 (which represents income).  I run the following code on the R console:

 ingreso - factor(ifelse(Ingr=3000,bajo,alto))
 tapply(Pa1,ingreso,summary)
 boxplot(Pa1~ingreso)

 and it works fine.  However, when I Sweave through an rnw file containing 
 that code, R gives me the following error:

 Error:  chunk 19 (label=cod3.19)
 Error in object[[i]] : object of type 'closure' is not subsettable

 What's going on here?

 Thanks in advance,
 jlrp


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


Re: [R] sapply, lattice functions

2010-03-19 Thread Gabor Grothendieck
Try this:

junk - sapply(aa,function(x) print(histogram(x,breaks=NULL)))

or, shorter:

for(a in aa) print(histogram(a, breaks = NULL)


On Fri, Mar 19, 2010 at 5:44 PM, Santosh santosh2...@gmail.com wrote:
 Dear R-gurus

 aa - data.frame(a1=rnorm(20),b1=rnorm(20,0.8),c1=rnorm(20,0.5))
 sapply(aa,function(x) histogram(x,breaks=NULL))

 or px - sapply(aa,function(x) histogram(x,breaks=NULL))
 print(px,split=c(1,1,1,1),more=F)

 The above code does not seem to work. am I missing something?

 Thanks,
 Santosh

        [[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] Does S inherit the enhancements in R language?

2010-03-19 Thread William Dunlap
 -Original Message-
 From: r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.org] On Behalf Of Paul Johnson
 Sent: Friday, March 19, 2010 1:44 PM
 To: R-help
 Subject: [R] Does S inherit the enhancements in R language?
 
 I don't know anybody who has S-plus these days, but I expect some of
 you might, and perhaps you won't mind telling me something.

TIBCO Software Inc takes care of S+ these days.

We do try to avoid gratuitous incompatibilities between
R and S+.  When we implement new functionality we check
to see if R has the same thing and will use R's name for
it if so.   When R does something a bit differently we
sometimes ask if it was intended and might even suggest a change.

As for the underscore, a few years ago we
introduced a mode=R or Splus argument to parse()
whose main effect is how the underscore is treated (assignment
operator in Splus mode and part of a name in R mode).
In the latest release, the parser emits a deprecation
warning whenever it sees the underscore while in Splus mode
(the user cannot turn off this warning).  Soon it will
not be an assignment operator.

S+ does not now have namespaces.  However, your rep example
is mainly a problem when your rep is the name of a function,
not the name of a nonfunction, as they are looked up differently.

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com  

 
 I'm working on my presentation about R for the general audience.  As I
 survey the suggestions from this list about that project, I find
 myself wondering whether S-plus benefits from R.  Does S-plus syntax
 change like R's does.  I can take code for S and run it through R, but
 if I took some R code to an S-plus system, would it work?
 
 Example 1. _, -, =
 
 The old S documents I find emphasize assigment with _.
 
 When I started with R, that was deprecated, then forbidden. _ was
 not allowed in file names, now it is.  It was absolutely necessary to
 use -. = caused errors.  Around the time of R-2.1 or so, it became
 possible to run R code that has = for assignments. It's not encouraged
 by R core team, but = is allowed.
 
 Does S+ now accept either
 
 -
 
 or
 
 =
 
 ?
 
 For that matter, in S+ is it now forbidden to use underscore for
 assignment, as it is in R?
 
 Example 2. Semicolons now discouraged in R code.
 
 We used to require ; to end commands.
 
 Now the R parser is smart enough to spot line breaks and interpret
 them accordingly. R's been that way for as long as I can remember, but
 I think the ; was required in earliest R releases.
 
 I rather liked the definitive ; at the end of every command.  That
 looks right to me, probably because of my SAS and C background.
 
 Would S+ have a panic attack?
 
 Example 3.  Namespace.  Does S-plus get better as R does?
 
 Years ago, I was modeling US Democrats and Republicans and I created
 an indicator variable called rep.  regression models would not work
 after that because the rep function had been blocked. It was very
 frustrating to me.
 Professor Ripley spotted the error and posed a message called Don't
 use the names of R functions as variable names
 http://www.mail-archive.com/r-h...@stat.math.ethz.ch/msg11585.html.
 
 After that, I was terrified that any name I used might conflict with a
 built in R function name.
 
 Last month, i saw a student here with a political model and he used
 rep as a variable in a regression model, it seemed to work just fine.
 I surmise that the rise in usage of namespaces in R packages accounts
 for that?
 
 I'm sorry if this is too OT for r-help.
 
 pj
 -- 
 Paul E. Johnson
 Professor, Political Science
 1541 Lilac Lane, Room 504
 University of Kansas
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] sapply, lattice functions

2010-03-19 Thread Santosh
Thanks for your response.
how do I print them in an ordered manner, akin to using
print(px,split=c(2,2,1,1),more=T)) or par(mfrow=c(x,y))?

-Santosh

On Fri, Mar 19, 2010 at 2:58 PM, Gabor Grothendieck ggrothendi...@gmail.com
 wrote:

 Try this:

 junk - sapply(aa,function(x) print(histogram(x,breaks=NULL)))

 or, shorter:

 for(a in aa) print(histogram(a, breaks = NULL)


 On Fri, Mar 19, 2010 at 5:44 PM, Santosh santosh2...@gmail.com wrote:
  Dear R-gurus
 
  aa - data.frame(a1=rnorm(20),b1=rnorm(20,0.8),c1=rnorm(20,0.5))
  sapply(aa,function(x) histogram(x,breaks=NULL))
 
  or px - sapply(aa,function(x) histogram(x,breaks=NULL))
  print(px,split=c(1,1,1,1),more=F)
 
  The above code does not seem to work. am I missing something?
 
  Thanks,
  Santosh
 
 [[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] sapply, lattice functions

2010-03-19 Thread Gabor Grothendieck
Try this:

histogram(~ values | ind, stack(aa))


On Fri, Mar 19, 2010 at 5:44 PM, Santosh santosh2...@gmail.com wrote:
 Dear R-gurus

 aa - data.frame(a1=rnorm(20),b1=rnorm(20,0.8),c1=rnorm(20,0.5))
 sapply(aa,function(x) histogram(x,breaks=NULL))

 or px - sapply(aa,function(x) histogram(x,breaks=NULL))
 print(px,split=c(1,1,1,1),more=F)

 The above code does not seem to work. am I missing something?

 Thanks,
 Santosh

        [[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] sapply, lattice functions

2010-03-19 Thread Sundar Dorai-Raj
Or perhaps more clearly,

histogram(~a1 + b1 + c1, data = aa, outer = TRUE)

--sundar

On Fri, Mar 19, 2010 at 3:50 PM, Gabor Grothendieck ggrothendi...@gmail.com
 wrote:

 Try this:

 histogram(~ values | ind, stack(aa))


 On Fri, Mar 19, 2010 at 5:44 PM, Santosh santosh2...@gmail.com wrote:
  Dear R-gurus
 
  aa - data.frame(a1=rnorm(20),b1=rnorm(20,0.8),c1=rnorm(20,0.5))
  sapply(aa,function(x) histogram(x,breaks=NULL))
 
  or px - sapply(aa,function(x) histogram(x,breaks=NULL))
  print(px,split=c(1,1,1,1),more=F)
 
  The above code does not seem to work. am I missing something?
 
  Thanks,
  Santosh
 
 [[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.


[[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] Merging Matrices

2010-03-19 Thread duncandonutz

I have two symmetric matrices, but of different dimensions.  The entries are
identified by specific labels some of which are shared by both matrices.  I
would like to sum the two matrices, but retain the union of the two.  In
other words, I want the result to be the same size as the larger of the two
matrices, but with the entries that they share added together.  

cbind() and rbind() don't work since the matrices are different sizes
(symmetrically).  Merge doesn't want to cooperate, although it might be
because I can't understand the documentation. I tried the package reshape
but didn't get very far with that either.  I tried simply adding (+) them,
but that was a stupid first try.

Any help is appreciated!
-- 
View this message in context: 
http://n4.nabble.com/Merging-Matrices-tp1605474p1605474.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] Can't setup rJava under ubuntu

2010-03-19 Thread fgrazi

Thank you very much, it worked!

Seems that the problem is that open-sdk and not sun-jdk is
expected.


-- 
View this message in context: 
http://n4.nabble.com/Can-t-setup-rJava-under-ubuntu-tp1599640p1606137.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] spatclus package:

2010-03-19 Thread Zhenqiang (James) Lu
Dear R users,

I am using package spatclus for cluster detection for case event spatial
data.  Is there any way to get he case identical numbers within cluster
after you run the main function of clus?

Thank you.

James

[[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] strange behavior, adds new field by non-existent field

2010-03-19 Thread jim holtman
?'['

and the look for partial matching

On Fri, Mar 19, 2010 at 3:38 PM, Peter Keller keller...@gmail.com wrote:



 data:
  tmp1
  Date HrMn  Temp Q.4
 1 19450101 0900 -37.0   1
 2 19450101 1000 -35.9   2
 3 19450101 1100 -35.9   3
 4 19450101 1200 -36.4   4
 5 19450101 1300 -36.4   5
 6 19450101 1400 -36.4   6
 7 19450101 1500 -36.4   7
 8 19450101 1600 -37.5   9

 Accidentally, I did this (I meant to write Q.4 instead of Q here)
  tmp1$Q[tmp1$Q!=1  tmp1$Q!= 5]-NA

 I would have expected it to tank, but still got a new field with the the
 values I wanted
  tmp1
  Date HrMn  Temp Q.4Q
 1 19450101 0900 -37.0   11
 2 19450101 1000 -35.9   2 NA
 3 19450101 1100 -35.9   3 NA
 4 19450101 1200 -36.4   4 NA
 5 19450101 1300 -36.4   55
 6 19450101 1400 -36.4   6 NA
 7 19450101 1500 -36.4   7 NA
 8 19450101 1600 -37.5   9 NA

 Can someone explain this?
 Peter

  sessionInfo()
 R version 2.10.1 Patched (2010-03-16 r51294)
 i386-pc-mingw32

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

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

 other attached packages:
 [1] lattice_0.18-3 fortunes_1.3-7 zoo_1.6-2

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

 --
 View this message in context:
 http://n4.nabble.com/strange-behavior-adds-new-field-by-non-existent-field-tp1603563p1603563.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.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] Dataframe calculations

2010-03-19 Thread jim holtman
try this:

# add 'date' to separate the data
SCHEDULE2 - within(SCHEDULE2, {
date - paste(YEAR, '-', MM, '-', DD, sep='')
ARRIVE - as.POSIXct(paste(date, ARRIVE))
DEPART - as.POSIXct(paste(date, DEPART))
})
# process each day
result - lapply(split(SCHEDULE2, SCHEDULE2$date), function(.day){
# assume first line is complete; convert to POSIXct
for (i in 2:nrow(.day)){
.day$ARRIVE[i] - .day$DEPART[i - 1L] + (.day$TRAVEL[i - 1L] * 60)
.day$DEPART[i] - .day$ARRIVE[i] + (.day$WAIT[i] * 60)
}
# return the changes
.day
})
SCHEDULE2 - do.call(rbind, result)


On Fri, Mar 19, 2010 at 9:05 AM, Hosack, Michael mhos...@state.pa.uswrote:

 Hi everyone,

 My question will probably seem simple to most of you, but I
 have spent many hours trying to solve it. I need to perform
 a series of sequential calculations on my dataframe that move
 across rows and down columns, and then repeat themselves at
 each unique 'MM' by 'DD' grouping. Specifically, I want to add
 'DEPART' time (24 hr time) to 'TRAVEL'(minutes) in line 1 and
 put the result in 'ARRIVE' (24 hr time) of line 2, then I want
 to add 'WAIT' (minutes) to that 'ARRIVE' time of line 2 to
 create 'DEPART', which will then be combined with 'TRAVEL'
 (minutes) to yield the 'ARRIVE' time of line 3, etc. This
 series of calc's will start anew beginning at each unique 'MM'
 by 'DD' grouping. Any advice would be greatly appreciated.

 Thank you,

 Mike

 SCHEDULE2 -
 structure(list(MM = c(05, 05, 05, 05, 05, 05, 05,
 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 05,
 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 05,
 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 05,
 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 05,
 05, 05, 05, 05, 05, 06, 06, 06, 06, 06, 06,
 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06,
 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06,
 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06,
 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06,
 06, 06, 07, 07, 07, 07, 07, 07, 07, 07, 07,
 07, 07, 07, 07, 07, 07, 07, 07, 07, 07, 07,
 07, 07, 07, 07, 07, 07, 07, 07, 07, 07, 07,
 07, 07, 07, 07, 07, 07, 07, 07, 07, 07, 07,
 07, 07, 07, 07, 07, 07, 08, 08, 08, 08, 08,
 08, 08, 08, 08, 08, 08, 08, 08, 08, 08, 08,
 08, 08, 08, 08, 08, 08, 08, 08, 08, 08, 08,
 08, 08, 08, 08, 08, 08, 08, 08, 08, 08, 08,
 08, 08, 08, 08, 08, 08, 08, 08, 08, 08, 08,
 08, 08, 08, 08, 08, 08, 08, 09, 09, 09, 09,
 09, 09, 09, 09, 09, 09, 09, 09, 09, 09, 09,
 09, 09, 09, 09, 09, 09, 09, 09, 09, 09, 09,
 09, 09, 09, 09, 09, 09, 09, 09, 09, 09, 09,
 09, 09, 09, 09, 09, 09, 09, 09, 09, 09, 09,
 09, 09, 09, 09, 10, 10, 10, 10, 10, 10, 10,
 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
 10), DD = c(02, 02, 02, 02, 03, 03, 03, 03,
 06, 06, 06, 06, 09, 09, 09, 09, 10, 10, 10,
 10, 14, 14, 14, 14, 16, 16, 16, 16, 17, 17,
 17, 17, 19, 19, 19, 19, 22, 22, 22, 22, 24,
 24, 24, 24, 27, 27, 27, 27, 29, 29, 29, 29,
 31, 31, 31, 31, 04, 04, 04, 04, 06, 06, 06,
 06, 07, 07, 07, 07, 10, 10, 10, 10, 12, 12,
 12, 12, 16, 16, 16, 16, 17, 17, 17, 17, 19,
 19, 19, 19, 22, 22, 22, 22, 23, 23, 23, 23,
 27, 27, 27, 27, 28, 28, 28, 28, 29, 29, 29,
 29, 03, 03, 03, 03, 05, 05, 05, 05, 09, 09,
 09, 09, 10, 10, 10, 10, 13, 13, 13, 13, 14,
 14, 14, 14, 18, 18, 18, 18, 22, 22, 22, 22,
 23, 23, 23, 23, 24, 24, 24, 24, 27, 27, 27,
 27, 28, 28, 28, 28, 01, 01, 01, 01, 04, 04,
 04, 04, 06, 06, 06, 06, 07, 07, 07, 07, 12,
 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14,
 16, 16, 16, 16, 19, 19, 19, 19, 21, 21, 21,
 21, 23, 23, 23, 23, 24, 24, 24, 24, 28, 28,
 28, 28, 31, 31, 31, 31, 02, 02, 02, 02, 04,
 04, 04, 04, 08, 08, 08, 08, 09, 09, 09, 09,
 11, 11, 11, 11, 14, 14, 14, 14, 16, 16, 16,
 16, 19, 19, 19, 19, 20, 20, 20, 20, 21, 21,
 21, 21, 26, 26, 26, 26, 27, 27, 27, 27, 29,
 29, 29, 29, 03, 03, 03, 03, 05, 05, 05, 05,
 08, 08, 08, 08, 10, 10, 10, 10, 14, 14, 14,
 14, 15, 15, 15, 15, 16, 16, 16, 16, 20, 20,
 20, 20, 21, 21, 21, 21, 24, 24, 24, 24, 26,
 26, 26, 26, 29, 29, 29, 29, 30, 30, 30, 30
 ), YEAR = c(2010, 2010, 2010, 2010, 2010, 2010, 2010,
 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010,
 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010,
 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010,
 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010,
 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010,
 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010,
 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010,
 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010,
 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010,
 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010,
 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010,
 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010,
 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010,
 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010,
 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010,
 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010,
 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010,
 2010, 2010, 2010, 2010, 

Re: [R] outputing text colors

2010-03-19 Thread Jakson A. Aquino
On Thu, Mar 18, 2010 at 11:27:40PM -0800, rtist wrote:
 
 Hi Everyone,
 
 And thanks for the replies.  I was more specifically referring to the
 console table output itself.
 I have a time series that has columns of months and rows of years, and each
 row,col is a value.
 I wanted the actual text output value to the console table r,c to have a
 color corresponding to the value,
 like ifelse(val0,txt=red,txt=green), so that I can quickly have an
 overview of returns by color.
 
 It looks like the only solution is to use a literal graphics object, and
 that the above solution is not feasible.
 I'll look into the graphical type objects.  It would be nice to have a
 function that simply reads a time series
 object table-f(ts.table) and outputs the above criteria.

It's possible to do it (at least in a Linux terminal emulator)
with the package xterm256. However, the default print function
does not print the scape sequences which the terminal emulator
interprets as colors. It would be necessary to create a print
method for ts.table (or any other object to be printed in color).
Simple example:

library(xterm256)
x - style(c(-1, 0, 1), fg = c(red, blue, green), check.xterm = F)
cat(x, \n)
print(x)

-- 
Jakson A. Aquino
Federal Uni. of Ceara
www.lepem.ufc.br - Brazil

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


Re: [R] strange behavior, adds new field by non-existent field

2010-03-19 Thread Jorge Ivan Velez
Hi Peter,

I think you want

tmp1$Q.4[tmp1$Q.4 != 1  tmp1$Q.4 != 5] - NA
tmp1
#Date HrMn  Temp Q.4
# 1 19450101  900 -37.0   1
# 2 19450101 1000 -35.9  NA
# 3 19450101 1100 -35.9  NA
# 4 19450101 1200 -36.4  NA
# 5 19450101 1300 -36.4   5
# 6 19450101 1400 -36.4  NA
# 7 19450101 1500 -36.4  NA
# 8 19450101 1600 -37.5  NA

(note the .4 after Q).

HTH,
Jorge

On Fri, Mar 19, 2010 at 3:38 PM, Peter Keller  wrote:



 data:
  tmp1
  Date HrMn  Temp Q.4
 1 19450101 0900 -37.0   1
 2 19450101 1000 -35.9   2
 3 19450101 1100 -35.9   3
 4 19450101 1200 -36.4   4
 5 19450101 1300 -36.4   5
 6 19450101 1400 -36.4   6
 7 19450101 1500 -36.4   7
 8 19450101 1600 -37.5   9

 Accidentally, I did this (I meant to write Q.4 instead of Q here)
  tmp1$Q[tmp1$Q!=1  tmp1$Q!= 5]-NA

 I would have expected it to tank, but still got a new field with the the
 values I wanted
  tmp1
  Date HrMn  Temp Q.4Q
 1 19450101 0900 -37.0   11
 2 19450101 1000 -35.9   2 NA
 3 19450101 1100 -35.9   3 NA
 4 19450101 1200 -36.4   4 NA
 5 19450101 1300 -36.4   55
 6 19450101 1400 -36.4   6 NA
 7 19450101 1500 -36.4   7 NA
 8 19450101 1600 -37.5   9 NA

 Can someone explain this?
 Peter

  sessionInfo()
 R version 2.10.1 Patched (2010-03-16 r51294)
 i386-pc-mingw32

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

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

 other attached packages:
 [1] lattice_0.18-3 fortunes_1.3-7 zoo_1.6-2

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

 --
 View this message in context:
 http://n4.nabble.com/strange-behavior-adds-new-field-by-non-existent-field-tp1603563p1603563.html
 Sent from the R help mailing list archive at Nabble.com.

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


[[alternative HTML version deleted]]

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


Re: [R] Merging Matrices

2010-03-19 Thread David Winsemius


On Mar 19, 2010, at 4:11 PM, duncandonutz wrote:



I have two symmetric matrices, but of different dimensions.  The  
entries are
identified by specific labels some of which are shared by both  
matrices.  I
would like to sum the two matrices, but retain the union of the  
two.  In
other words, I want the result to be the same size as the larger of  
the two

matrices, but with the entries that they share added together.

cbind() and rbind() don't work since the matrices are different sizes
(symmetrically).  Merge doesn't want to cooperate, although it might  
be
because I can't understand the documentation. I tried the package  
reshape
but didn't get very far with that either.  I tried simply adding (+)  
them,

but that was a stupid first try.


See if this effort to construct an example and implement what it  
sounds like you are asking is effective:


 A - matrix(1:25, 5)
 B - matrix(1:9, 3)
 colnames(A) - c(letters[1:5])
 colnames(B) - c(letters[1:3])
 rownames(B) - c(letters[1:3])
 rownames(A) - c(letters[1:5])
 rownames(A)[1] - A
 intersect(rownames(A),rownames(B))
[1] b c
 intersect(colnames(A),colnames(B))
[1] a b c
  
A[intersect(rownames(A),rownames(B)),intersect(colnames(A),colnames(B))]

  a b  c
b 2 7 12
c 3 8 13
  
B[intersect(rownames(A),rownames(B)),intersect(colnames(A),colnames(B))]

  a b c
b 2 5 8
c 3 6 9
  
A 
[intersect 
(rownames(A),rownames(B)),intersect(colnames(A),colnames(B))] -  
A 
[intersect 
(rownames(A),rownames(B)),intersect(colnames(A),colnames(B))] +  
B[intersect(rownames(A),rownames(B)),intersect(colnames(A),colnames(B))]

 A
  a  b  c  d  e
A 1  6 11 16 21
b 4 12 20 17 22
c 6 14 22 18 23
d 4  9 14 19 24
e 5 10 15 20 25

--
David


Any help is appreciated!
--
View this message in context: 
http://n4.nabble.com/Merging-Matrices-tp1605474p1605474.html
Sent from the R help mailing list archive at Nabble.com.

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


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


Re: [R] Define column names to a series of data.frames

2010-03-19 Thread Nikos Alexandris
Nikos Alexandris wrote:
... 
  I have 6 data frames consisting of 6 rows x 7 columns put together from
  other data.frames.
... 
  I want to give the following column names to each data.frame: (SDev,
  PC1, PC2, PC3, PC4, PC5, PC6)
... 
  How is it to be done at once for all data.frames that the function
  objects(pattern = SomePattern) can find?

Henrique Dallazuanna wrote:
 Yes, just in the list.
 If they want change the name in Environment GlobalEnv:
 
  for(i in ls(pattern = DF[0-9]))
assign(i, `names-`(get(i), c(SDev,PC1, PC2, PC3,
 PC4, PC5, PC6)), globalenv())

It works also using colnames() and rownames(), for example:

--%---
# collect results based on svd
svd.results - objects ( pattern = ^svd.result_of_.* )

# collect results based on eigenvector(s)
eigenvector.results - objects ( pattern = ^eigenvector.result_of_.* )

# combine all in one
pca.results - c ( svd.results , eigenvector.results )

# (re-)define column names
for ( i in pca.results ) assign ( i , `colnames-` ( get ( i ) ,
column_names ) , globalenv ( ) )

# (re-)define row names
for ( i in pca.results ) assign ( i , `rownames-` ( get ( i ) ,
row_names ) , globalenv ( ) )
--%---

Henrique D., you are a guRu!
Thank you, Nikos

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


Re: [R] Merging Matrices

2010-03-19 Thread Steven McKinney

 From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On Behalf 
 Of duncandonutz [dwads...@unm.edu]
 Sent: March 19, 2010 1:11 PM
 To: r-help@r-project.org
 Subject: [R] Merging Matrices
 
 I have two symmetric matrices, but of different dimensions.  The entries are
 identified by specific labels some of which are shared by both matrices.  I
 would like to sum the two matrices, but retain the union of the two.  In
 other words, I want the result to be the same size as the larger of the two
 matrices, but with the entries that they share added together.
 
 cbind() and rbind() don't work since the matrices are different sizes
 (symmetrically).  Merge doesn't want to cooperate, although it might be
 because I can't understand the documentation. I tried the package reshape
 but didn't get very far with that either.  I tried simply adding (+) them,
 but that was a stupid first try.

With appropriate indexing of the matrices via their shared names, 
it can be done as follows:

 A - matrix(1:9, nrow = 3)
 A[lower.tri(A)] - A[upper.tri(A)]
 B - matrix(1:25, nrow = 5)
 B[lower.tri(B)] - B[upper.tri(B)]
 dimnames(A) - list(letters[c(2, 4, 5)], letters[c(2, 4, 5)])
 dimnames(B) - list(letters[1:5], letters[1:5])
 A
  b d e
b 1 4 7
d 4 5 8
e 7 8 9
 B
   a  b  c  d  e
a  1  6 11 16 21
b  6  7 12 17 22
c 11 17 13 18 23
d 12 18 22 19 24
e 16 21 23 24 25
 B[dimnames(A)[[1]], dimnames(A)[[1]]]
   b  d  e
b  7 17 22
d 18 19 24
e 21 24 25
 C - B
 C[dimnames(A)[[1]], dimnames(A)[[1]]] - A + B[dimnames(A)[[1]], 
 dimnames(A)[[1]]]
 C
   a  b  c  d  e
a  1  6 11 16 21
b  6  8 12 21 29
c 11 17 13 18 23
d 12 22 22 24 32
e 16 28 23 32 34
 C - B
  a b c d e
a 0 0 0 0 0
b 0 1 0 4 7
c 0 0 0 0 0
d 0 4 0 5 8
e 0 7 0 8 9
 


HTH

Steve McKinney

 Any help is appreciated!
 --
 View this message in context: 
 http://n4.nabble.com/Merging-Matrices-tp1605474p1605474.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] strange behavior, adds new field by non-existent field

2010-03-19 Thread Bill.Venables
This is a property of lists.  With the $ form of extraction names may be 
abbreviated to the minimum number of characters required to specify the 
component uniquely.  This with your tmp1

 tmp1$Q
[1] 1 2 3 4 5 6 7 9
Levels: 1 2 3 4 5 6 7 9
 tmp1$Q.
[1] 1 2 3 4 5 6 7 9
Levels: 1 2 3 4 5 6 7 9
 tmp1$Q.4
[1] 1 2 3 4 5 6 7 9
Levels: 1 2 3 4 5 6 7 9


If you were to do it another way, e.g.

 tmp1 - within(tmp1, is.na(Q.4[!(Q.4 %in% c(1,5))]) - TRUE)

then you would need to use the full component name, Q.4.  (This works too, by 
the way:

 tmp1
  Date HrMn  Temp  Q.4
1 19450101  900 -37.01
2 19450101 1000 -35.9 NA
3 19450101 1100 -35.9 NA
4 19450101 1200 -36.4 NA
5 19450101 1300 -36.45
6 19450101 1400 -36.4 NA
7 19450101 1500 -36.4 NA
8 19450101 1600 -37.5 NA
 

you may care to figure out how it does so, though!)

On Fri, Mar 19, 2010 at 3:38 PM, Peter Keller  wrote:



 data:
  tmp1
  Date HrMn  Temp Q.4
 1 19450101 0900 -37.0   1
 2 19450101 1000 -35.9   2
 3 19450101 1100 -35.9   3
 4 19450101 1200 -36.4   4
 5 19450101 1300 -36.4   5
 6 19450101 1400 -36.4   6
 7 19450101 1500 -36.4   7
 8 19450101 1600 -37.5   9

 Accidentally, I did this (I meant to write Q.4 instead of Q here)
  tmp1$Q[tmp1$Q!=1  tmp1$Q!= 5]-NA

 I would have expected it to tank, but still got a new field with the the
 values I wanted
  tmp1
  Date HrMn  Temp Q.4Q
 1 19450101 0900 -37.0   11
 2 19450101 1000 -35.9   2 NA
 3 19450101 1100 -35.9   3 NA
 4 19450101 1200 -36.4   4 NA
 5 19450101 1300 -36.4   55
 6 19450101 1400 -36.4   6 NA
 7 19450101 1500 -36.4   7 NA
 8 19450101 1600 -37.5   9 NA

 Can someone explain this?
 Peter

  sessionInfo()
 R version 2.10.1 Patched (2010-03-16 r51294)
 i386-pc-mingw32

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

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

 other attached packages:
 [1] lattice_0.18-3 fortunes_1.3-7 zoo_1.6-2

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

 --
 View this message in context:
 http://n4.nabble.com/strange-behavior-adds-new-field-by-non-existent-field-tp1603563p1603563.html
 Sent from the R help mailing list archive at Nabble.com.

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


[[alternative HTML version deleted]]

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

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


Re: [R] Factor variables with GAM models

2010-03-19 Thread Steven McKinney
Hi Noah

GAM models were developed to assess the functional form
of the relationship of continuous predictor variables to the
response, so weren't really meant to handle factor variables
as predictor variables.  GAMs are of the form
E(Y | X1, X2, ...) = So + S(X1) + S(X2) + ...
where S(X) is a smooth function of X.

Hence you might want to rethink why you'd want a
factor variable as a predictor variable in a GAM.
This is why the gam machinery doesn't just do the
factor conversion to indicator variables as is done in
lm.

HTH

Steven McKinney


From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On Behalf Of 
Noah Silverman [n...@smartmediacorp.com]
Sent: March 19, 2010 12:54 PM
To: r-help@r-project.org
Subject: [R] Factor variables with GAM models

I'm just starting to learn about GAM models.

When using the lm function in R, any factors I have in my data set are
automatically converted into a series of binomial variables.

For example, if I have a data.frame with a column named color and values
red, green, blue.   The lm function automatically replaces it with
3 variables colorred, colorgreen, colorblue which are binomial {0,1}

When I use the gam function, R doesn't do this so I get an error.

1) Is there a way to ask the gam function to do this conversion for me?
2) If not, is there some other tool or utility to make this data
transformation easy?
3) Last option - can I use lm to transform the data and then extract it
into a new data.frame to then pass to gam?

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.

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


Re: [R] Factor variables with GAM models

2010-03-19 Thread Noah Silverman

Steve,

I get that.  What you wrote make sense.

My challenge is the data I'm attempting to model.  Some of the variables 
are continuous, some are factors.  both linear and poisson models work. 
(Poisson doing a much more accurate job.)  However, some of the 
numerical variables are clearly non-linear.  Hence my interest in GAM.  
I suppose one alternative would be to try some polynomial transformation 
on the variable as part of a Poisson model.


Any other suggestions would be welcome.

Thanks!

-N

On 3/19/10 8:37 PM, Steven McKinney wrote:

Hi Noah

GAM models were developed to assess the functional form
of the relationship of continuous predictor variables to the
response, so weren't really meant to handle factor variables
as predictor variables.  GAMs are of the form
E(Y | X1, X2, ...) = So + S(X1) + S(X2) + ...
where S(X) is a smooth function of X.

Hence you might want to rethink why you'd want a
factor variable as a predictor variable in a GAM.
This is why the gam machinery doesn't just do the
factor conversion to indicator variables as is done in
lm.

HTH

Steven McKinney


From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On Behalf Of 
Noah Silverman [n...@smartmediacorp.com]
Sent: March 19, 2010 12:54 PM
To: r-help@r-project.org
Subject: [R] Factor variables with GAM models

I'm just starting to learn about GAM models.

When using the lm function in R, any factors I have in my data set are
automatically converted into a series of binomial variables.

For example, if I have a data.frame with a column named color and values
red, green, blue.   The lm function automatically replaces it with
3 variables colorred, colorgreen, colorblue which are binomial {0,1}

When I use the gam function, R doesn't do this so I get an error.

1) Is there a way to ask the gam function to do this conversion for me?
2) If not, is there some other tool or utility to make this data
transformation easy?
3) Last option - can I use lm to transform the data and then extract it
into a new data.frame to then pass to gam?

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.



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


  1   2   >