Re: [R] Interface to open source Reporting tools

2009-01-15 Thread Philippe Grosjean

Dieter Menne wrote:

srinivasa raghavan srinivasraghav at gmail.com writes:


I am interested to generate  dashboard and reports based on data from  MS
Access.  These reports need to be posted on a weekly basis to the web. The
reporting interface should provide facilities for what if scenarios.

Is it possible to interface R analysis results to good open source reporting
tools like Jasper Reports. what is the appropriate system requirements for
carrying out real time reporting using R.


You could use package XML to produce jrxml output; or, probably easier for not
too complex reports, HTML could be generated by RHTML directly, including 
images.


You probably mean R2HTML?
Best,

Philippe


Dieter

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] [r] How to Solve the Error( error:cannot allocate vector of size 1.1 Gb)

2009-01-15 Thread Kum-Hoe Hwang
Hi, Gurus

Thanks to your good helps, I have managed starting the use of a text
mining package so called tm in R under the OS of Win XP.

However, during running the tm package, I got another mine like memory problem.

What is a the best way to solve this memory problem among increasing a
physical RAM, or doing other recipes, etc?

###
## my R Script's Outputs ##
###

 memory.limit(size = 2000)
NULL
 corpus.ko - Corpus(DirSource(test_konews/),
+  readerControl = list(reader = readPlain,
+  language = UTF-8, load = FALSE))
 corpus.ko.nowhite - tmMap(corpus.ko, stripWhitespace)
 corpus - tmMap(corpus.ko.nowhite, tmTolower)
 tdm - TermDocMatrix(corpus)
  findAssocs(tdm, city, 0.97)
error:cannot allocate vector of size 1.1 Gb
-


Thanks for your precious time,

--
Kum-Hoe Hwang, Ph.D.

Phone : 82-31-250-3516
Email : phdhw...@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] R package tests

2009-01-15 Thread Philippe Grosjean
There is a mechanism for testing code in R packages (R CMD check), see 
the Writing R extensions manual. If you need more flexibility for your 
tests, you could look at RUnit on CRAN, or svUnit on R-Forge 
(http://r-forge.r-project.org, on CRAN soon). For the later one, you 
install it by:


install.packages(svUnit, repos=http://R-Forge.R-project.org;)

These is a vignette associated with svUnit:

vignette(svUnit)

Note that RUnit and svUnit are test suite code compatible, but they 
use very different mechanisms internally.

Best,

Philippe Grosjean

..°}))
 ) ) ) ) )
( ( ( ( (Prof. Philippe Grosjean
 ) ) ) ) )
( ( ( ( (Numerical Ecology of Aquatic Systems
 ) ) ) ) )   Mons-Hainaut University, Belgium
( ( ( ( (
..

Nathan S. Watson-Haigh wrote:

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

I was wondering if anyone could point me in the right direction for reading up 
on writing tests in
R. I'm writing some functions for inclusion into a package and would like to 
test them to ensure
they're doing what I expect them to do.

Are these approaches used for testing packages in CRAN?

Cheers,
Nathan


- --
- 
Dr. Nathan S. Watson-Haigh
OCE Post Doctoral Fellow
CSIRO Livestock Industries
Queensland Bioscience Precinct
St Lucia, QLD 4067
Australia

Tel: +61 (0)7 3214 2922
Fax: +61 (0)7 3214 2900
Web: http://www.csiro.au/people/Nathan.Watson-Haigh.html
- 

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkluio8ACgkQ9gTv6QYzVL5X9QCgwvg5xjwZW2A2Z5G41iADu1Kz
hIkAoI5ISuAtHyQ+JwJSRBAc9q/oyeEt
=cqm4
-END PGP SIGNATURE-

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

2009-01-15 Thread Petr PIKAL
Hi

r-help-boun...@r-project.org napsal dne 15.01.2009 04:47:39:

 
 Dear R-Users
 if I have a data frame (or zoo data) as follows:
 
 Run  Bike Walk Drive
 1   2  7 5
 5   2  4 2 
 8   3  2 1
 
 How can I re-order it so that it reads: 
 
 Drive Run  Bike Walk 
   5  1  2 7 
   2  5  2 4 
   1  8  3 2 
 i.e. Drive has been copied and pasted to the left most column.

 test
  Run Bike Walk Drive
1   127 5
2   524 2
3   832 1

test2 - test[, c(4,1,2,3)]
  Drive Run Bike Walk
1 5   127
2 2   524
3 1   832

if you want it in new data frame or

test - test[, c(4,1,2,3)]

if you want to overwrite it.

Regards
Petr


 
 Thanks for your help.
 
 James
 -- 
 View this message in context: http://www.nabble.com/Moving-a-Data-Frame-
 Column-tp21470798p21470798.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] R package tests

2009-01-15 Thread Robin Hankin

I think the OP was asking about test suites that test the software.

The R package structure includes a test/ directory which you can use
to put tests.

For example, in the onion package I check that I have got my
signs and multiplication table correctly implemented:

 stopifnot(Hi*Hj ==  Hk)
 stopifnot(Hj*Hi == -Hk)
 stopifnot(Hj*Hk ==  Hi)
 stopifnot(Hk*Hj == -Hi)
 stopifnot(Hk*Hi ==  Hj)
 stopifnot(Hi*Hk == -Hj)

[and a whole lot of others]

and the elliptic package includes a whole bunch of code
that verifies identities that appear in AMS-55.  It also
includes numerical  verification that the functions,
using randomish arguments, match the output of
mathematica or maple.





Philippe Grosjean wrote:
There is a mechanism for testing code in R packages (R CMD check), see 
the Writing R extensions manual. If you need more flexibility for your 
tests, you could look at RUnit on CRAN, or svUnit on R-Forge 
(http://r-forge.r-project.org, on CRAN soon). For the later one, you 
install it by:


install.packages(svUnit, repos=http://R-Forge.R-project.org;)

These is a vignette associated with svUnit:

vignette(svUnit)

Note that RUnit and svUnit are test suite code compatible, but they 
use very different mechanisms internally.

Best,

Philippe Grosjean

..°}))
 ) ) ) ) )
( ( ( ( (Prof. Philippe Grosjean
 ) ) ) ) )
( ( ( ( (Numerical Ecology of Aquatic Systems
 ) ) ) ) )   Mons-Hainaut University, Belgium
