Re: [R] How to install older version of R?

2009-11-19 Thread Paul Hiemstra

Dear Jia-Chiun Pan,

First of all, why install an older version of R? In my experience the 
backward compatibility of R is quite good. So using R 2.10.0 should be 
ok. But if you really want this you can build R from source. The source 
can be downloaded from CRAN:


http://cran.r-project.org/src/base/R-2/R-2.7.2.tar.gz

Extract, ./configure, make, make install and you have R 2.7.2 installed 
on your system.


cheers,
Paul

Pan, Jia-chiun/潘家群 wrote:

Dear list

This is much like a linux problem, but I can't find any
reference for it. My OS is ubuntu 9.04 and a version of 2.9.2 of R has
been already installed in. Now, I need to install the version of 2.7.1.
I google a lot of websites and it seems like without a painless way
provided me to do it.
If any one offers me some suggestions/reference, I will
appreciate.

 Jia-Chiun Pan

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



--
Drs. Paul Hiemstra
Department of Physical Geography
Faculty of Geosciences
University of Utrecht
Heidelberglaan 2
P.O. Box 80.115
3508 TC Utrecht
Phone:  +3130 274 3113 Mon-Tue
Phone:  +3130 253 5773 Wed-Fri
http://intamap.geo.uu.nl/~paul

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

2009-11-19 Thread William Simpson
I have quite a complicated problem that's hard to describe.

Suppose I have a dataframe d. I want to access the vector d$var, where
var is one of the variables in d. Just take for granted that there's a
good reason I want to do this as follows.

var-DeOxyA
xx-paste(d$,var, sep=)
mean(xx)
[1] NA
Warning message:
In mean.default(xx) : argument is not numeric or logical: returning NA

 mean(d$DeOxyA)
[1] 21.98904

How can I convert xx so I can do mean(xx), for example? Currently xx
is a character, not a variable.
as.numeric doesn't do it. I want R to see
mean(DeOxyA), not
mean(DeOxyA)

I'm stumped.

Thanks very much for any help.

Bill

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Overlaying multiple ROC curves using ROCR

2009-11-19 Thread Matthew Peterson
Hello,

I was following an example on The ROCR Package pdf, learning to overlay ROC 
curves on the same plot using the add = TRUE statement.  I used this one:

data(ROCR.hiv) 
attach(ROCR.hiv) 
pred.svm - prediction(hiv.svm$predictions, hiv.svm$labels) 
perf.svm - performance(pred.svm, 'tpr', 'fpr') 
pred.nn - prediction(hiv.nn$predictions, hiv.svm$labels) 
perf.nn - performance(pred.nn, 'tpr', 'fpr') 
plot(perf.svm, lty=3, col=red,main=SVMs and NNs for prediction of HIV-1 
coreceptor usage) 
plot(perf.nn, lty=3, col=blue,add=TRUE) plot(perf.svm, avg=vertical, lwd=3, 
col=red,
spread.estimate=stderror,plotCI.lwd=2,add=TRUE) 
plot(perf.nn, avg=vertical, lwd=3, col=blue, 
spread.estimate=stderror,plotCI.lwd=2,add=TRUE) 
legend(0.6,0.6,c('SVM','NN'),col=c('red','blue'),lwd=3)

The problem that I face is that the ROC plots get replaced even with the add = 
TRUE statement.  I've done this example several times, but the result is the 
same; the ROC curves are not overlaid on the same plot.  Is there any reason 
why these ROC curves are not overlaying on the same plot.  Is there a work 
around for this, or a setting that I'm unaware of?


Thank you for any assistance.

-Matt
[[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] Unnecesary code?

2009-11-19 Thread Hun S. Tesatte


On Thu, 19 Nov 2009 00:13:27 +0100 Duncan Murdoch 
murd...@stats.uwo.ca wrote:
hunsynte...@hush.com wrote:
 Dear R-ers,

 While browsing the R sources, I found the following piece of 
code 
 in src\main\memory.c:

 static void reset_pp_stack(void *data)
 {
 R_size_t *poldpps = data;
 R_PPStackSize =  *poldpps;
 }

 To me, it looks like the poldpps pointer is a nuissance; can't 
you 
 just cast the data pointer and derefer it at once? Say,

 static void reset_pp_stack(void *data)
 {
 R_PPStackSize = * (R_size_t *) data;
 }
   
What would you gain by this change?

Duncan Murdoch

Seriously? What would you gain by rejecting the change?

I think the gain is obvious, even if not essential: the code is 
cleaner. If there is a choice between two different pieces of code 
that have the same effect, choosing the simpler makes it easier to 
maintain the code, and easier for a casual user to understand 
what's going on. Anyone looking at the original code for the first 
time will have to realise that poldpps is a nuissance variable with 
no practical importance and no gain whatsoever, the change cuts 
this need.  

There is also a negligible loss in performance when the inessential 
stack variable is allocated.

-- Hun

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] 3D plot, rotatable and with adjustable symbols

2009-11-19 Thread Joel Fürstenberg-Hägg

Hi all,

 

I've tried to make a 3D plot, but have run into some problems.

 

I'd like to have a plot that I can rotate interactively using the mouse, which 
is possible using the plots3d {R.basic}. However, I would like to change the 
symbols used as the points, but there's no pch in plot3d().

 

If I use the Scatterplot3d package, I'm able to change this, but not able to 
rotate the plot interactively.

 

Does anyone know a solution to this? Maybe another package is better?

 

Best regards,

 

Joel
  
_
Nya Windows 7 gör allt lite enklare. Hitta en dator som passar dig!
http://windows.microsoft.com/shop
[[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] name of a name

2009-11-19 Thread baptiste auguie
Hi,

Try this,


d - data.frame(a=1:4, b=3:6)

var - a

mean(d[var])

## or, if you are not aware of
## fortune(parse)

xx - paste(d$,var, sep=)
mean(eval(parse(text=xx)))

HTH,

baptiste




2009/11/19 William Simpson william.a.simp...@gmail.com:
 I have quite a complicated problem that's hard to describe.

 Suppose I have a dataframe d. I want to access the vector d$var, where
 var is one of the variables in d. Just take for granted that there's a
 good reason I want to do this as follows.

 var-DeOxyA
 xx-paste(d$,var, sep=)
 mean(xx)
 [1] NA
 Warning message:
 In mean.default(xx) : argument is not numeric or logical: returning NA

 mean(d$DeOxyA)
 [1] 21.98904

 How can I convert xx so I can do mean(xx), for example? Currently xx
 is a character, not a variable.
 as.numeric doesn't do it. I want R to see
 mean(DeOxyA), not
 mean(DeOxyA)

 I'm stumped.

 Thanks very much for any help.

 Bill

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

2009-11-19 Thread Jim Lemon

On 11/19/2009 03:13 AM, Sunita Patil wrote:

Hello Sir

I have got 150 observations, got 10 posts/ 6 departments/ tasks vary from 5
to 10,

A few of the variables are crossed specially in case of Office boy, where
the tasks are like open the door, put on the lights,

Yes time variable I have used Chron package, so that it works well

My aim for this study is to check the amount of time and its variability
for groups of tasks

Its my project work so need to work this out myself if it doesnt work then I
will have to consult a statistician

Thanks for guiding me to put up the question in more clearer way, I will
sure take care next time
   

Hi Sunita,
You seem to have two aims, one to display the tasks, and the other to 
summarize the times. I have been looking at the plot.dendrite function 
and it might perform the first task with a bit of rewriting (which it 
needs anyway). The second task might be handled by the hierobarp 
function. I'll try to work out whether these will do the job in the next 
day or two.


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] name of a name

2009-11-19 Thread William Simpson
Thanks very much Phil and Baptiste!
d[[var]]
is exactly what I wanted.
Sorry for being so inarticulate. I still couldn't describe my problem
if I wanted to! Anyway, now I have the solution.

Cheers
Bill

On Thu, Nov 19, 2009 at 9:39 AM, baptiste auguie
baptiste.aug...@googlemail.com wrote:
 Hi,

 Try this,


 d - data.frame(a=1:4, b=3:6)

 var - a

 mean(d[var])

 ## or, if you are not aware of
 ## fortune(parse)

 xx - paste(d$,var, sep=)
 mean(eval(parse(text=xx)))

 HTH,

 baptiste




 2009/11/19 William Simpson william.a.simp...@gmail.com:
 I have quite a complicated problem that's hard to describe.

 Suppose I have a dataframe d. I want to access the vector d$var, where
 var is one of the variables in d. Just take for granted that there's a
 good reason I want to do this as follows.

 var-DeOxyA
 xx-paste(d$,var, sep=)
 mean(xx)
 [1] NA
 Warning message:
 In mean.default(xx) : argument is not numeric or logical: returning NA

 mean(d$DeOxyA)
 [1] 21.98904

 How can I convert xx so I can do mean(xx), for example? Currently xx
 is a character, not a variable.
 as.numeric doesn't do it. I want R to see
 mean(DeOxyA), not
 mean(DeOxyA)

 I'm stumped.

 Thanks very much for any help.

 Bill

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

2009-11-19 Thread Ted Harding
Greetings All.
According to the PLoS (Public Library of Science) Guidelines
for Figure preparation, if a figure is submitted as EPS rather
than TIFF then Figure text must be in Arial font -- see:

[1]
http://www.plosntds.org/static/figureGuidelines.action#text

and also other sections in that web-page

[2]
http://www.plosntds.org/static/figureGuidelines.action

Now, Arial font is not (as a rule) available in Linux, and
EPS diagrams prepared using R graphics will call for Helvetica
(by default). Of course the Helvetica family is very similar to
Arial, but the in-file font references will call for Helvetica
so a production system which is expecting calls for Arial may
be thrown off the rails by an EPS file which calls for Helvetica.

While there is a section (Enable the use of Arial in R) in the
Guidelines (URL [2]), the instructions assume the presence of
Arial .ttf files, not usually the case with Linux.

The PLoS Guidelines state:

  Figure text that requires a font family other than Arial
   (math symbols, etc.) must have the font information embedded
   in the figure file, or be converted to outlines.

(same URL as [1] above). Of course, the Helvetica fonts are
amongst the Standard Adobe set, and are assumed to be available
on any PostScript-capable rendering device/system (either in
the official Adobe font-definition form, or as a simulacrum
which can be evoked by the same name), so as a rule the issue
of embedding fiont definitions does not arise.

Therefore I am wondering whether
[A]
An EPS which simply uses Helvetica will be accepted by PLoS
(the substitution of Arial being automatic, as an alias);
or [B]
One has to take special measures when preparing a diagram for
PLoS using R in Linux when Arial is not available;
or [C]
One should proceed in quite a different way!

Note: I am not keen on the PLoS preferred alternative of
submitting a TIFF file, since this gives a bit-mapped result
whicvh could render poorly.

On the other hand, the Guidelines state (with resepct to LaTeX
files): PLoS does not accept vector EPS figures generated
using LaTeX. We only accept LaTeX generated figures in TIFF format.
which suggests that vector-graphics formats (however generated)
may not be acceptable anyway!

I would very much welcome any guidance on these questions,
especially from people with experience of publishing with PLoS
who use R with Linux.

With thanks,
Ted.


E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk
Fax-to-email: +44 (0)870 094 0861
Date: 19-Nov-09   Time: 11:00:15
-- XFMail --

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


Re: [R] 3D plot, rotatable and with adjustable symbols

2009-11-19 Thread Remko Duursma
Try the rgl package.


r


-
Remko Duursma
Post-Doctoral Fellow

Centre for Plants and the Environment
University of Western Sydney
Hawkesbury Campus
Richmond NSW 2753

Dept of Biological Science
Macquarie University
North Ryde NSW 2109
Australia

Mobile: +61 (0)422 096908
www.remkoduursma.com



2009/11/19 Joel Fürstenberg-Hägg joel_furstenberg_h...@hotmail.com:

 Hi all,



 I've tried to make a 3D plot, but have run into some problems.



 I'd like to have a plot that I can rotate interactively using the mouse, 
 which is possible using the plots3d {R.basic}. However, I would like to 
 change the symbols used as the points, but there's no pch in plot3d().



 If I use the Scatterplot3d package, I'm able to change this, but not able to 
 rotate the plot interactively.



 Does anyone know a solution to this? Maybe another package is better?



 Best regards,



 Joel

 _
 Nya Windows 7 gör allt lite enklare. Hitta en dator som passar dig!
 http://windows.microsoft.com/shop
        [[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] randomForest: impact of bug fixed in version 4.5-13

2009-11-19 Thread J Sousa
The NEWS of the randomForest R library mention that version 4.5-13 fixed a
bug in predict.randomForest() when newdata is a matrix with no rownames.

I think it corresponds to the difference in files
predict.randomForest.R
which is the new line
if (is.null(rn)) rn - keep

As I've been using version 4.5-12 to make predictions for newdata with no
row labels, could anyone tell me how this bug affected the predictions?

Thanks,
jaslqa

[[alternative HTML version deleted]]

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


[R] How to analyse/visualize a city budget ?

2009-11-19 Thread Tal Galili
Hello all,

I happen to get a (legitimate) hold of a city budget for the (4) years:
2006,2007,2008,2009
The budget holds over 12,000 rows of budget sections with numbers being
Zero's positive and negatives.

I would like to find something interesting in this dataset.
I don't have a clear definition of what this interesting might be, nor how
to find it.  But my aim is to find where the city council did something
fishy (again, no clear definition).
My hope is to try and use the time element to catch something on the
variables.

My initial idea was to try to use each section 4 (time) data points, and
maybe check
1)  correlations and clusters within the section. to find suspicious
similar sections.
2) Also, I was hoping to make a small model for each section, and see if it
had major 1 outlier relative to the other 3 data points it has. (I feel that
is serious stretching of the data though...)

I would love for any interesting ideas (analysis or visualization vise).

Best,
Tal




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

