Re: [R] Problems with graphics

2006-10-04 Thread Christophe Nguyen
Thank you for your response, which is a partial solution to my problem. 
Actually, I would like to do the following plot. I have a data frame 
that includes the following variables: time, y=a response variable 
experimentally determined, ystd=its standard deviation, m=the 
modeled/simulated values for y, and F a classification/grouping 
variable. I would like to have a treillis plot, each panel corresponding 
to a level of F and includes y plotted against time with dots as symbol 
and with bars for standard deviation using ystd and m superimposed , 
plotted as a line.
Thanks for your help,
Chris



Petr Pikal wrote:
 Hi

 Well, you did not specified what you have tried to do and how did you 
 fail but

 On 2 Oct 2006 at 16:41, Christophe Nguyen wrote:

 Date sent:Mon, 02 Oct 2006 16:41:29 +0200
 From: Christophe Nguyen [EMAIL PROTECTED]
 To:   r-help@stat.math.ethz.ch
 Subject:  [R] Problems with graphics

   
 Dear all,
 I am a SAS user, who's trying R. I am a little bit lost for graphics.
 What is the simplest way for plotting y as a function of x with one
 symbol (line or dot) for each level of a class variable z (for SAS
 

 If z is factor
 plot(x,y pch=as.numeric(z), ...)

 otherwise you need to change it to one.

 BTW, you can use the similar approach with lines and points - col, 
 lwd, cex,... and othe parameters.


   
 langage= plot x*y=z). Can I add vertical bars for standard deviation
 

 there are various options, one is to use arrows with angle=90.

 arrows(x,y,x, y+ystd, angle=90)

   
 stored in a  separate variable (say  ystd). Finally, is it possible to
 do all this with xyplot function arranging plots according to A and B
 factor: xyplot(y~x|A*B) with as many plots and symbol as there is
 

 that is completely different story and you probably need to elaborate 
 your own panel.function.

 HTH
 Petr

   
 levels in the z variable for each panel? Thanks for the help. Chris

 -- 
 ___

 Christophe NGUYEN

 UMR 1220 INRA-ENITAB
 Transfert sol-plante et cycle des éléments minéraux
 dans les écosystčmes cultivés

 Centre INRA de Bordeaux-Aquitaine
 71, avenue Edouard Bourlaux, BP 81
 33883 Villenave d'Ornon, FRANCE

 Tel : 00 33 (0)5 57 12 25 07
 Fax : 00 33 (0)5 57 12 25 15

 email : [EMAIL PROTECTED]
 page infoservice: http://www.bordeaux.inra.fr/tcem

 __m°O°m

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

 Petr Pikal
 [EMAIL PROTECTED]





   

-- 
___

Christophe NGUYEN

UMR 1220 INRA-ENITAB
Transfert sol-plante et cycle des éléments minéraux
dans les écosystèmes cultivés

Centre INRA de Bordeaux-Aquitaine
71, avenue Edouard Bourlaux, BP 81
33883 Villenave d'Ornon, FRANCE

Tel : 00 33 (0)5 57 12 25 07
Fax : 00 33 (0)5 57 12 25 15

email : [EMAIL PROTECTED]
page infoservice: http://www.bordeaux.inra.fr/tcem

__m°O°m

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


Re: [R] Problems with graphics

2006-10-04 Thread Deepayan Sarkar
On 10/3/06, Christophe Nguyen [EMAIL PROTECTED] wrote:
 Thank you for your response, which is a partial solution to my problem.
 Actually, I would like to do the following plot. I have a data frame
 that includes the following variables: time, y=a response variable
 experimentally determined, ystd=its standard deviation, m=the
 modeled/simulated values for y, and F a classification/grouping
 variable. I would like to have a treillis plot, each panel corresponding
 to a level of F and includes y plotted against time with dots as symbol
 and with bars for standard deviation using ystd and m superimposed ,
 plotted as a line.

See

demo(intervals)

(code viewable using
file.show(system.file(demo/intervals.R, package = lattice))
)

for some ideas. The Hmisc package also has some extensions supporting
confidence intervals. If you want more specific help, give a
reproducible example.

Deepayan

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] Some questions about plotting with R

2006-10-04 Thread Wee-Jin Goh
Greetings list,

I'm currently in the process of migrating some Matlab code to R. It's  
going well, but I'm running into trouble with plotting. There are a  
few questions I have.

1) Is there any way to do a 3D line plot in R? This would be what the  
Matlab function plot3 does.

2) I would like to create 3 separate plots. With Matlab, this is done  
by doing ...
figure;
plot...
figure;
plot...
figure;
plot...

In R, I've found the function frame(), which I thought would do  
something similar. However, calling frame() seems to have no effect,  
as only 1 frame is created, and all three graphs are drawn to it,  
resulting in only the final graph being displayed. Help!

3) Is there a good site/book that lists the similarities/differences  
in plotting with R? I've found http://www.mathepi.com/methods/ 
matlabtor.html which is good for general Matlab to R concepts, but  
it's missing information on plotting.

Cheers,
Wee-Jin

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


Re: [R] Some questions about plotting with R

2006-10-04 Thread Wee-Jin Goh

On 4 Oct 2006, at 09:03, Robin Hankin wrote:

 Hi Wee-Jin

 check out R-and-octave.txt, on the contributed docs section of CRAN.


 HTH

 Robin

 --
 Robin Hankin
 Uncertainty Analyst
 National Oceanography Centre, Southampton
 European Way, Southampton SO14 3ZH, UK
  tel  023-8059-7743


Thanks for the response Robin, but that document doesn't help me with  
either my quest for plot3, or multiple figures (i.e. the 'figure'  
command in Octave/Matlab).

cheers,
Wee-Jin

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


Re: [R] Linear model with hidden variables

2006-10-04 Thread Ingmar Visser
Richard,
I'm not sure I fully understand your question but the flexmix package does
mixtures of linear models which may be what you want.
Hth, Ingmar


 From: Richard A. O'Keefe [EMAIL PROTECTED]
 Date: Wed, 4 Oct 2006 18:36:55 +1300 (NZDT)
 To: r-help@stat.math.ethz.ch
 Subject: [R] Linear model with hidden variables
 
 
 I have some data on a moving vehicle where, amongst other things,
 it looks as though it would be informative to fit a model with the
 following structure:
 
 Z = B.Y + errorz
 Y = C.X + errorz
 
 The X variables are observed predictor variables;
 6 of the variables look promising (on the basis of what they mean).
 
 The Z variables are observed response variables;
 there are 4 of them.
 
 There is a priori reason to believe, and scatterplots to suggest,
 that the Z variables are really essentially two-dimensional, so
 
 the Y variables are hidden intermediate variables.
 There should be 2 of them.  There are actually two physical candidates
 for what they might be, but they happen not to have been measured.
 
 There are 800 cases.  (More precisely, there are 14 periods, each with
 about 800 samples, and I am interested in fitting a separate model in
 each period.)
 
 A simple least squares fit for this model would minimise the sum of
 error squares for the Zs.  Oh, I do mean there to be constant terms.
 
 I suppose I could go back to first principles and work it all out,
 but has anyone ever done something like this in R?  There seems to
 be every imaginable variation on lm and some that I find unimaginable,
 so presumably a means to do this is already around somewhere.
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Some questions about plotting with R

2006-10-04 Thread Gabor Csardi
On Wed, Oct 04, 2006 at 09:10:23AM +0100, Wee-Jin Goh wrote:
 
 On 4 Oct 2006, at 09:03, Robin Hankin wrote:
 
  Hi Wee-Jin
 
  check out R-and-octave.txt, on the contributed docs section of CRAN.
 
 
  HTH
 
  Robin
 
  --
  Robin Hankin
  Uncertainty Analyst
  National Oceanography Centre, Southampton
  European Way, Southampton SO14 3ZH, UK
   tel  023-8059-7743
 
 
 Thanks for the response Robin, but that document doesn't help me with  
 either my quest for plot3, or multiple figures (i.e. the 'figure'  
 command in Octave/Matlab).

For 3d figures you can check the persp command, and for multiple figures,
just use x11():

x11()
plot()
x11()
plot()
...

You might want to check ?Devices to see how R handles graphics devices.

Gabor

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

-- 
Csardi Gabor [EMAIL PROTECTED]MTA RMKI, ELTE TTK

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


Re: [R] Some questions about plotting with R

2006-10-04 Thread Gavin Simpson
On Wed, 2006-10-04 at 09:10 +0100, Wee-Jin Goh wrote:
 On 4 Oct 2006, at 09:03, Robin Hankin wrote:
 
  Hi Wee-Jin
 
  check out R-and-octave.txt, on the contributed docs section of CRAN.
 
 
  HTH
 
  Robin
 
  --
  Robin Hankin
  Uncertainty Analyst
  National Oceanography Centre, Southampton
  European Way, Southampton SO14 3ZH, UK
   tel  023-8059-7743
 
 
 Thanks for the response Robin, but that document doesn't help me with  
 either my quest for plot3, or multiple figures (i.e. the 'figure'  
 command in Octave/Matlab).
 
 cheers,
 Wee-Jin

If you want three separate graphics windows (Devices) then,

X11() # not really needed as plot() will produce a new device if none is
  # open
plot(1:10)
X11()
plot(1:10)
X11()
plot(1:10)
...

Will create a new device. see ?Devices for a list of devices you can
open on your system or ?capabilities . It is so long since I used a
Windows version of R, that I forget if X11() opens a Windows graphics
device there as well.

As for 3D stuff, you might take a look at persp() (in base R) and the
scatterplot3D package. If you want to see what R's Graphics can do, then
the book R Graphics by Paul Murrell [1] will tell you all you need to
know, and the excellent, online R graphics gallery [2] has lots of
examples.

HTH

G

[1] http://www.stat.auckland.ac.nz/~paul/RGraphics/rgraphics.html
[2] http://addictedtor.free.fr/graphiques/
-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 *Note new Address and Fax and Telephone numbers from 10th April 2006*
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
Gavin Simpson [t] +44 (0)20 7679 0522
ECRC  [f] +44 (0)20 7679 0565
UCL Department of Geography
Pearson Building  [e] gavin.simpsonATNOSPAMucl.ac.uk
Gower Street
London, UK[w] http://www.ucl.ac.uk/~ucfagls/cv/
WC1E 6BT  [w] http://www.ucl.ac.uk/~ucfagls/
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

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


Re: [R] Some questions about plotting with R

2006-10-04 Thread Robin Hankin
Hi



 Thanks for the response Robin, but that document doesn't help me with
 either my quest for plot3, or multiple figures (i.e. the 'figure'
 command in Octave/Matlab).

 cheers,
 Wee-Jin

 If you want three separate graphics windows (Devices) then,

 X11() # not really needed as plot() will produce a new device if  
 none is
   # open
 plot(1:10)
 X11()
 plot(1:10)
 X11()
 plot(1:10)



This isn't in  R-and-octave.txt: I'll add it when I get a minute.

And come to think of it, R-and-octave.txt doesn't mention plot3,
probably because it's not implemented in octave AFAIR.
I'll add a section of 3D graphics, When I Get A Minute (tm).

You also have p3d() of the onion package for 3D plotting,
which you might find closer in spirit to the matlab functionality.

best wishes

rksh




 ...

 Will create a new device. see ?Devices for a list of devices you can
 open on your system or ?capabilities . It is so long since I used a
 Windows version of R, that I forget if X11() opens a Windows graphics
 device there as well.

 As for 3D stuff, you might take a look at persp() (in base R) and the
 scatterplot3D package. If you want to see what R's Graphics can do,  
 then
 the book R Graphics by Paul Murrell [1] will tell you all you need to
 know, and the excellent, online R graphics gallery [2] has lots of
 examples.






--
Robin Hankin
Uncertainty Analyst
National Oceanography Centre, Southampton
European Way, Southampton SO14 3ZH, UK
  tel  023-8059-7743

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


Re: [R] Some questions about plotting with R

2006-10-04 Thread Wee-Jin Goh

 This isn't in  R-and-octave.txt: I'll add it when I get a minute.

 And come to think of it, R-and-octave.txt doesn't mention plot3,
 probably because it's not implemented in octave AFAIR.
 I'll add a section of 3D graphics, When I Get A Minute (tm).

 You also have p3d() of the onion package for 3D plotting,
 which you might find closer in spirit to the matlab functionality.


Thanks for all the information given so far! It's been absolutely  
terrific!

Currently, I'm creating new devices using quartz() since I'm on the  
Mac. On my Linux box, I'd use X11() as suggested. This works  
beautifully.

For 3D plots, p3d from the onion package works pretty much exactly as  
plot3 does on Octave and Matlab.

Thanks a lot for the help. You guys are great.

Wee-Jin

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


Re: [R] nested design; intercept

2006-10-04 Thread Mark Difford
 Dear R-help,

I am sorry if this is more of a stats question than an R-question, but I have 
found it difficult to get a clear answer by other means.

Q. Would it be wrong to specify a nested model and retain a common intercept, 
e.g.

lm(NH4 ~ Site/TideCode + 1)

I am aware (?) that my Site-coefficients are now calculated relative to my 
reference Site  (treatment.contrasts), *but* that my TideCode levels now relate 
to their reference level within Site.

Is that correct?

Thank you in advance for help.

Regards,
Mark Difford.

  
Mark Difford 
Ph.D. candidate, Botany Department, 
Nelson Mandela Metropolitan University, 
Port Elizabeth, SA.

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


Re: [R] FW: new to R: don't understand errors

2006-10-04 Thread Fridolin Wild

Hello Jerad,

 It was suggested I contact you for possible help with this issue. Well,
 as you can see for the emails below, that is what I was told at R-help.
 Any insight to my lsa problems (also listed below) would be of great
 help.

