Re: [R] parsing pdf files

2010-01-10 Thread Mark Wardle
If you can use a R - java interface, you could use itext to do this
as long as the PDF is fairly sane.

see http://itextpdf.com/

It is what pdftk uses.

b/w

Mark

2010/1/9 David Kane d...@kanecap.com:
 I have a pdf file that I would like to parse into R:

 http://www.williams.edu/Registrar/geninfo/faculty.pdf

 For now, I open the file in Acrobat by hand, then save it as text
 and then use readLines(). That works fine but a) I am concerned that
 some information may be lost and b) I may be doing this a lot, so I
 would rather have R grab the information from the pdf file directly.

 So: is there something like readPDF() for R?

 Thanks,

 Dave Kane

 PS. If you're curious, here is the sort of work that I want to do with
 this data:
 http://www.ephblog.com/2010/01/08/class-update-and-faculty-ages/

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





-- 
Dr. Mark Wardle
Specialist registrar, Neurology
Cardiff, UK

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


Re: [R] parsing pdf files

2010-01-10 Thread Mark Wardle
[copied to list for posterity...]


Sorry. I am completely wrong. I've been using itext to split, fill in
forms and recombine PDF so assumed (wrongly) that text extraction was
possible.

In fact, reading the mailing lists is quite informative - clearly PDF
is not designed for this.

Try this

http://pdfbox.apache.org/commandlineutilities/ExtractText

can be run from command line so potentially could be automated.

Mark

2010/1/10 Mark Wardle m...@wardle.org:
 If you can use a R - java interface, you could use itext to do this
 as long as the PDF is fairly sane.

 see http://itextpdf.com/

 It is what pdftk uses.

 b/w

 Mark

 2010/1/9 David Kane d...@kanecap.com:
 I have a pdf file that I would like to parse into R:

 http://www.williams.edu/Registrar/geninfo/faculty.pdf

 For now, I open the file in Acrobat by hand, then save it as text
 and then use readLines(). That works fine but a) I am concerned that
 some information may be lost and b) I may be doing this a lot, so I
 would rather have R grab the information from the pdf file directly.

 So: is there something like readPDF() for R?

 Thanks,

 Dave Kane

 PS. If you're curious, here is the sort of work that I want to do with
 this data:
 http://www.ephblog.com/2010/01/08/class-update-and-faculty-ages/

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





 --
 Dr. Mark Wardle
 Specialist registrar, Neurology
 Cardiff, UK




-- 
Dr. Mark Wardle
Specialist registrar, Neurology
Cardiff, UK

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


Re: [R] Lattice in a loop does not produce output

2009-08-18 Thread Mark Wardle

Try printing the plot created.

print(xyplot(...))

--  
Dr. Mark Wardle

Specialist registrar, Neurology
(Sent from my mobile)


On 18 Aug 2009, at 13:13, Alex van der Spek am...@xs4all.nl wrote:


I cannot understand why xyplot does not work within a simple for loop.

This works up to the for loop; inside the for loop the png files are
opened and closed, but nothing is plotted. No error messages are  
written

to the console either. This is the case on both Windows and Linux.

By the way, running the script below on Linux using source() does not
even produce the first xyplot. This is less of an issue for me though.

#! usr/bin/env R
# Test lattice loop

rm(list=ls())

x-1:16
y-2*x-1
z-rep(c('A','B','C','D'),4)

xyz-data.frame(x=x,y=y,z=z)

require(lattice)

png('Test.png')
xyplot(y~x|z)
dev.off()

for (i in 1:5) {
f-paste('Test',i,'.png',sep='')
png(f)
xyplot(y~x|z)
dev.off()
}

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



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


Re: [R] read.csv from a remote machine

2009-08-04 Thread Mark Wardle
I would use sshfs or an alternatively remote file system access. Ssh  
to your Linux box and then mount the mac os x filesystem via sshfs, or  
afs for example. Alternatively, can't you copy the data to the Linux  
box using sftp first?


--
Dr. Mark Wardle
Specialist registrar, Neurology
(Sent from my mobile)


On 4 Aug 2009, at 18:50, Olga Lyashevska o...@herenstraat.nl wrote:


Thanks Barry and Steve,

I am trying to import data with read.csv and my file is on remote  
machine.
I believe that I need to open a connection, not sure about syntax  
though.

Probably works with ftp: too. How remote is it?


In fact it is a bit more complicated.
I am working on a Mac machine, from this machine I establish ssh  
with a Linux machine. I run R on Linux, while all my data files are  
stored on Mac. So in this case although physically I am using Mac,  
it is in fact remote. I hope it answers your question.



Thanks again,
Olga

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

2009-07-07 Thread Mark Wardle
I generate PDF images and then rasterise using imagemagick to large,
high quality JPG files. Then manually insert into powerpoint. Former
two can definitely be automated, I'm sure the latter insertion could
be automated with judicious use of scripting if really necessary.

2009/7/7 Thomas aikto...@yahoo.com:
 Hi,

 Is it possible to dump a series of plots directly into a powerpoint 
 presentation (as is possible in Splus)?

 Thank you,
 Thomas




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





-- 
Dr. Mark Wardle
Specialist registrar, Neurology
Cardiff, UK

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


Re: [R] OK - I got the data - now what? :-)

2009-07-06 Thread Mark Wardle
Hi. As I said in my first email, converting your data into a long
format makes a lot of sense. I'm sorry that you find it hard ... to
understand why this would make plotting easier.

Wide format:
Subject ID, Experiment ID, humidity, light, whatever, T1, T2,T3,T4.

is much better rotated to be
Subject ID, Experiment ID, humidity, light, whatever, time, result

So you end up with multiple rows per patient/individual/experiment. It
is much easier to analyse and plot data like this, particularly if the
original data is ragged. ie. you have a different number of
measurements per patient/individual/experiment.

Many plotting functions will support connecting related data (e.g. by
virtue of a particular identifier) and support much of what you are
likely to want (different plotting symbols, panelled plots depending
on experimental conditions etc) without you having to manually work
through data as you are suggesting.

Best wishes,

Mark


2009/7/6 Mark Knecht markkne...@gmail.com:
 On Sun, Jul 5, 2009 at 1:44 PM, hadley wickhamh.wick...@gmail.com wrote:
   I think the root cause of a number of my coding problems in R right
 now is my lack of skills in reading and grabbing portions of the data
 out of arrays. I'm new at this. (And not a programmer) I need to find
 some good examples to read and test on that subject. If I could locate
 which column was called C1, then read row 3 from C1 up to the last
 value before a 0, I'd have proper data to plot for one line. Repeat as
 necessary through the array and I get all the lines. Doing the lines
 one at a time should allow me the opportunity to apply color or not
 plot based on values in the first few columns.

 Thanks,
 Mark

 test - data.frame(A=1:10, B=100, C1=runif(10), C2=runif(10),
 C3=runif(10), C4=runif(10), C5=runif(10), C6=runif(10))
 test-round(test,2)

 #Make array ragged
 test$C3[2]-0;test$C4[2]-0;test$C5[2]-0;test$C6[2]-0
 test$C4[3]-0;test$C5[3]-0;test$C6[3]-0
 test$C6[7]-0
 test$C4[8]-0;test$C5[8]-0;test$C6[8]-0

 #Print array
 test

 Are the zeros always going to be arranged like this? i.e. for
 experiment there is a point at which all later values are zero?  If
 so, the following is a much simpler way of getting to the core of your
 data, without fussing with overly complicated matrix indexing:

 library(reshape)
 testm - melt(test, id = c(A, B))
 subset(testm, value  0)

 I suspect you will also find this form easier to plot and analyse.

 Hadley

 --
 http://had.co.nz/


 Hi Hadley,
   I wanted to look at reshape.

   Yes, there exists a point in each row (unless I get to the end with
 all numbers) where I get to a zero and everything to the right is
 zero.

   I'm looking at ReShape. It's interesting but I clearly don't
 understand it yet so I'm reading your ReShaping data with the reshap
 package form 11/07. Interesting.

   I know so little about R that I'm sort of drowning at this point
 that it's hard for me to understand why this would make plotting
 easier. Analysis possibly. Just the way it goes when you get started
 with something new.

   In ReShape lingo I think I have ID's. They cover things like time,
 date, success/failure and a few other things of interest. Once the
 data starts on a row it is all data from there on to the end of the
 row.

   My initial goal is to make a line plot of the data on a single row.
 All the data points should connect together. There is no real
 interaction planned with data on other rows, at least at this time.

   Thanks for the pointers and the code stub. I'll be looking at this.

 Cheers,
 Mark

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




-- 
Dr. Mark Wardle
Specialist registrar, Neurology
Cardiff, UK

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


Re: [R] OK - I got the data - now what? :-)

2009-07-05 Thread Mark Wardle
Hi. Essentially your data is currently in wide format, with repeated
measures in different columns. For most analysis and in particular for
graphing, it is frequently helpful to reshape your data into a long
format, with one row per data value and additional variables to list
experiment or subject identifier, experimental conditions etc.

see ?reshape and Dr. Wickham's reshape package (http://had.co.nz/reshape/)

Good luck,

Mark


