Re: [R] Help with rgl

2009-02-18 Thread Wacek Kusnierczyk
roger koenker wrote:
 Why I love R  [Number  6]:

 Chinese  extend a helping hand to Russians who happen to be in Brazil
 about a package written in Germany.   Trotsky would be proud  -- and
 amazed!


... and it's so . r specific!

vQ

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Added system Info:--Segmentation Fault occured while connecting to the database

2009-02-18 Thread Prof Brian Ripley
Your R is ancient, and the R posting guide asked you to update before 
posting.


This is a problem in a contributed DBMS package, so the posting guide 
asked you to contact the maintainer and the R-sig-db list would be 
the appropriate list to use.  But please ensure you are using a 
current version of R and the latest version of all the packages (which 
you seem not even to have mentioned, RMySQL and DBI).  Even then, 
without your system and your copy of MySQL this may well not be 
reproducible so you may have to debug (using gdb) yourself.


On Wed, 18 Feb 2009, Moumita Das wrote:


Hi All,
Wanted to add some more information ,regarding my problem.
configuration of teh OS and R:---
Linux 2.6.18-6-686

R.Version()

$platform
[1] i486-pc-linux-gnu

$arch
[1] i486

$os
[1] linux-gnu

$system
[1] i486, linux-gnu

$status
[1] Patched

$major
[1] 2

$minor
[1] 4.0

$year
[1] 2006

$month
[1] 11

$day
[1] 25

$`svn rev`
[1] 39997

$language
[1] R

$version.string
[1] R version 2.4.0 Patched (2006-11-25 r39997)



--
Thanks
Moumita

[[alternative HTML version deleted]]

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



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

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


[R] Remove top-K elements in Vector

2009-02-18 Thread Gundala Viswanath
Hi all,

Suppose I hve this vector:

 x
 [1]  3  4  7 17 22 12 15 12  3  3  1  1

How can I remove the top-3 element.
Yielding only:
[1]  17 22 12 15 12  3  3  1  1

- Gundala Viswanath
Jakarta - Indonesia

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] which test-statistic to use for quasibinomial GLMs?

2009-02-18 Thread Thomas Mang

Hi,

I have fitted quasibinomial GLM [glm(y ~ ..., family = quasibinomial)] 
to a binary response variable; quasibinomial, because there were clear 
signs of underdispersion in a 'simple' binomial GLM, and so the 
dispersion is a free parameter in the model.


My question is now: In a quasi-binomial model with a binary-only 
response variable, what are the most appropriate tests to compare 
different models? I have studied Faraway's book (Extending the linear 
Model with R) and concluded a likelihood-ratio test seems to be 
inappropriate, as seems to be the Wald-test. In chapter 7 an F-test is 
suggested, but this refers to an example with a beta-distributed response.

Can I conclude that the following code example will be fine in my case:
anova(model1, model2, test= F) ?

Moreover, the summary of the GLM, including parameters of the 
predictors, shall be presented. The summary method however does not 
conduct an F test; so in sync with my ideas above, shall I also use 
F-tests for the individual predictors (personally, I would, but as I am 
not sure I ask here...)?


Thanks a lot,
Thomas

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

2009-02-18 Thread Dimitris Rizopoulos

try this:

x[-(1:3)]
# or
tail(x, -3)


Best,
Dimitris


Gundala Viswanath wrote:

Hi all,

Suppose I hve this vector:


x

 [1]  3  4  7 17 22 12 15 12  3  3  1  1

How can I remove the top-3 element.
Yielding only:
[1]  17 22 12 15 12  3  3  1  1

- Gundala Viswanath
Jakarta - Indonesia

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



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

Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
Tel: +31/(0)10/7043478
Fax: +31/(0)10/7043014

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

2009-02-18 Thread ONKELINX, Thierry
Have a look at ?tail

tail(x, -3) should do the trick.

HTH,

Thierry




ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium 
tel. + 32 54/436 185
thierry.onkel...@inbo.be 
www.inbo.be 

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ Roger Brinner

The combination of some data and an aching desire for an answer does not
ensure that a reasonable answer can be extracted from a given body of
data.
~ John Tukey

-Oorspronkelijk bericht-
Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
Namens Gundala Viswanath
Verzonden: woensdag 18 februari 2009 9:20
Aan: r-h...@stat.math.ethz.ch
Onderwerp: [R] Remove top-K elements in Vector

Hi all,

Suppose I hve this vector:

 x
 [1]  3  4  7 17 22 12 15 12  3  3  1  1

How can I remove the top-3 element.
Yielding only:
[1]  17 22 12 15 12  3  3  1  1

- Gundala Viswanath
Jakarta - Indonesia

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

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 as a web scraping tool using RCurl

2009-02-18 Thread Harsh
Hi List,
I am trying to leverage my knowledge of R in trying to use it for tasks that
may not make R the best choice for these tasks.
I wish to automate a web scraping task, which requires a multi-step
procedure:
1) log in to a website
2) Go to a particular page
3) From the drop down menu, click on a particular link
4) From the tabulated data presented, choose relevant information based on a
filter on the date column.

I am not highly acquainted with RCurl or CURL for that matter. I've used
Perl extensively and know that such tasks are more suitable for such
scripting tools as Perl which have an efficient regex engine and a great
number of modules/packages for such web scraping tasks.

I am investigating RCurl's capabilities since I wish to use R, assuming no
knowledge of Perl or other more suitable web-scraping tools.

I would greatly appreciate any links/information/tutorials/book suggestions
that will allow me to use RCurl to get the above tasks accomplished. I have
looked at the Omegahat RCurl links and the manuals present there but would
like R users to share their personal experiences and resources they may have
used to use and implement RCurl.


Thanks
Harsh Singhal

Senior Jedi General
Decision Systems
Mu Sigma Inc.
Chicago, IL

[[alternative HTML version deleted]]

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


Re: [R] R as a web scraping tool using RCurl

2009-02-18 Thread Ajay ohri
Try Firefox and an add in called I Macros from www.iopus.com as an simpler
alternative

read some stuff here

http://www.decisionstats.com/2009/01/web-crawling-automation/

regards,

Ajay


On Wed, Feb 18, 2009 at 2:06 PM, Harsh singhal...@gmail.com wrote:

 Hi List,
 I am trying to leverage my knowledge of R in trying to use it for tasks
 that
 may not make R the best choice for these tasks.
 I wish to automate a web scraping task, which requires a multi-step
 procedure:
 1) log in to a website
 2) Go to a particular page
 3) From the drop down menu, click on a particular link
 4) From the tabulated data presented, choose relevant information based on
 a
 filter on the date column.

 I am not highly acquainted with RCurl or CURL for that matter. I've used
 Perl extensively and know that such tasks are more suitable for such
 scripting tools as Perl which have an efficient regex engine and a great
 number of modules/packages for such web scraping tasks.

 I am investigating RCurl's capabilities since I wish to use R, assuming no
 knowledge of Perl or other more suitable web-scraping tools.

 I would greatly appreciate any links/information/tutorials/book suggestions
 that will allow me to use RCurl to get the above tasks accomplished. I have
 looked at the Omegahat RCurl links and the manuals present there but would
 like R users to share their personal experiences and resources they may
 have
 used to use and implement RCurl.


 Thanks
 Harsh Singhal

 Senior Jedi General
 Decision Systems
 Mu Sigma Inc.
 Chicago, IL

[[alternative HTML version deleted]]

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


[[alternative HTML version deleted]]

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


[R] Barplot with Sorted X-Axis

2009-02-18 Thread Gundala Viswanath
Hi,

I have a binned data that looks like this.

  (8.048,18.05] (-21.95,-11.95] (-31.95,-21.95]   (18.05,28.05] (-41.95,-31.95]
 81  76  18  18  12
(-132,-122] (-122,-112] (-112,-102] (-162,-152]   (-102,-91.95]
  6   6   6   5   5
(-91.95,-81.95] (-192,-182]   (28.05,38.05]   (38.05,48.05]   (58.05,68.05]
  5   4   4   4   4
  (78.05,88.05] (98.05,108] (-562,-552] (-512,-502] (-482,-472]
  4   4   3   3   3
(-452,-442] (-412,-402] (-282,-272] (-152,-142]   (48.05,58.05]
  3   3   3   3   3
  (68.05,78.05]   (118,128]   (128,138] (-582,-572] (-552,-542]
  3   3   3   2   2
(-532,-522] (-422,-412] (-392,-382] (-362,-352] (-262,-252]
  2   2   2   2   2
(-252,-242] (-142,-132] (-81.95,-71.95]   (148,158]   (-1402,-1392]
  2   2   2   2   1
  (-1372,-1362]   (-1342,-1332] (-942,-932] (-862,-852] (-822,-812]
  1   1   1   1   1
(-712,-702] (-682,-672] (-672,-662] (-632,-622] (-542,-532]
  1   1   1   1   1
(-502,-492] (-492,-482] (-472,-462] (-462,-452] (-442,-432]
  1   1   1   1   1
(-432,-422] (-352,-342] (-332,-322] (-312,-302] (-302,-292]
  1   1   1   1   1
(-202,-192] (-182,-172] (-172,-162] (-51.95,-41.95]   (88.05,98.05]
  1   1   1   1   1
  (108,118]   (158,168]   (168,178]   (178,188]   (298,308]
  1   1   1   1   1
  (318,328]   (328,338]   (338,348]   (368,378]   (458,468]
  1   1   1   1   1


How can I plot the data so that the bin is sorted from most negative
in the left to most positive in the right?

Currently my graph look like this:

http://docs.google.com/Doc?id=dcvdrfrh_5cm5qkchw

Notice that it is unsorted at all,
In particular the second bar (value = 76)  id placed on the right  to the first.


  (8.048,18.05] (-21.95,-11.95]
 81  76


This is the command I use to plot:

barplot(x,ylab=Number of Unique Tags, xlab=Expected - Observed)

- Gundala Viswanath
Jakarta - Indonesia

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

2009-02-18 Thread enrico.fosco...@libero.it
Good Morning to Everybody,

I am searching a function which could define a 
vector of colors from a vector of gray, from white to black (not from black to 
white as the function gray()).

I have to use it in the function image(), 
parameter col.

Thank You very much,

Enrico Foscolo

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

2009-02-18 Thread Thomas Lumley

On Tue, 17 Feb 2009, Brigid Mooney wrote:


Thanks for pointing me to the quantreg package as a resource.  I was hoping
to ask be able to address one quick follow-up question...

I get slightly different variants between using the rq funciton with formula
= mydata ~ 1 as I would if I ran the same data using the quantile function.

Example:

mydata - (1:10)^2/2
pctile - seq(.59, .99, .1)

quantile(mydata, pctile)
59%69%79%89%99%
20.015 26.075 32.935 40.595 49.145

rq(mydata~1, tau=pctile)
Call:
rq(formula = mydata ~ 1, tau = pctile)
Coefficients:
   tau= 0.59 tau= 0.69 tau= 0.79 tau= 0.89 tau= 0.99
(Intercept)18  24.532  40.550
Degrees of freedom: 10 total; 9 residual

Is it correct to assume this is due to the different accepted methods of
calculating quantiles?


If you try
 lapply(1:9, function(i)quantile(mydata, pctile,type=i))
the answers from type=1 or 2 agree with rq().

  -thomas

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

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


Re: [R] Help with rgl

2009-02-18 Thread Uwe Ligges



Yihui Xie wrote:

Chinese extend a helping hand to Russians who happen to be in Brazil
about a package written in Germany, which gladdened an American.
Trotsky would be even more proud  -- and amazed!! :-)




Please note that rgl is maintained by a Canadian and two others (O. 
Nenadić and W. Zucchini) who, I guess, are from different nationalities 
as well have been involved in first versions of OpenGL interfaces.


Best,
Uwe Ligges




Regards,
Yihui
--
Yihui Xie xieyi...@gmail.com
Phone: +86-(0)10-82509086 Fax: +86-(0)10-82509086
Mobile: +86-15810805877
Homepage: http://www.yihui.name
School of Statistics, Room 1037, Mingde Main Building,
Renmin University of China, Beijing, 100872, China



On Wed, Feb 18, 2009 at 11:07 AM, roger koenker
ro...@ysidro.econ.uiuc.edu wrote:

Why I love R  [Number  6]:

Chinese  extend a helping hand to Russians who happen to be in Brazil
about a package written in Germany.   Trotsky would be proud  -- and amazed!

url:www.econ.uiuc.edu/~rogerRoger Koenker
email   rkoen...@uiuc.edu   Department of Economics
vox:217-333-4558University of Illinois
fax:217-244-6678Champaign, IL 61820


On Feb 17, 2009, at 8:37 PM, Yihui Xie wrote:


(1) you'll need ImageMagick installed to use the command convert to
convert image sequences into GIF animations; see ?movie3d
(2) viewport is read only!! see ?open3d carefully

Regards,
Yihui
--
Yihui Xie xieyi...@gmail.com
Phone: +86-(0)10-82509086 Fax: +86-(0)10-82509086
Mobile: +86-15810805877
Homepage: http://www.yihui.name
School of Statistics, Room 1037, Mingde Main Building,
Renmin University of China, Beijing, 100872, China



On Tue, Feb 17, 2009 at 2:45 AM, Iuri Gavronski i...@ufrgs.br wrote:

Hi,

I don't know much about the RGL package, and I have read the
documentation and tried some parameters, with no luck... I would like
to generate a movie from a 3D object (code below), where the vortex A
is closer to the observer, and then the object rotates and the B
vortex gets closer. I would like to capture this movie to a file.

By the way, I am not being able to insert unicode text with text3d.

rgl 0.82, R 2.8.1, Windows Vista.

Any help would be appreciated.

Code follows:

library(rgl)
open3d()

coord.1=c(0,100,0)
coord.2=c(100,100,0)
coord.3=c(100,0,0)
coord.4=c(0,0,0)
coord.5=c(50,50,70)

pyrcolor=red
triangles3d(rbind(coord.1,coord.4,coord.5),color=pyrcolor)
triangles3d(rbind(coord.1,coord.2,coord.5),color=pyrcolor)
triangles3d(rbind(coord.2,coord.3,coord.5),color=pyrcolor)
triangles3d(rbind(coord.3,coord.4,coord.5),color=pyrcolor)
quads3d(rbind(coord.1,coord.2,coord.3,coord.4),color=pyrcolor)

vertices = LETTERS[1:5]
text3d(coord.1,text=vertices[1],adj=1,color=blue)
text3d(coord.2,text=vertices[2],adj=0,color=blue)
text3d(coord.3,text=vertices[3],adj=0,color=blue)
text3d(coord.4,text=vertices[4],adj=1,color=blue)
text3d(coord.5,text=vertices[5],adj=0,color=blue)

# couldn't make this work...
#open3d(viewport=c(0,0,686,489))
#par3d(zoom = 1.157625)

filename = piramide.png
rgl.snapshot(filename)


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




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


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


Re: [R] Color Function

2009-02-18 Thread Uwe Ligges



enrico.fosco...@libero.it wrote:

Good Morning to Everybody,

I am searching a function which could define a 
vector of colors from a vector of gray, from white to black (not from black to 
white as the function gray()).




rev(gray())

Uwe Ligges


I have to use it in the function image(), 
parameter col.


Thank You very much,

Enrico Foscolo

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


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


Re: [R] Possible Cause of Segmentation Fault

2009-02-18 Thread Uwe Ligges



Moumita Das wrote:

Hi All,

If you have already finished reading my previous emails regarding
segmentation fault , please have a look at this .I think this may help you
to diagnose the reason for the segmentation fault and help me,because i
don't understand much.

Rather than running the script using  the command 
source(new_regression.R) , what I did was ,simply typed in the  commands
in R-prompt  and the results were:




drv-MySQL()



drv


MySQLDriver:(20645)


dbConnect(drv, user=xyz, password=xyz,dbname =xyz_database, host =

xyz.com)

Error in mysqlNewConnection(drv, ...) : *object xyz.com not found*



Perhaps you forgot to use quotes for the hostname?

Uwe Ligges



* *

* *

Thanks

Moumita

[[alternative HTML version deleted]]

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


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


Re: [R] matrix output

2009-02-18 Thread Jim Lemon

phoebe kong wrote:

Hi friends,

I have questions about printing a pretty big size matrix.

As you could see from below, the matrix wasn't showed in R at full size
(11X11), but it was cut partly into three smaller matrices (11X4,11X4,11X3).
I'm wondering if there is a way to show the whole matrix with dimension
11X11, do you know how to make it?

If R really couldn't fit the full big matrix at once, what about output the
FULL matrix to a .pdf document? I have been wondering for a long time if we
could output something other than graphic, like data frame or text, to a
.pdf file.
  

Hi phoebe,
If you don't need PDF, you can get an HTML display of this sort of 
matrix using the delim.table function in the prettyR package:


delim.table(SY,file=SY.html,delim=td,tabegin=table border=1,
 bor=trtd,tablend=/table)

You can embed a table like this into an HTML formatted output file of an 
R session using the htmlize function and calling delim.table to format 
the table.


Jim

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


Re: [R] Barplot with Sorted X-Axis

2009-02-18 Thread Jim Lemon

Gundala Viswanath wrote:

Hi,

I have a binned data that looks like this.

  (8.048,18.05] (-21.95,-11.95] (-31.95,-21.95]   (18.05,28.05] (-41.95,-31.95]
 81  76  18  18  12
(-132,-122] (-122,-112] (-112,-102] (-162,-152]   (-102,-91.95]
  6   6   6   5   5
(-91.95,-81.95] (-192,-182]   (28.05,38.05]   (38.05,48.05]   (58.05,68.05]
  5   4   4   4   4
  (78.05,88.05] (98.05,108] (-562,-552] (-512,-502] (-482,-472]
  4   4   3   3   3
(-452,-442] (-412,-402] (-282,-272] (-152,-142]   (48.05,58.05]
  3   3   3   3   3
  (68.05,78.05]   (118,128]   (128,138] (-582,-572] (-552,-542]
  3   3   3   2   2
(-532,-522] (-422,-412] (-392,-382] (-362,-352] (-262,-252]
  2   2   2   2   2
(-252,-242] (-142,-132] (-81.95,-71.95]   (148,158]   (-1402,-1392]
  2   2   2   2   1
  (-1372,-1362]   (-1342,-1332] (-942,-932] (-862,-852] (-822,-812]
  1   1   1   1   1
(-712,-702] (-682,-672] (-672,-662] (-632,-622] (-542,-532]
  1   1   1   1   1
(-502,-492] (-492,-482] (-472,-462] (-462,-452] (-442,-432]
  1   1   1   1   1