from what I see, the problem probably indeed lies within the
textfiles: for performance reasons, it was not possible to
include any check routines that exclude a file if it contains
no words (or words below a docFrequency) and thus produces
an empty column-vector.

I am pretty sure that you do not want to use docFrequency
with a value like 50 (it would mean that a term in a document
is only included if it appears more than 50 times in *that*
document).

I will send you the alpha-release of the updated lsa package
in a separate message which also includes a parameter called
minGlobFreq which is filtering out terms that appear less
than x times in the whole document collection. I guess that is
what you were looking for.

Considering the sanitizing: if you set minDocFreq to 1
and set minWordLength to 1, you should not get an error
with your document collection as you then are basically
taking everything (even a single character appearing
only once). It probably is not so problematic as the
LSA step will anyway group this low-frequency terms
in a lower order factor. Of course you will still get
an error if you use documents that are completely empty,
so delete all 0 bytes documents beforehands.

I am thinking about what to do with this sanitizing part.
It is not a good idea to integrate that into the
textmatrix method -- it would slow things down
tremendously.

So what about this idea: does it make sense to provide a
sanitizing collection of methods that help to select the
files you want to work with (copy them to a different
directory or just return a list with the filenames of
the ones that are good)? What should we do with other
sanitizing options (deleting urls from texts, deleting
short words, etc.)?

Hope, I could be of help,

Best,
Fridolin

-- 
Fridolin Wild, Institute for Information Systems and New Media,
Vienna University of Economics and Business Administration (WUW),
Augasse 2-6, A-1090 Wien, Austria
fon +43-1-31336-4488, fax +43-1-31336-746

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


Re: [R] Possible bug?

2006-10-04 Thread ronggui
Yes, the installer missed some file(s) in RHOME/bin.
When I choose Message translations, the /bin directory contains the
following files.

R.dll
R.exe
RSetReg.exe
Rblas.dll
Rcmd.exe
Rgui.exe
Rlapack.dll
Rproxy.dll
Rterm.exe
Stangle.sh
Sweave.sh
helpPRINT.bat
md5check.exe

When I install without choosing Message translations, the /bin directory
contains the following files.

INSTALL
R.dll
R.exe
REMOVE
RSetReg.exe
Rblas.dll
Rcmd.exe
Rd2dvi.sh
Rd2txt
Rdconv
Rdiff.sh
Rgui.exe
Rlapack.dll
Rprof
Rproxy.dll
Rterm.exe
SHLIB
Sd2Rd
Stangle.sh
Sweave.sh
build
check
helpPRINT.bat
massage-Examples
md5check.exe



On 10/4/06, Duncan Murdoch [EMAIL PROTECTED] wrote:

 On 10/4/2006 12:02 AM, Ray Brownrigg wrote:
  On Wednesday 04 October 2006 14:17, Duncan Murdoch wrote:
  On 10/3/2006 9:00 PM, ronggui wrote:
  This morning I downloaded R-2.4.0 and install in under Windows. I
  customized the installation and choose Message translations,but I
 could
  not launch Rgui.exe successfully( Rterm.exe worked fine). If I did't
  choose Message translations, Rgui.exe worked fine.
 
  Message translations is Simplified Chinese.
  Did you test any of the betas or release candidates?  I run an English
  language version of Windows, and I don't even get offered the chance to
  install in Simplified Chinese, so I certainly didn't test this.
 
  Duncan Murdoch
 
 
  7*runif(1)
  [1] 2.897160
 
  Well, I have a (self compiled) R-2.4.0 beta (2006-09-24 r39497) which
 doesn't
  exhibit the behaviour in the same environment (Windows XP Professional
  English version but with Simplified Chinese set as the locale) that the
  released R-2.4.0-win32.exe does.  [Perhaps my version didn't set up the
  equivalent of  Message translations so this may be a red herring, but
 it
  does output the startup message in Chinese, and error messages are also
  output in Chinese.]
 
  What happens with the release version is an error message:
  R for Windows GUI front-end has encountered a problem and needs to
 close.  We
  are sorry for the inconvenience.  Then it offers to Please tell
 Microsoft
  about the problem, and if you click here  the error signature has:
  AppName: rgui.exe AppVer: 2.40.39566.0ModName: r.dll
  ModVer: 2.40.39566.0  Offset: 000f22b3
 
  There is a lot more information as well, but I don't know how much is
  relevant.
 
  By Simplified Chinese set as the locale I mean 'Control Panel/Regional
 and
  Language Options' with Chinese (PRC) set in 'Regional Options/Standards
 and
  Formats' and 'Advanced/Language for non-Unicode Programs'.
 
  [I don't rely on the Chinese environment, so this doesn't materially
 affect
  me, but I may be able to help with diagnosis.]

 Could you take a look in RHOME/modules at the file iconv.dll?  We
 upgraded it to version 1.11.0.0 relatively late in the cycle; it's
 possible that your successful install uses a different version.  (The
 version should be available in the popup if you hover the mouse over it,
 or in the properties if you right click it.)

 If that's not it, then I'd guess the problem is that the installer
 missed some file(s); could you compare the installed file lists from the
 beta and the release, and send me a list of files that occur only in the
 beta?  It's normal for that list to be fairly long, because when you
 build yourself a lot of unnecessary files are left behind.

 Duncan Murdoch




-- 
»ÆÈÙ¹ó
Department of Sociology
Fudan University

[[alternative HTML version deleted]]

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


Re: [R] Possible bug?

2006-10-04 Thread Duncan Murdoch
On 10/4/2006 7:14 AM, ronggui wrote:
 Yes, the installer missed some file(s) in RHOME/bin.
 When I choose Message translations, the /bin directory contains the
 following files.
 
 R.dll
 R.exe
 RSetReg.exe
 Rblas.dll
 Rcmd.exe
 Rgui.exe
 Rlapack.dll
 Rproxy.dll
 Rterm.exe
 Stangle.sh
 Sweave.sh
 helpPRINT.bat
 md5check.exe
 
 When I install without choosing Message translations, the /bin directory
 contains the following files.
 
 INSTALL
 R.dll
 R.exe
 REMOVE
 RSetReg.exe
 Rblas.dll
 Rcmd.exe
 Rd2dvi.sh
 Rd2txt
 Rdconv
 Rdiff.sh
 Rgui.exe
 Rlapack.dll
 Rprof
 Rproxy.dll
 Rterm.exe
 SHLIB
 Sd2Rd
 Stangle.sh
 Sweave.sh
 build
 check
 helpPRINT.bat
 massage-Examples
 md5check.exe

That makes it look as though the installer aborted partway through.
Could you try to re-install, but run with the command line option /LOG?

This will create a log file in your TEMP directory (pointed to by your
TEMP environment variable, or perhaps in Local Settings/Temp in your
Windows home directory), named something like

Setup Log 2006-10-04 #001.txt

It might give some hint as to what went wrong, e.g. some file was in use
and couldn't be replaced, etc.

Duncan Murdoch

 
 
 
 On 10/4/06, Duncan Murdoch [EMAIL PROTECTED] wrote:
 On 10/4/2006 12:02 AM, Ray Brownrigg wrote:
 On Wednesday 04 October 2006 14:17, Duncan Murdoch wrote:
 On 10/3/2006 9:00 PM, ronggui wrote:
 This morning I downloaded R-2.4.0 and install in under Windows. I
 customized the installation and choose Message translations,but I
 could
 not launch Rgui.exe successfully( Rterm.exe worked fine). If I did't
 choose Message translations, Rgui.exe worked fine.

 Message translations is Simplified Chinese.
 Did you test any of the betas or release candidates?  I run an English
 language version of Windows, and I don't even get offered the chance to
 install in Simplified Chinese, so I certainly didn't test this.

 Duncan Murdoch

 7*runif(1)
 [1] 2.897160

 Well, I have a (self compiled) R-2.4.0 beta (2006-09-24 r39497) which
 doesn't
 exhibit the behaviour in the same environment (Windows XP Professional
 English version but with Simplified Chinese set as the locale) that the
 released R-2.4.0-win32.exe does.  [Perhaps my version didn't set up the
 equivalent of  Message translations so this may be a red herring, but
 it
 does output the startup message in Chinese, and error messages are also
 output in Chinese.]

 What happens with the release version is an error message:
 R for Windows GUI front-end has encountered a problem and needs to
 close.  We
 are sorry for the inconvenience.  Then it offers to Please tell
 Microsoft
 about the problem, and if you click here  the error signature has:
 AppName: rgui.exe AppVer: 2.40.39566.0ModName: r.dll
 ModVer: 2.40.39566.0  Offset: 000f22b3

 There is a lot more information as well, but I don't know how much is
 relevant.

 By Simplified Chinese set as the locale I mean 'Control Panel/Regional
 and
 Language Options' with Chinese (PRC) set in 'Regional Options/Standards
 and
 Formats' and 'Advanced/Language for non-Unicode Programs'.

 [I don't rely on the Chinese environment, so this doesn't materially
 affect
 me, but I may be able to help with diagnosis.]
 Could you take a look in RHOME/modules at the file iconv.dll?  We
 upgraded it to version 1.11.0.0 relatively late in the cycle; it's
 possible that your successful install uses a different version.  (The
 version should be available in the popup if you hover the mouse over it,
 or in the properties if you right click it.)

 If that's not it, then I'd guess the problem is that the installer
 missed some file(s); could you compare the installed file lists from the
 beta and the release, and send me a list of files that occur only in the
 beta?  It's normal for that list to be fairly long, because when you
 build yourself a lot of unnecessary files are left behind.

 Duncan Murdoch

 
 


__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] integers to POSIXct

2006-10-04 Thread paul sorenson
What is the recommended way to convert/coerce and integer to a POSIXct 
please?

d - as.POSIXct(Sys.Date())
i - as.integer(d)

as.POSIXct(i)
Error in as.POSIXct.default(i) : do not know how to convert 'i' to class 
POSIXlt

This appears to be the behaviour in 2.3.1 and 2.4.0 on windows XP.

I have tried searching on this and found as.Date.integer in package zoo 
which performs a similar function but wondered if there was something 
basic I was missing in the base distribution?

cheers

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


Re: [R] Linear model with hidden variables

2006-10-04 Thread John Fox
Dear Richard,

This looks like a latent-variable structural-equation model of the kind that
one can fit with the sem package. If, however, both of the Y's affect all of
the Z's, then the model isn't identified. (You also don't say what you
assume about the errors from different equations -- are they correlated?)

I hope this helps,
 John


John Fox
Department of Sociology
McMaster University
Hamilton, Ontario
Canada L8S 4M4
905-525-9140x23604
http://socserv.mcmaster.ca/jfox 
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of 
 Richard A. O'Keefe
 Sent: Wednesday, October 04, 2006 12:37 AM
 To: r-help@stat.math.ethz.ch
 Subject: [R] Linear model with hidden variables
 
 
 I have some data on a moving vehicle where, amongst other 
 things, it looks as though it would be informative to fit a 
 model with the following structure:
 
 Z = B.Y + errorz
 Y = C.X + errorz
 
 The X variables are observed predictor variables;
 6 of the variables look promising (on the basis of what they mean).
 
 The Z variables are observed response variables; there are 4 of them.
 
 There is a priori reason to believe, and scatterplots to 
 suggest, that the Z variables are really essentially 
 two-dimensional, so
 
 the Y variables are hidden intermediate variables.
 There should be 2 of them.  There are actually two physical 
 candidates for what they might be, but they happen not to 
 have been measured.
 
 There are 800 cases.  (More precisely, there are 14 periods, 
 each with about 800 samples, and I am interested in fitting a 
 separate model in each period.)
 
 A simple least squares fit for this model would minimise the 
 sum of error squares for the Zs.  Oh, I do mean there to be 
 constant terms.
 
 I suppose I could go back to first principles and work it all 
 out, but has anyone ever done something like this in R?  
 There seems to be every imaginable variation on lm and some 
 that I find unimaginable, so presumably a means to do this is 
 already around somewhere.
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] rendering date/times from 64bit julian format?

2006-10-04 Thread Derek Eder
Hellos,

I have date/times in 64-bit Julian format, that is the number of 
milliseconds since 1 jan 1970 (or something like that).E.g.,   
1159884877406

For the life of me I can't figure out how to render these in a more 
readable format, e.g.,  2006-10-04  23:12:93.191  (and I have tried to 
do my best searching the archives and help etc ...)


Thank you most sincerely,

Derek Eder




-- 
Derek N. Eder

Gothenburg University 
VINKLA - Vigilance and Neurocognition laboratory

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] [OT] Survival and Function as co-primary endpoints in clinical trials. How to simulate in R ?

2006-10-04 Thread Jean-Louis Abitbol
Dear R-Helpers,

Apologies in advance as this is partly (widely ?) OT. Not sure where to
ask, R is my favorite computer tool (no kidding) and there are plenty of
knowledgable and helpful people on the list.  