2009/7/5 Mark Knecht markkne...@gmail.com:
 OK, I guess I'm getting better at the data part of R. I wrote a
 program outside of R this morning to dump a bunch of experimental
 data. It's a sort of ragged array - about 700 rows and 400 columns,
 but the amount of data in each column varies based on the length of
 the experiment. The real data ends with a 0 following some non-zero
 value. It might be as short as 5 to 10 columns or as many as 390. The
 first 9 columns contain some data about when the experiment was run
 and a few other things I thought I might be interested in later. All
 the data starts in column 10 and has headers saying C1, C2, C3, C4,
 etc., up to C390 The first value for every experiment is some value I
 will normalize and then the values following are above and below the
 original tracing out the path that the experiment took, ending
 somewhere to the right but not a fixed number of readings.

 R reads it in fine and it looks good so far.

 Now, what I thought I might do with R is plot all 700 rows as
 individual lines, giving them some color based on info in columns 1-9,
 but suddenly I'm lost again in plots which I think should be fairly
 easy. How would I go about creating a plot for even one line, much
 less all of them? I don't have a row with 1,2,3,4 to us as the X axis
 values. I could go back and put one in the data but then I don't think
 that should really be required, or I could go back and make the
 headers for the whole array 1:400 and then plot from 10:400 but I
 thought I read that headers cannot start with numbers.

 Maybe the X axis values for a plot can actually be non-numeric C1, C2,
 C3, C4, etc and I could use line (C1,0) to (C2,5) and so on? Or maybe
 I should strip the C from C1 and be left with 1? Maybe the best thing
 is to copy the data for one line to another data.frame or array and
 then plot that?

 Just sort of lost looking at help files. Thanks for any ideas you can
 send along. Ask questions if I didn't explain my problem well enough.
 Not looking for anyone to do my work, just trying to get the concepts
 right

 Cheers,
 Mark

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





-- 
Dr. Mark Wardle
Specialist registrar, Neurology
Cardiff, UK

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


Re: [R] How to use current value of variable in function definition?

2009-07-03 Thread Mark Wardle
2009/7/2 Peter Dalgaard p.dalga...@biostat.ku.dk:
 Mark Wardle wrote:
 [...]
 Otherwise, it sounds like a recipe for obfuscation! What are you
 trying to do really?

 Not really obfuscation, there are legitimate reasons to want this sort of
 behaviour. See demo(scoping) for a related example
 [...]

I would have implemented this using either a OO approach or (if there
was not going to be future code re-use) by defining a hidden variable
with a lazy initialisation helper function that returns a cached value
of the data or acquires data for the first time. Not as elegant as the
solution given by Dr. Dalgaard.

-- 
Dr. Mark Wardle
Specialist registrar, Neurology
Cardiff, UK

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


Re: [R] How to use current value of variable in function definition?

2009-07-02 Thread Mark Wardle
Hi.

I've stared at your code for a number of minutes and can't understand
what you're trying to achieve here. It looks as if you're fighting
scope - it may be worth refactoring your approach to simplify matters.
Otherwise, it sounds like a recipe for obfuscation! What are you
trying to do really?

b/w

Mark

2009/7/2 Allan Engelhardt all...@cybaea.com:
 Must be the heat or something but I can't get my brain into gear and figure
 out how to get something like

 if (1) { c - 1; foo - function () print(c); }
 c - 2
 foo()

 to print 1, not 2.  (The real life example is a little more complex, but you
 get the idea.  I don't want the variable c in the function definition, I
 want its value at that time.)

 The only thing I have been able to come up with is something like

 if (1) foo - (function () { c - 1; return(function () print(c)) })()
 c - 2
 foo()
 # [1] 1

 but that just hurts.  Please make the pain go away.

 Can someone wake up my brain?

 Allan.

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





-- 
Dr. Mark Wardle
Specialist registrar, Neurology
Cardiff, UK

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


Re: [R] Drawing schematics

2009-05-29 Thread Mark Wardle
Hi. Have you looked at graphviz?

I have previously used R to generate graphviz diagrams. I create a
template graphviz diagram and then use R to parse this template,
substitute appropriate values and then outputto a temporary file. I
then use a system() call to run graphviz on thisoutputted intermediary
file to generate a PDF which is then incorporated into a report using
Sweave. There is an Rgraphviz package, but I simply used a system()
call instead.

I use RODBC to extract data directly from my research databases.

I've used it to generate pretty publication-quality graphs showing
patient recruitment, drop-outs etc., with patient numbers updated
every time it is run!

Hope this helps,

Best wishes,

Mark


2009/5/29 George Chen glc...@stanford.edu:
 Hi,

 I would like to represent the treatment course of a subject with an arrow 
 representing passage through time and various ticks, arrows, or bars 
 representing treatments done to the patient along the arrow.  I would like to 
 generate this sort of schematic for each patient in a database taking 
 information from the database such as time of treatment and type of treatment.

 Does anybody know how I can do this?  Is there a premade R package for this 
 sort of thing or should I try to make a new graphics function?  If a new 
 graphics function, where could I start?

 Thanks in advance.

 George

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





-- 
Dr. Mark Wardle
Specialist registrar, Neurology
Cardiff, UK

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


Re: [R] question about using a remote system

2009-05-29 Thread Mark Wardle
I've not ever tried something like this. You didn't quite answer the
question though. Do you need interactive sessions, or are users
choosing from a number of batch jobs?

If the latter, then perhaps you would be better forsaking Rcmdr (which
I have not used) and instead consider a shell-based, or web-based
interface (have you seen Rweb?). I presume by job you mean batch
jobs that are pre-written?

If you need an interactive session, then I can't see any easy way of
doing as you describe. I was waiting for someone else to suggest
something. My only suggestion would be to look at the unix program
screen. You could then have a simple click-on application (shell
script or something) that connects to your remote system, runs screen,
gives them a prompt, and allows them to run arbitrary R interactive
sessions. For long-running tasks, they can then detach the screen and
leave it running on  the remote system.

I'm only guessing at your specific requirements here as I don't have
enough information about exactly you want to do!

Best wishes,

Mark



2009/5/28 Erin Hodgess erinm.hodg...@gmail.com:
 My goal is for a user to sit down at a Linux laptop, get to an Rcmdr
 type screen, submit jobs on a remote system and then get the results
 back in R.

 We will assume that the user is naive, and the only thing he/she can
 do is get to the Rcmdr screen.

 The Rcmdr plugin will have a submit jobs menu.  The user presses
 that option, and gets results, without having to know the underside.

 thanks,
 Erin

 On Thu, May 28, 2009 at 1:54 AM, Mark Wardle m...@wardle.org wrote:
 Hi.

 Do you need an interactive session at the remote machine, or are you
 simply wanting to run a pre-written script?

 If the latter, then you can ask ssh to execute a remote command, which
 conceivably could be R CMD x

 If you explain exactly why and what you are trying to do, then perhaps
 there's a better solution

 bw

 Mark

 2009/5/28 Erin Hodgess erinm.hodg...@gmail.com:
 Dear R People:

 I would like to set up a plug-in for Rcmdr to do the following:

 I would start on a Linux laptop.  Then I would log into another
 outside system and run a some commands.

 Now, when I tried to do
 system(ssh e...@xxx.edu)
 password xx

 It goes to the remote system.  how do I continue to issue commands
 from the Linux laptop please?

 (hope this makes sense)

 thanks,
 Erin


 --
 Erin Hodgess
 Associate Professor
 Department of Computer and Mathematical Sciences
 University of Houston - Downtown
 mailto: erinm.hodg...@gmail.com

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





 --
 Dr. Mark Wardle
 Specialist registrar, Neurology
 Cardiff, UK




 --
 Erin Hodgess
 Associate Professor
 Department of Computer and Mathematical Sciences
 University of Houston - Downtown
 mailto: erinm.hodg...@gmail.com





-- 
Dr. Mark Wardle
Specialist registrar, Neurology
Cardiff, UK

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


Re: [R] question about using a remote system

2009-05-28 Thread Mark Wardle
Hi.

Do you need an interactive session at the remote machine, or are you
simply wanting to run a pre-written script?

If the latter, then you can ask ssh to execute a remote command, which
conceivably could be R CMD x

If you explain exactly why and what you are trying to do, then perhaps
there's a better solution

bw

Mark

2009/5/28 Erin Hodgess erinm.hodg...@gmail.com:
 Dear R People:

 I would like to set up a plug-in for Rcmdr to do the following:

 I would start on a Linux laptop.  Then I would log into another
 outside system and run a some commands.

 Now, when I tried to do
 system(ssh e...@xxx.edu)
 password xx

 It goes to the remote system.  how do I continue to issue commands
 from the Linux laptop please?

 (hope this makes sense)

 thanks,
 Erin


 --
 Erin Hodgess
 Associate Professor
 Department of Computer and Mathematical Sciences
 University of Houston - Downtown
 mailto: erinm.hodg...@gmail.com

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





-- 
Dr. Mark Wardle
Specialist registrar, Neurology
Cardiff, UK

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


Re: [R] Object-oriented programming in R

2009-05-28 Thread Mark Wardle
Hi. I remember considering these options myself but concluded that for
most analyses a strictly procedural approach was satisfactory.
Although I may re-run multiple analyses, the data manipulation (and
subsequent analysis - the former always more complex than the latter
IMHO) is fairly project- and data-specific. As such, quick and
specific code always seemed more appropriate than slow (to write) and
generic.

Obviously that doesn't apply to package creators and maintainers,
creating something that is going to re-used in many different projects
and can be made generic. That's the heuristic I now use - is this good
enough for other people's consumption - if so, create a package and
adopt some of the OO approaches seen in the base R packages.
Otherwise, stick to bespoke and specific (procedural) functions.