(-432,-422] (-352,-342] (-332,-322] (-312,-302] (-302,-292]
  1   1   1   1   1
(-202,-192] (-182,-172] (-172,-162] (-51.95,-41.95]   (88.05,98.05]
  1   1   1   1   1
  (108,118]   (158,168]   (168,178]   (178,188]   (298,308]
  1   1   1   1   1
  (318,328]   (328,338]   (338,348]   (368,378]   (458,468]
  1   1   1   1   1


How can I plot the data so that the bin is sorted from most negative
in the left to most positive in the right?

Currently my graph look like this:

http://docs.google.com/Doc?id=dcvdrfrh_5cm5qkchw

Notice that it is unsorted at all,
In particular the second bar (value = 76)  id placed on the right  to the first.


  (8.048,18.05] (-21.95,-11.95]
 81  76


This is the command I use to plot:

barplot(x,ylab=Number of Unique Tags, xlab=Expected - Observed)

  

Hi Gundala,
How about sorting the levels of the data first:

attr(mydata,levels)-sort(levels(mydata))

or sorting the columns of the above table if that is what you are using 
to plot.


Jim

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


Re: [R] Python and R

2009-02-18 Thread Gabor Grothendieck
On Tue, Feb 17, 2009 at 6:59 PM, Esmail Bonakdarian esmail...@gmail.com wrote:
 Well, I have a program written in R which already takes quite a while
 to run. I was
 just wondering if I were to rewrite most of the logic in Python - the
 main thing I use
 in R are its regression facilities - if it would speed things up. I
 suspect not since
 both of them are interpreted, and the bulk of the time is taken up by
 R's regression
 calls.

See ?Rprof for profiling your R code.

If lm is the culprit, rewriting your lm calls using lm.fit might help.

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

2009-02-18 Thread Luis Ridao Cruz
R-help,

How can I specify the distance between the axis and axis annotation?

Thanks in advance

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

2009-02-18 Thread Dimitris Rizopoulos

have a look at ?par() and specifically parameter 'mgp', e.g.,
compare

par(mfrow = c(1, 2))
plot(1, 1)
plot(1, 1, mgp = c(2.5, 0.5, 0))


I hope it helps.

Best,
Dimitris

Luis Ridao Cruz wrote:

R-help,

How can I specify the distance between the axis and axis annotation?

Thanks in advance

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



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

Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
Tel: +31/(0)10/7043478
Fax: +31/(0)10/7043014

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

2009-02-18 Thread Duncan Murdoch

Luis Ridao Cruz wrote:

R-help,

How can I specify the distance between the axis and axis annotation?


  
I don't think you can do this directly, but you can do it using mtext.  
For example:


x - 1:10
y - rnorm(10)

plot(x,y, axes=F)
box()
at - pretty(x)
min - par(usr)[1]
max - par(usr)[2]
at - at[ at = min  at = max]  # pretty extends the range
axis(1, at=at, labels=FALSE)
mtext(at, side=1, at=at, line=3)

Duncan Murdoch

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


Re: [R] Python and R

2009-02-18 Thread Barry Rowlingson
2009/2/17 Esmail Bonakdarian esmail...@gmail.com:

 Well, I have a program written in R which already takes quite a while
 to run. I was
 just wondering if I were to rewrite most of the logic in Python - the
 main thing I use
 in R are its regression facilities - if it would speed things up. I
 suspect not since
 both of them are interpreted, and the bulk of the time is taken up by
 R's regression
 calls.

 - and the bulk of the time in the regression calls will be taken up
by C code in the underlying linear algebra libraries (lapack, blas,
atlas and friends).

 Your best bet for optimisation in this case would be making sure you
have the best libraries for your architecture. That's a bit beyond me
at the moment, others here can probably tell you about getting the
best performing library for your system.

 This can also speed up Python (scipy or numpy) code that uses the
same libraries.

Barry

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


Re: [R] Subset Regression Package

2009-02-18 Thread Pedro Silva
--

Message: 72
Date: Tue, 17 Feb 2009 22:05:46 퍍 (UTC)
From: Hans W. Borchers hwborch...@gmail.com
Subject: Re: [R] Subset Regression Package
To: r-h...@stat.math.ethz.ch
Message-ID: loom.20090217t215556-...@post.gmane.org
Content-Type: text/plain; charset=us-ascii

Take also a look at the subselect package that can perform subset
selection in regression (and in several other statistical problems)
using both exact (leaps and bounds algorithm) and heuristic
(simulated annealing, genetic search, etc.) methods.

Regards,

A. Pedro Duarte Silva


Alex Roy alexroy2008 at gmail.com writes:

 
 Dear all ,
   Is there any subset regression (subset selection
 regression) package in R other than leaps?


Lars and Lasso are other 'subset selection' methods, see the corresponding
packages 'lars' and 'lasso2' and its description in The Elements of Statistical
Learning.
Also, 'dr', Methods for dimension reduction for regression, or  'relaimpo',
Relative importance of regressors in linear models, can be considered.


 Thanks and regards
 
 Alex


***

Esta mensagem (incluindo quaisquer anexos) pode conter informa豫o confidencial 
ou legalmente protegida para uso exclusivo do destinat�rio. Se n�o for o 
destinat�rio pretendido da mesma, n�o dever� fazer uso, copiar, distribuir ou 
revelar o seu conte�do (incluindo quaisquer anexos) a terceiros, sem a devida 
autoriza豫o. Se recebeu esta mensagem por engano, por favor informe o emissor, 
por e-mail, e elimine-a imediatamente. Obrigado.


This message may contain confidential information or pri...{{dropped:6}}

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

2009-02-18 Thread Esmail Bonakdarian

Gabor Grothendieck wrote:



See ?Rprof for profiling your R code.

If lm is the culprit, rewriting your lm calls using lm.fit might help.


Yes, based on my informal benchmarking, lm is the main bottleneck, the rest
of the code consists mostly of vector manipulations and control structures.

I am not familiar with lm.fit, I'll definitely look it up. I hope it's similar
enough to make it easy to substitute one for the other.

Thanks for the suggestion, much appreciated. (My runs now take sometimes
several hours, it would be great to cut that time down by any amount :-)

Esmail

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

2009-02-18 Thread Lauri Nikkinen
Hello,

How to produce .tif graphic in colors using bitmap function?

e.g this produces figure in grayscale

bitmap(file=volc.tif, type = tifflzw, res = 300)
image(t(volcano)[ncol(volcano):1,])
dev.off()

I'm using Windows XP and ghostscript.

 R.Version()
$platform
[1] i386-pc-mingw32

$arch
[1] i386

$os
[1] mingw32

$system
[1] i386, mingw32

$status
[1] 

$major
[1] 2

$minor
[1] 7.1

$year
[1] 2008

$month
[1] 06

$day
[1] 23

$`svn rev`
[1] 45970

$language
[1] R

$version.string
[1] R version 2.7.1 (2008-06-23)

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

2009-02-18 Thread Gabor Grothendieck
On Wed, Feb 18, 2009 at 7:27 AM, Esmail Bonakdarian esmail...@gmail.com wrote:
 Gabor Grothendieck wrote:


 See ?Rprof for profiling your R code.

 If lm is the culprit, rewriting your lm calls using lm.fit might help.

 Yes, based on my informal benchmarking, lm is the main bottleneck, the
 rest
 of the code consists mostly of vector manipulations and control structures.

 I am not familiar with lm.fit, I'll definitely look it up. I hope it's
 similar
 enough to make it easy to substitute one for the other.

 Thanks for the suggestion, much appreciated. (My runs now take sometimes
 several hours, it would be great to cut that time down by any amount :-)


Yes, the speedup can be significant.  e.g. here we cut the time down to
40% of the lm time by using lm.fit and we can get down to nearly 10% if
we go even lower level:

 system.time(replicate(1000, lm(DAX ~.-1, EuStockMarkets)))
   user  system elapsed
  26.850.07   27.35

 system.time(replicate(1000, lm.fit(EuStockMarkets[,-1], EuStockMarkets[,1])))
   user  system elapsed
  10.760.00   10.78

 system.time(replicate(1000, qr.coef(qr(EuStockMarkets[,-1]), 
 EuStockMarkets[,1])))
   user  system elapsed
   3.330.003.34

 lm(DAX ~.-1, EuStockMarkets)

Call:
lm(formula = DAX ~ . - 1, data = EuStockMarkets)

Coefficients:
 SMI   CAC  FTSE
 0.55156   0.45062  -0.09392

 # They call give the same coefficients:

 lm.fit(EuStockMarkets[,-1], EuStockMarkets[,1])$coef
SMI CACFTSE
 0.55156141  0.45062183 -0.09391815

 qr.coef(qr(EuStockMarkets[,-1]), EuStockMarkets[,1])
SMI CACFTSE
 0.55156141  0.45062183 -0.09391815

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

2009-02-18 Thread Uwe Ligges



Lauri Nikkinen wrote:

Hello,

How to produce .tif graphic in colors using bitmap function?

e.g this produces figure in grayscale

bitmap(file=volc.tif, type = tifflzw, res = 300)
image(t(volcano)[ncol(volcano):1,])
dev.off()


Why not upgrade R and use the tiff() device?

Uwe Ligges





I'm using Windows XP and ghostscript.


R.Version()

$platform
[1] i386-pc-mingw32

$arch
[1] i386

$os
[1] mingw32

$system
[1] i386, mingw32

$status
[1] 

$major
[1] 2

$minor
[1] 7.1

$year
[1] 2008

$month
[1] 06

$day
[1] 23

$`svn rev`
[1] 45970

$language
[1] R

$version.string
[1] R version 2.7.1 (2008-06-23)

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


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


Re: [R] cumsum vs. sum

2009-02-18 Thread Martin Maechler
 GaGr == Gabor Grothendieck ggrothendi...@gmail.com
 on Tue, 17 Feb 2009 20:53:18 -0500 writes:

GaGr Check out sum.exact and cumsum.exact in the caTools package.
 library(caTools)
GaGr Loading required package: bitops
 x - 1/(12:14)
 sum(x) - cumsum(x)[3]
GaGr [1] 2.775558e-17
 sum.exact(x) - cumsum.exact(x)[3]
GaGr [1] 0

[ buuh, humbug! ]

The  'NEWS'  for  R-devel (to become  R 2.9.0 in April)
has the following entry

o   cumsum(x) and cumprod(x) for double precision x now use a long
double accumulator where available and so more closely match
sum() and prod() in potentially being more accurate.

and indeed, in R-devel, 
sum(x) - cumsum(x)[length(x)]
gives 0 for your example.


Martin Maechler, ETH Zurich and R-core team


GaGr On Tue, Feb 17, 2009 at 5:12 PM, Stavros Macrakis 
macra...@alum.mit.edu wrote:
 I recently traced a bug of mine to the fact that cumsum(s)[length(s)]
 is not always exactly equal to sum(s).
 
 For example,
 
 x-1/(12:14)
 sum(x) - cumsum(x)[3]  = 2.8e-17
 
 Floating-point addition is of course not exact, and in particular is
 not associative, so there are various possible reasons for this.
 Perhaps sum uses clever summing tricks to get more accurate results?
 In some quick experiments, it does seem to get more accurate results
 than cumsum.
 
 It might be worth documenting.
 
 -s

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

2009-02-18 Thread Pedroso MOACIR

Hi all,

I want to approximate te shape of an area defined by a set of points.
The convex hull is not good enough, but I think that an alpha shape
would be fine. I did an RSiteSearch(),  google search, RSeek.org search,
looked at the CRAN Views, but was unable do find a function in R that
computes the alpha shape.  Does anyone know if there is such a function
in R?

Theank you very much.

Moacir Pedroso
Embrapa - Brazil

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


Re: [R] using stepAIC with negative binomial regression - e rror message help

2009-02-18 Thread Ben Bolker


t c mudiver1200 at yahoo.com writes:

 
 Dear List,
 I am having problems running stepAIC with a 
 negative binomial regression model.  I am working with data on
 manta ray abundance, using 20 predictor variables.  

 [snip]

The model I ran was:
 glm.nb.fullglm.nb(mantas~site+year+
  cosday+sinday+daylength+
  lunarpercent+sstmean+sststd+
 sshmean+sshstd+cosdir+sindir+spd+
  temp+alt+tideht+high+falling+low+plankton)
  
 However, when I use stepAIC on the model I get the message:
  
  stepAIC(glm.nb.full)
 Start:  AIC=19240.46
 mantas ~ site + year + cosday + sinday + daylength + lunarpercent + 
     sstmean + sststd + sshmean + sshstd + cosdir + sindir + spd + 
     temp + alt + tideht + high + falling + low + plankton
  
 Error in dropterm.default(object, ...) : 
   number of rows in use has changed: remove missing values?


   Yes.  As the note in ?stepAIC says,

  The model fitting must apply the models to the same dataset.  This
 may be a problem if there are missing values and an 'na.action'
 other than 'na.fail' is used (as is the default in R). We suggest
 you remove the missing values first.

  The easiest way to remove missing values is with na.omit, e.g.

fullmod - glm.nb(..., data=na.omit(mydata))
stepAIC(fullmod)

   aren't cosday, sinday, and daylength pretty strongly collinear ... ?

  Ben Bolker

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


[R] Counting/processing a character vector

2009-02-18 Thread Gavin Simpson
Dear List,

I have a data set stored in the following format:

 head(dat, n = 10)
  id  sppcode abundance
1  10307 1000 1
2  10307 16220602 2
3  10307 2000 5
4  10307 2011 2
5  10307 2400 1
6  10307 402183
7  10307 4021010245
8  10307 4514 1
9  10307 4563 1
10 10307 4563060041
 str(dat)
'data.frame':   111 obs. of  3 variables:
 $ id   : Factor w/ 3 levels 10307,10719,..: 1 1 1 1 1 1 1 1 1 1 ...
 $ sppcode  : chr  1000 16220602 2000 2011 ...
 $ abundance: num  1 2 5 2 1 83 45 1 1 41 ...

that represent counts of species, recorded with a particular coding
system. The abundance column is not needed for this particular
operation, but is present in the data files.

I am interested in counting entries (rows) in the sppcode component of
dat. The sppcode takes a particular format: Order Family Genus Species,
with 2 alphanumeric digits allocated for each level of the hierarchy. I
want to know how many species there are in each site (the id factor),
but I should only count a higher level entry if there are no lower
levels present.

For example, for the above data excerpt (just the headed rows), I would
count the following rows:

1000
16220602
2011
2400
40320203
4514
45630600 == 7 species present.

To be more specific, I don't count 4563 (row 9) because there exists
a sppcode for this 'id' where either of the next two pairs of digits are
not all 0's.

In words, I want to count all rows where WWXXYYZZ are ZZ != 00, then,
rows where ZZ == 00 only if the WWXXYY combination has not been counted
yet.

An example data set has been placed in my University web space and can
be read into R with the following:

## read example csv data
dat - 
read.csv(url(http://www.homepages.ucl.ac.uk/~ucfagls/files/example_data.csv;),
colClasses = c(factor,character,numeric))
## show the data
head(dat, n = 10)

And the sppcode variable can be broken out into the 4 levels if required via:

## split out the four levels of categorisation:
dat2 - data.frame(dat,
   order = with(dat, substr(sppcode, 1, 2)),
   family = with(dat, substr(sppcode, 3, 4)),
   genus = with(dat, substr(sppcode, 5, 6)),
   species = with(dat, substr(sppcode, 7, 8)))

The actual data set/problem contains several hundred different id's.

I can't see an efficient way of processing these data in the manner
described. Any help would be most gratefully received.

Many thanks,

Gavin
-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson [t] +44 (0)20 7679 0522
 ECRC, 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
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%



signature.asc
Description: This is a digitally signed message part
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] distance betwenn axis and axis annotation

2009-02-18 Thread Duncan Murdoch

On 18/02/2009 7:50 AM, Mark Difford wrote:

Duncan Murdoch wrote:


I don't think you can do this directly, but you can do it using mtext.


This is not correct.


It was correct at the time I wrote it.  Of course things have changed 
now that you and Dimitris have been so helpful:  now I *do* think you 
can do it directly.



 You can, as Dimitris has already shown. See ?par (sub

mgp). The difficulty arises if you want only one set of axes changed, which
is not what was requested.


There's no real difficulty there: axis takes an mgp arg as well.  So you 
can plot without axes, then add one axis with one mgp value, and the 
other axis with a different one.


Duncan Murdoch




## Example using your example
par(mfrow = c(1, 2))
x - 1:10
y - rnorm(10)

plot(x,y, axes=F)
box()
at - pretty(x)
min - par(usr)[1]
max - par(usr)[2]
at - at[ at = min  at = max]  # pretty extends the range
axis(1, at=at, labels=FALSE)
mtext(at, side=1, at=at, line=3)

plot(x, y, mgp = c(3, 3, 0))

Regards, Mark.


Duncan Murdoch-2 wrote:

Luis Ridao Cruz wrote:

R-help,

How can I specify the distance between the axis and axis annotation?


  
I don't think you can do this directly, but you can do it using mtext.  
For example:


x - 1:10
y - rnorm(10)

plot(x,y, axes=F)
box()
at - pretty(x)
min - par(usr)[1]
max - par(usr)[2]
at - at[ at = min  at = max]  # pretty extends the range
axis(1, at=at, labels=FALSE)
mtext(at, side=1, at=at, line=3)

Duncan Murdoch

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






__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Training nnet in two ways, trying to understand the performance difference - with (i hope!) commented, minimal, self-contained, reproducible code

2009-02-18 Thread Tony Breyal
Dear all,

Objective: I am trying to learn about neural networks. I want to see
if i can train an artificial neural network model to discriminate
between spam and nonspam emails.

Problem: I created my own model (example 1 below) and got an error of
about 7.7%. I created the same model using the Rattle package (example
2 below, based on rattles log script) and got a much better error of
about 0.073%.

Question 1: I don't understand why the rattle script gives a better
result? I must therefore be doing something wrong in my own script
(example 1) and would appreciate some insight  :-)

Question 2: As rattle gives a much better result, i would be happy to
use it's r-code instead of my own. How can I interpret it's
predictions as either being either 'spam' or 'nonspam'? I have looked
at the type='class' parameter in ?predict.nnet but it doesn't apply to
this situation i believe.

Below i give commented, minimal, self-contained and reproducible code.
(if you ignore the output, it really is very few lines of code and
therefore minimal i believe?)

## load library
library(nnet)

## Load in spam dataset from package kernlab
data(list = spam, package = kernlab)
set.seed(42)
my.sample - sample(nrow(spam), 3221)
spam.train - spam[my.sample, ]
spam.test - spam[-my.sample, ]


