[R] plot portion of a line

2007-01-16 Thread BBands
Dear HelpeRs,

Given:
x - rnorm(50)
y - rnorm(50)
plot(x,y)
abline(lm(x ~ y))

Is there a way to plot just a portion of the line? Say for values of x
 2.0 or x  -2.0 and x  4.0. (Still fitting all the points.)

Thank you,

jab
-- 
John Bollinger, CFA, CMT
www.BollingerBands.com

If you advance far enough, you arrive at the beginning.

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


Re: [R] R editor vs. Tinn-R

2007-01-12 Thread BBands
On 1/12/07, Martin Becker [EMAIL PROTECTED] wrote:
 Depending on which button you press in Tinn-R, the clipboard is used to
 transfer the commands to R, so sometimes you can't rely on the previous
 contents of the clipboard while using Tinn-R. If you use the
 (source)-versions of the buttons, the content of the clipboard should
 be preserved.

Something odd is going on. I can confirm that read.delim(clipboard)
works from R, but not from Tinn-R. What seems odd is that the contents
of the clipboard _are_ preserved after the Tinn-R send, so that a
subsequent paste or read.delim(clipboard) from R works correctly.
Perhaps Tinn-R restores the contents of the clipboard after sending to
R such that the R command runs before the restore takes place?

 jab
-- 
John Bollinger, CFA, CMT
www.BollingerBands.com

If you advance far enough, you arrive at the beginning.

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


[R] get.hist.quote

2007-01-04 Thread BBands
Odd behavior from get.hist.quote this AM.


 get.hist.quote('sunw')
trying URL 
'http://chart.yahoo.com/table.csv?s=sunwa=0b=02c=1991d=0e=03f=2007g=dq=qy=0z=sunwx=.csv'
Content type 'text/csv' length unknown
opened URL
.. .. .. .. ..
.. .. .. .. ..
.. .. .. .. ..
.. .. .. .
downloaded 189Kb

Error in if (!quiet  dat[n] != start) cat(format(dat[n], time
series starts %Y-%m-%d\n)) :
missing value where TRUE/FALSE needed


Indentical for 2.4.0 on SuSE 10.1 and 2.4.1 on Win XP.

jab
-- 
John Bollinger, CFA, CMT
www.BollingerBands.com

If you advance far enough, you arrive at the beginning.

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


Re: [R] get.hist.quote

2007-01-04 Thread BBands
On 1/4/07, BBands [EMAIL PROTECTED] wrote:
 Odd behavior from get.hist.quote this AM.

Now working, must have been a Yahoo! issue.

jab
-- 
John Bollinger, CFA, CMT
www.BollingerBands.com

If you advance far enough, you arrive at the beginning.

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


Re: [R] Does SQL group by have a heavy duty equivalent in R

2007-01-02 Thread BBands
On 1/1/07, Prof Brian Ripley [EMAIL PROTECTED] wrote:

 And it works perfectly well with RODBC, so you don't need yet
 another package.  RODBC even comes with SQLite examples.

Thanks, I hadn't thought of that and it should simplify things as we
are already using RODBC for MySQL.

 BTW, 'fast' is rather misleading: SQLite is often fast for small tasks,
 but can be very slow compared to a more serious DBMS.

Agreed. We switch to MySQL for larger jobs.

jab
-- 
John Bollinger, CFA, CMT
www.BollingerBands.com

If you advance far enough, you arrive at the beginning.

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


Re: [R] Does SQL group by have a heavy duty equivalent in R

2007-01-01 Thread BBands
On 12/30/06, Farrel Buchinsky [EMAIL PROTECTED] wrote:
 Instead I used RODBC

 sqlSave(channel,RawSeq)
 to push the table into a Microsoft Access database
 Then a sql query, courtesy of the Microsoft Access Query Wizard a la design
 mode.

If SQL does prove to be part of your approach you might want to have a
look at SQLite. Dirk introduced it to me back when we worked on
Crusher. We use it for development and some production work. Main
attributes: simple, fast and light weight.

Everything you for R need here:
http://cran.r-project.org/src/contrib/Descriptions/RSQLite.html

SQLite's home page:
http://www.sqlite.org/

And a Python connector:
http://initd.org/tracker/pysqlite

jab
-- 
John Bollinger, CFA, CMT
www.BollingerBands.com

If you advance far enough, you arrive at the beginning.

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


Re: [R] OT: any recommendation for scripting language

2006-12-30 Thread BBands
On 12/30/06, Wensui Liu [EMAIL PROTECTED] wrote:
 Dear Experts,

 Thank you so much for your opinions. I probably will go with python.

 Following your suggestion, I started reading some tutorials but have a
 quick question. In the sense of statistical computing, is there
 anything that can be easily done with python but not with SAS/R? Could
 you please give such an example?