Background: There are discussions among experts and regulatory
authorities (cf guideline
http://www.emea.europa.eu/pdfs/human/ewp/056598en.pdf) that, in for
example Amyotrophic Lateral Sclerosis, a functional endpoint
(respiratory function, muscular testing, rating scale) should be
associated (co-primary, 2 primaries etc..) to survival in drug trials.

My problem: I wish to illustrate that from my point of view and when you
have a drug that improves survival this is not what you should do for
the following reasons: - Death leads to missing data on function (sic)
   - This does not occur at random if the drug impacts
   survival
   - The assessment of function is biased in defavor of
   the drug improving survival (keeping alive patients
   with poor function)
 and in favor of the placebo group (those who
 survive have better function)

The questions: 1-Would some one please suggest litterature where this is
discussed or examples of similar situations
   2-  I would like to simulate the process in R ie generate
   survival (exponential for a start although Weibull may be
   be more  appropriate) data with several drug effects on
   survival (I can do this), and also simulate various
   effects on function (for example vital capacity) which
   would be correlated to the effect on survival (not sure I
   know what Ineed to do and how to do it...).

 I realize this is not clear language and a clear question but to help
 formulate the question better I would appreciate pointers to relevant
 litterature/scripts on simulation of clinical trials in general or more
 specific to my problem in R. 

Please answer to me directly to avoid OT inconvenience to the list and
so that I am not black listed...I'll be happy to summarize if relevant
to the list.

Best regards, Jean-Louis 
Jean-Louis Abitbol, MD
Chief Medical Officer
Trophos SA, Parc scientifique de Luminy, Case 931
Luminy Biotech Entreprises
13288 Marseille Cedex 9 France
Email: [EMAIL PROTECTED]  Backup Email: [EMAIL PROTECTED]
Cellular: (33) (0)6 24 47 59 34
Direct Line: (33) (0)4 91 82 82 73-Switchboard: (33) (0)4 91 82 82 82  
Fax: (33) (0)4 91 82 82 89

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] Optim: Function definition

2006-10-04 Thread Serguei Kaniovski
Hi all,

I apply optim to the function obj, which minimizes the goodness of 
fit statistic and obtains Pearson minimum chi-squared estimate for x[1], 
x[2] and x[3]. The vector fr contains the four observed frequencies.

Since fr[i] appears in the denominator, I would like to substitute 0 
in the sum if fr[i]=0.

I tried an ifelse condition which works, but in some cases the 
solution seems rather odd. Is there anything wrong with the way second 
objective function is coded?

obj-function(x){
(fr[1]-x[1]*x[2]-x[3]*sqrt(x[1]*(1-x[1])*x[2]*(1-x[2])))^2/fr[1]+
(fr[2]-(1-x[1])*x[2]+x[3]*sqrt(x[1]*(1-x[1])*x[2]*(1-x[2])))^2/fr[2]+
(fr[3]-x[1]*(1-x[2])+x[3]*sqrt(x[1]*(1-x[1])*x[2]*(1-x[2])))^2/fr[3]+
(fr[4]-(1-x[1])*(1-x[2])-x[3]*sqrt(x[1]*(1-x[1])*x[2]*(1-x[2])))^2/fr[4]
}

obj-function(x){
ifelse(fr[1]==0,0,(fr[1]-x[1]*x[2]-x[3]*sqrt(x[1]*(1-x[1])*x[2]*(1-x[2])))^2/fr[1])+
ifelse(fr[2]==0,0,(fr[2]-(1-x[1])*x[2]+x[3]*sqrt(x[1]*(1-x[1])*x[2]*(1-x[2])))^2/fr[2])+
ifelse(fr[3]==0,0,(fr[3]-x[1]*(1-x[2])+x[3]*sqrt(x[1]*(1-x[1])*x[2]*(1-x[2])))^2/fr[3])+
ifelse(fr[4]==0,0,(fr[4]-(1-x[1])*(1-x[2])-x[3]*sqrt(x[1]*(1-x[1])*x[2]*(1-x[2])))^2/fr[4])
}

sval=rep(0.1,3)
fr-c(0,0.1,0.2,0.3)

optim(sval,obj, method=BFGS)$par

Thank you,
Serguei
-- 
___

Austrian Institute of Economic Research (WIFO)

Name: Serguei Kaniovski P.O.Box 91
Tel.: +43-1-7982601-231 Arsenal Objekt 20
Fax:  +43-1-7989386 1103 Vienna, Austria
Mail: [EMAIL PROTECTED]

http://www.wifo.ac.at/Serguei.Kaniovski

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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 generate matrices based on an indicator variable

2006-10-04 Thread Ya-Hsiu Chuang
Hi,

I am trying to create matrices X's based on one indicator variable, r.

Given a 4 x4 matrix X= [ 0,0,0,0
0,0,0,0
0,0,0,0
0,0,0,1]
r= c(0, 0, 0, 1)

I'd like to create separate matrices where
when i = 1, X= [1,0,0,0
  0,0,0,0
  0,0,0,0
  0,0,0,1]

when i =2 , X= [0,0,0,0
 0,1,0,0
 0,0,0,0
 0,0,0,1]

when i = 3, X=  [0,0,0,0
  0,0,0,0
  0,0,1,0
  0,0,0,1]

when i = 4, X=  [0,0,0,0 
  0,0,0,0
  0,0,0,0
  0,0,0,1]

Any suggestions would be very appreciated.

Thanks


[[alternative HTML version deleted]]

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


Re: [R] rendering date/times from 64bit julian format?

2006-10-04 Thread Peter Dalgaard
Derek Eder [EMAIL PROTECTED] writes:

 Hellos,
 
 I have date/times in 64-bit Julian format, that is the number of 
 milliseconds since 1 jan 1970 (or something like that).E.g.,   
 1159884877406
 
 For the life of me I can't figure out how to render these in a more 
 readable format, e.g.,  2006-10-04  23:12:93.191  (and I have tried to 
 do my best searching the archives and help etc ...)
 

This should be close:

 format(ISOdatetime(1970,1,1,0,0,0)+1159884877406/1000,%Y-%m-%d %H:%M:%OS3)
[1] 2006-10-03 15:14:37.406

Beware the timezone issues though.
-- 
   O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - ([EMAIL PROTECTED])  FAX: (+45) 35327907

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


Re: [R] rendering date/times from 64bit julian format?

2006-10-04 Thread Dirk Eddelbuettel

On 4 October 2006 at 14:50, Derek Eder wrote:
| I have date/times in 64-bit Julian format, that is the number of 
| milliseconds since 1 jan 1970 (or something like that).E.g.,   
| 1159884877406
| 
| For the life of me I can't figure out how to render these in a more 
| readable format, e.g.,  2006-10-04  23:12:93.191  (and I have tried to 
| do my best searching the archives and help etc ...)

To paraphrase an old saying about Unix, you could say that R's very powerful
Date/Time operations are indeed very user-friendly -- but unfortunately also
picky in selecting their friends.

To key to this conversion is to use implicit casting.  Witness

 now - Sys.time()
 class(now)
[1] POSIXt  POSIXct
 format(as.numeric(now), digits=16)
[1] 1159968337.833141

so we *do* have the current time in a POSIXct as such a number.  So for your
purposes, create an 'offset', maybe via 

  offset - ISOdatetime(1970,1,1,0,0,0,tz=GMT)
 class(offset)
[1] POSIXt  POSIXct
 as.numeric(offset)
[1] 0

which gives you half the solution -- a POSIXct to start from, conveniently
placed at the 'epoch.. Pick whichever timezone works for you.

Then simply add your milliseconds -- but converted to seconds as that is how
the internal representation is scaled:

 offset + 1159884877406/1000
[1] 2006-10-03 14:14:37.406 GMT
 class(offset + 1159884877406/1000)
[1] POSIXt  POSIXct

Now your returned object is still POSIXct so you get to do all sort of fany
conversions for free.

The really nice thing is that thanks for a number of post-R 2.3.1
enhancements by Brian Ripley, we do have reall milisecond granularity in R.

Hope this helps,  Dirk

PS  Kurt, would this be worthy of a new FAQ entry?
 

-- 
Hell, there are no rules here - we're trying to accomplish something. 
  -- Thomas A. Edison

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 generate matrices based on an indicator variable

2006-10-04 Thread Gabor Grothendieck
This produces a list whose ith element is matrix Xi :

X4 - replace(matrix(0, 4, 4), cbind(4, 4), 1)
lapply(1:4, function(i) replace(X4, cbind(i,i), 1))


On 10/4/06, Ya-Hsiu Chuang [EMAIL PROTECTED] wrote:
 Hi,

 I am trying to create matrices X's based on one indicator variable, r.

 Given a 4 x4 matrix X= [ 0,0,0,0
0,0,0,0
0,0,0,0
0,0,0,1]
 r= c(0, 0, 0, 1)

 I'd like to create separate matrices where
 when i = 1, X= [1,0,0,0
  0,0,0,0
  0,0,0,0
  0,0,0,1]

 when i =2 , X= [0,0,0,0
 0,1,0,0
 0,0,0,0
 0,0,0,1]

 when i = 3, X=  [0,0,0,0
  0,0,0,0
  0,0,1,0
  0,0,0,1]

 when i = 4, X=  [0,0,0,0
  0,0,0,0
  0,0,0,0
  0,0,0,1]

 Any suggestions would be very appreciated.

 Thanks
\

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


Re: [R] integers to POSIXct

2006-10-04 Thread Gabor Grothendieck
Here are a few ways:


now - Sys.time()
Epoch - now - as.numeric(now)
i + Epoch

structure(i, class = c(POSIXt, POSIXct))

class(i) - c(POSIXt, POSIXct)


On 10/4/06, paul sorenson [EMAIL PROTECTED] wrote:
 What is the recommended way to convert/coerce and integer to a POSIXct
 please?

 d - as.POSIXct(Sys.Date())
 i - as.integer(d)

 as.POSIXct(i)
 Error in as.POSIXct.default(i) : do not know how to convert 'i' to class
 POSIXlt

 This appears to be the behaviour in 2.3.1 and 2.4.0 on windows XP.

 I have tried searching on this and found as.Date.integer in package zoo
 which performs a similar function but wondered if there was something
 basic I was missing in the base distribution?

 cheers

 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] One-arm survival sample estimates

2006-10-04 Thread Hamilton, Cody

A few months ago, I posted a query regarding code for a sample size
estimate for a one arm survival trial.  Below is some code I created to
calculate such an estimate - perhaps it may be of some use.



#cox.pow computes sample size for a one arm survival trial.  med.0 is
the null median

#survival, med.a is the alternative median survival, a.time is the
accrual time, and

#f.time is the follow up (assumes constant accrual and two sided test).
Approach taken

#from Lawless 1982, p. 108



cox.pow-function(med.0,med.a,a.time,f.time,alpha,beta) {

   #initialize number of events to 0

   r-0

   #find necessary number of events

   while (qchisq((1-alpha/2),(2*r+1))*(med.0/med.a) =
qchisq(beta,(2*r+1)) ) {r-r+1}

   #find proportion of patients that will experience event for given
median survivals,

   #accrual and follow up times (formula from Cox 1983)

   p - 1 - (exp(-0.69*f.time/med.a)*(1 -
exp(-0.69*a.time/med.a))/(0.69*a.time/med.a))

   #sample size is r/p

   n-round(r/p,0)

   return(n)

}



#compute necessary sample size for alternative median 9.3 vs. null
median 6.3 with 20

#months accrual and 4 months follow up

cox.pow(6.3,9.3,20,4,.05,.2)



Regards,

   -Cody



Cody Hamilton, Ph.D

Institute for Health Care Research and Improvement

Baylor Health Care System





This e-mail, facsimile, or letter and any files or attachmen...{{dropped}}

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] (not so real) function (more like #include)

2006-10-04 Thread Meinhard Ploner
Hello R users,

I have a very long function with parts of that looking like a list of  
jobs. The first part of the function defines a lot of local  
variables, which are used by the jobs. Now I extracted the job part  
und putted them into an external file, used by source(, local=T),  
which is more comfortable to me. Apart from that it gives me the  
opportunity that more users can work on the project. Is it possible  
to define a function for that code and passing to it the environment  
of f() without save(list=ls()) and load()  ?

Thanks in advance
Meinhard Ploner

longfun - f() {

## lot of local variables:
a - ...
b - ...
d - ...
...

out - ...

source(job1.txt, local=TRUE)   #changes out, uses a, b, d, ...

source(job2.txt, local=TRUE)  # changes out, uses a, b, d, ...
...
}



version
_
platform   i386-apple-darwin8.6.1
arch   i386
os darwin8.6.1
system i386, darwin8.6.1
status
major  2
minor  3.1
year   2006
month  06
day01
svn rev38247
language   R
version.string Version 2.3.1 (2006-06-01)

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] ciclo for in matrix construction ( matlab - R )

2006-10-04 Thread massimodisasha
hi,
i'm new to R
i have a little script in matlab
now i'm porting it to R but i've some problem.
how can i write in R language this
matlab/octave code:

LX = L ;  L is a matrix
ss = size(LX,1);
E_N_2 = zeros(ss,2);

for i = 1:ss
E_2 = E_0 + LX(i,1)*C(3)+LX(i,2)*C(4);   E_0 , C(3), c(4)   
are costant
N_2 = N_0 + LX(i,2)*C(3)-LX(i,1)*C(4);
r=[ E_2,N_2];
E_N_2(i,:)=r;
end
E_N_2

i'm try so :

library(matlab)
LX - L
ss - dim(LX)
ss - ss[1]
E_N_2 - zeros(ss,2)
for(i in 1:ss)
.
.?

thanks for any help :-)
Massimo

my mayor problem is to know how the cicle for works
[[alternative HTML version deleted]]

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


[R] Error in names-.default

2006-10-04 Thread nalluri pratap
Hi All,
   
  Can some one explain me the following error-
   
   Error in names-.default
  'names' attribute [1199] must be the same length as the vector [17].
   
  Thanks,
  Pratap


-


[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] ciclo for in matrix construction ( matlab - R )

2006-10-04 Thread massimodisasha
hi,
i'm new to R
i have a little script in matlab
now i'm porting it to R but i've some problem.
how can i write in R language this
matlab/octave code:

LX = L ;  L is a matrix
ss = size(LX,1);
E_N_2 = zeros(ss,2);

for i = 1:ss
E_2 = E_0 + LX(i,1)*C(3)+LX(i,2)*C(4);   E_0 , C(3), c(4)   
are costant
N_2 = N_0 + LX(i,2)*C(3)-LX(i,1)*C(4);
r=[ E_2,N_2];
E_N_2(i,:)=r;
end
E_N_2