## Example 1 - my own code
# train artificial neural network (nn1)
( nn1 - nnet(type~., data=spam.train, size=3, decay=0.1, maxit=1000) )
# predict spam.test dataset on nn1
 ( nn1.pr.test - predict(nn1, spam.test, type='class') )
   [1] spamspamspamspamnonspam spam
spam
   [etc...]
# error matrix
(nn1.test.tab-table(spam.test$type, nn1.pr.test, dnn=c('Actual', 
'Predicted')))
   Predicted
  Actualnonspam spam
nonspam 778   43
spam   63496
# Calucate overall error percentage ~ 7.68%
(nn1.test.perf - 100 * (nn1.test.tab[2] + nn1.test.tab[3]) / 
sum(nn1.test.tab))
[1] 7.68116


## Example 2 - code based on rattles log script
# train artifical neural network
nn2-nnet(as.numeric(type)-1~., data=spam.train, size=3, decay=0.1, maxit=1000)
# predict spam.test dataset on nn2.
# ?predict.nnet does have the parameter type='class', but i can't use
that here as an option
nn2.pr.test - predict(nn2, spam.test)
   [,1]
30.984972396013
40.931149225918
10   0.930001139978
13   0.923271300707
21   0.102282256315
[etc...]
# error matrix
( nn2.test.tab - round(100*table(nn2.pr.test, spam.test$type,
dnn=c(Predicted, Actual))/length
(nn2.pr.test)) )
   Actual
  Predictednonspam spam
-0.741896935969825  00
-0.706473834678304  00
-0.595327594045746  00
  [etc...]
# calucate overall error percentage. Am not sure how this line works
tbh,
# and i think it should be multiplied by 100. I got this from rattle's
log script.
(function(x){return((x[1,2]+x[2,1])/sum(x))})
(table(nn2.pr.test, spam.test$type,  dnn=c(Predicted,
Actual)))
[1] 0.0007246377
# i'm guessing the above should be ~0.072%


I know the above probably seems complicated, but any help that can be
offered would be much appreicated.

Thank you kindly in advance,
Tony

OS = Windows Vista Ultimate, running R in admin mode
 sessionInfo()
R version 2.8.1 (2008-12-22)
i386-pc-mingw32

locale:
LC_COLLATE=English_United Kingdom.1252;LC_CTYPE=English_United Kingdom.
1252;LC_MONETARY=English_United Kingdom.
1252;LC_NUMERIC=C;LC_TIME=English_United Kingdom.1252

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

other attached packages:
[1] RGtk2_2.12.8 vcd_1.2-2colorspace_1.0-0
MASS_7.2-45  rattle_2.4.8 nnet_7.2-45

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

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


Re: [R] alpha shape function

2009-02-18 Thread roger koenker
As it happens, I have also been looking into this.  I began by  
considering
Ken Clarkson's hull:  http://www.netlib.org/voronoi/hull.html  but  
eventually
discovered that its alpha shapes don't seem to treat holes in regions,  
only

simply connected regions.  (I would be happy to hear to the contrary, if
someone has other experience.)  There is a nice matlab implementation
http://www.mathworks.com/matlabcentral/fileexchange/6760 which I've
also experimented with using R.matlab, but  this is still very early  
days.
The matlab version is only 2d, whereas Clarkson does moderate d
which

extends at least to 3d.
Given tripack, it seems like alpha-shapes shouldn't be such a big  
enterprise, and

might  make a nice project for someone with an interest in computational
geometry.   Hint, hint.  Nudge, Nudge.

url:www.econ.uiuc.edu/~rogerRoger Koenker
emailrkoen...@uiuc.eduDepartment of Economics
vox: 217-333-4558University of Illinois
fax:   217-244-6678Champaign, IL 61820



On Feb 18, 2009, at 7:20 AM, Pedroso MOACIR wrote:


Hi all,

I want to approximate te shape of an area defined by a set of points.
The convex hull is not good enough, but I think that an alpha shape
would be fine. I did an RSiteSearch(),  google search, RSeek.org  
search,

looked at the CRAN Views, but was unable do find a function in R that
computes the alpha shape.  Does anyone know if there is such a  
function

in R?

Theank you very much.

Moacir Pedroso
Embrapa - Brazil

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


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

2009-02-18 Thread dwinsemius
I would think this could be approached by segmenting the  probability volume 
using identities such as these:

P(Y1  Z1, Y2  Z2, Y3  Z3, Y4  Z4) + P(Y1  Z1, Y2  Z2, Y3  Z3, Y4  Z4) =
  P(Y1  Z1, Y2  Z2, Y3  Z3, Y4  Inf)

and 

P(Y1  Z1, Y2  Z2, Y3  Z3, Y4 Inf) + P(Y1  Z1, Y2  Z2, Y3  Z3, Y4  Inf) =
  P(Y1  Z1, Y2  Z2, Y3 Inf, Y4  Inf)

-- 
David Winsemius
Apologies for what will probably be an html formatted message

 -- Original message --
From: Fernando Saldanha fsald...@gmail.com
 I wonder if an R package would have a function that calculates the following.
 
 Let Y be a normal multivariate function. For example, let Y have 4
 dimensions. I want to calculate
 
 P(Y1  Z1, Y2  Z2, Y3  Z3, Y4  Z4).
 
 There are R functions to do the calculation if all the inequalities
 are of the type  (the cdf). But is there an R function where the
 two types of inequalities ( and ) can be mixed? (The user would
 have to specify the set of indexes with inequalities of the type )
 
 Thanks for any suggestions.
 
 FS
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] Plotting Binned Data

2009-02-18 Thread Ben Bolker



Gundala Viswanath wrote:
 
 Dear all,
 
 I have a binned data that looks like this:
 
 dat
   (-1,9]   (9,19]  (19,29]  (29,39]  (39,49]  (49,59]  (59,69]  (69,79]
 10063374   79   1643443
  (79,89]  (89,99]
62
 
 I tried to plot a histogram overlayed with curve.
 With the following snippet:
 
 library(lattice)
 pdf(myfile.pdf)
 
 hist(dat)
 lines(dat,col=red)
 dev.off()
 __ END__
 
 

I think barplot is what you want: something like
barplot(dat,names.arg=names(dat))

  Are you sure you want to keep the first element
of dat?  You're certainly not going to be able to
see anything that's going on with the other
values ...

barplot(dat[-1],names.arg=names(dat)[-1])

  Ben Bolker

-- 
View this message in context: 
http://www.nabble.com/Plotting-Binned-Data-tp22071819p22079522.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Python and R

2009-02-18 Thread Kenn Konstabel
lm does lots of computations, some of which you may never need. If speed
really matters, you might want to compute only those things you will really
use. If you only need coefficients, then using %*%, solve and crossprod will
be remarkably faster than lm

# repeating someone else's example
# lm(DAX~., EuStockMarkets)

 y - EuStockMarkets[,DAX]
 x - EuStockMarkets
 x[,1]-1
colnames(x)[1] - Intercept

lm(y ~ x-1)
solve(crossprod(x), t(x))%*%y# probably this can be done more
efficiently

# and a naive timing

 system.time( for(i in 1:1000) lm(y ~ x-1))
   user  system elapsed
  14.640.33   32.69
 system.time(for(i in 1:1000) solve(crossprod(x), crossprod(x,y)) )
   user  system elapsed
   0.360.000.36


Also lsfit() is a bit quicker than lm or lm.fit.

Regards,
Kenn



On Wed, Feb 18, 2009 at 2:33 PM, Esmail Bonakdarian esmail...@gmail.comwrote:

 Barry Rowlingson wrote:



  - and the bulk of the time in the regression calls will be taken up
 by C code in the underlying linear algebra libraries (lapack, blas,
 atlas and friends).


 ah, good point.

   Your best bet for optimisation in this case would be making sure you
 have the best libraries for your architecture. That's a bit beyond me
 at the moment, others here can probably tell you about getting the
 best performing library for your system.

  This can also speed up Python (scipy or numpy) code that uses the
 same libraries.


 thanks for the suggestions Barry, I mostly run on intel machines, but
 using two flavors of Linux and also Windows XP - I grab any machine I can
 to
 help run this. R versions range from 2.6.x (Fedora) to 2.8.1 (XP) at the
 moment.

 Another post suggested I look at lm.fit in place of lm to help speed things
 up, so I'm going to look at that next.

 Appreciate all the helpful posts here.

 Esmail


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


[[alternative HTML version deleted]]

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


Re: [R] Cross classified or Multiple membership or Hierarchical (3level ) logistic models using Umacs

2009-02-18 Thread Doran, Harold
If the data are cross-classified, then hwy would you want a hierarchical
linear model? You might try the lmer function for this instead. 

 -Original Message-
 From: r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.org] On Behalf Of Luwis Tapiwa Diya
 Sent: Tuesday, February 17, 2009 4:17 PM
 To: r-help@r-project.org
 Subject: [R] Cross classified or Multiple membership or 
 Hierarchical (3level ) logistic models using Umacs
 
 Dear R users,
 
 I would like to fit cross classified or multiple membership 
 logistic models or a 3 level hierarchical logistic model 
 using the Umacs package. Can anyone advise me on how to 
 proceed or better point me to examples of  how its done.
 
 Regards,
 
 --
 Luwis Diya,
 Leuven Biostatistics and Statistical Bioinformatics Centre 
 (L-BioStat), Kapucijnenvoer 35 blok d - bus 7001, 3000 Leuven, Belgium
 
 Tel: +32 16 336886 or +32 16 336892
 Fax: +32 16 337015
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 

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


Re: [R] Python and R

2009-02-18 Thread Doran, Harold
 lm(y ~ x-1)
 solve(crossprod(x), t(x))%*%y# probably this can be done more
 efficiently


You could do

crossprod(x,y) instead of t(x))%*%y

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


Re: [R] Counting/processing a character vector

2009-02-18 Thread Gavin Simpson
Apologies, Jim Holtman has pointed out a couple of problems/queries with
my original email that I would like to make clear.

Firstly, I introduced a typo when trying to be helpful. In my email
below, I had incorrectly typed out one of the species codes I would
count:

1000
16220602
2011
2400
40320203 ## This should have been 40210102
4514
45630600 == 7 species present.

Secondly, the criteria I laid out might suggest that in the 10 rows of
example I quoted, I would count both:

4563
45630600

This is not what I wanted and apologies that this was not clear. I only
want to count 45630600 because this is more specific in terms of what
creature this is than 4563. I don't know that 4563 is not
45630600, so I should not count both 4563 and 45630600, as this
could be double accounting.

These data are species counts and sometimes it is not possible to
identify an individual to species level. Sometime we can't even get the
genera, or even family, hence why sometimes we have a count for the
family (4563) as well as for the genus (45630600) in the same
sample/site. It depends on how much of the individual there is to
identify it from as to how precise the identification is.

So I only want to count a higher level category only if I have not
counted a lower level category contained within this higher level.

I hope this is a little bit clearer? And no, I did not come up with this
coding system nor the idea to use counts of species in this
way... ;-)

Apologies if my original email caused unnecessary confusion.

All the best,

G

On Wed, 2009-02-18 at 13:37 +, Gavin Simpson wrote:
 Dear List,
 
 I have a data set stored in the following format:
 
  head(dat, n = 10)
   id  sppcode abundance
 1  10307 1000 1
 2  10307 16220602 2
 3  10307 2000 5
 4  10307 2011 2
 5  10307 2400 1
 6  10307 402183
 7  10307 4021010245
 8  10307 4514 1
 9  10307 4563 1
 10 10307 4563060041
  str(dat)
 'data.frame': 111 obs. of  3 variables:
  $ id   : Factor w/ 3 levels 10307,10719,..: 1 1 1 1 1 1 1 1 1 1 ...
  $ sppcode  : chr  1000 16220602 2000 2011 ...
  $ abundance: num  1 2 5 2 1 83 45 1 1 41 ...
 
 that represent counts of species, recorded with a particular coding
 system. The abundance column is not needed for this particular
 operation, but is present in the data files.
 
 I am interested in counting entries (rows) in the sppcode component of
 dat. The sppcode takes a particular format: Order Family Genus Species,
 with 2 alphanumeric digits allocated for each level of the hierarchy. I
 want to know how many species there are in each site (the id factor),
 but I should only count a higher level entry if there are no lower
 levels present.
 
 For example, for the above data excerpt (just the headed rows), I would
 count the following rows:
 
 1000
 16220602
 2011
 2400
 40320203
 4514
 45630600 == 7 species present.
 
 To be more specific, I don't count 4563 (row 9) because there exists
 a sppcode for this 'id' where either of the next two pairs of digits are
 not all 0's.
 
 In words, I want to count all rows where WWXXYYZZ are ZZ != 00, then,
 rows where ZZ == 00 only if the WWXXYY combination has not been counted
 yet.
 
 An example data set has been placed in my University web space and can
 be read into R with the following:
 
 ## read example csv data
 dat - 
 read.csv(url(http://www.homepages.ucl.ac.uk/~ucfagls/files/example_data.csv;),
 colClasses = c(factor,character,numeric))
 ## show the data
 head(dat, n = 10)
 
 And the sppcode variable can be broken out into the 4 levels if required via:
 
 ## split out the four levels of categorisation:
 dat2 - data.frame(dat,
order = with(dat, substr(sppcode, 1, 2)),
family = with(dat, substr(sppcode, 3, 4)),
genus = with(dat, substr(sppcode, 5, 6)),
species = with(dat, substr(sppcode, 7, 8)))
 
 The actual data set/problem contains several hundred different id's.
 
 I can't see an efficient way of processing these data in the manner
 described. Any help would be most gratefully received.
 
 Many thanks,
 
 Gavin
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson [t] +44 (0)20 7679 0522
 ECRC, 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

Re: [R] distance betwenn axis and axis annotation

2009-02-18 Thread Mark Difford

Duncan Murdoch wrote:

 There's no real difficulty there: axis takes an mgp arg as well.

Thanks for that. A good bit of practical advice, which I hadn't yet clicked
on. I won't comment on the thinking thing;)

Regards, Mark.


Duncan Murdoch-2 wrote:
 
 On 18/02/2009 7:50 AM, Mark Difford wrote:
 Duncan Murdoch wrote:
 
 I don't think you can do this directly, but you can do it using mtext.
 
 This is not correct.
 
 It was correct at the time I wrote it.  Of course things have changed 
 now that you and Dimitris have been so helpful:  now I *do* think you 
 can do it directly.
 
 
   You can, as Dimitris has already shown. See ?par (sub
 mgp). The difficulty arises if you want only one set of axes changed,
 which
 is not what was requested.
 
 There's no real difficulty there: axis takes an mgp arg as well.  So you 
 can plot without axes, then add one axis with one mgp value, and the 
 other axis with a different one.
 
 Duncan Murdoch
 
 
 
 ## Example using your example
 par(mfrow = c(1, 2))
 x - 1:10
 y - rnorm(10)
 
 plot(x,y, axes=F)
 box()
 at - pretty(x)
 min - par(usr)[1]
 max - par(usr)[2]
 at - at[ at = min  at = max]  # pretty extends the range
 axis(1, at=at, labels=FALSE)
 mtext(at, side=1, at=at, line=3)
 
 plot(x, y, mgp = c(3, 3, 0))
 
 Regards, Mark.
 
 
 Duncan Murdoch-2 wrote:
 Luis Ridao Cruz wrote:
 R-help,

 How can I specify the distance between the axis and axis annotation?


   
 I don't think you can do this directly, but you can do it using mtext.  
 For example:

 x - 1:10
 y - rnorm(10)

 plot(x,y, axes=F)
 box()
 at - pretty(x)
 min - par(usr)[1]
 max - par(usr)[2]
 at - at[ at = min  at = max]  # pretty extends the range
 axis(1, at=at, labels=FALSE)
 mtext(at, side=1, at=at, line=3)

 Duncan Murdoch

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



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

-- 
View this message in context: 
http://www.nabble.com/distance-betwenn-axis-and-axis-annotation-tp22076797p22079896.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Subset Regression Package

2009-02-18 Thread Alex Roy
Thank you very much for your help

Alex

On Wed, Feb 18, 2009 at 1:26 PM, Pedro Silva psi...@porto.ucp.pt wrote:

 --

 Message: 72
 Date: Tue, 17 Feb 2009 22:05:46 퍍 (UTC)
 From: Hans W. Borchers hwborch...@gmail.com
 Subject: Re: [R] Subset Regression Package
 To: r-h...@stat.math.ethz.ch
 Message-ID: loom.20090217t215556-...@post.gmane.org
 Content-Type: text/plain; charset=us-ascii

 Take also a look at the subselect package that can perform subset
 selection in regression (and in several other statistical problems)
 using both exact (leaps and bounds algorithm) and heuristic
 (simulated annealing, genetic search, etc.) methods.

 Regards,

 A. Pedro Duarte Silva


 Alex Roy alexroy2008 at gmail.com writes:

 
  Dear all ,
Is there any subset regression (subset selection
  regression) package in R other than leaps?


 Lars and Lasso are other 'subset selection' methods, see the corresponding
 packages 'lars' and 'lasso2' and its description in The Elements of
 Statistical
 Learning.
 Also, 'dr', Methods for dimension reduction for regression, or
  'relaimpo',
 Relative importance of regressors in linear models, can be considered.


  Thanks and regards
 
  Alex
 

 ***

 Esta mensagem (incluindo quaisquer anexos) pode conter informa豫o
 confidencial ou legalmente protegida para uso exclusivo do destinat�io. Se
 n� for o destinat�io pretendido da mesma, n� dever�fazer uso, copiar,
 distribuir ou revelar o seu conte�o (incluindo quaisquer anexos) a
 terceiros, sem a devida autoriza豫o. Se recebeu esta mensagem por engano, por
 favor informe o emissor, por e-mail, e elimine-a imediatamente. Obrigado.


 This message may contain confidential information or pri...{{dropped:6}}


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



[[alternative HTML version deleted]]

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


Re: [R] bitmap .tif in colors

2009-02-18 Thread Lauri Nikkinen
Thanks. I upgraded to R 2.8.1 and tried

tiff(filename = volc.tif, width=600, height=400, compression =
none, bg = white, res = 300)
image(t(volcano)[ncol(volcano):1,])
dev.off()

but this produces error

Error in plot.new() : figure margins too large

How this should be modified to produce a decent-sized graph?

Regards,
Lauri

2009/2/18 Uwe Ligges lig...@statistik.tu-dortmund.de:


 Lauri Nikkinen wrote:

 Hello,

 How to produce .tif graphic in colors using bitmap function?

 e.g this produces figure in grayscale

 bitmap(file=volc.tif, type = tifflzw, res = 300)
 image(t(volcano)[ncol(volcano):1,])
 dev.off()

 Why not upgrade R and use the tiff() device?

 Uwe Ligges




 I'm using Windows XP and ghostscript.

 R.Version()

 $platform
 [1] i386-pc-mingw32

 $arch
 [1] i386

 $os
 [1] mingw32

 $system
 [1] i386, mingw32

 $status
 [1] 

 $major
 [1] 2

 $minor
 [1] 7.1

 $year
 [1] 2008

 $month
 [1] 06

 $day
 [1] 23

 $`svn rev`
 [1] 45970

 $language
 [1] R

 $version.string
 [1] R version 2.7.1 (2008-06-23)

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


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


Re: [R] Help with rgl

2009-02-18 Thread Iuri Gavronski
The funniest part is that we are close to carnival in Brazil...
vacation time... more than 30C... and I am the one to try to get back
to the track...

Any clue on how to rotate the object? Examples?

Also, still on the same object. If I change zoom, position, etc. with
the mouse, where to query this information, for reproducing the same
image later on?

Best,

Iuri.

On Wed, Feb 18, 2009 at 6:56 AM, Uwe Ligges
lig...@statistik.tu-dortmund.de wrote:


 Yihui Xie wrote:

 Chinese extend a helping hand to Russians who happen to be in Brazil
 about a package written in Germany, which gladdened an American.
 Trotsky would be even more proud  -- and amazed!! :-)



 Please note that rgl is maintained by a Canadian and two others (O. Nenadić
 and W. Zucchini) who, I guess, are from different nationalities as well have
 been involved in first versions of OpenGL interfaces.

 Best,
 Uwe Ligges



 Regards,
 Yihui
 --
 Yihui Xie xieyi...@gmail.com
 Phone: +86-(0)10-82509086 Fax: +86-(0)10-82509086
 Mobile: +86-15810805877
 Homepage: http://www.yihui.name
 School of Statistics, Room 1037, Mingde Main Building,
 Renmin University of China, Beijing, 100872, China



 On Wed, Feb 18, 2009 at 11:07 AM, roger koenker
 ro...@ysidro.econ.uiuc.edu wrote:

 Why I love R  [Number  6]:

 Chinese  extend a helping hand to Russians who happen to be in Brazil
 about a package written in Germany.   Trotsky would be proud  -- and
 amazed!

 url:www.econ.uiuc.edu/~rogerRoger Koenker
 email   rkoen...@uiuc.edu   Department of Economics
 vox:217-333-4558University of Illinois
 fax:217-244-6678Champaign, IL 61820


 On Feb 17, 2009, at 8:37 PM, Yihui Xie wrote:

 (1) you'll need ImageMagick installed to use the command convert to
 convert image sequences into GIF animations; see ?movie3d
 (2) viewport is read only!! see ?open3d carefully

 Regards,
 Yihui
 --
 Yihui Xie xieyi...@gmail.com
 Phone: +86-(0)10-82509086 Fax: +86-(0)10-82509086
 Mobile: +86-15810805877
 Homepage: http://www.yihui.name
 School of Statistics, Room 1037, Mingde Main Building,
 Renmin University of China, Beijing, 100872, China



 On Tue, Feb 17, 2009 at 2:45 AM, Iuri Gavronski i...@ufrgs.br wrote:

 Hi,

 I don't know much about the RGL package, and I have read the
 documentation and tried some parameters, with no luck... I would like
 to generate a movie from a 3D object (code below), where the vortex A
 is closer to the observer, and then the object rotates and the B
 vortex gets closer. I would like to capture this movie to a file.

 By the way, I am not being able to insert unicode text with text3d.

 rgl 0.82, R 2.8.1, Windows Vista.

 Any help would be appreciated.

 Code follows:

 library(rgl)
 open3d()

 coord.1=c(0,100,0)
 coord.2=c(100,100,0)
 coord.3=c(100,0,0)
 coord.4=c(0,0,0)
 coord.5=c(50,50,70)

 pyrcolor=red
 triangles3d(rbind(coord.1,coord.4,coord.5),color=pyrcolor)
 triangles3d(rbind(coord.1,coord.2,coord.5),color=pyrcolor)
 triangles3d(rbind(coord.2,coord.3,coord.5),color=pyrcolor)
 triangles3d(rbind(coord.3,coord.4,coord.5),color=pyrcolor)
 quads3d(rbind(coord.1,coord.2,coord.3,coord.4),color=pyrcolor)

 vertices = LETTERS[1:5]
 text3d(coord.1,text=vertices[1],adj=1,color=blue)
 text3d(coord.2,text=vertices[2],adj=0,color=blue)
 text3d(coord.3,text=vertices[3],adj=0,color=blue)
 text3d(coord.4,text=vertices[4],adj=1,color=blue)
 text3d(coord.5,text=vertices[5],adj=0,color=blue)

 # couldn't make this work...
 #open3d(viewport=c(0,0,686,489))
 #par3d(zoom = 1.157625)

 filename = piramide.png
 rgl.snapshot(filename)

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


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

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


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

