[R] Interpreting Logistic Regression

2008-08-20 Thread Madhavi Bhave

Hi !

This is Madhavi from Mumbai, India. Incidently this is my first post.

I am working on Credit Scoring Model and using R, I have run the logistic 
regression. I have received following Output.

I have two questions

(a) What is the significance of "family = binomial(link = logit)". Why do I 
have to mention Binomial? Is it because my dependent variable assumes only two 
values 0 and 1? Can I write name of some other Statistical distribution (say 
Poisson or Negative Binomial) in place of Binomial? How will it affect my 
results?

(b) How do I interpret the "R" result as given below? I know all the variables 
are significant. How do I get Log Likelihood ratio, Odds ratio etc.?

Please can anyone help me out.

With warm regards

Madhavi



R OUTPUT


Call:
glm(formula = Y ~ Age1 + Age2 + Sex + Education + Profession + SavingsAccount + 
    CurrentAccount, family = binomial(link = logit), data = ons)

Deviance Residuals: 
     Min        1Q    Median        3Q       Max  
-3.21142  -0.42556  -0.15911  -0.02954   3.02465  

Coefficients:
                  Estimate Std. Error z value Pr(>|z|)    
(Intercept)       2.627725   0.110752  23.726  < 2e-16 ***
Age1              0.692180   0.070410   9.831  < 2e-16 ***
Age2             -2.817883   0.080801 -34.874  < 2e-16 ***
Sex              -0.486132   0.049766  -9.768  < 2e-16 ***
Education        -0.682142   0..046507 -14.667  < 2e-16 ***
Profession       -0.690937   0.069032 -10.009  < 2e-16 ***
SavingsAccount   -1.891455   0.074906 -25.251  < 2e-16 ***
CurrentAccount   -1.367460   0.079604 -17.178  < 2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ 
’ 1 

(Dispersion parameter for binomial family taken to be 1)

    Null deviance: 26932  on 24999  degrees of freedom
Residual deviance: 14615  on 24983  degrees of freedom
  (2 observations deleted due to missingness)
AIC: 14649

Number of Fisher Scoring iterations: 6




  Unlimited freedom, unlimited storage. Get it now, on 
http://help.yahoo.com/l/in/yahoo/mail/yahoomail/tools/tools-08.html/
[[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 Regarding 'integrate'

2008-08-20 Thread A
I have an R function defined as:

f<-function(x){
  return(dchisq(x,9,77)*((13.5/x)^5)*exp(-13.5/x))
}

Numerically integrating this function, I observed a couple of things:

A) Integrating the function f over the entire positive real line gives an
error:
> integrate(f,0,Inf)
Error in integrate(f, 0, Inf) : the integral is probably divergent

B)  Increasing the interval of integration actually decreases the value of
the integral:
> integrate(f,0,10^5)
9.813968e-06 with absolute error < 1.9e-05
> integrate(f,0,10^6)
4.62233e-319 with absolute error < 4.6e-319


Since the function f is uniformly positive, B) can not occur. Also, the
theory tells me that the infinite integral actually exists and is finite, so
A) can not occur. That means there are certain problems with the usage of
function 'integrate' which I do not understand. The help document tells me
that 'integrate' uses quadrature approximation to evaluate integrals
numerically. Since I do not come from the numerical methods community, I
would not know the pros and cons of various methods of quadrature
approximation. One naive way that I thought of evaluating the above integral
was by first locating the maximum of the function (may be by using
'optimize' in R) and then applying the Simpson's rule to an interval around
the maximum. However, I am sure that the people behind the R project and
other users have much better ideas, and I am sure the 'correct' method has
already been implemented in R. Therefore, I would appreciate if someone can
help me find it.


Thanks

[[alternative HTML version deleted]]

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


[R] Windows Vista, Rterm & LeftAlt + Tab issue

2008-08-20 Thread Henrik Bengtsson
Hi,

my Rterm does not longer take key presses after I have pressed Left
Alt+Tab in order to switch away from an active Rterm window.  I have
found a way to get Rterm to "respond" again.  I basically have to kill
the process.

This occurs on a fresh Windows Vista Business 32-bit installation
(with all recent MS updated installed; US locales), and with the
following R installations:

R version 2.7.1 Patched (2008-08-12 r46318)
R version 2.8.0 Under development (unstable) (2008-08-11 r46316)
R version 2.8.0 Under development (unstable) (2008-08-19 r46388)

More troubleshooting:
o It does not occur if I switch application by other means, e.g. using
the mouse, Win+Tab, and not even Right Alt+Tab.  It only occurs with
Left Alt+Tab.
o If I set a repeat{print(runif(1)} loop, press LAlt+Tab and goes
back, the loop is still running and I can stop it with Ctrl+C, but
after that I cannot type anything.  It does not work to paste from the
clipboard either.  I have tried to change the Properties of the
Windows Command Console, but no success.
o I have tried to deactived (unchecked "Enable Desktop Composition")
the new style Vista:s application switcher.
o Rterm --vanilla, of course. No difference.
o Same problem with %R_HOME%/bin/R.exe.
o Rgui.exe works fine.

Has anyone else observed this, or knows what goes on?

/Henrik (Windows Vista beginner)

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


Re: [R] vector operation using regexpr?

2008-08-20 Thread markleeds
Hi  John: I didn't realize that that was your problem. You can make it 
work for any number of rows by putting it in lapply as below.
I'm sorry for the misunderstanding. I'll send to the list also since I 
guess my last solution was kind of bad now that I understand what you 
want.


DF <- 
data.frame(col1=c("L","T"),col2=c("MAIL","KITE"),col3=c("PLOY","SIX"))

print(DF)

newcol <- lapply(1:nrow(DF), function(.row) {
  result <- NULL
  if ( regexpr(DF[.row,1],DF[.row,2]) != -1 ) result <- 
substr(DF[.row,3],regexpr(DF[.row,1],DF[.row,2]),regexpr(DF[.row,1],DF[.row,2]))

  result
})

print(newcol)

# BELOW IS FOR IF YOU ONLY WANT TO KEEP THE ONES THAT WERE FOUND
# AND NOT THE NULLS
newcol <- newcol[!sapply(newcol,is.null)]
print(newcol)





On Thu, Aug 21, 2008 at 12:25 AM, John Christie wrote:

The problem with the grep family of commands is that they either test 
a string against a list of strings or test a list of strings against a 
string.  But they cannot do both simultaneously.  Your example only 
works if there is only one row.


On Aug 21, 2008, at 12:30 AM, [EMAIL PROTECTED] wrote:

John: Below takes care of when L is not there but it's too ugly so 
I'm not even going to send this to the list. There should be a 
better way of doing it but I'm still learning ( I guess one can 
consider me a senior newbie !!! ) also so I don't know it. Good luck.


DF <- data.frame(col1="Y",col2="MAIL",col3="PLOY")
result <- NULL
if ( regexpr(DF$col1,DF$col2) != -1 ) result <- substr(DF 
$col3,regexpr(DF$col1,DF$col2),regexpr(DF$col1,DF$col2))

print(result)



On Wed, Aug 20, 2008 at 11:21 PM, [EMAIL PROTECTED] wrote:

Hi: I think you want regexpr so below does what you want but it 
doesn't handle the case when L isn't in the second column. I'm 
still trying to figure that out but don't count on it. Hopefully 
someone else will reply with that piece.


DF <- data.frame(col1="L",col2="MAIL",col3="PLOY")
print(DF)
index <- regexpr(DF$col1,DF$col2)
result <- substr(DF$col3,index,index)



On Wed, Aug 20, 2008 at  3:26 PM, John Christie wrote:


Hi,

Here's my problem... I have a data frame with three columns 
containing strings.  The first columns is a simple character. I 
want to get the index of that character in the second column and 
use it to extract the item from the third column.  I can do this 
using a scalar method.  But I'm not finding a vector method.  An 
example is below.


col1  col2  col3
'L' 'MAIL '   'PLOY'

What I want to do with the above is find the index of col1 in col2 
(4) and then use it to extract the character from col3 ('Y').  I 
could do the last part if I could get the index in a vector 
fashion.


So, the shorter question is, how do I get the index of the letter 
in col1 as it is found in col2?


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

2008-08-20 Thread Charles C. Berry

On Wed, 20 Aug 2008, John Christie wrote:


Hi,

Here's my problem... I have a data frame with three columns containing 
strings.  The first columns is a simple character. I want to get the index of 
that character in the second column and use it to extract the item from the 
third column.  I can do this using a scalar method.  But I'm not finding a 
vector method.  An example is below.


col1  col2  col3
'L' 'MAIL '   'PLOY'

What I want to do with the above is find the index of col1 in col2 (4) and 
then use it to extract the character from col3 ('Y').  I could do the last 
part if I could get the index in a vector fashion.


So, the shorter question is, how do I get the index of the letter in col1 as 
it is found in col2?



Let me count the ways... On second thought, let someone else count the 
ways. But here is one


## suppose 'df' is your data.frame
a.list <- lapply( df, function(x) strsplit(as.character(x), "") )
with(a.list, mapply( function(x,y,z) z[x==y], col1, col2, col3 ) )


This will return all matches in each row. You can use 'match(x,y,0)' in 
place of 'x==y' to get just the first one.



And if you KNOW a match in each row exists and is unique, this will work:

with(a.list, do.call(rbind,col3)[ do.call(rbind,col2) == col1 ] )

but I would not trust it.

HTH,

Chuck



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



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

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


Re: [R] Reading in a value of .Random.seed in .Rprofile

2008-08-20 Thread Rolf Turner


On 21/08/2008, at 3:24 PM, Charles C. Berry wrote:


On Thu, 21 Aug 2008, Rolf Turner wrote:





But why does this happen on *my* system, and not on Chuck's???


Because I goofed by rerunning ALL the lines in .Rprofile rather  
than just the last two.

When I run just the last two, I get the behavior you describe.


Well, that's a relief.  It's nice to know that the paranoids aren't
really after me! :-)


Sorry for the misdirection.


'Sa'right.  I've committed more egregious sins myself.

	BTW, the workaround that I've found is to run R with the --no- 
restore-data flag
	and then explicitly load .RData in my .Rprofile *before* I do the  
reading in of

.Random.seed.

	Of course if I were to run R without the --no-restore-data flag,  
then .RData
	would get loaded twice; once from explicit load in .Rprofile, and  
once from

what the ``system'' does.  But that only wastes a few electrons.

cheers,

Rolf

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

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


Re: [R] Advice requested: Best method of coding "time since" repeating event

2008-08-20 Thread Gabor Grothendieck
Without some data we can't tell precisely the setup but here it is
using Date class
and you can adapt it to your specific situation.  We first
define functions to get the prior wed (or the same day if its wed) and the last
day of the prior month.  Then we define the test data e of event dates and
do the calculation.

library(zoo) # as.yearmon, as.Date.numeric

prev.wed <- function(x) 7 * floor(as.numeric(x - 3 + 4)/7) + as.Date(3 - 4)

prior.month.end <- function(x) as.Date(as.yearmon(x)) - 1

# test data
e <- Sys.Date() + seq(0, length = 3, by = 100)

as.numeric(e - prev.wed(prior.month.end(e))) * 24 * 60


On Wed, Aug 20, 2008 at 10:26 PM, M-J S Milloy <[EMAIL PROTECTED]> wrote:
>
> Hello,
>
> I have a dataset containing approx 1000 events spanning four years (2004.03 
> to 2008.07). For each event, I'd like to determine the time (in minutes) 
> since the most recent final Wednesday of the month. I've found no obvious 
> solution on the list or online; I think I'll try to use functions in the 
> chron package.
>
> Anyone have any other advice?
>
> Thanks.
>
>
> M-J
>
>
> School of Population and Public Health,
> University of British Columbia
> Vancouver, Canada
>
> Centre for Excellence in HIV/AIDS,
> St. Paul's Hospital
> Vancouver, Canada
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Reading in a value of .Random.seed in .Rprofile

2008-08-20 Thread Charles C. Berry

On Thu, 21 Aug 2008, Rolf Turner wrote:



On 21/08/2008, at 10:21 AM, Charles C. Berry wrote:


On Thu, 21 Aug 2008, Rolf Turner wrote:

> 
> 
> For reasons that are best known to myself [ ;-) ] I have a value of 
> .Random.seed

> saved (via dput()) in a file ``.Random.seed.save''.
> 
> In my .Rprofile I have the lines:
> 
> .Random.seed <- dget(".Random.seed.save")

> Junk <- dget(".Random.seed.save")
> print(all.equal(.Random.seed,dget(".Random.seed.save")))
> print(all.equal(Junk,dget(".Random.seed.save")))
> 
> The two calls to all.equal() both return TRUE.
> 
> However when I repeat the calls from the command line after the

> R session has started, I get TRUE from the second (``Junk'') call
> but
> 
> [1] "Mean relative difference: 0.1"
> 
> from the first.


Not on my computer.


 H.  Why do these always happen to ***me*** and only to me?


I get TRUE twice whether at start up, source()ing .Rprofile, or C-c C-n'ing 
the lines from emacs ESS.


I have to type

 load(".RData")

_after_ startup to get behavior like you describe.