[[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] Unnecesary code?

2009-11-19 Thread Duncan Murdoch

On 19/11/2009 4:23 AM, Hun S. Tesatte wrote:


On Thu, 19 Nov 2009 00:13:27 +0100 Duncan Murdoch 
murd...@stats.uwo.ca wrote:

hunsynte...@hush.com wrote:

Dear R-ers,

While browsing the R sources, I found the following piece of 
code 

in src\main\memory.c:

static void reset_pp_stack(void *data)
{
R_size_t *poldpps = data;
R_PPStackSize =  *poldpps;
}

To me, it looks like the poldpps pointer is a nuissance; can't 
you 

just cast the data pointer and derefer it at once? Say,

static void reset_pp_stack(void *data)
{
R_PPStackSize = * (R_size_t *) data;
}
  

What would you gain by this change?

Duncan Murdoch


Seriously? What would you gain by rejecting the change?


I would save about an hour spent making the change, testing and 
committing it.


I think the gain is obvious, even if not essential: the code is 
cleaner. If there is a choice between two different pieces of code 
that have the same effect, choosing the simpler makes it easier to 
maintain the code, and easier for a casual user to understand 
what's going on. Anyone looking at the original code for the first
time will have to realise that poldpps is a nuissance variable with 
no practical importance and no gain whatsoever, the change cuts 
this need.  


But it makes the expression more complex, and doesn't give a hint about 
what's going on.  The name poldpps adds a bit of explanation of what the 
assumption is about what's being passed in data.




There is also a negligible loss in performance when the inessential 
stack variable is allocated.


There is likely no variable allocated.  Compilers are reasonably smart 
these days.


Duncan Murdoch



-- Hun


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

2009-11-19 Thread Liviu Andronic
Hello

On Thu, Nov 19, 2009 at 11:00 AM, Ted Harding
ted.hard...@manchester.ac.uk wrote:
 While there is a section (Enable the use of Arial in R) in the
 Guidelines (URL [2]), the instructions assume the presence of
 Arial .ttf files, not usually the case with Linux.

If you have a Windows installation, then you have the appropriate
license to use Arial, on Windows or on Linux. From what I remember, in
this case it could be relatively easy to copy the font files on the
Linux partition and install them. With some distributions it is
possible to install MS fonts from a third-party source (on Debian
ttf-mscorefonts-installer, on Gentoo some package also called
corefonts).

Regards
Liviu

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


Re: [R] PLoS, Arial, R linux

2009-11-19 Thread Deepayan Sarkar
On Thu, Nov 19, 2009 at 4:30 PM, Ted Harding
ted.hard...@manchester.ac.uk wrote:
 Greetings All.
 According to the PLoS (Public Library of Science) Guidelines
 for Figure preparation, if a figure is submitted as EPS rather
 than TIFF then Figure text must be in Arial font -- see:

 [1]
 http://www.plosntds.org/static/figureGuidelines.action#text

 and also other sections in that web-page

 [2]
 http://www.plosntds.org/static/figureGuidelines.action

 Now, Arial font is not (as a rule) available in Linux, and
 EPS diagrams prepared using R graphics will call for Helvetica
 (by default). Of course the Helvetica family is very similar to
 Arial, but the in-file font references will call for Helvetica
 so a production system which is expecting calls for Arial may
 be thrown off the rails by an EPS file which calls for Helvetica.

 While there is a section (Enable the use of Arial in R) in the

The fact that there is such a section suggests that they accept the
resulting files, doesn't it?

 Guidelines (URL [2]), the instructions assume the presence of
 Arial .ttf files, not usually the case with Linux.

But easy enough to fix (completely legally, thanks to a licensing
oversight by Microsoft):

http://corefonts.sourceforge.net/

In Debian (and I assume Ubuntu):

$ sudo apt-get install msttcorefonts

-Deepayan

[...]

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


[R] Problem with sqlSave

2009-11-19 Thread anna_l

Hello, the sqlSave function is used in order to write a dataframe on excel.
This function creates worksheets using the attribute tablename and writes
the data.frame in it. What I want to do is to create this data.frame but
being able in case this worksheet already exists to delete the former datas
and write the new ones in it. I used the safer and append attributes. When
you set safer to false, from what I understood, it should delete the former
datas. Then what I did is setting safer as false and append as true so it
can append to the empty dataframe the new dataframe but it didn´t work. It
appends in the existing worksheets but doesn´ t delete the existing datas.
Any idea?



-
Anna Lippel
new in R so be careful I should be asking a lt of questions!:teeth:
-- 
View this message in context: 
http://old.nabble.com/Problem-with-sqlSave-tp26421303p26421303.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] PLoS, Arial, R linux

2009-11-19 Thread Ted Harding
On 19-Nov-09 11:52:57, Deepayan Sarkar wrote:
 On Thu, Nov 19, 2009 at 4:30 PM, Ted Harding
 ted.hard...@manchester.ac.uk wrote:
 Greetings All.
 According to the PLoS (Public Library of Science) Guidelines
 for Figure preparation, if a figure is submitted as EPS rather
 than TIFF then Figure text must be in Arial font -- see:

 [1]
 http://www.plosntds.org/static/figureGuidelines.action#text

 and also other sections in that web-page

 [2]
 http://www.plosntds.org/static/figureGuidelines.action

 Now, Arial font is not (as a rule) available in Linux, and
 EPS diagrams prepared using R graphics will call for Helvetica
 (by default). Of course the Helvetica family is very similar to
 Arial, but the in-file font references will call for Helvetica
 so a production system which is expecting calls for Arial may
 be thrown off the rails by an EPS file which calls for Helvetica.

 While there is a section (Enable the use of Arial in R) in the
 
 The fact that there is such a section suggests that they accept the
 resulting files, doesn't it?
 
 Guidelines (URL [2]), the instructions assume the presence of
 Arial .ttf files, not usually the case with Linux.
 
 But easy enough to fix (completely legally, thanks to a licensing
 oversight by Microsoft):
 
 http://corefonts.sourceforge.net/
 
 In Debian (and I assume Ubuntu):
 
 $ sudo apt-get install msttcorefonts
 
 -Deepayan

Many thanks, Deepayan! I wasn't aware of that route.
Using synaptic on Debian (Etch), with Search: msttcorefonts
the font files were installed quite painlessly. I now have:

/usr/share/fonts/truetype/msttcorefonts/arialbd.ttf
/usr/share/fonts/truetype/msttcorefonts/arialbi.ttf
/usr/share/fonts/truetype/msttcorefonts/ariali.ttf
/usr/share/fonts/truetype/msttcorefonts/arial.ttf

so should be able to make progress as described in the Guidelines.
Ted.


E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk
Fax-to-email: +44 (0)870 094 0861
Date: 19-Nov-09   Time: 12:17:51
-- XFMail --

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


[R] [Follow-up] Re: PLoS, Arial, R linux

2009-11-19 Thread Ted Harding
See Addendum at end.

On 19-Nov-09 12:17:54, Ted Harding wrote:
 On 19-Nov-09 11:52:57, Deepayan Sarkar wrote:
 On Thu, Nov 19, 2009 at 4:30 PM, Ted Harding
 ted.hard...@manchester.ac.uk wrote:
 Greetings All.
 According to the PLoS (Public Library of Science) Guidelines
 for Figure preparation, if a figure is submitted as EPS rather
 than TIFF then Figure text must be in Arial font -- see:

 [1]
 http://www.plosntds.org/static/figureGuidelines.action#text

 and also other sections in that web-page

 [2]
 http://www.plosntds.org/static/figureGuidelines.action

 Now, Arial font is not (as a rule) available in Linux, and
 EPS diagrams prepared using R graphics will call for Helvetica
 (by default). Of course the Helvetica family is very similar to
 Arial, but the in-file font references will call for Helvetica
 so a production system which is expecting calls for Arial may
 be thrown off the rails by an EPS file which calls for Helvetica.

 While there is a section (Enable the use of Arial in R) in the
 
 The fact that there is such a section suggests that they accept the
 resulting files, doesn't it?
 
 Guidelines (URL [2]), the instructions assume the presence of
 Arial .ttf files, not usually the case with Linux.
 
 But easy enough to fix (completely legally, thanks to a licensing
 oversight by Microsoft):
 
 http://corefonts.sourceforge.net/
 
 In Debian (and I assume Ubuntu):
 
 $ sudo apt-get install msttcorefonts
 
 -Deepayan
 
 Many thanks, Deepayan! I wasn't aware of that route.
 Using synaptic on Debian (Etch), with Search: msttcorefonts
 the font files were installed quite painlessly. I now have:
 
 /usr/share/fonts/truetype/msttcorefonts/arialbd.ttf
 /usr/share/fonts/truetype/msttcorefonts/arialbi.ttf
 /usr/share/fonts/truetype/msttcorefonts/ariali.ttf
 /usr/share/fonts/truetype/msttcorefonts/arial.ttf
 
 so should be able to make progress as described in the Guidelines.
 Ted.

Addendum:

Well, the fonts were installed as above, indeed. However, according
to the PLoS Guidelines one must generate .afm files before using
them in R, along the lines of:

  First, convert the Arial .ttf files to afm:

  ttf2afm /usr/share/fonts/msttcorefonts/arial.ttf  ~/arial.afm
  ttf2afm /usr/share/fonts/msttcorefonts/ariali.ttf  ~/ariali.afm
  ttf2afm /usr/share/fonts/msttcorefonts/arialbd.ttf  ~/arialbd.afm
  ttf2afm /usr/share/fonts/msttcorefonts/arialbi.ttf  ~/arialbi.afm

and then one can use them in R's postscript() with the family
argument on the lines of

  postscript(file=try.ps, horizontal=F, onefile=F, width=4, height=4,
family=c(/home/stephen/arial.afm, /home/stephen/arialbd.afm,
/home/stephen/ariali.afm, /home/stephen/arialbi.afm),
pointsize=12)

However,
(a) I do not have the 'ttf2afm' program;
(b) Synaptic cannot find it in the repositories.

So, I'm off on another hunt!
Ted.


E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk
Fax-to-email: +44 (0)870 094 0861
Date: 19-Nov-09   Time: 12:58:32
-- XFMail --

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


[R] Accessing list names in lapply

2009-11-19 Thread Bjarke Christensen

Hi,

When using lapply (or sapply) to loop over a list, can I somehow access the
index of the list from inside the function?

A trivial example:

df1 - split(
   x=rnorm(n=100, sd=seq(from=1, to=10, each=10)),
   f=letters[seq(from=1, to=10, each=10)]
 )
str(df1)
#List of 10
# $ a: num [1:10] -0.801 0.418 1.451 -0.554 -0.578 ...
# $ b: num [1:10] -2.464 0.279 4.099 -2.483 1.921 ...
# $ c: num [1:10] -1.14 -1.773 2.512 -2.072 -0.904 ...
# $ d: num [1:10] 2.109 1.243 0.627 -2.343 -6.071 ...
#...
par(mfcol=c(5,2))
lapply(df1, plot)

This plots each element of the list, but the label on the vertical axis is
X[[0L]] (as expected from the documentation in ?lapply). I'd like the
heading for each plot to be the name of that item in the list. This can be
achieved by using a for-loop:

for (i in names(df1)) plot(df1[[i]], ylab=i)

but can it somehow be achieved bu using lapply? I would be hoping for
something like

lapply(df1, function(x) plot(x, ylab=parent.index()))

or some way to parse the index number out of the call, using match.call()
or something like that.

Thanks in advance for any comments,
Bjarke Christensen

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

2009-11-19 Thread Gabor Grothendieck
lapply over the list names rather than the list itself:

junk - lapply(names(df1), function(nm) plot(df1[[nm]], ylab = nm))


On Thu, Nov 19, 2009 at 7:27 AM, Bjarke Christensen
bjarke.christen...@sydbank.dk wrote:

 Hi,

 When using lapply (or sapply) to loop over a list, can I somehow access the
 index of the list from inside the function?

 A trivial example:

 df1 - split(
   x=rnorm(n=100, sd=seq(from=1, to=10, each=10)),
   f=letters[seq(from=1, to=10, each=10)]
  )
 str(df1)
 #List of 10
 # $ a: num [1:10] -0.801 0.418 1.451 -0.554 -0.578 ...
 # $ b: num [1:10] -2.464 0.279 4.099 -2.483 1.921 ...
 # $ c: num [1:10] -1.14 -1.773 2.512 -2.072 -0.904 ...
 # $ d: num [1:10] 2.109 1.243 0.627 -2.343 -6.071 ...
 #...
 par(mfcol=c(5,2))
 lapply(df1, plot)

 This plots each element of the list, but the label on the vertical axis is
 X[[0L]] (as expected from the documentation in ?lapply). I'd like the
 heading for each plot to be the name of that item in the list. This can be
 achieved by using a for-loop:

 for (i in names(df1)) plot(df1[[i]], ylab=i)

 but can it somehow be achieved bu using lapply? I would be hoping for
 something like

 lapply(df1, function(x) plot(x, ylab=parent.index()))

 or some way to parse the index number out of the call, using match.call()
 or something like that.

 Thanks in advance for any comments,
 Bjarke Christensen

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

2009-11-19 Thread Duncan Murdoch

On 19/11/2009 7:27 AM, Bjarke Christensen wrote:

Hi,

When using lapply (or sapply) to loop over a list, can I somehow access the
index of the list from inside the function?
  


No, but you can loop over the indices in lapply, not just in a for 
loop.  For example,


lapply(names(df1), function(x) plot(df1[[x]], ylab=x))

Duncan Murdoch

A trivial example:

df1 - split(
   x=rnorm(n=100, sd=seq(from=1, to=10, each=10)),
   f=letters[seq(from=1, to=10, each=10)]
 )
str(df1)
#List of 10
# $ a: num [1:10] -0.801 0.418 1.451 -0.554 -0.578 ...
# $ b: num [1:10] -2.464 0.279 4.099 -2.483 1.921 ...
# $ c: num [1:10] -1.14 -1.773 2.512 -2.072 -0.904 ...
# $ d: num [1:10] 2.109 1.243 0.627 -2.343 -6.071 ...
#...
par(mfcol=c(5,2))
lapply(df1, plot)

This plots each element of the list, but the label on the vertical axis is
X[[0L]] (as expected from the documentation in ?lapply). I'd like the
heading for each plot to be the name of that item in the list. This can be
achieved by using a for-loop:

for (i in names(df1)) plot(df1[[i]], ylab=i)

but can it somehow be achieved bu using lapply? I would be hoping for
something like

lapply(df1, function(x) plot(x, ylab=parent.index()))

or some way to parse the index number out of the call, using match.call()
or something like that.

Thanks in advance for any comments,
Bjarke Christensen

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] [Follow-up] Re: PLoS, Arial, R linux

2009-11-19 Thread Dirk Eddelbuettel

On 19 November 2009 at 13:00, (Ted Harding) wrote:
| However,
| (a) I do not have the 'ttf2afm' program;
| (b) Synaptic cannot find it in the repositories.
| 
| So, I'm off on another hunt!

i)   You should try to get over the 'Synaptic is the only interface to
 package' syndrome. It limits your ability to use your system to the 
 fullest.

ii)  E.g. consider http://packages.debian.org/ which has the handy shortcut
 http://packages.debian.org/file:path for the search for paths ending in 
 the keyword.

iii) This was another question for r-sig-debian, not r-help

iv)  You want the texlive-font-utils package as per ii) and
 
http://packages.debian.org/search?searchon=contentskeywords=ttf2afmmode=filenamesuite=unstablearch=any

Dirk

-- 
Three out of two people have difficulties with fractions.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] [Follow-up] Re: PLoS, Arial, R linux

2009-11-19 Thread Liviu Andronic
On 11/19/09, Ted Harding ted.hard...@manchester.ac.uk wrote:
  However,
  (a) I do not have the 'ttf2afm' program;
  (b) Synaptic cannot find it in the repositories.

http://packages.debian.org/search?searchon=contentskeywords=ttf2afmmode=exactfilenamesuite=testingarch=any

Liviu

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


[R] t-criterion calculation using means and SE

2009-11-19 Thread Антон Морковин
Dear all,

is there any functions which allow to calculate Student t-criterion using 
means, their SE and sample size? I've seek for, but bulit-in t-criterion works 
only with initial sample...

Best regards,

A.Morkovin

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

2009-11-19 Thread Romain Francois

Maybe this : http://tolstoy.newcastle.edu.au/R/e4/help/08/04/8720.html

Romain

On 11/19/2009 01:27 PM, Bjarke Christensen wrote:

Hi,

When using lapply (or sapply) to loop over a list, can I somehow access the
index of the list from inside the function?

A trivial example:

df1- split(
x=rnorm(n=100, sd=seq(from=1, to=10, each=10)),
f=letters[seq(from=1, to=10, each=10)]
  )
str(df1)
#List of 10
# $ a: num [1:10] -0.801 0.418 1.451 -0.554 -0.578 ...
# $ b: num [1:10] -2.464 0.279 4.099 -2.483 1.921 ...
# $ c: num [1:10] -1.14 -1.773 2.512 -2.072 -0.904 ...
# $ d: num [1:10] 2.109 1.243 0.627 -2.343 -6.071 ...
#...
par(mfcol=c(5,2))
lapply(df1, plot)

This plots each element of the list, but the label on the vertical axis is
X[[0L]] (as expected from the documentation in ?lapply). I'd like the
heading for each plot to be the name of that item in the list. This can be
achieved by using a for-loop:

for (i in names(df1)) plot(df1[[i]], ylab=i)

but can it somehow be achieved bu using lapply? I would be hoping for
something like

lapply(df1, function(x) plot(x, ylab=parent.index()))

or some way to parse the index number out of the call, using match.call()
or something like that.

Thanks in advance for any comments,
Bjarke Christensen


