[R] Decompose an irregular daily time series with missing values

2007-08-30 Thread Dag J. Steinskog

Dear all,

I have a daily time series for the months April to September (183 says) for
a 40 years period. It contain missing values. I would like to extract a
seasonal component, trend component and irregular component using an
adaptive model. 

#Commands for making a time series: 
timeser-rnorm(183*40)
#Add some missing values:
timeser[c(5,77,98,100,105,1000,1340,2001,3277,3278,3279,4004:4009,7000)]-NA

I had a look on the functions decompose and stl. But it seems unsuitable for
my problem. I appreciate if someone can help me out!
-- 
View this message in context: 
http://www.nabble.com/Decompose-an-irregular-daily-time-series-with-missing-values-tf4346265.html#a12382402
Sent from the R help mailing list archive at Nabble.com.

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


[R] Heatmap clustering

2007-08-30 Thread Adria Garriga Far
I have constructed a heatmap comparing distances between 30 elements. I 
get the heatmap plot with red dots when distance is close, and yellow 
when two elements differ. My question is...how can I get clusters of 
similarity from the headplot (I don´t know the total number of clusters, 
otherwise I´d have used Kmeans)?
Lots of thanks in advance!
Adrià

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


[R] correlation structure in lmer

2007-08-30 Thread Fränzi Korner
Hi

how can I specify a correlation structure in the lmer-function as it is
possible in lme(formula, ..., corr=corAR1(form=...))?

Thanks

Fränzi

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


[R] Simple Graph

2007-08-30 Thread amna khan
Hi Sir

We use the function mpg() for ticks on axes. If we define more number of
ticks then each tick is not labeled. How to label each tick on axes?
 Regards


-- 
AMINA SHAHZADI
Department of Statistics
GC University Lahore, Pakistan.
Email:
[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]

[[alternative HTML version deleted]]

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


[R] Single plot multiple levels in x?

2007-08-30 Thread Richard Yanicky
Plotting with 2 x axis?


One axis inside another, for example salary within state,




1-50 | 50 – 100 |  100+   |   1- 50 | 50 -100 | 100+ | …  repeated bins 
for salary
   AL   !   AR  
   ……  more states


The values are all stored with a single data frame. I have tried different 
things with the axis function and done many searches for plotting. Can’t find a 
direct reference 


Thanks.

Richard

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


[R] rpart's loss matrix in ipred

2007-08-30 Thread Niels Smits
Dear R users,

I have been using the rpart procedure to predict the occurrence of 
depression in a large data file. Since the prevalence is very low (5%), 
I have been using classification trees with a loss matrix that penalized 
false negatives more than false positives. I have become interesested in 
bagging these (successful!) classification trees, and have been using 
the ipred package for this. However, the ipred algorithm does not seem 
to do anything with the loss matrix I specify in