i'm try so :

library(matlab)
LX - L
ss - dim(LX)
ss - ss[1]
E_N_2 - zeros(ss,2)
for(i in 1:ss)
.
.?

thanks for any help :-)
Massimo

my mayor problem is to know how the cicle for works
[[alternative HTML version deleted]]

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


Re: [R] Linking R with Fortran 90: make: m2c: Command not found

2006-10-04 Thread Jason Liao
many Thanks to Mike Prager and José Fernández Menéndez  for your help. I tried 
what Mike suggested in various ways but the problem is still there. Jose's 
solution worked beautifully in producing a dll. After dyn.load() the dll, 
however, is.loaded() gives me a false answer. I still need to investigate this 
later part. Progress has been made, nevertheless.

Jason

from http://gcc.gnu.org/wiki/GfortranFAQ:


Gfortran creates a file namemod= for each module name. This confuses the gnu 
make, which thinks that .mod
files are Modula2 source code files. You must override this built-in
rule by adding the following line somewhere in your Makefile. 

%.o : %.mod
 
hope this helps!!!



Jason Liao, 
http://www.geocities.com/jg_liaoAssociate Professor of Biostatistics
Drexel University School of Public Health
245 N. 15th Street, Mail Stop 660
Philadelphia, PA 19102-1192
phone 215-762-3934

__

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