--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://tr.im/EAD5 : LondonR slides
|- http://tr.im/BcPw : celebrating R commit #5
`- http://tr.im/ztCu : RGG #158:161: examples of package IDPmisc

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

2009-11-19 Thread Henrique Dallazuanna
You can try this:

par(mfcol=c(5,2))
lapply(df1, function(x){
nm - 
names(eval(as.list(sys.call(-1))[[2]]))[as.numeric(gsub([^0-9],
, deparse(substitute(x]
plot(x, main = nm)
})

On Thu, Nov 19, 2009 at 10:27 AM, Bjarke Christensen
bjarke.christen...@sydbank.dk wrote:

 Hi,

 When using lapply (or sapply) to loop over a list, can I somehow access the
 index of the list from inside the function?

 A trivial example:

 df1 - split(
   x=rnorm(n=100, sd=seq(from=1, to=10, each=10)),
   f=letters[seq(from=1, to=10, each=10)]
  )
 str(df1)
 #List of 10
 # $ a: num [1:10] -0.801 0.418 1.451 -0.554 -0.578 ...
 # $ b: num [1:10] -2.464 0.279 4.099 -2.483 1.921 ...
 # $ c: num [1:10] -1.14 -1.773 2.512 -2.072 -0.904 ...
 # $ d: num [1:10] 2.109 1.243 0.627 -2.343 -6.071 ...
 #...
 par(mfcol=c(5,2))
 lapply(df1, plot)

 This plots each element of the list, but the label on the vertical axis is
 X[[0L]] (as expected from the documentation in ?lapply). I'd like the
 heading for each plot to be the name of that item in the list. This can be
 achieved by using a for-loop:

 for (i in names(df1)) plot(df1[[i]], ylab=i)

 but can it somehow be achieved bu using lapply? I would be hoping for
 something like

 lapply(df1, function(x) plot(x, ylab=parent.index()))

 or some way to parse the index number out of the call, using match.call()
 or something like that.

 Thanks in advance for any comments,
 Bjarke Christensen

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




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

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


Re: [R] re placing the dates format in R for exporting the data set...

2009-11-19 Thread David Winsemius


On Nov 18, 2009, at 11:00 PM, ychu066 wrote:



hey Jim ,

I have solve the column name problems now.  But i am still unable to  
read

the date in R ...

toms_dat- replace(toms_dat, toms_dat ==2009-08-24, 6)


replace needs its first argument to be a vector, while you have given  
it a dataframe.


Look at these examples:
 toms - data.frame(a=letters[1:10], b=Sys.Date() + 1:10)
 toms
   a  b
1  a 2009-11-20
2  b 2009-11-21
3  c 2009-11-22
4  d 2009-11-23
5  e 2009-11-24
6  f 2009-11-25
7  g 2009-11-26
8  h 2009-11-27
9  i 2009-11-28
10 j 2009-11-29
 replace(toms$b, toms$b==2009-11-23, 6)
Error in as.Date.numeric(value) : 'origin' must be supplied

Notice that this did not
 replace(toms$b, toms$b==2009-11-23, 2008-01-01)
 [1] 2009-11-20 2009-11-21 2009-11-22 2008-01-01 2009-11-24  
2009-11-25 2009-11-26

 [8] 2009-11-27 2009-11-28 2009-11-29
 toms
   a  b
1  a 2009-11-20
2  b 2009-11-21
3  c 2009-11-22
4  d 2009-11-23
5  e 2009-11-24
6  f 2009-11-25
7  g 2009-11-26
8  h 2009-11-27
9  i 2009-11-28
10 j 2009-11-29

Notice that the replace() operation did not do anything to toms. If  
you had wanted it to, you would have needed to do:


toms$b - replace(toms$b, toms$b==2009-11-23, 2008-01-01)

Now, if you want further assistance you need to provide a working  
excaple that has the same features as your problem. Use str(toms_dat)  
to see what type your columns are ant then perhaps:


dput(head(toms_dat))

or:

dump(toms_dat, file=stdout() )

or if toms_dat is big, then:

smalltoms - head(toms_dat)
dump(smalltoms, stdout() )




the toms_dat is a data frame , and I  want to replace the date to be a
single number eg:1,2,3, 

regards,
Tom.





jholtman wrote:


First of all '2009-08-06' is 1995; this is probably not what you were
expecting.  What do you what your expression to do?  Is 'toms_dat' a
dataframe?  if so, your expression 'toms_dat ==2009-08-06' seem
strange.  So tell us what you want to do, not how you want to do it.

On Tue, Nov 17, 2009 at 4:54 PM, ychu066 ychu...@aucklanduni.ac.nz
wrote:


hi everyone, i am having difficulties with replacing the dates  
format in

R
for exporting the data set...

eg: the code that i used was
toms_dat- replace(toms_dat, toms_dat ==2009-08-06, 2)
toms_dat- replace(toms_dat, toms_dat ==2009-08-04, 1)

but when i export the data as into txt file or excel file the  
dates come

up
with very large numbers .:drunk:

please help me ...=)
--
View this message in context:
http://old.nabble.com/replacing-the-dates-format-in-R-for-exporting-the-data-set...-tp26396492p26396492.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.





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

What is the problem that you are trying to solve?

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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://old.nabble.com/replacing-the-dates-format-in-R-for-exporting-the-data-set...-tp26396492p26420068.html
Sent from the R help mailing list archive at Nabble.com.

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


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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


[R] Acceptance sampling

2009-11-19 Thread Bodil Tufvesson

Hi

I'm trying to learn how to use R when it comes to acceptance sampling.

What I want to do is to type in a lot size, an AQL level and a LQ level and get 
the required sample size in accordance with inspection level II (ISO 2859-2).

I have tried  find.plan (c(0.01,0.95), c(0.07,0.05), type=hypergeom, 100)$n, 
but the value did not correspond to the value of the standard.

I then tried  x-OC2c(500,10,type=hypergeom,N=10001,pd=0.0315) and came to 
the conclusion that R is using inspection level III.

Can I use any command to get inspection level II?

Best regards
Bodil Tufvesson


[[alternative HTML version deleted]]

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


Re: [R] How do I change the colour and format for the trelli plot ?

2009-11-19 Thread Hrishi Mittal

Add col=i in the histogram call.
-- 
View this message in context: 
http://old.nabble.com/How-do-I-change-the-colour-and-format-for-the-trelli-plot---tp26418382p26421302.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] [Follow-up] Re: PLoS, Arial, R linux

2009-11-19 Thread Frank E Harrell Jr

Also see of the journal will let you use NimbusSan:

pdf('my.pdf', onefile=FALSE, pointsize=18,
family=NimbusSan,height=6,width=8,paper=special)
...
dev.off()
embedFonts('my.pdf')

Frank

Dirk Eddelbuettel wrote:

On 19 November 2009 at 13:00, (Ted Harding) wrote:
| However,
| (a) I do not have the 'ttf2afm' program;
| (b) Synaptic cannot find it in the repositories.
| 
| So, I'm off on another hunt!


i)   You should try to get over the 'Synaptic is the only interface to
 package' syndrome. It limits your ability to use your system to the 
 fullest.


ii)  E.g. consider http://packages.debian.org/ which has the handy shortcut
 http://packages.debian.org/file:path for the search for paths ending in 
 the keyword.


iii) This was another question for r-sig-debian, not r-help

iv)  You want the texlive-font-utils package as per ii) and
 
http://packages.debian.org/search?searchon=contentskeywords=ttf2afmmode=filenamesuite=unstablearch=any

Dirk




--
Frank E Harrell Jr   Professor and Chair   School of Medicine
 Department of Biostatistics   Vanderbilt University

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

2009-11-19 Thread David Winsemius


On Nov 19, 2009, at 4:39 AM, baptiste auguie wrote:


Hi,

Try this,


d - data.frame(a=1:4, b=3:6)

var - a

mean(d[var])


I tried get() on Simpson's pasted argument without success. Assuming  
the OP still wanted to use only text arguments, then this approach works


dfn - d

get(dfn)[var]

So get() works only on complete objects and not on expressions that  
include extraction operations.





## or, if you are not aware of
## fortune(parse)

xx - paste(d$,var, sep=)
mean(eval(parse(text=xx)))

HTH,

baptiste




2009/11/19 William Simpson william.a.simp...@gmail.com:

I have quite a complicated problem that's hard to describe.

Suppose I have a dataframe d. I want to access the vector d$var,  
where
var is one of the variables in d. Just take for granted that  
there's a

good reason I want to do this as follows.

var-DeOxyA
xx-paste(d$,var, sep=)
mean(xx)
[1] NA
Warning message:
In mean.default(xx) : argument is not numeric or logical: returning  
NA



mean(d$DeOxyA)

[1] 21.98904

How can I convert xx so I can do mean(xx), for example? Currently xx
is a character, not a variable.
as.numeric doesn't do it. I want R to see
mean(DeOxyA), not
mean(DeOxyA)

I'm stumped.

Thanks very much for any help.

Bill

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


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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


[R] ddply function nesting problems

2009-11-19 Thread Jason Rupert
While putting my R code into functions, I've encountered a ddply function 
nesting issue and need a bit of advice on the proper way to fix it.  I've tried 
several approahces, but neither worked and I need to have the ability to 
include the cut, range, and fullseq methods within ddply.  (For a bit of 
that explanation refer to 
http://finzi.psych.upenn.edu/Rhelp08/2009-February/187331.html)

Thus, in order to preserve that functionality, and put my code within 
functions, I needed to have an architecture similar to the following 
implemented, where you end up running:
function_nesting()

Unfortunately this produced errors within the ddply where it does not appear to 
be recognizing or allowing variables or functions to be processed within side 
its function.  

Thank you for any advice about how to proceed forward. 


determine_counts-function()
{

    min_range-1
    max_range-30
    bin_range_size-5
    Me_df-data.frame(Data = c(1:15), Person = Me)
    You_df-data.frame(Data = c(10:20), Person = You)
    Them_df-data.frame(Data = c(15:25), Person = Them)
    Group_df_tmp-rbind(Me_df,You_df)
    Group_df-rbind(Group_df_tmp,Them_df)
    Group_df$Person - factor(Group_df$Person, levels = c(Them, You, 
Me))
    #counts - ddply(Group_df, .(cut(Data, breaks=fullseq(range(Data), 5)), 
Person), nrow)
    
 # Approach 1
        counts - ddply(Group_df, .(cut(Data, 
breaks=fullseq(range(c(Group_df$Data, min_range, max_range)), bin_range_size)), 
Person), nrow)
    
        # Approach 2
    range_tmp-range(c(Group_df$Data, min_range, max_range))
    counts - ddply(Group_df, .(cut(Data, breaks=fullseq(range_tmp, 
bin_range_size)), Person), nrow)
    
    
    names(counts) - c(Bin, Person, Frequency)
    qplot(Person, Frequency, data = counts, fill = Person, geom=bar, 
stat=identity, width = 0.9, xlab=Person) +  facet_grid(. ~ Bin)
}




function_nesting-function()
{
    determine_counts()
}



However, if the code is just run straight through without being nested it works 
fine:

    min_range-1
    max_range-30
    bin_range_size-5 
    Me_df-data.frame(Data = c(1:15), Person = Me)
    You_df-data.frame(Data = c(10:20), Person = You)
    Them_df-data.frame(Data = c(15:25), Person = Them)
    Group_df_tmp-rbind(Me_df,You_df)
    Group_df-rbind(Group_df_tmp,Them_df)
    Group_df$Person - factor(Group_df$Person, levels = c(Them, You, 
Me))
    #counts - ddply(Group_df, .(cut(Data, breaks=fullseq(range(Data), 5)), 
Person), nrow)
    counts - ddply(Group_df, .(cut(Data, 
breaks=fullseq(range(c(Group_df$Data, min_range, max_range)), bin_range_size)), 
Person), nrow)

Unfortunately this is not within a function, so thanks again for any advice on 
how to approach this issue. 




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

2009-11-19 Thread Антон Морковин
Dear all,

I need to create n*n table with sums of all possible pair combinations of 
numbers from n-row column. What function allows it? 
 
Best regards,
 
A.Morkovin

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

2009-11-19 Thread Sunita Patil
Hello Sir

Thanx even I will try to work out on your suggestions, will keep you updated
on the progress. Thanx a lot

Regards

Our Thoughts have the Power to Change our Destiny.
Sunita


On Thu, Nov 19, 2009 at 3:50 PM, Jim Lemon j...@bitwrit.com.au wrote:

 On 11/19/2009 03:13 AM, Sunita Patil wrote:

 Hello Sir

 I have got 150 observations, got 10 posts/ 6 departments/ tasks vary from
 5
 to 10,

 A few of the variables are crossed specially in case of Office boy, where
 the tasks are like open the door, put on the lights,

 Yes time variable I have used Chron package, so that it works well

 My aim for this study is to check the amount of time and its variability
 for groups of tasks

 Its my project work so need to work this out myself if it doesnt work then
 I
 will have to consult a statistician

 Thanks for guiding me to put up the question in more clearer way, I will
 sure take care next time


 Hi Sunita,
 You seem to have two aims, one to display the tasks, and the other to
 summarize the times. I have been looking at the plot.dendrite function and
 it might perform the first task with a bit of rewriting (which it needs
 anyway). The second task might be handled by the hierobarp function. I'll
 try to work out whether these will do the job in the next day or two.

 Jim



[[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] Presentation of data in Graphical format

2009-11-19 Thread Sunita Patil
Hello Sir

Thanx a lot, will try Pareto chart for my data

Regards

Our Thoughts have the Power to Change our Destiny.
Sunita


On Thu, Nov 19, 2009 at 12:29 PM, Petr PIKAL petr.pi...@precheza.cz wrote:

 Well, from what you say it seems to me that you could also use Pareto
 charts together with some aggregation of data. But it depends on what you
 want to show to your audience. Below is some code which I slightly adapted
 form original author.

 Regards
 Petr


 #--
 # pareto. Produces a Pareto plot of effects.
 #
 # Parameters:
 # effects - vector or matrix of effects to plot.
 # names - vector of names to label the effects.
 # xlab - String to display as the x axis label.
 # ylab - String to display as the y axis label.
 # perlab - Label for the cumulative percentage label.
 # heading - Vector of names for plot heading.
 #
 pareto - function(effects, names=NULL, xlab=NULL, ylab=Magnitude of
 Effect, indicate.percent=TRUE, perlab=Cumulative Percentage,
 heading=NULL, trunc.perc=.95, long.names=FALSE,...)
 {
# set up graphics parameters, note: set las=2 for perpendicular
 axis.
oldpar - par( mar=c(6, 4, 2, 4) + 0.1 , las=3)
on.exit(par(oldpar))

if( ! is.matrix(effects)) effects-as.matrix( effects )

for( i in 1:ncol(effects) )
{

if( i==2 ) oldpar$ask-par(ask=TRUE)$ask
# draw bar plot
eff.ord - rev(order(abs(effects[,i])))
ef - abs(effects[eff.ord,i])
names-as.character(names)[eff.ord]
# plot barplot

# get cumulative sum of effects
sumeff - cumsum(ef)
m-max(ef)
sm-sum(ef)
sumeff - sumeff/sm

vyber-sumefftrunc.perc
suma.ef-sum(ef[vyber])
sumeff-c(sumeff[!vyber],1)*m
ef-c(ef[!vyber],suma.ef)
names-c(as.character(names[!vyber]),Dalsi)
ylimit-max(ef) + max(ef)*0.19
ylimit-c(0,ylimit)
par( mar=c(6, 4, 2, 4) + 0.1 , las=3)

if (long.names) {
x- barplot(ef, names.arg=names, ylim=ylimit, xlab=xlab,
 ylab=ylab, main=heading[i], plot=F, ...)
x- barplot(ef, ylim=ylimit, xlab=xlab, ylab=ylab,
 main=heading[i], ...)
text(x,ylimit[2]/10, names, srt=90, adj=0, cex=.7)} else {

x-barplot(ef, names.arg=names, ylim=ylimit, xlab=xlab,
 ylab=ylab, main=heading[i], ...)
}


if( indicate.percent == TRUE ){



# draws curve.
lines(x, sumeff, lty=solid, lwd=2, col=purple)

# draw 80% line
lines( c(0,max(x)), rep(0.8*m,2) )
# draw axis labling percentage.
at - c(0:5)* m/5
axis(4, at=at,
 labels=c(0,20,40,60,80,100), pos=max(x)+.6)
# add axis lables
par(las=0)
mtext(perlab, 4, line=2)
}

} # end for each col
 }


 #Don Wingate


 r-help-boun...@r-project.org napsal dne 18.11.2009 16:17:32:

  yes in my data the 1st column is the main category say suppose
 Secretary
  the second column is the sub category HR Dept the 3rd column is the
 list
  of duties performed by the Secretary from HR dept and 4th column is time
  required to perform the duty
 
  so there are many such posts and dept with varied duties and times resp.
 
  Regards
 
  Our Thoughts have the Power to Change our Destiny.
  Sunita
 
 
  On Wed, Nov 18, 2009 at 8:42 PM, Petr PIKAL petr.pi...@precheza.cz
 wrote:
 
   Hi
  
   r-help-boun...@r-project.org napsal dne 18.11.2009 16:01:27:
  
Yes I tried all the basic ones like box plot, pie chart, etc but the
   data
representation isnt that clear.
   
  
   I agree with Tal. But it partly depends on your data. If you have many
   levels and only few time values in each boxplot would not look well.
 Maybe
   you could check also ?xtabs or ?table and/or R graph gallery
   http://addictedtor.free.fr/graphiques/ if you find suitable graph.
  
   Regards
   Petr
  
  
  
   
Regards
   
Our Thoughts have the Power to Change our Destiny.
Sunita
   
   
On Wed, Nov 18, 2009 at 7:20 PM, Tal Galili tal.gal...@gmail.com
   wrote:
   
 I would start with
 ?boxplot


 --


 My contact information:
 Tal Galili
 E-mail: tal.gal...@gmail.com
 Phone number: 972-52-7275845
 FaceBook: Tal Galili
 My Blogs:
 http://www.talgalili.com (Web and general, Hebrew)
 http://www.biostatistics.co.il (Statistics, Hebrew)
 http://www.r-statistics.com/ (Statistics,R, English)



Re: [R] Accessing list names in lapply

2009-11-19 Thread Bjarke Christensen
Thanks to everybody who replied - I got three distinct, very useful
suggestions.

Bjarke Christensen



   
 Romain Francois   
 romain.francois@ 
 dbmail.com   Til 
   Bjarke Christensen  
 19-11-2009 14:33  bjarke.christen...@sydbank.dk 
cc 
   r-help@r-project.org
  Emne 
   Re: [R] Accessing list names in 
   lapply  
   
   
   
   
   
   




Maybe this : http://tolstoy.newcastle.edu.au/R/e4/help/08/04/8720.html

Romain

On 11/19/2009 01:27 PM, Bjarke Christensen wrote:
 Hi,

 When using lapply (or sapply) to loop over a list, can I somehow access
the
 index of the list from inside the function?

 A trivial example:

 df1- split(
 x=rnorm(n=100, sd=seq(from=1, to=10, each=10)),
 f=letters[seq(from=1, to=10, each=10)]
   )
 str(df1)
 #List of 10
 # $ a: num [1:10] -0.801 0.418 1.451 -0.554 -0.578 ...
 # $ b: num [1:10] -2.464 0.279 4.099 -2.483 1.921 ...
 # $ c: num [1:10] -1.14 -1.773 2.512 -2.072 -0.904 ...
 # $ d: num [1:10] 2.109 1.243 0.627 -2.343 -6.071 ...
 #...
 par(mfcol=c(5,2))
 lapply(df1, plot)

 This plots each element of the list, but the label on the vertical axis
is
 X[[0L]] (as expected from the documentation in ?lapply). I'd like the
 heading for each plot to be the name of that item in the list. This can
be
 achieved by using a for-loop:

 for (i in names(df1)) plot(df1[[i]], ylab=i)

 but can it somehow be achieved bu using lapply? I would be hoping for
 something like

 lapply(df1, function(x) plot(x, ylab=parent.index()))

 or some way to parse the index number out of the call, using match.call()
 or something like that.

 Thanks in advance for any comments,
 Bjarke Christensen

--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://tr.im/EAD5 : LondonR slides
|- http://tr.im/BcPw : celebrating R commit #5
`- http://tr.im/ztCu : RGG #158:161: examples of package IDPmisc

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

