Re: [R] New to R

2015-05-10 Thread rex

Boris Chow  [2015-05-09 20:04]:


I want to do a pricing of an American option as my first exercise. Can some 
experienced users give me some pointers to do so?


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

http://cran.r-project.org/web/packages/AmericanCallOpt/AmericanCallOpt.pdf

http://cran.r-project.org/web/packages/fOptions/fOptions.pdf


-rex
--
"The market can remain irrational longer than you can remain solvent."
-- John Maynard Keynes

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] CGIwithR installation failure

2013-06-08 Thread rex

Hello,

CGIwithR apparently is not available on CRAN for R 2.15.x, so I
downloaded the source (0.73) and tried:

~/Downloads$ R CMD INSTALL CGIwithR
* installing to library ‘/home/rex/R/x86_64-pc-linux-gnu-library/2.15’
* installing *source* package ‘CGIwithR’ ...
configure: creating ./config.status
config.status: creating R/CGIwithR.R

  *

  After the installation of this R package is complete
  copy the files R.cgi and .Rprofile in
  /home/rex/R/x86_64-pc-linux-gnu-library/2.15/CGIwithR/cgi-bin/
  to the cgi-bin area of your Web server. If necessary, 
  modify the settings in the first part of R.cgi to 
  suit your local configuration.


  *

** R
Error in parse(outFile) : embedded nul in string: '\0'
ERROR: unable to collate and parse R files for package ‘CGIwithR’


Any suggestions, including using a different package, appreciated.

Background: I want to solve the classic diet linear programming
problem. The CGI code needs to parse a POST, access a MySQL DB, solve
the problem (probably using the linprog package), and present the
solution to the vistor. I've done CGI programming in Python, but
not in R and don't know if CGIwithR is a good choice. It hasn't
been updated since 2005, so a more current package may be a better
choice. OTOH, my needs are (currently) simple so CGIwithR may
be an OK choice.

I've a Python version that does the above, except for finding the
lowest cost diet that meets constraints. The Python input form will be
used in the R version (no point in reinventing the wheel).

http://www.nosyntax.net/birdnutrit/

Thanks for any help.

-rex
--
If at first you do succeed, try not to look astonished.

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

2013-06-09 Thread rex

rex  [2013-06-08 18:05]:


CGIwithR apparently is not available on CRAN for R 2.15.x, so I
downloaded the source (0.73) and tried:

~/Downloads$ R CMD INSTALL CGIwithR


Typo. Actually, I downloaded 0.72. Later, I found 0.73 here:

http://cran.r-project.org/src/contrib/Archive/CGIwithR/

D/L 0.73
tar -xzvf CGIwithR_0.73-0.tar.gz
R CMD INSTALL CGIwithR
* installing to library ‘/home/rex/R/x86_64-pc-linux-gnu-library/2.15’
* installing *source* package ‘CGIwithR’ ...
** package ‘CGIwithR’ successfully unpacked and MD5 sums checked
configure: creating ./config.status
config.status: creating R/CGIwithR.R

   *

   After the installation of this R package is complete
   copy the files R.cgi and .Rprofile in
   /home/rex/R/x86_64-pc-linux-gnu-library/2.15/CGIwithR/cgi-bin/
   to the cgi-bin area of your Web server. If necessary, 
   modify the settings in the first part of R.cgi to 
   suit your local configuration.


   *

** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded

* DONE (CGIwithR)


