[R] quantmod's addTA plotting functions

2011-05-05 Thread Russ Abbott
Hi,

I'm having trouble with quantmod's addTA plotting functions.  They seem to
work fine when run from the command line. But when run inside a function,
only the last one run is visible.  Here's an example.


test.addTA - function(from = 2010-06-01) {
getSymbols(^GSPC, from = from)
GSPC.close - GSPC[,GSPC.Close]
GSPC.EMA.3   - EMA(GSPC.close, n=3, ratio=NULL)
GSPC.EMA.10  - EMA(GSPC.close, n=10, ratio=NULL)
chartSeries(GSPC.close, theme=chartTheme('white'), up.col=black,
dn.col=black)
addTA(GSPC.EMA.3,   on = 1, col = #ff)
addTA(GSPC.EMA.10,  on = 1, col = #ff)
# browser()
}


When I run this, GSPC.close always appears.  But only GSPC.EMA10 appears on
the plot along with it. If I switch the order of the addTA calls,
only GSPC.EMA3 appears. If I uncomment the call to browser() neither appears
when the browser() interrupt occurs. I can then draw both GSPC.EMA.3 and
GSPC.EMA10 manually, and let the function terminate. All intended plots are
visible after the function terminates. So it isn't as if one wipes out the
other. This shows that it's possible to get all three lines on the plot, but
I can't figure out how to do it without manual intervention. Any suggestions
are appreciated.

Thanks.

*-- Russ *

[[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 - problem with my loops which operate on raster data

2011-05-05 Thread mateokkk
library(rgdal) 
my_asc=dir(~/Pulpit/dods/karol/TVDI
113_121,pattern=.asc,recursive=T,full.names=T)
 for (i in 1:length(my_asc))
{
 r - readGDAL(my_asc[i])
 z - as.matrix(r)
 vectordata[i] - mean(z)
 vectordatamax[i] - max(z)
 vectordatamin[i] - min(z)
 vectordev[i] - sd(z,na.rm=True)
 hist(z)
 png(filename=hist+tostring(i)+.png)
}

liI try to do some modyfication of this loop, but it still doesn't works -
which fragment is incorrect?
liI would like also to use more complicated pattern (to list only files
which contains on the end of it name two numbers), but adding something
like:
pattern=_??.asc seems not works.
liI would like to add one more loop to get list of folders (instead of
manually inserting directories into my_asc variable), but I haven't got Idea
how I can do it?
liI do not know, why my way of creating vectors for mean, max, min and
standard deviation values is not working...


--
View this message in context: 
http://r.789695.n4.nabble.com/R-problem-with-my-loops-which-operate-on-raster-data-tp3497533p3497533.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] memory and bootstrapping

2011-05-05 Thread E Hofstadler
hello,

the following questions will without doubt reveal some fundamental
ignorance, but hopefully you can still help me out.

I'd like to bootstrap a coefficient gained on the basis of the
coefficients in a logistic regression model (the mean differences in
the predicted probabilities between two groups, where each predict()
operation uses as the newdata-argument a dataframe of equal size as
the original dataframe).I've got 130,000 rows and 7 columns in my
dataframe. The glm-model uses all variables (as well as two 2-way
interactions).

System:
- R-version: 2.12.2
- OS: Windows XP Pro, 32-bit
- 3.16Ghz intel dual core processor, 2.9GB RAM

I'm using the boot package to arrive at the standard errors for this
difference, but even with only 10 replications, this takes quite a
long time: 216 seconds (perhaps this is partly also due to my
inefficiently programmed function underlying the boot-call, I'm also
looking into that).

I wanted to try out calculating a bca-bootstrapped confidence
interval, which as I understand requires a lot more replications than
normal-theory intervals. Drawing on John Fox' Appendix to his An R
Companion to Applied Regression, I was thinking of trying out 2000
replications -- but this will take several hours to compute on my
system (which isn't in itself a major issue though).

My Questions:
- let's say I try bootstrapping with 2000 replications. Can I be
certain that the memory available to R  will be sufficient for this
operation?
- (this relates to statistics more generally): is it a good idea in
your opinion to try bca-bootstrapping, or can it be assumed that a
normal theory confidence interval will be a sufficiently good
approximation (letting me get away with, say, 500 replications)?


Best,
Esther

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] lapply, if statement and concatenating to a list

2011-05-05 Thread Lorenzo Cattarino
Hi R users

I was wondering on how to use lapply  co when the applied function has a 
conditional statement and the output is a 'growing' object.
See example below:

list1 - list('A','B','C')
list2 - c()

myfun - function(x,list2)
{
  one_elem - x
  cat('one_elem= ', one_elem, '\n')
  random - sample(1:2,1)
  show(random)
  if(random==2)
  {
list2 - c(list2,one_elem)
  }else{
list2
  }
}

lapply(list1,myfun,list2)

Is there a way to get rid of the 'NULL' elements in the output (when there is 
any?), without using a for loop?

Thanks for your help
Lorenzo

[[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] Extraction of columns from two matrices

2011-05-05 Thread nisha chandran
Hi,

I have two matrices with 4885 cols and 36 cols respectively . I would like
to extract these 36 columns from the bigger matrix, the column values are
different but the column names would be the same.Hence based on the names I
would like to perform my operation. So is there any way of extracting this
info in an easy way. I have tried names,which,grep,subset none have worked.
Could someone help me out here



Thanks a ton
Nisha

[[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] combine lattice plot and standard R plot

2011-05-05 Thread Lucia Cañas
Thank you very much for your help and for your quick answers.

Lucía Cañás Ferreiro

Instituto Español de Oceanografía
Centro Oceanográfico de A coruña
Paseo Marítimo Alcalde Francisco Vázquez, 10
15001 - A Coruña, Spain

Tel: +34 981 218151  Fax: +34 981 229077
lucia.ca...@co.ieo.es
http://www.ieo.es



[[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] Panels order in lattice graphs

2011-05-05 Thread Mark Difford
May 04, 2011; 5:50pm Cristina Silva wrote:

 In lattice graphs, panels are drawn from left to right and bottom to 
 top. The flag as.table=TRUE changes to left to right and top to 
 bottom. Is there any way to change to first top to bottom and then left 
 to right? didn´t find anything neither in Help pages nor Lattice book.

Cristina,

You have not fully explained your problem. An approach I use for
difficult-to-get-right arrangements is the following. Say you have two
conditioning variables (13 panels in all) and you want to place the last
panel on the top row in the first position on the bottom row, but leave
everything else the same, then easiest is the following:

## Note: T.xyplot$index.cond is a __list__, so you need to use [[
T.xyplot - xyplot(Prop ~ OM | interaction(Treatment, Aspect, drop = TRUE),
data = myDat)
print(T.xyplot)
 T.xyplot$index.cond
[[1]]
 [1]  1  2  3  4  5  6  7  8  9 10 11 12 13

T.xyplot$index.cond[[1]] - c(13, 1:12)
print(T.xyplot)

Hope this helps to solve your problem.

Regards, Mark.





-
Mark Difford (Ph.D.)
Research Associate
Botany Department
Nelson Mandela Metropolitan University
Port Elizabeth, South Africa
--
View this message in context: 
http://r.789695.n4.nabble.com/Panels-order-in-lattice-graphs-tp3496022p3497691.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] R: join tables in R

2011-05-05 Thread Roccato Alfredo (UniCredit)
Thanks a lot to Steve Lianoglou and Peter Savicky for their help!
Alfredo


-Messaggio originale-
Da: Steve Lianoglou [mailto:mailinglist.honey...@gmail.com] 

 I'd to match-merge 2 tables in such a manner that I keep all the rows in 
 table 1, but not the rows that are in both table 1 and 2.

 master - data.frame(ID=2001:2011)
 train   - data.frame(ID=2004:2006)
 valid - ???

 in this example table valid should have the following
 str(valid)
  Year: int  2001 2002 2003 2007 2008 2009 2010 2011

Are you working with only one column at a time? If so:

keep - !(master$ID %in% train$ID)
valid - master[keep,]


-Messaggio originale-
Da: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Per 
conto di Petr Savicky

Try the following, which assumes that train is a subset of master.

  master - data.frame(ID=2001:2011)
  train  - data.frame(ID=2004:2006)
  valid - master[! (master[, 1] %in% train[ ,1]), , drop=FALSE]

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


Re: [R] lapply, if statement and concatenating to a list

2011-05-05 Thread Kenn Konstabel
Hi Lorenzo,

On Thu, May 5, 2011 at 8:38 AM, Lorenzo Cattarino l.cattar...@uq.edu.au wrote:
 Hi R users

 I was wondering on how to use lapply  co when the applied function has a 
 conditional statement and the output is a 'growing' object.
 See example below:

 list1 - list('A','B','C')
 list2 - c()

 myfun - function(x,list2)
 {
  one_elem - x
  cat('one_elem= ', one_elem, '\n')
  random - sample(1:2,1)
  show(random)
  if(random==2)
  {
    list2 - c(list2,one_elem)
  }else{
    list2
  }
 }

 lapply(list1,myfun,list2)

 Is there a way to get rid of the 'NULL' elements in the output (when there is 
 any?), without using a for loop?

I don't understand what your example is trying to do and which object
you expect to be growing. list2 ain't growin', and it's not changing
(i.e., it remains NULL) in your code. Perhaps you meant to have a -
there; this would make your list2 growing, if you really want it to,
but in general, that's a bad idea. Lapply goes best with the
functional style where everything your function does is computing and
returning a value but here you're (if I get your intentions correctly)
counting on side effects. If you like side effects, a for (or while)
loop may be more logical choice.

Getting rid of the NULL elements is simple. One way is:

foo - lapply(list1, yourfun)
foo[!sapply(foo, is.null)]

Regards,
Kenn

        [[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] memory and bootstrapping

2011-05-05 Thread Prof Brian Ripley
The only reason the boot package will take more memory for 2000 
replications than 10 is that it needs to store the results.  That is 
not to say that on a 32-bit OS the fragmentation will not get worse, 
but that is unlikely to be a significant factor.


As for the methodology: 'boot' is support software for a book, so 
please consult it (and not secondary sources).  From your brief 
description it looks to me as if you should be using studentized CIs.


130,000 cases is a lot, and running the experiment on a 1% sample 
may well show that asymptotic CIs are good enough.


On Thu, 5 May 2011, E Hofstadler wrote:


hello,

the following questions will without doubt reveal some fundamental
ignorance, but hopefully you can still help me out.

I'd like to bootstrap a coefficient gained on the basis of the
coefficients in a logistic regression model (the mean differences in
the predicted probabilities between two groups, where each predict()
operation uses as the newdata-argument a dataframe of equal size as
the original dataframe).I've got 130,000 rows and 7 columns in my
dataframe. The glm-model uses all variables (as well as two 2-way
interactions).

System:
- R-version: 2.12.2
- OS: Windows XP Pro, 32-bit
- 3.16Ghz intel dual core processor, 2.9GB RAM

I'm using the boot package to arrive at the standard errors for this
difference, but even with only 10 replications, this takes quite a
long time: 216 seconds (perhaps this is partly also due to my
inefficiently programmed function underlying the boot-call, I'm also
looking into that).

I wanted to try out calculating a bca-bootstrapped confidence
interval, which as I understand requires a lot more replications than
normal-theory intervals. Drawing on John Fox' Appendix to his An R
Companion to Applied Regression, I was thinking of trying out 2000
replications -- but this will take several hours to compute on my
system (which isn't in itself a major issue though).

My Questions:
- let's say I try bootstrapping with 2000 replications. Can I be
certain that the memory available to R  will be sufficient for this
operation?
- (this relates to statistics more generally): is it a good idea in
your opinion to try bca-bootstrapping, or can it be assumed that a
normal theory confidence interval will be a sufficiently good
approximation (letting me get away with, say, 500 replications)?


Best,
Esther

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



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

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


Re: [R] Str info. Thanks for helping

2011-05-05 Thread Ivan Calandra

Hi William!

So... many things to say

First, your first steps are completely unnecessary.
Just do this:
data1 - read.csv(file.choose(), header=TRUE)
data1$IND - factor(data1$IND)
M - manova(as.matrix(data1[,-1])~data1$IND, data=data1)

Though I don't understand why this doesn't work:
M - manova(.~IND, data=data1)
Error in eval(expr, envir, enclos) : object '.' not found

Second, this doesn't work either:
S-summary(M, test=Pillai)
Error in summary.manova(M, test = Pillai) : residuals have rank 11  12
And I don't know what that means since I never do manova, but it's not 
really where you're stuck, I guess


Third, where you're stuck. Is this what you want?
SA-summary.aov(M)
out - lapply(seq_along(SA), FUN=function(x) unlist(SA[[x]][1,]))
mat - do.call(rbind, out)
row.names(mat) - names(SA)

Fourth, I wouldn't use as.vector(). I'm no R expert, but I have the 
impression that it is useless in this case. It probably has its use in 
some situations, but I think as.matrix(), as.data.frame() and so on 
would be more useful to you.


And last, reply to the list as well!! Since attached files are not 
transferred, copy the output from dput(data1) into the email, like this:

data1 - structure(list(IND = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L,
...
Dep1, Dep2, Dep3, Dep4, Dep5, Dep6, Dep7, Dep8,
Dep9, Dep10, Dep11, Dep12), row.names = c(NA, -133L), class = 
data.frame)  ## copy the whole thing, right!!



HTH,
Ivan


Le 5/5/2011 02:41, Reith, William [USA] a écrit :

CSV file is attached.

I am doing a manova test. Followed by a summary.aov to determine which of the 
12 dependent variables are significant and warrant further testing. There is 
only one independent variable which is categorical with 4 factors.

R Code:

data1- read.csv(file link, header=TRUE)
as.matrix(data1)
X-data1[,1]
Dep1-data1[,2]
Dep2-data1[,3]
Dep3-data1[,4]
Dep4-data1[,5]
Dep5-data1[,6]
Dep6-data1[,7]
Dep7-data1[,8]
Dep8-data1[,9]
Dep9-data1[,10]
Dep10-data1[,11]
Dep11-data1[,12]
Dep12-data1[,13]
Y-cbind(Dep1, Dep2, Dep3, Dep4, Dep5, Dep6, Dep7, Dep8, Dep9, Dep10, Dep11, 
Dep12)
M- manova(Y ~ as.factor(X), data=data1)

S-summary(M, test=Pillai)
S1-as.vector(S$stats[1,])
L-mat.or.vec(12,3)
SA-summary.aov(M)

#Stops working here. I want to save the numbers from each Depi test as a 
matrix or vector. S1 above works for the manova test, but I don't know how to reference 
my values for summary.aov

SA1-SA[ Response Dep1]


Thank you so much for any help you can give,

William



-Original Message-
From: Ivan Calandra [mailto:ivan.calan...@uni-hamburg.de]
Sent: Wednesday, May 04, 2011 4:38 PM
To: Reith, William [USA]
Cc: r-help@r-project.org
Subject: Re: Str info. Thanks for helping

It looks from str(SA) that Response IPS1 is a data.frame of class anova, 
which probably cannot be coerced to vector.

Maybe you can use unlist() instead of as.vector()
Or something like
SA[[Response IPS1]][as.factor(WSD),]  ## to select the first row only, even 
maybe with unlist()

Without a better REPRODUCIBLE example, I cannot tell more (maybe some others 
can, that's why I reply to the list)

HTH,
Ivan


Le 4 mai 2011 à 20:17, reith_will...@bah.com a écrit :


I am still waiting for this to get posted so I thought I would email it to you.

SA gives the output:

Response IPS1 :
Df Sum Sq Mean Sq F value   Pr(F)
as.factor(WSD)   3 3.3136 1.10455  23.047 5.19e-12 ***
Residuals  129 6.1823 0.04793
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
.
.
.
There are 11 more just like this output. Just increment IPS1 to IPS2, etc.


Goal: save 3 3.3136 1.10455  23.047 5.19e-12 as a vector.


Str(SA) gives the output:

str(SA)

str(SA)

List of 12
 $  Response IPS1 :Classes 'anova' and 'data.frame': 2 obs. of  5 variables:
  ..$ Df : num [1:2] 3 129
  ..$ Sum Sq : num [1:2] 3.31 6.18
  ..$ Mean Sq: num [1:2] 1.1045 0.0479
  ..$ F value: num [1:2] 23 NA
  ..$ Pr(F) : num [1:2] 5.19e-12 NA


There are several more but they are just repeats of this one only with IPS2, 
IPS3,...

The command:


SA1-as.vector(SA$Reponse IPS1)

Returns


NULL

As do several variations I have tried. Any ideas.



--
Ivan CALANDRA
PhD Student
University of Hamburg
Biozentrum Grindel und Zoologisches Institut und Museum
Abt. Säugetiere
Martin-Luther-King-Platz 3
D-20146 Hamburg, GERMANY
+49(0)40 42838 6231
ivan.calan...@uni-hamburg.de

**
http://www.for771.uni-bonn.de
http://webapp5.rrz.uni-hamburg.de/mammals/eng/1525_8_1.php



--
Ivan CALANDRA
PhD Student
University of Hamburg
Biozentrum Grindel und Zoologisches Museum
Abt. Säugetiere
Martin-Luther-King-Platz 3
D-20146 Hamburg, GERMANY
+49(0)40 42838 6231
ivan.calan...@uni-hamburg.de

**
http://www.for771.uni-bonn.de
http://webapp5.rrz.uni-hamburg.de/mammals/eng/1525_8_1.php

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

[R] Options for print()

2011-05-05 Thread Dan Abner
Hello everyone,

I have a few questions about the print() fn:

1) I have the following code that does not center the character string:

print(The TITLE,quote=FALSE,justify=center)

2) How can I get R to not print the leading [1], etc.  when using print()?

(Sorry, I don't know what the leading [1] is called. I tried looking it up
in An Introduction, but could not find it).

Any help is greatly appreciated!

Dan

[[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] combine lattice plot and standard R plot

2011-05-05 Thread Mark Difford
On May 04, 2011 at 8:26pm Lucia Cañas wrote:

 I would like to combine lattice plot (xyplot) and standard R plot (plot
 and plotCI) in an unique figure.

Hi Lucia,

Combining the two systems can be done. See:

Paul Murrell. Integrating grid graphics output with base graphics output. R
News, 3(2):7-12, October 2003
http://cran.r-project.org/doc/Rnews/Rnews_2003-2.pdf

Hope this helps.

Regards, Mark.

-
Mark Difford (Ph.D.)
Research Associate
Botany Department
Nelson Mandela Metropolitan University
Port Elizabeth, South Africa
--
View this message in context: 
http://r.789695.n4.nabble.com/combine-lattice-plot-and-standard-R-plot-tp3496409p3497717.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] Options for print()

2011-05-05 Thread baptiste auguie
Hi,

Try this,

cat(format(The TITLE, width=80, justify=centre))

HTH,

baptiste

On 5 May 2011 19:28, Dan Abner dan.abne...@gmail.com wrote:
 Hello everyone,

 I have a few questions about the print() fn:

 1) I have the following code that does not center the character string:

 print(The TITLE,quote=FALSE,justify=center)

 2) How can I get R to not print the leading [1], etc.  when using print()?

 (Sorry, I don't know what the leading [1] is called. I tried looking it up
 in An Introduction, but could not find it).

 Any help is greatly appreciated!

 Dan

        [[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] Remove all whitespaces

2011-05-05 Thread Joel
Hi

I got a string that looks something like this

1 2 3 4 5 6 7 8 9 ...

and I want it to be 

123456789...

So I want to remove all spaces (or whitespaces) from my string.

Anyone know a good way of doing this?

//Joel

--
View this message in context: 
http://r.789695.n4.nabble.com/Remove-all-whitespaces-tp3497867p3497867.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] R - problem with my loops which operate on raster data

2011-05-05 Thread Michael Sumner
Stackoverflow users have attempted to help you improve your question -
please don't ignore advice this with an undeclared cross-post here:

http://stackoverflow.com/questions/5892548/problem-with-loops-in-r

For this list

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

Cheers, Mike.

On Thu, May 5, 2011 at 2:21 PM, mateokkk vkedz...@is.pw.edu.pl wrote:

 library(rgdal)
 my_asc=dir(~/Pulpit/dods/karol/TVDI
 113_121,pattern=.asc,recursive=T,full.names=T)
  for (i in 1:length(my_asc))
 {
  r - readGDAL(my_asc[i])
  z - as.matrix(r)
  vectordata[i] - mean(z)
  vectordatamax[i] - max(z)
  vectordatamin[i] - min(z)
  vectordev[i] - sd(z,na.rm=True)
  hist(z)
  png(filename=hist+tostring(i)+.png)
 }

 liI try to do some modyfication of this loop, but it still doesn't works
 -
 which fragment is incorrect?
 liI would like also to use more complicated pattern (to list only files
 which contains on the end of it name two numbers), but adding something
 like:
 pattern=_??.asc seems not works.
 liI would like to add one more loop to get list of folders (instead of
 manually inserting directories into my_asc variable), but I haven't got
 Idea
 how I can do it?
 liI do not know, why my way of creating vectors for mean, max, min and
 standard deviation values is not working...


 --
 View this message in context:
 http://r.789695.n4.nabble.com/R-problem-with-my-loops-which-operate-on-raster-data-tp3497533p3497533.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.




-- 
Michael Sumner
Institute for Marine and Antarctic Studies, University of Tasmania
Hobart, Australia
e-mail: mdsum...@gmail.com

[[alternative HTML version deleted]]

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


Re: [R] Simple General Statistics and R question (with 3 line example) - get z value from pairwise.wilcox.test

2011-05-05 Thread JP
On 4 May 2011 15:32, peter dalgaard pda...@gmail.com wrote:


 On May 4, 2011, at 15:11 , JP wrote:

 Peter thanks for the fantastically simple and understandable explanation...

 To sum it up... to find the z values of a number of pairwise wilcox
 tests do the following:

 # pairwise tests with bonferroni correction
 x - pairwise.wilcox.test(a, b, alternative=two.sided,
 p.adj=bonferroni, exact=F, paired=T)


 You probably don't want the bonferroni correction there. Rather p.adj=none. 
 You generally correct the p values for multiple testing, not the test 
 statistics.


Oh, I see thanks... of course since I have 5 groups (samples) and 10
comparisons I still have to correct when quoting p values...


 (My sentiment would be to pick apart the stats:::wilcox.test.default function 
 and clone the computation of Z from it, but presumably backtracking from the 
 p value is a useful expedient.)


Should this be so onerous for the user [read non-statistician] ?


 # what is the data structure we got back
 is.matrix(x$p.value)
 # p vals
 x$p.value
 # z.scores for each
 z.score - qnorm(x$p.value / 2)


 Hmm, you're not actually getting a signed z out of this, you might want to 
 try alternative=greater and drop the division by 2 inside qnorm(). (If the 
 signs come out inverted, I meant less not greater...)


But I need a two sided test (changing the alternative would change the
hypothesis!)...  do I still do this?
All my z values are negative

Is this correct?

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


Re: [R] Remove all whitespaces

2011-05-05 Thread Ivan Calandra

Hi Joel,

Try this:
x - 1 2 3 4 5 6 7 8 9 
gsub( , , x)

Ivan


Le 5/5/2011 10:50, Joel a écrit :

Hi

I got a string that looks something like this

1 2 3 4 5 6 7 8 9 ...

and I want it to be

123456789...

So I want to remove all spaces (or whitespaces) from my string.

Anyone know a good way of doing this?

//Joel
  


--
Ivan CALANDRA
PhD Student
University of Hamburg
Biozentrum Grindel und Zoologisches Museum
Abt. Säugetiere
Martin-Luther-King-Platz 3
D-20146 Hamburg, GERMANY
+49(0)40 42838 6231
ivan.calan...@uni-hamburg.de

**
http://www.for771.uni-bonn.de
http://webapp5.rrz.uni-hamburg.de/mammals/eng/1525_8_1.php

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


Re: [R] Options for print()

2011-05-05 Thread Andreas Borg
Also take a look at sprintf, which offers everything the C-equivalent 
has. sprintf returns a string which can be sent to the console via cat.


Andreas

baptiste auguie schrieb:

Hi,

Try this,

cat(format(The TITLE, width=80, justify=centre))

HTH,

baptiste

On 5 May 2011 19:28, Dan Abner dan.abne...@gmail.com wrote:
  

Hello everyone,

I have a few questions about the print() fn:

1) I have the following code that does not center the character string:

print(The TITLE,quote=FALSE,justify=center)

2) How can I get R to not print the leading [1], etc.  when using print()?

(Sorry, I don't know what the leading [1] is called. I tried looking it up
in An Introduction, but could not find it).

Any help is greatly appreciated!

Dan

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

  



--
Andreas Borg
Medizinische Informatik

UNIVERSITÄTSMEDIZIN
der Johannes Gutenberg-Universität
Institut für Medizinische Biometrie, Epidemiologie und Informatik
Obere Zahlbacher Straße 69, 55131 Mainz
www.imbei.uni-mainz.de

Telefon +49 (0) 6131 175062
E-Mail: b...@imbei.uni-mainz.de

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. 
Wenn Sie nicht der
richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren 
Sie bitte sofort den
Absender und löschen Sie diese Mail. Das unerlaubte Kopieren sowie die 
unbefugte Weitergabe
dieser Mail und der darin enthaltenen Informationen ist nicht gestattet.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Ruby Koans an amazing platform for teaching programming. Would this work with R?

2011-05-05 Thread Pat Schmitz
For those not familiar Ruby Koans is a fantastic platform for teaching many
of the basics of programming in the Ruby language.  It uses unit tests
written for methods each of which describe a component of the Ruby
programming language.

http://rubykoans.com/

The koans platform has become popular enough that it has been translated to
a few other popular languages.

Clojure - https://github.com/functional-koans/clojure-koans
Python - https://github.com/gregmalcolm/python_koans
Javascript - https://github.com/mrdavidlaing/javascript-koans

I have been programming with R for around two years now, having come to R as
a non-programmer, hoping to use it as a pragmatic solution to handeling and
plotting lots of data.  My skills have increased but are still certainly
limited, and much of the advanced functionality remains a bit of a mystery
to me.

As I have learned more of other languages, particularly Ruby and Javascript,
I am amazed with what can be done and with some concepts I so clearly have
not learned while programming R.

Take a look at Ruby Koans.  Would this work for R?

-- 
Patrick Schmitz
Graduate Student
Plant Biology
1206 West Gregory Drive
RM 1500

[[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] nls problem with R

2011-05-05 Thread sterlesser
the dataset's form is changed after my post
so I repost it here

t
0
0.3403
0.4181
0.4986
0.7451
1.0069
1.5535
1.8049
2.4979
6.4903
13.5049
27.5049
41.5049


V(t)
6.053078443
5.56937391
5.45484486
5.193124598
4.31386722
3.645422269
3.587710965
3.740362689
3.699837726
2.908485019
1.888179494
1.176091259
1.176091259


--
View this message in context: 
http://r.789695.n4.nabble.com/nls-problem-with-R-tp3494454p3497827.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] nls problem with R

2011-05-05 Thread sterlesser
ID1  ID2 t   V(t)
1   1   0   6.053078443
2   1   0.3403  5.56937391
3   1   0.4181  5.45484486
4   1   0.4986  5.193124598
5   1   0.7451  4.31386722
6   1   1.0069  3.645422269
7   1   1.5535  3.587710965
8   1   1.8049  3.740362689
9   1   2.4979  3.699837726
10  1   6.4903  2.908485019
11  1   13.5049 1.888179494
12  1   27.5049 1.176091259
13  1   41.5049 1.176091259

The model
(1)  V(t)=V0[1-epi+ epi*exp(-c(t-t0))]
(2)  V(t)=V0{A*exp[-lambda1(t-t0)]+(1-A)*exp[-lambda2(t-t0)]}

in formula (2) lambda1=0.5*{(c+delta)+[(c-delta)^2+4*(1-epi)*c*delta]^0.5}
  
lambda2=0.5*{(c+delta)-[(c-delta)^2+4*(1-epi)*c*delta]^0.5}
   A=(epi*c-lambda2)/(lambda1-lambda2)

The regression rule :
for formula (1):(t=2,that is) first 8 rows are used for non-linear
regression
epi,c,t0,V0 parameters are obtained 
for formula (2):all 13 rows of results are used for non-linear regression 
lambda1,lambda2,A (with these parameters, delta can be calculated from them)

Thanks for help
Ster Lesser

--
View this message in context: 
http://r.789695.n4.nabble.com/nls-problem-with-R-tp3494454p3497825.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] Remove all whitespaces

2011-05-05 Thread Tom Osborn
sed?

1,$s/ //g
  - Original Message - 
  From: Joel
  To: r-help@r-project.org
  Sent: Thursday, May 05, 2011 6:50 PM
  Subject: [R] Remove all whitespaces


  Hi

  I got a string that looks something like this

  1 2 3 4 5 6 7 8 9 ...

  and I want it to be

  123456789...

  So I want to remove all spaces (or whitespaces) from my string.

  Anyone know a good way of doing this?

  //Joel

  --
  View this message in context: 
http://r.789695.n4.nabble.com/Remove-all-whitespaces-tp3497867p3497867.html
  Sent from the R help mailing list archive at Nabble.com.

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

[[alternative HTML version deleted]]

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


Re: [R] issue with strange characters (readHTMLTable)

2011-05-05 Thread R.T.A.J.Leenders

   Thank you. The line of code you give certainly resolves several of the
   issues.
   I didn't realize that font support is such a tough matter to realize. Let me
   express my gratitude to those who provide this for us in R.
   On 04-05-11, Prof Brian Ripley rip...@stats.ox.ac.uk wrote:

   Oh, please!
   This is about the contributed package XML, not R and not Windows.
   Some of us have worked very hard to provide reasonable font support in R,
   including on Windows.  We are given exceedingly little credit, just
   the brickbats for things for which we are not responsible.  (We even work
   hard to port XML to Windows for you, again with almost zero credit.)
   That URL is a page in UTF-8, as its header says.  We have provided many ways
   to work with UTF-8 on Windows, but it seems readHTMLTable() is not making
   use of them.
   You need to run iconv() on the strings in your object (which as it has
   factors, are the levels).  When you do so, you will discover that page
   contains characters not in your native charset (I presume, not having your
   locale).
   What you can do, in Rgui only, is
   for (n in names(Islands)) Encoding(levels(Islands[[n]])) -UTF-8
   but likely there are still characters it will not know how to display.
   On Wed, 4 May 2011, R.T.A.J.Leenders wrote:
   
 WinXP-x32, R-21.13.0
 Dear list,
  I have a problem that (I think) relates to the interaction between
   Windows
 and R.
 I am trying to scrape a table with data on the Hawai'ian Islands, This is
   my
 code:
 library(XML)
 u - [1]http://en.wikipedia.org/wiki/Hawaii;
 tables - readHTMLTable(u)
 Islands - tables[[5]]
 The output is (first set of columns):
IslandNickname
  Islands
IslandNickname
 Location
   1   Hawai�»i[7]The   Big   Island   
19Ã?°34′N
   155Ã?°30′W / 19.567
   �°N 155.5�°W / 19.567; -155.5
   2   Maui[8]TheValley   Isle   
20Ã?°48′N
   156Ã?°20′W / 20.8Ã?°N
   156.333�°W / 20.8; -156.333
   3   Kaho�»olawe[9]   The   Target   Isle
20Ã?°33′N
   156Ã?°36′W / 20.55
   �°N 156.6�°W / 20.55; -156.6
   4  L�na�»i[10] ThePineappleIsle
20Ã?°50′N
   156Ã?°56′W / 20.833Ã?°N 15
   6.933�°W / 20.833; -156.933
   5 Moloka�»i[11]  TheFriendlyIsle
21Ã?°08′N
   157Ã?°02′W / 21.133Ã?°N 1
   57.033�°W / 21.133; -157.033
   6O�»ahu[12]TheGatheringPlace
21Ã?°28′N
   157Ã?°59′W / 21.467Ã?°N 1
   57.983�°W / 21.467; -157.983
   7   Kaua�»i[13]   The   Garden   Isle   
22Ã?°05′N
   159Ã?°30′W / 22.083
   �°N 159.5�°W / 22.083; -159.5
   8  Ni�»ihau[14]The   Forbidden   Isle   
21Ã?°54′N
   160Ã?°10′W / 21.9Ã?°N
   160.167�°W / 21.9; -160.167
   
 As you can see, there are weird characters in there. I have also tried
 readHTMLTable(u,  encoding = UTF-16) and readHTMLTable(u, encoding =
 UTF-8)
 but that didn't help.
 It  seems to me that there may be an issue with the interaction of the
 Windows settings of the character set.
 sessionInfo() gives
  sessionInfo()
 R version 2.13.0 (2011-04-13)
 Platform: i386-pc-mingw32/i386 (32-bit)
 locale:
 [1] LC_COLLATE=Dutch_Netherlands.1252  LC_CTYPE=Dutch_Netherlands.1252
 LC_MONETARY=Dutch_Netherlands.1252
 [4] LC_NUMERIC=C   LC_TIME=Dutch_Netherlands.1252
 attached base packages:
 [1] stats graphics  grDevices utils datasets  methods   base
 other attached packages:
 [1] XML_3.2-0.2
 
 I  have  also  attempted  to  let  R  use another setting by entering:
 Sys.setlocale(LC_ALL, en_US.UTF-8), but this yields the response:
  Sys.setlocale(LC_ALL, en_US.UTF-8)
 [1] 
 Warning message:
 In Sys.setlocale(LC_ALL, en_US.UTF-8) :
   OS reports request to set locale to en_US.UTF-8 cannot be honored
 
  In addition, I have attempted to make the change directly from the
   windows
 command prompt, using: chcp 65001 and variations of that, but that
   didn't
 change anything.
 I have searched the list and the web and have found others bringing forth
   a
 similar issues, but have not been able to find a solution. I looks like
   this

Re: [R] Panels order in lattice graphs

2011-05-05 Thread Deepayan Sarkar
On Wed, May 4, 2011 at 9:20 PM, Cristina Silva csi...@ipimar.pt wrote:
 Hi all,

 In lattice graphs, panels are drawn from left to right and bottom to top.
 The flag as.table=TRUE changes to left to right and top to bottom. Is
 there any way to change to first top to bottom and then left to right?
 didn´t find anything neither in Help pages nor Lattice book.

See ?packet.panel.default. For example,


p - xyplot(mpg ~ disp | factor(carb), mtcars, as.table = TRUE)

print(p, packet.panel = packet.panel.default)

my.packet.panel -
function(layout, condlevels, page, row, column, ...)
{
tlayout - layout[c(2, 1, 3)] # switch row and column
print(packet.panel.default(tlayout, condlevels, page = page,
   row = column, column = row, ...))
}

print(p, packet.panel = my.packet.panel)


-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] Extraction of columns from two matrices

2011-05-05 Thread Dennis Murphy
Hi:

Is this what you have in mind?

m1 - matrix(rpois(100, 10), nrow = 10, dimnames = list(NULL,
paste('V', 1:10, sep = '')))
m2 - matrix(rpois(40, 10), nrow = 10, dimnames = list(NULL,
paste('V', c(2, 5, 7, 10), sep = '')))
colnames(m1)
colnames(m2)

m1[, colnames(m2)]

HTH,
Dennis

On Wed, May 4, 2011 at 11:10 PM, nisha chandran
slamdunkangel...@gmail.com wrote:
 Hi,

 I have two matrices with 4885 cols and 36 cols respectively . I would like
 to extract these 36 columns from the bigger matrix, the column values are
 different but the column names would be the same.Hence based on the names I
 would like to perform my operation. So is there any way of extracting this
 info in an easy way. I have tried names,which,grep,subset none have worked.
 Could someone help me out here



 Thanks a ton
 Nisha

        [[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] Remove all whitespaces

2011-05-05 Thread Janko Thyson
If your whitespace does not only contain regular spaces, this might also 
be useful:

x.1 - \t1 2 \n3   4
write(x.1, test.txt)
x.2 - readLines(test.txt)
x.3 - gsub([[:space:]], , x.2)
x - paste(x.3, collapse=)

See ?regex for details on regular expressions in R.

HTH,
Janko

On 05.05.2011 11:02, Ivan Calandra wrote:
 Hi Joel,

 Try this:
 x - 1 2 3 4 5 6 7 8 9 
 gsub( , , x)

 Ivan


 Le 5/5/2011 10:50, Joel a écrit :
 Hi

 I got a string that looks something like this

 1 2 3 4 5 6 7 8 9 ...

 and I want it to be

 123456789...

 So I want to remove all spaces (or whitespaces) from my string.

 Anyone know a good way of doing this?

 //Joel



-- 


*Janko Thyson*
janko.thy...@googlemail.com mailto:janko.thy...@googlemail.com

Jesuitenstraße 3
D-85049 Ingolstadt

Mobile: +49 (0)176 83294257

This e-mail and any attachment is for authorized use by the intended
recipient(s) only. It may contain proprietary material, confidential
information and/or be subject to legal privilege. It should not be
copied, disclosed to, retained or used by any other party.
If you are not an intended recipient then please promptly delete this
e-mail and any attachment and all copies and inform the sender.


[[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] Extraction of columns from two matrices

2011-05-05 Thread nisha chandran
Yea it did...
Thanks :)

On Thu, May 5, 2011 at 3:07 PM, Dennis Murphy djmu...@gmail.com wrote:

 Hi:

 Is this what you have in mind?

 m1 - matrix(rpois(100, 10), nrow = 10, dimnames = list(NULL,
 paste('V', 1:10, sep = '')))
 m2 - matrix(rpois(40, 10), nrow = 10, dimnames = list(NULL,
 paste('V', c(2, 5, 7, 10), sep = '')))
 colnames(m1)
 colnames(m2)

 m1[, colnames(m2)]

 HTH,
 Dennis

 On Wed, May 4, 2011 at 11:10 PM, nisha chandran
 slamdunkangel...@gmail.com wrote:
  Hi,
 
  I have two matrices with 4885 cols and 36 cols respectively . I would
 like
  to extract these 36 columns from the bigger matrix, the column values are
  different but the column names would be the same.Hence based on the names
 I
  would like to perform my operation. So is there any way of extracting
 this
  info in an easy way. I have tried names,which,grep,subset none have
 worked.
  Could someone help me out here
 
 
 
  Thanks a ton
  Nisha
 
 [[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.
 


[[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] Using functions/loops for repetitive commands

2011-05-05 Thread dereksloan


 I still need to do some repetitive statistical analysis on some outcomes
from a dataset.

Take the following as an example;

id  sex hiv age famsize bmi resprate
1   M   Pos 23  2   16  15
2   F   Neg 24  5   18  14
3   F   Pos 56  14  23  24
4   F   Pos 67  3   33  31
5   M   Neg 34  2   21  23

I want to know if there are statistically detectable differences in all of
the continuous variables in my data set when subdivided by sex or hiv status
(ie are age, family size, bmi and resprate different in my male and female
patients or in hiv pos/neg patients)
Of course I can use wilcoxon or t-tests e.g:

wilcox.test( age~sex)
wilcox.test(famsize~sex) 
wilcox.test(bmi~sex)
wilcox.test(resprate~sex)
wilcox.test( age~hiv)
wilcox.test(famsize~hiv) 
wilcox.test(bmi~hiv)
wilcox.test(resprate~hiv)

but there must be some easy way of looping/automating this code (i.e. get
all the continuous variables analysed one by one by sex, then analysed one
by one by hiv status).
Obviously my actual dataset is considerably bigger than what is shown here -
I have many variables to assess making the longhand instruction to do every
test pretty unsatisfactory.

I think I can use ‘for’ or some other looping command for this purpose but I
can’t work out how. I think I don’t properly understand how loops work yet
as I'm still quite new to R.

Please could someone help – ideally with an explanation and some quick
sample code? 

Derek


--
View this message in context: 
http://r.789695.n4.nabble.com/Using-functions-loops-for-repetitive-commands-tp3498006p3498006.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] nls problem with R

2011-05-05 Thread Andrew Robinson
Apologies, but I don't see a question here ... am I missing something
obvious?

Andrew

On Thu, May 05, 2011 at 01:20:33AM -0700, sterlesser wrote:
 ID1  ID2 t   V(t)
 1 1   0   6.053078443
 2 1   0.3403  5.56937391
 3 1   0.4181  5.45484486
 4 1   0.4986  5.193124598
 5 1   0.7451  4.31386722
 6 1   1.0069  3.645422269
 7 1   1.5535  3.587710965
 8 1   1.8049  3.740362689
 9 1   2.4979  3.699837726
 101   6.4903  2.908485019
 111   13.5049 1.888179494
 121   27.5049 1.176091259
 131   41.5049 1.176091259
 
 The model
 (1)  V(t)=V0[1-epi+ epi*exp(-c(t-t0))]
 (2)  V(t)=V0{A*exp[-lambda1(t-t0)]+(1-A)*exp[-lambda2(t-t0)]}
 
 in formula (2) lambda1=0.5*{(c+delta)+[(c-delta)^2+4*(1-epi)*c*delta]^0.5}
   
 lambda2=0.5*{(c+delta)-[(c-delta)^2+4*(1-epi)*c*delta]^0.5}
A=(epi*c-lambda2)/(lambda1-lambda2)
 
 The regression rule :
 for formula (1):(t=2,that is) first 8 rows are used for non-linear
 regression
 epi,c,t0,V0 parameters are obtained 
 for formula (2):all 13 rows of results are used for non-linear regression 
 lambda1,lambda2,A (with these parameters, delta can be calculated from them)
 
 Thanks for help
 Ster Lesser
 
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/nls-problem-with-R-tp3494454p3497825.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.

-- 
Andrew Robinson  
Program Manager, ACERA 
Department of Mathematics and StatisticsTel: +61-3-8344-6410
University of Melbourne, VIC 3010 Australia   (prefer email)
http://www.ms.unimelb.edu.au/~andrewpr  Fax: +61-3-8344-4599
http://www.acera.unimelb.edu.au/

Forest Analytics with R (Springer, 2011) 
http://www.ms.unimelb.edu.au/FAwR/
Introduction to Scientific Programming and Simulation using R (CRC, 2009): 
http://www.ms.unimelb.edu.au/spuRs/

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


Re: [R] quantmod's addTA plotting functions

2011-05-05 Thread P Ehlers

On 2011-05-05 0:47, Russ Abbott wrote:

Hi,

I'm having trouble with quantmod's addTA plotting functions.  They seem to
work fine when run from the command line. But when run inside a function,
only the last one run is visible.  Here's an example.


test.addTA- function(from = 2010-06-01) {
 getSymbols(^GSPC, from = from)
 GSPC.close- GSPC[,GSPC.Close]
 GSPC.EMA.3- EMA(GSPC.close, n=3, ratio=NULL)
 GSPC.EMA.10- EMA(GSPC.close, n=10, ratio=NULL)
 chartSeries(GSPC.close, theme=chartTheme('white'), up.col=black,
dn.col=black)
 addTA(GSPC.EMA.3,   on = 1, col = #ff)
 addTA(GSPC.EMA.10,  on = 1, col = #ff)
 # browser()
}


When I run this, GSPC.close always appears.  But only GSPC.EMA10 appears on
the plot along with it. If I switch the order of the addTA calls,
only GSPC.EMA3 appears. If I uncomment the call to browser() neither appears
when the browser() interrupt occurs. I can then draw both GSPC.EMA.3 and
GSPC.EMA10 manually, and let the function terminate. All intended plots are
visible after the function terminates. So it isn't as if one wipes out the
other. This shows that it's possible to get all three lines on the plot, but
I can't figure out how to do it without manual intervention. Any suggestions
are appreciated.


Perhaps you didn't see this NOTE on the ?TA help page:

Calling any of the above methods from within a function
or script will generally require them to be wrapped in a
plot call as they rely on the context of the call to
initiate the actual charting addition.

Peter Ehlers



Thanks.

*-- Russ *

[[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] Using functions/loops for repetitive commands

2011-05-05 Thread Gerrit Eichner

Hello, Derek,

see below.

On Thu, 5 May 2011, dereksloan wrote:

I still need to do some repetitive statistical analysis on some outcomes 
from a dataset.


Take the following as an example;

id  sex hiv age famsize bmi resprate
1   M   Pos 23  2   16  15
2   F   Neg 24  5   18  14
3   F   Pos 56  14  23  24
4   F   Pos 67  3   33  31
5   M   Neg 34  2   21  23

I want to know if there are statistically detectable differences in all 
of the continuous variables in my data set when subdivided by sex or hiv 
status (ie are age, family size, bmi and resprate different in my male 
and female patients or in hiv pos/neg patients) Of course I can use 
wilcoxon or t-tests e.g:


wilcox.test( age~sex)
wilcox.test(famsize~sex)
wilcox.test(bmi~sex)
wilcox.test(resprate~sex)
wilcox.test( age~hiv)
wilcox.test(famsize~hiv)
wilcox.test(bmi~hiv)
wilcox.test(resprate~hiv)
 [snip]



Define, e. g.,

my.wilcox.tests - function( var.names, groupvar.name, data) {
 lapply( var.names,
 function( v) {
  form - as.formula( paste( v, ~, groupvar.name))
  wilcox.test( form, data = data)
  } )
 }


and call something like

my.wilcox.test( character vector with relevant variable names,
character string with relevant grouping variable,
data = your data set as data frame)

Caveat: untested!

 Hth  --  Gerrit

-
Dr. Gerrit Eichner   Mathematical Institute, Room 212
gerrit.eich...@math.uni-giessen.de   Justus-Liebig-University Giessen
Tel: +49-(0)641-99-32104  Arndtstr. 2, 35392 Giessen, Germany
Fax: +49-(0)641-99-32109http://www.uni-giessen.de/cms/eichner

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


Re: [R] Panels order in lattice graphs

2011-05-05 Thread Cristina Silva

Thank you very much.

Cristina

On 05/05/2011 10:44, Deepayan Sarkar wrote:

On Wed, May 4, 2011 at 9:20 PM, Cristina Silvacsi...@ipimar.pt  wrote:

Hi all,

In lattice graphs, panels are drawn from left to right and bottom to top.
The flag as.table=TRUE changes to left to right and top to bottom. Is
there any way to change to first top to bottom and then left to right?
didn´t find anything neither in Help pages nor Lattice book.

See ?packet.panel.default. For example,


p- xyplot(mpg ~ disp | factor(carb), mtcars, as.table = TRUE)

print(p, packet.panel = packet.panel.default)

my.packet.panel-
 function(layout, condlevels, page, row, column, ...)
{
 tlayout- layout[c(2, 1, 3)] # switch row and column
 print(packet.panel.default(tlayout, condlevels, page = page,
row = column, column = row, ...))
}

print(p, packet.panel = my.packet.panel)


-Deepayan




--
--
Cristina Silva
INRB/L-IPIMAR
Unidade de Recursos Marinhos e Sustentabilidade
Av. de Brasília, 1449-006 Lisboa
Portugal
Tel.: 351 21 3027096
Fax: 351 21 3015948
csi...@ipimar.pt

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

2011-05-05 Thread Joel
Hi all R users

Ive got a file that contains diffrent settings in the manor of:

setting1=value1
setting2=value2
setting3=value3
setting4=value4
.
.
.

What I want to do is open the file and change the value of a specific
setting
like wanna change setting4=value4 - setting4=value5 and then save the
file again.

setting1=value1
setting2=value2
setting3=value3
setting4=value5
.
.
.




--
View this message in context: 
http://r.789695.n4.nabble.com/Alter-a-line-in-a-file-tp3498187p3498187.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] Draw a nomogram after glm

2011-05-05 Thread Frank Harrell
Please read the documentation for the rms package, particularly the datadist
function.

Note that in your subject line glm should be lrm.

Frank


Komine wrote:
 
 Hi all R users 
 I did a logistic regression with my binary variable Y (0/1) and 2
 explanatory variables.
 Now I try to draw my nomogram with predictive value. I visited the help of
 R but I have problem to understand well the example. When I use glm
 fonction, I have a problem, thus I use lrm. My code is: 
 modele-lrm(Y~L+P,data=donnee)
 fun- function(x) plogis(x-modele$coef[1]+modele$coef[2])
 f - Newlabels(modele,c(L=poids,P=taille))  
 nomogram(f, fun=list('Prob Y=1'=plogis), 
  fun.at=c(seq(0,1,by=.1),.95,.99),
  lmgp=.1, cex.axis=.6)
  fun.at=c(.01,.05,seq(.1,.9,by=.1),.95,.99),
  lmgp=.2, cex.axis=.6)
 options(Fire=NULL)
 Result is bad and I have this following error message:
 Erreur dans value.chk(at, i, NA, -nint, Limval, type.range = full) : 
   variable L does not have limits defined by datadist
 
 Could you help me on the code to draw nomogram. 
 Nb: my English is low, I apologize.
 Thank for your help
 Komine
 


-
Frank Harrell
Department of Biostatistics, Vanderbilt University
--
View this message in context: 
http://r.789695.n4.nabble.com/Draw-a-nomogram-after-glm-tp3498144p3498279.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] Alter a line in a file.

2011-05-05 Thread jim holtman
try this:

a - readLines(textConnection('setting1=value1
setting2=value2
setting3=value3
setting4=value4'))
closeAllConnections()
# change  values
ac - sub('setting4=value4', 'setting4=value5', a)
writeLines(ac, con='myFile.txt')


On Thu, May 5, 2011 at 8:16 AM, Joel joda2...@student.uu.se wrote:
 Hi all R users

 Ive got a file that contains diffrent settings in the manor of:

 setting1=value1
 setting2=value2
 setting3=value3
 setting4=value4
 .
 .
 .

 What I want to do is open the file and change the value of a specific
 setting
 like wanna change setting4=value4 - setting4=value5 and then save the
 file again.

 setting1=value1
 setting2=value2
 setting3=value3
 setting4=value5
 .
 .
 .




 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Alter-a-line-in-a-file-tp3498187p3498187.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.




-- 
Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?

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


[R] Odp: Alter a line in a file.

2011-05-05 Thread Petr PIKAL
Hi

r-help-boun...@r-project.org napsal dne 05.05.2011 14:16:04:

 Joel joda2...@student.uu.se 
 Odeslal: r-help-boun...@r-project.org
 
 05.05.2011 14:16
 
 
 Hi all R users
 
 Ive got a file that contains diffrent settings in the manor of:

What file, what is its structure, is it some R object or separate file? 
What did you try and what went wrong?

Regards
Petr

 
 setting1=value1
 setting2=value2
 setting3=value3
 setting4=value4
 .
 .
 .
 
 What I want to do is open the file and change the value of a specific
 setting
 like wanna change setting4=value4 - setting4=value5 and then save 
the
 file again.
 
 setting1=value1
 setting2=value2
 setting3=value3
 setting4=value5
 .
 .
 .
 
 
 
 
 --
 View this message in context: 
http://r.789695.n4.nabble.com/Alter-a-line-
 in-a-file-tp3498187p3498187.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] Outlier removal by Principal Component Analysis : error message

2011-05-05 Thread Claudia Beleites

Dear Boule,

thank you for your interest in hyperSpec.
In order to look into your *problem* I need some more information.

I suggest that we solve the error off-list. Please note also that 
hyperSpec has its own help mailing list:

hyperspec-h...@lists.r-forge.r-project.org
(due to the amount of spam I got to moderate, you need to subscribe 
first here: 
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/hyperspec-help)


- Which version of hyperSpec do you use? If it is the version from CRAN, 
could you please update to the development version at r-forge with

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

- Next, if the problem persists with the latest build, could you send me 
the raw data file so that I can exactly reproduce your problem?


- Also, for tracking down the exact source of the error, please execute
traceback ()
after you got the error and email me its output.

It is basically impossible to give general recommendations about 
*Outlier detection*: a few spectra that are very different from all 
other spectra may be outliers or they may be the target of a study...
This is also why the example in the vignette uses a two step procedure: 
PCA only identifies suspects, i.e. spectra that have very different 
scores than all others for some principal components. The second step is 
a manually supervised decision whether the spectrum is really an outlier.


The first step could be replaced by other measures that however depend 
on your data. E.g. if you expect/know your data to consist of different 
clusters, suspects could be spectra that are too far away from any 
cluster. If your data comes from a mixture of a few components, spectra 
that cannot be modeled decently by a few PLS components could be 
suspicious. Or spectra that require an own component, ...
Some kinds of outliers are actually well-defined in a spectroscopic 
sense, e.g. contamination by fluorescent lamp light.


The second step could be replaced by an automatic decision, e.g. with a 
distance threshold.
Personally, I rather use the term filtering for such automatic rules. 
And there you can think about any number of rules your spectra must 
comply with in order to be acceptable: signal to noise ratio, minimal 
and maximal intensity, original offset (baseline) less than, ...


Hope that helps,

Claudia



I am currently analysis Raman spectroscopic data with the hyperSpec package.
I consulted the documentation on this package and I found an example
work-flow dedicated to Raman spectroscopy (see the address :
http://hyperspec.r-forge.r-project.org/chondro.pdf)

I am currently trying to remove outliers thanks to PCA just as they did in
the documentation, but I get a message error I can't explain. Here is my
code :

#import the data :
T=read.table('bladder bis concatenation colonne.txt',header=TRUE)
spec=new(hyperSpec,wavelength=T[,1],spc=t(T[,-1]),data=data.frame(sample=colnames(T[,-1])),label=list(.wavelength=Raman
shift (cm-1),spc=Intensity (a.u.)))

#baseline correction of the spectra
spec=spec[,,500~1800]
bl=spc.fit.poly.below(spec)
spec=spec-bl

#normalization of the spectra
spec=sweep(spec,1,apply(spec,1,mean),'/')

#PCA
pca=prcomp(~ spc,data=spec$.,center=TRUE)
scores=decomposition(spec,pca$x,label.wavelength=PC,label.spc=score/a.u.)
loadings=decomposition(spec,t(pca$rotation),scores=FALSE,label.spc=laoding
I/a.u.)

#plot the scores of the first 20 PC against all other to have an idea where
to find the outliers
pairs(scores[[,,1:20]],pch=19,cex=0.5)

#identify the outliers thanks to map.identify
out=map.identify(scores[,,5])
Erreur dans `[.data.frame`(x@data, , j, drop = FALSE) :
   undefined columns selected

Does anybody understand where the problem comes from ?
And does anybody know another mean to find spectra outliers ?

Thank you in advance.

Boule

--
View this message in context: 
http://r.789695.n4.nabble.com/Outlier-removal-by-Principal-Component-Analysis-error-message-tp3496023p3496023.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.



--
Claudia Beleites
Spectroscopy/Imaging
Institute of Photonic Technology
Albert-Einstein-Str. 9
07745 Jena
Germany

email: claudia.belei...@ipht-jena.de
phone: +49 3641 206-133
fax:   +49 2641 206-399

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


Re: [R] Alter a line in a file.

2011-05-05 Thread Jannis
Well your question is quite general the solution would involve several steps. 
Probably the easiest solution would be to read the data in as a dataframe 
(using read.table()) and using the '=' as the separator of the columns. Then 
change the desired values in the dataframe and save it back as a *.csv file, 
again using sep='='. Another option would be to read the data as a text string 
and use regexpressions to replace certain strings.

Hope that gets you started
Jannis

--- Joel joda2...@student.uu.se schrieb am Do, 5.5.2011:

 Von: Joel joda2...@student.uu.se
 Betreff: [R] Alter a line in a file.
 An: r-help@r-project.org
 Datum: Donnerstag, 5. Mai, 2011 12:16 Uhr
 Hi all R users
 
 Ive got a file that contains diffrent settings in the manor
 of:
 
 setting1=value1
 setting2=value2
 setting3=value3
 setting4=value4
 .
 .
 .
 
 What I want to do is open the file and change the value of
 a specific
 setting
 like wanna change setting4=value4 - setting4=value5
 and then save the
 file again.
 
 setting1=value1
 setting2=value2
 setting3=value3
 setting4=value5
 .
 .
 .
 
 
 
 
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Alter-a-line-in-a-file-tp3498187p3498187.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@r-project.org
 mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained,
 reproducible code.


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


Re: [R] Alter a line in a file.

2011-05-05 Thread Joel

jholtman wrote:
 
 a - readLines(textConnection('setting1=value1
 setting2=value2
 setting3=value3
 setting4=value4'))
 closeAllConnections()
 # change  values
 ac - sub('setting4=value4', 'setting4=value5', a)
 writeLines(ac, con='myFile.txt')
 

Problem is that I dont know the value on all the settings that I wanna
change otherwise that looks like something to continue on.



Petr Pikal wrote:
 
 What file, what is its structure, is it some R object or separate file?
 What did you try and what went wrong?
 
 Regards
 Petr 
 

Just a normal textfile nothing fancy
Ive tried diffrent kind of ways of useing my OS witch is linux by the system
command to do it for me but Im not good enought on regexp to get it to work
properly.

--
View this message in context: 
http://r.789695.n4.nabble.com/Alter-a-line-in-a-file-tp3498187p3498316.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] Alter a line in a file.

2011-05-05 Thread Petr PIKAL
Hi

r-help-boun...@r-project.org napsal dne 05.05.2011 15:13:34:

 Joel joda2...@student.uu.se 
 Odeslal: r-help-boun...@r-project.org
 
 05.05.2011 15:13
 
 
 jholtman wrote:
  
  a - readLines(textConnection('setting1=value1
  setting2=value2
  setting3=value3
  setting4=value4'))
  closeAllConnections()
  # change  values
  ac - sub('setting4=value4', 'setting4=value5', a)
  writeLines(ac, con='myFile.txt')
  
 
 Problem is that I dont know the value on all the settings that I wanna
 change otherwise that looks like something to continue on.
 

But in that case how would you like to select the setting?

 
 
 Petr Pikal wrote:
  
  What file, what is its structure, is it some R object or separate 
file?
  What did you try and what went wrong?
  
  Regards
  Petr 
  
 
 Just a normal textfile nothing fancy
 Ive tried diffrent kind of ways of useing my OS witch is linux by the 
system
 command to do it for me but Im not good enought on regexp to get it to 
work
 properly.

I read the simple text file by read.table

 data
 V1
1 setting1=value1
2 setting2=value2
3 setting3=value3
4 setting4=value4

 grep(4, data$V1)
[1] 4

Regards
Petr

 
 --
 View this message in context: 
http://r.789695.n4.nabble.com/Alter-a-line-
 in-a-file-tp3498187p3498316.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] Simple General Statistics and R question (with 3 line example) - get z value from pairwise.wilcox.test

2011-05-05 Thread peter dalgaard

On May 5, 2011, at 10:58 , JP wrote:

 On 4 May 2011 15:32, peter dalgaard pda...@gmail.com wrote:
 
 
 On May 4, 2011, at 15:11 , JP wrote:
 
 Peter thanks for the fantastically simple and understandable explanation...
 
 To sum it up... to find the z values of a number of pairwise wilcox
 tests do the following:
 
 # pairwise tests with bonferroni correction
 x - pairwise.wilcox.test(a, b, alternative=two.sided,
 p.adj=bonferroni, exact=F, paired=T)
 
 
 You probably don't want the bonferroni correction there. Rather 
 p.adj=none. You generally correct the p values for multiple testing, not 
 the test statistics.
 
 
 Oh, I see thanks... of course since I have 5 groups (samples) and 10
 comparisons I still have to correct when quoting p values...
 
 
 (My sentiment would be to pick apart the stats:::wilcox.test.default 
 function and clone the computation of Z from it, but presumably backtracking 
 from the p value is a useful expedient.)
 
 
 Should this be so onerous for the user [read non-statistician] ?


My main reservation is that if the p value gets very small or close to 1 (for 
1-sided tests), then it might not be possible to reconstruct the underlying Z 
(qnorm(pnorm(Z)) breaks down around Z = -37 and Z=+8). If you get sensible 
values, there's probably not a problem.


 
 # what is the data structure we got back
 is.matrix(x$p.value)
 # p vals
 x$p.value
 # z.scores for each
 z.score - qnorm(x$p.value / 2)
 
 
 Hmm, you're not actually getting a signed z out of this, you might want to 
 try alternative=greater and drop the division by 2 inside qnorm(). (If the 
 signs come out inverted, I meant less not greater...)
 
 
 But I need a two sided test (changing the alternative would change the
 hypothesis!)...  do I still do this?

For the z's, yes.

Hmm, the asymmetry of qnorm(pnorm(...)) indicates that you might want to be a 
bit more careful.

 All my z values are negative
 
 Is this correct?

No, that's the problem. The sign of Z should depend on whether the signed ranks 
are predominantly positive or negative. If you do a two-sided p-value and 
divide by two, then by definition you get something less than .5 and qnorm of 
that will be negative. So if the 2-sided p is 0.04, the one-sided p will be 
either 0.02 or 0.98, depending on the alternative and on whether the V 
statistic is above or below its expectation. Notice that this corresponds to Z 
statistics of opposite sign:

 qnorm(.02)
[1] -2.053749
 qnorm(.98)
[1] 2.053749

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

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


Re: [R] Using functions/loops for repetitive commands

2011-05-05 Thread dereksloan
Your code may be untested but it works - also helping me slowly to start
understanding how to write functions. Thank you.

However I still have difficulty. I also have some categorical variables to
analyse by age  hiv status - i.e. my dataset expands to (for example);

id  sex hiv age famsize bmi resprate   smoker   alcohol
1   M   Pos 23  2  16   15 Y
   Y
2   F   Neg 24  5  18   14 Y
   Y
3   F   Pos 56  14 23   24 Y
   N
4   F   Pos 67  3  33   31 N
   N
5   M   Neg 34  2  21   23 N
   N


Using the template for the code you sent me I thought I could analyse the
categorical variables by sex  hiv status using a chiq-squared test;

Long-hand this would be;

chisq.test(smoker,sex)
chisq.test(alcohol,sex)
chisq.test(smoker,hiv)
chisq.test(alcohol,hiv)

Again I wanted to use a function to loop automate it and thought I could
write;

categ-c(smoker,alcohol)
group.name-c(sex,hiv)
bl.chisq-function(categ,group.name,dataframe name){
lapply(categ,
function(y){
form2-as.formula(paste(y,group.name))
chisq.test(form2,dataframe name)
})
}

bl.chisq(categ,group.name,data frame name)

but I get an error message:

Error in parse(text = x) : unexpected symbol in smoker sex

What is wrong with the code? Is is because the wilcox.test is a formula
(with a ~ symbol for modelling) whilst the chisq.test simply requires me to
list raw data? If so how can I change my code to automate the chisq.test in
the same way I did for the wilcox.test?

Many thanks for any help!

Derek 




--
View this message in context: 
http://r.789695.n4.nabble.com/Using-functions-loops-for-repetitive-commands-tp3498006p3498427.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] Simple General Statistics and R question (with 3 line example) - get z value from pairwise.wilcox.test

2011-05-05 Thread JP
Thanks once again Peter, I understand your points -- I fiddled and
googled and read some more and found an eas(ier) route:

library(coin)
t - wilcoxsign_test(a ~ b, alternative = two.sided, distribution =
exact())  # This is equivalent to paired wilcox.test
pval - pvalue(t)
sweet.zscore - statistic(t) # signed and everything

# correct for multiple testing if you are doing a number of the above...

I would never have got here without your guidance - so kudos to you.
JP


On 5 May 2011 14:52, peter dalgaard pda...@gmail.com wrote:

 On May 5, 2011, at 10:58 , JP wrote:

 On 4 May 2011 15:32, peter dalgaard pda...@gmail.com wrote:


 On May 4, 2011, at 15:11 , JP wrote:

 Peter thanks for the fantastically simple and understandable explanation...

 To sum it up... to find the z values of a number of pairwise wilcox
 tests do the following:

 # pairwise tests with bonferroni correction
 x - pairwise.wilcox.test(a, b, alternative=two.sided,
 p.adj=bonferroni, exact=F, paired=T)


 You probably don't want the bonferroni correction there. Rather 
 p.adj=none. You generally correct the p values for multiple testing, not 
 the test statistics.


 Oh, I see thanks... of course since I have 5 groups (samples) and 10
 comparisons I still have to correct when quoting p values...


 (My sentiment would be to pick apart the stats:::wilcox.test.default 
 function and clone the computation of Z from it, but presumably 
 backtracking from the p value is a useful expedient.)


 Should this be so onerous for the user [read non-statistician] ?


 My main reservation is that if the p value gets very small or close to 1 (for 
 1-sided tests), then it might not be possible to reconstruct the underlying Z 
 (qnorm(pnorm(Z)) breaks down around Z = -37 and Z=+8). If you get sensible 
 values, there's probably not a problem.



 # what is the data structure we got back
 is.matrix(x$p.value)
 # p vals
 x$p.value
 # z.scores for each
 z.score - qnorm(x$p.value / 2)


 Hmm, you're not actually getting a signed z out of this, you might want to 
 try alternative=greater and drop the division by 2 inside qnorm(). (If 
 the signs come out inverted, I meant less not greater...)


 But I need a two sided test (changing the alternative would change the
 hypothesis!)...  do I still do this?

 For the z's, yes.

 Hmm, the asymmetry of qnorm(pnorm(...)) indicates that you might want to be a 
 bit more careful.

 All my z values are negative

 Is this correct?

 No, that's the problem. The sign of Z should depend on whether the signed 
 ranks are predominantly positive or negative. If you do a two-sided p-value 
 and divide by two, then by definition you get something less than .5 and 
 qnorm of that will be negative. So if the 2-sided p is 0.04, the one-sided p 
 will be either 0.02 or 0.98, depending on the alternative and on whether the 
 V statistic is above or below its expectation. Notice that this corresponds 
 to Z statistics of opposite sign:

 qnorm(.02)
 [1] -2.053749
 qnorm(.98)
 [1] 2.053749

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




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


Re: [R] Question about error of non-numeric argument to binary operator

2011-05-05 Thread David Winsemius


On May 5, 2011, at 1:31 AM, Maximo Polanco wrote:

I have been trying to do a nls model and gives me the error of a  
nonnumeric

argument

This is my data set

TT

FFT

V

C

table(file=c:/tt2.txt,header=T)

fit.model - nls(TT~60*(1+alpha*(v/c)^beta),data=tt2,  
start=list(alpha=1,

beta=3, v=1000))

Error in v/c : non-numeric argument to binary operator


You have (perhaps) defined a column name of C and then attempted to  
reference it with c. Since `c` is a (rather fundamental) function in  
R, the interpreter has no problem accessing `c` but trying to take   
the ratio of a scalar to a function fails.


You can try changing c to C above and it may work, but in the  
future, please heed the issues raised at the bottom of this trimmed  
message!


(It would be much better to not use either C or c for object names  
since they are both function names.)


?C
C {stats}
R Documentation
Sets Contrasts for a FactorDescription
Sets the contrasts attribute for the factor.

Usage
C(object, contr, how.many, ...)





is.numeric(tt2)


[1] FALSE


is.character(tt2)


[1] FALSE


as.numeric(tt2)


Error: (list) object cannot be coerced to type 'double'





This is my data set

TT

FFT

V

C


1

70.475

60
snipped long ... incorrectly formatted data due to failing to post in  
plain text.





[[alternative HTML version deleted]]

***

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

###

--

David Winsemius, MD
West Hartford, CT

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


Re: [R] nls problem with R

2011-05-05 Thread Mike Marchywka










 Date: Thu, 5 May 2011 01:20:33 -0700
 From: sterles...@hotmail.com
 To: r-help@r-project.org
 Subject: Re: [R] nls problem with R

 ID1 ID2 t V(t)
 1 1 0 6.053078443
 2 1 0.3403 5.56937391
 3 1 0.4181 5.45484486
 4 1 0.4986 5.193124598
 5 1 0.7451 4.31386722
 6 1 1.0069 3.645422269
 7 1 1.5535 3.587710965
 8 1 1.8049 3.740362689
 9 1 2.4979 3.699837726
 10 1 6.4903 2.908485019
 11 1 13.5049 1.888179494
 12 1 27.5049 1.176091259
 13 1 41.5049 1.176091259

 The model
 (1) V(t)=V0[1-epi+ epi*exp(-c(t-t0))]

A=Vo, B-Vo*epi, C=exp(-c*t0)
V(t)=A-B+B*C*exp(-ct)

or further, D=A-B, F=B*C,

V(t)=D+F*exp(-ct)

this model only really has 3 attriubtes: initial value, final value,
and decay constant yet you ask for 4 parameters. There is no
way to get a unique answer. For some reason this same form comes up
a lot here, I think this is about third time I've sene this in last few weeks.

I guess when fishing or shopping for forms to fit, it is tempting to
throw a bunch of parameteres into your model but this can create intractable
ambiguities. 

Indeed, if I just remove t0 and use your first 8 points I get this
( random starting values, but convewrged easily you still need to plot etc)


[1] 1   v= 8.77181162126362  epi= 0.672516376478598  cl= 1.90973175223917 t0= 0
.643481321167201
 summary(nls2)

Formula: V2 ~ v0 * (1 - epi + epi * exp(-cl * (T2)))

Parameters:
    Estimate Std. Error t value Pr(|t|)
v0    6.2901 0.3384  18.585  8.3e-06 ***
epi   0.5430 0.1373   3.955   0.0108 *
cl    0.9684 0.5491   1.763   0.1381
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 0.3579 on 5 degrees of freedom

Number of iterations to convergence: 11
Achieved convergence tolerance: 4.057e-06



 (2) V(t)=V0{A*exp[-lambda1(t-t0)]+(1-A)*exp[-lambda2(t-t0)]}

 in formula (2) lambda1=0.5*{(c+delta)+[(c-delta)^2+4*(1-epi)*c*delta]^0.5}

 lambda2=0.5*{(c+delta)-[(c-delta)^2+4*(1-epi)*c*delta]^0.5}
 A=(epi*c-lambda2)/(lambda1-lambda2)

 The regression rule :
 for formula (1):(t=2,that is) first 8 rows are used for non-linear
 regression
 epi,c,t0,V0 parameters are obtained
 for formula (2):all 13 rows of results are used for non-linear regression
 lambda1,lambda2,A (with these parameters, delta can be calculated from them)

 Thanks for help
 Ster Lesser

 --
 View this message in context: 
 http://r.789695.n4.nabble.com/nls-problem-with-R-tp3494454p3497825.html
 Sent from the R help mailing list archive at Nabble.com.

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


[R] Draw a nomogram after glm

2011-05-05 Thread Komine
Hi all R users 
I did a logistic regression with my binary variable Y (0/1) and 2
explanatory variables.
Now I try to draw my nomogram with predictive value. I visited the help of R
but I have problem to understand well the example. When I use glm fonction,
I have a problem, thus I use lrm. My code is: 
modele-lrm(Y~L+P,data=donnee)
fun- function(x) plogis(x-modele$coef[1]+modele$coef[2])
f - Newlabels(modele,c(L=poids,P=taille))  
nomogram(f, fun=list('Prob Y=1'=plogis), 
 fun.at=c(seq(0,1,by=.1),.95,.99),
 lmgp=.1, cex.axis=.6)
 fun.at=c(.01,.05,seq(.1,.9,by=.1),.95,.99),
 lmgp=.2, cex.axis=.6)
options(Fire=NULL)
Result is bad and I have this following error message:
Erreur dans value.chk(at, i, NA, -nint, Limval, type.range = full) : 
  variable L does not have limits defined by datadist

Could you help me on the code to draw nomogram. 
Nb: my English is low, I apologize.
Thank for your help
Komine 
 


--
View this message in context: 
http://r.789695.n4.nabble.com/Draw-a-nomogram-after-glm-tp3498144p3498144.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] Convert a presence/ absence matrix to a list of presence only

2011-05-05 Thread antu
Thank you, it perfectly worked, except I had to modify some codes on the
rep(, maxLen - length(sp)) because it gave me some error, thanks



--
View this message in context: 
http://r.789695.n4.nabble.com/Convert-a-presence-absence-matrix-to-a-list-of-presence-only-tp3468479p3498116.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] Using error in histograms

2011-05-05 Thread Kristof Ostir
Hello!

I am trying to produce a histogram of measurement data (orientation of
archaeological structures) that are a subject to measurement error.
The normal histogram just computes frequencies, but does not take into
account that a particular value is spread over a range of values (in
my case the spread is different for reach measurement and is larger
than the bin size).

The closest approach is kernel density estimation (in the image is a
comparison of histogram and KDE):
http://en.wikipedia.org/wiki/Kernel_density_estimation
http://en.wikipedia.org/wiki/File:Comparison_of_1D_histogram_and_KDE.png
However in my case the kernel size is different for each value. I
wrote a program in IDL that performs the plotting, but am just
wondering if such a function is available in R. Basically it is a
problem of summing (and later plotting) several data distributions.

I would appreciate also any hint to a book that might be dealing with
the problem. I am not an expert in statistics and I might not be using
use the correct terminology in web searches.

Regards,

Kristof

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

2011-05-05 Thread matibie
I'm trying to add the exact value on top of each column of an Histogram, i
have been trying with the text function but it doesn't work.
The problem is that the program it self decides the exact value to give to
each column, and ther is not like in a bar-plot that I know exactly which
values are been plotting. 
If anyone have any new idea on how to do this
Thanks
Matias

--
View this message in context: 
http://r.789695.n4.nabble.com/Insert-values-to-histogram-tp3498140p3498140.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] lm weight adj r-sq

2011-05-05 Thread agent dunham
Dear all, 

First of all apologies, I'm pretty newbie, and secondly I know this is not a
question for the forum but I'd be very grateful if you'd help me. 

I had problems with normality assumptions, and I tried with weights in the
linear regression this way: 

modelw -lm(log(v1)~v2+log(v2)+log(v3)+v4, data=dat, weight=1/group.var^2)

I'd like to know how interpret/compute adj R-sq/mse from modelw, in order to
compare it to the adj R-sq/mse from model 
(model - lm(log(v1)~v2+log(v2)+log(v3)+v4, data=dat)

Thanks in advance, u...@host.com

pd I set the weights following this notes: 

(I was reading here:
statistics.unl.edu/faculty/bilder/stat870/schedule/Chapter%2011.doc
http://statistics.unl.edu/faculty/bilder/)

--
View this message in context: 
http://r.789695.n4.nabble.com/lm-weight-adj-r-sq-tp3498020p3498020.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] heatmap.3

2011-05-05 Thread elodie
I am intesrested by your heatmap function (allowing matrix in ColSideColors
option). Can you give your complete code of your function? thanks

--
View this message in context: 
http://r.789695.n4.nabble.com/heatmap-3-tp1566584p3498156.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] distance matrix

2011-05-05 Thread antu
Hello all, 

I am wondering if there is anyway to create distance matrix for replicated
data

for example, 

I have a data like

sample  pop id  var1var2var3var4
1.1 1   a   1   1   0   1
1.2 1   a   0   0   1   0
1.3 1   a   1   1   0   1
2.1 2   b   0   0   1   0
2.2 2   b   1   1   1   1
2.3 2   b   0   1   0   0
2.4 2   b   1   0   1   1
3.1 3   a   0   1   0   1
3.2 3   a   1   1   1   0
3.3 3   a   0   0   0   0


dist(data[,c(4:7)] gives the distance of samples, but I also need the
distances of pop ie (1,2,3) and also id (a,b) how can I achieve this??

Thanks


  

--
View this message in context: 
http://r.789695.n4.nabble.com/distance-matrix-tp3498033p3498033.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] Null

2011-05-05 Thread pcc
This is probably a very simple question but I am completely stumped!I am
trying to do shapiro.wilk(x) test on a relatively small dataset(75) and each
time my variable and keeps coming out as 'NULL', and 

 shapiro.test(fcv)
Error in complete.cases(x) : no input has determined the number of cases

my text file looks like this:

case
1.600972896
1.534026106
1.633468456
1.69019608
1.686636269
1.713490543
1.460897843
1.604226053
1.547774705
1.575187845
1.50242712
1.489958479
1.555094449
1.56937391
1.46686762
1.583198774
1.59439255
1.627365857
1.596597096
1.598790507
1.596597096
1.613841822
1.607455023
1.586587305
1.72427587
1.668385917
1.743509765
1.5774918
1.709269961
1.507855872
1.650307523
1.670245853
1.721810615
1.613841822
1.586587305
1.658011397
1.595496222
1.662757832
1.521138084
1.564666064
1.515873844
1.596597096
1.617000341
1.621176282
1.598790507
1.73479983
1.498310554
1.571708832
1.426511261
1.698970004
1.534026106
1.5774918
1.682145076
1.689308859
1.654176542
1.526339277
1.545307116
1.658964843
1.638489257
1.557507202
1.604226053
1.627365857
1.651278014
1.627365857
1.559906625
1.720159303
1.64738297
1.62324929
1.698970004
1.704150517
1.57863921
1.558708571
1.681241237
1.539076099
1.5132176

Any ideas?

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

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


Re: [R] How to fit a random data into Beta distribution?

2011-05-05 Thread Shekhar

Hi,

@Steven: Since Beta distribution is a generic distribution by which i
mean that by varying the parameter of alpha and beta we can fit any
distribution.
So to check this i generated a random data from Normal distribution
like

x.norm-rnorm(n=100,mean=10,sd=10);

Now i want to estimate the paramters alpha and beta of the beta
distribution which will fit the above generated random data. That's
what i want to do.

@Ali: When you said you drafted your own procedure, do you mean that
you are calculate the parameters using MLE or bayesian..???Can you
please give me some more ideas into this?

Thanks and Regards,
Som Shekhar

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


Re: [R] Remove all whitespaces

2011-05-05 Thread Shekhar
A more elegant way would be:

myString-1 2 3 4 5
myString-paste(unlist(strsplit(myString, )),collapse=)

The output will be 12345

Regards,
Som Shekhar

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] functions pandit and treebase in the package apTreeshape

2011-05-05 Thread Arnau Mir
Hello.

I'm trying to use the functions pandit and treebase. They are in the package 
apTreeshape. Once I've loaded the package, R responses:

- no function pandit/treebase.

Somebody knows why or what is the reason?


Thanks,

Arnau.

Arnau Mir Torres
Edifici A. Turmeda
Campus UIB
Ctra. Valldemossa, km. 7,5
07122 Palma de Mca.
tel: (+34) 971172987
fax: (+34) 971173003
email: arnau@uib.es
URL: http://dmi.uib.es/~arnau



[[alternative HTML version deleted]]

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


Re: [R] Using functions/loops for repetitive commands

2011-05-05 Thread Shekhar
Hi Derek,
You can accomplish your loop jobs by following means:
(a) use for loop
(b) use while loop
(c) use lapply, tapply, or sapply. (i feel lapply is the elegant
way )


---For Loop-
for loops are pretty simple to use and is almost similar to any
other scripting languages you know.( I am referring to Matlab)

(Example 1) lets say you know that you have to run 10 iterations then
you can run it as

for(i in 1:10) print(i)
//it will print the number from 1 to 10

(Example 2) You don't know how many iterations you need to run. Only
thing you have is some vector and you want to do some operation on
that vector. You can do something like this:

myVector-c(20,45,23,45,89)
for(i in seq_along(myVector)) print(myVector[i]

-Using lapply-
In lapply you need to provide mainly two things:
(1)First parameter: vectors or some sequence of numbers
(2)Second parameter: A function which could be user defined function
or some other inbuilt function.

lapply will call the function for every number given in the First
parameter of the function)

For example:

x-c(10,20,20)
lapply(seq_along(x),function(i) {//your logic})

if you see the first parameter i have sent seq_along(x). The outcome
of seq_along(x) will be 1, 2,3.
Now lapply will take each of these numbers and call the function. That
means lapply is calling the function thrice for the current data set
something like this

function(1) { //your logic}
function(2) { }
function(3) { //)

That means your logic inside the function will be executed for each
and every value specified in the first parameter of the lapply
function.

I hope it helps you in some way.

For your problem, i am making a guess that you are using data frame or
matrix to store the data and then you want to automate the data right?
You can try using lapply, i think that would be efficient..Let me
also try ..

Regards,
Som Shekhar

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Confidence interval for difference in Harrell's c statistics (or equivalently Somers' D statistics)

2011-05-05 Thread Laura Bonnett
Dear All,

I am trying to calculate a 95% confidence interval for the difference in two
c statistics (or equivalently D statistics).  In Stata I gather that this
can be done using the lincom command.  Is there anything similar in R?

As you can see below I have two datasets (that are actually two independent
subsets of the same data) and the respective c statistics for the variables
in both cases.  What I would now like to do is to prove that there is no
statistically significant difference between the statistics (between the dev
and val datasets.)

Any help would be much appreciated.

 rdev - rcorrcens(Surv(stimes1,eind1)~gendat1+neurodat1)
 rdev

Somers' Rank Correlation for Censored DataResponse
variable:Surv(stimes1, eind1)

  CDxy  aDxySDZ  Pn
gendat1   0.534  0.069 0.069 0.017 3.98 0.0001 1500
neurodat1 0.482 -0.036 0.036 0.011 3.18 0.0015 1500

 rval - rcorrcens(Surv(stimes2,eind2)~gendat2+neurodat2)
 rval

Somers' Rank Correlation for Censored DataResponse
variable:Surv(stimes2, eind2)

  CDxy  aDxySDZ Pn
gendat2   0.543  0.085 0.085 0.017 4.94 0e+00 1500
neurodat2 0.481 -0.038 0.038 0.011 3.44 6e-04 1500

Many thanks,
Laura
P.S. I'm using Windows XP, R 2.9.2

[[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] RV: R question

2011-05-05 Thread Pamela Santelices Elgueta

which is the maximum large of digits that R has?, because SQL work with 50 
digits I think. and I need a software that work  with a lot of digits.
Thanks.

Pamela Santelices Elgueta
Estadístico
Instituto Nacional de Estadísticas
Fono: (56-2) 7962491
Paseo Bulnes 209 oficina 82
Santiago


[[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] two-way group mean prediction in survreg with three factors

2011-05-05 Thread Pang Du
Oops, I hope not too.  Don't know why I had the brackets around B+C.  My
model is actually A*B+C.  And I'm not sure how to obtain the two-way
prediction of AB with C marginalized.  Thanks.

Pang

-Original Message-
From: Andrew Robinson [mailto:a.robin...@ms.unimelb.edu.au] 
Sent: Wednesday, May 04, 2011 10:13 PM
To: Pang Du
Cc: r-help@r-project.org
Subject: Re: [R] two-way group mean prediction in survreg with three factors

I hope not!

Facetiousness aside, the model that you have fit contains C, and,
indeed, an interaction between A and C.  So, the effect of A upon the
response variable depends on the level of C.  The summary you want
must marginalize C somehow, probably by a weighted or unweighted
average across its levels.  What does that summary really mean?  Can
you meaningfully average across the levels of a predictor that is
included in the model as a main and an interaction term?

Best wishes

Andrew

On Wed, May 04, 2011 at 12:24:50PM -0400, Pang Du wrote:
 I'm fitting a regression model for censored data with three categorical
 predictors, say A, B, C.  My final model based on the survreg function is 
 
 Surv(..) ~ A*(B+C).
 
 I know the three-way group mean estimates can be computed using the
predict
 function. But is there any way to obtain two-way group mean estimates, say
 estimated group mean for (A1, B1)-group?  The sample group means don't
 incorporate censoring and thus may not be appropriate here.
 
  
 
 Pang Du
 
 Virginia Tech
 
 
   [[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.

-- 
Andrew Robinson  
Program Manager, ACERA 
Department of Mathematics and StatisticsTel: +61-3-8344-6410
University of Melbourne, VIC 3010 Australia   (prefer email)
http://www.ms.unimelb.edu.au/~andrewpr  Fax: +61-3-8344-4599
http://www.acera.unimelb.edu.au/

Forest Analytics with R (Springer, 2011) 
http://www.ms.unimelb.edu.au/FAwR/
Introduction to Scientific Programming and Simulation using R (CRC, 2009): 
http://www.ms.unimelb.edu.au/spuRs/

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 fit a random data into Beta distribution?

2011-05-05 Thread Ravi Varadhan
Beta is not as general as you think.  Its support is limited to [0,1], but you 
are trying to fit data that lies outside of its support.  Please read about the 
beta distribution from a basic stats/prob book.  

Ravi.

From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On Behalf Of 
Shekhar [shekhar2...@gmail.com]
Sent: Thursday, May 05, 2011 6:54 AM
To: r-help@r-project.org
Subject: Re: [R] How to fit a random data into Beta distribution?

Hi,

@Steven: Since Beta distribution is a generic distribution by which i
mean that by varying the parameter of alpha and beta we can fit any
distribution.
So to check this i generated a random data from Normal distribution
like

x.norm-rnorm(n=100,mean=10,sd=10);

Now i want to estimate the paramters alpha and beta of the beta
distribution which will fit the above generated random data. That's
what i want to do.

@Ali: When you said you drafted your own procedure, do you mean that
you are calculate the parameters using MLE or bayesian..???Can you
please give me some more ideas into this?

Thanks and Regards,
Som Shekhar

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Conditional distribution plot using Model-based Recursive Partitioning

2011-05-05 Thread Alan Fernihough
Hello,

I am using the party module to estimate the relationship between the
probability of being a student and number of siblings (alive). However, I
need to include a number of relevant covariates. My code is below:

fm3 - mob(Student ~ age + alive + sex2 + cwa + cha + cym | Religion+Servant
+ Literacy, control = ctrl, data = samp2, model = glinearModel, family
=binomial())
plot(fm3, tp_args = list(which = alive),tnex = 2, type = simple )

Which works fine. However, the plots generated do not show the conditional
relationship between the dependent and independent variable at each node.
Basically, there are spinogram leafs at nodes where the unconditional
relationship is the opposite to the conditional relationship -- as given in
the summary tables.

I have tried playing around with the plot function arguements, yet to no
avail.

Can anybody suggest to me a way which I would be able to plot the tree and
have either a conditional spinogram in the leaf or even just text with a
number showing a marginal effect or coefficient please?

Thanks,

Alan

-- 
Alan Fernihough
IRCHSS Scholar
UCD School of Economics

[[alternative HTML version deleted]]

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


Re: [R] Using functions/loops for repetitive commands

2011-05-05 Thread David Winsemius


On May 5, 2011, at 10:01 AM, dereksloan wrote:

Your code may be untested but it works - also helping me slowly to  
start

understanding how to write functions. Thank you.

However I still have difficulty. I also have some categorical  
variables to
analyse by age  hiv status - i.e. my dataset expands to (for  
example);


id  sex hiv age famsize bmi resprate   smoker   alcohol
1   M   Pos 23  2  16   15 Y
   Y
2   F   Neg 24  5  18   14 Y
   Y
3   F   Pos 56  14 23   24 Y
   N
4   F   Pos 67  3  33   31 N
   N
5   M   Neg 34  2  21   23 N
   N


Using the template for the code you sent me I thought I could  
analyse the

categorical variables by sex  hiv status using a chiq-squared test;

Long-hand this would be;

chisq.test(smoker,sex)
chisq.test(alcohol,sex)
chisq.test(smoker,hiv)
chisq.test(alcohol,hiv)

Again I wanted to use a function to loop automate it and thought I  
could

write;

categ-c(smoker,alcohol)
group.name-c(sex,hiv)
bl.chisq-function(categ,group.name,dataframe name){
lapply(categ,
function(y){
form2-as.formula(paste(y,group.name))


I haven't tested it but I suspect you failed to note that Eichner used  
sep=~ in his paste argument to as.formula().



chisq.test(form2,dataframe name)
})
}

bl.chisq(categ,group.name,data frame name)

but I get an error message:

Error in parse(text = x) : unexpected symbol in smoker sex

What is wrong with the code? Is is because the wilcox.test is a  
formula
(with a ~ symbol for modelling) whilst the chisq.test simply  
requires me to
list raw data? If so how can I change my code to automate the  
chisq.test in

the same way I did for the wilcox.test?

Many thanks for any help!

Derek





David Winsemius, MD
West Hartford, CT

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


Re: [R] Confidence interval for difference in Harrell's c statistics (or equivalently Somers' D statistics)

2011-05-05 Thread David Winsemius


On May 5, 2011, at 8:20 AM, Laura Bonnett wrote:


Dear All,

I am trying to calculate a 95% confidence interval for the  
difference in two
c statistics (or equivalently D statistics).  In Stata I gather that  
this

can be done using the lincom command.  Is there anything similar in R?


Have you looked at rcorrp.cens {Hmisc}?

snipped


[[alternative HTML version deleted]]



Please post in plain text.

--
David Winsemius, MD
West Hartford, CT

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


Re: [R] distance matrix

2011-05-05 Thread csrabak

Em 5/5/2011 07:34, antu escreveu:

Hello all,

I am wondering if there is anyway to create distance matrix for replicated
data

for example,

I have a data like

sample  pop id  var1var2var3var4
1.1 1   a   1   1   0   1
1.2 1   a   0   0   1   0
1.3 1   a   1   1   0   1
2.1 2   b   0   0   1   0
2.2 2   b   1   1   1   1
2.3 2   b   0   1   0   0
2.4 2   b   1   0   1   1
3.1 3   a   0   1   0   1
3.2 3   a   1   1   1   0
3.3 3   a   0   0   0   0


dist(data[,c(4:7)] gives the distance of samples, but I also need the
distances of pop ie (1,2,3) and also id (a,b) how can I achieve this??

Just a doubt: does the idea of comparing (ordering) the variable pop and 
id make sense? Or expressed in more direct way: what would a distance 
between b and a mean (same for the pop labels)?


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Tone in mailing lists (was issue with strange characters (readHTMLTable))

2011-05-05 Thread Janko Thyson
I did read How To Ask Questions The Smart Way 
http://www.catb.org/%7Eesr/faqs/smart-questions.html and I don't have 
a problem with calling me stupid and/or a winer for posting this...

What's the purpose of an R Mailing list (especially r-help), after all? 
IMHO it should be about R users being able to ask questions and getting 
help from those who would like to provide some. Unless a post has been 
written in an clearly offensive tone and/or shows a major amount of 
ignorance on the part of the person asking, why would you want to not 
just provide an answer to the question posed but deliver on top either 
sarcasm, personal criticism, sharp remarks or the like?

I also believe that it's in the nature of things that R users will most 
likely rather post about problems/bugs they encountered than to simply 
drop a line of acknowledgment for the people who continuously develop R 
and its packages. It's nice if they do explicitly express their 
gratitude in their posts (and this *does* happen a lot also), but it is 
not *demanded* and if they don't, it doesn't automatically mean that 
they are not grateful...

Please understand me right: all the people working on pushing R forward 
do fantastic work and I greatly appreciate the inputs from the entire 
community, I sometimes just wonder about the tone in the mailing lists. 
But that's probably just me , maybe it's just the way the cookie 
crumbles in technical mailing lists ...

Regards,
Janko

On 05.05.2011 11:33, R.T.A.J.Leenders wrote:
 Thank you. The line of code you give certainly resolves several of the
 issues.
 I didn't realize that font support is such a tough matter to realize. Let 
 me
 express my gratitude to those who provide this for us in R.
 On 04-05-11, Prof Brian Ripleyrip...@stats.ox.ac.uk  wrote:

 Oh, please!
 This is about the contributed package XML, not R and not Windows.
 Some of us have worked very hard to provide reasonable font support in R,
 including on Windows.  We are given exceedingly little credit, just
 the brickbats for things for which we are not responsible.  (We even work
 hard to port XML to Windows for you, again with almost zero credit.)
 That URL is a page in UTF-8, as its header says.  We have provided many 
 ways
 to work with UTF-8 on Windows, but it seems readHTMLTable() is not making
 use of them.
 You need to run iconv() on the strings in your object (which as it has
 factors, are the levels).  When you do so, you will discover that page
 contains characters not in your native charset (I presume, not having your
 locale).
 What you can do, in Rgui only, is
 for (n in names(Islands)) Encoding(levels(Islands[[n]]))-UTF-8
 but likely there are still characters it will not know how to display.
 On Wed, 4 May 2011, R.T.A.J.Leenders wrote:
 
WinXP-x32, R-21.13.0
Dear list,
 I have a problem that (I think) relates to the interaction between
 Windows
and R.
I am trying to scrape a table with data on the Hawai'ian Islands, 
 This is
 my
code:
library(XML)
u- [1]http://en.wikipedia.org/wiki/Hawaii;
tables- readHTMLTable(u)
Islands- tables[[5]]
The output is (first set of columns):
   IslandNickname
  Islands
   IslandNickname
Location
 1   Hawai�?�»i[7]The   Big   Island   
 19�?�°34�¢�¤�²N
 155�?�°30�¢�¤�²W�¯�»�¿ / �¯�»�¿19.567
 �?�°N 155.5�?�°W�¯�»�¿ / 19.567; -155.5
 2   Maui[8]TheValley   Isle   
 20�?�°48�¢�¤�²N
 156�?�°20�¢�¤�²W�¯�»�¿ / �¯�»�¿20.8�?�°N
 156.333�?�°W�¯�»�¿ / 20.8; -156.333
 3   Kaho�?�»olawe[9]   The   Target   Isle
 20�?�°33�¢�¤�²N
 156�?�°36�¢�¤�²W�¯�»�¿ / �¯�»�¿20.55
 �?�°N 156.6�?�°W�¯�»�¿ / 20.55; -156.6
 4  L�?na�?�»i[10] ThePineappleIsle
 20�?�°50�¢�¤�²N
 156�?�°56�¢�¤�²W�¯�»�¿ / �¯�»�¿20.833�?�°N 15
 6.933�?�°W�¯�»�¿ / 20.833; -156.933
 5 Moloka�?�»i[11]  TheFriendlyIsle
 21�?�°08�¢�¤�²N
 157�?�°02�¢�¤�²W�¯�»�¿ / �¯�»�¿21.133�?�°N 1
 57.033�?�°W�¯�»�¿ / 21.133; -157.033
 6O�?�»ahu[12]TheGatheringPlace
 21�?�°28�¢�¤�²N
 157�?�°59�¢�¤�²W�¯�»�¿ / �¯�»�¿21.467�?�°N 1
 57.983�?�°W�¯�»�¿ / 21.467; -157.983
 7   Kaua�?�»i[13]   The   Garden   Isle   
 22�?�°05�¢�¤�²N
 159�?�°30�¢�¤�²W�¯�»�¿ / �¯�»�¿22.083
 �?�°N 159.5�?�°W�¯�»�¿ / 22.083; -159.5
 8  Ni�?�»ihau[14]The   Forbidden   

[R] Boxplot in order

2011-05-05 Thread Silvano

Hi,

I need construct box plot graph, but I want keep Groups 
order


karla = data.frame(
Groups = 
factor(rep(c('CPre','SPre','C7','S7','C14','S14','C21','S21'), 
11)),

Time = rep(c(0,7,14,21), 11),
Resp = valor
)

boxplot(Resp~Groups, order=T)

doesn't work.

How do this?

--
Silvano Cesar da Costa
Departamento de Estatística
Universidade Estadual de Londrina
Fone: 3371-4346

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] cross-correlation table with subscript or superscript to indicate significant differences

2011-05-05 Thread yoav baranan

Hi, I wonder whether the following is possible with R, and whether anyone has 
done that and can share his/her code with me. I have a correlation matrix, and 
I want to create a correlation table that I can copy to Microsoft Word with a 
superscript above each correlation, indicating significant differences in the 
same row. That is, when correlations in the same row do not share superscript, 
it means that they are significantly different from each other. 
thanks,yoav   
[[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] Null

2011-05-05 Thread Yuta Tamberg
There were no problems when I repeated the test with data provided.
I simply created a vector
-c(1.600972896,1.534026106,1.633468456,1.69019608,1.686636269,1.713490543,1.460897843,1.604226053,1.547774705,1.575187845,1.50242712,1.489958479,1.555094449,1.56937391,1.46686762,1.583198774,1.59439255,1.627365857,1.596597096,1.598790507,1.596597096,1.613841822,1.607455023,1.586587305,1.72427587,1.668385917,1.743509765,1.5774918,1.709269961,1.507855872,1.650307523,1.670245853,1.721810615,1.613841822,1.586587305,1.658011397,1.595496222,1.662757832,1.521138084,1.564666064,1.515873844,1.596597096,1.617000341,1.621176282,1.598790507,1.73479983,1.498310554,1.571708832,1.426511261,1.698970004,1.534026106,1.5774918,1.682145076,1.689308859,1.654176542,1.526339277,1.545307116,1.658964843,1.638489257,1.557507202,1.604226053,1.627365857,1.651278014,1.627365857,1.559906625,1.720159303,1.64738297,1.62324929,1.698970004,1.704150517,1.57863921,1.558708571,1.681241237,1.539076099,1.5132176)
and performed shapiro.test() with following results:
W = 0.9876, p-value = 0.677
As far as I understand R, complete.cases has nothing to do with normality
check of single vector.

pcc wrote:
 
 This is probably a very simple question but I am completely stumped!I am
 trying to do shapiro.wilk(x) test on a relatively small dataset(75) and
 each time my variable and keeps coming out as 'NULL' 


--
View this message in context: 
http://r.789695.n4.nabble.com/Null-tp3498261p3498607.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] Vermunt's LEM in R

2011-05-05 Thread David Joubert

Hello-

Does anyone know of packages that could emulate what J. Vermunt's LEM does ? 
What is the closest relative in R ?
I use both R and LEM but have trouble transforming my multiway tables in R into 
a .dat file compatible with LEM. 

Thanks,

David Joubert
  
[[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] Compiling a FORTRAN program under Windows 7

2011-05-05 Thread Mikael Anderson
Hi,

I am trying to compile a FORTRAN program to call from R under Windows 7 but
I am having problem in the compiling step. To demonstrate this is the
program testit.f:

--
  subroutine TESTIT(x,n,m)
  dimension x(n)
  do 10 i=1,n
10  x(i)=x(i)**m
  end


When I compile it with gfortran I get the following error:

--
c:\MinGW\programsgfortran testit.f -o testit.o
c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../libmingw32.a(main.o):main.c:(.tex
t+0xd2): undefined reference to `WinMain@16'
collect2: ld returned 1 exit status.


I should add that a program like the following hello.f compiles with no
problem.

--
 READ (*, *) YOURNAME
 WRITE (*, 200) YOURNAME
 200 FORMAT(//,' Hello ',A/)
 STOP
 END
--

I realize that this is not directly a question about R but I guess there are
some people here who have compiled FORTRAN programs under Windows 7 to call
from R. I appreciate any help to fix the problem.

/Mikael

[[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] Confidence interval for difference in Harrell's c statistics (or equivalently Somers' D statistics)

2011-05-05 Thread Laura Bonnett
Dear David,

Thank you for your reply.  I have come across rcorrp.cens before.  However,
I'm not sure it does quite what I want it to.  It seems to compare whether
one predictor is more concordant than another within the same survival
function.  I want to see whether one predictor is more concordant than
another over two survival functions hence I fitted two rcorrcens functions.

E.g. if I have a development data set with a variable for age and a
validation data set for age then I want to know if the concordance is the
same over the development and validation data sets.

Thank you,
Laura

On 5 May 2011 16:09, David Winsemius dwinsem...@comcast.net wrote:


 On May 5, 2011, at 8:20 AM, Laura Bonnett wrote:

  Dear All,

 I am trying to calculate a 95% confidence interval for the difference in
 two
 c statistics (or equivalently D statistics).  In Stata I gather that this
 can be done using the lincom command.  Is there anything similar in R?


 Have you looked at rcorrp.cens {Hmisc}?

 snipped


[[alternative HTML version deleted]]



 Please post in plain text.

 --
 David Winsemius, MD
 West Hartford, CT



[[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] perspective plot

2011-05-05 Thread Mauro
Hello,

I`m tryint to plot some variable over x and y coordinate, but can`t figure
out hot to do it ( I could do a simple scatterplot3d, but there I can`t
change the viewing angle). 

My dataset looks something like this (dataframe):

X   Y   Q95
21 2628711 1104437 0.7723994
22 2628721 1104437 0.5961789
23 2628731 1104437 1.2013182
24 2628741 1104437 1.3468632
25 2628751 1104437 1.1035517
26 2628761 1104437 1.0528809

Is there a way to plot Q95 over x and y? Something like persp(x,y,z) would
be nice, but can`t figure out the right input format for this function.


Thanks a lot,

Mauro

--
View this message in context: 
http://r.789695.n4.nabble.com/perspective-plot-tp3498754p3498754.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] cross-correlation table with subscript or superscript to indicate significant differences

2011-05-05 Thread David Winsemius


On May 5, 2011, at 10:48 AM, yoav baranan wrote:



Hi, I wonder whether the following is possible with R, and whether  
anyone has done that and can share his/her code with me. I have a  
correlation matrix, and I want to create a correlation table that I  
can copy to Microsoft Word with a superscript above each  
correlation, indicating significant differences in the same row.  
That is, when correlations in the same row do not share superscript,  
it means that they are significantly different from each other. 		 
thanks,yoav 		 	   		

[[alternative HTML version deleted]]


An example with data and the desired result might help focus the  
discussion.


This shows how to set up an example showing how extract the row  
numbers from a correlation matrix with absolute values above 0.5 but  
less than 1 (to exclude the trivial cases).


 set.seed(123)
 X - matrix(rnorm(100), 10)
 apply(cor(X), 2, function(x) which(abs(x)  0.5  x  1)  )
[[1]]
[1] 2 4 8

[[2]]
[1] 1 3

[[3]]
[1] 2 6 9

[[4]]
[1] 1 7

[[5]]
integer(0)

[[6]]
[1]  3 10

[[7]]
[1] 4

[[8]]
[1] 1

[[9]]
[1] 3

[[10]]
[1] 6

This would extract the rownames if they are letters[1:10]

 lapply( apply(cor(X), 2, function(x) which(abs(x)  0.5  x  1) ),  
function(x) rownames(X)[x])

[[1]]
[1] b d h

[[2]]
[1] a c

[[3]]
[1] b f i

[[4]]
[1] a g

[[5]]
character(0)

[[6]]
[1] c j

[[7]]
[1] d

[[8]]
[1] a

[[9]]
[1] c

[[10]]
[1] f

Exactly how we are supposed to pass this to MS Word does not seem to  
be a proper question for this mailing list.


--

David Winsemius, MD
West Hartford, CT

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


[R] simulate AR(1) process

2011-05-05 Thread Alemtsehai Abate
Dear R users,
May any of you tell me how to simulate data on:
y_t = a+b*y_{t-1} + u_t
where u_t~N(0,sigma^2), b1, and for some constant a.

Many thanks

Tsegaye tseg...@exeter.ac.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.


Re: [R] Compiling a FORTRAN program under Windows 7

2011-05-05 Thread Clint Bowman
You are compiling a subroutine not a program and you compile line 
should read:


gfortran testit.f -c testit.o

You then reference that object code testit.o in your final loading 
stage after compiling other routiens and the main program.


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


USPS:   PO Box 47600, Olympia, WA 98504-7600
Parcels:300 Desmond Drive, Lacey, WA 98503-1274


On Thu, 5 May 2011, Mikael Anderson wrote:


Hi,

I am trying to compile a FORTRAN program to call from R under Windows 7 but
I am having problem in the compiling step. To demonstrate this is the
program testit.f:

--
 subroutine TESTIT(x,n,m)
 dimension x(n)
 do 10 i=1,n
10  x(i)=x(i)**m
 end


When I compile it with gfortran I get the following error:

--
c:\MinGW\programsgfortran testit.f -o testit.o
c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../libmingw32.a(main.o):main.c:(.tex
t+0xd2): undefined reference to `WinMain@16'
collect2: ld returned 1 exit status.


I should add that a program like the following hello.f compiles with no
problem.

--
READ (*, *) YOURNAME
WRITE (*, 200) YOURNAME
200 FORMAT(//,' Hello ',A/)
STOP
END
--

I realize that this is not directly a question about R but I guess there are
some people here who have compiled FORTRAN programs under Windows 7 to call
from R. I appreciate any help to fix the problem.

/Mikael

[[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] simulate AR(1) process

2011-05-05 Thread Phil Spector

?arima.sim

- Phil Spector
 Statistical Computing Facility
 Department of Statistics
 UC Berkeley
 spec...@stat.berkeley.edu


On Thu, 5 May 2011, Alemtsehai Abate wrote:


Dear R users,
May any of you tell me how to simulate data on:
y_t = a+b*y_{t-1} + u_t
where u_t~N(0,sigma^2), b1, and for some constant a.

Many thanks

Tsegaye tseg...@exeter.ac.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] Null

2011-05-05 Thread Thomas Levine
Maybe you were doing something like

fcv - read.csv('fcv.csv')

instead of

fcv - read.csv('fcv.csv')[1]

(I haven't tested this.)

Tom

On Thu, May 5, 2011 at 8:48 AM, pcc polly...@hotmail.com wrote:

 This is probably a very simple question but I am completely stumped!I am
 trying to do shapiro.wilk(x) test on a relatively small dataset(75) and each
 time my variable and keeps coming out as 'NULL', and

  shapiro.test(fcv)
 Error in complete.cases(x) : no input has determined the number of cases

 my text file looks like this:

 case
 1.600972896
 1.534026106
 1.633468456
 1.69019608
 1.686636269
 1.713490543
 1.460897843
 1.604226053
 1.547774705
 1.575187845
 1.50242712
 1.489958479
 1.555094449
 1.56937391
 1.46686762
 1.583198774
 1.59439255
 1.627365857
 1.596597096
 1.598790507
 1.596597096
 1.613841822
 1.607455023
 1.586587305
 1.72427587
 1.668385917
 1.743509765
 1.5774918
 1.709269961
 1.507855872
 1.650307523
 1.670245853
 1.721810615
 1.613841822
 1.586587305
 1.658011397
 1.595496222
 1.662757832
 1.521138084
 1.564666064
 1.515873844
 1.596597096
 1.617000341
 1.621176282
 1.598790507
 1.73479983
 1.498310554
 1.571708832
 1.426511261
 1.698970004
 1.534026106
 1.5774918
 1.682145076
 1.689308859
 1.654176542
 1.526339277
 1.545307116
 1.658964843
 1.638489257
 1.557507202
 1.604226053
 1.627365857
 1.651278014
 1.627365857
 1.559906625
 1.720159303
 1.64738297
 1.62324929
 1.698970004
 1.704150517
 1.57863921
 1.558708571
 1.681241237
 1.539076099
 1.5132176

 Any ideas?

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

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

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


Re: [R] Using error in histograms

2011-05-05 Thread Greg Snow
The logspline package does density estimation in a different way than KDE, but 
it does allow for interval censored data (I know this value is between a and b, 
but not where in that range) using the oldlogspline function.  This may be what 
you are looking for.

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


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
 project.org] On Behalf Of Kristof Ostir
 Sent: Thursday, May 05, 2011 4:16 AM
 To: r-help@r-project.org
 Subject: [R] Using error in histograms
 
 Hello!
 
 I am trying to produce a histogram of measurement data (orientation of
 archaeological structures) that are a subject to measurement error.
 The normal histogram just computes frequencies, but does not take into
 account that a particular value is spread over a range of values (in
 my case the spread is different for reach measurement and is larger
 than the bin size).
 
 The closest approach is kernel density estimation (in the image is a
 comparison of histogram and KDE):
 http://en.wikipedia.org/wiki/Kernel_density_estimation
 http://en.wikipedia.org/wiki/File:Comparison_of_1D_histogram_and_KDE.pn
 g
 However in my case the kernel size is different for each value. I
 wrote a program in IDL that performs the plotting, but am just
 wondering if such a function is available in R. Basically it is a
 problem of summing (and later plotting) several data distributions.
 
 I would appreciate also any hint to a book that might be dealing with
 the problem. I am not an expert in statistics and I might not be using
 use the correct terminology in web searches.
 
 Regards,
 
 Kristof
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] quantmod's addTA plotting functions

2011-05-05 Thread Russ Abbott
Thanks. You're right. I didn't see that.  I read the ?addTA help page, which
(annoyingly) didn't mention that feature, but I didn't read the ?TA page.
(That page was mentioned as a see also, but not as a must see.)

I don't know what it means to wrap these calls in a plot call. I tried to
put the addTA calls into a function and call that function from the higher
level function, but that didn't work either. Would you tell me what it means
to wrap these calls in a plot call.

Thanks

*-- Russ *

P.S. Pardon my irritation, but I continually find that many of the help
files assume one already knows the information one is looking for. If you
don't know it, the help files are not very helpful.  This is a good example.
 In fact, it's two good examples.  I didn't know that I had to look at
another page, and I (still) don't know what it means to wrap plot calls in
another plot call.


On Thu, May 5, 2011 at 3:39 AM, P Ehlers ehl...@ucalgary.ca wrote:

 On 2011-05-05 0:47, Russ Abbott wrote:

 Hi,

 I'm having trouble with quantmod's addTA plotting functions.  They seem to
 work fine when run from the command line. But when run inside a function,
 only the last one run is visible.  Here's an example.


 test.addTA- function(from = 2010-06-01) {
 getSymbols(^GSPC, from = from)
 GSPC.close- GSPC[,GSPC.Close]
 GSPC.EMA.3- EMA(GSPC.close, n=3, ratio=NULL)
 GSPC.EMA.10- EMA(GSPC.close, n=10, ratio=NULL)
 chartSeries(GSPC.close, theme=chartTheme('white'), up.col=black,
 dn.col=black)
 addTA(GSPC.EMA.3,   on = 1, col = #ff)
 addTA(GSPC.EMA.10,  on = 1, col = #ff)
 # browser()
 }


 When I run this, GSPC.close always appears.  But only GSPC.EMA10 appears
 on
 the plot along with it. If I switch the order of the addTA calls,
 only GSPC.EMA3 appears. If I uncomment the call to browser() neither
 appears
 when the browser() interrupt occurs. I can then draw both GSPC.EMA.3 and
 GSPC.EMA10 manually, and let the function terminate. All intended plots
 are
 visible after the function terminates. So it isn't as if one wipes out the
 other. This shows that it's possible to get all three lines on the plot,
 but
 I can't figure out how to do it without manual intervention. Any
 suggestions
 are appreciated.


 Perhaps you didn't see this NOTE on the ?TA help page:

 Calling any of the above methods from within a function
 or script will generally require them to be wrapped in a
 plot call as they rely on the context of the call to
 initiate the actual charting addition.

 Peter Ehlers


 Thanks.

 *-- Russ *

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



[[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] Compiling a FORTRAN program under Windows 7

2011-05-05 Thread Berend Hasselman

Mikael Anderson wrote:
 
 Hi,
 
 I am trying to compile a FORTRAN program to call from R under Windows 7
 but
 I am having problem in the compiling step. To demonstrate this is the
 program testit.f:
 
 --
   subroutine TESTIT(x,n,m)
   dimension x(n)
   do 10 i=1,n
 10  x(i)=x(i)**m
   end
 
 
 

In addition to the previous remarks, you would do yourself a favour by
utilizing the implicit-none option of gfortran. That will force you to
declare every variable (and its type) which will avoid many nasty bugs.
In your case: x is a REAL single precision but with R you will preferably
need double precision.
So I would advise you to use

gfortran -fimplicit-none ..

Berend

--
View this message in context: 
http://r.789695.n4.nabble.com/Compiling-a-FORTRAN-program-under-Windows-7-tp3498663p3498839.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] Null

2011-05-05 Thread Clint Bowman

with(fcv,shapiro.test(case))


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


USPS:   PO Box 47600, Olympia, WA 98504-7600
Parcels:300 Desmond Drive, Lacey, WA 98503-1274


On Thu, 5 May 2011, Thomas Levine wrote:


Maybe you were doing something like

fcv - read.csv('fcv.csv')

instead of

fcv - read.csv('fcv.csv')[1]

(I haven't tested this.)

Tom

On Thu, May 5, 2011 at 8:48 AM, pcc polly...@hotmail.com wrote:


This is probably a very simple question but I am completely stumped!I am
trying to do shapiro.wilk(x) test on a relatively small dataset(75) and each
time my variable and keeps coming out as 'NULL', and


shapiro.test(fcv)

Error in complete.cases(x) : no input has determined the number of cases

my text file looks like this:

case
1.600972896
1.534026106
1.633468456
1.69019608
1.686636269
1.713490543
1.460897843
1.604226053
1.547774705
1.575187845
1.50242712
1.489958479
1.555094449
1.56937391
1.46686762
1.583198774
1.59439255
1.627365857
1.596597096
1.598790507
1.596597096
1.613841822
1.607455023
1.586587305
1.72427587
1.668385917
1.743509765
1.5774918
1.709269961
1.507855872
1.650307523
1.670245853
1.721810615
1.613841822
1.586587305
1.658011397
1.595496222
1.662757832
1.521138084
1.564666064
1.515873844
1.596597096
1.617000341
1.621176282
1.598790507
1.73479983
1.498310554
1.571708832
1.426511261
1.698970004
1.534026106
1.5774918
1.682145076
1.689308859
1.654176542
1.526339277
1.545307116
1.658964843
1.638489257
1.557507202
1.604226053
1.627365857
1.651278014
1.627365857
1.559906625
1.720159303
1.64738297
1.62324929
1.698970004
1.704150517
1.57863921
1.558708571
1.681241237
1.539076099
1.5132176

Any ideas?

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

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


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



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


Re: [R] Insert values to histogram

2011-05-05 Thread Greg Snow
Are you really sure that you want to do that?

Read the discussion starting with this post: 
http://tolstoy.newcastle.edu.au/R/e2/help/07/08/22858.html for reasons why you 
probably don't (yes, the question is about bar plots not histograms, but much 
of it will still apply).  Near the end of the discussion there are examples of 
alternatives and some ways to add that may apply to your question if you still 
feel the need.

Part of the answer depends on how you are creating your histogram in the first 
place, 3 different functions pop to my mind that create histograms (and I am 
sure there are plenty more if I looked), how to add numbers in each case would 
be very different, so any help we offered (beyond generalities mentioned above) 
could be more misleading than helpful without that information.

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


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
 project.org] On Behalf Of matibie
 Sent: Thursday, May 05, 2011 5:50 AM
 To: r-help@r-project.org
 Subject: [R] Insert values to histogram
 
 I'm trying to add the exact value on top of each column of an
 Histogram, i
 have been trying with the text function but it doesn't work.
 The problem is that the program it self decides the exact value to give
 to
 each column, and ther is not like in a bar-plot that I know exactly
 which
 values are been plotting.
 If anyone have any new idea on how to do this
 Thanks
 Matias
 
 --
 View this message in context: http://r.789695.n4.nabble.com/Insert-
 values-to-histogram-tp3498140p3498140.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] quantmod's addTA plotting functions

2011-05-05 Thread Jeff Ryan
There is a struggle in documentation that revolves around being too brief to
be useful and too verbose which then is often ignored.  In general, R
proper is far less verbose than quantmod docs - so if you have trouble
with quantmod...

from ?addTA

Value:

 ‘addTA’ will invisibly return an S4 object of class ‘chobTA’. If
 this function is called interactively, the ‘chobTA’ object will be
 evaluated and added to the current chart.

 ‘newTA’ will return a function object that can either be assigned
 or evaluated.  Evaluating this function will follow the logic of
 any standard addTA-style call, returning invisibly a ‘chobTA’
 object, or adding to the chart.

In addition there is a see also that references ?TA

One can also use the archives to see this problem discussed over and over.
 It isn't for lack of documentation typically - it is for lack of looking.

That said, could the docs be more clear/verbose?  Certainly.  Does that take
time?  Certainly.  Does answering the same question in a public forum take
time? Certainly.  What the latter does though is provide for an excellent
reference for those who misunderstand or don't understand the 'Value' aspect
of the docs (which here explains quite clearly that nothing is printed by
the call itself).

A suitably phrased patch for the docs is one way to contribute in a
productive manner - though it may not always be applied by those you submit
it to (to me or any of the other 3000 package author/maintainers/etc).

HTH
Jeff

On Thu, May 5, 2011 at 11:42 AM, Russ Abbott russ.abb...@gmail.com wrote:

 Thanks. You're right. I didn't see that.  I read the ?addTA help page,
 which (annoyingly) didn't mention that feature, but I didn't read the ?TA
 page. (That page was mentioned as a see also, but not as a must see.)

 I don't know what it means to wrap these calls in a plot call. I tried to
 put the addTA calls into a function and call that function from the higher
 level function, but that didn't work either. Would you tell me what it means
 to wrap these calls in a plot call.

 Thanks

 *-- Russ *

 P.S. Pardon my irritation, but I continually find that many of the help
 files assume one already knows the information one is looking for. If you
 don't know it, the help files are not very helpful.  This is a good example.
  In fact, it's two good examples.  I didn't know that I had to look at
 another page, and I (still) don't know what it means to wrap plot calls in
 another plot call.


 On Thu, May 5, 2011 at 3:39 AM, P Ehlers ehl...@ucalgary.ca wrote:

 On 2011-05-05 0:47, Russ Abbott wrote:

 Hi,

 I'm having trouble with quantmod's addTA plotting functions.  They seem
 to
 work fine when run from the command line. But when run inside a function,
 only the last one run is visible.  Here's an example.


 test.addTA- function(from = 2010-06-01) {
 getSymbols(^GSPC, from = from)
 GSPC.close- GSPC[,GSPC.Close]
 GSPC.EMA.3- EMA(GSPC.close, n=3, ratio=NULL)
 GSPC.EMA.10- EMA(GSPC.close, n=10, ratio=NULL)
 chartSeries(GSPC.close, theme=chartTheme('white'), up.col=black,
 dn.col=black)
 addTA(GSPC.EMA.3,   on = 1, col = #ff)
 addTA(GSPC.EMA.10,  on = 1, col = #ff)
 # browser()
 }


 When I run this, GSPC.close always appears.  But only GSPC.EMA10 appears
 on
 the plot along with it. If I switch the order of the addTA calls,
 only GSPC.EMA3 appears. If I uncomment the call to browser() neither
 appears
 when the browser() interrupt occurs. I can then draw both GSPC.EMA.3 and
 GSPC.EMA10 manually, and let the function terminate. All intended plots
 are
 visible after the function terminates. So it isn't as if one wipes out
 the
 other. This shows that it's possible to get all three lines on the plot,
 but
 I can't figure out how to do it without manual intervention. Any
 suggestions
 are appreciated.


 Perhaps you didn't see this NOTE on the ?TA help page:

 Calling any of the above methods from within a function
 or script will generally require them to be wrapped in a
 plot call as they rely on the context of the call to
 initiate the actual charting addition.

 Peter Ehlers


 Thanks.

 *-- Russ *

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





-- 
Jeffrey Ryan
jeffrey.r...@lemnica.com

www.lemnica.com

[[alternative HTML version deleted]]

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


Re: [R] Boxplot in order

2011-05-05 Thread Dennis Murphy
Hi:

Try this:

karla = data.frame(
Groups = factor(rep(c('CPre','SPre','C7','S7','C14','S14','C21','S21'), 11),
levels =
c('CPre','SPre','C7','S7','C14','S14','C21','S21')),
Time = rep(c(0,7,14,21), 11),
Resp = rnorm(88)
)

boxplot(Resp~Groups, data = karla)

Since you didn't have a variable valor defined, I substituted in
random normal deviates.

HTH,
Dennis

On Thu, May 5, 2011 at 7:41 AM, Silvano silv...@uel.br wrote:
 Hi,

 I need construct box plot graph, but I want keep Groups order

 karla = data.frame(
 Groups = factor(rep(c('CPre','SPre','C7','S7','C14','S14','C21','S21'),
 11)),
 Time = rep(c(0,7,14,21), 11),
 Resp = valor
 )

 boxplot(Resp~Groups, order=T)

 doesn't work.

 How do this?

 --
 Silvano Cesar da Costa
 Departamento de Estatística
 Universidade Estadual de Londrina
 Fone: 3371-4346

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


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


Re: [R] Using functions/loops for repetitive commands

2011-05-05 Thread dereksloan
Thanks David,

I did notice that and I got his code to work using wilcox.test for the
continuous variables.

The problem is that when I tried to alter the code to do chisq.test on my
categorical variables there is something wrong with the syntax and I don't
know what.

Derek

--
View this message in context: 
http://r.789695.n4.nabble.com/Using-functions-loops-for-repetitive-commands-tp3498006p3498896.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] perspective plot

2011-05-05 Thread Greg Snow
The persp function expects z to be a matrix, so you could reshape your data so 
that z is a matrix (the reshape function or package may help).  Or the 
wireframe function in the lattice package expects data more like what you show, 
that may be the easiest solution.

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


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
 project.org] On Behalf Of Mauro
 Sent: Thursday, May 05, 2011 10:09 AM
 To: r-help@r-project.org
 Subject: [R] perspective plot
 
 Hello,
 
 I`m tryint to plot some variable over x and y coordinate, but can`t
 figure
 out hot to do it ( I could do a simple scatterplot3d, but there I can`t
 change the viewing angle).
 
 My dataset looks something like this (dataframe):
 
 X   Y   Q95
 21 2628711 1104437 0.7723994
 22 2628721 1104437 0.5961789
 23 2628731 1104437 1.2013182
 24 2628741 1104437 1.3468632
 25 2628751 1104437 1.1035517
 26 2628761 1104437 1.0528809
 
 Is there a way to plot Q95 over x and y? Something like persp(x,y,z)
 would
 be nice, but can`t figure out the right input format for this function.
 
 
 Thanks a lot,
 
 Mauro
 
 --
 View this message in context:
 http://r.789695.n4.nabble.com/perspective-plot-tp3498754p3498754.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] quantmod's addTA plotting functions

2011-05-05 Thread P Ehlers

Russ,

All you have to do is replace

  addTA(GSPC.EMA.3,   on = 1, col = #ff)

with

  plot(addTA(GSPC.EMA.3,   on = 1, col = #ff))

etc.

I can sympathize with the documentation frustration, but I think
that much of the documentation in R and in many R packages is
actually very good. I get much more frustrated with the attempts
at 'non-technical' explanations I find in other software. It
does take a bit of getting used to always looking at the Value
section and, if in doubt, checking some of the See Alsos, but
it's worth it. I don't know quantmod very well, but even a
cursory look at the pdf file shows that the docs are quite
good.

As Jeff points out, good documentation is not easy. More good
examples are always better, but that's mighty time-consuming.

Peter Ehlers

On 2011-05-05 10:42, Russ Abbott wrote:

Thanks. You're right. I didn't see that.  I read the ?addTA help page,
which (annoyingly) didn't mention that feature, but I didn't read the
?TA page. (That page was mentioned as a see also, but not as a must see.)

I don't know what it means to wrap these calls in a plot call. I tried
to put the addTA calls into a function and call that function from the
higher level function, but that didn't work either. Would you tell me
what it means to wrap these calls in a plot call.

Thanks
/-- Russ /

P.S. Pardon my irritation, but I continually find that many of the help
files assume one already knows the information one is looking for. If
you don't know it, the help files are not very helpful.  This is a good
example.  In fact, it's two good examples.  I didn't know that I had to
look at another page, and I (still) don't know what it means to wrap
plot calls in another plot call.


On Thu, May 5, 2011 at 3:39 AM, P Ehlers ehl...@ucalgary.ca
mailto:ehl...@ucalgary.ca wrote:

On 2011-05-05 0:47, Russ Abbott wrote:

Hi,

I'm having trouble with quantmod's addTA plotting functions.
  They seem to
work fine when run from the command line. But when run inside a
function,
only the last one run is visible.  Here's an example.


test.addTA- function(from = 2010-06-01) {
 getSymbols(^GSPC, from = from)
 GSPC.close- GSPC[,GSPC.Close]
 GSPC.EMA.3- EMA(GSPC.close, n=3, ratio=NULL)
 GSPC.EMA.10- EMA(GSPC.close, n=10, ratio=NULL)
 chartSeries(GSPC.close, theme=chartTheme('white'),
up.col=black,
dn.col=black)
 addTA(GSPC.EMA.3,   on = 1, col = #ff)
 addTA(GSPC.EMA.10,  on = 1, col = #ff)
 # browser()
}


When I run this, GSPC.close always appears.  But only GSPC.EMA10
appears on
the plot along with it. If I switch the order of the addTA calls,
only GSPC.EMA3 appears. If I uncomment the call to browser()
neither appears
when the browser() interrupt occurs. I can then draw both
GSPC.EMA.3 and
GSPC.EMA10 manually, and let the function terminate. All
intended plots are
visible after the function terminates. So it isn't as if one
wipes out the
other. This shows that it's possible to get all three lines on
the plot, but
I can't figure out how to do it without manual intervention. Any
suggestions
are appreciated.


Perhaps you didn't see this NOTE on the ?TA help page:

Calling any of the above methods from within a function
or script will generally require them to be wrapped in a
plot call as they rely on the context of the call to
initiate the actual charting addition.

Peter Ehlers


Thanks.

*-- Russ *

[[alternative HTML version deleted]]

__
R-help@r-project.org mailto:R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] quantmod's addTA plotting functions

2011-05-05 Thread Jeff Ryan
Sorry, I forgot to give you a quick example of 'wrapping in plot'

plot(addTA(...))

The objects returned by most of the charting functions in quantmod results
from the desire for the functions to be syntactically identical whether
called from inside of chartSeries (e.g. TA=addMACD() ) as they are from
outside:

R addMACD()

The code the simplicity of this (and the lack of need for documenting 2
different functions, and learning all the details of 2 different functions
(2x the work)) you need to be a bit clever in how R works.  Describing that
is 1) not simple and 2) ironically, not very well documented in base R.  For
me to write it I just had to get around number 2.

HTH
Jeff

On Thu, May 5, 2011 at 11:55 AM, Jeff Ryan jeff.a.r...@gmail.com wrote:

 There is a struggle in documentation that revolves around being too brief
 to be useful and too verbose which then is often ignored.  In general, R
 proper is far less verbose than quantmod docs - so if you have trouble
 with quantmod...

 from ?addTA

 Value:

  ‘addTA’ will invisibly return an S4 object of class ‘chobTA’. If
  this function is called interactively, the ‘chobTA’ object will be
  evaluated and added to the current chart.

  ‘newTA’ will return a function object that can either be assigned
  or evaluated.  Evaluating this function will follow the logic of
  any standard addTA-style call, returning invisibly a ‘chobTA’
  object, or adding to the chart.

 In addition there is a see also that references ?TA

 One can also use the archives to see this problem discussed over and
 over.  It isn't for lack of documentation typically - it is for lack of
 looking.

 That said, could the docs be more clear/verbose?  Certainly.  Does that
 take time?  Certainly.  Does answering the same question in a public forum
 take time? Certainly.  What the latter does though is provide for an
 excellent reference for those who misunderstand or don't understand the
 'Value' aspect of the docs (which here explains quite clearly that nothing
 is printed by the call itself).

 A suitably phrased patch for the docs is one way to contribute in a
 productive manner - though it may not always be applied by those you submit
 it to (to me or any of the other 3000 package author/maintainers/etc).

 HTH
 Jeff

 On Thu, May 5, 2011 at 11:42 AM, Russ Abbott russ.abb...@gmail.comwrote:

 Thanks. You're right. I didn't see that.  I read the ?addTA help page,
 which (annoyingly) didn't mention that feature, but I didn't read the ?TA
 page. (That page was mentioned as a see also, but not as a must see.)

 I don't know what it means to wrap these calls in a plot call. I tried to
 put the addTA calls into a function and call that function from the higher
 level function, but that didn't work either. Would you tell me what it means
 to wrap these calls in a plot call.

 Thanks

 *-- Russ *

 P.S. Pardon my irritation, but I continually find that many of the help
 files assume one already knows the information one is looking for. If you
 don't know it, the help files are not very helpful.  This is a good example.
  In fact, it's two good examples.  I didn't know that I had to look at
 another page, and I (still) don't know what it means to wrap plot calls in
 another plot call.


 On Thu, May 5, 2011 at 3:39 AM, P Ehlers ehl...@ucalgary.ca wrote:

 On 2011-05-05 0:47, Russ Abbott wrote:

 Hi,

 I'm having trouble with quantmod's addTA plotting functions.  They seem
 to
 work fine when run from the command line. But when run inside a
 function,
 only the last one run is visible.  Here's an example.


 test.addTA- function(from = 2010-06-01) {
 getSymbols(^GSPC, from = from)
 GSPC.close- GSPC[,GSPC.Close]
 GSPC.EMA.3- EMA(GSPC.close, n=3, ratio=NULL)
 GSPC.EMA.10- EMA(GSPC.close, n=10, ratio=NULL)
 chartSeries(GSPC.close, theme=chartTheme('white'), up.col=black,
 dn.col=black)
 addTA(GSPC.EMA.3,   on = 1, col = #ff)
 addTA(GSPC.EMA.10,  on = 1, col = #ff)
 # browser()
 }


 When I run this, GSPC.close always appears.  But only GSPC.EMA10 appears
 on
 the plot along with it. If I switch the order of the addTA calls,
 only GSPC.EMA3 appears. If I uncomment the call to browser() neither
 appears
 when the browser() interrupt occurs. I can then draw both GSPC.EMA.3 and
 GSPC.EMA10 manually, and let the function terminate. All intended plots
 are
 visible after the function terminates. So it isn't as if one wipes out
 the
 other. This shows that it's possible to get all three lines on the plot,
 but
 I can't figure out how to do it without manual intervention. Any
 suggestions
 are appreciated.


 Perhaps you didn't see this NOTE on the ?TA help page:

 Calling any of the above methods from within a function
 or script will generally require them to be wrapped in a
 plot call as they rely on the context of the call to
 initiate the actual charting addition.

 Peter Ehlers


 Thanks.

 *-- Russ *

[[alternative HTML 

Re: [R] Using functions/loops for repetitive commands

2011-05-05 Thread David Winsemius


On May 5, 2011, at 1:08 PM, dereksloan wrote:


Thanks David,

I did notice that and I got his code to work using wilcox.test for the
continuous variables.

The problem is that when I tried to alter the code to do chisq.test  
on my
categorical variables there is something wrong with the syntax and I  
don't

know what.


Right
 ?chisq.test
# No mention of a formula argument seen
 ?chisq.test.formula
No documentation for 'chisq.test.formula' in specified packages and  
libraries:

you could try '??chisq.test.formula'

`chisq.test` doesn't have a formula method, so sending it a formula  
will fail.


Why aren't you sending it the arguments instead of turning them into  
strings?





Derek

--
View this message in context: 
http://r.789695.n4.nabble.com/Using-functions-loops-for-repetitive-commands-tp3498006p3498896.html
Sent from the R help mailing list archive at Nabble.com.

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


David Winsemius, MD
West Hartford, CT

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


Re: [R] Using functions/loops for repetitive commands

2011-05-05 Thread dereksloan
Thanks a lot,

I understand what you say but I'm having problems - maybe with the syntax or
the specific command.

You are right - I have a dataframe to store the data and want to automate
the analysis.

i.e. I want do a chisq.test with to know if alcohol intake (Y/N) differs
between sexes, then if smoking (Y/N) differs between sexes, then if alcohol
intake or smoking differ by hiv status.

The command within my data frame for each individual comparison is e.g.

chisq.test(alcohol,sex)... then repeat it for all combination of variables.

but using lapply I'm still unsure how to design the loop.

I'll keep trying - let me know if you have more ideas.

Derek


--
View this message in context: 
http://r.789695.n4.nabble.com/Using-functions-loops-for-repetitive-commands-tp3498006p3499001.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] distance matrix

2011-05-05 Thread antu
I don't know whether I understood your question, but 1.1, 1.2 , 1.3 all are
subsample of 1 , so, rather than comparing 1000 subsample, comparison of 20
pop level makes more sense in my case. 

thanks for query

-


Ananta Acharya
Graduate Student
--
View this message in context: 
http://r.789695.n4.nabble.com/distance-matrix-tp3498033p3498890.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] cross-correlation table with subscript or superscript to indicate significant differences

2011-05-05 Thread David Winsemius


On May 5, 2011, at 12:40 PM, yoav baranan wrote:


Here is an example for my earlier question.

Say you have a 3x3 correlation matrix:
corrs - matrix(c(0.25,0.32,0.66,0.14,0.24,0.34,0.44,0.34,0.11),  
nrow=3, ncol=3, dimnames = list(c('varA','varB', 'varC'),  
c('varA','varB', 'varC')))

And another matrix for the sample size of each correlation:
sizes - matrix(c(44,68,313,142,144,207,201,100,99), nrow=3, ncol=3,  
dimnames = list(c('varA','varB', 'varC'), c('varA','varB', 'varC')))


corrs looks like this:
 varA varB varC
varA 0.05 0.14 0.44
varB 0.32 0.24 0.34
varC 0.66 0.57 0.50

sizes:
 varA varB varC
varA   44  142  201
varB   68  144  100
varC  313  207   99

i.e., the correlation between variables A and C was 0.66 with sample  
size of 313. (I got these tables from rcorr).


Why not offer the result of dput() on the result from rcorrs cone on 3  
variables. Then we should have the necessary building blocks for your  
original request. This way we do not have the matrix of p-values.


And as the Posting Guide clearly says ...Please post in plain text. In  
your case it is particularly annoying because I do not get the  
filtered version but rather you html version and the text is almost  
unreadable at a font size of 10 in whatever font it is specifying!






What I want to do is to compare the correlations in each row  
(probably using r.test), and then create a correlation table with  
subscripts or superscripts indicating the significance  
group (again: correlations with different superscripts, in the  
same row, are significantly different from each other).

Something like this:
   varA varB varC
varA 0.05b 0.14b 0.44a
varB 0.32a 0.24a 0.34a
varC 0.66a 0.57ab 0.50b


At the moment we have no way of determining what values should be post- 
pended with which letters.





Of course, I don't have a 3x3 table. I have about 20 tables of at  
least 7x7 each, so this is why I'm looking for methods to automate  
the process.


Thanks,
Yoav

 CC: r-help@r-project.org
 From: dwinsem...@comcast.net
 To: ybara...@hotmail.com
 Subject: Re: [R] cross-correlation table with subscript or  
superscript to indicate significant differences

 Date: Thu, 5 May 2011 12:17:25 -0400


 On May 5, 2011, at 10:48 AM, yoav baranan wrote:

 
  Hi, I wonder whether the following is possible with R, and whether
  anyone has done that and can share his/her code with me. I have a
  correlation matrix, and I want to create a correlation table  
that I

  can copy to Microsoft Word with a superscript above each
  correlation, indicating significant differences in the same row.
  That is, when correlations in the same row do not share  
superscript,

  it means that they are significantly different from each other.
  thanks,yoav
  [[alternative HTML version deleted]]

 An example with data and the desired result might help focus the
 discussion.

 This shows how to set up an example showing how extract the row
 numbers from a correlation matrix with absolute values above 0.5 but
 less than 1 (to exclude the trivial cases).


snipped




David Winsemius, MD
West Hartford, CT

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


[R] Using $ accessor in GAM formula

2011-05-05 Thread Gene Leynes
This is not mission critical, but it's bothering me.  I'm getting
inconsistent results when I use the $ accessor in the gam formula

*In window #1:*
 library(mgcv)
 dat=data.frame(x=1:100,y=sin(1:100/50)+rnorm(100,0,.05))
 str(dat)
 gam(dat$y~s(dat$x))
Error in eval(expr, envir, enclos) : object 'x' not found


*In window #2:*
 gm = gam(dat$cf~s(dat$s))
 gm

Family: gaussian
Link function: identity

Formula:
dat$cf ~ s(dat$s)

Estimated degrees of freedom:
8.7757  total = 9.77568980091

GCV score: 302.551417213




Has anyone else seen the same thing?

In both cases I'm using Windows 7 and R 2.13.0

[[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] cross-correlation table with subscript or superscript to indicate significant differences

2011-05-05 Thread yoav baranan





Here is an example for my earlier question. Say you have a 3x3 correlation 
matrix:corrs - matrix(c(0.25,0.32,0.66,0.14,0.24,0.34,0.44,0.34,0.11), nrow=3, 
ncol=3, dimnames = list(c('varA','varB', 'varC'), c('varA','varB', 'varC')))And 
another matrix for the sample size of each correlation:sizes - 
matrix(c(44,68,313,142,144,207,201,100,99), nrow=3, ncol=3, dimnames = 
list(c('varA','varB', 'varC'), c('varA','varB', 'varC')))corrs looks like this: 
 varA varB varCvarA 0.05 0.14 0.44varB 0.32 0.24 0.34varC 0.66 0.57 
0.50sizes: varA varB varCvarA   44  142  201varB   68  144  100varC  313  
207   99i.e., the correlation between variables A and C was 0.66 with sample 
size of 313. (I got these tables from rcorr).What I want to do is to compare 
the correlations in each row (probably using r.test), and then create a 
correlation table with subscripts or superscripts indicating the significance 
group (again: correlations with different superscripts, in the same row, are 
signif!
 icantly different from each other). Something like this:   varA varB 
varCvarA 0.05b 0.14b 0.44avarB 0.32a 0.24a 0.34avarC 0.66a 0.57ab 0.50bOf 
course, I don't have a 3x3 table. I have about 20 tables of at least 7x7 each, 
so this is why I'm looking for methods to automate the process. Thanks,Yoav
 CC: r-help@r-project.org
 From: dwinsem...@comcast.net
 To: ybara...@hotmail.com
 Subject: Re: [R] cross-correlation table with subscript or superscript to 
 indicate significant differences
 Date: Thu, 5 May 2011 12:17:25 -0400
 
 
 On May 5, 2011, at 10:48 AM, yoav baranan wrote:
 
 
  Hi, I wonder whether the following is possible with R, and whether  
  anyone has done that and can share his/her code with me. I have a  
  correlation matrix, and I want to create a correlation table that I  
  can copy to Microsoft Word with a superscript above each  
  correlation, indicating significant differences in the same row.  
  That is, when correlations in the same row do not share superscript,  
  it means that they are significantly different from each other. 
   
  thanks,yoav 
  [[alternative HTML version deleted]]
 
 An example with data and the desired result might help focus the  
 discussion.
 
 This shows how to set up an example showing how extract the row  
 numbers from a correlation matrix with absolute values above 0.5 but  
 less than 1 (to exclude the trivial cases).
 
   set.seed(123)
   X - matrix(rnorm(100), 10)
   apply(cor(X), 2, function(x) which(abs(x)  0.5  x  1)  )
 [[1]]
 [1] 2 4 8
 
 [[2]]
 [1] 1 3
 
 [[3]]
 [1] 2 6 9
 
 [[4]]
 [1] 1 7
 
 [[5]]
 integer(0)
 
 [[6]]
 [1]  3 10
 
 [[7]]
 [1] 4
 
 [[8]]
 [1] 1
 
 [[9]]
 [1] 3
 
 [[10]]
 [1] 6
 
 This would extract the rownames if they are letters[1:10]
 
   lapply( apply(cor(X), 2, function(x) which(abs(x)  0.5  x  1) ),  
 function(x) rownames(X)[x])
 [[1]]
 [1] b d h
 
 [[2]]
 [1] a c
 
 [[3]]
 [1] b f i
 
 [[4]]
 [1] a g
 
 [[5]]
 character(0)
 
 [[6]]
 [1] c j
 
 [[7]]
 [1] d
 
 [[8]]
 [1] a
 
 [[9]]
 [1] c
 
 [[10]]
 [1] f
 
 Exactly how we are supposed to pass this to MS Word does not seem to  
 be a proper question for this mailing list.
 
 -- 
 
 David Winsemius, MD
 West Hartford, CT
 

  
[[alternative HTML version deleted]]

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


Re: [R] Using functions/loops for repetitive commands

2011-05-05 Thread David Winsemius


On May 5, 2011, at 1:45 PM, dereksloan wrote:


Thanks a lot,

I understand what you say but I'm having problems - maybe with the  
syntax or

the specific command.

You are right - I have a dataframe to store the data and want to  
automate

the analysis.

i.e. I want do a chisq.test with to know if alcohol intake (Y/N)  
differs
between sexes, then if smoking (Y/N) differs between sexes, then if  
alcohol

intake or smoking differ by hiv status.

The command within my data frame for each individual comparison is  
e.g.


chisq.test(alcohol,sex)... then repeat it for all combination of  
variables.


I don't generally answer questions that support shotgun approaches to  
manufacturing p-values for fear of encouraging unprincipled data- 
ming ... unless it is clear that the questioner understands what he  
are doing from a statistical point of view. So my apologies. I  
probably shouldn't have even posted in this case. I misunderstood the  
question and thought it was just a quick syntactic fix. I now  
understand it to be more involved and really demands more care and  
respect than I was giving it.




but using lapply I'm still unsure how to design the loop.

I'll keep trying - let me know if you have more ideas.

Derek


--

David Winsemius, MD
West Hartford, CT

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


Re: [R] Using $ accessor in GAM formula

2011-05-05 Thread David Winsemius


On May 5, 2011, at 1:08 PM, Gene Leynes wrote:


This is not mission critical, but it's bothering me.  I'm getting
inconsistent results when I use the $ accessor in the gam formula

*In window #1:*

library(mgcv)
dat=data.frame(x=1:100,y=sin(1:100/50)+rnorm(100,0,.05))
str(dat)
gam(dat$y~s(dat$x))

Error in eval(expr, envir, enclos) : object 'x' not found


I get the same error, but using the standard R approach to passing  
data and formulae to regression functions I have not difficulty:


 gam(y~s(x), data=dat)

Family: gaussian
Link function: identity

Formula:
y ~ s(x)

Estimated degrees of freedom:
4.1552  total = 5.155229

GCV score: 0.002242771





*In window #2:*

gm = gam(dat$cf~s(dat$s))
gm


Family: gaussian
Link function: identity

Formula:
dat$cf ~ s(dat$s)

Estimated degrees of freedom:
8.7757  total = 9.77568980091

GCV score: 302.551417213




Has anyone else seen the same thing?

In both cases I'm using Windows 7 and R 2.13.0

[[alternative HTML version deleted]]

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


David Winsemius, MD
West Hartford, CT

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


[R] R CMD check warning

2011-05-05 Thread swaraj basu
Dear All,
 I am trying to build a package for a set of functions.  I am
able to build the package and its working fine. When I check it with
 R CMD check

 I get a following warning :  no visible global function
definition for ‘biocLite’

  I have used biocLite to load a user defined library from
within a function if that library is not pre-installed

 if(is.element(annotpkg, installed.packages()[,1]) == FALSE){
   source(http://www.bioconductor.org/biocLite.R;)
   biocLite(annotpkg)
   library(annotpkg,character.only=TRUE)
 }

Should I ignore this error or there is a workaround for the
warning. My package is working fine though still I guess the warning has to
have significance. Please help in clarifying this
warning.

[[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] ANOVA

2011-05-05 Thread Asan Ramzan
Hello R-Help

How can i exctact and store the within group mean squared difference from an 
anova summary table into a varible.
[[alternative HTML version deleted]]

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


  1   2   >