I've a small library of helper functions, but these don't use OO
usually. They sometimes make assumptions about data passed in, don't
have particularly robust error checking, but in general, work well. I
suppose it depends on what you're trying to achieve and how much time
you've got!

Interested in other's thoughts too as clearly there's no right answer here.

bw

Mark

2009/5/27 Luc Villandre villa...@dms.umontreal.ca:
 Dear R-users,

 I have very recently started learning about object-oriented programming in
 R. I am far from being an expert in programming, although I do have an
 elementary C++ background.

 Please take a look at these lines of code.

 some.data = data.frame(V1 = 1:5, V2 = 6:10) ;
 p.plot = ggplot(data=some.data,aes(x=V1, y=V2)) ;
 class(p.plot) ;
 [1] ggplot

 My understanding is that the object p.plot belongs to the ggplot class.
 However, a new class definition like

 setClass(AClass, representation(mFirst = numeric, mSecond = ggplot))
 ;

 yields the warning

 Warning message:
 In .completeClassSlots(ClassDef, where) :
  undefined slot classes in definition of AClass: mSecond(class ggplot)

 The ggplot object is also a list :

 is.list(p.plot)
 [1] TRUE

 So, I guess I could identify mSecond as being a list.

 However, I don't understand why ggplot is not considered a valid slot
 type. I thought setClass() was analogous to the class declaration in C++,
 but I guess I might be wrong. Would anyone care to provide additional
 explanations about this?

 I decided to explore object-oriented programming in R so that I could
 organize the output from my analysis in a more rigorous fashion and then
 define custom methods that would yield relevant output. However, I'm
 starting to wonder if this aspect is not better suited for package builders.
 R lists are already very powerful and convenient templates. Although it
 wouldn't be as elegant, I could define functions that would take lists
 outputted by the different steps of my analysis and do what I want with
 them. I'm wondering what the merits of both approaches in the context of R
 would be. If anyone has any thoughts about this, I'd be most glad to read
 them.

 Cheers,
 --
 *Luc Villandré*
 /Biostatistician
 McGill University Health Center -
 Montreal Children's Hospital Research Institute/

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





-- 
Dr. Mark Wardle
Specialist registrar, Neurology
Cardiff, UK

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


Re: [R] Problem accessing row number from subset on a dataframe

2009-05-26 Thread Mark Wardle
Hi. I may be missing what you're trying to achieve, but...

what about

subset(airquality, airquality$Month!=6)

instead?

You can do arbitrarily complex queries if you wish, combining terms logically.

You don't have to use the subset function. You may find it helpful to
see what the following result in:

airquality$Month==6
airquality[airquality$Month==6, ]
airquality[airquality$Month==6, ]

There are ways of getting the row numbers, but I suspect you don't
actually need to do that, do you?

Best wishes,

Mark

2009/5/26 Jason Rupert jasonkrup...@yahoo.com:


 I would like to use the row number information returned from performing a 
 subset command on a dataframe.

 For example, I would like to automatically delete some rows from a dataframe 
 if they match a criteria.  Here is my example below.

 data(airquality)
 names(airquality)
 subset(airquality, airquality$Month == 6)

 Now how do I delete the row numbers returned automatically?

 I know I can type
 airquality_mod-airquality[-c(32:60)]

 However, I would like to check the row information and then use it to delete 
 the stuff out of the dataframe.

 Thank again for any feedback and insights.

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





-- 
Dr. Mark Wardle
Specialist registrar, Neurology
Cardiff, UK

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


Re: [R] Problem accessing row number from subset on a dataframe

2009-05-26 Thread Mark Wardle
Ok, if you insist [although it's still unclear why you need this level
of indirection!]

Try ?which

e.g.

 which(airquality$Month==5)
 [1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22
23 24 25 26 27 28 29 30 31
 which(airquality$Month==6)
 [1] 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
54 55 56 57 58 59 60 61


gives the vector indices. These can be used as row indices for the dataframe.

bw

Mark


2009/5/26 Jason Rupert jasonkrup...@yahoo.com:

 Mark,

 I really apprecaite your response and continue to be amazed by the 
 responsiveness and support on the R forums.

 And, well actually, I would like to get the row number(s) and then delete 
 or not via the row number.

 Again, I really appreciate the response...

 --- On Tue, 5/26/09, Mark Wardle m...@wardle.org wrote:

 From: Mark Wardle m...@wardle.org
 Subject: Re: [R] Problem accessing row number from subset on a dataframe
 To: Jason Rupert jasonkrup...@yahoo.com
 Cc: R-help@r-project.org
 Date: Tuesday, May 26, 2009, 3:18 PM
 Hi. I may be missing what you're
 trying to achieve, but...

 what about

 subset(airquality, airquality$Month!=6)

 instead?

 You can do arbitrarily complex queries if you wish,
 combining terms logically.

 You don't have to use the subset function. You may find it
 helpful to
 see what the following result in:

 airquality$Month==6
 airquality[airquality$Month==6, ]
 airquality[airquality$Month==6, ]

 There are ways of getting the row numbers, but I suspect
 you don't
 actually need to do that, do you?

 Best wishes,

 Mark

 2009/5/26 Jason Rupert jasonkrup...@yahoo.com:
 
 
  I would like to use the row number information
 returned from performing a subset command on a dataframe.
 
  For example, I would like to automatically delete some
 rows from a dataframe if they match a criteria.  Here is my
 example below.
 
  data(airquality)
  names(airquality)
  subset(airquality, airquality$Month == 6)
 
  Now how do I delete the row numbers returned
 automatically?
 
  I know I can type
  airquality_mod-airquality[-c(32:60)]
 
  However, I would like to check the row information and
 then use it to delete the stuff out of the dataframe.
 
  Thank again for any feedback and insights.
 
  __
  R-help@r-project.org
 mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide 
  http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained,
 reproducible code.
 
 



 --
 Dr. Mark Wardle
 Specialist registrar, Neurology
 Cardiff, UK









-- 
Dr. Mark Wardle
Specialist registrar, Neurology
Cardiff, UK

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


Re: [R] create string of comma-separated content of vector

2009-05-19 Thread Mark Wardle
see ?paste

e.g.

x - seq(0,10,1)
paste(x, collapse=, )


2009/5/19 Katharina May may.kathar...@googlemail.com:
 Hi,

 how do I create a string of the comma-separated content of a vector?

 I've got the vector i with several numeric values as content:
str(i)
 num 99

 and want to create a SQL statement to look like the following where
 the part '(2, 4, 6, 7)' should be
 the content of the vector i:
 select * from  [biomass_data$] where site_no in (2, 4, 6, 7)

 Here my approach (which doesn't work):
 site_all_data =  sqlQuery(channel, select * from  [biomass_data$]
 where site_no in (,paste(i,sep=,),) )


 sorry for spaming so much today to the mailing list...

 -Katharina

 --
 Time flies like an arrow, fruit flies like bananas.

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





-- 
Dr. Mark Wardle
Specialist registrar, Neurology
Cardiff, UK

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


Re: [R] SQL Queries from Multiple Servers

2009-05-15 Thread Mark Wardle
Hi.

Depending on your requirements, one option would be to do the join in
R using merge()

If you wish to run SQL joins across multiple databases, then it is not
an R problem but a database problem. For a quick solution, I would
write scripts that bring all your data together into one database
(could be written in any scripting language, and of course R) and then
process from there.

Bw

Mark

2009/5/13 Tom Schenk Jr tomschen...@gmail.com:
 I use RODBC as my conduit from R to SQL. It works well when the tables are
 stored on one channel, e.g.,

 channel - odbcConnect(data_base_01, uid=, dsn=)

 However, I often need to match tables across multiple databases, e.g.,
 data_base_01 and data_base_02. However, odbcConnect() appears limited
 insofar as you may only query from tables within a single channel, e.g.,
 database. I do not have access to write and create new tables on the SQL
 servers, which is a possible solution (e.g., copy all tables into a single
 database).

 Is there any way, in RODBC or another R-friendly SQL package, to perform SQL
 operations across multiple databases?

 Warm regards.

 --
 Tom Schenk Jr.
 tomschen...@gmail.com

        [[alternative HTML version deleted]]

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





-- 
Dr. Mark Wardle
Specialist registrar, Neurology
Cardiff, UK

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


Re: [R] R graph into MS Word: which format to use?

2009-04-20 Thread Mark Wardle
They may stipulate word files for the manuscript, but during
submission, journals usually request EPS or PDF formats. In fact, all
I've dealt with stipulate NEVER include graphcis into a Word document.

May be worth checking again!

Mark

2009/4/20 jjh21 jjhar...@gmail.com:

 Hello,

 The journal I am publishing in requires MS Word files. What is my best
 option for getting a high quality image of a graph done in R into Word?
 JPEG? Postscript?

 Thanks.
 --
 View this message in context: 
 http://www.nabble.com/R-graph-into-MS-Word%3A-which-format-to-use--tp23133745p23133745.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.





-- 
Dr. Mark Wardle
Specialist registrar, Neurology
Cardiff, UK

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


Re: [R] Faced Problems with RODBC package 1.2-5 and 1.2-4 for windows

2009-01-28 Thread Mark Wardle
You need to include much more information.

Try creating a reproducible example - you may find the answer in the
process of doing this.

You may find the posting guide for the mailing list to be helpful -
you've had no replies because you haven't explained your problem well
enough.

Mark

2009/1/28 Nikhil Bhide nikhil.bh...@tcs.com:
 Hi,

I am facing problems with RODBC package 1.2-5 and 1.2-4  built for
 windows. I am using R  2.8.1 version.
I faced some problems when I was trying to execute sql procedure
 from R  with exec/execute statement .

Stored procedure contains code/statements :
1) Call to another procedure (R calls one procedure which itself
 calls another procedure)
2) Iteration (while loop)
   I created stored procedure in which I used while loop
 and while loop contains two insert statements.I executed procedure from R.
 I found that expected results are not matching with the   results I got.
 Also results are not consistent.