( ( ( ( (
..

Nathan S. Watson-Haigh wrote:

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

I was wondering if anyone could point me in the right direction for 
reading up on writing tests in
R. I'm writing some functions for inclusion into a package and would 
like to test them to ensure

they're doing what I expect them to do.

Are these approaches used for testing packages in CRAN?

Cheers,
Nathan


- --
- 
Dr. Nathan S. Watson-Haigh
OCE Post Doctoral Fellow
CSIRO Livestock Industries
Queensland Bioscience Precinct
St Lucia, QLD 4067
Australia

Tel: +61 (0)7 3214 2922
Fax: +61 (0)7 3214 2900
Web: http://www.csiro.au/people/Nathan.Watson-Haigh.html
- 

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkluio8ACgkQ9gTv6QYzVL5X9QCgwvg5xjwZW2A2Z5G41iADu1Kz
hIkAoI5ISuAtHyQ+JwJSRBAc9q/oyeEt
=cqm4
-END PGP SIGNATURE-

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html

and provide commented, minimal, self-contained, reproducible code.




__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html

and provide commented, minimal, self-contained, reproducible code.


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


Re: [R] Logical function to turn missing values to 0's

2009-01-15 Thread ONKELINX, Thierry
Use the is.na function to test for NA values. And do read about
vectorizing your code. You don't need loops for this problem. Without
loops your code will run more than 400 times faster!

 n - 1000
 x - matrix(data=rep(c(1,2,3,NA), n), ncol=n, nrow=n)
 
 system.time({
+ y - matrix(data=0, ncol=ncol(x), nrow=nrow(x))
+ for(i in 1:nrow(x)) {
+ for(j in 1:ncol(x)) {
+ y[i,j] - ifelse(is.na(x[i,j]), 0, x[i,j])
+ }
+ }
+ })
   user  system elapsed 
  45.170.30   45.61 
 system.time(y - ifelse(is.na(x), 0, x))
   user  system elapsed 
   0.600.150.75 
 system.time({
+ y - x
+ y[is.na(x)] - 0
+ })
   user  system elapsed 
   0.110.000.11 




ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium 
tel. + 32 54/436 185
thierry.onkel...@inbo.be 
www.inbo.be 

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ Roger Brinner

The combination of some data and an aching desire for an answer does not
ensure that a reasonable answer can be extracted from a given body of
data.
~ John Tukey

-Oorspronkelijk bericht-
Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
Namens rafamoral
Verzonden: woensdag 14 januari 2009 23:32
Aan: r-help@r-project.org
Onderwerp: [R] Logical function to turn missing values to 0's


I have a dataset which contains some missing values, and I need to
replace
them with zeros. I tried using the following:

x - matrix(data=rep(c(1,2,3,NA),6), ncol=6, nrow=6)

y - matrix(data=0, ncol=ncol(x), nrow=nrow(x))

for(i in 1:nrow(x)) {

for(j in 1:ncol(x)) {

y[i,j] - ifelse(x[i,j]==NA, 0, x[i,j])

}}

But y returns an NA matrix.
I'd appreciate any help.
-- 
View this message in context:
http://www.nabble.com/Logical-function-to-turn-missing-values-to-0%27s-t
p21466785p21466785.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.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.

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

2009-01-15 Thread baptiste auguie

For the record, I thought I'd share two findings:

First, the web of science website does seem to have some sort of API,  
as discussed here:


http://scientific.thomson.com/support/faq/webservices/
It does not seem like a trivial thing to set up though.

Second, because I could not pass the search term easily in the  
address, I looked into Google scholar instead, where a typical search  
looks like:

http://scholar.google.co.uk/scholar?as_q=plasmonicsnum=10btnG=Search+Scholaras_epq=as_oq=as_eq=as_occt=anyas_sauthors=as_publication=as_ylo=as_yhi=1960as_allsubj=allhl=enlr=

here it is trivial to create such a string with the desired keyword  
and dates, and retrieve the number of results using readLines(url) and  
grep.



Thanks to Phil Spector for some pointers.

Best wishes,

baptiste


On 14 Jan 2009, at 13:44, baptiste auguie wrote:


Dear list,

This is a bit of an off-topic question, but I'm hoping to get some
advice from more experienced people. I've used the website Web of
Science to manually collect publication counts responding to several
keywords as a function of date, since the 1960s.

http://apps.isiknowledge.com/RAMore.do?product=UAsearch_mode=sid=p1g9lf...@eja6pjhkdqid=1ra_mode=morera_name=PublicationYeardb_id=UGBviewType=raMore

This is a really long and error-prone process. Once the data was
collected I rearranged it in a form R could read (see example in the
end), this step wasn't too bad. Finally, I plotted histograms to show
the temporal trends.

I have two questions:

- Is there a package or external tool to facilitate the collection of
data from this kind of online search tool? I could not find any public
API for this website, although some tools like Endnote clearly access
the database somehow. I'd be very grateful for any pointer.

- I feel like the display and choice of search terms is very arbitrary
and subjective. Any general advice on how to present this data better
is most welcome. (I should mention that i'd rather not  involve any
complicated statistical analysis, I only want to make sure that the
presentation is not horribly biased).


Best regards,

baptiste


statistics - list(list(values=read.table(textConnection(
date count
2007 600
2006 588
2008 555
2005 430
2004 418
2003 334
2002 277
2001 239
2000 226
1997 184
1999 184
1998 182
1996 129
1995 108
1994 92
1993 67
1992 53
1991 47
1990 37
1989 14
1988 11
1983 10
1987 7
1985 6
1986 6
1981 5
1984 5
1979 4
1982 4
2009 3
1971 2
1933 1
1973 1
1974 1
1977 1
1978 1
1980 1), head=T),type=1, cumSum=4833, search=photonics),
list(values=read.table(textConnection(
date count
2008 129
2007 92
2006 50
2005 26
2004 15
2003 4
1972 1
2001 1
2002 1), head=T),type=1, cumSum=319, search=plasmonics),
list(values=read.table(textConnection(
date count
2008 3207
2007 3105
2006 2666
2005 2323
2004 1910
2003 1552
2002 1372
2001 1292
2000 1095
1999 992
1998 863
1997 771
1996 643
1995 484
1993 418
1994 407
1992 345
1991 321
1990 120
1989 91
1988 82
1987 78
1981 77
1986 73
1983 72
1978 69
1979 68
1985 66
1976 63
1975 62
1980 59
1984 54
1982 52
1973 50
1977 50
1972 46
1974 43
1971 38
1969 28
1970 28
2009 26
1968 18
1967 11
1966 8
1962 5
1963 4
1900 3
1960 3
1961 3
1948 2
1912 1
1949 1
1950 1
1953 1
1954 1
1959 1
1964 1
1965 1), head=T),type=1, cumSum=25226, search=plasmonics+ plasmon),
list(values=read.table(textConnection(
date count
2008 2716
2007 2640
2006 2257
2005 1991
2004 1625
2003 1302
2002 1129
2001 1056
2000 862
1999 814
1998 650
1997 574
1996 427
1995 338
1994 272
1993 260
1991 187
1992 176
1990 62
1989 51
1981 41
1988 41
1987 36
1986 32
1983 30
1980 29
1982 28
1984 28
1985 27
1975 25
1976 23
2009 23
1973 22
1979 22
1972 15
1974 15
1977 13
1971 10
1978 10
1970 9
1968 7
1969 7
1966 1  ), head=T),type=2, cumSum=19883, search=surface plasmon),
list(values=read.table(textConnection(
date count
2008 324
2007 295
2006 248
2005 220
2004 156
2003 126
2002 113
2000 86
2001 84
1996 66
1999 59
1997 53
1998 53
1993 39
1992 34
1994 29
1995 29
1991 25
1973 2
1987 2
1970 1
1972 1
1978 1
1983 1
1984 1
1989 1
2009 1  ), head=T),type=2, cumSum=2050, search=localised or particle
plasmon),
list(values=read.table(textConnection(
date count
2007 196
2008 165
2005 141
2006 141
2003 112
2004 109
2002 83
2001 75
1999 62
2000 51
1998 38
1997 29
1995 13
1996 11
1993 6
1992 4
1994 4
1991 2
2009 2
1990 1), head=T),type=2, cumSum=1245, search=SPR sensor),
list(values=read.table(textConnection(
date count
2008 290
2007 225
2006 167
2005 138
2004 101
2003 79
2001 54
2002 51
2000 42
1998 31
1999 30
1997 27
1996 25
1992 20
1995 20
1991 15
1994 14
1993 10
1973 2
1984 2
1990 2
2009 2
1963 1
1972 1
1974 1
1977 1
1978 1
1982 1
1983 1
1988 1
1989 1), head=T), cumSum=1356,type=1,  search=light scattering  
gold))


str(statistics)

treatOne - function(ml){
   data.frame(ml$values, search= as.character(ml$search))
}
# treatOne(statistics[[1]])

library(plyr)
stats.list - llply(statistics[-3], treatOne)
stats.df - do.call(rbind, stats.list)

stats.melt - melt(stats.df, 

Re: [R] R package tests

2009-01-15 Thread ml-r-help
Hi Nathan,

in addition to what others have already mentioned there is some documentation
in the Writing R Extensions Manual:
- on the supported structure of packages, indicating where test code might be 
added
 
http://stat.ethz.ch/R-manual/R-patched/doc/manual/R-exts.html#Package-subdirectories
- and the recommended standard approach to check a package
http://stat.ethz.ch/R-manual/R-patched/doc/manual/R-exts.html#Checking-and-building-packages

and a wiki article on how to combine the standard check (viz R CMD check) with 
any of the
unit testing approaches
http://wiki.r-project.org/rwiki/doku.php?id=developers:runits=unit%20test

Examples for the standard approach employed by R can be found
in the R source repository
https://svn.r-project.org/R/trunk/src/library/stats/tests/

and for unit test based checking
e.g. Rmetrics
http://r-forge.r-project.org/plugins/scmsvn/viewcvs.php/pkg/?root=rmetrics

or BioConductor examples
https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/Biobase/inst/UnitTests/
where you need the access info provided here
http://wiki.fhcrc.org/bioc/DeveloperPage


Regards,

 Matthias

Nathan S. Watson-Haigh wrote:
 I was wondering if anyone could point me in the right direction for reading 
 up on writing tests in
 R. I'm writing some functions for inclusion into a package and would like to 
 test them to ensure
 they're doing what I expect them to do.
 
 Are these approaches used for testing packages in CRAN?
 
 Cheers,
 Nathan
 
 

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



-- 
Matthias Burger Project Manager/ Biostatistician
Epigenomics AGKleine Praesidentenstr. 110178 Berlin, Germany
phone:+49-30-24345-371  fax:+49-30-24345-555
http://www.epigenomics.com   matthias.bur...@epigenomics.com
--
Epigenomics AG Berlin   Amtsgericht Charlottenburg HRB 75861
Vorstand:   Geert Nygaard (CEO/Vorsitzender)
Oliver Schacht PhD (CFO)
Aufsichtsrat:   Prof. Dr. Dr. hc. Rolf Krebs (Chairman/Vorsitzender)

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 create a chromosome location map by locus ID

2009-01-15 Thread Sake

Hi,

I'm trying to make a chromosomal map in R by using the locus. I have a list
of genes and their locus, and I want to visualise that so you can see if
there are multiple genes on a specific place on a chromosome. A example of
what I more or less want is below:
http://www.nabble.com/file/p21474206/untitled.JPG untitled.JPG 
The genes and locus are here:
http://www.nabble.com/file/p21474206/genlocus.csv genlocus.csv 
I've tried some things, but nothing worked like I would like it to see.
Maybe there is some kind of package that does this for you, but I did not
find it yet.
Thanx

Sake
-- 
View this message in context: 
http://www.nabble.com/How-to-create-a-chromosome-location-map-by-locus-ID-tp21474206p21474206.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] Kaplan-Meier Plot

2009-01-15 Thread John Lande
thank you,

it worked properly.

On Thu, Jan 15, 2009 at 4:53 AM, Marc Schwartz marc_schwa...@comcast.netwrote:

 on 01/14/2009 03:32 PM John Lande wrote:
  dear all,
 
  I want to plot a kaplan Meier plot with the following functions, but I
 fail
  to produce the plot I want:
 
  library(survival)
  tim - (1:50)/6
  ind - runif(50)
  ind[ind  0.5] - 1; ind[ind  0.5] - 0;
  MS - runif(50)
  pred - vector()
  pred[MS  0.3] - 0; pred[MS = 0.3] - 1
  df - as.data.frame(cbind(MS, tim, pred, ind))
  names(df) - c(MS, time, pred, class)
  df$time[df$time  6] - 6
  surv - Surv(as.numeric(as.vector(df$time)),
  as.numeric(as.vector(df$class)))
  dfPval - summary(coxph(Surv(as.numeric(as.vector(df$time)),
  as.numeric(as.vector(df$class))) ~ pred, df))$sctest
  par(mfrow = c(2,2))
  plot(survfit(surv ~ df$pred), col=c(red,green), ylab = percentage of
  survival, xlab = survival years)
  plot(survfit(surv ~ df$pred), col=c(red,green), lwd = 8, ylab =
  percentage of survival, xlab = survival years)
  plot(survfit(surv ~ df$pred), col=c(red,green), lwd = 8, ylab =
  percentage of survival, xlab = survival years, cex = 2)
 
  I would like to increase the tickness of the censorship's pitch. as you
 can
  see with cex = 2, I can elongate the arms of the censorship, but I cant
 find
  how to increase the tickness of the pitch.
 
  how to do this?

 John,

 Is this what you want?


 par(mfrow = c(2, 1))

 # Normal plot
 plot(survfit(Surv(time, status) ~ x, data = aml))


 # Set par(lwd = 3) to increase the thickness of the censoring marks
 # Don't frame the plot region, as it uses par(lwd)
 par(lwd = 3)
 plot(survfit(Surv(time, status) ~ x, data = aml), frame = FALSE)

 # Reset par(lwd) to normal to frame the plot region
 par(lwd = 1)
 box()


 Note that given the way in which the plot code has been set up, using
 'lwd' in the function call affects the survivorship function line and
 not the censoring marks. By setting par(lwd = 3) prior to the plot call,
 this will be used internally when the marks are plotted using points(),
 without affecting the other lines, save the plot region frame.

 Just so that you don't think that you missed something obvious, this was
 a little trial and error after reviewing the R code for
 survival:::plot.survfit to see how the arguments from the function call
 are passed to the internal plotting functions. Combined also with some
 knowledge of how the graphic pars are handled...

 HTH,

 Marc Schwartz



[[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] regexp problem (was: Re: publication statistics from Web of Science)

2009-01-15 Thread baptiste auguie

Whoops, it seems I could use some help with regular expressions...

Consider the following two functions, creating a search string, and  
retrieving the content from the url,


makeURLsearch - function(key, dates=c(NULL, NULL)){

base.search - http://scholar.google.co.uk/scholar?;
key.search - paste(as_q=, key,,  sep=)
	other.search - num=10btnG=Search 
+ 
Scholar 
as_epq=as_oq=as_eq=as_occt=anyas_sauthors=as_publication=
	dates.search - paste(as_ylo=, dates[1], as_yhi=, dates[2],  
as_allsubj=allhl=enlr=, sep=)


	full.search - paste(base.search, key.search, other.search,  
dates.search, sep=)

return(full.search)
}


makeURLsearch(plasmonics)
makeURLsearch(photonics, c(1980, NULL))

retrieveNumberPublications - function(url){

x - readLines(url)
y - grep('of about',x, value=TRUE)
	z - gsub('of about\\s+/b','\\1',y[1],perl=TRUE) # this does not  
do what I wanted


# the bit to retrieve is the number below
#  b10/b of about b21,900/b for bbphotonics/b
z
}

retrieveNumberPublications( makeURLsearch(photonics, c(2008,  
NULL)) )


I can isolate the long string containing the result I want, but not  
single out the value which lies between  b10/b of about  
b21,900/b for bbphotonics/b  .


Any regexp guru to help me out? I've never got my head around these,  
other than trivial cases.


Many thanks,

baptiste


On 15 Jan 2009, at 09:45, baptiste auguie wrote:


For the record, I thought I'd share two findings:

First, the web of science website does seem to have some sort of API,
as discussed here:

http://scientific.thomson.com/support/faq/webservices/
It does not seem like a trivial thing to set up though.

Second, because I could not pass the search term easily in the
address, I looked into Google scholar instead, where a typical search
looks like:
http://scholar.google.co.uk/scholar?as_q=plasmonicsnum=10btnG=Search+Scholaras_epq=as_oq=as_eq=as_occt=anyas_sauthors=as_publication=as_ylo=as_yhi=1960as_allsubj=allhl=enlr=

here it is trivial to create such a string with the desired keyword
and dates, and retrieve the number of results using readLines(url) and
grep.


Thanks to Phil Spector for some pointers.

Best wishes,

baptiste


_

Baptiste Auguié

School of Physics
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK

Phone: +44 1392 264187

http://newton.ex.ac.uk/research/emag

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

2009-01-15 Thread Holger Kömm
Ladies and gentlemen,

 

this email is directed to all German-speaking members of the r-help list.

 

We from the chair of statistics and quantitative methods on the Catholic
University of Eichstätt-Ingolstadt, Germany, are searching for a new
colleague. You will find the corresponding job offer in the attachment.

 

If you are interested, please don´t shy and send us your application on the
address, called in the attachment.

 

You can also find the job offer on 

 

http://www.ku-eichstaett.de/stellenausschreibungen/stellen/wissenschaftlich/
HF_sections/content/ZZiQGkU3pLDLYB

 

Yours sincerely,

Holger Kömm

  _  

Holger Kömm
holger.ko...@ku-eichstaett.de

LSQM - Lehrstuhl für Statistik und Quantitative Methoden
Prof. Dr. Ulrich Küsters
Auf der Schanz 49
85049 Ingolstadt

Fon:   +49 841 937-1847
Fax:   +49 841 937-1965



 



Ausschreibung-WiMa-Statistik-www ku-eichstaett.pdf
Description: Adobe PDF document
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] remove columns containing all zeros (or other value)

2009-01-15 Thread Jim Lemon

How about:

remove.constant.values-function(x,MARGIN,value2remove) {
is.constant.line-function(x,value2remove) { return(any(x!=value2remove)) }
return(unlist(apply(x,MARGIN,is.constant.line,value2remove)))
}

x[,remove.constant.values(x,2,0)]

Jim

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


[R] Seemingly Unrelated Negative Binomial (SUNB) estimation

2009-01-15 Thread Elisa Lanzi
Dear all,
I am trying to estimate a system of equations with a Seemingly Unrelated
Regression. However because of the characteristics of the data I'd like to
do it with a negative binomial estimation. Would anybody know how to
implement a Seemingly Unrelated Negative Binomial (SUNB) estimation in R?
Thank you in advance for your help.
Best regards,
Elisa Lanzi


-- 
Elisa Lanzi
PhD student in Economics and Organisation
School of Advanced Studies in Venice (SSAV)
email: elisa.la...@unive.it
website: http://venus.unive.it/elisa.lanzi

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Summary of Total Object.Size in R Script

2009-01-15 Thread Gundala Viswanath
Sorry for my late reply.

Thank you so much Jim. This script of yours
is very2 useful. I have used it.

- Gundala Viswanath
Jakarta - Indonesia



On Wed, Jan 14, 2009 at 12:17 AM, jim holtman jholt...@gmail.com wrote:
 Here is a function I use to see how big the objects in my workspace are:

 my.ls -
 + function (pos = 1, sorted = F)
 + {
 + .result - sapply(ls(pos = pos, all.names = TRUE), function(..x)
 object.size(eval(as.symbol(..x
 + if (sorted) {
 + .result - rev(sort(.result))
 + }
 + .ls - as.data.frame(rbind(as.matrix(.result), `**Total` = 
 sum(.result)))
 + names(.ls) - Size
 + .ls$Size - formatC(.ls$Size, big.mark = ,, digits = 0,
 + format = f)
 + .ls$Mode - c(unlist(lapply(rownames(.ls)[-nrow(.ls)],
 function(x) mode(eval(as.symbol(x),
 + ---)
 + .ls
 + }
 my.ls()
  SizeMode
 .my.env 28 environment
 .Random.seed 2,528 numeric
 .required   72   character
 my.ls6,712function
 **Total  9,340 ---


 On Tue, Jan 13, 2009 at 9:53 AM, Gundala Viswanath gunda...@gmail.com wrote:
 Dear all,

 Is there a way we can find the total object.size of
 all the objects in our R script?

 The reason we want to do this because we want to know
 how much memory does our R script require overall.

 Rprofmem(), doesn't seem to do it.

 and Unix 'top' command is dynamic and
 it doesn't give the exact byte size.

 - Gundala Viswanath
 Jakarta - Indonesia

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




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

 What is the problem that you are trying to solve?


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


Re: [R] noise in time series

2009-01-15 Thread Gerard M. Keogh
Hi,

here's a possibility!

Your problem can be restated as given 2 observers giving 2 measures what
is their level of agreement - the classical measure here is the Kappa (see
sec 10.5 of Categorical Data Analysis by Alan Agresti (in Ed 1 - Ed 2
should also have it!) and you can also model the situation (same section of
book).

I had a similar problem comparing time series modelled by two (or more)
different methods in my PhD some years back. I had several series so it was
a bit easier.

Obviously, it's a bit of a problem with 2 time series but if they are
sufficiently long (say 200+ obs) you could proceed as follows:

   Take k sub-sample series of length say 35+ obs.
   Then fit say about 5 different arima models to each (if you know
   seasonal adjustment X11ARIMA the 5 basic models used there are good
   options - I can't remember them!)

   You can now create a 2X2 table (method 1 X method 2) each with 5 outcome
   model types and then count the number of models falling into each cell.
   Then apply the agreement measure!

Obviously, there will be dependence across the selected series that will
not be accounted for in the outcome frequencies, but if the time series are
reasonably long this shouldn't be too bad.

good luck with it!

Gerard





   
 Dieter Menne  
 dieter.me...@men 
 ne-biomed.de  To 
 Sent by:  r-h...@stat.math.ethz.ch
 r-help-boun...@r-  cc 
 project.org   
   Subject 
   Re: [R] noise in time series
 15/01/2009 07:54  
   
   
   
   
   




David Riano driano at ucdavis.edu writes:

 I have two time series. Both measure the same thing and I would like
 to determine which one is noisier.
 Would it be a good measure of the noise in each time series the
 absolute lag difference?
 Is this a good measure? Any other measure I could use?

You could fit an arima model and compare the residuals. It should
be could enough to get an estimate, even if I see some theoretical
problems in measure the same thing.

Dieter

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



**
The information transmitted is intended only for the person or entity to which 
it is addressed and may contain confidential and/or privileged material. Any 
review, retransmission, dissemination or other use of, or taking of any action 
in reliance upon, this information by persons or entities other than the 
intended recipient is prohibited. If you received this in error, please contact 
the sender and delete the material from any computer.  It is the policy of the 
Department of Justice, Equality and Law Reform and the Agencies and Offices 
using its IT services to disallow the sending of offensive material.
Should you consider that the material contained in this message is offensive 
you should contact the sender immediately and also mailminder[at]justice.ie.

Is le haghaidh an duine nó an eintitis ar a bhfuil sí dírithe, agus le haghaidh 
an duine nó an eintitis sin amháin, a bheartaítear an fhaisnéis a tarchuireadh 
agus féadfaidh sé go bhfuil ábhar faoi rún agus/nó faoi phribhléid inti. 
Toirmisctear aon athbhreithniú, atarchur nó leathadh a dhéanamh ar an 
bhfaisnéis seo, aon úsáid eile a bhaint aisti nó aon ghníomh a dhéanamh ar a 
hiontaoibh, ag daoine nó ag eintitis seachas an faighteoir beartaithe. Má fuair 
tú é seo trí dhearmad, téigh i dteagmháil leis an seoltóir, le do thoil, agus 
scrios an t-ábhar as aon ríomhaire. Is é beartas na Roinne Dlí agus Cirt, 
Comhionannais agus Athchóirithe Dlí, agus na nOifígí agus na nGníomhaireachtaí 
a úsáideann seirbhísí TF na Roinne, seoladh ábhair cholúil a dhícheadú.
Más rud é go measann tú gur ábhar colúil atá san ábhar atá sa teachtaireacht 
seo is ceart duit dul i dteagmháil leis an seoltóir láithreach agus le 
mailminder[ag]justice.ie chomh maith. 

Re: [R] How to create a chromosome location map by locus ID

2009-01-15 Thread Pablo G Goicoechea

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 create a chromosome location map by locus ID

2009-01-15 Thread Pablo G Goicoechea

Sorry list, I guess I sent an html reply.

Hi Sake:
If you do not find an answer within the list, MapChart will probably do 
what you want (without the fancy chromosomal bands, though). You can 
find it at


http://www.biometris.wur.nl/uk/Software/MapChart/

Hope this helps

Sake escribió:

Hi,

I'm trying to make a chromosomal map in R by using the locus. I have a list
of genes and their locus, and I want to visualise that so you can see if
there are multiple genes on a specific place on a chromosome. A example of
what I more or less want is below:
http://www.nabble.com/file/p21474206/untitled.JPG untitled.JPG 
The genes and locus are here:
http://www.nabble.com/file/p21474206/genlocus.csv genlocus.csv 
I've tried some things, but nothing worked like I would like it to see.

Maybe there is some kind of package that does this for you, but I did not
find it yet.
Thanx

Sake
  


--

*Pablo G Goicoechea*

Bioteknología Saila / /Dpto Biotecnología/

NEIKER-Tecnalia

Apdo 46

01080 Vitoria-Gasteiz (SPAIN)

Phone: +34 902 540 546 Fax: +34 902 540 547

pgoikoet...@neiker.net mailto:pgoikoet...@neiker.net

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

2009-01-15 Thread Guillaume Chapron

Hello,

I create this array:

x - cbind(c(1:4, rep(0,10)), c(rep(0,4), 1:2, rep(3,6), 4,5))

  [,1] [,2]
 [1,]10
 [2,]20
 [3,]30
 [4,]40
 [5,]01
 [6,]02
 [7,]03
 [8,]03
 [9,]03
[10,]03
[11,]03
[12,]03
[13,]04
[14,]05

I would like to do the following in vector syntax:

for rows where the first column is not 0, put into the second column  
the number of times the value of the first column appears in the  
second column of rows where the value in the first row is 0


I'm not sure this sounds super clear, so I will show what I want to get:

  [,1] [,2]
 [1,]11
 [2,]21
 [3,]36
 [4,]41
 [5,]01
 [6,]02
 [7,]03
 [8,]03
 [9,]03
[10,]03
[11,]03
[12,]03
[13,]04
[14,]05

So for example, x[3,2] = 6, because length(x[x[,1]==0  x[,2]==3,2]) = 6

I have tried this:

x[x[,1]!=0,2] - length(x[x[,1]==0  x[,2] %in% which(x[,1]!=0),2])

but it does not work correctly as it put the same value in the changed  
rows.


Thanks for your help!

Guillaume

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

2009-01-15 Thread Henrique Dallazuanna
Try this:

x[,2][x[,1][x[,1]  0]] - table(x[,2])[as.character(x[,1][x[,1]  0])]

On Thu, Jan 15, 2009 at 10:36 AM, Guillaume Chapron 
carnivorescie...@gmail.com wrote:

 Hello,

 I create this array:

 x - cbind(c(1:4, rep(0,10)), c(rep(0,4), 1:2, rep(3,6), 4,5))

  [,1] [,2]
  [1,]10
  [2,]20
  [3,]30
  [4,]40
  [5,]01
  [6,]02
  [7,]03
  [8,]03
  [9,]03
 [10,]03
 [11,]03
 [12,]03
 [13,]04
 [14,]05

 I would like to do the following in vector syntax:

 for rows where the first column is not 0, put into the second column the
 number of times the value of the first column appears in the second column
 of rows where the value in the first row is 0

 I'm not sure this sounds super clear, so I will show what I want to get:

  [,1] [,2]
  [1,]11
  [2,]21
  [3,]36
  [4,]41
  [5,]01
  [6,]02
  [7,]03
  [8,]03
  [9,]03
 [10,]03
 [11,]03
 [12,]03
 [13,]04
 [14,]05

 So for example, x[3,2] = 6, because length(x[x[,1]==0  x[,2]==3,2]) = 6

 I have tried this:

 x[x[,1]!=0,2] - length(x[x[,1]==0  x[,2] %in% which(x[,1]!=0),2])

 but it does not work correctly as it put the same value in the changed
 rows.

 Thanks for your help!

 Guillaume

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

2009-01-15 Thread Guillaume Chapron
Thank you! This is exactly what I wanted. Could you please explain the  
logic behind your code?



x[,2][x[,1][x[,1]  0]] - table(x[,2])[as.character(x[,1][x[,1]   
0])]


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] logistic regression - exp(estimates)?

2009-01-15 Thread gregor rolshausen

hello.

I have a question on the interpretation of a logistic model.

is it helpful to exponentiate the coefficients (estimates)? I think I 
once read something about that, but I cannot remember where.

if so, how would be the interpretation of the exp(estimate) ?

would there be a change of the interpretation of the ANOVA table (or is 
the ANOVA table not really helpful at all?).



thanks for your time.

cheers,
gregor rolshausen

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] misalignment of x-axis when overlaying two plots using latticeExtra

2009-01-15 Thread Felix Andrews
Hi Sean,

as.layer() does not do what you think it does: it does not attempt to
plot things on a common scale, it simply draws the panels of two
lattice plots in the same space. Actually, it is not very useful on
its own.

What you want is doubleYScale() in the development version (0.5-5) of
latticeExtra. You can install it with
install.packages(latticeExtra, repos=http://R-Forge.R-project.org;)
then
doubleYScale(barchart.obj, dot.outcome)

By the way, wise persons say plotting on multiple scales is often a
bad idea. I would at least make sure both axes start from zero.

-Felix

2009/1/15 Sean Zhang seane...@gmail.com:
 Dear R-helpers:
 I am an entry-level R user and have a question related to overlaying a
 barchart and and a xyplot using latticeExtra.
 My problem is that when I overlay them I fail to align their x-axes.
 I show my problem below through an example.

 #the example data frame is provided below

   vec -c(1,5.056656,0.5977967,0.06126587,0.08557778,
  2,4.601049,0.5995989,0.05002188,0.11410027,
  3,4.932008,0.5502283,0.06727938,0.12531825,
  4,4.763798,0.5499489,0.06473846,0.10752641,
  5,4.944967,0.5328129,0.05445327,0.13663951,
  6,5.063504,0.5267245,0.06477738,0.12380332,
  7,4.735251,0.5528205,0.06851714,0.12196075,
  8,5.141733,0.5304151,0.07965567,0.15123277,
  9,5.215678,0.5219224,0.06694207,0.16476356,
 10,4.930439,0.5712519,0.08591549,0.09710933,
 11,5.075990,0.5615573,0.05778996,0.15361845,
 12,4.909847,0.5683740,0.08711699,0.11189277,
 13,4.863164,0.5652511,0.0727,0.12071060,
 14,5.173818,0.5564918,0.09830620,0.11831926,
 15,4.762325,0.5345888,0.08792658,0.11738642,
 16,5.046225,0.5268459,0.09574746,0.13254236,
 17,4.902188,0.5370394,0.07194955,0.13164327,
 18,4.865935,0.5446562,0.06894994,0.12645103,
 19,5.204060,0.5650887,0.06726925,0.09242551,
 20,5.208138,0.5765187,0.09282935,0.11053842)

 df-as.data.frame( t(matrix(vec,nrow=5,ncol=20)))
 names(df)-c(group,outcome,proportion_1,proportion_2,proportion_3)

 library(latticeExtra)
 library(lattice)

 #First generate barchart to plot the 3 proportions
 prop.data -subset(df,select=c(proportion_1,proportion_2,proportion_3))
 prop.tab - as.table(as.matrix(prop.data))
 barchart.obj-barchart(prop.tab, stack=TRUE, horizontal = FALSE)
 #Second, generate the dots of outcome (I could have used type=l but using
 type=p makes the
 #misalignment of x-axis more obvious.
 dot.outcome - xyplot(outcome~group,df,type=p, col=blue)

 #Last, overlay the two plots
 barchart.obj+ as.layer(dot.outcome,style=2,axes=c(y), outside=TRUE)
 #Now, you should be able to see the x-axis of the two plots are not
 matching.
 #i.e., a dot is not at the center of its correspoding bar.

 How can I fix this?

 Your help will be highly appreciated. Many thanks in advance.

 -Sean

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




-- 
Felix Andrews / 安福立
http://www.neurofractal.org/felix/
3358 543D AAC6 22C2 D336  80D9 360B 72DD 3E4C F5D8

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

2009-01-15 Thread Henrique Dallazuanna
Guillaume,

# First, you need extract the values of x[,1] greater than 0:

x[,1][x[,1]  0]

# After, you want the number of times that appears in the second column:
table(x2)
# but only to values above:
table(x2)[as.character(x[,1][x[,1]  0])]

# Now, just put the values in column 2:
x[,2][x[,1][x[,1]  0]] - table(x[,2])[as.character(x[,1][x[,1]  0])]


On Thu, Jan 15, 2009 at 10:47 AM, Guillaume Chapron 
carnivorescie...@gmail.com wrote:

 Thank you! This is exactly what I wanted. Could you please explain the
 logic behind your code?


  x[,2][x[,1][x[,1]  0]] - table(x[,2])[as.character(x[,1][x[,1]  0])]


 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] radial.plot(plotrix) - plotting multiple polygons?

2009-01-15 Thread Stefan Uhmann

Dear List, Dear Jim,

is it possible to draw multiple polygons with different line types? 
lty=c or line.lty=c do not work with radial.plot (in the matrix case) as 
well as add=TRUE.


Stefan

Jim Lemon schrieb, Am 14.11.2008 10:38:

Jeremy Claisse wrote:

Is it possible to plot multiple polygons on radial.plot(plotrix)? The
new=FALSE argument (as used to add additional points or lines with the plot
function to an existing plot) doesn't appear to work. I would like to
overlay the outlines of multiple polygons of different colors on the same
radial plot.

  

Hi Jeremy,
You can do this by passing a matrix or data frame of values to 
radial.plot. Look at the last example on the help page for radial.plot 
and check the Details section.


Jim

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



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

2009-01-15 Thread Guillaume Chapron

table(x2)[as.character(x[,1][x[,1]  0])]


Why do I need as.character() here? I checked it does not work without,  
but I don't see why. The help says as.character attempts to coerce  
its argument to character type.


Thanks very much!

Guillaume

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

2009-01-15 Thread Guillaume Chapron


Because we want the values in table(x[,2]) where the **names** are  
as.character(x[,1][x[,1]  0])], not the positions x[,1][x[,1]  0])].


Thanks!

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


Re: [R] Linked count between matrix columns

2009-01-15 Thread Henrique Dallazuanna
Because we want the values in table(x[,2]) where the **names** are
as.character(x[,1][x[,1]  0])], not the positions x[,1][x[,1]  0])].

Best

On Thu, Jan 15, 2009 at 10:59 AM, Guillaume Chapron 
carnivorescie...@gmail.com wrote:

 table(x2)[as.character(x[,1][x[,1]  0])]


 Why do I need as.character() here? I checked it does not work without, but
 I don't see why. The help says as.character attempts to coerce its argument
 to character type.

 Thanks very much!

 Guillaume




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


[R] autocorrelation

2009-01-15 Thread jan nowak
Hi
Is any multiple regression-like test with correction for autocorrelation ?

Wojciech

[[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] Precision in R

2009-01-15 Thread David Winsemius

I'm not getting that difference:

 .Machine$double.eps
[1] 2.220446e-16
# so I don't think that explains the different behavior.

 WB-as.matrix(read.table(file.choose()))
 tcp1 - tcrossprod(WB)
 tcp2 - crossprod(t(WB))
 tcp1
   [,1]   [,2]   [,3]
[1,] 1916061939 2281366606  678696067
[2,] 2281366606 3098975504 1092911209
[3,]  678696067 1092911209  452399849


WBtWB

 [,1]   [,2]   [,3]
[1,] 1916061939 2281366606  678696067
[2,] 2281366606 3098975504 1092911209
[3,]  678696067 1092911209  452399849


 tcp2
   [,1]   [,2]   [,3]
[1,] 1916061939 2281366606  678696067
[2,] 2281366606 3098975504 1092911209
[3,]  678696067 1092911209  452399849
 solve(tcp1)
Error in solve.default(tcp1) :
  system is computationally singular: reciprocal condition number =  
9.60696e-17

 solve(tcp2)
Error in solve.default(tcp2) :
  system is computationally singular: reciprocal condition number =  
9.60696e-17


That is somewhat interesting since yesterday my machine solved my  
input version of your:



WBtWB

 [,1]   [,2]   [,3]
[1,] 1916061939 2281366606  678696067
[2,] 2281366606 3098975504 1092911209
[3,]  678696067 1092911209  452399849


I assume that despite those matrices being displayed as the same they  
are represented differently in the machine.



Berry wrote:

I suppose that it is possible that the difference between what you
report
and what I see lies in the numerical libraries (LINPACK/LAPACK) that R
calls upon.


That would seem to be a possibility. You are using an out-of-date  
version which may limit people's interest in investigating the problem.


--
David Winsemius

On Jan 15, 2009, at 12:47 AM, dos Reis, Marlon wrote:


Hi,
I attached the files I'm using, it may help.
I'm using Windows XP

sessionInfo()

R version 2.6.0 (2007-10-03)
i386-pc-mingw32
locale: LC_COLLATE=English_New Zealand.1252;LC_CTYPE=English_New
Zealand.1252;LC_MONETARY=English_New
Zealand.1252;LC_NUMERIC=C;LC_TIME=English_New Zealand.1252
attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base

Try for example:
WB-as.matrix(read.table(WB.dat))
tcp1 - tcrossprod(WB)
tcp2 - crossprod(t(WB))

solve(tcp1)
 [,1]  [,2]   [,3]
[1,] -41692.80  58330.89  -78368.17
[2,]  58330.89 -81608.66  109642.09
[3,] -78368.17 109642.09 -147305.32

solve(tcp2)
Error in solve.default(tcp2) :
 system is computationally singular: reciprocal condition number =
2.17737e-17

Marlon.

-Original Message-
From: Charles C. Berry [mailto:cbe...@tajo.ucsd.edu]
Sent: Thursday, 15 January 2009 5:16 p.m.
To: dos Reis, Marlon
Cc: r-help@r-project.org
Subject: Re: [R] Precision in R


Marlon,

Are you using a current version of R? sessionInfo()?

It would help if you had something we could _fully_ reproduce.

Taking the _printed_ values you have below (WBtWB) and adding or
subtracting what you have printed as the difference of the two  
visually

equal matrices ( say Delta ) , I am able to run

solve( dat3 )
solve( WBtWB + Delta )
solve( WBtWB - Delta )
solve( WBtWB + 2*Delta )
solve( WBtWB - 2*Delta )

and get the results to agree to 3 significant digits. And perturbing
things even more I still get solve() to return a value:


for ( i in 1:1000 ) solve(WBtWB - tcrossprod(rnorm(3)))
for ( i in 1:1000 ) solve(WBtWB + tcrossprod(rnorm(3)))



And I cannot get condition numbers anything like what you report:

range(replicate( 1, 1/kappa(dat3-tcrossprod(matrix(rnorm(9), 
3)

[1] 5.917764e-11 3.350445e-09





So I am very curious that you got the results that you print below.

I suppose that it is possible that the difference between what you
report
and what I see lies in the numerical libraries (LINPACK/LAPACK) that R
calls upon.

This was done on a windows XP PC. Here is my sessionInfo()


sessionInfo()

R version 2.8.1 Patched (2008-12-22 r47296)
i386-pc-mingw32

locale:
LC_COLLATE=English_United States.1252;LC_CTYPE=English_United
States.1252;LC_MONETARY=English_United
States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252

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




HTH,

Chuck

On Thu, 15 Jan 2009, dos Reis, Marlon wrote:


Dear All,
I'm preparing a simple algorithm for matrix multiplication for a
specific purpose, but I'm getting some unexpected results.
If anyone could give a clue, I would really appreciate.
Basically what I want to do is a simple matrix multiplication:
(WB) %*% t(WB).
The WB is in the disk so I compared to approaches:
-   Load 'WB' using 'read.table' (put it in WB.tmp) and then to the
simple matrix multiplication
WB.tmp%*%t(WB.tmp)

-   Scan each row of WB and do the cross products 'sum(WB.i*WB.i)'
and 'sum(WB.i*WB.j)', which proper arrangement leads to WBtWB.

Comparing these two matrices, I get the very similar values, however
when I tried their inverse, WBtWB leads to a singular system.
I've tried different tests 

Re: [R] power analyses for mixed effects lmer models

2009-01-15 Thread LeeDetroit

Greg and Ben,

Thanks for the suggestions. I'll give it a try, and I'll also poke around to
find the r-sig-mixed-models list. What a wonderful world we live in that
such a thing exists!

--Lee
-- 
View this message in context: 
http://www.nabble.com/power-analyses-for-mixed-effects-lmer-models-tp21457651p21478011.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] how to get the signed distance in SVM?

2009-01-15 Thread David Meyer

Dear Qing,

look at the file svminternals.txt in the /doc subdirectory of the 
installed e1071 package (or inst/doc in the source package), that should 
help.


David


 In the svm() function in the package e1071, is there anyway to get the
 signed distance of a sample point to the separating hyperplane in the
 feature space? Namely, if the separating hyperplane is given by f(x) =
 h(x)^T * w - rho, is there any way to get f(x)?

 Also, in the returned values of the function svm(), what does $coefs
 mean? It is said to be the corresponding coefficients times the
 training labels, but I don't know what is that corresponding
 coefficients denoting?

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] LCA (e1071 package): error

2009-01-15 Thread Tryntsje Wesselius
Hello,

I will use the lca method in the e1071 package. But I get the following error:
Error in pas[j, ] - drop(exp(rep(1, nvar) %*% log(mp))) :
  number of items to replace is not a multiple of replacement length

Does anybody know this error and knows what this means?

Kind regards,

Tryntsje

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

2009-01-15 Thread Suyan Tian

Hi everyone:

I want to fit the truncated polynomial smoothing to the quantiles  
instead of means, does someone know how to do it? I am thinking that  
maybe I can use SemiPar package, but can not find how.


Thanks so many,

Suyan

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

2009-01-15 Thread Luciano Bernardes
Hi,

I have a binary matrix and I would like from it make a cluster by
agglomerative method (like agnes), and then generate a ascii art dendrogram.
See the illustration:

binary matrixascii art dendrogram

 ABCDEFGH
P1 0101011101  +-P1
P2 1000101001  =  (Agnes) =  +--|
P3 1001011101   |   +-P3
P4 0101101110  +--|
|
+--P2
|

+--P4



Someone could help-me???

Thanks

Luciano

[[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] Seemingly Unrelated Negative Binomial (SUNB) estimation

2009-01-15 Thread Ben Bolker
Elisa Lanzi elisa.lanzi at unive.it writes:

 
 Dear all,
 I am trying to estimate a system of equations with a Seemingly Unrelated
 Regression. However because of the characteristics of the data I'd like to
 do it with a negative binomial estimation. Would anybody know how to
 implement a Seemingly Unrelated Negative Binomial (SUNB) estimation in R?
 Thank you in advance for your help.
 Best regards,
 Elisa Lanzi
 

  This PhD thesis

http://etd.library.arizona.edu/etd/metadata.jsp?id=urn:etd:azu_etd_1605_1_m

gives a log-likelihood function (pp. 43-45) and GAUSS code (p. 112)
that wouldn't be too hard to translate into R (using optim or mle).
(Not too hard implies you already have some reasonable grasp of R/
statistical programming; if you're looking for a black box solution
you will probably have to get some help ...)

  Ben Bolker

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

2009-01-15 Thread Andrew Choens
If I want to make a numerical series, I can do so easily with:

series.numbers - 1:10

But, I don't seem to be able to do the same with time. I want to create
a vector with 480 points that corresponds to the 480 minutes in a 8 hour
work day. Thus I want series.time to look something like this:

9:00
9:01
9:02
9:03
etc.

Last night I managed to build this by concatenating a series of strings,
and converting them to datetime format with as.Date() or strptime(), but
my method seems overly complex.

hour - 0:59
day - c(9, 10, 11, 12, 13, 14, 15, 16)
hours - c(rep(9, 60), rep(10, 60), rep(11, 60), rep(12, 60),   
 rep(1, 60), rep(2, 60), rep(3, 60), rep(4, 60))
one.day - paste(hours, :, hour, sep = )
strptime(one.day, %H:%M)
# OR
# as.Date(one.day, %H:%M)



Is there any way to do something similar to:
strptime(09:00, %H:%M) : strptime(11:00, %H:%M)

When I try this, I get the following error:
numerical expression has 9 elements: only the first used

Thanks.
--andy

-- 
Insert something humorous here.  :-)

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

2009-01-15 Thread e-letter
On 13/01/2009, David Winsemius dwinsem...@comcast.net wrote:
 It's fairly clear from the documentation that approxfun() will not
 extrapolate.

 help.search(extrapolate)
 library(Hmisc)
 ?approxExtrap

 Some sort of minimization approach:

   approxExtrap(x=c(0,5,10,15,20), y=c(16,45,77,101,125),xout=c(-4,0,4))
 $x
 [1] -4  0  4

 $y
 [1] -7.2 16.0 39.2

   approxExtrap(x=c(0,5,10,15,20),
 y=c(16,45,77,101,125),xout=seq(-2.8,-2.6, by=0.01))
 $x
   [1] -2.80 -2.79 -2.78 -2.77 -2.76 -2.75 -2.74 -2.73 -2.72 -2.71
 -2.70 -2.69 -2.68
 [14] -2.67 -2.66 -2.65 -2.64 -2.63 -2.62 -2.61 -2.60

 $y
   [1] -0.240 -0.182 -0.124 -0.066 -0.008  0.050  0.108  0.166  0.224
 0.282  0.340
 [12]  0.398  0.456  0.514  0.572  0.630  0.688  0.746  0.804  0.862
 0.920

 How accurate do you need the answer?

 I tried Hmisc's inverseFunction(), but it returned 0 for an argument
 of zero:

   invF - inverseFunction(x=c(0,5,10,15,20), y=c(16,45,77,101,125))
   invF(0)

 So I then hacked Harrell's inverseFunction by substituting
 approxExtrap in every in instance
 where approx appeared, creating invFunc2:

 then

   invF - invFunc2(x=c(0,5,10,15,20), y=c(16,45,77,101,125))
  
   invF(0)
 [1] -2.758621
I have compared your answer to those obtained from gnuplot, scilab and
qtiplot; all report a result of x=-3.28. Why is r different?

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

2009-01-15 Thread davide . massidda
Dear R-helpers,
I have a problem with the tcl after instruction. When I send:

 library(tcltk)
Loading Tcl/Tk interface ... done

 tcl(after,1000,cat(try tcl after\n))
try tcl after
Tcl

the tcl command works fine. Similarly, the tcl command:

 tcl(after,1000,plot(rnorm(100)))
Tcl

works fine. But, if I send the command:

 tcl(after,1000,10^2)
Tcl after#0

appears a popup window which reports:

Error: invalid command name “100”

Why?



Davide Massidda

Università di Padova
Dipartimento di Psicologia Generale
Via Venezia, 8 - 35131 Padova - Italy

QPLab http://qplab.psy.unipd.it/
tel. +39 049 8276905

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

2009-01-15 Thread David Winsemius


On Jan 15, 2009, at 1:10 AM, John Kerpel wrote:


Hi folks!
I run the following code to get a CI for a Poisson with lambda=12.73

library(MASS)

set.seed(125)

x - rpois(100,12.73)

lambda_hat-fitdistr(x, dpois, list(lambda=12))$estimate

#Confidence Intervals - Normal Approx.

alpha-c(.05,.025,.01)

for(n in 1:length(alpha)) {

LowerCI-mean(x)-(qnorm(1-alpha[n]/2, mean = 0, sd =
1)*sqrt(var(x)/length(x)))

UpperCI-mean(x)+(qnorm(1-alpha[n]/2, mean = 0, sd =
1)*sqrt(var(x)/length(x)))

cat(For
Alpha
=
,alpha
[n
],LowerCI
=,LowerCI,,Lambda=,mean(x),,UpperCI=,UpperCI,\n)


}


When I do something like:

qpois(.975, 12.73, lower.tail = TRUE, log.p = FALSE)
[1] 20

qpois(.025, 12.73, lower.tail = TRUE, log.p = FALSE)

[1] 6

I get quite a different result.  Is this the difference between the  
normal

approx and an (almost) exact Poisson CI?


Yes and no.

Using Byar's approximation, which is reasonably accurate at this  
expected value, I get 6.2 and 20.9 so R's qpois seems pretty sensible.


Your results don't look like a proper creation of a Normal approx,  
however. Weren't you worried that your code might not be performing as  
desired when the upper CL for your alpha= 0.05, and 0.01 results were  
only different by 0.3?


I would have thought a (much more simple) Normal approximation for the  
Poisson 0.05 CL around an expected of E might be
   E +/- 1.96* E^(.5).  So  12 +/- 2* 3.4 (5.2, 18.8)  might be an  
eyeball estimate.


 12 + 1.96*sqrt(12)
[1] 18.78964
 12 - 1.96*sqrt(12)
[1] 5.210361


--
David Winsemius

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

2009-01-15 Thread Gabor Grothendieck
Try this:

library(chron)
times(9:00:00) + 0:479/(24*60)

Also see R News 4/1 and read the help pages in chron.

If you eventually want to use these times with corresponding series
data look at the zoo package.

On Thu, Jan 15, 2009 at 10:01 AM, Andrew Choens andy.cho...@gmail.com wrote:
 If I want to make a numerical series, I can do so easily with:

series.numbers - 1:10

 But, I don't seem to be able to do the same with time. I want to create
 a vector with 480 points that corresponds to the 480 minutes in a 8 hour
 work day. Thus I want series.time to look something like this:

 9:00
 9:01
 9:02
 9:03
 etc.

 Last night I managed to build this by concatenating a series of strings,
 and converting them to datetime format with as.Date() or strptime(), but
 my method seems overly complex.

hour - 0:59
day - c(9, 10, 11, 12, 13, 14, 15, 16)
hours - c(rep(9, 60), rep(10, 60), rep(11, 60), rep(12, 60),
 rep(1, 60), rep(2, 60), rep(3, 60), rep(4, 60))
one.day - paste(hours, :, hour, sep = )
strptime(one.day, %H:%M)
# OR
# as.Date(one.day, %H:%M)



 Is there any way to do something similar to:
strptime(09:00, %H:%M) : strptime(11:00, %H:%M)

 When I try this, I get the following error:
numerical expression has 9 elements: only the first used

 Thanks.
 --andy

 --
 Insert something humorous here.  :-)

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

2009-01-15 Thread Duncan Murdoch

On 1/15/2009 10:18 AM, davide.massi...@unipd.it wrote:

Dear R-helpers,
I have a problem with the tcl after instruction. When I send:


library(tcltk)

Loading Tcl/Tk interface ... done


tcl(after,1000,cat(try tcl after\n))

try tcl after
Tcl

the tcl command works fine. Similarly, the tcl command:


tcl(after,1000,plot(rnorm(100)))

Tcl

works fine. But, if I send the command:


tcl(after,1000,10^2)

Tcl after#0

appears a popup window which reports:

Error: invalid command name “100”

Why?


The value of cat(something) is NULL, the value of plot(something) is 
NULL, but the value of 10^2 is 100.  You're trying to execute no Tcl 
command in the first two cases, but you're trying to execute the command 
100 in the last, and that's not a legal Tcl command.


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] Summary of Total Object.Size in R Script

2009-01-15 Thread Henrik Bengtsson
See also ll() in the R.oo package, e.g.

# To list all objects in .GlobalEnv:
ll()
  member data.class dimension objectSize
1*tmp* Person 1 428
2  as.character.Person   function  NULL1208
3  country  character 1  44
4equals.Person   function  NULL2324
5 filename  character 1  84
6   getAge   function  NULL 372
7getAge.Person   function  NULL 612
8   getName.Person   function  NULL 628
9  hashCode.Person   function  NULL1196
10last.warning   list 1 192
11 obj Person 1 428
12  Person  Class  NULL2292
13  setAge   function  NULL 372
14   setAge.Person   function  NULL2088
15 setName   function  NULL 372
16  setName.Person   function  NULL 760
17   staticCode.Person   function  NULL2372

# To list all functions in the methods package:
ll(mode=function, envir=methods)

# To list all numeric and character object in the base package:
ll(mode=c(numeric, character), envir=base)

# To list all objects in the base package greater than 40kb:
subset(ll(envir=base), objectSize  4)

ll() takes argument 'properties', which allows you to construct any
column property you ever like.  There is also a 'sortBy' argument.
See help(ll) for more details.

/Henrik

On Thu, Jan 15, 2009 at 3:00 AM, Gundala Viswanath gunda...@gmail.com wrote:
 Sorry for my late reply.

 Thank you so much Jim. This script of yours
 is very2 useful. I have used it.

 - Gundala Viswanath
 Jakarta - Indonesia



 On Wed, Jan 14, 2009 at 12:17 AM, jim holtman jholt...@gmail.com wrote:
 Here is a function I use to see how big the objects in my workspace are:

 my.ls -
 + function (pos = 1, sorted = F)
 + {
 + .result - sapply(ls(pos = pos, all.names = TRUE), function(..x)
 object.size(eval(as.symbol(..x
 + if (sorted) {
 + .result - rev(sort(.result))
 + }
 + .ls - as.data.frame(rbind(as.matrix(.result), `**Total` = 
 sum(.result)))
 + names(.ls) - Size
 + .ls$Size - formatC(.ls$Size, big.mark = ,, digits = 0,
 + format = f)
 + .ls$Mode - c(unlist(lapply(rownames(.ls)[-nrow(.ls)],
 function(x) mode(eval(as.symbol(x),
 + ---)
 + .ls
 + }
 my.ls()
  SizeMode
 .my.env 28 environment
 .Random.seed 2,528 numeric
 .required   72   character
 my.ls6,712function
 **Total  9,340 ---


 On Tue, Jan 13, 2009 at 9:53 AM, Gundala Viswanath gunda...@gmail.com 
 wrote:
 Dear all,

 Is there a way we can find the total object.size of
 all the objects in our R script?

 The reason we want to do this because we want to know
 how much memory does our R script require overall.

 Rprofmem(), doesn't seem to do it.

 and Unix 'top' command is dynamic and
 it doesn't give the exact byte size.

 - Gundala Viswanath
 Jakarta - Indonesia

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




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

 What is the problem that you are trying to solve?


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


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] LCA (e1071 package): error

2009-01-15 Thread Richard . Cotton
 I will use the lca method in the e1071 package. But I get the following 
error:
 Error in pas[j, ] - drop(exp(rep(1, nvar) %*% log(mp))) :
   number of items to replace is not a multiple of replacement length
 
 Does anybody know this error and knows what this means?

The error means that you are trying to assign a variable of one size to a 
variable of another fixed size.  An example that recreates it is:
x - matrix(1:6, nrow=3)
x[1,] - 1:10

x[1,] cannot be resized from 3 to 10 without affecting the rest of x, so 
an error is thrown.

In your example, the jth row of the matrix pas is a different size from 
drop(exp(rep(1, nvar) %*% log(mp))).

Since you haven't provided a reproducible example (tut tut, read the 
posting guide) you'll have to do the debugging yourself.

To get you started, type traceback() to see where the problem occurs.

Now try options(error=recover), and call the lca function again.  Now you 
can examine the values of nvar, mp and pas to see what is going wrong.

Regards,
Richie.

Mathematical Sciences Unit
HSL




ATTENTION:

This message contains privileged and confidential inform...{{dropped:20}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 R how to read a one column alone from a database table from MySQL

2009-01-15 Thread sankar82

hello friends

i have a created a database table in MYSQL consisting of 11 columns.
throught RMYSQL i managed to read the entire table in R. but i have few
qureries which i need solutions...here they are:

1. Using R how to read a one column alone from a database table from MYSQL.
2. Using R how to print on screen those column value.
3. Using R how to print one particular row (in this case row is X)value
alone.
4. Using R how to read all the column (11) and print (X) value alone on
screen.
5. Using R with logic print those (X) value which is/between say 20 to 30
degrees.

as im very new to this R softwareits quite awkward for an experienced
user to give me the solutions for my above queries...but i would be thankful
if i get the solutions and it will also be an learning for me too...so i
kindly request any people in this forum to give me solutions how to do it...

BR
sankar.
-- 
View this message in context: 
http://www.nabble.com/using-R-how-to-read-a-one-column-alone-from-a-database-table-from-MySQL-tp21478288p21478288.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] rimage installation problem-ubuntu 8.10

2009-01-15 Thread abbethesieyes

(I'm quite afraid this is a dumb question, so sorry in advance)
I am trying to install the package rimage to R version 2.8.1 with Ubuntu
Intrepid.  When I type sudo R CMD INSTALL I get the following error
message (pasted below). I know the same problem appears here
(http://www.r-project.org/nosvn/R.check/r-patched-linux-ix86/rimage-00install.html)
but I do not know what its appearance there means. 

Thanks in advance for any help!

Abbe

g++ -I/usr/share/R/include -g -O2   -fpic  -g -O2 -c matrix.cpp -o
matrix.o
/usr/include/c++/4.3/bits/stl_vector.h: In member function ‘void
std::vector_Tp, _Alloc::_M_initialize_dispatch(_Integer, _Integer,
std::__true_type) [with _Integer = int, _Tp = std::vectordouble,
std::allocatordouble , _Alloc = std::allocatorstd::vectordouble,
std::allocatordouble  ]’:
/usr/include/c++/4.3/bits/stl_vector.h:290:   instantiated from
‘std::vector_Tp, _Alloc::vector(_InputIterator, _InputIterator, const
_Alloc) [with _InputIterator = int, _Tp = std::vectordouble,
std::allocatordouble , _Alloc = std::allocatorstd::vectordouble,
std::allocatordouble  ]’
matrix.cpp:31:   instantiated from here
/usr/include/c++/4.3/bits/stl_vector.h:932: error: no matching function for
call to ‘std::vectorstd::vectordouble, std::allocatordouble ,
std::allocatorstd::vectordouble, std::allocatordouble  
::_M_fill_initialize(size_t, int)’
/usr/include/c++/4.3/bits/stl_vector.h:974: note: candidates are: void
std::vector_Tp, _Alloc::_M_fill_initialize(size_t, const _Tp) [with _Tp =
std::vectordouble, std::allocatordouble , _Alloc =
std::allocatorstd::vectordouble, std::allocatordouble  ]
make: *** [matrix.o] Error 1



-- 
View this message in context: 
http://www.nabble.com/rimage-installation-problem-ubuntu-8.10-tp21475502p21475502.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] R on Vista

2009-01-15 Thread Ziqi
Dear Sir/Madam,

Thanks for the software.

May I know that R can run on Vista system or not? Cause i donwload but cant
install..  =(

Thanks s much!!

-- 
Best Regards,

 Ivy

[[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] interpolation to abscissa

2009-01-15 Thread David Winsemius


On Jan 15, 2009, at 10:04 AM, e-letter wrote:


On 13/01/2009, David Winsemius dwinsem...@comcast.net wrote:

It's fairly clear from the documentation that approxfun() will not
extrapolate.

help.search(extrapolate)
library(Hmisc)
?approxExtrap

Some sort of minimization approach:

approxExtrap(x=c(0,5,10,15,20),  
y=c(16,45,77,101,125),xout=c(-4,0,4))

$x
[1] -4  0  4

$y
[1] -7.2 16.0 39.2


approxExtrap(x=c(0,5,10,15,20),

y=c(16,45,77,101,125),xout=seq(-2.8,-2.6, by=0.01))
$x
 [1] -2.80 -2.79 -2.78 -2.77 -2.76 -2.75 -2.74 -2.73 -2.72 -2.71
-2.70 -2.69 -2.68
[14] -2.67 -2.66 -2.65 -2.64 -2.63 -2.62 -2.61 -2.60

$y
 [1] -0.240 -0.182 -0.124 -0.066 -0.008  0.050  0.108  0.166  0.224
0.282  0.340
[12]  0.398  0.456  0.514  0.572  0.630  0.688  0.746  0.804  0.862
0.920

How accurate do you need the answer?

I tried Hmisc's inverseFunction(), but it returned 0 for an argument
of zero:


invF - inverseFunction(x=c(0,5,10,15,20), y=c(16,45,77,101,125))
invF(0)


So I then hacked Harrell's inverseFunction by substituting
approxExtrap in every in instance
where approx appeared, creating invFunc2:

then


invF - invFunc2(x=c(0,5,10,15,20), y=c(16,45,77,101,125))

invF(0)

[1] -2.758621

I have compared your answer to those obtained from gnuplot, scilab and
qtiplot; all report a result of x=-3.28. Why is r different?


Perhaps a coding error on my part (or on your part). Perhaps different  
methods (none of which you describe)?


I suspect that my method only used the first two points (I just  
checked by plotting and -2.7 is closer to the paper and pen result I  
get than is -3.28. Perhaps you made an extrapolation from a linear fit  
of a dataset that is not co-linear?


 lm(c(0,5) ~ c(16,45))

Call:
lm(formula = c(0, 5) ~ c(16, 45))

Coefficients:
(Intercept)c(16, 45)
-2.7586   0.1724

It not that R is different,  it is merely that I used it differently  
than you used your other tools.


Here's another method ( using all points and again reversing the roles  
of x and y) :

 lm(c(0,5,10,15,20) ~ c(16,45,77,101,125))

Call:
lm(formula = c(0, 5, 10, 15, 20) ~ c(16, 45, 77, 101, 125))

Coefficients:
(Intercept)  c(16, 45, 77, 101, 125)
-3.2332   0.1818





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

2009-01-15 Thread Peter Dalgaard
Duncan Murdoch wrote:
 On 1/15/2009 10:18 AM, davide.massi...@unipd.it wrote:
 Dear R-helpers,
 I have a problem with the tcl after instruction. When I send:

 library(tcltk)
 Loading Tcl/Tk interface ... done

 tcl(after,1000,cat(try tcl after\n))
 try tcl after
 Tcl

 the tcl command works fine. Similarly, the tcl command:

 tcl(after,1000,plot(rnorm(100)))
 Tcl

 works fine. But, if I send the command:

 tcl(after,1000,10^2)
 Tcl after#0

 appears a popup window which reports:

 Error: invalid command name “100”

 Why?
 
 The value of cat(something) is NULL, the value of plot(something) is
 NULL, but the value of 10^2 is 100.  You're trying to execute no Tcl
 command in the first two cases, but you're trying to execute the command
 100 in the last, and that's not a legal Tcl command.

Yes. Notice also that the argument is intended to be something to do
*after* the period of time has elapsed, and as written, it happens
immediately. You can use an R expression there, but it needs to be an
unevaluated call, usually created by
quote() or expression().


 tcl(after,5000,quote(cat(try tcl after\n))) ; for (i in
1:10){print(i);Sys.sleep(1)}
Tcl after#4
[1] 1
[1] 2
[1] 3
[1] 4
[1] 5
try tcl after
[1] 6
[1] 7
[1] 8
[1] 9
[1] 10

-- 
   O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - (p.dalga...@biostat.ku.dk)  FAX: (+45) 35327907

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

2009-01-15 Thread e-letter
 Perhaps a coding error on my part (or on your part). Perhaps different
 methods (none of which you describe)?


 I suspect that my method only used the first two points (I just
 checked by plotting and -2.7 is closer to the paper and pen result I
 get than is -3.28. Perhaps you made an extrapolation from a linear fit
 of a dataset that is not co-linear?

   lm(c(0,5) ~ c(16,45))

 Call:
 lm(formula = c(0, 5) ~ c(16, 45))

 Coefficients:
 (Intercept)c(16, 45)
  -2.7586   0.1724

 It not that R is different,  it is merely that I used it differently
 than you used your other tools.

 Here's another method ( using all points and again reversing the roles
 of x and y) :
   lm(c(0,5,10,15,20) ~ c(16,45,77,101,125))

 Call:
 lm(formula = c(0, 5, 10, 15, 20) ~ c(16, 45, 77, 101, 125))

 Coefficients:
  (Intercept)  c(16, 45, 77, 101, 125)
  -3.2332   0.1818
My understanding from gnuplot manual is that a marquart-levenberg
algorithm is used, which I applied to the data to perform a least
squares best fit linear curve. Gnuplot returns values for the
intercept and gradient which I then apply to solve the linear equation
y=mx+c. Similarly with scilab, where the regress(ion?) function was
applied. Qtiplot performed non-weighted linear regression to output
values similar to those from gnuplot.

Why reverse the roles of x and y in your method? Although your revised
value is closer to those from other programs, how do I understand and
explain the discrepancy?

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

2009-01-15 Thread Duncan Murdoch

On 1/15/2009 6:53 AM, Ziqi wrote:

Dear Sir/Madam,

Thanks for the software.

May I know that R can run on Vista system or not? Cause i donwload but cant
install..  =(

Thanks s much!!


R can run on Vista.  See the FAQ (online at 
http://cran.r-project.org/bin/windows/base/rw-FAQ.html, you want 
question 2.24) for details on what's different from earlier Windows systems.


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] problems with extractPrediction in package caret

2009-01-15 Thread Häring, Tim (LWF)
Hi list,

I´m working on a predictive modeling task using the caret package.
I found the best model parameters using the train() and trainControl() command. 
Now I want to evaluate my model and make predictions on a test dataset. I tried 
to follow the instructions in the manual and the vignettes but unfortunately 
I´m getting an error message I can`t figure out.
Here is my code:
rfControl - trainControl(method = oob, returnResamp = all, 
returnData=TRUE, verboseIter = TRUE)
rftrain - train(x=train_x, y=trainclass, method=rf, tuneGrid=tuneGrid, 
tr.control=rfControl)

pred - predict(rftrain) 
pred# this works fine
expred - extractPrediction(rftrain)

Error in models[[1]]$trainingData : 
  $ operator is invalid for atomic vectors

My predictors are 28 numeric attributes and one factor.
I`m working with the latest version of caret and R 2.7.2 on WinXP.

Any advice is very welcome.

Thanks.
TIM


--- 
Dipl.-Geogr. Tim Häring
Sachgebiet Standort und Bodenschutz (SG 2.1)
Bayerische Landesanstalt für Wald und Forstwirtschaft
Am Hochanger 11
D-85354 Freising

Tel.: +49-(0)8161/71-4769
E-Mail: tim.haer...@lwf.bayern.de
http://www.lwf.bayern.de




[[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] Using fortran code which call LAPACK subroutines

2009-01-15 Thread Matthieu Stigler

Prof Brian Ripley a écrit :

On Tue, 13 Jan 2009, Charles C. Berry wrote:


On Tue, 13 Jan 2009, Matthieu Stigler wrote:


Hello

I'm trying to run a fortran code which use LAPACK subroutines. I 
think I should use some points shown in the manual 5.5 Creating 
shared objects but it is too technical for me :-(...




Be sure to look over section 6, esp. 6.17

The headers for DGEQRF, DLASR, DROT, DROTG are all in Blas.h or 
Lapack.h (although you will see them in lower case).


XERBLA in libRBlas.so but is not in the R API, so if your code needs 
to use it you'll have to add a header like the one in main.c or add 
your own version.


Not in Fortran code, though: see below

I think Matthieu had not read quite a lot of the documentation: given 
how carefully it was written, that was disrespectful (as was the lack 
of a proper signature: see the posting guide: Charles aka Chuck has 
been exemplary).


Sorry if this could be seen as disrespectful, I nevertheless don't think 
that having difficulties to read a good but complex (and difficult for a 
newbie) documentation is a sign of disrespect.
To put it simply: if you are ashamed of who you are, so are the most 
prolific helpers here.  Some people resent being milked for free 
consultancy for commercial firms, and many of us will go many miles 
out of our way for third-world NGOs/academia.


Oh, I forgot to write my name... I'm sorry, well even if you could see 
it from my address I should have written. I understand your worry about 
commercial firms, personnaly, I'm trying to contribute myself to R 
through extensions of package tsDyn 
http://code.google.com/p/tsdyn/wiki/ThresholdCointegration

I think you can probably do what you want with just


PKG_LIBS=${LAPACK_LIBS} $(BLAS_LIBS) ${FLIBS}

in Makevars

and
R CMD INSTALL your-package

with just the default settings.


This did the job (just had to copy/paste the xerbla in a proper .f file 
in src)!

Thank you so much!

Agreed.



HTH,

Chuck

Could anyone help me for the procedure to do:


-which part of the manual is relevant for this type of question? 
actually I'm speaking from writing R extensions, should I read R admin?


-point 1.2 says: /Recent versions of Autoconf in fact allow an 
already set |FLIBS| to override the test for the FORTRAN linker 
flags. Also, recent versions of R can detect external BLAS and 
LAPACK libraries./
but nevertheless I have to include something more? or modify the 
script?


-should I compile from SHLIB with other options or include it 
directly into a package and cretae a makevars or PACKAGE_LIBS...? 
I'm lost...



The subroutine I try to use is delcols.f 
(http://www.maths.manchester.ac.uk/~clucas/updating/addcols.f) which 
calls


* .. External Subroutines ..
 EXTERNAL   DGEQRF, DLASR, DROT, DROTG, XERBLA


Thank you very much!!



Charles C. Berry(858) 534-2098
   Dept of Family/Preventive 
Medicine

E mailto:cbe...@tajo.ucsd.eduUC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 
92093-0901


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

2009-01-15 Thread David Winsemius


On Jan 15, 2009, at 11:31 AM, e-letter wrote:

Perhaps a coding error on my part (or on your part). Perhaps  
different

methods (none of which you describe)?




I suspect that my method only used the first two points (I just
checked by plotting and -2.7 is closer to the paper and pen result I
get than is -3.28. Perhaps you made an extrapolation from a linear  
fit

of a dataset that is not co-linear?


lm(c(0,5) ~ c(16,45))


Call:
lm(formula = c(0, 5) ~ c(16, 45))

Coefficients:
(Intercept)c(16, 45)
   -2.7586   0.1724

It not that R is different,  it is merely that I used it  
differently

than you used your other tools.

Here's another method ( using all points and again reversing the  
roles

of x and y) :

lm(c(0,5,10,15,20) ~ c(16,45,77,101,125))


Call:
lm(formula = c(0, 5, 10, 15, 20) ~ c(16, 45, 77, 101, 125))

Coefficients:
   (Intercept)  c(16, 45, 77, 101, 125)
   -3.2332   0.1818

My understanding from gnuplot manual is that a marquart-levenberg
algorithm is used, which I applied to the data to perform a least
squares best fit linear curve. Gnuplot returns values for the
intercept and gradient which I then apply to solve the linear equation
y=mx+c. Similarly with scilab, where the regress(ion?) function was
applied. Qtiplot performed non-weighted linear regression to output
values similar to those from gnuplot.

Why reverse the roles of x and y in your method?


I accidentally switched x and y ad then realized I could get an  
intercept value without the labor of solving by hand.


Although your revised value is closer to those from other programs,  
how do I understand and

explain the discrepancy?


The regression line for x ~ y is *not* the same as the regression line  
for y ~ x.


If you want to check that the numbers from R agree with your other  
solutions, then take the regression equation from

 lmmod

Call:
lm(formula = c(16, 45, 77, 101, 125) ~ c(0, 5, 10, 15, 20))

Coefficients:
   (Intercept)  c(0, 5, 10, 15, 20)
 18.00 5.48

... and then solve for x = 0  as you apparently did with the other  
systems.


--
David Winsemius

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 R how to read a one column alone from a database table from MySQL

2009-01-15 Thread Dieter Menne
sankar82 sankar.arughadhoss at tkk.fi writes:

 i have a created a database table in MYSQL consisting of 11 columns.
 throught RMYSQL i managed to read the entire table in R. but i have few
 qureries which i need solutions...here they are:
 
 1. Using R how to read a one column alone from a database table from MYSQL.
 2. Using R how to print on screen those column value.
 3. Using R how to print one particular row (in this case row is X)value
 alone.
 4. Using R how to read all the column (11) and print (X) value alone on
 screen.
 5. Using R with logic print those (X) value which is/between say 20 to 30
 degrees.
 

Have you tried the examples in Rmysql-package?
For 5., you could use something like:

dbSendQuery(con, select * from WL where width\_nm between 0.5 and 1)

Ok, here we let SQL do the job, and you homework want it to be done in R.

Dieter

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

2009-01-15 Thread Dirk Eddelbuettel

On 15 January 2009 at 03:06, abbethesieyes wrote:
| 
| (I'm quite afraid this is a dumb question, so sorry in advance)
| I am trying to install the package rimage to R version 2.8.1 with Ubuntu
| Intrepid.  When I type sudo R CMD INSTALL I get the following error
| message (pasted below). I know the same problem appears here
| 
(http://www.r-project.org/nosvn/R.check/r-patched-linux-ix86/rimage-00install.html)
| but I do not know what its appearance there means. 
| 
| Thanks in advance for any help!
| 
| Abbe
| 
| g++ -I/usr/share/R/include -g -O2   -fpic  -g -O2 -c matrix.cpp -o
| matrix.o
| /usr/include/c++/4.3/bits/stl_vector.h: In member function  void
| std::vector_Tp, _Alloc::_M_initialize_dispatch(_Integer, _Integer,
| std::__true_type) [with _Integer = int, _Tp = std::vectordouble,
| std::allocatordouble , _Alloc = std::allocatorstd::vectordouble,
| std::allocatordouble  ] :
| /usr/include/c++/4.3/bits/stl_vector.h:290:   instantiated from
|  std::vector_Tp, _Alloc::vector(_InputIterator, _InputIterator, const
| _Alloc) [with _InputIterator = int, _Tp = std::vectordouble,
| std::allocatordouble , _Alloc = std::allocatorstd::vectordouble,
| std::allocatordouble  ] 
| matrix.cpp:31:   instantiated from here
| /usr/include/c++/4.3/bits/stl_vector.h:932: error: no matching function for
| call to  std::vectorstd::vectordouble, std::allocatordouble ,
| std::allocatorstd::vectordouble, std::allocatordouble  
| ::_M_fill_initialize(size_t, int) 
| /usr/include/c++/4.3/bits/stl_vector.h:974: note: candidates are: void
| std::vector_Tp, _Alloc::_M_fill_initialize(size_t, const _Tp) [with _Tp =
| std::vectordouble, std::allocatordouble , _Alloc =
| std::allocatorstd::vectordouble, std::allocatordouble  ]
| make: *** [matrix.o] Error 1

Nothing specific to Ubuntu here. 

The rimage package simply does not build under g++ 4.3 as constructors like

   m = new vector vector double (x, y);

are not supported -- ie you cannot pass the (x,y) size information.  Looks
like that worked in the past.

However, you do get 

   m = new vector vector double ;

though and could explicitly resize the matrix (ie once for rows and then in a
loop for each column).  May require some testing though.

Dirk


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

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


Re: [R] interpolation to abscissa

2009-01-15 Thread David Winsemius


It appears the answer to your goal after a discursive exploration of  
interpolation, which was really extrapolation, is that you need to  
look at the predict methods for linear (and other sorts as well) models.


?predict
?predict.lm

 y - c(16,45,77,101,125)
 x - c(0,5,10,15,20)

 lmmod - lm(y ~ x)

 plot(x,y,  ylim = c(0,125), xlim =c(-4,22))  #defaults would not  
allow estimates from plot


 lines(x=seq(-4,22, by=.5),
y=predict(lm(y ~ x), newdata = data.frame(x = seq(-4,22, by=. 
5) ) ) )



--
David Winsemius


On Jan 15, 2009, at 11:31 AM, e-letter wrote:




snipped preceding excursion

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

2009-01-15 Thread David M Smith
On Sun, Jan 11, 2009 at 11:05 AM, Kingsford Jones
kingsfordjo...@gmail.com wrote:
 I hope that Marc doesn't mind, but I felt that part of his recent post
 was important enough to deserve it's own subject line rather then
 being lost in a 60-msg-long thread...

I also wanted to thank Marc for this wealth of information on using R
in clinical trials. I particularly want to recommend the R:
Regulatory Compliance and Validation Issues document at
http://www.r-project.org/certification.html .  Even if you're not
looking to validate R for 21CFR11 compliance, this document is an
excellent description of R's world-class software development process.
 With this, and the documented use of R by the FDA itself and within
pharma companies for clinical trials, I hope we can settle the Is R
Validated? question at long last. Thanks go to the authors (Marc
Schwartz, Frank Harrell, Tony Rossini and Ian Francis) and the R
Foundation generally for putting this together.

By the way, if (or a skeptical colleague) needs a more detailed answer
to the Is R Validated? question, I expand upon the information Marc
provided here:

http://blog.revolution-computing.com/2009/01/analyzing-clinical-trial-data-with-r.html

# David Smith

-- 
David M Smith da...@revolution-computing.com
Director of Community, REvolution Computing www.revolution-computing.com
Tel: +1 (206) 577-4778 x3203 (Seattle, USA)

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

2009-01-15 Thread Charles C. Berry

On Thu, 15 Jan 2009, dos Reis, Marlon wrote:


I'm using:
solve(a, b, tol, LINPACK = FALSE, ...)
Therefore,tol ==.Machine$double.eps

.Machine$double.eps

[1] 2.220446e-16

It explains why 'solve' works for 'tcp1' but not for 'tcp2':

eigen(tcp1)$values
[1]  5.208856e+09  2.585816e+08 -3.660671e-06

-3.660671e-06/5.208856e+09
[1] -7.027783e-16

eigen(tcp2)$values
[1]  5.208856e+09  2.585816e+08 -6.416393e-08
-6.416393e-08/5.208856e+09
[1] -1.231824e-17

My question would be why 'tcrossprod' and 'crossprod' leads to such
difference?


Thanks for posting your data, Marlon.

This is what I get on windows XP:


tcp1-tcp2

  [,1]  [,2]  [,3]
[1,] -2.861023e-06 -4.768372e-07 -4.768372e-07
[2,] -4.768372e-07 -3.814697e-06  2.622604e-06
[3,] -4.768372e-07  2.622604e-06 -5.960464e-08




but on my Gentoo Linux Intel Core 2 Duo:

 print(tcp1-tcp2,digits=20)
 [,1] [,2] [,3]
[1,]000
[2,]000
[3,]000






So, it would seem to be that the floating point calcs on my Windows
box, David's Mac, and whatever system you are using are not as
accurate as they might be.

It is well known that rounding error can play havoc with crossproducts 
(particularly when the range of magnitudes of the numbers is wide as it is 
here), which is why matrix decompositions are generally used for solving 
least squares problems.


The internal code for crossprod and tcrossprod is different, so the
computations are likely done in a different order, which would account
for the difference in tcp1 and tcp2 . Ultimately, array.c and blas.f SUBROUTINE
DSYRK have the code if you want to dig into it.

So to summarize: the difference is not due to R per se, but in the
limited accuracy of floating point calcs on the system used.

HTH,

Chuck




Marlon.

-Original Message-
From: David Winsemius [mailto:dwinsem...@comcast.net]
Sent: Thursday, 15 January 2009 6:04 p.m.
To: Charles C. Berry
Cc: dos Reis, Marlon; r-help@r-project.org
Subject: Re: [R] Precision in R

I am seeing different behavior than don Reis on my installation as well:
mtx is the same as his WBtWB

 mtx - matrix(c(1916061939, 2281366606,  678696067, 2281366606,
3098975504, 1092911209, 678696067, 1092911209,  452399849), ncol=3)

 mtx
   [,1]   [,2]   [,3]
[1,] 1916061939 2281366606  678696067
[2,] 2281366606 3098975504 1092911209
[3,]  678696067 1092911209  452399849
 eigen(mtx)
$values
[1]  5.208856e+09  2.585816e+08 -4.276959e-01

$vectors
   [,1]   [,2]   [,3]
[1,] -0.5855545 -0.7092633  0.3925195
[2,] -0.7678140  0.3299775 -0.5491599
[3,] -0.2599763  0.6229449  0.7378021

 rcond(mtx)
[1] 5.33209e-11

Despite a very ill-conditioned matrix, solve still proceeds

 solve(mtx)
   [,1]   [,2]   [,3]
[1,] -0.3602361  0.5039933 -0.6771204
[2,]  0.5039933 -0.7051189  0.9473348
[3,] -0.6771204  0.9473348 -1.2727543

 sessionInfo()
R version 2.8.1 Patched (2009-01-07 r47515)
i386-apple-darwin9.6.0

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

snipped package info

--
David Winsemius
On Jan 14, 2009, at 11:15 PM, Charles C. Berry wrote:



Marlon,

Are you using a current version of R? sessionInfo()?

It would help if you had something we could _fully_ reproduce.

Taking the _printed_ values you have below (WBtWB) and adding or
subtracting what you have printed as the difference of the two
visually equal matrices ( say Delta ) , I am able to run

solve( dat3 )
solve( WBtWB + Delta )
solve( WBtWB - Delta )
solve( WBtWB + 2*Delta )
solve( WBtWB - 2*Delta )

and get the results to agree to 3 significant digits. And perturbing
things even more I still get solve() to return a value:


for ( i in 1:1000 ) solve(WBtWB - tcrossprod(rnorm(3)))
for ( i in 1:1000 ) solve(WBtWB + tcrossprod(rnorm(3)))



And I cannot get condition numbers anything like what you report:


range(replicate( 1, 1/kappa(dat3-tcrossprod(matrix(rnorm(9),
3)

[1] 5.917764e-11 3.350445e-09





So I am very curious that you got the results that you print below.

I suppose that it is possible that the difference between what you
report and what I see lies in the numerical libraries (LINPACK/
LAPACK) that R calls upon.

This was done on a windows XP PC. Here is my sessionInfo()


sessionInfo()

R version 2.8.1 Patched (2008-12-22 r47296)
i386-pc-mingw32

locale:
LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.
1252;LC_MONETARY=English_United States.
1252;LC_NUMERIC=C;LC_TIME=English_United States.1252

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




HTH,

Chuck

On Thu, 15 Jan 2009, dos Reis, Marlon wrote:


Dear All,
I'm preparing a simple algorithm for matrix multiplication for a
specific purpose, but I'm getting some unexpected results.
If anyone could give a clue, I would really appreciate.
Basically what I want to do is a simple matrix multiplication:
(WB) %*% t(WB).
The WB is 

[R] user library help functionality (packages.html)

2009-01-15 Thread Jarrett Barber

Here's another help file question.

Some context: University setting wherein R is installed for  
availability to students and course instructors across campus in  
various PC labs.  Windows Vista environment.


Goal: To maximize flexibility and functionality of installing add-on  
packages and associated help files among different users, while  
avoiding conflicts across different user libraries.  (I could have my  
difficult-to-access sysadmin install _all_ libraries, but this seems  
wasteful, and would seem to present problems when my colleague or I  
want to update a package or install a newly available package but do  
not have time to wait a week or two for our sysadmin.)


Problem (?): As a course instructor, I want flexibility to install add- 
on libraries to a user (not site) library, and I don't want to step on  
my colleagues' toes (or vice-versa) when it comes to add-on packages  
and associated help files for use in classes.  I have no problem  
installing add-on packages to a user library, with one exception: I do  
not have permission to update the file $RHOME/doc/html/packages.html,  
as evidenced by a permission error upon installing a package to a user  
library using update.packages (not to the default site library, which  
is also restricted).  The installed add-on packages work fine, with  
the exception of some of the help functionality.  I find myself having  
to use browseURL() to point to the html files in the package's file  
structure.  I cannot expect the average student (or senior colleague)  
to tolerate this situation.


I'm thinking that I simply need to have my sysadmin give me and my  
colleagues (all users who want to install add-ons packages?)  
permission to read/write packages.html, and the problem will go away.   
But, before I ask my sysadmin to give permission, I want to know, does  
this create another problem?  For example, my colleague creates a  
library for STAT3000BC, which, I assume, will modify packages.html  
(assuming my sysadmin gives permission), then I create a library for  
STAT2010, which also modifies packages.html.  See my concern?  Does R  
somehow allow harmonious help functionality in such cases (by, for  
example, maintaining separate copies of packages.html for different  
users)?


Suggestions?  Thanks.

Jarrett


--
Jarrett Barber
Assistant Professor
Ross Hall Room 333
Department of Statistics
Dept. 3332
University of Wyoming
1000 E. University Ave.
Office: (307) 766-3341
Mobile: (307) 399-7759
FAX: (307) 766-3927
Reply To: jbarber8[ATT]uwyo.edu

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Bar Plot ggplot2 Filling bars with cross hatching

2009-01-15 Thread hadley wickham
Hi Stephen,

 #I am putting a test together for an introductory biology class and I
 would like to put different cross hatching inside of each bar for the
 bar plot below

ggplot2 uses the grid package to do all the drawing, and currently
grid doesn't support cross-hatching, so unfortunately there's no way
to do this in ggplot2.

Regards,

Hadley

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

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Bar Plot ggplot2 Filling bars with cross hatching

2009-01-15 Thread hadley wickham
This will be fixed in the next version, but until then you can do
title = Aquarium\n

Hadley

On Wed, Jan 14, 2009 at 9:24 PM, stephen sefick ssef...@gmail.com wrote:
 Also notice that the q in Aquarium is hidden.  Is there a way to make
 this not happen?
 thanks

 Stephen Sefick

 On Wed, Jan 14, 2009 at 10:18 PM, stephen sefick ssef...@gmail.com wrote:
 #I am putting a test together for an introductory biology class and I
 would like to put different cross hatching inside of each bar for the
 bar plot below

 color - c(Brightly Colored, Dull, Neither)
 lizards - c(277, 70, 3)
 liz.col - data.frame(color, lizards)
 qplot(color, lizards, data=liz.col, geom=bar, ylab=Observed
 Matings, main=Counts Out of 350 Aquariums, ylim=c(0,400),
 fill=color)+scale_y_continuous(breaks=c(0, 70, 277, 350))


 Thanks
 --
 Stephen Sefick

 Let's not spend our time and resources thinking about things that are
 so little or so large that all they really do for us is puff us up and
 make us feel like gods.  We are mammals, and have not exhausted the
 annoying little problems of being mammals.

-K. Mullis




 --
 Stephen Sefick

 Let's not spend our time and resources thinking about things that are
 so little or so large that all they really do for us is puff us up and
 make us feel like gods.  We are mammals, and have not exhausted the
 annoying little problems of being mammals.

-K. Mullis

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




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

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

2009-01-15 Thread rkevinburton
I have a question on whether a warning message is valid or if I just don't 
understand the process. Let me illustrate via some R code:

x - 1:20
i - x %% 2  0
y - rep(1,20)

x[i] - y
Warning message:
In x[i] - y :
  number of items to replace is not a multiple of replacement length

But it still does what I would expect for the assignment:

 x
 [1]  1  2  1  4  1  6  1  8  1 10  1 12  1 14  1 16  1 18  1 20
 

What don't I understand?

Thank you.

Kevin

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


Re: [R] Warning on assignment.

2009-01-15 Thread Sarah Goslee
The lengths are different, particularly the length of subsetted x[i]

 x - 1:20
 i - x %% 2  0
 y - rep(1,20)

 length(x)
[1] 20
 length(i)
[1] 20
 length(x[i])
[1] 10
 length(y)
[1] 20

You happened to be lucky and got what you wanted, but a more reliable
approach is:

 x[i] - y[i]

Sarah

On Thu, Jan 15, 2009 at 1:08 PM,  rkevinbur...@charter.net wrote:
 I have a question on whether a warning message is valid or if I just don't 
 understand the process. Let me illustrate via some R code:

 x - 1:20
 i - x %% 2  0
 y - rep(1,20)

 x[i] - y
 Warning message:
 In x[i] - y :
  number of items to replace is not a multiple of replacement length

 But it still does what I would expect for the assignment:

 x
  [1]  1  2  1  4  1  6  1  8  1 10  1 12  1 14  1 16  1 18  1 20


 What don't I understand?

 Thank you.

 Kevin


-- 
Sarah Goslee
http://www.functionaldiversity.org

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

2009-01-15 Thread rkevinburton
This was just an illustration. It is the warning message that I don't 
understand. The warning says number of items to replace is not a multiple of 
replacement length. The way I look at it 10 is a multiple of 20.

Kevin

 Sarah Goslee sarah.gos...@gmail.com wrote: 
 The lengths are different, particularly the length of subsetted x[i]
 
  x - 1:20
  i - x %% 2  0
  y - rep(1,20)
 
  length(x)
 [1] 20
  length(i)
 [1] 20
  length(x[i])
 [1] 10
  length(y)
 [1] 20
 
 You happened to be lucky and got what you wanted, but a more reliable
 approach is:
 
  x[i] - y[i]
 
 Sarah
 
 On Thu, Jan 15, 2009 at 1:08 PM,  rkevinbur...@charter.net wrote:
  I have a question on whether a warning message is valid or if I just don't 
  understand the process. Let me illustrate via some R code:
 
  x - 1:20
  i - x %% 2  0
  y - rep(1,20)
 
  x[i] - y
  Warning message:
  In x[i] - y :
   number of items to replace is not a multiple of replacement length
 
  But it still does what I would expect for the assignment:
 
  x
   [1]  1  2  1  4  1  6  1  8  1 10  1 12  1 14  1 16  1 18  1 20
 
 
  What don't I understand?
 
  Thank you.
 
  Kevin
 
 
 -- 
 Sarah Goslee
 http://www.functionaldiversity.org

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

2009-01-15 Thread Peter Dalgaard
rkevinbur...@charter.net wrote:
 This was just an illustration. It is the warning message that I don't
understand. The warning says number of items to replace is not a
multiple of replacement length. The way I look at it 10 is a multiple
of 20.

Um, with a multiplier of 0.5 ?

You're trying to put 20 things in 10 boxes. R will allow 10 things in 20
boxes (by recycling) without complaining.

-- 
   O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - (p.dalga...@biostat.ku.dk)  FAX: (+45) 35327907

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

2009-01-15 Thread Marc Schwartz
on 01/15/2009 11:42 AM David M Smith wrote:
 On Sun, Jan 11, 2009 at 11:05 AM, Kingsford Jones
 kingsfordjo...@gmail.com wrote:
 I hope that Marc doesn't mind, but I felt that part of his recent post
 was important enough to deserve it's own subject line rather then
 being lost in a 60-msg-long thread...
 
 I also wanted to thank Marc for this wealth of information on using R
 in clinical trials. I particularly want to recommend the R:
 Regulatory Compliance and Validation Issues document at
 http://www.r-project.org/certification.html .  Even if you're not
 looking to validate R for 21CFR11 compliance, this document is an
 excellent description of R's world-class software development process.
  With this, and the documented use of R by the FDA itself and within
 pharma companies for clinical trials, I hope we can settle the Is R
 Validated? question at long last. Thanks go to the authors (Marc
 Schwartz, Frank Harrell, Tony Rossini and Ian Francis) and the R
 Foundation generally for putting this together.

Thanks kindly David.

On the R Foundation side, I want to ensure appropriate credit and note
the tremendous assistance specifically provided by Doug Bates, Martin
Maechler, Peter Dalgaard, Kurt Hornik and John Fox. Over the past couple
of years their time, support, review and edits of the document ensured
that the light at the end of the tunnel was not an oncoming train and
ensured the accuracy of the content in documenting the R development
process.

In addition, their critical facilitation of the R Foundation review and
approval process has enabled us to have these recent discussions
predicated upon a base of formal and publicly available information that
should put to rest any concerns over R's quality development procedures.

R is developed and maintained using a world class process, implemented
by a world class team. Importantly and so that we never forget, that
Core team is comprised of volunteers who have donated of their time and
careers to bring us R and to enable this wonderful community.

Regards,

Marc

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

2009-01-15 Thread Carlos Hernandez

dear All,
i'm trying to calculate the number of Mondays, Tuesdays, etc that each  
month within a date range has. I have time series data that spans 60  
months and i want to calculate the number of Mondays, Tuesdays, Wed,  
etc of each month. (I want to control for weekly seasonality but my  
data is monthly).


Is there an easy way to to this in R? or is there a package i could  
use? i did some quick search in the help files and R sites but could  
not find any answers.


i appreciate any hint you could give,

thanks.

Carlos

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

2009-01-15 Thread Roy Mendelssohn

?chron()  in particular day.of.week

-Roy
On Jan 15, 2009, at 11:28 AM, Carlos Hernandez wrote:


dear All,
i'm trying to calculate the number of Mondays, Tuesdays, etc that  
each month within a date range has. I have time series data that  
spans 60 months and i want to calculate the number of Mondays,  
Tuesdays, Wed, etc of each month. (I want to control for weekly  
seasonality but my data is monthly).


Is there an easy way to to this in R? or is there a package i could  
use? i did some quick search in the help files and R sites but could  
not find any answers.


i appreciate any hint you could give,

thanks.

Carlos

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


**
The contents of this message do not reflect any position of the U.S.  
Government or NOAA.

**
Roy Mendelssohn
Supervisory Operations Research Analyst
NOAA/NMFS
Environmental Research Division
Southwest Fisheries Science Center
1352 Lighthouse Avenue
Pacific Grove, CA 93950-2097

e-mail: roy.mendelss...@noaa.gov (Note new e-mail address)
voice: (831)-648-9029
fax: (831)-648-8440
www: http://www.pfeg.noaa.gov/

Old age and treachery will overcome youth and skill.
From those who have been given much, much will be expected

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

2009-01-15 Thread David Winsemius


On Jan 15, 2009, at 2:28 PM, Carlos Hernandez wrote:


dear All,
i'm trying to calculate the number of Mondays, Tuesdays, etc that  
each month within a date range has. I have time series data that  
spans 60 months and i want to calculate the number of Mondays,  
Tuesdays, Wed, etc of each month. (I want to control for weekly  
seasonality but my data is monthly).


Is there an easy way to to this in R? or is there a package i could  
use? i did some quick search in the help files and R sites but could  
not find any answers.


The chron package has a wide assortment of functions of that sort.

Looks like Mondays would be 1

 day.of.week(1,15,2009) # a Thursday
[1] 4
 day.of.week(1,18,2009) #Saturday
[1] 0
 day.of.week(1,17,2009) #Sunday
[1] 6


--
David Winsemius

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

2009-01-15 Thread Gabor Grothendieck
Try this:

 library(zoo) # as.yearmon
 dd - seq(as.Date(2000-01-01), as.Date(2004-12-31), day)
 dow - as.numeric(format(dd, %w))
 ym - as.yearmon(dd)
 tab - do.call(rbind, tapply(dow, ym, table))
 rownames(tab) - format(as.yearmon(as.numeric(rownames(tab
 head(tab)
 0 1 2 3 4 5 6
Jan 2000 5 5 4 4 4 4 5
Feb 2000 4 4 5 4 4 4 4
Mar 2000 4 4 4 5 5 5 4
Apr 2000 5 4 4 4 4 4 5
May 2000 4 5 5 5 4 4 4
Jun 2000 4 4 4 4 5 5 4


On Thu, Jan 15, 2009 at 2:28 PM, Carlos Hernandez carlos.u...@gmail.com wrote:
 dear All,
 i'm trying to calculate the number of Mondays, Tuesdays, etc that each month
 within a date range has. I have time series data that spans 60 months and i
 want to calculate the number of Mondays, Tuesdays, Wed, etc of each month.
 (I want to control for weekly seasonality but my data is monthly).

 Is there an easy way to to this in R? or is there a package i could use? i
 did some quick search in the help files and R sites but could not find any
 answers.

 i appreciate any hint you could give,

 thanks.

 Carlos

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

2009-01-15 Thread Peter Dalgaard
Carlos Hernandez wrote:
 dear All,
 i'm trying to calculate the number of Mondays, Tuesdays, etc that each
 month within a date range has. I have time series data that spans 60
 months and i want to calculate the number of Mondays, Tuesdays, Wed, etc
 of each month. (I want to control for weekly seasonality but my data is
 monthly).
 
 Is there an easy way to to this in R? or is there a package i could use?
 i did some quick search in the help files and R sites but could not find
 any answers.
 
 i appreciate any hint you could give,

This is where POSIXlt objects are useful:

 unlist(unclass(as.POSIXlt(ISOdate(1959,3,11
  sec   min  hour  mday   mon  year  wday  yday isdst
0 01211 259 369 0

Which means that I was born on a Wednesday (wday==3) in March (mon==2)
(some of the fields count from 0 and others, like mday, from 1;
presumably some UNIX vendor back in the Stone Age got their
implementation turned into a standard...).

This allows you to do stuff like:


 dd - seq(Sys.Date(),as.Date(2009-3-11),1)
 dd - as.POSIXlt(dd)
 with(dd, table(mon,wday))
   wday
mon 0 1 2 3 4 5 6
  0 2 2 2 2 3 3 3
  1 4 4 4 4 4 4 4
  2 2 2 2 2 1 1 1

which I think is pretty much what you were looking for.


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


-- 
   O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - (p.dalga...@biostat.ku.dk)  FAX: (+45) 35327907

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

2009-01-15 Thread jimdare

Thanks, I knew it was something simple :) 




Petr Pikal wrote:
 
 Hi
 
 r-help-boun...@r-project.org napsal dne 15.01.2009 04:47:39:
 
 
 Dear R-Users
 if I have a data frame (or zoo data) as follows:
 
 Run  Bike Walk Drive
 1   2  7 5
 5   2  4 2 
 8   3  2 1
 
 How can I re-order it so that it reads: 
 
 Drive Run  Bike Walk 
   5  1  2 7 
   2  5  2 4 
   1  8  3 2 
 i.e. Drive has been copied and pasted to the left most column.
 
 test
   Run Bike Walk Drive
 1   127 5
 2   524 2
 3   832 1
 
 test2 - test[, c(4,1,2,3)]
   Drive Run Bike Walk
 1 5   127
 2 2   524
 3 1   832
 
 if you want it in new data frame or
 
 test - test[, c(4,1,2,3)]
 
 if you want to overwrite it.
 
 Regards
 Petr
 
 
 
 Thanks for your help.
 
 James
 -- 
 View this message in context: http://www.nabble.com/Moving-a-Data-Frame-
 Column-tp21470798p21470798.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.
 
 

-- 
View this message in context: 
http://www.nabble.com/Moving-a-Data-Frame-Column-tp21470798p21485810.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] user library help functionality (packages.html)

2009-01-15 Thread Jarrett Barber
This helps a lot.  I have options(htmlhelp=TRUE) and  
options(chmhelp=FALSE) (else problems).  Now, ?, help(), and  
help.search() seem to work well.  But, help.start() appears restricted  
to packages in the site library.  I see, in the Help/FAQ on R for  
Windows/ Sections 4.3 and 4.4, that I cannot expect more from  
help.start() unless I have write permission to $RHOME/library, which I  
do not (package does have a CONTENTS file however).  I assume that, if  
I want my students to have this functionality, they, too, would need  
write access to $RHOME/library, correct?  But, this does not seem a  
wise thing to give.  Am I missing something here, barring permission  
changes, that would allow help.search() to see user libraries?  This  
would be ideal, but your suggestions seems to give us nice help  
functionality, and I think we can implement an R installation campus- 
wide without the full functionality of help.seach().  Thanks very much.


Jarrett


R Session:

R version 2.7.0 (2008-04-22)
...snip...
 personalLib- .libPaths()[1]; personalLib
[1] H:\\Desktop\\RFiles\\Library
 getOption(htmlhelp)
[1] TRUE
 getOption(chmhelp)
[1] FALSE
 install.packages(UsingR,
+ lib=personalLib,
+ depend=TRUE)
trying URL 
'http://streaming.stat.iastate.edu/CRAN/bin/windows/contrib/2.7/UsingR_0.1-10.zip'
Content type 'application/zip' length 1433201 bytes (1.4 Mb)
opened URL
downloaded 1.4 Mb

package 'UsingR' successfully unpacked and MD5 sums checked

The downloaded packages are in
C:\Temp\RtmpQr4t3E\downloaded_packages
updating HTML package descriptions
Warning message:
In file.create(f.tg) :
  cannot create file 'C:\PROGRA~1\R\R-27~1.0/doc/html/packages.html',  
reason 'Permission denied'  ## PERMISSION PROBLEM

 library(UsingR)
Warning message:
package 'UsingR' was built under R version 2.7.2
 help(UsingR) ## works!
Help for ëUsingRí is shown in the browser
 help.start() ## restricted to site library
updating HTML package listing
updating HTML search index
fixing URLs in non-standard libraries
If nothing happens, you should open 'C:\PROGRA~1\R\R-27~1.0\doc\html 
\index.html' yourself

Warning message:
In file.create(f.tg) :
  cannot create file 'C:\PROGRA~1\R\R-27~1.0/doc/html/packages.html',  
reason 'Permission denied' ## SAME PERMISSION PROBLEM

 help.search(UsingR) ## works!
 ?UsingR ## works!
Help for ëUsingRí is shown in the browser
 q()


On Jan 15, 2009, at 11:42 AM, Duncan Murdoch wrote:


On 1/15/2009 12:50 PM, Jarrett Barber wrote:

Here's another help file question.
Some context: University setting wherein R is installed for   
availability to students and course instructors across campus in   
various PC labs.  Windows Vista environment.
Goal: To maximize flexibility and functionality of installing add- 
on  packages and associated help files among different users,  
while  avoiding conflicts across different user libraries.  (I  
could have my  difficult-to-access sysadmin install _all_  
libraries, but this seems  wasteful, and would seem to present  
problems when my colleague or I  want to update a package or  
install a newly available package but do  not have time to wait a  
week or two for our sysadmin.)
Problem (?): As a course instructor, I want flexibility to install  
add- on libraries to a user (not site) library, and I don't want to  
step on  my colleagues' toes (or vice-versa) when it comes to add- 
on packages  and associated help files for use in classes.  I have  
no problem  installing add-on packages to a user library, with one  
exception: I do  not have permission to update the file $RHOME/doc/ 
html/packages.html,  as evidenced by a permission error upon  
installing a package to a user  library using update.packages (not  
to the default site library, which  is also restricted).  The  
installed add-on packages work fine, with  the exception of some of  
the help functionality.  I find myself having  to use browseURL()  
to point to the html files in the package's file  structure.  I  
cannot expect the average student (or senior colleague)  to  
tolerate this situation.


A simpler way to get to the HTML man pages is to run

options(htmlhelp=TRUE)

and then the regular ?topic or help(topic) will find the HTML help  
pages in your local library.


I'm thinking that I simply need to have my sysadmin give me and my   
colleagues (all users who want to install add-ons packages?)   
permission to read/write packages.html, and the problem will go  
away.   But, before I ask my sysadmin to give permission, I want to  
know, does  this create another problem?  For example, my colleague  
creates a  library for STAT3000BC, which, I assume, will modify  
packages.html  (assuming my sysadmin gives permission), then I  
create a library for  STAT2010, which also modifies packages.html.   
See my concern?  Does R  somehow allow harmonious help  
functionality in such cases (by, for  example, maintaining separate  
copies of packages.html for different  users)?


You will likely 

Re: [R] user library help functionality (packages.html)

2009-01-15 Thread Duncan Murdoch

On 1/15/2009 3:17 PM, Jarrett Barber wrote:
This helps a lot.  I have options(htmlhelp=TRUE) and  
options(chmhelp=FALSE) (else problems).  Now, ?, help(), and  
help.search() seem to work well.  But, help.start() appears restricted  
to packages in the site library.  I see, in the Help/FAQ on R for  
Windows/ Sections 4.3 and 4.4, that I cannot expect more from  
help.start() unless I have write permission to $RHOME/library, which I  
do not (package does have a CONTENTS file however).  I assume that, if  
I want my students to have this functionality, they, too, would need  
write access to $RHOME/library, correct?  But, this does not seem a  
wise thing to give.  Am I missing something here, barring permission  
changes, that would allow help.search() to see user libraries?  


You mean help.start() here, don't you?  help.search() does see 
everything in the libraries listed in .libPaths().



This
would be ideal, but your suggestions seems to give us nice help  
functionality, and I think we can implement an R installation campus- 
wide without the full functionality of help.seach().  Thanks very much.


As far as I know on Windows there's currently no way to get help.start() 
to go to a personalized page.  The stuff that it refers to all lives in 
RHOME/doc/html, and many of the links in the files it works with assume 
that they are installed in the same hierarchy.


I'm not sure if things are different on Unix, where we use soft links to 
make all the package directories appear to be under one parent.


Duncan Murdoch


Jarrett


R Session:

R version 2.7.0 (2008-04-22)
...snip...
  personalLib- .libPaths()[1]; personalLib
[1] H:\\Desktop\\RFiles\\Library
  getOption(htmlhelp)
[1] TRUE
  getOption(chmhelp)
[1] FALSE
  install.packages(UsingR,
+ lib=personalLib,
+ depend=TRUE)
trying URL 
'http://streaming.stat.iastate.edu/CRAN/bin/windows/contrib/2.7/UsingR_0.1-10.zip'
Content type 'application/zip' length 1433201 bytes (1.4 Mb)
opened URL
downloaded 1.4 Mb

package 'UsingR' successfully unpacked and MD5 sums checked

The downloaded packages are in
 C:\Temp\RtmpQr4t3E\downloaded_packages
updating HTML package descriptions
Warning message:
In file.create(f.tg) :
   cannot create file 'C:\PROGRA~1\R\R-27~1.0/doc/html/packages.html',  
reason 'Permission denied'  ## PERMISSION PROBLEM

  library(UsingR)
Warning message:
package 'UsingR' was built under R version 2.7.2
  help(UsingR) ## works!
Help for ëUsingRí is shown in the browser
  help.start() ## restricted to site library
updating HTML package listing
updating HTML search index
fixing URLs in non-standard libraries
If nothing happens, you should open 'C:\PROGRA~1\R\R-27~1.0\doc\html 
\index.html' yourself

Warning message:
In file.create(f.tg) :
   cannot create file 'C:\PROGRA~1\R\R-27~1.0/doc/html/packages.html',  
reason 'Permission denied' ## SAME PERMISSION PROBLEM

  help.search(UsingR) ## works!
  ?UsingR ## works!
Help for ëUsingRí is shown in the browser
  q()


On Jan 15, 2009, at 11:42 AM, Duncan Murdoch wrote:


On 1/15/2009 12:50 PM, Jarrett Barber wrote:

Here's another help file question.
Some context: University setting wherein R is installed for   
availability to students and course instructors across campus in   
various PC labs.  Windows Vista environment.
Goal: To maximize flexibility and functionality of installing add- 
on  packages and associated help files among different users,  
while  avoiding conflicts across different user libraries.  (I  
could have my  difficult-to-access sysadmin install _all_  
libraries, but this seems  wasteful, and would seem to present  
problems when my colleague or I  want to update a package or  
install a newly available package but do  not have time to wait a  
week or two for our sysadmin.)
Problem (?): As a course instructor, I want flexibility to install  
add- on libraries to a user (not site) library, and I don't want to  
step on  my colleagues' toes (or vice-versa) when it comes to add- 
on packages  and associated help files for use in classes.  I have  
no problem  installing add-on packages to a user library, with one  
exception: I do  not have permission to update the file $RHOME/doc/ 
html/packages.html,  as evidenced by a permission error upon  
installing a package to a user  library using update.packages (not  
to the default site library, which  is also restricted).  The  
installed add-on packages work fine, with  the exception of some of  
the help functionality.  I find myself having  to use browseURL()  
to point to the html files in the package's file  structure.  I  
cannot expect the average student (or senior colleague)  to  
tolerate this situation.


A simpler way to get to the HTML man pages is to run

options(htmlhelp=TRUE)

and then the regular ?topic or help(topic) will find the HTML help  
pages in your local library.


I'm thinking that I simply need to have my sysadmin give me and my   
colleagues (all users who want to install add-ons 

Re: [R] user library help functionality (packages.html)

2009-01-15 Thread Jarrett Barber
Whoops!  Yes, my last help.search() should have been  
help.start().  Thanks again.  -- Jarrett


On Jan 15, 2009, at 1:27 PM, Duncan Murdoch wrote:


On 1/15/2009 3:17 PM, Jarrett Barber wrote:
This helps a lot.  I have options(htmlhelp=TRUE) and   
options(chmhelp=FALSE) (else problems).  Now, ?, help(), and   
help.search() seem to work well.  But, help.start() appears  
restricted  to packages in the site library.  I see, in the Help/ 
FAQ on R for  Windows/ Sections 4.3 and 4.4, that I cannot expect  
more from  help.start() unless I have write permission to $RHOME/ 
library, which I  do not (package does have a CONTENTS file  
however).  I assume that, if  I want my students to have this  
functionality, they, too, would need  write access to $RHOME/ 
library, correct?  But, this does not seem a  wise thing to give.   
Am I missing something here, barring permission  changes, that  
would allow help.search() to see user libraries?


You mean help.start() here, don't you?  help.search() does see  
everything in the libraries listed in .libPaths().



This
would be ideal, but your suggestions seems to give us nice help   
functionality, and I think we can implement an R installation  
campus- wide without the full functionality of help.seach().   
Thanks very much.


As far as I know on Windows there's currently no way to get  
help.start() to go to a personalized page.  The stuff that it refers  
to all lives in RHOME/doc/html, and many of the links in the files  
it works with assume that they are installed in the same hierarchy.


I'm not sure if things are different on Unix, where we use soft  
links to make all the package directories appear to be under one  
parent.


Duncan Murdoch


Jarrett
R Session:
R version 2.7.0 (2008-04-22)
...snip...
 personalLib- .libPaths()[1]; personalLib
[1] H:\\Desktop\\RFiles\\Library
 getOption(htmlhelp)
[1] TRUE
 getOption(chmhelp)
[1] FALSE
 install.packages(UsingR,
+ lib=personalLib,
+ depend=TRUE)
trying URL 
'http://streaming.stat.iastate.edu/CRAN/bin/windows/contrib/2.7/UsingR_0.1-10.zip'
Content type 'application/zip' length 1433201 bytes (1.4 Mb)
opened URL
downloaded 1.4 Mb
package 'UsingR' successfully unpacked and MD5 sums checked
The downloaded packages are in
C:\Temp\RtmpQr4t3E\downloaded_packages
updating HTML package descriptions
Warning message:
In file.create(f.tg) :
  cannot create file 'C:\PROGRA~1\R\R-27~1.0/doc/html/ 
packages.html',  reason 'Permission denied'  ## PERMISSION PROBLEM

 library(UsingR)
Warning message:
package 'UsingR' was built under R version 2.7.2
 help(UsingR) ## works!
Help for ëUsingRí is shown in the browser
 help.start() ## restricted to site library
updating HTML package listing
updating HTML search index
fixing URLs in non-standard libraries
If nothing happens, you should open 'C:\PROGRA~1\R\R-27~1.0\doc 
\html \index.html' yourself

Warning message:
In file.create(f.tg) :
  cannot create file 'C:\PROGRA~1\R\R-27~1.0/doc/html/ 
packages.html',  reason 'Permission denied' ## SAME PERMISSION  
PROBLEM

 help.search(UsingR) ## works!
 ?UsingR ## works!
Help for ëUsingRí is shown in the browser
 q()
On Jan 15, 2009, at 11:42 AM, Duncan Murdoch wrote:

On 1/15/2009 12:50 PM, Jarrett Barber wrote:

Here's another help file question.
Some context: University setting wherein R is installed for
availability to students and course instructors across campus  
in   various PC labs.  Windows Vista environment.
Goal: To maximize flexibility and functionality of installing  
add- on  packages and associated help files among different  
users,  while  avoiding conflicts across different user  
libraries.  (I  could have my  difficult-to-access sysadmin  
install _all_  libraries, but this seems  wasteful, and would  
seem to present  problems when my colleague or I  want to update  
a package or  install a newly available package but do  not have  
time to wait a  week or two for our sysadmin.)
Problem (?): As a course instructor, I want flexibility to  
install  add- on libraries to a user (not site) library, and I  
don't want to  step on  my colleagues' toes (or vice-versa) when  
it comes to add- on packages  and associated help files for use  
in classes.  I have  no problem  installing add-on packages to a  
user library, with one  exception: I do  not have permission to  
update the file $RHOME/doc/ html/packages.html,  as evidenced by  
a permission error upon  installing a package to a user  library  
using update.packages (not  to the default site library, which   
is also restricted).  The  installed add-on packages work fine,  
with  the exception of some of  the help functionality.  I find  
myself having  to use browseURL()  to point to the html files in  
the package's file  structure.  I  cannot expect the average  
student (or senior colleague)  to  tolerate this situation.


A simpler way to get to the HTML man pages is to run

options(htmlhelp=TRUE)

and then the regular ?topic or help(topic) will find 

Re: [R] number of Mondays

2009-01-15 Thread Prof Brian Ripley

Or for those not allergic to reading help, see ?weekdays .

Just how hard do you have to work to miss that?  E.g. ??day works.

On Thu, 15 Jan 2009, Peter Dalgaard wrote:


Carlos Hernandez wrote:

dear All,
i'm trying to calculate the number of Mondays, Tuesdays, etc that each
month within a date range has. I have time series data that spans 60
months and i want to calculate the number of Mondays, Tuesdays, Wed, etc
of each month. (I want to control for weekly seasonality but my data is
monthly).

Is there an easy way to to this in R? or is there a package i could use?
i did some quick search in the help files and R sites but could not find
any answers.

i appreciate any hint you could give,


This is where POSIXlt objects are useful:


unlist(unclass(as.POSIXlt(ISOdate(1959,3,11

 sec   min  hour  mday   mon  year  wday  yday isdst
   0 01211 259 369 0

Which means that I was born on a Wednesday (wday==3) in March (mon==2)
(some of the fields count from 0 and others, like mday, from 1;
presumably some UNIX vendor back in the Stone Age got their
implementation turned into a standard...).

This allows you to do stuff like:



dd - seq(Sys.Date(),as.Date(2009-3-11),1)
dd - as.POSIXlt(dd)
with(dd, table(mon,wday))

  wday
mon 0 1 2 3 4 5 6
 0 2 2 2 2 3 3 3
 1 4 4 4 4 4 4 4
 2 2 2 2 2 1 1 1

which I think is pretty much what you were looking for.



thanks.

Carlos

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



--
  O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
 c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
(*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - (p.dalga...@biostat.ku.dk)  FAX: (+45) 35327907

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



--
Brian D. Ripley,  rip...@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Precision in R

2009-01-15 Thread Duncan Murdoch

On 1/15/2009 1:32 PM, David Winsemius wrote:

On Jan 15, 2009, at 12:25 PM, Charles C. Berry wrote:



This is what I get on windows XP:


tcp1-tcp2

 [,1]  [,2]  [,3]
[1,] -2.861023e-06 -4.768372e-07 -4.768372e-07
[2,] -4.768372e-07 -3.814697e-06  2.622604e-06
[3,] -4.768372e-07  2.622604e-06 -5.960464e-08




but on my Gentoo Linux Intel Core 2 Duo:

print(tcp1-tcp2,digits=20)
[,1] [,2] [,3]
[1,]000
[2,]000
[3,]000




So, it would seem to be that the floating point calcs on my Windows
box, David's Mac, and whatever system you are using are not as
accurate as they might be.


For the record; on an Intel Mac (Leopard) with Urbanek's compilation  
of R 2.8.1


   print(tcp1-tcp2,digits=20)
  [,1] [,2] [,3]
[1,]000
[2,]000
[3,]000



I haven't debugged these, but I would guess this is because we have the 
Windows libraries set to use extended precision (64 bit mantissas) on 
intermediate results, whereas once things get stored to RAM, they are 
rounded to double precision (53 bit mantissas).  This has the benefit of 
giving a more accurate answer in many circumstances, but the 
disadvantage that the final results are more dependent on the order of 
calculations.  I think the other platforms never do the full extended 
precision calculations, so their results are consistent (but probably 
less accurate sometimes).


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] number of Mondays

2009-01-15 Thread Carlos Hernandez

Indeed, i overlooked weekdays.

Thank you all for your replies!


On Jan 15, 2009, at 21:23 , Prof Brian Ripley wrote:


Or for those not allergic to reading help, see ?weekdays .

Just how hard do you have to work to miss that?  E.g. ??day works.

On Thu, 15 Jan 2009, Peter Dalgaard wrote:


Carlos Hernandez wrote:

dear All,
i'm trying to calculate the number of Mondays, Tuesdays, etc that  
each

month within a date range has. I have time series data that spans 60
months and i want to calculate the number of Mondays, Tuesdays,  
Wed, etc
of each month. (I want to control for weekly seasonality but my  
data is

monthly).

Is there an easy way to to this in R? or is there a package i  
could use?
i did some quick search in the help files and R sites but could  
not find

any answers.

i appreciate any hint you could give,


This is where POSIXlt objects are useful:


unlist(unclass(as.POSIXlt(ISOdate(1959,3,11

sec   min  hour  mday   mon  year  wday  yday isdst
  0 01211 259 369 0

Which means that I was born on a Wednesday (wday==3) in March  
(mon==2)

(some of the fields count from 0 and others, like mday, from 1;
presumably some UNIX vendor back in the Stone Age got their
implementation turned into a standard...).

This allows you to do stuff like:



dd - seq(Sys.Date(),as.Date(2009-3-11),1)
dd - as.POSIXlt(dd)
with(dd, table(mon,wday))

 wday
mon 0 1 2 3 4 5 6
0 2 2 2 2 3 3 3
1 4 4 4 4 4 4 4
2 2 2 2 2 1 1 1

which I think is pretty much what you were looking for.



thanks.

Carlos

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



--
 O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
(*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45)  
35327918
~~ - (p.dalga...@biostat.ku.dk)  FAX: (+45)  
35327907


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



--
Brian D. Ripley,  rip...@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595


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

2009-01-15 Thread David Winsemius


On Jan 15, 2009, at 12:25 PM, Charles C. Berry wrote:



This is what I get on windows XP:


tcp1-tcp2

 [,1]  [,2]  [,3]
[1,] -2.861023e-06 -4.768372e-07 -4.768372e-07
[2,] -4.768372e-07 -3.814697e-06  2.622604e-06
[3,] -4.768372e-07  2.622604e-06 -5.960464e-08




but on my Gentoo Linux Intel Core 2 Duo:

print(tcp1-tcp2,digits=20)
[,1] [,2] [,3]
[1,]000
[2,]000
[3,]000




So, it would seem to be that the floating point calcs on my Windows
box, David's Mac, and whatever system you are using are not as
accurate as they might be.


For the record; on an Intel Mac (Leopard) with Urbanek's compilation  
of R 2.8.1


  print(tcp1-tcp2,digits=20)
 [,1] [,2] [,3]
[1,]000
[2,]000
[3,]000

--
David Winsemius




It is well known that rounding error can play havoc with  
crossproducts (particularly when the range of magnitudes of the  
numbers is wide as it is here), which is why matrix decompositions  
are generally used for solving least squares problems.


The internal code for crossprod and tcrossprod is different, so the
computations are likely done in a different order, which would account
for the difference in tcp1 and tcp2 . Ultimately, array.c and blas.f  
SUBROUTINE

DSYRK have the code if you want to dig into it.

So to summarize: the difference is not due to R per se, but in the
limited accuracy of floating point calcs on the system used.

HTH,

Chuck



snip

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] logistic regression - exp(estimates)?

2009-01-15 Thread Rolf Turner


On 16/01/2009, at 1:50 AM, gregor rolshausen wrote:


hello.

I have a question on the interpretation of a logistic model.

is it helpful to exponentiate the coefficients (estimates)? I think I
once read something about that, but I cannot remember where.
if so, how would be the interpretation of the exp(estimate) ?



exp(beta_i) is the odds ratio for success when the i-th predictor
x_i is incremented by 1.

In particular if x_i is a 0-1 indicator variable then exp(beta_i) is
the odds ratio for comparing the odds of success when x_i = 1 with
the odds of success when x_i = 0.

E.g. if x_i = 0 for Male and x_i = 1 for Female, and exp(beta_i) = 2,
then the odds of success for Females are twice as great as the odds
of success for Males.  I.e. Females are ``twice as likely'' to succeed
	as Males, all other things being equal.  (Which may or may not be a  
Good

Thing, depending on what ``success'' really means. :-) )


would there be a change of the interpretation of the ANOVA table  
(or is

the ANOVA table not really helpful at all?).


ANOVA tables are ***so*** 20th century!

cheers,

Rolf Turner

##
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}

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

2009-01-15 Thread Sarah Goslee
It's the other way around.

You are trying to replace 10 elements (x[i]) with 20 elements (y). R
makes a best
guess as to how you want to do that. 10 is not a multiple of 20.

If you were trying to replace 20 elements with 10, then R would recycle them
because 20 _is_ a multiple of 10.

The safest course is always to make sure you are replacing with equal numbers.

Sarah

On Thu, Jan 15, 2009 at 1:20 PM,  rkevinbur...@charter.net wrote:
 This was just an illustration. It is the warning message that I don't 
 understand. The warning says number of items to replace is not a multiple of 
 replacement length. The way I look at it 10 is a multiple of 20.

 Kevin

  Sarah Goslee sarah.gos...@gmail.com wrote:
 The lengths are different, particularly the length of subsetted x[i]

  x - 1:20
  i - x %% 2  0
  y - rep(1,20)

  length(x)
 [1] 20
  length(i)
 [1] 20
  length(x[i])
 [1] 10
  length(y)
 [1] 20

 You happened to be lucky and got what you wanted, but a more reliable
 approach is:

  x[i] - y[i]

 Sarah

 On Thu, Jan 15, 2009 at 1:08 PM,  rkevinbur...@charter.net wrote:
  I have a question on whether a warning message is valid or if I just don't 
  understand the process. Let me illustrate via some R code:
 
  x - 1:20
  i - x %% 2  0
  y - rep(1,20)
 
  x[i] - y
  Warning message:
  In x[i] - y :
   number of items to replace is not a multiple of replacement length
 
  But it still does what I would expect for the assignment:
 
  x
   [1]  1  2  1  4  1  6  1  8  1 10  1 12  1 14  1 16  1 18  1 20
 
 
  What don't I understand?
 
  Thank you.
 
  Kevin
 


-- 
Sarah Goslee
http://www.functionaldiversity.org

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


[R] Partial function application in R

2009-01-15 Thread nosek

Hello,

in a desperate desire of using partial function application in R I fried out
the following piece of code:

bind - function( f, ... ) {
  args - list(...)
  function(...) f( ..., unlist(args) )
}

Its purpose, if not clear, is to return a function with part of its
arguments bound to specific values, so that I can for example create and use
functions like this:
 q1 - bind( quantile, 0.25 )
 lapply( some_list, q1 )

It's been a lot of work and unfortunately is not perfect. My bind applies
arguments only using positional rule. What I dream of is a function bind2
that would apply keyword arguments, like:
 plot_lines - bind2( plot, type=l )
which would return
 function(...) plot( type=l, ... )

How to do this in R?

Regards,
nosek
-- 
View this message in context: 
http://www.nabble.com/Partial-function-application-in-R-tp21487269p21487269.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] user library help functionality (packages.html)

2009-01-15 Thread Duncan Murdoch

On 1/15/2009 12:50 PM, Jarrett Barber wrote:

Here's another help file question.

Some context: University setting wherein R is installed for  
availability to students and course instructors across campus in  
various PC labs.  Windows Vista environment.


Goal: To maximize flexibility and functionality of installing add-on  
packages and associated help files among different users, while  
avoiding conflicts across different user libraries.  (I could have my  
difficult-to-access sysadmin install _all_ libraries, but this seems  
wasteful, and would seem to present problems when my colleague or I  
want to update a package or install a newly available package but do  
not have time to wait a week or two for our sysadmin.)


Problem (?): As a course instructor, I want flexibility to install add- 
on libraries to a user (not site) library, and I don't want to step on  
my colleagues' toes (or vice-versa) when it comes to add-on packages  
and associated help files for use in classes.  I have no problem  
installing add-on packages to a user library, with one exception: I do  
not have permission to update the file $RHOME/doc/html/packages.html,  
as evidenced by a permission error upon installing a package to a user  
library using update.packages (not to the default site library, which  
is also restricted).  The installed add-on packages work fine, with  
the exception of some of the help functionality.  I find myself having  
to use browseURL() to point to the html files in the package's file  
structure.  I cannot expect the average student (or senior colleague)  
to tolerate this situation.


A simpler way to get to the HTML man pages is to run

options(htmlhelp=TRUE)

and then the regular ?topic or help(topic) will find the HTML help 
pages in your local library.




I'm thinking that I simply need to have my sysadmin give me and my  
colleagues (all users who want to install add-ons packages?)  
permission to read/write packages.html, and the problem will go away.   
But, before I ask my sysadmin to give permission, I want to know, does  
this create another problem?  For example, my colleague creates a  
library for STAT3000BC, which, I assume, will modify packages.html  
(assuming my sysadmin gives permission), then I create a library for  
STAT2010, which also modifies packages.html.  See my concern?  Does R  
somehow allow harmonious help functionality in such cases (by, for  
example, maintaining separate copies of packages.html for different  
users)?


You will likely have strange problems if you do that.  The 
doc/html/packages.html file is intended to talk about what is available 
to everyone; I suspect in your scenario, it would be updated to show 
your packages (but not your colleague's) whenever you added one, and 
then updated to show your colleague's packages (but not yours) when he 
added one, and would almost never be right for both of you.


The good news is that it looks as though sometime this year we will make 
quite substantial changes to the way the help system is stored, so a lot 
of things like packages.html could be generated on the fly.


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] Partial function application in R

2009-01-15 Thread David Winsemius

How is function() not the correct approach?

 plot_lines - function(x, ...) plot(x,  type=l, ...)

 plot_lines(1:10, xlim = c(1,5))

 plot_lines(1:10, 11:20, xlim = c(1,5))

Still seems to get the unnamed optional y argument to the plotting  
machinery.


--
David Winsemius

On Jan 15, 2009, at 4:25 PM, nosek wrote:



Hello,

in a desperate desire of using partial function application in R I  
fried out

the following piece of code:

bind - function( f, ... ) {
 args - list(...)
 function(...) f( ..., unlist(args) )
}

Its purpose, if not clear, is to return a function with part of its
arguments bound to specific values, so that I can for example create  
and use

functions like this:
q1 - bind( quantile, 0.25 )
lapply( some_list, q1 )

It's been a lot of work and unfortunately is not perfect. My bind  
applies
arguments only using positional rule. What I dream of is a function  
bind2

that would apply keyword arguments, like:
plot_lines - bind2( plot, type=l )
which would return
function(...) plot( type=l, ... )

How to do this in R?

Regards,
nosek
--
View this message in context: 
http://www.nabble.com/Partial-function-application-in-R-tp21487269p21487269.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] Partial function application in R

2009-01-15 Thread Gabor Grothendieck
Have a look at the setDefaults package.  It will set the default
arguments of a function to whatever you specify so that
if you omit them then those are the values you get for them.

On Thu, Jan 15, 2009 at 4:25 PM, nosek nospa...@interia.pl wrote:

 Hello,

 in a desperate desire of using partial function application in R I fried out
 the following piece of code:

 bind - function( f, ... ) {
  args - list(...)
  function(...) f( ..., unlist(args) )
 }

 Its purpose, if not clear, is to return a function with part of its
 arguments bound to specific values, so that I can for example create and use
 functions like this:
  q1 - bind( quantile, 0.25 )
  lapply( some_list, q1 )

 It's been a lot of work and unfortunately is not perfect. My bind applies
 arguments only using positional rule. What I dream of is a function bind2
 that would apply keyword arguments, like:
  plot_lines - bind2( plot, type=l )
 which would return
  function(...) plot( type=l, ... )

 How to do this in R?

 Regards,
 nosek
 --
 View this message in context: 
 http://www.nabble.com/Partial-function-application-in-R-tp21487269p21487269.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] Partial function application in R

2009-01-15 Thread nosek

Well, 

it looks like it's a perfectly correct approach to bind functions writing
their wrappers by hand.
But I don't want to write them by hand every time I need them.
Being lambda expression, function() is most general, but there must be some
kind of shorter way for such a common task as partial application.


David Winsemius wrote:
 
 How is function() not the correct approach?
 
   plot_lines - function(x, ...) plot(x,  type=l, ...)
  
   plot_lines(1:10, xlim = c(1,5))
 
   plot_lines(1:10, 11:20, xlim = c(1,5))
 
 Still seems to get the unnamed optional y argument to the plotting  
 machinery.
 
 -- 
 David Winsemius
 
 On Jan 15, 2009, at 4:25 PM, nosek wrote:
 

 Hello,

 in a desperate desire of using partial function application in R I  
 fried out
 the following piece of code:

 bind - function( f, ... ) {
  args - list(...)
  function(...) f( ..., unlist(args) )
 }

 Its purpose, if not clear, is to return a function with part of its
 arguments bound to specific values, so that I can for example create  
 and use
 functions like this:
 q1 - bind( quantile, 0.25 )
 lapply( some_list, q1 )

 It's been a lot of work and unfortunately is not perfect. My bind  
 applies
 arguments only using positional rule. What I dream of is a function  
 bind2
 that would apply keyword arguments, like:
 plot_lines - bind2( plot, type=l )
 which would return
 function(...) plot( type=l, ... )

 How to do this in R?

 Regards,
 nosek
 -- 
 View this message in context:
 http://www.nabble.com/Partial-function-application-in-R-tp21487269p21487269.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.
 
 

-- 
View this message in context: 
http://www.nabble.com/Partial-function-application-in-R-tp21487269p21489627.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] Security Data extraction

2009-01-15 Thread Subba Rao
Hi,

Today I came across the R application and I will admit I am not a
Statistician.  However, I think this application will be useful for me
at work.  I am a Network/System Security Engineer trying to make sense
of the huge security data I collect.  I am trying to visualize the
traffic on our network.   The data in the packet header (captured by
tcpdump) has all the information about the systems on the network.

There are lots of visual tools that can present the data in a meaningful
way.   Each tool seems to have a different data format while most tools
seem to understand CSV format?  How do I select the subset of the
network data or syslog data and create a CSV file?

How else can the R application help me present the security data in a
meaningful way to the management?

Please excuse my ignorance.

Thank you.

Subba Rao

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

2009-01-15 Thread Gabor Grothendieck
One other idea.  The proto package also does currying.  If f a method
(i.e. an R function
that takes an object as arg1 then p$f, i.e. the $.proto function,
returns function(...) f(p, ...).
Looking at the code for setDefaults as in my prior response and/or
proto should give
you some ideas.

On Thu, Jan 15, 2009 at 6:43 PM, Gabor Grothendieck
ggrothendi...@gmail.com wrote:
 Have a look at the setDefaults package.  It will set the default
 arguments of a function to whatever you specify so that
 if you omit them then those are the values you get for them.

 On Thu, Jan 15, 2009 at 4:25 PM, nosek nospa...@interia.pl wrote:

 Hello,

 in a desperate desire of using partial function application in R I fried out
 the following piece of code:

 bind - function( f, ... ) {
  args - list(...)
  function(...) f( ..., unlist(args) )
 }

 Its purpose, if not clear, is to return a function with part of its
 arguments bound to specific values, so that I can for example create and use
 functions like this:
  q1 - bind( quantile, 0.25 )
  lapply( some_list, q1 )

 It's been a lot of work and unfortunately is not perfect. My bind applies
 arguments only using positional rule. What I dream of is a function bind2
 that would apply keyword arguments, like:
  plot_lines - bind2( plot, type=l )
 which would return
  function(...) plot( type=l, ... )

 How to do this in R?

 Regards,
 nosek
 --
 View this message in context: 
 http://www.nabble.com/Partial-function-application-in-R-tp21487269p21487269.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.


[R] PDF slided (beamer or prosper) to an editable PPT

2009-01-15 Thread zubin
Hello, I am getting requests to place our PDF slides (output from 
beamer) into Microsoft Powerpoint formats (.ppt).  What's the best 
practice or any recommended software packages (any success with open or 
commercial) that we can use to convert PDF slides into an EDITABLE 
powerpoint deck? 


Thanks in advance.

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

2009-01-15 Thread jimdare

Dear R-Users

I have 2 questions to do with XYplot.  

1)

I am trying to use the XYplot function to generate multiple line graphs with
the legend outside the plot.
I am using the following loop for each graph:

library(lattice)

for (i in x.sp){
xyplot(Catch~Year, df, groups = Stock, type=a,auto.key =
   list(space = top, points = FALSE, lines = TRUE,columns = 4))
}

When I run the script I don't get any output graphs, however if I change
'XYplot' to 'plot', or generate the plots manually using XYplot, It seems to
work.  Is there a bug of some sort or is it me?

2)

How do I remove the top and right axis from a plot?  If I add 'axis(side
= c(bottom, left)' to the xyplot call it comes up with the message:
   
Error in axis(side = c(bottom, left)) : 
  plot.new has not been called yet

Any help is much appreciated :)


-- 
View this message in context: 
http://www.nabble.com/XYplot-in-Lattice-Package-tp21491296p21491296.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] Security Data extraction

2009-01-15 Thread Saeed Abu Nimeh
Subba Rao wrote:
 Hi,
 
 Today I came across the R application and I will admit I am not a
 Statistician.  However, I think this application will be useful for me
 at work.  I am a Network/System Security Engineer trying to make sense
 of the huge security data I collect.  I am trying to visualize the
 traffic on our network.   The data in the packet header (captured by
 tcpdump) has all the information about the systems on the network.
 
 There are lots of visual tools that can present the data in a meaningful
 way.   Each tool seems to have a different data format while most tools
 seem to understand CSV format?  How do I select the subset of the
 network data or syslog data and create a CSV file?

Sniff is a good tool: http://www.thedumbterminal.co.uk/software/sniff.shtml

 
 How else can the R application help me present the security data in a
 meaningful way to the management?

Depends on what you want to present

 
 Please excuse my ignorance.
 
 Thank you.
 
 Subba Rao
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Project Robust Linier Regresssion

2009-01-15 Thread Edwin Wibisono
Hello, I'm EDWIN, I create (make) GUI, with call many function
but I don't know why when I call function I can't. if without function, Yes
I can..

can you help me ? can you make this, become true with full code?
Can you help me to
create data.entry with interface
LM  - BETA1.HAT - BETA2.HAT SD.BETA1.HAT HAT SD.BETA2.HAT  RLM  - BETA1.HAT
- BETA2.HAT SD.BETA1.HAT HAT SD.BETA2.HAT
2
10   value
100


Thx
Edwwin
library(boot)
library(bootstrap)
library(MASS)   # MASS berisi tools untuk fitting robust regression 
library(tcltk)
library(stats)   
library(rpanel)


#
ambil-function() {
data - read.csv(F:/data.csv) 
plot-plot(data[,2],data[,3], xlab=Euro,ylab=Rupiah,main=Plot Euro, dan 
Rupiah)
 }

data - read.csv(F:/data.csv) 
x - data[,2]
y - data[,3]

#
function seluruhlinier(){
plot(x, y)
fred - lm(y ~ x)
curve(predict(fred, data.frame(x = x)), add = TRUE)
beta1.hat - coefficients(fred)[1]
beta2.hat - coefficients(fred)[2]
n - length(x)

beta1.star - double(nboot)
beta2.star - double(nboot)
for (i in 1:nboot) {
k.star - sample(n, replace = TRUE)
x.star - x[k.star]
y.star - y[k.star]
sally - lm(y.star ~ x.star )
curve(predict(sally, data.frame(x.star = x)),
add = TRUE, col = plum)
beta1.star[i] - coefficients(sally)[1]
beta2.star[i] - coefficients(sally)[2]
}
points(x, y, pch = 16)
curve(predict(fred, data.frame(x = x)),
   add = TRUE, lwd = 2)
data.frame (beta1.hat,sd(beta1.star),beta2.hat,sd(beta2.star),beta2.hat / 
sd(beta2.star))
}

#

function seluruhrobust(){
plot(x, y)
fred - rlm(y ~ x)
curve(predict(fred, data.frame(x = x)), add = TRUE)
beta1.hat - coefficients(fred)[1]
beta2.hat - coefficients(fred)[2]
n - length(x)

beta1.star - double(nboot)
beta2.star - double(nboot)
for (i in 1:nboot) {
k.star - sample(n, replace = TRUE)
x.star - x[k.star]
y.star - y[k.star]
sally - rlm(y.star ~ x.star )
curve(predict(sally, data.frame(x.star = x)),
add = TRUE, col = plum)
beta1.star[i] - coefficients(sally)[1]
beta2.star[i] - coefficients(sally)[2]
}
points(x, y, pch = 16)
curve(predict(fred, data.frame(x = x)),
   add = TRUE, lwd = 2)
data.frame (beta1.hat,sd(beta1.star),beta2.hat,sd(beta2.star),beta2.hat / 
sd(beta2.star))
}

#
function linier2(){
nboot - 2
seluruhlinier()
}
#

function linier30(){
nboot - 30
seluruhlinier()
}
###
function linier100(){
nboot - 100
seluruhlinier()
}


function robust2(){
nboot - 2
seluruhrobust()
}
#

function linier30(){
nboot - 30
seluruhrobust()
}
###
function linier100(){
nboot - 100
seluruhrobust()
}
###

hitungan-function()
{
#data.entry(y_hat_linier,y_hat_robust,Residual_linier,Residual_robust)
}






kesimpulan-function()
{
m4 - tktoplevel()
tkwm.geometry(m4, +0+0)
tkpack(fr - tkframe(m4), side = top)
tkwm.title(m4, Kesimpulan)
tkpack(tklabel(fr, text = Semakin besar bootstrap, semakin besar nilai beta1*, 
dan beta2*, Beta1 topi dan Beta topi2 akan tetap sama jika diulang terus 
menerus, width = 120), side = left)

tkpack(fr - tkframe(m4), side = top)
tkpack(tkbutton(m4, text = OK, command = function() tkdestroy(m4)),
side = right)
}


linier-function ()
 {
m2 - tktoplevel()
tkwm.geometry(m2, +0+0)
tkpack(fr - tkframe(m2), side = top)
tkwm.title(m2, Regresi Linier)
tkpack(tklabel(fr, text = OUTPUT, width = 50), side = left)
tkpack(tkbutton(m2, text = Regresi Linier B = 2,command=linier2), side = 
left) 
tkpack(tkbutton(m2, text = Regresi Linier B = 30,command=linier30), side = 
left)
tkpack(tkbutton(m2, text = Regresi Linier B = 100,command=linier100), side = 
left)

tkpack(fr - tkframe(m2), side = top)
tkpack(tkbutton(m2, text = Kembali, command = function() tkdestroy(m2)),
side = right)

 }


robust-function()
 {
m3 - tktoplevel()
tkwm.geometry(m3, +0+0)
tkpack(fr - tkframe(m3), side = top)
tkwm.title(m3, Regresi Robust)
tkpack(tklabel(fr, text = OUTPUT, width = 50), side = left)
tkpack(tkbutton(m3, text = Regresi robust B = 2,command=robust2), side = 
left) 
tkpack(tkbutton(m3, text = Regresi robust B = 

Re: [R] XYplot in Lattice Package

2009-01-15 Thread David Winsemius


On Jan 15, 2009, at 9:27 PM, jimdare wrote:



Dear R-Users

I have 2 questions to do with XYplot.

1)

I am trying to use the XYplot function to generate multiple line  
graphs with

the legend outside the plot.
I am using the following loop for each graph:

library(lattice)

for (i in x.sp){
xyplot(Catch~Year, df, groups = Stock, type=a,auto.key =
  list(space = top, points = FALSE, lines = TRUE,columns = 4))
}

 From the help on package lattice:
Note
High level Lattice functions (like xyplot) are different from  
conventional R graphics functions because they don't actually draw  
anything. Instead, they return an object of class trellis which has  
to be then printed or plotted to create the actual plot. This is  
normally done automatically, but not when the high level functions are  
called inside another function (most often source) or other contexts  
where automatic printing is suppressed (e.g. for or while loops). In  
such situations, an explicit call to print or plot is required.




Or the FAQ:

http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-do-lattice_002ftrellis-graphics-not-work_003f






When I run the script I don't get any output graphs, however if I  
change
'XYplot' to 'plot', or generate the plots manually using XYplot, It  
seems to

work.  Is there a bug of some sort or is it me?


It's you.




2)

How do I remove the top and right axis from a plot?  If I add  
'axis(side
= c(bottom, left)' to the xyplot call it comes up with the  
message:


Error in axis(side = c(bottom, left)) :
 plot.new has not been called yet


see at the top of the axis help page:

axis {graphics} so axis is not part of lattice

Had you continued reading the next sentence in the lattice intro help  
page, you would have seen:


Lattice plots are highly customizable via user-modifiable settings.  
However, these are completely unrelated to base graphics settings; in  
particular, changing par() settings usually have no effect on lattice  
plots.



Try:
http://stat.ethz.ch/R-manual/R-patched/library/lattice/html/axis.default.html

And chapter 8 of:

http://lmdvr.r-forge.r-project.org/figures/figures.html

Best of luck and buy Sarkar's book.
David Winsemius






Any help is much appreciated :)


--
View this message in context: 
http://www.nabble.com/XYplot-in-Lattice-Package-tp21491296p21491296.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.


[R] New Statistical Learning and Data Mining Course

2009-01-15 Thread Trevor Hastie

Short course: Statistical Learning and Data Mining III:
  Ten Hot Ideas for Learning from Data

 Trevor Hastie and Robert Tibshirani, Stanford University

 Sheraton Hotel
 Palo Alto, CA
 March 16-17, 2009

 This two-day course gives a detailed overview of statistical models  
for

 data mining, inference and prediction. With the rapid developments in
 internet technology, genomics, financial risk modeling, and other
 high-tech industries, we rely increasingly more on data analysis and
 statistical models to exploit the vast amounts of data at our
 fingertips.

 In this course we emphasize the tools useful for tackling modern-day
 data analysis problems. From the vast array of tools available, we  
have

 selected what we consider are the most relevant and exciting. Our
 top-ten list of topics are:

  * Regression and Logistic Regression (two golden oldies),
  * Lasso and Related Methods,
  * Support Vector and Kernel Methodology,
  * Principal Components (SVD) and Variations: sparse SVD, supervised  
PCA,

Multidimensional Scaling and Isomap, Nonnegative Matrix
 Factorization, and  Local Linear Embedding,
  * Boosting, Random Forests and Ensemble Methods,
  * Rule based methods (PRIM),
  * Graphical Models,
  * Cross-Validation,
  * Bootstrap,
  * Feature Selection, False Discovery Rates and Permutation Tests.

 Our earlier courses are not a prerequisite for this new course.  
Although

 there is some overlap with past courses, our new course contains many
 topics not covered by us before.

 The material is based on recent papers by the authors and other
 researchers, as well as the new second edition of our best selling  
book:


Statistical Learning: data mining, inference and prediction

Hastie, Tibshirani  Friedman, Springer-Verlag, 2008

http://www-stat.stanford.edu/ElemStatLearn/

 A copy of this book will be given to all attendees.
 ###

 The lectures will consist of video-projected presentations and
 discussion.
 Go to the site
 http://www-stat.stanford.edu/~hastie/sldm.html
 for more information and online registration.

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

2009-01-15 Thread Wacek Kusnierczyk
czesc,

looks like you want some sort of currying, or maybe partial currying,
right?  anyway, here's a quick guess at how you can modify your bind,
and it seems to work, as far as i get your intentions,  with the plot
example you gave:

bind = function(f, ...) {
   args = list(...)
   function(...) do.call(f, c(list(...), args)) }

plotlines = bind(plot, type='l')
plotlines(1:10, runif(10))

plotredlines = bind(plotlines, col=red)
plotredlines(runif(10))

# careful about not overriding a named argument
plotredpoints = bind(plotredlines, type=p)
plotredpoints(runif(10))

you may want to figure out how to get rid of the smart y-axis title.
is this what you wanted?

pzdr,
vQ


nosek wrote:
 Well, 

 it looks like it's a perfectly correct approach to bind functions writing
 their wrappers by hand.
 But I don't want to write them by hand every time I need them.
 Being lambda expression, function() is most general, but there must be some
 kind of shorter way for such a common task as partial application.


 David Winsemius wrote:
   
 How is function() not the correct approach?

   plot_lines - function(x, ...) plot(x,  type=l, ...)
  
   plot_lines(1:10, xlim = c(1,5))

   plot_lines(1:10, 11:20, xlim = c(1,5))

 Still seems to get the unnamed optional y argument to the plotting  
 machinery.

 -- 
 David Winsemius

 On Jan 15, 2009, at 4:25 PM, nosek wrote:

 
 Hello,

 in a desperate desire of using partial function application in R I  
 fried out
 the following piece of code:

 bind - function( f, ... ) {
  args - list(...)
  function(...) f( ..., unlist(args) )
 }

 Its purpose, if not clear, is to return a function with part of its
 arguments bound to specific values, so that I can for example create  
 and use
 functions like this:
 q1 - bind( quantile, 0.25 )
 lapply( some_list, q1 )

 It's been a lot of work and unfortunately is not perfect. My bind  
 applies
 arguments only using positional rule. What I dream of is a function  
 bind2
 that would apply keyword arguments, like:
 plot_lines - bind2( plot, type=l )
 which would return
 function(...) plot( type=l, ... )

 How to do this in R?

 Regards,


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