I gather that just about anything can be done in R and have seen some
pretty amazing examples, but I come from the right tool for the job
school as contrasted to the when you have a hammer everything begins
to look like a nail school. As a consequence I tend to use R for
statistics, SQL for database management, gnuplot for graphics and
Python for general programming and glue... A lot of that has to do
with the order in which I learned the tools, for example I am much
faster/more productive with gnuplot than with R graphics, but that gap
is narrowing as I climb R's grade.

jab--not an expert, just a traveller
-- 
John Bollinger, CFA, CMT
www.BollingerBands.com

If you advance far enough, you arrive at the beginning.

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


Re: [R] how to suppress a loading required package: ... message

2006-12-27 Thread BBands
On 12/27/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 Hi,

 how to suppress a loading required package:...  message?

require(package, quiet=TRUE)

 jab
-- 
John Bollinger, CFA, CMT
www.BollingerBands.com

If you advance far enough, you arrive at the beginning.

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


Re: [R] stacked plots

2006-12-27 Thread BBands
On 12/27/06, Dirk Eddelbuettel [EMAIL PROTECTED] wrote:
 Do you remember the bollingerBands example we worked on a few years ago and
 that is still at Romain's incredible R Graph Gallery at
   http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=65

 It uses layout, you can also use the simpler par(mfrow=...) approach *if* you
 also reduce bottom and top spacing accordingly as e.g. in the plot functions
 in the script referenced above.

I do indeed remember that, it was a nice piece of work that I learned
a lot from. At the time you mentioned there were some newer methods in
the works that might serve better, which prompted my question after an
appropriate delay. ;-)

jab
-- 
John Bollinger, CFA, CMT
www.BollingerBands.com

If you advance far enough, you arrive at the beginning.

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


Re: [R] OT: any recommendation for scripting language

2006-12-24 Thread BBands
On 12/23/06, Wensui Liu [EMAIL PROTECTED] wrote:
 if you recommend one, I will really appreciate it if you could point
 out a good source for learning as well.

We have found Python to be the perfect choice for our work. Python is
a high-level, cross-platform language that is easy to learn/write with
an extensive set of libraries. It supports object and procedural
programming styles equally well, so one may match the style to the
task. If is also an excellent 'glue' language, easily tying together
diverse programs in various environments.   There is great
connectivity with R though rpy and RSpython. Here are links to some of
the connectors we use:

R
http://rpy.sourceforge.net/
http://www.omegahat.org/RSPython/
Database
http://sourceforge.net/projects/mysql-python
http://www.initd.org/tracker/pysqlite
Graphics
http://gnuplot-py.sourceforge.net/
Windows--COM, DDE...
http://sourceforge.net/projects/pywin32/

The Python tutorial is the place to start:

http://docs.python.org/tut/

 jab
-- 
John Bollinger, CFA, CMT
www.BollingerBands.com

If you advance far enough, you arrive at the beginning.

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


Re: [R] Install R in Linux

2006-12-14 Thread BBands
On 12/13/06, lu kan [EMAIL PROTECTED] wrote:
 Hi, Is it possible to install R in a linux box (Debian) without being a root. 
 I know I can compile the R source code, but there is no F77 compiler on the 
 box. So is it possible to install binary R without being a root?

If you can get the F77 compiler installed you can configure, make,
test and run R from its bin directory without being root. I did this
last night on a SuSE box with 2.4.0 prior to doing a final make
install as root.

 jab
-- 
John Bollinger, CFA, CMT
www.BollingerBands.com

If you advance far enough, you arrive at the beginning.

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


Re: [R] Book recommendation for newbie to stats and R?

2006-10-17 Thread BBands
On 10/17/06, Zembower, Kevin [EMAIL PROTECTED] wrote:
 I work for an organization that analyses behavior change communication
 programs regarding HIV/AIDS and reproductive health. A typical question
 we're trying to answer is, Watching which television programs in South
 Africa is related to an increased use of condoms? All of our work is in
 the social sciences, I'd say. I'd like to help analyze our data using R.

I recently bought Peter Dalgaard's book and have found it to be quite helpful.

  jab
-- 
John Bollinger, CFA, CMT
www.BollingerBands.com

If you advance far enough, you arrive at the beginning.

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


Re: [R] cluster in R

2006-10-17 Thread BBands
On 10/17/06, Weiwei Shi [EMAIL PROTECTED] wrote:

 is there some good summary on clustering methods in R? It seems there
 are many packages involving it.

Gabor provided this very useful link a couple of days back.

http://cran.r-project.org/src/contrib/Views/Cluster.html