control=rpart.control(method=class,cp=0,xval=0,parms=list(loss=matrix(c(0,1,10,0)))

Am I doing anyting wrong or does the ipred package simply not allow for 
specifying such a matrix?

cheers!

-- 
Dr. Niels Smits
Research Methodology, 
Statistics and Data-analysis
Faculty of Psychology and Education
Vrije Universiteit Amsterdam
Van der Boechorststraat 1
1081 BT Amsterdam
The Netherlands
Tel:   +31 (0)20 5988713
Secr:  +31 (0)20 5988757
Fax:   +31 (0)20 5988758

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


[R] Converting into time series object

2007-08-30 Thread Shubha Vishwanath Karanth
Hi,

 

I have a dataframe of trading dates along with the corresponding prices.
I need to convert this into a time series object. How do I do this with
my price values being the time series object and the dates/time being
the trading dates.

 

 

BR, Shubha


[[alternative HTML version deleted]]

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


[R] Q: Mean, median and confidence intervals with functions summary boxplot.stats

2007-08-30 Thread Tom Willems
Dear R ussers,

My question is,  How can my mean be outside the confidence intervals ?!

I think i have the answer for it, but i would like to hear some other 
ideas on it.

First my data is not continuose but categorical, it is a titre calculated 
on a dilution serie.
It is stored as a column of values, and a column indicating the phase of 
the trail.
Theoreticaly it is possible to have a value ranging from 0 to 4, but in 
practice, only sertain values will occure, and they will repeat.
So it are frequencies.

This is why i belief that it is better to work with a median than with a 
mean, because it represents the cluster of values wich occure most.
Below I only give one example, but the mean being below the lowest 
confidence limit occures several times over different tests.

does my answer seam reasonable, or should i perhapes use an other methode, 
any sugestion?

summary_1d  = summary(subset(eda_data,  phase=='1'  test=='test 
1' ,select=lg_value), na.rm = T)
conf_1d  = boxplot.stats(subset(eda_data,  phase=='1'  
test=='test 1' ,select=lg_value))

MeanMedian 95% Confidence Int. StDev.  
Variance
1.1981.681   1.4411.922 0.931
   0.866

Kind regards,
Tom W.


Disclaimer: click here
[[alternative HTML version deleted]]

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


[R] Reading lines from file

2007-08-30 Thread uv

Hi. I have a text file containing a few hundred lines of numbers, each line
has a different length. For example:

1 4 1 1 7
3 11 1 1 1 1 1 1 2
2 4 1 2

And so on. I need to do a simple plot function for each line, and then to
save each plot into a separate file. Is there any way doing it from within
R? 

Alternatively, is there a way to run R from another language or from the X11
(Linux) terminal, sending as input each line, then plotting and saving?

Thank you very much for any idea. 
-- 
View this message in context: 
http://www.nabble.com/Reading-lines-from-file-tf4347936.html#a12387556
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Month end calculations

2007-08-30 Thread Jim Price

A simple example (avoiding using dates, just to show the principle) - this
assumes that your data are already sorted (?order).


temp - data.frame(subject = rep(1:2, each = 5), response = 1:10)
print(temp)

last - do.call(rbind, by(temp, temp$subject, function(x) tail(x, 1)))
print(last)


By changing the 2nd parameter to 'tail' you can get different numbers of
observations in the tail of each subset, so it has more power than SAS's
.last. If you need an equivalent of .first, then replace 'tail' with 'head'.

Jim.



Shubha Vishwanath Karanth wrote:
 
 Hi R users,
 
  
 
 Is there a function in R, which does some calculation only for the month
 end in a daily data?... In other words, is there a command in R,
 equivalent to last. function in SAS?
 
  
 
 BR, Shubha
 
 
   [[alternative HTML version deleted]]
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
View this message in context: 
http://www.nabble.com/Month-end-calculations-tf4347226.html#a12390874
Sent from the R help mailing list archive at Nabble.com.

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


[R] How to signal the end of the table?

2007-08-30 Thread Yuchen Luo
I am using a for loop to read a table row by row and I have to specify how
many records are there in the table. I need to read row by row because the
table is huge and the memory not large enough for the whole table.:



number.of.records=100



fp=file(abc.csv,r)

pos=seek(fp, rw=read)

for (i in 1:number.of.record){

current.row=scan(file=fp, sep=',', what=list(count=1, cusip6=, idate=1,
spread=1.1, vol252=1.1, vol1000=1.1, st_debt=1.1, lt_debt=1.1 , total_liab=
1.1, cr=1.1,   shrout=1.1, prc=1.1, mkt_cap=1.1, rtng=1.1, sec=1.1, cr3m=1.1,
cr5y=1.1, ust3m=1.1,  ust5y=1.1), flush=TRUE, nlines=1,quiet=T)

...

}



I need to know the number of records in the table and put it in the variable
named number.of.records. When I have a new table that I do not know how
many records it has, I use excel to open the file to figure it out and put
it in variable  number.of.records. I often have many tables to try and
every one of them has thousands of recordsit takes a lot of time and
trouble to adjust the code every time I read a different table.



I am wondering if I can change the for loop to a while loop:



while (the end of the table has not been reached)

{

current.row=scan(file=fp, sep=',', what=list(count=1, cusip6=, idate=1,
spread=1.1, vol252=1.1, vol1000=1.1, st_debt=1.1, lt_debt=1.1 , total_liab=
1.1, cr=1.1,   shrout=1.1, prc=1.1, mkt_cap=1.1, rtng=1.1, sec=1.1, cr3m=1.1,
cr5y=1.1, ust3m=1.1,  ust5y=1.1), flush=TRUE, nlines=1,quiet=T)

...

}


The problem is how to articulate while (the end of the table has not been
reached), or equivalently, how to signal the end of the table?

Best Wishes
Yuchen Luo

[[alternative HTML version deleted]]

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


Re: [R] customizing the color and point shape for each line drawn using lattice's xyplot

2007-08-30 Thread Ross Darnell
Does this help

common.without.Method4 - subset(common, Method!=4)
xyplot(MeanBxg ~ PercentVarExplained | bdg.f * bdx.f,
data=common.without.Method4,
groups=Method.f, type=l,  auto.key=T)

Ross Darnell

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Gen
Sent: Thursday, 30 August 2007 2:51 PM
To: r-help@stat.math.ethz.ch
Subject: [R] customizing the color and point shape for each line drawn
using lattice's xyplot


Description of what I am trying to do:
I am using the xyplot code below to plot the variable MeanBxg against
the
variable PercentVarExplained for all 9 possible combinations of
variables
bdg and bdx.  Within each of these 9 scenarios I am plotting a
separate
line for each of up to 9 different methods that I used to estimate the
variable MeanBxg. These methods are identified by the numeric variable
called Method.  Giving me one plot with 9 figures and each of the
figures
contains 9 lines. 

My problem arises because I would like to repeat the creation of this
plot 8
times, in each instance only a subset (eg 6) of the 9 methods are used
(a
different subset each time). 

What I can't figure out:
I would like to learn how to specify the exact line color that
corresponds
to each method such that Method==1 will always be represented by the
same
color (in every plot that it appears in).  Where two methods that I used
were of the same family of methods (say method==1 and method==2 made the
same assumptions about the data)  I would like to, if possible,
represent
the two methods using the same color and distinguish them by the symbol
used
to represent points on the line. 

My code as it currently stands:
xyplot(MeanBxg ~ PercentVarExplained | bdg.f * bdx.f, data=common,
groups=common$Method.f, type=l, subset= Method!=4, auto.key=T)

As the code is, the default colors assigned are repeated causing
different
methods to be represented by the same color with no way to distinguish
them
(I have not succeeded in plotting lines and points simultaneously).  

Side question: When I subset the data to particular methods, is there a
way
to remove the excluded methods from the key as well? (in my code
Method is
a numeric variable, and Method.f corresponds to the lengthy
descriptions
of each method for the purpose of the key)

Thank you very much for your help. 
Genevieve



-- 
View this message in context:
http://www.nabble.com/customizing-the-color-and-point-shape-for-each-lin
e-drawn-using-lattice%27s-xyplot-tf4351934.html#a12400517
Sent from the R help mailing list archive at Nabble.com.

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

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


[R] Incomplete output with `sn' library package

2007-08-30 Thread MANASI VYDYANATH
Dear R users:
I have a question regarding the output for two of the functions in  
the `sn' package, which deals with the mle fitting of skew normal  
curves to linear regressions. I'm using the examples and the dataset  
given as an example in the online documentation for this package, for  
the functions `msn.fit' and `msn.mle'. I'm following the example code  
in the documentation for these two functions exactly.
Part of the data output is supposed to be se, which gives the  
standard errors of the estimated coefficients. This particular value  
comes out as being NA in the examples given, but there are three  
coefficients in each case and no numerical problems about why the  
standard errors cannot be calculated.
Am I setting this program up right? Is there some other command I  
should use (or an option I need to use) to get the output to display  
standard errors of the coefficients?
Thank you for your time in reading this question -
Cordially,
Manasi

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


Re: [R] Reading lines from file

2007-08-30 Thread Barry Rowlingson
uv wrote:
 Hi. I have a text file containing a few hundred lines of numbers, each line
 has a different length. For example:
 
 1 4 1 1 7
 3 11 1 1 1 1 1 1 2
 2 4 1 2
 
 And so on. I need to do a simple plot function for each line, and then to
 save each plot into a separate file. Is there any way doing it from within
 R? 

  You can use read.table with the fill argument:

   read.table(file.txt,fill=NA)
   V1 V2 V3 V4 V5 V6 V7 V8 V9
1  1  4  1  1  7 NA NA NA NA
2  3 11  1  1  1  1  1  1  2
3  2  4  1  2 NA NA NA NA NA

  and then loop over rows. You may have to tell read.table the maximum 
number of columns in your data, since it only looks at the first five 
rows to have a guess at the size.

  Or you can use readLines(file.txt) to read each line into an element 
of a character vector, then use strsplit() to break it up:

   lapply(readLines(file.txt),
function(s){
  as.numeric(unlist(strsplit(s,split= )))
 })

[probably a neater way to do this but I'm not in the mood for playing R 
golf today]

  which gives a list:

[[1]]
[1] 1 4 1 1 7

[[2]]
[1]  3 11  1  1  1  1  1  1  2

[[3]]
[1] 2 4 1 2

  You could then lapply() on this list to do whatever to the elements, 
in your case the plotting.

Barry

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


Re: [R] Excel

2007-08-30 Thread James Reilly

On 30/8/07 6:42 AM, Erich Neuwirth wrote:
 There is one feature in Excel which is extremely convenient, Pivot
 tables. Anybody doing any work as statistical consultant really ought to
 know about Pivot tables, and I am still surprised how many statisticians
 do not know about it. Neither Gnumeric nor OpenOffice Calc offer
 comparably convenient ways working with multidimensional tables.

I'm not familiar with Gnumeric, but OpenOffice has provided the similar 
DataPilot feature for at least three years; see for example 
http://www.openofficetips.com/blog/archives/2004/09/datapilot_101.html

James
-- 
James Reilly
Department of Statistics, University of Auckland
Private Bag 92019, Auckland, New Zealand

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


Re: [R] Incomplete output with `sn' library package

2007-08-30 Thread Uwe Ligges


MANASI VYDYANATH wrote:
 Dear R users:
 I have a question regarding the output for two of the functions in  
 the `sn' package, which deals with the mle fitting of skew normal  
 curves to linear regressions. I'm using the examples and the dataset  
 given as an example in the online documentation for this package, for  
 the functions `msn.fit' and `msn.mle'. I'm following the example code  
 in the documentation for these two functions exactly.
 Part of the data output is supposed to be se, which gives the  
 standard errors of the estimated coefficients. This particular value  
 comes out as being NA in the examples given, but there are three  
 coefficients in each case and no numerical problems about why the  
 standard errors cannot be calculated.
 Am I setting this program up right? Is there some other command I  
 should use (or an option I need to use) to get the output to display  
 standard errors of the coefficients?

We cannot know if you use it right, since you have not given any details on

OS, R version, sn version, and particularly a reproducible example.

As each R-help message tells in the footer:

PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Uwe Ligges







 Thank you for your time in reading this question -
 Cordially,
 Manasi
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] Strage result with an append/strptime combination

2007-08-30 Thread Ptit_Bleu

Hi again,

Just a quick post to propose another solution (without chron) :
strptime function on the whole object and not on each namefile. 

 namefile-070707050642.dat
 namefile-append(namefile,namefile)
 namefile-append(namefile,namefile)
 namefile
[1] 070707050642.dat 070707050642.dat 070707050642.dat
070707050642.dat
 jourheure-strptime(namefile,%d%m%y%H%M%S)
 jourheure
[1] 2007-07-07 05:06:42 2007-07-07 05:06:42 2007-07-07 05:06:42
2007-07-07 05:06:42




Gabor Grothendieck wrote:
 
 Try chron:
 
 library(chron)
 namefile - 070707050642.dat#day-month-year-hour-minute-second.dat
 x - chron(substr(namefile, 1, 6), substr(namefile, 7, 12),
 +   format = c(dmy, hms), out.format = c(m/d/y, h:m:s))
 c(x, x)
 [1] (07/07/07 05:06:42) (07/07/07 05:06:42)
 
 See R News 4/1 Help Desk article for more.
 
 


 Hi,

 I keep on trying to write some small scripts in order to learn R but even
 with basic scripts I have problems ...

 I start with the name of a file which is in fact the time the file has
 been
 generated (I cannot change the format). Then I convert namefile with
 strptime. The problem occurs when I add another time from another file
 with
 append. It displays some informations I don't want.

 I found a post about this problem
 (http://www.nabble.com/Error-with-strptime-tf3607942.html#a10081942) but
 I
 don't understand the solution. I tested as.POSIXct or as.POSIX.lt but it
 has
 no effect.

 Do you have some ideas to solve this problem ?
 Thank you for your help.
 Ptit Bleu.

 ---

 namefile-070707050642.dat#day-month-year-hour-minute-second.dat
 jourheure-strptime(namefile,%d%m%y%H%M%S)

  jourheure
 [1] 2007-07-07 05:06:42

 jourheure-append(jourheure,jourheure)
  jourheure
 [1] 2007-07-07 05:06:42 Paris, Madrid (heure d'été) 2007-07-07
 05:06:42
 Paris, Madrid (heure d'été)

 --
 View this message in context:
 http://www.nabble.com/Strage-result-with-an-append-strptime-combination-tf4347401.html#a12385852
 Sent from the R help mailing list archive at Nabble.com.

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

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

-- 
View this message in context: 
http://www.nabble.com/Strange-result-with-an-append-strptime-combination-tf4347401.html#a12403499
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Simple Graph

2007-08-30 Thread Uwe Ligges


amna khan wrote:
 Hi Sir
 
 We use the function mpg() for ticks on axes. If we define more number of
 ticks then each tick is not labeled. How to label each tick on axes?

What is mpg()? Which version of R? Which device? Which OS?

I guess R cannot print more labels because the ticks are too dense, but 
there is no reproducible example in your message.

PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Uwe Ligges


  Regards
 


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


Re: [R] Q: Mean, median and confidence intervals with functions summary boxplot.stats

2007-08-30 Thread Uwe Ligges


Tom Willems wrote:
 Dear R ussers,
 
 My question is,  How can my mean be outside the confidence intervals ?!
 
 I think i have the answer for it, but i would like to hear some other 
 ideas on it.
 
 First my data is not continuose but categorical, it is a titre calculated 
 on a dilution serie.
 It is stored as a column of values, and a column indicating the phase of 
 the trail.
 Theoreticaly it is possible to have a value ranging from 0 to 4, but in 
 practice, only sertain values will occure, and they will repeat.
 So it are frequencies.
 
 This is why i belief that it is better to work with a median than with a 
 mean, because it represents the cluster of values wich occure most.
 Below I only give one example, but the mean being below the lowest 
 confidence limit occures several times over different tests.
 
 does my answer seam reasonable, or should i perhapes use an other methode, 
 any sugestion?
 
 summary_1d  = summary(subset(eda_data,  phase=='1'  test=='test 
 1' ,select=lg_value), na.rm = T)
 conf_1d  = boxplot.stats(subset(eda_data,  phase=='1'  
 test=='test 1' ,select=lg_value))
 
 MeanMedian 95% Confidence Int. StDev.  
 Variance
 1.1981.681   1.4411.922 0.931
0.866


I do not understand which confidence has been calculated? Based on 
which assumptions / data? Is it pointwise or not? We need much more 
information - and if you think it is a problem with R or usage of R 
functions, then please give us a reproducible example.

Uwe Ligges



 Kind regards,
 Tom W.
 
 
 Disclaimer: click here
   [[alternative HTML version deleted]]
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] How to signal the end of the table?

2007-08-30 Thread Uwe Ligges
What about trying to use a database system and make queries?
If you are at the end of a file, you will read elements of length 0...

Uwe Ligges



Yuchen Luo wrote:
 I am using a for loop to read a table row by row and I have to specify how
 many records are there in the table. I need to read row by row because the
 table is huge and the memory not large enough for the whole table.:
 
 
 
 number.of.records=100
 
 
 
 fp=file(abc.csv,r)
 
 pos=seek(fp, rw=read)
 
 for (i in 1:number.of.record){
 
 current.row=scan(file=fp, sep=',', what=list(count=1, cusip6=, idate=1,
 spread=1.1, vol252=1.1, vol1000=1.1, st_debt=1.1, lt_debt=1.1 , total_liab=
 1.1, cr=1.1,   shrout=1.1, prc=1.1, mkt_cap=1.1, rtng=1.1, sec=1.1, cr3m=1.1,
 cr5y=1.1, ust3m=1.1,  ust5y=1.1), flush=TRUE, nlines=1,quiet=T)
 
 ...
 
 }
 
 
 
 I need to know the number of records in the table and put it in the variable
 named number.of.records. When I have a new table that I do not know how
 many records it has, I use excel to open the file to figure it out and put
 it in variable  number.of.records. I often have many tables to try and
 every one of them has thousands of recordsit takes a lot of time and
 trouble to adjust the code every time I read a different table.
 
 
 
 I am wondering if I can change the for loop to a while loop:
 
 
 
 while (the end of the table has not been reached)
 
 {
 
 current.row=scan(file=fp, sep=',', what=list(count=1, cusip6=, idate=1,
 spread=1.1, vol252=1.1, vol1000=1.1, st_debt=1.1, lt_debt=1.1 , total_liab=
 1.1, cr=1.1,   shrout=1.1, prc=1.1, mkt_cap=1.1, rtng=1.1, sec=1.1, cr3m=1.1,
 cr5y=1.1, ust3m=1.1,  ust5y=1.1), flush=TRUE, nlines=1,quiet=T)
 
 ...
 
 }
 
 
 The problem is how to articulate while (the end of the table has not been
 reached), or equivalently, how to signal the end of the table?
 
 Best Wishes
 Yuchen Luo
 
   [[alternative HTML version deleted]]
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] Single plot multiple levels in x?

2007-08-30 Thread Uwe Ligges


Richard Yanicky wrote:
 Plotting with 2 x axis?
 
 
 One axis inside another, for example salary within state,
 
 
 
 
 1-50 | 50 – 100 |  100+   |   1- 50 | 50 -100 | 100+ | …  repeated 
 bins for salary
AL   !   AR
  ……  more states


Sounds like the lattice package does exactly what you want, but without 
any reproducible example.

Uwe Ligges



 
 The values are all stored with a single data frame. I have tried different 
 things with the axis function and done many searches for plotting. Can’t find 
 a direct reference 
 
 
 Thanks.
 
 Richard
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


[R] Simple Graph

2007-08-30 Thread amna khan
Hi Sir

If I want 10 ticks on x-axis and 10 ticks on y-axis then I  use

lab=c(10,10, 20)

Here first 10 is for 10 ticks on x-axis, second 10 is for 10 ticks on y-axis
and 20 is the lenght of x and y labels in characters.

Now my question is that how I can label all 10 ticks on x-aixs and all 10
ticks on y-axis, because R leaves some ticks unlabeled.

Thank You
-- 
AMINA SHAHZADI
Department of Statistics
GC University Lahore, Pakistan.
Email:
[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]

[[alternative HTML version deleted]]

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


[R] (no subject)

2007-08-30 Thread Sid Kouider

Dear R users,I am looking for an easy (i.e., direct) way in obtaining the F and 
p values from the intercept in anovas with within-subject designs. Data are 
from a psychophysics expeirment where I am using d' (d-prime) values obtained 
from 3 modalities of presentation in each subject.I would like to know not only 
whether there is an effect of modality, but also wether the main effect is 
signiticant (meaning that d' is differnt from 0). I know that a t.test again 
the nul mean would provide me with similar stats on the main effect, but I 
would like to get those stats in an F form, for consistency with the stats on 
the other factors of interest.
As far as I understand how R works, the function anova provides you with such 
information but it is restricted to between-group analyses. For within-subject 
designs, one has to use summray(aov) but stats on the intercept are not 
included in the the result of this function. I have pasted an exemple below. As 
onc can see only the Sum of Sq and Mean Sq are given from the main effect.Thank 
you for any advice you can provide,-Sid summary(aov(x~mod+Error(suj/(mod)), 
data=dp))Error: suj  Df  Sum Sq Mean Sq F value Pr(F)Residuals 10 
19.5977  1.9598   Error: suj:mod  Df  Sum Sq Mean Sq F 
value  Pr(F)  mod2  8.2475  4.1237  4.2955 0.02806 *Residuals 20 
19.2005  0.9600  ---Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 
0.05 '.' 0.1 ' ' 1 Error: Within  Df Sum Sq Mean Sq F value 
Pr(F)Residuals 33 55.812   1.691   
_

tiative now. It’s free. 

[[alternative HTML version deleted]]

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


Re: [R] Simple Graph

2007-08-30 Thread Uwe Ligges


amna khan wrote:
 Hi Sir
 
 If I want 10 ticks on x-axis and 10 ticks on y-axis then I  use
 
 lab=c(10,10, 20)
 
 Here first 10 is for 10 ticks on x-axis, second 10 is for 10 ticks on y-axis
 and 20 is the lenght of x and y labels in characters.
 
 Now my question is that how I can label all 10 ticks on x-aixs and all 10
 ticks on y-axis, because R leaves some ticks unlabeled.


So either make the font size smaller or rotate the labels...

Uwe Ligges


 Thank You

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


[R] how to calculate weighted means by groups

2007-08-30 Thread Patrick Zimmermann
Hello,
I want to calculate the weighted means of a table column, aggregated
by other elements of the same table.
For example I want to calculate mean species numbers weighted by area
and grouped by year, altitude and/or region.

I think a combination of aggregate() and weighted.mean() should work,
but I always get 'Errors'.

this was my favorite:

aggregate(tab, list(year = tab[,year], altitude= tab[,altit],
region= tab[,region]),
weighted.mean(tab[,spcs], tab[,area]))

with a table like:

spcs type altit area year region
38 a low 202 1980 W
40 a low 326 2000 W
45 b medium 207 1980 W
48 b medium 205 2000 W
50 a low 45 1980 E
53 a low 104 2000 E
43 c medium 7 1980 E
33 c medium 9 2000 E
23 c high 20 1980 E
13 c high 26 2000 E


Who can help?

Thanks in advance,
Patrick

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


Re: [R] How to signal the end of the table?

2007-08-30 Thread ONKELINX, Thierry

Have you tried read.table() and the similar functions? I think they
would provide a much more simple solution for your problem.

HTH,

Thierry



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

Do not put your faith in what statistics say until you have carefully
considered what they do not say.  ~William W. Watt
A statistical analysis, properly conducted, is a delicate dissection of
uncertainties, a surgery of suppositions. ~M.J.Moroney

 

 -Oorspronkelijk bericht-
 Van: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] Namens Yuchen Luo
 Verzonden: woensdag 29 augustus 2007 19:41
 Aan: r-help@stat.math.ethz.ch
 Onderwerp: [R] How to signal the end of the table?
 
 I am using a for loop to read a table row by row and I have 
 to specify how many records are there in the table. I need to 
 read row by row because the table is huge and the memory not 
 large enough for the whole table.:
 
 
 
 number.of.records=100
 
 
 
 fp=file(abc.csv,r)
 
 pos=seek(fp, rw=read)
 
 for (i in 1:number.of.record){
 
 current.row=scan(file=fp, sep=',', what=list(count=1, 
 cusip6=, idate=1, spread=1.1, vol252=1.1, vol1000=1.1, 
 st_debt=1.1, lt_debt=1.1 , total_liab=
 1.1, cr=1.1,   shrout=1.1, prc=1.1, mkt_cap=1.1, rtng=1.1, 
 sec=1.1, cr3m=1.1,
 cr5y=1.1, ust3m=1.1,  ust5y=1.1), flush=TRUE, nlines=1,quiet=T)
 
 ...
 
 }
 
 
 
 I need to know the number of records in the table and put it 
 in the variable named number.of.records. When I have a new 
 table that I do not know how many records it has, I use excel 
 to open the file to figure it out and put it in variable  
 number.of.records. I often have many tables to try and every 
 one of them has thousands of recordsit takes a lot of 
 time and trouble to adjust the code every time I read a 
 different table.
 
 
 
 I am wondering if I can change the for loop to a while loop:
 
 
 
 while (the end of the table has not been reached)
 
 {
 
 current.row=scan(file=fp, sep=',', what=list(count=1, 
 cusip6=, idate=1, spread=1.1, vol252=1.1, vol1000=1.1, 
 st_debt=1.1, lt_debt=1.1 , total_liab=
 1.1, cr=1.1,   shrout=1.1, prc=1.1, mkt_cap=1.1, rtng=1.1, 
 sec=1.1, cr3m=1.1,
 cr5y=1.1, ust3m=1.1,  ust5y=1.1), flush=TRUE, nlines=1,quiet=T)
 
 ...
 
 }
 
 
 The problem is how to articulate while (the end of the table 
 has not been reached), or equivalently, how to signal the 
 end of the table?
 
 Best Wishes
 Yuchen Luo
 
   [[alternative HTML version deleted]]
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


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


[R] Data simulation with R

2007-08-30 Thread Matiou

Hi, 

I am currently on a placement here at GSK for my studies, and I'm working on
Heckman Models. I have to make simulations, in order to see whether these
models are efficient or not.

 I have to generate a dataset under the following constraints: 

- outcome is 0 or 1 
- one control group, one treatment group, there must be no treatment effect 
- generate one continuous variable and one binary variable which are both
perfectly correlated to treatment, but not correlated to outcome 
- generate one continuous variable and one binary variable which are both
perfectly correlated to outcome, but not correlated to treatment 
- generate one continuous variable and one binary variable which are both
perfectly correlated to both treatment and outcome 

Problem is, it's my first time generating data, so I'm having quite a hard
time... I usually use SAS, but I didn't manage to generate data using it.
Some people told me it's quite easy to do with R, but I'm not really used to
this program. Is it really possible to simulate this kind of data with R ?
If it is, can someone help me ?

Thanks in advance. 
-- 
View this message in context: 
http://www.nabble.com/Data-simulation-with-R-tf4353531.html#a12405063
Sent from the R help mailing list archive at Nabble.com.

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


[R] R CMD BATCH: cat does not print

2007-08-30 Thread Paul Smith
Dear All,

I am trying to write my first R script. The code is simply

cat(Hello!\n)

However, when I run

$ R CMD BATCH myscript.R

I do not see Hello! on the console. I am using Fedora 7 (Linux) and R-2.5.1.

Any ideas?

Thanks in advance,

Paul

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


[R] bug in DEoptim package

2007-08-30 Thread Vladimir Eremeev

(the same mail was sent to the author)

When I called the function DEoptim with control=list(strategy=1) or
control=list(strategy=2)
I got the error:

Error in mui[rtd + 1, i] : incorrect number of dimensions


Analysis of the source code of the DEoptim reveals the following fragment

if (con$strategy  5)
  st - con$strategy - 5 ## binomial crossover
else {
  st - con$strategy ## exponential crossover
  mui - sort(t(mui)) ## transpose, collect 1's in each column

  for (i in 1:NP) {
n - floor(runif(1) * d)
if (n  0) {
  rtd - (rotd + n) %% d
  mui[,i] - mui[rtd + 1,i] ## rotate column i by n 
}
  }
  mui - t(mui) ## transpose back
}


sort returns a 1-dimensional vector, this causes the error in the
following indexing operators.

This also shows, that any strategy value from 1 through 5 will cause
this error, while values from 1 through 10 are possible.

Package's DESCRIPTION file contains the following:

Version: 1.1-8
Date: 2007-01-29

My sessionInfo():

 sessionInfo()
R version 2.5.1 Patched (2007-08-19 r42614) 
i386-pc-mingw32 

locale:
LC_COLLATE=Russian_Russia.1251;LC_CTYPE=Russian_Russia.1251;LC_MONETARY=Russian_Russia.1251;LC_NUMERIC=C;LC_TIME=Russian_Russia.1251

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

other attached packages:
   debug mvbutils  DEoptim 
 1.1.0  1.1.1  1.1-8 

Unfortunately I haven't submerged deep enough to the algorithm details to
propose the bug fix.

-- 
View this message in context: 
http://www.nabble.com/bug-in-DEoptim-package-tf4353533.html#a12405068
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] R CMD BATCH: cat does not print

2007-08-30 Thread Barry Rowlingson
Paul Smith wrote:
 Dear All,
 
 I am trying to write my first R script. The code is simply
 
 cat(Hello!\n)
 
 However, when I run
 
 $ R CMD BATCH myscript.R
 
 I do not see Hello! on the console. I am using Fedora 7 (Linux) and R-2.5.1.
 
 Any ideas?


  You shouldn't see it on the console! BATCH writes its output to a file.

  You should find a file called myscript.Rout that does contain the 
'Hello!'.

  Barry

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


Re: [R] breaking the x-axis and having two different x-axis labels

2007-08-30 Thread Jim Lemon
Georg Ehret wrote:
 Dear R community,
  I have two questions concerning barplots that I struggle to resolve:
 
 1) How can I break (interrupt) the x-axis (e.g.: have it display values from
 -100 to -90 and 90 to 100 only)?

I think you mean a horizontal barplot with a gap between -90 and 90. 
pyramid.plot (plotrix) doesn't quite do what you want, as the present 
version doesn't allow customized axis labels. The principle is the same 
as that used in gap.barplot, but the maintainer (me) didn't think that 
anyone would want to do this horizontally. If you are stuck I can add a 
feature or two...

However, here's an unbeauteous hack.
heights-c(sample(-100:-91,5),sample(91:100,5))
barplot(c(heights[1:5]+90,heights[6:10]-90),
  horiz=TRUE,xaxt=n,xlim=c(-10,10))
axis(1,at=seq(-9,9,by=2),
  labels=c(-99,-97,-95,-93,-91,91,93,95,97,99))
axis.break(1,-0.1,style=gap)

 2) I overlay two horizontal barplots: one with negative values only and one
 with positive values only: I would wish to mark the two datasets separately
 on the x-axis (or some other way). If I use the legend I get a superposed
 result... is there another way?
 
This sounds like a job for axis, but I can't really picture what you 
describe. Do you want the negative bars starting from the right and 
going left and the positive ones starting from the left and going right? 
Or a vertical line in the center with the bars going in the usual 
directions?

Jim

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


Re: [R] R CMD BATCH: cat does not print

2007-08-30 Thread Vladimir Eremeev

Use rscript

Rscript myscript.R 
or
Rscript -e 'cat(Hello!\n)'

will show Hello! on the console.

R CMD BATCH writes its output to the file myscript.Rout



Paul Smith wrote:
 
 Dear All,
 
 I am trying to write my first R script. The code is simply
 
 cat(Hello!\n)
 
 However, when I run
 
 $ R CMD BATCH myscript.R
 
 I do not see Hello! on the console. I am using Fedora 7 (Linux) and
 R-2.5.1.
 
 Any ideas?
 
 Thanks in advance,
 
 Paul
 




-- 
View this message in context: 
http://www.nabble.com/R-CMD-BATCH%3A-cat-does-not-print-tf4353572.html#a12405494
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] R CMD BATCH: cat does not print

2007-08-30 Thread Paul Smith
On 8/30/07, Barry Rowlingson [EMAIL PROTECTED] wrote:
  I am trying to write my first R script. The code is simply
 
  cat(Hello!\n)
 
  However, when I run
 
  $ R CMD BATCH myscript.R
 
  I do not see Hello! on the console. I am using Fedora 7 (Linux) and 
  R-2.5.1.
 
  Any ideas?
 

   You shouldn't see it on the console! BATCH writes its output to a file.

   You should find a file called myscript.Rout that does contain the
 'Hello!'.

Thanks, Barry. Indeed, the file myscript.Rout exists and contains the
output of cat. I was expecting a behavior similar to the bash scripts.
And by the way, cannot a R script write only on the console and just
what one tells it to write, likewise bash scripts?

Paul

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


Re: [R] R CMD BATCH: cat does not print

2007-08-30 Thread Paul Smith
On 8/30/07, Vladimir Eremeev [EMAIL PROTECTED] wrote:

 Use rscript

 Rscript myscript.R
 or
 Rscript -e 'cat(Hello!\n)'

 will show Hello! on the console.

 R CMD BATCH writes its output to the file myscript.Rout

Thanks, Vladimir. Rscript is exactly what I was looking for!

Paul



 Paul Smith wrote:
 
  Dear All,
 
  I am trying to write my first R script. The code is simply
 
  cat(Hello!\n)
 
  However, when I run
 
  $ R CMD BATCH myscript.R
 
  I do not see Hello! on the console. I am using Fedora 7 (Linux) and
  R-2.5.1.
 
  Any ideas?
 
  Thanks in advance,
 
  Paul
 




 --
 View this message in context: 
 http://www.nabble.com/R-CMD-BATCH%3A-cat-does-not-print-tf4353572.html#a12405494
 Sent from the R help mailing list archive at Nabble.com.

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


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


Re: [R] Simple Graph

2007-08-30 Thread Jim Lemon
amna khan wrote:
 Hi Sir
 
 We use the function mpg() for ticks on axes. If we define more number of
 ticks then each tick is not labeled. How to label each tick on axes?

Hi Amina,
The staxlab function in the plotrix package will display tick labels 
even if they would overlap on the standard axis display.

Jim

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


Re: [R] piecewise linear approximation

2007-08-30 Thread roger koenker
If you want to minimize absolute error for this, then you can
try the rqss fitting in the quantreg package and tune lambda
to get one break in the fitted function.


url:www.econ.uiuc.edu/~rogerRoger Koenker
email[EMAIL PROTECTED]Department of Economics
vox: 217-333-4558University of Illinois
fax:   217-244-6678Champaign, IL 61820


On Aug 29, 2007, at 8:05 PM, Achim Zeileis wrote:

 On Wed, 29 Aug 2007, Naxerova, Kamila wrote:

 Dear list,

 I have a series of data points which I want to approximate with  
 exactly two
 linear functions. I would like to choose the intervals so that the  
 total
 deviation from my fitted lines is minimal. How do I best do this?

 From the information you give it seems that you want to partition  
 a model
 like
lm(y ~ x)
 along a certain ordering of the observations. Without any further
 restrictions you can do that with the function breakpoints() in  
 package
 strucchange. If there are continuity restrictions or something like
 that, you want to look at the segmented package.

 hth,
 Z

 Thanks!
 Kamila


 The information transmitted in this electronic communication... 
 {{dropped}}

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



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

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


[R] Assigning line colors in xyplot

2007-08-30 Thread Christof Bigler
Hi,

I have a dataframe containing data from individuals 1, ..., 12 (grouping 
variable g in the data frame below), which belong either to A or B 
(grouping variable f):

set.seed(1)

tmp - data.frame(
  
y=c(rnorm(10,0,1),rnorm(10,4,2),rnorm(10,0,1),rnorm(10,4,2),rnorm(10,0,1),rnorm(10,4,2),rnorm(10,0,1),rnorm(10,4,2),rnorm(10,0,1),rnorm(10,4,2),rnorm(10,0,1),rnorm(10,4,2)),
  x=1:10,
  
f=c(rep(A,10),rep(B,10),rep(A,10),rep(B,10),rep(A,10),rep(B,10),rep(A,10),rep(B,10),rep(A,10),rep(B,10),rep(A,10),rep(B,10)),
  
g=c(rep(3,10),rep(2,10),rep(1,10),rep(4,10),rep(5,10),rep(6,10),rep(8,10),rep(7,10),rep(9,10),rep(11,10),rep(12,10),rep(10,10)))


I would like to draw line plots using the function xyplot:

library(lattice)

xyplot(y ~ x | g , groups=g, data=tmp,type=l,
  par.settings=list(superpose.line=list(col=c(red,blue))),
  auto.key=list(space=top, 
text=levels(tmp$f),points=FALSE,lines=TRUE))

As it is, the colors are recycled alternately in the order the 
individuals appear in the plot (1, 10, 11, 12, 2, ..., 9).

How can I assign the red color to all individuals of group A and the 
blue color to all individuals of group B?

Thanks in advance!

Christof

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


Re: [R] Converting into time series object

2007-08-30 Thread Henrique Dallazuanna
You can use the 'ts' function.

Example

df - ts(your_data_frame,
   start=c(1990,1), #The initial date of your data
   end=c(2000,12), #The final date of your data or
   frequency=12)#The frequency of your data, so you don't need of
the 'end' argument

See ?ts and ?as.ts for more.

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

On 29/08/2007, Shubha Vishwanath Karanth [EMAIL PROTECTED] wrote:

 Hi,



 I have a dataframe of trading dates along with the corresponding prices.
 I need to convert this into a time series object. How do I do this with
 my price values being the time series object and the dates/time being
 the trading dates.





 BR, Shubha


 [[alternative HTML version deleted]]

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


[[alternative HTML version deleted]]

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


Re: [R] Q: Mean, median and confidence intervals with functions summary boxplot.stats

2007-08-30 Thread S Ellison
If you look at ?boxplot.stats, you will find that the confidence interval it 
reports is centred on the median and : 
The notches (if requested) extend to '+/-1.58 IQR/sqrt(n)'.

If you have skewed data it is very possible (as you have found) that the mean 
is outside median+/-1.58 IQR/sqrt(n). 

All that is happening is that the majority of the data are around 1 or 2  and 
you have a substantial number near zero. Result: mean much lower than median. 
And with a high n, the boxplot notch is very narrow and excludes the mean.

But it does sound very much as if you are doing something questionable at best. 
I would not trust IQR as a dispersion measure on discrete data with few 
possible values even if they were on an interval scale; too much risk of 
getting the same IQR for many different distributions. On an ordinal scale it 
is worse; the only points that are valid at all are the valid scale values, so 
a CI that uses intermediate values is formally meaningless (what is a shoe size 
of 7.2, for example? Answer: Not a shoe size at all). It is of course entirely 
meaningless to talk about an IQR on a categorical scale.

It sounds like boxplot.stats is an inappropriate tool for summarising your data.

 Tom Willems [EMAIL PROTECTED] 30/08/2007 10:00:50 
Dear R ussers,

My question is,  How can my mean be outside the confidence intervals ?!

I think i have the answer for it, but i would like to hear some other 
ideas on it.

First my data is not continuose but categorical, it is a titre calculated 
on a dilution serie.
It is stored as a column of values, and a column indicating the phase of 
the trail.
Theoreticaly it is possible to have a value ranging from 0 to 4, but in 
practice, only sertain values will occure, and they will repeat.
So it are frequencies.

This is why i belief that it is better to work with a median than with a 
mean, because it represents the cluster of values wich occure most.
Below I only give one example, but the mean being below the lowest 
confidence limit occures several times over different tests.

does my answer seam reasonable, or should i perhapes use an other methode, 
any sugestion?

summary_1d  = summary(subset(eda_data,  phase=='1'  test=='test 
1' ,select=lg_value), na.rm = T)
conf_1d  = boxplot.stats(subset(eda_data,  phase=='1'  
test=='test 1' ,select=lg_value))

MeanMedian 95% Confidence Int. StDev.  
Variance
1.1981.681   1.4411.922 0.931
   0.866

Kind regards,
Tom W.


Disclaimer: click here
[[alternative HTML version deleted]]

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

***
This email and any attachments are confidential. Any use, co...{{dropped}}

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


Re: [R] Excel (off-topic, sort of)

2007-08-30 Thread f.jamitzky

Try prolog. You can do this sort of programming there.




Albicelli, Nicholas (Exchange) wrote:
 
 Except for the ability to perform circular recalculation, I believe that
 the closest programming analogy to a spreadsheet is a functional
 programming language.  Check out Haskell (or LISP or Erlang) to do what
 you describe.
 
 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of François Pinard
 Sent: Wednesday, August 29, 2007 11:36 AM
 To: Alberto Monteiro
 Cc: r-help@stat.math.ethz.ch
 Subject: Re: [R] Excel (off-topic, sort of)
 
 [Alberto Monteiro]
 
 Maybe I'll write a letter to Santa Claus [there are people
 who write to congressman; they must have more faith than me].
 
 :-) :-)
 
 I wish a language where I can write
 
  a = b + 10
 
 and then when I write
 
  a = 20
 
 the language automatically assigns b = 10.
 
 METAFONT does this (and consequently, Metapost as well).  I still 
 remember my surprise when I found out that Donald Knuth resorts to such 
 sophisticated machinery for the sole purpose of designing font 
 characters.  Knuth surely did many wonderful things :-).
 
 -- 
 François Pinard   http://pinard.progiciels-bpi.ca
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 
 
 ***
 Bear Stearns is not responsible for any recommendation, soli...{{dropped}}
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
View this message in context: 
http://www.nabble.com/Excel-tf4339367.html#a12406252
Sent from the R help mailing list archive at Nabble.com.

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