3) SET QUOTED_IDENTIFIER OFF statement

 Please give me a solution

 regards,
 Nikhil Ashok Bhide
 Cell:- +919604848030
 Mailto: nikhil.bh...@tcs.com
 Website: http://www.tcs.com
 
 Experience certainty.   IT Services
Business Solutions
Outsourcing
 
 ForwardSourceID:NT1B0E
 =-=-=
 Notice: The information contained in this e-mail
 message and/or attachments to it may contain
 confidential or privileged information. If you are
 not the intended recipient, any dissemination, use,
 review, distribution, printing or copying of the
 information contained in this e-mail message
 and/or attachments to it are strictly prohibited. If
 you have received this communication in error,
 please notify us by reply e-mail or telephone and
 immediately and permanently delete the message
 and any attachments. Thank you



[[alternative HTML version deleted]]

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


 __
 This email has been scanned by the MessageLabs Email Security System.
 For more information please visit http://www.messagelabs.com/email
 __




-- 
Dr. Mark Wardle
Specialist registrar, Neurology
Cardiff, UK

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


Re: [R] OT: Adding verbatim R code text into LaTeX documents: texttt; verb or url?

2009-01-27 Thread Mark Wardle
2009/1/28 Peter Dunn pdu...@usc.edu.au:
 Hi all

 I use Sweave extensively to mix R and LaTeX, and often have R code appearing 
 in my LaTeX document.

 Just a quick question then: What is the best way to add example of R commands 
 into LaTeX in-line?  (That is, not using Sweave.)  For example, suppose I 
 wish to place in my document this instruction:
 [...] *snip*

Try this:

\usepackage{listings}

\lstset{%
basicstyle=\scriptsize,
breaklines=true,
frame=single,
literate=
{-}{$\leftarrow$}{2}
}

\renewcommand\lstlistlistingname{List of listings}


Have a look at the listings package... You can see I'm making the font
size smaller, giving all code a frame, and converting - into a proper
left arrow (just for R!)

listings is very capable.

http://www.ctan.org/tex-archive/macros/latex/contrib/listings/
http://www.ctan.org/get/macros/latex/contrib/listings/listings.pdf

bw

Mark
-- 
Dr. Mark Wardle
Specialist registrar, Neurology
Cardiff, UK

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


Re: [R] using Sweave with a master file that has several iputted .tex files

2009-01-27 Thread Mark Wardle
The benefit of Makefiles is that one is essentially breaking up one
project into many smaller projects. My thesis has seven or so real
chapters. To build it all takes a few minutes on this laptop - not
intolerable but frustrating if one has to do it repeatedly. Using make
means a build for a single chapter is cached unless the source file
changes and so one can see the results of changes to one source file
almost immediately.

bw

Mark

2009/1/28 Christopher W. Ryan cr...@binghamton.edu:
 That's pretty slick! Thanks.

 It did not like absolute paths (unless I had spelled them out
 improperly.) It wanted just

 \SweaveInput{PreliminaryStudies}

 not

 \SweaveInput{C:/DATA/SCHOLAR/ADHDConstipation/SonographicStudy/PAR06180/PreliminaryStudies}

 And I tripped over the upper-case I at first.

 --Chris
 Christopher W. Ryan, MD
 SUNY Upstate Medical University Clinical Campus at Binghamton
 40 Arch Street, Johnson City, NY  13790
 cryanatbinghamtondotedu
 PGP public keys available at http://home.stny.rr.com/ryancw/

 If you want to build a ship, don't drum up the men to gather wood,
 divide the work and give orders. Instead, teach them to yearn for the
 vast and endless sea.  [Antoine de St. Exupery]

 Renaud Lancelot wrote:
 What about \Sweaveinput ?

 \begin{document}
 This command allows the inclusion of Sweave files:
 \SweaveInput{file1.Rnw}
 \SweaveInput{file2.Rnw}
 \end{document}

 Ffor those who can read French, this example is adapted from
 http://forums.cirad.fr/logiciel-R/viewtopic.php?t=1554 .

 Renaud


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


 __
 This email has been scanned by the MessageLabs Email Security System.
 For more information please visit http://www.messagelabs.com/email
 __




-- 
Dr. Mark Wardle
Specialist registrar, Neurology
Cardiff, UK

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


Re: [R] Avoiding multiple outputs using RODBC package

2008-12-14 Thread Mark Wardle
Hi.

You don't need to download the whole of the output database table to
look for an already generated answer. You can write a SQL query to do
that instead. ie. give me any rows with these parameters...  Get the
database to do the work - it is what they are designed to do.

So the procedure is:

1. Get input parameters
2. Query the output database to see whether analysis has already been
done (select * from output_table where...)
3. If not already done, do the calculation and insert result into output table

Note: you don't have to use sqlSave to save data. One can add single
rows by running arbitrary SQL.

Mark

2008/12/12 Brigid Mooney bkmoo...@gmail.com:
 I am using R as a data manipulation tool for a SQL database.  So in some of
 my R scripts I use the RODBC package to retreive data, then run analysis,
 and use the sqlSave function in the RODBC package to store the results in a
 database.

 There are two problems I want to avoid, and they are highly related: (1)
 having R rerun analysis which has already been done and saved into output
 database table, and (2) ending up with more than one identical row in
 my output database table.

 -
 The analysis I am running allows the user to input a large number of
 variables, for example:
 date, version, a, b, c, d, e, f, g, ...

 After R completes its analysis, I write the results to a database table in
 the format:
 Value, date, version, a, b, c, d, e, f, g, ...

 where Value is the result of the R analysis, and the rest of the columns are
 the criteria that was used to get that value.
 --

 Can anyone think of a way to address these problems?  The only thing I can
 think of so far is to run an sqlQuery to get a table of all the variable
 combinations that are saved at the start, and then simply avoid computing
 and re-outputing those results.  However, my results database table
 currently has over 200K rows (and will grow very quickly as I keep going
 with this project), so I think that would not be the most expeditious answer
 as I think just the SQL query to download 200K rows x 10+ columns is going
 to be time consuming in and of itself.

 I know this is kindof a weird problem, and am open to all sorts of ideas...

 Thanks!

[[alternative HTML version deleted]]

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


 __
 This email has been scanned by the MessageLabs Email Security System.
 For more information please visit http://www.messagelabs.com/email
 __




-- 
Dr. Mark Wardle
Specialist registrar, Neurology
Cardiff, UK

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


Re: [R] merge two data sets

2008-06-04 Thread Mark Wardle
Please see ?merge

In particular, see all.x parameter.

Mark

2008/6/4 kayj [EMAIL PROTECTED]:

 I would like to merge data1 that contains 100 unique ID's with  another
 data set data 2 with 150 ID's and the age of those individuals ( the ID in
 data1 is a subset of the ID in data 2) I  would like to merge these data1
 with data2 and have the result of the merge to have the ID ordered as in
 data1.

 Can this be done in R?


 --
 View this message in context: 
 http://www.nabble.com/merge-two-data-sets-tp17636278p17636278.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.

 __
 This email has been scanned by the MessageLabs Email Security System.
 For more information please visit http://www.messagelabs.com/email
 __




-- 
Dr. Mark Wardle
Specialist registrar, Neurology
Cardiff, UK

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


Re: [R] Sweave / Latex per-chapter output