2009-02-18 Thread Giovanni Petris

 Let Y be a normal multivariate function. For example, let Y have 4
 dimensions. I want to calculate
 
 P(Y1  Z1, Y2  Z2, Y3  Z3, Y4  Z4).
 
 There are R functions to do the calculation if all the inequalities
 are of the type  (the cdf). But is there an R function where the

The cdf, and some elementary algebra, is enough to compute the
probability you are interested in.

 two types of inequalities ( and ) can be mixed? (The user would
 have to specify the set of indexes with inequalities of the type )

Giovanni

-- 

Giovanni Petris  gpet...@uark.edu
Associate Professor
Department of Mathematical Sciences
University of Arkansas - Fayetteville, AR 72701
Ph: (479) 575-6324, 575-8630 (fax)
http://definetti.uark.edu/~gpetris/

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

2009-02-18 Thread Uwe Ligges



Lauri Nikkinen wrote:

Thanks. I upgraded to R 2.8.1 and tried

tiff(filename = volc.tif, width=600, height=400, compression =
none, bg = white, res = 300)
image(t(volcano)[ncol(volcano):1,])
dev.off()

but this produces error

Error in plot.new() : figure margins too large

How this should be modified to produce a decent-sized graph?

Regards,
Lauri



Try a somewhat lower resolution or reduce the margins:
par(mar=c())

Uwe Ligges




2009/2/18 Uwe Ligges lig...@statistik.tu-dortmund.de:


Lauri Nikkinen wrote:

Hello,

How to produce .tif graphic in colors using bitmap function?

e.g this produces figure in grayscale

bitmap(file=volc.tif, type = tifflzw, res = 300)
image(t(volcano)[ncol(volcano):1,])
dev.off()

Why not upgrade R and use the tiff() device?

Uwe Ligges





I'm using Windows XP and ghostscript.


R.Version()

$platform
[1] i386-pc-mingw32

$arch
[1] i386

$os
[1] mingw32

$system
[1] i386, mingw32

$status
[1] 

$major
[1] 2

$minor
[1] 7.1

$year
[1] 2008

$month
[1] 06

$day
[1] 23

$`svn rev`
[1] 45970

$language
[1] R

$version.string
[1] R version 2.7.1 (2008-06-23)

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


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


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


Re: [R] Help with rgl

2009-02-18 Thread Duncan Murdoch

On 18/02/2009 10:00 AM, Iuri Gavronski wrote:

The funniest part is that we are close to carnival in Brazil...
vacation time... more than 30C... and I am the one to try to get back
to the track...

Any clue on how to rotate the object? Examples?


example(spin3d)



Also, still on the same object. If I change zoom, position, etc. with
the mouse, where to query this information, for reproducing the same
image later on?


See ?par3d.  When you release the mouse, the userMatrix is updated to 
reflect the current position.  You may also have changed scale and 
projMatrix.


Duncan Murdoch



Best,

Iuri.

On Wed, Feb 18, 2009 at 6:56 AM, Uwe Ligges
lig...@statistik.tu-dortmund.de wrote:


Yihui Xie wrote:

Chinese extend a helping hand to Russians who happen to be in Brazil
about a package written in Germany, which gladdened an American.
Trotsky would be even more proud  -- and amazed!! :-)



Please note that rgl is maintained by a Canadian and two others (O. Nenadić
and W. Zucchini) who, I guess, are from different nationalities as well have
been involved in first versions of OpenGL interfaces.

Best,
Uwe Ligges




Regards,
Yihui
--
Yihui Xie xieyi...@gmail.com
Phone: +86-(0)10-82509086 Fax: +86-(0)10-82509086
Mobile: +86-15810805877
Homepage: http://www.yihui.name
School of Statistics, Room 1037, Mingde Main Building,
Renmin University of China, Beijing, 100872, China



On Wed, Feb 18, 2009 at 11:07 AM, roger koenker
ro...@ysidro.econ.uiuc.edu wrote:

Why I love R  [Number  6]:

Chinese  extend a helping hand to Russians who happen to be in Brazil
about a package written in Germany.   Trotsky would be proud  -- and
amazed!

url:www.econ.uiuc.edu/~rogerRoger Koenker
email   rkoen...@uiuc.edu   Department of Economics
vox:217-333-4558University of Illinois
fax:217-244-6678Champaign, IL 61820


On Feb 17, 2009, at 8:37 PM, Yihui Xie wrote:


(1) you'll need ImageMagick installed to use the command convert to
convert image sequences into GIF animations; see ?movie3d
(2) viewport is read only!! see ?open3d carefully

Regards,
Yihui
--
Yihui Xie xieyi...@gmail.com
Phone: +86-(0)10-82509086 Fax: +86-(0)10-82509086
Mobile: +86-15810805877
Homepage: http://www.yihui.name
School of Statistics, Room 1037, Mingde Main Building,
Renmin University of China, Beijing, 100872, China



On Tue, Feb 17, 2009 at 2:45 AM, Iuri Gavronski i...@ufrgs.br wrote:

Hi,

I don't know much about the RGL package, and I have read the
documentation and tried some parameters, with no luck... I would like
to generate a movie from a 3D object (code below), where the vortex A
is closer to the observer, and then the object rotates and the B
vortex gets closer. I would like to capture this movie to a file.

By the way, I am not being able to insert unicode text with text3d.

rgl 0.82, R 2.8.1, Windows Vista.

Any help would be appreciated.

Code follows:

library(rgl)
open3d()

coord.1=c(0,100,0)
coord.2=c(100,100,0)
coord.3=c(100,0,0)
coord.4=c(0,0,0)
coord.5=c(50,50,70)

pyrcolor=red
triangles3d(rbind(coord.1,coord.4,coord.5),color=pyrcolor)
triangles3d(rbind(coord.1,coord.2,coord.5),color=pyrcolor)
triangles3d(rbind(coord.2,coord.3,coord.5),color=pyrcolor)
triangles3d(rbind(coord.3,coord.4,coord.5),color=pyrcolor)
quads3d(rbind(coord.1,coord.2,coord.3,coord.4),color=pyrcolor)

vertices = LETTERS[1:5]
text3d(coord.1,text=vertices[1],adj=1,color=blue)
text3d(coord.2,text=vertices[2],adj=0,color=blue)
text3d(coord.3,text=vertices[3],adj=0,color=blue)
text3d(coord.4,text=vertices[4],adj=1,color=blue)
text3d(coord.5,text=vertices[5],adj=0,color=blue)

# couldn't make this work...
#open3d(viewport=c(0,0,686,489))
#par3d(zoom = 1.157625)

filename = piramide.png
rgl.snapshot(filename)


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

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

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



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


__
R-help@r-project.org mailing list

Re: [R] bitmap .tif in colors

2009-02-18 Thread Prof Brian Ripley

On Wed, 18 Feb 2009, Lauri Nikkinen wrote:


Thanks. I upgraded to R 2.8.1 and tried

tiff(filename = volc.tif, width=600, height=400, compression =
none, bg = white, res = 300)
image(t(volcano)[ncol(volcano):1,])
dev.off()

but this produces error

Error in plot.new() : figure margins too large

How this should be modified to produce a decent-sized graph?


Well, thae is a 2 by 1.3 image, so the pointsize is way too large. 
Increase the dimensions or decrease the resolution or decreaase the 
pointsize.


(As a warning, there was a 'grid' bug that affected some versions of 
tiff, png etc in 2.8.0 and 2.8.1 when plotting lattice plots at 
non-default resolutions.  The NEWS item is


o   grid-based plots no longer reset the base text size to the
default 96dpi in cairo-based bitmap devices.

for 2.8.1 patched.  But that produces too small not too large text.)



Regards,
Lauri

2009/2/18 Uwe Ligges lig...@statistik.tu-dortmund.de:



Lauri Nikkinen wrote:


Hello,

How to produce .tif graphic in colors using bitmap function?

e.g this produces figure in grayscale

bitmap(file=volc.tif, type = tifflzw, res = 300)
image(t(volcano)[ncol(volcano):1,])
dev.off()


Why not upgrade R and use the tiff() device?

Uwe Ligges





I'm using Windows XP and ghostscript.


R.Version()


$platform
[1] i386-pc-mingw32

$arch
[1] i386

$os
[1] mingw32

$system
[1] i386, mingw32

$status
[1] 

$major
[1] 2

$minor
[1] 7.1

$year
[1] 2008

$month
[1] 06

$day
[1] 23

$`svn rev`
[1] 45970

$language
[1] R

$version.string
[1] R version 2.7.1 (2008-06-23)

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




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



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

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


Re: [R] Barplot with Sorted X-Axis

2009-02-18 Thread Gundala Viswanath
Hi Jim,


 or sorting the columns of the above table if that is what you are using to
 plot.

How do you do that? Yes I am using that data exactly for the plotting.

- GV.



 Jim



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


Re: [R] bitmap .tif in colors

2009-02-18 Thread Lauri Nikkinen
Thanks Prof Ripley, now I understood.

tiff(filename = volc.tif, width=600, height=400, compression =
none, bg = white, res = 300, pointsize=3)
par(mar=c(3,3,2,2), cex=1)
image(t(volcano)[ncol(volcano):1,], xaxt=n, yaxt=n)
axis(1, at=seq(0, 1, 0.1), cex.axis=0.8, tick=T)
axis(2, at=seq(0, 1, 0.1), cex.axis=0.8, tick=T)
dev.off()

Regards,
Lauri

2009/2/18 Prof Brian Ripley rip...@stats.ox.ac.uk:
 On Wed, 18 Feb 2009, Lauri Nikkinen wrote:

 Thanks. I upgraded to R 2.8.1 and tried

 tiff(filename = volc.tif, width=600, height=400, compression =
 none, bg = white, res = 300)
 image(t(volcano)[ncol(volcano):1,])
 dev.off()

 but this produces error

 Error in plot.new() : figure margins too large

 How this should be modified to produce a decent-sized graph?

 Well, thae is a 2 by 1.3 image, so the pointsize is way too large.
 Increase the dimensions or decrease the resolution or decreaase the
 pointsize.

 (As a warning, there was a 'grid' bug that affected some versions of tiff,
 png etc in 2.8.0 and 2.8.1 when plotting lattice plots at non-default
 resolutions.  The NEWS item is

o   grid-based plots no longer reset the base text size to the
default 96dpi in cairo-based bitmap devices.

 for 2.8.1 patched.  But that produces too small not too large text.)


 Regards,
 Lauri

 2009/2/18 Uwe Ligges lig...@statistik.tu-dortmund.de:


 Lauri Nikkinen wrote:

 Hello,

 How to produce .tif graphic in colors using bitmap function?

 e.g this produces figure in grayscale

 bitmap(file=volc.tif, type = tifflzw, res = 300)
 image(t(volcano)[ncol(volcano):1,])
 dev.off()

 Why not upgrade R and use the tiff() device?

 Uwe Ligges




 I'm using Windows XP and ghostscript.

 R.Version()

 $platform
 [1] i386-pc-mingw32

 $arch
 [1] i386

 $os
 [1] mingw32

 $system
 [1] i386, mingw32

 $status
 [1] 

 $major
 [1] 2

 $minor
 [1] 7.1

 $year
 [1] 2008

 $month
 [1] 06

 $day
 [1] 23

 $`svn rev`
 [1] 45970

 $language
 [1] R

 $version.string
 [1] R version 2.7.1 (2008-06-23)

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


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


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


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


Re: [R] alpha shape function

2009-02-18 Thread Yihui Xie
Hi,

If the convex hull for *all* the data points is not ideal enough, is
it feasible to break the data into small subsets using clustering
methods such as kmeans() and compute the convex hull for each cluster?
Finally we are able to know the borders of all clusters using
chull(); I don't know how difficult it will be to find an exact
solution to your problem in the future computation, but I think there
can be good enough approximations.

For example, you may choose a proper 'k' for the k-means clustering:

##
set.seed(1234)
devAskNewPage(ask = TRUE)
par(pch = 20)
dat = iris[, 1:2]
n = nrow(dat)
for (k in 2:30) {
ch = integer()
cl = kmeans(dat, k, 50)$cluster
plot(dat, main = paste(k =, k))
for (i in unique(cl)) {
idx = chull(tmp - dat[cl == i, ])
ch = c(ch, as.integer(rownames(tmp[idx, ])))
polygon(tmp[idx, ], border = NA, col = rgb(0, 0, 0, 0.2))
}
plot(dat, main = paste(Polygon shape when k =, k))
polygon(dat[ch, ], col = rgb(0, 0, 0, 0.2))  # need to be ordered
}
##

One critical problem I have not solved in the above code, I think, is
the ordering of all the border points, so the last whole polygon looks
weird...

Regards,
Yihui
--
Yihui Xie xieyi...@gmail.com
Phone: +86-(0)10-82509086 Fax: +86-(0)10-82509086
Mobile: +86-15810805877
Homepage: http://www.yihui.name
School of Statistics, Room 1037, Mingde Main Building,
Renmin University of China, Beijing, 100872, China



On Wed, Feb 18, 2009 at 9:46 PM, roger koenker rkoen...@uiuc.edu wrote:
 As it happens, I have also been looking into this.  I began by considering
 Ken Clarkson's hull:  http://www.netlib.org/voronoi/hull.html  but
 eventually
 discovered that its alpha shapes don't seem to treat holes in regions, only
 simply connected regions.  (I would be happy to hear to the contrary, if
 someone has other experience.)  There is a nice matlab implementation
 http://www.mathworks.com/matlabcentral/fileexchange/6760 which I've
 also experimented with using R.matlab, but  this is still very early days.
 The matlab version is only 2d, whereas Clarkson does moderate d   which
 extends at least to 3d.
 Given tripack, it seems like alpha-shapes shouldn't be such a big
 enterprise, and
 might  make a nice project for someone with an interest in computational
 geometry.   Hint, hint.  Nudge, Nudge.

 url:www.econ.uiuc.edu/~rogerRoger Koenker
 emailrkoen...@uiuc.eduDepartment of Economics
 vox: 217-333-4558University of Illinois
 fax:   217-244-6678Champaign, IL 61820



 On Feb 18, 2009, at 7:20 AM, Pedroso MOACIR wrote:

 Hi all,

 I want to approximate te shape of an area defined by a set of points.
 The convex hull is not good enough, but I think that an alpha shape
 would be fine. I did an RSiteSearch(),  google search, RSeek.org search,
 looked at the CRAN Views, but was unable do find a function in R that
 computes the alpha shape.  Does anyone know if there is such a function
 in R?

 Theank you very much.

 Moacir Pedroso
 Embrapa - Brazil


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