Perhaps, you have something later in your .Rprofile that specifically 
load()'s your old .RData?


 No I haven't.  And that couldn't be the case, since ``Junk'' is
 there
 (it wasn't there in the saved image).

 So it would seem that what is happening is that the saved .RData is
 being loaded or restored
 ***after*** the commands to read in .Random.seed (and Junk) are
 issued.  The .Random.seed
 in the saved image then overwrites the .Random.seed that was just
 read in.

But why does this happen on *my* system, and not on Chuck's???



Because I goofed by rerunning ALL the lines in .Rprofile rather than 
just the last two. When I run just the last two, I get the behavior you 
describe.


Sorry for the misdirection.

Chuck


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

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


Re: [R] vector operation using regexpr?

2008-08-20 Thread markleeds
Hi: I think you want regexpr so below does what you want but it doesn't 
handle the case when L isn't in the second column. I'm still trying to 
figure that out but don't count on it. Hopefully someone else will reply 
with that piece.


DF <- data.frame(col1="L",col2="MAIL",col3="PLOY")
print(DF)
index <- regexpr(DF$col1,DF$col2)
result <- substr(DF$col3,index,index)



On Wed, Aug 20, 2008 at  3:26 PM, John Christie wrote:


Hi,

Here's my problem... I have a data frame with three columns containing 
strings.  The first columns is a simple character. I want to get the 
index of that character in the second column and use it to extract the 
item from the third column.  I can do this using a scalar method.  But 
I'm not finding a vector method.  An example is below.


col1  col2  col3
'L' 'MAIL '   'PLOY'

What I want to do with the above is find the index of col1 in col2 (4) 
and then use it to extract the character from col3 ('Y').  I could do 
the last part if I could get the index in a vector fashion.


So, the shorter question is, how do I get the index of the letter in 
col1 as it is found in col2?


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

2008-08-20 Thread Marina Laborde
Dear all,
 
I'm using a binomial distribution with a logit link function to fit a GAM 
model. I have 2 questions about it.
First i am not sure if i've chosen the most adequate distribution. I don't have 
presence/absence data (0/1) but I do have a rate which values vary between 0 
and 1. This means the response variable is continuous even if within a limited 
interval. Should i use binomial?
Secondly, in the numerical output i get negative values of UBRE score. I would 
like to know if one should consider the lowest absolute value or the lowest 
real value to select the best model.
 
Thank you in advance for your help.
Marina
_

s. It's easy!

aspx&mkt=en-us
[[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] vector operation using regexpr?

2008-08-20 Thread John Christie

Hi,

Here's my problem... I have a data frame with three columns containing  
strings.  The first columns is a simple character. I want to get the  
index of that character in the second column and use it to extract the  
item from the third column.  I can do this using a scalar method.  But  
I'm not finding a vector method.  An example is below.


col1  col2  col3
'L' 'MAIL '   'PLOY'

What I want to do with the above is find the index of col1 in col2 (4)  
and then use it to extract the character from col3 ('Y').  I could do  
the last part if I could get the index in a vector fashion.


So, the shorter question is, how do I get the index of the letter in  
col1 as it is found in col2?


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Advice requested: Best method of coding "time since" repeating event

2008-08-20 Thread M-J S Milloy

Hello,

I have a dataset containing approx 1000 events spanning four years (2004.03 to 
2008.07). For each event, I'd like to determine the time (in minutes) since the 
most recent final Wednesday of the month. I've found no obvious solution on the 
list or online; I think I'll try to use functions in the chron package. 

Anyone have any other advice?

Thanks.


M-J


School of Population and Public Health,
University of British Columbia
Vancouver, Canada

Centre for Excellence in HIV/AIDS,
St. Paul's Hospital
Vancouver, Canada

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

2008-08-20 Thread Daren Tan

Small progress, I am relying on levene test to check for equality of variances. 
Is my understanding correct, the larger the p-value, the more likely the 
variances are the same ?

> trt
 [1] 1 1 1 1 1 2 2 2 2 2 3 3 3 3 3 4 4 4 4 4
Levels: 1 2 3 4
> levene.test(rep(rnorm(5), 4), trt, option="median")

Modified Robust Brown-Forsythe Levene-type test based on the absolute
deviations from the median

data:  rep(rnorm(5), 4)
Test Statistic = 0, p-value = 1



> From: [EMAIL PROTECTED]
> To: [EMAIL PROTECTED]
> Subject: How to solve this problem ?
> Date: Wed, 20 Aug 2008 13:33:23 +
>
>
> I have disabled html text editing mode, thanks to Prof. Ripley for the kind 
> reminder.
>
> Given three geological devices that takes 5 readings at 4 environmental 
> conditions (A to D). What will be the proper approach to select the most 
> reliable device ?
>
> m1 <- c(73,52,49,53,83,43,58,94,53,62,75,66,41,72,70,75,57,59,85,84)
> m2 <- c(31,38,30,35,36,26,27,38,22,31,24,35,36,31,38,33,32,28,33,30)
> m3 <- c(65,57,36,40,36,30,40,34,37,40,33,33,37,29,37,37,30,33,40,35)
>
> names(m1) <- rep(LETTERS[1:4], each=5)
> names(m2) <- rep(LETTERS[1:4], each=5)
> names(m3) <- rep(LETTERS[1:4], each=5)
>
> Before writing this email, I have tried to compare the sd for each device at 
> each condition, but ran into obstacle on how to formulate the null 
> hypothesis. Alternative solution tried was ANOVA, I am unsure whether it can 
> help, as it compares the differences in means of each group.
>
> Thanks
>
> _
> Easily edit your photos like a pro with Photo Gallery.
> http://get.live.com/photogallery/overview

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


Re: [R] data.frame() creates list?

2008-08-20 Thread Bill.Venables
Data frames *are* lists.  They just have a guaranteed structure and a
different class, but they may be used interchangably with lists nearly
everywhere.

Try

class(ByEBNum)

for a more relevant check of what kind of object you have.



Bill Venables
http://www.cmis.csiro.au/bill.venables/ 


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Farley, Robert
Sent: Thursday, 21 August 2008 10:34 AM
To: r-help@r-project.org
Subject: [R] data.frame() creates list?

I obviously don't know what I'm doing.  I want to create "ByEBNum" as a
data frame, but it comes out as a list.  How do I make it a data frame?

 

 

> EBNumStn <- c(673.65, 800, 1000, 1000,  800,  700,  600, 500, 400,
200,  50, 50 )

> ByEBNum <- data.frame(c(1:12),EBNumStn)

> typeof(EBNumStn)

[1] "double"

> typeof(c(1:12))

[1] "integer"

> typeof(ByEBNum)

[1] "list"

> ByEBNum

   c.1.12. EBNumStn

11   673.65

22   800.00

33  1000.00

44  1000.00

55   800.00

66   700.00

77   600.00

88   500.00

99   400.00

10  10   200.00

11  1150.00

12  1250.00

> 

 

>sessionInfo() 

R version 2.7.1 (2008-06-23) 

i386-pc-mingw32 

 

locale:

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

 

attached base packages:

[1] graphics  grDevices utils datasets  stats methods   base


 

other attached packages:

[1] survey_3.8 fortunes_1.3-5 moonsun_0.1prettyR_1.3-2
foreign_0.8-28

> 

 

 

 

 

 

Robert Farley

Metro

1 Gateway Plaza

Mail Stop 99-23-7

Los Angeles, CA 90012-2952

Voice: (213)922-2532

Fax:(213)922-2868

www.Metro.net 

 

 


[[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] Reading in a value of .Random.seed in .Rprofile

2008-08-20 Thread Ray Brownrigg
Hi Rolf:

I think this is a case of RTFM.  ?.Rprofile tells you that the profile is 
executed before 
the workspace is restored.

Initially I thought this might be similar to bug PR#12567 that I filed this 
week, but now 
I think not necessarily.

Cheers,
Ray

On Thu, 21 Aug 2008, Rolf Turner wrote:
> For reasons that are best known to myself [ ;-) ] I have a value
> of .Random.seed
> saved (via dput()) in a file ``.Random.seed.save''.
>
> In my .Rprofile I have the lines:
>
> .Random.seed <- dget(".Random.seed.save")
> Junk <- dget(".Random.seed.save")
> print(all.equal(.Random.seed,dget(".Random.seed.save")))
> print(all.equal(Junk,dget(".Random.seed.save")))
>
> The two calls to all.equal() both return TRUE.
>
> However when I repeat the calls from the command line after the
> R session has started, I get TRUE from the second (``Junk'') call
> but
>
> [1] "Mean relative difference: 0.1"
>
> from the first.
>
> The value of .Random.seed appears to be that which was there when I quit
> the previous R session and not the one that I tried to read in from
> the file.
>
> If I *remove* .Random.seed before quitting (and save the workspace,
> so that
> there is no .Random.seed in .RData then I get TRUE from both calls to
> all.equal() made from the command line.  I.e. the value of .Random.seed
> ***is*** the one read in from the file.
>
> Can anyone:
>
>   (a) Explain what's going on?
>
>   (b) Suggest how I might arrange that the value of .Random.seed be
>   made equal to that read in from the file?
>
> ***PLEASE*** don't tell me to use set.seed() instead, or something
> like that.
> I ***know*** about set.seed() --- I wasn't born yesterday, y'know!
> Please just
> accept that I want to do what I want to do, and (if you can) tell me
> how.
>
> Ta.
>
>   cheers,
>
>   Rolf Turner
>
>
> ##
> Attention:\ This e-mail message is privileged and confid...{{dropped:9}}
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html and provide commented, minimal,
> self-contained, reproducible code.

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


Re: [R] data.frame() creates list?

2008-08-20 Thread Henrik Bengtsson
It is a data.frame.  They are represented by lists.

df <- data.frame(a=1:2, b=letters[1:2]);
> str(df)
'data.frame':   2 obs. of  2 variables:
 $ a: int  1 2
 $ b: Factor w/ 2 levels "a","b": 1 2
> class(df);
[1] "data.frame"
> mode(df);
[1] "list"
> typeof(df);
[1] "list"

For details, see code, e.g. page(data.frame).

/Henrik

On Wed, Aug 20, 2008 at 5:33 PM, Farley, Robert <[EMAIL PROTECTED]> wrote:
> I obviously don't know what I'm doing.  I want to create "ByEBNum" as a
> data frame, but it comes out as a list.  How do I make it a data frame?
>
>
>
>
>
>> EBNumStn <- c(673.65, 800, 1000, 1000,  800,  700,  600, 500, 400,
> 200,  50, 50 )
>
>> ByEBNum <- data.frame(c(1:12),EBNumStn)
>
>> typeof(EBNumStn)
>
> [1] "double"
>
>> typeof(c(1:12))
>
> [1] "integer"
>
>> typeof(ByEBNum)
>
> [1] "list"
>
>> ByEBNum
>
>   c.1.12. EBNumStn
>
> 11   673.65
>
> 22   800.00
>
> 33  1000.00
>
> 44  1000.00
>
> 55   800.00
>
> 66   700.00
>
> 77   600.00
>
> 88   500.00
>
> 99   400.00
>
> 10  10   200.00
>
> 11  1150.00
>
> 12  1250.00
>
>>
>
>
>
>>sessionInfo()
>
> R version 2.7.1 (2008-06-23)
>
> i386-pc-mingw32
>
>
>
> locale:
>
> LC_COLLATE=English_United States.1252;LC_CTYPE=English_United
> States.1252;LC_MONETARY=English_United
> States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252
>
>
>
> attached base packages:
>
> [1] graphics  grDevices utils datasets  stats methods   base
>
>
>
>
> other attached packages:
>
> [1] survey_3.8 fortunes_1.3-5 moonsun_0.1prettyR_1.3-2
> foreign_0.8-28
>
>>
>
>
>
>
>
>
>
>
>
>
>
> Robert Farley
>
> Metro
>
> 1 Gateway Plaza
>
> Mail Stop 99-23-7
>
> Los Angeles, CA 90012-2952
>
> Voice: (213)922-2532
>
> Fax:(213)922-2868
>
> www.Metro.net
>
>
>
>
>
>
>[[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] pnmath compilation failure; dylib issue?

2008-08-20 Thread Eric Rupley




(1) ...need to speed up a monte-carlo sampling...any suggestions about  
how I can get R to use all 8 cores of a mac pro would be most useful  
and very appreciated...


(2) spent the last few hours trying to get pnmath to compile under os- 
x 10.5.4...


using gcc version 4.2.1 (Apple Inc. build 5553) as downloaded from  
CRAN, xcode 3.0...


...xcode 3.1 installed over top of above after compilation  
failure...adverse effect, produced error on "-arch"


 any suggestion about how to get pnmath to compile would be most  
useful...I'm not sure it will even speed things up  but thought I  
would try...



pnmath failed:

...
gcc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx- 
version-min=10.4 -std=gnu99 -dynamiclib -Wl,- 
headerpad_max_install_names -mmacosx-version-min=10.4 -undefined  
dynamic_lookup -single_module -multiply_defined suppress -L/usr/local/ 
lib -o pnmath.so bd0.o beta.o chebyshev.o choose.o d1mach.o dbeta.o  
dbinom.o dcauchy.o dchisq.o dexp.o df.o dgamma.o dgeom.o dhyper.o  
dlnorm.o dlogis.o dnbeta.o dnbinom.o dnchisq.o dnf.o dnorm.o dnt.o  
dpois.o dt.o dunif.o dweibull.o fmax2.o fmin2.o ftrunc.o gamma.o  
gamma_cody.o i1mach.o imax2.o imin2.o lbeta.o lgamma.o lgammacor.o  
mlutils.o pbeta.o pbinom.o pcauchy.o pchisq.o pexp.o pf.o pgamma.o  
pgeom.o phyper.o plnorm.o plogis.o pnbeta.o pnbinom.o pnchisq.o pnf.o  
pnmath.o pnorm.o pnt.o polygamma.o ppois.o pt.o ptukey.o punif.o  
pweibull.o qbeta.o qbinom.o qcauchy.o qchisq.o qexp.o qf.o qgamma.o  
qgeom.o qhyper.o qlnorm.o qlogis.o qnbeta.o qnbinom.o qnchisq.o qnf.o  
qnorm.o qnt.o qpois.o qt.o qtukey.o qunif.o qweibull.o sign.o  
stirlerr.o toms708.o -lgomp  -F/Library/Frameworks/R.framework/.. - 
framework R -Wl,-framework -Wl,CoreFoundation
ld: warning, duplicate dylib /Developer/SDKs/MacOSX10.4u.sdk/usr/local/ 
lib/libgcc_s.1.dylib

** arch - ppc
...
gcc -arch ppc -isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx- 
version-min=10.4 -std=gnu99 -dynamiclib -Wl,- 
headerpad_max_install_names -mmacosx-version-min=10.4 -undefined  
dynamic_lookup -single_module -multiply_defined suppress -L/usr/local/ 
lib -o pnmath.so bd0.o beta.o chebyshev.o choose.o d1mach.o dbeta.o  
dbinom.o dcauchy.o dchisq.o dexp.o df.o dgamma.o dgeom.o dhyper.o  
dlnorm.o dlogis.o dnbeta.o dnbinom.o dnchisq.o dnf.o dnorm.o dnt.o  
dpois.o dt.o dunif.o dweibull.o fmax2.o fmin2.o ftrunc.o gamma.o  
gamma_cody.o i1mach.o imax2.o imin2.o lbeta.o lgamma.o lgammacor.o  
mlutils.o pbeta.o pbinom.o pcauchy.o pchisq.o pexp.o pf.o pgamma.o  
pgeom.o phyper.o plnorm.o plogis.o pnbeta.o pnbinom.o pnchisq.o pnf.o  
pnmath.o pnorm.o pnt.o polygamma.o ppois.o pt.o ptukey.o punif.o  
pweibull.o qbeta.o qbinom.o qcauchy.o qchisq.o qexp.o qf.o qgamma.o  
qgeom.o qhyper.o qlnorm.o qlogis.o qnbeta.o qnbinom.o qnchisq.o qnf.o  
qnorm.o qnt.o qpois.o qt.o qtukey.o qunif.o qweibull.o sign.o  
stirlerr.o toms708.o -lgomp  -F/Library/Frameworks/R.framework/.. - 
framework R -Wl,-framework -Wl,CoreFoundation
ld: warning in /Developer/SDKs/MacOSX10.4u.sdk/usr/local/lib/ 
libgomp.dylib, file is not of required architecture
ld: warning, duplicate dylib /Developer/SDKs/MacOSX10.4u.sdk/usr/local/ 
lib/libgcc_s.1.dylib
ld: in /Developer/SDKs/MacOSX10.4u.sdk/usr/local/lib/libstdc++. 
6.dylib, file is not of required architecture

collect2: ld returned 1 exit status
make: *** [pnmath.so] Error 1
chmod: /Library/Frameworks/R.framework/Resources/library/pnmath/libs/ 
ppc/*: No such file or directory

** Removing '/Library/Frameworks/R.framework/Resources/library/pnmath'
ERROR: compilation failed for package 'pnmath'
>

pnmath0 failed with the same first error; the second error was:

...
gcc -arch ppc -isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx- 
version-min=10.4 -std=gnu99 -dynamiclib -Wl,- 
headerpad_max_install_names -mmacosx-version-min=10.4 -undefined  
dynamic_lookup -single_module -multiply_defined suppress -L/usr/local/ 
lib -o pnmath0.so bd0.o beta.o chebyshev.o choose.o d1mach.o dbeta.o  
dbinom.o dcauchy.o dchisq.o dexp.o df.o dgamma.o dgeom.o dhyper.o  
dlnorm.o dlogis.o dnbeta.o dnbinom.o dnchisq.o dnf.o dnorm.o dnt.o  
dpois.o dt.o dunif.o dweibull.o fmax2.o fmin2.o ftrunc.o gamma.o  
gamma_cody.o i1mach.o imax2.o imin2.o lbeta.o lgamma.o lgammacor.o  
mlutils.o pbeta.o pbinom.o pcauchy.o pchisq.o pexp.o pf.o pgamma.o  
pgeom.o phyper.o plnorm.o plogis.o pnbeta.o pnbinom.o pnchisq.o pnf.o  
pnmath1.o pnorm.o pnt.o polygamma.o ppois.o pt.o ptukey.o punif.o  
pweibull.o qbeta.o qbinom.o qcauchy.o qchisq.o qexp.o qf.o qgamma.o  
qgeom.o qhyper.o qlnorm.o qlogis.o qnbeta.o qnbinom.o qnchisq.o qnf.o  
qnorm.o qnt.o qpois.o qt.o qtukey.o qunif.o qweibull.o sign.o  
stirlerr.o toms708.o workers1.o -lpthread  -F/Library/Frameworks/ 
R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
ld: warning, duplicate dylib /Developer/SDKs/MacOSX10.4u.sdk/usr/local/ 
lib/libgcc_s.1.dylib
ld: in /Developer/SDKs/MacOSX10.4u.sdk/usr/local/lib/libstdc++. 
6.dylib, file is 

[R] data.frame() creates list?

2008-08-20 Thread Farley, Robert
I obviously don't know what I'm doing.  I want to create "ByEBNum" as a
data frame, but it comes out as a list.  How do I make it a data frame?

 

 

> EBNumStn <- c(673.65, 800, 1000, 1000,  800,  700,  600, 500, 400,
200,  50, 50 )

> ByEBNum <- data.frame(c(1:12),EBNumStn)

> typeof(EBNumStn)

[1] "double"

> typeof(c(1:12))

[1] "integer"

> typeof(ByEBNum)

[1] "list"

> ByEBNum

   c.1.12. EBNumStn

11   673.65

22   800.00

33  1000.00

44  1000.00

55   800.00

66   700.00

77   600.00

88   500.00

99   400.00

10  10   200.00

11  1150.00

12  1250.00

> 

 

>sessionInfo() 

R version 2.7.1 (2008-06-23) 

i386-pc-mingw32 

 

locale:

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

 

attached base packages:

[1] graphics  grDevices utils datasets  stats methods   base


 

other attached packages:

[1] survey_3.8 fortunes_1.3-5 moonsun_0.1prettyR_1.3-2
foreign_0.8-28

> 

 

 

 

 

 

Robert Farley

Metro

1 Gateway Plaza

Mail Stop 99-23-7

Los Angeles, CA 90012-2952

Voice: (213)922-2532

Fax:(213)922-2868

www.Metro.net 

 

 


[[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] Extracting eg A[, , 3, 1, ] from an array but using dimension names and levels

2008-08-20 Thread Gabor Grothendieck
Try this:

do.call("[", c(list(HairEyeColor), list(TRUE, 3, 1)))

On Wed, Aug 20, 2008 at 7:16 PM, Søren Højsgaard
<[EMAIL PROTECTED]> wrote:
> Consider the extraction
>
>> HairEyeColor[,3,1]
> Black Brown   Red Blond
>   1025 7 5
>
> Suppose I have the appropriate dimensions and levels given as variables, e.g.
> d1 <-2
> l1 <-3
> d2 <-3
> l2 <-1
>
> How can I then make the "extraction" above using d1, l1, d2, l2  (for an 
> array of arbitrary dimension)?
>
> Best regards
> Søren
>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Extracting eg A[, , 3, 1, ] from an array but using dimension names and levels

2008-08-20 Thread Søren Højsgaard
Consider the extraction
 
> HairEyeColor[,3,1]
Black Brown   Red Blond 
   1025 7 5 

Suppose I have the appropriate dimensions and levels given as variables, e.g.
d1 <-2
l1 <-3 
d2 <-3
l2 <-1

How can I then make the "extraction" above using d1, l1, d2, l2  (for an array 
of arbitrary dimension)?
 
Best regards
Søren
 

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


[R] GAM_binomial logit link

2008-08-20 Thread Marina Laborde
Dear all,
 
I'm using a binomial distribution with a logit link function to fit a GAM 
model. I have 2 questions about it.
First i am not sure if i've chosen the most adequate distribution. I don't have 
presence/absence data (0/1) but I do have a rate which values vary between 0 
and 1. This means the response variable is continuous even if within a limited 
interval. Should i use binomial?
Secondly, in the numerical output i get negative values of UBRE score. I would 
like to know if one should consider the lowest absolute value or the lowest 
real value to select the best model.
 
Thank you in advance for your help.
Marina


  
[[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] Reading in a value of .Random.seed in .Rprofile

2008-08-20 Thread Rolf Turner


On 21/08/2008, at 10:21 AM, Charles C. Berry wrote:


On Thu, 21 Aug 2008, Rolf Turner wrote:




For reasons that are best known to myself [ ;-) ] I have a value  
of .Random.seed

saved (via dput()) in a file ``.Random.seed.save''.

In my .Rprofile I have the lines:

.Random.seed <- dget(".Random.seed.save")
Junk <- dget(".Random.seed.save")
print(all.equal(.Random.seed,dget(".Random.seed.save")))
print(all.equal(Junk,dget(".Random.seed.save")))

The two calls to all.equal() both return TRUE.

However when I repeat the calls from the command line after the
R session has started, I get TRUE from the second (``Junk'') call
but

[1] "Mean relative difference: 0.1"

from the first.


Not on my computer.


H.  Why do these always happen to ***me*** and only to me?


I get TRUE twice whether at start up, source()ing .Rprofile, or C-c  
C-n'ing the lines from emacs ESS.


I have to type

load(".RData")

_after_ startup to get behavior like you describe.


Perhaps, you have something later in your .Rprofile that  
specifically load()'s your old .RData?


No I haven't.  And that couldn't be the case, since ``Junk'' is there
(it wasn't there in the saved image).

	So it would seem that what is happening is that the saved .RData is  
being loaded or restored
	***after*** the commands to read in .Random.seed (and Junk) are  
issued.  The .Random.seed
	in the saved image then overwrites the .Random.seed that was just  
read in.


But why does this happen on *my* system, and not on Chuck's???

	Is there any way I can cause the reading in of the .Random.seed from  
the file

to happen *after* the loading/restoration of the saved image?


Chuck

p.s.


sessionInfo()

R version 2.7.1 (2008-06-23)
x86_64-unknown-linux-gnu

locale:
C

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


Ah, yes.  Session info --- I didn't give that, did I?  Naughty me.
Here it is:

> sessionInfo()
R version 2.7.1 (2008-06-23)
i386-apple-darwin8.10.1
locale: C

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

cheers,

Rolf

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

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


Re: [R] Reading in a value of .Random.seed in .Rprofile

2008-08-20 Thread Charles C. Berry

On Thu, 21 Aug 2008, Rolf Turner wrote:




For reasons that are best known to myself [ ;-) ] I have a value of 
.Random.seed

saved (via dput()) in a file ``.Random.seed.save''.

In my .Rprofile I have the lines:

.Random.seed <- dget(".Random.seed.save")
Junk <- dget(".Random.seed.save")
print(all.equal(.Random.seed,dget(".Random.seed.save")))
print(all.equal(Junk,dget(".Random.seed.save")))

The two calls to all.equal() both return TRUE.

However when I repeat the calls from the command line after the
R session has started, I get TRUE from the second (``Junk'') call
but

[1] "Mean relative difference: 0.1"

from the first.


Not on my computer.

I get TRUE twice whether at start up, source()ing 
.Rprofile, or C-c C-n'ing the lines from emacs ESS.


I have to type

load(".RData")

_after_ startup to get behavior like you describe.


Perhaps, you have something later in your .Rprofile that specifically 
load()'s your old .RData?



Chuck

p.s.


sessionInfo()

R version 2.7.1 (2008-06-23)
x86_64-unknown-linux-gnu

locale:
C

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

--

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

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


[R] Reading in a value of .Random.seed in .Rprofile

2008-08-20 Thread Rolf Turner



For reasons that are best known to myself [ ;-) ] I have a value  
of .Random.seed

saved (via dput()) in a file ``.Random.seed.save''.

In my .Rprofile I have the lines:

.Random.seed <- dget(".Random.seed.save")
Junk <- dget(".Random.seed.save")
print(all.equal(.Random.seed,dget(".Random.seed.save")))
print(all.equal(Junk,dget(".Random.seed.save")))

The two calls to all.equal() both return TRUE.

However when I repeat the calls from the command line after the
R session has started, I get TRUE from the second (``Junk'') call
but

[1] "Mean relative difference: 0.1"

from the first.

The value of .Random.seed appears to be that which was there when I quit
the previous R session and not the one that I tried to read in from  
the file.


If I *remove* .Random.seed before quitting (and save the workspace,  
so that

there is no .Random.seed in .RData then I get TRUE from both calls to
all.equal() made from the command line.  I.e. the value of .Random.seed
***is*** the one read in from the file.

Can anyone:

(a) Explain what's going on?

(b) Suggest how I might arrange that the value of .Random.seed be
made equal to that read in from the file?

***PLEASE*** don't tell me to use set.seed() instead, or something  
like that.
I ***know*** about set.seed() --- I wasn't born yesterday, y'know!   
Please just
accept that I want to do what I want to do, and (if you can) tell me  
how.


Ta.

cheers,

Rolf Turner


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

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


Re: [R] Positioning of axis titles

2008-08-20 Thread Greg Snow
You could also include the call to title/mtext in the plot.axes argument to 
filled.contour, then the coordinate system is still correct.

Hope this helps,

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



> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of Greg Snow
> Sent: Wednesday, August 20, 2008 12:52 PM
> To: Nicky Chorley; Uwe Ligges
> Cc: r-help@r-project.org
> Subject: Re: [R] Positioning of axis titles
>
> A couple of things to try:
>
> Some adjustment can be made by adding whitespace to your label, e.g.:
>
> > plot(1:10, xlab='test')
> > plot(1:10, xlab='test\n')
> > plot(1:10, xlab='test \n')
>
> You can set the label to be blank originally (xlab=''), then
> add it afterwards using title, mtext, or text; but with
> filled.contour the coordinates after the plot are not the
> same as those when the plot was created, so you may need to
> use grconvertX, grconvertY, or updateusr (last from the
> TeachingDemos package) to get the coordinates/positioning right.
>
> Hope this helps,
>
> --
> Gregory (Greg) L. Snow Ph.D.
> Statistical Data Center
> Intermountain Healthcare
> [EMAIL PROTECTED]
> (801) 408-8111
>
>
>
> > -Original Message-
> > From: [EMAIL PROTECTED]
> > [mailto:[EMAIL PROTECTED] On Behalf Of Nicky Chorley
> > Sent: Wednesday, August 20, 2008 12:30 PM
> > To: Uwe Ligges
> > Cc: r-help@r-project.org
> > Subject: Re: [R] Positioning of axis titles
> >
> > 2008/8/20 Uwe Ligges <[EMAIL PROTECTED]>:
> > > Increase the margins as well, default is:
> > >  par("mar"=c(5,4,4,1)+.1)
> > >
> > > Uwe Ligges
> > >
> >
> > Thanks very much. One further question: is it possible to
> change the
> > position of only one axis title (since using mgp changes both)?
> >
> > Thanks again,
> >
> > Nicky Chorley
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/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] Confidence Interval

2008-08-20 Thread Raphael Saldanha
Hi!

Here is a better code, using the percentil value instead the position, and
some corrections on the graph code.

The reason in the difference on the tails is elementar, but I don't had see
it before. The right and left limits are calculated by simulation, and his
differences from the mean are not exactly equal, so the areas under the
normal curve! I'm feeling like dummie now...

Thanks for the help!

Raphael Saldanha
BRAZIL

On Wed, Aug 20, 2008 at 12:07 PM, Raphael Saldanha <
[EMAIL PROTECTED]> wrote:

> Thanks Professor and Bernardo,
>
> What I'm trying to do is this: I have a macro for Minitab. His author says
> it's a "Monte Carlo simulation to estimate a confidence interval". But and
> don't have Minitab, don't like to work with illegal licenses, and LOVE R.
> So, I re-write the macro in a R script.
>
> Bellow, is the original macro, for Minitab:
>
> GMACRO
>
> TesteMedia
>
> do K1=1:1000
>  random 200 C1;
>  normal 100 2.
>  mean C1 K2
>  let C2(K1)=K2
> enddo
>
> sort C2 C3
>
> let K3=C3(25)
> let K4=C3(975)
> print K3 K4
>
> ENDMACRO
>
> The macro's author think on this way: I have a y vector of sorted means
> with 1000 registers. So, my CI is between the 25º and 975º element.
>
> So, I ask: Is this a Monte Carlo Simulation, and the nome is correct? The
> way to isolate the inferior and superior means is correct?
>
> About the graphics, I know the sample can't be reproduced because it's
> random. But, re-running the script some times, I can see, some times,
> differences in the right and left tail, under the normal curve. So, I wonder
> to know where my code is wrong, but just for know, I agree with histogram
> isn't the best way to illustrate confidence interval. I just show him on the
> plot to illustrated the sample used. I will re-make the plot, just with the
> curve and areas after the confidence interval, without the histogram.
>
>
> Thanks for the help!
>
>
>
>
>
>
> On Wed, Aug 20, 2008 at 12:16 AM, Prof Brian Ripley <[EMAIL PROTECTED]
> > wrote:
>
>> On Tue, 19 Aug 2008, Raphael Saldanha wrote:
>>
>>  Hi!
>>>
>>> With the following script, I'm trying to make a demonstration of a
>>> Confidence Interval, but I'm observing some differences on tails.
>>>
>>
>> You need to tell us what you are trying to do.  You seem to be computing a
>> parametric bootstrap interval, but incorrectly (you need to reflect
>> percentile intervals).  See Davison & Hinkley (1997) 'The Bootstrap and its
>> Application' for more details.
>>
>> In any case, your simulation is not repeatable (you set no seed), so we
>> don't know what you saw and what 'differences' disturbed you.
>>
>> Your calculation of quantiles is not quite correct: use quantile().
>> (The indices go from 1 to 1000, not 0 to 1000.)  E.g.
>>
>>  quantile(1:1000, c(0.025, 0.975))
>>>
>>   2.5%   97.5%
>>  25.975 975.025
>>
>> and not 25, 975.
>>
>> As your results show, a histogram is not a good summary of the shape of a
>> distribution on 1000 points.  We can do much better with an ecdf or a
>> density estimate.
>>
>>
>>> # Teste de m?dia entre uma amostra e uma popula??o normal
>>> # Autor: Raphael de Freitas Saldanha
>>> # Agosto de 2008
>>>
>>> n<- 200# Sample size
>>> xbar <- 100# Sample mean
>>> s<- 2  # Sample SD
>>> nc   <- 0.95   # Confidence level (95% -> 0.95)
>>> rep  <- 1000   # Loops
>>>
>>> ###
>>>
>>> y <- NULL# Vetor com as m?dias da amostra
>>> for (i in 1:rep){# Loop
>>> x <- rnorm(n,xbar,s) # Gere uma amostra normal n elementos, xbar
>>> m?dia e
>>> s desvio-padr?o
>>> x <- mean(x) # Calcule a m?dia (exata) dessa amostra
>>> y <- c(y,x)  # Coloque essa m?dia em um registro em y
>>> }
>>>
>>> y <- sort(y) # Ordene todas as m?dias geradas
>>>
>>> LI <- y[((1-nc)/2)*rep] # Limite inferior,
>>> LS <- y[rep-(((1-nc)/2)*rep)]   # Limite superior
>>>
>>> ### PARTE GR?FICA ###
>>>
>>> x <- mean(y)
>>>
>>> xvals <- seq(-LI, LI, length.out=5000)
>>> dvals <- dnorm(xvals,mean(y), sd(y))[1:5000]
>>>
>>> xbvals <- seq(LS, LS*2, length.out=5000)
>>> dbvals <- dnorm(xbvals,mean(y), sd(y))[1:5000]
>>>
>>> ahist <- hist(y, freq=FALSE, col="lightblue", main="Intervalo de
>>> confian?a")
>>>
>>> polygon(c(xvals,LI,LI), c(dvals,dnorm(LI,mean(y), sd(y)),min(dvals)),
>>> col="orange", lty=0)
>>> polygon(c(LS,LS,xbvals), c(min(dbvals),dnorm(LS,mean(y), sd(y)),dbvals),
>>> col="orange", lty=0)
>>> curve(dnorm(x,mean(y), sd(y)),add=TRUE, lty=1, col="red",lwd=2)
>>>
>>> ### Intervalo de Confian?a ###
>>>
>>> LI # Limite inferior
>>> LS # Limite superior
>>>
>>> --
>>> Atenciosamente,
>>>
>>> Raphael Saldanha
>>> [EMAIL PROTECTED]
>>>
>>>[[alternative HTML version deleted]]
>>>
>>>
>>>
>> --
>> Brian D. Ripley,  [EMAIL PROTECTED]
>> Professor of Applied Statistics,  
>> http://www.stats.ox.ac.uk/~ripley/
>> University of Oxford,  

Re: [R] R-Embedding and error messages

2008-08-20 Thread Jorge Cardoso

I tried both solutions but I always get
"undefined symbol"  when executing

I have checked my Makefile and I'm sure
that -lR is present when compiling

I did a grep for the R-sources and verified
that both functions exists

I will try to post it in r-devel list.

Thank for yours responses dear Martin and Luke.

Jorge


El Mié 20 Ago 2008, Luke Tierney escribió:
> On Wed, 20 Aug 2008, Martin Morgan wrote:
> > Hi Jorge --
> >
> > I hesitate to suggest this unsupported solution (as these public
> > suggestions tend to mean that the solution disappears!), but in C
>
> Don't use this -- it is subject to change/removal with no notice.
>
> I do not believe there is a C level methanism for catching the R error
> conditon at this point.  Thinking about this is on the list but it
> hasn't happened yet.  One thing you can do is use the geterrmessage R
> function to retrieve the most recent message (so if R_tryEval
> indicates an error occurred then build and execute a call to
> geterrmessage and extranct the message from the returned STRSXP).
>
> luke
>
> > extern void R_SetErrorHook(void (*)(SEXP, char *));
> >
> > void
> > my_ErrorHook(SEXP call, char *message)
> > {
> >
> >   /*
> >etc; e.g., cache message, perhaps reset error hook (hook is
> >removed after error; nested R-level try() may mean multiple
> >errors per R_tryEval?
> >   */
> >
> > }
> >
> > and then
> >
> > ...
> >
> >R_SetErrorHook( my_ErrorHook );
> >PROTECT(value = R_tryEval( expr, env, errorOccurred ));
> >if( *errorOccurred ) {
> >/* etc, e.g., retrieve error message(s) from cache */
> >}
> >/*
> >hmm, maybe R_SetErrorHook needs to be cleared here, or at
> >least replaced with a no-op?
> >*/
> > ...
> >
> > This is an R-devel question, not R-help.
> >
> > Martin
> >
> > "Jorge W. Cardoso" <[EMAIL PROTECTED]> writes:
> >> I'm writing a C++ application using R-embedding to do some
> >> forecast process.
> >>
> >> I also use R_tryEval instead of R_Eval to run my R-script,
> >> so that in case of error I know exactly in which line number
> >> was the last error.
> >>
> >> In particular, from time in time y get some error messages
> >> refering an exceptional condition in the arima model.
> >>
> >> I want to catch these error messages from de C code
> >> (or at least the code error number) to take some
> >> corrective actions.
> >>
> >> Is there any way to do that ?
> >>
> >> Regards,
> >>
> >> Jorge W. Cardoso
> >>
> >> __
> >> R-help@r-project.org mailing list
> >> https://stat.ethz.ch/mailman/listinfo/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] Looping over groups

2008-08-20 Thread Dylan Beaudette
On Wednesday 20 August 2008, Josh B wrote:
> > Works for me:
> > x <- read.csv('christina.txt')
> >
> > x.list <- by(x, x$gen, function(d) {
> > d.clean <- d[,-1]
> > cov(d.clean, y= NULL, use= "complete.obs", method="pearson")
> > } )
> >
> >note that the output is a list, where each element corresponds to one
> >level of 'gen'. if you need to write each element out to a file, see
> >?sapply or ?lapply .
>
> Yes, how would I do that? The usage of sapply is pretty hard to understand,
> at least at first glance, and I have never played with it before.
>
> I will need to output all of the covariance matrices to one CSV or text
> file (there's probably some sort of "append = TRUE" argument involved).
>
> Does anyone know how to do this easily?

very quickly I would try something like:

# will write to the screen
lapply(x.list, write.csv)

# you will probably want something more interesting:
lapply(x.list, function(element_i)
{
# get level of 'gen' from list element

# make a filename, see ?paste

# write out a file for each
write.table(element_i, file=filename, row.names=FALSE, ...)

}

)


-- 
Dylan Beaudette
Soil Resource Laboratory
http://casoilresource.lawr.ucdavis.edu/
University of California at Davis
530.754.7341

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


Re: [R] Positioning of axis titles

2008-08-20 Thread Prof Brian Ripley

On Wed, 20 Aug 2008, Nicky Chorley wrote:


2008/8/20 Uwe Ligges <[EMAIL PROTECTED]>:

Increase the margins as well, default is:
 par("mar"=c(5,4,4,1)+.1)

Uwe Ligges



Thanks very much. One further question: is it possible to change the
position of only one axis title (since using mgp changes both)?


As I said, use title() directly.  E.g.

par(mar=c(6,4,4,1)+.1)
plot(1:10, xlab="")
title(xlab="x lab title", line=4)

There's also a sneaky way in this case:

plot(1:10, xlab="", sub="x lab title")

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

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


Re: [R] Problems with PostScript Encoding

2008-08-20 Thread Prof Brian Ripley
Please read the posting guide and supply the information asked for and the 
minimal reproducible example asked for.


I suspect the issue is how you selected 'alpha', but another issue is if 
you mean the mathematical symbol alpha or the Greek letter alpha, for the 
solution is different in the two cases.



On Wed, 20 Aug 2008, FScottDahlgren wrote:



Hello all,


I suspect my problem is not new: I am having difficulty getting an alpha
character to print in a PostScript file made by R graphics (in my legend).
At first, I figured out how to actually get the character on the screen;
however, when I saved the graphic to a PostScript file the alpha character
was replaced by "..".


Obviously, something is not working when encoding.  I've tried to change the
encoding using ps.options; however, no matter what I try R encodes the file
using ISOLatin1Encoding.  I'm not even certain that changing the encoding
type would solve my problem.  I really do not want to resort to using
another file format, as the resulting images are inferior.  Is there
something I'm missing here?


Rather a lot ... see the above.



My current solution to the problem: editing the PostScript by hand.  I am no
PostScript wizard, so it is not particularly pretty.  Here is what the code
originally looks like:


/ps 12 def /Font1 findfont 12 s
0 setgray
167.68 434.79 (..=0.05) 0 0 0 t
167.68 420.39 (..=0.005) 0 0 0 t
167.68 405.99 (..=0.0005) 0 0 0 t


and here is what I've changed it to:


/ps 12 def /Font1 findfont 12 s
0 setgray
167.64 317.78 (Lower Limit, = 0.05) 0 0 0 t
167.64 303.38 (Upper Limit, = 0.05) 0 0 0 t
/Symbol 12 selectfont 240 303.38 moveto
/alpha glyphshow
240 317.78 moveto
/alpha glyphshow


The problem with this solution is that it is a terrible hack.  Can someone
please help me find a better solution to this problem?


Thanks,

Scott

--
View this message in context: 
http://www.nabble.com/Problems-with-PostScript-Encoding-tp19070021p19070021.html
Sent from the R help mailing list archive at Nabble.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.



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

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


Re: [R] Looping over groups

2008-08-20 Thread Josh B
> Works for me:
> x <- read.csv('christina.txt')
>
> x.list <- by(x, x$gen, function(d) {
> d.clean <- d[,-1]
> cov(d.clean, y= NULL, use= "complete.obs", method="pearson")
> } )
>
>note that the output is a list, where each element corresponds to one
>level of 'gen'. if you need to write each element out to a file, see
>?sapply or ?lapply .


Yes, how would I do that? The usage of sapply is pretty hard to understand, at 
least at first glance, and I have never played with it before.

I will need to output all of the covariance matrices to one CSV or text file 
(there's probably some sort of "append = TRUE" argument involved).

Does anyone know how to do this easily?



  
[[alternative HTML version deleted]]

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


Re: [R] read.csv : double quoted numbers

2008-08-20 Thread Gabor Grothendieck
The problem is the commas, not the quotes:

> Lines.raw <- '"1,001.23""1,008,000.456"'
> Lines <- readLines(textConnection(Lines.raw))
> Lines <- gsub(",", "", Lines)
> read.table(textConnection(Lines))
   V1  V2
1 1001.23 1008000



On Wed, Aug 20, 2008 at 2:27 PM, Aval Sarri <[EMAIL PROTECTED]> wrote:
> Hello;
>
> I am new user of R; so pardon me.
>
> I am reading a .txt file that has around 50+ numeric columns with '\t'
> as separator. I am using read.csv function along with colClasses but
> that fails to recognize double quoted numeric values. (My numeric
> values are something like "1,001.23"; "1,008,000.456".)   Basically
> read.csv fails with  - "scan() expected 'a real', got '"1,044.059"'.
>
> What I have tried and problems with them:
>
>
> 1) I tried  scan and pipe but getting following error message; that is
> how do I replace all double quotes with nothing. I tired enclosing sed
> command in single quotes but that does not help.
> (Though the sed command works from shell)
>
> scan(pipe("sed -e s/\"//g DataAll.txt"), sep="\t")
> sh: Syntax error: Unterminated quoted string
>
> 2) On mailing list on solution I found was setAs() described here
> http://www.nabble.com/Re%3A--R--read.table()-and-scientific-notation-p6734890.html
>
> 3) Other than using as.is=TRUE and then doing as.numeric for numeric
> columns what is the solution?  But then how do I efficiently convert
> 50+ columns to numeric using regular expression? That is all my
> numeric columns name starts with 'X' character, so how do I use sapply
> and/or regular expression to convert all columns starting with X to
> numeric? What is the alternate method to do so?
>
> Basically 2 and 3 works but which one is efficient and correct way to do this.
>
> (Also what is most efficient way to apply field level validation and
> conversion while reading a file? Does one has to read the file and
> only after that validation and conversion can happen?)
>
> Thanks for taking out time to read through the mail.
>
> Thanks and Regards
> -Aval
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Quantile regression with complex survey data

2008-08-20 Thread Stas Kolenikov
On Wed, Aug 20, 2008 at 8:12 AM, Cheng, Yiling (CDC/CCHP/NCCDPHP)
<[EMAIL PROTECTED]> wrote:
> I am working on the NHANES survey data, and want to apply quantile
> regression on these complex survey data. Does anyone know how to do
> this?

There are no references in technical literature (thinking, Annals,
JASA, JRSS B, Survey Methodology). Absolutely none. Zero. You might be
able to apply the procedure mechanically and then adjust the standard
errors, but God only knows what the population equivalent is of
whatever that model estimates. If there is a population analogue at
all.

In general, a quantile regression is a heavily model based concept:
for each value of the explanatory variables, there is a well defined
distribution of the response, and quantile regression puts additional
structure on it -- linearity of quantiles wrt to some explanatory
variables. That does not mesh well with the design paradigm according
to which the survey estimation is usually conducted. With the latter,
the finite population and characteristics of every unit are assumed
fixed, and randomness comes only from the sampling procedure. Within
that paradigm, you can define the marginal distribution of the
response (or any other) variable, but the conditional distributions
may simply be unavailable because there are no units in the population
satisfying the conditions.

-- 
Stas Kolenikov, also found at http://stas.kolenikov.name
Small print: I use this email account for mailing lists only.

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


Re: [R] Positioning of axis titles

2008-08-20 Thread Greg Snow
A couple of things to try:

Some adjustment can be made by adding whitespace to your label, e.g.:

> plot(1:10, xlab='test')
> plot(1:10, xlab='test\n')
> plot(1:10, xlab='test \n')

You can set the label to be blank originally (xlab=''), then add it afterwards 
using title, mtext, or text; but with filled.contour the coordinates after the 
plot are not the same as those when the plot was created, so you may need to 
use grconvertX, grconvertY, or updateusr (last from the TeachingDemos package) 
to get the coordinates/positioning right.

Hope this helps,

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



> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of Nicky Chorley
> Sent: Wednesday, August 20, 2008 12:30 PM
> To: Uwe Ligges
> Cc: r-help@r-project.org
> Subject: Re: [R] Positioning of axis titles
>
> 2008/8/20 Uwe Ligges <[EMAIL PROTECTED]>:
> > Increase the margins as well, default is:
> >  par("mar"=c(5,4,4,1)+.1)
> >
> > Uwe Ligges
> >
>
> Thanks very much. One further question: is it possible to
> change the position of only one axis title (since using mgp
> changes both)?
>
> Thanks again,
>
> Nicky Chorley
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Positioning of axis titles

2008-08-20 Thread Prof Brian Ripley

On Wed, 20 Aug 2008, Uwe Ligges wrote:




Nicky Chorley wrote:

Hi,

I have created a plot using filled.contour() and have the problem that
one of the axis titles and an axis label are overlapping. I have tried
changing par()$mgp (with, e.g. par(mgp=c(4,1,0)) ), but this just
makes the title go off the screen. I can't work out how to make the
plot take up less space in the window, so I can hopefully change mgp
and sort the problem.


To answer:


Is changing mgp the only way to position axis titles/labels?


No.  They are plotted by title(), and its help page indicates the argument 
'line'.  (Use R 2.7.2 RC or R-devel to get a fuller description.)



Increase the margins as well, default is:
 par("mar"=c(5,4,4,1)+.1)


You will need to do that in any case.



Uwe Ligges



Regards,

Nicky Chorley

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



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

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


Re: [R] Line of best

2008-08-20 Thread Ling, Gary (Electronic Trading)
See: ?loess or ?lowess

-gary



-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Altaweel, Mark R.
Sent: Wednesday, August 20, 2008 12:54 PM
To: r-help@r-project.org
Subject: [R] Line of best


Hi,

I have a scatter plot, with an equation that best fits the scatter plot
expressed as:  1/x^.6.  I know for normal linear regression lines you
can use the abline() command; however, since my best fit line is not
linear, how can I draw my line on the scatter plot in a similar fashion
to abline().

Thanks for everyone's help again. I appreciate this board's advice.

Mark

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


This message w/attachments (message) may be privileged, confidential or 
proprietary, and if you are not an intended recipient, please notify the 
sender, do not use or share it and delete it. Unless specifically indicated, 
this message is not an offer to sell or a solicitation of any investment 
products or other financial product or service, an official confirmation of any 
transaction, or an official statement of Merrill Lynch. Subject to applicable 
law, Merrill Lynch may monitor, review and retain e-communications (EC) 
traveling through its networks/systems. The laws of the country of each 
sender/recipient may impact the handling of EC, and EC may be archived, 
supervised and produced in countries other than the country in which you are 
located. This message cannot be guaranteed to be secure or error-free. This 
message is subject to terms available at the following link: 
http://www.ml.com/e-communications_terms/. By messaging with Merrill Lynch you 
consent to the foregoing.

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


Re: [R] Removing

2008-08-20 Thread Henrique Dallazuanna
Try this also:

Dt <- cbind(Age[o],Sex[o],Ill[o])
 subset(as.data.frame(Dt), V3 != "No")

On Wed, Aug 20, 2008 at 3:24 PM,  <[EMAIL PROTECTED]> wrote:
> I think I should be clearer.  Given the matrix of column vectors Age, Sex,
> and Ill
>
> Age=c(11,52,65,59,13,63,70,40,15,33,65,38,62,10,25,32,62,36,11,33,13,7,64,3,65,59,15,62,37,17,35,15,50,40,35,35,36,57,16,68,54,77,72,58,20,17,62,20,52,9,50,8,35,48,25,11,74,12,44,53,37,24,69,7,17,8,11,17,36,21,60,18,14,52,45)
> Sex=c("Male","Female","Male","Female","Female","Female","Male","Female","Female","Female","Male","Female","Female","Male","Male","Female","Female","Male","Male","Female","Female","Male","Male","Male","Female","Female","Female","Male","Female","Male","Male","Male","Female","Male","Female","Female","Male","Female","Female","Male","Female","Male","Female","Male","Male","Male","Female","Female","Female","Female","Male","Male","Female","Female","Male","Female","Male","Female","Female","Female","Male","Female","Female","Male","Female","Female","Female","Male","Female","Female","Male","Female","Female","Male","Female")
> Ill=c("No","Yes","Yes","Yes","No","Yes","Yes","Yes","Yes","Yes","No","No","No","Yes","No","Yes","Yes","Yes","No","Yes","Yes","Yes","No","Yes","No","Yes","Yes","No","Yes","No","Yes","Yes","Yes","No","No","Yes","No","Yes","Yes","Yes","No","Yes","Yes","Yes","No","No","Yes","Yes","Yes","No","No","Yes","No","Yes","Yes","No","Yes","Yes","Yes","Yes","No","No","No","No","Yes","Yes","No","No","No","Yes","Yes","Yes","No","Yes","Yes")
> o=order(Ill)
> cbind(Age[o],Sex[o],Ill[o])
>
> I am trying to remove all rows of the matrix in which the element in the Ill
> column vector is "No".  I appreciate any help you have to offer.
>
> Brian
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



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

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

2008-08-20 Thread bad2101

Thanks so much for the help!

Brian

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


[R] Problems with PostScript Encoding

2008-08-20 Thread FScottDahlgren

Hello all,


I suspect my problem is not new: I am having difficulty getting an alpha
character to print in a PostScript file made by R graphics (in my legend). 
At first, I figured out how to actually get the character on the screen;
however, when I saved the graphic to a PostScript file the alpha character
was replaced by "..".


Obviously, something is not working when encoding.  I've tried to change the
encoding using ps.options; however, no matter what I try R encodes the file
using ISOLatin1Encoding.  I'm not even certain that changing the encoding
type would solve my problem.  I really do not want to resort to using
another file format, as the resulting images are inferior.  Is there
something I'm missing here?


My current solution to the problem: editing the PostScript by hand.  I am no
PostScript wizard, so it is not particularly pretty.  Here is what the code
originally looks like:


/ps 12 def /Font1 findfont 12 s
0 setgray
167.68 434.79 (..=0.05) 0 0 0 t
167.68 420.39 (..=0.005) 0 0 0 t
167.68 405.99 (..=0.0005) 0 0 0 t


and here is what I've changed it to:


/ps 12 def /Font1 findfont 12 s
0 setgray
167.64 317.78 (Lower Limit, = 0.05) 0 0 0 t
167.64 303.38 (Upper Limit, = 0.05) 0 0 0 t
/Symbol 12 selectfont 240 303.38 moveto
/alpha glyphshow
240 317.78 moveto
/alpha glyphshow


The problem with this solution is that it is a terrible hack.  Can someone
please help me find a better solution to this problem?


Thanks,

Scott

-- 
View this message in context: 
http://www.nabble.com/Problems-with-PostScript-Encoding-tp19070021p19070021.html
Sent from the R help mailing list archive at Nabble.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.


[R] Quantile regression with complex survey data

2008-08-20 Thread Cheng, Yiling (CDC/CCHP/NCCDPHP)

> Dear there,
> 
> I am working on the NHANES survey data, and want to apply quantile
> regression on these complex survey data. Does anyone know how to do
> this?
> 
> Thank you in advance,
> Yiling Cheng
> Yiling J. Cheng MD, PhD
> Epidemiologist
> CoCHP, Division of Diabetes Translation
> Centers for Disease Control and Prevention
> 4770 Buford Highway, N.E. Mailstop K-10
> Atlanta, GA 30341
>  
> 
> 

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

2008-08-20 Thread Jorge Ivan Velez
I'm sorry Brian, my bad. Last line should be

yourdata[yourdata[,3]!='No',]


HTH,


Jorge



On Wed, Aug 20, 2008 at 2:29 PM, Jorge Ivan Velez
<[EMAIL PROTECTED]>wrote:

>
> Hi Brian,
>
> It's almost the same. Try this:
>
> yourdata=cbind(Age,Sex,Ill)  # Age, Sex and Ill are the variables in your
> post :)
> yourdata[yourdata[,3]=='Yes',]
>
> #or
>
> yourdata[yourdata[,3]!='Yes',]
>
>
> HTH,
>
> Jorge
>
>
>
>
>
>
>
>
> On Wed, Aug 20, 2008 at 2:24 PM, <[EMAIL PROTECTED]> wrote:
>
>> I think I should be clearer.  Given the matrix of column vectors Age, Sex,
>> and Ill
>>
>>
>> Age=c(11,52,65,59,13,63,70,40,15,33,65,38,62,10,25,32,62,36,11,33,13,7,64,3,65,59,15,62,37,17,35,15,50,40,35,35,36,57,16,68,54,77,72,58,20,17,62,20,52,9,50,8,35,48,25,11,74,12,44,53,37,24,69,7,17,8,11,17,36,21,60,18,14,52,45)
>>
>> Sex=c("Male","Female","Male","Female","Female","Female","Male","Female","Female","Female","Male","Female","Female","Male","Male","Female","Female","Male","Male","Female","Female","Male","Male","Male","Female","Female","Female","Male","Female","Male","Male","Male","Female","Male","Female","Female","Male","Female","Female","Male","Female","Male","Female","Male","Male","Male","Female","Female","Female","Female","Male","Male","Female","Female","Male","Female","Male","Female","Female","Female","Male","Female","Female","Male","Female","Female","Female","Male","Female","Female","Male","Female","Female","Male","Female")
>>
>> Ill=c("No","Yes","Yes","Yes","No","Yes","Yes","Yes","Yes","Yes","No","No","No","Yes","No","Yes","Yes","Yes","No","Yes","Yes","Yes","No","Yes","No","Yes","Yes","No","Yes","No","Yes","Yes","Yes","No","No","Yes","No","Yes","Yes","Yes","No","Yes","Yes","Yes","No","No","Yes","Yes","Yes","No","No","Yes","No","Yes","Yes","No","Yes","Yes","Yes","Yes","No","No","No","No","Yes","Yes","No","No","No","Yes","Yes","Yes","No","Yes","Yes")
>> o=order(Ill)
>> cbind(Age[o],Sex[o],Ill[o])
>>
>> I am trying to remove all rows of the matrix in which the element in the
>> Ill column vector is "No".  I appreciate any help you have to offer.
>>
>> Brian
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/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] Support Vector Machines