[R] boxplot will remember the factor levels

2007-08-30 Thread Luis Ridao Cruz
R-help,

I'm trying to do a simple box-and-whisker plot to some data.
The data are a subset of a large data frame
but when running the boxplot function on the subset data
all the factors are still present in the graph leaving a huge
empty space until the actuals factors are shown.
This produces a spurious box-and-whisker plot.

If the subset data are exported to another R session the problem is
gone.
Why are the factors still remembered by the boxplot?

Attached is a copy of the data.


Thanks in advance


## the line code
boxplot(mLength ~ puntar,data=test)

 version
   _   
platform   i386-pc-mingw32 
arch   i386
os mingw32 
system i386, mingw32   
status 
major  2   
minor  5.1 
year   2007
month  06  
day27  
svn rev42083   
language   R   
version.string R version 2.5.1 (2007-06-27)
 

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


Re: [R] R CMD BATCH: cat does not print

2007-08-30 Thread Barry Rowlingson
Paul Smith wrote:

 Thanks, Barry. Indeed, the file myscript.Rout exists and contains the
 output of cat. I was expecting a behavior similar to the bash scripts.
 And by the way, cannot a R script write only on the console and just
 what one tells it to write, likewise bash scripts?

  Not easily, I think. The 'BATCH' command is really intended for 
long-running or off-line jobs that may be disconnected from a terminal.


Barry

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


[R] How to mask or escape =

2007-08-30 Thread Vladimir Eremeev


-- 
View this message in context: 
http://www.nabble.com/How-to-mask-or-escape-%22%3D%22-tf4354174.html#a12406926
Sent from the R help mailing list archive at Nabble.com.

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


[R] How to mask or escape = in Windows command prompt?

2007-08-30 Thread Vladimir Eremeev

I have defined a function with several arguments and have it stored in the
.RData file.

The 'function head' is defined as follows
EstimALIConc
-function(sdname,SZ,W,farea,watri,biomodel,start.part=1,nparts=20,method=c(optim,DEoptim))
{
  [ blah-blah-blah ]
  (function body doesn't matter)
}

Then I call Rscript:

e: rscript --restore -e
EstimALIConc('17-aug',27.8,5,1,watri,biomodel,1,100,method='DEoptim');warnings();
117-aug-log.txt 217-aug.err

and get the error in the 17-aug.err:
Error in -args : invalid argument to unary operator
Execution halted

If I remove method= from the function call, then everything works fine,
and function executes.

e: rscript --restore -e
EstimALIConc('17-aug',27.8,5,1,watri,biomodel,1,100,'DEoptim');warnings();
117-aug-log.txt 217-aug.err

The problem seems to be that the equality sign acts as a separator.
How to avoid this?
This would allow skiping of the default arguments, for example start.part
-- 
View this message in context: 
http://www.nabble.com/How-to-mask-or-escape-%22%3D%22-in-Windows-command-prompt--tf4354195.html#a12407015
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] boxplot will remember the factor levels

2007-08-30 Thread Henrique Dallazuanna
Try:

boxplot(mLength ~ puntar[drop=T],data=test)


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

On 30/08/2007, Luis Ridao Cruz [EMAIL PROTECTED] wrote:

 R-help,

 I'm trying to do a simple box-and-whisker plot to some data.
 The data are a subset of a large data frame
 but when running the boxplot function on the subset data
 all the factors are still present in the graph leaving a huge
 empty space until the actuals factors are shown.
 This produces a spurious box-and-whisker plot.

 If the subset data are exported to another R session the problem is
 gone.
 Why are the factors still remembered by the boxplot?

 Attached is a copy of the data.


 Thanks in advance


 ## the line code
 boxplot(mLength ~ puntar,data=test)

  version
_
 platform   i386-pc-mingw32
 arch   i386
 os mingw32
 system i386, mingw32
 status
 major  2
 minor  5.1
 year   2007
 month  06
 day27
 svn rev42083
 language   R
 version.string R version 2.5.1 (2007-06-27)
 


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



[[alternative HTML version deleted]]

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


Re: [R] xeon processor and ATLAS

2007-08-30 Thread Jeffrey J. Hallman
hui xie [EMAIL PROTECTED] writes:

 The reason why I would like to use ATLAS is that R FAQ said :
 
 The savings can be appreciable: on a 2.6GHz P4 and a 1000 x 1000 matrix svd 
 took 16.2 sec with the standard BLAS and 7.8 sec with ATLAS.  Because ATLAS 
 is tuned to a particular chip we can't use it generally: the optimal routines 
 for a P4 or an Athlon XP are quite different and neither will run at all on a 
 PII.
 
 This seems to me an impressive gain to use the correct ATLAS instead of the
 default BLAS. 

I've been doing econometrics for nearly 20 years, and have not yet run across
a situation that called for looking at a 1000 x 1000 matrix.  I tend not to
believe analyses with more than a dozen explanatory variables.  But I suppose
that you could run across a situation where a design matrix with hundreds of
columns actually made sense.  But does that really happen often enough that
saving 8 seconds of computation time is worth going through the ATLAS hassle?

-- 
Jeff

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


[R] Another issue with the Matrix package.

2007-08-30 Thread Tony Chiang
Hi all,

I am encountering a strange issue with the Matrix package. I have just built
R-devel from source on my macbook pro, and I wonder if others can reproduce
this problem. I will give example code to go along:

Starting a fresh R session:

R version 2.6.0 Under development (unstable) (2007-08-30 r42697)
Copyright (C) 2007 The R Foundation for Statistical Computing
ISBN 3-900051-07-0

...

 log(2)
[1] 0.6931472
 library(Matrix)
Loading required package: lattice
 log(2)
Error in log(2) :
  could not find symbol base in environment of the generic function

There seems to be something wrong here and I cannot figure out what it is.
Am I doing something wrong or is it an issue with Matrix (which is what I
have narrowed it down to). I think that it might be a namespace collision or
something, but I am certainly not sure.

Here is my sessionInfo() output:
 sessionInfo()
R version 2.6.0 Under development (unstable) (2007-08-30 r42697)
i386-apple-darwin8.10.1

locale:
C

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

other attached packages:
[1] Matrix_0.99875-2 lattice_0.16-3

loaded via a namespace (and not attached):
[1] grid_2.6.0

Thanks.

Tony

[[alternative HTML version deleted]]

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


[R] categorical variable coefficients in QSAR