Re: [R] (not so real) function (more like #include)

2006-10-04 Thread Gabor Grothendieck
longfun could just pass a, b and d to each of the individual
functions and each of the individual functions could pass
out back as a return value.

f1 - f2 - function(a, b, d) a+b+d

longfun1 - function() {
   a - b - d - 1
   out - f1(a, b, d)
   out - f2(a, b, d) + out
   out
}

longfun1() # 6

If the problem is that a, b and d actually represent 100 variables, say,
and its a nuisance to pass them all explicitly you could do this:

f1 - f2 - function() with(parent.frame(), a + b + d)

longfun2 - function() {
   a - b - d - 1
   out - f1()
   out - f2() + out
   out
}

longfun2() # 6


or you could do it this way if you would prefer to have longfun
control the scoping rather than having it done within each
individual function:


f1 - f2 - function() a+b+d

longfun3 - function() {
a - b - d - 1
environment(f1) - environment(f2) - environment()
out - f1()
f2() + out
}

longfun3() # 6


On 10/4/06, Meinhard Ploner [EMAIL PROTECTED] wrote:
 Hello R users,

 I have a very long function with parts of that looking like a list of
 jobs. The first part of the function defines a lot of local
 variables, which are used by the jobs. Now I extracted the job part
 und putted them into an external file, used by source(, local=T),
 which is more comfortable to me. Apart from that it gives me the
 opportunity that more users can work on the project. Is it possible
 to define a function for that code and passing to it the environment
 of f() without save(list=ls()) and load()  ?

 Thanks in advance
 Meinhard Ploner

 longfun - f() {

## lot of local variables:
a - ...
b - ...
d - ...
...

out - ...

source(job1.txt, local=TRUE)   #changes out, uses a, b, d, ...

source(job2.txt, local=TRUE)  # changes out, uses a, b, d, ...
...
 }



 version
_
 platform   i386-apple-darwin8.6.1
 arch   i386
 os darwin8.6.1
 system i386, darwin8.6.1
 status
 major  2
 minor  3.1
 year   2006
 month  06
 day01
 svn rev38247
 language   R
 version.string Version 2.3.1 (2006-06-01)

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


Re: [R] strip function

2006-10-04 Thread Deepayan Sarkar
On 10/4/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 Hi,

 I would like to asign titles into strip of a panel of curves designed
 thanks to a xyplot function (lattice package)
 I ve tried the strip function, ...

 here is my code
 I would like to write in the strip of each panel conditionning varialbe
 (here, it is data[,1])
  xyplot (data[,3] ~ data[,2] | data[,1] ,  strip.default (which.given=1,
 which.panel = c(1:15), var.name= c
 (26,28,15,2,31,10,16,21,21.5,5,17,14,7,8,30),
 factor.levels=c(26,28,15,2,31,10,16,21,21.5,5,17,14,7,8,30),strip.names=c(1,0),strip.levels=c(0,0)),panel=function(x,y)
 {
 panel.xyplot(x,y,pch=4,col=3)
 type = c(p, r)
 COEFF-coef(lm(log(y)~x))
 panel.curve(exp(COEFF[1]+COEFF[2]*x),col=4)
 a-round(COEFF[1],digit=2)
 b-round(COEFF[2],digit=2)
 formula-as.name(paste(y=exp(,a,b,x),sep=))
 panel.text(10,700,formula)
 })


 I cannot get anny result exept one page with a big strip on which is
 written 26 and then the curve without specified strip

 CAn anyone give me some advices ?

Yes;

(1) acquire some rudimentary R programming skills, which you currently
do not seem to have. See the links under Documentation in
http://www.r-project.org for some possible starting points.

(2) read the posting guide at
http://www.R-project.org/posting-guide.html, and follow its
suggestions. In particular, give a _reproducible example_ and describe
what you _want to do_, not some badly written code which fails to do
it (in fact I'm surprised that your code does anything at all).

Deepayan

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] Bivariate Weibull distribution -- Copula

2006-10-04 Thread Jenny Stadt
Hi All,

I am struggling in a bivariate Weibull distribution although I searched 
R-Site-Help and found suggestion with Copula. Seems the maximum likelihood 
estimate is beyond what I can understand.

My case is: given two known marginal distribution (both are Weibull), and the 
correlation between them. How can I get the bivariate distribution based on 
these two? I wish if there is anybody has the experience in bivariate 
distribution could give me the hints. Thanks!

Jen.

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 convert all columns of a data frame into factors

2006-10-04 Thread Gabor Grothendieck
Try this:

replace(BOD, TRUE, lapply(BOD, factor))


On 10/4/06, Weiwei Shi [EMAIL PROTECTED] wrote:
 Hi,

 I use apply
 apply(x, 2, factor)

 but it does not work. please help. thanks.

 --
 Weiwei Shi, Ph.D
 Research Scientist
 GeneGO, Inc.

 Did you always know?
 No, I did not. But I believed...
 ---Matrix III

 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 convert all columns of a data frame into factors

2006-10-04 Thread Liaw, Andy
Alternatively:

x[] - lapply(x, factor)

Recall that a data frame is a list, so lapply() is a natural choice.

Andy 

From: Gabor Grothendieck
 
 Try this:
 
 replace(BOD, TRUE, lapply(BOD, factor))
 
 
 On 10/4/06, Weiwei Shi [EMAIL PROTECTED] wrote:
  Hi,
 
  I use apply
  apply(x, 2, factor)
 
  but it does not work. please help. thanks.
 
  --
  Weiwei Shi, Ph.D
  Research Scientist
  GeneGO, Inc.
 
  Did you always know?
  No, I did not. But I believed...
  ---Matrix III
 
  __
  R-help@stat.math.ethz.ch mailing list
  https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 
 


--
Notice:  This e-mail message, together with any attachments,...{{dropped}}

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 convert all columns of a data frame into factors

2006-10-04 Thread Gavin Simpson
On Wed, 2006-10-04 at 11:33 -0400, Weiwei Shi wrote:
 Hi,
 
 I use apply
 apply(x, 2, factor)
 
 but it does not work. please help. thanks.
 

In what sense does it not work? And how can you possibly expect anyone
on this list to help you as you neither supply the error message you
received nor provide us with x or a reproducible example, nor tell us
what you want to achieve.

E.g.

dat - sample(LETTERS, 100, replace = TRUE)
dat - matrix(dat, ncol = 10)
dat
apply(dat, 2, factor)

which appears to be converting a character vector into a factor, which
is then coerced to a numeric vector (as there are only numeric and
character matrices in R) - but I may be wrong:

as.numeric(factor(dat[,1]))
 [1] 7 7 2 5 8 1 4 7 3 6

which is the first column of the object returned by apply(dat, 2,
factor). Is this not what you wanted?

So perhaps you could provide the list with some further information as
you are asked to in the posting guide!

HTH

G
-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Gavin Simpson [t] +44 (0)20 7679 0522
 ECRC  ENSIS, UCL Geography,  [f] +44 (0)20 7679 0565
 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London  [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] Tabulation and missing values

2006-10-04 Thread David Scott

I think this is one for Gabor. I don't seem to be able to find my way to 
an answer despite numerous rereadings of factor and table.

Here is a toy example:


### Some data
EthnicCode - c(European/Other, NA, European/Other, European/Other,
 Pacific, European/Other, European/Other,
 European/Other, Maori, Maori, European/Other,
 European/Other, Asian, Pacific)
### I don't want the categories in the default order
### I also want to be able to include or exclude NA
### argument exclude controls inclusion of NA
table(EthnicCode)
table(EthnicCode,exclude=NULL)
### Creating a factor allows reordering
EthnicFactor - factor(EthnicCode, exclude=)
levels(EthnicFactor) - list(Maori=Maori,Pacific=Pacific,
 Asian=Asian,
 Europ/Other=European/Other,
 is.na=NA)
### I can tabulate with categories in the desired order
table(EthnicFactor[,drop=TRUE])
### But I can't seem to include the missing observations
table(EthnicFactor,exclude=NULL)

David Scott
_
David Scott Visiting (Until January 07)
Department of Probability and Statistics
The University of Sheffield
The Hicks Building
Hounsfield Road
Sheffield S3 7RH
United Kingdom
Phone:  +44 114 222 3908
Email:  [EMAIL PROTECTED]

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


Re: [R] Tabulation and missing values

2006-10-04 Thread Gabor Grothendieck
Is the idea here to have the NA entries be a factor level?  Try this:

table(format(EthnicCode))

with appropriate mods if you want to rearrange the levels.


On 10/4/06, David Scott [EMAIL PROTECTED] wrote:

 I think this is one for Gabor. I don't seem to be able to find my way to
 an answer despite numerous rereadings of factor and table.

 Here is a toy example:


 ### Some data
 EthnicCode - c(European/Other, NA, European/Other, European/Other,
 Pacific, European/Other, European/Other,
 European/Other, Maori, Maori, European/Other,
 European/Other, Asian, Pacific)
 ### I don't want the categories in the default order
 ### I also want to be able to include or exclude NA
 ### argument exclude controls inclusion of NA
 table(EthnicCode)
 table(EthnicCode,exclude=NULL)
 ### Creating a factor allows reordering
 EthnicFactor - factor(EthnicCode, exclude=)
 levels(EthnicFactor) - list(Maori=Maori,Pacific=Pacific,
 Asian=Asian,
 Europ/Other=European/Other,
 is.na=NA)
 ### I can tabulate with categories in the desired order
 table(EthnicFactor[,drop=TRUE])
 ### But I can't seem to include the missing observations
 table(EthnicFactor,exclude=NULL)

 David Scott
 _
 David Scott Visiting (Until January 07)
Department of Probability and Statistics
The University of Sheffield
The Hicks Building
Hounsfield Road
Sheffield S3 7RH
United Kingdom
 Phone:  +44 114 222 3908
 Email:  [EMAIL PROTECTED]

 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 convert all columns of a data frame into factors

2006-10-04 Thread Gavin Simpson
On Wed, 2006-10-04 at 17:04 +0100, Gavin Simpson wrote:
 On Wed, 2006-10-04 at 11:33 -0400, Weiwei Shi wrote:
  Hi,
  
  I use apply
  apply(x, 2, factor)
  
  but it does not work. please help. thanks.
  

Ah, lesson one: read the email clearly before replying - just like my
old Geography teacher used to tell me!

This works

dat - sample(LETTERS, 100, replace = TRUE)
# use a data. frame not a matrix
dat - data.frame(matrix(dat, ncol = 10))
dat
lapply(dat, factor) # as a list
# or, as a data.frame
data.frame(lapply(dat, factor))

G

 
 In what sense does it not work? And how can you possibly expect anyone
 on this list to help you as you neither supply the error message you
 received nor provide us with x or a reproducible example, nor tell us
 what you want to achieve.
 
 E.g.
 
 dat - sample(LETTERS, 100, replace = TRUE)
 dat - matrix(dat, ncol = 10)
 dat
 apply(dat, 2, factor)
 
 which appears to be converting a character vector into a factor, which
 is then coerced to a numeric vector (as there are only numeric and
 character matrices in R) - but I may be wrong:
 
 as.numeric(factor(dat[,1]))
  [1] 7 7 2 5 8 1 4 7 3 6
 
 which is the first column of the object returned by apply(dat, 2,
 factor). Is this not what you wanted?
 
 So perhaps you could provide the list with some further information as
 you are asked to in the posting guide!
 
 HTH
 
 G
-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Gavin Simpson [t] +44 (0)20 7679 0522
 ECRC  ENSIS, UCL Geography,  [f] +44 (0)20 7679 0565
 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London  [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

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


Re: [R] Error in names-.default

2006-10-04 Thread Gavin Simpson
On Wed, 2006-10-04 at 16:07 +0100, nalluri pratap wrote:
 Hi All,

   Can some one explain me the following error-

Error in names-.default
   'names' attribute [1199] must be the same length as the vector [17].

   Thanks,
   Pratap

You haven't shown us what you did, but it looks like you tried to
replace the names of an object with a vector (of length 1199) when a
vector of length 17 was required. See this example:

dat - as.data.frame(matrix(rnorm(100), ncol = 10))
names(dat) - LETTERS[1:10]
names(dat)
 [1] A B C D E F G H I J
names(dat) - LETTERS
Error in `names-.default`(`*tmp*`, value = c(A, B, C, D, E,  :
'names' attribute [26] must be the same length as the vector [10]

Where I have tried to replace names(dat) (which should be of length 10)
with a vector of length 26 (all the letters A-Z).

The error message above is not the same as the one you show though, so
this might not be the problem. As the posting guide asks, please give a
reproducible example or provide enough information for us to help you.

HTH

G

-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Gavin Simpson [t] +44 (0)20 7679 0522
 ECRC  ENSIS, UCL Geography,  [f] +44 (0)20 7679 0565
 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London  [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 convert all columns of a data frame into factors

2006-10-04 Thread Gabor Grothendieck
Just one small point on this.  This may not matter to you but
just in case it does, if L - lapply(BOD, factor) then

replace(BOD, TRUE, L)
data.frame(L)

are not exactly the same in the case that BOD has additional
attributes (which in this case it does).  The first one will
preserve the attributes and the second one does not.

attributes(BOD)  # note reference attribute
attributes(replace(BOD, TRUE, L)  # reference preserved
attributes(data.frame(L))  # no reference


On 10/4/06, Gavin Simpson [EMAIL PROTECTED] wrote:
 On Wed, 2006-10-04 at 17:04 +0100, Gavin Simpson wrote:
  On Wed, 2006-10-04 at 11:33 -0400, Weiwei Shi wrote:
   Hi,
  
   I use apply
   apply(x, 2, factor)
  
   but it does not work. please help. thanks.
  

 Ah, lesson one: read the email clearly before replying - just like my
 old Geography teacher used to tell me!

 This works

 dat - sample(LETTERS, 100, replace = TRUE)
 # use a data. frame not a matrix
 dat - data.frame(matrix(dat, ncol = 10))
 dat
 lapply(dat, factor) # as a list
 # or, as a data.frame
 data.frame(lapply(dat, factor))

 G

 
  In what sense does it not work? And how can you possibly expect anyone
  on this list to help you as you neither supply the error message you
  received nor provide us with x or a reproducible example, nor tell us
  what you want to achieve.
 
  E.g.
 
  dat - sample(LETTERS, 100, replace = TRUE)
  dat - matrix(dat, ncol = 10)
  dat
  apply(dat, 2, factor)
 
  which appears to be converting a character vector into a factor, which
  is then coerced to a numeric vector (as there are only numeric and
  character matrices in R) - but I may be wrong:
 
  as.numeric(factor(dat[,1]))
   [1] 7 7 2 5 8 1 4 7 3 6
 
  which is the first column of the object returned by apply(dat, 2,
  factor). Is this not what you wanted?
 
  So perhaps you could provide the list with some further information as
  you are asked to in the posting guide!
 
  HTH
 
  G
 --
 %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
  Gavin Simpson [t] +44 (0)20 7679 0522
  ECRC  ENSIS, UCL Geography,  [f] +44 (0)20 7679 0565
  Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
  Gower Street, London  [w] http://www.ucl.ac.uk/~ucfagls/
  UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
 %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

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


Re: [R] Tabulation and missing values

2006-10-04 Thread Gavin Simpson
On Thu, 2006-10-05 at 05:10 +1300, David Scott wrote:
 I think this is one for Gabor. I don't seem to be able to find my way to 
 an answer despite numerous rereadings of factor and table.
 
 Here is a toy example:
 
 
 ### Some data
 EthnicCode - c(European/Other, NA, European/Other, European/Other,
  Pacific, European/Other, European/Other,
  European/Other, Maori, Maori, European/Other,
  European/Other, Asian, Pacific)
 ### I don't want the categories in the default order
 ### I also want to be able to include or exclude NA
 ### argument exclude controls inclusion of NA
 table(EthnicCode)
 table(EthnicCode,exclude=NULL)
 ### Creating a factor allows reordering
 EthnicFactor - factor(EthnicCode, exclude=)
 levels(EthnicFactor) - list(Maori=Maori,Pacific=Pacific,
  Asian=Asian,
  Europ/Other=European/Other,
  is.na=NA)
   ^^^

Are you sure you want that last entry. You are basically creating a
level is.na, for those entries that have character NA (not same as
NA). When you use

table(EthnicFactor[,drop=TRUE])

you are dropping empty levels, not dropping NAs which is why your
self-inflicted is.na disappears, but not when you use exclude=NULL,
which I don't get either, as ?table has exclude = c(NA, NaN) not NULL.

Just do:

table(factor(EthnicCode))

but that loses the NAs in the factor created (see ?factor and argument
exclude). Compare:

dat - factor(EthnicCode)
dat
# preserves NAs as a level
dat2 - factor(EthnicCode, exclude = )
dat2

table(dat)
table(dat2) # NAs as a level  displayed
table(dat2, exclude = NA) # no NAs

Is that what you were looking for?

HTH

G

 ### I can tabulate with categories in the desired order
 table(EthnicFactor[,drop=TRUE])
 ### But I can't seem to include the missing observations
 table(EthnicFactor,exclude=NULL)
 
 David Scott

-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Gavin Simpson [t] +44 (0)20 7679 0522
 ECRC  ENSIS, UCL Geography,  [f] +44 (0)20 7679 0565
 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London  [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 convert all columns of a data frame into factors

2006-10-04 Thread Weiwei Shi
thanks, Andy and Jacques.
I forgot to convert the result from lapply to data.frame when I tried
lapply last time, :)
I should have done this
data.frame(lapply(x, factor))

On 10/4/06, Liaw, Andy [EMAIL PROTECTED] wrote:
 Alternatively:

 x[] - lapply(x, factor)

 Recall that a data frame is a list, so lapply() is a natural choice.

 Andy

 From: Gabor Grothendieck
 
  Try this:
 
  replace(BOD, TRUE, lapply(BOD, factor))
 
 
  On 10/4/06, Weiwei Shi [EMAIL PROTECTED] wrote:
   Hi,
  
   I use apply
   apply(x, 2, factor)
  
   but it does not work. please help. thanks.
  
   --
   Weiwei Shi, Ph.D
   Research Scientist
   GeneGO, Inc.
  
   Did you always know?
   No, I did not. But I believed...
   ---Matrix III
  
   __
   R-help@stat.math.ethz.ch mailing list
   https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 
 


 --
 Notice:  This e-mail message, together with any attachment...{{dropped}}

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


[R] R Graphics: Saving PDF and other formats from Windows Graphic Device for LaTeX

2006-10-04 Thread Anupam Tyagi
Hello, I can't seem to save (or find the default location) when I use the Window
Graphic Device's pull down menu. It does not seem to save to the directory I
have set using setwd(...). How do I make the pull down menu's work?

What is the best format to save R graphics for inclusion into a LaTeX documents?
I will use PdfTex, or LaTeX - PS - PsToPdf to generate the final PDF file.
Which is  likely to give the best graphics quality in the final PDF document?
The final graphs will be about 3x3 inch (fit in a column in two-column format).
I will be grateful if someone can share their experience.

Anupam.

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] extracting nested variances from lme4 model

2006-10-04 Thread Frank Samuelson
I have a model:
mod1-lmer( x ~  (1|rtr)+ trth/(1|cs) , data=dtf)  #

Here, cs and rtr are crossed random effects.
cs 1-5 are of type TRUE, cs 6-10 are of type FALSE,
so cs is nested in trth, which is fixed.
So for cs I should get a fit for 1-5 and 6-10.

This appears to be the case from the random effects:
  mean( ranef(mod1)$cs[[1]][1:5] )
[1] -2.498002e-16
  var( ranef(mod1)$cs[[1]][1:5] )
[1] 23.53083
  mean( ranef(mod1)$cs[[1]][6:10] )
[1] 2.706169e-16
  var( ranef(mod1)$cs[[1]][6:10] )
[1] 1.001065

However VarCorr(mod1) gives me only
a single variance estimate for the cases.
How do I get the other variance estimate?

Thanks for any help.

-Frank



My fake data set:
---
data:
$frame
  x rtr  trth cs
1   -4.4964808   1  TRUE  1
2   -0.6297254   1  TRUE  2
31.8062857   1  TRUE  3
42.7273275   1  TRUE  4
5   -0.6297254   1  TRUE  5
6   -1.3331767   1 FALSE  6
7   -0.3055796   1 FALSE  7
81.3331767   1 FALSE  8
90.1574314   1 FALSE  9
10  -0.1574314   1 FALSE 10
11  -3.0958803   2  TRUE  1
12  12.4601615   2  TRUE  2
13  -5.2363532   2  TRUE  3
14   1.5419810   2  TRUE  4
15   7.7071005   2  TRUE  5
16  -0.3854953   2 FALSE  6
17   0.7673098   2 FALSE  7
18   2.9485984   2 FALSE  8
19   0.3854953   2 FALSE  9
20  -0.3716558   2 FALSE 10
21  -6.4139940   3  TRUE  1
22  -3.8162344   3  TRUE  2
23 -11.0518554   3  TRUE  3
24   2.7462631   3  TRUE  4
25  16.2543990   3  TRUE  5
26  -1.7353668   3 FALSE  6
27   1.3521369   3 FALSE  7
28   1.3521369   3 FALSE  8
29   0.2054067   3 FALSE  9
30  -1.7446691   3 FALSE 10
31  -6.7468356   4  TRUE  1
32 -11.3228243   4  TRUE  2
33 -18.0088554   4  TRUE  3
34   4.6264891   4  TRUE  4
35   9.2973991   4  TRUE  5
36  -4.1122576   4 FALSE  6
37  -0.5091994   4 FALSE  7
38   1.2787085   4 FALSE  8
39  -1.6867089   4 FALSE  9
40  -0.5091994   4 FALSE 10

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


Re: [R] R Graphics: Saving PDF and other formats from Windows Graphic Device for LaTeX

2006-10-04 Thread Duncan Murdoch
On 10/4/2006 1:11 PM, Anupam Tyagi wrote:
 Hello, I can't seem to save (or find the default location) when I use the 
 Window
 Graphic Device's pull down menu. It does not seem to save to the directory I
 have set using setwd(...). How do I make the pull down menu's work?

If you want the best quality results, don't use the Save menu at all. 
Instead, write directly to a graphics device like pdf().
 
 What is the best format to save R graphics for inclusion into a LaTeX 
 documents?
 I will use PdfTex, or LaTeX - PS - PsToPdf to generate the final PDF file.
 Which is  likely to give the best graphics quality in the final PDF document?
 The final graphs will be about 3x3 inch (fit in a column in two-column 
 format).
 I will be grateful if someone can share their experience.

The postscript and pdf formats both give good results.  Depending on 
your Latex setup, sometimes only one or the other will be supported.

Duncan Murdoch

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


[R] A more efficient code using whole object approach?

2006-10-04 Thread Muzaffer Musal
Dear All, 
  I have the following code which works fine but takes 16+ hours to run and I 
was hoping someone could give me a hint as to how I could make it more 
efficient.
  Let me explain what the code is supposed to do. Each single row of the m.o.f 
matrix (n*p dim) has to go through the following operation Dm*m.o.f[i]^alpha1m 
where both Dm and alpha1m have n*1 dimensions.  Each row of the m.o.f is to be 
evaluated n times for the different values of alpha1m and Dm. My code changes 
the Dm and alpha1m (n*1) matrices into (n*p) matrices (not shown below, done 
only 1 time) and also change the (1*p) m.o.f row into a m.o (n*p) matrix (shown 
below, done n times). For each of the n rows of the m.o.f matrix we repeat this 
operation which we record in the temp matrix.  The third line of the loop 
multiplies for each row, the columns of the matrix and takes the resultant mean 
of the vector. 
  I know I should use the whole object approach somehow but after many tries I 
gaave up for the long approach. I know the explanation above is rather long and 
I apologize for that, any hint/help will be greatly appreciated.
 
  for (i in 1:numrows)
  {
  mo.o-t(array(m.o.f[i,],dim=c(numcols,numrows)))
  t-Dm*m.o^alpha1m
  l1[i]-mean(apply(t,1,prod))
  }
  Best Regards,


-


[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] concordance measures

2006-10-04 Thread lamack lamack
Dear all, I have a question about concordance measures.

I have n itens which are measured  by 4 subjects. The outcomes are discrete.

What is the appropriated test to verify the concordance between the 
subjects?


Best Regards.

_
Inscreva-se no novo Windows Live Mail beta e seja um dos primeiros a testar 
as novidades-grátis. Saiba mais:

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] discarding 'levels'

2006-10-04 Thread hoopz

Ok, so I am using read.table to read a .txt file and put it into a matrix. 
There are some values that are 'NA'.  If I use read.table with as.is =FALSE,
then some of the entries in the matrix return this:

 data[1,3]
[1]  0
Levels:  0  1  NA

and if I do 

 data[1,3]==0

it returns FALSE.  It's a zero, it's not false!


If I set as.is=TRUE, I don't get the levels problem, but in those entries
where I did get the levels problem, this happens:

 data[1,3]
[1]  0

This time, it keeps it as a string.  I can use as.numeric to fix it now, but
I'm just curious as to why this happens.


Thanks
-- 
View this message in context: 
http://www.nabble.com/discarding-%27levels%27-tf2384152.html#a6645474
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] R Graphics: Saving PDF and other formats from Windows GraphicDevice for LaTeX

2006-10-04 Thread Greg Snow
If you plan to include your graphics in LaTeX files then you should
really look at the Sweave function in the utils package.  This approach
may work better for you and make these questions not matter anymore. 


-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[EMAIL PROTECTED]
(801) 408-8111
 

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Anupam Tyagi
Sent: Wednesday, October 04, 2006 11:11 AM
To: r-help@stat.math.ethz.ch
Subject: [R] R Graphics: Saving PDF and other formats from Windows
GraphicDevice for LaTeX

Hello, I can't seem to save (or find the default location) when I use
the Window Graphic Device's pull down menu. It does not seem to save to
the directory I have set using setwd(...). How do I make the pull down
menu's work?

What is the best format to save R graphics for inclusion into a LaTeX
documents?
I will use PdfTex, or LaTeX - PS - PsToPdf to generate the final PDF
file.
Which is  likely to give the best graphics quality in the final PDF
document?
The final graphs will be about 3x3 inch (fit in a column in two-column
format).
I will be grateful if someone can share their experience.

Anupam.

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


Re: [R] ciclo for in matrix construction ( matlab - R )

2006-10-04 Thread Charles C. Berry

The help page for 'for' warns:

  Note that it is a common mistake to forget to put braces ('{ ..
  }') around your statements, e.g., after 'if(..)' or 'for()'.
  In particular, you should not have a newline between '}' and
  'else' to avoid a syntax error in entering a 'if ... else'
  construct at the keyboard or via 'source'. For that reason, one
  (somewhat extreme) attitude of defensive programming is to always
  use braces, e.g., for 'if' clauses.

Also this is illustrated in R FOR OCTAVE USERS

http://cran.r-project.org/doc/contrib/R-and-octave.txt

in the section starting:

MULTILINE FOR STATEMENTS:



On Wed, 4 Oct 2006, massimodisasha wrote:

 hi,
 i'm new to R
 i have a little script in matlab
 now i'm porting it to R but i've some problem.
 how can i write in R language this
 matlab/octave code:

 LX = L ;  L is a matrix
 ss = size(LX,1);
 E_N_2 = zeros(ss,2);

 for i = 1:ss
 E_2 = E_0 + LX(i,1)*C(3)+LX(i,2)*C(4);   E_0 , C(3), c(4)
 are costant
 N_2 = N_0 + LX(i,2)*C(3)-LX(i,1)*C(4);
 r=[ E_2,N_2];
 E_N_2(i,:)=r;
 end
 E_N_2

 i'm try so :

 library(matlab)
 LX - L
 ss - dim(LX)
 ss - ss[1]
 E_N_2 - zeros(ss,2)
 for(i in 1:ss)
 .
 .?

 thanks for any help :-)
 Massimo

 my mayor problem is to know how the cicle for works
   [[alternative HTML version deleted]]

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


Charles C. Berry(858) 534-2098
  Dept of Family/Preventive Medicine
E mailto:[EMAIL PROTECTED]   UC San Diego
http://biostat.ucsd.edu/~cberry/ La Jolla, San Diego 92093-0717

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


Re: [R] A more efficient code using whole object approach?

2006-10-04 Thread Greg Snow
A couple of thoughts (hopefully others will have even better
suggestions):

1. Could you do a some of the computations on the log scale?  This would
turn exponents into multiplications and multiplications into additions
and may turn a lot of the work into matrix multiplications.

2. It does not appear that the order matters (i=1, 2, ...), so this
could be easily parallelized, the nws package allows a fairly straight
forward way to do this if you have access to multiple computers (I for
one don't have a problem stealling cycles from my coworkers computers
when they are not doing computationally intesive things).

Hope this helps, 


-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[EMAIL PROTECTED]
(801) 408-8111
 

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Muzaffer Musal
Sent: Wednesday, October 04, 2006 11:36 AM
To: r-help@stat.math.ethz.ch
Subject: [R] A more efficient code using whole object approach?

Dear All,
  I have the following code which works fine but takes 16+ hours to run
and I was hoping someone could give me a hint as to how I could make it
more efficient.
  Let me explain what the code is supposed to do. Each single row of the
m.o.f matrix (n*p dim) has to go through the following operation
Dm*m.o.f[i]^alpha1m where both Dm and alpha1m have n*1 dimensions.  Each
row of the m.o.f is to be evaluated n times for the different values of
alpha1m and Dm. My code changes the Dm and alpha1m (n*1) matrices into
(n*p) matrices (not shown below, done only 1 time) and also change the
(1*p) m.o.f row into a m.o (n*p) matrix (shown below, done n times). For
each of the n rows of the m.o.f matrix we repeat this operation which we
record in the temp matrix.  The third line of the loop multiplies for
each row, the columns of the matrix and takes the resultant mean of the
vector. 
  I know I should use the whole object approach somehow but after many
tries I gaave up for the long approach. I know the explanation above is
rather long and I apologize for that, any hint/help will be greatly
appreciated.
 
  for (i in 1:numrows)
  {
  mo.o-t(array(m.o.f[i,],dim=c(numcols,numrows)))
  t-Dm*m.o^alpha1m
  l1[i]-mean(apply(t,1,prod))
  }
  Best Regards,


-


[[alternative HTML version deleted]]

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


Re: [R] Possible bug?

2006-10-04 Thread Ray Brownrigg
On Thursday 05 October 2006 00:14, ronggui wrote:
 Yes, the installer missed some file(s) in RHOME/bin.
 When I choose Message translations, the /bin directory contains the
 following files.

 -- snip --

I meant to mention that when I used the installer I didn't have to 
choose Message translations, it was ticked by default.

HTH,
Ray Brownrigg

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] Suitability of R for Algorithm simulations

2006-10-04 Thread Ethan B. Fini
Greetings,
 
 Sorry for the basic question, but I am trying to find out if R is a suitable 
platform for what I want to do...
 
 I am interested in creating simulations of distributed algorithms (i.e. team 
formation, Byzantine Generals , P2P  communication modeling, mobile networks) 
that would be represented in GUIs. I would like to be able to instantiate an 
object for each node in my simulated  (stand alone, one computer) distributed 
environment and then proceed by (a)  adding message exchange functionality and 
(b) algorithm  behavior to each node.
 
 The simulation results are represented on a GUI that looks like a grid with 
each node being a dot. As the algorithm progresses, different formations and 
messages are exchanged between the nodes.
 
 I am in a bit of a desperate situation as I am  trying to get away from MATLAB 
(too expensive,  no longer available to me)  and at the same time would like to 
avoid developing the infrastructure from scratch (i.e in Java) to run these 
simulations.
 
 Is R suitable for what I am trying to do? I looked around but have not been 
able to determine if R is the appropriate platform. 
 
 Your help, comments or suggestion of alternatives and pontification is welcome.
 
 Thank you,
 Ethan B. Finn
 
 


-

[[alternative HTML version deleted]]

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


Re: [R] complex plots using layout()

2006-10-04 Thread Paul Murrell
Hi


Lu, Jiang Jane wrote:
 Dear Dr. Murrell,
 
 Thank you very much for your suggestion. I have successfully produced
 the ideal plot following your advice. Please see the attached PDF file
 (layouttest.pdf) for results.
 
 However, I do not understand why the left and right outer margins are so
 big that it occupies almost half of the page. I did not specify any
 outer margins in my program, which I attached to this email at the end.
 Any comment is appreciated.


The blank space is there because the layout has 'respect=TRUE', which
means that a column width of 1 has the same physical size as a row
height of 1 (i.e., the scatterplots are square and, more importantly,
the two marginal histograms are the same height).  Overall, the layout
is square, but the page is rectangular, so the layout cannot use all of
the page.  Try removing the 'respect=TRUE' (I doubt you'll like the
result).  You could try partial respect, for example ...

layout(matrix(c(2,0,0,1,3,7,5,0,0,4,6,8), nrow=4, ncol=3,
  byrow=TRUE),
   widths=c(3,1,3), heights=c(1,3,1,3),
   respect=matrix(c(0,1,0,0,0,0,0,1,0,0,0,0), nrow=4, ncol=3,
  byrow=TRUE))

... (again, untested) just to enforce the histogram heights, but it can
take a bit of experimenting to understand what is going on with partial
respect.

BTW, I think your par(mar)'s are not quite right (the marginal
histograms stick out beyond the edges of the scatterplot).  I think
something like ...