2008-08-20 Thread excalibur

Hi,
i try to use function svm of package e1071 to estimate a density.

But if my data are X=(X1,...,Xn) and m<-svm(X) some values of m$SV are less
than 0.
I don't see how i can get the estimation of the density with this function.

Thanks for your help.

Rémi
-- 
View this message in context: 
http://www.nabble.com/Support-Vector-Machines-tp19069442p19069442.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] Quantile regression with complex survey data

2008-08-20 Thread Cheng, Yiling (CDC/CCHP/NCCDPHP)
Dear there,

I am working on the NHANES survey data, and want to apply quantile
regression on these complex survey data. Does anyone know how to do
this?

Thank you in advance,
Yiling Cheng
Yiling J. Cheng MD, PhD
Epidemiologist
CoCHP, Division of Diabetes Translation
Centers for Disease Control and Prevention
4770 Buford Highway, N.E. Mailstop K-10
Atlanta, GA 30341
 



[[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] Positioning of axis titles

2008-08-20 Thread Nicky Chorley
2008/8/20 Uwe Ligges <[EMAIL PROTECTED]>:
> Increase the margins as well, default is:
>  par("mar"=c(5,4,4,1)+.1)
>
> Uwe Ligges
>

Thanks very much. One further question: is it possible to change the
position of only one axis title (since using mgp changes both)?

Thanks again,

Nicky Chorley

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


Re: [R] Removing

2008-08-20 Thread Jorge Ivan Velez
Hi Brian,

It's almost the same. Try this:

yourdata=cbind(Age,Sex,Ill)  # Age, Sex and Ill are the variables in your
post :)
yourdata[yourdata[,3]=='Yes',]