2009-11-19 Thread David Winsemius


On Nov 19, 2009, at 9:40 AM, Антон Морковин wrote:


Dear all,

I need to create n*n table with sums of all possible pair  
combinations of numbers from n-row column. What function allows it?




?expand.grid


Best regards,

A.Morkovin

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


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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


Re: [R] 3D plot, rotatable and with adjustable symbols

2009-11-19 Thread Greg Snow
Look at the ggobi program and the rggobi package for interactions between R and 
ggobi.

-- 
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 Joel Fürstenberg-Hägg
 Sent: Thursday, November 19, 2009 2:27 AM
 To: r-help@r-project.org
 Subject: [R] 3D plot, rotatable and with adjustable symbols
 
 
 Hi all,
 
 
 
 I've tried to make a 3D plot, but have run into some problems.
 
 
 
 I'd like to have a plot that I can rotate interactively using the
 mouse, which is possible using the plots3d {R.basic}. However, I would
 like to change the symbols used as the points, but there's no pch in
 plot3d().
 
 
 
 If I use the Scatterplot3d package, I'm able to change this, but not
 able to rotate the plot interactively.
 
 
 
 Does anyone know a solution to this? Maybe another package is better?
 
 
 
 Best regards,
 
 
 
 Joel
 
 _
 Nya Windows 7 gör allt lite enklare. Hitta en dator som passar dig!
 http://windows.microsoft.com/shop
   [[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] ddply function nesting problems

2009-11-19 Thread baptiste auguie
Hi,

I think your ddply call with a calculation inside .(  ) is the
problem. Are you sure you need to do this? Performing the cut outside
ddply seems to work fine,

determine_counts-function()
{

min_range-1
max_range-30
bin_range_size-5
Me_df-data.frame(Data = c(1:15), Person = Me)
You_df-data.frame(Data = c(10:20), Person = You)
Them_df-data.frame(Data = c(15:25), Person = Them)
Group_df_tmp-rbind(Me_df,You_df)
Group_df-rbind(Group_df_tmp,Them_df)
Group_df$Person - factor(Group_df$Person, levels = c(Them,
You, Me))

Group_df - transform(Group_df, cut=cut(Data,
  breaks=fullseq(range(c(Data,
min_range, max_range)),
bin_range_size)))

counts - ddply(Group_df, .(cut, Person), nrow)


names(counts) - c(Bin, Person, Frequency)
qplot(Person, Frequency, data = counts,
  fill = Person, geom=bar, stat=identity, width = 0.9,
xlab=Person) +
facet_grid(. ~ Bin)
}

 function_nesting()

HTH,

baptiste


2009/11/19 Jason Rupert jasonkrup...@yahoo.com:
 While putting my R code into functions, I've encountered a ddply function 
 nesting issue and need a bit of advice on the proper way to fix it.  I've 
 tried several approahces, but neither worked and I need to have the ability 
 to include the cut, range, and fullseq methods within ddply.  (For a 
 bit of that explanation refer to 
 http://finzi.psych.upenn.edu/Rhelp08/2009-February/187331.html)

 Thus, in order to preserve that functionality, and put my code within 
 functions, I needed to have an architecture similar to the following 
 implemented, where you end up running:
 function_nesting()

 Unfortunately this produced errors within the ddply where it does not appear 
 to be recognizing or allowing variables or functions to be processed within 
 side its function.

 Thank you for any advice about how to proceed forward.


 determine_counts-function()
 {

     min_range-1
     max_range-30
     bin_range_size-5
     Me_df-data.frame(Data = c(1:15), Person = Me)
     You_df-data.frame(Data = c(10:20), Person = You)
     Them_df-data.frame(Data = c(15:25), Person = Them)
     Group_df_tmp-rbind(Me_df,You_df)
     Group_df-rbind(Group_df_tmp,Them_df)
     Group_df$Person - factor(Group_df$Person, levels = c(Them, You, 
 Me))
     #counts - ddply(Group_df, .(cut(Data, breaks=fullseq(range(Data), 
 5)), Person), nrow)

  # Approach 1
         counts - ddply(Group_df, .(cut(Data, 
 breaks=fullseq(range(c(Group_df$Data, min_range, max_range)), 
 bin_range_size)), Person), nrow)

         # Approach 2
     range_tmp-range(c(Group_df$Data, min_range, max_range))
     counts - ddply(Group_df, .(cut(Data, breaks=fullseq(range_tmp, 
 bin_range_size)), Person), nrow)


     names(counts) - c(Bin, Person, Frequency)
     qplot(Person, Frequency, data = counts, fill = Person, geom=bar, 
 stat=identity, width = 0.9, xlab=Person) +  facet_grid(. ~ Bin)
 }




 function_nesting-function()
 {
     determine_counts()
 }



 However, if the code is just run straight through without being nested it 
 works fine:

     min_range-1
     max_range-30
     bin_range_size-5
     Me_df-data.frame(Data = c(1:15), Person = Me)
     You_df-data.frame(Data = c(10:20), Person = You)
     Them_df-data.frame(Data = c(15:25), Person = Them)
     Group_df_tmp-rbind(Me_df,You_df)
     Group_df-rbind(Group_df_tmp,Them_df)
     Group_df$Person - factor(Group_df$Person, levels = c(Them, You, 
 Me))
     #counts - ddply(Group_df, .(cut(Data, breaks=fullseq(range(Data), 
 5)), Person), nrow)
     counts - ddply(Group_df, .(cut(Data, 
 breaks=fullseq(range(c(Group_df$Data, min_range, max_range)), 
 bin_range_size)), Person), nrow)

 Unfortunately this is not within a function, so thanks again for any advice 
 on how to approach this issue.




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

2009-11-19 Thread Carlos Hernandez
Dear All,
I appreciate any advice or hints you could provide about the following.

We are running R code in a server (running Windows XP and QuadCore Xeon
processors, see details below) and we would like to use the server
efficiently. Our code takes a bit more than 6 seconds per 25 iterations in
the server using a default R 2.10.0 installation.

We tested our code in two other computers, a Dell Latitute and a MacBook
Pro, and from the details that i include below you will notice that the code
needs almost twice the time when we used R for Windows compared against the
time the code needs when we use Linux or MacOSX 10.6.2 in each of these
computers.

I'm sorry I don't provide details on the code we are using. The code
consists of all sort of operations (matrix inverses, random number
generation, vectorized functions, a few loops, and so on). I hope I can get
some advice from you despite the lack of specific code details.

Is there any important R feature we should configure manually in the windows
server to speed the code up? Is there an optimized BLAS available somewhere
for this type of machine? Is these something else apart of an optimized BLAS
that we could do to improve the timing?

Best regards,

Carlos




**Server running WinXP (QuadCore Xeon 2.6GHz 8G Ram)
Time per 25 Iterations 6.17


**Dell Latitude running Linux (R 2.9.2, Intel Core 2 Duo P9500 @ 2.53GHz,
4GB ram)
Time per 25 iterations 2.88

**Dell Latitude running Win Vista (R 2.10.0, Intel Core 2 Duo P9500 @
2.53GHz, 4GB ram) with New DLL in terminal
Time per 25 iterations 5.53

---
**Macbook pro (2.16GHz Intel Core 2 Duo  2GB ram)
Time per 25 Iterations 4.58

**Macbook pro running WinXp (2.16GHz Intel Core 2 Duo  2GB ram)
Time per 25 Iterations 8.23


note: for the Dell and MacBook Pro we replaced the Rblas.dll file of R for
Windows with the file available here
http://cran.r-project.org/bin/windows/contrib/ATLAS/C2D/

[[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] Efficient cbind of elements from two lists

2009-11-19 Thread Stephan Dlugosz

Hi!

I have a data.frame data and splitted it.

data - split(data, data[,1])

This is a quite slow procedure; and I do not want to do it again. So, 
any unsplit and resplit is no option for me.
But: I have to cbind variables to the splitted data from another list, 
that contains of vectors with matching sizes, so


for (i in 1:length(data)) {
  data[[i]] - cbind(data[[i]], l[[i]]))
}

works well; but very, very slowly.
The lapply solution:

data - lapply(1:k, function(i) cbind(data[[i]], l[[i]]))

does not improve the situation, but allows for mclapply from the 
multicore package...

Is there a more efficient way to combine elements from two lists?

Thank you very much!

Greetings,
Stephan

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


Re: [R] Efficient cbind of elements from two lists

2009-11-19 Thread Jorge Ivan Velez
Dear Stephan,

Here is a suggestion using do.call():

res - do.call(cbind, yourlist)
res

HTH,
Jorge


On Thu, Nov 19, 2009 at 10:03 AM, Stephan Dlugosz  wrote:

 Hi!

 I have a data.frame data and splitted it.

 data - split(data, data[,1])

 This is a quite slow procedure; and I do not want to do it again. So, any
 unsplit and resplit is no option for me.
 But: I have to cbind variables to the splitted data from another list,
 that contains of vectors with matching sizes, so

 for (i in 1:length(data)) {
  data[[i]] - cbind(data[[i]], l[[i]]))
 }

 works well; but very, very slowly.
 The lapply solution:

 data - lapply(1:k, function(i) cbind(data[[i]], l[[i]]))

 does not improve the situation, but allows for mclapply from the multicore
 package...
 Is there a more efficient way to combine elements from two lists?

 Thank you very much!

 Greetings,
 Stephan

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


[[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] advice about R for windows speed

2009-11-19 Thread Marc Schwartz

On Nov 19, 2009, at 9:25 AM, Carlos Hernandez wrote:


Dear All,
I appreciate any advice or hints you could provide about the  
following.


We are running R code in a server (running Windows XP and QuadCore  
Xeon

processors, see details below) and we would like to use the server
efficiently. Our code takes a bit more than 6 seconds per 25  
iterations in

the server using a default R 2.10.0 installation.

We tested our code in two other computers, a Dell Latitute and a  
MacBook
Pro, and from the details that i include below you will notice that  
the code
needs almost twice the time when we used R for Windows compared  
against the
time the code needs when we use Linux or MacOSX 10.6.2 in each of  
these

computers.

I'm sorry I don't provide details on the code we are using. The code
consists of all sort of operations (matrix inverses, random number
generation, vectorized functions, a few loops, and so on). I hope I  
can get

some advice from you despite the lack of specific code details.

Is there any important R feature we should configure manually in the  
windows
server to speed the code up? Is there an optimized BLAS available  
somewhere
for this type of machine? Is these something else apart of an  
optimized BLAS

that we could do to improve the timing?

Best regards,

Carlos




**Server running WinXP (QuadCore Xeon 2.6GHz 8G Ram)
Time per 25 Iterations 6.17


**Dell Latitude running Linux (R 2.9.2, Intel Core 2 Duo P9500 @  
2.53GHz,

4GB ram)
Time per 25 iterations 2.88

**Dell Latitude running Win Vista (R 2.10.0, Intel Core 2 Duo P9500 @
2.53GHz, 4GB ram) with New DLL in terminal
Time per 25 iterations 5.53

---
**Macbook pro (2.16GHz Intel Core 2 Duo  2GB ram)
Time per 25 Iterations 4.58

**Macbook pro running WinXp (2.16GHz Intel Core 2 Duo  2GB ram)
Time per 25 Iterations 8.23


note: for the Dell and MacBook Pro we replaced the Rblas.dll file of  
R for

Windows with the file available here
http://cran.r-project.org/bin/windows/contrib/ATLAS/C2D/



Are you running 32 bit R on each platform or are you using 64 bit R on  
Linux and OSX?


On the Dell, you are running two different versions of R and you don't  
indicate the R versions on the MacBook.


The RAM configuration on each computer is different, which will impact  
the timings to some extent, depending upon how much RAM you may  
require for your R code, given other processes that are running and  
before any disk swapping kicks in. You might want to review R Windows  
FAQ 2.9, if you have not already:


  
http://cran.r-project.org/bin/windows/base/rw-FAQ.html#There-seems-to-be-a-limit-on-the-memory-it-uses_0021

For Windows on the MacBook, are you using Boot Camp to run Windows  
natively or are you using virtualization (eg. Parallels, VMWare,  
VirtualBox) to run Windows under OSX? If the latter, some of the time  
increase will be due to the virtualization overhead.


You should be using the same version of R across each platform for a  
fair comparison, as there is also the potential, if not the  
likelihood, that some code has been improved between versions, which  
may yield some performance differences. 32 bit versus 64 bit will also  
yield some differences. Differences in tuned BLAS libraries across  
each OS can also account for performance differences. You should look  
into using the one provided by R across each to enable more balanaced  
comparisons.


I am also not sure of what differences across each Windows test is  
attributable to WinXP versus Vista. There are others here with more  
insight into that aspect of things.


While there is a consistent increase for Windows timing as you have  
above, some of the differences may be due to not really having a  
(pardon the pun) Apples to Apples comparison across each platform.


HTH,

Marc Schwartz

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


Re: [R] Efficient cbind of elements from two lists

2009-11-19 Thread William Dunlap
 -Original Message-
 From: r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.org] On Behalf Of Stephan Dlugosz
 Sent: Thursday, November 19, 2009 7:03 AM
 To: r-help@r-project.org
 Subject: [R] Efficient cbind of elements from two lists
 
 Hi!
 
 I have a data.frame data and splitted it.
 
 data - split(data, data[,1])
 
 This is a quite slow procedure; and I do not want to do it again. So, 
 any unsplit and resplit is no option for me.
 But: I have to cbind variables to the splitted data from 
 another list, 
 that contains of vectors with matching sizes, so
 
 for (i in 1:length(data)) {
data[[i]] - cbind(data[[i]], l[[i]]))
 }
 
 works well; but very, very slowly.
 The lapply solution:
 
 data - lapply(1:k, function(i) cbind(data[[i]], l[[i]]))
 
 does not improve the situation, but allows for mclapply from the 
 multicore package...
 Is there a more efficient way to combine elements from two lists?

Can you restructure your analysis so you don't need
to split the data.frame itself?  I'm assuming the split
was slow because there are a lot of groups.  Splitting
a data.frame into lots of pieces is considerably slower
than splitting a few numeric or character columns in it.

   df - data.frame(group=rep(1:1e5, each=2), score=1:2e5)
   system.time(split(df, df$group)) # split entire data.frame into 1e5
parts
 user  system elapsed 
   117.32   38.42  154.34 
   system.time(split(df$score, df$group)) # split 2nd column into 1e5
parts
 user  system elapsed 
 0.430.030.46 