Re: [R] Chromatogram deconvolution and peak matching

2009-02-18 Thread Michael Lawrence
Just to be sure you're aware, there are packages for chromatograpy and mass
spec data in Bioconductor. Like xcms. Don't think any will directly address
your problem, but they might be useful.

Michael

On Tue, Feb 17, 2009 at 5:44 AM, bartjoosen bartjoo...@hotmail.com wrote:


 Hi,

 I'm trying to match peaks between chromatographic runs.
 I'm able to match peaks when they are chromatographed with the same method,
 but not when there are different methods are used and spectra comes in to
 play.

 While searching I found the ALS package which should be usefull for my
 application, but I couldn't figure it out.

 I made some dummy chroms with R, which mimic my actual datasets, to play
 with, but after looking at the manuals of ALS, I'm affraid I can't get the
 job done. Can someone put me on the right way?

 Here is my code to generate the dummy chroms, which also plots the 2 chroms
 and the spectra of the 3 peaks:

 #2D chromatogram generation
 par(mfrow=c(3,1))
 time - seq(0,20,by=0.05)
 f - function(x,rt) dnorm((x-rt),mean=0,sd=rt/35)
 c1 - f(time,6.1)
 c2 - f(time,5.6)
 c3 - f(time,15)
 plot(c1+c2+c3~time,type=l,main=chrom1)

 #spectrum generation
 spectra - function(x,a,b,c,d,e) a + b*(x-e) + c*((x-e)^2) + d*((x-e)^3)
 x - 220:300
 s1 - spectra(x,(-194.2),2.386,(-0.009617),(1.275e-05),0)
 s2 - spectra(x,(-1.054e02),1.3,(-5.239e-03),(6.927e-06),-20)
 s3 - spectra(x,(-194.2),2.386,(-0.009617),(1.275e-05),20)

 chrom1.tot -
 data.frame(time,outer(c1,s1,*)+outer(c2,s2,*)+outer(c2,s2,*))
 names(chrom.tot)[-1] - x

 #generation of chromatogram 2
 c1 - f(time,2.1)
 c2 - f(time,4)
 c3 - f(time,8)
 plot(c1+c2+c3~time,type=l,main=chrom2)

 chrom2.tot -
 data.frame(time,outer(c1,s1,*)+outer(c2,s2,*)+outer(c2,s2,*))
 names(chrom.tot)[-1] - x

 plot(s1~x,type=l,main=spectra)
 lines(s2~x,col=2)
 lines(s3~x,col=3)

 Thanks for your time

 Kind Regards

 Bart
 --
 View this message in context:
 http://www.nabble.com/Chromatogram-deconvolution-and-peak-matching-tp22057592p22057592.html
 Sent from the R help mailing list archive at Nabble.com.

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


[[alternative HTML version deleted]]

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


Re: [R] cumsum vs. sum

2009-02-18 Thread Martin Maechler
 SM == Stavros Macrakis macra...@alum.mit.edu
 on Wed, 18 Feb 2009 10:00:40 -0500 writes:

SM Nice!  Glad to hear it. It sounds as though it is still possible for
SM cumsum(x)[length(x)] to not be exactly equal to sum, though?

Well, possible, probably yes, platform-dependently; 
However I vaguely remember that I didn't see one such case in the few
experiments I did.

Martin

SM On Wed, Feb 18, 2009 at 8:03 AM, Martin Maechler
SM maech...@stat.math.ethz.ch wrote:
SM ...
 o   cumsum(x) and cumprod(x) for double precision x now use a long
 double accumulator where available and so more closely match
 sum() and prod() in potentially being more accurate.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] multidimensional scaling with long form data

2009-02-18 Thread Kirsten Beyer
I have a dissimilarity dataset with the form:

1  1  dissimilarity value
1  2  ...
1  3
1  4
2  2
2  3
2  4
...

I would like to do nonmetric multidimensional scaling with this data, but I
am having trouble using this format.  I would like to either find a function
that accepts this format or find a way to easily convert this format to a
matrix for use with existing functions.

Thanks!

[[alternative HTML version deleted]]

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


[R] March ** R ** course in New York City *** by XLSolutions Corp

2009-02-18 Thread s...@xlsolutions-corp.com
XLSolutions Corporation (www.xlsolutions-corp.com) is proud to announce
our*** R/Splus Fundamentals and Programming Techniques and  R Advanced
Programming***courses at USA locations for March - April 2009.


* New York City  ** March 19-20, 2009

R/Splus Fundamentals and Programming Techniques
http://www.xlsolutions-corp.com/rplus.asp

Looking for   R/Splus Advanced Programming  ?

http://www.xlsolutions-corp.com/rplus.asp 

* San Francisco  ** April 27-28, 2009
* Boston ** April 22-23, 2009
* New York City  ** April 20-21, 2009


Ask for group discount and reserve your seat Now - Earlybird Rates.
Payment due after the class! Email Sue Turner:  s...@xlsolutions-corp.com

Phone: 206-686-1578


Please let us know if you and your colleagues are interested in this
class to take advantage of group discount. Register now to secure your
seat!

Cheers,
Elvis Miller, PhD
Manager Training.
XLSolutions Corporation
206 686 1578
www.xlsolutions-corp.com
el...@xlsolutions-corp.com

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


Re: [R] cumsum vs. sum

2009-02-18 Thread Stavros Macrakis
Hmm.  Why not use the same method to guarantee the same result?  Or at
least document the possibility that cumsum(x)[length(x)] != sum(x)...
that seems like an easy trap to fall into.

  -s

On Wed, Feb 18, 2009 at 11:39 AM, Martin Maechler
maech...@stat.math.ethz.ch wrote:
 SM == Stavros Macrakis macra...@alum.mit.edu
 on Wed, 18 Feb 2009 10:00:40 -0500 writes:

SM Nice!  Glad to hear it. It sounds as though it is still possible for
SM cumsum(x)[length(x)] to not be exactly equal to sum, though?

 Well, possible, probably yes, platform-dependently;
 However I vaguely remember that I didn't see one such case in the few
 experiments I did.

 Martin

SM On Wed, Feb 18, 2009 at 8:03 AM, Martin Maechler
SM maech...@stat.math.ethz.ch wrote:
SM ...
 o   cumsum(x) and cumprod(x) for double precision x now use a long
 double accumulator where available and so more closely match
 sum() and prod() in potentially being more accurate.


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


Re: [R] Barplot with Sorted X-Axis

2009-02-18 Thread Greg Snow
Can you show us the code used to get the data?

The usual methods that I can think of would have sorted the columns correctly 
for you.  The fact that this is not the case indicates that you are using a 
different method, or doing something that looses the information along the way. 
 If you show us the steps you are taking, then we can help track down where the 
problem is occurring.

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
 project.org] On Behalf Of Gundala Viswanath
 Sent: Wednesday, February 18, 2009 8:25 AM
 To: Jim Lemon
 Cc: r-h...@stat.math.ethz.ch
 Subject: Re: [R] Barplot with Sorted X-Axis
 
 Hi Jim,
 
 
  or sorting the columns of the above table if that is what you are
 using to
  plot.
 
 How do you do that? Yes I am using that data exactly for the plotting.
 
 - GV.
 
 
 
  Jim
 
 
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] Counting/processing a character vector

2009-02-18 Thread Gavin Simpson
To answer my own post, and for the archives (hopefully not that anyone
has to repeat what I had to do ;-), after much hair-pulling , frowning
at the screen and general dumb headedness the following slab of R code
achieves the results I wanted. It isn't elegant but does a job.

msr - function(x) {
res - numeric(length = length(levels(x$id)))
names(res) - levels(x$id)
for(site in levels(x$id)) {
## subset just data for this site
DAT - x[x$id == site, ]

## split out the spp and count the ones not 00
spp - with(DAT, substr(sppcode, 7, 8))
spp.counted - which(spp != 00)
spp - with(DAT[spp.counted, ], sppcode)
SPP - length(spp.counted)
DAT - DAT[-spp.counted, ]

## drop genera for spp already counted
want - with(DAT, which(substr(sppcode, 1, 6) %in% substr(spp, 1, 6)))
if(length(want) = 1) {
DAT - DAT[-want, ]
}

## now count genera remaining not 00
gen - with(DAT, substr(sppcode, 5, 6))
gen.counted - which(gen != 00)
gen - with(DAT[gen.counted, ], sppcode)
GEN - length(gen.counted)
DAT - DAT[-gen.counted, ]

## drop families already in spp, or genera that we already caught
want1 - with(DAT, which(substr(sppcode, 1, 4) %in% substr(spp, 1, 4)))
want2 - with(DAT, which(substr(sppcode, 1, 4) %in% substr(gen, 1, 4)))
if(length(want - unique(c(want1, want2))) = 1) {
DAT - DAT[-want, ]
}

## count remaining families != 00
fam - with(DAT, substr(sppcode, 3, 4))
fam.counted - which(fam != 00)
fam - with(DAT[fam.counted, ], sppcode)
FAM - length(fam.counted)
DAT - DAT[-fam.counted, ]

## drop orders for families already counted
want1 - with(DAT, which(substr(sppcode, 1, 2) %in% substr(spp, 1, 2)))
want2 - with(DAT, which(substr(sppcode, 1, 2) %in% substr(gen, 1, 2)))
want3 - with(DAT, which(substr(sppcode, 1, 2) %in% substr(fam, 1, 2)))
if(length(want - unique(c(want1, want2, want3))) = 1) {
DAT - DAT[-want, ]
}

## count the orders remaining
ORD - nrow(DAT)

## populate return vector
res[site] - SPP + GEN + FAM + ORD
}
return(res)
}
## read example csv data
dat - 
read.csv(url(http://www.homepages.ucl.ac.uk/~ucfagls/files/example_data.csv;),
colClasses = c(factor,character,numeric))
## show the data
head(dat, n = 10)
## split out the four levels of categorisation:
dat2 - data.frame(dat,
   order = with(dat, substr(sppcode, 1, 2)),
   family = with(dat, substr(sppcode, 3, 4)),
   genus = with(dat, substr(sppcode, 5, 6)),
   species = with(dat, substr(sppcode, 7, 8)))

msr(dat)

Yields:
 msr(dat)
10307 10719 10786 
   154035

Which are correct.

G

On Wed, 2009-02-18 at 13:37 +, Gavin Simpson wrote:
 Dear List,
 
 I have a data set stored in the following format:
 
  head(dat, n = 10)
   id  sppcode abundance
 1  10307 1000 1
 2  10307 16220602 2
 3  10307 2000 5
 4  10307 2011 2
 5  10307 2400 1
 6  10307 402183
 7  10307 4021010245
 8  10307 4514 1
 9  10307 4563 1
 10 10307 4563060041
  str(dat)
 'data.frame': 111 obs. of  3 variables:
  $ id   : Factor w/ 3 levels 10307,10719,..: 1 1 1 1 1 1 1 1 1 1 ...
  $ sppcode  : chr  1000 16220602 2000 2011 ...
  $ abundance: num  1 2 5 2 1 83 45 1 1 41 ...
 
 that represent counts of species, recorded with a particular coding
 system. The abundance column is not needed for this particular
 operation, but is present in the data files.
 
 I am interested in counting entries (rows) in the sppcode component of
 dat. The sppcode takes a particular format: Order Family Genus Species,
 with 2 alphanumeric digits allocated for each level of the hierarchy. I
 want to know how many species there are in each site (the id factor),
 but I should only count a higher level entry if there are no lower
 levels present.
 
 For example, for the above data excerpt (just the headed rows), I would
 count the following rows:
 
 1000
 16220602
 2011
 2400
 40320203
 4514
 45630600 == 7 species present.
 
 To be more specific, I don't count 4563 (row 9) because there exists
 a sppcode for this 'id' where either of the next two pairs of digits are
 not all 0's.
 
 In words, I want to count all rows where WWXXYYZZ are ZZ != 00, then,
 rows where ZZ == 00 only if the WWXXYY combination has not been counted
 yet.
 
 An example data set has been placed in my University web space and can
 be read into R with the following:
 
 ## read example csv data
 dat - 
 read.csv(url(http://www.homepages.ucl.ac.uk/~ucfagls/files/example_data.csv;),
 colClasses = c(factor,character,numeric))
 ## show the 

Re: [R] How to create sequence of constant time interval

2009-02-18 Thread Gabor Grothendieck
For version 2.3-30 of chron which just appeared on CRAN this can
be simplified to:

library(chron)
tt - times(0:47/48)
tt
chron(1/1/09, tt) # no rep needed

On Mon, Feb 16, 2009 at 6:04 AM, Gabor Grothendieck
ggrothendi...@gmail.com wrote:
 Try this (and see R News 4/1 for more).

 library(chron)
 tt - times(0:47/48)
 tt
  [1] 00:00:00 00:30:00 01:00:00 01:30:00 02:00:00 02:30:00 03:00:00
 03:30:00 04:00:00 04:30:00 05:00:00 05:30:00 06:00:00 06:30:00
 07:00:00 07:30:00
 [17] 08:00:00 08:30:00 09:00:00 09:30:00 10:00:00 10:30:00 11:00:00
 11:30:00 12:00:00 12:30:00 13:00:00 13:30:00 14:00:00 14:30:00
 15:00:00 15:30:00
 [33] 16:00:00 16:30:00 17:00:00 17:30:00 18:00:00 18:30:00 19:00:00
 19:30:00 20:00:00 20:30:00 21:00:00 21:30:00 22:00:00 22:30:00
 23:00:00 23:30:00

 chron(rep(1/1/09, length = length(tt)), tt)
  [1] (01/01/09 00:00:00) (01/01/09 00:30:00) (01/01/09 01:00:00)
 (01/01/09 01:30:00) (01/01/09 02:00:00) (01/01/09 02:30:00) (01/01/09
 03:00:00)
  [8] (01/01/09 03:30:00) (01/01/09 04:00:00) (01/01/09 04:30:00)
 (01/01/09 05:00:00) (01/01/09 05:30:00) (01/01/09 06:00:00) (01/01/09
 06:30:00)
 [15] (01/01/09 07:00:00) (01/01/09 07:30:00) (01/01/09 08:00:00)
 (01/01/09 08:30:00) (01/01/09 09:00:00) (01/01/09 09:30:00) (01/01/09
 10:00:00)
 [22] (01/01/09 10:30:00) (01/01/09 11:00:00) (01/01/09 11:30:00)
 (01/01/09 12:00:00) (01/01/09 12:30:00) (01/01/09 13:00:00) (01/01/09
 13:30:00)
 [29] (01/01/09 14:00:00) (01/01/09 14:30:00) (01/01/09 15:00:00)
 (01/01/09 15:30:00) (01/01/09 16:00:00) (01/01/09 16:30:00) (01/01/09
 17:00:00)
 [36] (01/01/09 17:30:00) (01/01/09 18:00:00) (01/01/09 18:30:00)
 (01/01/09 19:00:00) (01/01/09 19:30:00) (01/01/09 20:00:00) (01/01/09
 20:30:00)
 [43] (01/01/09 21:00:00) (01/01/09 21:30:00) (01/01/09 22:00:00)
 (01/01/09 22:30:00) (01/01/09 23:00:00) (01/01/09 23:30:00)


 On Mon, Feb 16, 2009 at 5:00 AM, Suresh_FSFM suresh.ghals...@gmail.com 
 wrote:

 Dear R-Experts,

 seek your help.

 There are two parts I want to deal with.
 1)
 I want to create a time interval of say, 30 minutes starting from 00:00:00
 hrs
 Thus at the end, I want to create sequence:
 00:00:00
 00:30:00
 01:00:00
 01:30:00
 ..
 ..
 How to do so ?
 Later, I want to change the time-increment value in a variable and changing
 the value of this variable, I would like to create new sequence with that
 time increment. How to use seq() correctly?

 2)
 I have a date stored in one variable. Say 2009-01-01
 How can I combine this date with each time interval in the first part? Will
 concatenate work?
 so at the end, I would like to have:

 2009-01-01 00:00:00
 2009-01-01 00:30:00
 2009-01-01 01:00:00
 2009-01-01 01:30:00
 ...
 ...

 Thank you in advance.






 --
 View this message in context: 
 http://www.nabble.com/How-to-create-sequence-of-constant-time-interval-tp22034441p22034441.html
 Sent from the R help mailing list archive at Nabble.com.

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



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


Re: [R] cumsum vs. sum

2009-02-18 Thread Duncan Murdoch

On 18/02/2009 12:41 PM, Stavros Macrakis wrote:

Hmm.  Why not use the same method to guarantee the same result?  Or at
least document the possibility that cumsum(x)[length(x)] != sum(x)...
that seems like an easy trap to fall into.


Assuming equality of floating point numbers computed by two different 
paths is always a trap.


R doesn't try to obtain results that are equal to the last bit in other 
circumstances; why should it do so here?  For example, one somewhat 
controversial choice in R is to use 64 bit precision in intermediate 
computations when available, rather than rounding everything to 52 bits 
as it does when stored to memory in doubles.  This means that the value 
you get is likely to be closer to the truth than if you did the rounding 
earlier, but it is also subject to change according to optimization 
level, compiler version, etc.


Duncan Murdoch



  -s

On Wed, Feb 18, 2009 at 11:39 AM, Martin Maechler
maech...@stat.math.ethz.ch wrote:

SM == Stavros Macrakis macra...@alum.mit.edu
on Wed, 18 Feb 2009 10:00:40 -0500 writes:

   SM Nice!  Glad to hear it. It sounds as though it is still possible for
   SM cumsum(x)[length(x)] to not be exactly equal to sum, though?

Well, possible, probably yes, platform-dependently;
However I vaguely remember that I didn't see one such case in the few
experiments I did.

Martin

   SM On Wed, Feb 18, 2009 at 8:03 AM, Martin Maechler
   SM maech...@stat.math.ethz.ch wrote:
   SM ...