par(mar=c(5,5,1,1))
plot(x, y1, xlim=xrange, ylim=y1range, xlab=predtname[1], ylab=MJI)
lines(lowess(x[is.na(x)==FALSE],y1[is.na(x)==FALSE]),col=2,lwd=3)
par(mar=c(0,5,5,1))
barplot(xhist$counts, axes=FALSE, ylim=c(0, top1),
space=0,main=paste(Correlation Coeffcient = ,y1corr))
par(mar=c(5,0,1,1))
barplot(y1hist$counts, axes=FALSE, xlim=c(0, top1), space=0, horiz=TRUE)

... would be better.

Paul


 =
 y1 - demograc$MYOJEOP
 y2 - log(demograc$ntotles)
 x  - demograc$agebl
 xc - demograc$AGECAT
 
 predtname - c(Age,Categorical Age)
 prdtlevel - list(ctnage=0,
 ftage=c(50,50-59,60-69,=70))
 
 postscript(file=C:/Lu/MyR/Trials/Layout/testlayout.eps,horizontal=TRUE
 )
 
 xhist - hist(x,  plot=FALSE)
 y1hist - hist(y1,  plot=FALSE)
 y2hist - hist(y2,  plot=FALSE)
 
 top1 - max(c(xhist$counts, y1hist$counts))
 top2 - max(c(xhist$counts, y2hist$counts))
 
 xrange - range(x,na.rm=TRUE)
 y1range - range(y1,na.rm=TRUE)
 y2range - range(y2,na.rm=TRUE)
 
 y1corr - round(cor(x,y1,use=complete.obs),2)
 y2corr - round(cor(x,y2,use=complete.obs),2)
 
 def.par - par(no.readonly = TRUE) # save default, for resetting...
 
 nf - layout(matrix(c(2,0,0,1,3,7,5,0,0,4,6,8),nrow=4,ncol=3,
 byrow=TRUE),widths=c(3,1,3),heights=c(1,3,1,3),respect=TRUE)
 
 
 par(mar=c(5,5,1,1))
 plot(x, y1, xlim=xrange, ylim=y1range, xlab=predtname[1], ylab=MJI)
 lines(lowess(x[is.na(x)==FALSE],y1[is.na(x)==FALSE]),col=2,lwd=3)
 par(mar=c(0,3,5,1))
 barplot(xhist$counts, axes=FALSE, ylim=c(0, top1),
 space=0,main=paste(Correlation Coeffcient = ,y1corr))
 par(mar=c(3,0,1,1))
 barplot(y1hist$counts, axes=FALSE, xlim=c(0, top1), space=0, horiz=TRUE)
 
 par(mar=c(5,5,1,1))
 plot(x, y2, xlim=xrange, ylim=y2range, xlab=predtname[1],
 ylab=log(Numer of Lesions))
 lines(lowess(x[is.na(x)==FALSE],y2[is.na(x)==FALSE]),col=2,lwd=3)
 par(mar=c(0,3,5,1))
 barplot(xhist$counts, axes=FALSE, ylim=c(0, top2),
 space=0,main=paste(Correlation Coeffcient = ,y2corr))
 par(mar=c(3,0,1,1))
 barplot(y2hist$counts, axes=FALSE, xlim=c(0, top2), space=0, horiz=TRUE)
 
 y1pvalue - round(anova(lm(y1~factor(xc)))[1,5],3)
 y2pvalue - round(anova(lm(y2~factor(xc)))[1,5],3)
 
 par(mar=c(4,5,2,2))
 boxplot(y1~xc,varwidth=TRUE,main=paste(p-value of t test or ANOVA =
 ,y1pvalue),
   
 names=prdtlevel[[2]],ylab='MJI',xlab=predtname[2],na.action=na.omit)
 
 boxplot(y2~xc,varwidth=TRUE,main=paste(p-value of t test or ANOVA =
 ,y2pvalue),
   names=prdtlevel[[2]],ylab='log(Number of
 Lesions)',xlab=predtname[2],na.action=na.omit)
 
 par(def.par)
 
 dev.off()
 
 
 
 Jiang Lu
 
 BARI 2D Coordinating Center
 University of Pittsburgh
 130 DeSoto Street, 127 Parran Hall
 Pittsburgh, PA 15261
 Tel: (412)624-5219
 
 -Original Message-
 From: Paul Murrell [mailto:[EMAIL PROTECTED] 
 Sent: Tuesday, October 03, 2006 8:50 PM
 To: Lu, Jiang Jane
 Cc: r-help@stat.math.ethz.ch
 Subject: Re: [R] complex plots using layout()
 
 Hi
 
 
 Lu, Jiang Jane wrote:
 Dear r-help,

 I am trying to plot several scatter plots with marginal histograms on
 one page. Ideally, a page is equally divided into 4 figure regions.
 Within each figure region, a scatter plot with marginal histograms
 will
 be plotted.

 I followed Dr. Paul Murrell's code released online to successfully
 plot
 the scatter plot with marginal histograms. The code applies layout()
 to partition the page.

 Right now, 

[R] convert vector to matrix

2006-10-04 Thread nalluri pratap
Hi All,
   
   
  I have vector containing 10 elements(odservations). I need to put this into a 
matrix, where the matrix should contain only one column.
I need this to be done using the cbind command because in the final table I 
should have a column of attributes( from adifferent vector) and a column of 
vectors from the matrix above

  Please suggest me how this can be done
   
  Thanks and Regards,
  Pratap



-


[[alternative HTML version deleted]]

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


Re: [R] convert vector to matrix

2006-10-04 Thread Gavin Simpson
On Wed, 2006-10-04 at 21:50 +0100, nalluri pratap wrote:
 Hi All,


   I have vector containing 10 elements(odservations). I need to put
 this into a matrix, where the matrix should contain only one column.
 I need this to be done using the cbind command because in the final
 table I should have a column of attributes( from adifferent vector)
 and a column of vectors from the matrix above
 
   Please suggest me how this can be done

   Thanks and Regards,
   Pratap

Did you even try to use cbind on your vector? I guess not as,

 vec - 1:10
 mat - cbind(vec)
 mat
  vec
 [1,]   1
 [2,]   2
 [3,]   3
 [4,]   4
 [5,]   5
 [6,]   6
 [7,]   7
 [8,]   8
 [9,]   9
[10,]  10
 class(mat)
[1] matrix

clearly shows it is possible.

G

-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 *Note new Address and Fax and Telephone numbers from 10th April 2006*
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
Gavin Simpson [t] +44 (0)20 7679 0522
ECRC  [f] +44 (0)20 7679 0565
UCL Department of Geography
Pearson Building  [e] gavin.simpsonATNOSPAMucl.ac.uk
Gower Street
London, UK[w] http://www.ucl.ac.uk/~ucfagls/cv/
WC1E 6BT  [w] http://www.ucl.ac.uk/~ucfagls/
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] Spearman correlation test confidence intervals