If R does things the way S+ does this is because splitting
simple vectors is done in C code but splitting data.frames
invokes the S-language [.data.frame function, which is
relatively slow when selecting rows from a data.frame.

I'd suggest using ave() (or a function from the plyr package),
working on columns from your data.frame and adding ave's
output as a column in your big data.frame.  E.g., to compute
the average score in each group
   system.time(df$meanScore - ave(df$score, df$group, FUN=mean))
 user  system elapsed 
 3.370.003.50 
   df[1:6,]
group score meanScore
  1 1 1   1.5
  2 1 2   1.5
  3 2 3   3.5
  4 2 4   3.5
  5 3 5   5.5
  6 3 6   5.5

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com 
 
 Thank you very much!
 
 Greetings,
 Stephan
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 

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


[R] Problem on using Rexcel in the vba code

2009-11-19 Thread anna_l

Hello everybody, I started to use Rexcel and I am getting an error with the
following code:

Sub AutoForma1_Clique()
Call RInterface.StartRServer
Call RInterface.RRun(setwd(C:/Program Files/R/R-2.10.0/Working
Directory))
Call RInterface.RRun(getwd()) 
 
End Sub

The error is the following when I run the macro: error in time execution
'424', the object is obligatory
Any idea?


-
Anna Lippel
new in R so be careful I should be asking a lt of questions!:teeth:
-- 
View this message in context: 
http://old.nabble.com/Problem-on-using-Rexcel-in-the-vba-code-tp26421377p26421377.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] Printing labeled summary to text file ?

2009-11-19 Thread A Singh

Dear List,

I am trying to run a mixed model which, on the R console, prints output as 
follows:


[1] Marker
[1] perm no.
[1] NA
Linear mixed model fit by REML
Formula: peg.no.prm ~ 1 + (1 | family/f)
  Data: modeldf
 AIC  BIC logLik deviance REMLdev
3119 3134  -1555 31123111
Random effects:
Groups   NameVariance Std.Dev.
f:family (Intercept)   0.0 0.000
family   (Intercept)   0.0 0.000
Residual 178.513.360
Number of obs: 388, groups: f:family, 73; family, 60

Here 'Marker' is one of 426 markers, and 'perm.no' is one of 10,000 
permutations of variance for each marker.
Each time R begins with a new marker column, it prints 'Marker', and for 
each permutation it prints a number from 1 to 1 (it hasn't here, but 
even 'NA' tells me where one data block begins and another ends-- MUCH 
easier for eyeballing).


Of course, since at the end, I will have 426*1 blocks of data, the 
console doesn't handle it and I tried printing out to a text file (.txt) 
using capture.output().


The problem with this is that in the text file, my labels ('Marker' and 
'Perm no.') aren't printed (since the capture command only uses output from 
summary(*model*).
This leaves me with about 4 million blocks of output (hypothetically) and 
with no way of telling where one marker ends and the next begins. 
Eyeballing this will take years.


Is there a way to therefore produce labeled output while writing to a text 
file?


Thanks a lot for any suggestions that might help,

Aditi

-
Code for a test file with 10 markers:


model-read.table(...)

modeldf-data.frame(model)

modeldf[2:13]-lapply(modeldf[2:13],factor)
colms-(modeldf)[4:13]   ## ten marker columns
se-c(1:1)

peg.no-(modeldf)[,14]

library(lme4)


for(f in colms)
{
print(Marker)
{
for( i in 1:1)
{
print(perm no.)
print(se[i])
{
peg.no.prm-sample(peg.no, length(peg.no))
try(fit5-lmer(data=modeldf, peg.no.prm~1 + (1|family/f)))
print(summary(fit5))
capture.output(fit5, file=testperm5.txt, append=T)
}}}
}


The data files are at:


http://www.4shared.com/file/131980362/460bdafe/Testvcomp10.ht
ml (excel)
http://www.4shared.com/file/131980512/dc7308b/Testvcomp10.html
(txt)


--
A Singh
aditi.si...@bristol.ac.uk
School of Biological Sciences
University of Bristol

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Splitting massive output into multiple text files

2009-11-19 Thread A Singh

Dear List,

I thought it would be much easier to put a second query into a second mail.

I need to print 426*1 blocks of variance components data, where 426 is 
the number of columns of data that have 1 permutations of variance 
generated for each of them.


I have tried printing out a smaller number of permutations for a smaller 
number of markers and that has worked.


However, since a text file will not handle 4 million blocks in a single 
file (which is what I ultimately need to do), is there a way to tell R to 
create a new file for every 10 or so columns?


I tried to use some suggested code that looked like:

for (j in 1:426)
{
write(cbind(modeldf[,j:(j+9)]),file=as.character(j))
j - j+10
}

..but can't figure out how to put it into my own code and make it work.

I did find one example of code for split files, each successive file being 
labeled as a series of numbers, but I couldn't figure out how to even adapt 
that to my model.


I cannot figure out what other way there is to conveniently view 4 m. items 
of data without losing some of it somewhere..


Any help will be much much appreciated..

Aditi

--

Code for shorter sample file:


model-read.table(...)

modeldf-data.frame(model)

modeldf[2:13-lapply(modeldf[2:13],factor)

colms-(modeldf)[4:13]   ## 10 markers only in this file
se-c(1:1000)

for(f in colms)
{
print(Marker)
{
for( i in 1:1000)
{
print(perm no.)
print(se[i])
{
peg.no.prm-sample(peg.no, length(peg.no))
try(fit5-lmer(data=modeldf, peg.no.prm~1 + (1|family/f)))
print(summary(fit5))
capture.output(fit5, file=testperm5.txt, append=T)
}}}
}


The data files are at:



http://www.4shared.com/file/131980362/460bdafe/Testvcomp10.ht
ml (excel)
http://www.4shared.com/file/131980512/dc7308b/Testvcomp10.html
(txt)

--


--
A Singh
aditi.si...@bristol.ac.uk
School of Biological Sciences
University of Bristol

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


[R] Problem with zoo and BootPR packages

2009-11-19 Thread Ricardo Gonçalves Silva
Hi,

I'm trying to plot the forecasts I generated using the Plot.Fore function of 
the BootPR package.
But I got an error from zoo:

My data:

Time Series:
Start = 1 
End = 18 
Frequency = 1 
 [1]  38731  38628  39117  92809  71984  31226  58613  72360 107956  92066
[11]  95208  99098  95848 120383 110717 105680  98469 101916

Script:

y1-ts(y1);
forey1-BootBC(y1,p=2,h=3,nboot=5000,type=const+trend,correct=ssf)
Plot.Fore(y1,forey1$forecast,start=1966,end=1984,frequency=1)

The Error:

Error in zooreg(x, start, end, frequency) : 
  data : attempt to define illegal zoo object

Any Help?

Thanks

Rick
[[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] person-level to person-period xfm

2009-11-19 Thread Robert Terwilliger
Dear R experts,

I have a so-called person-level data frame that I need to transform
into a person-period data frame.

If the lingo is unclear, the data have one row for each subject, with
repeated measures data each in a separate column.

I need to transform these data so that each subject has multiple rows,
one for each repeated measure value.

Is there a quick-and-dirty way to do this transformation?

Many thanks,

-- 
Robert Terwilliger
Biomedical Physicist
Laboratory of Neurocognitive Development
Western Psychiatric Institute and Clinic
University of Pittsburgh Medical Center
Loeffler Building
121 Meyran Avenue  #114
Pittsburgh, PA 15213
412.383.8174  - Office
412.383.8179 - Fax
em: rater...@gmail.com
http://www.wpic.pitt.edu/research/lncd/

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


Re: [R] Problem with zoo and BootPR packages

2009-11-19 Thread Gabor Grothendieck
Contact the BootPR maintainer regarding a bug in this line of Plot.Fore:

   y1 - zooreg(x, start, end, frequency)

where x is a ts object but that may not be used in that context.
as.zooreg is available for converting ts series (and certain other
objects) to zooreg objects.

2009/11/19 Ricardo Gonçalves Silva ricard...@terra.com.br:
 Hi,

 I'm trying to plot the forecasts I generated using the Plot.Fore function of 
 the BootPR package.
 But I got an error from zoo:

 My data:

 Time Series:
 Start = 1
 End = 18
 Frequency = 1
  [1]  38731  38628  39117  92809  71984  31226  58613  72360 107956  92066
 [11]  95208  99098  95848 120383 110717 105680  98469 101916

 Script:

 y1-ts(y1);
 forey1-BootBC(y1,p=2,h=3,nboot=5000,type=const+trend,correct=ssf)
 Plot.Fore(y1,forey1$forecast,start=1966,end=1984,frequency=1)

 The Error:

 Error in zooreg(x, start, end, frequency) :
  data : attempt to define illegal zoo object

 Any Help?

 Thanks

 Rick
        [[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] advice about R for windows speed

2009-11-19 Thread Carlos Hernandez
Thanks for your reply! I just added some more details below.

Our code needs around 1GB of RAM and all machines and R configurations have
its default maximum above this number.

Our suspicion is that the windows server could run the code in half of its
current time (given the apparent factor of 2 between windows and other OS
timing). There may be something very important either in the R configuration
or in our code that we should take care of?

I appreciate a lot any further advice or hints, specially about speeding up
the code in the windows xp server with QuadCore Xeon processors.

Best regards,

Carlos






**Server running WinXP 64bit (R 2.10.0 32bit , QuadCore Xeon 2.6GHz 8G Ram)
Time per 25 Iterations 6.17


**Dell Latitude running Linux 32bit (R 2.9.2, Intel Core 2 Duo P9500 @
2.53GHz, 4GB ram)
Time per 25 iterations 2.88

**Dell Latitude running Win Vista 32bit (R 2.10.0, Intel Core 2 Duo P9500 @
2.53GHz, 4GB ram) with New DLL in terminal
Time per 25 iterations 5.53

---
**Macbook pro running Snow Leopard (R 2.10.0, 2.16GHz Intel Core 2 Duo  2GB
ram)
Time per 25 Iterations 4.58  (both R 2.10.0 32bit and 64bit produce almost
identical timings)

**Macbook pro running WinXp natively (R 2.10.0 32bit, 2.16GHz Intel Core 2
Duo  2GB ram)
Time per 25 Iterations 8.23

note: for the Dell and MacBook Pro we replaced the Rblas.dll file of R for
Windows with the file available here
http://cran.r-project.org/bin/windows/contrib/ATLAS/C2D/

==



On Thu, Nov 19, 2009 at 5:06 PM, Marc Schwartz marc_schwa...@me.com wrote:

 On Nov 19, 2009, at 9:25 AM, Carlos Hernandez wrote:

  Dear All,
 I appreciate any advice or hints you could provide about the following.

 We are running R code in a server (running Windows XP and QuadCore Xeon
 processors, see details below) and we would like to use the server
 efficiently. Our code takes a bit more than 6 seconds per 25 iterations in
 the server using a default R 2.10.0 installation.

 We tested our code in two other computers, a Dell Latitute and a MacBook
 Pro, and from the details that i include below you will notice that the
 code
 needs almost twice the time when we used R for Windows compared against
 the
 time the code needs when we use Linux or MacOSX 10.6.2 in each of these
 computers.

 I'm sorry I don't provide details on the code we are using. The code
 consists of all sort of operations (matrix inverses, random number
 generation, vectorized functions, a few loops, and so on). I hope I can
 get
 some advice from you despite the lack of specific code details.

 Is there any important R feature we should configure manually in the
 windows
 server to speed the code up? Is there an optimized BLAS available
 somewhere
 for this type of machine? Is these something else apart of an optimized
 BLAS
 that we could do to improve the timing?

 Best regards,

 Carlos




 **Server running WinXP (QuadCore Xeon 2.6GHz 8G Ram)
 Time per 25 Iterations 6.17

 
 **Dell Latitude running Linux (R 2.9.2, Intel Core 2 Duo P9500 @ 2.53GHz,
 4GB ram)
 Time per 25 iterations 2.88

 **Dell Latitude running Win Vista (R 2.10.0, Intel Core 2 Duo P9500 @
 2.53GHz, 4GB ram) with New DLL in terminal
 Time per 25 iterations 5.53

 ---
 **Macbook pro (2.16GHz Intel Core 2 Duo  2GB ram)
 Time per 25 Iterations 4.58

 **Macbook pro running WinXp (2.16GHz Intel Core 2 Duo  2GB ram)
 Time per 25 Iterations 8.23


 note: for the Dell and MacBook Pro we replaced the Rblas.dll file of R for
 Windows with the file available here
 http://cran.r-project.org/bin/windows/contrib/ATLAS/C2D/



 Are you running 32 bit R on each platform or are you using 64 bit R on
 Linux and OSX?

 On the Dell, you are running two different versions of R and you don't
 indicate the R versions on the MacBook.

 The RAM configuration on each computer is different, which will impact the
 timings to some extent, depending upon how much RAM you may require for your
 R code, given other processes that are running and before any disk swapping
 kicks in. You might want to review R Windows FAQ 2.9, if you have not
 already:


 http://cran.r-project.org/bin/windows/base/rw-FAQ.html#There-seems-to-be-a-limit-on-the-memory-it-uses_0021

 For Windows on the MacBook, are you using Boot Camp to run Windows natively
 or are you using virtualization (eg. Parallels, VMWare, VirtualBox) to run
 Windows under OSX? If the latter, some of the time increase will be due to
 the virtualization overhead.

 You should be using the same version of R across each platform for a fair
 comparison, as there is also the potential, if not the likelihood, that some
 code has been improved between versions, which may yield some performance
 differences. 32 bit versus 64 bit will also yield some differences.
 Differences in tuned BLAS libraries across each OS can also account for
 performance differences. You should look into using the one provided by R
 across each to enable more balanaced comparisons.

 I 

Re: [R] Problem with zoo and BootPR packages

2009-11-19 Thread Achim Zeileis

On Thu, 19 Nov 2009, Ricardo Gonçalves Silva wrote:


Hi,

I'm trying to plot the forecasts I generated using the Plot.Fore function of 
the BootPR package.
But I got an error from zoo:

My data:

Time Series:
Start = 1
End = 18
Frequency = 1
[1]  38731  38628  39117  92809  71984  31226  58613  72360 107956  92066
[11]  95208  99098  95848 120383 110717 105680  98469 101916

Script:

y1-ts(y1);
forey1-BootBC(y1,p=2,h=3,nboot=5000,type=const+trend,correct=ssf)
Plot.Fore(y1,forey1$forecast,start=1966,end=1984,frequency=1)

The Error:

Error in zooreg(x, start, end, frequency) :
 data : attempt to define illegal zoo object

Any Help?


This is a bug in Plot.Fore() which does not use the zoo functions 
correctly. It should be reported to the package maintainer.


To avoid it, you can do
  Plot.Fore(as.vector(y1), ...)
instead of
  Plot.Fore(y1, ...)

Note to the maintainer (Jae Kim, Cc now): Plot.Fore() calls zooreg(x) 
where x is a ts object. This isn't the appropriate use of zooreg() which 
expects a numeric vector/matrix (or a factor). In the case above 
as.zoo(y1) would already be enough (and preserve all time information). Or 
you can manually call zooreg(coredata(y1), start = ..., end = ..., ). 
See the zoo vignettes/examples for more details.


Best,
Z


Thanks

Rick
[[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] Problem with zoo and BootPR packages

2009-11-19 Thread Ricardo Gonçalves Silva

Ok,

Thanks all.
Rick.

--
From: Achim Zeileis achim.zeil...@wu-wien.ac.at
Sent: Thursday, November 19, 2009 3:06 PM
To: Ricardo Gonçalves Silva ricard...@terra.com.br
Cc: R-Help r-help@r-project.org; j@latrobe.edu.au
Subject: Re: [R] Problem with zoo and BootPR packages


On Thu, 19 Nov 2009, Ricardo Gonçalves Silva wrote:


Hi,

I'm trying to plot the forecasts I generated using the Plot.Fore function 
of the BootPR package.

But I got an error from zoo:

My data:

Time Series:
Start = 1
End = 18
Frequency = 1
[1]  38731  38628  39117  92809  71984  31226  58613  72360 107956  92066
[11]  95208  99098  95848 120383 110717 105680  98469 101916

Script:

y1-ts(y1);
forey1-BootBC(y1,p=2,h=3,nboot=5000,type=const+trend,correct=ssf)
Plot.Fore(y1,forey1$forecast,start=1966,end=1984,frequency=1)

The Error:

Error in zooreg(x, start, end, frequency) :
 data : attempt to define illegal zoo object

Any Help?


This is a bug in Plot.Fore() which does not use the zoo functions
correctly. It should be reported to the package maintainer.

To avoid it, you can do
  Plot.Fore(as.vector(y1), ...)
instead of
  Plot.Fore(y1, ...)

Note to the maintainer (Jae Kim, Cc now): Plot.Fore() calls zooreg(x)
where x is a ts object. This isn't the appropriate use of zooreg() which
expects a numeric vector/matrix (or a factor). In the case above
as.zoo(y1) would already be enough (and preserve all time information). Or
you can manually call zooreg(coredata(y1), start = ..., end = ..., ).
See the zoo vignettes/examples for more details.

Best,
Z


Thanks

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








No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 9.0.707 / Virus Database: 270.14.73/2513 - Release Date: 11/19/09 
05:51:00




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

2009-11-19 Thread Richard M. Heiberger

Robert Terwilliger wrote:

Dear R experts,

I have a so-called person-level data frame that I need to transform
into a person-period data frame.

If the lingo is unclear, the data have one row for each subject, with
repeated measures data each in a separate column.

I need to transform these data so that each subject has multiple rows,
one for each repeated measure value.

Is there a quick-and-dirty way to do this transformation?

Many thanks,

  

There are several ways.  This is one.

 tmp - data.frame(id=letters[1:3], x1=1:3, x2=4:6, x3=7:9, x4=10:12)
 tmp
 id x1 x2 x3 x4
1  a  1  4  7 10
2  b  2  5  8 11
3  c  3  6  9 12
 reshape(tmp, direction=long, varying=list(names(tmp)[-1]), ids=id)
   id time x1
a.1  a1  1
b.1  b1  2
c.1  c1  3
a.2  a2  4
b.2  b2  5
c.2  c2  6
a.3  a3  7
b.3  b3  8
c.3  c3  9
a.4  a4 10
b.4  b4 11
c.4  c4 12


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] plot filled.contour over continent map

2009-11-19 Thread Matthias Demuzere
Dear all,

As a newbie in R I would like to do the following (simple?) thing:

to plot a filled.contour plot over a map showing country boundaries (e.g. for 
Europe)
What i do is:
map('worldHires',xlim=c(-10,40),ylim=c(35,70),boundary = TRUE,border=0.1)
map.axes()
filled.contour(mslp, zlim=c(1000,1020),color.palette = 
colorRampPalette(c(blue, white, red)),main=Avegared MLSP (hPa) ERA40 JJA 
[1996-2002], xlab=Longitude,ylab=Latitude)

in which the mslp file is a netcdf file, with mean sea level pressure for a 
range of lat/lon values.

If I run the above-mentioned, I just get the map of Europe, without the 
contourplot.
When commenting the map statements I can see the contourplot.

So I am doing something wrong, but I really have no idea what?

Anybody could help me out here?
Thanks in advance,

Matthias

-
Department of Earth  Environmental Sciences
Physical and Regional Geography Research Group
Regional climate studies

Celestijnenlaan 200E
3001 Heverlee (Leuven)
BELGIUM

Tel: + 32 16 326424
Fax: + 32 16 322980

http://geo.kuleuven.be/aow/
www.kuleuven.be/geography
-


[[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] Error system is computationally singular by using function dmvnorm

2009-11-19 Thread Uwe Ligges



Alla Bulashevska wrote:

Dear R users,
i try to use function dmvnorm(x, mean, sigma, log=FALSE)
from R package mvtnorm to calculate the probability of x
under the multivariate normal distribution with mean equal
to mean and covariance matrix sigma.
I become the following 
Error in solve.default(cov, ...) :

  system is computationally singular: reciprocal condition
number = 1.81093e-19



Probably your sigma is almost singular and can't be inverted in the 
calculation of the Mahalanobis distance.


Uwe Ligges






What could be the reason of it?
Thank you in Advance,
Alla.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] converting a vector of bytes to a PNG/JPEG image

2009-11-19 Thread Uwe Ligges
Can't be too hard to convert it in pixmap representation, but you need 
to tell us hoe the representation looks like, probbaly with a short code 
that makes it reproducible (e.g. generate some data that we can use in R).


Uwe Ligges


Rajarshi Guha wrote:

Hi, I have some code that uses rJava. One of the Java side methods returns a
byte[] representing the bytes from a PNG image.

What I'd like to do is to be able to bring up the PNG on the R side (I can
bring up a Swing window to show the PNG but I want to avoid that). I have
looked at the pixmap and rimage packages but don't seem to be able to work
out how I'd go about this (or if it's at all possible).

Does anybody have any pointers?

Thanks,



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


Re: [R] ddply function nesting problems

2009-11-19 Thread Jason Rupert
Awesome!  

Thanks a ton!  

I guess I had overlooked how it was really working.

I will still have to reflect on why it was working running it straight through, 
but not being nested.

That is kind of a mystery.  Oh well...

Thanks again. 


 
- Original Message 
From: baptiste auguie baptiste.aug...@googlemail.com
To: Jason Rupert jasonkrup...@yahoo.com
Cc: R-help@r-project.org
Sent: Thu, November 19, 2009 9:24:29 AM
Subject: Re: [R] ddply function nesting problems

Hi,

I think your ddply call with a calculation inside .(  ) is the
problem. Are you sure you need to do this? Performing the cut outside
ddply seems to work fine,

determine_counts-function()
{

        min_range-1
        max_range-30
        bin_range_size-5
        Me_df-data.frame(Data = c(1:15), Person = Me)
        You_df-data.frame(Data = c(10:20), Person = You)
        Them_df-data.frame(Data = c(15:25), Person = Them)
        Group_df_tmp-rbind(Me_df,You_df)
        Group_df-rbind(Group_df_tmp,Them_df)
        Group_df$Person - factor(Group_df$Person, levels = c(Them,
You, Me))

        Group_df - transform(Group_df, cut=cut(Data,
                                          breaks=fullseq(range(c(Data,
min_range, max_range)),
                                            bin_range_size)))

        counts - ddply(Group_df, .(cut, Person), nrow)


        names(counts) - c(Bin, Person, Frequency)
        qplot(Person, Frequency, data = counts,
              fill = Person, geom=bar, stat=identity, width = 0.9,
xlab=Person) +
                facet_grid(. ~ Bin)
}

function_nesting()

HTH,

baptiste


2009/11/19 Jason Rupert jasonkrup...@yahoo.com:
 While putting my R code into functions, I've encountered a ddply function 
 nesting issue and need a bit of advice on the proper way to fix it.  I've 
 tried several approahces, but neither worked and I need to have the ability 
 to include the cut, range, and fullseq methods within ddply.  (For a 
 bit of that explanation refer to 
 http://finzi.psych.upenn.edu/Rhelp08/2009-February/187331.html)

 Thus, in order to preserve that functionality, and put my code within 
 functions, I needed to have an architecture similar to the following 
 implemented, where you end up running:
 function_nesting()

 Unfortunately this produced errors within the ddply where it does not appear 
 to be recognizing or allowing variables or functions to be processed within 
 side its function.

 Thank you for any advice about how to proceed forward.


 determine_counts-function()
 {

     min_range-1
     max_range-30
     bin_range_size-5
     Me_df-data.frame(Data = c(1:15), Person = Me)
     You_df-data.frame(Data = c(10:20), Person = You)
     Them_df-data.frame(Data = c(15:25), Person = Them)
     Group_df_tmp-rbind(Me_df,You_df)
     Group_df-rbind(Group_df_tmp,Them_df)
     Group_df$Person - factor(Group_df$Person, levels = c(Them, You, 
 Me))
     #counts - ddply(Group_df, .(cut(Data, breaks=fullseq(range(Data), 
 5)), Person), nrow)

  # Approach 1
         counts - ddply(Group_df, .(cut(Data, 
 breaks=fullseq(range(c(Group_df$Data, min_range, max_range)), 
 bin_range_size)), Person), nrow)

         # Approach 2
     range_tmp-range(c(Group_df$Data, min_range, max_range))
     counts - ddply(Group_df, .(cut(Data, breaks=fullseq(range_tmp, 
 bin_range_size)), Person), nrow)


     names(counts) - c(Bin, Person, Frequency)
     qplot(Person, Frequency, data = counts, fill = Person, geom=bar, 
 stat=identity, width = 0.9, xlab=Person) +  facet_grid(. ~ Bin)
 }




 function_nesting-function()
 {
     determine_counts()
 }



 However, if the code is just run straight through without being nested it 
 works fine:

     min_range-1
     max_range-30
     bin_range_size-5
     Me_df-data.frame(Data = c(1:15), Person = Me)
     You_df-data.frame(Data = c(10:20), Person = You)
     Them_df-data.frame(Data = c(15:25), Person = Them)
     Group_df_tmp-rbind(Me_df,You_df)
     Group_df-rbind(Group_df_tmp,Them_df)
     Group_df$Person - factor(Group_df$Person, levels = c(Them, You, 
 Me))
     #counts - ddply(Group_df, .(cut(Data, breaks=fullseq(range(Data), 
 5)), Person), nrow)
     counts - ddply(Group_df, .(cut(Data, 
 breaks=fullseq(range(c(Group_df$Data, min_range, max_range)), 
 bin_range_size)), Person), nrow)

 Unfortunately this is not within a function, so thanks again for any advice 
 on how to approach this issue.




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