jab
-- 
John Bollinger, CFA, CMT
www.BollingerBands.com

If you advance far enough, you arrive at the beginning.

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


Re: [R] Block comments in R?

2006-10-09 Thread BBands
Apparently misunderstanding me,
On 10/8/06, Richard A. O'Keefe [EMAIL PROTECTED] wrote:
 Amongst other things, it should NOT acquire misfeatures
 in order to support editors that happen not to support comment-region.
...

One can only comment from one's experience. We have found the concept
of inline documentation, and block comments in specific, to be very
valuable in our work. Indeed I cannot think of a problem caused by
this practice, but I can think of many problems caused by the absence
of such practice.

 jab
-- 
John Bollinger, CFA, CMT
www.BollingerBands.com

If you advance far enough, you arrive at the beginning.

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


Re: [R] Block comments in R?

2006-10-06 Thread BBands
And of course vim, emacs, nedit, tinn-r...

Should R be editor specific? Or should it be editor neutral?

In my view blocks comments are a desirable, editor-neutral approach.

Note that most of the more recent languages have some form of block
comment capability.

http://en.wikipedia.org/wiki/Comment#Summary

  jab
-- 
John Bollinger, CFA, CMT
www.BollingerBands.com

If you advance far enough, you arrive at the beginning.

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


Re: [R] Block comments in R?

2006-10-05 Thread BBands
+1 for Python style comments.


your comments here
and some more
...
and some related info


jab
-- 
John Bollinger, CFA, CMT
www.BollingerBands.com

If you advance far enough, you arrive at the beginning.

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


Re: [R] a decimal aligned column

2006-09-30 Thread BBands
As requested:

The alignment problem came from calling format many times. Marc
Schwartz suggested a solution of putting my results in a vector and
then formatting. As I understand it the problem is that fixed-width
fields are only available from sprintf, while comma delineation is
only available from format, formatC and prettyNum. The
interrelationships are complicated (format calls prettyNum) and
require _very_ careful study. Here is Marc's solution with a few
changes. It left aligns the symbols and truncates, right aligns and
comma delineates the numbers. In short you get a nice table that is
easy to scan.

If I had one wish for format, it would be that it could set fixed
field width as well as minimum.

library(tseries)
# the symbols
symbols - c('spy', 'ise', 'oih', 'mot', 'pbj', '')
# set the start date to a year ago
Start - Sys.Date() - 366
# Pre-allocate dolVol as a vector
dolVol - numeric(length(symbols))
# Now get the values, assign to dolVol by indexing
for(line in seq(along = symbols))
{
 a - get.hist.quote(instrument=symbols[line], start=Start,
 compression=w, quote=c(Close, Volume),
 quiet=TRUE)

 dolVol[line] - mean(a[,1]) * mean(a[,2])
}
# Now for the initial common formatting,
# truncating the dolVol values to whole numbers
dolVol.pretty - format(trunc(dolVol), big.mark=,, scientific=FALSE,
   justify=right, width=15)
# Now output
cat(paste(sprintf('%-4s',symbols), dolVol.pretty,
collapse = \n, sep = ), \n)

spy  8,770,399,023
ise 21,296,087
oih  1,415,206,983
mot416,923,148
pbj246,700
 4,077,543,493

jab
-- 
John Bollinger, CFA, CMT
www.BollingerBands.com

If you advance far enough, you arrive at the beginning.

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


Re: [R] a decimal aligned column

2006-09-29 Thread BBands
Many thanks to Marc Schwartz who helped me work through this problem
in a series of off list exchanges.

 jab
-- 
John Bollinger, CFA, CMT
www.BollingerBands.com

If you advance far enough, you arrive at the beginning.

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


[R] a decimal aligned column

2006-09-28 Thread BBands
Hello,

For numbers in the range 100 to 100,000,000 I'd like to decimal align
a right-justified comma-delineated column of numbers, but I haven't
been able to work out the proper format statement. format(num,
justify=right, width=15, big.mark=,) gets me close, but numbers
larger than 1,000,000 project a digit beyond the right edge of the
column, which I really don't understand. I gather I can get the
decimal alignment from sprintf(), but I am not sure about the
interaction of the two functions.

TIA,

jab
-- 
John Bollinger, CFA, CMT
www.BollingerBands.com

If you advance far enough, you arrive at the beginning.

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


Re: [R] Command area in SciViews 0.8.9 - second try

2006-09-21 Thread BBands
On 9/21/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 (i) the command area at the bottom cannot be found
 (ii) the regular R window cannot be minimized/maximized anymore.

I cannot duplicate these problems with R 2.3.1, SciViews 0.8-9, Win XP(current).

jab
-- 
John Bollinger, CFA, CMT
www.BollingerBands.com