o   cumsum(x) and cumprod(x) for double precision x now use a long
double accumulator where available and so more closely match
sum() and prod() in potentially being more accurate.



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


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


[R] Help on warning message from Neg. Binomial error during glm

2009-02-18 Thread Mahua Ghara
I am using glm.nb, a ~b*c ( b is categorical and c is continuous). when I
run this model I get the warning message:

Warning messages:
1: In theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
control$trace   :
  iteration limit reached
2: In theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
control$trace   :
  iteration limit reached

What does this mean?

-- 
Graduate student

[[alternative HTML version deleted]]

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


[R] R code compiled, assembled or interpreted?

2009-02-18 Thread francogrex

Hi all, do you know if an R program is compiled to machine language when
executed? And also is there any way to disassemble an R code/program: to see
how it is generating the machine instructions for the processor? Thanks
-- 
View this message in context: 
http://www.nabble.com/R-code-compiled%2C-assembled-or-interpreted--tp22079905p22079905.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] swich off printed info

2009-02-18 Thread robin

Dear R users,
I  use function kqr from package kernlab a large number of time and  
every time it is used it prints an info message which slows the  
process. Please note that it is not a warning message or an error  
message and that there is no info option in the function that could  
be set to FALSE.
How can I switch off this type of message ? I think of something  
similar to setting warns option to -1  or  similar to a function that  
could handle the message and throw it out  ( a sort of try function  
for non error messages ... )


Thank you in advance for your answer

Robin Girard

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Training nnet in two ways, trying to understand the performance difference - with (i hope!) commented, minimal, self-contained, reproducible code

2009-02-18 Thread Tony Breyal
hmm,  further investigation shows that two different fits are used.
Why did nnet decide to use different fits when the data is basically
the same (2 factors in nn1 and binary in nn2)?

# uses an entropy fit (maximum conditional likelihood)
 nn1
a 57-3-1 network with 178 weights
inputs: make address all num3d our over [etc...]
output(s): type
options were - entropy fitting  decay=0.1


# uses the default least squares fit
 nn2
a 57-3-1 network with 178 weights
inputs: make address all num3d our over [etc...]
output(s): as.numeric(type) - 1
options were - decay=0.1


again, many thanks for any help.
Tony

On 18 Feb, 11:40, Tony Breyal tony.bre...@googlemail.com wrote:
 Dear all,

 Objective: I am trying to learn about neural networks. I want to see
 if i can train an artificial neural network model to discriminate
 between spam and nonspam emails.

 Problem: I created my own model (example 1 below) and got an error of
 about 7.7%. I created the same model using the Rattle package (example
 2 below, based on rattles log script) and got a much better error of
 about 0.073%.

 Question 1: I don't understand why the rattle script gives a better
 result? I must therefore be doing something wrong in my own script
 (example 1) and would appreciate some insight  :-)

 Question 2: As rattle gives a much better result, i would be happy to
 use it's r-code instead of my own. How can I interpret it's
 predictions as either being either 'spam' or 'nonspam'? I have looked
 at the type='class' parameter in ?predict.nnet but it doesn't apply to
 this situation i believe.

 Below i give commented, minimal, self-contained and reproducible code.
 (if you ignore the output, it really is very few lines of code and
 therefore minimal i believe?)

 ## load library

 library(nnet)

 ## Load in spam dataset from package kernlab

 data(list = spam, package = kernlab)
 set.seed(42)
 my.sample - sample(nrow(spam), 3221)
 spam.train - spam[my.sample, ]
 spam.test - spam[-my.sample, ]

 ## Example 1 - my own code
 # train artificial neural network (nn1)( nn1 - nnet(type~., 
 data=spam.train, size=3, decay=0.1, maxit=1000) )

 # predict spam.test dataset on nn1 ( nn1.pr.test - predict(nn1, spam.test, 
 type='class') )

    [1] spam    spam    spam    spam    nonspam spam
 spam
    [etc...]
 # error matrix(nn1.test.tab-table(spam.test$type, nn1.pr.test, 
 dnn=c('Actual', 'Predicted')))

            Predicted
   Actual    nonspam spam
     nonspam     778   43
     spam           63    496
 # Calucate overall error percentage ~ 7.68%(nn1.test.perf - 100 * 
 (nn1.test.tab[2] + nn1.test.tab[3]) / sum(nn1.test.tab))

 [1] 7.68116

 ## Example 2 - code based on rattles log script
 # train artifical neural networknn2-nnet(as.numeric(type)-1~., 
 data=spam.train, size=3, decay=0.1, maxit=1000)

 # predict spam.test dataset on nn2.
 # ?predict.nnet does have the parameter type='class', but i can't use
 that here as an optionnn2.pr.test - predict(nn2, spam.test)

                [,1]
 3    0.984972396013
 4    0.931149225918
 10   0.930001139978
 13   0.923271300707
 21   0.102282256315
 [etc...]
 # error matrix( nn2.test.tab - round(100*table(nn2.pr.test, spam.test$type,

                             dnn=c(Predicted, Actual))/length
 (nn2.pr.test)) )
                                    Actual
   Predicted                    nonspam spam
     -0.741896935969825              0    0
     -0.706473834678304              0    0
     -0.595327594045746              0    0
   [etc...]
 # calucate overall error percentage. Am not sure how this line works
 tbh,
 # and i think it should be multiplied by 100. I got this from rattle's
 log script.(function(x){return((x[1,2]+x[2,1])/sum(x))})

             (table(nn2.pr.test, spam.test$type,  dnn=c(Predicted,
 Actual)))
 [1] 0.0007246377
 # i'm guessing the above should be ~0.072%

 I know the above probably seems complicated, but any help that can be
 offered would be much appreicated.

 Thank you kindly in advance,
 Tony

 OS = Windows Vista Ultimate, running R in admin mode sessionInfo()

 R version 2.8.1 (2008-12-22)
 i386-pc-mingw32

 locale:
 LC_COLLATE=English_United Kingdom.1252;LC_CTYPE=English_United Kingdom.
 1252;LC_MONETARY=English_United Kingdom.
 1252;LC_NUMERIC=C;LC_TIME=English_United Kingdom.1252

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

 other attached packages:
 [1] RGtk2_2.12.8     vcd_1.2-2        colorspace_1.0-0
 MASS_7.2-45      rattle_2.4.8     nnet_7.2-45

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

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

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

[R] auto.arima in forecasting package

2009-02-18 Thread emj83

I am using auto.arima to find the best arima model but am a little confused
by the output. I want to choose the best model using the BIC criteria.
This is my code (straightforward where a is the data)
auto.arima(a,d=0,D=0,max.p=5,max.q=5,max.P=0,max.Q=0,max.order=5,start.p=0,start.q=0,start.P=0,start.Q=0,ic=c(aic),
stationary=FALSE,stepwise=FALSE,trace=TRUE)

Part of the results I get back are:
 ARIMA(1,0,1) with zero mean : 1e+20
 ARIMA(1,0,1) with non-zero mean : -92.117
 ARIMA(1,0,2) with zero mean : 1e+20
 ARIMA(1,0,2) with non-zero mean : -101.8145
 ARIMA(1,0,3) with zero mean : 1e+20
 ARIMA(1,0,3) with non-zero mean : -110.5995

I am unsure what the values are after the colon. I thought it was the BIC
but it is found that the best model for the data is ARIMA(1,0,3) with
non-zero-mean and BIC= -91.42.

Could anyone tell me what the values are after the colon? I have tried
looking at the help page to no avail.

Thanks in advance Emma

-- 
View this message in context: 
http://www.nabble.com/auto.arima-in-forecasting-package-tp22083751p22083751.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] No results show up when running Rmdr

2009-02-18 Thread Andrew
Hi all,
When running Rmdr using the demo data file using the following
commands:

data(mdrdata)
cvk-10
nbr=2
res-rmdr(mdrdata,10,2, randomize=TRUE)


I could not find the statistical results, but like this:

[1] 1
 Cross Validation 1 Wed Feb 18 09:05:23 2009
The best set of loci is 13 17
 Cross Validation 2 Wed Feb 18 09:05:26 2009

Could you please tell me why and how to retrieve the results?

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] multidimensional scaling with long form data

2009-02-18 Thread Marcelino de la Cruz

This is my approach:

If  cosa is your data.frame . e.g.

 cosa
 i1 i2  dis
  [1,]  1  1 0.00
  [2,]  1  2 0.93
  [3,]  1  3 0.80
  [4,]  1  4 1.00
  [5,]  2  2 0.00
  [6,]  2  3 0.02
  [7,]  2  4 0.22
  [8,]  3  3 0.00
  [9,]  3  4 0.95
[10,]  4  4 0.00

# first crate a square matrix of  0´s, of the 
appropriate dimensions (in this example, 4)

pepe - matrix(0, nr=4, nc=4)

# then assign your long disimilarity data to trhe 
lower tree of the square matrix
# check the diag argument!

pepe[lower.tri(pepe, diag=T)] - cosa[,3]

# then transpose the matrix

pepe - t(pepe)

# and symmetrize the resulting matrix

library(calibrator)
pepe - symmetrize(pepe)

# finaly,  transform to a dist matrix:

pepe - as.dist (pepe)

HTH,

Marcelino




kirsten-be...@uiowa.edu wrote:

I have a dissimilarity dataset with the form:

1  1  dissimilarity value
1  2  ...
1  3
1  4
2  2
2  3
2  4
...

I would like to do nonmetric multidimensional scaling with this data, but I
am having trouble using this format.  I would like to either find a function
that accepts this format or find a way to easily convert this format to a
matrix for use with existing functions.

Thanks!








Marcelino de la Cruz Rot



Departamento de  Biología Vegetal

E.U.T.I. Agrícola

Universidad Politécnica de Madrid

28040-Madrid

Tel.: 91 336 54 35

Fax: 91 336 56 56

marcelino.delac...@upm.es

_
[[alternative HTML version deleted]]

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


[R] C# / R interface problem

2009-02-18 Thread jonboyGaTech

This is my situation:
I have a significant amount of data, and need to send it in pieces to R. I
need R to return certain parameters for further use.
I am sending files from C# (that are being queried from a database) into R. 
Currently I am trying to use the R(D)-Com package to figure out how to do
this.  Along with sending in the file(s) to R, I will be sending the
expressions for calculating distribution parameters in R as well.  I do not
really know how to go about doing this, and there doesn't appear to be much
literature online.  Please let me know if you have any suggestions, sample
code, references, etc.  

-- 
View this message in context: 
http://www.nabble.com/CR-interface-problem-tp22085283p22085283.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] R code compiled, assembled or interpreted?

2009-02-18 Thread Uwe Ligges



francogrex wrote:
Hi all, do you know if an R program 


If R program means pure R code, than now, R is an interpreted language.
For more information on the interpreter, you might want to start reading 
the manual R Internals.


Uwe Ligges


is compiled to machine language when
executed? And also is there any way to disassemble an R code/program: to see
how it is generating the machine instructions for the processor? Thanks


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


[R] Constraint in nls with factor in model?

2009-02-18 Thread Manuel Morales
Hi all,

I'm trying to fit a model using the shorthand coeff[factor] instead of
coding dummy variables. Is there a way to keep this notation when
specifying constraints? See example below:

x = runif(200)
b0 = c(rep(0,100),runif(100))
b1 = 1
fac - as.factor(rep(c(0,1), each=100))
y = b0+b1*x+rnorm(200,sd=0.05)

## No constraint - works
nls(y~b0[fac]+b1*x, start=list(b0=c(1,1),b1=1),algorithm=port)

## Constraint - doesn't work
nls(y~b0[fac]+b1*x, start=list(b0=c(1,1),b1=1), algorithm=port,
upper=c(100,100,.5))

## Constraint w/ dummy variable - works
nls(y~b01+I(as.numeric(fac)-1)*b02+b1*x, start=list(b01=1,b02=1,b1=1),
algorithm=port, upper=c(100,100,.5))

Thanks!

Manuel


-- 
http://mutualism.williams.edu


signature.asc
Description: This is a digitally signed message part
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Running out of memory when importing SPSS files

2009-02-18 Thread dobomode
Hello R-help,

I am trying to import a large dataset from SPSS into R. The SPSS file
is in .SAV format and is about 1GB in size. I use read.spss to import
the file and get an error saying that I have run out of memory. I am
on a MAC OS X 10.5 system with 4GB of RAM. Monitoring the R process
tells me that R runs out of memory when reaching about 3GB of RAM so I
suppose the remaining 1GB is used up by the OS.

Why would a 1GB SPSS file take up more than 3GB of memory in R? Is it
perhaps because R is converting each SPSS column to a less memory-
efficient data type? In general, what is the best strategy to load
large datasets in R?

Thanks!

P.S.

I exported the SPSS .SAV file to .CSV and tried importing the comma
delimited file. Same results – the import was much slower but
eventually I ran out of memory again...

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] lineplot in ggplot2 with different colour and linetype

2009-02-18 Thread Harsh
Hi list,
I would like to use ggplot2 in creating a line plot with 4 lines (groups), 2
of which I want in colour and the remaining two as dotted lines.

### R code ###
library(ggplot2)

### create data 
vals - rnorm(400)
div- c(rep(A,100),rep(B,100),rep(C,100),rep(D,100))
n- rep(1:100,4)
df- data.frame(div= as.factor(div),vals=vals,n=n)

### ggplot function 
qplot(x=n,y=vals, colour = div ,geom = line,data=df)

What I would like to see is a line plot where I can have lines for groups A,
and B in colour and lines for C and D in dotted and dashed respectively.

Also, I would like to know how I can draw two lines (groups C and D) which
are both dotted.


Thanks
Regards
Harsh Singhal

[[alternative HTML version deleted]]

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


Re: [R] cumsum vs. sum

2009-02-18 Thread Berwin A Turlach
G'day all,

On Wed, 18 Feb 2009 12:41:27 -0500
Stavros Macrakis macra...@alum.mit.edu wrote:

 Hmm.  Why not use the same method to guarantee the same result?  

Hmm, I did not look at the source code but, potentially, sum() could
use some tricks to reduce rounding errors further that would not be
available to cumsum(); e.g. sorting the data before adding summing
them; or grouping them into groups of roughly similar magnitude and
then sum group-by-group.  So it does may be counter-productive to use
the same method.

 Or at least document the possibility that cumsum(x)[length(x)] !=
 sum(x)... that seems like an easy trap to fall into.

But this is already documented, isn't it?  FAQ 7.31. ;-))

Cheers,

Berwin

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Age as time-scale in a cox model-How to calculate x-time risk?

2009-02-18 Thread Eleni Rapsomaniki

Dear R users,

My question is more methodology related rather than specific to R usage. Using 
time on study as time in a cox model, eg:

library(Design)
stanf.cph1=cph(Surv(time, status) ~ t5+id+age, data=stanford2, surv=T)

#In this case the 1000-day survival probability would be:
stanf.surv1=survest(stanf.cph1, times=1000)

#Age in this case is a covariate. 

#I now want to compare the above estimate to the 1000-day survival probability 
I get using age at entry and exit as my time-scale:
stanf.cph2=cph(Surv(age,age+time, status) ~ t5+id, data=stanford2, surv=T)
stanf.surv2=survest(stanf.cph2, times=1000)

summary(stanf.surv1$surv)
   Min. 1st Qu.  MedianMean 3rd Qu.Max.NA's 
 0.1131  0.3370  0.4669  0.4538  0.5633  0.7480 27. 
 summary(stanf.surv2$surv)
Min.  1st Qu.   Median Mean  3rd Qu. Max. NA's 
 0.07387  0.23240  0.35770  0.35370  0.46820  0.60650 27.0 

These are obviously out-of sync, so there must be some way I can adjust them to 
mean the same thing. The first means the probability of surviving a 1000 days 
since they started being followed up while the second means the probability of 
surviving up to starting age+1000 days. How do I get the equivalent risks from 
the two models?

Any tips greatly appreciated!!

