Re: [R] how to specify the order of panels with xyplot

2009-11-20 Thread Deepayan Sarkar
On Fri, Nov 20, 2009 at 12:53 PM, Dan Kortschak
dan.kortsc...@adelaide.edu.au wrote:
 I have sorted out how to do this - by much trial an error (a comment
 from Deepayan in a post some years ago pointed which way to go, though
 it took a lot of searching to find even where to start with it:

 I've bound the two sets of data together, making the relevant part an
 ordered factor. It's probably not the nicest way to do it, but it works.

Your example is not reproducible, so it's hard to suggest
alternatives. But it seems that your original 'chromosomes' data frame
has things in the right order, so a simple fix would be

chromosomes$name - with(chromosomes, factor(name, levels = name))

-Deepayan

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

2009-11-20 Thread Johannes Graumann
How about

plot(sigma, delta1, ylim=range(-0.5, 2), xlab='sigma', ylab='delta', pch=22, 
type='o')
points(sigma, delta2, col='red', axes=FALSE, type='o')
legend(topleft,c(Delta1,Delta2),fill=TRUE,col=c(black,red))

Send runnable example next time.

HTH, Joh

gcheer3 wrote:

 
 TO be specific, here is how I graphed
 
 plot(sigma, delta1, ylim=range(-0.5, 2), xlab='sigma',
 ylab='delta1--square delta2--circle', pch=22, type='o')
 par(new=TRUE)
 plot(sigma, delta2, ylim=range(-0.5, 2), xlab='sigma',
 ylab='delta1--square delta2--circle', col='red', axes=FALSE, type='o')
 
 Thanks a lot
 
 
 gcheer3 wrote:
 
 a graph question. Thanks a lot in advance.
 
 I made two scatterplots on one graph (sigma vs. delta1, sigma vs. delta2)
 (20 observations of delta1, delta2 and corresponding sigma) the x-axis is
 sigma, the y-axis is either delta1 or delta2. I connected both
 scatterplots. To seperate them, one curves is a line with circles, the
 other curve is a line with squares on it.
 
 I want to make a notation either on the y-axis or on the graph. The
 notiaion is delta1--square; delta2--circle. So when people look at the
 graph, they can easily tell each curve's meaning. The curve with squares
 on it means the sigma vs. delta1, and the curve with circles on it means
 sigma vs. delta2. I think I can use 'expression' to write delta1, delta2
 and sigma in greek letters, but I am not sure how to denote the square
 and cirle I graphed.
 


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

2009-11-20 Thread Deepayan Sarkar
On Fri, Nov 20, 2009 at 7:47 AM, Joe King j...@joepking.com wrote:
 I have been using lattice xyplot and am quite pleased, and I can use the
 type=c(b,g) to have it print gridlines into the page, yet if I want to
 have a line plot with points on it, how do I get the xYplot to print
 gridlines (I use Hmisc xYplot because of its bands method which allows
 plotting of confidence intervals). Any suggestions? I have looked at the
 panel functions but when I try it I get the gridlines but my data is gone.



 So a simple example is below. I want to create the reference lines in the
 lattice plot in the xYplot from Hmisc so I can keep the confidence intervals
 filled.



 x-seq(1,10,1)

 y-seq(1,10,1)

 ci-y*.10

 ciupper-y+ci

 cilower-y-ci



 xyplot(y~x, type=c(b,g),plot.points = TRUE)#using lattice



 xYplot(Cbind(y,cilower,ciupper)~x,col.fill=grey,plot.points =
 TRUE,type=c(b),method=filled bands)#using Hmisc

As ?panel.xyplot tells you, type=g is just a shortcut that calls
panel.grid(), so you get the equivalent effect with

xYplot(Cbind(y,cilower,ciupper)~x,col.fill=grey,plot.points = TRUE,
   type=b,method=filled bands,
   panel = function(...) {
   panel.grid(h = -1, v = -1)
   panel.xYplot(...)
   })

-Deepayan

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] different results across versions for glmer/lmer with the quasi-poisson or quasi-binomial families: the lattest version might not be accurate...

2009-11-20 Thread Gosselin Frederic
Dear R-helpers,

this mail is intended to mention a rather trange result and generate potential 
useful comments on it. I am not aware of another posts on this issue ( 
RSiteSearch(quasipoisson lmer version dispersion)).

MUsing the exemple in the reference of the lmer function (in lme4 library) and 
turning it into a quasi-poisson or quasi-binomial analysis, we get different 
results, especially for the dispersion parameter (section 1 in the following; 
cf. bold passages in the following). For the quasi-poisson, we found even 
stronger differences with another, bigger database on which we worked (residual 
variance from approx. 0.7 to 1.2). We also tested the differences between 
versions for plain likelihood families (poisson and binomial): the differences 
were slighter, and were actually very small in the case of the poisson family. 

My first reaction was that the later version should have been better. However, 
the quasibinomial results of this version are rather strange. Therefore, I 
simulated a bigger data set corresponding to Poisson and binomial mixed models 
(section 2 in the following). I actually found out that the later version of 
lme4 was suspect but not the old one. My temptative conclusion is therefore to 
use the old versions of lme4 (here:  lme4 version 0.99875-9) when using 
quasi-binomial and quasi-poisson methods.

Any comment/insight appreciated.

 
All the best,
 
Frédéric Gosselin
Engineer  Researcher (PhD) in Forest Ecology
Cemagref
Domaine des Barres
F-45290 Nogent sur Vernisson
France


### 1- EXAMPLE FROM LMER HELP

# here are the commands for the quasipoisson:
library(lme4)
gm1 - lmer(incidence ~ period + (1 | herd), family = quasipoisson, data = cbpp)
summary(gm1)


## here is the result under R2.5.1 and Package lme4 version 0.99875-9:
Generalized linear mixed model fit using Laplace
Formula: incidence ~ period + (1 | herd)
   Data: cbpp
 Family: quasipoisson(log link)
   AIC   BIC logLik deviance
 112.2 122.3 -51.11102.2
Random effects:
 Groups   NameVariance Std.Dev.
 herd (Intercept) 0.35085  0.59233
 Residual 1.40470  1.18520
number of obs: 56, groups: herd, 15

Fixed effects:
Estimate Std. Error t value
(Intercept)   1.2812 0.2200   5.824
period2  -1.1240 0.3315  -3.391
period3  -1.3203 0.3579  -3.689
period4  -1.9477 0.4808  -4.051

Correlation of Fixed Effects:
(Intr) perid2 perid3
period2 -0.339 
period3 -0.314  0.219  
period4 -0.233  0.163  0.151


# here is the result on R2.7.1 and Package lme4 version 0.999375-26

Generalized linear mixed model fit by the Laplace approximation
Formula: incidence ~ period + (1 | herd)
   Data: cbpp
   AIC   BIC logLik deviance
 114.2 126.4  -51.1102.2
Random effects:
 Groups   NameVariance Std.Dev.
 herd (Intercept) 0.32421  0.56939
 Residual 1.29474  1.13786
Number of obs: 56, groups: herd, 15

Fixed effects:
Estimate Std. Error t value
(Intercept)   1.2762 0.2115   6.035
period2  -1.1249 0.3187  -3.530
period3  -1.3190 0.3438  -3.837
period4  -1.9450 0.4615  -4.215

Correlation of Fixed Effects:
(Intr) perid2 perid3
period2 -0.339 
period3 -0.314  0.219  
period4 -0.233  0.163  0.151



# now the commands for the quasibinomial:
library(lme4)
toto-as.double(cbpp$incidence0)
gm2 - lmer(toto ~ period + (1 | herd), family = quasibinomial, data = cbpp)
summary(gm2)
 
## here is the result under R2.5.1 and Package lme4 version 0.99875-9:

Generalized linear mixed model fit using Laplace 
Formula: toto ~ period + (1 | herd) 
   Data: cbpp 
 Family: quasibinomial(logit link)
   AIC   BIC logLik deviance
 72.04 82.17 -31.0262.04
Random effects:
 Groups   NameVariance   Std.Dev.  
 herd (Intercept) 5.0259e-10 2.2418e-05
 Residual 1.0052e+00 1.0026e+00
number of obs: 56, groups: herd, 15
 
Fixed effects:
Estimate Std. Error t value
(Intercept)2.662  1.048   2.540
period2   -2.078  1.188  -1.750
period3   -2.950  1.180  -2.501
period4   -3.135  1.194  -2.626
 
Correlation of Fixed Effects:
(Intr) perid2 perid3
period2 -0.882  
period3 -0.888  0.784   
period4 -0.878  0.775  0.780

 
 
# here is the result on R2.7.1 and Package lme4 version 0.999375-26

Generalized linear mixed model fit by the Laplace approximation 
Formula: toto ~ period + (1 | herd) 
   Data: cbpp 
   AIC  BIC logLik deviance
 74.04 86.2 -31.0262.04
Random effects:
 Groups   NameVariance Std.Dev.
 herd (Intercept) 0.0  0.0 
 Residual 0.13522  0.36772 
Number of obs: 56, groups: herd, 15
 
Fixed effects:
Estimate Std. Error t value
(Intercept)   2.6391 0.3806   6.933
period2  -2.0513 0.4324  -4.744
period3  -2.9267 0.4293  -6.817
period4  -3.1091 

Re: [R] Problem with sqlSave

2009-11-20 Thread Karl Ove Hufthammer
On Thu, 19 Nov 2009 04:07:52 -0800 (PST) anna_l lippelanna21
@hotmail.com wrote:
 Hello, the sqlSave function is used in order to write a dataframe on excel.
 This function creates worksheets using the attribute tablename and writes
 the data.frame in it. What I want to do is to create this data.frame but
 being able in case this worksheet already exists to delete the former datas
 and write the new ones in it. I used the safer and append attributes. When
 you set safer to false, from what I understood, it should delete the former
 datas. Then what I did is setting safer as false and append as true so it
 can append to the empty dataframe the new dataframe but it didn?t work.

Your question doesn't make sense. If you want to delete the older data, 
you should *not* use append = TRUE, since that is used only in the case 
that you want to append the new data to the old date. Since you *don't* 
want to retain the old data, why do you set append = TRUE?

-- 
Karl Ove Hufthammer

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Splitting massive output into multiple text files

2009-11-20 Thread bartjoosen


try:
capture.output(fit5, file=paste(testperm, i, .txt, sep=), append=T)


Bart