2007-08-30 Thread rlittle
Dear list:
I am interested in the following sort of problem, as is found frequently
in the field of QSAR. I have biological activity as a function of chemical
structure, with structure defined in a categorical manner in that the
SUBSTITUENT is the levels of the POSITION factor. For example, data from
Kubinyi (http://www.kubinyi.de/dd-12.pdf) for this type of analysis is
presented as follows:
factor para:
H
F
Cl
Br
I
Me
H
H
H
H
H
F
F
F
Cl
Cl
Cl
Br
Br
Br
Me
Me
factor meta:
H
H
H
H
H
H
F
Cl
Br
I
Me
Cl
Br
Me
Cl
Br
Me
Cl
Br
Me
Me
Br
observed biological activity:
7.46
8.16
8.68
8.89
9.25
9.30
7.52
8.16
8.30
8.40
8.46
8.19
8.57
8.82
8.89
8.92
8.96
9.00
9.35
9.22
9.30
9.52

I then think the following analysis should be appropriate


meta-factor(scan(file=meta,what=character))
para-factor(scan(file=para,what=character))
ba-scan(file=ba)

rslt-lm(ba~meta+para-1)

What I wish to obtain is a coefficient for each substituent at each
position, as does Kubinyi:

H F Cl Br I Me
meta 0.00 -0.30 0.21 0.43 0.58 0.45
para 0.00 0.34 0.77 1.02 1.43 1.26


However, I do not get a coefficient for the Br substituent at the para
position. I would like to know if there is an error in this formulation.
The technique is quite well established in the field of medicinal
chemistry and it is traditional that the binary incidence matrix is formed
by hand as an intermediate step in the analysis, instead of the much
simpler formulation that I am considering here.

Thank you for whatever insight you may give.

Prof. Roy Little
Dept. Chem.
Universidad de los Andes
Mérida, Venezuela

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


[R] categorical variable coefficients in QSAR

2007-08-30 Thread rlittle
Dear list:
I am interested in the following sort of problem, as is found frequently
in the field of QSAR. I have biological activity as a function of chemical
structure, with structure defined in a categorical manner in that the
SUBSTITUENT is the levels of the POSITION factor. For example, data from
Kubinyi (http://www.kubinyi.de/dd-12.pdf) for this type of analysis is
presented as follows:
factor para:
H
F
Cl
Br
I
Me
H
H
H
H
H
F
F
F
Cl
Cl
Cl
Br
Br
Br
Me
Me
factor meta:
H
H
H
H
H
H
F
Cl
Br
I
Me
Cl
Br
Me
Cl
Br
Me
Cl
Br
Me
Me
Br
observed biological activity:
7.46
8.16
8.68
8.89
9.25
9.30
7.52
8.16
8.30
8.40
8.46
8.19
8.57
8.82
8.89
8.92
8.96
9.00
9.35
9.22
9.30
9.52

I then think the following analysis should be appropriate


meta-factor(scan(file=meta,what=character))
para-factor(scan(file=para,what=character))
ba-scan(file=ba)

rslt-lm(ba~meta+para-1)

What I wish to obtain is a coefficient for each substituent at each
position, as does Kubinyi:

H F Cl Br I Me
meta 0.00 -0.30 0.21 0.43 0.58 0.45
para 0.00 0.34 0.77 1.02 1.43 1.26


However, I do not get a coefficient for the Br substituent at the para
position. I would like to know if there is an error in this formulation.
The technique is quite well established in the field of medicinal
chemistry and it is traditional that the binary incidence matrix is formed
by hand as an intermediate step in the analysis, instead of the much
simpler formulation that I am considering here.

Thank you for whatever insight you may give.

Prof. Roy Little
Dept. Chem.
Universidad de los Andes
Mérida, Venezuela

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


[R] How to signal the end of the table?

2007-08-30 Thread Monica Pisica

Well, i am surprise you have problems to read a table that is small enough to 
be opened entirely in Excel. 
 
I work with csv tables with hundreds of thousands of rows, and sometimes even 
millions  with no problems except that sometimes i have to wait up to 1 or 
2 minutes for R to read the table. I use the command read.csv.
 
If your tables are always small enough to be read in Excel, the limit of number 
of rows in Excel is about 64000 or something of that sort (maybe 65000 ) so 
you can use this number as a limit for your number of rows  although you 
may have to clean-up your data.frame afterwards.
 
I work on a Windows machine with 4 Gb DRAM - just for comparison.
 
I hope this helps,
 
Monica
 
 
 
 
 

Message: 88Date: Wed, 29 Aug 2007 10:41:05 -0700From: Yuchen Luo [EMAIL 
PROTECTED]Subject: [R] How to signal the end of the table?To: 
r-help@stat.math.ethz.chMessage-ID:[EMAIL PROTECTED]Content-Type: 
text/plainI am using a for loop to read a table row by row and I have to 
specify howmany records are there in the table. I need to read row by row 
because thetable is huge and the memory not large enough for the whole 
table.:number.of.records=100fp=file(abc.csv,r)pos=seek(fp, 
rw=read)for (i in 1:number.of.record){current.row=scan(file=fp, sep=',', 
what=list(count=1, cusip6=, idate=1,spread=1.1, vol252=1.1, vol1000=1.1, 
st_debt=1.1, lt_debt=1.1 , total_liab=1.1, cr=1.1, shrout=1.1, prc=1.1, 
mkt_cap=1.1, rtng=1.1, sec=1.1, cr3m=1.1,cr5y=1.1, ust3m=1.1, ust5y=1.1), 
flush=TRUE, nlines=1,quiet=T)...}I need to know the number of records 
in the table and put it in the variablenamed nu!
 mber.of.records. When I have a new table that I do not know howmany records 
it has, I use excel to open the file to figure it out and putit in variable  
number.of.records. I often have many tables to try andevery one of them has 
thousands of recordsit takes a lot of time andtrouble to adjust the code 
every time I read a different table.I am wondering if I can change the 
for loop to a while loop:while (the end of the table has not been 
reached){current.row=scan(file=fp, sep=',', what=list(count=1, cusip6=, 
idate=1,spread=1.1, vol252=1.1, vol1000=1.1, st_debt=1.1, lt_debt=1.1 , 
total_liab=1.1, cr=1.1, shrout=1.1, prc=1.1, mkt_cap=1.1, rtng=1.1, sec=1.1, 
cr3m=1.1,cr5y=1.1, ust3m=1.1, ust5y=1.1), flush=TRUE, 
nlines=1,quiet=T)...}The problem is how to articulate while (the end of 
the table has not beenreached), or equivalently, how to signal the end of the 
table?Best WishesYuchen Luo [[alternative HTML version deleted]]
_
Discover the new Windows Vista

[[alternative HTML version deleted]]

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


Re: [R] Single plot multiple levels in x?

2007-08-30 Thread Richard Yanicky
Uwe,

I have looked into lattice and can't seem to make this work. I can easily make 
multiple panels but this isn't what I am looking to do. Any suggestions on 
which functions to use? the axis function seems a natural place to start but I 
still can't seem to make it happen.

HELP!


Richard 

-Original Message-
From: Uwe Ligges [EMAIL PROTECTED]
Sent: Aug 30, 2007 5:59 AM
To: Richard Yanicky [EMAIL PROTECTED]
Cc: r-help@stat.math.ethz.ch
Subject: Re: [R] Single plot multiple levels in x?



Richard Yanicky wrote:
 Plotting with 2 x axis?
 
 
 One axis inside another, for example salary within state,
 
 
 
 
 1-50 | 50 – 100 |  100+   |   1- 50 | 50 -100 | 100+ | …  repeated 
 bins for salary
AL   !   AR   
   ……  more states


Sounds like the lattice package does exactly what you want, but without 
any reproducible example.

Uwe Ligges



 
 The values are all stored with a single data frame. I have tried different 
 things with the axis function and done many searches for plotting. Can’t 
 find a direct reference 
 
 
 Thanks.
 
 Richard
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] Month end calculations

2007-08-30 Thread Jeff Ryan
Shubha,

I apologize if this is a bit late - consequence of digest summary preference.

If I understand what you need, it is to calculate the value at month
end given a data object. For zoo objects the following should do what
you need. Actually is part of my new package on CRAN quantmod -
basically a workflow management tool for quant finance modelling.
Also visible at www.quantmod.com

If you convert your data.frame to a zoo object (designed for ordered
obs. -  e.g. time-series)

# for your data - which I don't know : )
zoo.ts - zoo(youdataframe[,-1],as.Date(yourdataframe[,1]))

#^
  ^
#   ^ ^
^ ^
# minus 'date' column  the 'date'
column - in CCYY-MM-DD format


My example:

A zoo time series object consisting of 231 days:

 zoo.ts - zoo(rnorm(231),as.Date(13514:13744))
 start(zoo.ts)
[1] 2007-01-01
 end(zoo.ts)
[1] 2007-08-19

# these are the end points of each period
 breakpoints(zoo.ts,months,TRUE)
[1]   0  31  59  90 120 151 181 212 231

# get the associated values
 zoo.ts[breakpoints(zoo.ts,months,TRUE)]
  2007-01-31   2007-02-28   2007-03-31   2007-04-30   2007-05-31   2007-06-30
-0.008829668 -2.207802921  0.171705151 -1.820125167  1.776643162  0.884558259
  2007-07-31   2007-08-19
 0.655305543  0.191870144

You can also apply a function inside each of these periods (intervals)
with the function
period.apply:

e.g. the standard deviation of each period would be had with:

 period.apply(zoo.ts,breakpoints(zoo.ts,months,TRUE),FUN=sd)
[1] 0.9165168 1.2483743 1.0717529 1.2002236 0.9568443 0.8112068 0.8563814
[8] 0.8671502

The functions (and many others) are in quantmod - on CRAN and most up
to date at www.quantmod.com

For those who'd rather just have the functions:

breakpoints -
function (x, by = c(weekdays, weeks, months, quarters, years), ...)
{
if (length(by) != 1)
stop(choose ONE method for \by\)
by - match.fun(by)
breaks - which(diff(as.numeric(by(x, ...))) != 0)
breaks - c(0, breaks, NROW(x))
return(breaks)
}


period.apply -
function (x, INDEX, FUN, ...)
{
FUN - match.fun(FUN)
y - NULL
for (i in 1:(length(INDEX) - 1)) {
sindex - (INDEX[i] + 1):INDEX[i + 1]
dat - x[sindex]
y - c(y, FUN(dat, ...))
}
return(y)
}

Jeff Ryan

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


Re: [R] xeon processor and ATLAS

2007-08-30 Thread Dirk Eddelbuettel
On Thu, Aug 30, 2007 at 09:33:32AM -0400, Jeffrey J. Hallman wrote:
 saving 8 seconds of computation time is worth going through the ATLAS hassle?

For some of us, the 'hassle' is typing 

$ sudo apt-get install atlas3-base

which gives you the low-hanging fruit of basic Atlas. Locally
re-building the Debian/Ubuntu package to match _your_ cpu is also
supported ... but there I share the '80/20' rule sentiment that the
additional work is not always worth the additional effort.

But let's remind people that they have a choice.  

Dirk

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

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


Re: [R] retrieve p-value from a cox.obj

2007-08-30 Thread Terry Therneau
 
 Several responders have given input on how to find and read the code for
summary.coxph and print.coxph, or using str() to examine the output of a 
coxph object.

  An even better starting place would be the documentation (yes there is some).
  
help(coxph) gives a page that contains:

  Value:  an object of class coxph.  See 'coxph.object' for details.
  
and help(coxph.object) gives a description of all the components.

Terry Therneau

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


Re: [R] Another issue with the Matrix package *under R-devel*

2007-08-30 Thread Prof Brian Ripley
I suspect you have not using a re-installed Matrix after re-building R.
I can reproduce the problem using a version of Matrix I installed under 
2.5.1, but not with one installed under R-devel this week.

Since R-devel is 'Under development' you may need to reinstall packages 
when it changes.  This is particularly prevalent with S4-using packages, 
as the methods code tends to capture the value of objects as they existed 
when a package was installed.  In this case log() was changed quite a few 
weeks ago, but Matrix needs to be reinstalled after other changes last 
weekend.

For the record, the packages I know need to reinstalled under a recent 
R-devel are Matrix, distr, kernlab, kinship and matlab (but there may be 
others).

And please use the appropriately named R-devel list for questions about 
R-devel.


On Thu, 30 Aug 2007, Tony Chiang wrote:

 Hi all,

 I am encountering a strange issue with the Matrix package. I have just built
 R-devel from source on my macbook pro, and I wonder if others can reproduce
 this problem. I will give example code to go along:

 Starting a fresh R session:

 R version 2.6.0 Under development (unstable) (2007-08-30 r42697)
 Copyright (C) 2007 The R Foundation for Statistical Computing
 ISBN 3-900051-07-0

 ...

 log(2)
 [1] 0.6931472
 library(Matrix)
 Loading required package: lattice
 log(2)
 Error in log(2) :
  could not find symbol base in environment of the generic function

 There seems to be something wrong here and I cannot figure out what it is.
 Am I doing something wrong or is it an issue with Matrix (which is what I
 have narrowed it down to). I think that it might be a namespace collision or
 something, but I am certainly not sure.

 Here is my sessionInfo() output:
 sessionInfo()
 R version 2.6.0 Under development (unstable) (2007-08-30 r42697)
 i386-apple-darwin8.10.1

 locale:
 C

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

 other attached packages:
 [1] Matrix_0.99875-2 lattice_0.16-3

 loaded via a namespace (and not attached):
 [1] grid_2.6.0

 Thanks.

 Tony

   [[alternative HTML version deleted]]

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


-- 
Brian D. Ripley,  [EMAIL PROTECTED]
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@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] How to signal the end of the table?

2007-08-30 Thread Vladimir Eremeev

For example,

fp-file(abc.csv,r)
c.row-scan(file=fp,sep=,,nlines=1) # what argument is omitted for
bevity as it doesn't matter
rows-c.row

while(length(c.row)0) {
   c.row-scan(file=fp,sep=;,nlines=1); 
   rows-rbind(rows,c.row)
}
close(fp)

If you want to read a file by parts, then you do something like the
following (untested)
But this looks like a C-style approach, not R-style

fp-file(abc.csv,r)
lines.skip-0
for(i in 1:nparts){
  c.row-scan(file=fp,sep=,,nlines=1,skip=lines.skip) 
  lines.read-1
  rows-c.row

  while(length(c.row)0  lines.readpart.size) {
 c.row-scan(file=fp,sep=;,nlines=1); # nlines can be also 1
 rows-rbind(rows,c.row)
 lines.read-lines.read+1  # if nlines above is 1 then +1 must be
replaced with nlines value
  }
  lines.skip-lines.read

# do operations with rows
}
close(fp)



Yuchen Luo wrote:
 
 I am using a for loop to read a table row by row and I have to specify
 how
 many records are there in the table. I need to read row by row because the
 table is huge and the memory not large enough for the whole table.:
 
 
 
 number.of.records=100
 
 
 
 fp=file(abc.csv,r)
 
 pos=seek(fp, rw=read)
 
 for (i in 1:number.of.record){
 
 current.row=scan(file=fp, sep=',', what=list(count=1, cusip6=, idate=1,
 spread=1.1, vol252=1.1, vol1000=1.1, st_debt=1.1, lt_debt=1.1 ,
 total_liab=
 1.1, cr=1.1,   shrout=1.1, prc=1.1, mkt_cap=1.1, rtng=1.1, sec=1.1,
 cr3m=1.1,
 cr5y=1.1, ust3m=1.1,  ust5y=1.1), flush=TRUE, nlines=1,quiet=T)
 
 ...
 
 }
 
 
 
 I need to know the number of records in the table and put it in the
 variable
 named number.of.records. When I have a new table that I do not know how
 many records it has, I use excel to open the file to figure it out and put
 it in variable  number.of.records. I often have many tables to try and
 every one of them has thousands of recordsit takes a lot of time and
 trouble to adjust the code every time I read a different table.
 
 
 
 I am wondering if I can change the for loop to a while loop:
 
 
 
 while (the end of the table has not been reached)
 
 {
 
 current.row=scan(file=fp, sep=',', what=list(count=1, cusip6=, idate=1,
 spread=1.1, vol252=1.1, vol1000=1.1, st_debt=1.1, lt_debt=1.1 ,
 total_liab=
 1.1, cr=1.1,   shrout=1.1, prc=1.1, mkt_cap=1.1, rtng=1.1, sec=1.1,
 cr3m=1.1,
 cr5y=1.1, ust3m=1.1,  ust5y=1.1), flush=TRUE, nlines=1,quiet=T)
 
 ...
 
 }
 
 
 The problem is how to articulate while (the end of the table has not been
 reached), or equivalently, how to signal the end of the table?
 
 Best Wishes
 Yuchen Luo
 
 

-- 
View this message in context: 
http://www.nabble.com/How-to-signal-the-end-of-the-table--tf4353030.html#a12408586
Sent from the R help mailing list archive at Nabble.com.

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


[R] Behaviour of very large numbers

2007-08-30 Thread willem vervoort
Dear all,
I am struggling to understand this.

What happens when you raise a negative value to a power and the result
is a very large number?

 B
[1] 47.73092

 -51^B
[1] -3.190824e+81

# seems fine
# now this:
 x - seq(-51,-49,length=100)

 x^B
  [1] NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN snip
 is.numeric(x^B)