Re: [R] person-level to person-period xfm

2009-11-19 Thread David Winsemius


On Nov 19, 2009, at 12:23 PM, Richard M. Heiberger wrote:


Robert Terwilliger wrote:

Dear R experts,

I have a so-called person-level data frame that I need to transform
into a person-period data frame.

If the lingo is unclear, the data have one row for each subject, with
repeated measures data each in a separate column.

I need to transform these data so that each subject has multiple  
rows,

one for each repeated measure value.

Is there a quick-and-dirty way to do this transformation?

Many thanks,



There are several ways.  This is one.


Here's another:
 data.frame(id=tmp$id, stack(tmp, select=-id))
   id values ind
1   a  1  x1
2   b  2  x1
3   c  3  x1
4   a  4  x2
5   b  5  x2
6   c  6  x2
7   a  7  x3
8   b  8  x3
9   c  9  x3
10  a 10  x4
11  b 11  x4
12  c 12  x4




 tmp - data.frame(id=letters[1:3], x1=1:3, x2=4:6, x3=7:9, x4=10:12)
 tmp
id x1 x2 x3 x4
1  a  1  4  7 10
2  b  2  5  8 11
3  c  3  6  9 12
 reshape(tmp, direction=long, varying=list(names(tmp)[-1]),  
ids=id)

  id time x1
a.1  a1  1
b.1  b1  2
c.1  c1  3
a.2  a2  4
b.2  b2  5
c.2  c2  6
a.3  a3  7
b.3  b3  8
c.3  c3  9
a.4  a4 10
b.4  b4 11
c.4  c4 12


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


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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


Re: [R] Problem with zoo and BootPR packages

2009-11-19 Thread Gabor Grothendieck
Actually it may be that the documentation is at fault more than the
code.  The help page for Plot.Fore says that the first argument is a
time series data set and although that seems to suggest that it should
be a ts object the code seems to be written assuming a plain numeric
vector; therefore, you could do this:

library(zoo)
Plot.Fore(coredata(y1), forey1$forecast, start = 1966, end = 1984,
frequency = 1)