2006-10-04 Thread Mahesh Krishnan


Hello,

How does one calculate the confidence levels for a spearman correlation
test?  I noticed cor.test(x,y) gives the confidence levels only for
pearson test.

Thank you for the suggestions, in advance.

Best Regards,

Mahesh Krishnan

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


Re: [R] convert vector to matrix

2006-10-04 Thread Alberto Monteiro
Gavin Simpson wrote:
 
 Did you even try to use cbind on your vector? I guess not as,
 
  vec - 1:10
  mat - cbind(vec)
  mat

Why does mat remain a matrix instead of losing one dimension?
I am reading the FAQ at...
http://cran.us.r-project.org/doc/FAQ/R-FAQ.html#Why-do-my-matrices-lose-
dimensions_003f
... and it seems that anything you do to mat should turn it back
into a one-dimensional vector.

Alberto Monteiro

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] RODBC: longest string is truncated

2006-10-04 Thread Jerome Asselin
Hello R community:

I'm encountering unexpected behaviour as I download string data from
MySQL using the RODBC package. The unexpected behaviour is that the last
character of the string is truncated. As far as I can see, this happens
when some strings are of length 501 or more.

Here's how to reproduce this behaviour.

## In MySQL, pick a database and run this:
CREATE TABLE test (
  v1 text NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
INSERT INTO test
set v1=concat(repeat('a',499),'1'); # length 500
INSERT INTO test
set v1=concat(repeat('a',499),'12'); # length 501
INSERT INTO test
set v1=concat(repeat('a',499),'123'); # length 502

## In R, first setup a channel to connect to your MySQL database.
# library(RODBC)
# channel - odbcConnect(mydb)
## Now run this:
sqlQuery(channel, select * from test, as.is=T)$v1

You'll see the entire strings, except for the last character of the 3rd
record, which is 3. Strange enough, if I remove the last record from
the MySQL table and reload the data in R, I see that the 2 of the 2nd
record is truncated. Looks like only the string with greatest length is
truncated.

Can you reproduce this behaviour? Is this a bug? Can someone please
explain why the last character is truncated?

Many thanks for your help.
Jerome

OS: RHEL 4 AS
R version 2.3.1
RODBC version 1.1-7

-- 
Jerome Asselin, M.Sc., Agent de recherche, RHCE
CHUM -- Centre de recherche
3875 rue St-Urbain, 3e etage // Montreal QC  H2W 1V1
Tel.: 514-890-8000 Poste 15914; Fax: 514-412-7106

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


Re: [R] convert vector to matrix

2006-10-04 Thread David Barron
cbind always produces a matrix or data frame.  What the FAQ says is
that a subsetting operation *on* a matrix will result in redundant
dimensions being
dropped, not that you can't get a matrix with a redundant dimension
as a result of a function.

So,
 vec-1:10
 vec
 [1]  1  2  3  4  5  6  7  8  9 10
 cbind(vec)
  vec
 [1,]   1
 [2,]   2
 [3,]   3
 [4,]   4
 [5,]   5
 [6,]   6
 [7,]   7
 [8,]   8
 [9,]   9
[10,]  10
 mat-cbind(vec)
 dim(mat)
[1] 10  1
 mat[,1]
 [1]  1  2  3  4  5  6  7  8  9 10

takes us back to a vector again.

On 04/10/06, Alberto Monteiro [EMAIL PROTECTED] wrote:
 Gavin Simpson wrote:
 
  Did you even try to use cbind on your vector? I guess not as,
 
   vec - 1:10
   mat - cbind(vec)
   mat
 
 Why does mat remain a matrix instead of losing one dimension?
 I am reading the FAQ at...
 http://cran.us.r-project.org/doc/FAQ/R-FAQ.html#Why-do-my-matrices-lose-
 dimensions_003f
 ... and it seems that anything you do to mat should turn it back
 into a one-dimensional vector.

 Alberto Monteiro

 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/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 Barron
Said Business School
University of Oxford
Park End Street
Oxford OX1 1HP

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


Re: [R] discarding 'levels'

2006-10-04 Thread Mike Nielsen
From TFM of read.table:

 as.is: the default behavior of 'read.table' is to convert character
  variables (which are not converted to logical, numeric or
  complex) to factors.  The variable 'as.is' controls the
  conversion of columns not otherwise specified by
  'colClasses'. Its value is either a vector of logicals
  (values are recycled if necessary), or a vector of numeric or
  character indices which specify which columns should not be
  converted to factors.

You may have some blanks in the third column.

Factor levels whose character representation happens to be a numeral
don't necessarily compare equal to the integer with the same character
representation (if you get my drift...).

You can use as.numeric, but better would be to use colClasses in read.table.

Regards,

Mike

On 10/4/06, hoopz [EMAIL PROTECTED] wrote:

 Ok, so I am using read.table to read a .txt file and put it into a matrix.
 There are some values that are 'NA'.  If I use read.table with as.is =FALSE,
 then some of the entries in the matrix return this:

  data[1,3]
 [1]  0
 Levels:  0  1  NA

 and if I do

  data[1,3]==0

 it returns FALSE.  It's a zero, it's not false!


 If I set as.is=TRUE, I don't get the levels problem, but in those entries
 where I did get the levels problem, this happens:

  data[1,3]
 [1]  0

 This time, it keeps it as a string.  I can use as.numeric to fix it now, but
 I'm just curious as to why this happens.


 Thanks
 --
 View this message in context: 
 http://www.nabble.com/discarding-%27levels%27-tf2384152.html#a6645474
 Sent from the R help mailing list archive at Nabble.com.

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




-- 
Regards,

Mike Nielsen

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] compiling rgdal package on windows / macos

2006-10-04 Thread Dylan Beaudette
Greetings:

As I am not a windows user, I cannot try this: is it possible to install rgdal 
on windows without having to compile it from source ?   

Compilation on MacOS is within my abilities, however each time i try and 
install the rgdal package it dies complaining that it cannot find 
gdal-config --- which was recently installed with GRASS. I have updated my 
PATH environment variable, logged out, but R still cannot find the 
gdal-config program.

any tips on getting the rgdal package up and running on MacOS or Windows would 
be greatly appreciated.

Cheers,


-- 
Dylan Beaudette
Soils and Biogeochemistry Graduate Group
University of California at Davis
530.754.7341

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


Re: [R] R-2.4.0 is released

2006-10-04 Thread Robert King
On Tue, 3 Oct 2006 20:30, Peter Dalgaard wrote:
 o   load()ing an object saved in one of the formats used prior to
 R 1.4.0 is deprecated.  Such objects should be re-saved in the
 current format.

Is there some property of old .RData files that I could use with find on 
linux to detect and update them?  I suppose I could use the last modified 
date, but it would be nice to detect the format?

Robert.
-- 
Robert King, Statistics, School of Mathematical  Physical Sciences,
University of Newcastle, Australia
Room V133  ph +61 2 4921 5548
[EMAIL PROTECTED]   http://tolstoy.newcastle.edu.au/~rking/

Verbogeny is one of the pleasurettes of a creatific thinkerizer.
   - Peter da Silva [EMAIL PROTECTED] in alt.sysadmin.recovery

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


Re: [R] Spearman correlation test confidence intervals

2006-10-04 Thread Peter Dalgaard
Mahesh Krishnan [EMAIL PROTECTED] writes:

 Hello,
 
 How does one calculate the confidence levels for a spearman correlation
 test?  I noticed cor.test(x,y) gives the confidence levels only for
 pearson test.
 
 Thank you for the suggestions, in advance.

You can't. Not easily anyway. The distribution of the Spearman
correlation is known under the null hypothesis of independence
(through symmetry considerations), but not otherwise. In largish
samples, I suppose that resampling techniques could be employed.

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

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


Re: [R] convert vector to matrix

2006-10-04 Thread Gavin Simpson
On Wed, 2006-10-04 at 19:55 -0200, Alberto Monteiro wrote:
 Gavin Simpson wrote:
  
  Did you even try to use cbind on your vector? I guess not as,
  
   vec - 1:10
   mat - cbind(vec)
   mat
 
 Why does mat remain a matrix instead of losing one dimension?
 I am reading the FAQ at...
 http://cran.us.r-project.org/doc/FAQ/R-FAQ.html#Why-do-my-matrices-lose-
 dimensions_003f
 ... and it seems that anything you do to mat should turn it back
 into a one-dimensional vector.

Dear Alberto,

That FAQ is referring to subsetting a matrix, and as yet, the code above
has not subsetted mat at all - indeed, we have only created it and then
examined it's class, if we were to now look at rows 2:5, then we'd see
that mat loses a dimension and reverts to a vector:

 vec - 1:10
 mat - cbind(vec)
 mat
  vec
 [1,]   1
 [2,]   2
 [3,]   3
 [4,]   4
 [5,]   5
 [6,]   6
 [7,]   7
 [8,]   8
 [9,]   9
[10,]  10
 mat[2:5,]
[1] 2 3 4 5
 vec[2:5]
[1] 2 3 4 5
 class(mat[2:5,])
[1] integer
 class(vec[2:5])
[1] integer
 all.equal(mat[2:5,], vec[2:5])
[1] TRUE

To preserve dimensions, we use drop = FALSE, as discussed in the FAQ you
quote: 

 mat[2:5, , drop = FALSE]
 vec
[1,]   2
[2,]   3
[3,]   4
[4,]   5
 class(mat[2:5, , drop = FALSE])
[1] matrix

HTH

G
-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 *Note new Address and Fax and Telephone numbers from 10th April 2006*
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
Gavin Simpson [t] +44 (0)20 7679 0522
ECRC  [f] +44 (0)20 7679 0565
UCL Department of Geography
Pearson Building  [e] gavin.simpsonATNOSPAMucl.ac.uk
Gower Street
London, UK[w] http://www.ucl.ac.uk/~ucfagls/cv/
WC1E 6BT  [w] http://www.ucl.ac.uk/~ucfagls/
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

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


Re: [R] compiling rgdal package on windows / macos

2006-10-04 Thread apjaworski
I just tried the PackagesInstall package(s)..  menu item on my fresh
R-2.4.0-patched and rgdal just shows up on the list of packages to install,
so I am not sure what the problem is.  Alternatively, you can download the
Windows *.zip file from any CRAN repository and install it from your hard
drive.

Hope this helps,

Andy

__
Andy Jaworski
518-1-01
Process Laboratory
3M Corporate Research Laboratory
-
E-mail: [EMAIL PROTECTED]
Tel:  (651) 733-6092
Fax:  (651) 736-3122


   
 Dylan Beaudette   
 dylan.beaudette@ 
 gmail.com To 
 Sent by:  r-help@stat.math.ethz.ch
 [EMAIL PROTECTED]  cc 
 at.math.ethz.ch   
   Subject 
   [R] compiling rgdal package on  
 10/04/2006 05:46  windows / macos 
 PM
   
   
 Please respond to 
 [EMAIL PROTECTED] 
 mail.com  
   
   




Greetings:

As I am not a windows user, I cannot try this: is it possible to install
rgdal
on windows without having to compile it from source ?

Compilation on MacOS is within my abilities, however each time i try and
install the rgdal package it dies complaining that it cannot find
gdal-config --- which was recently installed with GRASS. I have updated my
PATH environment variable, logged out, but R still cannot find the
gdal-config program.

any tips on getting the rgdal package up and running on MacOS or Windows
would
be greatly appreciated.

Cheers,


--
Dylan Beaudette
Soils and Biogeochemistry Graduate Group
University of California at Davis
530.754.7341

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


Re: [R] treatment effect at specific time point within mixed effects model

2006-10-04 Thread Spencer Graves
  Consider the following modification of your example: 

fm1a = lme(z ~ (factor(Time)-1)*drug, data = data.grp,
random = list(Patient = ~ 1) )

summary(fm1a)
snip
 Value Std.Error DFt-value p-value
factor(Time)1   -0.6238472 0.7170161 10 -0.8700602  0.4047
factor(Time)2   -1.0155283 0.7170161 10 -1.4163256  0.1871
factor(Time)30.1446512 0.7170161 10  0.2017405  0.8442
factor(Time)40.7751736 0.7170161 10  1.0811105  0.3050
factor(Time)50.1566588 0.7170161 10  0.2184871  0.8314
factor(Time)60.0616839 0.7170161 10  0.0860286  0.9331
drugP1.2781723 1.0140139  3  1.2605077  0.2966
factor(Time)2:drugP  0.4034690 1.4340322 10  0.2813528  0.7842
factor(Time)3:drugP -0.6754441 1.4340322 10 -0.4710104  0.6477
factor(Time)4:drugP -1.8149720 1.4340322 10 -1.2656424  0.2343
factor(Time)5:drugP -0.6416580 1.4340322 10 -0.4474502  0.6641
factor(Time)6:drugP -2.1396105 1.4340322 10 -1.4920240  0.1666

  Does this answer your question? 
  Hope this helps. 
  Spencer Graves