[1] TRUE
 is.real(x^B)
[1] TRUE
 is.infinite(x^B)
  [1] FALSE FALSE FALSE FALSE FALSE

I am lost, I checked the R mailing help, but could not find anything
directly. I loaded package Brobdingnag and tried:
as.brob(x^B)
  [1] NAexp(NaN) NAexp(NaN) NAexp(NaN) NAexp(NaN) NAexp(NaN)
 as.brob(x)^B
  [1] NAexp(187.67) NAexp(187.65) NAexp(187.63) NAexp(187.61)

I guess I must be misunderstanding something fundamental.

Any clues would be really appreciated.
Willem

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


[R] R and Web Applications

2007-08-30 Thread Chris Parkin
Hello,

I'm curious to know how people are calling R from web applications (I've
been looking for Perl but I'm open to other languages).  After doing a
search, I came across the R package RSPerl, but I'm having difficulties
getting it installed (on Mac OSX).  I believe the problem probably has to do
with changes in R since the package release.  Below you will see where the
installation process comes to an end.  Does anyone have any suggestions, or
perhaps a direction to point me in?

Thanks in advance for your insight!

Chris

* Installing to library '/Library/Frameworks/R.framework/Resources/library'
* Installing *source* package 'RSPerl' ...
checking for perl... /usr/bin/perl
No support for any of the Perl modules from calling Perl from R.
*

   Set PERL5LIB to
/Library/Frameworks/R.framework/Versions/2.5/Resources/library/RSPerl/perl

*
Testing: -F/Library/Frameworks/R.framework/.. -framework R
Using '/usr/bin/perl' as the perl executable
Perl modules (no):
Adding R package to list of Perl modules to enable callbacks to R from Perl
Creating the C code for dynamically loading modules with native code for
Perl:  R
modules:   R; linking:
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
Support R in Perl: yes
configure: creating ./config.status
config.status: creating src/Makevars
config.status: creating inst/scripts/RSPerl.csh
config.status: creating inst/scripts/RSPerl.bsh
config.status: creating src/RinPerlMakefile
config.status: creating src/Makefile.PL
config.status: creating cleanup
config.status: creating src/R.pm
config.status: creating R/perl5lib.R
making target all in RinPerlMakefile
RinPerlMakefile:5: /Library/Frameworks/R.framework/Resources/etc/Makeconf:
No such file or directory
make: *** No rule to make target
`/Library/Frameworks/R.framework/Resources/etc/Makeconf'.  Stop.

[[alternative HTML version deleted]]

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


Re: [R] correlation structure in lmer

2007-08-30 Thread Douglas Bates
On 8/29/07, Fränzi Korner [EMAIL PROTECTED] wrote:

 how can I specify a correlation structure in the lmer-function as it is
 possible in lme(formula, ..., corr=corAR1(form=...))?

The short answer is you can't.

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


Re: [R] Assigning line colors in xyplot

2007-08-30 Thread hadley wickham
Hi Christof,

You can do this in ggplot, with one exception:

install.packages(ggplot2)
library(ggplot2)
qplot(x, y, data=tmp, facets = . ~ g, geom=line, colour=f)

Unfortunately I don't yet have an implementation of facetting that
works like lattice, wrapping the line of plots in to 2d dimensions.

You can find out more about ggplot2 at http://had.co.nz/ggplot2

Hadley

On 8/30/07, Christof Bigler [EMAIL PROTECTED] wrote:
 Hi,

 I have a dataframe containing data from individuals 1, ..., 12 (grouping
 variable g in the data frame below), which belong either to A or B
 (grouping variable f):

 set.seed(1)

 tmp - data.frame(

 y=c(rnorm(10,0,1),rnorm(10,4,2),rnorm(10,0,1),rnorm(10,4,2),rnorm(10,0,1),rnorm(10,4,2),rnorm(10,0,1),rnorm(10,4,2),rnorm(10,0,1),rnorm(10,4,2),rnorm(10,0,1),rnorm(10,4,2)),
   x=1:10,

 f=c(rep(A,10),rep(B,10),rep(A,10),rep(B,10),rep(A,10),rep(B,10),rep(A,10),rep(B,10),rep(A,10),rep(B,10),rep(A,10),rep(B,10)),

 g=c(rep(3,10),rep(2,10),rep(1,10),rep(4,10),rep(5,10),rep(6,10),rep(8,10),rep(7,10),rep(9,10),rep(11,10),rep(12,10),rep(10,10)))


 I would like to draw line plots using the function xyplot:

 library(lattice)

 xyplot(y ~ x | g , groups=g, data=tmp,type=l,
   par.settings=list(superpose.line=list(col=c(red,blue))),
   auto.key=list(space=top,
 text=levels(tmp$f),points=FALSE,lines=TRUE))

 As it is, the colors are recycled alternately in the order the
 individuals appear in the plot (1, 10, 11, 12, 2, ..., 9).

 How can I assign the red color to all individuals of group A and the
 blue color to all individuals of group B?

 Thanks in advance!

 Christof

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



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

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


Re: [R] Excel (off-topic, sort of)

2007-08-30 Thread Thomas Lumley
On Wed, 29 Aug 2007, Alberto Monteiro wrote:

 Do you know what's in my wish list?

 I wish spreadsheets and computer languages had gone one
 step further.

 I mean, it's nice to define Cell X to be equal to
 Cell Y + 10, and then when we change Cell Y, magically we
 see Cell X change.

 But why can't it be the reverse? Why can't I change Cell X
 _and see the change in Cell Y_?


Well, most statistical calculations are data-reducing, ie, many-to-one.

I don't think you are likely to find a language where you can change the 
confidence limits for the sample mean and have the data change in 
response.


-thomas

Thomas Lumley   Assoc. Professor, Biostatistics
[EMAIL PROTECTED]   University of Washington, Seattle

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


[R] mtext, picking subscript text from colnames(df)

2007-08-30 Thread Tord Snäll
Hi!
Could someone give advise on how to plot Greek letters where subscript 
text is picked from the names of a data.frame.
I want what appears using this code
mtext(expression(mu[Mountain]),side=2,at=max(y)-7,las=1,cex=1.5)

but I would like to do it using something like this:
mtext(expression(mu[colnames(PresEsts)[2]]),side=2,at=max(y)-15,las=1)

BTW,
colnames(PresEsts)[2]
[1] Mountain

Thanks!

/Tord

-- 

Tord Snäll
Department of Ecology
Swedish University of Agricultural Sciences (SLU)
P.O. 7002, SE-750 07 Uppsala, Sweden
Office/Mobile/Fax
+46-18-672612/+46-730-891356/+46-18-673537
E-mail: [EMAIL PROTECTED]
www.nvb.slu.se/staff_tordsnall

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


Re: [R] Month end calculations

2007-08-30 Thread Jeff Ryan
Shubha et al,

I forgot that the period methods may not work without the full
package.  So either just download the current CRAN version 0.1-0 or
version 0.1-3 from quantmod.com, a new more complete version will be
up with a week or two.

For completeness here is my months method for zoo objects:

 quantmod:::months.zoo
function (x, abbreviate = FALSE)
{
format(index(x), ifelse(abbreviate, %m, %B))
}
environment: namespace:quantmod

The primary difference is that abbreviate=TRUE will return the month
NUMBER, not the standard English abbreviation.  For the other methods
it is probably wiser to install the package as opposed to my obviously
deficient copy and paste method.

Thanks,
Jeff Ryan

On 8/30/07, Jeff Ryan [EMAIL PROTECTED] wrote:
 Shubha,

 I apologize if this is a bit late - consequence of digest summary preference.

 If I understand what you need, it is to calculate the value at month
 end given a data object. For zoo objects the following should do what
 you need. Actually is part of my new package on CRAN quantmod -
 basically a workflow management tool for quant finance modelling.
 Also visible at www.quantmod.com

 If you convert your data.frame to a zoo object (designed for ordered
 obs. -  e.g. time-series)

 # for your data - which I don't know : )
 zoo.ts - zoo(youdataframe[,-1],as.Date(yourdataframe[,1]))

 #^
   ^
 #   ^ ^
 ^ ^
 # minus 'date' column  the 'date'
 column - in CCYY-MM-DD format


 My example:

 A zoo time series object consisting of 231 days:

  zoo.ts - zoo(rnorm(231),as.Date(13514:13744))
  start(zoo.ts)
 [1] 2007-01-01
  end(zoo.ts)
 [1] 2007-08-19

 # these are the end points of each period
  breakpoints(zoo.ts,months,TRUE)
 [1]   0  31  59  90 120 151 181 212 231

 # get the associated values
  zoo.ts[breakpoints(zoo.ts,months,TRUE)]
   2007-01-31   2007-02-28   2007-03-31   2007-04-30   2007-05-31   2007-06-30
 -0.008829668 -2.207802921  0.171705151 -1.820125167  1.776643162  0.884558259
   2007-07-31   2007-08-19
  0.655305543  0.191870144

 You can also apply a function inside each of these periods (intervals)
 with the function
 period.apply:

 e.g. the standard deviation of each period would be had with:

  period.apply(zoo.ts,breakpoints(zoo.ts,months,TRUE),FUN=sd)
 [1] 0.9165168 1.2483743 1.0717529 1.2002236 0.9568443 0.8112068 0.8563814
 [8] 0.8671502

 The functions (and many others) are in quantmod - on CRAN and most up
 to date at www.quantmod.com

 For those who'd rather just have the functions:

 breakpoints -
 function (x, by = c(weekdays, weeks, months, quarters, years), ...)
 {
 if (length(by) != 1)
 stop(choose ONE method for \by\)
 by - match.fun(by)
 breaks - which(diff(as.numeric(by(x, ...))) != 0)
 breaks - c(0, breaks, NROW(x))
 return(breaks)
 }


 period.apply -
 function (x, INDEX, FUN, ...)
 {
 FUN - match.fun(FUN)
 y - NULL
 for (i in 1:(length(INDEX) - 1)) {
 sindex - (INDEX[i] + 1):INDEX[i + 1]
 dat - x[sindex]
 y - c(y, FUN(dat, ...))
 }
 return(y)
 }

 Jeff Ryan


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


Re: [R] xeon processor and ATLAS

2007-08-30 Thread Douglas Bates
On 8/29/07, hui xie [EMAIL PROTECTED] wrote:
 Thanks very much for all your advice. To be clear, my OS is window XP. I 
 bought this server last year. It's Dell Precision PWS690. THe processor is 
 Xeon(TM) CPU 3GHZ, 2G RAM. I am not sure how to check more details of 
 processor on my computer. But I went to Dell website and from what I can 
 recall, it seemed that I ordered a Dual-core Intel Xeon 5160 3GHz, 1333FSB, 
 4MB L2 Cache, 80watts.

 I think from time to time, I will need linear algebra to do things such as 
 Choleskey Factorization, and matrix inverse etc... At the same time, I 
 considered myself quite unskilled on building R by myself. It seems there 
 were lots of details that I can get things wrong. So if there is an existing 
 ATLAS one on R website that I can use, I would be very happy to use it to 
 replace the default one. The reason why I would like to use ATLAS is that R 
 FAQ said :

Rather than worrying about versions of ATLAS you may want to spend
your time considering exactly how you are going about the
calculations.  A general result in numerical linear algebra is that if
your algorithm involves computing the inverse of a matrix you have a
sub-optimal algorithm.

 The savings can be appreciable: on a 2.6GHz P4 and a 1000 x 1000 matrix svd 
 took 16.2 sec with the standard BLAS and 7.8 sec with ATLAS.  Because ATLAS 
 is tuned to a particular chip we can't use it generally: the optimal routines 
 for a P4 or an Athlon XP are quite different and neither will run at all on a 
 PII.

 This seems to me an impressive gain to use the correct ATLAS instead of the 
 default BLAS.  I guess my  Xeon processor is either a P4 or  Core2Duo, but I 
 am really not sure which one to use. Could you please offer me some 
 suggestions?

 Again, many thanks for all your advice!

 Best,

 Hui

 Uwe Ligges [EMAIL PROTECTED] wrote:

 Prof Brian Ripley wrote:
  On Tue, 28 Aug 2007, hui xie wrote:
 
  hi everyone:
 
  I have a Dell Server that has a Xeon processor, and I would like to use
  the best ATLAS posted in the R website. I find that R has ATLAS for
  core2duo and P4. I am not sure which one of these two is best suited for
  Xeon processor, or is that neither of these two is good and I should
  stick with the default one that was installed originally?
 
  And your OS is?
 
  There are many different 'Xeon' processors with very different
  capabilities.

 ... the earlier similar to P4 and some similar to Core2Duo. You won't
 make use of bigger L2/L3 caches in Xeon processors.

   You really ought to build ATLAS for yourself if numerical
  linear algebra performance matters to you (and it makes little difference
  to most people: I think Uwe Ligges quoted 10% for testing all CRAN
  packages).


 Right, it depends on what you are really doing. If most time is spend in
 certain numerical matrix operations, ATLAS is your friend. In all other
 cases, it does not matter so much, as Brian cited correctly.

 Uwe Ligges


 
  Your advice is very much appreciated!
 
  Best,
 
  Hui
 
 
  -
  Park yourself in front of a world of choices in alternative vehicles.
 
   [[alternative HTML version deleted]]
 
  __
  R-help@stat.math.ethz.ch mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide 
  http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
  Please do!
 
 



 -

 [[alternative HTML version deleted]]

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


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


[R] t-test within tapply

2007-08-30 Thread Sonia Mehault
Hello,

 

My data are as following:

 

Data - data.frame(Ind=rep(1:3,c(10,10,10)),

   Replicate=rep(c(rep(a,5),rep(b,5)),3),

   EggSize=rep(rnorm(5,mean=10),6)

   ) 

attach(Data)

 

 

Using a t-test, I want to check if the mean egg sizes are significantly
different between replicates a and b for each individuals (ie. In that case,
3 outputs with 3 p-values).

I tried the following, but doesn't work: 

 

 

Fun - function(x,y) {

   print(t.test(x ~ y))

   }

 

tapply(EggSize,Ind,Fun(EggSize,Replicate)) 

 

 

What should I do?

Many thanks.


[[alternative HTML version deleted]]

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


Re: [R] Single plot multiple levels in x?

2007-08-30 Thread Uwe Ligges


Richard Yanicky wrote:
 Uwe,
 
 I have looked into lattice and can't seem to make this work. I can easily 
 make multiple panels but this isn't what I am looking to do. Any suggestions 
 on which functions to use? the axis function seems a natural place to start 
 but I still can't seem to make it happen.

If lattice is not what you want, I do not understand what you mean. Can 
you give a more elaborated example, please?

Uwe


 
 HELP!
 
 
 Richard 
 
 -Original Message-
 From: Uwe Ligges [EMAIL PROTECTED]
 Sent: Aug 30, 2007 5:59 AM
 To: Richard Yanicky [EMAIL PROTECTED]
 Cc: r-help@stat.math.ethz.ch
 Subject: Re: [R] Single plot multiple levels in x?



 Richard Yanicky wrote:
 Plotting with 2 x axis?


 One axis inside another, for example salary within state,




 1-50 | 50 – 100 |  100+   |   1- 50 | 50 -100 | 100+ | …  repeated 
 bins for salary
AL   !   AR  
……  more states

 Sounds like the lattice package does exactly what you want, but without 
 any reproducible example.

 Uwe Ligges



 The values are all stored with a single data frame. I have tried different 
 things with the axis function and done many searches for plotting. Can’t 
 find a direct reference 


 Thanks.

 Richard

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


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


Re: [R] Behaviour of very large numbers

2007-08-30 Thread Scionforbai
Hello,
it seems to be an R bug. It gives strange errors for non-integer exponents:

 version
platform   i686-redhat-linux-gnu
version.string R version 2.4.1 (2006-12-18)

 x^47.0
  [1] -1.802180e+80 -1.768932e+80 -1.736284e+80 -1.704227e+80
-1.672748e+80 [...]
 x^47.10
  [1] NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
NaN NaN [...]

 x[2]^b
[1] NaN

But:

 x[2]
[1] -50.9798
 -50.9798^b
[1] -3.131003e+81

So it is not a merely numerical problem. Maybe a bug in memory
allocation for vectors containing such big numbers?

Scion

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


[R] How to obtain intercept statistics in anova with within-subject factors?

2007-08-30 Thread Sid Kouider
Dear R users,
I am looking for an easy (i.e., direct) way of obtaining the F and p values
from the intercept in anovas with within-subject designs.
My data are from a psychophysics experiment where I am using d' (d-prime)
values obtained from 3 modalities of presentation in each subject. I would
like to know not only whether there is an effect of modality, but also
whether the main effect is significant (meaning that d'  0). 
I know that a t.test again the null mean would provide me with similar stats
on the main effect, but I would like to get those stats in an F form, for
consistency with the stats on the other factors of interest.

As far as I understand how R works, the function anova provides you with
such information but it is restricted to between-group analyses. For
within-subject designs, one has to use summary(aov) but stats on the
intercept are not included in the result of this function. I have pasted an
example below. As one can see, only the Sum of Sq and Mean Sq are given for
the main effect.

Thank you for any advice you can provide, 
-Sid

summary(aov(x~mod+Error(suj/(mod)), data=dp))

Error: suj  Df  Sum Sq Mean Sq F value Pr(F)
Residuals 10 19.5977  1.9598
Error: suj:mod
Df  Sum Sq Mean Sq F value  Pr(F)  mod
2  8.2475  4.1237  4.2955 0.02806 *
Residuals 20 19.2005  0.9600
---Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Error:
Within
Df Sum Sq Mean Sq F value Pr(F)Residuals 33 55.812   1.691

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


Re: [R] Excel

2007-08-30 Thread Duncan Murdoch
On 8/28/2007 3:16 AM, J Dougherty wrote:
 On Monday 27 August 2007 22:21, David Scott wrote:
 On Tue, 28 Aug 2007, Robert A LaBudde wrote:
  If you format the column as Text, you won't have this problem. By
  leaving the cells as General, you leave it up to Excel to guess at
  the correct interpretation.

 Not true actually. I had converted the column to Text because I saw the
 interpretation as a date in the .xls file. I saved the .csv file *after*
 the column had been converted to Text. Looking at the .csv file in a text
 editor, the entry is correct.

 I have just rechecked this.

 On reopening the .csv using Excel, the entry AUG2699 had been interpreted
 as a date, and was showing as Aug-99. Most bizarre is that the NHI value
 of AUG1838 has *not* been interpreted as a date.

 Actually, in Excel 2000, he's right.  What you have to is be sure of is that 
 the ' that denotes a text entry precedes EVERY entry that can be confused 
 with a date.  Selecting the entire column and setting the format to text 
 *before* data is entered does this.  It will also create an appropriate *.csv 
 file.  Excel is notable too because it will automatically convert date-like 
 entries as you type.  In a column of IDs or similar critical data, that 
 behaviour is really bad.  I have never tried the MS site, but I haven't been 
 able to find any entry about how to turn that particular automatic behaviour 
 off. 
 
 However, while I have not experimented extensively, as far as I have 
 experimented, OpenOffice spreadsheet does not behave this way.

I don't use Excel, but in OpenOffice 2.2.1 the ' is lost when a file is 
saved as .csv and reloaded.  So if I take care and enter

'November 15

in a cell, then save it, OO will change it to 11/15/2007 when I reload. 
  I can override this change by manually changing Standard format to 
Text *every time* I load the file.  There's a help index entry date 
formats;avoiding conversion to, but it offers no more help than add an 
apostrophe at the beginning of the entry.

This is brain-dead behaviour.

Duncan Murdoch


 
 JWDougherty
 
 PS, I quit using Excel for most important work after it returned a negative 
 variance on some data I was collecting descriptive statistics on.
 
 JWD
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] Incomplete output with `sn' library package