(FYI A related entry to my question can be found at:
http://tolstoy.newcastle.edu.au/R/e2/help/07/02/9831.html)

Eleni Rapsomaniki
 
Research Associate
Department of Public Health and Primary Care
University of Cambridge


 




[[alternative HTML version deleted]]

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


Re: [R] cumsum vs. sum

2009-02-18 Thread Stavros Macrakis
Duncan, Berwin, Martin,

Thanks for your thoughtful explanations, which make perfect sense.

May I simply suggest that the non-identity between last(cumsum) and
sum might be worth mentioning in the cumsum doc page?

-s

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

2009-02-18 Thread diego Diego
Dear R experts:

 I have a list (a very long one) and I need to create successively txt
outputs (on diferent files ideally) for the data of each component of the
list.

How can I do this?


Thanks in advance!!

[[alternative HTML version deleted]]

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


Re: [R] lineplot in ggplot2 with different colour and linetype

2009-02-18 Thread Domenico Vistocco


Harsh wrote:

Hi list,
I would like to use ggplot2 in creating a line plot with 4 lines (groups), 2
of which I want in colour and the remaining two as dotted lines.

### R code ###
library(ggplot2)

### create data 
vals - rnorm(400)
div- c(rep(A,100),rep(B,100),rep(C,100),rep(D,100))
n- rep(1:100,4)
df- data.frame(div= as.factor(div),vals=vals,n=n)

### ggplot function 
qplot(x=n,y=vals, colour = div ,geom = line,data=df)

What I would like to see is a line plot where I can have lines for groups A,
and B in colour and lines for C and D in dotted and dashed respectively.
  
ggp - ggplot(aes(x=n,y=vals, colour=div, linetype=div), data=df) + 
geom_line()
ggp + scale_colour_manual(values = c(red,blue,black,black)) + 
scale_linetype_manual(values = c(1,1,3,2))



Also, I would like to know how I can draw two lines (groups C and D) which
are both dotted.
  

For graphic specifications see Hadley' instructions:
http://had.co.nz/ggplot2/book/specifications.pdf

Ciao,
domenico


Thanks
Regards
Harsh Singhal

[[alternative HTML version deleted]]

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




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


Re: [R] How to connect R and WinBUGS/OpenBUGS/LinBUGS in Linux in Feb. 2009

2009-02-18 Thread chaogai

Hi,

For me running winbugs through wine just works. Even when I do not specify  
any directories.

The example they give in the bugs helpfile was my starting point.
Setup is suse 11.1, latest Wine, R, R2WinBUGS  winbugs.
I assume you first tried without specifying directories?
The directories you use do not work for me, with WINEPATH the culprit.
If you do not have the latest wine I advise to upgrade  not specify  
directories.


Good luck,
Kees

On Wed, 18 Feb 2009 01:27:18 +0100, Paul Heinrich Dietrich  
paul.heinrich.dietr...@gmail.com wrote:




Hi Uwe,
Thank you for your guidance.  I have installed R2WinBUGS and WinBUGS14  
under

wine.  Using ?bugs for help, it tells me:

useWINE: logical; attempt to use the Wine emulator to run 'WinBUGS',
defaults to 'FALSE' on Windows, and 'TRUE' otherwise. Not available in
S-PLUS.

WINE: character, path to 'wine' binary file, it is tried hard (by a guess
and the utilities 'which' and 'locate')  to get the information
automatically if not given.

newWINE: Use new versions of Wine that have 'winepath' utility

WINEPATH: character, path to 'winepath' binary file, it is tried hard  
(by a

guess and the utilities 'which' and 'locate')  to get the information
automatically if not given.

..and the following code is a simple Bayesian version of a t-test...

  Directory Paths   


MyModelPath - /home/me/Compound/R/WinBUGS/
MyBUGSPath - /home/me/.wine/drive_c/Program Files/WinBUGS14/
MyModelFile - paste(MyModelPath, model.bug, sep=)
WINEPATH - /usr/bin/wine

  Create Data Set   


# Here is some fake data
n_draws - 50
x - round(runif(n_draws, 1, 2))
y - ifelse(x == 1, rnorm(n_draws, 1, 1), rnorm(n_draws, 1.2, 0.8))
MyData - as.data.frame(cbind(y, x))
y.n - NROW(MyData$y)
x.j - length(unique(x))
summary(MyData)

##  Format Data for WinBUGS   
##

MyBUGSData - list(y=MyData$y, x=MyData$x, n=y.n, x.j=x.j)
MyBUGSData

##  WinBUGS Model File   
###

library(R2WinBUGS)
cat(model
{
for (i in 1:n)
{
y[i] ~ dnorm(mu[i], tau)
mu[i] - alpha + beta[x[i]]
}
### STZ (Sum-To-Zero) Constraints
beta[1] - -sum(beta[2:x.j])
### Priors
alpha ~ dnorm(0.0, 1.0E-4)
for (i in 2:x.j)
{
beta[i] ~ dnorm(0.0, 1.0E-4)
}
tau ~ dgamma(0.01, 0.01)
precision - sqrt(1/tau)
},
file=MyModelFile)
file.show(MyModelFile)

#  WinBUGS Model   
#

MyModel - bugs(MyBUGSData, inits=NULL,
model.file=MyModelFile,
parameters.to.save=c(alpha, beta, precision),
n.chains=3, n.iter=2000, n.burnin=1000, n.thin=1, codaPkg=TRUE,
bugs.directory = MyBUGSPath, working.directory=MyModelPath,
useWINE=TRUE, WINEPATH=WINEPATH, debug=TRUE)

The output says:

ERROR:
  cannot open the connection

I'm wondering if I've misinterpreted how to set my paths with wine,  
because
I can go to the following path, double-click on WinBUGS14.exe, and open  
it

just fine: /home/me/.wine/drive_c/Program Files/WinBUGS14/

I can also go to Applications  Wine  Browse C:\ Drive and navigate to
WinBUGS.

Please help if I've done something wrong.  Thanks.




--

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


[R] RcolorBrewer

2009-02-18 Thread Alina Sheyman
I've downloaded the RcolorBrewer package, but when I try to run
mypalette-brewer.pal(7,Greens)

(or any other command with brewer.pal)

I get the following error message - Error: could not find function
brewer.pal

Does anyone know why that's happening? Is there smth else I need to
download?

thank you

[[alternative HTML version deleted]]

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


Re: [R] Creating several txt outputs

2009-02-18 Thread Domenico Vistocco

diego Diego wrote:

Dear R experts:

 I have a list (a very long one) and I need to create successively txt
outputs (on diferent files ideally) for the data of each component of the
list.

How can I do this?
  

Maybe this could help you:

list2Files - list(1:3, letters[1:10], matrix(1:15, 5, 3))
mapply(function(x, idFile){write(x, paste(file, idFile, .txt, 
sep=))}, list2Files, 1:length(list2FIles))


Ciao,
domenico

PS:
you can specify the full path of the file (else you are writing in the 
current directory)


Thanks in advance!!

[[alternative HTML version deleted]]

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




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


Re: [R] RcolorBrewer

2009-02-18 Thread Domenico Vistocco

Alina Sheyman wrote:

I've downloaded the RcolorBrewer package, but when I try to run
mypalette-brewer.pal(7,Greens)

(or any other command with brewer.pal)

I get the following error message - Error: could not find function
brewer.pal

Does anyone know why that's happening? Is there smth else I need to
download?
  

Do you have loaded the package?
library(RcolorBrewer)


thank you

[[alternative HTML version deleted]]

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




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


Re: [R] RcolorBrewer

2009-02-18 Thread Alina Sheyman
I figured it out
thanks

On Wed, Feb 18, 2009 at 3:50 PM, Domenico Vistocco visto...@unicas.itwrote:

 Alina Sheyman wrote:

 I've downloaded the RcolorBrewer package, but when I try to run
 mypalette-brewer.pal(7,Greens)

 (or any other command with brewer.pal)

 I get the following error message - Error: could not find function
 brewer.pal

 Does anyone know why that's happening? Is there smth else I need to
 download?


 Do you have loaded the package?
 library(RcolorBrewer)

  thank you

[[alternative HTML version deleted]]

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






[[alternative HTML version deleted]]

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


[R] understanding how R determines numbers and characters when creating a data frame

2009-02-18 Thread Alan Smith
Hello R Users and Developers,

I have a basic question about how R works.  Over the past few years I have
struggled when I try to generate a new data frame that I believe should
contain numeric data in some columns and character data in others only to
find everything converted to character data. Is there a general method to
create data frames that contain the data in the desired format:  numbers as
numeric and character as a factor etc?  I often have this problem and in the
worst case I have to export the file and read it back it in.I have
emulated a simple example of the problem.  It often happens while using
for loops.  Could someone explain how to avoid this problem by properly
creating data frames in for loops that can contain both numeric and
character data.

 

Question for example 1.

Why does the cbind command convert the numeric data to character data?  Why
can't the character data be converted to numeric data using the fix command?


### Example 1  #

data(iris)

obsnum-NULL

results-NULL

for(s in unique(as.character(iris$Species))){

temp1-iris[iris$Species==s,]

obsnum-length(unique(temp1$Sepal.Length))  # a number

out1-cbind(species=as.character(paste(s)),obsnum)  # number converted to
character

results-rbind(out1,results)

}

results

#fix(results)  # cannot convert obsnum to numeric using fix



 

**Question for example 2

Why does adding the data.frame command allow the character data to be
converted to numeric data using fix command?

### Example 2  #

data(iris)

obsnum-NULL

results-NULL

for(s in unique(as.character(iris$Species))){

temp1-iris[iris$Species==s,]

obsnum-length(unique(temp1$Sepal.Length))

out1-data.frame(cbind(species=as.character(paste(s)),obsnum)) # number
converted to character

results-rbind(out1,results)

}

results

#fix(results)  # can now convert obsnum to numeric using fix

 

##

 

 

Thank you,

Alan Smith


[[alternative HTML version deleted]]

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


[R] [package-car:Anova] extracting residuals from Anova for Type II/III Repeated Measures ?

2009-02-18 Thread Tal Galili
Hello dear R members.
I have been learning the Anova syntax in order to perform an SS type III
Anova with repeated measures designs (thank you Prof. John Fox!)
And another question came up: where/what are the (between/within) residuals
for my model?



  Play code:


phase - factor(rep(c(pretest, posttest, followup), c(5, 5, 5)),
levels=c(pretest, posttest, followup))
hour - ordered(rep(1:5, 3))
idata - data.frame(phase, hour)
idata

mod.ok - lm(cbind(pre.1, pre.2, pre.3, pre.4, pre.5,
 post.1, post.2, post.3, post.4, post.5,
 fup.1, fup.2, fup.3, fup.4, fup.5) ~
 treatment*gender,
data=OBrienKaiser)
av.ok - Anova(mod.ok, idata=idata, idesign=~phase*hour)


summary(av.ok, multivariate=FALSE)

## Univariate Type II Repeated-Measures ANOVA Assuming Sphericity
##
##  SS num Df Error SS den Df   F
 Pr(F)
## treatment   211.286  2  228.056 10  4.6323
 0.037687
## gender   58.286  1  228.056 10  2.5558
 0.140974
## treatment:gender130.241  2  228.056 10  2.8555
 0.104469
## phase   167.500  2   80.278 20 20.8651
1.274e-05
## treatment:phase  78.668  4   80.278 20  4.8997
 0.006426
## gender:phase  1.668  2   80.278 20  0.2078
 0.814130
## treatment:gender:phase   10.221  4   80.278 20  0.6366
 0.642369
## hour106.292  4   62.500 40 17.0067
3.191e-08
## treatment:hour1.161  8   62.500 40  0.0929
 0.999257
## gender:hour   2.559  4   62.500 40  0.4094
 0.800772
## treatment:gender:hour 7.755  8   62.500 40  0.6204
 0.755484
## phase:hour   11.083  8   96.167 80  1.1525
 0.338317
## treatment:phase:hour  6.262 16   96.167 80  0.3256
 0.992814
## gender:phase:hour 6.636  8   96.167 80  0.6900
 0.699124
## treatment:gender:phase:hour  14.155 16   96.167 80  0.7359
 0.749562









-- 
--


My contact information:
Tal Galili
Phone number: 972-50-3373767
FaceBook: Tal Galili
My Blogs:
www.talgalili.com
www.biostatistics.co.il

[[alternative HTML version deleted]]

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


Re: [R] Adding greek letters to plot title

2009-02-18 Thread Domenico Vistocco

gina patel wrote:

I would like to add the greek letter mu to replace u in my title shown below.

main=R=[0.001uM]:A=[750uM]

i tried using main=expression(R=[0.001~mu~M]:A=[750~mu~M])

plot(1:3, main=expression(paste(R=[0.001~,mu,~M]:A=[750~,mu,~M])))

Ciao,
domenico

but this is not working at the moment.

any help is appreciated

thanks in advance




  
	[[alternative HTML version deleted]]


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




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


Re: [R] How to connect R and WinBUGS/OpenBUGS/LinBUGS in Linux in Feb. 2009

2009-02-18 Thread Tobias Verbeke

Uwe Ligges wrote:


Hi all,
I've managed to get JAGS working on my Ubuntu Hardy Linux with a 32-bit
computer and AMD processors using R 2.8.1.  JAGS is great.  I've read 
that

JAGS is the fastest, but that hasn't been my experience.  At any rate, I
have more experience with WinBUGS under Windows and would like a 
version of

that working as well.

It seems like I've read a lot on the subject and tried a lot, but haven't
managed to get BUGS to work yet.  The most success I've had is to install
WinBUGS or OpenBUGS using this method:
http://www.math.aau.dk/~slb/kurser/bayes-08/install.html

What you also need to know is that you need to open Wine and add a 
drive. Although Z is recommended, I haven't been able to specify it, 
but have

gotten a D drive to work, using:

wine D:/opt/OpenBUGS/winbugs.exe

Using this method, OpenBUGS opens.  Now, to be able to open it with 
R.  I've
read all sorts of discussions about BRugs (which is no longer on CRAN, 
but

old versions can still be found), rbugs, and R2WinBUGS (which I'm used to
using on Windows with WinBUGS).  Some people say R2WinBUGS cannot run
OpenBUGS on Linux, some claim they've done it (I think).  It seems the 
same

thing with everything else.  I've tried making the linbugs and cbugs file
recommended elsewhere online.  It's all very confusing.


For short: It is quite unlikely that BRugs / OpenBUGS (which is called 
LinBUGS under Linux) works natively under your Linux (although it might 
work under very specific settings). 


As every now and then I get offline requests from people who stumble on 
this thread


http://finzi.psych.upenn.edu/R/Rhelp08/archive/132855.html

to give details on how I got OpenBUGS running under GNU/Linux,
I made a stripped-down package that does just that. The approach is 
very, very basic and I only tested this on a few machines and

distributions, but if it can be useful to anyone, I temporarily
put it up at

http://www.openanalytics.be/rOpenBUGS_0.0-1.tar.gz

Best,
Tobias

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Re place Values within vector using Translation vector

2009-02-18 Thread Christian Langkamp

Dear everyone 
I would like to change values in vectors doing a translation. i.e. I have a
start vector giving me the levels in one vector (numbers 1 to x - rating)
and then I have a second vector giving me the values to be allocated (loss
probabilities), but the number of potential rating classes and loss
estimates is still subject to a lot of discussion.

Attached a simplified version of the problem (original has more values and
needs to stay flexible, i.e. length of translation vector can change.

Trans_Prob_values-c(0.005, 0.01, 0.1)
Trans_CR-c(1,2,3)
a-c(3,2,1,1,2,3)
A-replace(a, Trans_CR, Trans_Prob_values)
A

This however produces
[1] 0.005 0.010 0.100 1.000 2.000 3.000
as opposed to the desired result.


The help however says 
replace replaces the values in x with indexes given in list by those given
in values. If necessary, the values in values are recycled.  which in my
view should be exactly doing the job intended above.

Constructions with nested ifelse statements and individual replacements are
too cumbersome in my view.
I searched for conditional replacement, vector replace, replace function and
read the problems, but generally they have conditions like age30 then x,
not a direct translation of values.

If anyone has an idea, please do share it.
Thanks
Christian

-- 
View this message in context: 
http://www.nabble.com/Replace-Values-within-vector-using-Translation-vector-tp22088527p22088527.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] understanding how R determines numbers and characters when creating a data frame

2009-02-18 Thread Greg Snow
The culprit is the cbind function.  When given 2 vectors (not already something 
else), cbind will create a matrix, not a data frame.  A matrix can only have 1 
type, so the numbers get converted to character.  In your first example you 
never do create a data frame, you just build a matrix (try str(results)) so fix 
cannot change a single column to numeric in something that is a matrix.  In the 
second example you do create a data frame so fix will allow changing of 
columns, but the cbind inside the call to data.frame is still creating a matrix 
(and converting numeric to character) before it is included in the data frame.  
Remove the cbind and just do:

out1 - data.frame(species=as.character(paste(s)),obsnum=obsnum)

and then out1 will be a data frame without ever converting the number obsnum to 
a character.

Hope this helps,

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
 project.org] On Behalf Of Alan Smith
 Sent: Wednesday, February 18, 2009 2:01 PM
 To: r-help@r-project.org
 Subject: [R] understanding how R determines numbers and characters when
 creating a data frame
 
 Hello R Users and Developers,
 
 I have a basic question about how R works.  Over the past few years I
 have
 struggled when I try to generate a new data frame that I believe should
 contain numeric data in some columns and character data in others only
 to
 find everything converted to character data. Is there a general method
 to
 create data frames that contain the data in the desired format:
 numbers as
 numeric and character as a factor etc?  I often have this problem and
 in the
 worst case I have to export the file and read it back it in.I have
 emulated a simple example of the problem.  It often happens while using
 for loops.  Could someone explain how to avoid this problem by
 properly
 creating data frames in for loops that can contain both numeric and
 character data.
 
 
 
 Question for example 1.
 
 Why does the cbind command convert the numeric data to character data?
 Why
 can't the character data be converted to numeric data using the fix
 command?
 
 
 ### Example 1  #
 
 data(iris)
 
 obsnum-NULL
 
 results-NULL
 
 for(s in unique(as.character(iris$Species))){
 
 temp1-iris[iris$Species==s,]
 
 obsnum-length(unique(temp1$Sepal.Length))  # a number
 
 out1-cbind(species=as.character(paste(s)),obsnum)  # number converted
 to
 character
 
 results-rbind(out1,results)
 
 }
 
 results
 
 #fix(results)  # cannot convert obsnum to numeric using fix
 
 
 
 
 
 **Question for example 2
 
 Why does adding the data.frame command allow the character data to be
 converted to numeric data using fix command?
 
 ### Example 2  #
 
 data(iris)
 
 obsnum-NULL
 
 results-NULL
 
 for(s in unique(as.character(iris$Species))){
 
 temp1-iris[iris$Species==s,]
 
 obsnum-length(unique(temp1$Sepal.Length))
 
 out1-data.frame(cbind(species=as.character(paste(s)),obsnum)) # number
 converted to character
 
 results-rbind(out1,results)
 
 }
 
 results
 
 #fix(results)  # can now convert obsnum to numeric using fix
 
 
 
 ##
 
 
 
 
 
 Thank you,
 
 Alan Smith
 
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


[R] color maps with counts

2009-02-18 Thread Alina Sheyman
I have yet another question concerning maps.
This time I want to create a colored map of number of students by state.
Can this be done using palettes in Rcolor brewer, is there some other way?

I've been looking through R archives, but am still really at a loss here, so
all help will be much appreciated.

Thank you!

[[alternative HTML version deleted]]

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


Re: [R] Re place Values within vector using Translation vector

2009-02-18 Thread Duncan Murdoch

On 18/02/2009 4:24 PM, Christian Langkamp wrote:
Dear everyone 
I would like to change values in vectors doing a translation. i.e. I have a

start vector giving me the levels in one vector (numbers 1 to x - rating)
and then I have a second vector giving me the values to be allocated (loss
probabilities), but the number of potential rating classes and loss
estimates is still subject to a lot of discussion.

Attached a simplified version of the problem (original has more values and
needs to stay flexible, i.e. length of translation vector can change.

Trans_Prob_values-c(0.005, 0.01, 0.1)
Trans_CR-c(1,2,3)
a-c(3,2,1,1,2,3)
A-replace(a, Trans_CR, Trans_Prob_values)
A

This however produces
[1] 0.005 0.010 0.100 1.000 2.000 3.000
as opposed to the desired result.


The help however says 
replace replaces the values in x with indexes given in list


Since your Trans_CR contains 1:3, this says the first 3 entries of x 
will be replaced, and that's what happened.


What you want is simply

A - Trans_Prob_values[a]

(assuming that the indices are always in 1:x, and that Trans_Prob_values 
will have x values in it).


Duncan Murdoch


 by those given

in values. If necessary, the values in values are recycled.  which in my
view should be exactly doing the job intended above.

Constructions with nested ifelse statements and individual replacements are
too cumbersome in my view.
I searched for conditional replacement, vector replace, replace function and
read the problems, but generally they have conditions like age30 then x,
not a direct translation of values.

If anyone has an idea, please do share it.
Thanks
Christian



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] understanding how R determines numbers and characters when creating a data frame

2009-02-18 Thread Domenico Vistocco

Alan Smith wrote:

Hello R Users and Developers,

I have a basic question about how R works.  Over the past few years I have
struggled when I try to generate a new data frame that I believe should
contain numeric data in some columns and character data in others only to
find everything converted to character data. Is there a general method to
create data frames that contain the data in the desired format:  numbers as
numeric and character as a factor etc?  I often have this problem and in the
worst case I have to export the file and read it back it in.I have
emulated a simple example of the problem.  It often happens while using
for loops.  Could someone explain how to avoid this problem by properly
creating data frames in for loops that can contain both numeric and
character data.

 


Question for example 1.

Why does the cbind command convert the numeric data to character data?  Why
can't the character data be converted to numeric data using the fix command?
  

See ?cbind for a detailed explanation.
Anyway, when cbind/rbind is used on vector / matrix it returns matrix. 
Matrix are necessarily composed of the same type of data (see 
Introduction to R): combining character and numeric data you are 
implicitly converting the short type (numeric) to the long type 
(character).


### Example 1  #

data(iris)

obsnum-NULL

results-NULL

for(s in unique(as.character(iris$Species))){

temp1-iris[iris$Species==s,]

obsnum-length(unique(temp1$Sepal.Length))  # a number

  

Instead of using cbind here:

out1-cbind(species=as.character(paste(s)),obsnum)  # number converted to
character
  

using data.frame:
out1 - data.frame(species=as.character(paste(s)),obsnum)

you are telling R to convert character in factor and to preserve the 
numeric:

c(class(results$species),mode(results$species))
c(class(results$obsnum),mode(results$obsnum))

You can keep the character using the stringsAsFactors argument of the 
data.frame() function:
out1 - data.frame(species=as.character(paste(s)),obsnum, 
stringsAsFactors=FALSE)


And then:
class(results$species)

The message is: if you want to mix up different data type you need lists 
(and data.frame are a special type of list where each component has the 
same number of elements).


Ciao,
domenico

results-rbind(out1,results)

}

results

#fix(results)  # cannot convert obsnum to numeric using fix



 


**Question for example 2

Why does adding the data.frame command allow the character data to be
converted to numeric data using fix command?

### Example 2  #

data(iris)

obsnum-NULL

results-NULL

for(s in unique(as.character(iris$Species))){

temp1-iris[iris$Species==s,]

obsnum-length(unique(temp1$Sepal.Length))

out1-data.frame(cbind(species=as.character(paste(s)),obsnum)) # number
converted to character

results-rbind(out1,results)

}

results

#fix(results)  # can now convert obsnum to numeric using fix

 


##

 

 


Thank you,

Alan Smith


[[alternative HTML version deleted]]

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




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


Re: [R] Re place Values within vector using Translation vector

2009-02-18 Thread Greg Snow
The call to replace is replacing the 1st 3 elements of a (your indexes in 
Trans_CR) with the values and leaving the 4-6 elements alone.  For what you 
want, try:

A - Trans_Prob_values[ match(a, Trans_CR) ]

Hope this helps,


-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
 project.org] On Behalf Of Christian Langkamp
 Sent: Wednesday, February 18, 2009 2:25 PM
 To: r-help@r-project.org
 Subject: [R] Re place Values within vector using Translation vector
 
 
 Dear everyone
 I would like to change values in vectors doing a translation. i.e. I
 have a
 start vector giving me the levels in one vector (numbers 1 to x -
 rating)
 and then I have a second vector giving me the values to be allocated
 (loss
 probabilities), but the number of potential rating classes and loss
 estimates is still subject to a lot of discussion.
 
 Attached a simplified version of the problem (original has more values
 and
 needs to stay flexible, i.e. length of translation vector can change.
 
 Trans_Prob_values-c(0.005, 0.01, 0.1)
 Trans_CR-c(1,2,3)
 a-c(3,2,1,1,2,3)
 A-replace(a, Trans_CR, Trans_Prob_values)
 A
 
 This however produces
 [1] 0.005 0.010 0.100 1.000 2.000 3.000
 as opposed to the desired result.
 
 
 The help however says
 replace replaces the values in x with indexes given in list by those
 given
 in values. If necessary, the values in values are recycled.  which in
 my
 view should be exactly doing the job intended above.
 
 Constructions with nested ifelse statements and individual replacements
 are
 too cumbersome in my view.
 I searched for conditional replacement, vector replace, replace
 function and
 read the problems, but generally they have conditions like age30 then
 x,
 not a direct translation of values.
 
 If anyone has an idea, please do share it.
 Thanks
 Christian
 
 --
 View this message in context: http://www.nabble.com/Replace-Values-
 within-vector-using-Translation-vector-tp22088527p22088527.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


[R] How to verify R is running with multi-threads

2009-02-18 Thread Jong
Hi all,

I've compiled R (version 2.8.1) from the source code with --with-
blas= option in order to use external multi-threaded blas package.
However, it's very hard to verify that compilation is correct and R is
using multi-threads correctly or not. Which command or operation in R
will run with multi-threads?

I assumed that matrix multiplication %*% may call multi-threaded blas
operation. So, I run the following code:

n - 2000
T = matrix(runif(n*n), nrow=n, ncol=n)
system.time(T %*% T)

and watch R process by using unix top command with show-all-threads
option. However, it seems like my R doesn't use multi-threads but just
run with single thread. Is there any other command that I can use to
verify multi-threads use?

Regarding the with-blas option, I have tried to use either atlas or
gotoblas with the following configure option:
--with-blas=-lptf77blas -lpthread -latlas
--with-blas=-lgotocblas -lgotoblas -lpthread

Not sure if my options are correct or not.

Thank you for your and comment or advice in advance.


Thanks,
Jong

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] interaction.plot - gridlines and formatting legend title...