#or

yourdata[yourdata[,3]!='Yes',]


HTH,

Jorge








On Wed, Aug 20, 2008 at 2:24 PM, <[EMAIL PROTECTED]> wrote:

> I think I should be clearer.  Given the matrix of column vectors Age, Sex,
> and Ill
>
>
> Age=c(11,52,65,59,13,63,70,40,15,33,65,38,62,10,25,32,62,36,11,33,13,7,64,3,65,59,15,62,37,17,35,15,50,40,35,35,36,57,16,68,54,77,72,58,20,17,62,20,52,9,50,8,35,48,25,11,74,12,44,53,37,24,69,7,17,8,11,17,36,21,60,18,14,52,45)
>
> Sex=c("Male","Female","Male","Female","Female","Female","Male","Female","Female","Female","Male","Female","Female","Male","Male","Female","Female","Male","Male","Female","Female","Male","Male","Male","Female","Female","Female","Male","Female","Male","Male","Male","Female","Male","Female","Female","Male","Female","Female","Male","Female","Male","Female","Male","Male","Male","Female","Female","Female","Female","Male","Male","Female","Female","Male","Female","Male","Female","Female","Female","Male","Female","Female","Male","Female","Female","Female","Male","Female","Female","Male","Female","Female","Male","Female")
>
> Ill=c("No","Yes","Yes","Yes","No","Yes","Yes","Yes","Yes","Yes","No","No","No","Yes","No","Yes","Yes","Yes","No","Yes","Yes","Yes","No","Yes","No","Yes","Yes","No","Yes","No","Yes","Yes","Yes","No","No","Yes","No","Yes","Yes","Yes","No","Yes","Yes","Yes","No","No","Yes","Yes","Yes","No","No","Yes","No","Yes","Yes","No","Yes","Yes","Yes","Yes","No","No","No","No","Yes","Yes","No","No","No","Yes","Yes","Yes","No","Yes","Yes")
> o=order(Ill)
> cbind(Age[o],Sex[o],Ill[o])
>
> I am trying to remove all rows of the matrix in which the element in the
> Ill column vector is "No".  I appreciate any help you have to offer.
>
> Brian
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] read.csv : double quoted numbers

2008-08-20 Thread Aval Sarri
Hello;

I am new user of R; so pardon me.

I am reading a .txt file that has around 50+ numeric columns with '\t'
as separator. I am using read.csv function along with colClasses but
that fails to recognize double quoted numeric values. (My numeric
values are something like "1,001.23"; "1,008,000.456".)   Basically
read.csv fails with  - "scan() expected 'a real', got '"1,044.059"'.

What I have tried and problems with them:


1) I tried  scan and pipe but getting following error message; that is
how do I replace all double quotes with nothing. I tired enclosing sed
command in single quotes but that does not help.
(Though the sed command works from shell)

scan(pipe("sed -e s/\"//g DataAll.txt"), sep="\t")
sh: Syntax error: Unterminated quoted string

2) On mailing list on solution I found was setAs() described here
http://www.nabble.com/Re%3A--R--read.table()-and-scientific-notation-p6734890.html

3) Other than using as.is=TRUE and then doing as.numeric for numeric
columns what is the solution?  But then how do I efficiently convert
50+ columns to numeric using regular expression? That is all my
numeric columns name starts with 'X' character, so how do I use sapply
and/or regular expression to convert all columns starting with X to
numeric? What is the alternate method to do so?

Basically 2 and 3 works but which one is efficient and correct way to do this.

(Also what is most efficient way to apply field level validation and
conversion while reading a file? Does one has to read the file and
only after that validation and conversion can happen?)

Thanks for taking out time to read through the mail.

Thanks and Regards
-Aval

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

2008-08-20 Thread Luke Tierney

On Wed, 20 Aug 2008, Martin Morgan wrote:


Hi Jorge --

I hesitate to suggest this unsupported solution (as these public
suggestions tend to mean that the solution disappears!), but in C


Don't use this -- it is subject to change/removal with no notice.

I do not believe there is a C level methanism for catching the R error
conditon at this point.  Thinking about this is on the list but it
hasn't happened yet.  One thing you can do is use the geterrmessage R
function to retrieve the most recent message (so if R_tryEval
indicates an error occurred then build and execute a call to
geterrmessage and extranct the message from the returned STRSXP).

luke


extern void R_SetErrorHook(void (*)(SEXP, char *));

void
my_ErrorHook(SEXP call, char *message)
{

  /*
   etc; e.g., cache message, perhaps reset error hook (hook is
   removed after error; nested R-level try() may mean multiple
   errors per R_tryEval?
  */

}

and then

...

   R_SetErrorHook( my_ErrorHook );
   PROTECT(value = R_tryEval( expr, env, errorOccurred ));
   if( *errorOccurred ) {
   /* etc, e.g., retrieve error message(s) from cache */
   }
   /*
   hmm, maybe R_SetErrorHook needs to be cleared here, or at
   least replaced with a no-op?
   */
...

This is an R-devel question, not R-help.

Martin

"Jorge W. Cardoso" <[EMAIL PROTECTED]> writes:


I'm writing a C++ application using R-embedding to do some
forecast process.

I also use R_tryEval instead of R_Eval to run my R-script,
so that in case of error I know exactly in which line number
was the last error.

In particular, from time in time y get some error messages
refering an exceptional condition in the arima model.

I want to catch these error messages from de C code
(or at least the code error number) to take some
corrective actions.

Is there any way to do that ?

Regards,

Jorge W. Cardoso

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





--
Luke Tierney
Chair, Statistics and Actuarial Science
Ralph E. Wareham Professor of Mathematical Sciences
University of Iowa  Phone: 319-335-3386
Department of Statistics andFax:   319-335-3017
   Actuarial Science
241 Schaeffer Hall  email:  [EMAIL PROTECTED]
Iowa City, IA 52242 WWW:  http://www.stat.uiowa.edu

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


[R] Removing

2008-08-20 Thread bad2101
I think I should be clearer.  Given the matrix of column vectors Age,  
Sex, and Ill


Age=c(11,52,65,59,13,63,70,40,15,33,65,38,62,10,25,32,62,36,11,33,13,7,64,3,65,59,15,62,37,17,35,15,50,40,35,35,36,57,16,68,54,77,72,58,20,17,62,20,52,9,50,8,35,48,25,11,74,12,44,53,37,24,69,7,17,8,11,17,36,21,60,18,14,52,45)
Sex=c("Male","Female","Male","Female","Female","Female","Male","Female","Female","Female","Male","Female","Female","Male","Male","Female","Female","Male","Male","Female","Female","Male","Male","Male","Female","Female","Female","Male","Female","Male","Male","Male","Female","Male","Female","Female","Male","Female","Female","Male","Female","Male","Female","Male","Male","Male","Female","Female","Female","Female","Male","Male","Female","Female","Male","Female","Male","Female","Female","Female","Male","Female","Female","Male","Female","Female","Female","Male","Female","Female","Male","Female","Female","Male","Female")
Ill=c("No","Yes","Yes","Yes","No","Yes","Yes","Yes","Yes","Yes","No","No","No","Yes","No","Yes","Yes","Yes","No","Yes","Yes","Yes","No","Yes","No","Yes","Yes","No","Yes","No","Yes","Yes","Yes","No","No","Yes","No","Yes","Yes","Yes","No","Yes","Yes","Yes","No","No","Yes","Yes","Yes","No","No","Yes","No","Yes","Yes","No","Yes","Yes","Yes","Yes","No","No","No","No","Yes","Yes","No","No","No","Yes","Yes","Yes","No","Yes","Yes")
o=order(Ill)
cbind(Age[o],Sex[o],Ill[o])

I am trying to remove all rows of the matrix in which the element in  
the Ill column vector is "No".  I appreciate any help you have to offer.


Brian

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


Re: [R] Removing

2008-08-20 Thread Jorge Ivan Velez
Hi Brian,

Try

Ill[Ill!='No']

#or

Ill[Ill=='Yes']


HTH,

Jorge



On Wed, Aug 20, 2008 at 2:16 PM, <[EMAIL PROTECTED]> wrote:

> I'm trying to remove the elements "No" from the character vector
>
>
> Ill=c("No","Yes","Yes","Yes","No","Yes","Yes","Yes","Yes","Yes","No","No","No","Yes","No","Yes","Yes","Yes","No","Yes","Yes","Yes","No","Yes","No","Yes","Yes","No","Yes","No","Yes","Yes","Yes","No","No","Yes","No","Yes","Yes","Yes","No","Yes","Yes","Yes","No","No","Yes","Yes","Yes","No","No","Yes","No","Yes","Yes","No","Yes","Yes","Yes","Yes","No","No","No","No","Yes","Yes","No","No","No","Yes","Yes","Yes","No","Yes","Yes")
>
> but cannot figure out how to do it.  I appreciate any help you have to
> offer.
>
> Brian
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Removing

2008-08-20 Thread Henrique Dallazuanna
Try this:

Ill[Ill != "No"]

On Wed, Aug 20, 2008 at 3:16 PM,  <[EMAIL PROTECTED]> wrote:
> I'm trying to remove the elements "No" from the character vector
>
> Ill=c("No","Yes","Yes","Yes","No","Yes","Yes","Yes","Yes","Yes","No","No","No","Yes","No","Yes","Yes","Yes","No","Yes","Yes","Yes","No","Yes","No","Yes","Yes","No","Yes","No","Yes","Yes","Yes","No","No","Yes","No","Yes","Yes","Yes","No","Yes","Yes","Yes","No","No","Yes","Yes","Yes","No","No","Yes","No","Yes","Yes","No","Yes","Yes","Yes","Yes","No","No","No","No","Yes","Yes","No","No","No","Yes","Yes","Yes","No","Yes","Yes")
>
> but cannot figure out how to do it.  I appreciate any help you have to
> offer.
>
> Brian
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



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

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

2008-08-20 Thread bad2101

I'm trying to remove the elements "No" from the character vector

Ill=c("No","Yes","Yes","Yes","No","Yes","Yes","Yes","Yes","Yes","No","No","No","Yes","No","Yes","Yes","Yes","No","Yes","Yes","Yes","No","Yes","No","Yes","Yes","No","Yes","No","Yes","Yes","Yes","No","No","Yes","No","Yes","Yes","Yes","No","Yes","Yes","Yes","No","No","Yes","Yes","Yes","No","No","Yes","No","Yes","Yes","No","Yes","Yes","Yes","Yes","No","No","No","No","Yes","Yes","No","No","No","Yes","Yes","Yes","No","Yes","Yes")

but cannot figure out how to do it.  I appreciate any help you have to offer.

Brian

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


Re: [R] nonlinear constrained optimization

2008-08-20 Thread Paul Smith
On Tue, Aug 19, 2008 at 8:12 PM, Hans W. Borchers <[EMAIL PROTECTED]> wrote:
> Please have a look at the 'Rdonlp2' package at .
> It provides non-linear optimization with nonlinear constraints.

Notwithstanding, be aware of the following limitation of Donlp2:

"If the problem is large and sparse, the package should not be used,
since DONLP2 treats all matrices as dense.",

according to what is written at

http://www-new.mcs.anl.gov/otc/Guide/SoftwareGuide/Blurbs/donlp2.html