2009/11/19 Gabor Grothendieck ggrothendi...@gmail.com:
 Contact the BootPR maintainer regarding a bug in this line of Plot.Fore:

   y1 - zooreg(x, start, end, frequency)

 where x is a ts object but that may not be used in that context.
 as.zooreg is available for converting ts series (and certain other
 objects) to zooreg objects.

 2009/11/19 Ricardo Gonçalves Silva ricard...@terra.com.br:
 Hi,

 I'm trying to plot the forecasts I generated using the Plot.Fore function of 
 the BootPR package.
 But I got an error from zoo:

 My data:

 Time Series:
 Start = 1
 End = 18
 Frequency = 1
  [1]  38731  38628  39117  92809  71984  31226  58613  72360 107956  92066
 [11]  95208  99098  95848 120383 110717 105680  98469 101916

 Script:

 y1-ts(y1);
 forey1-BootBC(y1,p=2,h=3,nboot=5000,type=const+trend,correct=ssf)
 Plot.Fore(y1,forey1$forecast,start=1966,end=1984,frequency=1)

 The Error:

 Error in zooreg(x, start, end, frequency) :
  data : attempt to define illegal zoo object

 Any Help?

 Thanks

 Rick
        [[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] How do I specify a partially completed survival analysis model?

2009-11-19 Thread RWilliam

Hello,

I just started using R to do epidemiologic simulation research using the Cox
proportional hazard model. I have 2 covariates X1 and X2 which I want to
model as h(t,X)=h0(t)*exp(b1*X1+b2*X2). I assume independence of X from t. 

After I simulate Time and Censor data vectors denoting the censoring time
and status respectively, I can call the following function to fit the data
into the Cox model (a is a data.frame containing 4 columns X1, X2, Time and
Censor):
b = coxph (Surv (Time, Censor) ~ X1 + X2, data = a, method = breslow);

Now the purpose of me doing simulation is that I have another mechanism to
generate the number b2. From the given b2 (say it's 4.3), Cox model can be
fit to generate b1 and check how feasible the new model is. Thus, my
question is, how do I specify such a model that is partially completed (as
in b2 is known). I tried things like Surv(Time,Censor)~X1+4.3*X2, but it's
not working. Thanks very much.
-- 
View this message in context: 
http://old.nabble.com/How-do-I-specify-a-partially-completed-survival-analysis-model--tp26421391p26421391.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] Reading in a series of files using a for loop

2009-11-19 Thread Thomas Jackson
Dear R Users,

I am trying to read in a series of csv files which vary by the letter on the 
end of he file name.  When I input what seems to be a logical for loop I get an 
error message that doesn't make sense to me.  

 for(i in 1:12){ paste(GP, LETTERS[i],sep='') 
 -read.csv(paste(/Users/thomasjackson/Data/GEPCO/GEPCO,LETTERS[i],/HPLC_,LETTERS[i],12.csv,sep=''),
  header=T, sep=',')}


Error in paste(GP, LETTERS[i], sep = ) - 
read.csv(paste(/Users/thomasjackson/Data/GEPCO/GEPCO,  : 
  target of assignment expands to non-language object


For example the first file name is HPLC_A12.csv in the folder GEPCOA

Thanks for any help,
Thomas Jackson
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 install older version of R?

2009-11-19 Thread 潘家群
Dear Paul,

Thank you for your response.  I am investigating a differentially expressed
gene detected method that cannot be applied on R 2.9.1 that currently I
used. The reason about why it cannot work due to the changes of new version
of R. And, recently, I study a lots of methods that developed by some
statisticians, they kindly provided me source code, but some of codes only
implements on the older version of R or packages. I have met many cases of
this situation. That's why I am trying to get an older version.

Jia-Chiun Pan

2009/11/19 Paul Hiemstra p.hiems...@geo.uu.nl

 Dear Jia-Chiun Pan,

 First of all, why install an older version of R? In my experience the
 backward compatibility of R is quite good. So using R 2.10.0 should be ok.
 But if you really want this you can build R from source. The source can be
 downloaded from CRAN:

 http://cran.r-project.org/src/base/R-2/R-2.7.2.tar.gz

 Extract, ./configure, make, make install and you have R 2.7.2 installed on
 your system.

 cheers,
 Paul


 Pan, Jia-chiun/¼ï®a¸s wrote:

  Dear list

This is much like a linux problem, but I can't find any
 reference for it. My OS is ubuntu 9.04 and a version of 2.9.2 of R has
 been already installed in. Now, I need to install the version of 2.7.1.
 I google a lot of websites and it seems like without a painless way
 provided me to do it.
If any one offers me some suggestions/reference, I will
 appreciate.

 Jia-Chiun Pan

 __
 R-help@r-project.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.




 --
 Drs. Paul Hiemstra
 Department of Physical Geography
 Faculty of Geosciences
 University of Utrecht
 Heidelberglaan 2
 P.O. Box 80.115
 3508 TC Utrecht
 Phone:  +3130 274 3113 Mon-Tue
 Phone:  +3130 253 5773 Wed-Fri
 http://intamap.geo.uu.nl/~paul



[[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] Reading in a series of files using a for loop

2009-11-19 Thread Jorge Ivan Velez
Hi Thomas,

Here are two suggestions which storage all the files in a list:

# Parameters
route - /Users/thomasjackson/Data/GEPCO/GEPCO
lts - LETTERS[1:12]
toread - paste(route,lts,/HPLC_,lts,12.csv,sep='')

# Reading in the data   -- option 1
myfiles - list()
for(i in 1:12)  myfiles[i] - read.csv(toread, header=T, sep=',')
names(myfiles) - paste(GP, lts, sep='')
myfiles

# Option 2   -- no for() loop
myfiles2 - lapply(toread, read.csv, header=T, sep=',')
myfiles2

To access the first file just type either

myfiles[[1]]

or

myfiles2[[1]]

For further analysis using each file, the lapply (see ?lapply) function
might be useful.

HTH,
Jorge


On Thu, Nov 19, 2009 at 12:29 PM, Thomas Jackson  wrote:

 Dear R Users,

 I am trying to read in a series of csv files which vary by the letter on
 the end of he file name.  When I input what seems to be a logical for loop I
 get an error message that doesn't make sense to me.

  for(i in 1:12){ paste(GP, LETTERS[i],sep='')
 -read.csv(paste(/Users/thomasjackson/Data/GEPCO/GEPCO,LETTERS[i],/HPLC_,LETTERS[i],12.csv,sep=''),
 header=T, sep=',')}


 Error in paste(GP, LETTERS[i], sep = ) -
 read.csv(paste(/Users/thomasjackson/Data/GEPCO/GEPCO,  :
  target of assignment expands to non-language object


 For example the first file name is HPLC_A12.csv in the folder GEPCOA

 Thanks for any help,
 Thomas Jackson
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Reading in a series of files using a for loop

2009-11-19 Thread Greg Snow
Try something like:

gp - lapply(  
paste((/Users/thomasjackson/Data/GEPCO/GEPCO,LETTERS[1:12],/HPLC_,LETTERS[1:12],12.csv,sep=''),
read.csv, header=TRUE, sep=',' )
names(gp) - paste(GandP, LETTERS[1:12], sep='')

Now gp (or whatever you want to call it) will be a list with your 12 data files 
as elements.  You can analyze individual elements, or use lapply to perform the 
same analysis on each of them.

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 Thomas Jackson
 Sent: Thursday, November 19, 2009 10:29 AM
 To: r-help@r-project.org
 Subject: [R] Reading in a series of files using a for loop
 
 Dear R Users,
 
 I am trying to read in a series of csv files which vary by the letter
 on the end of he file name.  When I input what seems to be a logical
 for loop I get an error message that doesn't make sense to me.
 
  for(i in 1:12){ paste(GP, LETTERS[i],sep='') -
 read.csv(paste(/Users/thomasjackson/Data/GEPCO/GEPCO,LETTERS[i],/H
 PLC_,LETTERS[i],12.csv,sep=''), header=T, sep=',')}
 
 
 Error in paste(GP, LETTERS[i], sep = ) -
 read.csv(paste(/Users/thomasjackson/Data/GEPCO/GEPCO,  :
   target of assignment expands to non-language object
 
 
 For example the first file name is HPLC_A12.csv in the folder GEPCOA
 
 Thanks for any help,
 Thomas Jackson
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] plot filled.contour over continent map

2009-11-19 Thread Ray Brownrigg
On Fri, 20 Nov 2009, Matthias Demuzere wrote:
 Dear all,

 As a newbie in R I would like to do the following (simple?) thing:

 to plot a filled.contour plot over a map showing country boundaries (e.g.
 for Europe) What i do is:
 map('worldHires',xlim=c(-10,40),ylim=c(35,70),boundary = TRUE,border=0.1)
 map.axes()
 filled.contour(mslp, zlim=c(1000,1020),color.palette =
 colorRampPalette(c(blue, white, red)),main=Avegared MLSP (hPa) ERA40
 JJA [1996-2002], xlab=Longitude,ylab=Latitude)

 in which the mslp file is a netcdf file, with mean sea level pressure for a
 range of lat/lon values.

 If I run the above-mentioned, I just get the map of Europe, without the
 contourplot. When commenting the map statements I can see the
 contourplot.

 So I am doing something wrong, but I really have no idea what?

Does the filled.contour() call work on its own? It should, right?

What I would expect to see is just the contour plot, since that should 
overwrite the map() 
plot.

Once you get filled.contour() working, try adding the map using:
map('worldHires',xlim=c(-10,40),ylim=c(35,70),boundary = TRUE, border=0.1, add 
= TRUE)

You may have to put the xlim= and ylim= into the filled.contour() call to get 
what you 
want.

HTH
Ray Brownrigg

 Anybody could help me out here?
 Thanks in advance,

 Matthias

 -
 Department of Earth  Environmental Sciences
 Physical and Regional Geography Research Group
 Regional climate studies

 Celestijnenlaan 200E
 3001 Heverlee (Leuven)
 BELGIUM

 Tel: + 32 16 326424
 Fax: + 32 16 322980

 http://geo.kuleuven.be/aow/
 www.kuleuven.be/geography
 -


   [[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] Reading in a series of files using a for loop

2009-11-19 Thread David Winsemius

You need to look at the assign function:

http://cran.r-project.org/doc/FAQ/R-FAQ.html#How-can-I-turn-a-string-into-a-variable_003f

(... and in addition to R FAQ 7.21 also perhaps read the rest of the R  
FAQ.)


There are a ton of very similar questions in the r-help archives, so  
you could also try


RSiteSearch(read.table paste)

-- David




On Nov 19, 2009, at 12:29 PM, Thomas Jackson wrote:


Dear R Users,

I am trying to read in a series of csv files which vary by the  
letter on the end of he file name.  When I input what seems to be a  
logical for loop I get an error message that doesn't make sense to me.


for(i in 1:12){ paste(GP, LETTERS[i],sep='') -read.csv(paste(/ 
Users/thomasjackson/Data/GEPCO/GEPCO,LETTERS[i],/ 
HPLC_,LETTERS[i],12.csv,sep=''), header=T, sep=',')}



Error in paste(GP, LETTERS[i], sep = ) - read.csv(paste(/ 
Users/thomasjackson/Data/GEPCO/GEPCO,  :

 target of assignment expands to non-language object


For example the first file name is HPLC_A12.csv in the folder GEPCOA


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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


Re: [R] plot filled.contour over continent map

2009-11-19 Thread Greg Snow
You probably want to put the map boundaries on top of the contour plot rather 
than the other way around.  Here is one example of doing that (find the correct 
asp may be the hardest part):

library(maps)

x - seq( -124.7, -67, length.out=25 )
y - seq( 25, 49, length.out=25 )

z - outer(x,y,'+')

filled.contour(x,y,z, asp=1.5, plot.axes=map('state',add=TRUE)  )

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 Ray Brownrigg
 Sent: Thursday, November 19, 2009 11:50 AM
 To: r-help@r-project.org
 Cc: Matthias Demuzere
 Subject: Re: [R] plot filled.contour over continent map
 
 On Fri, 20 Nov 2009, Matthias Demuzere wrote:
  Dear all,
 
  As a newbie in R I would like to do the following (simple?) thing:
 
  to plot a filled.contour plot over a map showing country boundaries
 (e.g.
  for Europe) What i do is:
  map('worldHires',xlim=c(-10,40),ylim=c(35,70),boundary =
 TRUE,border=0.1)
  map.axes()
  filled.contour(mslp, zlim=c(1000,1020),color.palette =
  colorRampPalette(c(blue, white, red)),main=Avegared MLSP (hPa)
 ERA40
  JJA [1996-2002], xlab=Longitude,ylab=Latitude)
 
  in which the mslp file is a netcdf file, with mean sea level pressure
 for a
  range of lat/lon values.
 
  If I run the above-mentioned, I just get the map of Europe, without
 the
  contourplot. When commenting the map statements I can see the
  contourplot.
 
  So I am doing something wrong, but I really have no idea what?
 
 Does the filled.contour() call work on its own? It should, right?
 
 What I would expect to see is just the contour plot, since that should
 overwrite the map()
 plot.
 
 Once you get filled.contour() working, try adding the map using:
 map('worldHires',xlim=c(-10,40),ylim=c(35,70),boundary = TRUE,
 border=0.1, add = TRUE)
 
 You may have to put the xlim= and ylim= into the filled.contour() call
 to get what you
 want.
 
 HTH
 Ray Brownrigg
 
  Anybody could help me out here?
  Thanks in advance,
 
  Matthias
 
  -
  Department of Earth  Environmental Sciences
  Physical and Regional Geography Research Group
  Regional climate studies
 
  Celestijnenlaan 200E
  3001 Heverlee (Leuven)
  BELGIUM
 
  Tel: + 32 16 326424
  Fax: + 32 16 322980
 
  http://geo.kuleuven.be/aow/
  www.kuleuven.be/geography
  -
 
 
  [[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.html and provide commented,
 minimal,
  self-contained, reproducible code.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


[R] Lme

2009-11-19 Thread Patrick Bedard
Hi 

In my experiment I have 2 Groups (control patient) and 4 blocks of trials
per subject,  n=12 for Control and n=11 for patient
The variances of the patients is very much higher than that of the Control.

1-  I tried an ANOVA with Groups as between factor and Blocks as within
factor (repeated measures).
aov(Y ~ gr*block+Error(subj/block), data=d)
works OK but without the significant effect I was looking for, which may
be caused by the variances.  So  I though I¹d use lme

2-  lme.m = lme(Y ~ gr*block, data=d, random=~1 + block | subj);
anova(lme.m)


I¹d like to make sure that my lme model is correctly psecified.

Thanks in advance for your help!
__ 
Patrick Bédard Ph.D.
Dept. of Neuroscience
Brown University



[[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] Calling R (GAMM) from Fortran

2009-11-19 Thread Paul Warren Simonin


   Hello,

     I am currently working on a modeling project using Fortran to run  
large repetitive loops (many DO loops). As part of this process I  
would like to use a model fit in R and currently stored as an R  
object. This is a rather complex model, a GAMM, and I am curious  
whether there is a way to call this model from Fortran. I am not sure  
call is correct terminology, but I would basically like to use this  
GAMM to make a prediction as part of each DO loop. Is this possible? I  
have found instructions, etc. for calling Fortran from R but not vice  
versa.

     Thank you for any information or advice. General advice to  
address this situation is also welcome.

   Thanks again!

   -Paul Simonin

[[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] Partial derivatives of the multivariate cumulative distribution

2009-11-19 Thread Stephane LUCHINI
I'm currently using the mvtnorm package to model unobserved  
heterogeneity in a structural model and using optim to estimate the  
model. I have got good clues that convergence is not really a problem  
but the hessian matrix estimate is very bad. To overcome this problem,  
I'm constructing an OPG estimator of the information matrix and I was  
wondering if there were an easy way to obtain partial derivatives of  
say for instance:


P1  -  
pmvnorm(lower=c(-Inf,-Inf,-Inf,-Inf),upper=c(theta1,theta2,theta3,theta4),corr=ssigma)


with respect to the mean parameters theta1, theta2, theta3, theta4 and  
the non-diagonal parameters in sigma, hence $\partial P_1 / \partial  
\theta_1$, etc...


I can deal with numerical or analytical partial derivatives - a  
gradient would be fine since all observations share the same partial  
derivative.


Stephane

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Calling R (GAMM) from Fortran

2009-11-19 Thread Charlie Sharpsteen
On Thu, Nov 19, 2009 at 12:14 PM, Paul Warren Simonin
paul.simo...@uvm.edu wrote:


   Hello,

     I am currently working on a modeling project using Fortran to run
 large repetitive loops (many DO loops). As part of this process I
 would like to use a model fit in R and currently stored as an R
 object. This is a rather complex model, a GAMM, and I am curious
 whether there is a way to call this model from Fortran. I am not sure
 call is correct terminology, but I would basically like to use this
 GAMM to make a prediction as part of each DO loop. Is this possible? I
 have found instructions, etc. for calling Fortran from R but not vice
 versa.

     Thank you for any information or advice. General advice to
 address this situation is also welcome.

   Thanks again!

   -Paul Simonin


The R library and interpreter are written in C and available using a C
interface.  Therefore, it  would be theoretically possible to call
this interface from Fortran-- however there are details that probably
make a direct call impossible in practice.  This is because
interfacing with R requires passing representations of R objects
(SEXPs) which are far removed from the basic C variable types
supported by standardized C--Fortran interfaces.

 It may be that the only plausible way to approach this problem may
involve writing a set of bindings in C that interface with R and
extract the information you are interested in and then express it
using basing C variables that Fortran can understand.  With such a
system in place your Fortran program would call a set of routines
written in C that called routines from the R libraries and then
reformatted the results and returned them to Fortran.

This is a conclusion based on my limited experience-- not any formal
expertise.  There are definitely others on this list that could
provide a better qualified answer.

Good luck!

-Charlie

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 wait for a user response in Rscript?

2009-11-19 Thread Peng Yu
Why I don't see 'par(ask=T)' in /usr/lib/R/library/graphics/R-ex/barplot.R?

Is 'par(ask=T)' implicitly called by example()?

On Mon, Sep 7, 2009 at 10:55 AM, RIOS,ALFREDO ARTURO ar...@ufl.edu wrote:
 Hi Peng

 I think this is what you are looking for

 par(ask=T)

 Alfredo


 On Sun Sep 06 12:52:31 EDT 2009, Peng Yu pengyu...@gmail.com wrote:

 Hi,

 In 'example(barplot)' running in R, I see 'Hit Return to see next
 plot:', then R waits for my input. I am wondering how to wait for a
 user response in Rscript.

 Regards,
 Peng

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





 --
 RIOS,ALFREDO ARTURO



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Performance of 'by' and 'ddply' on a large data frame

2009-11-19 Thread Tahir Butt
I've only recently started using R. One of the problems I come up
against is after having extracted a large dataset (5M rows) out of
database, I realize I need another variable. In this case I have data
frame with dates. I want to find the minimum date for each value of x1
and add that minimum date to my data.frame.

 randomdf - function(p) {
data.frame(x1=sample(1:10^4, 10^p, replace=T),
x2=sample(seq.Date(Sys.Date() - 356*3,Sys.Date(), by=day), 10^p, replace=T),
y1=sample(1:100, 10^p, replace=T))
}
 testby - function(p) {
df - randomdf(p)
system.time(by(df, df$x1, function(dfi) { min(dfi$x2) }))
}
 lapply(c(1,2,3,4,5), testby)
[[1]]
  user  system elapsed
 0.006   0.000   0.006

[[2]]
  user  system elapsed
 0.024   0.000   0.025

[[3]]
  user  system elapsed
 0.233   0.000   0.234

[[4]]
  user  system elapsed
 1.996   0.026   2.022

[[5]]
  user  system elapsed
11.030   0.000  11.032

Strangely enough, not sure why this is, the result of by with the min
function is not date objects but instead integers representing days
from an origin. Is there a min function that would return me a date
instead of an integer? Or is this a result of using by?

I also wanted to see how ddply compares.

 testddply - function(p) { pdf - randomdf(p); system.time(ddply(pdf, .(x1), 
 function(df) { return (data.frame(min(df$x2))) })) }
 lapply(c(1,2,3,4,5), testddply)
[[1]]
   user  system elapsed
  0.020   0.000   0.021

[[2]]
   user  system elapsed
  0.119   0.000   0.119

[[3]]
   user  system elapsed
  1.008   0.000   1.008

[[4]]
   user  system elapsed
  8.425   0.001   8.428

[[5]]
   user  system elapsed
 23.070   0.000  23.075

Once the data frame gets above 1M rows, the timings are a bit too long
(on a previous run it went up to 8000s user time). This seems quite a
bit slower than I expected. Maybe there's a better and faster way to
add such variables to a data frame that are derived using some
aggregation.

Also, ddply seems to take twice as long as by. Are these two
operations not equivalent?

Thanks,
Tahir

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Is there an variant of apply() that does not return anything?

2009-11-19 Thread Peng Yu
There are a few version of apply() (e.g., lapply(), sapply()). I'm
wondering if there is one that does not return anything but just
silently apply a function to the list argument.

For example, the plot function is applied to each element in 'alist'.
It is redundant to return anything from apply.

apply(alist,function(x){ plot each element of alist})

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Is there an variant of apply() that does not return anything?

2009-11-19 Thread Marc Schwartz

On Nov 20, 2009, at 10:21 AM, Peng Yu wrote:


There are a few version of apply() (e.g., lapply(), sapply()). I'm
wondering if there is one that does not return anything but just
silently apply a function to the list argument.

For example, the plot function is applied to each element in 'alist'.
It is redundant to return anything from apply.

apply(alist,function(x){ plot each element of alist})




Just use a for() loop. If you are plotting things, the performance  
bottleneck is not going to be in the loop.


Sometimes, we get too anal about avoiding for() loops.

HTH,

Marc Schwartz

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


Re: [R] Is there an variant of apply() that does not return anything?

2009-11-19 Thread Charlie Sharpsteen
On Thu, Nov 19, 2009 at 2:21 PM, Peng Yu pengyu...@gmail.com wrote:
 There are a few version of apply() (e.g., lapply(), sapply()). I'm
 wondering if there is one that does not return anything but just
 silently apply a function to the list argument.

 For example, the plot function is applied to each element in 'alist'.
 It is redundant to return anything from apply.

 apply(alist,function(x){ plot each element of alist})

Take a look at the l_ply(), a_ply() and d_ply() functions from
Hadley's plyr package.  They are a refinement and extension to the
apply family of functions and the underscore, _, in the function
names indicates that they have no return value.


-Charlie

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Is there an variant of apply() that does not return anything?

2009-11-19 Thread jim holtman
invisible(apply(...))

On Thu, Nov 19, 2009 at 5:21 PM, Peng Yu pengyu...@gmail.com wrote:
 There are a few version of apply() (e.g., lapply(), sapply()). I'm
 wondering if there is one that does not return anything but just
 silently apply a function to the list argument.

 For example, the plot function is applied to each element in 'alist'.
 It is redundant to return anything from apply.

 apply(alist,function(x){ plot each element of alist})

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




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

What is the problem that you are trying to solve?

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Is there an variant of apply() that does not return anything?

2009-11-19 Thread Peng Yu
On Thu, Nov 19, 2009 at 4:27 PM, Marc Schwartz marc_schwa...@me.com wrote:
 On Nov 20, 2009, at 10:21 AM, Peng Yu wrote:

 There are a few version of apply() (e.g., lapply(), sapply()). I'm
 wondering if there is one that does not return anything but just
 silently apply a function to the list argument.

 For example, the plot function is applied to each element in 'alist'.
 It is redundant to return anything from apply.

 apply(alist,function(x){ plot each element of alist})



 Just use a for() loop. If you are plotting things, the performance
 bottleneck is not going to be in the loop.

 Sometimes, we get too anal about avoiding for() loops.

Is there a way to get the name of the list in the loop body?

 List=list(a='c',b='x',e='q')
 for(x in List) { print(x) }
[1] c
[1] x
[1] q

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Is there an variant of apply() that does not return anything?

2009-11-19 Thread Peng Yu
I want to use both the name and the content. Although, I could do the
following thing.

for(x in names(List)) {
  do some thing with x
  do some thing with List[[x]]
}

However, I'd prefer something like the following if R offers such
functionality. But it seems not.

for(x in List) {
  do something with the name of x
  do something with x
}

On Fri, Nov 20, 2009 at 4:35 PM, Jorge Ivan Velez
jorgeivanve...@gmail.com wrote:
 If I understood correctly
 for(x in names(List)) print(x)
 should do what you asked.
 HTH, Jorge

 On Thu, Nov 19, 2009 at 5:31 PM, Peng Yu  wrote:

 On Thu, Nov 19, 2009 at 4:27 PM, Marc Schwartz marc_schwa...@me.com
 wrote:
  On Nov 20, 2009, at 10:21 AM, Peng Yu wrote:
 
  There are a few version of apply() (e.g., lapply(), sapply()). I'm
  wondering if there is one that does not return anything but just
  silently apply a function to the list argument.
 
  For example, the plot function is applied to each element in 'alist'.
  It is redundant to return anything from apply.
 
  apply(alist,function(x){ plot each element of alist})
 
 
 
  Just use a for() loop. If you are plotting things, the performance
  bottleneck is not going to be in the loop.
 
  Sometimes, we get too anal about avoiding for() loops.

 Is there a way to get the name of the list in the loop body?

  List=list(a='c',b='x',e='q')
  for(x in List) { print(x) }
 [1] c
 [1] x
 [1] q

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Is there an variant of apply() that does not return anything?

2009-11-19 Thread Gabor Grothendieck
On Thu, Nov 19, 2009 at 5:31 PM, Peng Yu pengyu...@gmail.com wrote:
 Is there a way to get the name of the list in the loop body?


This was just discussed!  See this thread:

https://stat.ethz.ch/pipermail/r-help/2009-November/218919.html

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


[R] Change color of single panel in xyplot

2009-11-19 Thread jimdare

Hi there,

I have created a single page, multi-panel, xyplot using lattice.  Each panel
is a trial (total of 8) from an experiment with 3 variables on the x axis
and the observed value on the y axis.  I have added the mean of all trials
so the entire plot looks like this (where M=mean panel and 1-8 = trial
panels):  

M 1 2
3 4 5
6 7 8  

I want to change the colour of the mean panel (M) so that it stands out from
the trials.  I have tried using: col=c(red,rep(black,8)), but this
changes the first point to red on all panels.  Is there a way to specify the
colour for a single panel without changing the rest?

Thanks,

James 

-- 
View this message in context: 
http://old.nabble.com/Change-color-of-single-panel-in-xyplot-tp26421512p26421512.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] Is there an variant of apply() that does not return anything?

2009-11-19 Thread Marc Schwartz

On Nov 19, 2009, at 4:31 PM, Peng Yu wrote:

On Thu, Nov 19, 2009 at 4:27 PM, Marc Schwartz  
marc_schwa...@me.com wrote:

On Nov 20, 2009, at 10:21 AM, Peng Yu wrote:


There are a few version of apply() (e.g., lapply(), sapply()). I'm
wondering if there is one that does not return anything but just
silently apply a function to the list argument.

For example, the plot function is applied to each element in  
'alist'.

It is redundant to return anything from apply.

apply(alist,function(x){ plot each element of alist})




Just use a for() loop. If you are plotting things, the performance
bottleneck is not going to be in the loop.

Sometimes, we get too anal about avoiding for() loops.


Is there a way to get the name of the list in the loop body?


List=list(a='c',b='x',e='q')
for(x in List) { print(x) }

[1] c
[1] x
[1] q



Here is one approach to give you some insight into how to get the name  
(as opposed to the object itself) of an argument passed to a function:


MyList - list(a = 1, b = 2, e = 3)

PlotFn - function(x)
{
  # Get the name of the object passed as 'x' (eg. MyList)
  Main - deparse(substitute(x))

  for (i in seq(along = x))
  {
plot(x[[i]], main = Main, ylab = names(x[i]))
  }
}

# Set to pause between each graphic
par(ask = TRUE)

PlotFn(MyList)

Take note that the main title for each graphic will be MyList and  
the y axis label for each, will be the name of each of the three  
components in MyList (eg. a, b and e)


HTH,

Marc Schwartz

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


Re: [R] How to wait for a user response in Rscript?

2009-11-19 Thread Peter Ehlers

You could try

 ?example

and see what the help page says.

 -Peter Ehlers

Peng Yu wrote:

Why I don't see 'par(ask=T)' in /usr/lib/R/library/graphics/R-ex/barplot.R?

Is 'par(ask=T)' implicitly called by example()?

On Mon, Sep 7, 2009 at 10:55 AM, RIOS,ALFREDO ARTURO ar...@ufl.edu wrote:

Hi Peng

I think this is what you are looking for

par(ask=T)

Alfredo


On Sun Sep 06 12:52:31 EDT 2009, Peng Yu pengyu...@gmail.com wrote:


Hi,

In 'example(barplot)' running in R, I see 'Hit Return to see next
plot:', then R waits for my input. I am wondering how to wait for a
user response in Rscript.

Regards,
Peng

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





--
RIOS,ALFREDO ARTURO




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

2009-11-19 Thread rkevinburton
Hello,

In reading the loess description I see:

 span: the parameter alpha which controls the degree of smoothing.

The default seems to be 0.75. Would it be possible to expand on this decription 
so I can avoid trail and error? Can I increase this pass 'span'  1? 
Qualitatively to what degree changing this value affects the smoothing of the 
data?

Thank you.

Kevin

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


[R] optim(.. ,SANN,..)

2009-11-19 Thread lloyd barcza
I have a problem using optim, so I am hoping someone can help me out with it:

Suppose I have the list:

list(D,R,P)
[[1]]
   V1 V2 V3 V4
1   0  1  0  1
2   1  1  0  0
3   1  0  1  0
4   0  0  1  1
5   0  1  0  1
6   1  1  0  0
7   1  0  1  0
8   0  0  1  1
9   1  0  1  0
10  0  0  1  1

[[2]]
 [1]   23   85   12   73   23   24   25   56   78 1200

[[3]]
  V1
1 25
2 80
3 15
4 60
5 56
6 15
7 20
8 70
9 45
10 12000

and the strange function fr which I want to maximise:

fr-function(x){y-x*D
C-apply(t(apply(y,1,function(c){c[c0]})),1,prod)
R2-R*C
w-R2[R2P]
g-sum(w)
return(g)}

v-c(1,1,1,1,1,1,1,1,1,1)

res - optim(v, fr, method=SANN,
  control=list(maxit=200, temp=20,v))

I get the following error:
Error in prod(..., na.rm = na.rm) : invalid 'type' (list) of argument

I'm not sure if its because this function is too disjoint to be opimised using 
SANN or I am not using optim properly. 

Any help or suggestions would be appreciated.

Thanks

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


Re: [R] Change color of single panel in xyplot

2009-11-19 Thread David Winsemius

This was just answered by Deepayan earlier today:

This code did not produce the plot you have linked to. The answer to
your question depends on how you created the plot, so you have to tell
us that. Changing the color in all panels is easy:

histogram(rnorm(100), col = goldenrod)

Different colors in different panels is a little more work:

histogram(~rnorm(100) | gl(3, 1, 100),
 mycolors = sample(colors(), 3),
 panel = function(..., col, mycolors) {
 panel.histogram(..., col = mycolors[panel.number()])
 })

-Deepayan


--  
David


On Nov 19, 2009, at 5:43 PM, jimdare wrote:



Hi there,

I have created a single page, multi-panel, xyplot using lattice.   
Each panel
is a trial (total of 8) from an experiment with 3 variables on the x  
axis
and the observed value on the y axis.  I have added the mean of all  
trials

so the entire plot looks like this (where M=mean panel and 1-8 = trial
panels):

M 1 2
3 4 5
6 7 8

I want to change the colour of the mean panel (M) so that it stands  
out from

the trials.  I have tried using: col=c(red,rep(black,8)), but this
changes the first point to red on all panels.  Is there a way to  
specify the

colour for a single panel without changing the rest?

Thanks,

James

--
View this message in context: 
http://old.nabble.com/Change-color-of-single-panel-in-xyplot-tp26421512p26421512.html
Sent from the R help mailing list archive at Nabble.com.

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


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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


[R] Passing filenames to the getopt package

2009-11-19 Thread EJ Nikelski
Hi all,

I've finally started to use Rscript for my statistical scripting
needs, and find I'm being blocked by what must be a very simple
problem.  Specifically, the command lines for my scripts usually
contain: (1) the script name, (2) one or more options and their
arguments, and finally, (3) one or more filenames to be processed.
While the getopt package seems to provide me with excellent option
reading functionality, it however, also wants to read the trailing
filenames as options as well -- and then fails.  Am I missing
something obvious?

Thanks,

-Jim

 version
  _
platform   i386-apple-darwin8.11.1
arch   i386
os darwin8.11.1
system i386, darwin8.11.1
status
major  2
minor  9.2
year   2009
month  08
day24
svn rev49384
language   R
version.string R version 2.9.2 (2009-08-24)


-- 
=
Jim Nikelski, Ph.D.
Postdoctoral Research Fellow
Bloomfield Centre for Research in Aging
Lady Davis Institute for Medical Research
Sir Mortimer B. Davis - Jewish General Hospital
McGill University

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


Re: [R] How do I change the colour and format for the trelli plot ?

2009-11-19 Thread ychu066

what is that ?



Hrishi Mittal wrote:
 
 Add col=i in the histogram call.
 

-- 
View this message in context: 
http://old.nabble.com/How-do-I-change-the-colour-and-format-for-the-trelli-plot---tp26418382p26421453.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] sqldf

2009-11-19 Thread JoK LoQ

Hello,

   I would like some help with sqldf syntax.
   
   Suppose I have table 1 and table 2.
   What do I have to do to generate a table with columns 2,5,6 from table 1
(for example), and columns 3,4,5,9 from table 2, but only when values in
column 2 from table 1 are equal to values in column 5 from table 2. 

tnks 
-- 
View this message in context: 
http://old.nabble.com/sqldf-tp26421449p26421449.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] How do I change the colour and format for the trelli plot ?

2009-11-19 Thread Hrishi Mittal

To have a different colour for each histogram. Wasn't that your question?
Sorry if I misunderstood.

Did you try it?



ychu066 wrote:
 
 what is that ?
 
 
 
 Hrishi Mittal wrote:
 
 Add col=i in the histogram call.
 
 
 

-- 
View this message in context: 
http://old.nabble.com/How-do-I-change-the-colour-and-format-for-the-trelli-plot---tp26418382p26421456.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] Tinn-R related problem

2009-11-19 Thread AlisonT

As of last night I have this exact same problem, Enter, Backspace and the
arrow keys do not work for me in TinnR! I am using windows vista prof on a
64bit laptop. I have uninstalled, re-installed many times and even cleaned
the registry etc. Does anyone know of a reason and a fix for this problem?
thanks
Alison



davidseres wrote:
 
 
 
 David Hewitt wrote:
 
 
 
 A few weeks ago all of a sudden the backspace, enter and direction keys
 were not working. I updated Tinn-R to the newest version but still no
 sollution. After this I tried reinstalling it (prior to that I removed
 Tinn-R and deleted all the leftovers manually) and still no change. In
 every other execution (e.g. when I save a file) every key works fine.
 
 
 I've used Tinn-R with R on Win XP ever since I started with R, and I've
 never had this problem. The only immediate thing that comes to mind is
 that you should be installing R in SDI mode to get it working with
 Tinn-R. At least that's what they say, and I've never tried it the other
 way (MDI). Maybe just uninstall R and Tinn-R, then reload R, use Custom
 installation and pick SDI, then reinstall Tinn-R. Worth a shot.
 
 
 
 From what I have read in the other forums I believe this issue is not
 necessarily R or Tinn-R related but might be some hidden Windows
 settings (I'm using XP) but of this I'm not sure.
 
 
 If that's the case, I can't help. What occurred a few weeks ago that
 might have been related? Did you upgrade R?
 
 
 
 I am using R in the SDI mode.
 I can't really recall what happened a few weeks ago. There is too much
 going on on my laptop. But yes, I've upgraded R to 2.6.2 but I don't
 remember this causing the problem.
 

-- 
View this message in context: 
http://old.nabble.com/Tinn-R-related-problem-tp15950714p26421486.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] How do I change the colour and format for the trelli plot ?

2009-11-19 Thread ychu066

Fore example my code is 
histogram(~data[,8]|data[,2], ylab = Frequency, xlab = Score, xlim =
c(1,5), ylim = c(0,100),layout = c(3,1),col=data[,2] )

and i want the colour to be depended on the level of the factor in data[,2]. 
how do i do that ?





ychu066 wrote:
 
 what is that ?
 
 
 
 Hrishi Mittal wrote:
 
 Add col=i in the histogram call.
 
 
 

-- 
View this message in context: 
http://old.nabble.com/How-do-I-change-the-colour-and-format-for-the-trelli-plot---tp26418382p26421461.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] How do I change the colour and format for the trelli plot ?

2009-11-19 Thread ychu066

I want to change the colour of the histogram in each panel by the levels of
the conoditonal factor.

I have 3 levels in the factor 

levels(data[,2])[1] 
levels(data[,2])[2]
levels(data[,2])[3]

what can i do , in order to chnage the colour ??



ychu066 wrote:
 
 Fore example my code is 
 histogram(~data[,8]|data[,2], ylab = Frequency, xlab = Score, xlim =
 c(1,5), ylim = c(0,100),layout = c(3,1),col=data[,2] )
 
 and i want the colour to be depended on the level of the factor in
 data[,2].  how do i do that ?
 
 
 
 
 
 ychu066 wrote:
 
 what is that ?
 
 
 
 Hrishi Mittal wrote:
 
 Add col=i in the histogram call.
 
 
 
 
 

-- 
View this message in context: 
http://old.nabble.com/How-do-I-change-the-colour-and-format-for-the-trelli-plot---tp26418382p26421465.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] RE shaping large dataset

2009-11-19 Thread ychu066

I am doing a project which involve reshaping a large dataset, can any of you
please sugguest me some good reading/websites/ examples  can be in R and
SAS 


Thanks everyone !!! 
-- 
View this message in context: 
http://old.nabble.com/REshaping-large-dataset-tp26421513p26421513.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] sqldf

2009-11-19 Thread Gabor Grothendieck
Google for sql join and see the examples in Example 4 on the sqldf home page:
http://code.google.com/p/sqldf/#Example_4._Join


On Thu, Nov 19, 2009 at 2:30 PM, JoK LoQ jok...@gmail.com wrote:

 Hello,

   I would like some help with sqldf syntax.

   Suppose I have table 1 and table 2.
   What do I have to do to generate a table with columns 2,5,6 from table 1
 (for example), and columns 3,4,5,9 from table 2, but only when values in
 column 2 from table 1 are equal to values in column 5 from table 2.

 tnks
 --
 View this message in context: 
 http://old.nabble.com/sqldf-tp26421449p26421449.html
 Sent from the R help mailing list archive at Nabble.com.

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


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


Re: [R] How do I change the colour and format for the trelli plot ?

2009-11-19 Thread David Winsemius


On Nov 19, 2009, at 3:10 PM, ychu066 wrote:



I want to change the colour of the histogram in each panel by the  
levels of

the conoditonal factor.

I have 3 levels in the factor

levels(data[,2])[1]
levels(data[,2])[2]
levels(data[,2])[3]

what can i do , in order to chnage the colour ??


Why do you suppose there is a FAQ?

Assuming that the underlying levels are coercible to numeric type then:

col = as.numeric(as.character(data[ , 2] ) )

and of course:

library(fortunes)
fortune(dog)

-- David





ychu066 wrote:


Fore example my code is
histogram(~data[,8]|data[,2], ylab = Frequency, xlab = Score,  
xlim =

c(1,5), ylim = c(0,100),layout = c(3,1),col=data[,2] )

and i want the colour to be depended on the level of the factor in
data[,2].  how do i do that ?





ychu066 wrote:


what is that ?



Hrishi Mittal wrote:


Add col=i in the histogram call.









--
View this message in context: 
http://old.nabble.com/How-do-I-change-the-colour-and-format-for-the-trelli-plot---tp26418382p26421465.html
Sent from the R help mailing list archive at Nabble.com.

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


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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


[R] how to plot mean+/-SD from externally calculated values

2009-11-19 Thread Dan Kortschak
Hi,

I am trying to plot a set of means+/-SD calculated by an external
program (an RDBMS) since the data set is too large to happily fit in R
(740M x 100 values - which are summarised to 100 means/SD by the DB). I
want to have a mean with whiskers at +/-1SD.

Can anyone suggest a way to do this?

thanks
Dan

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 plot mean+/-SD from externally calculated values

2009-11-19 Thread David Winsemius


On Nov 19, 2009, at 6:33 PM, Dan Kortschak wrote:


Hi,

I am trying to plot a set of means+/-SD calculated by an external
program (an RDBMS) since the data set is too large to happily fit in R
(740M x 100 values - which are summarised to 100 means/SD by the  
DB). I

want to have a mean with whiskers at +/-1SD.

Can anyone suggest a way to do this?


 install.packages(plotrix)
 library(plotrix)
 ?plotCI

--

David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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


[R] Finding replacing non-ASCII characters

2009-11-19 Thread Steven Kang
Hi guys,





Are there any feasible methods in searching  finding non-ASCII characters
in R?



For example, from the following object,



x - mia. SzaÌmitaÌó



The desired output is,

x.out - mia. SzaImitaIA



Your help in resolving this would be greatly appreciated.

[[alternative HTML version deleted]]

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


  1   2   >