Re: [R] AIC extract and comparison

2008-04-30 Thread Uwe Ligges



Lisa wrote:

Hi, I need to fit models and use AIC method to campare the best fitted model
manually.

When i extract AIC by using extractAIC, it gave me the df and AIC values.
Now the problem is, how can I compare the AIC values from two models?
is there anyway to extract AIC with no df so that I can compare directly?
Thank you!


extractAIC(coxout)

[1]1.000 1723.038


extractAIC(coxout)[2]

Uwe




[[alternative HTML version deleted]]

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


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


[R] What are ties? Wilcox u-test

2008-04-30 Thread Dirkheld

Hi,

When I execute a Wilcox u-test on two variables I receive a warning :
'cannot compute exact p-value with ties'
- What are ties? What does this mean for my data?
- Is that a problem for significance testing?
- is there a way to overcome this problem?

I have different threads in this forum but it hard to find what the exact
meaning of this warning message is.
-- 
View this message in context: 
http://www.nabble.com/What-are-ties--Wilcox-u-test-tp16977232p16977232.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] What are ties? Wilcox u-test

2008-04-30 Thread Uwe Ligges



Dirkheld wrote:

Hi,

When I execute a Wilcox u-test on two variables I receive a warning :
'cannot compute exact p-value with ties'
- What are ties? What does this mean for my data?


If you have two identical values in your data, these are called ties.
Now the ranks are not unique anymore and hence exact p-values cannot be 
calculated.
And since you do not know this, it might be worth to note that the 
Wilcoxon test also assumes a non-skewed distribution.




- Is that a problem for significance testing?


If there are just a few ties, you should not worry, but re-check how 
your data looks like. It is a warning, not an error message.




- is there a way to overcome this problem?


If you need to, use an appropriate test for your data.



I have different threads in this forum but it hard to find what the exact
meaning of this warning message is.


Read some textbook?

Uwe Ligges

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


Re: [R] Problem installing packages

2008-04-30 Thread Uwe Ligges
I cannot reproduce this, hence we need much more information in order to 
reproduce the problem.


Which OS are we talking about? XP or Vista?
If Vista: Are you running R with administrator privileges when trying to 
install the packages? Please do so (e.g. by right-clicking appropriately 
when starting R).


Which version of R? (I guess 2.7.0 release from the paths given below)
Which version of DBI (I guess it does not matter).
Which CRAN mirror? (I guess it does not matter).

Uwe Ligges



Owe Jessen wrote:

Hi,

when I try installing new packages (in this case DBI) I run into the 
following problem:


Paket 'DBI' erfolgreich ausgepackt und MD5 Summen abgeglichen
Warnung: kann temporäre Installation 
'C:\Programme\R\R-2.7.0\library\file5f906952\DBI' nicht nach 'ÝxlDÌú 
[EMAIL PROTECTED]' verschieben


Has anybody any idea where these strange symbols come from?

Thanks in advance,
Owe



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


Re: [R] What are ties? Wilcox u-test

2008-04-30 Thread Ted Harding
On 30-Apr-08 07:47:56, Uwe Ligges wrote:
 Dirkheld wrote:
 Hi,
 When I execute a Wilcox u-test on two variables I receive a
 warning : 'cannot compute exact p-value with ties'
 - What are ties? What does this mean for my data?
 
 If you have two identical values in your data, these are called
 ties. Now the ranks are not unique anymore and hence exact
 p-values cannot be calculated.
 And since you do not know this, it might be worth to note that
 the Wilcoxon test also assumes a non-skewed distribution.

For the sake of clarification, it should be emphasised that
assumes a non-skewed distribution applies only to the paired
two-sample case (signed-rank) or the single sample case.
In this case the Wilcoxon test is in effect a test of symmetry.

I think this is reasonably clear from ?wilcox.test.

Dirkheld did not state that he was using the paired test,
and may well simply have been comparing two samples (possibly
of different sizes) of values of X and Y.

When the Wilcoxon test is used to compare two samples of
values which are not paired, it makes no assumption about
the shape of the distribution, only that (as null hypothesis)
the distribution from which X is sampled is the same as the
distribution from which Y is sampled. It is, in effect,
based on an estimate of P(X  Y).

In this respect, I think ?wilcox.test is misleading. While
people commonly think that the Wilcoxon test (or its equivalent
the Mann-Whitney U test) is a test of shift in location,
this is only a special case of the class of alternatives
(to the null hypothesis that the distributions are the same)
to which the Wilcoxon (or Mann-Whitney) test is sensitive.

In particular, the expected value of the Wilxoxon (or the
Mann-Whitney) test statistic is a linear function of
P(X  Y).

Hoping this helps,
Ted.

 - Is that a problem for significance testing?
 
 If there are just a few ties, you should not worry, but re-check how 
 your data looks like. It is a warning, not an error message.
 
 
 - is there a way to overcome this problem?
 
 If you need to, use an appropriate test for your data.
 
 
 I have different threads in this forum but it hard to find what the
 exact
 meaning of this warning message is.
 
 Read some textbook?
 
 Uwe Ligges
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


E-Mail: (Ted Harding) [EMAIL PROTECTED]
Fax-to-email: +44 (0)870 094 0861
Date: 30-Apr-08   Time: 09:24:57
-- XFMail --

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


Re: [R] Combine Values into a Vector or List

2008-04-30 Thread Diego Culattoni
Hello Jorge,
Sorry, my aim is to get each individual separately, so that if I input 
 A1 # the the result would be 
    1
This because I would like to use
lm.D - lm(y~A1+A1+A3...)
Thanks,
Diego

- Original Message 
From: Jorge Ivan Velez [EMAIL PROTECTED]
To: Diego Culattoni [EMAIL PROTECTED]
Cc: R mailing list r-help@r-project.org
Sent: Tuesday, April 29, 2008 9:03:20 PM
Subject: Re: [R] Combine Values into a Vector or List


Hi Diego,

Try this:

z-As[A1]+As[A2]; names(z)-z
z
4

HTH,

Jorge




On Tue, Apr 29, 2008 at 2:57 PM, Diego Culattoni [EMAIL PROTECTED] wrote:

Thank you Jorge, what I want to have is 
 z - A1+A2
z
  4
The problem is that A1, A2,... still unknown, so that I have the following error
 A1
object A1 not found

Thank you in advance!


- Original Message 
From: Jorge Ivan Velez [EMAIL PROTECTED]
To: Diego Culattoni [EMAIL PROTECTED]

Cc: R mailing list r-help@r-project.org
Sent: Tuesday, April 29, 2008 7:38:41 PM
Subject: Re: [R] Combine Values into a Vector or List


Hi Diego,

Is this what you want?

# Data set
set.seed(123)
x1-paste(A, 1:6, sep = )
x2- round(rgamma(6,2,1))
x3-paste(B, 1:6, sep = )
x4- round(rgamma(6,2,1))
data1 - data.frame(x1,x2,x3,x4)
data1
x1 x2 x3 x4
1 A1  1 B1  0
2 A2  3 B2  0
3 A3  0 B3  3
4 A4  2 B4  2
5 A5  4 B5  2
6 A6  2 B6  2

# A's
As=as.numeric(t(data1[,1:2])[-1,])
names(As)=paste('A',1:length(As),sep=)
As
A1 A2 A3 A4 A5 A6 
 1  3  0  2  4  2 

# B's
Bs=as.numeric(t(data1[,3:4])[-1,])
names(Bs)=paste('B',1:length(Bs),sep=)
Bs
B1 B2 B3 B4 B5 B6 
 0  0  3  2  2  2 

HTH,

Jorge



On Tue, Apr 29, 2008 at 1:20 PM, Diego Culattoni [EMAIL PROTECTED] wrote:

Hi Richard,

Thanks a lot! What I actually want to have
A1
 4
A2
  2
... and so on! Is this possible?

Thank you again :)!



- Original Message 
From: [EMAIL PROTECTED] [EMAIL PROTECTED]
To: Diego Culattoni [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Monday, April 28, 2008 11:24:12 AM
Subject: Re: [R] Combine Values into a Vector or List

 x1-paste(A, 1:6, sep = )
 x2- round(rgamma(6,2,1))
 x3-paste(B, 1:6, sep = )
 x4- round(rgamma(6,2,1))
 data1 - data.frame(x1,x2,x3,x4)
 I would like to get
 data2 - c(A1=4, A2=1, A3=0,...)
 Is there any standard for such a case?

I presume that 4, 2, 0 are the first few values of x2.  In which case, I
think that what you want is simply this:

names(x2) - x1

Regards,
Richie.

Mathematical Sciences Unit
HSL



ATTENTION:

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

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] randomForest weighting of variables and count data

2008-04-30 Thread Birgit Lemcke

Hello R-user!

I am running R 2.7.0 on a Power Book (Tiger). (I am still R and  
statistics beginner)


I try to find the most important variables to divide my dataset as  
given in a categorical variable using randomForest.


I was wondering if there is the possibility in randomForest to give  
different weights to the explaining variables and additonally if it  
makes a difference using count data?


Thanks in advance

Birgit



Birgit Lemcke
Institut für Systematische Botanik
Zollikerstrasse 107
CH-8008 Zürich
Switzerland
Ph: +41 (0)44 634 8351
[EMAIL PROTECTED]

175 Jahre UZH
«staunen.erleben.begreifen. Naturwissenschaft zum Anfassen.»
MNF-Jubiläumsevent für gross und klein.
19. April 2008, 10.00 Uhr bis 02.00 Uhr
Campus Irchel, Winterthurerstrasse 190, 8057 Zürich
Weitere Informationen http://www.175jahre.uzh.ch/naturwissenschaft

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

2008-04-30 Thread Lauri Nikkinen
R users,

I intention is to calculate some summary statistics across factor
levels. I know that in Hmisc package there is a summary function which
produces neat summary statistics when using cross option. I would
like to produce similar output with N and Missing columns but produce
a data.frame. Is there any built-in function for that?

#example data
install.packages(Hmisc)
library(Hmisc)
sek - seq(1, nrow(Indometh), 9)
Indometh$time[sek] - NA
Indometh$timeclass - factor(cut(Indometh$time, breaks=c(0,2,4,6,8,10)))
Indometh
with(Indometh, summary(conc ~ Subject + timeclass, method=cross))

#similar with aggregate and reshape but no N or Missing count
i.mean - aggregate(Indometh$conc, list(Indometh$Subject,
Indometh$timeclass), mean, na.rm=T)
i.mean.rhsp - reshape(i.mean, v.names=x, idvar=Group.1,
timevar=Group.2, direction=wide)
i.mean.rhsp  # N and missing columns needed

Thanks,
Lauri

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

2008-04-30 Thread Monna Nygård

No matter how I´ve tried o find a solution for this simple question, I can´t. 
Sorry for bothering with such a matter.
 