Paul

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


Re: [R] FYI: APL in R

2008-08-20 Thread Emmanuel Charpentier
Le mardi 19 août 2008 à 23:52 -0700, Jan de Leeuw a écrit :
> http://idisk.mac.com/jdeleeuw-Public/utilities/apl/apl.R

Thank you ! I was beginning to think I was the last of the dinosaurs...
ISTR that someone else on the list is also an (un)repentant APLer...

> Although this is all prefix and no infix, we could easily
> recreate some of the infamous APL one-liners that nobody
> can possibly understand or reproduce.

:-)!!! Having implemented a (primitive) stats package in APL, I know
what you mean... A liberal use of lamp was ... well, enlightening...

Emmanuel Charpentier

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 send Html using SQL Server db mail

2008-08-20 Thread Barry Rowlingson
2008/8/20 Bos, Roger <[EMAIL PROTECTED]>:
> All,
>
> I have a variable called `go` and it has a single quote in the name
> column of line 47 that I am trying to get rid of.  I have tried using
> gsub, but I cannot get the syntax correct to tell R to remove the '
> (single quote).
>
>> go[47,]
>gvkey SymbolName   Rank MarketCap MemoDate
> Action Analyst Reason SharesHeld
> 75 065105 BJ BJ'S WHOLESALE CLUB INC 0.9579   2258.24 
>   
>>
>
> I have tried every combination I could think of, some of them being:
> gsub(go, `'`, ` `)
> gsub(go, "'", " ")
> gsub(go, "\'S", " S")
> gsub(go, "'S", "S")

 Did you try reading the help for gsub?

 > s="Mom's Friendly Robot Company"
 > gsub("'","",s)
 [1] "Moms Friendly Robot Company"

 It's gsub(pattern, replacement, x), not gsub(x,pattern,replacement).

If this still fails for you then it's possible the ' mark in your text
isn't an ascii ' but some other mark that looks like an ascii '.
There's a lot of them about.

What's this got to do with "How to send Html using SQL Server db
mail"? If you use a meaningful subject then more people will read it.
Except for weirdos like me who read stuff with odd subjects anyway...

Barry

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


Re: [R] Positioning of axis titles

2008-08-20 Thread Uwe Ligges



Nicky Chorley wrote:

Hi,

I have created a plot using filled.contour() and have the problem that
one of the axis titles and an axis label are overlapping. I have tried
changing par()$mgp (with, e.g. par(mgp=c(4,1,0)) ), but this just
makes the title go off the screen. I can't work out how to make the
plot take up less space in the window, so I can hopefully change mgp
and sort the problem. Is changing mgp the only way to position axis
titles/labels?


Increase the margins as well, default is:
  par("mar"=c(5,4,4,1)+.1)

Uwe Ligges



Regards,

Nicky Chorley

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

2008-08-20 Thread Ben Bolker
Altaweel, Mark R.  anl.gov> writes:

> I have a scatter plot, with an equation that best fits
 the scatter plot expressed as:  1/x^.6.  I know for
> normal linear regression lines you can use the abline() command;
 however, since my best fit line is not
> linear, how can I draw my line on the scatter plot in a similar 
fashion to abline().

curve() or predict(): see

http://wiki.r-project.org/rwiki/doku.php?id=tips:graphics-misc:plotpredicted

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

2008-08-20 Thread Martin Morgan
Hi Jorge --

I hesitate to suggest this unsupported solution (as these public
suggestions tend to mean that the solution disappears!), but in C

extern void R_SetErrorHook(void (*)(SEXP, char *));

void
my_ErrorHook(SEXP call, char *message)
{

   /*
etc; e.g., cache message, perhaps reset error hook (hook is
removed after error; nested R-level try() may mean multiple
errors per R_tryEval?
   */

}

and then

...

R_SetErrorHook( my_ErrorHook );
PROTECT(value = R_tryEval( expr, env, errorOccurred ));
if( *errorOccurred ) {
/* etc, e.g., retrieve error message(s) from cache */
}
/*
hmm, maybe R_SetErrorHook needs to be cleared here, or at
least replaced with a no-op?
*/
...

This is an R-devel question, not R-help.

Martin

"Jorge W. Cardoso" <[EMAIL PROTECTED]> writes:

> I'm writing a C++ application using R-embedding to do some
> forecast process.
>
> I also use R_tryEval instead of R_Eval to run my R-script,
> so that in case of error I know exactly in which line number
> was the last error.
>
> In particular, from time in time y get some error messages
> refering an exceptional condition in the arima model.
>
> I want to catch these error messages from de C code 
> (or at least the code error number) to take some 
> corrective actions.
>
> Is there any way to do that ?
>
> Regards,
>
> Jorge W. Cardoso
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

-- 
Martin Morgan
Computational Biology / Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N.
PO Box 19024 Seattle, WA 98109

Location: Arnold Building M2 B169
Phone: (206) 667-2793

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

2008-08-20 Thread Nicky Chorley
Hi,

I have created a plot using filled.contour() and have the problem that
one of the axis titles and an axis label are overlapping. I have tried
changing par()$mgp (with, e.g. par(mgp=c(4,1,0)) ), but this just
makes the title go off the screen. I can't work out how to make the
plot take up less space in the window, so I can hopefully change mgp
and sort the problem. Is changing mgp the only way to position axis
titles/labels?

Regards,

Nicky Chorley

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


Re: [R] Survey Design / Rake questions

2008-08-20 Thread Farley, Robert
Thank you for your help.  Yes, my problem is one of non-response.  We
try to hand a survey form to everyone that boards at each stop, but
we're getting only ~10% usable responses.  One reason is that the "full
survey" is long, and requires geo-locating 2 points - Trip Origin and
Destination.   


My hope is to perform a second survey to establish the temporal
distribution.  Unfortunately, it appears that this will need to be
nearly as extensive (expensive) as the original survey.  


If this (raking "time on board") can be show to work, we can then
generalize the process to other variables.  


Thank you.




PS  Why is 'ByEBOn' a list and not a DataFrame?

> OnLabels<- c( "Warner Center", "De Soto", "Pierce College",
"Tampa", "Reseda", "Balboa", "Woodley", "Sepulveda", "Van Nuys",
"Woodman", "Valley College", "Laurel Canyon", "North Hollywood")
> EBOnNewTots <- c(1000,   600, 1200,
500, 1000,  500,   200, 250,   1000,   300,
100,  50,73.65 )
> EBNumStn <- c(673.65, 800, 1000, 1000,  800,  700,  600, 500, 400,
200,  50, 50 )
> ByEBOn <- data.frame(OnLabels,EBOnNewTots)
> ByEBNum <- data.frame(c(1:12),EBNumStn)
> RakedEBSurvey <- rake(EBDesign, list(~ByEBOn, ~ByEBNum),
list(EBOnNewTots, EBNumStn ) )
Error in model.frame.default(margin, data = design$variables) : 
  invalid type (list) for variable 'ByEBOn'
>


 
Robert Farley
Metro
www.Metro.net 
 