A Singh wrote:
 
 Dear List,
 
 I thought it would be much easier to put a second query into a second
 mail.
 
 I need to print 426*1 blocks of variance components data, where 426 is 
 the number of columns of data that have 1 permutations of variance 
 generated for each of them.
 
 I have tried printing out a smaller number of permutations for a smaller 
 number of markers and that has worked.
 
 However, since a text file will not handle 4 million blocks in a single 
 file (which is what I ultimately need to do), is there a way to tell R to 
 create a new file for every 10 or so columns?
 
 I tried to use some suggested code that looked like:
 
 for (j in 1:426)
 {
  write(cbind(modeldf[,j:(j+9)]),file=as.character(j))
  j - j+10
 }
 
 ..but can't figure out how to put it into my own code and make it work.
 
 I did find one example of code for split files, each successive file being 
 labeled as a series of numbers, but I couldn't figure out how to even
 adapt 
 that to my model.
 
 I cannot figure out what other way there is to conveniently view 4 m.
 items 
 of data without losing some of it somewhere..
 
 Any help will be much much appreciated..
 
 Aditi
 
 --
 
 Code for shorter sample file:
 
 
 model-read.table(...)
 
 modeldf-data.frame(model)
 
 modeldf[2:13-lapply(modeldf[2:13],factor)
 
 colms-(modeldf)[4:13]   ## 10 markers only in this file
 se-c(1:1000)
 
 for(f in colms)
 {
 print(Marker)
 {
 for( i in 1:1000)
 {
 print(perm no.)
 print(se[i])
 {
 peg.no.prm-sample(peg.no, length(peg.no))
 try(fit5-lmer(data=modeldf, peg.no.prm~1 + (1|family/f)))
 print(summary(fit5))
 capture.output(fit5, file=testperm5.txt, append=T)
 }}}
 }
 
 
 The data files are at:


 http://www.4shared.com/file/131980362/460bdafe/Testvcomp10.ht
 ml (excel)
 http://www.4shared.com/file/131980512/dc7308b/Testvcomp10.html
 (txt)
 --
 
 
 --
 A Singh
 aditi.si...@bristol.ac.uk
 School of Biological Sciences
 University of Bristol
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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://old.nabble.com/Splitting-massive-output-into-multiple-text-files-tp26429300p26432040.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] advice about R for windows speed

2009-11-20 Thread bartjoosen

I can only speak for the Windows part, but isn't it possible to test on
Windows 7 64bit?
(you can download a test version, and use a dual boot setup to try)
I always heard about the difficulties with WinXP 64bit, so maybe that is
just the problem?
Another thing to find out: maybe you can take advantage of the 4 processors
of your quadcore by using snow or similar?

Bart





Carlos Hernandez-7 wrote:
 
 Thanks for your reply! I just added some more details below.
 
 Our code needs around 1GB of RAM and all machines and R configurations
 have
 its default maximum above this number.
 
 Our suspicion is that the windows server could run the code in half of its
 current time (given the apparent factor of 2 between windows and other OS
 timing). There may be something very important either in the R
 configuration
 or in our code that we should take care of?
 
 I appreciate a lot any further advice or hints, specially about speeding
 up
 the code in the windows xp server with QuadCore Xeon processors.
 
 Best regards,
 
 Carlos
 
 
 
 
 
 
 **Server running WinXP 64bit (R 2.10.0 32bit , QuadCore Xeon 2.6GHz 8G
 Ram)
 Time per 25 Iterations 6.17
 
 
 **Dell Latitude running Linux 32bit (R 2.9.2, Intel Core 2 Duo P9500 @
 2.53GHz, 4GB ram)
 Time per 25 iterations 2.88
 
 **Dell Latitude running Win Vista 32bit (R 2.10.0, Intel Core 2 Duo P9500
 @
 2.53GHz, 4GB ram) with New DLL in terminal
 Time per 25 iterations 5.53
 
 ---
 **Macbook pro running Snow Leopard (R 2.10.0, 2.16GHz Intel Core 2 Duo 
 2GB
 ram)
 Time per 25 Iterations 4.58  (both R 2.10.0 32bit and 64bit produce
 almost
 identical timings)
 
 **Macbook pro running WinXp natively (R 2.10.0 32bit, 2.16GHz Intel Core 2
 Duo  2GB ram)
 Time per 25 Iterations 8.23
 
 note: for the Dell and MacBook Pro we replaced the Rblas.dll file of R for
 Windows with the file available here
 http://cran.r-project.org/bin/windows/contrib/ATLAS/C2D/
 
 ==
 
 
 
 On Thu, Nov 19, 2009 at 5:06 PM, Marc Schwartz marc_schwa...@me.com
 wrote:
 
 On Nov 19, 2009, at 9:25 AM, Carlos Hernandez wrote:

  Dear All,
 I appreciate any advice or hints you could provide about the following.

 We are running R code in a server (running Windows XP and QuadCore Xeon
 processors, see details below) and we would like to use the server
 efficiently. Our code takes a bit more than 6 seconds per 25 iterations
 in
 the server using a default R 2.10.0 installation.

 We tested our code in two other computers, a Dell Latitute and a MacBook
 Pro, and from the details that i include below you will notice that the
 code
 needs almost twice the time when we used R for Windows compared against
 the
 time the code needs when we use Linux or MacOSX 10.6.2 in each of these
 computers.

 I'm sorry I don't provide details on the code we are using. The code
 consists of all sort of operations (matrix inverses, random number
 generation, vectorized functions, a few loops, and so on). I hope I can
 get
 some advice from you despite the lack of specific code details.

 Is there any important R feature we should configure manually in the
 windows
 server to speed the code up? Is there an optimized BLAS available
 somewhere
 for this type of machine? Is these something else apart of an optimized
 BLAS
 that we could do to improve the timing?

 Best regards,

 Carlos




 **Server running WinXP (QuadCore Xeon 2.6GHz 8G Ram)
 Time per 25 Iterations 6.17

 
 **Dell Latitude running Linux (R 2.9.2, Intel Core 2 Duo P9500 @
 2.53GHz,
 4GB ram)
 Time per 25 iterations 2.88

 **Dell Latitude running Win Vista (R 2.10.0, Intel Core 2 Duo P9500 @
 2.53GHz, 4GB ram) with New DLL in terminal
 Time per 25 iterations 5.53

 ---
 **Macbook pro (2.16GHz Intel Core 2 Duo  2GB ram)
 Time per 25 Iterations 4.58

 **Macbook pro running WinXp (2.16GHz Intel Core 2 Duo  2GB ram)
 Time per 25 Iterations 8.23


 note: for the Dell and MacBook Pro we replaced the Rblas.dll file of R
 for
 Windows with the file available here
 http://cran.r-project.org/bin/windows/contrib/ATLAS/C2D/



 Are you running 32 bit R on each platform or are you using 64 bit R on
 Linux and OSX?

 On the Dell, you are running two different versions of R and you don't
 indicate the R versions on the MacBook.

 The RAM configuration on each computer is different, which will impact
 the
 timings to some extent, depending upon how much RAM you may require for
 your
 R code, given other processes that are running and before any disk
 swapping
 kicks in. You might want to review R Windows FAQ 2.9, if you have not
 already:


 http://cran.r-project.org/bin/windows/base/rw-FAQ.html#There-seems-to-be-a-limit-on-the-memory-it-uses_0021

 For Windows on the MacBook, are you using Boot Camp to run Windows
 natively
 or are you using virtualization (eg. Parallels, VMWare, VirtualBox) to
 run
 Windows under OSX? If the latter, some of the time increase will be due
 to
 the virtualization overhead.

 You should be using 

Re: [R] 2 functions in xyplot

2009-11-20 Thread Paul Hiemstra

RICHARD M. HEIBERGER wrote:

Unexpected symbol often means missing punctuation.

In this case, it looks like

panel=function(){panel.xyplot(Kalibrierung$Spannung,Kalibrierung
$Magnetfeld)panel.abline(reg=test)}

this argument is missing a semi-colon ; before panel.abline.

panel=function(){panel.xyplot(Kalibrierung$Spannung,Kalibrierung
$Magnetfeld); panel.abline(reg=test)}

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

in addition to Richard:

I would try to write out the function over multiple lines:

panel=function(){
   panel.xyplot(Kalibrierung$Spannung,Kalibrierung$Magnetfeld)
   panel.abline(reg=test)}

solven the problem you had, as would the semicolon, but in my opinion it 
make the command more readable. You can also use '...' in the panel 
function:


panel=function(...){
   panel.xyplot(...)
   panel.abline(reg=test)}

I like this because I don't have think about what to pass on to 
panel.xyplot.


hope this helps,
Paul


--
Drs. Paul Hiemstra
Department of Physical Geography
Faculty of Geosciences
University of Utrecht
Heidelberglaan 2
P.O. Box 80.115
3508 TC Utrecht
Phone:  +3130 274 3113 Mon-Tue
Phone:  +3130 253 5773 Wed-Fri
http://intamap.geo.uu.nl/~paul

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


[R] Classification

2009-11-20 Thread Chris Li

Hi all,

I have got a dataset like the following:

3
5
7
3
9
7


i.e. random numbers with some repeats.

I want R to classify them for me. E.g. every row that has a value of 3 will
be asigned a value of 1, and every row that has a value will be asigned a
value of 2 etc.

I want R to return the following, using the example above:

1
2
3
1
4
3

Thanks in advance.
Chris
-- 
View this message in context: 
http://old.nabble.com/Classification-tp26429330p26429330.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] DBFIsRecordDeleted() in read.dbf?

2009-11-20 Thread Florian Jansen

Dear Nicholas Lewin-Koh and Roger Bivand or Frank Warmerdam,

I am using read.dbf from the foreign package within my package vegdata.
Unfortunately if you delete some data in the primary program the data in 
the dbase file is not deleted but the line only gets a flag IsDeleted.
read.dbf ignores this information but the shapelib C code 
(http://shapelib.maptools.org/.) provides this information as far as I 
understood (DBFIsRecordDeleted()).
Would it be possible to respect this information during import using 
read.dbf?


All the best,
Florian Jansen

--
Dr. Florian Jansen
Geobotany  Nature Conservation
Institute of Botany and Landscape Ecology
Ernst-Moritz-Arndt-University
Grimmer Str. 88
17487 Greifswald
Germany
+49 (0)3834 86 4147
http://www.botanik.uni-greifswald.de/jansen.html

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Bessel function with large index value

2009-11-20 Thread David Scott


I am looking for a method of dealing with the modified Bessel function 
K_\nu(x) for large \nu.


The besselK function implementation of this allows for dealing with 
large values of x by allowing for exponential scaling, but there is no 
facility for dealing with large \nu.


What would work for me would be an lbesselK function in the manner of 
lgamma which returned the log of K_\nu(x) for large \nu. Does anybody 
have any leads on this?


Note that I have trawled through Abramowitz and Stegun and found 9.7.8 
which doesn't work for me because of the complication in the definition 
of the x argument. I have also seen a result of Ismail (1977) reported 
by Barndorff-Nielsen and Blaesild which has the other problem, the 
treatment of the x argument is too simple.


To do the calculation I am attempting, I need to have the Bessel 
function in a form that will allow a cancellation with a Gamma function 
of high order in the denominator.


David Scott


--
_
David Scott Department of Statistics
The University of Auckland, PB 92019
Auckland 1142,NEW ZEALAND
Phone: +64 9 923 5055, or +64 9 373 7599 ext 85055
Email:  d.sc...@auckland.ac.nz,  Fax: +64 9 373 7018

Director of Consulting, Department of Statistics

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

2009-11-20 Thread smu

Hello,

x - c(3,5,7,3,9,7)
 as.numeric(as.factor(x))
[1] 1 2 3 1 4 3

regards,
 stefan


On Fri, Nov 20, 2009 at 12:02:59AM -0800, Chris Li wrote:
 
 Hi all,
 
 I have got a dataset like the following:
 
 3
 5
 7
 3
 9
 7
 
 
 i.e. random numbers with some repeats.
 
 I want R to classify them for me. E.g. every row that has a value of 3 will
 be asigned a value of 1, and every row that has a value will be asigned a
 value of 2 etc.
 
 I want R to return the following, using the example above:
 
 1
 2
 3
 1
 4
 3
 
 Thanks in advance.
 Chris
 -- 
 View this message in context: 
 http://old.nabble.com/Classification-tp26429330p26429330.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] boxplot question

2009-11-20 Thread Antje

Hi there,

I was wondering if anybody can explain to me why the boxplot ends up 
with different results in the following case:


I have some integer data as a vector and I compare the stats of boxplot 
with the same data divided by a factor.


I've attached a csv file with both data present (d1, d2). The factor is 
34.16667.


If I run the boxplot function on d1 I get the following stats:

0.848...
0.907...
0.936...
0.965...
1.024...

For d2 I get these stats:

29
31
32
33
36


If I convert the stats of d1 with the factor, I get

29
31
32
33
35

Obviously different for the upper whisker. But why???

Antje
,d1,d2
1,0.936585365853659,32
2,0.936585365853659,32
3,0.936585365853659,32
4,0.936585365853659,32
5,0.907317073170732,31
6,1.08292682926829,37
7,1.08292682926829,37
8,1.02439024390244,35
9,1.08292682926829,37
10,1.05365853658537,36
11,0.936585365853659,32
12,1.08292682926829,37
13,0.936585365853659,32
14,0.907317073170732,31
15,0.936585365853659,32
16,0.907317073170732,31
17,1.02439024390244,35
18,0.878048780487805,30
19,1.08292682926829,37
20,1.02439024390244,35
21,0.936585365853659,32
22,0.936585365853659,32
23,1.08292682926829,37
24,1.02439024390244,35
25,1.05365853658537,36
26,1.02439024390244,35
27,0.936585365853659,32
28,1.11219512195122,38
29,0.878048780487805,30
30,1.02439024390244,35
31,0.995121951219512,34
32,1.11219512195122,38
33,0.936585365853659,32
34,0.995121951219512,34
35,0.936585365853659,32
36,1.02439024390244,35
37,0.965853658536585,33
38,0.965853658536585,33
39,0.995121951219512,34
40,0.848780487804878,29
41,0.907317073170732,31
42,0.907317073170732,31
43,0.907317073170732,31
44,1.05365853658537,36
45,0.878048780487805,30
46,0.878048780487805,30
47,0.878048780487805,30
48,0.936585365853659,32
49,0.936585365853659,32
50,0.878048780487805,30
51,0.936585365853659,32
52,1.05365853658537,36
53,0.878048780487805,30
54,1.17073170731707,40
55,0.907317073170732,31
56,0.995121951219512,34
57,0.907317073170732,31
58,0.907317073170732,31
59,0.936585365853659,32
60,0.965853658536585,33
61,0.965853658536585,33
62,0.936585365853659,32
63,0.936585365853659,32
64,0.878048780487805,30
65,0.907317073170732,31
66,1.08292682926829,37
67,0.907317073170732,31
68,0.848780487804878,29
69,0.907317073170732,31
70,0.965853658536585,33
71,0.936585365853659,32
72,0.936585365853659,32
73,1.08292682926829,37
74,0.936585365853659,32
75,0.936585365853659,32
76,1.11219512195122,38
77,0.878048780487805,30
78,0.965853658536585,33
79,0.907317073170732,31
80,0.936585365853659,32
81,0.907317073170732,31
82,0.878048780487805,30
83,0.936585365853659,32
84,0.965853658536585,33
85,0.907317073170732,31
86,1.02439024390244,35
87,0.995121951219512,34
88,0.965853658536585,33
89,0.936585365853659,32
90,0.936585365853659,32
91,1.11219512195122,38
92,0.907317073170732,31
93,0.907317073170732,31
94,0.936585365853659,32
95,0.907317073170732,31
96,0.907317073170732,31
97,0.936585365853659,32
98,0.936585365853659,32
99,0.936585365853659,32
100,0.907317073170732,31
101,0.907317073170732,31
102,0.848780487804878,29
103,0.907317073170732,31
104,0.965853658536585,33
105,0.936585365853659,32
106,0.907317073170732,31
107,0.878048780487805,30
108,1.02439024390244,35
109,0.907317073170732,31
110,1.11219512195122,38
111,1.02439024390244,35
112,0.907317073170732,31
113,0.936585365853659,32
114,0.878048780487805,30
115,0.907317073170732,31
116,0.936585365853659,32
117,0.936585365853659,32
118,1.05365853658537,36
119,0.907317073170732,31
120,0.878048780487805,30
121,0.936585365853659,32
122,1.02439024390244,35
123,0.965853658536585,33
124,0.965853658536585,33
125,0.936585365853659,32
126,0.936585365853659,32
127,0.936585365853659,32
128,0.907317073170732,31
129,0.907317073170732,31
130,0.878048780487805,30
131,0.936585365853659,32
132,1.02439024390244,35
133,0.936585365853659,32
134,0.936585365853659,32
135,0.995121951219512,34
136,0.965853658536585,33
137,0.965853658536585,33
138,0.907317073170732,31
139,0.936585365853659,32
140,0.936585365853659,32
141,0.878048780487805,30
142,0.907317073170732,31
143,0.965853658536585,33
144,0.936585365853659,32
145,0.936585365853659,32
146,0.995121951219512,34
147,1.02439024390244,35
148,1.08292682926829,37
149,0.878048780487805,30
150,0.936585365853659,32
151,0.848780487804878,29
152,0.907317073170732,31
153,0.907317073170732,31
154,0.907317073170732,31
155,0.965853658536585,33
156,1.02439024390244,35
157,0.995121951219512,34
158,0.995121951219512,34
159,0.936585365853659,32
160,1.08292682926829,37
161,0.907317073170732,31
162,0.907317073170732,31
163,0.936585365853659,32
164,0.907317073170732,31
165,0.907317073170732,31
166,0.907317073170732,31
167,0.907317073170732,31
168,1.05365853658537,36
169,1.05365853658537,36
170,0.936585365853659,32
171,0.965853658536585,33
172,0.965853658536585,33
173,0.936585365853659,32
174,0.907317073170732,31
175,0.878048780487805,30
176,0.995121951219512,34
177,0.936585365853659,32
178,0.936585365853659,32
179,0.907317073170732,31
180,1.08292682926829,37

[R] barchart problem was: Re: how to specify the order of panels with xyplot

2009-11-20 Thread Dan Kortschak
Thank you, that works perfectly and is more elegant - I'm sorry not to
have included complete code/data.

I have another question that I have been having problems with recently,
described by this code:

reads-as.data.frame(cbind(c(1:25),rnorm(25),rnorm(25),rnorm(25),rnorm(25)))
names(reads)-c('id','u','a','b','m')
barchart(cbind(as.vector(reads$u),as.vector(reads$m)),horizontal=FALSE,groups=FALSE,layout=c(1,2))

This is undoubtedly the worst way to do this, and doesn't give me
exactly what I want, though is close: what is desired is the categories
being described by reads$id and the strips holding 'u' or 'm'. I know
this is a result of decontextualising the data as I have.

I have tried to make a data frame that matches the example for barchart
in the help for lattice.

Trying to match the barley data frame:

reads-as.data.frame(rbind(cbind(reads$id,reads$u,'u'),cbind(reads$id,reads$m,'m')))
names(reads)-c('id','freq','type')

barchart(freq ~ id | type, data = 
reads,horizontal=FALSE,groups=FALSE,layout=c(1,2))

Does not give anything that is analogous to the naive chart above. Can
you point to where I am going wrong (I have also tried barchart(freq |
type, data = reads,...), but this gives an error)? It looks like the
previously numeric values are being treated as non-numeric on the basis
of the sorting of the categories, but changing this:

reads$id-as.numeric(reads$id)
reads$freq-as.double(reads$freq)

does not fix the problem (except for the categories' order). In fact I'm
not sure how the plot looks the way it does at all from this (the values
of read$freq are completely changed by this cast!).

thanks for your help
Dan

On Fri, 2009-11-20 at 13:53 +0530, Deepayan Sarkar wrote:
 Your example is not reproducible, so it's hard to suggest
 alternatives. But it seems that your original 'chromosomes' data frame
 has things in the right order, so a simple fix would be
 
 chromosomes$name - with(chromosomes, factor(name, levels = name))
 
 -Deepayan

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

2009-11-20 Thread Karl Ove Hufthammer
On Fri, 20 Nov 2009 10:43:19 +0100 smu m...@z107.de wrote:
 x - c(3,5,7,3,9,7)
  as.numeric(as.factor(x))
 [1] 1 2 3 1 4 3

While that is my preferred solution too, this may be easier to 
understand:

 match(x,sort(unique(x)))

(It is basically what 'factor' does.)

The question wasn't quite clear, though. Should the first occuring 
number get the category 1, or should the *lowest* number get this 
category. I.e., what should be the result of

x - c(5,3,7,3,9,7)

Should it be 1, 2, 3, 2, 4, 3 or 2, 1, 3, 1, 4, 3?

The factor and match methods above give the second solution. To get the 
first solution, just remove the 'sort':

match(x,unique(x))

-- 
Karl Ove Hufthammer

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

2009-11-20 Thread Nora Hanson
Hello,

This is probably very simple but I am trying to select a region from the
OIv2 SST dataset that crosses 0 longitude. The longitude variable is
arranged from 0 to 360 and I get an error message when trying to go from 330
to 30 for example. The data are from a NOAA netCDF file.

*temp = open.ncdf(c:/documents and settings/theoni/desktop/sstoi_v2.nc)
print(temp)
y1 = get.var.ncdf( temp, latitude)
x1 = get.var.ncdf( temp, longitude)
t1 = get.var.ncdf( temp, time)
z1 = get.var.ncdf( temp, sst)
sst = get.var.ncdf( temp, sst, start=c(330,136,313), count=c(56,44,1))*

Error message I get is:
*Error in get.var.ncdf(temp, sst, start = c(330, 136, 313), count = c(56,
:
  C function R_nc_get_vara_double returned error*

I couldn't seem to find any info on this in the help archives but am a new
user so apologies if it has been addressed elsewhere.

Many thanks,
Nora



-- 
Nora Hanson
Sea Mammal Research Unit
Scottish Oceans Institute
University of St. Andrews
St. Andrews
Fife KY16 8LB
Scotland
n...@st-andrews.ac.uk
tel: 0044 (0)1334 463485

The University of St Andrews is a charity
registered in Scotland : No SC013532

[[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] Spatstat, markcorr, max. radius limited??

2009-11-20 Thread rudi1978
Hello,

could please somebody help me. I want to apply the mark correlation function 
but for radii up to 75 meters (in 75 individual 1m steps). Unfortunately, 
There is a sensible default for the values of the argument r at which the mark 
correlation function kf (r) should be evaluated, so that I do not get results 
for r  25m. Can I change something in the function to get the required values 
as written above?

Thanks,

Rudi

-- 
GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Compiling from sources (ubuntu and x11)

2009-11-20 Thread Jakson A. Aquino
On Thu, Nov 19, 2009 at 11:34:22PM -0600, stephen sefick wrote:
  am using ubuntu 9.10 and I am getting and x11 lib/headers not found.
 I have installed libx11-dev.  I thought this would solve the problem,
 but it is not.  Any help would be appreciated.

Looking at output of the configure script you should be able to
know what specific file is missing. Then you can Search the
contents of packages at http://packages.ubuntu.com/ to know what
package contains the missing file.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] What happen for Negative binomial link in Lmer fonction?

2009-11-20 Thread Emmanuelle Robardet

Dear R users,
As I have no answer to my las reply i try again.
If the binomal negative link has never been implemented in the lmer
fonction, 
and as it was working when I did it some months ago,
What kind of result did I get?

This is the exemple of the answer of R when i was using lmer with negative
binomal family:

m1a-lmer(atpos~ninter+saison+milieu*zone+(1|code),family=neg.bin(0.429),method=Laplace,data=manu)
summary(m1a)
Generalized linear mixed model fit using Laplace 
Formula: atpos ~ ninter + saison + milieu * zone + (1 | code) 
   Data: manu 
 Family: Negative Binomial(log link)
   AIC   BIC logLik deviance
 125.1 147.6 -54.57109.1

Thank you for your answers,
Best Regards
Emmanuelle



E. Robardet wrote:
 
 Thank you for your answers,
 
 I have an exemple of that i was using:
 
 m1a-lmer(atpos~ninter+saison+milieu*zone+(1|code),family=neg.bin(0.429),method=Laplace,data=manu)
 summary(m1a)
 Generalized linear mixed model fit using Laplace 
 Formula: atpos ~ ninter + saison + milieu * zone + (1 | code) 
Data: manu 
  Family: Negative Binomial(log link)
AIC   BIC logLik deviance
  125.1 147.6 -54.57109.1
 
 I think It was the version lme4 0.9975-10.
 Unfortunately, I have this version no more available on my computer..
 I wonder if this old results are still valid..
 
 
 Ben Bolker wrote:
 
 
 
 ROBARDET Emmanuelle wrote:
 
 Dear R users,
 I'm performing some GLMMs analysis with a negative binomial link.
 I already performed such analysis some months ago with the lmer()
 function but when I tried it today I encountered this problem:
 Erreur dans famType(glmFit$family) : unknown GLM family: 'Negative
 Binomial'
 
 Does anyone know if the negative binomial family has been removed from
 this function?
 I really appreciate any response.
 Emmanuelle
 
 
 
 I would be extremely surprised if this worked in the past; to
 the best of my knowledge the negative binomial family has
 never been implemented in lmer.  One could in principle
 do a glmmPQL fit with the negative binomial family
 (with a fixed value of the overdispersion parameter).
 glmmADMB is another option.
 Can you say which version etc. you were using???
 
 Follow-ups should probably be sent to r-sig-mixed-mod...@r-project.org
 
 
 
 

-- 
View this message in context: 
http://old.nabble.com/What-happen-for-Negative-binomial-link-in-Lmer-fonction--tp26013041p26439076.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] find data (date) gaps in time series

2009-11-20 Thread Stefan Strohmeier

Dear R users,

I have a time series of precipitation data. The time series comprises  
~ 20 years and it is supposed to be constant (one value per day), but  
due to some failure of the measuring device some days or periods are  
missing. I would like to find these missing days or periods just to  
get a first idea about the reliability of the measurements. The only  
function I could find was is.constant(), but of course I only get a  
true or false statement instead of the dates missing.
Google searches and a look at the R help mailing did not reveal an  
answer.


Please find attached a few dates of the time series with missing  
values from February to April. I would like R to detect those missing  
dates.


Any hints or solutions are highly appreciated.

Regards,
Stefan Strohmeier

2916 2002-02-17  0.0
2917 2002-02-18  0.3
2918 2002-02-19  3.8
2919 2002-02-20 43.6
2920 2002-02-21  1.0
2921 2002-02-22  5.6
2922 2002-02-23 10.6
2923 2002-02-24  2.8
2924 2002-02-25 19.1
2925 2002-02-26 20.5
2926 2002-03-06  0.0
2927 2002-05-06  0.0
2928 2002-05-07  0.0
2929 2002-05-08  0.0
2930 2002-05-09  0.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] Compatibility of AIC values calculated with different link functions?

2009-11-20 Thread Søren Faurby
In a binomial regression analysis I have used the AIC value as a guide  
for which link function (logit or probit) provides the best fit to my  
data, but one of the reviewers have questioned this approach.


Is AIC values calculated with different link functions within the  
binomial function in GLM comparable or can AIC values only be used to  
compare models with the same link?


I believe my approach is valid if GLM can be expected to find the true  
global ML estimate but I do not know if any approximations in the GLM  
function change this.


Kind regards, Søren

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 2.10 'memory leak'? on OS X

2009-11-20 Thread Duncan Murdoch

On 20/11/2009 12:33 AM, Stropharia wrote:

Dear R users,

I am running R 2.10.0 on OS X 10.5.8.

I had been running 2.10 successfully for about a week (and have used
previous R versions for 2+ years on the same computer) until 2 days ago it
failed to start up for me. Now when I try to start R, the application tries
to initiate for several minutes then crashes. Looking at the activity
monitor, my memory usage goes from having about 1.6Gb free (out of 2Gb) to
7Mb in the first 10-15 seconds of attempting to start the program. At this
point I either have to force quit R (as everything starts to freeze up) or
wait several minutes for it to crash.

I have erased the application and reinstalled it 4 times now - with exactly
the same result. I looked around in the Library and System folders to see if
any other files needed to be removed, but couldn't find any. I have also
restarted the computer and repaired permissions multiple times - and then
reinstalled R, with no luck. The exact same thing happens if I start R64.

I did not updated OS X or R, or install any other programs, just prior to
this first happening and am at a loss to explain what's going on. I have
copied the first part of one of the crash logs below. Does anyone have any
ideas for to remedy this?



It sounds like one of your user-specific startup files is causing the 
problem, e.g. .RData, or .Rprofile.  Did you try starting R with option 
--vanilla?  That will skip them.


Duncan Murdoch


best,

Steve


# Crash log 
Process: R [231]
Path:/Applications/R.app/Contents/MacOS/R
Identifier:  org.R-project.R
Version: R 2.10.0 GUI 1.30 Leopard build 32-bit (5511)
Code Type:   X86 (Native)
Parent Process:  launchd [101]

Date/Time:   2009-11-18 23:15:45.570 -0500
OS Version:  Mac OS X 10.5.8 (9L31a)
Report Version:  6
Anonymous UUID:  D86CDCBC-00FD-4AEE-AB50-2EFE0DAE9E1E

Exception Type:  EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x00067ee2
Crashed Thread:  0

Thread 0 Crashed:
0   libSystem.B.dylib 0x07c7 __memcpy + 39
(cpu_capabilities.h:246)
1   com.apple.CoreFoundation   0x96a6a0b4 __CFStringEncodeByteStream +
4052
2   com.apple.Foundation   0x94446eb7
-[NSString(NSStringOtherEncodings)
getBytes:maxLength:usedLength:encoding:options:range:remainingRange:] + 295
3   com.apple.Foundation   0x94446a1a _NSNewStringByAppendingStrings
+ 538
4   com.apple.Foundation   0x94446760 -[NSString
stringByAppendingString:] + 192
5   org.R-project.R   0x9ce8 -[RController doLoadHistory:] +
808
6   org.R-project.R   0x76df -[RController awakeFromNib] +
2319
7   com.apple.CoreFoundation   0x96ac07f5 -[NSSet
makeObjectsPerformSelector:] + 181
8   com.apple.AppKit   0x92efed8e -[NSIBObjectData
nibInstantiateWithOwner:topLevelObjects:] + 1533
9   com.apple.AppKit   0x92ef4fba loadNib + 264
10  com.apple.AppKit   0x92ef491c +[NSBundle(NSNibLoading)
_loadNibFile:nameTable:withZone:ownerBundle:] + 946
11  com.apple.AppKit   0x92ef455f +[NSBundle(NSNibLoading)
loadNibFile:externalNameTable:withZone:] + 171
12  com.apple.AppKit   0x92ef449d +[NSBundle(NSNibLoading)
loadNibNamed:owner:] + 391
13  org.R-project.R   0x2538 main + 296
14  org.R-project.R   0x23d6 start + 54
#--


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Problem with Numerical derivatives (numDeriv) and mvtnorm

2009-11-20 Thread Stephane LUCHINI
I'm trying to obtain numerical derivative of a probability computed  
with mvtnorm with respect to its parameters using grad() and  
jacobian() from NumDeriv.


To simplify the matter, here is an example:

PP1 - function(p){
  thetac - p
  thetae - 0.323340333
  thetab - -0.280970036
  thetao -  0.770768082
  ssigma  - diag(4)
  ssigma[1,2] -  0.229502120
  ssigma[1,3] -  0.677949335
  ssigma[1,4] -  0.552907745
  ssigma[2,3] -  0.784263100
  ssigma[2,4] -  0.374065025
  ssigma[3,4] -  0.799238700
  ssigma[2,1] -  ssigma[1,2]
  ssigma[3,1] -  ssigma[1,3]
  ssigma[4,1] -  ssigma[1,4]
  ssigma[3,2] -  ssigma[2,3]
  ssigma[4,2] -  ssigma[2,4]
  ssigma[4,3] -  ssigma[3,4]
  pp1  -  
pmvnorm(lower=c(-Inf,-Inf,-Inf,-Inf),upper=c(thetac,thetae,thetab,thetao),corr=ssigma)

  return(pp1)}

xx - -0.6675762

If I compute several times the probability PP1, i obtain some slightly  
different numbers but I suppose this is ok:



PP1(xx)

[1] 0.1697787
attr(,error)
[1] 0.000840748
attr(,msg)
[1] Normal Completion

PP1(xx)

[1] 0.1697337
attr(,error)
[1] 0.0009363715
attr(,msg)
[1] Normal Completion

PP1(xx)

[1] 0.1691539
attr(,error)
[1] 0.0006682577
attr(,msg)
[1] Normal Completion

When I now turn to the numerical derivatives of the probability, I  
obtain large discrepencies if I repeat the instruction grad:



grad(PP1,xx)

[1] -42.58016

grad(PP1,xx)

[1] 9.297055

grad(PP1,xx)

[1] -6.736725

grad(PP1,xx)

[1] -20.71176

grad(PP1,xx)

[1] 18.51968

The problem is the same if I turn to the jacobian function (when I  
want to compute all partial derivatives in one shot)


Someone can help?

Stephane

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

2009-11-20 Thread Antje

Hey there,

I'm running R 2.10 on Windows XP (Professional) and I was wondering 
where the HTML help window disappeared?
With earlier versions everything was fine. Now I get only this 
old-fashioned text windows without any links when I type

?some_function
Can anybody help me?

Antje

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

2009-11-20 Thread SIES 73
Yet another possibility is to iterate on both values and names simultaneously 
using mapply():

df1 - split(
   x=rnorm(n=100, sd=seq(from=1, to=10, each=10)),
   f=letters[seq(from=1, to=10, each=10)]
 )

mapply(function(x, y) plot(x, ylab=y), df1, names(df1)) 


Enrique

-Original Message-
Date: Thu, 19 Nov 2009 13:27:08 +0100
From: Bjarke Christensen bjarke.christen...@sydbank.dk
Subject: [R] Accessing list names in lapply
To: r-help@r-project.org
Message-ID:
of5533f0b9.99f78ab0-onc1257673.004273ae-c1257673.00446...@bdpnet.dk
Content-Type: text/plain; charset=US-ASCII


Hi,

When using lapply (or sapply) to loop over a list, can I somehow access the
index of the list from inside the function?

A trivial example:

df1 - split(
   x=rnorm(n=100, sd=seq(from=1, to=10, each=10)),
   f=letters[seq(from=1, to=10, each=10)]
 )
str(df1)
#List of 10
# $ a: num [1:10] -0.801 0.418 1.451 -0.554 -0.578 ...
# $ b: num [1:10] -2.464 0.279 4.099 -2.483 1.921 ...
# $ c: num [1:10] -1.14 -1.773 2.512 -2.072 -0.904 ...
# $ d: num [1:10] 2.109 1.243 0.627 -2.343 -6.071 ...
#...
par(mfcol=c(5,2))
lapply(df1, plot)

This plots each element of the list, but the label on the vertical axis is
X[[0L]] (as expected from the documentation in ?lapply). I'd like the
heading for each plot to be the name of that item in the list. This can be
achieved by using a for-loop:

for (i in names(df1)) plot(df1[[i]], ylab=i)

but can it somehow be achieved bu using lapply? I would be hoping for
something like

lapply(df1, function(x) plot(x, ylab=parent.index()))

or some way to parse the index number out of the call, using match.call()
or something like that.

Thanks in advance for any comments,
Bjarke Christensen

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


Re: [R] Problem with sqlSave

2009-11-20 Thread anna_l

Hi Karl, I was setting append=true because safer would delete the former
datas when set to false. I must not have understood the purpose of these two
attributes right. To be honest I tried all possible combinations and none
would work. I am doing all this now with RExcel as I have been advised and
it worked very well. Thank you for trying to help.


Karl Ove Hufthammer wrote:
 
 On Thu, 19 Nov 2009 04:07:52 -0800 (PST) anna_l lippelanna21
 @hotmail.com wrote:
 Hello, the sqlSave function is used in order to write a dataframe on
 excel.
 This function creates worksheets using the attribute tablename and writes
 the data.frame in it. What I want to do is to create this data.frame but
 being able in case this worksheet already exists to delete the former
 datas
 and write the new ones in it. I used the safer and append attributes.
 When
 you set safer to false, from what I understood, it should delete the
 former
 datas. Then what I did is setting safer as false and append as true so it
 can append to the empty dataframe the new dataframe but it didn?t work.
 
 Your question doesn't make sense. If you want to delete the older data, 
 you should *not* use append = TRUE, since that is used only in the case 
 that you want to append the new data to the old date. Since you *don't* 
 want to retain the old data, why do you set append = TRUE?
 
 -- 
 Karl Ove Hufthammer
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 


-
Anna Lippel
new in R so be careful I should be asking a lt of questions!:teeth:
-- 
View this message in context: 
http://old.nabble.com/Problem-with-sqlSave-tp26421303p26441564.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] Compiling from sources (ubuntu and x11)

2009-11-20 Thread Dirk Eddelbuettel

On 19 November 2009 at 23:34, stephen sefick wrote:
|  am using ubuntu 9.10 and I am getting and x11 lib/headers not found.
| I have installed libx11-dev.  I thought this would solve the problem,
| but it is not.  Any help would be appreciated.

You can try 'sudo apt-get build-dep r-base' which will use the package info to 
get
the required packages. You may need deb-src entries for that.

Or look at the diff.gz on the mirrors to read the entry:

  Build-Depends: gcc (= 4:4.1.0), g++ (= 4:4.1.0), gfortran (= 4:4.1.0),
libblas-dev, liblapack-dev (= 3.1.1), tcl8.5-dev, tk8.5-dev, bison,
groff-base, libncurses5-dev, libreadline-dev, debhelper (= 7.2.3),
texi2html, texinfo (= 4.1-2), libbz2-dev, libpcre3-dev, xdg-utils,
zlib1g-dev, libpng12-dev, libjpeg62-dev, libx11-dev, libxt-dev,
x11proto-core-dev, libpango1.0-dev, libcairo2-dev, libtiff4-dev, xvfb,
xauth, xfonts-base, texlive-base, texlive-latex-base,
texlive-generic-recommended, texlive-fonts-recommended,
texlive-extra-utils, texlive-latex-recommended, texlive-latex-extra,
texinfo, texi2html, openjdk-6-jdk [!arm !hppa !kfreebsd-i386
!kfreebsd-amd64 !hurd-i386]

so 'libx11-dev, libxt-dev, x11proto-core-dev' are what you need, but you
probably also need the headers for devices etc.

Or, as suggested, look at the configure output.

Or read the 'R Adminstration' manual which details some of this too, and
recommends the xorg-dev package on Debian (and Ubuntu should be close).

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] different results across versions for glmer/lmer wi th the quasi-poisson or quasi-binomial families: the lattest version might not be accurate...

2009-11-20 Thread Ben Bolker
 
Gosselin Frederic frederic.gosselin at cemagref.fr writes:

 
 Dear R-helpers,
 
 this mail is intended to mention a rather trange result and 
 generate potential useful comments on it. I am
 not aware of another posts on this issue 
 ( RSiteSearch(quasipoisson lmer version dispersion)).
 

[snip snip]

 I would definitely forward this to 
r-sig-mixed-mod...@lists.r-project.org, if I were you.
At one point I reported what may be the same bug;

http://tinyurl.com/ye3pkve

 I don't know when it appeared and when it was
fixed, so I don't know whether it explains your
results or not.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] can R scripts detect signals sent by the task scheduler ?

2009-11-20 Thread mauede
In general, is it possible to run R scripts through cron jobs ?
Is it possible to make  the script detect the system interrupt, save its 
current status and then exit so that next time it is rescheduled it can pick up 
from where it left ? 
Examples, if any, are more then welcome.

Thank you in advance,
Maura



tutti i telefonini TIM!


[[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] How to do X11 seasonal adjust in R?

2009-11-20 Thread sdlywjl666
Dear All£¬
How to do X-11 seasonal adjustment in R?
Thanks£¡
[[alternative HTML version deleted]]

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


Re: [R] Bessel function with large index value

2009-11-20 Thread David Scott
This is a reply to my own question. I thought I had found an answer but 
it seems not so (some analysis follows below). Maybe Martin Maechler or 
Robin Hankin or Duncan Murdoch may have some ideas---I know the question 
is a bit specialized.


David Scott wrote:
I am looking for a method of dealing with the modified Bessel function 
K_\nu(x) for large \nu.


The besselK function implementation of this allows for dealing with 
large values of x by allowing for exponential scaling, but there is no 
facility for dealing with large \nu.


What would work for me would be an lbesselK function in the manner of 
lgamma which returned the log of K_\nu(x) for large \nu. Does anybody 
have any leads on this?


Note that I have trawled through Abramowitz and Stegun and found 9.7.8 
which doesn't work for me because of the complication in the definition 
of the x argument. I have also seen a result of Ismail (1977) reported 
by Barndorff-Nielsen and Blaesild which has the other problem, the 
treatment of the x argument is too simple.


To do the calculation I am attempting, I need to have the Bessel 
function in a form that will allow a cancellation with a Gamma function 
of high order in the denominator.


David Scott




After posting I checked the GNU Scientific Library 
(http://www.gnu.org/software/gsl/) and found:



— Function: double gsl_sf_bessel_lnKnu (double nu, double x)
— Function: int gsl_sf_bessel_lnKnu_e (double nu, double x, 
gsl_sf_result * result)


These routines compute the logarithm of the irregular modified 
Bessel function of fractional order \nu, \ln(K_\nu(x)) for x0, \nu0.


I then recalled that Robin Hankin and Duncan Murdoch had made the GSL 
available. I installed the package gsl and investigated the function

bessel_lnKnu.

Unfortunately, it appears that this function has *smaller* range than 
besselK when it comes to the index. The following shows it:


library(plyr)
library(gsl)
### Check calculations using both methods
lnKnu - maply(expand.grid(x = 100*(1:7), nu = 10*(1:100)), bessel_lnKnu)
lnKnu
Knu - maply(expand.grid(x = 100*(1:7), nu = 10*(1:100)), besselK)
Knu
lnKnu/log(Knu)

I was expecting what happens with gamma and lgamma

### Compare gamma function
lgam - lgamma(100*(1:7))
lgam
gam - gamma(100*(1:7))
gam
lgam/log(gam)

It seems that bessel_lnKnu is set up to protect against infinity when x 
becomes small:


### Does lnKnu protect against Inf when x goes to zero?
lnnear0 - maply(expand.grid(x = 0.0001*(1:10), nu = 10*(0:5)), 
bessel_lnKnu)

lnnear0
near0 - maply(expand.grid(x = 0.0001*(1:10), nu = 10*(0:5)), besselK)
near0
lnnear0/log(near0)

So, I am still in need of a solution: an implementation of log of Bessel 
K which protects against the index nu becoming large.


David Scott

--
_
David Scott Department of Statistics
The University of Auckland, PB 92019
Auckland 1142,NEW ZEALAND
Phone: +64 9 923 5055, or +64 9 373 7599 ext 85055
Email:  d.sc...@auckland.ac.nz,  Fax: +64 9 373 7018

Director of Consulting, Department of Statistics

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] find data (date) gaps in time series

2009-11-20 Thread David Winsemius


On Nov 20, 2009, at 6:26 AM, Stefan Strohmeier wrote:


Dear R users,

I have a time series of precipitation data. The time series  
comprises ~ 20 years and it is supposed to be constant (one value  
per day), but due to some failure of the measuring device some days  
or periods are missing. I would like to find these missing days or  
periods just to get a first idea about the reliability of the  
measurements. The only function I could find was is.constant(), but  
of course I only get a true or false statement instead of the dates  
missing.
Google searches and a look at the R help mailing did not reveal an  
answer.


Please find attached a few dates of the time series with missing  
values from February to April. I would like R to detect those  
missing dates.



 dtdta - read.table(textConnection(2916 2002-02-17  0.0
+ 2917 2002-02-18  0.3
+ 2918 2002-02-19  3.8
+ 2919 2002-02-20 43.6
+ 2920 2002-02-21  1.0
+ 2921 2002-02-22  5.6
+ 2922 2002-02-23 10.6
+ 2923 2002-02-24  2.8
+ 2924 2002-02-25 19.1
+ 2925 2002-02-26 20.5
+ 2926 2002-03-06  0.0
+ 2927 2002-05-06  0.0
+ 2928 2002-05-07  0.0
+ 2929 2002-05-08  0.0
+ 2930 2002-05-09  0.0) )

 dtdta[dtdta$V3 == 0, ]

 V1 V2 V3
1  2916 2002-02-17  0
11 2926 2002-03-06  0
12 2927 2002-05-06  0
13 2928 2002-05-07  0
14 2929 2002-05-08  0
15 2930 2002-05-09  0

You seem to be using 0 as a missing marker. That's bad practice, but  
I suppose it's possble you cannot change how your instruments report.  
You should be using NA and the functions that support proper treatment  
of missingness.


--
David

Any hints or solutions are highly appreciated.

Regards,
Stefan Strohmeier

2916 2002-02-17  0.0
2917 2002-02-18  0.3
2918 2002-02-19  3.8
2919 2002-02-20 43.6
2920 2002-02-21  1.0
2921 2002-02-22  5.6
2922 2002-02-23 10.6
2923 2002-02-24  2.8
2924 2002-02-25 19.1
2925 2002-02-26 20.5
2926 2002-03-06  0.0
2927 2002-05-06  0.0
2928 2002-05-07  0.0
2929 2002-05-08  0.0
2930 2002-05-09  0.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.


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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


Re: [R] Accessing list names in lapply

2009-11-20 Thread Bjarke Christensen
Yes, that is it. Or even simpler:
mapply(plot, x=df1, ylab=names(df1), col=1:10, main=paste(Plot,
names(df1)))

Thank you!

Bjarke Christensen



   
 Bengoechea
 Bartolomé Enrique 
 (SIES 73) Til 
 enrique.bengoech r-help@r-project.org  
 e...@credit-suisse.  cc 
 com  bjarke.christen...@sydbank.dk 
  Emne 
 20-11-2009 13:19  RE: [R] Accessing list names in 
   lapply  
   
   
   
   
   
   




Yet another possibility is to iterate on both values and names
simultaneously using mapply():

df1 - split(
   x=rnorm(n=100, sd=seq(from=1, to=10, each=10)),
   f=letters[seq(from=1, to=10, each=10)]
 )

mapply(function(x, y) plot(x, ylab=y), df1, names(df1))


Enrique

-Original Message-
Date: Thu, 19 Nov 2009 13:27:08 +0100
From: Bjarke Christensen bjarke.christen...@sydbank.dk
Subject: [R] Accessing list names in lapply
To: r-help@r-project.org
Message-ID:

of5533f0b9.99f78ab0-onc1257673.004273ae-c1257673.00446...@bdpnet.dk
Content-Type: text/plain; charset=US-ASCII


Hi,

When using lapply (or sapply) to loop over a list, can I somehow access the
index of the list from inside the function?

A trivial example:

df1 - split(
   x=rnorm(n=100, sd=seq(from=1, to=10, each=10)),
   f=letters[seq(from=1, to=10, each=10)]
 )
str(df1)
#List of 10
# $ a: num [1:10] -0.801 0.418 1.451 -0.554 -0.578 ...
# $ b: num [1:10] -2.464 0.279 4.099 -2.483 1.921 ...
# $ c: num [1:10] -1.14 -1.773 2.512 -2.072 -0.904 ...
# $ d: num [1:10] 2.109 1.243 0.627 -2.343 -6.071 ...
#...
par(mfcol=c(5,2))
lapply(df1, plot)

This plots each element of the list, but the label on the vertical axis is
X[[0L]] (as expected from the documentation in ?lapply). I'd like the
heading for each plot to be the name of that item in the list. This can be
achieved by using a for-loop:

for (i in names(df1)) plot(df1[[i]], ylab=i)

but can it somehow be achieved bu using lapply? I would be hoping for
something like

lapply(df1, function(x) plot(x, ylab=parent.index()))

or some way to parse the index number out of the call, using match.call()
or something like that.

Thanks in advance for any comments,
Bjarke Christensen



--

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] find data (date) gaps in time series

2009-11-20 Thread Marc Schwartz

On Nov 20, 2009, at 8:04 AM, David Winsemius wrote:



On Nov 20, 2009, at 6:26 AM, Stefan Strohmeier wrote:


Dear R users,

I have a time series of precipitation data. The time series  
comprises ~ 20 years and it is supposed to be constant (one value  
per day), but due to some failure of the measuring device some days  
or periods are missing. I would like to find these missing days or  
periods just to get a first idea about the reliability of the  
measurements. The only function I could find was is.constant(), but  
of course I only get a true or false statement instead of the dates  
missing.
Google searches and a look at the R help mailing did not reveal an  
answer.


Please find attached a few dates of the time series with missing  
values from February to April. I would like R to detect those  
missing dates.



 dtdta - read.table(textConnection(2916 2002-02-17  0.0
+ 2917 2002-02-18  0.3
+ 2918 2002-02-19  3.8
+ 2919 2002-02-20 43.6
+ 2920 2002-02-21  1.0
+ 2921 2002-02-22  5.6
+ 2922 2002-02-23 10.6
+ 2923 2002-02-24  2.8
+ 2924 2002-02-25 19.1
+ 2925 2002-02-26 20.5
+ 2926 2002-03-06  0.0
+ 2927 2002-05-06  0.0
+ 2928 2002-05-07  0.0
+ 2929 2002-05-08  0.0
+ 2930 2002-05-09  0.0) )

 dtdta[dtdta$V3 == 0, ]

V1 V2 V3
1  2916 2002-02-17  0
11 2926 2002-03-06  0
12 2927 2002-05-06  0
13 2928 2002-05-07  0
14 2929 2002-05-08  0
15 2930 2002-05-09  0

You seem to be using 0 as a missing marker. That's bad practice,  
but I suppose it's possble you cannot change how your instruments  
report. You should be using NA and the functions that support proper  
treatment of missingness.



David,

I think that he is actually looking for dates where there is no  
measurement as opposed to dates where the measurement is 0.


Thus:

 DF
 V1 V2   V3
1  2916 2002-02-17  0.0
2  2917 2002-02-18  0.3
3  2918 2002-02-19  3.8
4  2919 2002-02-20 43.6
5  2920 2002-02-21  1.0
6  2921 2002-02-22  5.6
7  2922 2002-02-23 10.6
8  2923 2002-02-24  2.8
9  2924 2002-02-25 19.1
10 2925 2002-02-26 20.5
11 2926 2002-03-06  0.0
12 2927 2002-05-06  0.0
13 2928 2002-05-07  0.0
14 2929 2002-05-08  0.0
15 2930 2002-05-09  0.0


# Convert V2 to dates
# Default format is %Y-%m-%d
# See ?as.Date
DF$V2 - as.Date(DF$V2)


# Get the range of dates covered
DateRange - seq(min(DF$V2), max(DF$V2), by = 1)


# Get the dates in DateRange that are not in DF$V2
# See ?%in%
 DateRange[!DateRange %in% DF$V2]
 [1] 2002-02-27 2002-02-28 2002-03-01 2002-03-02 2002-03-03
 [6] 2002-03-04 2002-03-05 2002-03-07 2002-03-08 2002-03-09
[11] 2002-03-10 2002-03-11 2002-03-12 2002-03-13 2002-03-14
[16] 2002-03-15 2002-03-16 2002-03-17 2002-03-18 2002-03-19
[21] 2002-03-20 2002-03-21 2002-03-22 2002-03-23 2002-03-24
[26] 2002-03-25 2002-03-26 2002-03-27 2002-03-28 2002-03-29
[31] 2002-03-30 2002-03-31 2002-04-01 2002-04-02 2002-04-03
[36] 2002-04-04 2002-04-05 2002-04-06 2002-04-07 2002-04-08
[41] 2002-04-09 2002-04-10 2002-04-11 2002-04-12 2002-04-13
[46] 2002-04-14 2002-04-15 2002-04-16 2002-04-17 2002-04-18
[51] 2002-04-19 2002-04-20 2002-04-21 2002-04-22 2002-04-23
[56] 2002-04-24 2002-04-25 2002-04-26 2002-04-27 2002-04-28
[61] 2002-04-29 2002-04-30 2002-05-01 2002-05-02 2002-05-03
[66] 2002-05-04 2002-05-05

HTH,

Marc Schwartz

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


Re: [R] denoting max value in ylim

2009-11-20 Thread separent

Have you tried max()?

i.e.
plot (D10$Part.P ~ D10$Klorofyll,pch=16,log = xy, xlab = (Chla), ylab =
(POP), ylim = c (0, max(D10$Klorofyll)))



helene frigstad wrote:
 
 Hi,
 
 is there any way to set the ylim range from zero to whatever is the max
 value in that dataset? I am plotting many similar plots to the one below,
 and would like to avoid having to find the max value each time. 
 
 
 plot (D10$Part.P ~ D10$Klorofyll,pch=16,log = xy, xlab = (Chla), ylab
 = (POP), ylim = c (0, ???)) 
   abline(m3, untf=TRUE, lty=1,col=blue)
   text(5, 0.05,paste(round(glm(D10$Part.P ~ D10$Klorofyll, data = D10,
 family = Gamma(link =  identity))$coef, 2),collapse =  ))
 
 thank you very much for your time and help.
 
 Best regards,
 Helene Frigstad
 

-- 
View this message in context: 
http://old.nabble.com/denoting-max-value-in-ylim-tp26441589p26441703.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] Has anyone had success with RGTK2/rattle and windows 7 64-bit?

2009-11-20 Thread Tetrick, Scott
I have been unable to get rattle to run in my new Windows7-64 bit 
configuration.  For wither Rgtk2 or rattle, I get an error:

Entry point not found

The procedure entry point g_assetion_message_expr could not be located in the 
dynamic link library libglib-2.0-0.dll.

Any help is really appreciated.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 do I specify a partially completed survival analysis model?

2009-11-20 Thread RWilliam

Sorry for being impatient but is there really no way of doing this at all?
It's quite urgent so any help is very much appreciated. Thank you.



RWilliam wrote:
 
 Hello,
 
 I just started using R to do epidemiologic simulation research using the
 Cox proportional hazard model. I have 2 covariates X1 and X2 which I want
 to model as h(t,X)=h0(t)*exp(b1*X1+b2*X2). I assume independence of X from
 t. 
 
 After I simulate Time and Censor data vectors denoting the censoring time
 and status respectively, I can call the following function to fit the data
 into the Cox model (a is a data.frame containing 4 columns X1, X2, Time
 and Censor):
 b = coxph (Surv (Time, Censor) ~ X1 + X2, data = a, method = breslow);
 
 Now the purpose of me doing simulation is that I have another mechanism to
 generate the number b2. From the given b2 (say it's 4.3), Cox model can be
 fit to generate b1 and check how feasible the new model is. Thus, my
 question is, how do I specify such a model that is partially completed (as
 in b2 is known). I tried things like Surv(Time,Censor)~X1+4.3*X2, but it's
 not working. Thanks very much.
 

-- 
View this message in context: 
http://old.nabble.com/How-do-I-specify-a-partially-completed-survival-analysis-model--tp26421391p26441878.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] How do I specify a partially completed survival analysis model?

2009-11-20 Thread David Winsemius


On Nov 20, 2009, at 9:46 AM, RWilliam wrote:



Sorry for being impatient but is there really no way of doing this  
at all?

It's quite urgent so any help is very much appreciated. Thank you.



The general method with glm's to specify a model with fixed  
coefficients is to use an offset. I believe that the coxph function  
also has that facility and seem to remember that Therneau uses offsets  
in some of the examples he offers in his books and technical reports.


Perhaps:
cmod - coxph( Surv(Time,Censor)~X1, offset=4.3*X2, data= dfname  )

Further requests about specifics should be accompanied (as suggested  
by the Posting Guide) by some code that sets up a reproducible example.


--
David.



RWilliam wrote:


Hello,

I just started using R to do epidemiologic simulation research  
using the
Cox proportional hazard model. I have 2 covariates X1 and X2 which  
I want
to model as h(t,X)=h0(t)*exp(b1*X1+b2*X2). I assume independence of  
X from

t.

After I simulate Time and Censor data vectors denoting the  
censoring time
and status respectively, I can call the following function to fit  
the data
into the Cox model (a is a data.frame containing 4 columns X1, X2,  
Time

and Censor):
b = coxph (Surv (Time, Censor) ~ X1 + X2, data = a, method =  
breslow);


Now the purpose of me doing simulation is that I have another  
mechanism to
generate the number b2. From the given b2 (say it's 4.3), Cox model  
can be

fit to generate b1 and check how feasible the new model is. Thus, my
question is, how do I specify such a model that is partially  
completed (as
in b2 is known). I tried things like Surv(Time,Censor)~X1+4.3*X2,  
but it's

not working. Thanks very much.



--
View this message in context: 
http://old.nabble.com/How-do-I-specify-a-partially-completed-survival-analysis-model--tp26421391p26441878.html
Sent from the R help mailing list archive at Nabble.com.

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


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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


Re: [R] How do I specify a partially completed survival analysis model?

2009-11-20 Thread David Winsemius


On Nov 20, 2009, at 9:57 AM, David Winsemius wrote:



On Nov 20, 2009, at 9:46 AM, RWilliam wrote:



Sorry for being impatient but is there really no way of doing this  
at all?

It's quite urgent so any help is very much appreciated. Thank you.



The general method with glm's to specify a model with fixed  
coefficients is to use an offset. I believe that the coxph function  
also has that facility and seem to remember that Therneau uses  
offsets in some of the examples he offers in his books and technical  
reports.


Perhaps:
cmod - coxph( Surv(Time,Censor)~X1, offset=4.3*X2, data= dfname  )


Or much more likely:
cmod - coxph( Surv(Time,Censor)~X1, offset=log(4.3*X2), data=  
dfname  )


I forgot what scale I should be thinking on. Sorry.

--
David



Further requests about specifics should be accompanied (as suggested  
by the Posting Guide) by some code that sets up a reproducible  
example.


--
David.



RWilliam wrote:


Hello,

I just started using R to do epidemiologic simulation research  
using the
Cox proportional hazard model. I have 2 covariates X1 and X2 which  
I want
to model as h(t,X)=h0(t)*exp(b1*X1+b2*X2). I assume independence  
of X from

t.

After I simulate Time and Censor data vectors denoting the  
censoring time
and status respectively, I can call the following function to fit  
the data
into the Cox model (a is a data.frame containing 4 columns X1, X2,  
Time

and Censor):
b = coxph (Surv (Time, Censor) ~ X1 + X2, data = a, method =  
breslow);


Now the purpose of me doing simulation is that I have another  
mechanism to
generate the number b2. From the given b2 (say it's 4.3), Cox  
model can be

fit to generate b1 and check how feasible the new model is. Thus, my
question is, how do I specify such a model that is partially  
completed (as
in b2 is known). I tried things like Surv(Time,Censor)~X1+4.3*X2,  
but it's

not working. Thanks very much.



--
View this message in context: 
http://old.nabble.com/How-do-I-specify-a-partially-completed-survival-analysis-model--tp26421391p26441878.html
Sent from the R help mailing list archive at Nabble.com.

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


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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


Re: [R] can R scripts detect signals sent by the task scheduler ?

2009-11-20 Thread Dirk Eddelbuettel

On 20 November 2009 at 14:25, mau...@alice.it wrote:
| In general, is it possible to run R scripts through cron jobs ?
| Is it possible to make  the script detect the system interrupt, save its 
current status and then exit so that next time it is rescheduled it can pick up 
from where it left ? 
| Examples, if any, are more then welcome.

You are conflating a few things here:

  i)yes, you can run R from cron or task scheduler -- that is how R
updates webpages on the R site, how CRANberries is updated etc pp
 
  ii)   to a program, it doesn't matter who started it, be it the task
scheduler or interactive use (modulo correcly setup PATH et al
variables

  iii)  R and its predecessor systems have stopped and resumed for decades,
look at help(save.image) or help(save)

  iv)   Snapshotting running applications and resuming them elsewhere is
an operating system task -- some OSs do this, but typically not
in consumer grade versions.

Hope this helps, 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] can R scripts detect signals sent by the task scheduler ?

2009-11-20 Thread Barry Rowlingson
On Fri, Nov 20, 2009 at 1:25 PM,  mau...@alice.it wrote:
 In general, is it possible to run R scripts through cron jobs ?

 Yes, the only problem might be if you use anything that needs a
graphics window. In the old days you needed an X11 display to create
png graphics with the png() function, but not any more. I'm not sure
if yo need an X11 system for anything apart from showing graphs. But I
don't know everything.

 Is it possible to make  the script detect the system interrupt, save its 
 current status and then exit so that next time it is rescheduled it can pick 
 up from where it left ?

?Signals:

Interrupting Execution of R
Description:
 On receiving ‘SIGUSR1’ R will save the workspace and quit.
 ‘SIGUSR2’ has the same result except that the ‘.Last’ function and
 ‘on.exit’ expressions will not be called.

 So if you can send that signal to your process you might be in luck.
However if by 'system interrupt' you mean the SIGQUIT signal, then I'm
not sure that R can trap interrupts to that extent. You might want to
see if your operating system supports 'checkpointing', in which case
any process can be saved and restarted.

 If by 'system interrupt' you mean SIGKILL (signal 9) then you are very stuck.

 What is going on in your system? Are you trying to checkpoint if the
machine is shut down?

 Barry

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

2009-11-20 Thread helene frigstad

Hi,

is there any way to set the ylim range from zero to whatever is the max
value in that dataset? I am plotting many similar plots to the one below,
and would like to avoid having to find the max value each time. 


plot (D10$Part.P ~ D10$Klorofyll,pch=16,log = xy, xlab = (Chla), ylab =
(POP), ylim = c (0, ???)) 
abline(m3, untf=TRUE, lty=1,col=blue)
text(5, 0.05,paste(round(glm(D10$Part.P ~ D10$Klorofyll, data = D10, 
family
= Gamma(link =  identity))$coef, 2),collapse =  ))

thank you very much for your time and help.

Best regards,
Helene Frigstad
-- 
View this message in context: 
http://old.nabble.com/denoting-max-value-in-ylim-tp26441589p26441589.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] denoting max value in ylim

2009-11-20 Thread helene frigstad

Hi,

is there any way to set the ylim range from zero to whatever is the max
value in that dataset? I am plotting many similar plots to the one below,
and would like to avoid having to find the max value each time. 


plot (D10$Part.P ~ D10$Klorofyll,pch=16,log = xy, xlab = (Chla), ylab =
(POP), ylim = c (0, ???)) 
abline(m3, untf=TRUE, lty=1,col=blue)
text(5, 0.05,paste(round(glm(D10$Part.P ~ D10$Klorofyll, data = D10, 
family
= Gamma(link =  identity))$coef, 2),collapse =  ))

thank you very much for your time and help.

Best regards,
Helene Frigstad
-- 
View this message in context: 
http://old.nabble.com/denoting-max-value-in-ylim-tp26441590p26441590.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] symbol in the plot

2009-11-20 Thread gcheer3

Thanks for your reply.  It is very helpful. I am sorry I didn't make my
queston clearer. 
I have two concerns about this graph.
One thing is denote 'sigma' and 'delta' as greek letters, usually I use
'expression'. But I don't know how to use 'expression' in the 'legend'
The other thing is, the graph will also be print out with black and white. I
try to use circle and squre to seperate 'delta1's curve and 'delta2's curve.
So even someone read the black and white handout, they can tell which graph
is which.  It will be nice if there is a notation on the graph, next to a
square symble, it says 'delta 1', next to a circle symble, it says'delta 2'. 
I wrote it on the label with phrases, looks not professional. 

Thank you for any suggestons.

my runable code is as follows:

sigma=c( 0.00625, 0.06250, 0.12500, 0.18750, 0.25000, 0.31250, 0.37500,
0.43750, 0.5,
0.56250)
delta1=c(0.90768, 0.90489, 0.901788,0.898681, 0.8955, 0.89557,
0.892474,0.88936, 0.886262, 0.179959)
delta2=c(0.90830, 0.9110998, 0.914203, 0.917308, 0.920412, 0.923517,
0.926623, 1.71524, 1.7153, 1.7154)

plot(sigma, delta1, ylim=range(-0.5, 2), xlab='sigma', ylab='delta1--square 
delta2--circle', pch=22, type='o') 
par(new=TRUE) 
plot(sigma, delta2, ylim=range(-0.5, 2), xlab='sigma', ylab='delta1--square 
delta2--circle', col='red', axes=FALSE, type='o') 


-- 
View this message in context: 
http://old.nabble.com/symbol-in-the-plot-tp26422303p26442986.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] denoting max value in ylim

2009-11-20 Thread Sundar Dorai-Raj
ylim = c(0, max(log10(D10$Part.P)))

Make sure you remove any 0s or NAs before computing the max though.

--sundar

On Fri, Nov 20, 2009 at 6:12 AM, helene frigstad
helenefrigs...@hotmail.com wrote:

 Hi,

 is there any way to set the ylim range from zero to whatever is the max
 value in that dataset? I am plotting many similar plots to the one below,
 and would like to avoid having to find the max value each time.


 plot (D10$Part.P ~ D10$Klorofyll,pch=16,log = xy, xlab = (Chla), ylab =
 (POP), ylim = c (0, ???))
        abline(m3, untf=TRUE, lty=1,col=blue)
        text(5, 0.05,paste(round(glm(D10$Part.P ~ D10$Klorofyll, data = D10, 
 family
 = Gamma(link =      identity))$coef, 2),collapse =  ))

 thank you very much for your time and help.

 Best regards,
 Helene Frigstad
 --
 View this message in context: 
 http://old.nabble.com/denoting-max-value-in-ylim-tp26441590p26441590.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] find data (date) gaps in time series

2009-11-20 Thread David Winsemius


On Nov 20, 2009, at 9:21 AM, Marc Schwartz wrote:


On Nov 20, 2009, at 8:04 AM, David Winsemius wrote:



On Nov 20, 2009, at 6:26 AM, Stefan Strohmeier wrote:


Dear R users,

I have a time series of precipitation data. The time series  
comprises ~ 20 years and it is supposed to be constant (one value  
per day), but due to some failure of the measuring device some  
days or periods are missing. I would like to find these missing  
days or periods just to get a first idea about the reliability of  
the measurements. The only function I could find was  
is.constant(), but of course I only get a true or false statement  
instead of the dates missing.
Google searches and a look at the R help mailing did not reveal an  
answer.


Please find attached a few dates of the time series with missing  
values from February to April. I would like R to detect those  
missing dates.



 dtdta - read.table(textConnection(2916 2002-02-17  0.0
+ 2917 2002-02-18  0.3
+ 2918 2002-02-19  3.8
+ 2919 2002-02-20 43.6
+ 2920 2002-02-21  1.0
+ 2921 2002-02-22  5.6
+ 2922 2002-02-23 10.6
+ 2923 2002-02-24  2.8
+ 2924 2002-02-25 19.1
+ 2925 2002-02-26 20.5
+ 2926 2002-03-06  0.0
+ 2927 2002-05-06  0.0
+ 2928 2002-05-07  0.0
+ 2929 2002-05-08  0.0
+ 2930 2002-05-09  0.0) )

 dtdta[dtdta$V3 == 0, ]

   V1 V2 V3
1  2916 2002-02-17  0
11 2926 2002-03-06  0
12 2927 2002-05-06  0
13 2928 2002-05-07  0
14 2929 2002-05-08  0
15 2930 2002-05-09  0

You seem to be using 0 as a missing marker. That's bad practice,  
but I suppose it's possble you cannot change how your instruments  
report. You should be using NA and the functions that support  
proper treatment of missingness.



David,

I think that he is actually looking for dates where there is no  
measurement as opposed to dates where the measurement is 0.


Thus:

 DF
V1 V2   V3
1  2916 2002-02-17  0.0
2  2917 2002-02-18  0.3
3  2918 2002-02-19  3.8
4  2919 2002-02-20 43.6
5  2920 2002-02-21  1.0
6  2921 2002-02-22  5.6
7  2922 2002-02-23 10.6
8  2923 2002-02-24  2.8
9  2924 2002-02-25 19.1
10 2925 2002-02-26 20.5
11 2926 2002-03-06  0.0
12 2927 2002-05-06  0.0
13 2928 2002-05-07  0.0
14 2929 2002-05-08  0.0
15 2930 2002-05-09  0.0


You're right. I slipped a gear in reading that.


# Convert V2 to dates
# Default format is %Y-%m-%d
# See ?as.Date
DF$V2 - as.Date(DF$V2)


At this point an alternative approach:

# Scan for differences  1
 diff(DF$V2)
Time differences in days
 [1]  1  1  1  1  1  1  1  1  1  8 61  1  1  1

#Records at the start of gaps
 dtdta[diff(dtdta$V2)1, ]
 V1 V2   V3
10 2925 2002-02-26 20.5
11 2926 2002-03-06  0.0

$Records at the end of gaps
 dtdta[c(1, diff(dtdta$V2))1, ]
 V1 V2 V3
11 2926 2002-03-06  0
12 2927 2002-05-06  0

#Gap dataframe
 dfgaps -data.frame( start= DF[c(1, diff(DF$V2))1, ]$V2, end=  
DF[diff(DF$V2)1, ]$V2)

 dfgaps
   startend
1 2002-03-06 2002-02-26
2 2002-05-06 2002-03-06




# Get the range of dates covered
DateRange - seq(min(DF$V2), max(DF$V2), by = 1)


# Get the dates in DateRange that are not in DF$V2
# See ?%in%
 DateRange[!DateRange %in% DF$V2]
[1] 2002-02-27 2002-02-28 2002-03-01 2002-03-02 2002-03-03
[6] 2002-03-04 2002-03-05 2002-03-07 2002-03-08 2002-03-09
[11] 2002-03-10 2002-03-11 2002-03-12 2002-03-13 2002-03-14
[16] 2002-03-15 2002-03-16 2002-03-17 2002-03-18 2002-03-19
[21] 2002-03-20 2002-03-21 2002-03-22 2002-03-23 2002-03-24
[26] 2002-03-25 2002-03-26 2002-03-27 2002-03-28 2002-03-29
[31] 2002-03-30 2002-03-31 2002-04-01 2002-04-02 2002-04-03
[36] 2002-04-04 2002-04-05 2002-04-06 2002-04-07 2002-04-08
[41] 2002-04-09 2002-04-10 2002-04-11 2002-04-12 2002-04-13
[46] 2002-04-14 2002-04-15 2002-04-16 2002-04-17 2002-04-18
[51] 2002-04-19 2002-04-20 2002-04-21 2002-04-22 2002-04-23
[56] 2002-04-24 2002-04-25 2002-04-26 2002-04-27 2002-04-28
[61] 2002-04-29 2002-04-30 2002-05-01 2002-05-02 2002-05-03
[66] 2002-05-04 2002-05-05

HTH,

Marc Schwartz



David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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


Re: [R] R 2.10 'memory leak'? on OS X

2009-11-20 Thread Stropharia

Thanks Duncan,

I managed to get R to start through the terminal this way. Still no luck
getting the R.app to start. Is it possible to directly access (and then
trash or modify) the .RData and .RProfile files? I assume they would be
recreated if I could then open the R.app. Having searched for them on
spotlight and in the /user/library folder, I don't see them anywhere - are
they always located in the same place on OS X?

thanks,

Steve


Duncan Murdoch-2 wrote:
 
 On 20/11/2009 12:33 AM, Stropharia wrote:
 Dear R users,
 
 I am running R 2.10.0 on OS X 10.5.8.
 
 I had been running 2.10 successfully for about a week (and have used
 previous R versions for 2+ years on the same computer) until 2 days ago
 it
 failed to start up for me. Now when I try to start R, the application
 tries
 to initiate for several minutes then crashes. Looking at the activity
 monitor, my memory usage goes from having about 1.6Gb free (out of 2Gb)
 to
 7Mb in the first 10-15 seconds of attempting to start the program. At
 this
 point I either have to force quit R (as everything starts to freeze up)
 or
 wait several minutes for it to crash.
 
 I have erased the application and reinstalled it 4 times now - with
 exactly
 the same result. I looked around in the Library and System folders to see
 if
 any other files needed to be removed, but couldn't find any. I have also
 restarted the computer and repaired permissions multiple times - and then
 reinstalled R, with no luck. The exact same thing happens if I start R64.
 
 I did not updated OS X or R, or install any other programs, just prior to
 this first happening and am at a loss to explain what's going on. I have
 copied the first part of one of the crash logs below. Does anyone have
 any
 ideas for to remedy this?
 
 
 It sounds like one of your user-specific startup files is causing the 
 problem, e.g. .RData, or .Rprofile.  Did you try starting R with option 
 --vanilla?  That will skip them.
 
 Duncan Murdoch
 
 best,
 
 Steve
 
 
 # Crash log 
 Process: R [231]
 Path:/Applications/R.app/Contents/MacOS/R
 Identifier:  org.R-project.R
 Version: R 2.10.0 GUI 1.30 Leopard build 32-bit (5511)
 Code Type:   X86 (Native)
 Parent Process:  launchd [101]
 
 Date/Time:   2009-11-18 23:15:45.570 -0500
 OS Version:  Mac OS X 10.5.8 (9L31a)
 Report Version:  6
 Anonymous UUID:  D86CDCBC-00FD-4AEE-AB50-2EFE0DAE9E1E
 
 Exception Type:  EXC_BAD_ACCESS (SIGBUS)
 Exception Codes: KERN_PROTECTION_FAILURE at 0x00067ee2
 Crashed Thread:  0
 
 Thread 0 Crashed:
 0   libSystem.B.dylib 0x07c7 __memcpy + 39
 (cpu_capabilities.h:246)
 1   com.apple.CoreFoundation   0x96a6a0b4 __CFStringEncodeByteStream
 +
 4052
 2   com.apple.Foundation   0x94446eb7
 -[NSString(NSStringOtherEncodings)
 getBytes:maxLength:usedLength:encoding:options:range:remainingRange:] +
 295
 3   com.apple.Foundation   0x94446a1a
 _NSNewStringByAppendingStrings
 + 538
 4   com.apple.Foundation   0x94446760 -[NSString
 stringByAppendingString:] + 192
 5   org.R-project.R   0x9ce8 -[RController
 doLoadHistory:] +
 808
 6   org.R-project.R   0x76df -[RController awakeFromNib]
 +
 2319
 7   com.apple.CoreFoundation   0x96ac07f5 -[NSSet
 makeObjectsPerformSelector:] + 181
 8   com.apple.AppKit   0x92efed8e -[NSIBObjectData
 nibInstantiateWithOwner:topLevelObjects:] + 1533
 9   com.apple.AppKit   0x92ef4fba loadNib + 264
 10  com.apple.AppKit   0x92ef491c +[NSBundle(NSNibLoading)
 _loadNibFile:nameTable:withZone:ownerBundle:] + 946
 11  com.apple.AppKit   0x92ef455f +[NSBundle(NSNibLoading)
 loadNibFile:externalNameTable:withZone:] + 171
 12  com.apple.AppKit   0x92ef449d +[NSBundle(NSNibLoading)
 loadNibNamed:owner:] + 391
 13  org.R-project.R   0x2538 main + 296
 14  org.R-project.R   0x23d6 start + 54
 #--
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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://old.nabble.com/R-2.10-%27memory-leak%27--on-OS-X-tp26422775p26443494.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] symbol in the plot

2009-11-20 Thread gcheer3

Joh, thank you very much. sorry for confusing you. I didn't make my question
clear.  I tried your code it looks much better than my original one. Just I
prefer I can write the greek letter delta1 and delta 2 instead of words
'delta1' and 'delta2'. Also, it will be nice if there is a square symbol
next to delta1 and a circle symbol next to delta 2, since sometimes I have
to print the graph in a white and black paper. Thanks for any suggestions.
Sorry for not asking question clearly.


Johannes Graumann-2 wrote:
 
 How about
 
 plot(sigma, delta1, ylim=range(-0.5, 2), xlab='sigma', ylab='delta',
 pch=22, 
 type='o')
 points(sigma, delta2, col='red', axes=FALSE, type='o')
 legend(topleft,c(Delta1,Delta2),fill=TRUE,col=c(black,red))
 
 Send runnable example next time.
 
 HTH, Joh
 
 gcheer3 wrote:
 
 
 TO be specific, here is how I graphed
 
 plot(sigma, delta1, ylim=range(-0.5, 2), xlab='sigma',
 ylab='delta1--square delta2--circle', pch=22, type='o')
 par(new=TRUE)
 plot(sigma, delta2, ylim=range(-0.5, 2), xlab='sigma',
 ylab='delta1--square delta2--circle', col='red', axes=FALSE, type='o')
 
 Thanks a lot
 
 
 gcheer3 wrote:
 
 a graph question. Thanks a lot in advance.
 
 I made two scatterplots on one graph (sigma vs. delta1, sigma vs.
 delta2)
 (20 observations of delta1, delta2 and corresponding sigma) the x-axis
 is
 sigma, the y-axis is either delta1 or delta2. I connected both
 scatterplots. To seperate them, one curves is a line with circles, the
 other curve is a line with squares on it.
 
 I want to make a notation either on the y-axis or on the graph. The
 notiaion is delta1--square; delta2--circle. So when people look at the
 graph, they can easily tell each curve's meaning. The curve with squares
 on it means the sigma vs. delta1, and the curve with circles on it means
 sigma vs. delta2. I think I can use 'expression' to write delta1, delta2
 and sigma in greek letters, but I am not sure how to denote the square
 and cirle I graphed.
 

 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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://old.nabble.com/symbol-in-the-plot-tp26422303p26443123.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] symbol in the plot

2009-11-20 Thread David Winsemius


On Nov 20, 2009, at 10:23 AM, gcheer3 wrote:



Thanks for your reply.  It is very helpful. I am sorry I didn't make  
my

queston clearer.
I have two concerns about this graph.
One thing is denote 'sigma' and 'delta' as greek letters, usually I  
use

'expression'. But I don't know how to use 'expression' in the 'legend'
The other thing is, the graph will also be print out with black and  
white. I
try to use circle and squre to seperate 'delta1's curve and  
'delta2's curve.
So even someone read the black and white handout, they can tell  
which graph
is which.  It will be nice if there is a notation on the graph, next  
to a
square symble, it says 'delta 1', next to a circle symble, it  
says'delta 2'.

I wrote it on the label with phrases, looks not professional.

Thank you for any suggestons.

my runable code is as follows:

sigma=c( 0.00625, 0.06250, 0.12500, 0.18750, 0.25000, 0.31250,  
0.37500,

0.43750, 0.5,
0.56250)
delta1=c(0.90768, 0.90489, 0.901788,0.898681, 0.8955, 0.89557,
0.892474,0.88936, 0.886262, 0.179959)
delta2=c(0.90830, 0.9110998, 0.914203, 0.917308, 0.920412, 0.923517,
0.926623, 1.71524, 1.7153, 1.7154)

plot(sigma, delta1, ylim=range(-0.5, 2), xlab='sigma', ylab='delta1-- 
square

delta2--circle', pch=22, type='o')
par(new=TRUE)
plot(sigma, delta2, ylim=range(-0.5, 2), xlab='sigma', ylab='delta1-- 
square

delta2--circle', col='red', axes=FALSE, type='o')


legend(topleft,legend=expression(Delta~1, Delta~2),  
col=c(black,red), pch=c(22,1) )


(I think I got the order of hte red and circle correct. You should  
check.)


--
David.


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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


[R] Remove leading and trailing white spaces

2009-11-20 Thread Bos, Roger
I have a character string and I would like to remove the leading and
tailing white spaces.  The example for 'sub' shows how to remove the
trailing white spaces, but I still can't figure out how to remove both
trailing and leading white spaces because I can't find any documentation
for what +$ means or what \\s+$ means.  Maybe its because I don't
have a Unix background.  Thanks in advance for any help with this.

str - 'Now is the time  '
sub(' +$', '', str)  ## spaces only
sub('[[:space:]]+$', '', str) ## white space, POSIX-style
sub('\\s+$', '', str, perl = TRUE) ## Perl-style white space

Thanks,

Roger
***

This message is for the named person's use only. It may\...{{dropped:23}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Bessel function with large index value

2009-11-20 Thread Martin Maechler
 DS == David Scott d.sc...@auckland.ac.nz
 on Sat, 21 Nov 2009 02:29:38 +1300 writes:

DS This is a reply to my own question. I thought I had found an answer but 
DS it seems not so (some analysis follows below). Maybe Martin Maechler or 
DS Robin Hankin or Duncan Murdoch may have some ideas---I know the 
question 
DS is a bit specialized.

Indeed.

The good news is that last winter (when in the Swiss Alps, typically
after enjoying the sun and snow) I've written an experimental and
unpublished R package called  'Bessel'
where I've started to collect bessel implementations /
approximations that I had collected and partly tested in the
past,  also looking at what other packages on CRAN had.
My 'Bessel' package depends on my new package  'Rmpfr'
(for arbitrary precision arithmetic), as I really want to
explore the quality of the different Bessel computations, and
for that  have wanted access to infinite precision arithmetic.

Apropos 'Rmpfr': This has been on R-forge for about a year, and
now become a CRAN package a couple of weeks ago.
 Thanks to Brian Ripley and Stefan Theussl, the package is
 available for Windows from R-forge, but not yet from CRAN.
 For MacOSX, it has not yet been made available in precompiled
 form, but there you should be able to build it from the
 sources, after installing the (GNU) GMP library, and the MPFR
 library which builds on GMP.

Back to Bessel and my experimental code:
In there, I have a function, currently only for the Bessel
I_[\nu] that uses the Debye polynomial series needed for these
cases,
and indeed my function has a  'log' argument.

DS David Scott wrote:
 I am looking for a method of dealing with the modified Bessel function 
 K_\nu(x) for large \nu.
 
 The besselK function implementation of this allows for dealing with 
 large values of x by allowing for exponential scaling, but there is no 
 facility for dealing with large \nu.
 
 What would work for me would be an lbesselK function in the manner of 
 lgamma which returned the log of K_\nu(x) for large \nu. Does anybody 
 have any leads on this?
 
 Note that I have trawled through Abramowitz and Stegun and found 9.7.8 
 which doesn't work for me because of the complication in the definition 
 of the x argument. I have also seen a result of Ismail (1977) reported 
 by Barndorff-Nielsen and Blaesild which has the other problem, the 
 treatment of the x argument is too simple.

As my implementation uses A__S 9.3.7 for I_nu,
I wonder why you say that that  the completely analogous 9.3.8
for  K_nu is not appropriate.

 To do the calculation I am attempting, I need to have the Bessel 
 function in a form that will allow a cancellation with a Gamma function 
 of high order in the denominator.

so, working on the log scale saves all problems, right?

I think we should further correspond offline on the topic;
given your interest, I guess I should probably make my 'Bessel' available
from R-forge 

Martin Maechler, ETH Zurich

 David Scott
 
 

DS After posting I checked the GNU Scientific Library 
DS (http://www.gnu.org/software/gsl/) and found:

DS 
DS — Function: double gsl_sf_bessel_lnKnu (double nu, double x)
DS — Function: int gsl_sf_bessel_lnKnu_e (double nu, double x, 
DS gsl_sf_result * result)

DS These routines compute the logarithm of the irregular modified 
DS Bessel function of fractional order \nu, \ln(K_\nu(x)) for x0, \nu0.
DS 
DS I then recalled that Robin Hankin and Duncan Murdoch had made the GSL 
DS available. I installed the package gsl and investigated the function
DS bessel_lnKnu.

DS Unfortunately, it appears that this function has *smaller* range than 
DS besselK when it comes to the index. The following shows it:

DS library(plyr)
DS library(gsl)
DS ### Check calculations using both methods
DS lnKnu - maply(expand.grid(x = 100*(1:7), nu = 10*(1:100)), 
bessel_lnKnu)
DS lnKnu
DS Knu - maply(expand.grid(x = 100*(1:7), nu = 10*(1:100)), besselK)
DS Knu
DS lnKnu/log(Knu)

DS I was expecting what happens with gamma and lgamma

DS ### Compare gamma function
DS lgam - lgamma(100*(1:7))
DS lgam
DS gam - gamma(100*(1:7))
DS gam
DS lgam/log(gam)

DS It seems that bessel_lnKnu is set up to protect against infinity when x 
DS becomes small:

DS ### Does lnKnu protect against Inf when x goes to zero?
DS lnnear0 - maply(expand.grid(x = 0.0001*(1:10), nu = 10*(0:5)), 
DS bessel_lnKnu)
DS lnnear0
DS near0 - maply(expand.grid(x = 0.0001*(1:10), nu = 10*(0:5)), 
besselK)
DS near0
DS lnnear0/log(near0)

DS So, I am still in need of a solution: an implementation of log of 
Bessel 
DS K which protects against the index nu becoming large.

DS David Scott

DS -- 
DS 

Re: [R] Remove leading and trailing white spaces

2009-11-20 Thread jim holtman
try this:

 x - ' middle of the string  '
 sub(^[[:space:]]*(.*?)[[:space:]]*$, \\1, x, perl=TRUE)
[1] middle of the string



On Fri, Nov 20, 2009 at 10:51 AM, Bos, Roger roger@rothschild.com wrote:
 I have a character string and I would like to remove the leading and
 tailing white spaces.  The example for 'sub' shows how to remove the
 trailing white spaces, but I still can't figure out how to remove both
 trailing and leading white spaces because I can't find any documentation
 for what +$ means or what \\s+$ means.  Maybe its because I don't
 have a Unix background.  Thanks in advance for any help with this.

 str - '    Now is the time      '
 sub(' +$', '', str)  ## spaces only
 sub('[[:space:]]+$', '', str) ## white space, POSIX-style
 sub('\\s+$', '', str, perl = TRUE) ## Perl-style white space

 Thanks,

 Roger
 ***

 This message is for the named person's use only. It may\...{{dropped:23}}

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] can R scripts detect signals sent by the task scheduler ?

2009-11-20 Thread Prof Brian Ripley

On Fri, 20 Nov 2009, Barry Rowlingson wrote:


On Fri, Nov 20, 2009 at 1:25 PM,  mau...@alice.it wrote:

In general, is it possible to run R scripts through cron jobs ?


Yes, the only problem might be if you use anything that needs a
graphics window. In the old days you needed an X11 display to create
png graphics with the png() function, but not any more. I'm not sure
if yo need an X11 system for anything apart from showing graphs. But I
don't know everything.


Some package authors assume such a display to install their packages 
(and a few of those may not have a choice as some graphics libraries 
seem to need one to be loaded). So my dept's automated package updater 
scripts run from cron, and start (and stop) a Xvfb X server to get 
around that.


[...]

--
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] R 2.10 'memory leak'? on OS X

2009-11-20 Thread Duncan Murdoch

On 20/11/2009 10:38 AM, Stropharia wrote:

Thanks Duncan,

I managed to get R to start through the terminal this way. Still no luck
getting the R.app to start. Is it possible to directly access (and then
trash or modify) the .RData and .RProfile files? I assume they would be
recreated if I could then open the R.app. Having searched for them on
spotlight and in the /user/library folder, I don't see them anywhere - are
they always located in the same place on OS X?
  


.RProfile won't be recreated:  it's where you put your own startup 
customizations.  It sounds as though .RData is a more likely culprit.


.RData is created when you quit and reply Yes to the question about 
saving.  I forget if there are special rules on a Mac about where the 
saving occurs, but on other systems it's in the current working 
directory.  On startup, R will look there and in the user's home 
directory. 


You probably want to ask on R-sig-mac for some Mac specific advice.

Duncan Murdoch

thanks,

Steve


Duncan Murdoch-2 wrote:
 
 On 20/11/2009 12:33 AM, Stropharia wrote:

 Dear R users,
 
 I am running R 2.10.0 on OS X 10.5.8.
 
 I had been running 2.10 successfully for about a week (and have used

 previous R versions for 2+ years on the same computer) until 2 days ago
 it
 failed to start up for me. Now when I try to start R, the application
 tries
 to initiate for several minutes then crashes. Looking at the activity
 monitor, my memory usage goes from having about 1.6Gb free (out of 2Gb)
 to
 7Mb in the first 10-15 seconds of attempting to start the program. At
 this
 point I either have to force quit R (as everything starts to freeze up)
 or
 wait several minutes for it to crash.
 
 I have erased the application and reinstalled it 4 times now - with

 exactly
 the same result. I looked around in the Library and System folders to see
 if
 any other files needed to be removed, but couldn't find any. I have also
 restarted the computer and repaired permissions multiple times - and then
 reinstalled R, with no luck. The exact same thing happens if I start R64.
 
 I did not updated OS X or R, or install any other programs, just prior to

 this first happening and am at a loss to explain what's going on. I have
 copied the first part of one of the crash logs below. Does anyone have
 any
 ideas for to remedy this?
 
 
 It sounds like one of your user-specific startup files is causing the 
 problem, e.g. .RData, or .Rprofile.  Did you try starting R with option 
 --vanilla?  That will skip them.
 
 Duncan Murdoch
 
 best,
 
 Steve
 
 
 # Crash log 

 Process: R [231]
 Path:/Applications/R.app/Contents/MacOS/R
 Identifier:  org.R-project.R
 Version: R 2.10.0 GUI 1.30 Leopard build 32-bit (5511)
 Code Type:   X86 (Native)
 Parent Process:  launchd [101]
 
 Date/Time:   2009-11-18 23:15:45.570 -0500

 OS Version:  Mac OS X 10.5.8 (9L31a)
 Report Version:  6
 Anonymous UUID:  D86CDCBC-00FD-4AEE-AB50-2EFE0DAE9E1E
 
 Exception Type:  EXC_BAD_ACCESS (SIGBUS)

 Exception Codes: KERN_PROTECTION_FAILURE at 0x00067ee2
 Crashed Thread:  0
 
 Thread 0 Crashed:

 0   libSystem.B.dylib 0x07c7 __memcpy + 39
 (cpu_capabilities.h:246)
 1   com.apple.CoreFoundation   0x96a6a0b4 __CFStringEncodeByteStream
 +
 4052
 2   com.apple.Foundation   0x94446eb7
 -[NSString(NSStringOtherEncodings)
 getBytes:maxLength:usedLength:encoding:options:range:remainingRange:] +
 295
 3   com.apple.Foundation   0x94446a1a
 _NSNewStringByAppendingStrings
 + 538
 4   com.apple.Foundation   0x94446760 -[NSString
 stringByAppendingString:] + 192
 5   org.R-project.R   0x9ce8 -[RController
 doLoadHistory:] +
 808
 6   org.R-project.R   0x76df -[RController awakeFromNib]
 +
 2319
 7   com.apple.CoreFoundation   0x96ac07f5 -[NSSet
 makeObjectsPerformSelector:] + 181
 8   com.apple.AppKit   0x92efed8e -[NSIBObjectData
 nibInstantiateWithOwner:topLevelObjects:] + 1533
 9   com.apple.AppKit   0x92ef4fba loadNib + 264
 10  com.apple.AppKit   0x92ef491c +[NSBundle(NSNibLoading)
 _loadNibFile:nameTable:withZone:ownerBundle:] + 946
 11  com.apple.AppKit   0x92ef455f +[NSBundle(NSNibLoading)
 loadNibFile:externalNameTable:withZone:] + 171
 12  com.apple.AppKit   0x92ef449d +[NSBundle(NSNibLoading)
 loadNibNamed:owner:] + 391
 13  org.R-project.R   0x2538 main + 296
 14  org.R-project.R   0x23d6 start + 54
 #--
 
 __

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

2009-11-20 Thread Gabor Grothendieck
See:
http://finzi.psych.upenn.edu/R/Rhelp02a/archive/40714.html

There are many packages which have this functionality as well and a
search (??, RSiteSearch, rseek.org) will find them.

The links box on the http://gsubfn.googlecode.com page has links to
regular expression pages on the web.

On Fri, Nov 20, 2009 at 10:51 AM, Bos, Roger roger@rothschild.com wrote:
 I have a character string and I would like to remove the leading and
 tailing white spaces.  The example for 'sub' shows how to remove the
 trailing white spaces, but I still can't figure out how to remove both
 trailing and leading white spaces because I can't find any documentation
 for what +$ means or what \\s+$ means.  Maybe its because I don't
 have a Unix background.  Thanks in advance for any help with this.

 str - '    Now is the time      '
 sub(' +$', '', str)  ## spaces only
 sub('[[:space:]]+$', '', str) ## white space, POSIX-style
 sub('\\s+$', '', str, perl = TRUE) ## Perl-style white space

 Thanks,

 Roger
 ***

 This message is for the named person's use only. It may\...{{dropped:23}}

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

2009-11-20 Thread Johannes Graumann
plot(sigma, delta1, ylim=range(-0.5, 2), xlab='sigma', ylab='delta',pch=22, 
type='o')
points(sigma, delta2, col='red', axes=FALSE, pch=1,type='o')
legend(topleft,c(expression(Delta*1),expression(delta*2)),fill=TRUE,col=c(black,red),pch=c(1,22))

See:
?plotmath

Still, gimme a easily runnable example next time.

HTH, Joh

gcheer3 wrote:

 
 Joh, thank you very much. sorry for confusing you. I didn't make my
 question
 clear.  I tried your code it looks much better than my original one. Just
 I prefer I can write the greek letter delta1 and delta 2 instead of words
 'delta1' and 'delta2'. Also, it will be nice if there is a square symbol
 next to delta1 and a circle symbol next to delta 2, since sometimes I have
 to print the graph in a white and black paper. Thanks for any suggestions.
 Sorry for not asking question clearly.
 
 
 Johannes Graumann-2 wrote:
 
 How about
 
 plot(sigma, delta1, ylim=range(-0.5, 2), xlab='sigma', ylab='delta',
 pch=22,
 type='o')
 points(sigma, delta2, col='red', axes=FALSE, type='o')
 legend(topleft,c(Delta1,Delta2),fill=TRUE,col=c(black,red))
 
 Send runnable example next time.
 
 HTH, Joh
 
 gcheer3 wrote:
 
 
 TO be specific, here is how I graphed
 
 plot(sigma, delta1, ylim=range(-0.5, 2), xlab='sigma',
 ylab='delta1--square delta2--circle', pch=22, type='o')
 par(new=TRUE)
 plot(sigma, delta2, ylim=range(-0.5, 2), xlab='sigma',
 ylab='delta1--square delta2--circle', col='red', axes=FALSE, type='o')
 
 Thanks a lot
 
 
 gcheer3 wrote:
 
 a graph question. Thanks a lot in advance.
 
 I made two scatterplots on one graph (sigma vs. delta1, sigma vs.
 delta2)
 (20 observations of delta1, delta2 and corresponding sigma) the x-axis
 is
 sigma, the y-axis is either delta1 or delta2. I connected both
 scatterplots. To seperate them, one curves is a line with circles, the
 other curve is a line with squares on it.
 
 I want to make a notation either on the y-axis or on the graph. The
 notiaion is delta1--square; delta2--circle. So when people look at
 the graph, they can easily tell each curve's meaning. The curve with
 squares on it means the sigma vs. delta1, and the curve with circles on
 it means sigma vs. delta2. I think I can use 'expression' to write
 delta1, delta2 and sigma in greek letters, but I am not sure how to
 denote the square and cirle I graphed.
 

 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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 2.10 'memory leak'? on OS X

2009-11-20 Thread David Winsemius

Probably best further discussed on R-SIG-Mac list:

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

... since that is where the tricks of convincing MacOSX to display  
system files is discussed and a semi-regular basis:


https://stat.ethz.ch/pipermail/r-sig-mac/2009-November/006768.html

https://stat.ethz.ch/pipermail/r-sig-mac/2009-March/005925.html

--
David.

On Nov 20, 2009, at 10:38 AM, Stropharia wrote:



Thanks Duncan,

I managed to get R to start through the terminal this way. Still no  
luck
getting the R.app to start. Is it possible to directly access (and  
then
trash or modify) the .RData and .RProfile files? I assume they would  
be

recreated if I could then open the R.app. Having searched for them on
spotlight and in the /user/library folder, I don't see them anywhere  
- are

they always located in the same place on OS X?

thanks,

Steve


Duncan Murdoch-2 wrote:


On 20/11/2009 12:33 AM, Stropharia wrote:

Dear R users,

I am running R 2.10.0 on OS X 10.5.8.

I had been running 2.10 successfully for about a week (and have used
previous R versions for 2+ years on the same computer) until 2  
days ago

it
failed to start up for me. Now when I try to start R, the  
application

tries
to initiate for several minutes then crashes. Looking at the  
activity
monitor, my memory usage goes from having about 1.6Gb free (out of  
2Gb)

to
7Mb in the first 10-15 seconds of attempting to start the  
program. At

this
point I either have to force quit R (as everything starts to  
freeze up)

or
wait several minutes for it to crash.

I have erased the application and reinstalled it 4 times now - with
exactly
the same result. I looked around in the Library and System folders  
to see

if
any other files needed to be removed, but couldn't find any. I  
have also
restarted the computer and repaired permissions multiple times -  
and then
reinstalled R, with no luck. The exact same thing happens if I  
start R64.


I did not updated OS X or R, or install any other programs, just  
prior to
this first happening and am at a loss to explain what's going on.  
I have
copied the first part of one of the crash logs below. Does anyone  
have

any
ideas for to remedy this?



It sounds like one of your user-specific startup files is causing the
problem, e.g. .RData, or .Rprofile.  Did you try starting R with  
option

--vanilla?  That will skip them.

Duncan Murdoch


best,

Steve


# Crash log 
Process: R [231]
Path:/Applications/R.app/Contents/MacOS/R
Identifier:  org.R-project.R
Version: R 2.10.0 GUI 1.30 Leopard build 32-bit (5511)
Code Type:   X86 (Native)
Parent Process:  launchd [101]

Date/Time:   2009-11-18 23:15:45.570 -0500
OS Version:  Mac OS X 10.5.8 (9L31a)
Report Version:  6
Anonymous UUID:  D86CDCBC-00FD-4AEE-AB50-2EFE0DAE9E1E

Exception Type:  EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x00067ee2
Crashed Thread:  0

Thread 0 Crashed:
0   libSystem.B.dylib 0x07c7 __memcpy + 39
(cpu_capabilities.h:246)
1   com.apple.CoreFoundation   0x96a6a0b4  
__CFStringEncodeByteStream

+
4052
2   com.apple.Foundation   0x94446eb7
-[NSString(NSStringOtherEncodings)
getBytes 
:maxLength:usedLength:encoding:options:range:remainingRange:] +

295
3   com.apple.Foundation   0x94446a1a
_NSNewStringByAppendingStrings
+ 538
4   com.apple.Foundation   0x94446760 -[NSString
stringByAppendingString:] + 192
5   org.R-project.R   0x9ce8 -[RController
doLoadHistory:] +
808
6   org.R-project.R   0x76df -[RController  
awakeFromNib]

+
2319
7   com.apple.CoreFoundation   0x96ac07f5 -[NSSet
makeObjectsPerformSelector:] + 181
8   com.apple.AppKit   0x92efed8e -[NSIBObjectData
nibInstantiateWithOwner:topLevelObjects:] + 1533
9   com.apple.AppKit   0x92ef4fba loadNib + 264
10  com.apple.AppKit   0x92ef491c + 
[NSBundle(NSNibLoading)

_loadNibFile:nameTable:withZone:ownerBundle:] + 946
11  com.apple.AppKit   0x92ef455f + 
[NSBundle(NSNibLoading)

loadNibFile:externalNameTable:withZone:] + 171
12  com.apple.AppKit   0x92ef449d + 
[NSBundle(NSNibLoading)

loadNibNamed:owner:] + 391
13  org.R-project.R   0x2538 main + 296
14  org.R-project.R   0x23d6 start + 54
#--


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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://old.nabble.com/R-2.10-%27memory-leak%27--on-OS-X-tp26422775p26443494.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing 

Re: [R] How do I specify a partially completed survival analysis model?

2009-11-20 Thread RWilliam

In reply to suggestion by David W., setting an offset parameter doesn't seem
to work as R is not recognizing the X2 part of  coxph(
Surv(Time,Censor)~X1, offset=log(4.3*X2), data= a ). Also, here's some
sample data:

   X1 X2 TimeCensor
1   1 0.40619454  77.00666  0
2   1 0.20717868 100.0  0
3   1 0.77360963  79.03463  1
4   1 0.62221954 100.0  0
5   1 0.32191280 100.0  0
6   1 0.73790704  72.84842  0
7   1 0.65012237 100.0  0
8   1 0.71596105 100.0  0
9   1 0.74787202  84.00172  0
10  1 0.66803790  41.65760  0
11  1 0.79922364  92.41999  0
12  1 0.76433736  90.99983  0
13  1 0.57014524 100.0  0
14  1 0.39642235 100.0  0
15  1 0.55756045 100.0  0
16  0 0.60079340 100.0  0
17  0 0.43630695 100.0  0
18  0 0.09388013 100.0  0
19  0 0.55956791 100.0  0
20  0 0.52491597  97.71884  1

where we set the coefficient of X2 to be 8.



RWilliam wrote:
 
 Sorry for being impatient but is there really no way of doing this at all?
 It's quite urgent so any help is very much appreciated. Thank you.
 
 
 
 RWilliam wrote:
 
 Hello,
 
 I just started using R to do epidemiologic simulation research using the
 Cox proportional hazard model. I have 2 covariates X1 and X2 which I want
 to model as h(t,X)=h0(t)*exp(b1*X1+b2*X2). I assume independence of X
 from t. 
 
 After I simulate Time and Censor data vectors denoting the censoring time
 and status respectively, I can call the following function to fit the
 data into the Cox model (a is a data.frame containing 4 columns X1, X2,
 Time and Censor):
 b = coxph (Surv (Time, Censor) ~ X1 + X2, data = a, method = breslow);
 
 Now the purpose of me doing simulation is that I have another mechanism
 to generate the number b2. From the given b2 (say it's 4.3), Cox model
 can be fit to generate b1 and check how feasible the new model is. Thus,
 my question is, how do I specify such a model that is partially completed
 (as in b2 is known). I tried things like Surv(Time,Censor)~X1+4.3*X2, but
 it's not working. Thanks very much.
 
 
 

-- 
View this message in context: 
http://old.nabble.com/How-do-I-specify-a-partially-completed-survival-analysis-model--tp26421391p26443562.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] HTML help missing?

2009-11-20 Thread Duncan Murdoch

On 20/11/2009 7:11 AM, Antje wrote:

Hey there,

I'm running R 2.10 on Windows XP (Professional) and I was wondering 
where the HTML help window disappeared?
With earlier versions everything was fine. Now I get only this 
old-fashioned text windows without any links when I type

?some_function
Can anybody help me?

Edit the R_HOME/etc/Rprofile.site file to uncomment the line

options(help_type=html)

(or just install the patched version, this installer bug was discovered 
after release).


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] How to concatenate expressions

2009-11-20 Thread Sebastien Bihorel

Dear R-users,

I am developing a plotting function, which receives expressions and 
character/numerical vectors as part of the many input arguments and 
which tries to concatenate them before displaying the result to the 
plot. I currently cannot find a way to make this concatenation works. I 
have read several posts in the list that solved this problem by pasting 
the different elements together before creating the expressions (like in 
http://tolstoy.newcastle.edu.au/R/help/02a/4790.html). I cannot 
implement this solution because my expressions and numerical/character 
vectors are passed to the function and not create inside the function. I 
would greatly appreciate any help with the following example code.


Thank you


testplot - function(a,b,c) {

 text - as.expression(paste(a,b,c,sep=' '))

 dev.new()

 plot(-5:5,-5:5,col=0)

 for (i in 1:3) { 
   text(x=i,

y=i,
labels=text[i])
 }
}

a - as.expression(c(bquote(alpha),bquote(beta),bquote(gamma)))

b - as.expression(1:3)

c - as.expression(c(bquote('-10'^th),
bquote('-20'^th),
bquote('-30'^th)))

testplot(a,b,c)

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] ctree (party) changing font sizes in plots

2009-11-20 Thread Sam Thomas
When plotting Binary Trees (ctree) from the party package, is there a
way to adjust the font sizes of the leaves?  

 

require(party)

irisct - ctree(Species ~ ., data = iris)

plot(irisct)

 

I want to adjust the font sizes for Node 2, Node 5, etc.  I'd also
like to be able to adjust the font sizes for the x-axis and y-axis
labels of the histograms.  

 

Thanks,

 

Sam Thomas

Revelant Technologies, LLC.

sam.tho...@revelanttech.com mailto:sam.tho...@revelanttech.com 

317-696-9214

 


[[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] how to draw image of a data distribution? Thanks

2009-11-20 Thread Senlin Liang
I have a file with 3 cols as:
xyvalue
110.5000
121.8333
134.
210.7500
220.7500
234
310.7500
321.4167
335.1667

I read them in using
p - read.table(data.txt, header=TRUE)

My questoin: how to draw a image to show the values at different positions
(x, y)? I would like to see different colors for different values.

Sorry if it is a naive question, but it is my first week of R and I have
been trying for several hours trying to make it.

Thank you,
-- 
Senlin Liang

[[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] ctree (party) changing font sizes in plots

2009-11-20 Thread Achim Zeileis

On Fri, 20 Nov 2009, Sam Thomas wrote:


When plotting Binary Trees (ctree) from the party package, is there a
way to adjust the font sizes of the leaves?


Currently, this is not implemented in party. In interactive usage it is 
not easy to change the fontsize. If you're printing to PDF, you could 
easily increase/decrease the height and width which will decrease/increase 
the relative size of the text, respectively. Not elegant but works.


Alternatively, you could obtain the partykit package from R-Forge which 
has a new implementation of general infrastructure for tree. With that you 
can do


library(partykit)
irisct - ctree(Species ~ ., data = iris)
plot(irisct, gp = gpar(fontsize = 20))

Note that party and partykit should not be used together, partykit has 
a slightly enhanced/modified ctree() function.


hth,
Z




require(party)

irisct - ctree(Species ~ ., data = iris)

plot(irisct)



I want to adjust the font sizes for Node 2, Node 5, etc.  I'd also
like to be able to adjust the font sizes for the x-axis and y-axis
labels of the histograms.



Thanks,



Sam Thomas

Revelant Technologies, LLC.

sam.tho...@revelanttech.com mailto:sam.tho...@revelanttech.com

317-696-9214




[[alternative HTML version deleted]]

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




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


Re: [R] how to draw image of a data distribution? Thanks

2009-11-20 Thread Clint Bowman

with(p,plot(x,y,pch=20,col=1+as.integer(value)))

--
Clint BowmanINTERNET:   cl...@ecy.wa.gov
Air Quality Modeler INTERNET:   cl...@math.utah.edu
Department of Ecology   VOICE:  (360) 407-6815
PO Box 47600FAX:(360) 407-7534
Olympia, WA 98504-7600

On Fri, 20 Nov 2009, Senlin Liang wrote:


I have a file with 3 cols as:
xyvalue
110.5000
121.8333
134.
210.7500
220.7500
234
310.7500
321.4167
335.1667

I read them in using
p - read.table(data.txt, header=TRUE)

My questoin: how to draw a image to show the values at different positions
(x, y)? I would like to see different colors for different values.

Sorry if it is a naive question, but it is my first week of R and I have
been trying for several hours trying to make it.

Thank you,



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

2009-11-20 Thread Leonid Gibiansky

Dear All,
I am new to this list, and also to population modeling with R (nlmeODE). 
Could someone send me a simple example how to do posthoc-type estimate 
(for example, for the Theoph.nlme model in PKPDmodels library):


I have a PK model, and I have a new subject. How to estimate individual 
parameters for a new subject based on the population model?


In general, what would be the best book/tutorial/online resource to 
learn nlmeODE package (I am a nonmem user, so just need to see examples 
or clear description of how it needs to be done); I do not want to 
bother r-help too often but the R-help included into the package is not 
very detailed.


Thanks!
Leonid

--
--
Leonid Gibiansky, Ph.D.
President, QuantPharm LLC
web:www.quantpharm.com
e-mail: LGibiansky at quantpharm.com
tel:(301) 767 5566

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


[R] read a file into a matrix

2009-11-20 Thread Peng Yu
read.delim gives me a data.frame. Is there a function that can return
the result in a matrix rather than data.frame?

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


Re: [R] read a file into a matrix

2009-11-20 Thread Steve Lianoglou

read.delim gives me a data.frame. Is there a function that can return
the result in a matrix rather than data.frame?


m - as.matrix(read.delim(..))

-steve

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

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


Re: [R] How to concatenate expressions

2009-11-20 Thread baptiste auguie
Hi,

You can try this, though I hope to learn of a better way to do it,

a = c(quote(alpha),quote(beta),quote(gamma))
b = lapply(1:3, function(x) as.character(x))
c = c(quote('-10'^th),
  quote('-20'^th),
  quote('-30'^th))

testplot - function(a,b,c) {

 text -
   lapply(seq_along(a), function(ii) bquote(.(a[[ii]])*.(b[[ii]])*.(c[[ii]])))

 dev.new()

 plot(-5:5,-5:5,col=0)

 for (i in seq_along(a)) {
   text(x=i,
   y=i,
   labels=text[[i]])
 }
}

testplot(a,b,c)

HTH,

baptiste

2009/11/20 Sebastien Bihorel sebastien.biho...@cognigencorp.com:
 Dear R-users,

 I am developing a plotting function, which receives expressions and
 character/numerical vectors as part of the many input arguments and which
 tries to concatenate them before displaying the result to the plot. I
 currently cannot find a way to make this concatenation works. I have read
 several posts in the list that solved this problem by pasting the different
 elements together before creating the expressions (like in
 http://tolstoy.newcastle.edu.au/R/help/02a/4790.html). I cannot implement
 this solution because my expressions and numerical/character vectors are
 passed to the function and not create inside the function. I would greatly
 appreciate any help with the following example code.

 Thank you


 testplot - function(a,b,c) {

  text - as.expression(paste(a,b,c,sep=' '))

  dev.new()

  plot(-5:5,-5:5,col=0)

  for (i in 1:3) {   text(x=i,
        y=i,
        labels=text[i])
  }
 }

 a - as.expression(c(bquote(alpha),bquote(beta),bquote(gamma)))

 b - as.expression(1:3)

 c - as.expression(c(bquote('-10'^th),
                    bquote('-20'^th),
                    bquote('-30'^th)))

 testplot(a,b,c)

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


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


Re: [R] read a file into a matrix

2009-11-20 Thread Peng Yu
On Sat, Nov 21, 2009 at 11:55 AM, Steve Lianoglou
mailinglist.honey...@gmail.com wrote:
 read.delim gives me a data.frame. Is there a function that can return
 the result in a matrix rather than data.frame?

 m - as.matrix(read.delim(..))

I knew this approach. But this takes an extra step. Is there a command
that read a file directly into a matrix?

Regards,
Peng

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] AKIMA: z values at a set coordinate

2009-11-20 Thread Rhelp wanted
Dear all.

I am using the akima function to produce 3d contour plots using interp based
on irregular data.

using the eg in the akima manual

library(akima)
data(akima)
plot(y ~ x, data = akima, main = akima example data)
with(akima, text(x, y, formatC(z,dig=2), adj = -0.1))
## linear interpolation
akima.li - interp(akima$x, akima$y, akima$z)
image (akima.li, add=TRUE)
contour(akima.li, add=TRUE)
points (akima, pch = 3)

so with this in mind is there a way of obtaining the interpolated value at a
particular coordinate eg at (11.25,6.5) I can see that it as an orange and
should I look at the contour lines I can see what value it produces. However
Is there a way of saying function[11.25,6.5] which provides a value for that
coordinate.

Hope someone can help

[[alternative HTML version deleted]]

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


[R] problem with predict from nnet package

2009-11-20 Thread Mauricio Romero
Hi,

 

I’m having mayor issues with predict from the nnet package.

I’m training a neural network for forecasting. I trained the network with
info from 1995 to 2009 and I want to forecast month by month 2010.(the
network forecasts one month at a  time).

 

Since I have to do iterative forecasting, im using predict several times
including, including the new forecast each time, but for some reason predict
doesn’t forecast after the first itereation.

 

Here is my code:

 

pronostico4=function(x,rezagosx,muestra, reps, tam, maxi,vo,net){

library(timeSeries)

library(nnet)

library(dummies)

x=as.timeSeries(x)

X=NULL

 for (k in 1:length(rezagosx)) {

 X=cbind(X, lag(diff(log(x)),rezagosx[k]))

 }

 

  pred=predict(net, X,type=raw)

  print(sum(is.na(pred)))

  pred[muestra]=diff(log(x))[muestra]

  pred=exp(diffinv(pred[is.na(pred)==0],xi=log(vo)) )

  muestra2=muestra

  muestra2[max(which(muestra2==1))+1]=TRUE

  print(length(pred))

  print(sum(muestra2))

  print(sum(is.na(X)))

  x[muestra2]=pred[1:sum(muestra2)]

  return(x)

  }

  

  

  muestra=(is.na(a[,Precio.Promedio.Bolsa])==0 
a[,año]2009)

  pred=a[,Precio.Promedio.Bolsa]

  pred[muestra==F]=NA

   pred=as.timeSeries(pred)

X=NULL

for (k in 1:length(rezagosx)) {

 X=cbind(X, lag(diff(log(pred)),rezagosx[k]))

 }

  net=nnet2(diff(log(pred)),X,muestra,reps,tam,maxi)

 

 

  for (i in 1:12){

 
pred=pronostico4(pred,rezagosx,muestra,reps,tam,maxi,vo,net)

  muestra[max(which(muestra==1))+1]=TRUE

  } 

 

 

 

Mauricio Romero 

Quantil S.A.

Cel: 3112231150

 

It is from the earth that we must find our substance; it is on the earth
that we must find solutions to the problems that promise to destroy all life
here

 


[[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] How do I specify a partially completed survival analysis model?

2009-11-20 Thread David Winsemius


On Nov 20, 2009, at 11:07 AM, RWilliam wrote:



In reply to suggestion by David W., setting an offset parameter  
doesn't seem

to work as R is not recognizing the X2 part of  coxph(
Surv(Time,Censor)~X1, offset=log(4.3*X2), data= a ). Also, here's some
sample data:



The problem, arising as a result of not having a dataset against which  
to test my memories of syntactic niceties, is that glm and coxph use  
different methods of supplying offsets. Thereau and Gramsch's book has  
examples, but if you did not have the book you still had alternatives.  
A bit of searching with the terms: coxph Therneau offset;  produced  
lots of hits for the occurrence of offset in warning messages so  
adding -warning to that search then produced a hit to the Google books  
look at TG's text with a worked example:


 a$logX2 - log(a$X2)
 coxph(Surv(Time,Censor)~X1 + offset(logX2), data= a )
Call:
coxph(formula = Surv(Time, Censor) ~ X1 + offset(logX2), data = a)


 coef exp(coef) se(coef) zp
X1 -0.885 0.413 1.43 -0.62 0.54

#Or just:

 coxph(Surv(Time,Censor)~X1 + offset(log(4.3*X2)), data= a )




  X1 X2 TimeCensor
1   1 0.40619454  77.00666  0
2   1 0.20717868 100.0  0
3   1 0.77360963  79.03463  1
4   1 0.62221954 100.0  0
5   1 0.32191280 100.0  0
6   1 0.73790704  72.84842  0
7   1 0.65012237 100.0  0
8   1 0.71596105 100.0  0
9   1 0.74787202  84.00172  0
10  1 0.66803790  41.65760  0
11  1 0.79922364  92.41999  0
12  1 0.76433736  90.99983  0
13  1 0.57014524 100.0  0
14  1 0.39642235 100.0  0
15  1 0.55756045 100.0  0
16  0 0.60079340 100.0  0
17  0 0.43630695 100.0  0
18  0 0.09388013 100.0  0
19  0 0.55956791 100.0  0
20  0 0.52491597  97.71884  1

where we set the coefficient of X2 to be 8.



RWilliam wrote:


Sorry for being impatient but is there really no way of doing this  
at all?

It's quite urgent so any help is very much appreciated. Thank you.



RWilliam wrote:


Hello,

I just started using R to do epidemiologic simulation research  
using the
Cox proportional hazard model. I have 2 covariates X1 and X2 which  
I want
to model as h(t,X)=h0(t)*exp(b1*X1+b2*X2). I assume independence  
of X

from t.

After I simulate Time and Censor data vectors denoting the  
censoring time
and status respectively, I can call the following function to fit  
the
data into the Cox model (a is a data.frame containing 4 columns  
X1, X2,

Time and Censor):
b = coxph (Surv (Time, Censor) ~ X1 + X2, data = a, method =  
breslow);


Now the purpose of me doing simulation is that I have another  
mechanism
to generate the number b2. From the given b2 (say it's 4.3), Cox  
model
can be fit to generate b1 and check how feasible the new model is.  
Thus,
my question is, how do I specify such a model that is partially  
completed
(as in b2 is known). I tried things like  
Surv(Time,Censor)~X1+4.3*X2, but

it's not working. Thanks very much.






--
View this message in context: 
http://old.nabble.com/How-do-I-specify-a-partially-completed-survival-analysis-model--tp26421391p26443562.html
Sent from the R help mailing list archive at Nabble.com.

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


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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


[R] How to: highlight R syntax on webpages ?

2009-11-20 Thread Tal Galili
My question if in the Subject, but if to extend: I am specifically curious
about WordPress blogs. But any solution will give me a lead.

Thanks,
Tal


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

[[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] read a file into a matrix

2009-11-20 Thread Benilton Carvalho

I can't think of anything that is already built in.

But you can always:

read.as.matrix - function(...) as.matrix(read.delim(...))

and now you get one step only ;-)

b

On Nov 20, 2009, at 4:01 PM, Peng Yu wrote:


On Sat, Nov 21, 2009 at 11:55 AM, Steve Lianoglou
mailinglist.honey...@gmail.com wrote:
read.delim gives me a data.frame. Is there a function that can  
return

the result in a matrix rather than data.frame?


m - as.matrix(read.delim(..))


I knew this approach. But this takes an extra step. Is there a command
that read a file directly into a matrix?

Regards,
Peng

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


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


[R] How to use results of distribution fitting for further processing?

2009-11-20 Thread Raymond Wong
This is probably simple, but I have a hard time finding the solution. Any help 
greatly appreciated.
 
I would like to use the results of 
fitdistr(z,densfun=dweibull,start=list(scale=1,shape=1)) for further 
processing.  How do I assign the values of scale and shape to b and a without 
manually entering the numbers?
 
TIA


  __
Looking for the perfect gift? Give the gift of Flickr! 


[[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] How to: highlight R syntax on webpages ?

2009-11-20 Thread Benilton Carvalho

take a look at geshi. b
On Nov 20, 2009, at 4:26 PM, Tal Galili wrote:

My question if in the Subject, but if to extend: I am specifically  
curious

about WordPress blogs. But any solution will give me a lead.

Thanks,
Tal


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

www.r-statistics.com/ (English)

   [[alternative HTML version deleted]]

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


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


Re: [R] read a file into a matrix

2009-11-20 Thread David Winsemius


On Nov 20, 2009, at 1:01 PM, Peng Yu wrote:


On Sat, Nov 21, 2009 at 11:55 AM, Steve Lianoglou
mailinglist.honey...@gmail.com wrote:
read.delim gives me a data.frame. Is there a function that can  
return

the result in a matrix rather than data.frame?


m - as.matrix(read.delim(..))


I knew this approach. But this takes an extra step. Is there a command
that read a file directly into a matrix?


You can wrap matrix() around a scan() call. An example might prompt  
more specifics.


You also could easily modify read.delim (which is after all a wrapped  
scan call) to create a matrix rather than a dataframe.


--

David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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


Re: [R] How to use results of distribution fitting for further processing?

2009-11-20 Thread Peter Ehlers



Raymond Wong wrote:

This is probably simple, but I have a hard time finding the solution. Any help 
greatly appreciated.
 
I would like to use the results of fitdistr(z,densfun=dweibull,start=list(scale=1,shape=1)) for further processing.  How do I assign the values of scale and shape to b and a without manually entering the numbers?


fd - fitdistr(z,densfun=dweibull,start=list(scale=1,shape=1))
str(fd)
fd$estimate
fd$estimate[1]

etc

Remember the ever useful str().

 -Peter Ehlers


 
TIA



  __
Looking for the perfect gift? Give the gift of Flickr! 



[[alternative HTML version deleted]]





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


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


Re: [R] How to concatenate expressions

2009-11-20 Thread Sebastien Bihorel

Thanks a bunch, Baptiste,

Your lapply call works like a charm. BTW, it works also if a, b, and c 
are expressions :D


Sebastien

baptiste auguie wrote:

Hi,

You can try this, though I hope to learn of a better way to do it,

a = c(quote(alpha),quote(beta),quote(gamma))
b = lapply(1:3, function(x) as.character(x))
c = c(quote('-10'^th),
  quote('-20'^th),
  quote('-30'^th))

testplot - function(a,b,c) {

 text -
   lapply(seq_along(a), function(ii) bquote(.(a[[ii]])*.(b[[ii]])*.(c[[ii]])))

 dev.new()

 plot(-5:5,-5:5,col=0)

 for (i in seq_along(a)) {
   text(x=i,
   y=i,
   labels=text[[i]])
 }
}

testplot(a,b,c)

HTH,

baptiste

2009/11/20 Sebastien Bihorel sebastien.biho...@cognigencorp.com:
  

Dear R-users,

I am developing a plotting function, which receives expressions and
character/numerical vectors as part of the many input arguments and which
tries to concatenate them before displaying the result to the plot. I
currently cannot find a way to make this concatenation works. I have read
several posts in the list that solved this problem by pasting the different
elements together before creating the expressions (like in
http://tolstoy.newcastle.edu.au/R/help/02a/4790.html). I cannot implement
this solution because my expressions and numerical/character vectors are
passed to the function and not create inside the function. I would greatly
appreciate any help with the following example code.

Thank you


testplot - function(a,b,c) {

 text - as.expression(paste(a,b,c,sep=' '))

 dev.new()

 plot(-5:5,-5:5,col=0)

 for (i in 1:3) {   text(x=i,
   y=i,
   labels=text[i])
 }
}

a - as.expression(c(bquote(alpha),bquote(beta),bquote(gamma)))

b - as.expression(1:3)

c - as.expression(c(bquote('-10'^th),
   bquote('-20'^th),
   bquote('-30'^th)))

testplot(a,b,c)

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Problem at adding lines on a graphics with lines() function

2009-11-20 Thread anna_l

Hello, I am trying to plot a graphic with many lines with the following
command:

plot(datas[1:n,1],datas[1:n,2],type=l,main=SP500 Prices and Moving
Averages,xlab=Date,ylab=Prices,col=black)
lines(datas[1:n,1],datas[1:n,3],type=l,col=green,lty=solid)

But I just see the first curve. I have tried it on the console separately
and it´s still not working. There is no error message but I can´t see the
second curve. Is there a parameter that I need to change with par()?
Thank you

-
Anna Lippel
new in R so be careful I should be asking a lt of questions!:teeth:
-- 
View this message in context: 
http://old.nabble.com/Problem-at-adding-lines-on-a-graphics-with-lines%28%29-function-tp26443627p26443627.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] How to use results of distribution fitting for further processing?

2009-11-20 Thread David Winsemius


On Nov 20, 2009, at 1:47 PM, Peter Ehlers wrote:




Raymond Wong wrote:
This is probably simple, but I have a hard time finding the  
solution. Any help greatly appreciated.
I would like to use the results of  
fitdistr(z,densfun=dweibull,start=list(scale=1,shape=1)) for  
further processing.  How do I assign the values of scale and shape  
to b and a without manually entering the numbers?




library(MASS)


fd - fitdistr(z,densfun=dweibull,start=list(scale=1,shape=1))
str(fd)
fd$estimate
fd$estimate[1]

etc

Remember the ever useful str().


Agree! You cannot learn R without knowing to use str().

Could also get more self-documenting code with:

fd$estimate[c(scale, shape)]

--
David



-Peter Ehlers



David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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


Re: [R] Problem at adding lines on a graphics with lines() function

2009-11-20 Thread David Winsemius


On Nov 20, 2009, at 1:56 PM, anna_l wrote:



Hello, I am trying to plot a graphic with many lines with the  
following

command:

plot(datas[1:n,1],datas[1:n,2],type=l,main=SP500 Prices and Moving
Averages,xlab=Date,ylab=Prices,col=black)
lines(datas[1:n,1],datas[1:n,3],type=l,col=green,lty=solid)

But I just see the first curve. I have tried it on the console  
separately
and it´s still not working. There is no error message but I can´t  
see the

second curve. Is there a parameter that I need to change with par()?
Thank you

-
Anna Lippel
new in R so be careful I should be asking a lt of  
questions!:teeth:


If you are going to be asking a lot of questions, then please take the  
time to read the Posting Guide and the message at tehend of every r- 
help reply:

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



--
View this message in context: 
http://old.nabble.com/Problem-at-adding-lines-on-a-graphics-with-lines%28%29-function-tp26443627p26443627.html
Sent from the R help mailing list archive at Nabble.com.

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


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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


Re: [R] symbol in the plot

2009-11-20 Thread gcheer3

Thank you again, Joh

Based on your code seems I solved the problem.
new code as follows:
cs-expression(delta[1], delta[2])
plot(sigma, delta1, ylim=range(-0.5, 2), xlab='sigma', ylab='delta', pch=22, 
type='o') 
points(sigma, delta2, col='red', axes=FALSE, type='o') 
legend(topleft, cs,pch = c(21, 22), lty=1, col=2:1)

only concern is there is a waring message in R: Warning message:
In plot.xy(xy.coords(x, y), type = type, ...) :
  axes is not a graphical parameter



gcheer3 wrote:
 
 a graph question. Thanks a lot in advance.
 
 I made two scatterplots on one graph (sigma vs. delta1, sigma vs. delta2)
 (20 observations of delta1, delta2 and corresponding sigma) the x-axis is
 sigma, the y-axis is either delta1 or delta2. I connected both
 scatterplots. To seperate them, one curves is a line with circles, the
 other curve is a line with squares on it. 
 
 I want to make a notation either on the y-axis or on the graph. The
 notiaion is delta1--square; delta2--circle. So when people look at the
 graph, they can easily tell each curve's meaning. The curve with squares
 on it means the sigma vs. delta1, and the curve with circles on it means
 sigma vs. delta2. I think I can use 'expression' to write delta1, delta2
 and sigma in greek letters, but I am not sure how to denote the square and
 cirle I graphed.
 

-- 
View this message in context: 
http://old.nabble.com/symbol-in-the-plot-tp26422303p26443550.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] symbol in the plot

2009-11-20 Thread gcheer3

Thank you, David. 
thanks for letting me know how to use expression in legend. It works too.

gcheer3 wrote:
 
 a graph question. Thanks a lot in advance.
 
 I made two scatterplots on one graph (sigma vs. delta1, sigma vs. delta2)
 (20 observations of delta1, delta2 and corresponding sigma) the x-axis is
 sigma, the y-axis is either delta1 or delta2. I connected both
 scatterplots. To seperate them, one curves is a line with circles, the
 other curve is a line with squares on it. 
 
 I want to make a notation either on the y-axis or on the graph. The
 notiaion is delta1--square; delta2--circle. So when people look at the
 graph, they can easily tell each curve's meaning. The curve with squares
 on it means the sigma vs. delta1, and the curve with circles on it means
 sigma vs. delta2. I think I can use 'expression' to write delta1, delta2
 and sigma in greek letters, but I am not sure how to denote the square and
 cirle I graphed.
 

-- 
View this message in context: 
http://old.nabble.com/symbol-in-the-plot-tp26422303p26443555.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 can I remove one of variables which both variables have correlation coefficient more than 0.95 randomly?

2009-11-20 Thread bbslover

http://old.nabble.com/file/p26443595/Edragonr.txt Edragonr.txt 
HI all,

I have a 72*495 matrix, and the first column is the response, and the
remaining are independences. Final I want to select some independence to fit
y, but there are so many independences, the fit result is not meaning, so I
want to reduce the independece,now. Which method or R package or algorithms
in R package can deal with this problem?

next question, firstly, I want to check the pair correlation coeficient,and
want to  remove one of variables which both variables have correlation
coefficient more than 0.95 randomly?  NOTE, This is random. Before I write a
programe that can delete correlation variable onlly the first variable, It
is not scientific.so I hope all friends can help me write a programe to,
randomly,remove one of variables which both variables have correlation
coefficient more than 0.95 ?  At last, I use those selected variables to fit
y, and hope the regression result is beter with correlation coefficient (r2)
more than 0.7  at less.

n-0
for(i in 1:(dim.cor[1]-1)) 
{ 
  for(j in (i+1):(dim.cor[2]))
   { 
  if (mat3.cor[i,j]=0.90) 
  { 
  mat3-mat3[,-(i-n)] 
  n-n+1
  break 
  } 
} 
}   this is my code,but it is not scientific like I said above.

And I upload my file.  Hoping all friends can help me.
-- 
View this message in context: 
http://old.nabble.com/How-can-I-remove-one-of-variables-which-both-variables-have-correlation-coefficient-more-than-0.95-randomly--tp26443595p26443595.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] multivariate type II regressions

2009-11-20 Thread Angelique Dupuch
 Dear all,

I am looking for a R package or R code dealing with multivariate type II
regressions. I know the lmodel2 and smatr packages, but they just allow
to perform bivariate type II regressions.

Ideally, I would use the method described by McArdle (1988) called standard
minor axis regression, and use the bootstrap to calculate confidence
intervals for each coefficient.

I would appreciate any help you could provide.

Thank you in advance,

Angélique


McArdle (1988). The structural relationship: regression in biology. Can. J.
Zool. 66:2329-2339.


-- 
Angélique Dupuch, PhD
Department of Biology
Lakehead University
955 Oliver Road
Thunder Bay, ON
P7B 5E1, CANADA

Phone: (807) 343-8732
Fax: (807) 343-7796

[[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] find data (date) gaps in time series

2009-11-20 Thread Stefan Strohmeier

David and Marc,

thank you very much for your quick and professional help.

Both approaches are doing what I was looking for.

Next time I will try to provide an example that is more clearly.

Regards,
Stefan
University of Bayreuth

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


Re: [R] Problem at adding lines on a graphics with lines() function

2009-11-20 Thread Jorge Ivan Velez
Hi Anna,

I guess it happened because the range of datas[1:n, 2] differs from the
range of datas[1:n, 3]. A workaround would be either to use the maplot()
function as follows or figuring out their ranges and then plug them in as
the ylim argument in the plot call.

Here is a suggestion using matplot()

matplot(datas[1:n,1], cbind(datas[1:n, 2:3]), type=l, main = SP500 Prices
and Moving
Averages, xlab = Date, ylab = Prices,col = c(black,green), lty = 1)

See ?matplot for details.

And for what you had before:

plot(datas[1:n,1],datas[1:n,2],type=l,main=SP500 Prices and Moving
Averages,xlab=Date,ylab=Prices,col=black,
ylim = c( min(datas[1:n, 2], datas[1:n, 3]), max(datas[1:n, 2], datas[1:n,
3])))
lines(datas[1:n,1],datas[1:n,3],type=l,col=green,lty=solid)

HTH,
Jorge


On Fri, Nov 20, 2009 at 1:56 PM, anna_l  wrote:


 Hello, I am trying to plot a graphic with many lines with the following
 command:

 plot(datas[1:n,1],datas[1:n,2],type=l,main=SP500 Prices and Moving
 Averages,xlab=Date,ylab=Prices,col=black)
 lines(datas[1:n,1],datas[1:n,3],type=l,col=green,lty=solid)

 But I just see the first curve. I have tried it on the console separately
 and it´s still not working. There is no error message but I can´t see the
 second curve. Is there a parameter that I need to change with par()?
 Thank you

 -
 Anna Lippel
 new in R so be careful I should be asking a lt of questions!:teeth:
 --
 View this message in context:
 http://old.nabble.com/Problem-at-adding-lines-on-a-graphics-with-lines%28%29-function-tp26443627p26443627.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.


[[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] symbol in the plot

2009-11-20 Thread David Winsemius


On Nov 20, 2009, at 10:52 AM, gcheer3 wrote:



Thank you again, Joh

Based on your code seems I solved the problem.
new code as follows:
cs-expression(delta[1], delta[2])
plot(sigma, delta1, ylim=range(-0.5, 2), xlab='sigma', ylab='delta',  
pch=22,

type='o')
points(sigma, delta2, col='red', axes=FALSE, type='o')
legend(topleft, cs,pch = c(21, 22), lty=1, col=2:1)

only concern is there is a waring message in R: Warning message:
In plot.xy(xy.coords(x, y), type = type, ...) :
 axes is not a graphical parameter


You should not be specifying axis types or flags to a function,  
[ points() in this case] that is not intended to do anything with the  
axes. To be Biblical: If thine warning offend thee, pluck it[the  
argument] out.


--
David




gcheer3 wrote:


a graph question. Thanks a lot in advance.

I made two scatterplots on one graph (sigma vs. delta1, sigma vs.  
delta2)
(20 observations of delta1, delta2 and corresponding sigma) the x- 
axis is

sigma, the y-axis is either delta1 or delta2. I connected both
scatterplots. To seperate them, one curves is a line with circles,  
the

other curve is a line with squares on it.

I want to make a notation either on the y-axis or on the graph. The
notiaion is delta1--square; delta2--circle. So when people look  
at the
graph, they can easily tell each curve's meaning. The curve with  
squares
on it means the sigma vs. delta1, and the curve with circles on it  
means
sigma vs. delta2. I think I can use 'expression' to write delta1,  
delta2
and sigma in greek letters, but I am not sure how to denote the  
square and

cirle I graphed.



--
View this message in context: 
http://old.nabble.com/symbol-in-the-plot-tp26422303p26443550.html
Sent from the R help mailing list archive at Nabble.com.

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


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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


Re: [R] read a file into a matrix

2009-11-20 Thread jim holtman
What is wrong with the extra step?  Is it taking too much time (you
did not specify that), is it taking too much memory?  How many times
are you going to be doing it?  If not many, then may be it is OK.  You
have to quantify what you are asking for.  It may take longer to send
a message to R-Help and get a response than to just read the file in
and process it.

On Fri, Nov 20, 2009 at 1:01 PM, Peng Yu pengyu...@gmail.com wrote:
 On Sat, Nov 21, 2009 at 11:55 AM, Steve Lianoglou
 mailinglist.honey...@gmail.com wrote:
 read.delim gives me a data.frame. Is there a function that can return
 the result in a matrix rather than data.frame?

 m - as.matrix(read.delim(..))

 I knew this approach. But this takes an extra step. Is there a command
 that read a file directly into a matrix?

 Regards,
 Peng

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] How to: highlight R syntax on webpages ?

2009-11-20 Thread Romain Francois

Hi,

I am about to release the highlight package which just does that.

You would basically do :

 highlight( some_file, output = some_other_file_or_connection,
+   renderer = renderer_html() )


If you are in a rush you can grab it from r-forge:
http://r-forge.r-project.org/projects/highlight/

Romain


On 11/20/2009 07:26 PM, Tal Galili wrote:


My question if in the Subject, but if to extend: I am specifically curious
about WordPress blogs. But any solution will give me a lead.

Thanks,
Tal


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



--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://tr.im/EAD5 : LondonR slides
|- http://tr.im/BcPw : celebrating R commit #5
`- http://tr.im/ztCu : RGG #158:161: examples of package IDPmisc

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

2009-11-20 Thread Leonid Gibiansky

Dear All,

One more nlmeODE question:

I have a differential equation where one of the parameters depends on 
time. Values of this parameter at fixed time points are known but need 
to be interpolated between these known points. Can it be implemented in 
nlmeODE solver?


Thanks
Leonid

--
Leonid Gibiansky, Ph.D.
President, QuantPharm LLC
web:www.quantpharm.com
e-mail: LGibiansky at quantpharm.com
tel:(301) 767 5566




David Winsemius wrote:


On Nov 20, 2009, at 10:52 AM, gcheer3 wrote:



Thank you again, Joh

Based on your code seems I solved the problem.
new code as follows:
cs-expression(delta[1], delta[2])
plot(sigma, delta1, ylim=range(-0.5, 2), xlab='sigma', ylab='delta', 
pch=22,

type='o')
points(sigma, delta2, col='red', axes=FALSE, type='o')
legend(topleft, cs,pch = c(21, 22), lty=1, col=2:1)

only concern is there is a waring message in R: Warning message:
In plot.xy(xy.coords(x, y), type = type, ...) :
 axes is not a graphical parameter


You should not be specifying axis types or flags to a function, [ 
points() in this case] that is not intended to do anything with the 
axes. To be Biblical: If thine warning offend thee, pluck it[the 
argument] out.




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


Re: [R] How to use results of distribution fitting for further processing?

2009-11-20 Thread Peter Ehlers

Quite right, David. I forgot to indicate that MASS needs of course
to be loaded. It's such a useful package that I usually have it
loaded.

Raymond:
When you ask for help with a function in an add-on package
you should indicate that package in your query.

 -Peter Ehlers

David Winsemius wrote:


On Nov 20, 2009, at 1:47 PM, Peter Ehlers wrote:




Raymond Wong wrote:
This is probably simple, but I have a hard time finding the solution. 
Any help greatly appreciated.
I would like to use the results of 
fitdistr(z,densfun=dweibull,start=list(scale=1,shape=1)) for further 
processing.  How do I assign the values of scale and shape to b and a 
without manually entering the numbers?




library(MASS)


fd - fitdistr(z,densfun=dweibull,start=list(scale=1,shape=1))
str(fd)
fd$estimate
fd$estimate[1]

etc

Remember the ever useful str().


Agree! You cannot learn R without knowing to use str().

Could also get more self-documenting code with:

fd$estimate[c(scale, shape)]



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

2009-11-20 Thread Erik Iverson
Hello, 

I wrote a Wordpress blog entry about not only highlighting R syntax, but 
embedding R commands within an entry and using Sweave to produce the R output, 
all within Emacs.  The output of the process is ready to paste Wordpress HTML, 
and a few other R blogs have started using it to generate their content.  
Disclaimer, the following is a link to my blog, but it describes a process you 
might be interested in:

http://blogisticreflections.wordpress.com/2009/09/20/welcome-to-blogistic-reflections/

Best,
Erik 

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of Tal Galili
 Sent: Friday, November 20, 2009 12:27 PM
 To: r-help@r-project.org
 Subject: [R] How to: highlight R syntax on webpages ?
 
 My question if in the Subject, but if to extend: I am specifically curious
 about WordPress blogs. But any solution will give me a lead.
 
 Thanks,
 Tal
 
 
 --
 Contact me: tal.gal...@gmail.com |  972-52-7275845
 Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
 www.r-statistics.com/ (English)
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] Performance of 'by' and 'ddply' on a large data frame

2009-11-20 Thread Tahir Butt
A faster solution using tapply was sent to me via email:

testtapply = function(p){
   df = randomdf(p)
   system.time({res = tapply(df$x2,df$x1,min);
res = as.Date(res,origin=as.Date('1970-01-01'));
df$mindate = res[as.character(df$x1)]})
}

Thanks Phil!

Tahir

On Thu, Nov 19, 2009 at 5:19 PM, Tahir Butt tahir.b...@gmail.com wrote:
 I've only recently started using R. One of the problems I come up
 against is after having extracted a large dataset (5M rows) out of
 database, I realize I need another variable. In this case I have data
 frame with dates. I want to find the minimum date for each value of x1
 and add that minimum date to my data.frame.

 randomdf - function(p) {
 data.frame(x1=sample(1:10^4, 10^p, replace=T),
 x2=sample(seq.Date(Sys.Date() - 356*3,Sys.Date(), by=day), 10^p, replace=T),
 y1=sample(1:100, 10^p, replace=T))
 }
 testby - function(p) {
 df - randomdf(p)
 system.time(by(df, df$x1, function(dfi) { min(dfi$x2) }))
 }
 lapply(c(1,2,3,4,5), testby)
 [[1]]
   user  system elapsed
  0.006   0.000   0.006

 [[2]]
   user  system elapsed
  0.024   0.000   0.025

 [[3]]
   user  system elapsed
  0.233   0.000   0.234

 [[4]]
   user  system elapsed
  1.996   0.026   2.022

 [[5]]
   user  system elapsed
 11.030   0.000  11.032

 Strangely enough, not sure why this is, the result of by with the min
 function is not date objects but instead integers representing days
 from an origin. Is there a min function that would return me a date
 instead of an integer? Or is this a result of using by?

 I also wanted to see how ddply compares.

 testddply - function(p) { pdf - randomdf(p); system.time(ddply(pdf, .(x1), 
 function(df) { return (data.frame(min(df$x2))) })) }
 lapply(c(1,2,3,4,5), testddply)
 [[1]]
   user  system elapsed
  0.020   0.000   0.021

 [[2]]
   user  system elapsed
  0.119   0.000   0.119

 [[3]]
   user  system elapsed
  1.008   0.000   1.008

 [[4]]
   user  system elapsed
  8.425   0.001   8.428

 [[5]]
   user  system elapsed
  23.070   0.000  23.075

 Once the data frame gets above 1M rows, the timings are a bit too long
 (on a previous run it went up to 8000s user time). This seems quite a
 bit slower than I expected. Maybe there's a better and faster way to
 add such variables to a data frame that are derived using some
 aggregation.

 Also, ddply seems to take twice as long as by. Are these two
 operations not equivalent?

 Thanks,
 Tahir


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

2009-11-20 Thread Leonid Gibiansky

Please, ignore this question (see below): I found the way how to do it

Thanks
Leonid
--
Leonid Gibiansky, Ph.D.
President, QuantPharm LLC
web:www.quantpharm.com
e-mail: LGibiansky at quantpharm.com
tel:(301) 767 5566



Leonid Gibiansky wrote:

Dear All,

One more nlmeODE question:

I have a differential equation where one of the parameters depends on 
time. Values of this parameter at fixed time points are known but need 
to be interpolated between these known points. Can it be implemented in 
nlmeODE solver?


Thanks
Leonid

--
Leonid Gibiansky, Ph.D.
President, QuantPharm LLC
web:www.quantpharm.com
e-mail: LGibiansky at quantpharm.com
tel:(301) 767 5566




David Winsemius wrote:


On Nov 20, 2009, at 10:52 AM, gcheer3 wrote:



Thank you again, Joh

Based on your code seems I solved the problem.
new code as follows:
cs-expression(delta[1], delta[2])
plot(sigma, delta1, ylim=range(-0.5, 2), xlab='sigma', ylab='delta', 
pch=22,

type='o')
points(sigma, delta2, col='red', axes=FALSE, type='o')
legend(topleft, cs,pch = c(21, 22), lty=1, col=2:1)

only concern is there is a waring message in R: Warning message:
In plot.xy(xy.coords(x, y), type = type, ...) :
 axes is not a graphical parameter


You should not be specifying axis types or flags to a function, [ 
points() in this case] that is not intended to do anything with the 
axes. To be Biblical: If thine warning offend thee, pluck it[the 
argument] out.






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


Re: [R] formatting dates in axis labels (ggplot2)

2009-11-20 Thread hadley wickham
Hi Michael,

 I'm having trouble figuring out how to format Date variables when used as
 axis labels in graphs.
 The particular case here is an attempt to re-create Nightingale's coxcomb
 graph with ggplot2,
 where I'd like the months to be labeled as Mar 1885, Apr 1885, using a
 date format
 of %b %Y applied to label the dates, or really anything other than
 1885-03-01. I know the solution has to do with formatting the dates, while
 preserving their
 status as an ordered factor, but I don't know how to do that.

Dates are, by their very nature, ordered so you don't need to keep
them as an ordered factor.  If you don't do that you'll find that the
scale_date formatting options will work.

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] R 2.10 'memory leak'? on OS X

2009-11-20 Thread Stropharia

Thanks a lot Duncan and David, the remedy was to delete the files .Rhistory
and .RData via the terminal - with rm . Rhistory etc. (By default they are
hidden on OS X.) Now R.app opens fine.

best,

Steve



David Winsemius wrote:
 
 Probably best further discussed on R-SIG-Mac list:
 
 https://stat.ethz.ch/mailman/listinfo/r-sig-mac
 
 ... since that is where the tricks of convincing MacOSX to display  
 system files is discussed and a semi-regular basis:
 
 https://stat.ethz.ch/pipermail/r-sig-mac/2009-November/006768.html
 
 https://stat.ethz.ch/pipermail/r-sig-mac/2009-March/005925.html
 
 -- 
 David.
 
 On Nov 20, 2009, at 10:38 AM, Stropharia wrote:
 

 Thanks Duncan,

 I managed to get R to start through the terminal this way. Still no  
 luck
 getting the R.app to start. Is it possible to directly access (and  
 then
 trash or modify) the .RData and .RProfile files? I assume they would  
 be
 recreated if I could then open the R.app. Having searched for them on
 spotlight and in the /user/library folder, I don't see them anywhere  
 - are
 they always located in the same place on OS X?

 thanks,

 Steve


 Duncan Murdoch-2 wrote:

 On 20/11/2009 12:33 AM, Stropharia wrote:
 Dear R users,

 I am running R 2.10.0 on OS X 10.5.8.

 I had been running 2.10 successfully for about a week (and have used
 previous R versions for 2+ years on the same computer) until 2  
 days ago
 it
 failed to start up for me. Now when I try to start R, the  
 application
 tries
 to initiate for several minutes then crashes. Looking at the  
 activity
 monitor, my memory usage goes from having about 1.6Gb free (out of  
 2Gb)
 to
 7Mb in the first 10-15 seconds of attempting to start the  
 program. At
 this
 point I either have to force quit R (as everything starts to  
 freeze up)
 or
 wait several minutes for it to crash.

 I have erased the application and reinstalled it 4 times now - with
 exactly
 the same result. I looked around in the Library and System folders  
 to see
 if
 any other files needed to be removed, but couldn't find any. I  
 have also
 restarted the computer and repaired permissions multiple times -  
 and then
 reinstalled R, with no luck. The exact same thing happens if I  
 start R64.

 I did not updated OS X or R, or install any other programs, just  
 prior to
 this first happening and am at a loss to explain what's going on.  
 I have
 copied the first part of one of the crash logs below. Does anyone  
 have
 any
 ideas for to remedy this?


 It sounds like one of your user-specific startup files is causing the
 problem, e.g. .RData, or .Rprofile.  Did you try starting R with  
 option
 --vanilla?  That will skip them.

 Duncan Murdoch

 best,

 Steve


 # Crash log 
 Process: R [231]
 Path:/Applications/R.app/Contents/MacOS/R
 Identifier:  org.R-project.R
 Version: R 2.10.0 GUI 1.30 Leopard build 32-bit (5511)
 Code Type:   X86 (Native)
 Parent Process:  launchd [101]

 Date/Time:   2009-11-18 23:15:45.570 -0500
 OS Version:  Mac OS X 10.5.8 (9L31a)
 Report Version:  6
 Anonymous UUID:  D86CDCBC-00FD-4AEE-AB50-2EFE0DAE9E1E

 Exception Type:  EXC_BAD_ACCESS (SIGBUS)
 Exception Codes: KERN_PROTECTION_FAILURE at 0x00067ee2
 Crashed Thread:  0

 Thread 0 Crashed:
 0   libSystem.B.dylib 0x07c7 __memcpy + 39
 (cpu_capabilities.h:246)
 1   com.apple.CoreFoundation   0x96a6a0b4  
 __CFStringEncodeByteStream
 +
 4052
 2   com.apple.Foundation   0x94446eb7
 -[NSString(NSStringOtherEncodings)
 getBytes 
 :maxLength:usedLength:encoding:options:range:remainingRange:] +
 295
 3   com.apple.Foundation   0x94446a1a
 _NSNewStringByAppendingStrings
 + 538
 4   com.apple.Foundation   0x94446760 -[NSString
 stringByAppendingString:] + 192
 5   org.R-project.R   0x9ce8 -[RController
 doLoadHistory:] +
 808
 6   org.R-project.R   0x76df -[RController  
 awakeFromNib]
 +
 2319
 7   com.apple.CoreFoundation   0x96ac07f5 -[NSSet
 makeObjectsPerformSelector:] + 181
 8   com.apple.AppKit   0x92efed8e -[NSIBObjectData
 nibInstantiateWithOwner:topLevelObjects:] + 1533
 9   com.apple.AppKit   0x92ef4fba loadNib + 264
 10  com.apple.AppKit   0x92ef491c + 
 [NSBundle(NSNibLoading)
 _loadNibFile:nameTable:withZone:ownerBundle:] + 946
 11  com.apple.AppKit   0x92ef455f + 
 [NSBundle(NSNibLoading)
 loadNibFile:externalNameTable:withZone:] + 171
 12  com.apple.AppKit   0x92ef449d + 
 [NSBundle(NSNibLoading)
 loadNibNamed:owner:] + 391
 13  org.R-project.R   0x2538 main + 296
 14  org.R-project.R   0x23d6 start + 54
 #--

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

Re: [R] How to: highlight R syntax on webpages ?

2009-11-20 Thread Thomas S. Dye

Hi Erik,

Interesting blog.  I was pleased to see the reference to org-babel, a  
language-agnostic alternative to Sweave.  Org-babel is a software  
masterpiece that anyone using emacs, LaTeX and R should know about,  
especially if they also use python, ruby, clojure, etc.


All the best,
Tom

On Nov 20, 2009, at 10:02 AM, Erik Iverson wrote:


Hello,

I wrote a Wordpress blog entry about not only highlighting R syntax,  
but embedding R commands within an entry and using Sweave to produce  
the R output, all within Emacs.  The output of the process is ready  
to paste Wordpress HTML, and a few other R blogs have started using  
it to generate their content.  Disclaimer, the following is a link  
to my blog, but it describes a process you might be interested in:


http://blogisticreflections.wordpress.com/2009/09/20/welcome-to-blogistic-reflections/

Best,
Erik


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

On Behalf Of Tal Galili
Sent: Friday, November 20, 2009 12:27 PM
To: r-help@r-project.org
Subject: [R] How to: highlight R syntax on webpages ?

My question if in the Subject, but if to extend: I am specifically  
curious

about WordPress blogs. But any solution will give me a lead.

Thanks,
Tal


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

www.r-statistics.com/ (English)

[[alternative HTML version deleted]]

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


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


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


[R] Help with multiple comparisons on a 2-way repeated measures ANOVA

2009-11-20 Thread Karine Gagnon
Hi everyone,

I'm trying to do a 2-way repeated measures ANOVA with data that looks like
this:
subject block rep  day  light   response
   1 1   1oneL1  5.5
   2 1   2oneL1  4.5
   3 1   1oneL2  4
   4 1   2oneL2  5.1
   5 2   1oneL1  5.3
   6 2   2oneL1  4.8
   7 2   1oneL2  4.6
   8 2   2oneL2  4.9
   1 1   1twoL1  5.2
   2 1   2twoL1  5.0
   3 1   1twoL2  3.2
   4 1   2twoL2  3.4
   5 2   1twoL1  4.6
   6 2   2twoL1  4.9
   7 2   1twoL2  3.3
   8 2   2twoL2  2.9


I'm using lme():
m1-light(buoy~light*day, random=~1|subject/day)
summary(m1)

and get this output:
Linear mixed-effects model fit by REML
 Data: NULL
   AIC  BIClogLik
  24.94574 28.34008 -5.472868

Random effects:
 Formula: ~1 | subject
(Intercept)
StdDev:  0.05400619

 Formula: ~1 | day %in% subject
(Intercept)Residual
StdDev:   0.29127730.06415494

Fixed effects: response ~ light * day
Value  Std.ErrorDF  t-value   p-value
(Intercept) 5.025  0.1515545  6   33.15640   0.
lightL2  -0.200  0.2143304  6   -0.93314   0.3868
daytwo -0.100  0.2109008  6   -0.47416   0.6522
lightL2:daytwo  -1.525  0.2982588  6   -5.11301   0.0022
 Correlation:
(Intr) lghtL2   daytwo
lightL2 -0.707
daytwo -0.696  0.492
lightL2:daytwo  0.492  -0.696   -0.707

Standardized Within-Group Residuals:
  MinQ1  MedQ3
   Max
-0.36863373 -0.15741132  0.03092751  0.14569214  0.32591770

Number of Observations: 16
Number of Groups:
 subject day   %in% subject
816

My FIRST problem is that I'm not quite sure how to analyse the above output.

My SECOND problem is when I try to use glht(), to get multiple comparisons:
summary(glht(m1,linfct=mcp(day=Tukey)))

I get an error message:
Error in as.vector(x, mode) : invalid 'mode' argument

Im not sure where this comes from. I've tried everything I (and my
labmates, we are a bunch of field biologists, not statisticians) can think
of, but this keeps coming back.  Is it because glht() isn't appropriate for
2-way ANOVAs?  If that's the problem, what is the correct way to do this?
Or am I going about this completely wrong from the get-go?

Thanks for all the help you can provide!
K

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


  1   2   >