My slightly modified R.cgi, trivial.html & trivial.R are
below for reference (I'm running Debian Testing & R 2.15.3).

R.cgi

#! /bin/sh

###  A shell script to make CGI scripting possible in R.  Part of the
###  "CGIwithR" package for R.
###
###  Author: David Firth, University of Warwick 
###  (d.fi...@warwick.ac.uk)

###
###  Terms of use: GPL version 2 or later.  See "COPYING" in the
###  R distribution.
###
###  NO WARRANTY GIVEN, AND NO LIABILITY ACCEPTED FOR LOSS CAUSED BY
###  USE OF THIS PROGRAM
###
###
###  INSTALLING IT:
###
###  This file, and the one-line ".Rprofile" file included with the
###  package, must be placed together in a "cgi-bin" directory.  Both 
###  files should be readable (and this file executable) by the web 
###  server.

###
###
###  CONFIGURING IT:
###
###  First locate R on the local system (typically the answer 
###  to "which R"). This is the command to run R.
###  Individual R CGI scripts may request execution by a  
###  different, elsewhere-installed version of R; the R specified 
###  here is the default.


R_DEFAULT=/usr/bin/R
#R_DEFAULT=/usr/local/bin/R

###  Graphs can be included in the output using either the 
###  GDD package (available from cran.r-project.org) 
###  or via ghostscript.

###  GDD is the default.  If it is not installed, the webPNG()
###  function will attempt to use ghostscript.  You can specify
###  where the executable is located on your system via the R_GSCMD
###  environment variable.  If using GDD, you can ignore this.

R_GSCMD=/usr/bin/gs
#R_GSCMD=/usr/local/bin/gs
export R_GSCMD

###  The next two lines may optionally be edited to limit access
###  to local resources.
###
###  This line allows specification of the priority
###  given to the R process.  A nice of "0" is the normal  
###  priority, while e.g. "+10" causes R to be run as a 
###  low-priority process.  The value "NONE" should be given if  
###  nice is not implemented locally.


R_NICE=NONE

###  This line allows the imposition of a length limit on the data
###  entered on an HTML form for processing by an R script.  
###  Setting MAX_DATA_LENGTH=1000, for example, aborts  
###  execution if the data length exceeds 1000 characters.  Or

###  use MAX_DATA_LENGTH=NONE to impose no limit here.

MAX_DATA_LENGTH=1000


###
### To make use of packages not installed in the default library for R
### i.e. `R RHOME`/library/, set the environment R_LIBS to identify
### one or more library directories containing the packages (separated by :).
### This is only necessary if the CGIwithR package itself is not located
### in the default library, e.g. if one is using a different version.

R_LIBS=/home/rex/R/x86_64-pc-linux-gnu-library/2.15/
export R_LIBS


###  No further configuration is needed.

No changes made in R.cgi below here.

trivial.html

http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd";>


An example form for CGIwithR


http://www.nosyntax.net/cgi-bin/R.cgi/trivial.R"; method="POST">

Enter some words: 

Now some numbers (separated by any kind of white space):







trivial.R

#! /usr/bin/R

tag(HTML)
tag(HEAD)
tag(TITLE)
cat("An example R.cgi output page")
untag(TITLE)
untag(HEAD)
comments("Some comments to be ignored by the web browser")

lf(2)

tag(BODY, bgcolor = "lightyellow")
lf(2)
tag(h3)
cat("A large heading")
untag(h3)

lf(2)

tag(p)
cat("Your words in italics:")
tag(i)
cat(formData$words)
untag

Re: [R] CGIwithR installation failure

2013-06-09 Thread rex

Prof Brian Ripley  [2013-06-08 23:23]:

On 08/06/2013 23:27, rex wrote:

CGIwithR apparently is not available on CRAN for R 2.15.x, so I


It is not hosted on CRAN.  You should ask its maintainer (and package 
installation problems most often belong on the R-devel list).


Actually it is, but not in the usual place.

See what the posting guide says about that and about upgrading your R 
before posting. 


I did read the posting guide before posting, and I'm in no hurry to
upgrade R, thank you. As you can see from my [Solved] post, the problem
was with 0.72, and 0.73 works with R 2.15.3.


Background: I want to solve the classic diet linear programming
problem. The CGI code needs to parse a POST, access a MySQL DB,
solve the problem (probably using the linprog package), and present
the solution to the vistor. I've done CGI programming in Python, but
not in R and don't know if CGIwithR is a good choice. It hasn't been
updated since 2005 [0.73 was updated in 2010], so a more current
package may be a better choice. OTOH, my needs are (currently)
simple so CGIwithR may be an OK choice.


It would have been nice to get some feedback on the suitability of 
CGIwithR compared to other CGI alternatives.


-rex
--
Life would be easier if I had the source 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] CGIwithR installation failure [SOLVED]

2013-06-09 Thread rex

Prof Brian Ripley  [2013-06-09 00:22]:

On 09/06/2013 08:05, rex wrote:

Typo. Actually, I downloaded 0.72. Later, I found 0.73 here:

http://cran.r-project.org/src/contrib/Archive/CGIwithR/


But see http://cran.r-project.org/package=CGIwithR for the current host.