Afshartous, David wrote:
  
 All,

 The code below is for a pseudo dataset of repeated measures on patients
 where there is also a treatment factor called drug.  Time is treated
 as categorical.  

 What code is necessary to test for a treatment effect at a single time
 point,
 e.g., time = 3?   Does the answer matter if the design is a crossover
 design,
 i.e, each patient received drug and placebo?

 Finally, what would be a good response to someone that suggests to do a
 simple t-test (paired in crossover case) instead of the test above
 within a mixed model?

 thanks!
 dave



 z = rnorm(24, mean=0, sd=1)
 time = rep(1:6, 4)
 Patient = rep(1:4, each = 6)
 drug = factor(rep(c(I, P), each = 6, times = 2)) ## P = placebo, I =
 Ibuprofen
 dat.new = data.frame(time, drug, z, Patient)
 data.grp = groupedData(z ~ time | Patient, data = dat.new)
 fm1 = lme(z ~ factor(time) + drug + factor(time):drug, data = data.grp,
 random = list(Patient = ~ 1) )

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


Re: [R] Suitability of R for Algorithm simulations

2006-10-04 Thread François Pinard
[Ethan B. Fini]

 I would like to be able to instantiate an object for each node in my 
 simulated  (stand alone, one computer) distributed environment and 
 then proceed by (a)  adding message exchange functionality and (b) 
 algorithm  behavior to each node.

Not so long ago, I quickly glanced at Eiffel after an enthusiastic 
friend told me about it, and while I do not think I will soon use it for 
myself, Eiffel might be the right choice for you, being strong on 
light-weight processes and message passing, from what I've read...

If I had a simulation problem to tackle nowadays, I'd likely consider 
Python supplemented with greelets from the pylib library, mainly because 
I'm fond on Python legibility, and have a reasonably good confidence in 
people having implemented greenlets.

 The simulation results are represented on a GUI [...]

The GUI aspects of Eiffel are unknown to me, I did not dive deep enough 
to touch them.  For Python, I'd use pygtk, but there are many toolkits 
to choose from.

 Is R suitable for what I am trying to do? I looked around but have not 
 been able to determine if R is the appropriate platform. 

R libraries are especially good at statistics and graphics.  The 
language in itself is much oriented towards vectorisation, among other 
things, and this might be convenient for a speedy implementation of some 
simulation problems.  If vectorisation could not be turned into an 
advantage for you with R, it is likely that R might be slow for such 
problems, and also not so well adapted to quasi-parallelism between 
interacting processes having each their own behaviour.

Of course, seasoned R users might have much more sound opinions than 
mine on this topic! :-)

-- 
François Pinard   http://pinard.progiciels-bpi.ca

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


[R] help with script

2006-10-04 Thread JOHN VOIKLIS
Hello,

I wrote the function, below, in the hope of _quickly_ generating a
sliding-window time series of the mean, sd, median, and mad values
from a matrix of data. The script below is anything but quick; it has
been working away on a 2500 x 2500 matrix with a sliding window of 100
x 100 for five days, with no end in sight. Obviously, I am not the
best of programmers. Can anyone offer suggestions as to how I might
optimize this script.

Thank you,

John

common.ground-function(inMatrix,window){

cleanMatrix-as.matrix(inMatrix)
diag(cleanMatrix)-NA
outMatrix-matrix(0,dim(inMatrix)[1]-window,4)
colnames(outMatrix)-c(mean,SD, median,mad)

for(i in 1:dim(outMatrix)[1]){
for(j in window:dim(cleanMatrix)[2]){

outMatrix[i,1]-mean(cleanMatrix[c(i:j),c(i:j)],na.rm=TRUE)

outMatrix[i,2]-sd(c(cleanMatrix[c(i:j),c(i:j)]),na.rm=TRUE)

outMatrix[i,3]-median(cleanMatrix[c(i:j),c(i:j)],na.rm=TRUE)

outMatrix[i,4]-mad(cleanMatrix[c(i:j),c(i:j)],na.rm=TRUE)
}
}
return(outMatrix)
}

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


Re: [R] help with script

2006-10-04 Thread Gabor Grothendieck
See:

http://tolstoy.newcastle.edu.au/R/help/04/10/5161.html

On 10/4/06, JOHN VOIKLIS [EMAIL PROTECTED] wrote:
 Hello,

 I wrote the function, below, in the hope of _quickly_ generating a
 sliding-window time series of the mean, sd, median, and mad values
 from a matrix of data. The script below is anything but quick; it has
 been working away on a 2500 x 2500 matrix with a sliding window of 100
 x 100 for five days, with no end in sight. Obviously, I am not the
 best of programmers. Can anyone offer suggestions as to how I might
 optimize this script.

 Thank you,

 John

 common.ground-function(inMatrix,window){

cleanMatrix-as.matrix(inMatrix)
diag(cleanMatrix)-NA
outMatrix-matrix(0,dim(inMatrix)[1]-window,4)
colnames(outMatrix)-c(mean,SD, median,mad)

for(i in 1:dim(outMatrix)[1]){
for(j in window:dim(cleanMatrix)[2]){

 outMatrix[i,1]-mean(cleanMatrix[c(i:j),c(i:j)],na.rm=TRUE)

 outMatrix[i,2]-sd(c(cleanMatrix[c(i:j),c(i:j)]),na.rm=TRUE)

 outMatrix[i,3]-median(cleanMatrix[c(i:j),c(i:j)],na.rm=TRUE)

 outMatrix[i,4]-mad(cleanMatrix[c(i:j),c(i:j)],na.rm=TRUE)
}
}
return(outMatrix)
 }

 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] Bug in 2.4.0 Windows menu setup

2006-10-04 Thread Duncan Murdoch
I've tracked down where this is occurring, but I don't know how to fix 
it.  Here's a summary:

If the language in Windows is set to simplified Chinese (i.e. Chinese 
(PRC)) and message translations are installed, then on startup Rgui 
crashes when it tries to install the console popup menu.  The crash 
comes when it gets an error trying to do a conversion using mbrtowc, and 
tries to report it using error(); but the R symbol table is needed for 
that, and it hasn't been set up yet.

I'm not sure which menu entry causes the crash, but I think it's not the 
first, so conceivably this is caused by an error in one of the 
translation files.  Indeed, setting the language to Chinese (Taiwan) works.

I don't know how to debug the translation files, so I'm going to have to 
leave this one for now.  I think Brian Ripley is the only one who 
understands all the details of what goes on in the translations, and 
he's away until Oct 9.

Duncan Murdoch

On 10/3/2006 9:00 PM, ronggui wrote:
 This morning I downloaded R-2.4.0 and install in under Windows. I customized
 the installation and choose Message translations,but I could not launch
 Rgui.exe successfully( Rterm.exe worked fine). If I did't choose Message
 translations, Rgui.exe worked fine.
 
 Message translations is Simplified Chinese.
 
 version
_
 platform   i386-pc-mingw32
 arch   i386
 os mingw32
 system i386, mingw32
 status
 major  2
 minor  4.0
 year   2006
 month  10
 day03
 svn rev39566
 language   R
 version.string R version 2.4.0 (2006-10-03)
 
 
 
 
 
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] help with script

2006-10-04 Thread Gabor Grothendieck
Also see package caTools.

On 10/4/06, Gabor Grothendieck [EMAIL PROTECTED] wrote:
 See:

 http://tolstoy.newcastle.edu.au/R/help/04/10/5161.html

 On 10/4/06, JOHN VOIKLIS [EMAIL PROTECTED] wrote:
  Hello,
 
  I wrote the function, below, in the hope of _quickly_ generating a
  sliding-window time series of the mean, sd, median, and mad values
  from a matrix of data. The script below is anything but quick; it has
  been working away on a 2500 x 2500 matrix with a sliding window of 100
  x 100 for five days, with no end in sight. Obviously, I am not the
  best of programmers. Can anyone offer suggestions as to how I might
  optimize this script.
 
  Thank you,
 
  John
 
  common.ground-function(inMatrix,window){
 
 cleanMatrix-as.matrix(inMatrix)
 diag(cleanMatrix)-NA
 outMatrix-matrix(0,dim(inMatrix)[1]-window,4)
 colnames(outMatrix)-c(mean,SD, median,mad)
 
 for(i in 1:dim(outMatrix)[1]){
 for(j in window:dim(cleanMatrix)[2]){
 
  outMatrix[i,1]-mean(cleanMatrix[c(i:j),c(i:j)],na.rm=TRUE)
 
  outMatrix[i,2]-sd(c(cleanMatrix[c(i:j),c(i:j)]),na.rm=TRUE)
 
  outMatrix[i,3]-median(cleanMatrix[c(i:j),c(i:j)],na.rm=TRUE)
 
  outMatrix[i,4]-mad(cleanMatrix[c(i:j),c(i:j)],na.rm=TRUE)
 }
 }
 return(outMatrix)
  }
 
  __
  R-help@stat.math.ethz.ch mailing list
  https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] littler release 0.0.6

2006-10-04 Thread Dirk Eddelbuettel

What ?
--

   We are pleased to announce version 0.0.6 of littler 


What's new ?


   This version includes a bug fix or two as well as a number of small
   enhancements to the documentation.

   For OS X and the r/R confusion, our recommended suggestion is to call
   configure using either the --program-suffix=X  or  --program-prefix=Y
   option to have the binary and manual page renamed when 'make install'
   runs. In this example, r would be renamed to rX and Yr, resptively.
   Suitable choices of X and Y are left to the user.
   

Where ?
---

   You can find the source tarball at both

http://dirk.eddelbuettel.com/code/littler/

   and 

http://biostat.mc.vanderbilt.edu/LittleR



Comments are welcome, as are are suggestions, bug fixes, or patches.

- Jeffrey Horner [EMAIL PROTECTED]
- Dirk Eddelbuettel [EMAIL PROTECTED] 


-- 
Hell, there are no rules here - we're trying to accomplish something. 
  -- Thomas A. Edison

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


Re: [R] ciclo for in matrix construction ( matlab - R )

2006-10-04 Thread Jeff Newmiller
massimodisasha wrote:
 hi,
 i'm new to R
 i have a little script in matlab
 now i'm porting it to R but i've some problem.
 how can i write in R language this
 matlab/octave code:
 
 LX = L ;  L is a matrix
 ss = size(LX,1);
 E_N_2 = zeros(ss,2);
 
 for i = 1:ss
 E_2 = E_0 + LX(i,1)*C(3)+LX(i,2)*C(4);   E_0 , C(3), c(4)   
 are costant
 N_2 = N_0 + LX(i,2)*C(3)-LX(i,1)*C(4);
 r=[ E_2,N_2];
 E_N_2(i,:)=r;
 end
 E_N_2
 
 i'm try so :
 
 library(matlab)
 LX - L
 ss - dim(LX)
 ss - ss[1]
 E_N_2 - zeros(ss,2)
 for(i in 1:ss)
 .
 .?
 
 thanks for any help :-)
 Massimo
 
 my mayor problem is to know how the cicle for works

Perhaps a more important problem is learning how to
use matrix algebra.  Loops are notoriously slow in R,
and worth avoiding in octave as well.

E_0 - 12
N_0 - 13
C3 - 21
C4 - 22
L - matrix(c(1,2,3,4,5,6,7,8,9),ncol=3)

ss - dim(L)[1]
LX - L[1:ss,1:2]
C - matrix(c(C3,C4,-C4,C3),ncol=2)
EN - matrix(rep(c(E_0,N_0),ss),ncol=2,byrow=TRUE)
E_N_2 - EN + LX %*% C
E_N_2


-- 
---
Jeff NewmillerThe .   .  Go Live...
DCN:[EMAIL PROTECTED]Basics: ##.#.   ##.#.  Live Go...
   Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k

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


Re: [R] R Graphics: Saving PDF and other formats from Win dows Graphic Device for LaTeX

2006-10-04 Thread Anupam Tyagi
Thanks. That worked. I am using the following to set-up the device:

pdf(sgr6100.pdf, horizontal=FALSE, onefile=FALSE, 
height=3, width=3, pointsize=6)

Reducing point-size below 6 does not seem to make any difference to 
the size of text and symbols. Any suggestions to get smaller font sizes?

I am using WinEdt with MikTeX set-up. 

Any suggestions about something, or some packages, 
that might improve graphics inclusion. 

Latex complains about the [scale...] part for any scale in 

\includegraphics[scale=1]{} 

and pauses. Suggestions will be appreciated about what is the best way to scale
R graphics for inclusion in LaTeX.

Anupam.

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] searching for data.frame rows / processing of rows

2006-10-04 Thread Greg Tarpinian
R 2.3.1, WinXP:

I have a puzzling problem that I suspect may be solved using
grep or a regular expression but am at a loss how to actually do it...
My data.frame looks like

  Location   TimeXY
        ---  ---
  1  0  1.6  9.3
  1  3  4.2  10.4
  1  6  2.7  16.3
  2  0  0.5  2.1
  2  3  NA   3.6
  2  3  5.0  0.06
  2  6  3.4  14.0

and so forth.  I would like to search for duplicate Time values
within a Location and take the numerical average (where possible)
of the elements in X and Y.  These numerical averages should
then be used to create a single row where multiple rows once 
existed.  So, I would like to obtain

  2  3  5.0  1.83

for the two Time = 3 rows for Location = 2 and use it to replace
these two rows.  Ideally, avoiding for(i in 1:blah) loops would be
nice because the data.frame has about 10,000 rows that need to
be searched and processed.  My intent is to do some comparing of
SAS to R -- the DATA step processing in SAS is quite fast and 
using the RETAIN statement along with the LAG( ) function allows
this sort of thing to be done rapidly.


Thanks in advance,

   Greg

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