2009-02-18 Thread Dimitri Liakhovitski
Thank you for providing advice on this graphics question.

I am building an interaction.plot.

d=data.frame(xx=c(3,3,2,2,1,1),yy=c(4,3,4,3,4,3),zz=c(5.1,4.2,4.4,3.5,3.3,-1.1,-1.3)
d[[1]]-as.factor(d[[1]])
d[[2]]-as.factor(d[[2]])
print(d)
interaction.plot(d$xx, d$yy, d$zz,
   type=b, col=c(red,blue), legend=F,
   lty=c(1,2), lwd=2, pch=c(18,24),
   xlab=X Label,
   ylab=Y Label,
   main=Chart Label)
legend(bottomright, c(level 1,level
2),bty=n,lty=c(1,2),lwd=2,pch=c(18,24),
col=c(red,blue), title=Legend Title,inset = .02)

I think it is not using lattice, does it? So, I was wondering if it is
at all possible to:

1. Create gridlines in an interaction.plot
2. Define the font type of the legend title (e.g., regular vs. bold as
in font=2)
3. Put actual values (on Y) next to each point in the graph.

Thank you so much for your advice!


-- 
Dimitri Liakhovitski
MarketTools, Inc.
dimitri.liakhovit...@markettools.com

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


Re: [R] Unadulterated plot

2009-02-18 Thread James Nicolson
Hi,

Thanks for your help. I have looked at the beginners documentation and
while there are options to configure various aspects of the plot none of
them seem to have the desired effect. I have managed to ensure that the
plot fills the space vertically with no margins, no axes etc (using
mai=c(0,0,0,0)). However, horizontally there remains a margin to the
right that pads the space between the filled.contour and its legend.
I've tried options to par and filled.contour but I can't seem to remove
the legend.

Kind Regards,
James

Simon Pickett wrote:
 Hi James,

 What you really need to do is to check out the many freely available
 pdfs for R beginners. Here is a good place to start

 http://cran.r-project.org/other-docs.html

 If I am right interpreting what you want, I think you need to create a
 blank plot with no axes, axis labels etc. Try

 plot(x,y,xlab=,ylab=,xaxt=NULL,yaxt=NULL,type=n)
 #blank plot
 points(x,y)

 type ?par into R and see how you can set parameters like this up as
 the default.

 Hope this helps?

 Simon.


 - Original Message - From: James Nicolson
 jlnicol...@gmail.com
 To: r-help@r-project.org
 Sent: Sunday, February 15, 2009 10:29 PM
 Subject: [R] Unadulterated plot


 To all,

 Apologies if this question has already been asked but I can't find
 anything. I can't seem to think of more specific search terms. I want
 to display/create a file of a pure plot with a specific height and
 width. I want to utilise every single pixel inside the axes. I do not
 want to display any margins, legends, axes, titles or spaces around
 the edges. Is this possible? Additionally, the plot I am working with
 is a filled.contour plot and I can not remove the legend? How can I
 do this?

 Kind Regards,
 James

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




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


Re: [R] [package-car:Anova] extracting residuals from Anova for Type II/III Repeated Measures ?

2009-02-18 Thread John Fox
Dear Tal,

I suppose that the between residuals would be obtained, for your example,
by residuals(mod.ok). I'm not sure what the within residuals are. You
could apply the transformation for each within-subject effect to the matrix
of residuals to get residuals for that effect -- is that what you had in
mind? A list of transformations is in the element $P of the Anova.mlm
object.

Regards,
 John

--
John Fox, Professor
Department of Sociology
McMaster University
Hamilton, Ontario, Canada
web: socserv.mcmaster.ca/jfox


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On
 Behalf Of Tal Galili
 Sent: February-18-09 4:04 PM
 To: r-help@r-project.org
 Subject: [R] [package-car:Anova] extracting residuals from Anova for Type
 II/III Repeated Measures ?
 
 Hello dear R members.
 I have been learning the Anova syntax in order to perform an SS type III
 Anova with repeated measures designs (thank you Prof. John Fox!)
 And another question came up: where/what are the (between/within)
residuals
 for my model?
 
 
 
   Play code:
 
 
 phase - factor(rep(c(pretest, posttest, followup), c(5, 5, 5)),
 levels=c(pretest, posttest, followup))
 hour - ordered(rep(1:5, 3))
 idata - data.frame(phase, hour)
 idata
 
 mod.ok - lm(cbind(pre.1, pre.2, pre.3, pre.4, pre.5,
  post.1, post.2, post.3, post.4, post.5,
  fup.1, fup.2, fup.3, fup.4, fup.5) ~
  treatment*gender,
 data=OBrienKaiser)
 av.ok - Anova(mod.ok, idata=idata, idesign=~phase*hour)
 
 
 summary(av.ok, multivariate=FALSE)
 
 ## Univariate Type II Repeated-Measures ANOVA Assuming Sphericity
 ##
 ##  SS num Df Error SS den Df   F
  Pr(F)
 ## treatment   211.286  2  228.056 10  4.6323
  0.037687
 ## gender   58.286  1  228.056 10  2.5558
  0.140974
 ## treatment:gender130.241  2  228.056 10  2.8555
  0.104469
 ## phase   167.500  2   80.278 20 20.8651
 1.274e-05
 ## treatment:phase  78.668  4   80.278 20  4.8997
  0.006426
 ## gender:phase  1.668  2   80.278 20  0.2078
  0.814130
 ## treatment:gender:phase   10.221  4   80.278 20  0.6366
  0.642369
 ## hour106.292  4   62.500 40 17.0067
 3.191e-08
 ## treatment:hour1.161  8   62.500 40  0.0929
  0.999257
 ## gender:hour   2.559  4   62.500 40  0.4094
  0.800772
 ## treatment:gender:hour 7.755  8   62.500 40  0.6204
  0.755484
 ## phase:hour   11.083  8   96.167 80  1.1525
  0.338317
 ## treatment:phase:hour  6.262 16   96.167 80  0.3256
  0.992814
 ## gender:phase:hour 6.636  8   96.167 80  0.6900
  0.699124
 ## treatment:gender:phase:hour  14.155 16   96.167 80  0.7359
  0.749562
 
 
 
 
 
 
 
 
 
 --
 --
 
 
 My contact information:
 Tal Galili
 Phone number: 972-50-3373767
 FaceBook: Tal Galili
 My Blogs:
 www.talgalili.com
 www.biostatistics.co.il
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


[R] ggplot2 Y axis labels

2009-02-18 Thread Felipe Carrillo
Hi all:
Using the example below, is there a way to add Y axis titles to each graphic 
instead of sharing the same title?

library(ggplot2)

RT = matrix(c(814, 500, 424, 394, 967, 574, 472, 446),4,2)
colnames(RT) = c('repetition','alternation')
rownames(RT) = c('7-yrs','11-yrs','15-yrs','21-yrs')

rt - melt(RT)
names(rt) - c(age, trt, value)
rt$variable - rt

#this next block was missing in Hadley's previous example
error = matrix(c(10,6,6,4,13,7,6,3),4,2)
colnames(error) = c('repetition','alternation')
rownames(error) = c('7-yrs','11-yrs','15-yrs','21-yrs')

errors - melt(error)
names(errors) - c(age, trt, value)
errors$variable - error

df - rbind(rt, errors)

# Make sure factors are ordered correctly
df$age - factor(df$age, levels = c(7-yrs, 11-yrs, 15-yrs, 21-yrs))

# Which results in:
structure(list(age = structure(c(1L, 2L, 3L, 4L, 1L, 2L, 3L,
4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L), .Label = c(7-yrs, 11-yrs,
15-yrs, 21-yrs), class = factor), trt = structure(c(2L,
2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L), .Label =
c(alternation,
repetition), class = factor), value = c(814, 500, 424, 394,
967, 574, 472, 446, 10, 6, 6, 4, 13, 7, 6, 3), variable = c(rt,
rt, rt, rt, rt, rt, rt, rt, error, error, error,
error, error, error, error, error)), .Names = c(age,
trt, value, variable), row.names = c(NA, 16L), class = data.frame)

# It's now straightforward to create recreate the plot with lines
# or with bars:

plot - ggplot(df, aes(x=age, y=value, colour = trt, fill = trt)) +
facet_grid(variable ~ . , scale = free)
plot + geom_bar(position = dodge)  +   geom_line(aes(group = trt)) + 
geom_point()

Felipe D. Carrillo  
Supervisory Fishery Biologist  
Department of the Interior  
US Fish  Wildlife Service  
California, USA

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Running out of memory when importing SPSS files

2009-02-18 Thread Uwe Ligges



dobomode wrote:

Hello R-help,

I am trying to import a large dataset from SPSS into R. The SPSS file
is in .SAV format and is about 1GB in size. I use read.spss to import
the file and get an error saying that I have run out of memory. I am
on a MAC OS X 10.5 system with 4GB of RAM. Monitoring the R process
tells me that R runs out of memory when reaching about 3GB of RAM so I
suppose the remaining 1GB is used up by the OS.

Why would a 1GB SPSS file take up more than 3GB of memory in R? 


Because SPSS stores data in a compressed way?

 Is it

perhaps because R is converting each SPSS column to a less memory-
efficient data type? In general, what is the best strategy to load
large datasets in R?


Use a 64-bit version of R and have sufficient amount of RAM in your system.

Uwe Ligges


Thanks!

P.S.

I exported the SPSS .SAV file to .CSV and tried importing the comma
delimited file. Same results – the import was much slower but
eventually I ran out of memory again...

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


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


[R] indicator or deviation contrasts in log-linear modelling

2009-02-18 Thread maiya

I am fairly new to log-linear modelling, so as opposed to trying to fit
modells, I am still trying to figure out how it actually works - hence I am
looking at the interpretation of parameters. Now it seems most people skip
this part and go directly to measuring model fit, so I am finding very few
references to actual parameters, and am of course clear on the fact that
their choice is irelevant for the actual model fit. 

But here is my question: loglin uses deviation contrasts, so the
coefficients in each term add up to zero.
Another option are indicator contrasts, where a reference category is chosen
in each term and set to zero, while the others are relative to it. My
question is if there is a log-linear command equivalent to loglin that uses
this secong dummy coding style of constraints (I know e.g. spss genlog
does this). 

I hope this is not to basic a question!

And if anyone is up for answeing the wider question of why log-linear
parameters are not something to be looked at - which might just be my
impression of the literature - feel free to comment!

Thanks for your help!

Maja
-- 
View this message in context: 
http://www.nabble.com/indicator-or-deviation-contrasts-in-log-linear-modelling-tp22090104p22090104.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Unadulterated plot

2009-02-18 Thread Patrizio Frederic
James,
you're probably interested in image function rather than in
filled.contour. Type ?image to see the syntax.
Cheers,

Patrizio

2009/2/18 James Nicolson jlnicol...@gmail.com:
 Hi,

 Thanks for your help. I have looked at the beginners documentation and
 while there are options to configure various aspects of the plot none of
 them seem to have the desired effect. I have managed to ensure that the
 plot fills the space vertically with no margins, no axes etc (using
 mai=c(0,0,0,0)). However, horizontally there remains a margin to the
 right that pads the space between the filled.contour and its legend.
 I've tried options to par and filled.contour but I can't seem to remove
 the legend.

 Kind Regards,
 James

 Simon Pickett wrote:
 Hi James,

 What you really need to do is to check out the many freely available
 pdfs for R beginners. Here is a good place to start

 http://cran.r-project.org/other-docs.html

 If I am right interpreting what you want, I think you need to create a
 blank plot with no axes, axis labels etc. Try

 plot(x,y,xlab=,ylab=,xaxt=NULL,yaxt=NULL,type=n)
 #blank plot
 points(x,y)

 type ?par into R and see how you can set parameters like this up as
 the default.

 Hope this helps?

 Simon.


 - Original Message - From: James Nicolson
 jlnicol...@gmail.com
 To: r-help@r-project.org
 Sent: Sunday, February 15, 2009 10:29 PM
 Subject: [R] Unadulterated plot


 To all,

 Apologies if this question has already been asked but I can't find
 anything. I can't seem to think of more specific search terms. I want
 to display/create a file of a pure plot with a specific height and
 width. I want to utilise every single pixel inside the axes. I do not
 want to display any margins, legends, axes, titles or spaces around
 the edges. Is this possible? Additionally, the plot I am working with
 is a filled.contour plot and I can not remove the legend? How can I
 do this?

 Kind Regards,
 James

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




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


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


Re: [R] Adding greek letters to plot title

2009-02-18 Thread Gabor Grothendieck
Try this (or replace selected occurrences of * with ~ to get spaces
instead of juxtaposition):

plot(1:3, main = ~ R=[ * 0.001 * mu * Mu * ]:A=[ * 750 * mu * Mu * ])

On Wed, Feb 18, 2009 at 3:56 PM, gina patel ginapatel1...@yahoo.com wrote:
 I would like to add the greek letter mu to replace u in my title shown below.

 main=R=[0.001uM]:A=[750uM]

 i tried using main=expression(R=[0.001~mu~M]:A=[750~mu~M])

 but this is not working at the moment.

 any help is appreciated

 thanks in advance





[[alternative HTML version deleted]]

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


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


  1   2   >