I did; that's where I found the link to the CRAN archive that has 0.73.
The http://www.omegahat.org/CGIwithR/ link is to 0.72. IOW, the CRAN
archive is more up-to-date than the "current" host.

-rex
--
Nostalgia ain't what it used to be.

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

2013-06-09 Thread rex

Bhupendrasinh Thakre  [2013-06-09 20:03]:


library("sendmailR")

from <- "a...@outlook.com"
to <-  <mailto:e...@gmail.com> e...@gmail.com
subject <- "Run at"
mailControl = list(smtpServer="blu-m.hotmail.com")
attachment <- "type_1.pdf"
attachmentName <- "target_score.pdf"
attachmentObject <- mime_part(x= attachment,name= attachmentName)
body <- "Email Body"
bodywithAttachement <- list(body, attachmentObject)
sendmail(from=from,to=to,subject=subject,msg=
bodywithAttachement,control=mailControl)

However it gives me following Error:

Error:

Error in socketConnection(host = server, port = port, blocking = TRUE) :
 cannot open the connection
In addition: Warning message:
In socketConnection(host = server, port = port, blocking = TRUE) :
 blu-m.hotmail.com:25 cannot be opened


It's an unsurprising result since telnet doesn't connect either:
 
telnet blu-m.hotmail.com 25

Trying 65.55.121.94...
telnet: Unable to connect to remote host: Connection timed out

Try port 443:

telnet blu-m.hotmail.com 443
Trying 65.55.121.94...
Connected to eas-blu.hot.glbdns.microsoft.com.
Escape character is '^]'.

But it's probably expecting TLS, and sendmailR doesn't support it.


Please let me know if we have some solution for this.


If you want to use sendmailR, you need to find a mail server that
does not require TLS. This may mean running your own mail server. 


Or, you can call an external program that handles a TLS connection.

-rex
--
Proofread carefully to see if you any words out.

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

2014-03-19 Thread rex
Wolf, Steven  [2014-03-18 21:05]:
> I am looking for a verification protocol which can look at a data file and 
> see if it has been modified.  Ideally, this should be something that I can 
> check the file with to see if the file has been changed or corrupted and 
> incorporate into my analysis workflow.  (i.e., every time I look at my data, 
> I can run this protocol to ensure the file hasn?t changed.)

http://dirk.eddelbuettel.com/code/digest.html

Overview

