Re: [R] long output in R

2010-04-22 Thread Tal Galili
Not answering your question,

But if you where to ask this regarding plots, the answer would be to use:
par(ask = T)


Best,
Tal

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




On Thu, Apr 22, 2010 at 1:01 AM, Mingfeng Lin mingfeng@gmail.comwrote:

 Hello all:

 Is there a way to set up R such that, when you have a very long output
 from a command, it will pause when it has displayed one-screen of
 information and ask me to press a button to continue displaying? I
 happen to have one such command and the information I need is at the
 top of the output - and it's just nowhere to be seen.

 (If you are familiar with Stata, I'm looking for something equivalent
 to the -set more on- option there.

 Thanks a lot!

 Mingfeng

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


[[alternative HTML version deleted]]

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


[R] time difference

2010-04-22 Thread Carol Gao
Hi,

Does anyone know how to take a time difference when the format of the time
is as 13:22:23.586? I am trying to take the difference of time between stock
transactions and need to keep the three decimal places for seconds. I have
tried *diff(strptime(x, %H:%M:%S.000))*, but apperantly that doesn't work.

Carol Gao

[[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] Assigning week numbers

2010-04-22 Thread Gustaf Rydevik
On Wed, Apr 21, 2010 at 6:50 PM, Michael Hosack mhosa...@hotmail.com wrote:


 I provided a minimized version of my dataframe at the bottom of this message 
 containing the results of David's code in variable ('wkoffset') and Jeff 
 Hallman's code in ('WEEK'). Jeff's code produced the correct results (thank 
 you Jeff) though I have been unable to understand it. David, as you can see 
 your code begins week 2 for year 2011 on a Wednesday, rather than on a 
 Saturday, as it should. Your adjustment seems not to correct the problem, but 
 I concede I may be using it incorrectly. If you are obtaining the correct 
 results please let me know what I am doing wrong.

 Thanks,

 Mike



Hello again,

Just for fun, I implemented the gist of your original code in R. It's
much longer and not as elegant as the other solutions, but perhaps
someone can learn something from it.
Regards,
Gustaf



Daterange-range(SCHEDULE3$DATE.)
Daterange[1]-paste(as.numeric(
substr(as.character(Daterange[1]),1,4))-1,
-05-01,sep=)
Daterange[2]-paste(as.numeric(
substr(as.character(Daterange[2]),1,4))+1,
-05-01,sep=)

alldates-seq(from=Daterange[1],to=Daterange[2],by=1)


My.locale-Sys.getlocale(LC_TIME)
Sys.setlocale(LC_TIME,English_USA.1252)
Week-1
allweeks-vector(length=length(alldates))


for(i in seq_along(alldates)){
if(weekdays(alldates[i])==Saturday){
Week-Week+1
}
if(substr(as.character(alldates[i]),6,10)==05-01){
Week-1
}
allweeks[i]-Week
}

SCHEDULE3$Week-allweeks[match(SCHEDULE3$DATE.,alldates)]

Sys.setlocale(LC_TIME,My.locale)



-- 
Gustaf Rydevik, M.Sci.
tel: +46(0)703 051 451
address:Essingetorget 40,112 66 Stockholm, SE
skype:gustaf_rydevik

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

2010-04-22 Thread Patrick Burns

There are at least two functions that
may be of interest to you in this regard:

'head' (there is also 'tail')
'page'

On 21/04/2010 23:01, Mingfeng Lin wrote:

Hello all:

Is there a way to set up R such that, when you have a very long output
from a command, it will pause when it has displayed one-screen of
information and ask me to press a button to continue displaying? I
happen to have one such command and the information I need is at the
top of the output - and it's just nowhere to be seen.

(If you are familiar with Stata, I'm looking for something equivalent
to the -set more on- option there.

Thanks a lot!

Mingfeng

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



--
Patrick Burns
pbu...@pburns.seanet.com
http://www.burns-stat.com
(home of 'Some hints for the R beginner'
and 'The R Inferno')

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

2010-04-22 Thread Viechtbauer Wolfgang (STAT)
A similar problem was mentioned before:

https://stat.ethz.ch/pipermail/r-sig-mixed-models/2008q3/001425.html

There appears to be a bug in the C code leading to memory corruption.

Best,

--
Wolfgang Viechtbauerhttp://www.wvbauer.com/
Department of Methodology and StatisticsTel: +31 (0)43 388-2277
School for Public Health and Primary Care   Office Location:
Maastricht University, P.O. Box 616 Room B2.01 (second floor)
6200 MD Maastricht, The Netherlands Debyeplein 1 (Randwyck)


Original Message
From: r-help-boun...@r-project.org
[mailto:r-help-boun...@r-project.org] On Behalf Of Michael Steven
Rooney Sent: Wednesday, April 21, 2010 17:41 To: r-help@r-project.org
Subject: [R] R crashing oddly

 Hi,

 I am working with the package nlme, and I tried creating a new
 correlation class (which, according to the help pages, is possible if
 you write a few new method functions). Anyways, I think I am 99% of
 the way there, but I have a recurring problem with R crashing on
 seemingly innocuous statements (I have set debug() on nearly every
 function, so I can see where it is failing).

 For instance, sometime the code fails on the simple statement:
 object[[i]] Two things are odd about this: 1. It's not the first time
 I call object[[i]] 2. If I run save() on the object just before the
 crash, open the object in a new workspace and run object[[i]], then
 no crash or error occurs.

 [[ is not the only function that has been giving me grief. Certain
 C routines that get called multiple time have displayed very similar
 behavior (ie. they work fine several times before they crash, and if
 the object is exported just before the crash and the routine is
 called in a new workspace there is no error).

 The behavior kind of reminds me of the craziness that occur with an
 uninitialized pointer (thinking back to coding in C in college). The
 other thing that points me in that direction is that Windows returns
 an error code ending ...5, which I believe indicates a
 segmentation fault. I was also wondering whether there might be some
 rogue global variable, but I have no idea what.

 I have struggling with this for a week. Does anyone have any insights
 on what might be wrong or what I might try?

 Thanks so much,
 Mike

   [[alternative HTML version deleted]]

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

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


Re: [R] Huge data sets and RAM problems

2010-04-22 Thread Stella Pachidi
Dear all,

Thank you very much for your replies and help. I will try to work with
your suggestions and come back to you if I need something more.

Kind regards,
Stella Pachidi

On Thu, Apr 22, 2010 at 5:30 AM, kMan kchambe...@gmail.com wrote:
 You set records to NULL perhaps (delete, shift up). Perhaps your system is
 susceptible to butterflies on the other side of the world.

 Your code may have 'worked' on a small section of data, but the data used
 did not include all of the cases needed to fully test your code. So... test
 your code!

 scan(), used with 'nlines', 'skip', 'sep', and 'what' will cut your read
 time by at least half while taking less RAM memory to do it, do most of your
 post processing, and give you something to better test your code. Or, don't
 use 'nlines' and lose your time/memory benefits over read.table(). 'skip'
 will get you right to the point before where things failed. That would be
 an interesting small segment of data to test with.

 wordpad can read your file (and then some). Eventually.

 Sincerely,
 KeithC.

 -Original Message-
 From: Stella Pachidi [mailto:stella.pach...@gmail.com]
 Sent: Monday, April 19, 2010 2:07 PM
 To: r-h...@stat.math.ethz.ch
 Subject: [R] Huge data sets and RAM problems

 Dear all,

 This is the first time I am sending mail to the mailing list, so I hope I do
 not make a mistake...

 The last months I have been working on my MSc thesis project on performing
 data mining techniques on user logs of a software-as-a-service application.
 The main problem  I am experiencing is how to process the huge amount of
 data. More specifically:

 I am using R 2.10.1 in a laptop with Windows 7 - 32bit system, 2GB RAM and
 CPU Intel Core Duo 2GHz.

 The user logs data come from a query Crystal report (.rpt file) which I
 transform with some Java code into a tab separated file.

 Although with a small subset of my data everything manages to run, when I
 increase the data set I get several problems:

 The first problem is with the use of read.delim(). When  I try to read a big
 amount of data  (over 2.400.000 rows and 18 attributes at each
 row) it doesn't seem to transform all table into a data frame. In
 particular, the data frame returned has 1.220.987 rows.

 Furthermore, as one of the data attributes is DataTime, when I try to split
 this column into two columns (one with Data and one with the Time), the
 returned result is quite strange, as the two new columns appear to have more
 rows than the data frame:

 applicLog.dat - read.delim(file.txt)
 #Process the syscreated column (Date time -- Date + time) copyDate -
 applicLog.dat[[ï..syscreated]] copyDate - as.character(copyDate)
 splitDate - strsplit(copyDate,  ) splitDate - unlist(splitDate)
 splitDateIndex - c(1:length(splitDate)) sysCreatedDate -
 splitDate[splitDateIndex %% 2 == 1] sysCreatedTime -
 splitDate[splitDateIndex %% 2 == 0] sysCreatedDate -
 strptime(sysCreatedDate, format=%Y-%m-%d) op - options(digits.secs = 3)
 sysCreatedTime - strptime(sysCreatedTime, format =%H:%M:%OS)
 applicLog.dat[[ï..syscreated]] - NULL applicLog.dat - cbind
 (sysCreatedDate,sysCreatedTime,applicLog.dat)

 Then I get the error: Error in data.frame(..., check.names = FALSE) :
  arguments imply differing number of rows: 1221063, 1221062, 1220987


 Finally, another problem I have is when I perform association mining on the
 data set using the package arules: I turn the data frame into transactions
 table and then run the apriori algorithm. When I put too low support in
 order to manage to find the rules I need, the vector of rules becomes too
 big and I get problems with the memory such as:
 Error: cannot allocate vector of size 923.1 Mb In addition: Warning
 messages:
 1: In items(x) : Reached total allocation of 153Mb: see help(memory.size)

 Could you please help me with how I could allocate more RAM? Or, do you
 think there is a way to process the data by loading them into a document
 instead of loading all into RAM? Do you know how I could manage to read all
 my data set?

 I would really appreciate your help.

 Kind regards,
 Stella Pachidi

 PS: Do you know any text editor that can read huge .txt files?





 --
 Stella Pachidi
 Master in Business Informatics student
 Utrecht University







-- 
Stella Pachidi
Master in Business Informatics student
Utrecht University
email: s.pach...@students.uu.nl
tel: +31644478898

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

2010-04-22 Thread jim holtman
?strptime

Read the documentation and you will find reference to %OSn

 x - strptime('13:45:34.123', format=%H:%M:%OS)
 x
[1] 2010-04-22 13:45:34
 format(x, format=%H:%M:%OS3)
[1] 13:45:34.123



On Thu, Apr 22, 2010 at 2:58 AM, Carol Gao carol.g...@gmail.com wrote:

 Hi,

 Does anyone know how to take a time difference when the format of the time
 is as 13:22:23.586? I am trying to take the difference of time between
 stock
 transactions and need to keep the three decimal places for seconds. I have
 tried *diff(strptime(x, %H:%M:%S.000))*, but apperantly that doesn't work.

 Carol Gao

[[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.htmlhttp://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] time series' year not recognized

2010-04-22 Thread Sara Szeremeta
I am working with time series and I have encountered a problem with R not
recognizing a series properly. I can do the tests and fitting, but when I
want to decompose the series I got a message:

d-decompose(data)
Error in decompose(dane) : time series has no or less than 2 periods

Maybe I have made a mistake in defining the TS? However, when I input
time(data), R correctly recognizes which value corresponds to which year.
I give the code for data formating below:

library(urca)
data(npext)
x-npext[c(year,unemploy)]  #Nelson  Plosser extended data set
x-c(na.omit(npext$unemploy))   #getting rid of NA's for initial years from
the data set
data-ts(x, start=1890, frequency=1)

Thanks.

[[alternative HTML version deleted]]

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


[R] Convert character string to top levels + NAN

2010-04-22 Thread Michael Haenlein
Dear all,

I have several character strings with a high number of different levels.
unique(x) gives me values in the range of 100-200.
This creates problems as I would like to use them as predictors in a coxph
model.

I therefore would like to convert each of these strings to a new string
(x_new).
x_new should be equal to x for the top n categories (i.e. the top n levels
with the highest occurrence) and NAN elsewhere.
For example, for n=3 x_new would have three levels: The three most common
levels of x + NAN.

Is there some convenient way of doing this?

Thanks in advance,

Michael


Michael Haenlein
Associate Professor of Marketing
ESCP Europe
Paris, France

[[alternative HTML version deleted]]

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


[R] R 2.11.0 is released

2010-04-22 Thread Peter Dalgaard
I've rolled up R-2.11.0.tar.gz a short while ago. This is a development
release which contains a number of new features.

Also, a number of mostly minor bugs have been fixed. See the full list
of changes below.

NOTE: The build platform has been changed for this release. Please watch out 
extra carefully for anomalies.

You can get it from

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

or wait for it to be mirrored at a CRAN site nearer to you.

Binaries for various platforms will appear in due course.

   For the R Core Team

   Peter Dalgaard

These are the md5sums for the freshly created files, in case you wish
to check that they are uncorrupted:

MD5 (AUTHORS) = ac9746b4845ae81f51cfc99262f5
MD5 (COPYING) = eb723b61539feef013de476e68b5c50a
MD5 (COPYING.LIB) = a6f89e2100d9b6cdffcea4f398e37343
MD5 (FAQ) = 5b653442bedab476a4eff7468192fb5f
MD5 (INSTALL) = 70447ae7f2c35233d3065b004aa4f331
MD5 (NEWS) = 59017734fb8474f98f994c7a5a27f9fb
MD5 (ONEWS) = a8c985af5ad5e9c7e0a9f502d07baeb4
MD5 (OONEWS) = 4f004de59e24a52d0f500063b4603bcb
MD5 (R-latest.tar.gz) = c6c1e866299f533617750889c729bfb3
MD5 (README) = 433182754c05c2cf7a04ad0da474a1d0
MD5 (RESOURCES) = 020479f381d5f9038dcb18708997f5da
MD5 (THANKS) = f2ccf22f3e20ebaa86f8ee5cc6b0f655
MD5 (R-2/R-2.11.0.tar.gz) = c6c1e866299f533617750889c729bfb3

This is the relevant part of the NEWS file:

CHANGES IN R VERSION 2.11.0


SIGNIFICANT USER-VISIBLE CHANGES

o   Packages must have been installed under R = 2.10.0, as the
current help system is the only one now supported.

o   A port to 64-bit Windows is now available as well as binary
package repositiories: see the 'R Administration and
Installation Manual'.

o   Argument matching for primitive functions is now done in the
same way as for interpreted functions except for the deliberate
exceptions

call switch .C .Fortran .Call .External

all of which use positional matching for their first argument,
and also some internal-use-only primitives.

o   The default device for command-line R at the console on Mac OS X
is now quartz() and not X11().


NEW FEATURES

o   The 'open' modes for connections are now interpreted more
consistently.  open = r is now equivalent to open = rt for
all connections.  The default open =  now means rt for all
connections except the compressed file connections gzfile(),
bzfile() and xzfile() for which it means rb.

o   R CMD INSTALL now uses the internal untar() in package utils:
this ensures that all platforms can install bzip2- and
xz-compressed tarballs.  In case this causes problems (as it
has on some Windows file systems when run from Cygwin tools)
it can be overridden by the environment variable
R_INSTALL_TAR: setting this to a modern external tar program
will speed up unpacking of large (tens of Mb or more)
tarballs.

o   help(try.all.packages = TRUE) is much faster (although the
time taken by the OS to find all the packages the first time
it is used can dominate the time).

o   R CMD check has a new option '--timings' to record
per-example timings in file pkg.Rcheck/pkg-Ex.timings.

o   The TRE library has been updated to version 0.8.0 (minor bugfixes).

o   grep[l], [g]sub and [g]regexpr now work in bytes in an 8-bit
locales if there is no marked UTF-8 input string: this will be
somewhat faster, and for [g]sub() give the result in the
native encoding rather than in UTF-8 (which returns to the
behaviour prior to R 2.10.0).

o   A new argument 'skipCalls' has been added to browser() so that
it can report the original context when called by other
debugging functions.

o   More validity checking of UTF-8 and MBCS strings is done by
agrep() and the regular-expression matching functions.

o   The undocumented restriction on gregexpr() to length(text)  0
has been removed.

o   Package tcltk now sends strings to Tcl in UTF-8: this means
that strings with a marked UTF-8 encoding are supported in
non-UTF-8 locales.

o   The graphics engine now supports rendering of raster (bitmap)
images, though not all graphics devices can provide (full)
support.  Packages providing graphics devices (e.g., Cairo,
RSvgDevice, cairoDevice) will need to be reinstalled.

There is also support in the graphics engine for capturing
raster images from graphics devices (again not supported
on all graphics devices).

o   R CMD check now also checks if the package and namespace can
be unloaded: this provides a check of the .Last.lib() and
.onUnload() hook functions (unless --install=fake).

o   prop.table(x) now accepts a one-dimensional table for x.

o   A new function vapply() has been 

Re: [R] time difference

2010-04-22 Thread Stefan
Carol Gao carol.gaox at gmail.com writes:

 
 Hi,
 
 Does anyone know how to take a time difference when the format of the time
 is as 13:22:23.586? I am trying to take the difference of time between stock
 transactions and need to keep the three decimal places for seconds. I have
 tried *diff(strptime(x, %H:%M:%S.000))*, but apperantly that doesn't work.
 
 Carol Gao
 
   [[alternative HTML version deleted]]
 
 



I found this:
http://tolstoy.newcastle.edu.au/R/e6/help/09/05/15738.html

It seems to me that this is partly an options issue. Maybe this is something to
work with:

options(digits.secs=3)
strptime(x, %H:%M:%S%OS)

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

2010-04-22 Thread Simon Goodman

Thanks for the suggestions Unfortunately contour won't in this case as it
expects the x,y values to be in an ascending sequence.

 

-- 
View this message in context: 
http://r.789695.n4.nabble.com/overlaying-a-levelplot-on-a-map-plot-tp2019419p2020292.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] R2.11.0 - rasterImage() and barplot fill-patterns

2010-04-22 Thread Tal Galili
Hello Peter,
Thank you, and the R core team, for the new release.


I see that in R 2.11.0 there is now support for rendering of raster (bitmap)
images through rasterImage().

I am wondering - can this be used to create a texture/fill-pattern for
hist()/barplot()  ?
(A request made several times throughout the years on the mailing list.
For example:
http://osdir.com/ml/lang.r.general/2005-07/msg00799.html
)

(I am also sending this e-mail to the maintainers of lattice, ggplot2 and
gplots in the hope for more perspectives)

With much respect,
Tal








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




On Thu, Apr 22, 2010 at 12:01 PM, Peter Dalgaard pd@cbs.dk wrote:

 I've rolled up R-2.11.0.tar.gz a short while ago. This is a development
 release which contains a number of new features.

 Also, a number of mostly minor bugs have been fixed. See the full list
 of changes below.

 NOTE: The build platform has been changed for this release. Please watch
 out extra carefully for anomalies.

 You can get it from

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

 or wait for it to be mirrored at a CRAN site nearer to you.

 Binaries for various platforms will appear in due course.

   For the R Core Team

   Peter Dalgaard

 These are the md5sums for the freshly created files, in case you wish
 to check that they are uncorrupted:

 MD5 (AUTHORS) = ac9746b4845ae81f51cfc99262f5
 MD5 (COPYING) = eb723b61539feef013de476e68b5c50a
 MD5 (COPYING.LIB) = a6f89e2100d9b6cdffcea4f398e37343
 MD5 (FAQ) = 5b653442bedab476a4eff7468192fb5f
 MD5 (INSTALL) = 70447ae7f2c35233d3065b004aa4f331
 MD5 (NEWS) = 59017734fb8474f98f994c7a5a27f9fb
 MD5 (ONEWS) = a8c985af5ad5e9c7e0a9f502d07baeb4
 MD5 (OONEWS) = 4f004de59e24a52d0f500063b4603bcb
 MD5 (R-latest.tar.gz) = c6c1e866299f533617750889c729bfb3
 MD5 (README) = 433182754c05c2cf7a04ad0da474a1d0
 MD5 (RESOURCES) = 020479f381d5f9038dcb18708997f5da
 MD5 (THANKS) = f2ccf22f3e20ebaa86f8ee5cc6b0f655
 MD5 (R-2/R-2.11.0.tar.gz) = c6c1e866299f533617750889c729bfb3

 This is the relevant part of the NEWS file:

CHANGES IN R VERSION 2.11.0


 SIGNIFICANT USER-VISIBLE CHANGES

o   Packages must have been installed under R = 2.10.0, as the
current help system is the only one now supported.

o   A port to 64-bit Windows is now available as well as binary
package repositiories: see the 'R Administration and
Installation Manual'.

o   Argument matching for primitive functions is now done in the
same way as for interpreted functions except for the deliberate
exceptions

call switch .C .Fortran .Call .External

all of which use positional matching for their first argument,
and also some internal-use-only primitives.

o   The default device for command-line R at the console on Mac OS X
is now quartz() and not X11().


 NEW FEATURES

o   The 'open' modes for connections are now interpreted more
consistently.  open = r is now equivalent to open = rt for
all connections.  The default open =  now means rt for all
connections except the compressed file connections gzfile(),
bzfile() and xzfile() for which it means rb.

o   R CMD INSTALL now uses the internal untar() in package utils:
this ensures that all platforms can install bzip2- and
xz-compressed tarballs.  In case this causes problems (as it
has on some Windows file systems when run from Cygwin tools)
it can be overridden by the environment variable
R_INSTALL_TAR: setting this to a modern external tar program
will speed up unpacking of large (tens of Mb or more)
tarballs.

o   help(try.all.packages = TRUE) is much faster (although the
time taken by the OS to find all the packages the first time
it is used can dominate the time).

o   R CMD check has a new option '--timings' to record
per-example timings in file pkg.Rcheck/pkg-Ex.timings.

o   The TRE library has been updated to version 0.8.0 (minor bugfixes).

o   grep[l], [g]sub and [g]regexpr now work in bytes in an 8-bit
locales if there is no marked UTF-8 input string: this will be
somewhat faster, and for [g]sub() give the result in the
native encoding rather than in UTF-8 (which returns to the
behaviour prior to R 2.10.0).

o   A new argument 'skipCalls' has been added to browser() so that
it can report the original context when called by other
debugging functions.

o   More validity checking of UTF-8 and MBCS strings is done by
agrep() and the regular-expression matching functions.

   

[R] install or uncompress package build in one platform in another platform

2010-04-22 Thread carol white
Hi,
Is an R package built under Unix (package.tar.gz) could be installed on other 
platforms like windows or Mac? The compressed tar file (.tar.gz) built under 
Unix doesn't seem to be uncompressed under windows (unzip under windows instead 
of gunzip). How to proceed?

Look forward to your reply,

Carol

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

2010-04-22 Thread Ronaldo Reis Junior
Hi,

I try to create a data.frame from results of a tapply.

I have this results from tapply:
--
, , tapinom sp 1

1  2  3  4  5  6  7  8  9 10
1 NA NA NA NA NA NA NA NA NA NA
4 NA NA NA NA NA NA NA NA NA  4
5 NA NA NA NA NA NA NA NA NA NA
6 NA NA NA NA NA NA NA NA NA NA
7 NA NA NA NA NA NA NA NA NA NA

, , wasm sp 2

1  2  3  4  5  6  7  8  9 10
1  1 NA NA NA NA NA NA NA NA NA
4  4 NA NA NA NA NA NA NA NA NA
5 NA NA NA NA NA NA NA NA NA NA
6 NA NA NA NA NA NA NA NA NA NA
7  7 NA  7  7  7  7 NA NA  7  7


I try to enter in tapply result to make a vector for each name, like this:

tapinom sp 1
NA
NA
NA
NA
NA
NA
NA
NA
NA
NA
NA
NA
NA
NA
NA
NA
NA
NA
NA
4
NA
NA
NA
NA
NA
NA
NA
NA
NA
NA
NA
NA
NA
NA
NA
NA
NA
NA
NA
NA
NA
NA
NA
NA
NA
NA
NA
NA
NA
NA

The problem is how a access the tapply results? I try using names, but 
it have no names, I try using [] but without sucess.

Thanks
Ronaldo

-- 

  Prof. Ronaldo Reis Júnior
|  .''`. UNIMONTES/DBG/Lab. Ecologia Comportamental e Computacional
| : :'  : Campus Universitário Prof. Darcy Ribeiro, Vila Mauricéia
| `. `'` CP: 126, CEP: 39401-089, Montes Claros - MG - Brasil
|   `- Fone: (38) 3229-8192 | ronaldo.r...@unimontes.br
| http://www.ppgcb.unimontes.br/lecc | LinuxUser#: 205366


[[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] Convert character string to top levels + NAN

2010-04-22 Thread David Winsemius


On Apr 22, 2010, at 5:16 AM, Michael Haenlein wrote:


Dear all,

I have several character strings with a high number of different  
levels.

unique(x) gives me values in the range of 100-200.
This creates problems as I would like to use them as predictors in a  
coxph

model.

I therefore would like to convert each of these strings to a new  
string

(x_new).
x_new should be equal to x for the top n categories (i.e. the top n  
levels

with the highest occurrence) and NAN elsewhere.
For example, for n=3 x_new would have three levels: The three most  
common

levels of x + NAN.

Is there some convenient way of doing this?


 x - sample(c(top, three, levels, 0ther, strings), 30,
 replace=TRUE, prob=c(.3,.3,.3,.1,.1))
 y - c(top, three, levels)
 xnew - x
 xnew[ !xnew %in% y ] - NAN  # not same as NaN
 table(xnew)

#
xnew
levelsNAN  threetop
 5  5  9 11

--
David.



Thanks in advance,

Michael


Michael Haenlein
Associate Professor of Marketing
ESCP Europe
Paris, France

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


David Winsemius, MD
West Hartford, CT

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


Re: [R] Help with tapply selection

2010-04-22 Thread Henrique Dallazuanna
Try this:

as.vector(tapply(...))

On Thu, Apr 22, 2010 at 9:47 AM, Ronaldo Reis Junior chrys...@gmail.comwrote:

 Hi,

 I try to create a data.frame from results of a tapply.

 I have this results from tapply:
 --
 , , tapinom sp 1

1  2  3  4  5  6  7  8  9 10
 1 NA NA NA NA NA NA NA NA NA NA
 4 NA NA NA NA NA NA NA NA NA  4
 5 NA NA NA NA NA NA NA NA NA NA
 6 NA NA NA NA NA NA NA NA NA NA
 7 NA NA NA NA NA NA NA NA NA NA

 , , wasm sp 2

1  2  3  4  5  6  7  8  9 10
 1  1 NA NA NA NA NA NA NA NA NA
 4  4 NA NA NA NA NA NA NA NA NA
 5 NA NA NA NA NA NA NA NA NA NA
 6 NA NA NA NA NA NA NA NA NA NA
 7  7 NA  7  7  7  7 NA NA  7  7
 

 I try to enter in tapply result to make a vector for each name, like this:

 tapinom sp 1
 NA
 NA
 NA
 NA
 NA
 NA
 NA
 NA
 NA
 NA
 NA
 NA
 NA
 NA
 NA
 NA
 NA
 NA
 NA
 4
 NA
 NA
 NA
 NA
 NA
 NA
 NA
 NA
 NA
 NA
 NA
 NA
 NA
 NA
 NA
 NA
 NA
 NA
 NA
 NA
 NA
 NA
 NA
 NA
 NA
 NA
 NA
 NA
 NA
 NA

 The problem is how a access the tapply results? I try using names, but
 it have no names, I try using [] but without sucess.

 Thanks
 Ronaldo

 --

   Prof. Ronaldo Reis Júnior
 |  .''`. UNIMONTES/DBG/Lab. Ecologia Comportamental e Computacional
 | : :'  : Campus Universitário Prof. Darcy Ribeiro, Vila Mauricéia
 | `. `'` CP: 126, CEP: 39401-089, Montes Claros - MG - Brasil
 |   `- Fone: (38) 3229-8192 | ronaldo.r...@unimontes.br
 | http://www.ppgcb.unimontes.br/lecc | LinuxUser#: 205366


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




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

[[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] question on rpart

2010-04-22 Thread Terry Therneau
--- Begin included message

I have attempted to email the author of this package without success,
just wondering if anybody else has experienced this.

I am having an using rpart on 4000 rows of data with 13 attributes.
I can run the same test on 300 rows of the same data with no issue.
When I run on 4000 rows, Rgui.exe runs consistently at 50% cpu and the
UI hangs it will stay like this for at least 4-5hours if I let it
run, and never exit or become responsive.

here is the code I am using both on the 300 and 4000 size subset :

train-read.csv(input.csv,header=T)
y-train[,18]
x-train[,3:17]
library(rpart)
fit-rpart(y~.,x)

Is this a known limitation of rpart, am I doing something wrong?
potential workarounds?

-

 I don't remember seeing a message from you.  If I accidentally deleted
one along with the daily junk mail I apologize.
  I run rpart on larger problems than this without issue.  I'd have to
see the data; perchance you have found a never-before-seen infinite
loop.  
  Terry Therneau

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 or uncompress package build in one platform in another platform

2010-04-22 Thread David Winsemius


On Apr 22, 2010, at 8:09 AM, carol white wrote:


Hi,
Is an R package built under Unix (package.tar.gz) could be installed  
on other platforms like windows or Mac? The compressed tar file  
(.tar.gz) built under Unix doesn't seem to be uncompressed under  
windows (unzip under windows instead of gunzip). How to proceed?




If it has only R code then on a Mac the Archive Utility.app would  
decompress a tar.gz file and give you a package folder that you could  
put into the appropriate location in your Library. If it has compiled  
code then no, forget it. There must be ways to ungzip and untar files  
in Windows.


--

David Winsemius, MD
West Hartford, CT

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


Re: [R] overlaying a levelplot on a map plot

2010-04-22 Thread David Winsemius


On Apr 22, 2010, at 5:33 AM, Simon Goodman wrote:



Thanks for the suggestions Unfortunately contour won't in this  
case as it

expects the x,y values to be in an ascending sequence.


?order





David Winsemius, MD
West Hartford, CT

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


[R] Compare two data frames

2010-04-22 Thread Doran, Harold
I wonder if there is a more efficient way to do this task. Suppose I have two 
data frames, such as

d1 - data.frame(x = c(1,2,3), y = c(4,5,6), z = c(7,8,9))

d2 - d1[, c('y', 'x')]

The first dataframe d1 has more variables than d2 and the variable columns are 
in a different order.

So, what I want to do is compare the two frames on the variables that are 
common between the two. First I find the common variables between the two 
dataframes

common_order - intersect(colnames(d1), colnames(d2))

Then, I have to put the variables in d2 in the same order as d1 as

d2 - d2[, common_order]

Then, I keep only the variables in common between d1 and d2 as

d1 - d1[, common_order]

Then, finally I can do the compare on the common variables now in the same 
order.

all.equal(d1, d2)

None of this is horribly difficult, but it requires a couple of steps that I am 
wondering might be eliminated. 

Harold

 sessionInfo()
R version 2.10.1 (2009-12-14) 
i386-pc-mingw32 

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252  
  LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C   LC_TIME=English_United States.1252   
 

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

other attached packages:
[1] MiscPsycho_1.6 statmod_1.4.6 

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

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


Re: [R] How to stamp my graphs with date and time

2010-04-22 Thread Kevin Wright
Jun,

I created a function called pageNum that does exactly what you want for
both 'base' and 'lattice' graphics.  You can find it here:
http://ryouready.wordpress.com/2009/02/17/r-good-practice-adding-footnotes-to-graphics/

Kevin


On Wed, Apr 21, 2010 at 7:23 PM, Jun Shen jun.shen...@gmail.com wrote:

 David, Duncan,

 Thanks. I didn't realize the functions in graphic also work in lattice.
 I thought they didn't work with each other.

 Jun


 On Wed, Apr 21, 2010 at 6:51 PM, Duncan Murdoch murdoch.dun...@gmail.com
 wrote:

  On 21/04/2010 5:41 PM, Jun Shen wrote:
 
  Dear all,
 
  How do stamp my graphs with date and time somewhere like left corner of
  the
  graph (not the plotting area). I know date() and Sys.time(), but where
 to?
  Thanks.
 
  Use mtext() to put text onto a plot.  For example,
 
  plot(1)
  mtext(Sys.time(), side=1, line=4, at=par(usr)[1])
 
  (You will need to play with the side=, line= and at= specifications to
 get
  the location you want.)
 
  Duncan Murdoch
 

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




-- 
Kevin Wright

[[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] R2.11.0 - rasterImage() and barplot fill-patterns

2010-04-22 Thread baptiste auguie
Hi,

This idea was also discussed when Paul Murrell first announced the
grid.raster function to R-devel,
http://tolstoy.newcastle.edu.au/R/e8/devel/09/12/0912.html

My personal conclusion was that vector fill patterns are generally
better in terms of resolution and speed. Of course the situation might
be different if one wanted to use a fancy image pattern, or if there
was a fast implementation of tiling patterns at the C level.

I wrote a proof-of-concept here --- my main issue is that the
resulting grob is not vectorized,

http://gridextra.googlecode.com/svn/trunk/inst/comparisonPattern.r

Best,

baptiste


On 22 April 2010 14:10, Tal Galili tal.gal...@gmail.com wrote:
 Hello Peter,
 Thank you, and the R core team, for the new release.


 I see that in R 2.11.0 there is now support for rendering of raster (bitmap)
 images through rasterImage().

 I am wondering - can this be used to create a texture/fill-pattern for
 hist()/barplot()  ?
 (A request made several times throughout the years on the mailing list.
 For example:
 http://osdir.com/ml/lang.r.general/2005-07/msg00799.html
 )

 (I am also sending this e-mail to the maintainers of lattice, ggplot2 and
 gplots in the hope for more perspectives)

 With much respect,
 Tal








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




 On Thu, Apr 22, 2010 at 12:01 PM, Peter Dalgaard pd@cbs.dk wrote:

 I've rolled up R-2.11.0.tar.gz a short while ago. This is a development
 release which contains a number of new features.

 Also, a number of mostly minor bugs have been fixed. See the full list
 of changes below.

 NOTE: The build platform has been changed for this release. Please watch
 out extra carefully for anomalies.

 You can get it from

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

 or wait for it to be mirrored at a CRAN site nearer to you.

 Binaries for various platforms will appear in due course.

       For the R Core Team

       Peter Dalgaard

 These are the md5sums for the freshly created files, in case you wish
 to check that they are uncorrupted:

 MD5 (AUTHORS) = ac9746b4845ae81f51cfc99262f5
 MD5 (COPYING) = eb723b61539feef013de476e68b5c50a
 MD5 (COPYING.LIB) = a6f89e2100d9b6cdffcea4f398e37343
 MD5 (FAQ) = 5b653442bedab476a4eff7468192fb5f
 MD5 (INSTALL) = 70447ae7f2c35233d3065b004aa4f331
 MD5 (NEWS) = 59017734fb8474f98f994c7a5a27f9fb
 MD5 (ONEWS) = a8c985af5ad5e9c7e0a9f502d07baeb4
 MD5 (OONEWS) = 4f004de59e24a52d0f500063b4603bcb
 MD5 (R-latest.tar.gz) = c6c1e866299f533617750889c729bfb3
 MD5 (README) = 433182754c05c2cf7a04ad0da474a1d0
 MD5 (RESOURCES) = 020479f381d5f9038dcb18708997f5da
 MD5 (THANKS) = f2ccf22f3e20ebaa86f8ee5cc6b0f655
 MD5 (R-2/R-2.11.0.tar.gz) = c6c1e866299f533617750889c729bfb3

 This is the relevant part of the NEWS file:

                CHANGES IN R VERSION 2.11.0


 SIGNIFICANT USER-VISIBLE CHANGES

    o   Packages must have been installed under R = 2.10.0, as the
        current help system is the only one now supported.

    o   A port to 64-bit Windows is now available as well as binary
        package repositiories: see the 'R Administration and
        Installation Manual'.

    o   Argument matching for primitive functions is now done in the
        same way as for interpreted functions except for the deliberate
        exceptions

            call switch .C .Fortran .Call .External

        all of which use positional matching for their first argument,
        and also some internal-use-only primitives.

    o   The default device for command-line R at the console on Mac OS X
        is now quartz() and not X11().


 NEW FEATURES

    o   The 'open' modes for connections are now interpreted more
        consistently.  open = r is now equivalent to open = rt for
        all connections.  The default open =  now means rt for all
        connections except the compressed file connections gzfile(),
        bzfile() and xzfile() for which it means rb.

    o   R CMD INSTALL now uses the internal untar() in package utils:
        this ensures that all platforms can install bzip2- and
        xz-compressed tarballs.  In case this causes problems (as it
        has on some Windows file systems when run from Cygwin tools)
        it can be overridden by the environment variable
        R_INSTALL_TAR: setting this to a modern external tar program
        will speed up unpacking of large (tens of Mb or more)
        tarballs.

    o   help(try.all.packages = TRUE) is much faster (although the
        time taken by the OS to find all the packages the first time
        it is used can dominate the time).

    o   R CMD check has a new option '--timings' to record
        per-example timings in file 

Re: [R] Compare two data frames

2010-04-22 Thread David Winsemius


On Apr 22, 2010, at 9:41 AM, Doran, Harold wrote:

I wonder if there is a more efficient way to do this task. Suppose I  
have two data frames, such as


d1 - data.frame(x = c(1,2,3), y = c(4,5,6), z = c(7,8,9))

d2 - d1[, c('y', 'x')]

The first dataframe d1 has more variables than d2 and the variable  
columns are in a different order. So, what I want to do is compare  
the two frames on the variables that are common between the two.  
First I find the common variables between the two dataframes


common_order - intersect(colnames(d1), colnames(d2))

Then, I have to put the variables in d2 in the same order as d1 as

d2 - d2[, common_order]

Then, I keep only the variables in common between d1 and d2 as

d1 - d1[, common_order]

Then, finally I can do the compare on the common variables now in  
the same order.


all.equal(d1, d2)

None of this is horribly difficult, but it requires a couple of  
steps that I am wondering might be eliminated.


What you are doing sounds a lot like the operations that merge()  
implements in one function.


--
David.


Harold



David Winsemius, MD
West Hartford, CT

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


Re: [R] install or uncompress package build in one platform in another platform

2010-04-22 Thread Uwe Ligges



On 22.04.2010 15:34, David Winsemius wrote:


On Apr 22, 2010, at 8:09 AM, carol white wrote:


Hi,
Is an R package built under Unix (package.tar.gz) could be installed
on other platforms like windows or Mac? The compressed tar file
(.tar.gz) built under Unix doesn't seem to be uncompressed under
windows (unzip under windows instead of gunzip). How to proceed?



If it has only R code then on a Mac the Archive Utility.app would
decompress a tar.gz file and give you a package folder that you could
put into the appropriate location in your Library. If it has compiled
code then no, forget it. There must be ways to ungzip and untar files in
Windows.



For more details see the R Installation and Administration manual that 
tells you how to install source packages under Mac aas well as under 
Windows.


Uwe Ligges

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 or uncompress package build in one platform in another platform

2010-04-22 Thread Duncan Murdoch

On 22/04/2010 8:09 AM, carol white wrote:

Hi,
Is an R package built under Unix (package.tar.gz) could be installed on other 
platforms like windows or Mac? The compressed tar file (.tar.gz) built under 
Unix doesn't seem to be uncompressed under windows (unzip under windows instead 
of gunzip). How to proceed?


Use either R CMD INSTALL foo.tar.gz at the cmd prompt, or from within 
R, install.packages(foo.tar.gz, repos=NULL, type=source).  R knows 
how to do the decompression.


If the package contains external code, this requires that you have the 
tools set up to compile it; see www.murdoch-sutherland.com/Rtools to get 
them for Windows.  Most Windows users find it tricky to get the setup 
right at first, which is why we provide binaries for CRAN packages, and 
why Uwe provides the http://win-builder.r-project.org/ service.  Simon 
Urbanek has a web page to provide the tools for the Mac.


Duncan Murdoch

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


Re: [R] densCols: what are the computed densities and how to create a legend

2010-04-22 Thread Florian Hahne
Hi Kate,
the function does not directly return the calculated density values, however 
those can be recomputed through the internal function .smoothScatterCalcDensity
This function is not exported from the grDevices name space, so you need to use 
the full qualifier:

dat - cbind(rnorm(100), rnorm(100))
dc - densCols(dat)
dd - grDevices:::.smoothScatterCalcDensity(dat, nbin=128)

Densities are computed using a binning approach, and the grid of densities is 
available as the list item fhat. In order to map those to colors we need to 
find the absolute range of density values:
dens - as.numeric(dd$fhat)
dens - dens[dens0]
range(dens)

And now we can construct a mapping of values to colors:
colLegend - data.frame(density=seq(min(dens), max(dens), len=10), 
color=I(colorRampPalette(blues9[-(1:3)])(10)))

For plotting of a legend, you could try something like this:
plot(NA, xlim=c(0,10), ylim=c(0,11), type=n, ann=FALSE, axes=FALSE)
rect(0, 1:10, 1, 2:11, border=NA, col=colLegend$col)
text(2, (1:10)+0.5, signif(colLegend$density, 2))

And to get everything in one plot, something like this:
layout(matrix(rep(1:2, c(5,1)), nrow=1))
plot(dat, col=dc, pch=20)
par(mar=c(5,0,5,0))
plot(NA, xlim=c(0,10), ylim=c(0,11), type=n, ann=FALSE, axes=FALSE)
rect(0, 1:10, 1, 2:11, border=NA, col=colLegend$col)
text(2, (1:10)+0.5, signif(colLegend$density, 2), adj=0)

Please note that there might be some slight rounding errors here, since the 
colors for densCols are computed on a subset of bins (those in which the data 
points fall).  The bandwidth smoothing results in non-zero density values for 
neighboring bins, and since we map our colors to the overall range of 
densities, we can end up being slightly off. If you want this to be 100% 
accurate, you have to figure out the densities for the filled bins only and 
map color space to that, in which case you essentially reproduce all that 
densCols is doing (type densCols in your R session to see the source code and 
copy paste what you need...)

Hope that helps. 
Florian


On Apr 20, 2010, at 4:08 PM, Kate Zinszer wrote:

 
 Hi Dr. Hahne,
 I saw that you were affiliated with this function so perhaps you have some 
 insight in my problem that is stated below?
 
 Many thanks,
 Kate
 
 
 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
 Behalf Of Kate Zinszer
 Sent: 19 avril 2010 15:21
 To: r-help@R-project.org
 Subject: [R] densCols: what are the computed densities and how to create a 
 legend
 
 Hi,
 
 I'm using the densCols function for a scatterplot and cannot figure out 1) 
 how to extract the computed densities, and 2) how to create a legend based 
 that represents the upper and lower ranges of the densities.
 
 For example:
 
 movers.den  - densCols(move$x, move$y)
 table(movers.den)
 #08306B #083775 #083B7C #083D7E #3989C1 #3F8FC4 
 28 22 101 25 4  5 
 #4392C6 #65AAD3 #69ACD5 #6CAED6 #77B4D8 #98C6DF 
 14   684  3   9 
 plot(move, col=movers.den, pch=20,ylab=y coordinate movement 
 (meters),xlab=x coordinate movement (meters))
 abline(h=0, v=0, col = grey, lty=2)
 #legend??
 
 Any help would be appreciated!
 Kate
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Jonckheere-Terpstra test using coin package?

2010-04-22 Thread GlenB

I am unfamiliar with how to use coin, but it looks like it should be doable -
the vignette in coin.pdf does a Page test. The wikipedia page for Page's
test explains how this is related to the Jonckheere-Terpstra test, which
seems to suggest if it can do one it should be able to do the other. Add to
that the fact that coin can do the unordered version of the J-T (which is
just Kruskal-Wallis) and again, it seems like it should be able to do it.

-- 
View this message in context: 
http://r.789695.n4.nabble.com/Jonckheere-Terpstra-test-using-coin-package-tp2019893p2020340.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] R loop.

2010-04-22 Thread mhalsham

Thanks a lot for the help, but it’s not what I needed.  
-- 
View this message in context: 
http://r.789695.n4.nabble.com/R-loop-tp1979620p2020386.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] Amusing coincidence

2010-04-22 Thread peter dalgaard
...that this Danish movie would have an official release today:

http://www.imdb.com/title/tt1434443/

http://filmz.dk/film/r/trailers/24836

-- 
Peter Dalgaard
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd@cbs.dk  Priv: pda...@gmail.com

-- 
Peter Dalgaard
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd@cbs.dk  Priv: pda...@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.


Re: [R] compare variables and take largest value?

2010-04-22 Thread Duncan Murdoch

On 22/04/2010 11:07 AM, Vlatka Matkovic Puljic wrote:

Hi!

I have v1, v2 and v3 (data in v. ranges 1 to 4)

v1
   [1]   1   1   1   1 NaN   1   1   4   1   1   3
v2
   [1]   1   1   1   1   1   1   1   1   1   1   1
v3
   [1]   1   1   1   1   1   1   1   1   1   1   1

I want R to compare entries in v1,v2,v3 and in v4 to put largest value
(NA=0).
For example. first line v4 would be 1, but last line v4 would be 3.

What function should I use?

  


pmax.

Duncan Murdoch

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


[R] cell-based high-throughput chemical compound screens package?

2010-04-22 Thread Zoppoli, Gabriele (NIH/NCI) [G]
Hi 

I'm looking for a package to perform quality control, normalization and 
analysis of high throughput cell-base chemical screens. I know that the 
cellHTS2 package provides this for siRNA screens.

Does anybody know if something like what I'm looking for exists?

Thank you!
 

Gabriele Zoppoli, MD
Ph.D. Fellow, Experimental and Clinical Oncology and Hematology, University of 
Genova, Genova, Italy
Guest Researcher, LMP, NCI, NIH, Bethesda MD

Work: 301-451-8575
Mobile: 301-204-5642
Email: zoppo...@mail.nih.gov
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] compare variables and take largest value?

2010-04-22 Thread Vlatka Matkovic Puljic
Thanx a lot! That's it!

2010/4/22 Duncan Murdoch murdoch.dun...@gmail.com

 On 22/04/2010 11:07 AM, Vlatka Matkovic Puljic wrote:

 Hi!

 I have v1, v2 and v3 (data in v. ranges 1 to 4)

 v1
   [1]   1   1   1   1 NaN   1   1   4   1   1   3
 v2
   [1]   1   1   1   1   1   1   1   1   1   1   1
 v3
   [1]   1   1   1   1   1   1   1   1   1   1   1

 I want R to compare entries in v1,v2,v3 and in v4 to put largest value
 (NA=0).
 For example. first line v4 would be 1, but last line v4 would be 3.

 What function should I use?




 pmax.

 Duncan Murdoch

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




-- 
**
Vlatka Matkovic Puljic
095/8618 171

[[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] Amusing coincidence

2010-04-22 Thread Barry Rowlingson
On Thu, Apr 22, 2010 at 3:27 PM, peter dalgaard pda...@gmail.com wrote:
 ...that this Danish movie would have an official release today:

 http://www.imdb.com/title/tt1434443/

Does it have music by this composer:

 http://www.imdb.com/name/nm1731203/

 and stills photography by:

http://www.imdb.com/name/nm2083657/

?

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] using which to select range of values

2010-04-22 Thread Muhammad Rahiz

Hi all,

I would like to get the array index for a range of values, say  0  x  
1.5. I'm wondering if there is an alternative for the following which 
I've done


x0 - rnorm(100)
x1 - ifelse(x0  0  x0  1.5,t,f)
x2 - which(x1==t,arr.ind=TRUE)
x0[x2]

Thanks.

--

Muhammad

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

2010-04-22 Thread Vlatka Matkovic Puljic
Only thing that when I put  na.rm=FALSE,
R is puting in v4 NA (as is largest)
and I want to see NA as zero (0, smallest value)

2010/4/22 Vlatka Matkovic Puljic v.matkovic.pul...@gmail.com

 Thanx a lot! That's it!

 2010/4/22 Duncan Murdoch murdoch.dun...@gmail.com

 On 22/04/2010 11:07 AM, Vlatka Matkovic Puljic wrote:

 Hi!

 I have v1, v2 and v3 (data in v. ranges 1 to 4)

 v1
   [1]   1   1   1   1 NaN   1   1   4   1   1   3
 v2
   [1]   1   1   1   1   1   1   1   1   1   1   1
 v3
   [1]   1   1   1   1   1   1   1   1   1   1   1

 I want R to compare entries in v1,v2,v3 and in v4 to put largest value
 (NA=0).
 For example. first line v4 would be 1, but last line v4 would be 3.

 What function should I use?




 pmax.

 Duncan Murdoch

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




 --
 **
 Vlatka Matkovic Puljic
 095/8618 171




-- 
**
Vlatka Matkovic Puljic
095/8618 171

[[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] Amusing coincidence

2010-04-22 Thread Ted Harding
On 22-Apr-10 15:19:45, Barry Rowlingson wrote:
 On Thu, Apr 22, 2010 at 3:27 PM, peter dalgaard pda...@gmail.com
 wrote:
 ...that this Danish movie would have an official release today:

 http://www.imdb.com/title/tt1434443/
 
 Does it have music by this composer:
 
  http://www.imdb.com/name/nm1731203/
 
  and stills photography by:
 
 http://www.imdb.com/name/nm2083657/
 
 ?

Nah, it was all outsourced to http://www.imdb.com/name/nm0264036/

Ted.


E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk
Fax-to-email: +44 (0)870 094 0861
Date: 22-Apr-10   Time: 16:34:19
-- XFMail --

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


Re: [R] using which to select range of values

2010-04-22 Thread Steve Lianoglou
Hi,

On Thu, Apr 22, 2010 at 11:21 AM, Muhammad Rahiz
muhammad.ra...@ouce.ox.ac.uk wrote:
 Hi all,

 I would like to get the array index for a range of values, say  0  x  1.5.
 I'm wondering if there is an alternative for the following which I've done

 x0 - rnorm(100)
 x1 - ifelse(x0  0  x0  1.5,t,f)
 x2 - which(x1==t,arr.ind=TRUE)
 x0[x2]

Two things:

1. Not that it really matters, but why are you using arr.ind=TRUE when
x0 is just a normal vector?

2. Just skip the middle-man creation of x1:

R x0 - rnorm(100)
R x2 - which(x0  0  x0  1.5)
R x0[x2]

Why not just skip the middle man (x1)?

-- 
Steve Lianoglou
Graduate Student: Computational Systems Biology
 | Memorial Sloan-Kettering Cancer Center
 | Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact

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

2010-04-22 Thread David Winsemius


On Apr 22, 2010, at 11:39 AM, Steve Lianoglou wrote:


Hi,

On Thu, Apr 22, 2010 at 11:21 AM, Muhammad Rahiz
muhammad.ra...@ouce.ox.ac.uk wrote:

Hi all,

I would like to get the array index for a range of values, say  0   
x  1.5.
I'm wondering if there is an alternative for the following which  
I've done


x0 - rnorm(100)
x1 - ifelse(x0  0  x0  1.5,t,f)
x2 - which(x1==t,arr.ind=TRUE)
x0[x2]


Two things:

1. Not that it really matters, but why are you using arr.ind=TRUE when
x0 is just a normal vector?

2. Just skip the middle-man creation of x1:

R x0 - rnorm(100)
R x2 - which(x0  0  x0  1.5)
R x0[x2]

Why not just skip the middle man (x1)?


Or just skip all the middle-men:

x0[ which(x0  0  x0  1.5) ]

And further simplification with logical indexing:

x0[ x0  0  x0  1.5 ]

--
David.



--
Steve Lianoglou
Graduate Student: Computational Systems Biology
| Memorial Sloan-Kettering Cancer Center
| Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact

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


David Winsemius, MD
West Hartford, CT

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


Re: [R] using which to select range of values

2010-04-22 Thread David Winsemius


On Apr 22, 2010, at 11:21 AM, Muhammad Rahiz wrote:


Hi all,

I would like to get the array index for a range of values, say  0   
x  1.5. I'm wondering if there is an alternative for the following  
which I've done


x0 - rnorm(100)
x1 - ifelse(x0  0  x0  1.5,t,f)
x2 - which(x1==t,arr.ind=TRUE)


A further point. Since x1 was not an array, setting arr.ind=TRUE did  
nothing. That flag is designed to allow return of multiple dimensional  
results:


 arr - array(1:27, c(3,3,3) )
 which(arr==9)
[1] 9
 which(arr==9, arr.ind=TRUE)
 dim1 dim2 dim3
[1,]331



x0[x2]

Thanks.

--

--

David Winsemius, MD
West Hartford, CT

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


[R] macro variable in R?

2010-04-22 Thread karena

I need to create 10 matrices. say matrix 1-10.

matrix_1 is 1 by 1
matrix_2 is 2 by 2
matrix_3 is 3 by 3
   .
   .
   .
matrix_10 is 10 by 10

I am just wondering if there are some functions in R that are similar to the
macro variables in SAS. so I can create these 10 matrices by doing:
for (i in 1: 10) {
matrix_$i - matrix(nrow=i, ncol=i)
}

rather thank creating these matrices one by one manually.

Anyone have any suggestions?

thanks,

karena

-- 
View this message in context: 
http://r.789695.n4.nabble.com/macro-variable-in-R-tp2020772p2020772.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] Multicolor main title in a plot or mtext

2010-04-22 Thread Ottorino-Luca Pantani

Dear R-users, the problem I'm facing today is to write a
multicolor main title in a plot.

I would like to have 3/4 colors to help people in the
audience to visually realize what is what in a 4x2 plot array

On top of each plot I would like to have two lines.
The 1st line will indicate what is plotted
The 2nd line will indicate a a reference

Graphically speaking I would like a result similar to this (simplified) one:

par(mfrow=c(2,4))
for(aux in 1:4){
plot(1,1)
mtext(1st treatm, cex=1, line=1.7, adj=0.1, col=1)
mtext(2nd treatm, cex=1, line=1.7, adj=0.5, col=2)
mtext(3rd treatm, cex=1, line=1.7, adj=0.9, col=3)
mtext(1st treatm, line=0.6, adj=0.1, col=1)
mtext(1st treatm, line=0.6, adj=0.5, col=1)
mtext(1st treatm, line=0.6, adj=0.9, col=1)
}
for(aux in 1:4){
plot(2,2)
mtext(1st treatm, cex=1, line=1.7, adj=0.1, col=1)
mtext(2nd treatm, cex=1, line=1.7, adj=0.5, col=2)
mtext(3rd treatm, cex=1, line=1.7, adj=0.9, col=3)
mtext(2nd treatm, line=0.6, adj=0.1, col=2)
mtext(2nd treatm, line=0.6, adj=0.5, col=2)
mtext(2nd treatm, line=0.6, adj=0.9, col=2)
}


The code above does more or less what I want and
I wrote it to simplify my explanation to you all.

But what I really need is  to put on top of each plot
an entire string with color embedded into, so to say.

A sort of 1st treatm 2nd treatm 3rd treatm string with
informations able to colour the word 1st treatm in black,
the word 2nd treatm in red and so on.

I need this because I have my descriptions in a vector like

c(1st treatm 2nd treatm 3rd treatm,
 2nd treatm 3rd treatm 1st treatm,
  ...)

What I have in mind is something similar to the latex code
\color{black}{1st treatm} \color{red}{2nd treatm} \color{green}{3rd treatm}

Which pages of the R manual should I have to read to solve my problem ?

Thanks in advance
--
Ottorino-Luca Pantani, Università di Firenze
Dip.to di Scienze delle Produzioni Vegetali,
del Suolo e dell'Ambiente Forestale (DiPSA)

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

2010-04-22 Thread Mario Valle

Why don't use a list?
m - list()
for(i in 1:10) {
m[[i]] - matrix(NA, i, i)
}
then access them as m[[7]][1,6]
Ciao!
mario

On 22-Apr-10 18:08, karena wrote:


I need to create 10 matrices. say matrix 1-10.

matrix_1 is 1 by 1
matrix_2 is 2 by 2
matrix_3 is 3 by 3
.
.
.
matrix_10 is 10 by 10

I am just wondering if there are some functions in R that are similar to the
macro variables in SAS. so I can create these 10 matrices by doing:
for (i in 1: 10) {
matrix_$i- matrix(nrow=i, ncol=i)
}

rather thank creating these matrices one by one manually.

Anyone have any suggestions?

thanks,

karena



--
Ing. Mario Valle
Data Analysis and Visualization Group| 
http://www.cscs.ch/~mvalle

Swiss National Supercomputing Centre (CSCS)  | Tel:  +41 (91) 610.82.60
v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax:  +41 (91) 610.82.82

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

2010-04-22 Thread Benilton Carvalho
maybe

for (i in 1:10) assign(paste(matrix, i, sep=_), matrix(nrow=i, ncol=i))

suffices?

On Thu, Apr 22, 2010 at 5:08 PM, karena dr.jz...@gmail.com wrote:

 I need to create 10 matrices. say matrix 1-10.

 matrix_1 is 1 by 1
 matrix_2 is 2 by 2
 matrix_3 is 3 by 3
   .
   .
   .
 matrix_10 is 10 by 10

 I am just wondering if there are some functions in R that are similar to the
 macro variables in SAS. so I can create these 10 matrices by doing:
 for (i in 1: 10) {
 matrix_$i - matrix(nrow=i, ncol=i)
 }

 rather thank creating these matrices one by one manually.

 Anyone have any suggestions?

 thanks,

 karena

 --
 View this message in context: 
 http://r.789695.n4.nabble.com/macro-variable-in-R-tp2020772p2020772.html
 Sent from the R help mailing list archive at Nabble.com.

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


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


Re: [R] macro variable in R?

2010-04-22 Thread Steve Lianoglou
Hi,

On Thu, Apr 22, 2010 at 12:08 PM, karena dr.jz...@gmail.com wrote:

 I need to create 10 matrices. say matrix 1-10.

 matrix_1 is 1 by 1
 matrix_2 is 2 by 2
 matrix_3 is 3 by 3
   .
   .
   .
 matrix_10 is 10 by 10

 I am just wondering if there are some functions in R that are similar to the
 macro variables in SAS. so I can create these 10 matrices by doing:
 for (i in 1: 10) {
 matrix_$i - matrix(nrow=i, ncol=i)
 }

 rather thank creating these matrices one by one manually.

 Anyone have any suggestions?

I believe the most idiomatic R way is to make a list of length 10:

R mats - lapply(1:10, function(x) matrix(0, nrow=x, ncol=x))

Then reference them like so:

R mats[[1]]

If you *really* want them to be in your global namespace, you have two options:

1. You can slightly modify the `mat` list I made above with more
variable-friendly names and then `attach` it (or use `with`):

R names(mats) - paste(m, 1:10, sep=)
R attach(mats)
R m2
 [,1] [,2]
[1,]00
[2,]00

2. Or you could forget the `lapply` from above use `assign` in a for loop:

R for (i in 1:10) {
  assign(sprintf('mat%d', i), matrix(0, nrow=i, ncol=i))
}
R mat2
 [,1] [,2]
[1,]00
[2,]00

Other notes: using attach isn't really best practice -- look into using `with`

Documentation you should read:

?lapply
?attach
?with
?assign

-steve

-- 
Steve Lianoglou
Graduate Student: Computational Systems Biology
 | Memorial Sloan-Kettering Cancer Center
 | Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact

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

2010-04-22 Thread jim holtman
You did not give a good description of your problem, or what you wanted as a
solution (what is a 'button'), or a reasonable idea of what you data is.

Here is one solution

x - read.table(textConnection(Deafness, EYA4, DIAPH1, MYO7A, TECTA,
COL11A2, POU4F3, MYH9, ACTG1, MYO6),
as.is=TRUE, sep=',')
output - file('output.txt', 'w')
for (i in seq(nrow(x))){
for (j in 2:ncol(x)){
cat(x[i,1], ',', x[i,j], '\n', file=output)
}
}
close(output)

output.txt file*
Deafness ,  EYA4
Deafness ,  DIAPH1
Deafness ,  MYO7A
Deafness ,  TECTA
Deafness ,  COL11A2
Deafness ,  POU4F3
Deafness ,  MYH9
Deafness ,  ACTG1
Deafness ,  MYO6


On Thu, Apr 22, 2010 at 7:07 AM, mhalsham mhals...@bradford.ac.uk wrote:


 Thanks a lot for the help, but it’s not what I needed.
 --
 View this message in context:
 http://r.789695.n4.nabble.com/R-loop-tp1979620p2020386.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.htmlhttp://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] Arima online forecasting

2010-04-22 Thread Matteo Bertini
I'd like to have an online horizon=k forecast with Arima, something like:

library(forecast)

air.model = Arima(AirPassengers[0:100], c(1,0,1),
seasonal=list(order=c(0,1,1), period=12))

for(i in 0:(length(AirPassengers)-100)) {
air.model2 = Arima(AirPassengers[0:(100+i)], model=air.model)
cat(forecast(air.model2, h=2)$mean, '\n')
}

But this approach, even if not fitting the model from scratch, is still very
slow for big timeseries.

Some hints to speed it up?

Thanks,
Matteo

[[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] Error in plotting non-linear regression

2010-04-22 Thread Muhammad Rahiz

Hello everyone,

I'm trying to draw the non-linear regression curve to look at the 
distance decay relationship between distance and correlation values. But 
I'm not able to plot the curve as I'm struggling with the following 
error (parameters without starting value in 'data': x) and found no 
answers online.*


*Can anyone help...

--
Muhammad*


*s1 cm
10 0.57223196
2   10 0.33110049
3   20 0.11163181
4   30 0.10242237
5   40 0.09254315
6   50 0.02739370
7   60 0.02567137
8   70 0.02492397
9   80 0.03206637
10  90 0.02487381
11 100 0.01747584
12 110 0.15977533
13 120 0.13317708

new - data.frame(s1,cm)
plot(s1,cm)
f  - function(x,a,b){a*exp(-b*x)}
fm - nls(cm~f(x,a,b),data=new,start=c(a=1,b=1))   
co - coef(fm)   
curve(f(x,a=co[1],b=co[2]),add=TRUE,col=blue)


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

2010-04-22 Thread David Winsemius


On Apr 22, 2010, at 12:24 PM, Steve Lianoglou wrote:


Hi,

On Thu, Apr 22, 2010 at 12:08 PM, karena dr.jz...@gmail.com wrote:


I need to create 10 matrices. say matrix 1-10.

matrix_1 is 1 by 1
matrix_2 is 2 by 2
matrix_3 is 3 by 3
  .
  .
  .
matrix_10 is 10 by 10

I am just wondering if there are some functions in R that are  
similar to the

macro variables in SAS. so I can create these 10 matrices by doing:
for (i in 1: 10) {
matrix_$i - matrix(nrow=i, ncol=i)
}

rather thank creating these matrices one by one manually.

Anyone have any suggestions?


I believe the most idiomatic R way is to make a list of length 10:

R mats - lapply(1:10, function(x) matrix(0, nrow=x, ncol=x))


A somewhat similar method using Map:

 mtxlist - Map(matrix, rep(0,10), 1:10, 1:10)
 names(mtxlist) - paste(matrix, 1:10, sep=_)
 mtxlist$matrix_1
 mtxlist$matrix_10

Or with nested Map/mapply calls:

 mtxlist - Map(assign, paste(matx, 1:10, sep=_), Map(matrix,  
rep(0,10), 1:10, 1:10) )


And if you wanted to have all of those individual mtx_n's floating  
around:


 mapply(assign,
   paste(matx, 1:4, sep=_),
   Map(matrix, 1:4, 1:4, 1:4),
   MoreArgs=list( envir=.GlobalEnv) )




Then reference them like so:

R mats[[1]]

If you *really* want them to be in your global namespace, you have  
two options:


1. You can slightly modify the `mat` list I made above with more
variable-friendly names and then `attach` it (or use `with`):

R names(mats) - paste(m, 1:10, sep=)
R attach(mats)
R m2
[,1] [,2]
[1,]00
[2,]00

2. Or you could forget the `lapply` from above use `assign` in a for  
loop:


R for (i in 1:10) {
 assign(sprintf('mat%d', i), matrix(0, nrow=i, ncol=i))
}
R mat2
[,1] [,2]
[1,]00
[2,]00

Other notes: using attach isn't really best practice -- look into  
using `with`


Documentation you should read:

?lapply
?attach
?with
?assign

-steve

--
Steve Lianoglou
Graduate Student: Computational Systems Biology
| Memorial Sloan-Kettering Cancer Center
| Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact

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


David Winsemius, MD
West Hartford, CT

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


Re: [R] R crashing oddly

2010-04-22 Thread Michael Steven Rooney
Hi Uwe,

I downloaded R 2.11.0 and the latest version of nlme. I am still getting the
problem. I should also note that I got a message from Viechtbauer Wolfgang
saying that he had experienced a similar problem using nlme.

I have pasted the code below. (The data is generated in the first ~15
lines). I have bunch of debug() statements, which may or may not be useful.
The code is not as elegant as it could be since I have been constantly
editing it to try to track down the bug (I replaced the corMatrix C routine
with R code). FYI, the objective of the code is to simultaneously fit
temporal and spatial correlation (adding one corExp matrix plus another)
where the nuggets are constrained to add to 1.

I really hope you have a chance to look at this. Thanks so much!!

## BEGIN

N - 100
x - round(sin(rep(1:23/2,length.out=N)),digits=2)+1:N*2/N
y - round(cos(rep(1:23/2,length.out=N)),digits=2)+1:N*2/N
g - rep(1:5,each=N/5)
a - round(runif(N,0,10))
t - 1:N
r - runif(N,0,5)
e - 5*sin(4*x) +
 5*cos(4*y) +
 5*sin(t) +
 2*g +
 a +
 r
e - round(e)

df - data.frame(x,y,g,a,t,r,e)
df - df[-c(22,23,67),]

library(nlme)

corSPT - function(a,b) {
  object - list(time=a,space=b)
  class(object)  -  c(corSPT,corSpatial,corStruct)
  attr(object, formula) - formula(object)
  attr(object, nugget) - attr(object[[time]], nugget)
  attr(object, metric) - attr(object[[time]], metric)
  attr(object, fixed) - attr(object[[time]], fixed)
  return(object)
}

coef.corSPT - function(object,...) {

c(time=coef(object[[time]],...),space=coef(object[[space]],...)[1])
}

coef-.corSPT - function (object, ..., value) {
value - as.numeric(value)
if (length(value) != 3) {
stop(Cannot change the length of the parameter of a corSPT object)
}
object[[time]][] - value[1:2]
object[[space]][] - c(value[3],-value[2]) # nugget for space is
determined by the nugget for time
attr(object, factor) - NULL
attr(object, factor) - corFactor(object)
attr(object, logDet) - NULL
attr(object, logDet) - logDet(object)
object
}

Initialize.corSPT - function (object, data, ...) {
if (!is.null(attr(object[[time]], minD))) {
return(object)
}
object[[time]] -
getS3method(Initialize,corStruct)(object[[time]], data)
object[[space]] -
getS3method(Initialize,corStruct)(object[[space]], data)
object[[time]][1] - log(object[[time]][1])
object[[space]][1] - log(object[[space]][1])
object[[time]][2] - log(object[[time]][2]/(1 -
object[[time]][2]))
object[[space]][2] - -object[[time]][2]
attr(object,groups) - attr(object[[time]],groups)
attr(object,Dim) - attr(object[[time]],Dim)
attr(object,covariate) - NULL
attr(object, nugget) - attr(object[[time]], nugget)
attr(object[[time]],minD) - min(unlist(attr(object[[time]],
covariate)))
attr(object[[space]],minD) - min(unlist(attr(object[[space]],
covariate)))
attr(object, minD) - NULL
###
corD - Dim(object[[time]])
attr(object[[time]],covariate) - lapply(seq(corD$M),function(M) {
  x - attr(object[[time]],covariate)[[M]]
  l - corD$len[M]
  g - rep(seq(l),(l-1):0)
  mat - do.call(rbind,lapply(seq(l),function(G) {c(rep(0,G),x[g==G])}))
  mat - mat + t(mat)
})
attr(object[[space]],covariate) - lapply(seq(corD$M),function(M) {
  x - attr(object[[space]],covariate)[[M]]
  l - corD$len[M]
  g - rep(seq(l),(l-1):0)
  mat - do.call(rbind,lapply(seq(l),function(G) {c(rep(0,G),x[g==G])}))
  mat - mat + t(mat)
})
###
attr(object, factor) - corFactor(object)
attr(object, logDet) - -attr(attr(object, factor), logDet)
object
}

corMatrix.corSPT - function(object,covariate = NULL,corr=TRUE, ...) {
  if (corr) {
temp - coef(object[[time]],unconstrained=FALSE)
cat(temp)
time.rng - temp[1]
time.nug - temp[2]
temp - coef(object[[space]],unconstrained=FALSE)
space.rng - temp[1]
space.nug - temp[2]
cor.time - lapply(attr(object[[time]],covariate),function(mat)
(1-time.nug)*exp(-mat/time.rng))
cor.space - lapply(attr(object[[space]],covariate),function(mat)
(1-space.nug)*exp(-mat/space.rng))
x - lapply(seq(length(cor.time)),function(mat)
round(cor.time[[mat]]+cor.space[[mat]],4))
attr(x, logDet) - NULL
  } else {
d - Dim(object)
gg - rep(seq(d$M),each=d$len^2)
cf - corFactor(object)
lD - attr(cf, logDet)
x - lapply(seq(d$M),function(mm) {mat - cf[gg==mm];
matrix(mat,nrow=d$len[mm])})
attr(x,logDet) - lD
  }
  return(x)
}

corFactor.corSPT - getS3method(corFactor,corStruct)
logDet.corSPT - getS3method(logDet,corStruct)
recalc.corSPT - getS3method(recalc,corStruct)

formula.corSPT - function(object,...) {
  a - as.character(formula(object[[time]]))
  b - as.character(formula(object[[space]]))
  a - strsplit(a[2],split=|,fixed=TRUE)[[1]]
  b - strsplit(b[2],split=|,fixed=TRUE)[[1]]
  as.formula(paste(~,a[1],+,b[1],|,a[2]))
}

Dim.corSPT - function(object,...) {
  

[R] simple question

2010-04-22 Thread Zoppoli, Gabriele (NIH/NCI) [G]
Hi

how can I find, in a vector of characters, which is the most frequent one?

Thanks

Gabriele Zoppoli, MD
Ph.D. Fellow, Experimental and Clinical Oncology and Hematology, University of 
Genova, Genova, Italy
Guest Researcher, LMP, NCI, NIH, Bethesda MD

Work: 301-451-8575
Mobile: 301-204-5642
Email: zoppo...@mail.nih.gov
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 plotting non-linear regression

2010-04-22 Thread Peter Ehlers

On 2010-04-22 11:09, Muhammad Rahiz wrote:

Hello everyone,

I'm trying to draw the non-linear regression curve to look at the
distance decay relationship between distance and correlation values. But
I'm not able to plot the curve as I'm struggling with the following
error (parameters without starting value in 'data': x) and found no
answers online.*

*Can anyone help...

--
Muhammad*


* s1 cm
1 0 0.57223196
2 10 0.33110049
3 20 0.11163181
4 30 0.10242237
5 40 0.09254315
6 50 0.02739370
7 60 0.02567137
8 70 0.02492397
9 80 0.03206637
10 90 0.02487381
11 100 0.01747584
12 110 0.15977533
13 120 0.13317708

new - data.frame(s1,cm)
plot(s1,cm)
f - function(x,a,b){a*exp(-b*x)} fm -
nls(cm~f(x,a,b),data=new,start=c(a=1,b=1)) co - coef(fm)


Presumably you want f(s1,a,b) in your nls call.

 -Peter Ehlers


curve(f(x,a=co[1],b=co[2]),add=TRUE,col=blue)

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




--
Peter Ehlers
University of Calgary

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

2010-04-22 Thread Marc Schwartz
On Apr 22, 2010, at 10:34 AM, Ted Harding wrote:

 On 22-Apr-10 15:19:45, Barry Rowlingson wrote:
 On Thu, Apr 22, 2010 at 3:27 PM, peter dalgaard pda...@gmail.com
 wrote:
 ...that this Danish movie would have an official release today:
 
 http://www.imdb.com/title/tt1434443/
 
 Does it have music by this composer:
 
 http://www.imdb.com/name/nm1731203/
 
 and stills photography by:
 
 http://www.imdb.com/name/nm2083657/
 
 ?
 
 Nah, it was all outsourced to http://www.imdb.com/name/nm0264036/
 
 Ted.


And of course, a member of the screen writing team is 
http://www.imdb.com/title/tt0134119/

:-)

Regards,

Marc Schwartz

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


Re: [R] simple question

2010-04-22 Thread Joshua Wiley
Hello,

What about

test - c(rep(c(A,C,G,T), 20),C)
table(test)

I am not sure that is an apt representation of the data and problem
you are trying to solve.  It also occurred to me that each character
may not be its own element in the vector.  If that is so, you would
need to do something a little differently.

Let us know.

Josh

On Thu, Apr 22, 2010 at 10:36 AM, Zoppoli, Gabriele (NIH/NCI) [G]
zoppo...@mail.nih.gov wrote:
 Hi

 how can I find, in a vector of characters, which is the most frequent one?

 Thanks

 Gabriele Zoppoli, MD
 Ph.D. Fellow, Experimental and Clinical Oncology and Hematology, University 
 of Genova, Genova, Italy
 Guest Researcher, LMP, NCI, NIH, Bethesda MD

 Work: 301-451-8575
 Mobile: 301-204-5642
 Email: zoppo...@mail.nih.gov
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.




-- 
Joshua Wiley
Senior in Psychology
University of California, Riverside
http://www.joshuawiley.com/

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


Re: [R] simple question

2010-04-22 Thread Muhammad Rahiz

Hi Gabriele,

This is one way but I'm sure that there is an optimal way of doing so...

x - c(A,B,C,C,C,C,C,B,B)
name - unique(x) # get unique characters

freq - c()
for (a in 1:length(name)){
freq[a] - sum(x==name[a])}# get frequency
out - cbind(name,freq)   


Muhammad





Zoppoli, Gabriele (NIH/NCI) [G] wrote:

Hi

how can I find, in a vector of characters, which is the most frequent one?

Thanks

Gabriele Zoppoli, MD
Ph.D. Fellow, Experimental and Clinical Oncology and Hematology, University of 
Genova, Genova, Italy
Guest Researcher, LMP, NCI, NIH, Bethesda MD

Work: 301-451-8575
Mobile: 301-204-5642
Email: zoppo...@mail.nih.gov
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] simple question

2010-04-22 Thread David Winsemius


On Apr 22, 2010, at 1:36 PM, Zoppoli, Gabriele (NIH/NCI) [G] wrote:


Hi

how can I find, in a vector of characters, which is the most  
frequent one?


 a - sample(letters[1:10], 100, replace=TRUE)
 table(a)
a
 a  b  c  d  e  f  g  h  i  j
10  7  7 13  7 12  1 14 15 14
 max(table(a))
[1] 15
 which.max(table(a))
i
9   # so the ninth element in the table is the max
 table(a)[which.max(table(a))]
 i
15   # but the table entry needs to be extracted if you want the count.



Thanks

Gabriele Zoppoli, MD
Ph.D. Fellow, Experimental and Clinical Oncology and Hematology,  
University of Genova, Genova, Italy

Guest Researcher, LMP, NCI, NIH, Bethesda MD

Work: 301-451-8575
Mobile: 301-204-5642
Email: zoppo...@mail.nih.gov
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


David Winsemius, MD
West Hartford, CT

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


Re: [R] Error in plotting non-linear regression

2010-04-22 Thread Muhammad Rahiz

It now works. Thanks both.

Muhammad





Peter Ehlers wrote:

On 2010-04-22 11:09, Muhammad Rahiz wrote:
  

Hello everyone,

I'm trying to draw the non-linear regression curve to look at the
distance decay relationship between distance and correlation values. But
I'm not able to plot the curve as I'm struggling with the following
error (parameters without starting value in 'data': x) and found no
answers online.*

*Can anyone help...

--
Muhammad*


* s1 cm
1 0 0.57223196
2 10 0.33110049
3 20 0.11163181
4 30 0.10242237
5 40 0.09254315
6 50 0.02739370
7 60 0.02567137
8 70 0.02492397
9 80 0.03206637
10 90 0.02487381
11 100 0.01747584
12 110 0.15977533
13 120 0.13317708

new - data.frame(s1,cm)
plot(s1,cm)
f - function(x,a,b){a*exp(-b*x)} fm -
nls(cm~f(x,a,b),data=new,start=c(a=1,b=1)) co - coef(fm)



Presumably you want f(s1,a,b) in your nls call.

  -Peter Ehlers

  

curve(f(x,a=co[1],b=co[2]),add=TRUE,col=blue)

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

2010-04-22 Thread Lee.Adams
Gabriele - 

How about this:

 data-c(A,A,A,B,B,C,D)
 data
[1] A A A B B C D
 table(data)
data
A B C D 
3 2 1 1

Thanks,
Lee

. . . people who focus only on 'what is' will create more of 'what is.'

People who focus mostly on 'what could be' will begin to create 'what
could be.' ~ Laura Beth Jones
Lee P. Adams | Fuel  Emissions Strategy | Luminant Energy |
lee.ad...@luminant.com | 214.875.8737 Office | 214.701.0687 Mobile

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of Zoppoli, Gabriele (NIH/NCI) [G]
Sent: Thursday, April 22, 2010 12:37 PM
To: r-help@r-project.org
Subject: [R] simple question

Hi

how can I find, in a vector of characters, which is the most frequent
one?

Thanks

Gabriele Zoppoli, MD
Ph.D. Fellow, Experimental and Clinical Oncology and Hematology,
University of Genova, Genova, Italy
Guest Researcher, LMP, NCI, NIH, Bethesda MD

Work: 301-451-8575
Mobile: 301-204-5642
Email: zoppo...@mail.nih.gov
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Confidentiality Notice: This email message, including an...{{dropped:10}}

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

2010-04-22 Thread Kevin Wright
Mixing base/lattice graphics can be tricky, but is possible.

http://www.bioconductor.org/CRAN/web/packages/gridBase/vignettes/gridBase.pdf

Also, did you look at Chapter 13 of the lattice book?
http://lmdvr.r-forge.r-project.org/figures/figures.html

Kevin


On Wed, Apr 21, 2010 at 2:08 PM, David Winsemius dwinsem...@comcast.netwrote:


 On Apr 21, 2010, at 2:27 PM, Simon Goodman wrote:


 I've generated a levelplot showing the density distribution of a species
 derived from survey transects, with lon, lat co-ordinates.

 I'd like to overlay this on a map of the study region specified by:

 map('worldHires', xlim = range(mlon), ylim = range(mlat)), where mlon,
 mlat
 specifies the study region.


  ?map
 No documentation for 'map' in specified packages and libraries:
 you could try '??map'
  ??map
  require(maps)
 Loading required package: maps
  map

 So map uses base graphics.



  I've tried plotting the map first, then using the options: 'add=TRUE,
 axes=FALSE' in the levelplot,



 levelplot is a lattice function. You will have failure with most efforts to
 mix base and grid graphics.





  but this doesn't work - a new plot is
 generated for the level plot despite the 'add' option. If I try to add the
 map on top of the level plot, they are not to the same scale.

 Any suggestions on how to get round this.

 Thanks

 --
 View this message in context:
 http://n4.nabble.com/overlaying-a-levelplot-on-a-map-plot-tp2019419p2019419.html
 Sent from the R help mailing list archive at Nabble.com.

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


 David Winsemius, MD
 West Hartford, CT

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




-- 
Kevin Wright

[[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] compare variables and take largest value?

2010-04-22 Thread Henrique Dallazuanna
Try this:

apply(replace(v - rbind(v1, v2, v3), is.nan(v), 0), 2, max)


On Thu, Apr 22, 2010 at 12:24 PM, Vlatka Matkovic Puljic 
v.matkovic.pul...@gmail.com wrote:

 Only thing that when I put  na.rm=FALSE,
 R is puting in v4 NA (as is largest)
 and I want to see NA as zero (0, smallest value)

 2010/4/22 Vlatka Matkovic Puljic v.matkovic.pul...@gmail.com

  Thanx a lot! That's it!
 
  2010/4/22 Duncan Murdoch murdoch.dun...@gmail.com
 
  On 22/04/2010 11:07 AM, Vlatka Matkovic Puljic wrote:
 
  Hi!
 
  I have v1, v2 and v3 (data in v. ranges 1 to 4)
 
  v1
[1]   1   1   1   1 NaN   1   1   4   1   1   3
  v2
[1]   1   1   1   1   1   1   1   1   1   1   1
  v3
[1]   1   1   1   1   1   1   1   1   1   1   1
 
  I want R to compare entries in v1,v2,v3 and in v4 to put largest value
  (NA=0).
  For example. first line v4 would be 1, but last line v4 would be 3.
 
  What function should I use?
 
 
 
 
  pmax.
 
  Duncan Murdoch
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 
 
 
  --
  **
  Vlatka Matkovic Puljic
  095/8618 171
 



 --
 **
 Vlatka Matkovic Puljic
 095/8618 171

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




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

[[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] Multicolor main title in a plot or mtext

2010-04-22 Thread Kevin Wright
Perhaps this helps?
http://blog.revolution-computing.com/2009/01/multicolor-text-in-r.html

Kevin


On Thu, Apr 22, 2010 at 11:18 AM, Ottorino-Luca Pantani 
ottorino-luca.pant...@unifi.it wrote:

 Dear R-users, the problem I'm facing today is to write a
 multicolor main title in a plot.

 I would like to have 3/4 colors to help people in the
 audience to visually realize what is what in a 4x2 plot array

 On top of each plot I would like to have two lines.
 The 1st line will indicate what is plotted
 The 2nd line will indicate a a reference

 Graphically speaking I would like a result similar to this (simplified)
 one:

 par(mfrow=c(2,4))
 for(aux in 1:4){
 plot(1,1)
 mtext(1st treatm, cex=1, line=1.7, adj=0.1, col=1)
 mtext(2nd treatm, cex=1, line=1.7, adj=0.5, col=2)
 mtext(3rd treatm, cex=1, line=1.7, adj=0.9, col=3)
 mtext(1st treatm, line=0.6, adj=0.1, col=1)
 mtext(1st treatm, line=0.6, adj=0.5, col=1)
 mtext(1st treatm, line=0.6, adj=0.9, col=1)
 }
 for(aux in 1:4){
 plot(2,2)
 mtext(1st treatm, cex=1, line=1.7, adj=0.1, col=1)
 mtext(2nd treatm, cex=1, line=1.7, adj=0.5, col=2)
 mtext(3rd treatm, cex=1, line=1.7, adj=0.9, col=3)
 mtext(2nd treatm, line=0.6, adj=0.1, col=2)
 mtext(2nd treatm, line=0.6, adj=0.5, col=2)
 mtext(2nd treatm, line=0.6, adj=0.9, col=2)
 }


 The code above does more or less what I want and
 I wrote it to simplify my explanation to you all.

 But what I really need is  to put on top of each plot
 an entire string with color embedded into, so to say.

 A sort of 1st treatm 2nd treatm 3rd treatm string with
 informations able to colour the word 1st treatm in black,
 the word 2nd treatm in red and so on.

 I need this because I have my descriptions in a vector like

 c(1st treatm 2nd treatm 3rd treatm,
  2nd treatm 3rd treatm 1st treatm,
  ...)

 What I have in mind is something similar to the latex code
 \color{black}{1st treatm} \color{red}{2nd treatm} \color{green}{3rd treatm}

 Which pages of the R manual should I have to read to solve my problem ?

 Thanks in advance
 --
 Ottorino-Luca Pantani, Università di Firenze
 Dip.to di Scienze delle Produzioni Vegetali,
 del Suolo e dell'Ambiente Forestale (DiPSA)

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




-- 
Kevin Wright

[[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] Accessing outside data sources for stock data?

2010-04-22 Thread Brigid Mooney
Hi All,

I apologize if this is not the right forum for this question.

I know there used to be a package for R that connected to opentick's (open
source) stock market data.  However, opentick closed up about a year ago.

Does anyone know of a similar package that connects to IQfeed's stock market
data (or another source of historical stock market data)?

Thanks,
Brigid

[[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] overlaying a levelplot on a map plot

2010-04-22 Thread David Winsemius


On Apr 22, 2010, at 2:24 PM, Kevin Wright wrote:


Mixing base/lattice graphics can be tricky, but is possible.

http://www.bioconductor.org/CRAN/web/packages/gridBase/vignettes/gridBase.pdf


That could be quite useful in the future. Thanks for that.



Also, did you look at Chapter 13 of the lattice book?
http://lmdvr.r-forge.r-project.org/figures/figures.html


I did look at the actual book, and upon doing so yet again, I would  
say that my comments were an accurate, if pithy, summary of the  
message I take away from what very little regarding base graphics  
appears in that chapter.


--
David.



Kevin

On Wed, Apr 21, 2010 at 2:08 PM, David Winsemius dwinsem...@comcast.net 
 wrote:


On Apr 21, 2010, at 2:27 PM, Simon Goodman wrote:

I've generated a levelplot showing the density distribution of a  
species

derived from survey transects, with lon, lat co-ordinates.

I'd like to overlay this on a map of the study region specified by:

map('worldHires', xlim = range(mlon), ylim = range(mlat)), where  
mlon, mlat

specifies the study region.

 ?map
No documentation for 'map' in specified packages and libraries:
you could try '??map'
 ??map
 require(maps)
Loading required package: maps
 map


So map uses base graphics.



I've tried plotting the map first, then using the options:  
'add=TRUE,

axes=FALSE' in the levelplot,




levelplot is a lattice function. You will have failure with most  
efforts to mix base and grid graphics.



but this doesn't work - a new plot is
generated for the level plot despite the 'add' option. If I try to  
add the

map on top of the level plot, they are not to the same scale.

Any suggestions on how to get round this.

Thanks



--


David Winsemius, MD
West Hartford, CT

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


[R] R and S-Plus: Two programs separated by a common language?

2010-04-22 Thread Paul Miller
Hello Everyone,
 
My company purchased S-Plus before it was bought out by Tibco. My understanding 
is that we own version 7.0 outright. 
 
So far, I've been learning in R but thought I might also try working in S-Plus. 
My understanding is that S-Plus has some useful extra features. Another 
potential benefit would be the ability to purchase technical support, which I 
thought might help me to learn the S language.
 
I was just wondering if anyone could give me some advice about the wisdom or 
folly of trying to use both products. For example, how well do the two play 
together? If I learn to do something using a package in R, is their some way to 
bring that into S-Plus? I've noticed that some R packages, such as MASS and 
Hmisc are in S-Plus but are unsupported. Others, such as reshape, appear not to 
be in the program but I thought maybe they could be imported.
 
I know that R and S-Plus code are supposed to be very similar. I was just 
wondering how similar. Yesterday, I ran some code from the MASS package in 
S-Plus but the program didn't produce the graph I exepected to see. I've been 
able to use windows() in R to correct this, but S-Plus doesn't recognize that. 
So I was wondering how often code written in one program would fail to work in 
the other.
 
Any insights you can offer will be most appreciated.
 
Thanks,
 
Paul 
 


[[alternative HTML version deleted]]

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


[R] read.table understands comment field and ignores text

2010-04-22 Thread Jack T.

Hi I'm trying to import a large csv file without quotes around each field. 
This creates some problems when there are # characters in certain strings
as R understands its comment field and ignores the rest of the line.

Here's an example:

var1, var2, var3, var4
one, two, three, four

  Use this in R to get off clipboard:

  read.table(clipboard, header=F, sep=,,na.strings=c(NULL, ),
dec=., strip.white=TRUE, fill=T)

Now try it with this table:

var1, var2, var3, var4
one#, two, three, four

Notice R ignores everything after the # character.  Is this something that
can be fixed?




-- 
View this message in context: 
http://r.789695.n4.nabble.com/read-table-understands-comment-field-and-ignores-text-tp2021036p2021036.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] read.table understands comment field and ignores text

2010-04-22 Thread Marc Schwartz
On Apr 22, 2010, at 2:05 PM, Jack T. wrote:

 
 Hi I'm trying to import a large csv file without quotes around each field. 
 This creates some problems when there are # characters in certain strings
 as R understands its comment field and ignores the rest of the line.
 
 Here's an example:
 
 var1, var2, var3, var4
 one, two, three, four
 
  Use this in R to get off clipboard:
 
  read.table(clipboard, header=F, sep=,,na.strings=c(NULL, ),
 dec=., strip.white=TRUE, fill=T)
 
 Now try it with this table:
 
 var1, var2, var3, var4
 one#, two, three, four
 
 Notice R ignores everything after the # character.  Is this something that
 can be fixed?


Change the 'comment.char' argument to :

  read.table(, comment.char = )

See ?read.table for more information.

HTH,

Marc Schwartz

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


Re: [R] read.table understands comment field and ignores text

2010-04-22 Thread David Winsemius


On Apr 22, 2010, at 3:05 PM, Jack T. wrote:



Hi I'm trying to import a large csv file without quotes around each  
field.
This creates some problems when there are # characters in certain  
strings

as R understands its comment field and ignores the rest of the line.

Here's an example:

var1, var2, var3, var4
one, two, three, four

 Use this in R to get off clipboard:

 read.table(clipboard, header=F, sep=,,na.strings=c(NULL, ),
dec=., strip.white=TRUE, fill=T)

Now try it with this table:

var1, var2, var3, var4
one#, two, three, four

Notice R ignores everything after the # character.  Is this  
something that

can be fixed?


?read.table

Read the documentation with particular attention to comment.char

--





David Winsemius, MD
West Hartford, CT

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


Re: [R] read.table understands comment field and ignores text

2010-04-22 Thread Jack T.

Oh man, totally missed that one!  Thanks so much for the reminder.
-- 
View this message in context: 
http://r.789695.n4.nabble.com/read-table-understands-comment-field-and-ignores-text-tp2021036p2021055.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] mixed model with subject-specific variance structure

2010-04-22 Thread Jiang, Yonghua
Hi All,

I built a mixed model with subject-specific variance structure in SAS and it 
works quite well. Now I intended to implement the same model in R using lme 
with weights option. Following is the SAS code and the corresponding R code:

SAS:
proc mixed data=source;
class id trial group valence scan;
model y=group|valence|scan;
repeated /sub=id(trial) group=id type=AR(1);
run;

R

vf1Ident-varIdent(~1|id)
vf1Ident.ini-Initialize(vf1Ident,grouped.data)
model-lme(fixed=y~group*valence*scan,data=grouped.data,correlation=corAR1(),weights=vf1Ident.ini);

The result shows :convergence error code = 1  message = iteration limit reached 
without convergence (9)

I searched the help archive and likely the weights option does not work well. 
Any suggestion to implement the subject-specific variance structure in R?

Thanks,

Yonghua

[[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] What is the test statistics in perm.test

2010-04-22 Thread Xiang Gao
Hi,

The permutation test for two samples in R is function perm.test(). I could
not figure out what is the statistics it estimate and how many permutation
it did in default?

Thanks,

[[alternative HTML version deleted]]

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


[R] index ordering

2010-04-22 Thread tamas barjak
Hi All!

I have a problem that I do not know it how it is necessary to query an index
belonging to a given value.

Somebody would help?

[[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] index ordering

2010-04-22 Thread David Winsemius


On Apr 22, 2010, at 3:45 PM, tamas barjak wrote:


Hi All!

I have a problem that I do not know it how it is necessary to query  
an index

belonging to a given value.



I bit hard to tell without an example but suspect you want:

?which

--
David Winsemius, MD
West Hartford, CT

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


Re: [R] Compare two data frames

2010-04-22 Thread Paul Murrell

Hi

Sounds like the 'compare' package might do some of what you want.

Paul

On 23/04/2010 1:41 a.m., Doran, Harold wrote:

I wonder if there is a more efficient way to do this task. Suppose I
have two data frames, such as

d1- data.frame(x = c(1,2,3), y = c(4,5,6), z = c(7,8,9))

d2- d1[, c('y', 'x')]

The first dataframe d1 has more variables than d2 and the variable
columns are in a different order.

So, what I want to do is compare the two frames on the variables that
are common between the two. First I find the common variables between
the two dataframes

common_order- intersect(colnames(d1), colnames(d2))

Then, I have to put the variables in d2 in the same order as d1 as

d2- d2[, common_order]

Then, I keep only the variables in common between d1 and d2 as

d1- d1[, common_order]

Then, finally I can do the compare on the common variables now in the
same order.

all.equal(d1, d2)

None of this is horribly difficult, but it requires a couple of steps
that I am wondering might be eliminated.

Harold


sessionInfo()

R version 2.10.1 (2009-12-14) i386-pc-mingw32

locale: [1] LC_COLLATE=English_United States.1252
LC_CTYPE=English_United States.1252LC_MONETARY=English_United
States.1252 [4] LC_NUMERIC=C
LC_TIME=English_United States.1252

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

other attached packages: [1] MiscPsycho_1.6 statmod_1.4.6

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

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


--
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
p...@stat.auckland.ac.nz
http://www.stat.auckland.ac.nz/~paul/

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


Re: [R] R2.11.0 - rasterImage() and barplot fill-patterns

2010-04-22 Thread Paul Murrell

Hi

On 23/04/2010 12:10 a.m., Tal Galili wrote:

Hello Peter,
Thank you, and the R core team, for the new release.


I see that in R 2.11.0 there is now support for rendering of raster (bitmap)
images through rasterImage().

I am wondering - can this be used to create a texture/fill-pattern for
hist()/barplot()  ?


That is one possible application (see 
http://developer.r-project.org/Raster/raster-RFC.html)


Paul


(A request made several times throughout the years on the mailing list.
For example:
http://osdir.com/ml/lang.r.general/2005-07/msg00799.html
)

(I am also sending this e-mail to the maintainers of lattice, ggplot2 and
gplots in the hope for more perspectives)

With much respect,
Tal








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




On Thu, Apr 22, 2010 at 12:01 PM, Peter Dalgaardpd@cbs.dk  wrote:


I've rolled up R-2.11.0.tar.gz a short while ago. This is a development
release which contains a number of new features.

Also, a number of mostly minor bugs have been fixed. See the full list
of changes below.

NOTE: The build platform has been changed for this release. Please watch
out extra carefully for anomalies.

You can get it from

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

or wait for it to be mirrored at a CRAN site nearer to you.

Binaries for various platforms will appear in due course.

   For the R Core Team

   Peter Dalgaard

These are the md5sums for the freshly created files, in case you wish
to check that they are uncorrupted:

MD5 (AUTHORS) = ac9746b4845ae81f51cfc99262f5
MD5 (COPYING) = eb723b61539feef013de476e68b5c50a
MD5 (COPYING.LIB) = a6f89e2100d9b6cdffcea4f398e37343
MD5 (FAQ) = 5b653442bedab476a4eff7468192fb5f
MD5 (INSTALL) = 70447ae7f2c35233d3065b004aa4f331
MD5 (NEWS) = 59017734fb8474f98f994c7a5a27f9fb
MD5 (ONEWS) = a8c985af5ad5e9c7e0a9f502d07baeb4
MD5 (OONEWS) = 4f004de59e24a52d0f500063b4603bcb
MD5 (R-latest.tar.gz) = c6c1e866299f533617750889c729bfb3
MD5 (README) = 433182754c05c2cf7a04ad0da474a1d0
MD5 (RESOURCES) = 020479f381d5f9038dcb18708997f5da
MD5 (THANKS) = f2ccf22f3e20ebaa86f8ee5cc6b0f655
MD5 (R-2/R-2.11.0.tar.gz) = c6c1e866299f533617750889c729bfb3

This is the relevant part of the NEWS file:

CHANGES IN R VERSION 2.11.0


SIGNIFICANT USER-VISIBLE CHANGES

o   Packages must have been installed under R= 2.10.0, as the
current help system is the only one now supported.

o   A port to 64-bit Windows is now available as well as binary
package repositiories: see the 'R Administration and
Installation Manual'.

o   Argument matching for primitive functions is now done in the
same way as for interpreted functions except for the deliberate
exceptions

call switch .C .Fortran .Call .External

all of which use positional matching for their first argument,
and also some internal-use-only primitives.

o   The default device for command-line R at the console on Mac OS X
is now quartz() and not X11().


NEW FEATURES

o   The 'open' modes for connections are now interpreted more
consistently.  open = r is now equivalent to open = rt for
all connections.  The default open =  now means rt for all
connections except the compressed file connections gzfile(),
bzfile() and xzfile() for which it means rb.

o   R CMD INSTALL now uses the internal untar() in package utils:
this ensures that all platforms can install bzip2- and
xz-compressed tarballs.  In case this causes problems (as it
has on some Windows file systems when run from Cygwin tools)
it can be overridden by the environment variable
R_INSTALL_TAR: setting this to a modern external tar program
will speed up unpacking of large (tens of Mb or more)
tarballs.

o   help(try.all.packages = TRUE) is much faster (although the
time taken by the OS to find all the packages the first time
it is used can dominate the time).

o   R CMD check has a new option '--timings' to record
per-example timings in filepkg.Rcheck/pkg-Ex.timings.

o   The TRE library has been updated to version 0.8.0 (minor bugfixes).

o   grep[l], [g]sub and [g]regexpr now work in bytes in an 8-bit
locales if there is no marked UTF-8 input string: this will be
somewhat faster, and for [g]sub() give the result in the
native encoding rather than in UTF-8 (which returns to the
behaviour prior to R 2.10.0).

o   A new argument 'skipCalls' has been added to browser() so that
it can report the original context when called by other
debugging functions.

o   

Re: [R] index ordering

2010-04-22 Thread Tal Galili
Ah.
Close to what David suggested...
Try:

?which.max




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




On Thu, Apr 22, 2010 at 10:57 PM, tamas barjak tamas.bar...@gmail.comwrote:

 Of course!

  max(dbinom(0:20, 20, 0.4))
 [1] 0.1797058


 I would like the place of the maximum for this. The value is found, I do
 not know it only which index belongs to.



[[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] Subject: R and S-Plus: Two programs separated by a common language?

2010-04-22 Thread John James
Paul

 

Just as in your implied analogy there are significant differences
beneath the surface between these programs despite superficial
similarities.

 

You will soon get frustrated trying to use both simultaneously as you
will not be sure that the critical step you've discovered in one will
work in the other. Most basic functions will work but I suspect that you
will soon discover some development or feature in the R pantheon that
will not translate readily to S-PLUS (and certainly not versions before
8.1).

 

The reasons for these differences are the result of fundamental
differences in architectures.

 

I used S-PLUS for 12 years, and I still need to use it occasionally the
most useful feature is the oft-despised Windows GUI. This is because it
provides a ready means to start to use a function that perhaps I only
use infrequently. However the GUI soon looses its appeal as I start to
solve a problem and almost immediately return to the scripting or
command line interface.

 

In R there are many useful starting points (help, apropos, views and a
simple search mechanism) that replace this comfortable feature, but
there is a learning curve to 'how do I find out how to find out in R'.
There are a range of helpful 'Starting R' books and they are worth the
effort of buying and reading.

 

Many companies, including the one I work for, offer support of all kinds
in R (as well as S-PLUS).

 

However the best help is the mechanism you have just used: an active and
mostly friendly R community. In addition there is a plethora of R
community groups, London, Chicago, New York come to mind - drop along to
some of them. And start to use R.

 

Regards

 

John James

Mango

 

- Original Message -

From: r-help-boun...@r-project.org r-help-boun...@r-project.org

To: r-help@r-project.org r-help@r-project.org

Sent: Thu Apr 22 20:00:13 2010

Subject: [R] R and S-Plus: Two programs separated by a common language?

 

Hello Everyone,

 

My company purchased S-Plus before it was bought out by Tibco. My
understanding is that we own version 7.0 outright. 

 

So far, I've been learning in R but thought I might also try working in
S-Plus. My understanding is that S-Plus has some useful extra features.
Another potential benefit would be the ability to purchase technical
support, which I thought might help me to learn the S language.

 

I was just wondering if anyone could give me some advice about the
wisdom or folly of trying to use both products. For example, how well do
the two play together? If I learn to do something using a package in R,
is their some way to bring that into S-Plus? I've noticed that some R
packages, such as MASS and Hmisc are in S-Plus but are unsupported.
Others, such as reshape, appear not to be in the program but I thought
maybe they could be imported.

 

I know that R and S-Plus code are supposed to be very similar. I was
just wondering how similar. Yesterday, I ran some code from the MASS
package in S-Plus but the program didn't produce the graph I exepected
to see. I've been able to use windows() in R to correct this, but S-Plus
doesn't recognize that. So I was wondering how often code written in one
program would fail to work in the other.

 

Any insights you can offer will be most appreciated.

 

Thanks,

 

Paul 

 

 

LEGAL NOTICE
\ This message is intended for the use of...{{dropped:14}}

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

2010-04-22 Thread Simon Goodman

Thanks for those pointers making some progress now

The following will put the levelplot on to the map, but the not with the
co-ordinates aligned...
The level plot appears on a slightly larger scale compared to the underlying
map.

In both the map and levelplot, the coordinates are in lon, lat decimal
degrees.
Hopefully I'm nearly there, with 1 or 2 tweaks. 


library(gridBase)
mlat-c(n1,n2)
mlon-c(n3,n4)
map('worldHires', xlim = range(mlon), ylim = range(mlat))
axis(1);axis(2);axis(3);axis(4)

lvl.plot-levelplot(z~x+y,xyz,pretty=TRUE,at=at,col.regions=cl)
vps - baseViewports()
pushViewport(vps$inner, vps$figure, vps$plot)
pushViewport(viewport(print(lvl.plot, newpage=FALSE)))
popViewport()
popViewport(3)

However after the line 'pushViewport(viewport(print(lvl.plot,
newpage=FALSE)))' an error is returned:

Error in unit(x, default.units) : 
  (list) object cannot be coerced to type 'double'







-- 
View this message in context: 
http://r.789695.n4.nabble.com/overlaying-a-levelplot-on-a-map-plot-tp2019419p2021128.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Compare two data frames

2010-04-22 Thread Bert Gunter
Why does:

nm - intersect(names(d1),names(d2))
identical(d1[,nm], d2[,nm])

not do it?

-- Bert

Bert Gunter
Nonclinical Biostatistics
467-7374

http://devo.gene.com/groups/devo/depts/ncb/home.shtml

 

 

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Paul Murrell
Sent: Thursday, April 22, 2010 12:54 PM
To: Doran, Harold
Cc: r help
Subject: Re: [R] Compare two data frames

Hi

Sounds like the 'compare' package might do some of what you want.

Paul

On 23/04/2010 1:41 a.m., Doran, Harold wrote:
 I wonder if there is a more efficient way to do this task. Suppose I
 have two data frames, such as

 d1- data.frame(x = c(1,2,3), y = c(4,5,6), z = c(7,8,9))

 d2- d1[, c('y', 'x')]

 The first dataframe d1 has more variables than d2 and the variable
 columns are in a different order.

 So, what I want to do is compare the two frames on the variables that
 are common between the two. First I find the common variables between
 the two dataframes

 common_order- intersect(colnames(d1), colnames(d2))

 Then, I have to put the variables in d2 in the same order as d1 as

 d2- d2[, common_order]

 Then, I keep only the variables in common between d1 and d2 as

 d1- d1[, common_order]

 Then, finally I can do the compare on the common variables now in the
 same order.

 all.equal(d1, d2)

 None of this is horribly difficult, but it requires a couple of steps
 that I am wondering might be eliminated.

 Harold

 sessionInfo()
 R version 2.10.1 (2009-12-14) i386-pc-mingw32

 locale: [1] LC_COLLATE=English_United States.1252
 LC_CTYPE=English_United States.1252LC_MONETARY=English_United
 States.1252 [4] LC_NUMERIC=C
 LC_TIME=English_United States.1252

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

 other attached packages: [1] MiscPsycho_1.6 statmod_1.4.6

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

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

-- 
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
p...@stat.auckland.ac.nz
http://www.stat.auckland.ac.nz/~paul/

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

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


[R] How to insert gridlines in lattice density plot

2010-04-22 Thread Giles

Greetings.

How can I  insert gridlines
in the following density plot call?
Must one compose a panel function?

'data.frame':   46 obs. of  2 variables:
 $ fallrates: num  5.2 7.1 7.1 9.8 3.7 7.5 5 6.2 1.5 2.9 ...
 $ prepost  : Factor w/ 2 levels post,pre: 2 2 2 2 2 2 2 2 2 2 ...

library(lattice)

  densityplot(~fallrates,  groups = prepost,
 kernal=triangular, lwd=2,
 plot.points = TRUE, ref = TRUE, auto.key = list(columns = 2),
 main=Estimated fall rate density, pre and post intevention)


Thank you for your consideration and comments.
Giles Crane

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

2010-04-22 Thread Nilza BARROS
Dear R users,

I have been plotting several graphics in only one page. I intend to plot
only one legend in each page.
Since the graphics are inside a loop I have to do it automatically.
The main problem is that inside the loop I work with differente types of
variables, I mean , the range is different for each one.

I have already tried :

par(xpd=TRUE)
pos-par(usr)
legend(pos[1],pos[3]-(pos[3]*.05),c(Modelo,Observado),col =
c(blue,orange),cex=1.0, pch=15)
I would like to be able to plot the legend outer the graphics region.
Something like I've done with title.
You can see one figure an attached file.

I really appreciate any help.
Nilza Barros







-- 
Abraço,
Nilza Barros
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 insert gridlines in lattice density plot

2010-04-22 Thread Bert Gunter
 Must one compose a panel function?

Depending on what you want exactly, no. Add the argument

type=g

to your call.
(e.g.
   densityplot(~fallrates,  groups = prepost,type=g,...
)

See ?panel.xyplot  and recall that lattice passes down arguments that it
does not know what to do with to the panel function.

Bert Gunter
Genentech Nonclinical Biostatistics
 
 
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Giles
Sent: Thursday, April 22, 2010 1:31 PM
To: r-help@r-project.org
Subject: [R] How to insert gridlines in lattice density plot

Greetings.

How can I  insert gridlines
in the following density plot call?
Must one compose a panel function?

'data.frame':   46 obs. of  2 variables:
  $ fallrates: num  5.2 7.1 7.1 9.8 3.7 7.5 5 6.2 1.5 2.9 ...
  $ prepost  : Factor w/ 2 levels post,pre: 2 2 2 2 2 2 2 2 2 2 ...

library(lattice)

   densityplot(~fallrates,  groups = prepost,
  kernal=triangular, lwd=2,
  plot.points = TRUE, ref = TRUE, auto.key = list(columns = 2),
  main=Estimated fall rate density, pre and post intevention)


Thank you for your consideration and comments.
Giles Crane

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] using which to select range of values

2010-04-22 Thread Greg Snow
Another solution (whether this is better/worse, prettier/uglier, etc./etc. is 
in the eye of the beholder):

library(TeachingDemos)
x0 - rnorm(100)
x0[ 0 %% x0 %% 1.5 ]

Hope this helps,

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


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
 project.org] On Behalf Of Muhammad Rahiz
 Sent: Thursday, April 22, 2010 9:21 AM
 To: r-help@r-project.org
 Subject: [R] using which to select range of values
 
 Hi all,
 
 I would like to get the array index for a range of values, say  0  x 
 1.5. I'm wondering if there is an alternative for the following which
 I've done
 
 x0 - rnorm(100)
 x1 - ifelse(x0  0  x0  1.5,t,f)
 x2 - which(x1==t,arr.ind=TRUE)
 x0[x2]
 
 Thanks.
 
 --
 
 Muhammad
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] How to insert gridlines in lattice density plot

2010-04-22 Thread David Winsemius


On Apr 22, 2010, at 4:52 PM, Bert Gunter wrote:


 Must one compose a panel function?

Depending on what you want exactly, no. Add the argument

type=g

to your call.
(e.g.
  densityplot(~fallrates,  groups = prepost,type=g,...
)

See ?panel.xyplot  and recall that lattice passes down arguments  
that it

does not know what to do with to the panel function.


I found that type=g interfered with execution of the ,,,  
plot.points=TRUE, ... directive and got better success with  ... ,  
type=c(p, g)


--
David.


Bert Gunter
Genentech Nonclinical Biostatistics


-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org 
] On

Behalf Of Giles
Sent: Thursday, April 22, 2010 1:31 PM
To: r-help@r-project.org
Subject: [R] How to insert gridlines in lattice density plot

Greetings.

How can I  insert gridlines
in the following density plot call?
Must one compose a panel function?

'data.frame':   46 obs. of  2 variables:
 $ fallrates: num  5.2 7.1 7.1 9.8 3.7 7.5 5 6.2 1.5 2.9 ...
 $ prepost  : Factor w/ 2 levels post,pre: 2 2 2 2 2 2 2 2 2 2 ...

library(lattice)

  densityplot(~fallrates,  groups = prepost,
 kernal=triangular, lwd=2,
 plot.points = TRUE, ref = TRUE, auto.key = list(columns = 2),
 main=Estimated fall rate density, pre and post intevention)


Thank you for your consideration and comments.
Giles Crane

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

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


David Winsemius, MD
West Hartford, CT

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


[R] How to insert gridlines in lattice density plot

2010-04-22 Thread Giles

Thank you Burt Gunter and David Winsemius,

I confirmed David's comment.
One must use type=c(p,g)
in order to get both the grid and points.

So, to use densityplot well,
we must be quite aware of the options
for panel.xyplot!
Cordially,
Giles Crane

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

2010-04-22 Thread Felix Andrews
You don't have to use map() to draw the map.

m - map(..., plot = FALSE)
xyplot(y ~ x, m, type = l, aspect = iso,
  par.settings = list(axis.line = list(col = transparent)))

or inside a panel function, assuming appropriate scales:
panel.xyplot(m$x, m$y, ...)



On 23 April 2010 04:38, David Winsemius dwinsem...@comcast.net wrote:
 On Apr 22, 2010, at 2:24 PM, Kevin Wright wrote:

 Mixing base/lattice graphics can be tricky, but is possible.


 http://www.bioconductor.org/CRAN/web/packages/gridBase/vignettes/gridBase.pdf

 That could be quite useful in the future. Thanks for that.


 Also, did you look at Chapter 13 of the lattice book?
 http://lmdvr.r-forge.r-project.org/figures/figures.html

 I did look at the actual book, and upon doing so yet again, I would say that
 my comments were an accurate, if pithy, summary of the message I take away
 from what very little regarding base graphics appears in that chapter.

 --
 David.


 Kevin

 On Wed, Apr 21, 2010 at 2:08 PM, David Winsemius dwinsem...@comcast.net
 wrote:

 On Apr 21, 2010, at 2:27 PM, Simon Goodman wrote:

 I've generated a levelplot showing the density distribution of a species
 derived from survey transects, with lon, lat co-ordinates.

 I'd like to overlay this on a map of the study region specified by:

 map('worldHires', xlim = range(mlon), ylim = range(mlat)), where mlon,
 mlat
 specifies the study region.

  ?map
 No documentation for 'map' in specified packages and libraries:
 you could try '??map'
  ??map
  require(maps)
 Loading required package: maps
  map

 So map uses base graphics.


 I've tried plotting the map first, then using the options: 'add=TRUE,
 axes=FALSE' in the levelplot,


 levelplot is a lattice function. You will have failure with most efforts
 to mix base and grid graphics.

 but this doesn't work - a new plot is
 generated for the level plot despite the 'add' option. If I try to add
 the
 map on top of the level plot, they are not to the same scale.

 Any suggestions on how to get round this.

 Thanks

 --

 David Winsemius, MD
 West Hartford, CT

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




-- 
Felix Andrews / 安福立
Postdoctoral Fellow
Integrated Catchment Assessment and Management (iCAM) Centre
Fenner School of Environment and Society [Bldg 48a]
The Australian National University
Canberra ACT 0200 Australia
M: +61 410 400 963
T: + 61 2 6125 4670
E: felix.andr...@anu.edu.au
CRICOS Provider No. 00120C
-- 
http://www.neurofractal.org/felix/

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

2010-04-22 Thread Nick Fankhauser
I'm using randomSurvivalForest to predict survival from a rather small 
sample. As it's not enough data to have training and validation set, I 
rely on the Estimate of error rate computed by the randomForest. If I 
understand the method correctly, it repeatedly partitions the data into 
varying training/validation sets during the learning steps, which also 
produces the estimate of error.
My questions is, would it be possible to compute a ROC curve during RF 
training?
A possible approach I considered would be to train the RF on a subset of 
the data and create a ROC curve from the prediction on the remaining 
data. By repeating this process, I would get the variation of the ROC 
curve for the different possible data subsets.
But this seems to be not such an elegant solution, as this could be done 
during one instance of RF learning.
It would be very helpful, if someone could point to an approach on how 
to do this.


Nick Fankhauser

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Why does 'apply(.., 1, .., ..)' transpose result

2010-04-22 Thread Worik R
I am sorry if this is documented in apply's dcumentation or completely
obvious, I could not find or work it out.

Given an matricies Q: 2x3, R:1x3 and S:1x2

apply(Q, 1, '-', R) is 3x2 and apply(Q, 2, '-', S) is 2x3

Why?

cheers
Worik

 Q
 [,1] [,2] [,3]
[1,]123
[2,]   10   11   12
 R
[1] 1 4 7
 S
[1] 1 4
 apply(Q, 1, '-', R)
 [,1] [,2]
[1,]09
[2,]   -27
[3,]   -45
 apply(Q, 2, '-', S)
 [,1] [,2] [,3]
[1,]012
[2,]678


[[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] simple question

2010-04-22 Thread Carl Witthoft

Or use this handy-dandy function:


smode-function(x){
xtab-table(x)
modes-xtab[max(xtab)==xtab]
mag-as.numeric(modes[1]) #in case mult. modes, this is safer
themodes-names(modes)
mout-list(themodes=themodes,modeval=mag)
return(mout)
}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 reorder of groups and specify ylim for each row in lattice barchart

2010-04-22 Thread Peter Ehlers

On 2010-04-21 21:13, zhenjiang xu wrote:

R experts,

Is there anyway to reorder inside each group? In the following example, the
bar of year 1932 is always plotted before the bar of year 1931, may I change
the order inside each groups of bars?



Do you mean a different order in different panels? That seems to
me to defeat the purpose of panels. I can't think of an easy way
to do that.


library(lattice)
barchart(yield ~ variety | site,data=barley, groups = year, layout =
c(1,6),auto.key = list(points = FALSE, rectangles = TRUE, space =
right),ylab = Barley Yield (bushels/acre),scales = list(x = list(rot =
45)))


Another questions is: may I specify the various ranges of y axis for each
row of the panels? In the example of above, how can I change the y range of
Waseca panel to (40,70) from the default (0,80)? Please notice I don't
want to set arguement scales = list(y=list(relation='free')), for the
automatic various setting of ranges for different panels isn't good enough
for me. Basically I'd like to manually control y ranges.


You can use scales() with
 y=list(relation='free', ylim=mylist)

where mylist is a list of ylims:
 mylim - list(c(0,30), c(40,80), )

 -Peter Ehlers



Thank you!


--
Peter Ehlers
University of Calgary

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] cell-based high-throughput chemical compound screens package?

2010-04-22 Thread Zoppoli, Gabriele (NIH/NCI) [G]
Hi

I'm looking for a package to perform quality control, normalization and 
analysis of high throughput cell-based chemical screens. I know that the 
cellHTS2 package provides this for siRNA screens.

Does anybody know if something like what I'm looking for exists?

Thank you!


Gabriele Zoppoli, MD
Ph.D. Fellow, Experimental and Clinical Oncology and Hematology, University of 
Genova, Genova, Italy
Guest Researcher, LMP, NCI, NIH, Bethesda MD

Work: 301-451-8575
Mobile: 301-204-5642
Email: zoppo...@mail.nih.gov

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

2010-04-22 Thread Felix Andrews
You are plotting the entire lattice plot (including axes, margins etc)
in the grid viewport. What you want to do is to call the panel
function, panel.levelplot(), instead.

However, why not just

mm - map('worldHires', plot = FALSE)
levelplot(z~x+y,xyz, mm = mm, panel = function(..., mm) {
panel.levelplot(...)
panel.lines(mm$x, mm$y)
})


On 23 April 2010 06:16, Simon Goodman s.j.good...@leeds.ac.uk wrote:
 Thanks for those pointers making some progress now

 The following will put the levelplot on to the map, but the not with the
 co-ordinates aligned...
 The level plot appears on a slightly larger scale compared to the underlying
 map.

 In both the map and levelplot, the coordinates are in lon, lat decimal
 degrees.
 Hopefully I'm nearly there, with 1 or 2 tweaks.


 library(gridBase)
 mlat-c(n1,n2)
 mlon-c(n3,n4)
 map('worldHires', xlim = range(mlon), ylim = range(mlat))
 axis(1);axis(2);axis(3);axis(4)

 lvl.plot-levelplot(z~x+y,xyz,pretty=TRUE,at=at,col.regions=cl)
 vps - baseViewports()
 pushViewport(vps$inner, vps$figure, vps$plot)
 pushViewport(viewport(print(lvl.plot, newpage=FALSE)))
 popViewport()
 popViewport(3)

 However after the line 'pushViewport(viewport(print(lvl.plot,
 newpage=FALSE)))' an error is returned:

 Error in unit(x, default.units) :
  (list) object cannot be coerced to type 'double'







 --
 View this message in context: 
 http://r.789695.n4.nabble.com/overlaying-a-levelplot-on-a-map-plot-tp2019419p2021128.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.




-- 
Felix Andrews / 安福立
Postdoctoral Fellow
Integrated Catchment Assessment and Management (iCAM) Centre
Fenner School of Environment and Society [Bldg 48a]
The Australian National University
Canberra ACT 0200 Australia
M: +61 410 400 963
T: + 61 2 6125 4670
E: felix.andr...@anu.edu.au
CRICOS Provider No. 00120C
-- 
http://www.neurofractal.org/felix/

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

2010-04-22 Thread Claus O'Rourke
Dear all,

I have a couple of short noob questions for whoever can take them. I'm
from a very non-stats background so sorry for offending anybody with
stupid questions ! :-)

I have been using logistic regression care of glm to analyse a binary
dependent variable against a couple of independent variables. All has
gone well so far. In my work I have to compare the accuracy of
analysis to a C4.5 machine learning approach. With the machine
learning, a straight-forward measure of the quality of the classifier
is simply the percentage of correctly classified instances. I can
calculate this for the resultant model by comparing predictions to
original values 'manually'. My question: is this not automatically -
or easily - calculated in the produced model or the summary of that
model?

I want to use my model in real time to produce results for new inputs.
Basically this model is to be used as a classifier for a robot in real
time. Can anyone suggest the best way that a produced model can be
used directly in external code once the model has been developed in R?
If my external code is in Java, then using jri is one option. A more
efficient method would be to take the intercept and coefficients and
actually code up the function in the appropriate programming language.
Has anyone ever tried doing this?

Apologies again for the stupid questions, but the sooner I get some of
these things straight, the better.

Claus

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

2010-04-22 Thread rusers.sh
Hi ,
  This maybe a bug. I checked my another package, the same problem occurred.
See below for detailed information.
##check log##
* using log directory 'D:/StatSoft/R/MyPackage/sbar.Rcheck'
* using R version 2.10.1 (2009-12-14)
* using session charset: ISO8859-1
* checking for file 'sbar/DESCRIPTION' ... OK
* this is package 'sbar' version '0.0-1'
* checking package name space information ... OK
* checking package dependencies ... OK
* checking if this is a source package ... OK
* checking for executable files ... OK
* checking whether package 'sbar' can be installed ... OK
* checking package directory ... OK
* checking for portable file names ... OK
* checking DESCRIPTION meta-information ... OK
* checking top-level files ... OK
* checking index information ... OK
* checking package subdirectories ... OK
* checking R files for non-ASCII characters ... OK
* checking R files for syntax errors ... OK
* checking whether the package can be loaded ... OK
* checking whether the package can be loaded with stated dependencies ... OK
* checking whether the name space can be loaded with stated dependencies ...
OK
* checking for unstated dependencies in R code ... OK
* checking S3 generic/method consistency ... OK
* checking replacement functions ... OK
* checking foreign function calls ... OK
* checking R code for possible problems ... OK
* checking Rd files ... OK
* checking Rd metadata ... OK
* checking Rd cross-references ... OK
* checking for missing documentation entries ... OK
* checking for code/documentation mismatches ... OK
* checking Rd \usage sections ... OK
* checking examples ... ERROR
Running examples in 'sbar-Ex.R' failed.
###sbar-Ex.R###
### * HEADER
###
attach(NULL, name = CheckExEnv)
assign(nameEx,
   local({
   s - __{must remake R-ex/*.R}__
   function(new) {
   if(!missing(new)) s - new else s
   }
   }),
   pos = CheckExEnv)
## Add some hooks to label plot pages for base and grid graphics
assign(base_plot_hook,
   function() {
   pp - par(c(mfg,mfcol,oma,mar))
   if(all(pp$mfg[1:2] == c(1, pp$mfcol[2]))) {
   outer - (oma4 - pp$oma[4])  0; mar4 - pp$mar[4]
   mtext(sprintf(help(\%s\), nameEx()), side = 4,
 line = if(outer)max(1, oma4 - 1) else min(1, mar4 - 1),
   outer = outer, adj = 1, cex = .8, col = orchid, las=3)
   }
   },
   pos = CheckExEnv)
assign(grid_plot_hook,
   function() {
   grid::pushViewport(grid::viewport(width=grid::unit(1, npc) -
  grid::unit(1, lines), x=0, just=left))
   grid::grid.text(sprintf(help(\%s\), nameEx()),
   x=grid::unit(1, npc) + grid::unit(0.5,
lines),
   y=grid::unit(0.8, npc), rot=90,
   gp=grid::gpar(col=orchid))
   },
   pos = CheckExEnv)
setHook(plot.new, get(base_plot_hook, pos = CheckExEnv))
setHook(persp,get(base_plot_hook, pos = CheckExEnv))
setHook(grid.newpage, get(grid_plot_hook, pos = CheckExEnv))
assign(cleanEx,
   function(env = .GlobalEnv) {
   rm(list = ls(envir = env, all.names = TRUE), envir = env)
   RNGkind(default, default)
   set.seed(1)
  options(warn = 1)
   .CheckExEnv - as.environment(CheckExEnv)
   delayedAssign(T, stop(T used instead of TRUE),
  assign.env = .CheckExEnv)
   delayedAssign(F, stop(F used instead of FALSE),
  assign.env = .CheckExEnv)
   sch - search()
   newitems - sch[! sch %in% .oldSearch]
   for(item in rev(newitems)) detach(item, character.only=TRUE)
   missitems - .oldSearch[! .oldSearch %in% sch]
   if(length(missitems))
   warning(items , paste(missitems, collapse=, ),
have been removed from the search path)
   },
   pos = CheckExEnv)
assign(ptime, proc.time(), pos = CheckExEnv)
## at least one package changes these via ps.options(), so do this
## before loading the package.
## Use postscript as incomplete files may be viewable, unlike PDF.
## Choose a size that is close to on-screen devices, fix paper
grDevices::ps.options(width = 7, height = 7, paper = a4, reset = TRUE)
grDevices::postscript(paste(pkgname, -Ex.ps, sep=))

assign(par.postscript, graphics::par(no.readonly = TRUE), pos =
CheckExEnv)
options(contrasts = c(unordered = contr.treatment, ordered =
contr.poly))
options(pager = console)
library('sbar')

assign(.oldSearch, search(), pos = 'CheckExEnv')
assign(.oldNS, loadedNamespaces(), pos = 'CheckExEnv')
cleanEx(); nameEx(stKDE.simcomp)
### * stKDE.simcomp

flush(stderr()); flush(stdout())

### Name: stKDE.simcomp
### Here, just copied my example codes, so i ignored here to save space.

### * FOOTER
###
cat(Time elapsed: , proc.time() - get(ptime, pos = 'CheckExEnv'),\n)
grDevices::dev.off()
###
### Local variables: ***
### mode: outline-minor ***
### outline-regexp: \\( \\)?### [*]+ ***
### End: ***
quit('no')



2010/4/22 Dennis Murphy djmu...@gmail.com

 Hi Jane,

 I was just hoping to 

[R] Remove duplicated rows

2010-04-22 Thread chrisli1223

Hi all,

I have a dataset similar to the following

NameDateValue
A   1/01/2000   4
A   2/01/2000   4
A   3/01/2000   5
A   4/01/2000   4
A   5/01/2000   1
B   6/01/2000   2
B   7/01/2000   1
B   8/01/2000   1

I would like R to remove duplicates based on column 1 and 3 only. In
addition, I would like R to remove duplicates based on the underlying and
overlying row only. For example, for A, I would like to remove row 2 only
and keep row 1, 3 and 4.

I have tried: unique() and replicated(), but I do not have much success. I
have also tried: dataset-c(1,diff(dataset)!=0), but I don't know how to
apply it to this multi-column situation.

Any help would be greatly appreciated.

Thanks in advance,
Chris
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Remove-duplicated-rows-tp2023065p2023065.html
Sent from the R help mailing list archive at Nabble.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.


Re: [R] User inputs

2010-04-22 Thread chrisli1223

Thank you very much Dieter and Don. This solves my problem. :)
-- 
View this message in context: 
http://r.789695.n4.nabble.com/User-inputs-tp2018251p2023067.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Practical work with logistic regression

2010-04-22 Thread Gabor Grothendieck
confusionMatrix in the caret package can be used to replace your
manual procedure.

You could try using RWeka, the R interface to the java Weka software.
Once you have it working you could then directly interface your java
program to Weka without involving R.

On Thu, Apr 22, 2010 at 9:29 PM, Claus O'Rourke claus.orou...@gmail.com wrote:
 Dear all,

 I have a couple of short noob questions for whoever can take them. I'm
 from a very non-stats background so sorry for offending anybody with
 stupid questions ! :-)

 I have been using logistic regression care of glm to analyse a binary
 dependent variable against a couple of independent variables. All has
 gone well so far. In my work I have to compare the accuracy of
 analysis to a C4.5 machine learning approach. With the machine
 learning, a straight-forward measure of the quality of the classifier
 is simply the percentage of correctly classified instances. I can
 calculate this for the resultant model by comparing predictions to
 original values 'manually'. My question: is this not automatically -
 or easily - calculated in the produced model or the summary of that
 model?

 I want to use my model in real time to produce results for new inputs.
 Basically this model is to be used as a classifier for a robot in real
 time. Can anyone suggest the best way that a produced model can be
 used directly in external code once the model has been developed in R?
 If my external code is in Java, then using jri is one option. A more
 efficient method would be to take the intercept and coefficients and
 actually code up the function in the appropriate programming language.
 Has anyone ever tried doing this?

 Apologies again for the stupid questions, but the sooner I get some of
 these things straight, the better.

 Claus

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

2010-04-22 Thread Carol Gao
thank you! this really helps!

On Thu, Apr 22, 2010 at 7:00 PM, jim holtman jholt...@gmail.com wrote:

 ?strptime

 Read the documentation and you will find reference to %OSn

  x - strptime('13:45:34.123', format=%H:%M:%OS)
  x
 [1] 2010-04-22 13:45:34
  format(x, format=%H:%M:%OS3)
 [1] 13:45:34.123
 


   On Thu, Apr 22, 2010 at 2:58 AM, Carol Gao carol.g...@gmail.com wrote:

  Hi,

 Does anyone know how to take a time difference when the format of the time
 is as 13:22:23.586? I am trying to take the difference of time between
 stock
 transactions and need to keep the three decimal places for seconds. I have
 tried *diff(strptime(x, %H:%M:%S.000))*, but apperantly that doesn't
 work.

 Carol Gao

[[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.htmlhttp://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] packages gdata / gtools - installation in R 2.11.0

2010-04-22 Thread Paulo Barata


Dear R-list members,

I have just downloaded R version 2.11.0. Then I installed
package gdata. At the end of the installation, a warning message
said that package gtools could not be found. Package gdata
was, after the installation, included in the Package Index
in the help files. Messages during installation (which was made
through the menu Packages / Instal package(s), choosing the Austria
site, R running on Windows XP):

utils:::menuInstallPkgs()
Warning: dependency ‘gtools’ is not available
trying URL 'http://cran.at.r-project.org/bin/windows/contrib
/2.11/gdata_2.7.1.zip'
Content type 'application/zip' length 830646 bytes (811 Kb)
opened URL
downloaded 811 Kb
package 'gdata' successfully unpacked and MD5 sums checked

When I tried to use (in R 2.11.0) package gdata and its function
write.fwf, I got the messages below:

library(gdata)
Error in loadNamespace(i[[1L]], c(lib.loc, .libPaths())) :
  there is no package called 'gtools'
Error: package/namespace load failed for 'gdata'
write.fwf(x,'test-01.txt')
Error: could not find function write.fwf
(** Note: x is a data frame **)

Package gdata is correctly installed in my R 2.10.1, and both
packages gdata and gtools appear in the list of available packages
when I try to install some package in R 2.10.1 through the menu
Packages / Instal package(s), choosing the Austria site.

But when I try to install some package in R 2.11.0 through the
menu, only package gdata appears in the list of available packages
- package gtools does not appear in that list.

Both packages are listed on the CRAN (Austria) package Web page.

It seems that R 2.11.0 is somehow not seeing the package gtools.
Is there any way around this situation? How to correctly install
package gdata (which depends on gtools) in R 2.11.0?

Both R 2.10.1 and R 2.11.0 are running on Windows XP, in the same
computer.

Thank you very much.

Paulo Barata


Paulo Barata
Fundacao Oswaldo Cruz - Oswaldo Cruz Foundation
Rua Leopoldo Bulhoes 1480 - 8A
21041-210  Rio de Janeiro - RJ
Brazil

E-mail: pbar...@infolink.com.br
E-mail: paulo.bar...@ensp.fiocruz.br

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

2010-04-22 Thread Frank E Harrell Jr

Claus O'Rourke wrote:

Dear all,

I have a couple of short noob questions for whoever can take them. I'm
from a very non-stats background so sorry for offending anybody with
stupid questions ! :-)

I have been using logistic regression care of glm to analyse a binary
dependent variable against a couple of independent variables. All has
gone well so far. In my work I have to compare the accuracy of
analysis to a C4.5 machine learning approach. With the machine
learning, a straight-forward measure of the quality of the classifier
is simply the percentage of correctly classified instances. I can
calculate this for the resultant model by comparing predictions to
original values 'manually'. My question: is this not automatically -
or easily - calculated in the produced model or the summary of that
model?


The percent classified correctly is an improper scoring rule that will 
lead to a selection of a bogus model.  You can easily find examples 
where adding a very important variable to a binary logistic model 
results in a decrease in the percent correct.


Frank



I want to use my model in real time to produce results for new inputs.
Basically this model is to be used as a classifier for a robot in real
time. Can anyone suggest the best way that a produced model can be
used directly in external code once the model has been developed in R?
If my external code is in Java, then using jri is one option. A more
efficient method would be to take the intercept and coefficients and
actually code up the function in the appropriate programming language.
Has anyone ever tried doing this?

Apologies again for the stupid questions, but the sooner I get some of
these things straight, the better.

Claus

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




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

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


[R] help with plotting lines linking two sets of points?

2010-04-22 Thread Kristiina Hurme

Hello everyone, 
I'm trying to plot the initial and final size of some tadpoles and look at
their growth rates (slope of line). They are divided into 6 densities, and
so far I have plotted the initial and final sizes (these are means for a
pool), and color coded for the 6 densities, but I want a line to connect the
initial and final value for each pool (also color coded by density). Any
ideas?
I'm hoping to see what the effect of density is on growth, and there are 4
replicates for each density. The initial and final sizes are staggered, 1/2
were measured at age 7.3 and 11, and the other 1/2 were measured at age 8.5
and 12.

here's a sample

 pool age age2 density body_length body_length2
11 7.4 11.3  25   0.887 1.322550
22 7.4 11.3 100   0.921 1.152000
33 7.4 11.3 250   0.896 1.136300
44 7.4 11.3  75   0.723 0.955950
55 7.4 11.3 500   0.755 1.113300
66 7.4 11.3  50   0.869 1.169833

and as far as i've gotten
 plot(age,body_length,pch=as.numeric(school), col=as.numeric(density),
 xlim=c(6,13), ylim=c(0.7,1.6))
 points(age2, body_length2, pch=as.numeric(school),
 col=as.numeric(density))

http://n4.nabble.com/forum/FileDownload.jtp?type=nid=2023096name=Screen_shot_2010-04-22_at_11.03.08_PM.png
 

thanks! kristiina

-- 
View this message in context: 
http://r.789695.n4.nabble.com/help-with-plotting-lines-linking-two-sets-of-points-tp2023096p2023096.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.


  1   2   >