2007-08-30 Thread MANASI VYDYANATH
You have my sincere apologies for the incompleteness of my message.   
I have given the details below, including my dataset and my code.

I'm using R, version 2.5.0. My OS is a Mac, (version Tiger).

The sn package is Version 0.4-1

My code was as follows:

  mydata - read.table(url(http://www.statsci.org/data/oz/ 
ais.txt), header = T)
  attach(mydata)
  a - msn.fit(X = cbind(1,Ht,Wt), y = BMI, control = list(x.tol=1e-6))
  b - msn.mle(X=cbind(1,Ht,Wt), y=SSF)
  a
  b

My problem is that neither the a nor the b output gives me any  
standard errors - those should appear under $se. In both the  
regressions, this field is left blank with NA under it. I would  
appreciate some help on this matter - are the standard errors not  
supposed to appear here, or is there something else I should put into  
the inputs?

Thank you once again for your time,

Manasi



On Aug 30, 2007, at 5:47 AM, Uwe Ligges wrote:



 MANASI VYDYANATH wrote:
 Dear R users:
 I have a question regarding the output for two of the functions  
 in  the `sn' package, which deals with the mle fitting of skew  
 normal  curves to linear regressions. I'm using the examples and  
 the dataset  given as an example in the online documentation for  
 this package, for  the functions `msn.fit' and `msn.mle'. I'm  
 following the example code  in the documentation for these two  
 functions exactly.
 Part of the data output is supposed to be se, which gives the   
 standard errors of the estimated coefficients. This particular  
 value  comes out as being NA in the examples given, but there  
 are three  coefficients in each case and no numerical problems  
 about why the  standard errors cannot be calculated.
 Am I setting this program up right? Is there some other command I   
 should use (or an option I need to use) to get the output to  
 display  standard errors of the coefficients?

 We cannot know if you use it right, since you have not given any  
 details on

 OS, R version, sn version, and particularly a reproducible example.

 As each R-help message tells in the footer:

 PLEASE do read the posting guide http://www.R-project.org/posting- 
 guide.html
 and provide commented, minimal, self-contained, reproducible code.

 Uwe Ligges







 Thank you for your time in reading this question -
 Cordially,
 Manasi
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting- 
 guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] R and Web Applications

2007-08-30 Thread Gabor Grothendieck
The R packages and projects for the web and R are listed here:

 http://www.lmbe.seu.edu.cn/CRAN/doc/FAQ/R-FAQ.html#R-Web-Interfaces


On 8/30/07, Chris Parkin [EMAIL PROTECTED] wrote:
 Hello,

 I'm curious to know how people are calling R from web applications (I've
 been looking for Perl but I'm open to other languages).  After doing a
 search, I came across the R package RSPerl, but I'm having difficulties
 getting it installed (on Mac OSX).  I believe the problem probably has to do
 with changes in R since the package release.  Below you will see where the
 installation process comes to an end.  Does anyone have any suggestions, or
 perhaps a direction to point me in?

 Thanks in advance for your insight!

 Chris

 * Installing to library '/Library/Frameworks/R.framework/Resources/library'
 * Installing *source* package 'RSPerl' ...
 checking for perl... /usr/bin/perl
 No support for any of the Perl modules from calling Perl from R.
 *

   Set PERL5LIB to
 /Library/Frameworks/R.framework/Versions/2.5/Resources/library/RSPerl/perl

 *
 Testing: -F/Library/Frameworks/R.framework/.. -framework R
 Using '/usr/bin/perl' as the perl executable
 Perl modules (no):
 Adding R package to list of Perl modules to enable callbacks to R from Perl
 Creating the C code for dynamically loading modules with native code for
 Perl:  R
 modules:   R; linking:
 checking for gcc... gcc
 checking for C compiler default output file name... a.out
 checking whether the C compiler works... yes
 checking whether we are cross compiling... no
 checking for suffix of executables...
 checking for suffix of object files... o
 checking whether we are using the GNU C compiler... yes
 checking whether gcc accepts -g... yes
 checking for gcc option to accept ISO C89... none needed
 Support R in Perl: yes
 configure: creating ./config.status
 config.status: creating src/Makevars
 config.status: creating inst/scripts/RSPerl.csh
 config.status: creating inst/scripts/RSPerl.bsh
 config.status: creating src/RinPerlMakefile
 config.status: creating src/Makefile.PL
 config.status: creating cleanup
 config.status: creating src/R.pm
 config.status: creating R/perl5lib.R
 making target all in RinPerlMakefile
 RinPerlMakefile:5: /Library/Frameworks/R.framework/Resources/etc/Makeconf:
 No such file or directory
 make: *** No rule to make target
 `/Library/Frameworks/R.framework/Resources/etc/Makeconf'.  Stop.

[[alternative HTML version deleted]]

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


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


Re: [R] Behaviour of very large numbers

2007-08-30 Thread Duncan Murdoch
On 8/30/2007 11:08 AM, willem vervoort wrote:
 Dear all,
 I am struggling to understand this.
 
 What happens when you raise a negative value to a power and the result
 is a very large number?
 
  B
 [1] 47.73092
 
 -51^B
 [1] -3.190824e+81

You should be using parentheses.  You evaluated -(51^B), not (-51)^B. 
The latter gives NaN.
 
 # seems fine
 # now this:
 x - seq(-51,-49,length=100)
 
 x^B
   [1] NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 
 snip
 is.numeric(x^B)
 [1] TRUE
 is.real(x^B)
 [1] TRUE
 is.infinite(x^B)
   [1] FALSE FALSE FALSE FALSE FALSE
 
 I am lost, I checked the R mailing help, but could not find anything
 directly. I loaded package Brobdingnag and tried:
 as.brob(x^B)
   [1] NAexp(NaN) NAexp(NaN) NAexp(NaN) NAexp(NaN) NAexp(NaN)
 as.brob(x)^B
   [1] NAexp(187.67) NAexp(187.65) NAexp(187.63) NAexp(187.61)
 
 I guess I must be misunderstanding something fundamental.

Two things:  operator precedence (the ^ has higher precedence than the 
unary minus), and the mathematical definition of raising something to a 
fractional power.  The approach R takes to the latter is to define x^B 
to be exp(B * ln(x)), and ln(x) is undefined for negative x.

Duncan Murdoch

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


Re: [R] customizing the color and point shape for each line drawn using lattice's xyplot

2007-08-30 Thread Gen

Thank you for your suggestion. Unfortunately it does not appear to matter if
the data is subsetted before the xyplot command or within it.  The problem
remains. 

I was able to remove method 4 entirely from the key by using your suggestion
to subset the dataset “common,” and then creating a new variable to assign
labels for just this subset “common.without.Method4$method.not4.f”  The
resulting code was:

xyplot(MeanBxg ~ PercentVarExplained | bdg.f * bdx.f,
data=common.without.Method4, groups=method.not4.f, type=l,  auto.key=T)

This however leads to lack of continuity between plots, as when I exclude
methods 4 and 6 in my second plot, using the same approach, the color that
had corresponds to methods 7, 8 and 9 in plot one is automatically changed
in plot two.  The subsetting may work, so long as I can dictate line color
and symbol type in each plot. 



Ross Darnell wrote:
 
 Does this help
 
 common.without.Method4 - subset(common, Method!=4)
 xyplot(MeanBxg ~ PercentVarExplained | bdg.f * bdx.f,
 data=common.without.Method4,
 groups=Method.f, type=l,  auto.key=T)
 
 Ross Darnell
 
 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of Gen
 Sent: Thursday, 30 August 2007 2:51 PM
 To: r-help@stat.math.ethz.ch
 Subject: [R] customizing the color and point shape for each line drawn
 using lattice's xyplot
 
 
 Description of what I am trying to do:
 I am using the xyplot code below to plot the variable MeanBxg against
 the
 variable PercentVarExplained for all 9 possible combinations of
 variables
 bdg and bdx.  Within each of these 9 scenarios I am plotting a
 separate
 line for each of up to 9 different methods that I used to estimate the
 variable MeanBxg. These methods are identified by the numeric variable
 called Method.  Giving me one plot with 9 figures and each of the
 figures
 contains 9 lines. 
 
 My problem arises because I would like to repeat the creation of this
 plot 8
 times, in each instance only a subset (eg 6) of the 9 methods are used
 (a
 different subset each time). 
 
 What I can't figure out:
 I would like to learn how to specify the exact line color that
 corresponds
 to each method such that Method==1 will always be represented by the
 same
 color (in every plot that it appears in).  Where two methods that I used
 were of the same family of methods (say method==1 and method==2 made the
 same assumptions about the data)  I would like to, if possible,
 represent
 the two methods using the same color and distinguish them by the symbol
 used
 to represent points on the line. 
 
 My code as it currently stands:
 xyplot(MeanBxg ~ PercentVarExplained | bdg.f * bdx.f, data=common,
 groups=common$Method.f, type=l, subset= Method!=4, auto.key=T)
 
 As the code is, the default colors assigned are repeated causing
 different
 methods to be represented by the same color with no way to distinguish
 them
 (I have not succeeded in plotting lines and points simultaneously).  
 
 Side question: When I subset the data to particular methods, is there a
 way
 to remove the excluded methods from the key as well? (in my code
 Method is
 a numeric variable, and Method.f corresponds to the lengthy
 descriptions
 of each method for the purpose of the key)
 
 Thank you very much for your help. 
 Genevieve
 
 
 
 -- 
 View this message in context:
 http://www.nabble.com/customizing-the-color-and-point-shape-for-each-lin
 e-drawn-using-lattice%27s-xyplot-tf4351934.html#a12400517
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
View this message in context: 
http://www.nabble.com/customizing-the-color-and-point-shape-for-each-line-drawn-using-lattice%27s-xyplot-tf4351934.html#a12409939
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] R and Web Applications

2007-08-30 Thread Martin Morgan
Hi Chris --

RWebServices provides a way to expose R functionality as (SOAP-based)
web services.

http://bioconductor.org/packages/2.0/bioc/html/RWebServices.html

This might be more than you are looking for, and has not been tested
on MacOS (which seems to be your platform).

Martin

Chris Parkin [EMAIL PROTECTED] writes:

 Hello,

 I'm curious to know how people are calling R from web applications (I've
 been looking for Perl but I'm open to other languages).  After doing a
 search, I came across the R package RSPerl, but I'm having difficulties
 getting it installed (on Mac OSX).  I believe the problem probably has to do
 with changes in R since the package release.  Below you will see where the
 installation process comes to an end.  Does anyone have any suggestions, or
 perhaps a direction to point me in?

 Thanks in advance for your insight!

 Chris

 * Installing to library '/Library/Frameworks/R.framework/Resources/library'
 * Installing *source* package 'RSPerl' ...
 checking for perl... /usr/bin/perl
 No support for any of the Perl modules from calling Perl from R.
 *

Set PERL5LIB to
 /Library/Frameworks/R.framework/Versions/2.5/Resources/library/RSPerl/perl

 *
 Testing: -F/Library/Frameworks/R.framework/.. -framework R
 Using '/usr/bin/perl' as the perl executable
 Perl modules (no):
 Adding R package to list of Perl modules to enable callbacks to R from Perl
 Creating the C code for dynamically loading modules with native code for
 Perl:  R
 modules:   R; linking:
 checking for gcc... gcc
 checking for C compiler default output file name... a.out
 checking whether the C compiler works... yes
 checking whether we are cross compiling... no
 checking for suffix of executables...
 checking for suffix of object files... o
 checking whether we are using the GNU C compiler... yes
 checking whether gcc accepts -g... yes
 checking for gcc option to accept ISO C89... none needed
 Support R in Perl: yes
 configure: creating ./config.status
 config.status: creating src/Makevars
 config.status: creating inst/scripts/RSPerl.csh
 config.status: creating inst/scripts/RSPerl.bsh
 config.status: creating src/RinPerlMakefile
 config.status: creating src/Makefile.PL
 config.status: creating cleanup
 config.status: creating src/R.pm
 config.status: creating R/perl5lib.R
 making target all in RinPerlMakefile
 RinPerlMakefile:5: /Library/Frameworks/R.framework/Resources/etc/Makeconf:
 No such file or directory
 make: *** No rule to make target
 `/Library/Frameworks/R.framework/Resources/etc/Makeconf'.  Stop.

   [[alternative HTML version deleted]]

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

-- 
Martin Morgan
Bioconductor / Computational Biology
http://bioconductor.org

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


Re: [R] Q: how to interrupt long calculation?

2007-08-30 Thread D. R. Evans
Paul Smith said the following at 08/29/2007 04:32 PM :

 The instance of R running will be immediately killed and then you can
 start R again.

But then I would lose all the work. There must be some way to merely
interrupt the current calculation. Mustn't there?

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


Re: [R] correlation structure in lmer

2007-08-30 Thread Douglas Bates
On 8/30/07, Douglas Bates [EMAIL PROTECTED] wrote:
 On 8/29/07, Fränzi Korner [EMAIL PROTECTED] wrote:

  how can I specify a correlation structure in the lmer-function as it is
  possible in lme(formula, ..., corr=corAR1(form=...))?

 The short answer is you can't.

My response was incorrect.  I should have remembered the words of
Simon Yoda Bloomberg.  Of course you can do this but you will need
to write the code to implement it.

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


Re: [R] Behaviour of very large numbers

2007-08-30 Thread Gustaf Rydevik
On 8/30/07, Gustaf Rydevik [EMAIL PROTECTED] wrote:
 On 8/30/07, willem vervoort [EMAIL PROTECTED] wrote:
  Dear all,
  I am struggling to understand this.
 
  What happens when you raise a negative value to a power and the result
  is a very large number?
 
   B
  [1] 47.73092
 
   -51^B
  [1] -3.190824e+81
 
  # seems fine
  # now this:
   x - seq(-51,-49,length=100)
 
   x^B
[1] NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 
  snip
   is.numeric(x^B)
  [1] TRUE
   is.real(x^B)
  [1] TRUE
   is.infinite(x^B)
[1] FALSE FALSE FALSE FALSE FALSE
 
  I am lost, I checked the R mailing help, but could not find anything
  directly. I loaded package Brobdingnag and tried:
  as.brob(x^B)
[1] NAexp(NaN) NAexp(NaN) NAexp(NaN) NAexp(NaN) NAexp(NaN)
   as.brob(x)^B