digest provides `hash' function summaries for GNU R objects. The md5,
sha-1, sha-256 and crc32 hash functions are available. The md5
algorithm by Ron Rivest is specified in RFC 1321, the SHA-1 and
SHA-256 algorithm is specified in FIPS-180-1 and FIPS-180-2,
respectively, and the crc32 algorithm is described in here. For md5,
sha-1 and sha-256, this packages uses small standalone C
implementations that were provided by by Christophe Devine. For crc32,
code from the zlib library is used. For sha-512, a routine by Aaron
Gifford is used. Please note that this package is not meant to be
deployed for cryptographic purposes for which more comprehensive (and
widely tested) libraries such as OpenSSL should be used.

Example

The following verbatim R session loads digest and runs the example()
from the corresponding help page:

> library(digest)
> example(digest)

digest> md5Input <- c("", "a", "abc", "message digest", 
"abcdefghijklmnopqrstuvwxyz",
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
paste("12345678901234567890123456789012345678901234567890123456789012",
"34567890123456 ..." ... [TRUNCATED]
[...]

HTH,

-rex
-- 
"...I paid a visit to Schrodinger in his Vienna apartment before his death...
There were no cats. I was told he did not like cats." -quantam leaps,
bernstein.

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


[R] ggplot2 help/suggestions needed

2011-07-28 Thread Bruce Rex

Hello,

I have written a version of the Kohenen Self Organizing Map (in R) and wish
to use ggplot2 for the visualization. My results are RGB values in a matrix
[x,y,1:3] where x and y comprise the first two dimensions and the third
dimension is the RGB vector.

I am not sure whether to use geom_tile or geom_hex as there really is no
binning at the finest granularity. For testing, the matrix is 100, 100, 3 in
size. What approach would you suggest?

TIA,
DrX

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

2010-01-12 Thread Rex C. Eastbourne
Let's say I have data in the following schema that describes the number of
purchases a company has received from each County in the US:

State | County | Purchases
---
NJ | Mercer | 550
CA | Orange | 23


I would like to visualize what states contribute the most to the overall
total, and furthermore within those states, what Counties contribute the
most. What are some recommended R visualizations for this type of data? I
created a treemap using map.market from the portfolio library, like the
following:

http://zoonek2.free.fr/UNIX/48_R/g126.png

Although this is an attractive visual, I want something that makes it easier
to compare the relative sizes of components at a glance (hard with a treemap
because rectangles have different aspect ratios). Does anyone have a
recommended alternate visualization?

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.


Re: [R] Recommended visualization for hierarchical data

2010-01-12 Thread Rex C. Eastbourne
On Tue, Jan 12, 2010 at 5:26 PM, Rex C. Eastbourne  wrote:

> Let's say I have data in the following schema that describes the number of
> purchases a company has received from each County in the US:
>
> State | County | Purchases
> ---
> NJ | Mercer | 550
> CA | Orange | 23
> 
>
> I would like to visualize what states contribute the most to the overall
> total, and furthermore within those states, what Counties contribute the
> most. What are some recommended R visualizations for this type of data? I
> created a treemap using map.market from the portfolio library, like the
> following:
>
> http://zoonek2.free.fr/UNIX/48_R/g126.png
>
> Although this is an attractive visual, I want something that makes it
> easier to compare the relative sizes of components at a glance (hard with a
> treemap because rectangles have different aspect ratios). Does anyone have a
> recommended alternate visualization?
>
> Thanks!
>

Just to clarify: I made up the above example for simplicity's sake to
illustrate what I meant by "hierarchical" data. My actual data is not
related to maps or geography, so a map-based visualization wouldn't work.

[[alternative HTML version deleted]]

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


Re: [R] Recommended visualization for hierarchical data

2010-01-12 Thread Rex C. Eastbourne
On Tue, Jan 12, 2010 at 8:58 PM, Simon Knapp  wrote:

>  Not sure if there are any 'recommended' visualisations, but the following
> is
> a start (you will need to tune the scaling of the x-axis label and state
> identifiers).
>
> In the plot produced, the widths of the 'columns' are proportional of
> purchases occurring in the state, and the height of the 'boxes' are
> proportional to the purchases occurring in the County - hence the area of
> each box represents the proportion of total (i.e. national) sales occurring
> in the County.
>
> #generate some random data
> n <- 100
> dat <- data.frame(
>State=(tmp <- sample(LETTERS, n, T)),
>County=paste(tmp, 1:n, sep=''),
>Purchases=floor(rnorm(n, 100, 20))
> )
>
> # draw the plot
> split.dat <- split(dat, dat$State)
> widths <- sapply(split.dat, function(x) sum(x$Purchases))
> widths <- widths / sum(widths)
> cum.widths <- c(0.0, cumsum(widths)[-length(widths)])
> plot(0:1, 0:1, type='n', xaxt='n', yaxt='n', xlab='', ylab='')
> par(usr=c(0,1,0,1), xpd=NA)
> mapply(function(x, cum.tot, width) {
>heights <- x$Purchases / sum(x$Purchases)
>cum.heights <- c(0.0, cumsum(heights)[-length(heights)])
>mapply(function(y, height, x, width) rect(x, y, x+width, y+height),
> cum.heights, heights, MoreArgs=list(cum.tot, width))
>text(cum.tot + width/2, heights/2 + cum.heights, x$County)
> }, split.dat, cum.widths, widths)
>
> axis(1, (widths / 2 + cum.widths), names(split.dat))
>
>
>
> Hope this helps,
> Simon Knapp
>

This is great, Simon! I'm going to tweak this code some more.

Thanks,

Rex

[[alternative HTML version deleted]]

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


[R] Barchart bar lengths not proportionate

2010-01-14 Thread Rex C. Eastbourne
When I use barchart (with default formatting options), I get bars whose
lengths/heights are not proportional to their value. For example:

http://drop.io/wbagm6s/asset/capture-png

Many of the values in this chart are 1; however, because the blue bars
extend to the left of the "0" tick mark, those bars appear to represent
higher numeric values. Is there a way to make the length of the bar
proportional to the data value, so that people looking at my chart are not
misled?

Thanks,

Rex

[[alternative HTML version deleted]]

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


Re: [R] Barchart bar lengths not proportionate

2010-01-14 Thread Rex C. Eastbourne
That fixed it! Thanks to all who replied.
On Thu, Jan 14, 2010 at 9:13 AM, S Ellison  wrote:

> I think you should rather look at the origin= parameter in barchart. See
>
> ?panel.barchart for a discussion of this exact problem:
> "  origin: the origin for the bars.  For grouped displays with 'stack
> =
>  TRUE', this argument is ignored and the origin set to 0.
>  Otherwise, defaults to 'NULL', in which case bars start at
>  the left (or bottom) end of a panel.  This choice is
> somewhat
>  unfortuntate, as it can be misleading, but is the default
> for
>  historical reasons.  For tabular (or similar) data, 'origin
> =
>  0' is usually more appropriate; if not, one should
> reconsider
>  the use of a bar chart in the first place (dot plots are
>  often a good alternative). "
>
> The result of setting origin is more sensible:
> require(lattice)
> da <- expand.grid(A=c("a","b"), x=1:4)
> da$y <- c(1,5,6,3,2,0,6,0)
>
> barchart(y~x|A, data=da, horizontal=FALSE)
>
> barchart(y~x|A, data=da, horizontal=FALSE, origin=0)
>
> >>> Walmes Zeviani  14/01/2010 14:49:01 >>>
>
> Rex,
>
> I think this problem can be solved using xlim()/ylim() argument. Look
> at the
> follwing code:
>
> require(lattice)
> da <- expand.grid(A=c("a","b"), x=1:4)
> da$y <- c(1,5,6,3,2,0,6,0)
>
> barchart(y~x|A, data=da, horizontal=FALSE)
>
> barchart(y~x|A, data=da, horizontal=FALSE,
> ylim=c(0, 1.05*max(da$y)))
>
> At your disposal.
> Walmes.
>
>
>
> Rex C. Eastbourne wrote:
> >
> > When I use barchart (with default formatting options), I get bars
> whose
> > lengths/heights are not proportional to their value. For example:
> >
> > http://drop.io/wbagm6s/asset/capture-png
> >
> > Many of the values in this chart are 1; however, because the blue
> bars
> > extend to the left of the "0" tick mark, those bars appear to
> represent
> > higher numeric values. Is there a way to make the length of the bar
> > proportional to the data value, so that people looking at my chart
> are not
> > misled?
> >
> > Thanks,
> >
> > Rex
> >
> >   [[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<http://www.r-project.org/posting-guide.html>
> > and provide commented, minimal, self-contained, reproducible code.
> >
> >
>
>
> -
> ..oooO
>
> ..
> ..()... 0ooo...  Walmes Zeviani
> ...\..(.(.)... Master in Statistics and Agricultural
> Experimentation
> \_). )../   walmeszevi...@hotmail.com, Lavras - MG,
> Brasil
> 
>
> (_/
> --
> View this message in context:
>
> http://n4.nabble.com/Barchart-bar-lengths-not-proportionate-tp1013702p1013918.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<http://www.r-project.org/posting-guide.html>
> and provide commented, minimal, self-contained, reproducible code.
>
> ***
> This email and any attachments are confidential. Any u...{{dropped:13}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Newbie mistakes saving images to files

2010-01-14 Thread Rex C. Eastbourne
On Thu, Jan 14, 2010 at 2:15 PM, Rex C. Eastbourne  wrote:

> I am encountering problems using the png() function to save around 20
> charts to separate files.
>
> My script is conceptually structured as follows:
>
> ### 
> png("Image %03d.png")
>
> # the following are calls to user-defined functions I wrote that call plot,
> barchart, etc. with special arguments.
>  myPlot("a")
> myPlot("b")
> myPlot("c")
>
> myBarchart("a")
> myBarchart("b")
> myBarchart("c")
>
>  myBarchart2("a")
> myBarchart2("b")
> myBarchart2("c")
>
> dev.off()
> ### 
>
> When I run the code a few lines at a time it generates the images
> correctly. However, when I execute all lines of the script at once (Ctrl+A,
> Ctrl+R in the Rgui editor), the output doesn't get generated right. Most
> notably:
>
> - Only one plot created by myBarchart (or myBarchart2) gets saved, instead
> of all 3
> - Some images are blank
>
> I'm having trouble isolating the problem to one line of code.
>
> I suspect there is some fundamental paradigm I'm not aware of about how R
> devices and images work, perhaps relating to the importance of the order in
> which the calls to png, dev.off(), etc. are executed, the required state of
> my workspace before I run the code (e.g. whether the previous plot window
> should be open or closed), or maybe even time dependency (do I need to
> insert timed pauses so that my diagram has time to render before saving to a
> file?).
>
> Does this ring a bell to anyone? I read the R documentation on devices and
> png(), and searched the mailing list archives and the web, but haven't
> figured out how to get this working. Any help would be appreciated.
>
> Thanks,
>
> Rex
>

I'm on Windows 7 and R 2.9.2, BTW.

[[alternative HTML version deleted]]

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


[R] Newbie mistakes saving images to files

2010-01-14 Thread Rex C. Eastbourne
I am encountering problems using the png() function to save around 20 charts
to separate files.

My script is conceptually structured as follows:

### 
png("Image %03d.png")

# the following are calls to user-defined functions I wrote that call plot,
barchart, etc. with special arguments.
 myPlot("a")
myPlot("b")
myPlot("c")

myBarchart("a")
myBarchart("b")
myBarchart("c")

 myBarchart2("a")
myBarchart2("b")
myBarchart2("c")

dev.off()
### 

When I run the code a few lines at a time it generates the images correctly.
However, when I execute all lines of the script at once (Ctrl+A, Ctrl+R in
the Rgui editor), the output doesn't get generated right. Most notably:

- Only one plot created by myBarchart (or myBarchart2) gets saved, instead
of all 3
- Some images are blank

I'm having trouble isolating the problem to one line of code.

I suspect there is some fundamental paradigm I'm not aware of about how R
devices and images work, perhaps relating to the importance of the order in
which the calls to png, dev.off(), etc. are executed, the required state of
my workspace before I run the code (e.g. whether the previous plot window
should be open or closed), or maybe even time dependency (do I need to
insert timed pauses so that my diagram has time to render before saving to a
file?).

Does this ring a bell to anyone? I read the R documentation on devices and
png(), and searched the mailing list archives and the web, but haven't
figured out how to get this working. Any help would be appreciated.

Thanks,

Rex

[[alternative HTML version deleted]]

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


Re: [R] Newbie mistakes saving images to files

2010-01-14 Thread Rex C. Eastbourne
Thanks Jim! I followed the instructions in the FAQ and wrapped print()
around my function calls. The images are now properly generated.

Rex
On Thu, Jan 14, 2010 at 4:38 PM, jim holtman  wrote:

> If you are using lattice, check out FAQ 7.22
>
>  On Thu, Jan 14, 2010 at 5:15 PM, Rex C. Eastbourne <
> rex.eastbou...@gmail.com> wrote:
>
>>  I am encountering problems using the png() function to save around 20
>> charts
>> to separate files.
>>
>> My script is conceptually structured as follows:
>>
>> ### 
>> png("Image %03d.png")
>>
>> # the following are calls to user-defined functions I wrote that call
>> plot,
>> barchart, etc. with special arguments.
>>  myPlot("a")
>> myPlot("b")
>> myPlot("c")
>>
>> myBarchart("a")
>> myBarchart("b")
>> myBarchart("c")
>>
>>  myBarchart2("a")
>> myBarchart2("b")
>> myBarchart2("c")
>>
>> dev.off()
>> ### 
>>
>> When I run the code a few lines at a time it generates the images
>> correctly.
>> However, when I execute all lines of the script at once (Ctrl+A, Ctrl+R in
>> the Rgui editor), the output doesn't get generated right. Most notably:
>>
>> - Only one plot created by myBarchart (or myBarchart2) gets saved, instead
>> of all 3
>> - Some images are blank
>>
>> I'm having trouble isolating the problem to one line of code.
>>
>> I suspect there is some fundamental paradigm I'm not aware of about how R
>> devices and images work, perhaps relating to the importance of the order
>> in
>> which the calls to png, dev.off(), etc. are executed, the required state
>> of
>> my workspace before I run the code (e.g. whether the previous plot window
>> should be open or closed), or maybe even time dependency (do I need to
>> insert timed pauses so that my diagram has time to render before saving to
>> a
>> file?).
>>
>> Does this ring a bell to anyone? I read the R documentation on devices and
>> png(), and searched the mailing list archives and the web, but haven't
>> figured out how to get this working. Any help would be appreciated.
>>
>> Thanks,
>>
>> Rex
>>
>>[[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<http://www.r-project.org/posting-guide.html>
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
>
>
> --
> Jim Holtman
> Cincinnati, OH
> +1 513 646 9390
>
> What is the problem that you are trying to solve?
>

[[alternative HTML version deleted]]

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


[R] Possible to write text inside a bar of a barplot?

2010-01-15 Thread Rex C. Eastbourne
How can I write text inside a bar of a barplot? I tried using text(), but I
am only able to specify the numeric y-coordinate. The different columns of
my barplot correspond to factors and not numbers, so I don't know how to
access the horizontal positions of the bars. I tried fiddling with different
values of the "adj" argument, but this appears unreliable.

Background: I have created a barplot visualization where the bars represent
the size of different items (e.g. US state populations), and the sub-bars
represent the size of the different sub-components of each item (e.g.
counties). Picture: http://drop.io/hjcodjj/asset/capture-png

I would like to put in a label inside each sub-bar (e.g. indicating the name
of the county represented by that sub-bar).

Rex

p.s.: In case anyone finds this visualization useful I'll share my code
afterward, but just need to get the labeling working properly first.

[[alternative HTML version deleted]]

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


Re: [R] Possible to write text inside a bar of a barplot?

2010-01-15 Thread Rex C. Eastbourne
Thanks for the replies! The answer is that barplot() returns the x
coordinates of the bars.

On Fri, Jan 15, 2010 at 12:01 PM, Rex C. Eastbourne <
rex.eastbou...@gmail.com> wrote:

> How can I write text inside a bar of a barplot? I tried using text(), but I
> am only able to specify the numeric y-coordinate. The different columns of
> my barplot correspond to factors and not numbers, so I don't know how to
> access the horizontal positions of the bars. I tried fiddling with different
> values of the "adj" argument, but this appears unreliable.
>
> Background: I have created a barplot visualization where the bars represent
> the size of different items (e.g. US state populations), and the sub-bars
> represent the size of the different sub-components of each item (e.g.
> counties). Picture: http://drop.io/hjcodjj/asset/capture-png
>
> I would like to put in a label inside each sub-bar (e.g. indicating the
> name of the county represented by that sub-bar).
>
> Rex
>
> p.s.: In case anyone finds this visualization useful I'll share my code
> afterward, but just need to get the labeling working properly first.
>

[[alternative HTML version deleted]]

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


[R] Drawing paths through a grid

2010-06-17 Thread Rex C. Eastbourne
I would like to draw a set of points that are equally spaced in a 2-D
grid. Then I would like to draw lines that illustrate different
directed paths through subsets of points. Imagine that the points
correspond to booths in a conference center, and I want to show the
various paths people took to visit the booths (using color to
highlight different types of paths). An example path might be: [(1,1),
(1,3), (3, 3)].

Note: I would like to also make the size of the points in the grid
variable (they correspond to the sizes of the booth).

Can anyone suggest a way to do this in R? (Or to suggest another
software package.)

Thanks,
Rex

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

2008-01-02 Thread Rex Carazo-Zapetis
 Hi,

   I have two separate questions relating to the KernSmooth package.  I am
using the dpik function from the KernSmooth package and receive the error

 Warning message:
In kappam * Gcounts :
 longer object length is not a multiple of shorter object length

   I saw an earlier post , but the issue was using the bkde fxn and the
person appeared to be using too small of a bandwidth.  However,
dpik returns a bandwidth and therefore I am not sure why I am getting this
error.  If I use dpik and specify scalest to be "stdev" then the fxn works.


  Secondly,  I am using the bkde function and when I put in a vector of data
the function computes some bandwidth to use as it then proceeds to return x
and y vectors.  I do not see in  the documentation the process by which this
bandwidth is computed.  It does not appear to match the bandwidth (or even
be remotely close, it is an order of magnitude different) when using the
dpik function (with scalest = "stdev").  If someone could tell me how it
calculates the bandwidth which the function uses I would appreciate it.

Thank you in advance.

[[alternative HTML version deleted]]

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