2008-05-22 Thread Mark Wardle
 for proper display; also I would
 loose the latex-y beauty of my PDF

 As I'm a novice in Latex and Makefiles usage, I'd be glad if you could
 tell me if what I want to do is feasible (I'm sure it is), and which
 would be the best, fussless method to do it (i.e. generate both types
 of output without changing the R/Sweave code).

 I know you'll probably tell me to break my long Sweave code into
 smaller parts, but as I briefly said above, I do some variable setting
 and table querying at the start - things I will repeatedly need in
 later chapters (e.g. I query a population table for computing
 incidence rates several times in later chapters). If there is a better
 way to split the code without having to requery the database at each
 chapter, I'll be glad to know about that too!

 BTW, I'm working on Ubuntu Linux.

 Thanks a lot for your insight,

 Anne-Marie

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


 __
 This email has been scanned by the MessageLabs Email Security System.
 For more information please visit http://www.messagelabs.com/email
 __




-- 
Dr. Mark Wardle
Specialist registrar, Neurology
Cardiff, UK

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


[R] Lattice book

2008-04-30 Thread Mark Wardle
Dear all,

I haven't seen this mentioned and presumably Dr. Deepayan Sarkar is
too polite to advertise!

I just received a flyer from Springer: A new book on Lattice released today!!

http://www.springer.com/statistics/computational/book/978-0-387-75968-5?cm_mmc=NBA-_-Apr-08_UK_1753460-_-product-_-978-0-387-75968-5

http://www.amazon.co.uk/exec/obidos/ASIN/0387759689/ref=ord_cart_shr?%5Fencoding=UTF8m=A3P5ROKL5A1OLE

Well done and many congratulations. My order is being processed as we speak!

Best wishes,

Mark
-- 
Dr. Mark Wardle
Specialist registrar, Neurology
Cardiff, UK

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


Re: [R] how to write a table to pdf

2008-04-15 Thread Mark Wardle
I would look at Sweave, particularly outputting to LaTeX. Then have a
look at the xtable or Hmisc's latex() functions.

I believe one can write to OpenOffice file formats too which may be an
alternative solution.

Best wishes,

Mark

On 14/04/2008, Ng Stanley [EMAIL PROTECTED] wrote:
 Hi,

  Is there a way to write a table to pdf ? I have checked write.table, it only
  writes to text file.

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


  __
  This email has been scanned by the MessageLabs Email Security System.
  For more information please visit http://www.messagelabs.com/email
  __



-- 
Dr. Mark Wardle
Specialist registrar, Neurology
Cardiff, UK

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


Re: [R] How to include files in .R?

2008-04-04 Thread Mark Wardle
?source

bw

Mark

On 04/04/2008, Jonas Stein [EMAIL PROTECTED] wrote:
 Hi,

  may be its a very simple question, but i did not find any documentation
  about a 'include' command or something like this.

  I have to set many constants in my R-files and want to move all these to
  one file, so that i can reuse it in all other R-files.

  Something like

  include(~/R/myconstants.R)

  kind regards,

  --
  Jonas Stein [EMAIL PROTECTED]

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


  __
  This email has been scanned by the MessageLabs Email Security System.
  For more information please visit http://www.messagelabs.com/email
  __



-- 
Dr. Mark Wardle
Specialist registrar, Neurology
Cardiff, UK

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


Re: [R] Multiple plots question

2008-03-21 Thread Mark Wardle
1. Work out what you want on the x and y scales from your data.
2. In your first call (to plot) set the xlim and ylim parameters to
the required range.

Good luck,

Mark


On 20/03/2008, Andre Nathan [EMAIL PROTECTED] wrote:
 Hello

  (Sorry if this appears twice, had some mail problems...)

  I have a number of different data sets, each loaded as a matrix. I'd
  like to plot them in a way that the data in the first column of each
  matrix is plotted on the same pair of axes.

  What I'm doing now is to call plot() for the data on the first matrix,
  then call points() for the other ones. However, the axes are set by R
  according to the data passed to plot(), and sometimes the data passed to
  points() has larger values on the x axis, and the plot ends up being
  cut (the y axis is not a problem since they're all probabilities).

  Is there a way to dynamically adapt the axes so that all data can be
  seen? I know I could build a new matrix with the columns I want to plot
  but each matrix has 1 million rows, so I figure this would be
  inefficient.

  Do I have to check beforehand which column has the largest value and
  call plot() on it, and then points() on the others, or is there an
  automatic way to do this?

  Thanks in advance,
  Andre

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


  __
  This email has been scanned by the MessageLabs Email Security System.
  For more information please visit http://www.messagelabs.com/email
  __



-- 
Dr. Mark Wardle
Specialist registrar, Neurology
Cardiff, UK

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


Re: [R] factanal and plotting?

2008-03-17 Thread Mark Wardle
Dear Martin,

The plot you refer to is a scree plot.

One option (there are many) is to have a look at the nFactors package.
Despite its package description, it includes the function plotnScree.

You will find it helpful to search google for scree plot R and/or
use rseek.org as there are many possibilities.

Good luck.

Best wishes,

Mark


On 13/03/2008, Martin Kaffanke [EMAIL PROTECTED] wrote:
 Hi there!

  To make a good choice for the estimation of the number of usefull
  factors.  And I'd like to plot a graph like:

  http://de.wikipedia.org/wiki/Bild:Parallelanalyse.jpg

  where I don't need the green line (random values).

  But with

  str(factanal(data, factors=10)) I cannot figure out where I can find the
  values for plotting.

  Can you please help me in this question?

  Thanks,
  Martin

  --
  Ihr Partner für Webdesign, Webapplikationen und Webspace.
  http://www.roomandspace.com/
  Martin Kaffanke +43 650 4514224

  __
  This email has been scanned by the MessageLabs Email Security System.
  For more information please visit http://www.messagelabs.com/email
  __
 __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.





-- 
Dr. Mark Wardle
Specialist registrar, Neurology
Cardiff, UK

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


Re: [R] help

2008-03-09 Thread Mark Wardle
I don't really understand your question, but try this:

http://www.econ.uiuc.edu/~roger/research/links/Rnews.pdf

http://cran.r-project.org/web/packages/VGAM/NEWS

Try typing cauchit into rseek.org

In addition, follow the references in the help page in VGAM cauchit help page.

Best wishes,

Mark

On 09/03/2008, kike díaz peñaloza [EMAIL PROTECTED] wrote:
  Hello,

  nowadays I am employed at my thesis with the link cauchit, nevertheless I
  have not found theory it brings over of this one, if someone could help one
  would be grateful for it very much.
  You forgive for my English, I am from Chile.

  Regards

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


  __
  This email has been scanned by the MessageLabs Email Security System.
  For more information please visit http://www.messagelabs.com/email
  __



-- 
Dr. Mark Wardle
Specialist registrar, Neurology
Cardiff, UK

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


Re: [R] data frame question

2008-02-10 Thread Mark Wardle
On 10/02/2008, joseph [EMAIL PROTECTED] wrote:
 Hello
 I have 2 data frames df1 and df2. I would like to create a
 new data frame new_df which will contain only the common rows based on the 
 first 2
 columns (chrN and start). The column score in the new data frame
 should
 be replaced with a column containing the average score (average_score) from 
 df1
 and df2.


Try this:   (avoiding underscores)

new.df - merge(df1, df2, by=c('chrN','start'))
new.df$average.score - apply(df3[,c('score.x','score.y')], 1, mean, na.rm=T)

As always, interested to see whether it can be done in one line...

-- 
Dr. Mark Wardle
Specialist registrar, Neurology
Cardiff, UK

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


Re: [R] is it safe to replace every - by = in R code?

2008-01-14 Thread Mark Wardle
Thank you (all) for the helpful explanations! My own R code tends to
simpler constructs, but now perhaps we can start having obfuscated
code competitions: something common in Perl, but I have not seen in R
(yet). Anyone up for the challenge?

Best wishes,

Mark


-- 
Dr. Mark Wardle
Specialist registrar, Neurology
Cardiff, UK

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


Re: [R] is it safe to replace every - by = in R code?

2008-01-13 Thread Mark Wardle
On 14/01/2008, Gabor Grothendieck [EMAIL PROTECTED] wrote:
 Its not related to scoping. f(b = 10) passes 10 as argument b
 but f(b - 10) assigns to variable b (which has nothing to do with
 argument b) and then passes the result of the b-10 expression (which is
 10) to f.  Since no argument was specified it uses positional
 matching and the first position is argument a.  Thus its the same
 as f(10).  Note that f(b-10) isthe same as f( (b - 10) ) which may
 make it clearer.

Of course! Straightforward!

Many thanks,

Mark

-- 
Dr. Mark Wardle
Specialist registrar, Neurology
Cardiff, UK

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


Re: [R] run setwd at the launch of R

2008-01-06 Thread Mark Wardle
It may be disgusting, but I'm not how you expect R to know where to startup.

On my Mac, I keep all my scripts in a per-project working directory.

I therefore type

cd ~/Documents/ataxia

If you have multiple nested directories then why not create a
directory alias (soft-link) so it is easy to cd to? Or move the
relevant folders to a better place?

Alternatively, use the Mac OS X GUI, which has an option in
preferences about initial working directory.

Mark

On 06/01/2008, bunny , lautloscrew.com [EMAIL PROTECTED] wrote:
 Dear all,

 my R files (and the .csv files as well) are saved somewhere pretty
 deep down my hard disk.
 i have to chage to working directory therefore everytime i run R (i
 run it on powerPC mac), which is disgusting.
 using the setwd command at the beginning of an R script doesnt really
 help because i have to find this file first by hand.

 I am looking for possibility to run setwd during the launch process
 of R are straight after it ... any suggestions ?

 i would be very glad about good ideas or help !

 thanks in advance

 matthias

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


 __
 This email has been scanned by the MessageLabs Email Security System.
 For more information please visit http://www.messagelabs.com/email
 __



-- 
Dr. Mark Wardle
Specialist registrar, Neurology
Cardiff, UK

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


Re: [R] modify a data.frame within a function

2007-12-15 Thread Mark Wardle
You need to read about scope.

Try using return() from within your function to return the modified
data frame to the caller.

Best wishes,

Mark

On 15/12/2007, Yuval Sapir [EMAIL PROTECTED] wrote:
  Hello all,
 I'm trying to modify a single column of a data frame to remove randomly half 
 of the values. I want to do it within a function, but can not assign the 
 modified column back into the data frame. It was easy and successful without 
 a function, so I suspect the problem is the call of the single column within 
 the function.

 removedata-function(datafull,var.removed)
 {
 attach(datafull)
 NArandom-rnorm(n=length(var.removed), mean=0, sd=1)
 for (i in 1:length(var.removed))
   if(NArandom[i]0)
 var.removed[i]-NA
 datamiss-datafull
 detach(datafull)
 }

 -- Yuval Sapir, PhDResearcherInstitute of Evolution, Haifa UniversityHaifa, 
 Israel 3190‎

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


 __
 This email has been scanned by the MessageLabs Email Security System.
 For more information please visit http://www.messagelabs.com/email
 __



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


Re: [R] Getting estimates from survfit.coxph

2007-12-10 Thread Mark Wardle
Can't ask for more than that!

Many many thanks for making all these tools available. I wince when I
see my colleagues struggling with SPSS or SAS! R and the bundled and
third-party libraries have saved me an inordinate amount of time and
effort!

Best wishes,

Mark

On 10/12/2007, Terry Therneau [EMAIL PROTECTED] wrote:
   The problem will be fixed in the next resease of the survival code.  (That 
 is,
 it is fixed on our local version of R).  The summary.survfit result now 
 includes
 an element 'table' containing the matrix that is shown by print.survfit.

 Terry



 __
 This email has been scanned by the MessageLabs Email Security System.
 For more information please visit http://www.messagelabs.com/email
 __



-- 
Dr. Mark Wardle
Specialist registrar, Neurology
Cardiff, UK

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


[R] Getting estimates from survfit.coxph

2007-12-09 Thread Mark Wardle
Dear all,

I'm having difficulty getting access to data generated by survfit and
print.survfit when they are using with a Cox model (survfit.coxph).

I would like to programmatically access the median survival time for
each strata together with the 95% confidence interval. I can get it on
screen, but can't get to it algorithmically. I found myself examining
the source of print.survfit to try to work out how it is done
internally, but is there a better way?

An example (and I realise that estimating survival curses from an
average status and time is incorrect in this instance, but it keeps
this example simple):

test1 - list(time=  c(4, 3,1,1,2,2,3),
status=c(1,NA,1,0,1,1,0),
x= c(0, 2,1,1,1,0,0),
sex=   c(0, 0,0,0,1,1,1))
c1 - coxph( Surv(time, status) ~ x + strata(sex), test1)  #stratified model

f1 - survfit(c1)
sf1 - summary(f1)
str(f1)
print(f1)
print(sf1)
str(sf1)

I'm sure I am missing something obvious. Apologies - but any help
greatfully received!

Best wishes,

Mark

P.S. I can get to diferrent estimates for median survival for
different groups using simpler mechanisms, but they yield different
estimates: From my data, so no reproducible (and ataxSurv() is a
wrapper function that calls plain Surv() after manipulating the data
simply):


# For an average patient: (doesn't make any sense biologically)
 survfit(surv.results$cox)
Call: survfit.coxph(object = surv.results$cox)

  n  events  median 0.95LCL 0.95UCL
136  96   6   6   8

#
# predict a curve for a patient: (these are the answers I really want
to extract)
#
 survfit(surv.results$cox, newdata=data.frame(onset=50, ic.duration=10, 
 simple.msa=c('MSA','Not MSA'), autoimmune=F, carcinoma=F))
Call: survfit.coxph(object = surv.results$cox, newdata = data.frame(onset = 50,
ic.duration = 10, simple.msa = c(MSA, Not MSA), autoimmune = F,
carcinoma = F))

   n events median 0.95LCL 0.95UCL
[1,] 136 96  8   7  11
[2,] 136 96  3   2   6

#
# without using Cox regression:
#
 survfit(ataxSurv(surv.support, surv.follow.up, surv.results$data) ~ 
 simple.msa, data=surv.results$data)
Call: survfit(formula = ataxSurv(surv.support, surv.follow.up,
surv.results$data) ~
simple.msa, data = surv.results$data)

   1 observation deleted due to missingness
 n events median 0.95LCL 0.95UCL
simple.msa=Not MSA 120 80  8   6  11
simple.msa=MSA  19 17  2   1   4


-- 
Dr. Mark Wardle
Specialist registrar, Neurology
Cardiff, UK

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


Re: [R] Getting estimates from survfit.coxph

2007-12-09 Thread Mark Wardle
On 09/12/2007, Frank E Harrell Jr [EMAIL PROTECTED] wrote:
 Dieter Menne wrote:
 

Thank you both!

Best wishes,

Mark

-- 
Dr. Mark Wardle
Specialist registrar, Neurology
Cardiff, UK

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


Re: [R] Export in pdf, png, jpg, eps, etc...

2007-11-27 Thread Mark Wardle
I don't have any problems with this:

I generate PDFs directly. All other formats I post-process using
command line tools to automatically batch convert (using ImageMagick).

Best wishes,

Mark

On 27/11/2007, Sébastien [EMAIL PROTECTED] wrote:
 Dear R-users,

 I have created a bunch of R scripts that automatically create multiple
 plots, all saved in a pdf device. I initially chose pdf output in order
 to easily access to multiple plots in a single file.
 Now, I am trying to play with different devices, like png or eps and I
 realize that the settings I used to have nice plots in a pdf device are
 giving awful outputs with the other devices... Playing with the
 resolution, for instance, impacts directly on the width of lines and
 sympbols, making them almost invisible at high resolution.
 Optimizing all these settings for every devices might be very tidious
 for me, given the number and the length of my scripts. Is there any easy
 way to keep the aspect of my plots the same way using different devices ?

 Thanks you in advance for your feedback.

 Sebastien

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


 __
 This email has been scanned by the MessageLabs Email Security System.
 For more information please visit http://www.messagelabs.com/email
 __



-- 
Dr. Mark Wardle
Specialist registrar, Neurology
Cardiff, UK

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


Re: [R] question about multiple comparison in ANOVA

2007-11-21 Thread Mark Wardle
Hello.

I'm replying because you haven't had a reply. You haven't said which
system you are running or which version of different packages you have
installed.

On my system (see below for the results from running sessionInfo())
that code runs fine with no errors at all.

library(multcomp)
#  Loading required package: mvtnorm
amod - aov(minutes ~ blanket, data=recovery)
rht - glht(amod, linfct = mcp(blanket = Dunnett),
  alternative = less)
rht


produces:


General Linear Hypotheses

Multiple Comparisons of Means: Dunnett Contrasts


Linear Hypotheses:
 Estimate
b1 - b0 = 0   -2.133
b2 - b0 = 0   -7.467
b3 - b0 = 0   -1.667



On 21/11/2007, Qiu Anqi [EMAIL PROTECTED] wrote:
 I am not sure whether there is a bug. When I tested the example given
 for glht in the help, I entered the following error:



 Running commands:

 amod - aov(minutes ~ blanket, data = recovery)
 rht - glht(amod, linfct = mcp(blanket = Dunnett),
   alternative = less)


 Errors are:

 Error in try(coef.(model)) : could not find function coef.

 Error in modelparm.default(model, ...) : no 'coef' method for 'model'
 found!


This all sounds a bit odd, and (although I am not an R expert by any
means) therefore wonder whether you have an installation problem of
some form?

my sessionInfo():

R version 2.6.0 (2007-10-03)
i386-apple-darwin8.10.1

locale:
en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8

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

other attached packages:
[1] multcomp_0.992-6 mvtnorm_0.8-1lattice_0.16-5   RODBC_1.2-2

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


-- 
Dr. Mark Wardle
Specialist registrar, Neurology
Cardiff, UK

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


Re: [R] Query an Access database based on a date attribute

2007-11-13 Thread Mark Wardle
On 12/11/2007, Tudor Bodea [EMAIL PROTECTED] wrote:
 Dear useRs,

 I would like to query an Access database through R based on a date attribute
 but, unfortunately, I fail to do so. For example, the table test_table of the
 test.mdb looks like:

ID cd  market competitor dd price
 1   1 2007-11-20 atl-bos  delta 2007-11-20   210
 2   2 2007-11-20 atl-bos  delta 2007-11-21   190
 3   3 2007-11-20 atl-bos  delta 2007-11-22   180
 4   4 2007-11-20 atl-bos united 2007-11-20   205
 5   5 2007-11-20 atl-bos united 2007-11-21   195
 6   6 2007-11-20 atl-bos united 2007-11-22   175
 7   7 2007-11-20 atl-sfa  delta 2007-11-20   350
 8   8 2007-11-20 atl-sfa  delta 2007-11-21   320
 9   9 2007-11-20 atl-sfa  delta 2007-11-22   300
 10 10 2007-11-20 atl-sfa aa 2007-11-20   340
 11 11 2007-11-20 atl-sfa aa 2007-11-21   320
 12 12 2007-11-20 atl-sfa aa 2007-11-22   300

 In this context, I try to get all the records for which market is atl-bos,
 competitor is delta and dd is 2007-11-20 (first record above). To do this I 
 used

 # channel - odbcConnectAccess(test.mdb)
 res - sqlQuery(channel, select * from test_table where market = 'atl-bos'
 and competitor = 'delta' and dd = 2007-11-20)

 but the result seems to be incorrect.


Dear Tudor,

Try running your query in Microsoft Access/Query first. Once it works,
then move to R/RODBC...

I don't use MS Access routinely in this way, but presumably there is a
problem with your SQL.

Best wishes,

Mark
-- 
Dr. Mark Wardle
Specialist registrar, Neurology
Cardiff, UK

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


[R] Fwd: Produce a multiple formats graphic

2007-11-06 Thread Mark Wardle
-- Forwarded message --
From: Mark Wardle [EMAIL PROTECTED]
Date: 6 Nov 2007 16:01
Subject: Re: [R] Produce a multiple formats graphic
To: Cuvelier Etienne [EMAIL PROTECTED]


You have several options:

1. Write a function that creates your plot, and call that function
repeatedly manually.
2. Write a wrapper function that takes the name of a function, and an
output filename, and calls that function repeatedly after creating
different graphics devices.
3. Create as PDF, and use something else (like ImageMagick) to convert
to different formats.

I tend to do option 3 as it is the most flexible.

Best wishes,

Mark

On 06/11/2007, Cuvelier Etienne [EMAIL PROTECTED] wrote:
 Is it possible to produce the same graphic in different formats
 in one shot?
 Now if I want to produce the same graphic in pdf, ps and jpeg
 I run the producing code, but I change the graphic device, and
 I choose successively :
 pdf(...)
 ps(...)
 jpeg(...)

 So in this case I run the same code 3 times, or I have
 to choose a format and use converters...

 Is it possible to produce the 3 graphics in once ?


 Thank you very much

 --
 ===
 Cuvelier Etienne
 Assistant
 FUNDP - Institut d'Informatique
 rue Grandgagnage, 21   B-5000 Namur (Belgique)
 tel: 32.81.72.49.93fax: 32.81.72.49.67
 ===
 Top 10 reasons to become a Statistician

   1. Deviation is considered normal
   2. We feel complete and sufficient
   3. We are 'mean' lovers
   4. Statisticians do it discretely and
  continuously
   5. We are right 95% of the time
   6. We can legally comment on someone's
  posterior distribution
   7. We may not be normal, but we are
  transformable
   8. We never have to say we are certain
   9. We are honestly significantly different
  10. No one wants our jobs

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


 __
 This email has been scanned by the MessageLabs Email Security System.
 For more information please visit http://www.messagelabs.com/email
 __



--
Dr. Mark Wardle
Specialist registrar, Neurology
Cardiff, UK


-- 
Dr. Mark Wardle
Specialist registrar, Neurology
Cardiff, UK

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


Re: [R] Package Installer Fails in OSX 10.5 Leopard

2007-10-27 Thread Mark Wardle
least=list.

it is late (here)!

On 28/10/2007, Mark Wardle [EMAIL PROTECTED] wrote:
 Hi.

 Sorry to hear you are having problems. I'm not installing Leopard just
 yet, as I cannot live without a working system running R, PostgreSQL,
 Filemaker, and Adobe applications. At least two on that least are said
 to have problems with Leopard!

 If no-one else replies, try the Mac R help list. I can't see any
 mention in the archives on a brief search of September's and October's
 archives.

 See https://stat.ethz.ch/mailman/listinfo/r-sig-mac


 Best wishes,

 Mark

 On 27/10/2007, Don Kalar [EMAIL PROTECTED] wrote:
  Hello all,
  I apologize in advance if this is not the correct list to post these sorts
  of issues. When attempting to install the latest stable build of R (2.6) or
  the most recent nightly build from R.research.att.com, the installer
  disables the ability to actually install R or any of the other bundled
  frameworks (i.e. the list is unchecked and grayed out). Before I start
  trying to either coerce the package definitions or build from source, I was
  wondering if there's any recommended way to get R running on Leopard. I've
  searched the lists and online, but as of yet have found no posted solution.
 
 
  cheers,
  -d
 
  ==
  Donald Kalar, M.A.
  Graduate Student,
  Cognitive Neuroscience
  UCLA Department of Psychology
  1285 Franz  Hall, Box 951563
  Los Angeles, CA
  90095-1563
  ==
 
  [[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.
 
 
  __
  This email has been scanned by the MessageLabs Email Security System.
  For more information please visit http://www.messagelabs.com/email
  __
 


 --
 Dr. Mark Wardle
 Specialist registrar, Neurology
 Cardiff, UK



-- 
Dr. Mark Wardle
Specialist registrar, Neurology
Cardiff, UK

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


Re: [R] Package Installer Fails in OSX 10.5 Leopard

2007-10-27 Thread Mark Wardle
Hi.

Sorry to hear you are having problems. I'm not installing Leopard just
yet, as I cannot live without a working system running R, PostgreSQL,
Filemaker, and Adobe applications. At least two on that least are said
to have problems with Leopard!

If no-one else replies, try the Mac R help list. I can't see any
mention in the archives on a brief search of September's and October's
archives.

See https://stat.ethz.ch/mailman/listinfo/r-sig-mac


Best wishes,

Mark

On 27/10/2007, Don Kalar [EMAIL PROTECTED] wrote:
 Hello all,
 I apologize in advance if this is not the correct list to post these sorts
 of issues. When attempting to install the latest stable build of R (2.6) or
 the most recent nightly build from R.research.att.com, the installer
 disables the ability to actually install R or any of the other bundled
 frameworks (i.e. the list is unchecked and grayed out). Before I start
 trying to either coerce the package definitions or build from source, I was
 wondering if there's any recommended way to get R running on Leopard. I've
 searched the lists and online, but as of yet have found no posted solution.


 cheers,
 -d

 ==
 Donald Kalar, M.A.
 Graduate Student,
 Cognitive Neuroscience
 UCLA Department of Psychology
 1285 Franz  Hall, Box 951563
 Los Angeles, CA
 90095-1563
 ==

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


 __
 This email has been scanned by the MessageLabs Email Security System.
 For more information please visit http://www.messagelabs.com/email
 __



-- 
Dr. Mark Wardle
Specialist registrar, Neurology
Cardiff, UK

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


Re: [R] Error in if loop

2007-10-21 Thread Mark Wardle
On 21/10/2007, stat stat [EMAIL PROTECTED] wrote:
 I have created a if loop as follows:

 name = e
 if (name == v)
   {
u = 0
 }
 else u = 1

 however i am getting error : Error: unexpected 'else' in else

There are 3 issues here:

1. Do you appreciate the difference between ifelse and if ? What are
you actually trying to do - in this context, ifelse would usually be
more sensible but as you've not said what you want to do, it is
difficult to guess.
2. I don't get the same error as you. Which version of R are you using?

 if (name==v)
+ {
+ u=0
+ }
 else u=1
Error: syntax error

This error message makes it clear that there is a syntax problem. In
fact, look at the lefthand column of characters and you should see
what the problem is

3. R is interpreting your code as two separate expressions because you
are using an interactive shell. Try this instead:

if (name=='v') {
u=1
} else {
u=0
}

Hope this helps.

Best wishes,

Mark

-- 
Dr. Mark Wardle
Specialist registrar, Neurology
Cardiff, UK

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


Re: [R] Error in if loop

2007-10-21 Thread Mark Wardle
No.

Think of if only as a means to control program flow.
Use ifelse to use conditional logic on each item of a vector

Best wishes,

Mark


On 21/10/2007, stat stat [EMAIL PROTECTED] wrote:
 Dear Mark,

 Thanks for this. Can you please explain me what is the difference between
 ifelse and if?
 generally if there is more than one syntax within the 'if' I use 'if' loop
 otherwise I use 'ifelse' loop. Is it the only difference between them?


 Mark Wardle [EMAIL PROTECTED] wrote:
  On 21/10/2007, stat stat wrote:
  I have created a if loop as follows:
 
  name = e
  if (name == v)
  {
  u = 0
  }
  else u = 1
 
  however i am getting error : Error: unexpected 'else' in else

 There are 3 issues here:

 1. Do you appreciate the difference between ifelse and if ? What are
 you actually trying to do - in this context, ifelse would usually be
 more sensible but as you've not said what you want to do, it is
 difficult to guess.
 2. I don't get the same error as you. Which version of R are you using?

  if (name==v)
 + {
 + u=0
 + }
  else u=1
 Error: syntax error

 This error message makes it clear that there is a syntax problem. In
 fact, look at the lefthand column of characters and you should see
 what the problem is

 3. R is interpreting your code as two separate expressions because you
 are using an interactive shell. Try this instead:

 if (name=='v') {
 u=1
 } else {
 u=0
 }

 Hope this helps.

 Best wishes,

 Mark

 --
 Dr. Mark Wardle
 Specialist registrar, Neurology
 Cardiff, UK



 thanks in advance

  
  Forgot the famous last words? Access your message archive online. Click
 here.
 __
  This email has been scanned by the MessageLabs Email Security System.
  For more information please visit
 http://www.messagelabs.com/email
 __



-- 
Dr. Mark Wardle
Specialist registrar, Neurology
Cardiff, UK

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


Re: [R] A read.table mystery (data for Filemaker Mac)

2007-10-13 Thread Mark Wardle
On 12/10/2007, Emmanuel Charpentier [EMAIL PROTECTED] wrote:
 Mark Wardle a écrit :
  1. Which version of Filemaker? NB: Framemaker is a different program
  (desktop publishing), so do be a little precise!

 Dunno. The file is named export.fm7 ; one might be tempted to infer
 Filemaker 7.

Probably: Filemaker 7 or later, as newer versions share the same file format.

 Framemaker is a typo

  2. If it is an ancient version, then I suggest exporting a block of
  columns at a time, and then using merge() in R to join it all back up

 Not an option : I do not make the export myself, and I do not have
 Filemaker on any machine I can lay my hands on...

So you can't ask the person doing the export to do this?

I have to say I have no problem exporting data from Filemaker 7 and
above - with no size limitations. Mind you, you may not believe me,
but one very good way of doing export is to export as HTML, and then
import into Excel.


  3. I store all my clinical data in Filemaker 8.5 on the Mac. It is
  great. There have been no significant data export or import issues.

 Except for date formats (DD/MM/ in lieu of -MM-DD), numeric
 values (comma as decimal mark) and character set (something looking like
 Latin-1 in lieu of utf8). Sigh ...

Weird. My numeric values aren't exported like that! I can get dates
converted easily?


  One problem (with this version - may be fixed in 9.0) is that
  Filemaker ODBC drivers are pretty dreadful and so I do not use ODBC to
  access the data held in a Filemaker database. However, Filemaker's
  client ODBC access works fine, and, in conjunction with some
  commercial ODBC drivers for PostgreSQL, export my data into
  postgresql, and then from there import data into R. It is fast and
  works very well, albeit in a rather convoluted fashion!

 That would be a (good !) option if both the data producer and me had
 access to a common database server. It turns out not to be the case
 (alas...).

 As a general comment, I fpound the combination of a DBMS (Postgres in my
 case), an ODBC-able front end (OOo base, MS-Access, Filemaker : pîck
 ypouir poison...) and R a very good working setup. I use it every time I
 can. However, in this case, that's pipedream...


If you wish, I would be happy to look at your FP7 file and see what
the problem is.

Best wishes,

Mark

-- 
Dr. Mark Wardle
Specialist registrar, Neurology
Cardiff, UK

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


Re: [R] confusion with R syntax

2007-10-11 Thread Mark Wardle
On 11/10/2007, Leeds, Mark (IED) [EMAIL PROTECTED] wrote:
 I just noticed something by accident with R syntax that I'm sure is
 correct but I don't understand it. If I have
 a simple numeric vector x and I subscript it, it seems that I can then
 subscript a second time with TRUE
 or FALSE, sort of like a 2 dimensional array in C. Does someone know if
 this is documented somewhere
 Because it's neat but I never knew it existed. To me it seems like a 1
 dimensional vector should
 have only one dimensional indexing ?

 x - seq(1,10)
  x
  [1]  1  2  3  4  5  6  7  8  9 10
  x[2:4][c(TRUE,FALSE,TRUE)]
 [1] 2 4

 But, it only works for TRUE or FALSE and not numbers so I think it's not
 really 2 dimensional indexing.

 x[1][2]

 [1] NA

 If someone could explain this mechanism or tell me what I should look
 for in the archives, it would
 be appreciated. Thanks.

I may be being naive, but it is much simply than you are trying to
make it. Aren't the two indexing operations run in sequence?

Therefore

x[2:4][c(TRUE,FALSE,TRUE)]

actually is interpreted in two steps. Try this:

x -  seq(1,10)
y - x[2:4]
z - y[c(TRUE, FALSE, TRUE)]

Indeed, while your code:

x[1][2]

doesn't work,

if you try
x[2:4][3]

then you get the third index of the vector created by 2:4

ie

y - x[2:4]
z - y[3]

Best wishes,

Mark

-- 
Dr. Mark Wardle
Specialist registrar, Neurology
Cardiff, UK

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


Re: [R] A read.table mystery (data for Framemaker Mac)

2007-10-11 Thread Mark Wardle
1. Which version of Filemaker? NB: Framemaker is a different program
(desktop publishing), so do be a little precise!
2. If it is an ancient version, then I suggest exporting a block of
columns at a time, and then using merge() in R to join it all back up
3. I store all my clinical data in Filemaker 8.5 on the Mac. It is
great. There have been no significant data export or import issues.
One problem (with this version - may be fixed in 9.0) is that
Filemaker ODBC drivers are pretty dreadful and so I do not use ODBC to
access the data held in a Filemaker database. However, Filemaker's
client ODBC access works fine, and, in conjunction with some
commercial ODBC drivers for PostgreSQL, export my data into
postgresql, and then from there import data into R. It is fast and
works very well, albeit in a rather convoluted fashion!

Best wishes,

Mark



On 12/10/2007, Emmanuel Charpentier [EMAIL PROTECTED] wrote:
 Gabor Grothendieck a écrit :
  On 10/11/07, Emmanuel Charpentier [EMAIL PROTECTED] wrote:
  I have to read some clinical data a file coming from Filemaker on
  Macintosh (Ugh ! But it could be worse and come from Excel...).
  Exporting via Excel is out of question since the file has 467 columns
  and 121 lines (+ headers), which is out of reach of Excel. So I received
  an mer files, which is what Filemaker exports as a text file.
 
  The limits for Excel are 1 million rows and 16,000 columns (based on
  Excel 2007 which is what I have).

 I don't. More important, the version of Framemaker used by my
 correspondent still uses old Excel limits (,o more than 256 columns).

  Read the last line on every message to r-help,

 I do ...

 Emmanuel Charpentier

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


 __
 This email has been scanned by the MessageLabs Email Security System.
 For more information please visit http://www.messagelabs.com/email
 __



-- 
Dr. Mark Wardle
Specialist registrar, Neurology
Cardiff, UK

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


Re: [R] Help with functions (iterations)

2007-09-30 Thread Mark Wardle
Dear Letticia,

Are you using R-help for your homework?

See your previous postings:


1. 15th September:

With a single R command complete the following:
create a vector calles seqvec that repeats the sequence 1, 3,6,
10,15,21.( I was trying to use c() but this does not work)
create a 5-row, 6-column matirx from seqvec wuth each row containg the
sequence from before
and complete the two task above in a single step.


2. 16th September

iven the following data for a data set called airquality. To identify
the nature of the objects from the data set airquality example Ozone
would it be best to use the command is. like
is.character(airquality$Ozone) ... I tried
attributes(airquality$Ozone) but it came up null. Would there be a
better way to identify these objects.

3. 27th September

Using a 3-level input factor alternative so that a function(below) can
compute both a two-sided and one-sided p-values. Making the two-sided
test the default. And produce output information about which
alternative was tested.

4. Today

Need to create a for loop that saves the estimate of pi from each 0f
100 separate iterations and store it in a numeric vector (of length
100). The for loop should be placed in a function that allows the user
to vary the sample size, the simulation size, the integration limits
and the input function. In addition construct a histogram of the
estimates and include a red vertical line at pi.

Mark

On 29/09/2007, Letticia Ramlal [EMAIL PROTECTED] wrote:
 Hello:
 I am a bit confused by this problem. Can anyone give me some advice on this I 
 would greatly appreciate it. Thank you for all your help.

 Need to create a for loop that saves the estimate of pi from each 0f 100 
 separate iterations and store it in a numeric vector (of length 100). The for 
 loop should be placed in a function that allows the user to vary the sample 
 size, the simulation size, the integration limits and the input function. In 
 addition construct a histogram of the estimates and include a red vertical 
 line at pi.

 ex1.fcn-function(x){
 h-4/(1+x^2)
 return(h)
 }
 n=1000
 a=0
 b=1
 my.rand.x=runif(n,min=a,max=b)
 pi.MC = ((b-a)/n)*sum(ex1.fcn(my.rand.x))


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


 __
 This email has been scanned by the MessageLabs Email Security System.
 For more information please visit http://www.messagelabs.com/email
 __



-- 
Dr. Mark Wardle
Specialist registrar, Neurology
Cardiff, UK

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


Re: [R] How to read stored functions

2007-09-25 Thread Mark Wardle
Jared:

I agree with your advice - I use source() too!

I think I work in a different way to many, and don't ever save
current workspace but use the interactive R environment cutting and
pasting code from documents held under version control.

As long as one is careful, I don't think there is any problem!

Best wishes,

Mark

On 25/09/2007, Jared O'Connell [EMAIL PROTECTED] wrote:
 ...and my R education (and embarassment) continues ;)

 On 9/25/07, Vladimir Eremeev [EMAIL PROTECTED] wrote:
 
 
  source'ing is a bad practice because this saves additional copies of
  functions and data in the local workspace.
 
  Wasting disk space is not a problem now since HDDs are cheap and function
  bodies are generally small.
 
  But, when you change any function body, you have to repeat that source()
  call in local workspace of every project using the functions.
 
 
  Jared O'Connell wrote:
  
   Having your functions in a text file, say functions.r and then
  calling:
  
  source(functions.r)
  
   is also an option.  This assumes you are in the same directory as 
   functions.r.  Perhaps take a look at ?setwd and ?getwd as well.
  
  
   On 9/25/07, Vladimir Eremeev [EMAIL PROTECTED] wrote:
  
   You can save your functions to a file with
   save(names,file=/path/to/func_lib.RData)
   and then attach(/path/to/func_lib.RData).
  
   Or, you can create a package and load it with library() or require()
  
   Mauricio Malfert wrote:
   
Hi I'm simulating missing data patterns and  I've started to get a
  lot
of
functions in the same .R file is it possible to store al these
   functions
in
a library like one does in C++ (i.e the .h file) and read the
  functions
from
the main .R file
/Mauricio
  
 
  --
  View this message in context:
  http://www.nabble.com/How-to-read-stored-functions-tf4513863.html#a12875031
  Sent from the R help mailing list archive at Nabble.com.
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 

 [[alternative HTML version deleted]]

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


 __
 This email has been scanned by the MessageLabs Email Security System.
 For more information please visit http://www.messagelabs.com/email
 __



-- 
Dr. Mark Wardle
Specialist registrar, Neurology
Cardiff, UK

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