[1] NAexp(187.67) NAexp(187.65) NAexp(187.63) NAexp(187.61)
 
  I guess I must be misunderstanding something fundamental.
 
  Any clues would be really appreciated.
  Willem
 

 non-integer exponents of non-positive values are not defined, thus the NaN.

  -1^2.5
 [1] -1
  (-1)^2.5
 [1] NaN
 

 Best,

 Gustaf


To modify, that is if you are working with reals.

 x
[1] -1
 x^(1/2)
[1] NaN
 class(x)-complex
 x^(1/2)
[1] 0+1i
 x--51
 x^47.7
[1] NaN
 class(x)-complex
 x^47.7
[1] 1.660795e+81-2.285889e+81i



Best,

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

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


Re: [R] Excel (off-topic, sort of)

2007-08-30 Thread Duncan Murdoch
On 8/30/2007 10:43 AM, Thomas Lumley wrote:
 On Wed, 29 Aug 2007, Alberto Monteiro wrote:

 Do you know what's in my wish list?

 I wish spreadsheets and computer languages had gone one
 step further.

 I mean, it's nice to define Cell X to be equal to
 Cell Y + 10, and then when we change Cell Y, magically we
 see Cell X change.

 But why can't it be the reverse? Why can't I change Cell X
 _and see the change in Cell Y_?

 
 Well, most statistical calculations are data-reducing, ie, many-to-one.
 
 I don't think you are likely to find a language where you can change the 
 confidence limits for the sample mean and have the data change in 
 response.

But just think how much money you could make as a consultant if you 
could change the p-value from 0.08 to 0.01.

Duncan Murdoch

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


Re: [R] Behaviour of very large numbers

2007-08-30 Thread Nordlund, Dan (DSHS/RDA)
 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of willem vervoort
 Sent: Thursday, August 30, 2007 8:09 AM
 To: r-help@stat.math.ethz.ch
 Subject: [R] Behaviour of very large numbers
 
 Dear all,
 I am struggling to understand this.
 
 What happens when you raise a negative value to a power and the result
 is a very large number?
 
  B
 [1] 47.73092
 
  -51^B
 [1] -3.190824e+81
 
 # seems fine

It seems fine because the precedence of the '^' operator is higher than the 
unary negation operator '-'.  Your example is actually evaluated as -(51^B).

 # now this:
  x - seq(-51,-49,length=100)
 
  x^B
   [1] NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 
 NaN NaN NaN snip
  is.numeric(x^B)
 [1] TRUE
  is.real(x^B)
 [1] TRUE
  is.infinite(x^B)
   [1] FALSE FALSE FALSE FALSE FALSE
 
 I am lost, I checked the R mailing help, but could not find anything
 directly. I loaded package Brobdingnag and tried:
 as.brob(x^B)
   [1] NAexp(NaN) NAexp(NaN) NAexp(NaN) NAexp(NaN) NAexp(NaN)
  as.brob(x)^B
   [1] NAexp(187.67) NAexp(187.65) NAexp(187.63) NAexp(187.61)
 
 I guess I must be misunderstanding something fundamental.
 

Yes, you can't raise a negative number to a fractional power.

Hope this is helpful,

Dan

Daniel J. Nordlund
Research and Data Analysis
Washington State Department of Social and Health Services
Olympia, WA  98504-5204

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


Re: [R] Nested functions.

2007-08-30 Thread Paul Hiemstra
nalluri pratap schreef:
 Hi All,

   I have two variables X, Y. The question is if the value of X is equal to 
 one, then the values in Y have to be reversed other wise it should not perfom 
 any action. I think this should be done using lapply function?

   Example

   Y values : 1 2 3  NA
   X  Y (ORIGINAL) Y (REVERSED)
   1 NA   1
   0   ---
   1   2 3
   1   1 4
   1   3 2
   ...

   Can anyone provide solution to this?

   Thanks,
   Pratap  



 -

   [[alternative HTML version deleted]]

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

You could try something like this:

x = c(1,0,1,1)
y = c(1,2,3,NA)
y_rev = rev(y)
ifelse(x == 1, y_rev, y)

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:  +31302535773
Fax:+31302531145
http://intamap.geo.uu.nl/~paul

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


Re: [R] Behaviour of very large numbers

2007-08-30 Thread Martin Becker
willem vervoort wrote:
 Dear all,
 I am struggling to understand this.

 What happens when you raise a negative value to a power and the result
 is a very large number?

  B
 [1] 47.73092

   
 -51^B
 
 [1] -3.190824e+81

 # seems fine
   

Well, this seems not to be what you intended to do, you didn't raise a 
negative value to a power, but you got the negative of a positive number 
raised to that power (operator precedence, -51^B is the same as -(51^B) 
and not the same as (-51)^B...).

If you really want to raise a negative value to a fractional power, you 
may want to tell R to use complex numbers:

B - 47.73092
x - complex(real=seq(-51,-49,length=10))

x^B

 [1] 2.117003e+81-2.387323e+81i 1.718701e+81-1.938163e+81i
 [3] 1.394063e+81-1.572071e+81i 1.129702e+81-1.273954e+81i
 [5] 9.146212e+80-1.031409e+81i 7.397943e+80-8.342587e+80i
 [7] 5.978186e+80-6.741541e+80i 4.826284e+80-5.442553e+80i
 [9] 3.892581e+80-4.389625e+80i 3.136461e+80-3.536955e+80i
 

Regards,

  Martin


 # now this:
   
 x - seq(-51,-49,length=100)
 

   
 x^B
 
   [1] NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 
 snip
   
 is.numeric(x^B)
 
 [1] TRUE
   
 is.real(x^B)
 
 [1] TRUE
   
 is.infinite(x^B)
 
   [1] FALSE FALSE FALSE FALSE FALSE

 I am lost, I checked the R mailing help, but could not find anything
 directly. I loaded package Brobdingnag and tried:
 as.brob(x^B)
   [1] NAexp(NaN) NAexp(NaN) NAexp(NaN) NAexp(NaN) NAexp(NaN)
   
 as.brob(x)^B
 
   [1] NAexp(187.67) NAexp(187.65) NAexp(187.63) NAexp(187.61)

 I guess I must be misunderstanding something fundamental.

 Any clues would be really appreciated.
 Willem

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


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


[R] xyplot() groups scope issue

2007-08-30 Thread Mike Lawrence
Hi all,

Tinkering with a wrapper for xyplot that will help me plot a bunch of  
plots in a data analysis I'm doing and I ran into an odd error that  
I'm guessing is a scope issue. Here's a very simple version of the code:


###
#load lattice
library(lattice)

#create the wrapper function
do.xyplot = function( plot.formula, data.frame, plot.groups){

print(plot.groups) #show me what the wrapper function thinks  
'plot.groups' is

xyplot(
plot.formula
,data = data.frame
,groups = eval(plot.groups)
)
}

#create some data
mydata = as.data.frame(cbind( x = c(1:4), y = rep(1:2), z = rep(1:2,  
each = 2) ))

#try to plot the data (fails)
do.xyplot(
plot.formula=formula(x~y)
,data.frame = mydata
,plot.groups = expression(z)
)


#after error message try again, this time declaring plot.groups as a  
global variable (succeeds)
plot.groups = expression(z)
do.xyplot(
plot.formula=formula(x~y)
,data.frame = mydata
,plot.groups = expression(z)
)

#

I'm fine with declaring plot.groups before each call to do.xyplot,  
but I'm curious if there's a simpler solution.

Mike

--
Mike Lawrence
Graduate Student, Department of Psychology, Dalhousie University

Website: http://memetic.ca

Public calendar: http://icalx.com/public/informavore/Public

The road to wisdom? Well, it's plain and simple to express:
Err and err and err again, but less and less and less.
- Piet Hein

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


Re: [R] R and Web Applications

2007-08-30 Thread Paul Hiemstra
Dear Chris,