I have an excel-files with some empty cells=missing values. How do I tell R 
that these should be NA´s? 
 
  TRFLP1 -(read.table(file=S://SEDIM//Kokeilu//TRFLP1.txt,col.names= 
 c(Dye_Sample Peak, Sample_File_Name, Size, Height, Area_in_Point, 
 Area_in_BP, Data_Point, Begin_Point, Begin_BP, End_Point, End_BP, 
 Width_in_Point, Width_in_BP, 1 ), header=F , dec = ,, )Error in 
 scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings,  :   line 
 1743 did not have 14 elements
 
I believe the error occurs becouse line 1743 has an empty cell. How do I read 
in the file without first checking for missing values and changing them to NAs 
myself?
 
Thank you for you time,
 
Monna Nygård
_


[[alternative HTML version deleted]]

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


Re: [R] + and - in RODBC : no longer considered factors

2008-04-30 Thread Prof Brian Ripley

It is nothing to do with RODBC, which follows read.table here:

% cat  foo.txt
x
+
-
...


read.table(foo.txt, header=TRUE)

  x
1 0
2 0

and that uses


type.convert(c(+, -))

[1] 0 0

type.convert(c(+, a))

[1] + a
Levels: + a

Whereas 2.6.2 did


type.convert(c(+, -))

[1] + -
Levels: + -

The difference is related to a change to deciding in R (and not the OS)
what a 'numeric field' is:

o   Parsing and scanning of numerical constants is now done by R's
own C code.  This ensures cross-platform consistency, and
mitigates the effects of setting LC_NUMERIC (within base R it
only applies to output -- packages may differ).

The format accepted is more general than before and includes
binary exponents in hexadecimal constants: see
?NumericConstants for details.

There's a comment in the sources that numeric fields with no digits should 
perhaps be regarded as non-numeric, so this can easily be changed.



On Wed, 30 Apr 2008, Dieter Menne wrote:


I have a large Sweave report that reads data from a database file. Some of
the columns are 1-character strings containing only +, - or NA. An example
for such a table is shown below, and can be downloaded for easier testing
from

http://www.menne-biomed.de/uni/test.zip

(For security reasons, the file is zipped)

table test

hp  hp1
+   a
-   +


library(RODBC)
channel = odbcConnectAccess(test.mdb)
ret =  sqlQuery(channel,select * from test)
odbcClose(channel)
str(ret)
# 'data.frame':   2 obs. of  2 variables:
# $ hp : num  0 0
# $ hp1: Factor w/ 2 levels +,a: 2 1


Note that the column hp with + and - only is read as numeric 0, but
when there is only other character such as in hp1, the conversion occurs.

In R 2.6.2 (or was it an earlier version of RODBC?), column hp was treated
as factor.

Is this a new feature I have to live with, or an ... ahem ... issue? I know
that with as.is I can get around this, but it need a lot of explicit
programming for the columns I don't want to be as.issed

Disclaimer:
-- Yes, I know I should have reported this earlier, but the problem of
having
to re-create the report came up today.
-- Yes, I should have reported this on the windows/devel r-help or directly
to the author (of RODBC; or base?), so I feel guilty in advance that this is

the wrong list.
-- Yes, I have read the NEWS, and could not find something related.
-- Yes, I cannot rule out this is a user error.


Dieter


---

R version 2.7.0 (2008-04-22)
i386-pc-mingw32

locale:
LC_COLLATE=German_Germany.1252;LC_CTYPE=German_Germany.1252;LC_MONETARY=Germ
an_Germany.1252;LC_NUMERIC=C;LC_TIME=German_Germany.1252

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

other attached packages:
[1] RODBC_1.2-3





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


Re: [R] ggplot2: labels and breaks order does not match and I can't usescale_fill_identity

2008-04-30 Thread ONKELINX, Thierry
Mikhail,

Have you tried sorting your dataframe according to the levels on the
x-axis?

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 

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

The plural of anecdote is not data.
~ Roger Brinner

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

-Oorspronkelijk bericht-
Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Namens Mikhail Spivakov
Verzonden: dinsdag 29 april 2008 16:53
Aan: r-help@r-project.org
Onderwerp: [R] ggplot2: labels and breaks order does not match and I
can't usescale_fill_identity

Hi,

I'm plotting a bar chart like this:

ggplot() +
geom_bar(data=res,aes(fill=f1,x=f2,y=y),stat=identity,position=dodge
)

f1 contains quite a few levels and the plot is really quite difficult to
read when the order of bars on the graph and on the legend does not
match.

This problem has been discussed recently here:
http://www.nabble.com/ggplot2---legend-for-fill-coulours-td16235166.html
and the solution was to use scale_fill_identity to manually define the
order
of both the breaks and the labels.
This is however unsuitable for me (at least in the unmodified form), as
this
is part of a script that does not know in advance how many levels there
arae
in f1.

Is there a way round this problem?

Many thanks
Mikhail Spivakov

Mikhail Spivakov PhD
Postdoctoral Fellow
EMBL/EBI
Germany/UK

[[alternative HTML version deleted]]

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

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


Re: [R] Empty Set In a Set

2008-04-30 Thread Duncan Murdoch

On 29/04/2008 9:39 PM, Jason Q. McClintic wrote:

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256

Dear List:

I'm looking for a form of the empty set such that if ES is said
representation,

~ES %in% c(1,2,3)

evaluates to TRUE.


%in% is a vector operator, checking each element of ES and returning a 
vector result.  It sounds like you want a subset test, i.e. to check 
that all the results are TRUE,


all(ES %in% c(1,2,3))

which returns TRUE when ES is empty.

Duncan Murdoch



Thank you in advance for your assistance.

Sincerely,

Jason Q. McClintic
- --
Jason Q McClintic
UST MB 1945
2115 Summit Avenue
St. Paul, MN 55105
[EMAIL PROTECTED]
[EMAIL PROTECTED]

It is insufficient to protect ourselves with laws, we must protect
ourselves with mathematics.--Bruce Schneier
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iQEVAwUBSBfN5hMtGNvij6jtAQgx3gf7Bxmht6ODCjsvhuFPkW1QWC1ey/ygVW9m
uuwNZVCz2hBNDSV2NktaOHe+hl3sEj4gmxv0Q6onf4Opg59o9OQ1EtaeY13S/ouk
EIO2fERY7VQcFbqjr1SnhlXGfyjX5bLk0ipFlqd11R+yXzFxzbafDtfcfKP+sp59
CQ8uZ2wAshPgrN5ZHIrg8RpBEWUnjH19iS4vDr40IrYyVbFLSnT1XM+D3kaMHgtc
oEi3wldigmSllX8KGVVp7DeXbEvUdrvsJgF1VLG/R8EFlMMHUVE1OD3d8SJ+y9Wh
SuVqWcL+aFXqJvjpQsQaE/2ywk8mis+46EjX1zcYKHPyoIoeqv4OdQ==
=tBx1
-END PGP SIGNATURE-

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


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


Re: [R] ggplot2: labels and breaks order does not match and I can't use scale_fill_identity

2008-04-30 Thread Xavier Chardon
The solution to this problem is in the mail below. I initially forgot to 
send a copy to the mailing list, and I'm doing it now for the record, in 
case someone bumps into this problem.


Xavier

 Message original 
Sujet: 	Re: [R] ggplot2: labels and breaks order does not match and I 
can't use scale_fill_identity

Date:   Tue, 29 Apr 2008 17:29:13 +0200
De: Xavier Chardon [EMAIL PROTECTED]
Répondre à ::   [EMAIL PROTECTED]
Pour :: Mikhail Spivakov [EMAIL PROTECTED]
Références: [EMAIL PROTECTED]



Hi,

I had a similar problem. I don't know if the solution will apply to your 
case but you might want to give it a try. It consists in including the 
following line before the plot is created:


res$f1 - factor(res$f1, levels = unique(res$f1) )

with f1 sorted in the order you want it to appear.


Xavier


Mikhail Spivakov a écrit :

Hi,

I'm plotting a bar chart like this:

ggplot() +
geom_bar(data=res,aes(fill=f1,x=f2,y=y),stat=identity,position=dodge)

f1 contains quite a few levels and the plot is really quite difficult to
read when the order of bars on the graph and on the legend does not match.

This problem has been discussed recently here:
http://www.nabble.com/ggplot2---legend-for-fill-coulours-td16235166.html
and the solution was to use scale_fill_identity to manually define the order
of both the breaks and the labels.
This is however unsuitable for me (at least in the unmodified form), as this
is part of a script that does not know in advance how many levels there arae
in f1.

Is there a way round this problem?

Many thanks
Mikhail Spivakov

Mikhail Spivakov PhD
Postdoctoral Fellow
EMBL/EBI
Germany/UK

[[alternative HTML version deleted]]

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

  


--
Xavier Chardon
Thésard Institut de l'élevage / INRA
Projet ACTA modélisation environnementale des systèmes bovins et porcins

[EMAIL PROTECTED]
[EMAIL PROTECTED]
02 23 48 50 91




--
Xavier Chardon
Thésard Institut de l'élevage / INRA
Projet ACTA modélisation environnementale des systèmes bovins et porcins

[EMAIL PROTECTED]
[EMAIL PROTECTED]
02 23 48 50 91

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


Re: [R] missing values in document

2008-04-30 Thread S Ellison
What exactly is on line 1743?

Genuinely empty cells will probably read as NA anyway. Excel errors, prefixed # 
in excel, will be read as comment markers and cause the remainder of the line 
to be ignored. This often causes this kind of error. 

Steve E
 Monna Nygård [EMAIL PROTECTED] 30/04/2008 11:51:16 

No matter how I´ve tried o find a solution for this simple question, I can´t. 
Sorry for bothering with such a matter.
 
I have an excel-files with some empty cells=missing values. How do I tell R 
that these should be NA´s? 
 
  TRFLP1 -(read.table(file=S://SEDIM//Kokeilu//TRFLP1.txt,col.names= 
 c(Dye_Sample Peak, Sample_File_Name, Size, Height, Area_in_Point, 
 Area_in_BP, Data_Point, Begin_Point, Begin_BP, End_Point, End_BP, 
 Width_in_Point, Width_in_BP, 1 ), header=F , dec = ,, )Error in 
 scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings,  :   line 
 1743 did not have 14 elements
 
I believe the error occurs becouse line 1743 has an empty cell. How do I read 
in the file without first checking for missing values and changing them to NAs 
myself?
 
Thank you for you time,
 
Monna Nygård
_


[[alternative HTML version deleted]]


***
This email and any attachments are confidential. Any use...{{dropped:8}}

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


Re: [R] missing values in document

2008-04-30 Thread Jim Lemon

Monna Nygård wrote:

No matter how I´ve tried o find a solution for this simple question, I can´t. 
Sorry for bothering with such a matter.
 
I have an excel-files with some empty cells=missing values. How do I tell R that these should be NA´s? 
 


TRFLP1 -(read.table(file=S://SEDIM//Kokeilu//TRFLP1.txt,col.names= c(Dye_Sample Peak, Sample_File_Name, Size, Height, Area_in_Point, Area_in_BP, 
Data_Point, Begin_Point, Begin_BP, End_Point, End_BP, Width_in_Point, Width_in_BP, 1 ), header=F , dec = ,, )Error in scan(file, what, 
nmax, sep, dec, quote, skip, nlines, na.strings,  :   line 1743 did not have 14 elements


 
I believe the error occurs becouse line 1743 has an empty cell. How do I read in the file without first checking for missing values and changing them to NAs myself?
 

Hi Monna,
read.table has an argument na.strings that allows you to specify what 
will be read as a missing value. Setting this to na.strings= should 
get you there.


Jim

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


Re: [R] + and - in RODBC : no longer considered factors

2008-04-30 Thread Dieter Menne
Prof Brian Ripley ripley at stats.ox.ac.uk writes:

 
 It is nothing to do with RODBC, which follows read.table here:
 
 % cat  foo.txt
 x
 +
 -
 ...
 
  read.table(foo.txt, header=TRUE)
x
 1 0
 2 0
 
 and that uses
 
  type.convert(c(+, -))
 [1] 0 0
  type.convert(c(+, a))
 [1] + a
 Levels: + a
 

Thank, Prof. Ripley, this makes sense as an explanation. So even 

a = type.convert(c(+, -),as.is=TRUE)
str(a)
# num [1:2] 0 0

does not help, because num bites first. Since the docs say
convert it it to logical, integer, numeric or complex

I would have expected this to be integer, but that's only of academic interest.
So the only workaround to make the large old code base to work is get the old
type.convert implementation and inject it.

Dieter

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


[R] rmvbin

2008-04-30 Thread Timmy Mutsvari
Hie all,

Anyone with an idea on how to generate binary data using (rmvbin) taking
into account covariates e.g age and gender.

Thanks

[[alternative HTML version deleted]]

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


[R] fCopulae

2008-04-30 Thread chockri adnen
Hello,

Hela wrote :

My problem in a few words is as folow:
I used the fCopulae packages because i have 2 series which are already
transformed in the uniform domain (the space of the copulas functions) and i
estimated with type archmList() from 1 to 22, but i don't know their
names:for exemple the type=4 is the Gumbel Copula...and for the others i
can't have any idea about how can i find teir names explicitly?
Please can you help me in this point?
Thank you.


Very Best Regards,

Adnen CHOCKRI

[[alternative HTML version deleted]]

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


Re: [R] Summary statistics across factor levels

2008-04-30 Thread Henrique Dallazuanna
Try this:

sek - seq(1, nrow(Indometh), 9)
Indometh$time[sek] - NA
Indometh$timeclass - factor(cut(Indometh$time, breaks=c(0,2,4,6,8,10)))
x - summary(conc ~ Subject + timeclass, method=cross, data=Indometh)
vec - x$S
dim(vec) - attr(x, out.attrs)$dim
dimnames(vec) - attr(x, out.attrs)$dimnames
as.data.frame(vec)

On Wed, Apr 30, 2008 at 7:27 AM, Lauri Nikkinen [EMAIL PROTECTED]
wrote:

 R users,

 I intention is to calculate some summary statistics across factor
 levels. I know that in Hmisc package there is a summary function which
 produces neat summary statistics when using cross option. I would
 like to produce similar output with N and Missing columns but produce
 a data.frame. Is there any built-in function for that?

 #example data
 install.packages(Hmisc)
 library(Hmisc)
 sek - seq(1, nrow(Indometh), 9)
 Indometh$time[sek] - NA
 Indometh$timeclass - factor(cut(Indometh$time, breaks=c(0,2,4,6,8,10)))
 Indometh
 with(Indometh, summary(conc ~ Subject + timeclass, method=cross))

 #similar with aggregate and reshape but no N or Missing count
 i.mean - aggregate(Indometh$conc, list(Indometh$Subject,
 Indometh$timeclass), mean, na.rm=T)
 i.mean.rhsp - reshape(i.mean, v.names=x, idvar=Group.1,
 timevar=Group.2, direction=wide)
 i.mean.rhsp  # N and missing columns needed

 Thanks,
 Lauri

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




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

[[alternative HTML version deleted]]

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


Re: [R] missing values in document

2008-04-30 Thread jim holtman
How are the 'empty' cell identified?  It appears that you are using
the default of read.table which says blanks are the delimiters.  How
are two or more empty cells identified?  Can you output a CSV file so
that you have commas as separators so you can identify the empty
fields?

On Wed, Apr 30, 2008 at 6:51 AM, Monna Nygård [EMAIL PROTECTED] wrote:

 No matter how I´ve tried o find a solution for this simple question, I can´t. 
 Sorry for bothering with such a matter.

 I have an excel-files with some empty cells=missing values. How do I tell R 
 that these should be NA´s?

   TRFLP1 -(read.table(file=S://SEDIM//Kokeilu//TRFLP1.txt,col.names= 
  c(Dye_Sample Peak, Sample_File_Name, Size, Height, Area_in_Point, 
  Area_in_BP, Data_Point, Begin_Point, Begin_BP, End_Point, 
  End_BP, Width_in_Point, Width_in_BP, 1 ), header=F , dec = ,, 
  )Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, 
   :   line 1743 did not have 14 elements

 I believe the error occurs becouse line 1743 has an empty cell. How do I read 
 in the file without first checking for missing values and changing them to 
 NAs myself?

 Thank you for you time,

 Monna Nygård
 _


[[alternative HTML version deleted]]


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





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

What is the problem you are trying to solve?

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


[R] fft: characteristic function to distribution

2008-04-30 Thread Thomas Steiner
The characteristic function is the inverse Fourier transform of the
distribution function. The characteristic function of a normaly
distributed random variable is exp(-t^2/2).

x=seq(-2,2,length=100)
fft(pnorm(x),inverse=T)/length(x)
exp(-x^2/2)

Why aren't the inverse fft and the mentioned function the same?
Thanks for help,
Thomas

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


Re: [R] Summary statistics across factor levels

2008-04-30 Thread Frank E Harrell Jr

Lauri Nikkinen wrote:

R users,

I intention is to calculate some summary statistics across factor
levels. I know that in Hmisc package there is a summary function which
produces neat summary statistics when using cross option. I would
like to produce similar output with N and Missing columns but produce
a data.frame. Is there any built-in function for that?


Take a look at the Hmisc summarize function.



#example data
install.packages(Hmisc)
library(Hmisc)
sek - seq(1, nrow(Indometh), 9)
Indometh$time[sek] - NA
Indometh$timeclass - factor(cut(Indometh$time, breaks=c(0,2,4,6,8,10)))
Indometh
with(Indometh, summary(conc ~ Subject + timeclass, method=cross))


If using summary I suggest summary(conc ~ Subject + cut2(time, 
c(0,2,4,6,8,10)), data=Indometh, method='cross')


Frank



#similar with aggregate and reshape but no N or Missing count
i.mean - aggregate(Indometh$conc, list(Indometh$Subject,
Indometh$timeclass), mean, na.rm=T)
i.mean.rhsp - reshape(i.mean, v.names=x, idvar=Group.1,
timevar=Group.2, direction=wide)
i.mean.rhsp  # N and missing columns needed

Thanks,
Lauri

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




--
Frank E Harrell Jr   Professor and Chair   School of Medicine
 Department of Biostatistics   Vanderbilt University

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


[R] Survival Regression with multiple records per subject

2008-04-30 Thread Fabian Hefner
Dear R users!

I reformulate the question with another example perhaps my question will be
more clearly now.
 
I have several subjects. One subject has multiple records. Only a starting
point exists the end point is vague.
Here is an example:
 
   itm  ID exercise  time
1.40186910 1
1.32439010 2
1.32439010 3
1.3810 4
1.34676110 5
1.31544111 6
1.33781220 1
1.31991520 2
1.35123521 3
itm is the covariate;
ID is the subject Id;
exercise indicates if the subject is dead=1 or alive=0
 
How can I allocate the multiple records to one subject (for example record
1-6 are part of subject with ID 1 record 7-9 are part of subject with ID2)
and process a survival regression.
 
the survRegData - survreg(formula=Surv(time,exercise)~itm, data=Data,
dist=weibull) command doesn't take into account that multiple records are
part of one subject.
 
Many thanks!
 
Fabian Hefner

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

2008-04-30 Thread John Lande
Dear Bioc,

I am using the stat.diag.da function from sma package in R-2.7.0 to make
class prediction in microarray dataset.

I would like to retrive the not only the classification, but also the raw
score assigned to each sample in order to be classified both in the training
and in the validation set.
how can I do that?

thank you


John

[[alternative HTML version deleted]]

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


Re: [R] Survival Regression with multiple records per subject

2008-04-30 Thread Dimitris Rizopoulos
If 'itm' is a covariate with measurement error, then you could also 
have a look at the 'JM' package.


I hope it helps.

Best,
Dimitris


Dimitris Rizopoulos
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/(0)16/336899
Fax: +32/(0)16/337015
Web: http://med.kuleuven.be/biostat/
http://www.student.kuleuven.be/~m0390867/dimitris.htm


- Original Message - 
From: Fabian Hefner [EMAIL PROTECTED]

To: 'Terry Therneau' [EMAIL PROTECTED]
Cc: r-help@r-project.org
Sent: Wednesday, April 30, 2008 1:25 PM
Subject: [R] Survival Regression with multiple records per subject



Dear R users!

I reformulate the question with another example perhaps my question 
will be

more clearly now.

I have several subjects. One subject has multiple records. Only a 
starting

point exists the end point is vague.
Here is an example:

  itm  ID exercise  time
1.40186910 1
1.32439010 2
1.32439010 3
1.3810 4
1.34676110 5
1.31544111 6
1.33781220 1
1.31991520 2
1.35123521 3
itm is the covariate;
ID is the subject Id;
exercise indicates if the subject is dead=1 or alive=0

How can I allocate the multiple records to one subject (for example 
record
1-6 are part of subject with ID 1 record 7-9 are part of subject 
with ID2)

and process a survival regression.

the survRegData - survreg(formula=Surv(time,exercise)~itm, 
data=Data,
dist=weibull) command doesn't take into account that multiple 
records are

part of one subject.

Many thanks!

Fabian Hefner

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

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




Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm

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


Re: [R] How do you test for consecutivity?

2008-04-30 Thread Karl Ove Hufthammer
Charles C. Berry:

 Are the numbers 1:30 equiprobable??
 
 If so, you can find the probability by direct enumeration.

Or by a simple formula:

* Probabilities of Consecutive Integers in Lotto
* Author(s): Stanley P. Gudder and James N. Hagler
* Source: Mathematics Magazine, Vol. 74, No. 3 (Jun., 2001), pp. 216-222
* Publisher: Mathematical Association of America
* Stable URL: http://www.jstor.org/stable/2690723

-- 
Karl Ove Hufthammer

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


Re: [R] c code working in linux and hanging in windows

2008-04-30 Thread Ben Bolker
Vidhu Choudhary vidhu.choudhary at gmail.com writes:

 
 Hi All,
 I am calling some c code from R.
 It successfully makes the dll and .so files.
 When I run .so in Linux is works prefect but hangs in windows. Though the
 dll loads but it never returns back from the c function
 
 Can you please suggest the possible cause of this
 
 thank you
 vidhu
 

   This isn't enough detail for us to work with (you 
might have gotten lucky and this problem would have rung
a bell for someone, but I guess not).  Therefore, you
need to go back and do the hard stuff -- try to create
a minimal example (you will often figure out the problem
in the process), tell us what versions of R, compiler, OS
you are using, etc etc etc ...

  Ben Bolker

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


Re: [R] Applying user function over a large matrix

2008-04-30 Thread Sudipta Sarkar
Dear Folks
Thanks for all your replies and suggestions, I will be trying
out these suggestions today and let you know how it goes.
Please let me know if you can think of anything else to
resolve the issue.
Regards

 Original message 
Date: Tue, 29 Apr 2008 15:43:41 -0700
From: Bert Gunter [EMAIL PROTECTED]  
Subject: Re: [R] Applying user function over a large matrix  
To: 'Ray Brownrigg' [EMAIL PROTECTED],
r-help@r-project.org
Cc: 'Tony Plate' [EMAIL PROTECTED]

If you can(one dimensional only), try using lowess() instead.
Probably in a
for loop as Ray suggested.

loess() is more powerful and flexible, but you pay for it in
extra
complexity and time. Maybe in this case, it's not worth it.

-- Bert Gunter
Genentech

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On
Behalf Of Ray Brownrigg
Sent: Tuesday, April 29, 2008 3:19 PM
To: r-help@r-project.org
Cc: Tony Plate
Subject: Re: [R] Applying user function over a large matrix

In addition to Tony's suggestion, have a look at the
following sequence,
which 
I suspect is because the call to apply will duplicate your
1.5GB matrix, 
whereas the for loop doesn't [I stand to be corrected here].

 x - matrix(runif(21), 21)
 unix.time({res - numeric(ncol(x)); for(i in 1:length(res))
res[i] - 
sum(x[, i])})
   user  system elapsed
  0.079   0.000   0.079
 unix.time(apply(x, 2, sum))
   user  system elapsed
   0.100.010.11
 x - matrix(runif(210), 21)
 unix.time({res - numeric(ncol(x)); for(i in 1:length(res))
res[i] - 
sum(x[, i])})
   user  system elapsed
  0.791   0.010   0.801
 unix.time(apply(x, 2, sum))
   user  system elapsed
  1.096   0.011   1.107
 x - matrix(runif(2100), 21)
 unix.time({res - numeric(ncol(x)); for(i in 1:length(res))
res[i] - 
sum(x[, i])})
   user  system elapsed
  7.825   0.011   7.840
 unix.time(apply(x, 2, sum))
   user  system elapsed
 15.431   0.142  15.592
 

Also, preliminary checking using the top utility shows the
for loop requires

just over half the memory of the apply() call.  This is on a
NetBSD system 
with 2GB memory.

HTH,
Ray Brownrigg

On Wed, 30 Apr 2008, Tony Plate wrote:
 It's quite possible that much of the time spent in loess()
is setting up
 the data (i.e., the formula, terms, model.frame, etc.), and
that much of
 that is repeated identically for each call to loess().  I
would suggest
 looking at the code of loess() and work out what arguments
it is calling
 simpleLoess() with, and then try calling
stats:::simpleLoess() directly. 
 (Of course you have to be careful with this because this is
not using the
 published API).

 -- Tony Plate

 Sudipta Sarkar wrote:
  Respected R experts,
  I am trying to apply a user function that basically calls and
  applies the R loess function from stat package over each time
  series. I have a large matrix of size 21 X 900 and I need
  to apply the loess for each column and hence I have
  implemented this separate user function that applies loess
  over each column and I am calling this function foo as
follows:
  xc-apply(t,2,foo) where t is my 21 X 900 matrix and
  loess. This is turning out to be a very slow process and I
  need to repeat this step for 25-30 such large matrix chunks.
  Is there any trick I can use to make this work faster?
  Any help will be deeply appreciated.
  Regards
 
 
  Sudipta Sarkar PhD
  Senior Analyst/Scientist
  Lanworth Inc. (Formerly Forest One Inc.)
  300 Park Blvd., Ste 425
  Itasca, IL
  Ph: 630-250-0468
 

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

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


Sudipta Sarkar PhD
Senior Analyst/Scientist
Lanworth Inc. (Formerly Forest One Inc.)
300 Park Blvd., Ste 425
Itasca, IL
Ph: 630-250-0468

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


Re: [R] Cross Spectrum Analysis

2008-04-30 Thread stephen sefick
 $names
 [1] freq  spec  coh   phase kerneldf
 [7] bandwidth n.usedorig.nseriessnamesmethod
[13] taper pad   detrend   demean

$freq and $spec are used to plot the power spectrum.  freq is the x-axis and
spec is the y-axis.  $coh is the squared coherency between the two signals
in your case and I believe that this is also plotted against frequency.
This is your correlation strength.  Phase I haven't been able to figure
out- I think that it is some sort of estimator for the phase shift.  to get
either phase or coherency plot add the plot.type argument to your plot
command

x - spectrum(yourdata, log=no) #this will plot it without a log scale I
find it useful to look at both the no log plot and then the logscale plot
(just remove the log=no)

plot(x, plot.type=marginal)  #this is the default type (the powerspectrum)
plot(x, plot.type=phase)
plot(x, plot.type=coherency)

also just look at

?spectrum
schumway is a good book - I think it is something like time series analysis
with examples in R

hope this helps

stephen


On Tue, Apr 29, 2008 at 8:54 PM, Maura E Monville [EMAIL PROTECTED]
wrote:

 I am reading some documentation about Cross Spectrum Analysis as a
 technique
 to compare spectra.
 My understanding is  that it estimates the correlation strength between
 quasi-periodic structures embedded in two signals. I believe it may be
 useful for my signals  analysis.

 I was referred to the R  functions that  implement this type of analysis.
 I
 tried all the examples which generated a series of fancy plots. But  I
 need
 to work on the numerical results.

 I have read that the following info is available through Cross Spectra
 analysis:
 *Cross-periodogram, Cross-Density, Quadrature-density, Cross-amplitude,
 Squared
 Coherency, Gain, and Phase Shift*
 I went through a couple of the two-series (bivariate) cross-spectrum
 analysis examples with R.
 I also printed out the attributes of the analysis (see the following). I
 cannot quite match the above quantities with the attributes/features
 output
 of cross-spectra analysis with R.
 I would greatly appreciate some explanation (which is what) and seeing
 some
 more worked out examples.

  attributes(mfdeaths.spc)
 $names
  [1] freq  spec  coh   phase kerneldf
  [7] bandwidth n.usedorig.nseriessnamesmethod
 [13] taper pad   detrend   demean

 $class
 [1] spec


 Thank you so much.

 Yours Faithfully,
 --
 Maura E.M

[[alternative HTML version deleted]]

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




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

-K. Mullis

[[alternative HTML version deleted]]

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


[R] Tab-delimited AOV summaries

2008-04-30 Thread Chris Sims
Hello,

I am trying to print out ANOVA summaries --- as returned by summary 
(aov(...))--- in tab-delimited format, either to a file or to the  
console, but so far I haven't been able to figure out a solution. My  
particular ANOVA has repeated measures, so it is an instance of class  
aovlist. Can anyone offer any suggestions? I am relatively new to R,  
so please forgive me if I am missing something obvious.

Regards,
-Chris

Chris R. Sims
Doctoral Student, Department of Cognitive Science
Rensselaer Polytechnic Institute
Troy, NY 12180


[[alternative HTML version deleted]]

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


Re: [R] NumDeriv - derivatives of covariance matrix

2008-04-30 Thread Paul Gilbert
Your calculation can be thought of as a function from R^m to R^(n*n), 
and functions in numDeriv can be used to calculate a numerical 
approximation to the derivative of the function. However, the functions 
in numDeriv try to calculate accurate approximations, as opposed to 
quick approximations like one might want in an optimization problem. 
Given that you already have an analytic solution, I doubt that even a 
quick approximation will be faster. You might better look at trying to 
convert parts of your double loop into vector or matrix calculations, or 
 focusing on the fact that the matrix is symmetric.


Paul Gilbert

Daomeng Gao wrote:

Hello R-help,

I need to compute matrices of first derivatives of a covariance matrix C
with entries given by c_ij=theta*exp(-0.5* sum(eta*(x[i,]-x[j,])^2)), wrt to
elements of eta, a m-dimensional vector of parameters, given a n*m data
matrix x. So far, I have been computing matrices for each parameter (given
by par[index]) analytically, using the following

kmatder- function(x, par, index) {
## x: n*m matrix
## par: vector of parameters, m=length(par)=ncol(x)
## compute matrix of partial derivatives wrt parameter par[index]: Cder
= d C/d par[index]
theta-1
  eta-par
n-nrow(x)
Cder-matrix(0,n,n)
for (i in 1:n) {
for (j in i:n) {
Cder[i,j]-(-0.5*((x[i,index]-x[j,index])^2))*theta*exp(-0.5*
sum(eta*(x[i,]-x[j,])^2))
}
}
Cder-0.5*(Cder+t(Cder))
Cder
}

I was wondering whether it might be possible to speed up things using
numDeriv (jacobian). If so, what would be the right way to implement a
suitable method ?

Cheers,
Gao Daomeng

[[alternative HTML version deleted]]

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



La version française suit le texte anglais.



This email may contain privileged and/or confidential in...{{dropped:26}}

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


Re: [R] Calling R from C - part way there but need a push!

2008-04-30 Thread Jeffrey Horner

Maximillian Murphy wrote on 04/29/2008 11:19 AM:


Dear All,


I've read the manual on Writing R Extensions and in particular the 
part on calling R from C.  (Most of the manual is about calling C from 
R, not the other way around.)


The good news is that I can now call _some_ R from C, specifically the R 
functions which have C header files.  However it isn't clear to me how 
to call R functions that are written in R.  I imagine that there is a 
standard C function of the form


Call_r_from_C(package name, Rfunction name as a string, arg1, arg2, 
...);


where arg1 etc are standardised ways of representing R data structures 
in C.  However I haven't been able to find such a function prototype in 
the R include/*.h files.  See footnote (1).  Can you point me in the 
right direction please?  Is there a set of examples somewhere that I can 
peruse?



Does R keep any state when being called from C?  Should I think of it as 
being a co-process, so I can make consecutive calls to it and expect it 
to remember previous calls?  I'm thinking of a sequence of calls such as 
load library,  load R code from a file of my own, set value of x, 
make a call and read the values back into my C program?



Help is much appreciated.


I would recommend studying the examples found in the tests/Embedding 
directory from the R sources. For instance, the following is from 
RNamedCall.c:


 /*
  Call the function foo() with 3 arguments, 2 of which
  are named.
   foo(pch=+, id = 123, c(T,F))

  Note that PrintValue() of the expression seg-faults.
  We have to set the print name correctly.
*/

void
bar1()
{
SEXP fun, pch;
SEXP e;

PROTECT(e = allocVector(LANGSXP, 4));
fun = findFun(install(foo), R_GlobalEnv);
if(fun == R_NilValue) {
	fprintf(stderr, No definition for function foo. Source foo.R and save 
the session.\n);

UNPROTECT(1);
exit(1);
}
SETCAR(e, fun);

SETCADR(e, mkString(+));
SET_TAG(CDR(e), install(pch));

SETCADDR(e, ScalarInteger(123));
SET_TAG(CDR(CDR(e)), install(id));

pch = allocVector(LGLSXP, 2);
LOGICAL(pch)[0] = TRUE;
LOGICAL(pch)[1] = FALSE;
SETCADDDR(e, pch);

PrintValue(e);
eval(e, R_GlobalEnv);

SETCAR(e, install(foo));
PrintValue(e);
R_tryEval(e, R_GlobalEnv, NULL);

UNPROTECT(1);
}

Best,

Jeff




Regards, Max


(1) The most likely include file is Rinterface.h and within that the 
most likely candidates seem to be:

extern int  (*ptr_R_ReadConsole)(const char *, unsigned char *, int, int);
extern void (*ptr_R_WriteConsole)(const char *, int);
extern void (*ptr_R_WriteConsoleEx)(const char *, int, int);

but it turns out that they assume that R is running the terminal and 
these are requests to R to display or read from R's console.  R isn't 
acting as the back end being given work and returning answers.


(2) Googling calling r from c yields precisely five hits, most of 
which just point back at the R extensions document with vague It's in 
there somewhere's.  I've looked!


(3) Leads suggested by help.search(C)
Foreign(base):
 Foreign Function Interface  Functions to make calls to compiled 
code that has been loaded into R.


.Internal(base) Call an Internal Function
 '.Internal' performs a call to an internal code which is built in
 to the R interpreter.

 Only true R wizards should even consider using this function, and
 only R developers can add to the list of internal functions.

 (Definitely not me!)

.Primitive(base)Call a Primitive Internal Function

 The advantage of '.Primitive' over '.Internal' functions is the
 potential efficiency of argument passing.

(4) R code that I have called successfully is that with prototypes 
defined in e.g. include/R_ext/Applic.h


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

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


Re: [R] + and - in RODBC : no longer considered factors

2008-04-30 Thread Prof Brian Ripley
So the only workaround to make the large old code base to work is get 
the old type.convert implementation and inject it.


That would be rather hard.  Try R-patched (from tomorrow, say) instead.

Note that in well over a month of testing no one else has reported this.

On Wed, 30 Apr 2008, Dieter Menne wrote:


Prof Brian Ripley ripley at stats.ox.ac.uk writes:



It is nothing to do with RODBC, which follows read.table here:

% cat  foo.txt
x
+
-
...


read.table(foo.txt, header=TRUE)

   x
1 0
2 0

and that uses


type.convert(c(+, -))

[1] 0 0

type.convert(c(+, a))

[1] + a
Levels: + a



Thank, Prof. Ripley, this makes sense as an explanation. So even

a = type.convert(c(+, -),as.is=TRUE)
str(a)
# num [1:2] 0 0

does not help, because num bites first. Since the docs say
convert it it to logical, integer, numeric or complex

I would have expected this to be integer, but that's only of academic interest.
So the only workaround to make the large old code base to work is get the old
type.convert implementation and inject it.

Dieter

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



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


Re: [R] Empty Set In a Set

2008-04-30 Thread Jason Q. McClintic

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256

Exactly what I needed.

Thanks to everyone who replied.

Sincerely,

Jason Q. McClintic
- --
MIDN 1/C Jason Q McClintic
Battalion Commander
Naval ROTC Battalion
University of Minnesota
UST MB 1945
2115 Summit Avenue
Saint Paul, MN 55105
[EMAIL PROTECTED]
[EMAIL PROTECTED]
(c) 763-442-3404

It is insufficient to protect ourselves with laws, we must protect
ourselves with mathematics.--Bruce Schneier

Duncan Murdoch wrote:
| On 29/04/2008 9:39 PM, Jason Q. McClintic wrote:
| Dear List:
|
| I'm looking for a form of the empty set such that if ES is said
| representation,
|
| ~ES %in% c(1,2,3)
|
| evaluates to TRUE.
|
| %in% is a vector operator, checking each element of ES and returning a
| vector result.  It sounds like you want a subset test, i.e. to check
| that all the results are TRUE,
|
| all(ES %in% c(1,2,3))
|
| which returns TRUE when ES is empty.
|
| Duncan Murdoch
|
| Thank you in advance for your assistance.
|
| Sincerely,
|
| Jason Q. McClintic
|
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

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

iQEVAwUBSBiD6BMtGNvij6jtAQj+awf+KNXnXImjCi/x0V+pYZI+3A41Pf3yRbXo
oV99Px/ymBjGjwO4q3rKnMZmJFNTr906MPziAgTKxVQ1tboJyGpF/KAhk8ASQhO0
JqxlpzlEMwVnfZlORgo9vOjmNyl5nGL4G5X8Q1Ta9HqrvovZk2MJooP7jg37uEJy
CaSLmGQrFiqQjdrXpDEfkmThUYQaAcpAKQtJFo3BeC3qjFeF2h+fK9lrFEb2bNX+
jCKWIZbJSdFHsxR6rZrsExcyE6uv+WCgPMb0WW9LXYR03mGMmin6Sr/xcqW6jXKJ
dzrXc6RmFlsgfdqg/afTYwk9CVzIyWjq9/4FT9+Muj7VKClnCYlMOA==
=fxWV
-END PGP SIGNATURE-

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


[R] wireframe - add data points

2008-04-30 Thread Strubbe Diederik
Hello all,

I’m trying to add some data points to a wireframe. X an Y axis are independent 
variables, Z axis is predicted probability. I’d like to add the original data 
points on which the predicted probabilities are based to the wireframe. I’ve 
followed some of the previous post on this but get stuck : 

## first part yields the wireframe##
setwd(C:/Temp)
 rnp - read.table(interact.csv,header=T,sep=;)
 status -rnp[,1:1]
 totalfrost - rnp[,2:2]
 logtps - rnp[,3:3]
 logpd - rnp[,4:4]
 logwinterp - rnp[,5:5]
model - 
glm(status~totalfrost+logtps+logpd+logwinterp+totalfrost*logtps+totalfrost*logwinterp,binomial)
abc - 
expand.grid(totalfrost=seq(-1.9,3.6,by=0.25),logtps=seq(-3.3,1.1,by=0.25),logpd=seq(0.95,4.1,
 by=0.25),logwinterp=seq(1.49,1.78, by=0.25))
abc$status -as.vector(predict(model,abc,type=response))

##below is the import of the original data together with their predicted 
probabilities##
punten - read.table(probs.csv,header=T,sep=;)
x - punten[,1:1]
y - punten[,2:2]
z - punten[,3:3]

pts - data.frame(x=x,y=y,z=z)
##end import original data##


wireframe(status~totalfrost*logtps,abc,scales=list(arrows=TRUE),drape=TRUE, 
screen =list (x=15, y=-50, z=-105), pts = pts,
panel.3d.wireframe =
  function(x, y, z,
   xlim, ylim, zlim,
   xlim.scaled, ylim.scaled, zlim.scaled,
   pts,
   ...) {
  panel.3dwire(x = x, y = y, z = z,
   xlim = xlim,
   ylim = ylim,
   zlim = zlim,
   xlim.scaled = xlim.scaled,
   ylim.scaled = ylim.scaled,
   zlim.scaled = zlim.scaled,
   ...)
  xx -
  xlim.scaled[1] + diff(xlim.scaled) *
  (pts$x - xlim[1]) / diff(xlim)
  yy -
  ylim.scaled[1] + diff(ylim.scaled) *
  (pts$y - ylim[1]) / diff(ylim)
  zz -
  zlim.scaled[1] + diff(zlim.scaled) *
  (pts$z - zlim[1]) / diff(zlim)
  panel.3dscatter(x = xx,
  y = yy,
  z = zz,
  xlim = xlim,
  ylim = ylim,
  zlim = zlim,
  xlim.scaled = xlim.scaled,
  ylim.scaled = ylim.scaled,
  zlim.scaled = zlim.scaled,
  ...)
  })

This yields me the following errors : 

Warning messages:
1: In Ops.factor(pts$x, xlim[1]) : - not meaningful for factors
2: In Ops.factor(pts$y, ylim[1]) : - not meaningful for factors
3: In Ops.factor(pts$z, zlim[1]) : - not meaningful for factors

Any idea about what is wrong and what to do about it?

Thanks!

Diederi


Diederik Strubbe
Evolutionary Ecology Group
Department of Biology, University of Antwerp
Universiteitsplein 1
B-2610 Antwerp, Belgium
http://webhost.ua.ac.be/deco
tel : 32 3 820 23 85


[[alternative HTML version deleted]]

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


Re: [R] fft: characteristic function to distribution

2008-04-30 Thread Prof Brian Ripley

On Wed, 30 Apr 2008, Thomas Steiner wrote:


The characteristic function is the inverse Fourier transform of the
distribution function. The characteristic function of a normaly
distributed random variable is exp(-t^2/2).


The fft is a discrete Fourier transforn, not a continuous one.
Further in each case where the normalizing constants are placed and the 
units of frequecy differ from source to source.


?fft has references to exactly what it computes: please consult them.



x=seq(-2,2,length=100)
fft(pnorm(x),inverse=T)/length(x)
exp(-x^2/2)

Why aren't the inverse fft and the mentioned function the same?
Thanks for help,
Thomas

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Test its performace on new data of a established neural network or SVM model

2008-04-30 Thread jrwang
Hi:

I have already using the MLInterface to train and build a neural network
model and SVM model to clustering a set of data.  Now I have a new set of
data.  I need use these established NN model and SVM to cluster these new
data without retraining it.  I am aware that I can use predict command to do
this in a linear regressing model.  Should I use predict command to do it?
Is there any other way to do this?


Weihsin Wang
Department of bioinformatics
ITRI, Taiwan


[[alternative HTML version deleted]]

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


Re: [R] Problem installing packages

2008-04-30 Thread Owe Jessen

Owe Jessen schrieb:

Hi,

when I try installing new packages (in this case DBI) I run into the 
following problem:


Paket 'DBI' erfolgreich ausgepackt und MD5 Summen abgeglichen
Warnung: kann temporäre Installation 
'C:\Programme\R\R-2.7.0\library\file5f906952\DBI' nicht nach 
'ÝxlDÌú [EMAIL PROTECTED]' verschieben


Has anybody any idea where these strange symbols come from?

Thanks in advance,
Owe


Excuse me for not giving much detail:

The OS is Win XP SP2, R is 2.7.0, DBI is 0.2-4, the mirror was 
Göttingen, but I had similar problems with Zürich.


A rough translation of the warning is:  Package 'DBI' successfully 
extracted and MD5 sums successfully checked. Warning: cannot move 
temporary installation 
'C:\Programme\R\R-2.7.0\library\file5f906952\DBI' to 'ÝxlDÌú 
[EMAIL PROTECTED]'. The cryptic part is not constant when i repeat 
the installation, another example is 
'ÝxlÔu [EMAIL PROTECTED]' or 'ÝxlÈ/w [EMAIL PROTECTED]'.


I hope this makes a bit more sense.

TIA
Owe

--
Owe Jessen
Diplom-Volkswirt
Von-der-Horst-Str. 9 
24118 Kiel


[EMAIL PROTECTED]
http://www.econinfo.de

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


[R] error with lme within a loop

2008-04-30 Thread Tomas Goicoa
Dear R users,

I want to conduct a small simulation study and I have to use the lme 
function in a loop to save the restricted log likelihood. 
However,  for one simulated data set the lme function gives this error


Error en lme.formula(yboot ~ X[, -1], data = data.fr, random = Z.block) :
   nlminb problem, convergence error code = 1
   message = singular convergence (7)

and then, the  simulation stops.   I would like to skip this 
simulated data,  and then continue with the loop, but I cannot find 
the way of doing this. I am using R2.6.2.

Can anybody tell me if I can write a condition to avoid the problematic data?

I Have also obtained similar errors

Error en lme.formula(yboot ~ X[, -1], data = data.fr, random = Z.block) :
   nlminb problem, convergence error code = 1
   message = false convergence (8)




My data can be reproduced as follows


library(splines)
library(nlme)


x-c(rep(1993:2007,9))
barrio-factor(c(rep(1:9,rep(15,9

xl-min(x)-0.1
xr-max(x)+0.1
ndx-4
bdeg-3
pord-2
dx - (xr-xl)/ndx
knots - seq(xl-bdeg*dx, xr+bdeg*dx, by=dx)

B-spline.des(knots,x,bdeg+1,0*x)$design

m=ncol(B)
D=diff(diag(m),differences=pord)
P=t(D)%*%D
P.svd=svd(t(D)%*%D)
U=(P.svd$u)[,1:(m-pord)]
d=(P.svd$d)[1:(m-pord)]
Delta=diag(1/sqrt(d))
Z=B%*%U%*%Delta
X=NULL
for(i in 0:(pord-1)){X=cbind(X,x^i)}

### This X and Z matrix are the matrices in the mixed model 
representation of a spline


n-nrow(X)
Id- factor(rep(1,n))
Z.block-list(list(Id=pdIdent(~Z-1)),list(barrio=pdIdent(~1)))
Z.block-unlist(Z.block,recursive=FALSE)

fijos2-c(-326.9178203,0.1645375 )
ef.spline-c(-0.2214524, -0.1649163, -0.1649163,  0.8878776, -0.2214524)

set.seed(48)
ef.error-rnorm(135,0,sqrt(0.03073974))

where

  ef.spline are standardized random effects, and errores are the residuals.




My loop looks like this


B-1000
y.boot-array(0,c(nrow(Z),B))
log.comp-array(0,B)


while(iB){
i-i+1
spline-sample(ef.spline,size=ncol(Z),replace=T)
errores-sample(ef.error,size=nrow(Z),replace=T)
y.boot[,i]-X%*%fijos2+Z%*%spline+errores
yboot-y.boot[,i]
data.fr - groupedData( yboot ~ X[,-1] |Id ,data = 
data.frame(yboot,X,Z,barrio))
log.comp[i]-lme(yboot~X[,-1],data=data.fr,random=Z.block)$logLik
}



The idea is to add a condition in the loop such that

if(condition..) {i-i-1}

and then substitute the problematic data by a new one,

Many thanks,

Tomas Goicoa 
[[alternative HTML version deleted]]

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


[R] checking whether a file is empty

2008-04-30 Thread Faheem Mitha


Hi,

Is there a way to check whether a file is empty in R. I did the customary 
searches, but did not find anything. Please cc me on any reply.

   Thanks, Faheem.

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


Re: [R] checking whether a file is empty

2008-04-30 Thread Prof Brian Ripley

What is wrong with


file.create(foo)

[1] TRUE

file.info(foo)$size

[1] 0

file.remove(foo)


?

I really wonder what searches you did: help.search(file) come up with 
file.info.



On Wed, 30 Apr 2008, Faheem Mitha wrote:

Is there a way to check whether a file is empty in R. I did the customary 
searches, but did not find anything. Please cc me on any reply.

  Thanks, Faheem.


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


Re: [R] checking whether a file is empty

2008-04-30 Thread Faheem Mitha



On Wed, 30 Apr 2008, Prof Brian Ripley wrote:


What is wrong with


file.create(foo)

[1] TRUE

file.info(foo)$size

[1] 0

file.remove(foo)


?


Thanks, that works for me.

I really wonder what searches you did: help.search(file) come up with 
file.info.


I did a Google search for R check file empty, R check file size and 
similar. Then I tried one of those R specific searches you can find on the 
web.


Then I did a help.search(empty). Probably not the best search term. It 
didn't occur to me to search for file.

  Faheem.

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


Re: [R] wireframe - add data points

2008-04-30 Thread Deepayan Sarkar
On 4/30/08, Strubbe Diederik [EMAIL PROTECTED] wrote:
 Hello all,

  I'm trying to add some data points to a wireframe. X an Y axis are 
 independent variables, Z axis is predicted probability. I'd like to add the 
 original data points on which the predicted probabilities are based to the 
 wireframe. I've followed some of the previous post on this but get stuck :

  ## first part yields the wireframe##
  setwd(C:/Temp)
   rnp - read.table(interact.csv,header=T,sep=;)
   status -rnp[,1:1]
   totalfrost - rnp[,2:2]
   logtps - rnp[,3:3]
   logpd - rnp[,4:4]
   logwinterp - rnp[,5:5]
  model - 
 glm(status~totalfrost+logtps+logpd+logwinterp+totalfrost*logtps+totalfrost*logwinterp,binomial)
  abc - 
 expand.grid(totalfrost=seq(-1.9,3.6,by=0.25),logtps=seq(-3.3,1.1,by=0.25),logpd=seq(0.95,4.1,
  by=0.25),logwinterp=seq(1.49,1.78, by=0.25))
  abc$status -as.vector(predict(model,abc,type=response))

  ##below is the import of the original data together with their predicted 
 probabilities##
  punten - read.table(probs.csv,header=T,sep=;)
  x - punten[,1:1]
  y - punten[,2:2]
  z - punten[,3:3]

  pts - data.frame(x=x,y=y,z=z)
  ##end import original data##


  wireframe(status~totalfrost*logtps,abc,scales=list(arrows=TRUE),drape=TRUE, 
 screen =list (x=15, y=-50, z=-105), pts = pts,
  panel.3d.wireframe =
   function(x, y, z,
xlim, ylim, zlim,
xlim.scaled, ylim.scaled, zlim.scaled,
pts,
...) {
   panel.3dwire(x = x, y = y, z = z,
xlim = xlim,
ylim = ylim,
zlim = zlim,
xlim.scaled = xlim.scaled,
ylim.scaled = ylim.scaled,
zlim.scaled = zlim.scaled,
...)
   xx -
   xlim.scaled[1] + diff(xlim.scaled) *
   (pts$x - xlim[1]) / diff(xlim)
   yy -
   ylim.scaled[1] + diff(ylim.scaled) *
   (pts$y - ylim[1]) / diff(ylim)
   zz -
   zlim.scaled[1] + diff(zlim.scaled) *
   (pts$z - zlim[1]) / diff(zlim)
   panel.3dscatter(x = xx,
   y = yy,
   z = zz,
   xlim = xlim,
   ylim = ylim,
   zlim = zlim,
   xlim.scaled = xlim.scaled,
   ylim.scaled = ylim.scaled,
   zlim.scaled = zlim.scaled,
   ...)
   })

  This yields me the following errors :

  Warning messages:
  1: In Ops.factor(pts$x, xlim[1]) : - not meaningful for factors
  2: In Ops.factor(pts$y, ylim[1]) : - not meaningful for factors
  3: In Ops.factor(pts$z, zlim[1]) : - not meaningful for factors

  Any idea about what is wrong and what to do about it?

Without access to the data, my only guess is that pty$x etc. are
factors. Can you show us tthe output of str(pts)?

-Deepayan

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


Re: [R] checking whether a file is empty

2008-04-30 Thread Jorge Ivan Velez
Hi Faheem,

Also, you could try in www.rseek.org and RSiteSearch(your.topic.here).

HTH,

Jorge


On Wed, Apr 30, 2008 at 11:53 AM, Faheem Mitha [EMAIL PROTECTED] wrote:



 On Wed, 30 Apr 2008, Prof Brian Ripley wrote:

  What is wrong with
 
   file.create(foo)
  
  [1] TRUE
 
   file.info(foo)$size
  
  [1] 0
 
   file.remove(foo)
  
 
  ?
 

 Thanks, that works for me.

  I really wonder what searches you did: help.search(file) come up with
  file.info.
 

 I did a Google search for R check file empty, R check file size and
 similar. Then I tried one of those R specific searches you can find on the
 web.

 Then I did a help.search(empty). Probably not the best search term. It
 didn't occur to me to search for file.
  Faheem.


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


[[alternative HTML version deleted]]

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


Re: [R] Problem installing packages

2008-04-30 Thread Prof Brian Ripley
The first message makes sense, but unfortunately if we cannot reproduce 
it, we cannot help.  The issue appears to be that your OS is garbling file 
names.


Is this is a translation back from German?  The original would appear to 
be


unable to move temporary installation '...' to '...'

Could you try a recent R-patched build?  There is a possibility that one 
of two fixes might have fixed this too.



On Wed, 30 Apr 2008, Owe Jessen wrote:


Owe Jessen schrieb:

Hi,

when I try installing new packages (in this case DBI) I run into the 
following problem:


Paket 'DBI' erfolgreich ausgepackt und MD5 Summen abgeglichen
Warnung: kann temporäre Installation 
'C:\Programme\R\R-2.7.0\library\file5f906952\DBI' nicht nach 'ÝxlDÌú 
[EMAIL PROTECTED]' verschieben


Has anybody any idea where these strange symbols come from?

Thanks in advance,
Owe


Excuse me for not giving much detail:

The OS is Win XP SP2, R is 2.7.0, DBI is 0.2-4, the mirror was Göttingen, but 
I had similar problems with Zürich.


A rough translation of the warning is:  Package 'DBI' successfully extracted 
and MD5 sums successfully checked. Warning: cannot move temporary 
installation 'C:\Programme\R\R-2.7.0\library\file5f906952\DBI' to 'ÝxlDÌú 
[EMAIL PROTECTED]'. The cryptic part is not constant when i repeat the 
installation, another example is 'ÝxlÔu [EMAIL PROTECTED]' or 
'ÝxlÈ/w [EMAIL PROTECTED]'.


I hope this makes a bit more sense.

TIA
Owe

--
Owe Jessen
Diplom-Volkswirt
Von-der-Horst-Str. 9 24118 Kiel

[EMAIL PROTECTED]
http://www.econinfo.de

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


Re: [R] checking whether a file is empty

2008-04-30 Thread Henrik Bengtsson
help(file.info).  /Henrik

On Wed, Apr 30, 2008 at 5:33 PM, Faheem Mitha [EMAIL PROTECTED] wrote:

  Hi,

  Is there a way to check whether a file is empty in R. I did the customary
 searches, but did not find anything. Please cc me on any reply.
Thanks, Faheem.

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


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


Re: [R] checking whether a file is empty

2008-04-30 Thread Dirk Eddelbuettel
On Wed, Apr 30, 2008 at 11:33:01AM -0400, Faheem Mitha wrote:
 Is there a way to check whether a file is empty in R. I did the customary 
 searches, but did not find anything. Please cc me on any reply.

Empty file have, by definition, a size of zero, so here's one way:

 system(touch /tmp/faheem)
 file.info(/tmp/faheem)$size == 0
[1] TRUE

Hth, Dirk
-- 
Three out of two people have difficulties with fractions.

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


[R] randomForest interaction detection

2008-04-30 Thread Retzer Joe
I've been using the randomForest package and getting very useful  
results for some time now.

I have a question pertaining to variable interactions. Since, unlike  
CART, no single tree representative of the solution is available, I  
was wondering if there was some way of discerning / identifying  
potential interactions in the data. I'll sometimes produce 2-way  
partial dependence plots but I select variables for these plots  
somewhat arbitrarily (i.e. without prior suggestion of interaction).

On Breimans’ website he mentions an experimental approach to identify  
interactions. I know this has come up before, a couple years ago, and  
Andy Liaw noted it was not implemented in part due to its experimental  
nature.

I was wondering if anyone had a suggestion for detecting interactions  
using the randomForest package (In an analogous manner to Breimans'  
suggestion or another approach).

Many Thanks,
Joe Retzer


[[alternative HTML version deleted]]

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


Re: [R] predict.glm newdata

2008-04-30 Thread Yasir Kaheil

You could just say:
yhat=predict(reg1,x2)
the function predict will assing x2 to 'newdata' by default.
thanks




Daniel Malter wrote:
 
 Hi,
 
 could it be the newdata argument? When I run predict with the newdata
 argument, I get an error message - a different one though. The second
 reason
 might be that your dataset is named df, which is defined as a function an
 may produce problems. Try renaming the dataset.
 
 yhat=predict(reg1,newdata=x2) 
 
 x1=seq(1:100)   
 r.norm1=rnorm(100,0,20) 
 x1=r.norm1+x1   
 
 x2=x1*2 
 r.norm2=rnorm(200,0,20) 
 x2=r.norm2+x2
 
 reg1=glm(y1~x1,binomial)  
 yhat=predict(reg1) ##prediction works fine   
 yhat=predict(reg1,newdata=x2) ##gives error message because of newdata
 
Error in eval(predvars, data, env) : 
   numeric 'envir' arg not of length one
 
 yhat=predict(reg1,data=x2) ##works fine
 
 ##using offset
 
 ofst=rep(0.5,100)
  
 reg1=glm(y1~x1,binomial,offset=ofst) 
 yhat=predict(reg1)   
 yhat1=predict(reg1,newdata=x2) ##gives error message   
 yhat2=predict(reg1,data=x2)  ##works fine   
 
 
 -
 cuncta stricte discussurus
 -
 
 -Ursprüngliche Nachricht-
 Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Im
 Auftrag von Tom Guston
 Gesendet: Friday, April 04, 2008 1:29 PM
 An: r-help@r-project.org
 Betreff: [R] predict.glm  newdata
 
 
 Hi all - 
 
 I'm stumped by the following
 
 mdl - glm(resp ~ . , data = df, family=binomial, offset = ofst) WORKS
 yhat
 - predict(mdl) WORKS yhat - predict(mdl,newdata = df) FAILS
 
 Error in drop(X[, piv, drop = FALSE] %*% beta[piv]) : 
   subscript out of bounds
 
 
 I've tried without offset, quoting binomial. The offset variable ofst IS
 in
 df.
 
 Previous postings indicate possible names(df) problems (renaming factor
 levels?) but I'm using the same data.frame for the newdata option.
 
 Thank you in advance for any pointers.
 
 Tom.
 
 
 
 
 _
 Going green? See the top 12 foods to eat organic.
 
 1N1653A
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
View this message in context: 
http://www.nabble.com/predict.glm---newdata-tp16501614p16986751.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] sudden problem with script

2008-04-30 Thread daniel guertin


Hi,

First off, please understand that I am not a frequent R user.  I am trying to 
use a script generated by another program in R for a certain analysis.  I have 
used the script successfully in the past.  Recently, when trying to load the 
script, I receive a warning message: package 'nls' has been merged with 
'stats'.  As a result, program R does not do the analysis.  Does anyone have 
any idea how to fix this sudden problem?  I have not done anything differently 
between my successful analyses and the current attempts.  Any advice would be 
greatly appreciated.

Thanks
Dan


_


=en-US?ocid=TAG_APRIL
[[alternative HTML version deleted]]

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


Re: [R] sudden problem with script

2008-04-30 Thread Daniel Nordlund
 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
 Of daniel guertin
 Sent: Wednesday, April 30, 2008 9:59 AM
 To: r-help@r-project.org
 Subject: [R] sudden problem with script
 
 
 
 Hi,
 
 First off, please understand that I am not a frequent R user.  I am trying to 
 use a script
 generated by another program in R for a certain analysis.  I have used the 
 script
 successfully in the past.  Recently, when trying to load the script, I 
 receive a warning
 message: package 'nls' has been merged with 'stats'.  As a result, program R 
 does not
 do the analysis.  Does anyone have any idea how to fix this sudden problem?  
 I have
 not done anything differently between my successful analyses and the current
 attempts.  Any advice would be greatly appreciated.
 
 Thanks
 Dan
 
 

My crystal ball is malfunctioning, so from way over here it is hard to see your 
code. Without seeing the script it is speculation, but the script likely has a 
reference to the package nls in a library statement.  Something like

   library(nls)

You can change that to 

   library(stats)

and the script will likely run.  But again, this is pure speculation.  

Dan

Daniel Nordlund
Bothell, WA USA
  

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


[R] Bug? in summary( ) function base package

2008-04-30 Thread Richard Saba
There seems to be an error in the summary() function when applied to ts
class objects. The results of a call to summary( ), on the R  ts data set
USAccDeaths , reports the wrong value for Max. The value reported by the
summary function is 11320. The max( ) function returns the correct value
11317, the July 1993 value. Coercing the data to a data.frame and calling
summary returns the correct max value. A search of R -help found a post in
2007 that mentioned a problem but attributed it to rounding errors. But this
is too large a difference to account for a simple rounding error. 

Has anyone else encountered the problem? Is there a workaround?


R version 2.6.2 Patched (2008-02-08 r44394)
Copyright (C) 2008 The R Foundation for Statistical Computing
ISBN 3-900051-07-0

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

 data(USAccDeaths)
 summary(USAccDeaths)
   Min. 1st Qu.  MedianMean 3rd Qu.Max. 
   68928089872887899323   11320 
 max(USAccDeaths)
[1] 11317
 USAccDeaths
   Jan   Feb   Mar   Apr   May   Jun   Jul   Aug   Sep   Oct   Nov   Dec
1973  9007  8106  8928  9137 10017 10826 11317 10744  9713  9938  9161  8927
1974  7750  6981  8038  8422  8714  9512 10120  9823  8743  9129  8710  8680
1975  8162  7306  8124  7870  9387  9556 10093  9620  8285  8466  8160  8034
1976  7717  7461  7767  7925  8623  8945 10078  9179  8037  8488  7874  8647
1977  7792  6957  7726  8106  8890  9299 10625  9302  8314  8850  8265  8796
1978  7836  6892  7791  8192  9115  9434 10484  9827  9110  9070  8633  9240

 dat1-as.data.frame(USAccDeaths)
 summary(dat1)
   x
 Min.   : 6892  
 1st Qu.: 8089  
 Median : 8728  
 Mean   : 8789  
 3rd Qu.: 9323  
 Max.   :11317  

Thanks,
R Saba

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


Re: [R] Bug? in summary( ) function base package

2008-04-30 Thread hadley wickham
On Wed, Apr 30, 2008 at 1:06 PM, Richard Saba [EMAIL PROTECTED] wrote:
 There seems to be an error in the summary() function when applied to ts
  class objects. The results of a call to summary( ), on the R  ts data set
  USAccDeaths , reports the wrong value for Max. The value reported by the
  summary function is 11320. The max( ) function returns the correct value
  11317, the July 1993 value. Coercing the data to a data.frame and calling
  summary returns the correct max value. A search of R -help found a post in
  2007 that mentioned a problem but attributed it to rounding errors. But this
  is too large a difference to account for a simple rounding error.

Notice that all the numbers in :

   summary(USAccDeaths)
Min. 1st Qu.  MedianMean 3rd Qu.Max.
68928089872887899323   11320

have four significant digits and then carefully read the documentation
for the digits argument of summary.  That should suggest both the
cause and a solution.

Hadley


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

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


[R] ordering a factor in boxplot output

2008-04-30 Thread Tubin

I'm sure I'm missing something obvious in the documentation...

I'm generating a boxplot 
boxplot(CleanValue~ApptCategory*ReportingCode,data=newfile)
where ApptCategory is a factor with possible values (New,Established)

Problem is, the output orders those factors alphabetically, and I'd really
rather see New come first. I'm apparently confused by the reorder function
because somehow my attempts to apply it have resulted in reversing the
labelling (so now the established boxes are labelled as new).

What am I missing?  Thanks.
-- 
View this message in context: 
http://www.nabble.com/ordering-a-factor-in-boxplot-output-tp16989073p16989073.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Use of recordPlot

2008-04-30 Thread Greg Snow
My impression of the plot recording in windows was that it was a quick tool to 
be useful, but not a high priority.  Trying to keep track of 50 plots (and 
using different plot windows) is pushing it beyond its original intention.  I 
expect that he core people have higher priorities, so may not even want to look 
at it for a while.
 
If you want to be able to scroll through 50 or so plots made by a script, I 
would suggest using the pdf device (or postscript) to write them all to a file, 
then open the file and use pgup/pgdn to scroll through the graphs.  This is a 
couple of extra steps, but I think it will work better for you at this point.



From: Beck, Kenneth (STP) [mailto:[EMAIL PROTECTED]
Sent: Mon 4/28/2008 8:53 AM
To: Greg Snow; r-help@r-project.org
Subject: RE: [R] Use of recordPlot



Thanks for the clarification, this helps a lot, expecially your comment
about source is real. I will stop my effort to save the graphs
permanently, the scripts don't take long to generate.

But the end of your response hits on the key issue: when I create
several graphs, I would like to be able to use PgUp/PgDn or some other
keystroke to easily scroll through them all in sequence. One of my
scripts now creates 30+ graphs, and to view them I have to mouse to the
list of graphics devices and pick off the list. Your last comment
indicates you can set it up to quick page through lists of graphs.
I just tried adding options(graphics.record=TRUE); to my code, and I now
find the .SavedPlots variable in the work space, but I was hoping to use
replayPlot(.SavedPlots) or something like that to be able to scroll
through the plots, but it does not seem to work.

Why do I not get anything when I ask for help (?.SavedPlots)?

Does this variable contain only those plots for which I call recordPlot?
At times it seems yes (e.g. only a few plots), but then later it seemed
to contain all that were generated by the script (nearly 50). When I
pick Previous/Next Plot or use PgUp/PgDn when viewing a graphcis Device,
the title bar stays on the latest graphics Device number, though the
graph itself may change. But then on further PgUp, I see only the
layout, not the graph.

When I use commands in the console to attempt to show graphs, I get a
warning suggesting the graph was saved in an older format, but I have
the latest R installed (2.6.2):

.SavedPlots[2] or replayPlot(.SavedPlots[2])
Warning message:
In replayPlot(x) : loading snapshot from pre-2.0.0 R version

Is there a simple command or series of commands to add to the script to
enable scrolling through all plots generated by that script? Or maybe
something at the beginning with something else at the end??

Thanks for your help...


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Greg Snow
Sent: Tuesday, April 22, 2008 10:43 AM
To: Beck, Kenneth (STP); r-help@r-project.org
Subject: Re: [R] Use of recordPlot

You seem to be confusing several issues.

First, being object oriented does not mean that it matches C++ syntax or
that every object is guarenteed to have specific methods.  What lead you
to think that a recordedplot would have a metafile method?  Nothing else
has that method, and the only function I find with metafile is the
win.metafile graphics device.

The difference between SavedPlots and recordedPlot is the same as the
difference between flock and sheep when talking about a flock of
sheep.  A recordedPlot object is a single plot, a SavedPlots object is a
group of recordedPlot objects (not the plural vs. singular).

Look at the help for objects or ls (?ls) and look at the 'all.names'
argument to see how to find .SavedPlots

R does not use object.method for method dispatch, trying that is
confusing the parser and that is why you get an error.  Try
method(object) instead.

Also recognize that R follows the philosophy of Source is Real. For
what you are trying to do, it will probably work better to write a
script or function that creates your plots, then rerun the code when you
want the plots again.  The current mechanism is useful for a quick
paging through plots, but was not meant for much more. 


--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[EMAIL PROTECTED]
(801) 408-8111



 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of Beck, Kenneth (STP)
 Sent: Monday, April 21, 2008 4:10 PM
 To: r-help@r-project.org
 Subject: [R] Use of recordPlot

 I am trying to save plots that I create using calls to
 windows() folowed by multiple calls to plot to place several plots on
 a page. I want to store the plots as variables to be able to recall
 them later.
 The documentation states:
 Recorded plot histories are of class SavedPlots. They have a print
 method, and a subset method.
 As the individual plots are of class recordedplot they can be
 replayed by printing them: see recordPlot.
 The active plot history is stored in variable 

[R] Aggregate() questions

2008-04-30 Thread Chip Barnaby

Dear all --

I have a data frame containing data related to heat gain through 
windows.  The general form is ...


Key  ProfAIAC   many other numeric columns
AAA0.7
AAA  10.6
AAA0   .66
AAA  20   .45
(more AAA rows)
(then AAB rows)

'Key' identifies the physical configuration ... rows with a given Key 
contain data for same window under various conditions.


I want to add a column IAC0 containing, for each Key, the mean IAC of 
all rows with ProfA == 0.


The general approach I think I need is approximately (the following 
is not known to run) --


1) XS-subset( X, ProfA  .01) to get the ProfA == 0 rows.  This 
could be done implicitly as part of step 2, I suppose.


2) X0-aggregate( XS[,IAC], by=list( Key=XS$Key), mean)

3) XF-merge( X, X0, by=Key)

4) Change new col name to IAC0 (see Question 2).

Question 1: Is this a reasonable way to solve my problem?

Question 2: The aggregate() result has 2 columns: Key and 
x.   Can the name of the mean column be specified (short of 
renaming after the fact)?  All the aggregate() examples (e.g. in 
help()) elegantly produce the right result with nicely named 
columns etc.  I can't seem to make things work so smoothly.


Thanks!

Chip Barnaby









-
Chip Barnaby   [EMAIL PROTECTED]
Vice President of Research
Wrightsoft Corp.   781-862-8719 x118 voice
131 Hartwell Ave   781-861-2058 fax
Lexington, MA 02421 www.wrightsoft.com

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


Re: [R] Survival Regression with multiple records per subject

2008-04-30 Thread Ronaldo Reis Junior
Em Qua 30 Abr 2008, Fabian Hefner escreveu:
 Here is an example:
  
    itm      ID     exercise      time
 1.401869    1        0             1
 1.324390    1        0             2
 1.324390    1        0             3
 1.38    1        0             4
 1.346761    1        0             5
 1.315441    1        1             6
 1.337812    2        0             1
 1.319915    2        0             2
 1.351235    2        1             3
 itm is the covariate;
 ID is the subject Id;
 exercise indicates if the subject is dead=1 or alive=0
  
 How can I allocate the multiple records to one subject (for example record
 1-6 are part of subject with ID 1 record 7-9 are part of subject with ID2)
 and process a survival regression.

Hi,

If I got it, the time must be converted to time to death, your table must be:

itm  ID exercise  time to death
 1.31544111 6
 1.35123521 3

The problem is your itm covariate, may be it must be converted to de 
difference between the first value and the last value.

Inte
Ronaldo
-- 
Send lawyers, guns and money...
-- Lyrics from a Warren Zevon song
--
 Prof. Ronaldo Reis Júnior
|  .''`. UNIMONTES/Depto. Biologia Geral/Lab. de Biologia Computacional
| : :'  : Campus Universitário Prof. Darcy Ribeiro, Vila Mauricéia
| `. `'` CP: 126, CEP: 39401-089, Montes Claros - MG - Brasil
|   `- Fone: (38) 3229-8187 | [EMAIL PROTECTED] | [EMAIL PROTECTED]
| http://www.ppgcb.unimontes.br/ | ICQ#: 5692561 | LinuxUser#: 205366

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


Re: [R] Aggregate() questions

2008-04-30 Thread Henrique Dallazuanna
If I understand your question:

 x$IAC0 - with(x, ave(IAC, list(ProfA, Key), FUN = mean))

On Wed, Apr 30, 2008 at 3:52 PM, Chip Barnaby [EMAIL PROTECTED]
wrote:

 Dear all --

 I have a data frame containing data related to heat gain through windows.
  The general form is ...

 Key  ProfAIAC   many other numeric columns
 AAA0.7
 AAA  10.6
 AAA0   .66
 AAA  20   .45
 (more AAA rows)
 (then AAB rows)

 'Key' identifies the physical configuration ... rows with a given Key
 contain data for same window under various conditions.

 I want to add a column IAC0 containing, for each Key, the mean IAC of all
 rows with ProfA == 0.

 The general approach I think I need is approximately (the following is not
 known to run) --

 1) XS-subset( X, ProfA  .01) to get the ProfA == 0 rows.  This could be
 done implicitly as part of step 2, I suppose.

 2) X0-aggregate( XS[,IAC], by=list( Key=XS$Key), mean)

 3) XF-merge( X, X0, by=Key)

 4) Change new col name to IAC0 (see Question 2).

 Question 1: Is this a reasonable way to solve my problem?

 Question 2: The aggregate() result has 2 columns: Key and x.   Can the
 name of the mean column be specified (short of renaming after the fact)?
  All the aggregate() examples (e.g. in help()) elegantly produce the right
 result with nicely named columns etc.  I can't seem to make things work so
 smoothly.

 Thanks!

 Chip Barnaby









 -
 Chip Barnaby   [EMAIL PROTECTED]
 Vice President of Research
 Wrightsoft Corp.   781-862-8719 x118 voice
 131 Hartwell Ave   781-861-2058 fax
 Lexington, MA 02421 www.wrightsoft.com

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




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

[[alternative HTML version deleted]]

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


[R] R isn't finding tcltk

2008-04-30 Thread John P. Burkett
On a x86 machine operating under Gentoo Linux, I'm having persistent 
difficulty in getting R version 2.6.1 (the latest available through 
Gentoo's portage system) to use tcltk.  The R command library(tcltk) 
elicits the following response:

Error in firstlib(which.lib.loc, package) :
  Tcl/Tk support is not available on this system
Error in library(tcltk) : .First.lib failed for 'tcltk'

After first encountering this problem, I took the following steps:
1. Made sure that installed programs include dev-lang/tcl, 
dev-tcltk/mysqltcl, dev-tcltk/otcl, dev-tcltk/tcl-debug, 
dev-tcltk/tcldom, dev-tcltk/tcllib, dev-tcltk/tclperl, 
dev-tcltk/tclpython, dev-tcltk/tclreadline, dev-tcltk/tclxml,

and dev-tcltk/tclxml-expat.
2. Verified that tcltk was installed by writing a little file hello.tcl, 
running the command tclsh hello.tcl, and observing that the output was 
correct.

3. Removed R by doing emerge -C R.
4. Set a tcltk USE flag for R by appending the line dev-lang/R tcltk
to my /etc/portage/package.use file.
5. Reinstalled R by doing emerge R

Then I started R and again tried library(tcltk).  The response was 
exactly the same before.


I would be very grateful for your suggestions for solving this problem.

Best regards,
John




--
John P. Burkett
Department of Environmental and Natural Resource Economics
and Department of Economics
University of Rhode Island
Kingston, RI 02881-0808
USA

phone (401) 874-9195

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

2008-04-30 Thread Vidhu Choudhary
Hi All,
My R code takes very long time to finish the processing. I want to see at
what stage the script is running. So I wrote some output messages using cat.
But instead of displaying the cat messages at different stages they are
buffered and displayed in the end when entire processing is done.
Can you please suggest how to stop this buffering or some alternative way to
display messages

Thank you
Vidhu

[[alternative HTML version deleted]]

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


Re: [R] How to stop buffering of cat

2008-04-30 Thread Tony Plate

If you're using Rgui under Windows, see FAQ 7.1:


7.1 When using Rgui the output to the console seems to be delayed.
This is deliberate: the console output is buffered ...


(the FAQ says how to turn it off -- it's a menu item).

Vidhu Choudhary wrote:

Hi All,
My R code takes very long time to finish the processing. I want to see at
what stage the script is running. So I wrote some output messages using cat.
But instead of displaying the cat messages at different stages they are
buffered and displayed in the end when entire processing is done.
Can you please suggest how to stop this buffering or some alternative way to
display messages

Thank you
Vidhu

[[alternative HTML version deleted]]

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



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


Re: [R] How to stop buffering of cat

2008-04-30 Thread Charles C. Berry

On Wed, 30 Apr 2008, Vidhu Choudhary wrote:


Hi All,
My R code takes very long time to finish the processing. I want to see at
what stage the script is running. So I wrote some output messages using cat.
But instead of displaying the cat messages at different stages they are
buffered and displayed in the end when entire processing is done.
Can you please suggest how to stop this buffering or some alternative way to
display messages


By reading the R for Windows FAQ??

7.1 When using Rgui the output to the console seems to be delayed.



Thank you
Vidhu

[[alternative HTML version deleted]]

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



Charles C. Berry(858) 534-2098
Dept of Family/Preventive Medicine
E mailto:[EMAIL PROTECTED]  UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901

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


[R] Why R is 200 times slower than Matlab ?

2008-04-30 Thread Zhandong Liu
I am switching from Matlab to R, but I found that R is 200 times slower than
matlab.

Since I am newbie to R, I must be missing some important programming tips.

Please help me out on this.

Here is the function:
## make the full pair-wise permutation of a vector
## input_fc=c(1,2,3);
## output_fc=(
1 1 1 2 2 2 3 3 3
1 2 3 1 2 3 1 2 3
);

grw_permute = function(input_fc){

fc_vector = input_fc

index = 1

k = length(fc_vector)

fc_matrix = matrix(0,2,k^2)

for(i in 1:k){

for(j in 1:k){

fc_matrix[index]  =  fc_vector[i]

fc_matrix[index+1]  =  fc_vector[j]

index = index+2

}

}

return(fc_matrix)

}

For an input vector of size 300. It took R 2.17 seconds to run.

But the same code in matlab only needs 0.01 seconds to run.

Am I missing sth in R.. Is there a away to optimize.  ???

Thanks

-- 
Zhandong Liu

Genomics and Computational Biology
University of Pennsylvania

616 BRB II/III, 421 Curie Boulevard
University of Pennsylvania School of Medicine
Philadelphia, PA 19104-6160

[[alternative HTML version deleted]]

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


Re: [R] R isn't finding tcltk

2008-04-30 Thread Peter Dalgaard

John P. Burkett wrote:
On a x86 machine operating under Gentoo Linux, I'm having persistent 
difficulty in getting R version 2.6.1 (the latest available through 
Gentoo's portage system) to use tcltk.  The R command library(tcltk) 
elicits the following response:

Error in firstlib(which.lib.loc, package) :
  Tcl/Tk support is not available on this system
Error in library(tcltk) : .First.lib failed for 'tcltk'

Hmm, so Gentoo's all-singing all-dancing build system is helping you 
install an obsolescent version incorrectly?


Can't you try building from plain sources? In particulat the output from 
the configure step should be informative.


Usually, it is a -devel package  that is missing, e.g. on  Fedora  you 
need not only


tk-8.4.17-2.fc8
tcl-8.4.17-1.fc8

but also

tk-devel-8.4.17-2.fc8
tcl-devel-8.4.17-1.fc8

   -pd


After first encountering this problem, I took the following steps:
1. Made sure that installed programs include dev-lang/tcl, 
dev-tcltk/mysqltcl, dev-tcltk/otcl, dev-tcltk/tcl-debug, 
dev-tcltk/tcldom, dev-tcltk/tcllib, dev-tcltk/tclperl, 
dev-tcltk/tclpython, dev-tcltk/tclreadline, dev-tcltk/tclxml,

and dev-tcltk/tclxml-expat.
2. Verified that tcltk was installed by writing a little file 
hello.tcl, running the command tclsh hello.tcl, and observing that 
the output was correct.

3. Removed R by doing emerge -C R.
4. Set a tcltk USE flag for R by appending the line dev-lang/R tcltk
to my /etc/portage/package.use file.
5. Reinstalled R by doing emerge R

Then I started R and again tried library(tcltk).  The response was 
exactly the same before.


I would be very grateful for your suggestions for solving this problem.

Best regards,
John







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

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


[R] How to fit parametric survival model using counting process data

2008-04-30 Thread Rachel Jia

Hi,

I was trying to fit a parametric survival model with Weibull distribution on
counting process type of data (NOT interval censor data), but the
survreg(Surv(T1,T2,event)~x,data,dist=weibull) did not seem to work.
Anyone can help me with that?

Thanks,

Rachel
Memorial Sloan-Kettering Cancer Center
-- 
View this message in context: 
http://www.nabble.com/How-to-fit-parametric-survival-model-using-counting-process-data-tp16990348p16990348.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Why R is 200 times slower than Matlab ?

2008-04-30 Thread Wensui Liu
Hi, ZD,
Your comment about speed is too general. Here is a benchmark
comparison among several languages and HTH.
http://www.sciviews.org/benchmark/index.html

On Wed, Apr 30, 2008 at 4:15 PM, Zhandong Liu
[EMAIL PROTECTED] wrote:
 I am switching from Matlab to R, but I found that R is 200 times slower than
  matlab.

  Since I am newbie to R, I must be missing some important programming tips.

  Please help me out on this.

  Here is the function:
  ## make the full pair-wise permutation of a vector
  ## input_fc=c(1,2,3);
  ## output_fc=(
  1 1 1 2 2 2 3 3 3
  1 2 3 1 2 3 1 2 3
  );

  grw_permute = function(input_fc){

  fc_vector = input_fc

  index = 1

  k = length(fc_vector)

  fc_matrix = matrix(0,2,k^2)

  for(i in 1:k){

  for(j in 1:k){

  fc_matrix[index]  =  fc_vector[i]

  fc_matrix[index+1]  =  fc_vector[j]

  index = index+2

  }

  }

  return(fc_matrix)

  }

  For an input vector of size 300. It took R 2.17 seconds to run.

  But the same code in matlab only needs 0.01 seconds to run.

  Am I missing sth in R.. Is there a away to optimize.  ???

  Thanks

  --
  Zhandong Liu

  Genomics and Computational Biology
  University of Pennsylvania

  616 BRB II/III, 421 Curie Boulevard
  University of Pennsylvania School of Medicine
  Philadelphia, PA 19104-6160

 [[alternative HTML version deleted]]

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




-- 
===
WenSui Liu
ChoicePoint Precision Marketing
Phone: 678-893-9457
Email : [EMAIL PROTECTED]
Blog : statcompute.spaces.live.com

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


[R] Getting variable names from as.matrix

2008-04-30 Thread David Kaplan

Hi all,

I'm running a multidimensional scaling model on data that are first 
transformed into a similarity matrix using the program daisy in the 
cluster package.  If I already provide the similarity matrix, the 
plotting routine will give me the variable names on the plot itself.  
But, it seems that when I use the daisy program to create the similarity 
matrix, I can't get the program to give me variable names on the plot.  
Here is the input



## Sammon's MDS

country.demog - read.csv(~/Desktop/country.demog.csv)

## daisy requires loading the cluster package.  It will calculate 
standardized Eculidean distances


country.demog.dist - daisy(country.demog,metric=euclidean,stand=TRUE)

## The following line calculates the ordinal MDS

country.mds - sammon(dist(country.demog.dist), k=2)

## The following lines create the MDS map using country names.  It also 
places horizontal and vertical lines for reference.


plot(country.mds$points,type=n)
text(country.mds$points, labels = as.character(country.demog$country))
abline(h=0)
abline(v=0)


Thanks for any advice,

David

--
===
David Kaplan, Ph.D.
Professor
Department of Educational Psychology
University of Wisconsin - Madison
Educational Sciences, Room, 1061
1025 W. Johnson Street
Madison, WI 53706

email: dkaplan at education dot wisc dot edu
homepage:
http://www.education.wisc.edu/edpsych/facstaff/kaplan/kaplan.htm
Phone: 608-262-0836

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


Re: [R] Why R is 200 times slower than Matlab ?

2008-04-30 Thread Gabor Csardi
I would rather not comment on matlab (where is
your matlab code by the way?), but your function
could be simplified a bit:

grw.permute - function(v) {
  cbind( rep(v, each=length(v)), rep(v, length(v)) )
}

 system.time(tmp - f( 1:300))
   user  system elapsed 
  0.020   0.000   0.019 

This is on my quite busy 4 years old laptop

Best,
Gabor

On Wed, Apr 30, 2008 at 04:15:46PM -0400, Zhandong Liu wrote:
 I am switching from Matlab to R, but I found that R is 200 times slower than
 matlab.
 
 Since I am newbie to R, I must be missing some important programming tips.
 
[...]

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

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

2008-04-30 Thread Claire Sheller
I have been trying to preform both a bartlett's test and an arcsine
transformation on some average percentage data. I've tried inputting it
different ways and I keep getting the same error message:

 head(workingdata)
   DYAD   BEFORE AFTER
1 BG-FL 4.606772  5.787520
2 BG-LL 5.467503  7.847395
3 AD-MV 5.333735 11.107380
4 MM-FL 5.578708 12.063500
5 MM-MV 2.037605  6.415303
6 MM-RM 6.158885 11.911080
 bartlett.test(BEFORE ~ AFTER)
Error in bartlett.test.default(c(4.606772, 5.467503, 5.333735, 5.578708,  :
  there must be at least 2 observations in each group
 asin(BEFORE)
[1] NaN NaN NaN NaN NaN NaN NaN
Warning message:
In asin(BEFORE) : NaNs produced

I'm at a loss here and I would greatly appreciate any guidance that could be
given me. Thank you!

-- 
Claire Sheller
Department of Anthropology
Tulane University
New Orleans, LA 70118
615-210-9129

[[alternative HTML version deleted]]

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


Re: [R] Why R is 200 times slower than Matlab ?

2008-04-30 Thread jim holtman
You just have to use the right functions: is this fast enough

 system.time(x - expand.grid(1:300, 1:300))
   user  system elapsed
   0.000.010.01



On Wed, Apr 30, 2008 at 4:15 PM, Zhandong Liu
[EMAIL PROTECTED] wrote:
 I am switching from Matlab to R, but I found that R is 200 times slower than
 matlab.

 Since I am newbie to R, I must be missing some important programming tips.

 Please help me out on this.

 Here is the function:
 ## make the full pair-wise permutation of a vector
 ## input_fc=c(1,2,3);
 ## output_fc=(
 1 1 1 2 2 2 3 3 3
 1 2 3 1 2 3 1 2 3
 );

 grw_permute = function(input_fc){

 fc_vector = input_fc

 index = 1

 k = length(fc_vector)

 fc_matrix = matrix(0,2,k^2)

 for(i in 1:k){

 for(j in 1:k){

 fc_matrix[index]  =  fc_vector[i]

 fc_matrix[index+1]  =  fc_vector[j]

 index = index+2

 }

 }

 return(fc_matrix)

 }

 For an input vector of size 300. It took R 2.17 seconds to run.

 But the same code in matlab only needs 0.01 seconds to run.

 Am I missing sth in R.. Is there a away to optimize.  ???

 Thanks

 --
 Zhandong Liu

 Genomics and Computational Biology
 University of Pennsylvania

 616 BRB II/III, 421 Curie Boulevard
 University of Pennsylvania School of Medicine
 Philadelphia, PA 19104-6160

[[alternative HTML version deleted]]

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




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

What is the problem you are trying to solve?

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


Re: [R] Bug? in summary( ) function base package

2008-04-30 Thread Mike Prager
Richard Saba [EMAIL PROTECTED] wrote:

 There seems to be an error in the summary() function when applied to ts
 class objects. The results of a call to summary( ), on the R  ts data set
 USAccDeaths , reports the wrong value for Max. The value reported by the
 summary function is 11320. The max( ) function returns the correct value
 11317, the July 1993 value. Coercing the data to a data.frame and calling
 summary returns the correct max value. A search of R -help found a post in
 2007 that mentioned a problem but attributed it to rounding errors. But this
 is too large a difference to account for a simple rounding error. 
 
 Has anyone else encountered the problem? Is there a workaround?

A documented feature of summary() is that it rounds values. In
doing so, it may print meaningless digits and thus give the
appearance of more precision than is really represented.

-- 
Mike Prager, NOAA, Beaufort, NC
* Opinions expressed are personal and not represented otherwise.
* Any use of tradenames does not constitute a NOAA endorsement.

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


Re: [R] Why R is 200 times slower than Matlab ?

2008-04-30 Thread Erik Iverson



Zhandong Liu wrote:

I am switching from Matlab to R, but I found that R is 200 times slower than
matlab.

Since I am newbie to R, I must be missing some important programming tips.


The most important tip I would give you is to use the vectorized nature 
of R whenever possible.  This helps avoid messy indexing and 'for' loops.


Look at the following 3 functions.  Yours, Gabor's, and my own (which I 
was about to post when I saw Gabor's nice solution, and is basically the 
same).


Also see the system timings after the definitions.

grw_permute - function(input_fc){
  fc_vector - input_fc
  index - 1
  k - length(fc_vector)
  fc_matrix - matrix(0, 2, k^2)

  for(i in 1:k){
for(j in 1:k){
  fc_matrix[index]  -  fc_vector[i]
  fc_matrix[index+1]  -  fc_vector[j]
  index - index + 2
}
  }
  return(fc_matrix)
}

grw.permute2 - function(v) {
  cbind( rep(v, each=length(v)), rep(v, length(v)) )
}


grw_permute3 - function(input_fc) {
  matrix(c(rep(input_fc, each = length(input_fc)),
   rep.int(input_fc, times = length(input_fc))),
 nrow = 2, byrow = TRUE)
}

 system.time(p1 - grw_permute(1:300))
   user  system elapsed
  1.548   0.064   2.341
 system.time(p2 - grw_permute2(1:300))
   user  system elapsed
  0.009   0.001   0.010
 system.time(p3 - grw_permute3(1:300))
   user  system elapsed
  0.008   0.002   0.010


Erik Iverson

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


Re: [R] Why R is 200 times slower than Matlab ?

2008-04-30 Thread Gabor Csardi
But please consider that this benchmark is five years old, and i believe 
that R has changed quite a lot since version 1.9. 

Gabor

On Wed, Apr 30, 2008 at 04:21:51PM -0400, Wensui Liu wrote:
 Hi, ZD,
 Your comment about speed is too general. Here is a benchmark
 comparison among several languages and HTH.
 http://www.sciviews.org/benchmark/index.html
 
[...]

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

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


Re: [R] Why R is 200 times slower than Matlab ?

2008-04-30 Thread Peter Dalgaard

Zhandong Liu wrote:

I am switching from Matlab to R, but I found that R is 200 times slower than
matlab.

Since I am newbie to R, I must be missing some important programming tips.

Please help me out on this.

Here is the function:
## make the full pair-wise permutation of a vector
## input_fc=c(1,2,3);
## output_fc=(
1 1 1 2 2 2 3 3 3
1 2 3 1 2 3 1 2 3
);

grw_permute = function(input_fc){

fc_vector = input_fc

index = 1

k = length(fc_vector)

fc_matrix = matrix(0,2,k^2)

for(i in 1:k){

for(j in 1:k){

fc_matrix[index]  =  fc_vector[i]

fc_matrix[index+1]  =  fc_vector[j]

index = index+2

}

}

return(fc_matrix)

}

For an input vector of size 300. It took R 2.17 seconds to run.

But the same code in matlab only needs 0.01 seconds to run.

Am I missing sth in R.. Is there a away to optimize.  ???

Thanks

  
This is pretty characteristic. With R, you really don't want nested 
loops doing single-element accessing (if you have better things to do 
with 2.16 seconds of our life). You will usually find that this sort of 
problem is handled either using vectorized operations at a higher level, 
or pushed into C code which is dynamically loaded. For the particular 
problem, notice that the same result is obtained with


 system.time(rbind(rep(1:300,300),rep(1:300,each=300)))
  user  system elapsed
 0.041   0.006   0.050

or even (OK, so it's transposed)

 system.time(expand.grid(1:300,1:300))
  user  system elapsed
 0.027   0.011   0.040


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

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


Re: [R] ordering a factor in boxplot output

2008-04-30 Thread Peter Alspach
One option is to set the order in newfile:

newfile$ApptCategory - factor(newfile$ApptCategory,
levels=c('New','Established'))

Of course, this will then affect the order for other things associated
with ApptCategory, but that is probably what you want.

HTH ...

Peter Alspach


 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Tubin
 Sent: Thursday, 1 May 2008 6:40 a.m.
 To: r-help@r-project.org
 Subject: [R] ordering a factor in boxplot output
 
 
 I'm sure I'm missing something obvious in the documentation...
 
 I'm generating a boxplot
 boxplot(CleanValue~ApptCategory*ReportingCode,data=newfile)
 where ApptCategory is a factor with possible values 
 (New,Established)
 
 Problem is, the output orders those factors alphabetically, 
 and I'd really rather see New come first. I'm apparently 
 confused by the reorder function because somehow my 
 attempts to apply it have resulted in reversing the labelling 
 (so now the established boxes are labelled as new).
 
 What am I missing?  Thanks.
 --
 View this message in context: 
 http://www.nabble.com/ordering-a-factor-in-boxplot-output-tp16
 989073p16989073.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 

The contents of this e-mail are privileged and/or confidential to the named
 recipient and are not to be used by any other person and/or organisation.
 If you have received this e-mail in error, please notify the sender and delete
 all material pertaining to this e-mail.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Fwd: Why R is 200 times slower than Matlab ?

2008-04-30 Thread roger koenker

This is what I refer to as ab uno disce omnes-thinking:
-- from one example all is revealed -- but this is the antithesis
of statistical thinking.

Here is an example function, others can probably do better.
On a vector of length 300 it takes .018 seconds on my aging
G5 ppc mac:

pears - function(x){
n - length(x)
A - combos(n,2)
rbind(x[A[1,]],x[A[2,]])
}

This is actually a (shameless) advertisement for the function
combos in my quantreg package which uses a slightly fancy
algorithm to order the n choose p indices as, say produced
by base R's combn() in such a way that adjacent columns
differ by only one element.

PS.  Isn't there a better way to do the indexing on the last line?


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 Apr 30, 2008, at 3:15 PM, Zhandong Liu wrote:

I am switching from Matlab to R, but I found that R is 200 times  
slower than

matlab.

Since I am newbie to R, I must be missing some important programming  
tips.


Please help me out on this.

Here is the function:
## make the full pair-wise permutation of a vector
## input_fc=c(1,2,3);
## output_fc=(
1 1 1 2 2 2 3 3 3
1 2 3 1 2 3 1 2 3
);

grw_permute = function(input_fc){

fc_vector = input_fc

index = 1

k = length(fc_vector)

fc_matrix = matrix(0,2,k^2)

for(i in 1:k){

for(j in 1:k){

fc_matrix[index]  =  fc_vector[i]

fc_matrix[index+1]  =  fc_vector[j]

index = index+2

}

}

return(fc_matrix)

}

For an input vector of size 300. It took R 2.17 seconds to run.

But the same code in matlab only needs 0.01 seconds to run.

Am I missing sth in R.. Is there a away to optimize.  ???

Thanks

--
Zhandong Liu

Genomics and Computational Biology
University of Pennsylvania

616 BRB II/III, 421 Curie Boulevard
University of Pennsylvania School of Medicine
Philadelphia, PA 19104-6160

[[alternative HTML version deleted]]

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


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


Re: [R] arcsine transformation

2008-04-30 Thread Michael Kubovy
Perhaps you need
with(workingdata, asin(BEFORE))
or
asin(workingdata$BEFORE)
_
Professor Michael Kubovy
University of Virginia
Department of Psychology
USPS: P.O.Box 400400Charlottesville, VA 22904-4400
Parcels:Room 102Gilmer Hall
 McCormick RoadCharlottesville, VA 22903
Office:B011+1-434-982-4729
Lab:B019+1-434-982-4751
Fax:+1-434-982-4766
WWW:http://www.people.virginia.edu/~mk9y/

On Apr 30, 2008, at 4:52 PM, Claire Sheller wrote:

 I have been trying to preform both a bartlett's test and an arcsine
 transformation on some average percentage data. I've tried inputting  
 it
 different ways and I keep getting the same error message:

 head(workingdata)
   DYAD   BEFORE AFTER
 1 BG-FL 4.606772  5.787520
 2 BG-LL 5.467503  7.847395
 3 AD-MV 5.333735 11.107380
 4 MM-FL 5.578708 12.063500
 5 MM-MV 2.037605  6.415303
 6 MM-RM 6.158885 11.911080
 bartlett.test(BEFORE ~ AFTER)
 Error in bartlett.test.default(c(4.606772, 5.467503, 5.333735,  
 5.578708,  :
  there must be at least 2 observations in each group
 asin(BEFORE)
 [1] NaN NaN NaN NaN NaN NaN NaN
 Warning message:
 In asin(BEFORE) : NaNs produced

 I'm at a loss here and I would greatly appreciate any guidance that  
 could be
 given me. Thank you!

 -- 
 Claire Sheller
 Department of Anthropology
 Tulane University
 New Orleans, LA 70118
 615-210-9129


[[alternative HTML version deleted]]

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


Re: [R] Why R is 200 times slower than Matlab ?

2008-04-30 Thread Ray Brownrigg
On Thu, 01 May 2008, Zhandong Liu wrote:
 I am switching from Matlab to R, but I found that R is 200 times slower
 than matlab.

 Since I am newbie to R, I must be missing some important programming tips.

 Please help me out on this.

 Here is the function:
 ## make the full pair-wise permutation of a vector
 ## input_fc=c(1,2,3);
 ## output_fc=(
 1 1 1 2 2 2 3 3 3
 1 2 3 1 2 3 1 2 3
 );

 grw_permute = function(input_fc){

 fc_vector = input_fc

 index = 1

 k = length(fc_vector)

 fc_matrix = matrix(0,2,k^2)

 for(i in 1:k){

 for(j in 1:k){

 fc_matrix[index]  =  fc_vector[i]

 fc_matrix[index+1]  =  fc_vector[j]

 index = index+2

 }

 }

 return(fc_matrix)

 }

 For an input vector of size 300. It took R 2.17 seconds to run.

 But the same code in matlab only needs 0.01 seconds to run.

I am not a MATLAB user, but I suspect it wasn't the same code that produced 
an answer in MATLAB, but you don't provide your MATLAB code, nor do you 
specify what version of R, of MATLAB, or what hardware and OS you are using.

I get {NetBSD, R version 2.6.0 (2007-10-03), Core 2 Duo, 3.x GHz}:
 input_fc - sample(1:600)
 unix.time(a1 - grw_permute(input_fc))
   user  system elapsed
  3.279  -0.001   3.280
 unix.time({n - length(input_fc); a2 - matrix(c(rep(input_fc, each=n), 
rep(input_fc, n)), 2, n*n, byrow = T)})
   user  system elapsed
  0.019   0.020   0.040
 all.equal(a1, a2)
[1] TRUE
   
A sample of length 300 took less than 1 second using your grw_permute() (so 
your OS may be making a difference as well).

 Am I missing sth in R.. Is there a away to optimize.  ???

Yes. Loops are not efficient in R.

 Thanks

HTH,
Ray Brownrigg

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

2008-04-30 Thread Mark Wardle
Dear all,

I haven't seen this mentioned and presumably Dr. Deepayan Sarkar is
too polite to advertise!

I just received a flyer from Springer: A new book on Lattice released today!!

http://www.springer.com/statistics/computational/book/978-0-387-75968-5?cm_mmc=NBA-_-Apr-08_UK_1753460-_-product-_-978-0-387-75968-5

http://www.amazon.co.uk/exec/obidos/ASIN/0387759689/ref=ord_cart_shr?%5Fencoding=UTF8m=A3P5ROKL5A1OLE

Well done and many congratulations. My order is being processed as we speak!

Best wishes,

Mark
-- 
Dr. Mark Wardle
Specialist registrar, Neurology
Cardiff, UK

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


Re: [R] Why R is 200 times slower than Matlab ?

2008-04-30 Thread Zhandong Liu
This is the missing Matlab code:

function[fc_matrix]=grw_permute(fc_vector)



n=length(fc_vector);



fc_matrix=zeros(2,n^2);



index=1;

for i=1:n

for j=1:n

fc_matrix(index)=fc_vector(i);

fc_matrix(index+1)=fc_vector(j);

index=index+2;

end

end






On Wed, Apr 30, 2008 at 4:47 PM, Ray Brownrigg [EMAIL PROTECTED]
wrote:

 On Thu, 01 May 2008, Zhandong Liu wrote:
  I am switching from Matlab to R, but I found that R is 200 times slower
  than matlab.
 
  Since I am newbie to R, I must be missing some important programming
 tips.
 
  Please help me out on this.
 
  Here is the function:
  ## make the full pair-wise permutation of a vector
  ## input_fc=c(1,2,3);
  ## output_fc=(
  1 1 1 2 2 2 3 3 3
  1 2 3 1 2 3 1 2 3
  );
 
  grw_permute = function(input_fc){
 
  fc_vector = input_fc
 
  index = 1
 
  k = length(fc_vector)
 
  fc_matrix = matrix(0,2,k^2)
 
  for(i in 1:k){
 
  for(j in 1:k){
 
  fc_matrix[index]  =  fc_vector[i]
 
  fc_matrix[index+1]  =  fc_vector[j]
 
  index = index+2
 
  }
 
  }
 
  return(fc_matrix)
 
  }
 
  For an input vector of size 300. It took R 2.17 seconds to run.
 
  But the same code in matlab only needs 0.01 seconds to run.

 I am not a MATLAB user, but I suspect it wasn't the same code that
 produced
 an answer in MATLAB, but you don't provide your MATLAB code, nor do you
 specify what version of R, of MATLAB, or what hardware and OS you are
 using.

 I get {NetBSD, R version 2.6.0 (2007-10-03), Core 2 Duo, 3.x GHz}:
  input_fc - sample(1:600)
  unix.time(a1 - grw_permute(input_fc))
   user  system elapsed
  3.279  -0.001   3.280
  unix.time({n - length(input_fc); a2 - matrix(c(rep(input_fc, each=n),
 rep(input_fc, n)), 2, n*n, byrow = T)})
   user  system elapsed
  0.019   0.020   0.040
  all.equal(a1, a2)
 [1] TRUE
 
 A sample of length 300 took less than 1 second using your grw_permute()
 (so
 your OS may be making a difference as well).
 
  Am I missing sth in R.. Is there a away to optimize.  ???
 
 Yes. Loops are not efficient in R.

  Thanks

 HTH,
 Ray Brownrigg




-- 
Zhandong Liu

Genomics and Computational Biology
University of Pennsylvania

616 BRB II/III, 421 Curie Boulevard
University of Pennsylvania School of Medicine
Philadelphia, PA 19104-6160

[[alternative HTML version deleted]]

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


Re: [R] Why R is 200 times slower than Matlab ?

2008-04-30 Thread Ray Brownrigg
Ah, so the code is quite similar in MATLAB (and the *algorithm* is the 
same :-) ).

The Important programming tip is that when converting from MATLAB to R, you 
shouldn't just 'translate' from MATLAB code to R code, you must reconsider 
the problem in the context of the R environment.  This is very much like 
translating poetry, where the result should really be a poem in the target 
language, not just an accurate word-for-word (or even sentence-for-sentence) 
translation.

Ray

On Thu, 01 May 2008, you wrote:
 This is the missing Matlab code:

 function[fc_matrix]=grw_permute(fc_vector)



 n=length(fc_vector);



 fc_matrix=zeros(2,n^2);



 index=1;

 for i=1:n

 for j=1:n

 fc_matrix(index)=fc_vector(i);

 fc_matrix(index+1)=fc_vector(j);

 index=index+2;

 end

 end






 On Wed, Apr 30, 2008 at 4:47 PM, Ray Brownrigg
 [EMAIL PROTECTED]

 wrote:
  On Thu, 01 May 2008, Zhandong Liu wrote:
   I am switching from Matlab to R, but I found that R is 200 times slower
   than matlab.
  
   Since I am newbie to R, I must be missing some important programming
 
  tips.
 
   Please help me out on this.
  
   Here is the function:
   ## make the full pair-wise permutation of a vector
   ## input_fc=c(1,2,3);
   ## output_fc=(
   1 1 1 2 2 2 3 3 3
   1 2 3 1 2 3 1 2 3
   );
  
   grw_permute = function(input_fc){
  
   fc_vector = input_fc
  
   index = 1
  
   k = length(fc_vector)
  
   fc_matrix = matrix(0,2,k^2)
  
   for(i in 1:k){
  
   for(j in 1:k){
  
   fc_matrix[index]  =  fc_vector[i]
  
   fc_matrix[index+1]  =  fc_vector[j]
  
   index = index+2
  
   }
  
   }
  
   return(fc_matrix)
  
   }
  
   For an input vector of size 300. It took R 2.17 seconds to run.
  
   But the same code in matlab only needs 0.01 seconds to run.
 
  I am not a MATLAB user, but I suspect it wasn't the same code that
  produced
  an answer in MATLAB, but you don't provide your MATLAB code, nor do you
  specify what version of R, of MATLAB, or what hardware and OS you are
  using.
 
  I get {NetBSD, R version 2.6.0 (2007-10-03), Core 2 Duo, 3.x GHz}:
   input_fc - sample(1:600)
   unix.time(a1 - grw_permute(input_fc))
 
user  system elapsed
   3.279  -0.001   3.280
 
   unix.time({n - length(input_fc); a2 - matrix(c(rep(input_fc, each=n),
 
  rep(input_fc, n)), 2, n*n, byrow = T)})
user  system elapsed
   0.019   0.020   0.040
 
   all.equal(a1, a2)
 
  [1] TRUE
 
  A sample of length 300 took less than 1 second using your grw_permute()
  (so
  your OS may be making a difference as well).
 
   Am I missing sth in R.. Is there a away to optimize.  ???
 
  Yes. Loops are not efficient in R.
 
   Thanks
 
  HTH,
  Ray Brownrigg

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


[R] why my code is not computing significance level and power correctly

2008-04-30 Thread jinjin

I am trying to compare Levene,bartlett, count5 tests for a random normal
sample for the significance level and power, the problem seems bug free but
with obvious wrong result, anyone can help, I send the R code as attachment.
Thanks http://www.nabble.com/file/p16992744/758%2Bproject 758+project 
-- 
View this message in context: 
http://www.nabble.com/why-my-code-is-not-computing-significance-level-and-power-correctly-tp16992744p16992744.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] efficiency profiling? (was: Why R is 200 times slower than Matlab ?)

2008-04-30 Thread esmail bonakdarian

This has been an interesting discussion, and brings up two questions
for me:

Is there a good collection of hints/suggestions for R language idoms in terms
of efficiency? For instance I read not to use for-loops, so I used apply only to
later read that apply is internally implemented as a for so nothing gained
here. Warnings about pitfalls (such as nested loops), hints, suggestions would
be great.

The second question - is there some sort of profiling tool available that would
make it easy to recognize where the script is spending most of its time? Might
be especially useful for newbies like me.

Thanks all,

Esmail

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

_
Spell a grand slam in this game where word skill meets World Series. Get in the 
game.

08
[[alternative HTML version deleted]]

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


Re: [R] Lattice book

2008-04-30 Thread Charilaos Skiadas
Actually it's been out for a couple of weeks now at least. I just  
finished my first reading of it, and I must say it was spectacular.  
Congratulations Deepayan, the book gave me exactly the kind of  
lattice knowledge I needed, and then some. The graphics are really  
impressive and good illustrations of what lattice can do, and I found  
the writing very clear, with the complexity increasing at just the  
right speed. I definitely recommend it to anyone who wants to learn  
how to use lattice, at any level they desire.


Ok, I guess I better stop now. Happy reading Mark!

Haris Skiadas
Department of Mathematics and Computer Science
Hanover College

On Apr 30, 2008, at 4:51 PM, Mark Wardle wrote:


Dear all,

I haven't seen this mentioned and presumably Dr. Deepayan Sarkar is
too polite to advertise!

I just received a flyer from Springer: A new book on Lattice  
released today!!


http://www.springer.com/statistics/computational/book/ 
978-0-387-75968-5?cm_mmc=NBA-_-Apr-08_UK_1753460-_-product- 
_-978-0-387-75968-5


http://www.amazon.co.uk/exec/obidos/ASIN/0387759689/ 
ref=ord_cart_shr?%5Fencoding=UTF8m=A3P5ROKL5A1OLE


Well done and many congratulations. My order is being processed as  
we speak!


Best wishes,

Mark
--
Dr. Mark Wardle
Specialist registrar, Neurology
Cardiff, UK


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


Re: [R] arcsine transformation

2008-04-30 Thread Chuck Cleland

On 4/30/2008 4:52 PM, Claire Sheller wrote:

I have been trying to preform both a bartlett's test and an arcsine
transformation on some average percentage data. I've tried inputting it
different ways and I keep getting the same error message:


head(workingdata)

   DYAD   BEFORE AFTER
1 BG-FL 4.606772  5.787520
2 BG-LL 5.467503  7.847395
3 AD-MV 5.333735 11.107380
4 MM-FL 5.578708 12.063500
5 MM-MV 2.037605  6.415303
6 MM-RM 6.158885 11.911080

bartlett.test(BEFORE ~ AFTER)

Error in bartlett.test.default(c(4.606772, 5.467503, 5.333735, 5.578708,  :
  there must be at least 2 observations in each group


  bartlett.test() expects the second argument to be a vector or factor 
object giving the group for the corresponding elements of x.  You seem 
to have paired samples instead.



asin(BEFORE)

[1] NaN NaN NaN NaN NaN NaN NaN
Warning message:
In asin(BEFORE) : NaNs produced


  You might divide the values by 100 prior to asin().


I'm at a loss here and I would greatly appreciate any guidance that could be
given me. Thank you! 


--
Chuck Cleland, Ph.D.
NDRI, Inc. (www.ndri.org)
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 512-0171 (M, W, F)
fax: (917) 438-0894

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


Re: [R] Why R is 200 times slower than Matlab ?

2008-04-30 Thread Gabor Grothendieck
Aside from optiming your code by making use of R functions
that use C underneath as much as possible the big difference
between R and Matlab is Matlab's just-in-time compilation of
code.  When that was introduced in Matlab huge speedups of
Matlab programs were noticeable.

For R, there is a new package on CRAN, jit, that
aims to provide similar speedups.

On Wed, Apr 30, 2008 at 4:15 PM, Zhandong Liu
[EMAIL PROTECTED] wrote:
 I am switching from Matlab to R, but I found that R is 200 times slower than
 matlab.

 Since I am newbie to R, I must be missing some important programming tips.

 Please help me out on this.

 Here is the function:
 ## make the full pair-wise permutation of a vector
 ## input_fc=c(1,2,3);
 ## output_fc=(
 1 1 1 2 2 2 3 3 3
 1 2 3 1 2 3 1 2 3
 );

 grw_permute = function(input_fc){

 fc_vector = input_fc

 index = 1

 k = length(fc_vector)

 fc_matrix = matrix(0,2,k^2)

 for(i in 1:k){

 for(j in 1:k){

 fc_matrix[index]  =  fc_vector[i]

 fc_matrix[index+1]  =  fc_vector[j]

 index = index+2

 }

 }

 return(fc_matrix)

 }

 For an input vector of size 300. It took R 2.17 seconds to run.

 But the same code in matlab only needs 0.01 seconds to run.

 Am I missing sth in R.. Is there a away to optimize.  ???

 Thanks

 --
 Zhandong Liu

 Genomics and Computational Biology
 University of Pennsylvania

 616 BRB II/III, 421 Curie Boulevard
 University of Pennsylvania School of Medicine
 Philadelphia, PA 19104-6160

[[alternative HTML version deleted]]

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


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


Re: [R] Why R is 200 times slower than Matlab ?

2008-04-30 Thread Nelson Castillo
On Wed, Apr 30, 2008 at 6:27 PM, Gabor Grothendieck
[EMAIL PROTECTED] wrote:
 Aside from optiming your code by making use of R functions
  that use C underneath as much as possible the big difference
  between R and Matlab is Matlab's just-in-time compilation of
  code.  When that was introduced in Matlab huge speedups of
  Matlab programs were noticeable.

  For R, there is a new package on CRAN, jit, that
  aims to provide similar speedups.

http://www.milbo.users.sonic.net/ra/index.html

Great! I just found out about ra. In Python I love psyco and I guess I will test
ra soon.

Thanks,
N.-

-- 
http://arhuaco.org

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


Re: [R] efficiency profiling? (was: Why R is 200 times slower than Matlab ?)

2008-04-30 Thread Gabor Csardi
On Wed, Apr 30, 2008 at 06:59:38PM -0400, esmail bonakdarian wrote:
 
 This has been an interesting discussion, and brings up two questions
 for me:
 
 Is there a good collection of hints/suggestions for R language idoms in terms
 of efficiency? For instance I read not to use for-loops, so I used apply only 
 to
 later read that apply is internally implemented as a for so nothing gained
 here. Warnings about pitfalls (such as nested loops), hints, suggestions would
 be great.

Personally i like {l,t,}apply better, 1) it is more readable,
2) it takes two minutes to change it to par{L,S,}apply and then 
it runs in parallel.

 The second question - is there some sort of profiling tool available that 
 would
 make it easy to recognize where the script is spending most of its time? Might
 be especially useful for newbies like me.

See ?Rprof

G.

[...]

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

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


Re: [R] efficiency profiling?

2008-04-30 Thread Duncan Murdoch

On 30/04/2008 6:59 PM, esmail bonakdarian wrote:

This has been an interesting discussion, and brings up two questions
for me:

Is there a good collection of hints/suggestions for R language idoms in terms
of efficiency? For instance I read not to use for-loops, so I used apply only to
later read that apply is internally implemented as a for so nothing gained
here. Warnings about pitfalls (such as nested loops), hints, suggestions would
be great.

The second question - is there some sort of profiling tool available that would
make it easy to recognize where the script is spending most of its time? Might
be especially useful for newbies like me.


See ?Rprof for the tool.  For the tips, I think you just need to hang 
around here a while.  I don't know of a nice collection (but I'm sure 
there are several.)


Duncan Murdoch

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


Re: [R] efficiency profiling?

2008-04-30 Thread esmail bonakdarian


 See ?Rprof for the tool.  For the tips, I think you just need to hang 
 around here a while.  I don't know of a nice collection (but I'm sure 
 there are several.)
 
 Duncan Murdoch


Hi,

thanks .. several folks pointed me to Rprof, I'll take a look.

Yes, I have been reading the list, the amount of messages per day
is simply amazing, I can hardly keep up. Do most of you read this
on the web or get it as digest? I am getting them as individual
e-mails (thank god for filters) ... :-)

Esmail

_
Back to work after baby–how do you know when you’re ready?

5797498ocid=T067MSN40A0701A
[[alternative HTML version deleted]]

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


Re: [R] efficiency profiling?

2008-04-30 Thread Duncan Murdoch

On 30/04/2008 7:47 PM, esmail bonakdarian wrote:


See ?Rprof for the tool.  For the tips, I think you just need to hang 
around here a while.  I don't know of a nice collection (but I'm sure 
there are several.)


Duncan Murdoch



Hi,

thanks .. several folks pointed me to Rprof, I'll take a look.

Yes, I have been reading the list, the amount of messages per day
is simply amazing, I can hardly keep up. Do most of you read this
on the web or get it as digest? I am getting them as individual
e-mails (thank god for filters) ... :-)


I think most read as email, but a substantial minority read it on the 
web.  You really do need filters.


Personally, I scan the subject lines, and read about 1 in 10 threads.

Duncan Murdoch

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


[R] using the sink() function in a for-look

2008-04-30 Thread Tony Dell
hi all,

i wanted to use the sink function to sequentially output regression
summaries within a for-loop. i must have something wrong somewhere (or be
using the sink function incorrectly), but can anyone help?

the code I am using is:

where data.x is a data.frame of independents, and data.y is a data.frame of
dependents.


 for (i in 1:length(data.y)){   
taxa.i - names(data.y[i]) 

jpeg(file=paste(taxa.i,.multiple.regress.residuals.1.RAW.jpeg,sep=),
quality=90, width=1000, height=1000)
par(mfrow=c(2,2), lwd=0.5, mar=c(3,4,3,1), bty=o, oma=c(0,3,2,0))
attach(data.x)
mult.reg.raw.i - lm(data.y[,i] ~ CURRENT + LITTER + PERCURR + SUBST)
plot(mult.reg.raw.i, ask=FALSE)
mtext(names(data.y[i]), side=3, line=-1.5, adj=0.48, cex=0.75,
outer=TRUE)
dev.off()
sink(mulptiple regression - summary RAW.txt, append=TRUE)
summary(mult.reg.raw.i)
sink()
 }

cheers,

tony
__

tony dell
department of marine and tropical biology james cook university townsville,
qld 4811 australia

[p] 07 47815751 or 47814520
[e] [EMAIL PROTECTED]
[skype] anphony


Checked by AVG. 

6:27 PM

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


Re: [R] efficiency profiling?

2008-04-30 Thread Kingsford Jones
On Wed, Apr 30, 2008 at 4:33 PM, Duncan Murdoch [EMAIL PROTECTED] wrote:
 On 30/04/2008 6:59 PM, esmail bonakdarian wrote:
snip
  Is there a good collection of hints/suggestions for R language idoms in
 terms
  of efficiency?
snip

  See ?Rprof for the tool.  For the tips, I think you just need to hang
 around here a while.  I don't know of a nice collection (but I'm sure there
 are several.)

  Duncan Murdoch


;-) here's one:  https://stat.ethz.ch/pipermail/r-help/2005-October/080991.html


Kingsford Jones

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

2008-04-30 Thread steven wilson
The code I sent before had some typos, here is the corrected one:

pca.nipals - function(X, ncomp, iter = 50, toler = sqrt(.Machine$double.eps))
 # X...data matrix, ncomp...number of components,
 # iter...maximal number of iterations per component,
 # toler...precision tolerance for calculation of components
 {

 Xh - scale(X, center = TRUE, scale = FALSE)
 nr - 0
 T - NULL; P - NULL # matrix of scores and loadings
 for (h in 1:ncomp)
  {
 th - Xh[, 1]
 ende - FALSE
 while (!ende)
   {
   nr - nr + 1
   ph - t(crossprod(th, Xh) * as.vector(1 /
crossprod(th)))
   ph - ph * as.vector(1/sqrt(crossprod(ph)))
   thnew - t(tcrossprod(t(ph), Xh) *
as.vector(1/(crossprod(ph
   prec - crossprod(th-thnew)
   th - thnew
   if (prec = (toler^2)) ende - TRUE
   if (iter = nr) ende - TRUE # didn't converge
   }

 Xh - Xh - tcrossprod(th)
 T - cbind(T, th); P - cbind(P, ph)
 nr - 0
   }
 list(T = T, P = P)
 }

Thanks again


-- Forwarded message --
From: steven wilson [EMAIL PROTECTED]
Date: Wed, Apr 30, 2008 at 11:56 PM
Subject: efficient code - yet another question
To: r-help@r-project.org


Dear list members;

 The code given below corresponds to the PCA-NIPALS (principal
 component analysis) algorithm adapted from the nipals function in the
 package chemometrics. The reason for using NIPALS instead of SVD is
 the ability of this algorithm to handle missing values, but that's a
 different story. I've been trying to find a way to improve (if
 possible) the efficiency of the code, especially when the number of
 components to calculate is higher than 100. I've been working with a
 data set of 500 rows x 700 variables. The code gets really slow when
 the number of PC to calculate is for example 600 (why that number of
 components?because I need them to detect outliers using another
 algorithm). In my old laptop running Win XP and R 2.7.0 (1GB RAM) it
 takes around 6 or 7 minutes. That shouldn't be a problem for one
 analysis, but when cross-validation is added the time increases
 severely.Although there are several examples on the R help list
 giving some with 'hints' to improve effciency the truth is that I
 don't know (or I can't see it) the part of the code that can be
 improved (but it is clear that the bottle neck is the for and while
 loops). I would really appreciate any ideas/comments/etc...

 Thanks

 #

 pca.nipals - function(X, ncomp, iter = 50, toler = sqrt(.Machine$double.eps))
 # X...data matrix, ncomp...number of components,
 # iter...maximal number of iterations per component,
 # toler...precision tolerance for calculation of components
 {

 Xh - scale(X, center = TRUE, scale = FALSE)
 nr - 0
 T - NULL; P - NULL # matrix of scores and loadings
 for (h in 1:ncomp)
  {
 th - Xh[, 1]
 ende - FALSE
 while (!ende)
   {
   nr - nr + 1
   ph - t(crossprod(th, Xh) * as.vector(1 /
 crossprod(th)))
   ph - ph * as.vector(1/sqrt(crossprod(ph)))
   thnew - t(tcrossprod(t(ph), Xh) *
 as.vector(1/(crossprod(ph
   prec - crossprod(th-thnew)
   th - thnew
   if (prec = (tol^2)) ende - TRUE
   if (it = nr) ende - TRUE # didn't converge
   }

 Xh - Xh - tcrossprod(th)
 T - cbind(T, th); P - cbind(P, ph)
 nr - 0
   }
 list(T = T, P = P)
 }

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


Re: [R] using the sink() function in a for-look

2008-04-30 Thread Rolf Turner


On 1/05/2008, at 2:32 PM, Tony Dell wrote:


hi all,

i wanted to use the sink function to sequentially output regression
summaries within a for-loop. i must have something wrong somewhere  
(or be

using the sink function incorrectly), but can anyone help?


snip

You need to ***print*** the output you want to see.

Typing ``x'' in an interactive environment causes the value of
x to be printed.  But in a non-interactive environment (inside
a function such as source() or a for loop) it doesn't, and
you need to say ``print(x)''.

Trap for young players.

cheers,

Rolf Turner

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

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


[R] (no subject)

2008-04-30 Thread Tony Dell
hi all,

i wanted to use the sink function to sequentially output regression
summaries within a for-loop. i must have something wrong somewhere (or be
using the sink function incorrectly), but can anyone help?

the code I am using is:

where data.x is a data.frame of independents, and data.y is a data.frame of
dependents.


 for (i in 1:length(data.y)){   
taxa.i - names(data.y[i]) 

jpeg(file=paste(taxa.i,.multiple.regress.residuals.1.RAW.jpeg,sep=),
quality=90, width=1000, height=1000)
par(mfrow=c(2,2), lwd=0.5, mar=c(3,4,3,1), bty=o, oma=c(0,3,2,0))
attach(data.x)
mult.reg.raw.i - lm(data.y[,i] ~ CURRENT + LITTER + PERCURR + SUBST)
plot(mult.reg.raw.i, ask=FALSE)
mtext(names(data.y[i]), side=3, line=-1.5, adj=0.48, cex=0.75,
outer=TRUE)
dev.off()
sink(mulptiple regression - summary RAW.txt, append=TRUE)
summary(mult.reg.raw.i)
sink()
 }

cheers,

tony
__

tony dell
department of marine and tropical biology
james cook university
townsville, qld 4811 australia

[p] 07 47815751 or 47814520
[e] [EMAIL PROTECTED] 
[skype] anphony


Checked by AVG. 

6:27 PM

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

2008-04-30 Thread Jill Elizabeth
I would like to compute the next 15 observations for
an ARFIMA(2,1,0) model along with confidence
intervals.  Can someone provide code?

Many thanks.

Jill


  


[[elided Yahoo spam]]

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

2008-04-30 Thread steven wilson
Dear list members;

The code given below corresponds to the PCA-NIPALS (principal
component analysis) algorithm adapted from the nipals function in the
package chemometrics. The reason for using NIPALS instead of SVD is
the ability of this algorithm to handle missing values, but that's a
different story. I've been trying to find a way to improve (if
possible) the efficiency of the code, especially when the number of
components to calculate is higher than 100. I've been working with a
data set of 500 rows x 700 variables. The code gets really slow when
the number of PC to calculate is for example 600 (why that number of
components?because I need them to detect outliers using another
algorithm). In my old laptop running Win XP and R 2.7.0 (1GB RAM) it
takes around 6 or 7 minutes. That shouldn't be a problem for one
analysis, but when cross-validation is added the time increases
severely.Although there are several examples on the R help list
giving some with 'hints' to improve effciency the truth is that I
don't know (or I can't see it) the part of the code that can be
improved (but it is clear that the bottle neck is the for and while
loops). I would really appreciate any ideas/comments/etc...

Thanks

#

pca.nipals - function(X, ncomp, iter = 50, toler = sqrt(.Machine$double.eps))
# X...data matrix, ncomp...number of components,
# iter...maximal number of iterations per component,
# toler...precision tolerance for calculation of components
{

 Xh - scale(X, center = TRUE, scale = FALSE)
 nr - 0
 T - NULL; P - NULL # matrix of scores and loadings
 for (h in 1:ncomp)
  {
 th - Xh[, 1]
 ende - FALSE
 while (!ende)
   {
   nr - nr + 1
   ph - t(crossprod(th, Xh) * as.vector(1 /
crossprod(th)))
   ph - ph * as.vector(1/sqrt(crossprod(ph)))
   thnew - t(tcrossprod(t(ph), Xh) *
as.vector(1/(crossprod(ph
   prec - crossprod(th-thnew)
   th - thnew
   if (prec = (tol^2)) ende - TRUE
   if (it = nr) ende - TRUE # didn't converge
   }

 Xh - Xh - tcrossprod(th)
 T - cbind(T, th); P - cbind(P, ph)
 nr - 0
   }
 list(T = T, P = P)
}

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


Re: [R] using the sink() function in a for-look

2008-04-30 Thread Johannes Hüsing
Tony Dell [EMAIL PROTECTED] [Thu, May 01, 2008 at 04:32:23AM CEST]:
 hi all,
 
 i wanted to use the sink function to sequentially output regression
 summaries within a for-loop. i must have something wrong somewhere (or be
 using the sink function incorrectly), but can anyone help?
 
 the code I am using is:
 

Please use code and data which is reproducible for us. As we don't have
access to your data, we'd have to construct some of our own.

This code, however, has the same effect:

for (i in 1:100) {
sink(./sometext.txt, append=TRUE)
summary(rnorm(80))
sink()}


When you do the following:

for (i in 1:100) {
summary(rnorm(80))}

what output do you get?

And all this output is redirected to your file by sink(), so it works
as expected.

-- 
Johannes Hüsing   There is something fascinating about science. 
  One gets such wholesale returns of conjecture 
mailto:[EMAIL PROTECTED]  from such a trifling investment of fact.  
  
http://derwisch.wikidot.com (Mark Twain, Life on the Mississippi)

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


Re: [R] using the sink() function in a for-look

2008-04-30 Thread Tony Dell
bingo. thanks Ralph.  


__

tony dell
department of marine and tropical biology
james cook university
townsville, qld 4811 australia

[p] 07 47815751 or 47814520
[e] [EMAIL PROTECTED] 
[skype] anphony

-Original Message-
From: Rolf Turner [mailto:[EMAIL PROTECTED] 
Sent: Thursday, 1 May 2008 1:20 PM
To: Tony Dell
Cc: r-help@r-project.org
Subject: Re: [R] using the sink() function in a for-look


On 1/05/2008, at 2:32 PM, Tony Dell wrote:

 hi all,

 i wanted to use the sink function to sequentially output regression 
 summaries within a for-loop. i must have something wrong somewhere (or 
 be using the sink function incorrectly), but can anyone help?

snip

You need to ***print*** the output you want to see.

Typing ``x'' in an interactive environment causes the value of x to be
printed.  But in a non-interactive environment (inside a function such as
source() or a for loop) it doesn't, and you need to say ``print(x)''.

Trap for young players.

cheers,

Rolf Turner

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

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