If you advance far enough, you arrive at the beginning.

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


Re: [R] plot correlation matrix

2006-09-21 Thread BBands
On 9/21/06, Earl F. Glynn [EMAIL PROTECTED] wrote:
  Which function was used to produce this plot?

 library(ellipse)
  ?plotcorr

 Look at the third example for the color plot.

That's pretty nice. I have been using symnum(). Are there any other
neat visualisations for correlation matrices?

 jab
-- 
John Bollinger, CFA, CMT
www.BollingerBands.com

If you advance far enough, you arrive at the beginning.

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


Re: [R] currency or stock trading strategy

2006-09-19 Thread BBands
On 9/17/06, Darren Weber [EMAIL PROTECTED] wrote:
 Hi,

 are there any good charting and analysis tools for use with
 currencies, stocks, etc. in R?  I have some tools to download currency
 data from the NYFRB using python and XML.  Can we get and parse an XML
 download using R?  Can we have interaction in R plots?  Does anyone
 use R for back-testing trading strategies?  Are there any forums for
 discussion of using R for this specific purpose (apart from this
 general list)?  Is anyone aware of any general open-source
 developments for these purposes (I don't see any from GNU or google
 searches)?

 Take care, Darren

I hardly know where to start either. I use R, Python, rpy, gnuplot-py
and gnuplot together and am very happy with the result. I find that
each piece has it own strengths and together they provide a very
powerful solution. I am currently working on integrating TA-lib into
this mix via a project started by Andrea Malagoli--see the
r-sig-finance archives.

http://rpy.sourceforge.net/
http://www.gnuplot.info/
http://gnuplot-py.sourceforge.net/
http://ta-lib.org/

 jab
-- 
John Bollinger, CFA, CMT
www.BollingerBands.com

If you advance far enough, you arrive at the beginning.

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


Re: [R] Connecting to R using Perl?

2006-09-08 Thread BBands
On 9/8/06, Ffenics [EMAIL PROTECTED] wrote:
 Hi there
 Can anyone tell me please if I can access R though a perl script?

http://www.omegahat.org/RSPerl/

And there is always:

http://rpy.sourceforge.net/

jab
-- 
John Bollinger, CFA, CMT
www.BollingerBands.com

If you advance far enough, you arrive at the beginning.

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


Re: [R] Connecting to a SQLBASE database with R

2006-09-08 Thread BBands
for RODBC you must make a connection SQLBASE first:

For XP: control panel  Admin tools  Data sources  Add...

You may have to install the SQLBASE ODBC driver first if it is not on the list.

The rest should be easy just supply the connection name and details to RODBC.

jab
-- 
John Bollinger, CFA, CMT
www.BollingerBands.com

If you advance far enough, you arrive at the beginning.

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


Re: [R] .Rprofile under Windoze.

2006-08-30 Thread BBands
On 8/30/06, Rolf Turner [EMAIL PROTECTED] wrote:
 I am (for my sins) having to do some work using R under Windoze.  I
 wanted to set up a .Rprofile to control my set-up.  The docs on
 .Rprofile say that it can/should be placed in ``the user's home
 directory''.  ``An Introduction to R'' observes lucidly that this
 concept needs to be clarified under Windoze.

Saving .Rprofile to the R root directory works for me.

On my system that is C:\Program Files\R\R-2.3.1\

 jab
-- 
John Bollinger, CFA, CMT
www.BollingerBands.com

If you advance far enough, you arrive at the beginning.

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


Re: [R] .Rprofile under Windoze.

2006-08-30 Thread BBands
And... If you have/use shortcuts to R, you may also save an
.Rprofile to whatever directory you name in the Start in: field of
the shortcut. This allows one to have many profiles.

   jab
-- 
John Bollinger, CFA, CMT
www.BollingerBands.com

If you advance far enough, you arrive at the beginning.

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


[R] passing namees

2006-08-29 Thread BBands
R 2.3.1

I wrote a little script to do some cross correlations. The symbols are
in a text file like so:

symbols.txt
ibm
dd
csco


require(tseries)
symbols - scan(symbols.txt, what = 'character')

for(line in 1:(length(symbols)-1)) {
   assign(symbols[line], get.hist.quote(instrument = symbols[line],
   start = 2005-09-01, quote = Close))
   }
# this results in objects ibm, dd... with the last symbol skipped

mat - cbind(symbols) # this is the problem
(cor_mat - cor(mat))
symnum(cor_mat)


How can I pass a list of the objects to cbind()? As written cbind gets
only the names of the objects and binds the names not the objects.

Thanks in advance,

 jab
-- 
John Bollinger, CFA, CMT
www.BollingerBands.com

If you advance far enough, you arrive at the beginning.

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