I use Python (http://www.python.org) in combination with Rpy 
(http://rpy.sourceforge.net/). Rpy enables you to use R commands inside 
Python, not the other way around. Works quite well, also for different R 
versions (I currently run R 2.5.1 under Linux).

cheers,

Paul

Chris Parkin schreef:
 Hello,

 I'm curious to know how people are calling R from web applications (I've
 been looking for Perl but I'm open to other languages).  After doing a
 search, I came across the R package RSPerl, but I'm having difficulties
 getting it installed (on Mac OSX).  I believe the problem probably has to do
 with changes in R since the package release.  Below you will see where the
 installation process comes to an end.  Does anyone have any suggestions, or
 perhaps a direction to point me in?

 Thanks in advance for your insight!

 Chris

 * Installing to library '/Library/Frameworks/R.framework/Resources/library'
 * Installing *source* package 'RSPerl' ...
 checking for perl... /usr/bin/perl
 No support for any of the Perl modules from calling Perl from R.
 *

Set PERL5LIB to
 /Library/Frameworks/R.framework/Versions/2.5/Resources/library/RSPerl/perl

 *
 Testing: -F/Library/Frameworks/R.framework/.. -framework R
 Using '/usr/bin/perl' as the perl executable
 Perl modules (no):
 Adding R package to list of Perl modules to enable callbacks to R from Perl
 Creating the C code for dynamically loading modules with native code for
 Perl:  R
 modules:   R; linking:
 checking for gcc... gcc
 checking for C compiler default output file name... a.out
 checking whether the C compiler works... yes
 checking whether we are cross compiling... no
 checking for suffix of executables...
 checking for suffix of object files... o
 checking whether we are using the GNU C compiler... yes
 checking whether gcc accepts -g... yes
 checking for gcc option to accept ISO C89... none needed
 Support R in Perl: yes
 configure: creating ./config.status
 config.status: creating src/Makevars
 config.status: creating inst/scripts/RSPerl.csh
 config.status: creating inst/scripts/RSPerl.bsh
 config.status: creating src/RinPerlMakefile
 config.status: creating src/Makefile.PL
 config.status: creating cleanup
 config.status: creating src/R.pm
 config.status: creating R/perl5lib.R
 making target all in RinPerlMakefile
 RinPerlMakefile:5: /Library/Frameworks/R.framework/Resources/etc/Makeconf:
 No such file or directory
 make: *** No rule to make target
 `/Library/Frameworks/R.framework/Resources/etc/Makeconf'.  Stop.

   [[alternative HTML version deleted]]

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


-- 
Drs. Paul Hiemstra
Department of Physical Geography
Faculty of Geosciences
University of Utrecht
Heidelberglaan 2
P.O. Box 80.115
3508 TC Utrecht
Phone:  +31302535773
Fax:+31302531145
http://intamap.geo.uu.nl/~paul

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


Re: [R] Behaviour of very large numbers

2007-08-30 Thread Prof Brian Ripley
On Thu, 30 Aug 2007, willem vervoort wrote:

 Dear all,
 I am struggling to understand this.

 What happens when you raise a negative value to a power and the result
 is a very large number?

Where are the 'very large numbers' here?  R can cope with much larger 
numbers (over 10^300).

 B
 [1] 47.73092

 -51^B
 [1] -3.190824e+81

Yes, that is -(51^B).

 # seems fine
 # now this:
 x - seq(-51,-49,length=100)

 x^B
  [1] NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 
 snip
 is.numeric(x^B)
 [1] TRUE
 is.real(x^B)
 [1] TRUE
 is.infinite(x^B)
  [1] FALSE FALSE FALSE FALSE FALSE

 I am lost, I checked the R mailing help, but could not find anything
 directly. I loaded package Brobdingnag and tried:
 as.brob(x^B)
  [1] NAexp(NaN) NAexp(NaN) NAexp(NaN) NAexp(NaN) NAexp(NaN)
 as.brob(x)^B

 I guess I must be misunderstanding something fundamental.

You are.  A negative number to a non-integer power is undefined in the 
real number system.

Look at (x+0i)^B.

-- 
Brian D. Ripley,  [EMAIL PROTECTED]
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@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] 7 Courses: Upcoming September-October 2007 R/S+ schedule by XLSolutions Corp

2007-08-30 Thread Sue Turner
Our upcoming September-October 2007 R/S+ course schedule is now
available. Please check out this link for additional information  and
direct enquiries to Sue Turner [EMAIL PROTECTED]  Phone: 206 686
1578
 
 

http://www.xlsolutions-corp.com/courselist.htm  
 
--

(1) An Introduction to S and R 
*** Seattle / October 29-30, 2007  ***

(2) R/S Fundamentals and Programming Techniques 
*** Seattle / September 24-25, 2007  ***
*** Boston / September 27-28, 2007   ***
 
(3) R/S System: Complementing and Extending Statistical Computing forSAS
Users 
*** Raleigh / October 22-23, 2007 ***  
 
(4) R/S System: Advanced Programming 
*** Princeton / October 29-30, 2007 ***
*** San Francisco / October 25-26, 2007 
--

http://www.xlsolutions-corp.com/courselist.htm  

 
(5) Introduction to R/S+ programming: Microarrays Analysis
andBioconductor.

*** Los Angeles 9/24/2007 9/25/2007  *** 
(6) Microarrays Data Analysis with R/S+ and GGobi  
*** New York City 10/18/2007 10/19/2007 ***  
(7) Data Mining: Practical Tools and Techniques in R/Splus 
*** San Francisco 9/27/2007 9/28/2007 ***
 
---
 

 Payment due AFTER the class
 Email us for group discounts. 
 Email Sue Turner: [EMAIL PROTECTED] 
 Phone: 206-686-1578 
 Visit us: www.xlsolutions-corp.com/courselist.htm 
 Please let us know if you and your colleagues are interested inthis 
 class to take advantage of group discount. Register now to secureyour 
 seat! 
 
 Cheers, 
 Elvis Miller, PhD 
 Manager Training. 
 XLSolutions Corporation 
 206 686 1578 
 www.xlsolutions-corp.com

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


Re: [R] mtext, picking subscript text from colnames(df)

2007-08-30 Thread Henrique Dallazuanna
Try:

mtext(eval(parse(tex=paste(expression(mu[, colnames(PresEsts)[2],]),
sep=))),side=2,at=max(y)-15,las=1)


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

[[alternative HTML version deleted]]

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


Re: [R] Behaviour of very large numbers

2007-08-30 Thread Duncan Murdoch
On 8/30/2007 12:11 PM, Martin Becker wrote:
 willem vervoort wrote:
 Dear all,
 I am struggling to understand this.

 What happens when you raise a negative value to a power and the result
 is a very large number?

  B
 [1] 47.73092

   
 -51^B
 
 [1] -3.190824e+81

 # seems fine
   
 
 Well, this seems not to be what you intended to do, you didn't raise a 
 negative value to a power, but you got the negative of a positive number 
 raised to that power (operator precedence, -51^B is the same as -(51^B) 
 and not the same as (-51)^B...).
 
 If you really want to raise a negative value to a fractional power, you 
 may want to tell R to use complex numbers:
 
 B - 47.73092
 x - complex(real=seq(-51,-49,length=10))
 
 x^B
 
  [1] 2.117003e+81-2.387323e+81i 1.718701e+81-1.938163e+81i
  [3] 1.394063e+81-1.572071e+81i 1.129702e+81-1.273954e+81i
  [5] 9.146212e+80-1.031409e+81i 7.397943e+80-8.342587e+80i
  [7] 5.978186e+80-6.741541e+80i 4.826284e+80-5.442553e+80i
  [9] 3.892581e+80-4.389625e+80i 3.136461e+80-3.536955e+80i

But watch out if you do this, because of the arbitrary choice of a root. 
  You get oddities like this:

  x - complex(real = -1)
  x
[1] -1+0i
  1/x
[1] -1+0i
  x^(1/3)
[1] 0.5+0.8660254i
  (1/x)^(1/3)
[1] 0.5-0.8660254i

i.e. even though x and 1/x are equal, the 1/3 powers of them are not.

Duncan Murdoch

P.S. I'm tempted to say, But don't worry about it, the difference is 
only imaginary, but I'll refrain.

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


Re: [R] xyplot() groups scope issue

2007-08-30 Thread deepayan . sarkar
On 8/30/07, Mike Lawrence [EMAIL PROTECTED] wrote:
 Hi all,

 Tinkering with a wrapper for xyplot that will help me plot a bunch of
 plots in a data analysis I'm doing and I ran into an odd error that
 I'm guessing is a scope issue. Here's a very simple version of the code:

It's indeed a scoping issue. For writing wrappers, the best solution
I've been able to come up with involves match.call() and
eval.parent(). See lattice:::dotplot.formula for a template.

If you really want to do it your way, try changing the environment of
the formula:

do.xyplot = function( plot.formula, data.frame, plot.groups){
print(plot.groups)
environment(plot.formula) - environment() # new
xyplot(
plot.formula
,data = data.frame
,groups = eval(plot.groups)
)
}

-Deepayan

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


Re: [R] Assigning line colors in xyplot

2007-08-30 Thread deepayan . sarkar
On 8/30/07, Christof Bigler [EMAIL PROTECTED] wrote:
 Hi,

 I have a dataframe containing data from individuals 1, ..., 12 (grouping
 variable g in the data frame below), which belong either to A or B
 (grouping variable f):

 set.seed(1)

 tmp - data.frame(

 y=c(rnorm(10,0,1),rnorm(10,4,2),rnorm(10,0,1),rnorm(10,4,2),rnorm(10,0,1),rnorm(10,4,2),rnorm(10,0,1),rnorm(10,4,2),rnorm(10,0,1),rnorm(10,4,2),rnorm(10,0,1),rnorm(10,4,2)),
   x=1:10,

 f=c(rep(A,10),rep(B,10),rep(A,10),rep(B,10),rep(A,10),rep(B,10),rep(A,10),rep(B,10),rep(A,10),rep(B,10),rep(A,10),rep(B,10)),

 g=c(rep(3,10),rep(2,10),rep(1,10),rep(4,10),rep(5,10),rep(6,10),rep(8,10),rep(7,10),rep(9,10),rep(11,10),rep(12,10),rep(10,10)))


 I would like to draw line plots using the function xyplot:

 library(lattice)

 xyplot(y ~ x | g , groups=g, data=tmp,type=l,
   par.settings=list(superpose.line=list(col=c(red,blue))),
   auto.key=list(space=top,
 text=levels(tmp$f),points=FALSE,lines=TRUE))

 As it is, the colors are recycled alternately in the order the
 individuals appear in the plot (1, 10, 11, 12, 2, ..., 9).

 How can I assign the red color to all individuals of group A and the
 blue color to all individuals of group B?

Why not simply use f as the grouping variable rather than g:

xyplot(y ~ x | g , groups=f, data=tmp,type=l,
  par.settings=list(superpose.line=list(col=c(red,blue))),
  auto.key=list(space=top, points=FALSE,lines=TRUE))

? Or am I missing something?

-Deepayan

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


[R] percentage explained by fixed effects in random model

2007-08-30 Thread Simon Pickett
Hi,

I realise this has come up before in various reincarnations but I couldnt
find the answer...

I wish to quote the percentage variance explained by each of three
components in my mixed model.

If I didnt have a random effect I would just use r squared. I can work out
the percentage explained by the random effect using summary() but this
doesnt give variance for the fixed effects.

Linear mixed-effects model fit by REML
Formula: yell ~ carot.code + weight16 + (1 | fosterbrood)
   Data: colour
  AIC  BIClogLik MLdeviance REMLdeviance
 1555.455 1576.282 -772.7276   1536.585 1545.455
Random effects:
 Groups  NameVariance Std.Dev.
 fosterbrood (Intercept) 1.0747   1.0367
 Residual1.1363   1.0660
# of obs: 476, groups: fosterbrood, 61

Fixed effects:
  Estimate Std. Error  DF t value Pr(|t|)
(Intercept)  -3.187028   1.011828 473 -3.1498 0.001737 **
carot.code1   0.201951   0.098442 473  2.0515 0.040771 *
weight16  0.168861   0.054273 473  3.1114 0.001975 **
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Correlation of Fixed Effects:
(Intr) crt.c1
carot.code1  0.035
weight16-0.989 -0.084

I was thinking of (cheating by) taking the residuals from a regression
with the random effect (fosterbrood) as a fixed effect, then correlating
these with my two x variables?

Any better ideas?

Thanks in advance, Simon.

[[alternative HTML version deleted]]

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


Re: [R] Month end calculations

2007-08-30 Thread Gabor Grothendieck
The zoo package includes the yearmon class to facilitate such
manipulations.  Here are a few solutions assuming you store
you series in a zoo variable:

# test data
library(zoo)
z - zoo(1001:1100, as.Date(101:200))[-(45:55)]

# Solution 1.  tapply produces indexes of last of month
tt - time(z)
z[ c(tapply(seq_along(tt), as.yearmon(tt), tail, 1)) ]

# If we want to create a last variable which corresponds
# to last in sas then do it this slightly longer way:

# Solution 2
tt - time(z)
last - seq_along(tt) %in% tapply(seq_along(tt), as.yearmon(tt), tail, 1)
z[last]

# Solution 3. another solution with a last variable.  f(x) is
# vector same length as x with all 0's except last element is 1.
tt - time(z)
f - function(x) replace(0*x, length(x), 1)
last - ave(seq_along(tt), as.yearmon(tt), FUN = f)
z[last]

In all these solutions the last point in the series is always
included.

We have not assumed that every day is necessarily included in your
series but if every day is included then even simpler solutions
are possible.

On 8/29/07, Shubha Vishwanath Karanth [EMAIL PROTECTED] wrote:
 Hi R users,



 Is there a function in R, which does some calculation only for the month
 end in a daily data?... In other words, is there a command in R,
 equivalent to last. function in SAS?



 BR, Shubha


[[alternative HTML version deleted]]

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


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


Re: [R] Month end calculations

2007-08-30 Thread Gabor Grothendieck
The last line is wrong (see below for correction):

On 8/30/07, Gabor Grothendieck [EMAIL PROTECTED] wrote:
 The zoo package includes the yearmon class to facilitate such
 manipulations.  Here are a few solutions assuming you store
 you series in a zoo variable:

 # test data
 library(zoo)
 z - zoo(1001:1100, as.Date(101:200))[-(45:55)]

 # Solution 1.  tapply produces indexes of last of month
 tt - time(z)
 z[ c(tapply(seq_along(tt), as.yearmon(tt), tail, 1)) ]

 # If we want to create a last variable which corresponds
 # to last in sas then do it this slightly longer way:

 # Solution 2
 tt - time(z)
 last - seq_along(tt) %in% tapply(seq_along(tt), as.yearmon(tt), tail, 1)
 z[last]

 # Solution 3. another solution with a last variable.  f(x) is
 # vector same length as x with all 0's except last element is 1.
 tt - time(z)
 f - function(x) replace(0*x, length(x), 1)
 last - ave(seq_along(tt), as.yearmon(tt), FUN = f)
 z[last]

This last line should be:

z[last == 1]



 In all these solutions the last point in the series is always
 included.

 We have not assumed that every day is necessarily included in your
 series but if every day is included then even simpler solutions
 are possible.

 On 8/29/07, Shubha Vishwanath Karanth [EMAIL PROTECTED] wrote:
  Hi R users,
 
 
 
  Is there a function in R, which does some calculation only for the month
  end in a daily data?... In other words, is there a command in R,
  equivalent to last. function in SAS?
 
 
 
  BR, Shubha
 
 
 [[alternative HTML version deleted]]
 
  __
  R-help@stat.math.ethz.ch mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 


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


Re: [R] Q: how to interrupt long calculation?

2007-08-30 Thread Prof Brian Ripley
On Thu, 30 Aug 2007, D. R. Evans wrote:

 Paul Smith said the following at 08/29/2007 04:32 PM :

 The instance of R running will be immediately killed and then you can
 start R again.

 But then I would lose all the work. There must be some way to merely
 interrupt the current calculation. Mustn't there?

Only if it is long-running in R code, when ctrl-C or equivalent (Esc in 
Rgui) works. If it is long-running in C or Fortran code, there is not.

Assuming a Unix-alike, sending SIGUSR1 will save the current workspace and 
quit.  Even that is a little dangerous as the workspace need not be in a 
consistent state.

People who have been bitten will learn safer programming practices, for 
example to call save.image() at suitable checkpoint times.

-- 
Brian D. Ripley,  [EMAIL PROTECTED]
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@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Barplot2 using for loop, how to adjust margins?

2007-08-30 Thread Lauri Nikkinen
Hi R-users,

I inted to make multiple plots using for loop. The question is how can
I adjust the left hand side margin of the plot according to the
names.arg argument in barplot2. In every plot I have different
annotations in the y axis and they vary in length. Now when I have
fixed margins

opar - par(mar=c(3,15,0,2)...

I get the same margins in all of the plots. That leaves lots of white
space in plots where the annotations are short.

Here is the code I'm using:

library(gplots)
opar - par(mar=c(3,15,0,2), bg=white, cex=1, oma = c(0, 0, 2, 0),
mgp=c(3,0.5,0))
for (i in names(spl)) {
  .order - order(spl[[i]]$x)
  barplot2(spl[[i]]$x[.order],
  names.arg=as.character(spl[[i]]$os[.order]),
  horiz=TRUE,
  las=1,
  cex.names=0.7,
  cex.main=0.9,
  cex.axis=0.7,
  xlim=c(0, max(spl[[i]]$x)+10),
  col=as.character(spl[[i]][1,7]),
  plot.grid = TRUE,
  )
  box()
  mtext(paste(paste(as.character(spl[[i]][1,2]), :, sep=),
texthere, (texthere), as.character(spl[[i]][1,3])), outer=T, line
= 0.5, cex=1.1)
  mtext(texthere, side=1, line=1.5, adj=0.5)
  dev.copy(png, filename=paste(i, .png, sep=), height=400,
width=480)
  dev.off()
}

Thanks in advance
Lauri

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


[R] Additions to xyplot (lattice)? - legend, ticks, axis label size, text

2007-08-30 Thread Dave Hewitt
I have created an xyplot of a time series with the following code...

win.graph(width = 10, height = 7)

panel1 = function(x, y)  {
  panel.loess(x, y, lwd=2.5, span=0.5, col=gray)
  panel.xyplot(x, y, pch=19, col=blue, cex=1.25)
  }

xyplot(oneplusdensity ~ year, data=figdata, aspect=fill, cex=1.5,
  xlab=NULL, ylab=expression(Crabs per 1,000 m^2),
  xlim=c(1964, 2007), ylim=c(-2, 62),
  scales=list (x=list(tick.number=41, cex=0.8, rot=90),
  y= list(tick.number=7, cex=1.2)), panel=panel1)

I want to do the following things:

(1) Remove the ticks on the top and right boundaries
(2) Increase the size of the y-axis label to be larger than the tick labels
(3) Add a legend with the points and lowess line
(4) Add some annotation (text) in the lower left corner ('text' for plot() 
did not work)

I'm relatively new to lattice and spent a few hours with the manual and 
other help pages. I've begun to wonder if a regular old plot() for this 
would be better. Appreciate any redirection or suggestions.

Thanks,
Dave Hewitt

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


Re: [R] Q: how to interrupt long calculation?

2007-08-30 Thread Horan, Brian
On linux and solaris, I have had some luck doing a CTRL-Z (STOP signal)
and the resuming later... some libraries have issues (I don't recall
which) but...usually pretty good.

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of D. R. Evans
Sent: Thursday, August 30, 2007 11:56 AM
Cc: r-help@stat.math.ethz.ch
Subject: Re: [R] Q: how to interrupt long calculation?

Paul Smith said the following at 08/29/2007 04:32 PM :

 The instance of R running will be immediately killed and then you can
 start R again.

But then I would lose all the work. There must be some way to merely
interrupt the current calculation. Mustn't there?

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

-
This email transmission and any accompanying attachments may
contain CSX privileged and confidential information intended only
for the use of the intended addressee.  Any dissemination,
distribution, copying or action taken in reliance on the contents
of this email by anyone other than the intended recipient is
strictly prohibited.  If you have received this email in error
please immediately delete it and  notify sender at the above CSX
email address.  Sender and CSX accept no liability for any damage
caused directly or indirectly by receipt of this email.

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


Re: [R] Q: how to interrupt long calculation?

2007-08-30 Thread D. R. Evans
Prof Brian Ripley said the following at 08/30/2007 11:00 AM :
 On Thu, 30 Aug 2007, D. R. Evans wrote:
 
 Paul Smith said the following at 08/29/2007 04:32 PM :

 The instance of R running will be immediately killed and then you can
 start R again.
 But then I would lose all the work. There must be some way to merely
 interrupt the current calculation. Mustn't there?
 
 Only if it is long-running in R code, when ctrl-C or equivalent (Esc in 
 Rgui) works. If it is long-running in C or Fortran code, there is not.
 

It's inside loess()... so isn't that R code?

I can sit hitting ctrl-C all day (well, it seems like it), but the code
does not get interrupted :-(

 Assuming a Unix-alike, sending SIGUSR1 will save the current workspace and 
 quit.  Even that is a little dangerous as the workspace need not be in a 
 consistent state.
 

That's helpful, thank you; at least it means I stand a chance of being able
to interrupt the code and recover.

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


Re: [R] Additions to xyplot (lattice)? - legend, ticks, axis label size, text

2007-08-30 Thread deepayan . sarkar
On 8/30/07, Dave Hewitt [EMAIL PROTECTED] wrote:
 I have created an xyplot of a time series with the following code...

 win.graph(width = 10, height = 7)

 panel1 = function(x, y)  {
   panel.loess(x, y, lwd=2.5, span=0.5, col=gray)
   panel.xyplot(x, y, pch=19, col=blue, cex=1.25)
   }

 xyplot(oneplusdensity ~ year, data=figdata, aspect=fill, cex=1.5,
   xlab=NULL, ylab=expression(Crabs per 1,000 m^2),
   xlim=c(1964, 2007), ylim=c(-2, 62),
   scales=list (x=list(tick.number=41, cex=0.8, rot=90),
   y= list(tick.number=7, cex=1.2)), panel=panel1)

 I want to do the following things:

 (1) Remove the ticks on the top and right boundaries

scales = list(tck = c(1, 0), x = ..., y = ...)

 (2) Increase the size of the y-axis label to be larger than the tick labels

ylab = list( expression(...), cex = 2)

 (3) Add a legend with the points and lowess line

See the entry for 'key' in ?xyplot. As a starting point,

key = list(text = list(loess), lines = list(lwd=2.5, span=0.5, col=gray),
   text = list(points), points = list(pch=19, col=blue, cex=1.25))

 (4) Add some annotation (text) in the lower left corner ('text' for plot()
 did not work)

Use panel.text() instead inside your panel function.

-Deepayan

 I'm relatively new to lattice and spent a few hours with the manual and
 other help pages. I've begun to wonder if a regular old plot() for this
 would be better. Appreciate any redirection or suggestions.

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


Re: [R] Month end calculations

2007-08-30 Thread Gabor Grothendieck
And one more yearmon solution.  Here z is a zoo series as before:

tt - time(z)
aggregate(z, ave(tt, as.yearmon(tt), FUN = max), tail, 1)


On 8/30/07, Gabor Grothendieck [EMAIL PROTECTED] wrote:
 The last line is wrong (see below for correction):

 On 8/30/07, Gabor Grothendieck [EMAIL PROTECTED] wrote:
  The zoo package includes the yearmon class to facilitate such
  manipulations.  Here are a few solutions assuming you store
  you series in a zoo variable:
 
  # test data
  library(zoo)
  z - zoo(1001:1100, as.Date(101:200))[-(45:55)]
 
  # Solution 1.  tapply produces indexes of last of month
  tt - time(z)
  z[ c(tapply(seq_along(tt), as.yearmon(tt), tail, 1)) ]
 
  # If we want to create a last variable which corresponds
  # to last in sas then do it this slightly longer way:
 
  # Solution 2
  tt - time(z)
  last - seq_along(tt) %in% tapply(seq_along(tt), as.yearmon(tt), tail, 1)
  z[last]
 
  # Solution 3. another solution with a last variable.  f(x) is
  # vector same length as x with all 0's except last element is 1.
  tt - time(z)
  f - function(x) replace(0*x, length(x), 1)
  last - ave(seq_along(tt), as.yearmon(tt), FUN = f)
  z[last]

 This last line should be:

 z[last == 1]


 
  In all these solutions the last point in the series is always
  included.
 
  We have not assumed that every day is necessarily included in your
  series but if every day is included then even simpler solutions
  are possible.
 
  On 8/29/07, Shubha Vishwanath Karanth [EMAIL PROTECTED] wrote:
   Hi R users,
  
  
  
   Is there a function in R, which does some calculation only for the month
   end in a daily data?... In other words, is there a command in R,
   equivalent to last. function in SAS?
  
  
  
   BR, Shubha
  
  
  [[alternative HTML version deleted]]
  
   __
   R-help@stat.math.ethz.ch mailing list
   https://stat.ethz.ch/mailman/listinfo/r-help
   PLEASE do read the posting guide 
   http://www.R-project.org/posting-guide.html
   and provide commented, minimal, self-contained, reproducible code.
  
 


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


Re: [R] Q: how to interrupt long calculation?

2007-08-30 Thread Prof Brian Ripley
On Thu, 30 Aug 2007, D. R. Evans wrote:

 Prof Brian Ripley said the following at 08/30/2007 11:00 AM :
 On Thu, 30 Aug 2007, D. R. Evans wrote:

 Paul Smith said the following at 08/29/2007 04:32 PM :

 The instance of R running will be immediately killed and then you can
 start R again.
 But then I would lose all the work. There must be some way to merely
 interrupt the current calculation. Mustn't there?

 Only if it is long-running in R code, when ctrl-C or equivalent (Esc in
 Rgui) works. If it is long-running in C or Fortran code, there is not.


 It's inside loess()... so isn't that R code?

No, it is mainly Fortran, called from C called from R.

 I can sit hitting ctrl-C all day (well, it seems like it), but the code
 does not get interrupted :-(

 Assuming a Unix-alike, sending SIGUSR1 will save the current workspace and
 quit.  Even that is a little dangerous as the workspace need not be in a
 consistent state.


 That's helpful, thank you; at least it means I stand a chance of being able
 to interrupt the code and recover.


-- 
Brian D. Ripley,  [EMAIL PROTECTED]
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@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


  1   2   >