-Original Message-
From: Stas Kolenikov [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, August 20, 2008 07:13
To: Farley, Robert
Cc: r-help@r-project.org
Subject: Re: [R] Survey Design / Rake questions

On Mon, Aug 18, 2008 at 6:18 PM, Farley, Robert <[EMAIL PROTECTED]>
wrote:
> My motivation is to try to correct for a "time on board" bias we see
in
> our surveys.  Not surprisingly, riders who are only on board a short
> time don't attempt/finish our survey forms.  We're able to weight our
> survey to the "bus stop-on by bus run" level.

So is it the problem of catching the short rides in your sample, or
the problem of having those short rides complete the survey? If the
former, then all you have to do is to weight by inverse probability of
selection (Horvitz-Thompson estimator). This probability is probably
roughly proportional to time on bus, which in turn might be
proportional to the number of stops in their ride. You may not need
any raking for that, just do some algebra computing those
probabilities of selection.

If the latter is the problem, then it is the problem of non-response.
If you think that the only thing that matters in whether a person
chooses to respond or not is the length of the ride, then your data
are "missing at random" (MAR), one of several standard concepts in the
missing data statistics
(http://www.citeulike.org/user/ctacmo/article/553290). You can bypass
that -- in survey statistics, that will be done with weights, again.
Here, you would need to boost the weight by the inverse fraction of
those who did complete the survey.

In a more difficult situation, your response probability might depend
on other factors, say demographics of the passengers, time of the day,
etc. I would imagine you would still have MAR data, unless you have
some weird questions like "Do you carry firearms on the bus?" to which
the people who did have guns at the time of their ride would probably
decline to answer, making the data informatively missing/not missing
at random (NMAR).

-- 
Stas Kolenikov, also found at http://stas.kolenikov.name
Small print: I use this email account for mailing lists only.

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


Re: [R] Writing Rcmdr Plugins

2008-08-20 Thread G. Jay Kerns
...[snipped]

>
> The /inst directory:  in here you will need to put a file "menus.txt"
>

This should have been "the /inst/etc" directory, as you noted in your
original post.
Jay

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

2008-08-20 Thread Altaweel, Mark R.
Hi,

I have a scatter plot, with an equation that best fits the scatter plot 
expressed as:  1/x^.6.  I know for normal linear regression lines you can use 
the abline() command; however, since my best fit line is not linear, how can I 
draw my line on the scatter plot in a similar fashion to abline().

Thanks for everyone's help again. I appreciate this board's advice.

Mark

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


Re: [R] Writing Rcmdr Plugins

2008-08-20 Thread G. Jay Kerns
Dear Irina,


On Wed, Aug 20, 2008 at 12:02 PM, Irina Ursachi
<[EMAIL PROTECTED]> wrote:
> Dear all,
>
> I am trying to write a plugin for the RCommander and having troubles
> understanding how to actually do that. I have read Mr. Fox's tutorial
> about writing Rcmdr plugins and though it seems to me that some
> steps are missing.  I would like to know, whether there are some
> Commands which generate a plugin package out of a given library. Or do
> we just have to attach the .First.lib function and the menus.txt data to
> the library? Out of the RcmdrPlugin.TeachingDemos example I could see,
> that one of the differences between the plugin and the library, is the
> fact that the plugin package also contains the "etc" subdirectory... so
> I suppose my plugin package should contain one too, right?
> The way I was trying to build my plugin package (and it didn't work )
> was: I installed Rcmdr, the latest version locally, in a folder named
> "Rlib". There is where I also installed my library and trying to use the
> "require" command to load it into R Commander. What I don't understand,
> is how to build the RcmdrPlugin.*?
> I would really appreciate, if somebody could help me with that, or maybe
> just recommend me a tutorial.
>
> Best regards,
> Irina Ursachi.
>

In general, you can read the R-manuals (in particular, the "Writing R
Extensions" one) to make sure that you have all of absolutely
necessary components (a DESCRIPTION, an /R directory, all of the
required documentation, etc.)

That being said, the basic format of an RcmdrPlugin is:

The /R directory:  this is where you put all of the Tcl/Tk functions
for your menus that you want to add.  In addition, any extra functions
that you wrote that are new should go in here.  You will need in here
the .First.lib function that John mentioned in his article, in the
format that he suggested.

The /man directory:  this has all of the .Rd help files.   One of
these files will likely be titled something like
"RcmdrPlugin.foo-internal.Rd".  This is where you will put aliases to
many of the functions that are 'internal' in the sense that they are
not to be called by the user.

The /inst directory:  in here you will need to put a file "menus.txt".
 John Fox's article gives you lots of details about how to set it up
correctly.  You only need to include lines for the menus that you are
specifically adding.  And now with Rcmdr_1.4-0, you can include lines
for menus that you prefer _not_ to appear (this really helps with
making the menus less cluttered when multiple plugins are loaded).

The /data directory: optional.  Do you want to include data with your plugin?

Your DESCRIPTION file should be set up as the article recommends, with
the DEPENDS argument showing at least Rcmdr 1.3.0 (and you would be
advised to go with Rcmdr 1.4.0).  See the article about the details of
DESCRIPTION.

There are a lot more things that you can do;  please see the manuals
for details.  But the above has the bare essentials for a RcmdrPlugin
(I don't believe that I am forgetting anything.)

Once you have those essential parts, then the RcmdrPlugin is built and
installed in exactly the same way as any other R package (again, see
the manuals  I see an "R CMD build" in your future...  :-).  There
are many, many messages on the R-help archive to help you for your
operating system, and many people have written online tutorials.

Perhaps the best advice is to download the source code
RcmdrPlugin.x.tar.gz from CRAN (e.g. RcmdrPlugin.IPSUR), extract
the archive, and take a look at how other people have done it.

I hope that this helps, and good luck!  :-)

Jay




***
G. Jay Kerns, Ph.D.
Associate Professor
Department of Mathematics & Statistics
Youngstown State University
Youngstown, OH 44555-0002 USA
Office: 1035 Cushwa Hall
Phone: (330) 941-3310 Office (voice mail)
-3302 Department
-3170 FAX
E-mail: [EMAIL PROTECTED]
http://www.cc.ysu.edu/~gjkerns/

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 estimate of a probability by simulation (sender)

2008-08-20 Thread Van Wyk, Jaap
Thank you for all the responses!
It turned out that my "theory" contained an error - the answer is 0.2544, and 
this was confirmed with the simulation in R.
My students will be impressed - and I will quote where I found the great help.
 
Regards
Jacob
 
 
 
Jacob L van Wyk
Dept of Statistics
University of Johannesburg
P O Box 524
Auckland Park 2006
South Africa
Tel: +27-11-559-3080
Fax: +27-11-559-2832
Cell: +27-82-859-2031

[[alternative HTML version deleted]]

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


Re: [R] Lattice: problem using panel.superpose and panel.groups

2008-08-20 Thread Emmanuel Charpentier
Le dimanche 17 août 2008 à 09:36 +, Dieter Menne a écrit :

[ Snip .. ]
> Trellis graphics are a bit like hash functions: you can be close to the 
> target, but get a far-off result.

Nice candidate for a fortune() entry ...

Emmanuel Charpentier

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


Re: [R] Writing Rcmdr Plugins

2008-08-20 Thread stephen sefick
Session info- what type of computer-etc.

On Wed, Aug 20, 2008 at 12:02 PM, Irina Ursachi
<[EMAIL PROTECTED]> wrote:
> Dear all,
>
> I am trying to write a plugin for the RCommander and having troubles
> understanding how to actually do that. I have read Mr. Fox's tutorial
> about writing Rcmdr plugins and though it seems to me that some
> steps are missing.  I would like to know, whether there are some
> Commands which generate a plugin package out of a given library. Or do
> we just have to attach the .First.lib function and the menus.txt data to
> the library? Out of the RcmdrPlugin.TeachingDemos example I could see,
> that one of the differences between the plugin and the library, is the
> fact that the plugin package also contains the "etc" subdirectory... so
> I suppose my plugin package should contain one too, right?
> The way I was trying to build my plugin package (and it didn't work )
> was: I installed Rcmdr, the latest version locally, in a folder named
> "Rlib". There is where I also installed my library and trying to use the
> "require" command to load it into R Commander. What I don't understand,
> is how to build the RcmdrPlugin.*?
> I would really appreciate, if somebody could help me with that, or maybe
> just recommend me a tutorial.
>
> Best regards,
> Irina Ursachi.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



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

-K. Mullis

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


[R] How to send Html using SQL Server db mail

2008-08-20 Thread Bos, Roger
All,

I have a variable called `go` and it has a single quote in the name
column of line 47 that I am trying to get rid of.  I have tried using
gsub, but I cannot get the syntax correct to tell R to remove the '
(single quote).  

> go[47,]
gvkey SymbolName   Rank MarketCap MemoDate
Action Analyst Reason SharesHeld
75 065105 BJ BJ'S WHOLESALE CLUB INC 0.9579   2258.24 
  
>

I have tried every combination I could think of, some of them being:
gsub(go, `'`, ` `)
gsub(go, "'", " ")
gsub(go, "\'S", " S")
gsub(go, "'S", "S")

I understand the problem is that R interprets the single quote as a
single quote instead of a character that I want to remove, but I don't
know how to tell R that I want to identiy the single quote and remove
it. This is probably easy for some, but to me it seems much more
difficult than it should be.

Thanks,

Roger

** * 
This message is for the named person's use only. It may 
contain confidential, proprietary or legally privileged 
information. No right to confidential or privileged treatment 
of this message is waived or lost by any error in 
transmission. If you have received this message in error, 
please immediately notify the sender by e-mail, 
delete the message and all copies from your system and destroy 
any hard copies. You must not, directly or indirectly, use, 
disclose, distribute, print or copy any part of this message 
if you are not the intended recipient. 

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


Re: [R] Looping over groups

2008-08-20 Thread Dylan Beaudette
2008/8/20 Josh B <[EMAIL PROTECTED]>:
> Here is my underlying data file. Of course, please don't feel obliged to 
> spend any more time on this!
>
>
> - Original Message 
> From: Dylan Beaudette <[EMAIL PROTECTED]>
> To: Josh B <[EMAIL PROTECTED]>
> Cc: r-help@r-project.org
> Sent: Wednesday, August 20, 2008 10:58:26 AM
> Subject: Re: [R] Looping over groups
>
> On Wed, Aug 20, 2008 at 7:48 AM, Josh B <[EMAIL PROTECTED]> wrote:
>> Hello,
>>
>> My R skills are somewhere between novice and intermediary, and I am hoping 
>> that some of you very helpful forum members, whom I've seen work your magic 
>> on other peoples' problems/questions, can help me here.
>>
>> I have a matrix with the following format:
>>
>> (i) individual plants comprising many different genotype groups (i.e., a 
>> plant is genotype 1 or genotype 2 or genotype 3, etc). The column for 
>> genotypes is called "gen", and the plants are members of genotype class 1 - 
>> 309, with no overlaps (i.e., you're either a genotype 1 or a genotype 
>> something else, but not both) and no missing values.
>> (ii) Various trait measurements taken on the plants, with multiple 
>> replicates per genotype group
>>
>> I want to create a covariance matrix, separately for plants from each 
>> genotype group. I know how to use the command "cov"; my problem is that I 
>> have 309 different genotype groups and so I need to set up some sort of an 
>> automated loop to go through each genotype group and create a separate 
>> covariance matrix based on it.
>>
>> My question is, how do I make a loop to automatically go through and create 
>> these covariance matrices, i.e., a separate covariance matrix for plants 
>> from each genotype group?
>>
>> I am familiar with the "for" command, but I cannot get it to work. Here is 
>> my code:
>>
>> christina= read.table("christina.txt", sep= ",", na= "NA", header= TRUE)
>> {for (i in 1:309)
>> christina.i= subset(christina, gen == i)
>> christina.i.clean= christina.i[,-1]
>> christina.matrix.i= as.matrix(christina.i.clean)
>> christina.cov.i= cov(christina.matrix.i, y= NULL, use= "complete.obs", 
>> method= c("pearson"))
>> write.table(christina.cov.i, sep= ",", file= "covariances.csv", row.names= 
>> FALSE, col.names= FALSE, append= TRUE)}
>>
>>
>> The problem occurs at my code snippet "gen == i". I want R to insert a 
>> number in place of "i", depending on what round of the loop it is on, but R 
>> insists that I am literally referring to a genotype class named "i". I have 
>> made sure that the column "gen" is numeric, but the same problem persists if 
>> I make the column a factor instead.
>>
>> Any help would be much appreciated, but help that includes sample code would 
>> be most useful. Thank you in advance!
>>
>> Sincerely,
>> Josh
>>
>
> If you can make your data into a dataframe, you can use something like this:
>
> # might work
> christina.df <- as.data.frame(christina)
>
> # this should work, if your ID var ('gen') is the first column in the data 
> frame
> by(christina.df, christina.df$gen, function(d) {
> d.clean <- d[,-1]
> cov(d.clean, y= NULL, use= "complete.obs", method= c("pearson")
> } )
>
> for more ideas, see ?by
>
> Cheers,
>
> Dylan
>
>
>
>

Works for me:
x <- read.csv('christina.txt')

x.list <- by(x, x$gen, function(d) {
d.clean <- d[,-1]
cov(d.clean, y= NULL, use= "complete.obs", method="pearson")
} )

note that the output is a list, where each element corresponds to one
level of 'gen'. if you need to write each element out to a file, see
?sapply or ?lapply .

Cheers,

Dylan

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

2008-08-20 Thread Irina Ursachi
Dear all,

I am trying to write a plugin for the RCommander and having troubles
understanding how to actually do that. I have read Mr. Fox's tutorial
about writing Rcmdr plugins and though it seems to me that some
steps are missing.  I would like to know, whether there are some
Commands which generate a plugin package out of a given library. Or do
we just have to attach the .First.lib function and the menus.txt data to
the library? Out of the RcmdrPlugin.TeachingDemos example I could see,
that one of the differences between the plugin and the library, is the
fact that the plugin package also contains the "etc" subdirectory... so
I suppose my plugin package should contain one too, right?
The way I was trying to build my plugin package (and it didn't work )
was: I installed Rcmdr, the latest version locally, in a folder named
"Rlib". There is where I also installed my library and trying to use the
"require" command to load it into R Commander. What I don't understand,
is how to build the RcmdrPlugin.*?
I would really appreciate, if somebody could help me with that, or maybe
just recommend me a tutorial.

Best regards,
Irina Ursachi.

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

2008-08-20 Thread davidr
I get 5/36 + log(2)/6, not 1/9.

David L. Reiner, PhD
Head Quant
Rho Trading Securities, LLC

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Alberto Monteiro
Sent: Wednesday, August 20, 2008 7:56 AM
To: Van Wyk, Jaap; r-help@r-project.org
Subject: Re: [R] Simple estimate of a probability by simulation


Jaap Van Wyk wrote:
> 
> I would appreciate any help with the following. 
> Problem: Suppose A, B and C are independent U(0,1) random variables. 
> What is the probability that A(x^2) + Bx + C has real roots? I have 
> done the theoretical work and obtained an answer of 1/9 = 0.. 
> Now I want to show my students to get this in R with simulation. 
> Below are two attemps, both giving the answer to be about 0.26.
> 
> Could anybody please help me with providing a more elegant way to do 
> this? (I am still learning R and trying to get my students to learn 
> it as well. I know there must be a better way to get this.) I must 
> be doing something wrong ?
> 
Always think that R is vector-oriented, so you should think
in terms of vectors.

A simple solution for your problem would be:

n <- 1
# n <- 1? Make n <- 100 !
n <- 100
a <- runif(n)  # a vector of n unifs
b <- runif(n)
c <- runif(n)
delta <- b^2 - 4 * a * c # a vector of deltas

# The answer then is how many deltas are non-negative:

sum(delta > 0) / length(delta)

# Explanation
b^2 is the vector of the squares of b's
a * c does the pointwise product of vectors
delta > 0 is a logical array with TRUE or FALSE
sum(delta > 0) coerces TRUE to 1 and FALSE to 0
length(delta) is the length of delta (n)

Alberto Monteiro

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

2008-08-20 Thread Josh B
When I try your suggestion, I get the output, e.g.,:


christina.df$gen: 309
NULL

Returned for each vector. That doesn't seem good (I associate "NULL" with 
something being empty), but perhaps I am misinterpreting it?

- Original Message 
From: Dylan Beaudette <[EMAIL PROTECTED]>
To: Josh B <[EMAIL PROTECTED]>
Cc: r-help@r-project.org
Sent: Wednesday, August 20, 2008 10:58:26 AM
Subject: Re: [R] Looping over groups

On Wed, Aug 20, 2008 at 7:48 AM, Josh B <[EMAIL PROTECTED]> wrote:
> Hello,
>
> My R skills are somewhere between novice and intermediary, and I am hoping 
> that some of you very helpful forum members, whom I've seen work your magic 
> on other peoples' problems/questions, can help me here.
>
> I have a matrix with the following format:
>
> (i) individual plants comprising many different genotype groups (i.e., a 
> plant is genotype 1 or genotype 2 or genotype 3, etc). The column for 
> genotypes is called "gen", and the plants are members of genotype class 1 - 
> 309, with no overlaps (i.e., you're either a genotype 1 or a genotype 
> something else, but not both) and no missing values.
> (ii) Various trait measurements taken on the plants, with multiple replicates 
> per genotype group
>
> I want to create a covariance matrix, separately for plants from each 
> genotype group. I know how to use the command "cov"; my problem is that I 
> have 309 different genotype groups and so I need to set up some sort of an 
> automated loop to go through each genotype group and create a separate 
> covariance matrix based on it.
>
> My question is, how do I make a loop to automatically go through and create 
> these covariance matrices, i.e., a separate covariance matrix for plants from 
> each genotype group?
>
> I am familiar with the "for" command, but I cannot get it to work. Here is my 
> code:
>
> christina= read.table("christina.txt", sep= ",", na= "NA", header= TRUE)
> {for (i in 1:309)
> christina.i= subset(christina, gen == i)
> christina.i.clean= christina.i[,-1]
> christina.matrix.i= as.matrix(christina.i.clean)
> christina.cov.i= cov(christina.matrix.i, y= NULL, use= "complete.obs", 
> method= c("pearson"))
> write.table(christina.cov.i, sep= ",", file= "covariances.csv", row.names= 
> FALSE, col.names= FALSE, append= TRUE)}
>
>
> The problem occurs at my code snippet "gen == i". I want R to insert a number 
> in place of "i", depending on what round of the loop it is on, but R insists 
> that I am literally referring to a genotype class named "i". I have made sure 
> that the column "gen" is numeric, but the same problem persists if I make the 
> column a factor instead.
>
> Any help would be much appreciated, but help that includes sample code would 
> be most useful. Thank you in advance!
>
> Sincerely,
> Josh
>

If you can make your data into a dataframe, you can use something like this:

# might work
christina.df <- as.data.frame(christina)

# this should work, if your ID var ('gen') is the first column in the data frame
by(christina.df, christina.df$gen, function(d) {
d.clean <- d[,-1]
cov(d.clean, y= NULL, use= "complete.obs", method= c("pearson")
} )

for more ideas, see ?by

Cheers,

Dylan

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


Re: [R] Looping over groups

2008-08-20 Thread Peter Dalgaard
Dylan Beaudette wrote:
> On Wed, Aug 20, 2008 at 7:48 AM, Josh B <[EMAIL PROTECTED]> wrote:
>   
>> Hello,
>>
>> My R skills are somewhere between novice and intermediary, and I am hoping 
>> that some of you very helpful forum members, whom I've seen work your magic 
>> on other peoples' problems/questions, can help me here.
>>
>> I have a matrix with the following format:
>>
>> (i) individual plants comprising many different genotype groups (i.e., a 
>> plant is genotype 1 or genotype 2 or genotype 3, etc). The column for 
>> genotypes is called "gen", and the plants are members of genotype class 1 - 
>> 309, with no overlaps (i.e., you're either a genotype 1 or a genotype 
>> something else, but not both) and no missing values.
>> (ii) Various trait measurements taken on the plants, with multiple 
>> replicates per genotype group
>>
>> I want to create a covariance matrix, separately for plants from each 
>> genotype group. I know how to use the command "cov"; my problem is that I 
>> have 309 different genotype groups and so I need to set up some sort of an 
>> automated loop to go through each genotype group and create a separate 
>> covariance matrix based on it.
>>
>> My question is, how do I make a loop to automatically go through and create 
>> these covariance matrices, i.e., a separate covariance matrix for plants 
>> from each genotype group?
>>
>> I am familiar with the "for" command, but I cannot get it to work. Here is 
>> my code:
>>
>> christina= read.table("christina.txt", sep= ",", na= "NA", header= TRUE)
>> {for (i in 1:309)
>> christina.i= subset(christina, gen == i)
>> christina.i.clean= christina.i[,-1]
>> christina.matrix.i= as.matrix(christina.i.clean)
>> christina.cov.i= cov(christina.matrix.i, y= NULL, use= "complete.obs", 
>> method= c("pearson"))
>> write.table(christina.cov.i, sep= ",", file= "covariances.csv", row.names= 
>> FALSE, col.names= FALSE, append= TRUE)}
>>
>>
>> The problem occurs at my code snippet "gen == i". I want R to insert a 
>> number in place of "i", depending on what round of the loop it is on, but R 
>> insists that I am literally referring to a genotype class named "i". I have 
>> made sure that the column "gen" is numeric, but the same problem persists if 
>> I make the column a factor instead.
>>
>> Any help would be much appreciated, but help that includes sample code would 
>> be most useful. Thank you in advance!
>>
>> Sincerely,
>> Josh
>>
>> 
>
> If you can make your data into a dataframe, you can use something like this:
>
> # might work
> christina.df <- as.data.frame(christina)
>
> # this should work, if your ID var ('gen') is the first column in the data 
> frame
> by(christina.df, christina.df$gen, function(d) {
> d.clean <- d[,-1]
> cov(d.clean, y= NULL, use= "complete.obs", method= c("pearson")
> } )
>
> for more ideas, see ?by
>
>   
also

dd <- christina ## just for brevity
lapply(split(dd[-1], dd[1]), cov, use="complete.obs")



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

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


Re: [R] Confidence Interval

2008-08-20 Thread Raphael Saldanha
Thanks Professor and Bernardo,

What I'm trying to do is this: I have a macro for Minitab. His author says
it's a "Monte Carlo simulation to estimate a confidence interval". But and
don't have Minitab, don't like to work with illegal licenses, and LOVE R.
So, I re-write the macro in a R script.

Bellow, is the original macro, for Minitab:

GMACRO

TesteMedia

do K1=1:1000
 random 200 C1;
 normal 100 2.
 mean C1 K2
 let C2(K1)=K2
enddo

sort C2 C3

let K3=C3(25)
let K4=C3(975)
print K3 K4

ENDMACRO

The macro's author think on this way: I have a y vector of sorted means with
1000 registers. So, my CI is between the 25º and 975º element.

So, I ask: Is this a Monte Carlo Simulation, and the nome is correct? The
way to isolate the inferior and superior means is correct?

About the graphics, I know the sample can't be reproduced because it's
random. But, re-running the script some times, I can see, some times,
differences in the right and left tail, under the normal curve. So, I wonder
to know where my code is wrong, but just for know, I agree with histogram
isn't the best way to illustrate confidence interval. I just show him on the
plot to illustrated the sample used. I will re-make the plot, just with the
curve and areas after the confidence interval, without the histogram.


Thanks for the help!






On Wed, Aug 20, 2008 at 12:16 AM, Prof Brian Ripley
<[EMAIL PROTECTED]>wrote:

> On Tue, 19 Aug 2008, Raphael Saldanha wrote:
>
>  Hi!
>>
>> With the following script, I'm trying to make a demonstration of a
>> Confidence Interval, but I'm observing some differences on tails.
>>
>
> You need to tell us what you are trying to do.  You seem to be computing a
> parametric bootstrap interval, but incorrectly (you need to reflect
> percentile intervals).  See Davison & Hinkley (1997) 'The Bootstrap and its
> Application' for more details.
>
> In any case, your simulation is not repeatable (you set no seed), so we
> don't know what you saw and what 'differences' disturbed you.
>
> Your calculation of quantiles is not quite correct: use quantile().
> (The indices go from 1 to 1000, not 0 to 1000.)  E.g.
>
>  quantile(1:1000, c(0.025, 0.975))
>>
>   2.5%   97.5%
>  25.975 975.025
>
> and not 25, 975.
>
> As your results show, a histogram is not a good summary of the shape of a
> distribution on 1000 points.  We can do much better with an ecdf or a
> density estimate.
>
>
>> # Teste de m?dia entre uma amostra e uma popula??o normal
>> # Autor: Raphael de Freitas Saldanha
>> # Agosto de 2008
>>
>> n<- 200# Sample size
>> xbar <- 100# Sample mean
>> s<- 2  # Sample SD
>> nc   <- 0.95   # Confidence level (95% -> 0.95)
>> rep  <- 1000   # Loops
>>
>> ###
>>
>> y <- NULL# Vetor com as m?dias da amostra
>> for (i in 1:rep){# Loop
>> x <- rnorm(n,xbar,s) # Gere uma amostra normal n elementos, xbar m?dia
>> e
>> s desvio-padr?o
>> x <- mean(x) # Calcule a m?dia (exata) dessa amostra
>> y <- c(y,x)  # Coloque essa m?dia em um registro em y
>> }
>>
>> y <- sort(y) # Ordene todas as m?dias geradas
>>
>> LI <- y[((1-nc)/2)*rep] # Limite inferior,
>> LS <- y[rep-(((1-nc)/2)*rep)]   # Limite superior
>>
>> ### PARTE GR?FICA ###
>>
>> x <- mean(y)
>>
>> xvals <- seq(-LI, LI, length.out=5000)
>> dvals <- dnorm(xvals,mean(y), sd(y))[1:5000]
>>
>> xbvals <- seq(LS, LS*2, length.out=5000)
>> dbvals <- dnorm(xbvals,mean(y), sd(y))[1:5000]
>>
>> ahist <- hist(y, freq=FALSE, col="lightblue", main="Intervalo de
>> confian?a")
>>
>> polygon(c(xvals,LI,LI), c(dvals,dnorm(LI,mean(y), sd(y)),min(dvals)),
>> col="orange", lty=0)
>> polygon(c(LS,LS,xbvals), c(min(dbvals),dnorm(LS,mean(y), sd(y)),dbvals),
>> col="orange", lty=0)
>> curve(dnorm(x,mean(y), sd(y)),add=TRUE, lty=1, col="red",lwd=2)
>>
>> ### Intervalo de Confian?a ###
>>
>> LI # Limite inferior
>> LS # Limite superior
>>
>> --
>> Atenciosamente,
>>
>> Raphael Saldanha
>> [EMAIL PROTECTED]
>>
>>[[alternative HTML version deleted]]
>>
>>
>>
> --
> Brian D. Ripley,  [EMAIL PROTECTED]
> Professor of Applied Statistics,  
> http://www.stats.ox.ac.uk/~ripley/
> University of Oxford, Tel:  +44 1865 272861 (self)
> 1 South Parks Road, +44 1865 272866 (PA)
> Oxford OX1 3TG, UKFax:  +44 1865 272595
>



-- 
Atenciosamente,

Raphael Saldanha
[EMAIL PROTECTED]
Robert Orben  - "To err is human - and to blame it on a computer is even
more so."

[[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] Looping over groups

2008-08-20 Thread Dylan Beaudette
On Wed, Aug 20, 2008 at 7:48 AM, Josh B <[EMAIL PROTECTED]> wrote:
> Hello,
>
> My R skills are somewhere between novice and intermediary, and I am hoping 
> that some of you very helpful forum members, whom I've seen work your magic 
> on other peoples' problems/questions, can help me here.
>
> I have a matrix with the following format:
>
> (i) individual plants comprising many different genotype groups (i.e., a 
> plant is genotype 1 or genotype 2 or genotype 3, etc). The column for 
> genotypes is called "gen", and the plants are members of genotype class 1 - 
> 309, with no overlaps (i.e., you're either a genotype 1 or a genotype 
> something else, but not both) and no missing values.
> (ii) Various trait measurements taken on the plants, with multiple replicates 
> per genotype group
>
> I want to create a covariance matrix, separately for plants from each 
> genotype group. I know how to use the command "cov"; my problem is that I 
> have 309 different genotype groups and so I need to set up some sort of an 
> automated loop to go through each genotype group and create a separate 
> covariance matrix based on it.
>
> My question is, how do I make a loop to automatically go through and create 
> these covariance matrices, i.e., a separate covariance matrix for plants from 
> each genotype group?
>
> I am familiar with the "for" command, but I cannot get it to work. Here is my 
> code:
>
> christina= read.table("christina.txt", sep= ",", na= "NA", header= TRUE)
> {for (i in 1:309)
> christina.i= subset(christina, gen == i)
> christina.i.clean= christina.i[,-1]
> christina.matrix.i= as.matrix(christina.i.clean)
> christina.cov.i= cov(christina.matrix.i, y= NULL, use= "complete.obs", 
> method= c("pearson"))
> write.table(christina.cov.i, sep= ",", file= "covariances.csv", row.names= 
> FALSE, col.names= FALSE, append= TRUE)}
>
>
> The problem occurs at my code snippet "gen == i". I want R to insert a number 
> in place of "i", depending on what round of the loop it is on, but R insists 
> that I am literally referring to a genotype class named "i". I have made sure 
> that the column "gen" is numeric, but the same problem persists if I make the 
> column a factor instead.
>
> Any help would be much appreciated, but help that includes sample code would 
> be most useful. Thank you in advance!
>
> Sincerely,
> Josh
>

If you can make your data into a dataframe, you can use something like this:

# might work
christina.df <- as.data.frame(christina)

# this should work, if your ID var ('gen') is the first column in the data frame
by(christina.df, christina.df$gen, function(d) {
d.clean <- d[,-1]
cov(d.clean, y= NULL, use= "complete.obs", method= c("pearson")
} )

for more ideas, see ?by

Cheers,

Dylan

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

2008-08-20 Thread Jorge W. Cardoso
I'm writing a C++ application using R-embedding to do some
forecast process.

I also use R_tryEval instead of R_Eval to run my R-script,
so that in case of error I know exactly in which line number
was the last error.

In particular, from time in time y get some error messages
refering an exceptional condition in the arima model.

I want to catch these error messages from de C code 
(or at least the code error number) to take some 
corrective actions.

Is there any way to do that ?

Regards,

Jorge W. Cardoso

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

2008-08-20 Thread Josh B
Hello,

My R skills are somewhere between novice and intermediary, and I am hoping that 
some of you very helpful forum members, whom I've seen work your magic on other 
peoples' problems/questions, can help me here.

I have a matrix with the following format:

(i) individual plants comprising many different genotype groups (i.e., a plant 
is genotype 1 or genotype 2 or genotype 3, etc). The column for genotypes is 
called "gen", and the plants are members of genotype class 1 - 309, with no 
overlaps (i.e., you're either a genotype 1 or a genotype something else, but 
not both) and no missing values.
(ii) Various trait measurements taken on the plants, with multiple replicates 
per genotype group

I want to create a covariance matrix, separately for plants from each genotype 
group. I know how to use the command "cov"; my problem is that I have 309 
different genotype groups and so I need to set up some sort of an automated 
loop to go through each genotype group and create a separate covariance matrix 
based on it.

My question is, how do I make a loop to automatically go through and create 
these covariance matrices, i.e., a separate covariance matrix for plants from 
each genotype group?

I am familiar with the "for" command, but I cannot get it to work. Here is my 
code:

christina= read.table("christina.txt", sep= ",", na= "NA", header= TRUE)
{for (i in 1:309)
christina.i= subset(christina, gen == i)
christina.i.clean= christina.i[,-1]
christina.matrix.i= as.matrix(christina.i.clean)
christina.cov.i= cov(christina.matrix.i, y= NULL, use= "complete.obs", method= 
c("pearson"))
write.table(christina.cov.i, sep= ",", file= "covariances.csv", row.names= 
FALSE, col.names= FALSE, append= TRUE)}


The problem occurs at my code snippet "gen == i". I want R to insert a number 
in place of "i", depending on what round of the loop it is on, but R insists 
that I am literally referring to a genotype class named "i". I have made sure 
that the column "gen" is numeric, but the same problem persists if I make the 
column a factor instead.

Any help would be much appreciated, but help that includes sample code would be 
most useful. Thank you in advance!

Sincerely,
Josh

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


Re: [R] nonlinear constrained optimization

2008-08-20 Thread Paul Smith
On Tue, Aug 19, 2008 at 7:37 PM, Ravi Varadhan <[EMAIL PROTECTED]> wrote:
> The "Tango project" website (from Brazil) has some R functions to implement
> Algencan.  I haven't used it, but I would be interested to hear others'
> experience if someone has already used it or will be using it.

Ravi,

The last beta version of Algencan has now a R interface, which I have
used. It seems to work fine.

Maybe someone will one day embody it in R itself.

Paul

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


Re: [R] arma: what is the meaning of Pr(>|t|)?

2008-08-20 Thread Prof Brian Ripley

On Wed, 20 Aug 2008, Prof Brian Ripley wrote:


On Wed, 20 Aug 2008, Alberto Monteiro wrote:


In the summary of the output of arma, there's a number Pr(>|t|), however, I
don't know what is its meaning - at least, it doesn't _seem_ to be a
Student's t distribution.


It is using asymptotic normality.  There is no exact theory.  Who mentioned 
Student's t?



Reproducible test case:
 x <- c(0.5, sin(1:9))
 reg <- arma(x, c(1,0))
 summary(reg)


Call:
arma(x = x, order = c(1, 0))

Model:
ARMA(1,0)

Residuals:
   Min  1Q  Median  3Q Max
-0.9217 -0.4915  0.2254  0.4580  0.7481

Coefficient(s):
  Estimate  Std. Error  t value Pr(>|t|)
ar1  0.6089  0.24902.446   0.0145 *
intercept0.0790  0.18150.435   0.6634
---
Signif. codes:  0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1

Fit:
sigma^2 estimated as 0.3348,  Conditional Sum-of-Squares = 2.68,  AIC = 
21.44



Now, 2.446 is 0.6089 / 0.2490, but 0.0145 is not
2 * (1 - pt(2.446, df = 7))

(I think there are seven degrees of freedom: the first value of
the series x is deterministic, and two degrees are lost in the
estimation of ar1 and intercept)


Why is the first value deterministic?  This is not a conditional mle (see the 
help page).


It is a conditional SSq, so perhaps you meant 'held constant'?


What am I misunderstanding?

BTW, a similar example:
x <- 1:10
y <- sin(x)
reg <- lm(y ~ x)
summary(reg)

will give a t-value for 'x' = 0.704 with P(>|t|) = 0.501,
which is 2 * (1 - pt(0.704, df=8))

Alberto Monteiro

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

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



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



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

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


Re: [R] arma: what is the meaning of Pr(>|t|)?

2008-08-20 Thread Prof Brian Ripley

On Wed, 20 Aug 2008, Alberto Monteiro wrote:


In the summary of the output of arma, there's a number Pr(>|t|), however, I
don't know what is its meaning - at least, it doesn't _seem_ to be a
Student's t distribution.


It is using asymptotic normality.  There is no exact theory.  Who 
mentioned Student's t?



Reproducible test case:
 x <- c(0.5, sin(1:9))
 reg <- arma(x, c(1,0))
 summary(reg)


Call:
arma(x = x, order = c(1, 0))

Model:
ARMA(1,0)

Residuals:
   Min  1Q  Median  3Q Max
-0.9217 -0.4915  0.2254  0.4580  0.7481

Coefficient(s):
  Estimate  Std. Error  t value Pr(>|t|)
ar1  0.6089  0.24902.446   0.0145 *
intercept0.0790  0.18150.435   0.6634
---
Signif. codes:  0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1

Fit:
sigma^2 estimated as 0.3348,  Conditional Sum-of-Squares = 2.68,  AIC = 21.44


Now, 2.446 is 0.6089 / 0.2490, but 0.0145 is not
2 * (1 - pt(2.446, df = 7))

(I think there are seven degrees of freedom: the first value of
the series x is deterministic, and two degrees are lost in the
estimation of ar1 and intercept)


Why is the first value deterministic?  This is not a conditional mle (see 
the help page).



What am I misunderstanding?

BTW, a similar example:
x <- 1:10
y <- sin(x)
reg <- lm(y ~ x)
summary(reg)

will give a t-value for 'x' = 0.704 with P(>|t|) = 0.501,
which is 2 * (1 - pt(0.704, df=8))

Alberto Monteiro

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



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

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


Re: [R] Survey Design / Rake questions

2008-08-20 Thread Stas Kolenikov
On Mon, Aug 18, 2008 at 6:18 PM, Farley, Robert <[EMAIL PROTECTED]> wrote:
> My motivation is to try to correct for a "time on board" bias we see in
> our surveys.  Not surprisingly, riders who are only on board a short
> time don't attempt/finish our survey forms.  We're able to weight our
> survey to the "bus stop-on by bus run" level.

So is it the problem of catching the short rides in your sample, or
the problem of having those short rides complete the survey? If the
former, then all you have to do is to weight by inverse probability of
selection (Horvitz-Thompson estimator). This probability is probably
roughly proportional to time on bus, which in turn might be
proportional to the number of stops in their ride. You may not need
any raking for that, just do some algebra computing those
probabilities of selection.

If the latter is the problem, then it is the problem of non-response.
If you think that the only thing that matters in whether a person
chooses to respond or not is the length of the ride, then your data
are "missing at random" (MAR), one of several standard concepts in the
missing data statistics
(http://www.citeulike.org/user/ctacmo/article/553290). You can bypass
that -- in survey statistics, that will be done with weights, again.
Here, you would need to boost the weight by the inverse fraction of
those who did complete the survey.

In a more difficult situation, your response probability might depend
on other factors, say demographics of the passengers, time of the day,
etc. I would imagine you would still have MAR data, unless you have
some weird questions like "Do you carry firearms on the bus?" to which
the people who did have guns at the time of their ride would probably
decline to answer, making the data informatively missing/not missing
at random (NMAR).

-- 
Stas Kolenikov, also found at http://stas.kolenikov.name
Small print: I use this email account for mailing lists only.

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

2008-08-20 Thread hadley wickham
On Wed, Aug 20, 2008 at 7:56 AM, Alberto Monteiro
<[EMAIL PROTECTED]> wrote:
>
> Jaap Van Wyk wrote:
>>
>> I would appreciate any help with the following.
>> Problem: Suppose A, B and C are independent U(0,1) random variables.
>> What is the probability that A(x^2) + Bx + C has real roots? I have
>> done the theoretical work and obtained an answer of 1/9 = 0..
>> Now I want to show my students to get this in R with simulation.
>> Below are two attemps, both giving the answer to be about 0.26.
>>
>> Could anybody please help me with providing a more elegant way to do
>> this? (I am still learning R and trying to get my students to learn
>> it as well. I know there must be a better way to get this.) I must
>> be doing something wrong ?
>>
> Always think that R is vector-oriented, so you should think
> in terms of vectors.
>
> A simple solution for your problem would be:
>
> n <- 1
> # n <- 1? Make n <- 100 !
> n <- 100
> a <- runif(n)  # a vector of n unifs
> b <- runif(n)
> c <- runif(n)
> delta <- b^2 - 4 * a * c # a vector of deltas
>
> # The answer then is how many deltas are non-negative:
>
> sum(delta > 0) / length(delta)

Which can be even more succinctly expressed as
mean(delta > 0)

It's also often informative to plot the running estimate so you have
some idea whether or not you've done enough samples:

plot(cumsum(delta > 0) / seq_along(delta), type="l")

Hadley

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

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


Re: [R] Simple estimate of a probability by simulation

2008-08-20 Thread N'DOYE Souleymane
Greetings,

Let me present my modest proposition as function with an input and an
output, it is based on the valuable solution of Alberto Monteiro. I have
choosen delta superior or equal to 0 wich still provide a REAL solution :

prob <- function(n){

a <- runif(n)
b <- runif(n)
c <- runif(n)
delta <- b^2 - 4 * a * c # a vector of deltas

sum(delta >= 0) / length(delta)

return(p = sum(delta >= 0) / length(delta))
}

# To test
> prob(1000)
[1] 0.232
> prob(10)
[1] 0.25308
> prob(1000)
[1] 0.2544715

Best regards,

Souleymane N'DOYE, M.Sc.
Statistician Engineer & Decision Support System Consultant, French.
www.labstatconseil.com
[EMAIL PROTECTED]
P.O. Box 1601 – 00606 Sarit Center, Nairobi, Kenya
Mobile : +254 736 842 478.

On Wed, Aug 20, 2008 at 3:56 PM, Alberto Monteiro
<[EMAIL PROTECTED]>wrote:

>
> Jaap Van Wyk wrote:
> >
> > I would appreciate any help with the following.
> > Problem: Suppose A, B and C are independent U(0,1) random variables.
> > What is the probability that A(x^2) + Bx + C has real roots? I have
> > done the theoretical work and obtained an answer of 1/9 = 0..
> > Now I want to show my students to get this in R with simulation.
> > Below are two attemps, both giving the answer to be about 0.26.
> >
> > Could anybody please help me with providing a more elegant way to do
> > this? (I am still learning R and trying to get my students to learn
> > it as well. I know there must be a better way to get this.) I must
> > be doing something wrong ?
> >
> Always think that R is vector-oriented, so you should think
> in terms of vectors.
>
> A simple solution for your problem would be:
>
> n <- 1
> # n <- 1? Make n <- 100 !
> n <- 100
> a <- runif(n)  # a vector of n unifs
> b <- runif(n)
> c <- runif(n)
> delta <- b^2 - 4 * a * c # a vector of deltas
>
> # The answer then is how many deltas are non-negative:
>
> sum(delta > 0) / length(delta)
>
> # Explanation
> b^2 is the vector of the squares of b's
> a * c does the pointwise product of vectors
> delta > 0 is a logical array with TRUE or FALSE
> sum(delta > 0) coerces TRUE to 1 and FALSE to 0
> length(delta) is the length of delta (n)
>
> Alberto Monteiro
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] How to solve this problem ?

2008-08-20 Thread Daren Tan

I have disabled html text editing mode, thanks to Prof. Ripley for the kind 
reminder. 

Given three geological devices that takes 5 readings at 4 environmental 
conditions (A to D). What will be the proper approach to select the most 
reliable device ? 

m1 <- c(73,52,49,53,83,43,58,94,53,62,75,66,41,72,70,75,57,59,85,84)
m2 <- c(31,38,30,35,36,26,27,38,22,31,24,35,36,31,38,33,32,28,33,30)
m3 <- c(65,57,36,40,36,30,40,34,37,40,33,33,37,29,37,37,30,33,40,35)

names(m1) <- rep(LETTERS[1:4], each=5)
names(m2) <- rep(LETTERS[1:4], each=5)
names(m3) <- rep(LETTERS[1:4], each=5)

Before writing this email, I have tried to compare the sd for each device at 
each condition, but ran into obstacle on how to formulate the null hypothesis. 
Alternative solution tried was ANOVA, I am unsure whether it can help, as it 
compares the differences in means of each group. 

Thanks

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


Re: [R] arma: what is the meaning of Pr(>|t|)?

2008-08-20 Thread Peter Dalgaard
Alberto Monteiro wrote:
> In the summary of the output of arma, there's a number Pr(>|t|), however, I 
> don't know what is its meaning - at least, it doesn't _seem_ to be a 
> Student's t distribution.
>
> Reproducible test case:
>   x <- c(0.5, sin(1:9))
>   reg <- arma(x, c(1,0))
>   summary(reg)
>   
Not quite. You forgot library(tseries).
> 
> Call:
> arma(x = x, order = c(1, 0))
>
> Model:
> ARMA(1,0)
>
> Residuals:
> Min  1Q  Median  3Q Max 
> -0.9217 -0.4915  0.2254  0.4580  0.7481 
>
> Coefficient(s):
>Estimate  Std. Error  t value Pr(>|t|)  
> ar1  0.6089  0.24902.446   0.0145 *
> intercept0.0790  0.18150.435   0.6634  
> ---
> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 
>
> Fit:
> sigma^2 estimated as 0.3348,  Conditional Sum-of-Squares = 2.68,  AIC = 21.44
> 
>
> Now, 2.446 is 0.6089 / 0.2490, but 0.0145 is not 
> 2 * (1 - pt(2.446, df = 7))
>
> (I think there are seven degrees of freedom: the first value of
> the series x is deterministic, and two degrees are lost in the
> estimation of ar1 and intercept)
>
> What am I misunderstanding?
>
>   
That when at least some people say _asymptotic_ they effectively set the
df to Inf and use the normal distribution

> 2*pnorm(-2.446)
[1] 0.0144451

(Personally, I prefer to call the test statistic "z" in such cases, but
traditions vary. Some use "t" for any quantity divided by its standard
error, others use it only when they intend to refer it to the t
distribution.)

I would expect that the "correct" df are not all that easy to come by;
with correlated data, the asymptotic theory is nontrival, and the exact
distribution of "t" is likely not a t distribution, although it sounds
likely that a t distribution with about 7 df would come closer than the
normal distribution. However, the whole thing is not really designed for
very short time series.


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

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


Re: [R] Simple estimate of a probability by simulation

2008-08-20 Thread Alberto Monteiro

Jaap Van Wyk wrote:
> 
> I would appreciate any help with the following. 
> Problem: Suppose A, B and C are independent U(0,1) random variables. 
> What is the probability that A(x^2) + Bx + C has real roots? I have 
> done the theoretical work and obtained an answer of 1/9 = 0.. 
> Now I want to show my students to get this in R with simulation. 
> Below are two attemps, both giving the answer to be about 0.26.
> 
> Could anybody please help me with providing a more elegant way to do 
> this? (I am still learning R and trying to get my students to learn 
> it as well. I know there must be a better way to get this.) I must 
> be doing something wrong ?
> 
Always think that R is vector-oriented, so you should think
in terms of vectors.

A simple solution for your problem would be:

n <- 1
# n <- 1? Make n <- 100 !
n <- 100
a <- runif(n)  # a vector of n unifs
b <- runif(n)
c <- runif(n)
delta <- b^2 - 4 * a * c # a vector of deltas

# The answer then is how many deltas are non-negative:

sum(delta > 0) / length(delta)

# Explanation
b^2 is the vector of the squares of b's
a * c does the pointwise product of vectors
delta > 0 is a logical array with TRUE or FALSE
sum(delta > 0) coerces TRUE to 1 and FALSE to 0
length(delta) is the length of delta (n)

Alberto Monteiro

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


Re: [R] bug in lme4?

2008-08-20 Thread Renaud Lancelot
Thank you very much !

Renaud

2008/8/20 Peter Dalgaard <[EMAIL PROTECTED]>

> Renaud Lancelot wrote:
> > Dear all,
> >
> > As the maintener of package aod, I thank you for bringing my attention on
> > this problem. I will try to alter the code in aod. However, I am not sure
> to
> > be able to do it right now.
> >
> Looks like it should be fairly easy:
>
> Get rid of
> setMethod(f = "AIC", signature = "logLik", ...etc...
>
> Instead, define a (local) function, say AIC1(), and use that inside
>
> setMethod(f = "AIC", signature = "glimML", 
>
> Redefining methods from stats is just a bad idea. Packages might protect
> themselves from it, but command-line behaviour of AIC(ll) is also affected.
>
>
> > Best regards,
> >
> > Renaud
> >
> > 2008/8/20 Martin Maechler <[EMAIL PROTECTED]>
> >
> >
> >>>   <[EMAIL PROTECTED]>
> >>> on Wed, 20 Aug 2008 03:03:29 +0100 writes:
> >>>
> >>> Dear all,
> >>> I found a problem with 'lme4'. Basically, once you load the package
> >> 'aod' (Analysis of Overdispersed Data), the functions 'lmer' and 'glmer'
> >> don't work anymore:
> >>
> >>> library(lme4)
> >>> (fm1 <- lmer(Reaction ~ Days + (Days|Subject), sleepstudy))
> >>> (gm1 <- glmer(cbind(incidence, size - incidence) ~ period + (1 |
> >> herd),
> >>> family = binomial, data = cbpp))
> >>> install.packages("aod")
> >>> library(aod)
> >>> (fm1 <- lmer(Reaction ~ Days + (Days|Subject), sleepstudy))
> >>> (gm1 <- glmer(cbind(incidence, size - incidence) ~ period + (1 |
> >> herd),
> >>> family = binomial, data = cbpp))
> >>
> >>> Taking into account that this package is used to perform
> >>> similar analyses, this could be a problem.
> >>
> >> It is a problem, and it *is* a bug;
> >> thank you for reporting it, Antonio.
> >>
> >> Since lme4 uses a NAMESPACE, it could and probably should make
> >> sure to protect itself from incompatible function redefinitions
> >> such as the one the  'aod' package "provides" :
> >>
> >> Arguably, the bug is really in package 'aod' rather than 'lme4':
> >> 'aod' redefines the AIC() method for 'logLik' objects in a not quite
> >> backward-compatible way:
> >>
> >> The standard method (S3 alas, in package 'stats') is
> >>
> >>   > stats:::AIC.logLik
> >>   function (object, ..., k = 2)
> >>   -2 * c(object) + k * attr(object, "df")
> >>   
> >>
> >> The redefinition from package 'aod' is
> >>
> >>   > selectMethod(AIC, "logLik")
> >>   Method Definition:
> >>
> >>   function (object, ..., k = 2)
> >>   {
> >>   npar <- attr(object, "df")
> >>   nobs <- attr(object, "nobs")
> >>   c(AIC = -2 * c(object) + k * npar, AICc = -2 * c(object) +
> >>   k * npar + 2 * npar * (npar + 1)/(nobs - npar - 1))
> >>   }
> >>   
> >>
> >>   Signatures:
> >>   object
> >>   target  "logLik"
> >>   defined "logLik"
> >>
> >> which returns a (named) numeric vector of length 2,
> >> and the code in lme4 was expecting length 1.
> >>
> >> As a matter of fact, I even like the idea to extend AIC() to
> >> also compute newer versions of AIC; but probably 'aod' should
> >> have done so in a different way {maybe with an additional
> >> 'kind' argument to the method}.
> >>
> >> Martin
> >>
> >>> All the best
> >>
> >>> Antonio Gasparrini
> >>> Public and Environmental Health Research Unit (PEHRU)
> >>> London School of Hygiene & Tropical Medicine
> >>> Keppel Street, London WC1E 7HT, UK
> >>> Office: 0044 (0)20 79272406 - Mobile: 0044 (0)79 64925523
> >>> http://www.lshtm.ac.uk/people/gasparrini.antonio (
> >> http://www.lshtm.ac.uk/pehru/ )
> >>
> >> __
> >> R-help@r-project.org mailing list
> >> https://stat.ethz.ch/mailman/listinfo/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.
> >
>
>
> --
>O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
>  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
>  (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
> ~~ - ([EMAIL PROTECTED])  FAX: (+45) 35327907
>
>
>


-- 
Renaud LANCELOT
Département Systèmes Biologiques du CIRAD
CIRAD, Biological Systems Department

Campus International de Baillarguet
TA 30 / B
F34398 Montpellier
Tel +33 (0)4 67 59 37 17
Secr. +33 (0)4 67 59 37 37
Fax +33 (0)4 67 59 37 95

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https:

[R] Simple estimate of a probability by simulation

2008-08-20 Thread Van Wyk, Jaap
Hallo
 
I would appreciate any help with the following. 
Problem: Suppose A, B and C are independent U(0,1) random variables. What is 
the probability that A(x^2) + Bx + C has real roots?
I have done the theoretical work and obtained an answer of 1/9 = 0..
Now I want to show my students to get this in R with simulation.
Below are two attemps, both giving the answer to be about 0.26.
 
Could anybody please help me with providing a more elegant way to do this? (I 
am still learning R and trying to get my students to learn it as well. I know 
there must be a better way to get this.) I must be doing something wrong ?
 
n <- 1
### Method 1 ###
cnt <- rep(0,n)
for (i in (1:n)) {
   a <- runif(1)
   b <- runif(1)
   c <- runif(1)
   cnt[i] <- ifelse(((b^2)>4*a*c),1,0)
}
sum(cnt)/n
### Method 2 ###
one.s <- function(x) {
  ret <- ifelse(((x[2]^2) > 4 * x[1] * x[3]),1,0)
  ret
}
m <- cbind(runif(n),runif(n),runif(n))
sum(apply(m,1,one.s))/n
##
 
THANK YOU.
Jacob L van Wyk
Dept of Statistics
University of Johannesburg
P O Box 524
Auckland Park 2006
South Africa
Tel: +27-11-559-3080
Fax: +27-11-559-2832
Cell: +27-82-859-2031

[[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] arma: what is the meaning of Pr(>|t|)?

2008-08-20 Thread Alberto Monteiro
In the summary of the output of arma, there's a number Pr(>|t|), however, I 
don't know what is its meaning - at least, it doesn't _seem_ to be a 
Student's t distribution.

Reproducible test case:
  x <- c(0.5, sin(1:9))
  reg <- arma(x, c(1,0))
  summary(reg)


Call:
arma(x = x, order = c(1, 0))

Model:
ARMA(1,0)

Residuals:
Min  1Q  Median  3Q Max 
-0.9217 -0.4915  0.2254  0.4580  0.7481 

Coefficient(s):
   Estimate  Std. Error  t value Pr(>|t|)  
ar1  0.6089  0.24902.446   0.0145 *
intercept0.0790  0.18150.435   0.6634  
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 

Fit:
sigma^2 estimated as 0.3348,  Conditional Sum-of-Squares = 2.68,  AIC = 21.44


Now, 2.446 is 0.6089 / 0.2490, but 0.0145 is not 
2 * (1 - pt(2.446, df = 7))

(I think there are seven degrees of freedom: the first value of
the series x is deterministic, and two degrees are lost in the
estimation of ar1 and intercept)

What am I misunderstanding?

BTW, a similar example:
x <- 1:10
y <- sin(x)
reg <- lm(y ~ x)
summary(reg)

will give a t-value for 'x' = 0.704 with P(>|t|) = 0.501,
which is 2 * (1 - pt(0.704, df=8))

Alberto Monteiro

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


Re: [R] Time Series w/irregular frequency, how to construct a time series object?

2008-08-20 Thread Gabor Grothendieck
The zoo package can represent irregular time series.

On Wed, Aug 20, 2008 at 4:41 AM, Marco Leandro Carmosino
<[EMAIL PROTECTED]> wrote:
> Hello,
>
> I am having trouble constructing a time series object for my data. This is
> because the frequency is irregular: one year, there may be only 100
> individuals, another 200. There are 100 measurements for every individual. I
> have the observations in a data frame with the year that they were taken from
> as a factor.
>
> I would like to plot the top 10 mean measurements for each year and connect 
> them
> with a line, to measurements in the same category. I would also like to try
> using linear filtering and exponential smoothing on the measurements to look
> for patterns, in particular synchronized drastic changes in measurement 
> values.
>
> Are all the time-series analysis functions inappropriate because of the
> irregular frequency in my data? I looked at the reference manual, and it seems
> that even building the tsp attribute manually would require providing a
> frequency argument. It's quite possible that I have some very wrong ideas 
> about
> time series analysis, as I am just beginning to study the subject.
>
> Thanks for any help,
>
> --Marco
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

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


[R] How to concatenate values from a time series and a forecast

2008-08-20 Thread Lane, Jim
Hi, All

I have a time series object:

o1ts
 Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
2005  56  58  67  68  69  71  78  78
2006  84  83  86  97 103 123 120 134 131 127 135 137
2007 142 138 141 151 155 173 181 188 195 191 262 273
2008 283 295 311 327 334 340 361 

And a forecast derived from it:

> o1fa
 Point Forecast Lo 95 Hi 95
Aug 2009374   349   398
Sep 2009386   350   423
Oct 2009399   352   446
Nov 2009412   354   469
Dec 2009424   357   492
Jan 2009437   359   515
Feb 2009450   361   538
Mar 2009463   364   562
Apr 2009475   366   585
May 2009488   367   609
Jun 2009501   369   633
Jul 2010513   370   657
Aug 2010526   371   681
Sep 2010539   372   705
Oct 2010552   373   730
Nov 2010564   373   755
Dec 2010577   373   780
Jan 2010590   373   806
Feb 2010602   373   832
Mar 2010615   373   857
Apr 2010628   372   884
May 2010640   371   910
Jun 2010653   370   936
Jul 2010666   368   963

I would like to get a single data frame combining the actual values from
the time series with the predicted values from the forecast, each value
with the corresponding month. How could I do this? 

TIA

-Jim Lane
___

This e-mail may be privileged and/or confidential, and the sender does not 
waive any related rights and obligations.
Any distribution, use or copying of this e-mail or the information it contains 
by other than an intended recipient is unauthorized.
If you received this e-mail in error, please advise me (by return e-mail or 
otherwise) immediately.  

Ce courrier électronique est confidentiel et protégé. L'expéditeur ne renonce 
pas aux droits et obligations qui s'y rapportent.
Toute diffusion, utilisation ou copie de ce message ou des renseignements qu'il 
contient par une personne autre que le (les) destinataire(s) désigné(s) est 
interdite.
Si vous recevez ce courrier électronique par erreur, veuillez m'en aviser 
immédiatement, par retour de courrier électronique ou par un autre moyen.

[[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] pdf filenames in while loop

2008-08-20 Thread Barry Rowlingson
2008/8/20 Wesley Roberts <[EMAIL PROTECTED]>:
> Dear R users,

> pdf(file="as.character(paste(f.mat[a])).pdf")

Whoa! Why the quotes? And why the as.character? Just paste:

 pdf(file=paste(f.mat[a],".pdf",sep=""))

 should do it. It looks like you were trying to create a file called
"as.character(...etc".

Barry

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


[R] centroid of radial.plot differs from centroid.polygon

2008-08-20 Thread Stefan Uhmann

Dear R-Helpers,

I need the centroid of circular data and (because the function used does 
not provide the centroid coordinates, or did I miss sth.?) tried it via 
the indirect way and just computed the cartesian coordinates:


>>>
library(plotrix)
library(maps)

#generate data
data1<-matrix(c(1.8,1.5,1.2,0.9,0.0,-0.9,-0.6,0.3)+1.2,nrow=1)
#radial plot
radial.plot(data1,labels=paste("Dim",1:8,sep=""),rp.type="s",
main="test",show.grid=TRUE, radial.lim=c(0,3.5), show.centroid=TRUE, 
clockwise=T)

#compute cartesian coordinates
deg1<-seq(from=0,to=7,by=1)*pi/4
x=(data1)*cos(2*pi-deg1)
y=(data1)*sin(2*pi-deg1)
#print cartesian points (of polygon)
points(x,y,pch=18)
#print cartesian centroid
points(matrix(centroid.polygon(cbind(as.vector(x),as.vector(y))), 
nrow=1), pch=17)

>>>

My problem is, that the centroid computed by the radial.plot-function 
(big unfilled circle) is somewhat different from the one computed 'by 
hand' using cartesian coordiantes and centroid.polygon (small triangle). 
I would really appreciate any suggestions how to obtain the correct 
centroid and what is wrong here.


Thanks,
Stefan

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

2008-08-20 Thread N'DOYE Souleymane
Dear all,

My email address has changed today to [EMAIL PROTECTED]

Best regards,

Souleymane

[[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] spatial probit/logit for prediction

2008-08-20 Thread Roger Bivand
Freeman, Robert  emcc.edu> writes:

> I am wondering if there is a way to do a spatial error probit/logit 
> model in R?  I can't seem to find it in any of
> the packages.  I can do it in MATLAB with Gibbs sampling, but would 
> like to confirm the results.  Ideally I
> would like to use this model to predict probability of parcel 
> conversion in a future time period.  This
> seems especially difficult in a binary outcome model setting.  

There are no such functions (as far as I know) in any package on CRAN 
for a spatial weights matrix based approach based say on contiguities. 
You could consider asking on the R-sig-geo list, and/or reviewing 
http://leg.ufpr.br/Rcitrus/, which may prove helpful (especially 
if you know Portuguese). 

Roger

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


Re: [R] converting coordinates from utm to longitude / latitude

2008-08-20 Thread Werner Wernersen
I forgot one more potentially time-saving hint if someone else wants to use 
org2org for such a conversion: 
I found that only GDAL for Windows 1.4.4 works together with the proj.dll file 
which is downloadable from proj.4 but version 1.5 does not. 



- Ursprüngliche Mail 
Von: Dylan Beaudette <[EMAIL PROTECTED]>
An: r-help@r-project.org
CC: Werner Wernersen <[EMAIL PROTECTED]>
Gesendet: Dienstag, den 19. August 2008, 23:29:34 Uhr
Betreff: Re: [R] converting coordinates from utm to longitude / latitude

If you would like to convert the entire shapfile check out GDAL:

http://www.gdal.org/

http://casoilresource.lawr.ucdavis.edu/drupal/node/98

Cheers,

Dylan


On Tuesday 19 August 2008, Werner Wernersen wrote:
> It would be nicer to convert directly the entire shapefile object to
> long/lat coordinates but if that is not possible, I will convert the other
> points to UTM. Hence, I am playing around with rgdal.
>
> library(rgdal)
> SP <- SpatialPoints(cbind(32.29252, -0.3228500),
>   proj4string=CRS("+proj=longlat"))
> spTransform(SP, CRS("+proj=utm +zone=36"))
>
> > spTransform(SP, CRS("+proj=utm +zone=36"))
>
> SpatialPoints:
>  coords.x1 coords.x2
> [1,]  421274.4 -35687.37
> Coordinate Reference System (CRS) arguments: +proj=utm +zone=36
> +ellps=WGS84
>
> This result corresponds with what I get when using convUL() but my map of
> that area in UTM coordinates does not extend to the negative. An external
> program converts the point to x=420994   y=9964407 which also seems correct
> with respect to the map. Fore sure, I am using the function wrongly
> somehow. Can anyone give me a hint?
>
> That's very much appreciated!
>
> Thanks,
>Werner
>
>
>
> - Ursprüngliche Mail 
> Von: Werner Wernersen <[EMAIL PROTECTED]>
> An: [EMAIL PROTECTED]
> Gesendet: Dienstag, den 19. August 2008, 20:28:29 Uhr
> Betreff: converting coordinates from utm to longitude / latitude
>
> Hi,
>
> is there a function in R to convert data read with read.shape and which is
> originally in UTM coordinates into longitude / latitude coordinates? I
> found the convUL() function from the PBSmapping package but I have no idea
> how I could apply that to the read.shape object.
>
> Many thanks,
>   Werner
>
>
> __
> fügt über einen herausragenden Schutz gegen Massenmails.
> http://mail.yahoo.com
>
>
> __
> Do
> ragenden Schutz gegen Massenmails.
> http://mail.yahoo.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.



-- 
Dylan Beaudette
Soil Resource Laboratory
http://casoilresource.lawr.ucdavis.edu/
University of California at Davis
530.754.7341


__
Do You Yahoo!?
Sie sind
Massenmails. 
http://mail.yahoo.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] spatial probit/logit for prediction

2008-08-20 Thread Torsten Hothorn


Hi Robb,

the gamboost() function in package `mboost' may help. The details
are described in

@article{Kneib+Hothorn+Tutz:2009,
  author = {Thomas Kneib and Torsten Hothorn and Gerhard Tutz},
  title = {Variable Selection and Model Choice in Geoadditive Regression 
Models},
  journal = {Biometrics},
  year = {2009},
  note = {Accepted}
}

(preprint available from http://epub.ub.uni-muenchen.de/2063/)

Best wishes,

Torsten

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


[R] pdf filenames in while loop

2008-08-20 Thread Wesley Roberts
Dear R users,

I am a remote sensing researcher currently studying the use of LiDAR data for 
quantifying tree height, in particular I would like to determine the sample 
size needed to capture and quantify canopy height variability. To do this I 
have employed the use of automap(), which automatically calculates variograms 
including reporting the range of the variogram. The program is easy to use and 
I have had much success with it. However, I have run into a  slight problem. My 
analysis consists of 60 independent plots located in our study area and I wish 
to run the variogram analyses for each plot and then write the resulting plot 
to a pdf file. Given that I have 60 plots I would like to vary the name of each 
file based on the plot being processed, see my code below. I have tried a 
number of different approaches using the paste() command but cant seem to get 
it to work.

Currently, as.character does not seem to solve the problem

pdf(file="as.character(paste(f.mat[a])).pdf")

alternatively I could write out to JPEG but I would rather not take that 
approach or I could write all pdf plots to one file but I am not sure how to do 
this.

Could someone suggest a solution?

I am using R version 2.7.1 (2008-06-23) on Ubuntu 7.10.

Many thanks,
Wesley





library(gstat)
library(automap)

## List of files to be used in the while loop

files <- read.table("files.txt")
f.mat <- as.matrix(files)

## start loop here with a as the control

a=1
while(a <= 60)
{

d <- read.csv(paste(f.mat[a]), header=TRUE, sep=",")
coordinates(d) = ~dbl_1+dbl_2
variogram = autofitVariogram(dbl_5~1,d, model = c("Sph"), 
fix.values=c(NA,NA,NA), verbose = FALSE)

print(variogram)
print(variogram$var_model$psill[1])
print(variogram$var_model$range[2])
p <- plot(variogram, main="Semi-variogram (Spherical Model)", 
sub=paste("Range: ",variogram$var_model$range[2]))
print(p)

pdf(file="as.character(paste(f.mat[a])).pdf")
plot(p, main="Semi-variogram (Spherical Model)", sub=paste("Range: 
",variogram$var_model$range[2]))
dev.off()
a=a+1

}


Wesley Roberts MSc.
Researcher
Natural Resources and the Environment (Earth Observation)
CSIR
Tel: +27 (31) 242-2353
Fax: +27 (31) 261-1216
http://ffp.csir.co.za/

"To know the road ahead, ask those coming back."
- Chinese proverb

-- 
This message is subject to the CSIR's copyright terms and conditions, e-mail 
legal notice, and implemented Open Document Format (ODF) standard. 
The full disclaimer details can be found at 
http://www.csir.co.za/disclaimer.html.

This message has been scanned for viruses and dangerous content by MailScanner, 
and is believed to be clean.  MailScanner thanks Transtec Computers for their 
support.

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


Re: [R] address (nil), cause 'memory not mapped'

2008-08-20 Thread Roger Bivand
Juan Manuel Barreneche  gmail.com> writes:

> 
> just to mention that the loop was already running for about 20 hours...
> 
> Juan
> 
> On Tue, Aug 19, 2008 at 6:31 PM, Juan Manuel Barreneche
>  gmail.com>wrote:
> 
> > Dear users,
> > I got this problem and i don't have a clue of what it could be happening...
> >
> > The context: i'm running a loop in which i extract information from a
> > raster map (I work with GRASS and R, using spgrass6 package), and rearrange
> > it to create a matrix. 
...
> > Even so, the message "address (nil), cause 'memory not mapped'" appeared,
> > and i really don't have a clue of what it means.
> >

This question was also posted to the statgrass list, where it belongs. 
The thread will continue there (cross-posting is not a good idea). 
The messages so far do not contain information about what is happening, 
other than that a system() call from the R side, provoking an issue 
in running a GRASS module, should not bring R down. I feel that 
the general workflow is not adequate, and that very possibly 
the same instance of R should not be left running (script the other 
way round from the shell or similar)

Roger

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


Re: [R] Writing R Extensions : A new R package for Gini Index decomposition to prupose

2008-08-20 Thread Ndoye Souleymane

Greetings,
 
I have implemented the Gini Decomposition by groups. This programme works for 
two groups it provides:
 
Gini Between Intergoup,
Gini Net Intergoup, and
Transvariation Intergroup.
 
Regards,
 
Souleymane
> Date: Tue, 19 Aug 2008 19:33:30 -0500> From: [EMAIL PROTECTED]> To: [EMAIL 
> PROTECTED]; r-help@r-project.org; [EMAIL PROTECTED]> Subject: Re: [R] Writing 
> R Extensions : A new R package for Gini Index decomposition to prupose> > 
> there are many useful decompositions of the Gini... which one did you 
> implement?> > On Tue, Aug 19, 2008 at 8:42 AM, stephen sefick <[EMAIL 
> PROTECTED]> wrote:> > See if there is interest. If there is not make your own 
> package or> > see if someone else would like to include it into a package 
> that is> > complementary.> >> > Stephen Sefick> >> > On Tue, Aug 19, 2008 at 
> 3:46 AM, Ndoye Souleymane <[EMAIL PROTECTED]> wrote:> >>> >> Dear All,> >>> 
> >> I have developed a programme the anable the decomposition of the Gini 
> index, it complets tha valuable work of Achim Zeileis, the author of the ineq 
> package.> >> I would like to make it to be part of all R package. How should 
> I proceed.> >> Must I sent it to the the Core developement team ?> >> The pro!
 ogramme is written in R.> >>> >> Many thanks for your advice,> >>> >> Best 
regards,> >>> >> Souleymane> >> 
_> >> 
Retouchez, classez et partagez vos photos gratuitement avec le logiciel Galerie 
de Photos !> >>> >> __> >> 
R-help@r-project.org mailing list> >> 
https://stat.ethz.ch/mailman/listinfo/r-help> >> PLEASE do read the posting 
guide http://www.R-project.org/posting-guide.html> >> and provide commented, 
minimal, self-contained, reproducible code.> >>> >> >> >> > --> > Let's not 
spend our time and resources thinking about things that are> > so little or so 
large that all they really do for us is puff us up and> > make us feel like 
gods. We are mammals, and have not exhausted the> > annoying little problems of 
being mammals.> >> > -K. Mullis> >> > 
__> > R-help@r-project.org mailing 
list> > https://stat.ethz.ch/mailman/list!
 info/r-help> > PLEASE do read the posting guide http://www.R-project.o
rg/posting-guide.html> > and provide commented, minimal, self-contained, 
reproducible code.> >
_
[[elided Hotmail spam]]


[[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] Writing R Extensions : A new R package for Gini Index decomposition to prupose

2008-08-20 Thread Ndoye Souleymane

Many thanks for your advice.
 
Regards,
 
Souleymane> Date: Tue, 19 Aug 2008 09:42:30 -0400> From: [EMAIL PROTECTED]> To: 
[EMAIL PROTECTED]> Subject: Re: [R] Writing R Extensions : A new R package for 
Gini Index decomposition to prupose> CC: r-help@r-project.org; [EMAIL 
PROTECTED]> > See if there is interest. If there is not make your own package 
or> see if someone else would like to include it into a package that is> 
complementary.> > Stephen Sefick> > On Tue, Aug 19, 2008 at 3:46 AM, Ndoye 
Souleymane <[EMAIL PROTECTED]> wrote:> >> > Dear All,> >> > I have developed a 
programme the anable the decomposition of the Gini index, it complets tha 
valuable work of Achim Zeileis, the author of the ineq package.> > I would like 
to make it to be part of all R package. How should I proceed.> > Must I sent it 
to the the Core developement team ?> > The proogramme is written in R.> >> > 
Many thanks for your advice,> >> > Best regards,> >> > Souleymane> > 
!
 _> > Retouchez, classez et partagez vos photos gratuitement avec le logiciel 
Galerie de Photos !> >> > __> > 
R-help@r-project.org mailing list> > 
https://stat.ethz.ch/mailman/listinfo/r-help> > PLEASE do read the posting 
guide http://www.R-project.org/posting-guide.html> > and provide commented, 
minimal, self-contained, reproducible code.> >> > > > -- > Let's not spend our 
time and resources thinking about things that are> so little or so large that 
all they really do for us is puff us up and> make us feel like gods. We are 
mammals, and have not exhausted the> annoying little problems of being 
mammals.> > -K. Mullis
_
[[elided Hotmail spam]]


[[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] converting coordinates from utm to longitude / latitude

2008-08-20 Thread Werner Wernersen
After having figured out that I had to download the proj.dll file additionally 
(it would be nice if they actually added a note to their readme) and setting 
the "+south" parameter, the conversion of the shapfile from UTM to long/lat 
with the ogr2ogr utility from gdal worked perfectly. 

Thanks so much Dylan!
  Werner



- Ursprüngliche Mail 
Von: Dylan Beaudette <[EMAIL PROTECTED]>
An: r-help@r-project.org
CC: Werner Wernersen <[EMAIL PROTECTED]>
Gesendet: Dienstag, den 19. August 2008, 23:29:34 Uhr
Betreff: Re: [R] converting coordinates from utm to longitude / latitude

If you would like to convert the entire shapfile check out GDAL:

http://www.gdal.org/

http://casoilresource.lawr.ucdavis.edu/drupal/node/98

Cheers,

Dylan


On Tuesday 19 August 2008, Werner Wernersen wrote:
> It would be nicer to convert directly the entire shapefile object to
> long/lat coordinates but if that is not possible, I will convert the other
> points to UTM. Hence, I am playing around with rgdal.
>
> library(rgdal)
> SP <- SpatialPoints(cbind(32.29252, -0.3228500),
>   proj4string=CRS("+proj=longlat"))
> spTransform(SP, CRS("+proj=utm +zone=36"))
>
> > spTransform(SP, CRS("+proj=utm +zone=36"))
>
> SpatialPoints:
>  coords.x1 coords.x2
> [1,]  421274.4 -35687.37
> Coordinate Reference System (CRS) arguments: +proj=utm +zone=36
> +ellps=WGS84
>
> This result corresponds with what I get when using convUL() but my map of
> that area in UTM coordinates does not extend to the negative. An external
> program converts the point to x=420994   y=9964407 which also seems correct
> with respect to the map. Fore sure, I am using the function wrongly
> somehow. Can anyone give me a hint?
>
> That's very much appreciated!
>
> Thanks,
>Werner
>
>
>
> - Ursprüngliche Mail 
> Von: Werner Wernersen <[EMAIL PROTECTED]>
> An: [EMAIL PROTECTED]
> Gesendet: Dienstag, den 19. August 2008, 20:28:29 Uhr
> Betreff: converting coordinates from utm to longitude / latitude
>
> Hi,
>
> is there a function in R to convert data read with read.shape and which is
> originally in UTM coordinates into longitude / latitude coordinates? I
> found the convUL() function from the PBSmapping package but I have no idea
> how I could apply that to the read.shape object.
>
> Many thanks,
>   Werner
>
>
> __
> fügt über einen herausragenden Schutz gegen Massenmails.
> http://mail.yahoo.com
>
>
> __
> Do
> ragenden Schutz gegen Massenmails.
> http://mail.yahoo.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.



-- 
Dylan Beaudette
Soil Resource Laboratory
http://casoilresource.lawr.ucdavis.edu/
University of California at Davis
530.754.7341


__
Do You Yahoo!?
Sie sind
Massenmails. 
http://mail.yahoo.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.


  1   2   >