Re: [R] Selecting 3 different hours in a day

2011-11-07 Thread Jeff Newmiller
No data sample was provided, so with a verbal description of the problem comes 
a verbal answer.

I would use expand.grid to build a set of all desired date/time combinations, 
then use the merge function to select rows in your actual data.
---
Jeff NewmillerThe .   .  Go Live...
DCN:Basics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
--- 
Sent from my phone. Please excuse my brevity.

jck13  wrote:

>Hello,
>
>I have a csv with 5months of hourly data for 4 years. I would like to
>get
>9am, 12pm and 3pm from each day  and create a subset or a new data
>frame
>that I can analyze. The time are from hour 0-23 for each day.
>I am not sure how to create a loop which will take out each of these
>hours
>and create a subset.
>
>I was thinking of doing a for loop using the row number since:
>9am= row 10
>12pm= row 13
>3pm= row 16
>
>trying to loop through to extract these 3 times each day.
>
>n=length(date_stamp)
> 
>for (i in i:n) {
>m= 10
>i= 1
>new1= mv[m,]
>i= i+1
>m= m+3
>##m+18 at row 16?
>}
>
>I need some help creating a loop through this! Thank you! 
>
>
>--
>View this message in context:
>http://r.789695.n4.nabble.com/Selecting-3-different-hours-in-a-day-tp4015010p4015010.html
>Sent from the R help mailing list archive at Nabble.com.
>
>__
>R-help@r-project.org mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] Sampling with conditions

2011-11-07 Thread Ted Harding
[Correction below (I was writing too late at night ... ]

On 08-Nov-11 00:25:57, Ted Harding wrote:
> On 07-Nov-11 22:22:54, SarahJoyes wrote:
>> Hey everyone, 
>> I am at best, an amateur user of R, but I am stuck on how
>> to set-up the following situation. 
>> I am trying to select a random sample of numbers from 0 to 10
>> and insert them into the first column of a matrix (which will
>> used later in a loop).
>> However, I need to have those numbers add up to 10. How can
>> I set those conditions?
>> So far I have:
>> n<-matrix(0,nr=5,ncol=10)
>> for(i in 1:10){n[i,1]<-sample(0:10,1)}
>> How do I set-up the "BUT sum(n[i,1])=10"?
>> Thanks
>> SarahJ
> 
> Sarah, your example is confusing because you have set up a
> matrix 'n' with 5 rows and 10 columns. But your loop cycles
> through 10 rows!
> 
> However, assuming that your basic requirement is to sample
> 10 integers which add up to 10, consider rmultinom():
> 
>   rmultinom(n=1,size=10,prob=(1:10)/10)
>   #  [,1]
>   # [1,]1
>   # [2,]0
>   # [3,]2
>   # [4,]0
>   # [5,]1
>   # [6,]1
>   # [7,]2
>   # [8,]0
>   # [9,]1
>   #[10,]2
>   rmultinom(n=1,size=10,prob=(1:10)/10)
>   #  [,1]
>   # [1,]0
>   # [2,]0
>   # [3,]0
>   # [4,]0
>   # [5,]1
>   # [6,]1
>   # [7,]2
>   # [8,]1
>   # [9,]2
>   #[10,]3
> 
> This gives each integer in (0:10) equal chances of being
> in the sample. For unequal chances, vary 'prob'.
> 
> Hoping this helps,
> Ted.

That should have read:

  This gives a uniform distribution over the positions in
  the sample vector for the sampled integers, so that all
  permutations are equally likely. For a non-uniform
  distribution, vary 'prob'.

Sorry,
Ted.


E-Mail: (Ted Harding) 
Fax-to-email: +44 (0)870 094 0861
Date: 08-Nov-11   Time: 07:40:51
-- XFMail --

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


[R] similar package in R like "SKEW CALCULATOR"?

2011-11-07 Thread Knut Krueger


Hi to all
is there a similar package like the  SKEW CALCULATOR from
Peter Nonacs (University of California - Department of Ecology and 
Evolutionary Biology)


http://www.eeb.ucla.edu/Faculty/Nonacs/shareware.htm


Kind Regards Knut

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


Re: [R] Estimate of intercept in loglinear model

2011-11-07 Thread Mark Difford
Nov 08, 2011; 4:58am Rolf Turner wrote:

>(in response to 
>>> Professor Colin Aitken, 
>>> Professor of Forensic Statistics, 
>!!!) 

> 
>> 
>> Do you suppose you could provide a data-corpse for us to dissect? 

>Fortune nomination!!!

I think Sherlock would have said, "But it's elementary, my dear Watson.
Oftentimes a corpse is not necessary, as here."

Regards, Mark.

-
Mark Difford (Ph.D.)
Research Associate
Botany Department
Nelson Mandela Metropolitan University
Port Elizabeth, South Africa
--
View this message in context: 
http://r.789695.n4.nabble.com/Estimate-of-intercept-in-loglinear-model-tp4009905p4015131.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] Need help for the CO_PLOT method

2011-11-07 Thread Hui Xu
Hi,

   I am trying to draw some figures using the CO_PLOT method mentioned by
Adi Raveh (1998). This method puts observations on a two-dimensional space
using multiple dimension scale method, then add arrows to the  panel based
on the correlation between variables. Has anyone done the co-plot work in R
before? It looks like biplot, but they are different. I am not sure whether
vegan is the right package to do this, anyone has suggestions for this?
Thank you so much!

Best
Hui

-- 

Hui Xu
Graduate Student
School of Natural Resources and Environment
University of Michigan, Ann Arbor

Cell:517-899-6255

[[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] Selecting 3 different hours in a day

2011-11-07 Thread jck13
Hello,

I have a csv with 5months of hourly data for 4 years. I would like to get
9am, 12pm and 3pm from each day  and create a subset or a new data frame
that I can analyze. The time are from hour 0-23 for each day.
I am not sure how to create a loop which will take out each of these hours
and create a subset.

I was thinking of doing a for loop using the row number since:
9am= row 10
12pm= row 13
3pm= row 16

trying to loop through to extract these 3 times each day.

n=length(date_stamp)
 
for (i in i:n) {
m= 10
i= 1
new1= mv[m,]
i= i+1
m= m+3
##m+18 at row 16?
}

I need some help creating a loop through this! Thank you! 


--
View this message in context: 
http://r.789695.n4.nabble.com/Selecting-3-different-hours-in-a-day-tp4015010p4015010.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] why NA coefficients

2011-11-07 Thread David Winsemius


On Nov 8, 2011, at 1:19 AM, David Winsemius wrote:



On Nov 7, 2011, at 10:07 PM, array chip wrote:

Thanks David. The only category that has no cases is "treat 1-group  
2":


> with(test,table(treat,group))
group
treat 1 2
   1 8 0
   2 1 5
   3 5 5
   4 7 3
   5 7 4
   6 3 3
   7 8 2

But why the coefficient for "treat 7-group 2" is not estimable?


Well, it had to omit one of them didn't it?

(But I don't know why that level was chosen.)


But this output suggests there may be alligators in the swamp:

> predict(lmod, newdata=data.frame(treat=1, group=2))
 1
0.09133691
Warning message:
In predict.lm(lmod, newdata = data.frame(treat = 1, group = 2)) :
  prediction from a rank-deficient fit may be misleading

--
David.


--
David.


Thanks

John


From: David Winsemius 
To: array chip 
Cc: "r-help@r-project.org" 
Sent: Monday, November 7, 2011 5:13 PM
Subject: Re: [R] why NA coefficients


On Nov 7, 2011, at 7:33 PM, array chip wrote:

> Hi, I am trying to run ANOVA with an interaction term on 2  
factors (treat has 7 levels, group has 2 levels). I found the  
coefficient for the last interaction term is always 0, see attached  
dataset and the code below:

>
>> test<-read.table("test.txt",sep='\t',header=T,row.names=NULL)
>> lm(y~factor(treat)*factor(group),test)
>
> Call:
> lm(formula = y ~ factor(treat) * factor(group), data = test)
>
> Coefficients:
>  (Intercept) 
factor(treat)2factor(treat)3
>  0.429244   
0.499982  0.352971
>factor(treat)4 
factor(treat)5factor(treat)6
>-0.204752   
0.142042  0.044155
>factor(treat)7factor(group)2   
factor(treat)2:factor(group)2
>-0.007775   
-0.337907  -0.208734
> factor(treat)3:factor(group)2  factor(treat)4:factor(group)2   
factor(treat)5:factor(group)2
>-0.195138   
0.800029  0.227514

> factor(treat)6:factor(group)2  factor(treat)7:factor(group)2
>  0.331548NA
>
>
> I guess this is due to model matrix being singular or  
collinearity among the matrix columns? But I can't figure out how  
the matrix is singular in this case? Can someone show me why this  
is the case?


Because you have no cases in one of the crossed categories.

--David Winsemius, MD
West Hartford, CT





David Winsemius, MD
West Hartford, CT

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


David Winsemius, MD
West Hartford, CT

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


Re: [R] why NA coefficients

2011-11-07 Thread David Winsemius


On Nov 7, 2011, at 10:07 PM, array chip wrote:

Thanks David. The only category that has no cases is "treat 1-group  
2":


> with(test,table(treat,group))
 group
treat 1 2
1 8 0
2 1 5
3 5 5
4 7 3
5 7 4
6 3 3
7 8 2

But why the coefficient for "treat 7-group 2" is not estimable?


Well, it had to omit one of them didn't it?

(But I don't know why that level was chosen.)

--
David.


Thanks

John


From: David Winsemius 
To: array chip 
Cc: "r-help@r-project.org" 
Sent: Monday, November 7, 2011 5:13 PM
Subject: Re: [R] why NA coefficients


On Nov 7, 2011, at 7:33 PM, array chip wrote:

> Hi, I am trying to run ANOVA with an interaction term on 2 factors  
(treat has 7 levels, group has 2 levels). I found the coefficient  
for the last interaction term is always 0, see attached dataset and  
the code below:

>
>> test<-read.table("test.txt",sep='\t',header=T,row.names=NULL)
>> lm(y~factor(treat)*factor(group),test)
>
> Call:
> lm(formula = y ~ factor(treat) * factor(group), data = test)
>
> Coefficients:
>  (Intercept) 
factor(treat)2factor(treat)3
>  0.429244   
0.499982  0.352971
>factor(treat)4 
factor(treat)5factor(treat)6
>-0.204752   
0.142042  0.044155
>factor(treat)7factor(group)2   
factor(treat)2:factor(group)2
>-0.007775   
-0.337907  -0.208734
> factor(treat)3:factor(group)2  factor(treat)4:factor(group)2   
factor(treat)5:factor(group)2
>-0.195138   
0.800029  0.227514

> factor(treat)6:factor(group)2  factor(treat)7:factor(group)2
>  0.331548NA
>
>
> I guess this is due to model matrix being singular or collinearity  
among the matrix columns? But I can't figure out how the matrix is  
singular in this case? Can someone show me why this is the case?


Because you have no cases in one of the crossed categories.

--David Winsemius, MD
West Hartford, CT





David Winsemius, MD
West Hartford, CT

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


Re: [R] why NA coefficients

2011-11-07 Thread array chip
Hi Dennis,

The cell mean mu_12 from the model involves the intercept and factor 2:

Coefficients:
  (Intercept) factor(treat)2 
factor(treat)3  
 0.429244   
0.499982   0.352971  
   factor(treat)4 factor(treat)5 
factor(treat)6  
    -0.204752   
0.142042   0.044155  
   factor(treat)7 factor(group)2  
factor(treat)2:factor(group)2  
    -0.007775  
-0.337907  -0.208734  
factor(treat)3:factor(group)2  factor(treat)4:factor(group)2  
factor(treat)5:factor(group)2  
    -0.195138   
0.800029   0.227514  
factor(treat)6:factor(group)2  factor(treat)7:factor(group)2  
 0.331548 NA

So mu_12 = 0.429244-0.337907 = 0.091337. This can be verified by:

> predict(fit,data.frame(list(treat=1,group=2)))
 1 
0.09133691 
Warning message:
In predict.lm(fit, data.frame(list(treat = 1, group = 2))) :
  prediction from a rank-deficient fit may be misleading


But as you can see, it gave a warning about rank-deficient fit... why this is a 
rank-deficient fit?

Because "treat 1_group 2" has no cases, so why it is still estimable while on 
the contrary, "treat 7_group 2" which has 2 cases is not?

Thanks

John








From: Dennis Murphy 

Sent: Monday, November 7, 2011 9:29 PM
Subject: Re: [R] why NA coefficients

Hi John:

What is the estimate of the cell mean \mu_{12}? Which model effects
involve that cell mean? With this data arrangement, the expected
population marginal means of treatment 1 and group 2 are not estimable
either, unless you're willing to assume a no-interaction model.

Chapters 13 and 14 of Milliken and Johnson's Analysis of Messy Data
(vol. 1) cover this topic in some detail, but it assumes you're
familiar with the matrix form of a linear statistical model. Both
chapters cover the two-way model with interaction - Ch.13 from the
cell means model approach and Ch. 14 from the model effects approach.
Because this was written in the mid 80s and republished in the early
90s, all the code used is in SAS.

HTH,
Dennis


> Thanks David. The only category that has no cases is "treat 1-group 2":
>
>> with(test,table(treat,group))
>  group
> treat 1 2
>     1 8 0
>     2 1 5
>     3 5 5
>     4 7 3
>     5 7 4
>     6 3 3
>     7 8 2
>
> But why the coefficient for "treat 7-group 2" is not estimable?
>
> Thanks
>
> John
>
>
>
>
> 
> From: David Winsemius 
>
> Cc: "r-help@r-project.org" 
> Sent: Monday, November 7, 2011 5:13 PM
> Subject: Re: [R] why NA coefficients
>
>
> On Nov 7, 2011, at 7:33 PM, array chip wrote:
>
>> Hi, I am trying to run ANOVA with an interaction term on 2 factors (treat 
>> has 7 levels, group has 2 levels). I found the coefficient for the last 
>> interaction term is always 0, see attached dataset and the code below:
>>
>>> test<-read.table("test.txt",sep='\t',header=T,row.names=NULL)
>>> lm(y~factor(treat)*factor(group),test)
>>
>> Call:
>> lm(formula = y ~ factor(treat) * factor(group), data = test)
>>
>> Coefficients:
>>                   (Intercept)                 factor(treat)2                 
>>factor(treat)3
>>                      0.429244                       0.499982                 
>>      0.352971
>>                factor(treat)4                 factor(treat)5                 
>>factor(treat)6
>>                     -0.204752                       0.142042                 
>>      0.044155
>>                factor(treat)7                 factor(group)2  
>>factor(treat)2:factor(group)2
>>                     -0.007775                      -0.337907                 
>>     -0.208734
>> factor(treat)3:factor(group)2  factor(treat)4:factor(group)2  
>> factor(treat)5:factor(group)2
>>                     -0.195138                       0.800029                 
>>      0.227514
>> factor(treat)6:factor(group)2  factor(treat)7:factor(group)2
>>                      0.331548                             NA
>>
>>
>> I guess this is due to model matrix being singular or collinearity among the 
>> matrix columns? But I can't figure out how the matrix is singular in this 
>> case? Can someone show me why this is the case?
>
> Because you have no cases in one of the crossed categories.
>
> --David Winsemius, MD
> West Hartford, CT
>        [[alternative HTML version deleted]]
>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>
[[alternative HTML version deleted]]

___

[R] Unexpected behavior when browsing list objects by name, when the object name is a substring (prefix) of an existing object that has a valid value

2011-11-07 Thread Val Athaide
>
> Hi,
>
> The program I am writing requires me to append named objects to my
> existing list objects dynamically.
>
> So my list object is retval. retval always has a metadatatabletype object
>
> createMetadata=TRUE
> retval <-list()
> retval$metadatatype =c("normal")
> retval$metadata=NULL
>
> How, depending on certain logic, I create a metadata object
>
> if (createMetadata==TRUE) retval$metadata =rbind(retval$metadata,c(1,0) )
> The results are
> > retval$metadata
>  [,1] [,2]
> [1,] "normal" "normal"
> [2,] "1"  "0"
>
>
> What I expected to see is
> > retval$metadata
>  [,1] [,2]
> [1,] "1"  "0"
>
>
>
> I have been able to reproduce this problem only when the object
> retval$metadata is NULL and there is an existing object that has a valid
> value and the NULL object is a sub-string (prefix) of the existing object
> with a valid value.
>
> Also, retval$metadata takes on a value of "normal" even though it has been
> explicity set as NULL
>
> Your assistance is appreciated.
>
> Thanks
> Vathaid
>
>
>
>

[[alternative HTML version deleted]]

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


Re: [R] How to delete only those rows in a dataframe in which all records are missing

2011-11-07 Thread Petr PIKAL
Hi Dennis

Yes you are completely right. Well, we use to say "Quick work is wretched 
work" and this is perfect example.

Regards
Petr

> Hi Petr:
> 
> You might want to double check your post. The OP wanted to remove
> cases where *all* the variables in a row were NA. complete.cases()
> eliminates rows that have *any* NA values. That's why Michael coded it
> the way he did.
> 
> Example:
> 
> dff <- data.frame(x1 = c(1, 2, 3, NA, 4, NA),
>   x2 = c(NA, 2, 3, NA, 4, 5),
>   x3 = c(1, 2, 3, NA, 4, NA))
> dff
> dff[complete.cases(dff),]
> dff[!(rowSums(is.na(dff)) == NCOL(dff)), ]
> 
> 
> Cheers,
> Dennis
> 
> 2011/11/7 Petr PIKAL :
> >>
> >> Perhaps something like this will work.
> >>
> >> df[!(rowSums(is.na(df))==NCOL(df)),]
> >
> >
> > Or
> >
> > df[complete.cases(df),]
> >
> > Regards
> > Petr
> >
> >
> >>
> >> Michael
> >>
> >> On Fri, Nov 4, 2011 at 9:27 AM, Jose Iparraguirre
> >>  wrote:
> >> > Hi,
> >> >
> >> > Imagine I have the following data frame:
> >> >
> >> >> a <- c(1,NA,3)
> >> >> b <- c(2,NA,NA)
> >> >> c <- data.frame(cbind(a,b))
> >> >> c
> >> >   a  b
> >> > 1  1  2
> >> > 2 NA NA
> >> > 3  3 NA
> >> >
> >> > I want to delete the second row. If I use na.omit, that would also
> >> affect the third row. I tried to use a loop and an ifelse clause with
> >> is.na to get R identify that row in which all records are missing, as
> >> opposed to the first row in which no records are missing or the third
> > one,
> >> in which only one record is missing. How can I get R identify the row 
in
> >
> >> which all records are missing? Or, how can I get R delete/omit only 
this
> > row?
> >> > Thanks in advance,
> >> >
> >> > José
> >> >
> >> >
> >> > José Iparraguirre
> >> > Chief Economist
> >> > Age UK
> >> >
> >> > T 020 303 31482
> >> > E jose.iparragui...@ageuk.org.uk<
mailto:jose.iparragui...@ageuk.org.uk
> >>
> >> >
> >> > Tavis House, 1- 6 Tavistock Square
> >> > London, WC1H 9NB
> >> > www.ageuk.org.uk | 
ageukblog.org.uk >> ageukblog.org.uk/> | @AgeUKPA
> >> >
> >> >
> >> > Age UK  Improving later life
> >> >
> >> > www.ageuk.org.uk
> >> >
> >> >
> >> >
> >> >
> >> >
> >> > ---
> >> >
> >> > Age UK is a registered charity and company limited by guarantee,
> >> (registered charity number 1128267, registered company number 
6825798).
> >> Registered office: Tavis House, 1-6 Tavistock Square, London WC1H 
9NA.
> >> >
> >> > For the purposes of promoting Age UK Insurance, Age UK is an 
Appointed
> >
> >> Representative of Age UK Enterprises Limited, Age UK is an Introducer
> >> Appointed Representative of JLT Benefit Solutions Limited and
> > Simplyhealth
> >> Access for the purposes of introducing potential annuity and health 
cash
> >
> >> plans customers respectively.  Age UK Enterprises Limited, JLT 
Benefit
> >> Solutions Limited and Simplyhealth Access are all authorised and
> > regulated
> >> by the Financial Services Authority.
> >> >
> >> >
> >> >
> >> >
> >> >
> >> > --
> >> >
> >> > This email and any files transmitted with it are confidential and
> >> intended solely for the use of the individual or entity to whom they 
are
> >
> >> addressed. If you receive a message in error, please advise the 
sender
> > and
> >> delete immediately.
> >> >
> >> >
> >> >
> >> > Except where this email is sent in the usual course of our 
business,
> > any
> >> opinions expressed in this email are those of the author and do not
> >> necessarily reflect the opinions of Age UK or its subsidiaries and
> >> associated companies. Age UK monitors all e-mail transmissions 
passing
> >> through its network and may block or modify mails which are deemed to 
be
> > unsuitable.
> >> >
> >> >
> >> >
> >> >
> >> >
> >> > Age Concern England (charity number 261794) and Help the Aged 
(charity
> >
> >> number 272786) and their trading and other associated companies 
merged
> > on
> >> 1st April 2009.  Together they have formed the Age UK Group, 
dedicated
> > to
> >> improving the lives of people in later life.  The three national Age
> >> Concerns in Scotland, Northern Ireland and Wales have also merged 
with
> >> Help the Aged in these nations to form three registered charities: 
Age
> >> Scotland, Age NI, Age Cymru.
> >> >
> >> >
> >> >
> >> >
> >> >
> >> >
> >> >
> >> >
> >> >
> >> >
> >> >
> >> >
> >> >
> >> >
> >> >
> >> >
> >> >
> >> >
> >> >
> >> >
> >> >
> >> >
> >> >
> >> >
> >> >
> >> >
> >> >[[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
> >> 

Re: [R] Intervals in function cut

2011-11-07 Thread Julio Sergio
Duncan Murdoch  gmail.com> writes:
...



Thanks Duncan!

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

2011-11-07 Thread SML
I'm trying to rekey values which denote there is no values, i.e.,
'-999' in a dataset which contains both '-999' and NA entries.
When I try the following command I get the following error:

> data.frame[data.frame$MAR <= -9,"MAR"] <- NA

"missing values are not allowed in subscripted assignments of data
frames"

Example of data:
YEAR   JAN FEB MAR ... DEC
1931   5   -999NA  3
1932   2   1   -9992
.
.
.
2010   -999NA  2   1


I've tried to replace the NAs with -999 values first to remove the NA
values, but got the same error.

I'm quite new to R, and these little issues seem to be a stumbling
block. Many thanks for any help you might be able to offer.

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


Re: [R] why NA coefficients

2011-11-07 Thread array chip
Thanks David. The only category that has no cases is "treat 1-group 2":

> with(test,table(treat,group))
 group
treat 1 2
    1 8 0
    2 1 5
    3 5 5
    4 7 3
    5 7 4
    6 3 3
    7 8 2

But why the coefficient for "treat 7-group 2" is not estimable?  

Thanks

John





From: David Winsemius 

Cc: "r-help@r-project.org" 
Sent: Monday, November 7, 2011 5:13 PM
Subject: Re: [R] why NA coefficients


On Nov 7, 2011, at 7:33 PM, array chip wrote:

> Hi, I am trying to run ANOVA with an interaction term on 2 factors (treat has 
> 7 levels, group has 2 levels). I found the coefficient for the last 
> interaction term is always 0, see attached dataset and the code below:
> 
>> test<-read.table("test.txt",sep='\t',header=T,row.names=NULL)
>> lm(y~factor(treat)*factor(group),test)
> 
> Call:
> lm(formula = y ~ factor(treat) * factor(group), data = test)
> 
> Coefficients:
>                   (Intercept)                 factor(treat)2                 
>factor(treat)3
>                      0.429244                       0.499982                  
>     0.352971
>                factor(treat)4                 factor(treat)5                 
>factor(treat)6
>                     -0.204752                       0.142042                  
>     0.044155
>                factor(treat)7                 factor(group)2  
>factor(treat)2:factor(group)2
>                     -0.007775                      -0.337907                  
>    -0.208734
> factor(treat)3:factor(group)2  factor(treat)4:factor(group)2  
> factor(treat)5:factor(group)2
>                     -0.195138                       0.800029                  
>     0.227514
> factor(treat)6:factor(group)2  factor(treat)7:factor(group)2
>                      0.331548                             NA
> 
> 
> I guess this is due to model matrix being singular or collinearity among the 
> matrix columns? But I can't figure out how the matrix is singular in this 
> case? Can someone show me why this is the case?

Because you have no cases in one of the crossed categories.

--David Winsemius, MD
West Hartford, CT
[[alternative HTML version deleted]]

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


Re: [R] Estimate of intercept in loglinear model

2011-11-07 Thread Rolf Turner


On 08/11/11 07:11, David Winsemius wrote:

(in response to

Professor Colin Aitken,
Professor of Forensic Statistics,

!!!)




Do you suppose you could provide a data-corpse for us to dissect?


Fortune nomination!!!

cheers,

Rolf Turner

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

2011-11-07 Thread Rolf Turner

On 08/11/11 02:40, Joshua Wiley wrote:

On Mon, Nov 7, 2011 at 5:32 AM, Alaios  wrote:

So I just need to get the

user  system elapsed
   0.460   0.048  67.366


user value and convert the seconds to days and then to hours ? Right?

What about this elapsed field?

It's all in seconds.  Convert whatever fields you want.


That being said, doesn't having an elapsed time of over 67 seconds,
when the actual calculation takes less than half a second, indicate
that something weird is going on?  At the very least the R calculations
are fighting for resources with some other very greedy processes.

cheers,

Rolf Turner

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


Re: [R] Rd2pdf error after 2.14 upgrade‏

2011-11-07 Thread Tyler Rinker

I have determined this is a MikTex problem and not an R problem.
 
I apoligize for the post.
 

> From: tyler_rin...@hotmail.com
> To: r-help@r-project.org
> Date: Mon, 7 Nov 2011 20:38:54 -0500
> Subject: [R] Rd2pdf error after 2.14 upgradeþ
> 
> 
> > The command Rd2pdf was rather useful for opening a package's manual
> > when you don't have access to the Internet (by using latex to pdf
> > conversion). However the way the function seems to operate changed at
> > version 2.14 of R. The noted changes listed on CRAN for this function
> > are as follows (which doesn't seem like it would affect my usage as
> > below):
> > 
> > #R CMD Rd2dvi without the --pdf option is now deprecated: only PDF output 
> > will be 
> > #supported in future releases (since this allows the use of fonts only 
> > #supported for PDF), and only R CMD Rd2pdf will be available. 
> > 
> > The way I used to open a package's pdf manual from latex file was as
> > follows:
> 
> (path <- find.package('plyr'))
> 
> system(paste(shQuote(file.path(R.home("bin"), "R")),"CMD", 
> "Rd2pdf",shQuote(path)))
> 
> > After version 2.14 R the same code now throws up the error:
> > 
> > Hmm ... looks like a package
> > Converting parsed Rd's to LaTeX 
> > Creating pdf output from LaTeX ...
> > Error in texi2dvi("Rd2.tex", pdf = (out_ext == "pdf"), quiet = FALSE, : 
> > pdflatex is not available
> > Error in running tools::texi2dvi
> > Warning message:
> > running command '"C:/PROGRA~1/R/R-214~1.0/bin/i386/R" CMD 
> > Rd2pdf "C:/Users/Rinker/R/win-library/2.14/plyr"' had status 1 
> > 
> > 
> > I'm running this from the R console. Any idea on what changes would
> > be needed to make this code work to generate a pdf from latex? I also
> > just downloaded the new miktex2.9 over 2.8. Not sure if this
> > information is relevant (I believe this is an R problem but don't know how 
> > to diagnosis this from the error). Usually, I can figure out the error 
> > message
> > but not this time.
> 
> R version 2.14.0 2011-10-31
> OS windows 7 
> [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
  
[[alternative HTML version deleted]]

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


Re: [R] Intervals in function cut

2011-11-07 Thread jim holtman
In stepping through 'cut.default' that is called, I get the following interval:

 -0.008  0.994  1.996  2.998  4.000  5.002  6.004  7.006  8.008

In printing out to three significant digits, you will have "(0.994,
2]"  or "(2,3]" as you see in the factors.

If instead you used:

cut(x, b = 8, dig.lab = 7)

you will get:

cut(x, b= 8, dig.lab=7)
 [1] (-0.008,0.994] (-0.008,0.994] (-0.008,0.994] (-0.008,0.994]
(-0.008,0.994] (-0.008,0.994]
 [7] (-0.008,0.994] (-0.008,0.994] (-0.008,0.994] (0.994,1.996]
(0.994,1.996]  (0.994,1.996]
[13] (0.994,1.996]  (1.996,2.998]  (1.996,2.998]  (1.996,2.998]
(1.996,2.998]  (1.996,2.998]
[19] (1.996,2.998]  (2.998,4]  (2.998,4]  (2.998,4]
(2.998,4]  (2.998,4]
[25] (4,5.002]  (4,5.002]  (4,5.002]  (4,5.002]
(4,5.002]  (4,5.002]
[31] (4,5.002]  (4,5.002]  (4,5.002]  (4,5.002]
(4,5.002]  (4,5.002]
[37] (4,5.002]  (5.002,6.004]  (5.002,6.004]  (5.002,6.004]
(5.002,6.004]  (5.002,6.004]
[43] (6.004,7.006]  (6.004,7.006]  (6.004,7.006]  (7.006,8.008]
(7.006,8.008]  (7.006,8.008]
[49] (7.006,8.008]  (7.006,8.008]
8 Levels: (-0.008,0.994] (0.994,1.996] (1.996,2.998] (2.998,4]
(4,5.002] ... (7.006,8.008]

aren't floating point numbers fun; read FAQ 7.31

On Mon, Nov 7, 2011 at 7:48 PM, JulioSergio  wrote:
> When I was studying the function cut I found this example:
>
>> x <- rep(0:8, tx0)
>> x
>  [1] 0 0 0 0 0 0 0 0 0 1 1 1 1 2 2 2 2 2 2 3 3 3 3 3 4 4 4 5 5 5 5 5 5
> 5 5 5 5 6
> [39] 6 6 6 6 7 7 7 8 8 8 8 8
>
>> cut(x, b = 8)
>  [1] (-0.008,0.994] (-0.008,0.994] (-0.008,0.994] (-0.008,0.994]
> (-0.008,0.994]
>  [6] (-0.008,0.994] (-0.008,0.994] (-0.008,0.994] (-0.008,0.994] (0.994,2]
> [11] (0.994,2]      (0.994,2]      (0.994,2]      (2,3]          (2,3]
> [16] (2,3]          (2,3]          (2,3]          (2,3]          (3,4]
> [21] (3,4]          (3,4]          (3,4]          (3,4]          (4,5]
> [26] (4,5]          (4,5]          (4,5]          (4,5]          (4,5]
> [31] (4,5]          (4,5]          (4,5]          (4,5]          (4,5]
> [36] (4,5]          (4,5]          (5,6]          (5,6]          (5,6]
> [41] (5,6]          (5,6]          (6,7.01]       (6,7.01]       (6,7.01]
> [46] (7.01,8.01]    (7.01,8.01]    (7.01,8.01]    (7.01,8.01]    (7.01,8.01]
> 8 Levels: (-0.008,0.994] (0.994,2] (2,3] (3,4] (4,5] (5,6] ... (7.01,8.01]
>
> I undestand that the resulting factor yields as its first component the
> corresponding "intervals" that the original vector (x) elements belong to.
> So, clearly, the first element of x, 0, belongs to (-0.008,0.994] because
> -0.008 < 0 <= 0.994. However, when I come to the 14th element of x,
> that is, 2, I don't see that it belongs to (2,3], because 2 < 2 <= 3,
> is strictly false according to the standard inverval notation
> (http://en.wikipedia.org/wiki/Interval_notation). Maybe, there is something
> I have not understood of either the cut function or the interval notation.
> Do you have
> any comments?
>
> Thanks,
>
> Sergio.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.

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


Re: [R] Warning message interpretation

2011-11-07 Thread Duncan Murdoch

On 11-11-07 8:08 PM, eric wrote:

Using the rmarketdata package and getting a warning message.

What does this warning message tell me ? What could I do to eliminate or
address it ?

require(rdatamarket)
Loading required package: rdatamarket
Loading required package: zoo


Warning message:
In assignInNamespace("as.Date.numeric", function(x, origin, ...) { :
   binding of ‘as.Date.numeric’ is locked and will not be changed


It says one of the packages tried to change an object in another 
package, which is not allowed.


Duncan Murdoch

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


Re: [R] Intervals in function cut

2011-11-07 Thread Duncan Murdoch

On 11-11-07 7:48 PM, JulioSergio wrote:

When I was studying the function cut I found this example:


x<- rep(0:8, tx0)
x

  [1] 0 0 0 0 0 0 0 0 0 1 1 1 1 2 2 2 2 2 2 3 3 3 3 3 4 4 4 5 5 5 5 5 5
5 5 5 5 6
[39] 6 6 6 6 7 7 7 8 8 8 8 8


cut(x, b = 8)

  [1] (-0.008,0.994] (-0.008,0.994] (-0.008,0.994] (-0.008,0.994]
(-0.008,0.994]
  [6] (-0.008,0.994] (-0.008,0.994] (-0.008,0.994] (-0.008,0.994] (0.994,2]
[11] (0.994,2]  (0.994,2]  (0.994,2]  (2,3]  (2,3]
[16] (2,3]  (2,3]  (2,3]  (2,3]  (3,4]
[21] (3,4]  (3,4]  (3,4]  (3,4]  (4,5]
[26] (4,5]  (4,5]  (4,5]  (4,5]  (4,5]
[31] (4,5]  (4,5]  (4,5]  (4,5]  (4,5]
[36] (4,5]  (4,5]  (5,6]  (5,6]  (5,6]
[41] (5,6]  (5,6]  (6,7.01]   (6,7.01]   (6,7.01]
[46] (7.01,8.01](7.01,8.01](7.01,8.01](7.01,8.01](7.01,8.01]
8 Levels: (-0.008,0.994] (0.994,2] (2,3] (3,4] (4,5] (5,6] ... (7.01,8.01]

I undestand that the resulting factor yields as its first component the
corresponding "intervals" that the original vector (x) elements belong to.
So, clearly, the first element of x, 0, belongs to (-0.008,0.994] because
-0.008<  0<= 0.994. However, when I come to the 14th element of x,
that is, 2, I don't see that it belongs to (2,3], because 2<  2<= 3,
is strictly false according to the standard inverval notation
(http://en.wikipedia.org/wiki/Interval_notation). Maybe, there is something
I have not understood of either the cut function or the interval notation.
Do you have
any comments?


The actual break is 1.996, but the formatting rounded that to 2 for 
printing.  You can see it more accurately if you set dig.lab to 4 or more.


Duncan Murdoch



Thanks,

Sergio.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Rd2pdf error after 2.14 upgrade‏

2011-11-07 Thread Tyler Rinker

> The command Rd2pdf was rather useful for opening a package's manual
> when you don't have access to the Internet (by using latex to pdf
> conversion).  However the way the function seems to operate changed at
> version 2.14 of R.  The noted changes listed on CRAN for this function
> are as follows (which doesn't seem like it would affect my usage as
> below):
> 
> #R CMD Rd2dvi without the --pdf option is now deprecated: only PDF output 
> will be 
> #supported in future releases (since this allows the use of fonts only 
> #supported for  PDF), and only R CMD Rd2pdf will be available. 
> 
> The way I used to open a package's pdf manual from latex file was as
> follows:
 
 (path <- find.package('plyr'))
 
 system(paste(shQuote(file.path(R.home("bin"), "R")),"CMD", 
   "Rd2pdf",shQuote(path)))
 
> After version 2.14 R the same code now throws up the error:
> 
> Hmm ... looks like a package
> Converting parsed Rd's to LaTeX 
> Creating pdf output from LaTeX ...
> Error in texi2dvi("Rd2.tex", pdf = (out_ext == "pdf"), quiet = FALSE,  : 
> pdflatex is not available
> Error in running tools::texi2dvi
> Warning message:
> running command '"C:/PROGRA~1/R/R-214~1.0/bin/i386/R" CMD 
> Rd2pdf "C:/Users/Rinker/R/win-library/2.14/plyr"' had status 1 
> 
> 
> I'm running this from the R console.  Any idea on what changes would
> be needed to make this code work to generate a pdf from latex?  I also
> just downloaded the new miktex2.9 over 2.8.  Not sure if this
> information is relevant (I believe this is an R problem but don't know how to 
> diagnosis this from the error).  Usually, I can figure out the error message
> but not this time.
 
R version 2.14.0 2011-10-31
OS windows 7  
[[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] Intervals in function cut

2011-11-07 Thread JulioSergio
When I was studying the function cut I found this example:

> x <- rep(0:8, tx0)
> x
 [1] 0 0 0 0 0 0 0 0 0 1 1 1 1 2 2 2 2 2 2 3 3 3 3 3 4 4 4 5 5 5 5 5 5 
5 5 5 5 6
[39] 6 6 6 6 7 7 7 8 8 8 8 8

> cut(x, b = 8)
 [1] (-0.008,0.994] (-0.008,0.994] (-0.008,0.994] (-0.008,0.994] 
(-0.008,0.994]
 [6] (-0.008,0.994] (-0.008,0.994] (-0.008,0.994] (-0.008,0.994] (0.994,2] 
[11] (0.994,2]  (0.994,2]  (0.994,2]  (2,3]  (2,3] 
[16] (2,3]  (2,3]  (2,3]  (2,3]  (3,4] 
[21] (3,4]  (3,4]  (3,4]  (3,4]  (4,5] 
[26] (4,5]  (4,5]  (4,5]  (4,5]  (4,5] 
[31] (4,5]  (4,5]  (4,5]  (4,5]  (4,5] 
[36] (4,5]  (4,5]  (5,6]  (5,6]  (5,6] 
[41] (5,6]  (5,6]  (6,7.01]   (6,7.01]   (6,7.01]  
[46] (7.01,8.01](7.01,8.01](7.01,8.01](7.01,8.01](7.01,8.01]   
8 Levels: (-0.008,0.994] (0.994,2] (2,3] (3,4] (4,5] (5,6] ... (7.01,8.01]

I undestand that the resulting factor yields as its first component the 
corresponding "intervals" that the original vector (x) elements belong to. 
So, clearly, the first element of x, 0, belongs to (-0.008,0.994] because 
-0.008 < 0 <= 0.994. However, when I come to the 14th element of x, 
that is, 2, I don't see that it belongs to (2,3], because 2 < 2 <= 3, 
is strictly false according to the standard inverval notation 
(http://en.wikipedia.org/wiki/Interval_notation). Maybe, there is something 
I have not understood of either the cut function or the interval notation. 
Do you have 
any comments?

Thanks,

Sergio.

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

2011-11-07 Thread eric
Using the rmarketdata package and getting a warning message. 

What does this warning message tell me ? What could I do to eliminate or
address it ?

require(rdatamarket)
Loading required package: rdatamarket
Loading required package: zoo


Warning message:
In assignInNamespace("as.Date.numeric", function(x, origin, ...) { :
  binding of ‘as.Date.numeric’ is locked and will not be changed

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

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


Re: [R] why NA coefficients

2011-11-07 Thread David Winsemius


On Nov 7, 2011, at 7:33 PM, array chip wrote:

Hi, I am trying to run ANOVA with an interaction term on 2 factors  
(treat has 7 levels, group has 2 levels). I found the coefficient  
for the last interaction term is always 0, see attached dataset and  
the code below:



test<-read.table("test.txt",sep='\t',header=T,row.names=NULL)
lm(y~factor(treat)*factor(group),test)


Call:
lm(formula = y ~ factor(treat) * factor(group), data = test)

Coefficients:
  (Intercept)  
factor(treat)2 factor(treat)3
 0.429244
0.499982   0.352971
   factor(treat)4  
factor(treat)5 factor(treat)6
-0.204752
0.142042   0.044155
   factor(treat)7 factor(group)2   
factor(treat)2:factor(group)2
-0.007775   
-0.337907  -0.208734
factor(treat)3:factor(group)2  factor(treat)4:factor(group)2   
factor(treat)5:factor(group)2
-0.195138
0.800029   0.227514

factor(treat)6:factor(group)2  factor(treat)7:factor(group)2
 0.331548 NA


I guess this is due to model matrix being singular or collinearity  
among the matrix columns? But I can't figure out how the matrix is  
singular in this case? Can someone show me why this is the case?


Because you have no cases in one of the crossed categories.

--
David Winsemius, MD
West Hartford, CT

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


[R] why NA coefficients

2011-11-07 Thread array chip
Hi, I am trying to run ANOVA with an interaction term on 2 factors (treat has 7 
levels, group has 2 levels). I found the coefficient for the last interaction 
term is always 0, see attached dataset and the code below:

> test<-read.table("test.txt",sep='\t',header=T,row.names=NULL)
> lm(y~factor(treat)*factor(group),test)

Call:
lm(formula = y ~ factor(treat) * factor(group), data = test)

Coefficients:
  (Intercept) factor(treat)2 
factor(treat)3  
 0.429244   
0.499982   0.352971  
   factor(treat)4 factor(treat)5 
factor(treat)6  
    -0.204752   
0.142042   0.044155  
   factor(treat)7 factor(group)2  
factor(treat)2:factor(group)2  
    -0.007775  
-0.337907  -0.208734  
factor(treat)3:factor(group)2  factor(treat)4:factor(group)2  
factor(treat)5:factor(group)2  
    -0.195138   
0.800029   0.227514  
factor(treat)6:factor(group)2  factor(treat)7:factor(group)2  
 0.331548 NA 


I guess this is due to model matrix being singular or collinearity among the 
matrix columns? But I can't figure out how the matrix is singular in this case? 
Can someone show me why this is the case?

Thanks

Johntreat   group   y
3   1   0.659156868932769
2   2   0.531460140598938
5   2   0.111702043330297
3   2   0.531970057170838
3   2   0.190075619611889
6   2   0.0234142139088362
2   1   0.929225602652878
1   1   0.165439655771479
1   1   0.245642073685303
4   2   0.973135874373838
2   2   0.40159740881063
2   2   0.230675351573154
4   1   0.15201729699038
4   2   0.770770706702024
3   2   0.00170516152866185
7   1   0.475904347142205
7   1   0.477398047922179
2   2   0.57676896895282
2   2   0.17242363281548
1   1   0.263812917750329
1   1   0.332802928285673
7   1   0.999866250436753
7   2   0.0795505701098591
5   2   0.723311265930533
4   1   0.301724245771766
4   1   0.174829749623314
4   1   0.161948098335415
4   1   0.0022172573953867
3   1   0.815872102044523
3   1   0.953563597053289
7   1   0.687810138566419
7   1   0.305082862731069
1   1   0.742835792247206
1   1   0.643639815272763
4   1   0.751568211475387
6   1   0.844687921227887
4   2   0.315934179816395
5   1   0.884743785485625
5   1   0.316437228582799
3   2   0.00965709099546075
3   2   0.512446181615815
5   1   0.765263902954757
5   1   0.754491505213082
4   1   0.0271341009065509
7   1   0.242603822145611
7   1   0.12916071084328
6   1   0.531941789202392
6   1   0.043566432675
5   1   0.380349192768335
5   1   0.457562071271241
6   2   0.539795646909624
6   2   0.837911191163585
7   1   0.0539217721670866
1   1   0.910242940066382
1   1   0.129532726714388
5   1   0.440152890980244
3   1   0.945850990246981
3   1   0.53663158044219
5   2   0.866308335913345
5   2   0.142251220298931
7   2   0.0875730190891773
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Sampling with conditions

2011-11-07 Thread Ted Harding
On 07-Nov-11 22:22:54, SarahJoyes wrote:
> Hey everyone, 
> I am at best, an amateur user of R, but I am stuck on how
> to set-up the following situation. 
> I am trying to select a random sample of numbers from 0 to 10
> and insert them into the first column of a matrix (which will
> used later in a loop).
> However, I need to have those numbers add up to 10. How can
> I set those conditions?
> So far I have:
> n<-matrix(0,nr=5,ncol=10)
> for(i in 1:10){n[i,1]<-sample(0:10,1)}
> How do I set-up the "BUT sum(n[i,1])=10"?
> Thanks
> SarahJ

Sarah, your example is confusing because you have set up a
matrix 'n' with 5 rows and 10 columns. But your loop cycles
through 10 rows!

However, assuming that your basic requirement is to sample
10 integers which add up to 10, consider rmultinom():

  rmultinom(n=1,size=10,prob=(1:10)/10)
  #  [,1]
  # [1,]1
  # [2,]0
  # [3,]2
  # [4,]0
  # [5,]1
  # [6,]1
  # [7,]2
  # [8,]0
  # [9,]1
  #[10,]2
  rmultinom(n=1,size=10,prob=(1:10)/10)
  #  [,1]
  # [1,]0
  # [2,]0
  # [3,]0
  # [4,]0
  # [5,]1
  # [6,]1
  # [7,]2
  # [8,]1
  # [9,]2
  #[10,]3

This gives each integer in (0:10) equal chances of being
in the sample. For unequal chances, vary 'prob'.

Hoping this helps,
Ted.


E-Mail: (Ted Harding) 
Fax-to-email: +44 (0)870 094 0861
Date: 08-Nov-11   Time: 00:25:54
-- XFMail --

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


Re: [R] help with formula for clogit

2011-11-07 Thread Weidong Gu
clogit needs to spell out formula plus strata, you can try modify the code
...
d2=d[,c(mols,'group','Age','strata')]
fo<-as.formula(paste(paste('group~','Age',sep=''),'strata(strata)',sep='+'))
log.reg<-clogit(fo,data=d2)
...

Weidong

On Mon, Nov 7, 2011 at 10:19 AM, 1Rnwb  wrote:
> I would like to know if clogit function can be used as below
> clogit(group~., data=dataframe)
>
> When I try to use in above format it takes a long time, I would appreciate
> some pointers to get multiple combinations tested.
>
> set.seed(100)
>  d=data.frame(x=rnorm(20)+5,
>  x1=rnorm(20)+5,
>  x2=rnorm(20)+5,
>  x3=rnorm(20)+5,
>  x4=rnorm(20)+5,
>  x5=rnorm(20)+5,
>  x6=rnorm(20)+5,
>  x7=rnorm(20)+5,
>  x8=rnorm(20)+5,
> group=rep(c(1,2),10), Age=rnorm(20)+35,strata=c(rep(1,10), rep(2,10)))
>
> nam=names(d)[1:9]
> results <- c("Protein", "OR", "p-val")
> pc3=combinations(n=length(nam),r=2)
>
> for (len in 1:dim(pc3)[2])
>  {
>  prs=pc3[len,]
>  mols=nam[prs]
>  d2=d[,c(mols,'group','Age','strata')]
>  log.reg<-clogit(group~.,data=d2)
>  a = summary(log.reg)$conf.int
>  z= summary(log.reg)$coefficients[1,4]  #ncol in coefficients is 3 * number
> of parameters
>  pval  = 2*pnorm(-abs(z))
>  res2 = c(paste('IL8+',molecule,sep=''), paste (round(a[1,1],2), " ("  ,
> round(a[1,3],2), " - " , round(a[1,4],2), ")" , sep=""), pval)
>  results  = rbind (results ,res2 )
> }
>
> Thanks
> Sharad
>
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/help-with-formula-for-clogit-tp3998967p3998967.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

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


Re: [R] Sampling with conditions

2011-11-07 Thread Daniel Nordlund
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
> On Behalf Of SarahJoyes
> Sent: Monday, November 07, 2011 2:23 PM
> To: r-help@r-project.org
> Subject: [R] Sampling with conditions
> 
> Hey everyone,
> I am at best, an amateur user of R, but I am stuck on how to set-up the
> following situation.
> I am trying to select a random sample of numbers from 0 to 10 and insert
> them into the first column of a matrix (which will used later in a loop).
> However, I need to have those numbers add up to 10. How can I set those
> conditions?
> So far I have:
> n<-matrix(0,nr=5,ncol=10)
> for(i in 1:10){n[i,1]<-sample(0:10,1)}
> How do I set-up the "BUT sum(n[i,1])=10"?
> Thanks
> SarahJ
> 

Sarah,

Does something like this do what you want?

n <- matrix(0,nrow=5, ncol=10)
repeat{
  c1 <- sample(0:10, 4, replace=TRUE)
  if(sum(c1) <= 10) break
}
n[,1] <- c(c1,10-sum(c1))
n


Hope this is helpful,

Dan

Daniel Nordlund
Bothell, WA USA

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


Re: [R] False Virus detection with colorspace package?

2011-11-07 Thread John C Frain
Thanks.  This is exactly what I thought.  The idea was to check if
anyone else had detected a problem.  I have since discovered
http://virusscan.jotti.org which allows one to check the files using
20 different anti-virus programs.  Only AVG detected a virus. The
other 19 reported no problems.

Best Regards

John

On 7 November 2011 23:44, Jeff Newmiller  wrote:
> This kind of thing is all too common. You can download the source, review the 
> code, and build the package yourself, and compare the supplied binary with 
> your home-built one. Chances are AVG will complain about that one too, and 
> you can confirm the false positive. Anti virus software is not too friendly 
> with non-mainstream software.
> ---
> Jeff Newmiller                        The     .       .  Go Live...
> DCN:        Basics: ##.#.       ##.#.  Live Go...
>                                      Live:   OO#.. Dead: OO#..  Playing
> Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
> /Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
> ---
> Sent from my phone. Please excuse my brevity.
>
> John C Frain  wrote:
>
>>After updating to version 2.14 and copying packages from my Version
>>2.13.2 library  I ran
>>
>>update.packages(checkBuilt=TRUE,ask=FALSE) to update these packages.
>>This failed because AVG reported a virus in the "temporary" copy of
>>colorspace.dll created during the install and the update then failed
>>because it was unable to open this temporary file.  To continue I
>>deleted the colorspace packages and its reverse dependences and the
>>reverse dependencies of the reverse dependencies.  After deleting
>>these packages the update process then finished.
>>
>>I would presume that the virus is probably a false detection.  However
>>when I virus check the version 2.13.2 library AVG does not find a
>>virus.  As far as I can determine the only difference between the two
>>packages is that they are built with different versions of R.  I would
>>intend to reinstall these packages when the problem has been solved.
>>I am sending a report to AVG. For the moment I can fall back to the
>>earlier version if necessary.
>>
>>Has any one else detected a similar problem.
>>
>>An extract of the diagnosis sent to AVG is below.
>>
>>Best regards
>>
>>John
>>
>>AVG Free Version 2012.0.1869 Virus database 2092/4602 detects a virus
>>in the colorspace package in the R statistical system.  The zip file
>>containing the offending file can be downloaded from
>>
>>http://ftp.heanet.ie/mirrors/cran.r-project.org/bin/windows/contrib/r-release/colorspace_1.1-0.zip
>>or from any of the CRAN mirrors.
>>
>>The message produced by AVG is
>>
>>*
>>
>>File name:   c:\.\colourspace\libs\i386\colorspace.dll
>>
>>Threat name: Virus found Win32/Heur
>>
>>Detected on open
>>
>>*
>>
>>Is this a false positive?
>>
>>--
>>John C Frain
>>Economics Department
>>Trinity College Dublin
>>Dublin 2
>>Ireland
>>www.tcd.ie/Economics/staff/frainj/home.html
>>mailto:fra...@tcd.ie
>>mailto:fra...@gmail.com
>>
>>__
>>R-help@r-project.org mailing list
>>https://stat.ethz.ch/mailman/listinfo/r-help
>>PLEASE do read the posting guide
>>http://www.R-project.org/posting-guide.html
>>and provide commented, minimal, self-contained, reproducible code.
>
>



-- 
John C Frain
Economics Department
Trinity College Dublin
Dublin 2
Ireland
www.tcd.ie/Economics/staff/frainj/home.html
mailto:fra...@tcd.ie
mailto:fra...@gmail.com

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


Re: [R] False Virus detection with colorspace package?

2011-11-07 Thread Jeff Newmiller
This kind of thing is all too common. You can download the source, review the 
code, and build the package yourself, and compare the supplied binary with your 
home-built one. Chances are AVG will complain about that one too, and you can 
confirm the false positive. Anti virus software is not too friendly with 
non-mainstream software.
---
Jeff NewmillerThe .   .  Go Live...
DCN:Basics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
--- 
Sent from my phone. Please excuse my brevity.

John C Frain  wrote:

>After updating to version 2.14 and copying packages from my Version
>2.13.2 library  I ran
>
>update.packages(checkBuilt=TRUE,ask=FALSE) to update these packages.
>This failed because AVG reported a virus in the "temporary" copy of
>colorspace.dll created during the install and the update then failed
>because it was unable to open this temporary file.  To continue I
>deleted the colorspace packages and its reverse dependences and the
>reverse dependencies of the reverse dependencies.  After deleting
>these packages the update process then finished.
>
>I would presume that the virus is probably a false detection.  However
>when I virus check the version 2.13.2 library AVG does not find a
>virus.  As far as I can determine the only difference between the two
>packages is that they are built with different versions of R.  I would
>intend to reinstall these packages when the problem has been solved.
>I am sending a report to AVG. For the moment I can fall back to the
>earlier version if necessary.
>
>Has any one else detected a similar problem.
>
>An extract of the diagnosis sent to AVG is below.
>
>Best regards
>
>John
>
>AVG Free Version 2012.0.1869 Virus database 2092/4602 detects a virus
>in the colorspace package in the R statistical system.  The zip file
>containing the offending file can be downloaded from
>
>http://ftp.heanet.ie/mirrors/cran.r-project.org/bin/windows/contrib/r-release/colorspace_1.1-0.zip
>or from any of the CRAN mirrors.
>
>The message produced by AVG is
>
>*
>
>File name:   c:\.\colourspace\libs\i386\colorspace.dll
>
>Threat name: Virus found Win32/Heur
>
>Detected on open
>
>*
>
>Is this a false positive?
>
>-- 
>John C Frain
>Economics Department
>Trinity College Dublin
>Dublin 2
>Ireland
>www.tcd.ie/Economics/staff/frainj/home.html
>mailto:fra...@tcd.ie
>mailto:fra...@gmail.com
>
>__
>R-help@r-project.org mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] False Virus detection with colorspace package?

2011-11-07 Thread John C Frain
After updating to version 2.14 and copying packages from my Version
2.13.2 library  I ran

update.packages(checkBuilt=TRUE,ask=FALSE) to update these packages.
This failed because AVG reported a virus in the "temporary" copy of
colorspace.dll created during the install and the update then failed
because it was unable to open this temporary file.  To continue I
deleted the colorspace packages and its reverse dependences and the
reverse dependencies of the reverse dependencies.  After deleting
these packages the update process then finished.

I would presume that the virus is probably a false detection.  However
when I virus check the version 2.13.2 library AVG does not find a
virus.  As far as I can determine the only difference between the two
packages is that they are built with different versions of R.  I would
intend to reinstall these packages when the problem has been solved.
I am sending a report to AVG. For the moment I can fall back to the
earlier version if necessary.

Has any one else detected a similar problem.

An extract of the diagnosis sent to AVG is below.

Best regards

John

AVG Free Version 2012.0.1869 Virus database 2092/4602 detects a virus
in the colorspace package in the R statistical system.  The zip file
containing the offending file can be downloaded from

http://ftp.heanet.ie/mirrors/cran.r-project.org/bin/windows/contrib/r-release/colorspace_1.1-0.zip
or from any of the CRAN mirrors.

The message produced by AVG is

*

File name:   c:\.\colourspace\libs\i386\colorspace.dll

Threat name: Virus found Win32/Heur

Detected on open

*

Is this a false positive?

-- 
John C Frain
Economics Department
Trinity College Dublin
Dublin 2
Ireland
www.tcd.ie/Economics/staff/frainj/home.html
mailto:fra...@tcd.ie
mailto:fra...@gmail.com

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


Re: [R] Sampling with conditions

2011-11-07 Thread Weidong Gu
Not sure this is valid that you can have 9 random samples out of 10,
but the last one has to be fixed to meet the restraint, sum=10.

Weidong

On Mon, Nov 7, 2011 at 5:22 PM, SarahJoyes  wrote:
> Hey everyone,
> I am at best, an amateur user of R, but I am stuck on how to set-up the
> following situation.
> I am trying to select a random sample of numbers from 0 to 10 and insert
> them into the first column of a matrix (which will used later in a loop).
> However, I need to have those numbers add up to 10. How can I set those
> conditions?
> So far I have:
> n<-matrix(0,nr=5,ncol=10)
> for(i in 1:10){n[i,1]<-sample(0:10,1)}
> How do I set-up the "BUT sum(n[i,1])=10"?
> Thanks
> SarahJ
>
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/Sampling-with-conditions-tp4014036p4014036.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

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


Re: [R] DESeq

2011-11-07 Thread R. Michael Weylandt
This is one of those quirky R moments, try something like
as.integer(as.character(DATA)).

Michael

On Mon, Nov 7, 2011 at 4:24 PM, Eric  wrote:
> Hello,
>
> I have RNAseq data, which I am trying to analyze with DESeq. My file (tab 
> delimited .txt) appears to be correct:
>
>>head(myfile)
>        VZ_w13 VZ_w14a VZ_w14b VZ_w15a VZ_w15b VZ_w16a
>        ENSG0253101      0       0       0       0       0       0
>        ENSG0223972      0       0       0       0       0       0...
>
> However, when I try to analyze the data with
>
>>cds <- newCountDataSet(myfile,conds)
>
> I get the following message:
>
> "Error in newCountDataSet(myfile,conds) : The countData is not integer.
>
> The problem, as far as I can tell, is that my data are numerical, not 
> integer, because when I run
>
>>str(myfile)
>        'data.frame':   53433 obs. of  14 variables:
>         $ VZ_w13   : num  0 0 0 0 8 0 0 0 0 0 ...
>
> Does anyone have a way to convert my file from numerical to integer? As you 
> can see, the data are in fact integers are already, so I'm a bit confused.
>
> Thanks,
> Eric
>
>
>        [[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] RpgSQL row names

2011-11-07 Thread Gabor Grothendieck
On Mon, Nov 7, 2011 at 5:34 PM, Ben quant  wrote:
> Hello,
>
> Using the RpgSQL package, there must be a way to get the row names into the
> table automatically. In the example below, I'm trying to get rid of the
> cbind line, yet have the row names of the data frame populate a column.
>
>> bentest = matrix(1:4,2,2)
>> dimnames(bentest) = list(c('ra','rb'),c('ca','cb'))
>> bentest
>   ca cb
> ra  1  3
> rb  2  4
>> bentest = cbind(item_name=rownames(bentest),bentest)
>> dbWriteTable(con, "r.bentest", bentest)
> [1] TRUE
>> dbGetQuery(con, "SELECT * FROM r.bentest")
>  item_name ca cb
> 1        ra  1  3
> 2        rb  2  4
>
>

The RJDBC based drivers currently don't support that. You can create a
higher level function that does it.

dbGetQuery2 <- function(...) {
  out <- dbGetQuery(...)
  i <- match("row_names", names(out), nomatch = 0)
  if (i > 0) {
rownames(out) <- out[[i]]
out <- out[-1]
  }
  out
}

rownames(BOD) <- letters[1:nrow(BOD)]
dbWriteTable(con, "BOD", cbind(row_names = rownames(BOD), BOD))
dbGetQuery2(con, "select * from BOD")

-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

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


Re: [R] rearrange set of items randomly

2011-11-07 Thread David Winsemius


On Nov 7, 2011, at 4:09 PM, flokke wrote:


Dear all,
I hope that this question is not too weird, I will try to explain it  
as good

as I can.

I have to write a function for a school project and one limitation  
is that I

may not use the in built function sample()

At one point in the function I would like to resample/rearrange the  
items of
my sample (so I would want to use sample, but I am not allowed to do  
so), so
I have to come up with sth else that does the same as the in built  
function

sample()

The only thing that sample() does is rearranging the items of a  
sample, so I
searched the internet for a function that does that to be able to  
use it,

but I cannot find anything that could help me.

Can maybe someone help me with this?
I would be very grateful,


May I suggests thinking about the ordering of random variables?

--

David Winsemius, MD
West Hartford, CT

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


Re: [R] Aggregate or extract function ?

2011-11-07 Thread Jean V Adams
Celine wrote on 11/07/2011 02:50:55 PM:
> 
> Hi R user,
> 
> I have two dataframe with different variables and coordinates :
>X Y sp bio3 bio5 bio6 bio13 bio14
> 1 -70.91667 -45.08333  0   47  194  -274712
> 2 -86.58333  66.25000  0   16  119 -34542 3
> 3 -62.58333 -17.91667  0   68  334  152   14428
> 4 -68.91667 -31.25000  0   54  235  -4525 7
> 5  55.58333  48.41667  0   23  319 -1722314
> 6  66.25000  37.75000  0   34  363  -1849 0
> 
> and this one :
> 
>  X  Y LU1 LU2 LU3 LU4 LU5 LU6 LU7 LU8 LU9 LU10 LU11 LU12 LU13   LU14
> LU15 LU16 LU17 LU18
> 1 -36.5 84   0   0   0   0   0   0   0   0   00000 
> 0.000000
> 2 -36.0 84   0   0   0   0   0   0   0   0   00000 
> 0.000000
> 3 -35.5 84   0   0   0   0   0   0   0   0   00000 
> 26.0854680000
> 4 -35.0 84   0   0   0   0   0   0   0   0   00000 
> 0.000000
> 5 -34.5 84   0   0   0   0   0   0   0   0   00000 
> 5.2677610000
> 6 -34.0 84   0   0   0   0   0   0   0   0   00000
> 105.3710690000
> 
> I wouldlike to add to my first dataframe the value of the LU variables 
at
> the coordinates of the first dataframe. Of course, the coordinates are 
not
> at the same resolution and are different, this is the problem.
>  I wouldlike to decrease the resolution of the first one because the 
second
> dataframe have a coarser resolution and obtain something like that :
> 
>X Y sp bio3 bio5 bio6 bio13 bio14 LU1 LU2 LU3 LU4 ...
> 1 -70.91667 -45.08333  0   47  194  -274712 0 22.08 76.9
> 2 -86.58333  66.25000  0   16  119 -34542 3 0 22.08 76.9
> 3 -62.58333 -17.91667  0   68  334  152   14428 0 22.08 76.9
> 4 -68.91667 -31.25000  0   54  235  -4525 7 0 22.08 76.9
> 5  55.58333  48.41667  0   23  319 -1722314 0 22.08 76.9
> 6  66.25000  37.75000  0   34  363  -1849 0 0 22.08 76.9
> 
> Do someone know a function or a way to do obtain that ?
> 
> Thanks in advance for the help,
> Céline


You could use 1-nearest neighbor classification to find the closest set of 
coordinates in the second data frame (df2) to each row of coordinates in 
the first data frame (df1).  The function knn1() is in the r package 
"class".  For example:

library(class)

train <- df2[, c("X", "Y")]
test <- df1[, c("X", "Y")]
cl <- 1:dim(train)[1]
rowz <- knn1(train, test, cl)
data.frame(df1, df2[rowz, ])

Jean

[[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] Adding lines to scatterplot odd result when creating multiple plots

2011-11-07 Thread markm0705
Dear R helpers

I'm attempting to create a matrix of scatterplots with X-Y mean lines and
regression lines added to each plot in the matrix.  I have managed to create
the first plot I would like using scatterplot but have run into an odd
result when I use par() to set up the page to take multiple plot. 
Specifically, the mean and regression lines appear to plot in the second
plot window, not on top of the scatterplot (when I include the par(mfcol)
command).  

How do I get the scatterplot and added lines to stay together on this plot
and subsequent plots I would like to include in the scatterplot matrix

Data attached

Thanks in advance MarkM

library("car")

par(mfcol=c(1,2))

# Parameters to change

Infile<-"kt3d_Thk1.dat"
X<-"Estimated thickness (mE)"
Y<-"True thickness (mE)"

#load data
#read the data skip then read header

crossval <- read.table(Infile,skip = 9,sep = "")
head<-readLines(Infile,9)

#decode the header lines wanted

head2<-head[3:9]
colnames(crossval)=head2

#Filter out non-estimated

crossval2<-crossval[crossval$Estimate>0,]

# Compute the means

AveEst<-mean(crossval2$Estimate)
AveTru<-mean(crossval2$True)

#Fit the regression line

Fit<-lm(crossval2$True~crossval2$Estimate )

#create plots

scatterplot(True ~ Estimate,
data=crossval2,
xlab= X,
ylab= Y,
main= "Min 4 Max 8",
grid=FALSE,
xlim=c(0,8),
ylim=c(0,8),
pch=21,
cex=1.2,
smooth=FALSE,
reg.line=FALSE
)


#Plot mean lines and regression

abline(h=AveTru,col="grey70")
abline(v=AveEst,col="grey70")
abline(0,1,col="red")
abline(lm(crossval2$True~crossval2$Estimate), col="blue", lty=1, lwd=2)

--
View this message in context: 
http://r.789695.n4.nabble.com/Adding-lines-to-scatterplot-odd-result-when-creating-multiple-plots-tp4014140p4014140.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] geoR, variofit/likfit

2011-11-07 Thread katiab81
hi,
I have a problem with the functions variofit ant likfit.
I have to chose the more appropriate variogram model for my specific problem
and data.
I write the alghoritm has follows:

library(geoR)
data(wolfcamp)
v.e<-variog(wolfcamp)
exp.vario<-variofit(v.e,ini.cov.pars=c(175226.94,139.81),cov.model="exponential",nugget=21903.37)
lines(exp.vario,col=1)
sph.vario<-variofit(v.e,ini.cov.pars=c(175226.94,139.81),cov.model="spherical",nugget=21903.37)
lines(sph.vario,col=2)
.
exp.lik<-likfit(wolfcamp,coords=wolfcamp$coords,data=wolfcamp$data,ini.cov.pars=c(175226.94,139.81),cov.model="exponential",trend="cte",fix.kappa=FALSE,nugget=21903,37)
lines(exp.lik,col=5)
sph.lik<-likfit(wolfcamp,coords=wolfcamp$coords,data=wolfcamp$data,ini.cov.pars=c(175226.94,139.81),cov.model="spherical",trend="cte",fix.kappa=FALSE,nugget=21903,37)
lines(sph.lik,col=6)


the lines of the resultant variograms are different using variofit or
likfit, but when I change the cov.model (from exp to sph or lin) the
program gives identical result.

I think this is incorrect
can you tell me if I made any mistake in the implementations of the
algorithm. 

thank you. 
P.S. sorry for my english.

katia



--
View this message in context: 
http://r.789695.n4.nabble.com/geoR-variofit-likfit-tp4013734p4013734.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] Sampling with conditions

2011-11-07 Thread SarahJoyes
Hey everyone, 
I am at best, an amateur user of R, but I am stuck on how to set-up the
following situation. 
I am trying to select a random sample of numbers from 0 to 10 and insert
them into the first column of a matrix (which will used later in a loop).
However, I need to have those numbers add up to 10. How can I set those
conditions?
So far I have:
n<-matrix(0,nr=5,ncol=10)
for(i in 1:10){n[i,1]<-sample(0:10,1)}
How do I set-up the "BUT sum(n[i,1])=10"?
Thanks
SarahJ

--
View this message in context: 
http://r.789695.n4.nabble.com/Sampling-with-conditions-tp4014036p4014036.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] DESeq

2011-11-07 Thread Eric
Hello,

I have RNAseq data, which I am trying to analyze with DESeq. My file (tab 
delimited .txt) appears to be correct:

>head(myfile)
VZ_w13 VZ_w14a VZ_w14b VZ_w15a VZ_w15b VZ_w16a
ENSG0253101  0   0   0   0   0   0
ENSG0223972  0   0   0   0   0   0...

However, when I try to analyze the data with

>cds <- newCountDataSet(myfile,conds)

I get the following message:

"Error in newCountDataSet(myfile,conds) : The countData is not integer.

The problem, as far as I can tell, is that my data are numerical, not integer, 
because when I run

>str(myfile)
'data.frame':   53433 obs. of  14 variables:
 $ VZ_w13   : num  0 0 0 0 8 0 0 0 0 0 ...

Does anyone have a way to convert my file from numerical to integer? As you can 
see, the data are in fact integers are already, so I'm a bit confused. 

Thanks,
Eric


[[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] rearrange set of items randomly

2011-11-07 Thread flokke
Dear all,
I hope that this question is not too weird, I will try to explain it as good
as I can.

I have to write a function for a school project and one limitation is that I
may not use the in built function sample()

At one point in the function I would like to resample/rearrange the items of
my sample (so I would want to use sample, but I am not allowed to do so), so
I have to come up with sth else that does the same as the in built function
sample()

The only thing that sample() does is rearranging the items of a sample, so I
searched the internet for a function that does that to be able to use it,
but I cannot find anything that could help me. 

Can maybe someone help me with this?
I would be very grateful,

Cheers,
Maria

--
View this message in context: 
http://r.789695.n4.nabble.com/rearrange-set-of-items-randomly-tp4013723p4013723.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] RpgSQL row names

2011-11-07 Thread Ben quant
Hello,

Using the RpgSQL package, there must be a way to get the row names into the
table automatically. In the example below, I'm trying to get rid of the
cbind line, yet have the row names of the data frame populate a column.

> bentest = matrix(1:4,2,2)
> dimnames(bentest) = list(c('ra','rb'),c('ca','cb'))
> bentest
   ca cb
ra  1  3
rb  2  4
> bentest = cbind(item_name=rownames(bentest),bentest)
> dbWriteTable(con, "r.bentest", bentest)
[1] TRUE
> dbGetQuery(con, "SELECT * FROM r.bentest")
  item_name ca cb
1ra  1  3
2rb  2  4


Thanks,
Ben

[[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] vars impulse response function output

2011-11-07 Thread Richard Saba
Sorry about first post. This is in plain text.


Does anyone know if the  bootstrap  CI intervals generated by the irf()
function (impulse response function) in the " vars"  package are bias
corrected?
Thanks,
Richard Saba

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


Re: [R] Correction in error

2011-11-07 Thread Dennis Murphy
Hi:

In your function call, x[1, 1] = theta = 0. In the first line of the
loop, your rbinom() call works out to be
  x[2, 1] <- rbinom(x[1, 3], 1, x[1, 1])   <=> rbinom(10, 1, 0)

That likely accounts for the error message:
Error in x[t, 1] <- rbinom(x[t - 1, 3], 1, x[t - 1, 1]) :
  replacement has length zero

HTH,
Dennis

On Mon, Nov 7, 2011 at 12:10 PM, Gyanendra Pokharel
 wrote:
> Hello R community, following is my code and it shows error, can some one
> fix this error and explain why this occurs?
>
> gibbs <-function(m,n, theta = 0, lambda = 1){
>    alpha <- 1.5
>    beta <- 1.5
>    gamma <- 1.5
>    x<- array(0,c(m+1, 3))
>    x[1,1] <- theta
>    x[1,2] <- lambda
>    x[1,3]<- n
>    for(t in 2:m+1){
>        x[t,1] <- rbinom(x[t-1,3], 1, x[t-1,1])
>        x[t,2]<-rbeta(m, x[t-1,1] + alpha, tx[t-1,3] - x[t-1,1] + beta)
>        x[t,3] <- rpois(x[t-1,3] - x[t-1,1],(1 - x[t-1,2])*gamma)
>    }
>    x
> }
> gibbs(100, 10)
>
> Gyn
>
>        [[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] Aggregate or extract function ?

2011-11-07 Thread Celine
Hi R user,

I have two dataframe with different variables and coordinates :
   X Y sp bio3 bio5 bio6 bio13 bio14
1 -70.91667 -45.08333  0   47  194  -274712
2 -86.58333  66.25000  0   16  119 -34542 3
3 -62.58333 -17.91667  0   68  334  152   14428
4 -68.91667 -31.25000  0   54  235  -4525 7
5  55.58333  48.41667  0   23  319 -1722314
6  66.25000  37.75000  0   34  363  -1849 0

and this one :

 X  Y LU1 LU2 LU3 LU4 LU5 LU6 LU7 LU8 LU9 LU10 LU11 LU12 LU13   LU14
LU15 LU16 LU17 LU18
1 -36.5 84   0   0   0   0   0   0   0   0   00000  
0.000000
2 -36.0 84   0   0   0   0   0   0   0   0   00000  
0.000000
3 -35.5 84   0   0   0   0   0   0   0   0   00000 
26.0854680000
4 -35.0 84   0   0   0   0   0   0   0   0   00000  
0.000000
5 -34.5 84   0   0   0   0   0   0   0   0   00000  
5.2677610000
6 -34.0 84   0   0   0   0   0   0   0   0   00000
105.3710690000

I wouldlike to add to my first dataframe the value of the LU variables at
the coordinates of the first dataframe. Of course, the coordinates are not
at the same resolution and are different, this is the problem.
 I wouldlike to decrease the resolution of the first one because the second
dataframe have a coarser resolution and obtain something like that :

   X Y sp bio3 bio5 bio6 bio13 bio14 LU1 LU2 LU3 LU4 ...
1 -70.91667 -45.08333  0   47  194  -274712 0 22.08 76.9
2 -86.58333  66.25000  0   16  119 -34542 3 0 22.08 76.9
3 -62.58333 -17.91667  0   68  334  152   14428 0 22.08 76.9
4 -68.91667 -31.25000  0   54  235  -4525 7 0 22.08 76.9
5  55.58333  48.41667  0   23  319 -1722314 0 22.08 76.9
6  66.25000  37.75000  0   34  363  -1849 0 0 22.08 76.9

Do someone know a function or a way to do obtain that ?

Thanks in advance for the help,
Céline


--
View this message in context: 
http://r.789695.n4.nabble.com/Aggregate-or-extract-function-tp4013673p4013673.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Correction in error

2011-11-07 Thread William Dunlap
A possible third problem is that
   2:m+1
is the same as
   (2:m) + 1
and you probably want
   2:(m+1)

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com 

> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
> Behalf Of Sarah Goslee
> Sent: Monday, November 07, 2011 12:26 PM
> To: Gyanendra Pokharel
> Cc: R-help@r-project.org
> Subject: Re: [R] Correction in error
> 
> Hi,
> 
> I see two problems right off:
> 
> On Mon, Nov 7, 2011 at 3:10 PM, Gyanendra Pokharel
>  wrote:
> > Hello R community, following is my code and it shows error, can some one
> > fix this error and explain why this occurs?
> >
> > gibbs <-function(m,n, theta = 0, lambda = 1){
> >    alpha <- 1.5
> >    beta <- 1.5
> >    gamma <- 1.5
> >    x<- array(0,c(m+1, 3))
> >    x[1,1] <- theta
> >    x[1,2] <- lambda
> >    x[1,3]<- n
> >    for(t in 2:m+1){
> >        x[t,1] <- rbinom(x[t-1,3], 1, x[t-1,1])
> 
> The rbinom() command here returns a vector of values, but you're
> trying to assign it to a single matrix element. You might want to
> double-check the help for rbinom() again.
> 
> 
> >        x[t,2]<-rbeta(m, x[t-1,1] + alpha, tx[t-1,3] - x[t-1,1] + beta)
> 
> tx isn't defined, but is probably a typo for x
> 
> >        x[t,3] <- rpois(x[t-1,3] - x[t-1,1],(1 - x[t-1,2])*gamma)
> >    }
> >    x
> > }
> > gibbs(100, 10)
> 
> With a nice short function such as this, it's easy to set your
> arguments to their default values and actually run the function line
> by line at the command prompt so you can see whether what is happening
> is what you expect.
> 
> Sarah
> 
> --
> Sarah Goslee
> http://www.functionaldiversity.org
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] Correction in error

2011-11-07 Thread R. Michael Weylandt
The first argument to rbinom() is how many random samples you want to
draw, not whatever you seem to think it is. It's not matching the size
of what you mean to assign it to: in particular note that x[t-1, 3] is
zero for t=3 which is where you initialize it. (I.e., you are also
probably getting tripped up by an order of operations error)

Michael

On Mon, Nov 7, 2011 at 3:10 PM, Gyanendra Pokharel
 wrote:
> Hello R community, following is my code and it shows error, can some one
> fix this error and explain why this occurs?
>
> gibbs <-function(m,n, theta = 0, lambda = 1){
>    alpha <- 1.5
>    beta <- 1.5
>    gamma <- 1.5
>    x<- array(0,c(m+1, 3))
>    x[1,1] <- theta
>    x[1,2] <- lambda
>    x[1,3]<- n
>    for(t in 2:m+1){
>        x[t,1] <- rbinom(x[t-1,3], 1, x[t-1,1])
>        x[t,2]<-rbeta(m, x[t-1,1] + alpha, tx[t-1,3] - x[t-1,1] + beta)
>        x[t,3] <- rpois(x[t-1,3] - x[t-1,1],(1 - x[t-1,2])*gamma)
>    }
>    x
> }
> gibbs(100, 10)
>
> Gyn
>
>        [[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] Correction in error

2011-11-07 Thread Sarah Goslee
Hi,

I see two problems right off:

On Mon, Nov 7, 2011 at 3:10 PM, Gyanendra Pokharel
 wrote:
> Hello R community, following is my code and it shows error, can some one
> fix this error and explain why this occurs?
>
> gibbs <-function(m,n, theta = 0, lambda = 1){
>    alpha <- 1.5
>    beta <- 1.5
>    gamma <- 1.5
>    x<- array(0,c(m+1, 3))
>    x[1,1] <- theta
>    x[1,2] <- lambda
>    x[1,3]<- n
>    for(t in 2:m+1){
>        x[t,1] <- rbinom(x[t-1,3], 1, x[t-1,1])

The rbinom() command here returns a vector of values, but you're
trying to assign it to a single matrix element. You might want to
double-check the help for rbinom() again.


>        x[t,2]<-rbeta(m, x[t-1,1] + alpha, tx[t-1,3] - x[t-1,1] + beta)

tx isn't defined, but is probably a typo for x

>        x[t,3] <- rpois(x[t-1,3] - x[t-1,1],(1 - x[t-1,2])*gamma)
>    }
>    x
> }
> gibbs(100, 10)

With a nice short function such as this, it's easy to set your
arguments to their default values and actually run the function line
by line at the command prompt so you can see whether what is happening
is what you expect.

Sarah

-- 
Sarah Goslee
http://www.functionaldiversity.org

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


[R] Upgrade R?

2011-11-07 Thread Kevin Burton
I am trying to upgrade to R 2.14 from R 2.13.1 I have compied all the
libraries from the 'library' directory in my existing installation (2.13.1)
to the installed R 2.14. Now I want to uninstall the old installation (R
2.13.1) and I get the error:

 

Internal Error: Cannot find utCompiledCode record for this version of the
uninstaller.

 

Any ideas?

 

Kevin


[[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] Correction in error

2011-11-07 Thread Gyanendra Pokharel
Hello R community, following is my code and it shows error, can some one
fix this error and explain why this occurs?

gibbs <-function(m,n, theta = 0, lambda = 1){
alpha <- 1.5
beta <- 1.5
gamma <- 1.5
x<- array(0,c(m+1, 3))
x[1,1] <- theta
x[1,2] <- lambda
x[1,3]<- n
for(t in 2:m+1){
x[t,1] <- rbinom(x[t-1,3], 1, x[t-1,1])
x[t,2]<-rbeta(m, x[t-1,1] + alpha, tx[t-1,3] - x[t-1,1] + beta)
x[t,3] <- rpois(x[t-1,3] - x[t-1,1],(1 - x[t-1,2])*gamma)
}
x
}
gibbs(100, 10)

Gyn

[[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] Regression-Discontinuity Analysis

2011-11-07 Thread Jose Bustos Melo
Hi everyone,

In social reseach, economic and others fields "Non-Equivalent Groups Analysis" 
shows an issue when data are biased between Posttest and Pretest. Many authors 
talk about the Regression-Discontinuity Analysis wich is used when dispersion 
are different in both groups (in this case Control vs. Treatment). I have found 
this function that seems to work well finding this problem (sm.discontinuity), 
also fixing this problem in is not trivial among reseachers.

A good source of theorical information correcting this problem can be found 
here: http://www.socialresearchmethods.net/kb/statnegd.php

Someone knows if there's any way to do this through R?

Thanks in advance!
José
[[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] Doing dist on separate objects in a text file

2011-11-07 Thread jim holtman
Is this what you want:

> x <- read.table(textConnection('"Label" "X" "Y" "Slice"
+ 1   "Field_1_R3D_D3D_PRJ_w617.tif"  348 506 1
+ 2   "Field_1_R3D_D3D_PRJ_w617.tif"  359 505 1
+ 3   "Field_1_R3D_D3D_PRJ_w617.tif"  356 524 1
+ 4   "Field_1_R3D_D3D_PRJ_w617.tif"  2   0   1
+ 5   "Field_1_R3D_D3D_PRJ_w617.tif"  412 872 1
+ 6   "Field_1_R3D_D3D_PRJ_w617.tif"  422 863 1
+ 7   "Field_1_R3D_D3D_PRJ_w617.tif"  429 858 1
+ 8   "Field_1_R3D_D3D_PRJ_w617.tif"  429 880 1
+ 9   "Field_1_R3D_D3D_PRJ_w617.tif"  437 865 1
+ 10  "Field_1_R3D_D3D_PRJ_w617.tif"  447 855 1
+ 11  "Field_1_R3D_D3D_PRJ_w617.tif"  450 868 1
+ 12  "Field_1_R3D_D3D_PRJ_w617.tif"  447 875 1
+ 13  "Field_1_R3D_D3D_PRJ_w617.tif"  439 885 1
+ 14  "Field_1_R3D_D3D_PRJ_w617.tif"  2   8   1'), header =
TRUE, as.is = TRUE)
> closeAllConnections()
> # create column to segment the data
> x$mark <- cumsum(x$X < 10)
> # now remove separators
> x <- subset(x, X >= 10)
> # now split the data
> x.s <- split(x, x$mark)
> # now do the dist
> lapply(x.s, function(a) dist(a[, c("X", "Y")]))
$`0`
 12
2 11.04536
3 19.69772 19.23538

$`1`
   5 6 7 8 910
1112
6  13.453624
7  22.022716  8.602325
8  18.788294 18.384776 22.00
9  25.961510 15.132746 10.630146 17.00
10 38.910153 26.248809 18.248288 30.805844 14.142136
11 38.209946 28.442925 23.259407 24.186773 13.341664 13.341664
12 35.128336 27.730849 24.758837 18.681542 14.142136 20.00
7.615773
13 29.966648 27.802878 28.792360 11.180340 20.099751 31.048349
20.248457 12.806248


On Sun, Nov 6, 2011 at 3:49 PM, ScottDaniel  wrote:
>>
>> On Nov 5, 2011, at 7:20 PM, ScottDaniel wrote:
>>
>> > So I have a text file that looks like this:
>> > "Label"     "X"     "Y"     "Slice"
>> > 1   "Field_1_R3D_D3D_PRJ_w617.tif"  348     506     1
>> > 2   "Field_1_R3D_D3D_PRJ_w617.tif"  359     505     1
>> > 3   "Field_1_R3D_D3D_PRJ_w617.tif"  356     524     1
>> > 4   "Field_1_R3D_D3D_PRJ_w617.tif"  2       0       1
>> > 5   "Field_1_R3D_D3D_PRJ_w617.tif"  412     872     1
>> > 6   "Field_1_R3D_D3D_PRJ_w617.tif"  422     863     1
>> > 7   "Field_1_R3D_D3D_PRJ_w617.tif"  429     858     1
>> > 8   "Field_1_R3D_D3D_PRJ_w617.tif"  429     880     1
>> > 9   "Field_1_R3D_D3D_PRJ_w617.tif"  437     865     1
>> > 10  "Field_1_R3D_D3D_PRJ_w617.tif"  447     855     1
>> > 11  "Field_1_R3D_D3D_PRJ_w617.tif"  450     868     1
>> > 12  "Field_1_R3D_D3D_PRJ_w617.tif"  447     875     1
>> > 13  "Field_1_R3D_D3D_PRJ_w617.tif"  439     885     1
>> > 14  "Field_1_R3D_D3D_PRJ_w617.tif"  2       8       1
>> >
>> > What it represents are the locations of centromeres per nucleus in a
>> > microscope image. What I need to do is do a dist() on each grouping
>> > (the
>> > grouping being separated by the low values of x and y's) and then
>> > compute an
>> > average. The part that I'm having trouble with is writing code that
>> > will
>> > allow R to separate these objects.
>>
>> I'm having trouble figuring out what you mean by "separating the
>> objects". Each row is a separate reading, and I think you just want
>> pairwise distances, right?
>
> What I mean is that rows 1-3 represent one group of centromeres and
> rows 5-13 represent a second group. So I want to do a separate dist on
> each group (i.e. I want a pair wise distance for rows 1 and 3 but not
> 1 and 12). Does that clear thing up?
>
>
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/Doing-dist-on-separate-objects-in-a-text-file-tp3994515p3996701.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.
>



-- 
Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.

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


Re: [R] Estimate of intercept in loglinear model

2011-11-07 Thread Mark Difford
On Nov 07, 2011 at 7:59pm Colin Aitken wrote:

> How does R estimate the intercept term \alpha in a loglinear 
> model with Poisson model and log link for a contingency table of counts?

Colin,

If you fitted this using a GLM then the default in R is to use so-called
treatment contrasts (i.e. Dunnett contrasts). See ?contr.treatment. Take the
first example on the ?glm help page

## Dobson (1990) Page 93: Randomized Controlled Trial :
counts <- c(18,17,15,20,10,20,25,13,12)
outcome <- gl(3,1,9)
treatment <- gl(3,3)
print(d.AD <- data.frame(treatment, outcome, counts))
glm.D93 <- glm(counts ~ outcome + treatment, family=poisson())
anova(glm.D93)
summary(glm.D93)

< snip >
Coefficients:
  Estimate Std. Error z value Pr(>|z|)
(Intercept)  3.045e+00  1.709e-01  17.815   <2e-16 ***
outcome2-4.543e-01  2.022e-01  -2.247   0.0246 *  
outcome3-2.930e-01  1.927e-01  -1.520   0.1285
treatment2   1.338e-15  2.000e-01   0.000   1.
treatment3   1.421e-15  2.000e-01   0.000   1.
< snip >

> levels(outcome)
[1] "1" "2" "3"
> levels(treatment)
[1] "1" "2" "3"

So here the intercept represents the estimated counts at the first level of
"outcome" (i.e. outcome = 1) and the first level of "treatment" (i.e.
treatment = 1).

> predict(glm.D93, newdata=data.frame(outcome="1", treatment="1"))
   1 
3.044522

Regards, Mark.

-
Mark Difford (Ph.D.)
Research Associate
Botany Department
Nelson Mandela Metropolitan University
Port Elizabeth, South Africa
--
View this message in context: 
http://r.789695.n4.nabble.com/Estimate-of-intercept-in-loglinear-model-tp4009905p4012346.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] Comparing Excel to R for Standard Curves

2011-11-07 Thread minda berbeco
Hello,

In the past I have used Excel for creating standard curves.  I recently
switched to R using the lm function to create my curves instead, but find
the results are slightly different even though my y-intercept and slope are
the same.  A friend told me that the difference was due to R and Excel
using a different algorithm to calculate the line.  Has anyone run into
this problem before?

Thank you in advance,

Minda


-- 
Minda R Berbeco, PhD
Steenwerth Lab
Viticulture & Enology
University of California, Davis
https://sites.google.com/site/mindaberbeco/

[[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] Estimate of intercept in loglinear model

2011-11-07 Thread Mark Difford
On Nov 07, 2011 at 9:04pm Mark Difford wrote:

> So here the intercept represents the estimated counts...

Perhaps I should have added (though surely unnecessary in your case) that
exponentiation gives the predicted/estimated counts, viz 21 (compared to 18
for the saturated model).

##
> exp(3.044522)
[1] 20.9

Regards, Mark.

-
Mark Difford (Ph.D.)
Research Associate
Botany Department
Nelson Mandela Metropolitan University
Port Elizabeth, South Africa
--
View this message in context: 
http://r.789695.n4.nabble.com/Estimate-of-intercept-in-loglinear-model-tp4009905p4012723.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] ordination in vegan: what does downweight() do?

2011-11-07 Thread kelsmith
Can anyone point me in the right direction of figuring out what downweight()
is doing?
 
I am using vegan to perform CCA on diatom assemblage data. I have a lot of
rare species, so I want to reduce the influence of rare species in my CCA. I
have read that some authors reduce rare species by only including species
with an abundance of at least 1% in at least one sample (other authors use
5% as a rule, but this removes at least half my species). If I code it as
follows:

cca(downweight(diatoms, fraction=5) ~ ., env)

It is clearly not removing these species entirely from analysis, as some
authors suggest. So I am wondering: what is downweight() doing exactly? I
assume it is somehow ranking the species and reducing their abundance values
based on their rank, but I'm not entirely sure and can't seem to figure out
how to look at the code (R novice here). Nor can I find a clear description
within the documentation (although I may be looking in all the wrong
places).  

So, my inclination is to remove species that are very rare (max abundance <
1%) prior to the CCA and then use the downweight function (fraction = 5?) in
my CCA (as above). This way, I can include most of my species, but overall
still reduce the impact of rare species. 

Any advice is appreciated. Thanks!

--
View this message in context: 
http://r.789695.n4.nabble.com/ordination-in-vegan-what-does-downweight-do-tp4010352p4010352.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Lower bounds on selfStart function not working

2011-11-07 Thread Schatzi
I ran the code again and got an error saying that the "x" was unknown. I
don't know why I hadn't seen that error before. Anyway, I made the edits to
"func1" so instead of "x", it is "xy$x."
#function to optimize
func1 <- function(value) {
   A.s  <- value[1]
   mu.s  <- value[2]
   l.s <- value[3]
   b.s<- value[4]
  y1<-rep(0,length(xy$x)) # generate vector for predicted y (y1) to evaluate
against observed y
  for(cnt in 1:length(xy$x)){
  y1[cnt]<- b.s+A.s/(1+exp(4*mu.s/A.s*(l.s-xy$x[cnt])+2))}  #predicting y1
for values of y
  evl<-sum((xy$y-y1)^2) #sum of squares is function to minimize
  return(evl)}


There is another place where there is an "x" in the selfStart function:
SSpowrDplt<-selfStart(~b+A/(1+exp(4*mu/A*(l-x)+2)),initial=powrDpltInit,
parameters=c("A","mu","l","b"))

I don't know why that is working fine or how it knows that my "x" is that
specific one. It seems that I am not fully understanding how this is
working.

-
In theory, practice and theory are the same. In practice, they are not - Albert 
Einstein
--
View this message in context: 
http://r.789695.n4.nabble.com/Lower-bounds-on-selfStart-function-not-working-tp3999231p4012805.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] [R-pkgs] new version 2.0-0 of the sem package

2011-11-07 Thread John Fox
Dear R users,

Jarrett Byrnes and I would like to announce version 2.0-0 of the sem package
for fitting observed- and latent-variable structural equation models. This
is a general reworking of the original sem package (which is still available
on R-Forge as package sem1). 

Some highlights of sem 2.0-0 include:

o  More convenient and compact model specification, including the default
automatic generation of error variances for endogenous variables and more
compact specification of error covariances. In the near future, we
anticipate releasing an update that permits equation-style specification of
structural equations.

o  The ability to update model specifications.

o  Soft-coded objective functions ("fit" functions in SEM jargon) and
optimizers. Two objective functions are provided, for multinormal
full-information maximum likelihood and for generalized least squares; and
three optimizers are provided, based on the standard R nlm(), optim(), and
nlminb() optimizers. The user can add objective functions and optimizers.

o  Analytic standard errors are provided by default for the FIML estimator
(standard errors based on the numeric Hessian are now optional), and robust
standard errors and tests are optionally available.

o  The ability to fit a model to a data frame, as a preferred alternative to
computing a covariance or moment matrix in an intermediate step. The
original data are required to obtain robust standard errors and tests, and
are optional otherwise.

o  Correctly computed "modification indices" (score tests for fixed
parameters).

o  Enhanced output, including R^2s for endogenous variables, additional
information criteria, and the computation of indirect effects.

o  Executable examples in the help pages for the package, along with (as
before) non-executable examples in which model specifications and
correlation/covariance/moment matrices appear in the input stream.

The new sem package is designed to be upwards compatible with the old one,
so that scripts that worked previously should still work.

Although we have tested the new sem package, this is a major update and it's
possible that bugs will surface. Please let me know if you encounter
problems.

Best,
 John


John Fox
Senator William McMaster
  Professor of Social Statistics
Department of Sociology
McMaster University
Hamilton, Ontario, Canada
http://socserv.mcmaster.ca/jfox

___
R-packages mailing list
r-packa...@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-packages

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


Re: [R] repeating a loop

2011-11-07 Thread R. Michael Weylandt
Could you just initialize RepeatPlot = "y" and then wrap your whole
script in while(RepeatPlot == "y") { ## YOUR STUFF ENDING WITH A
POSSIBLE MODIFICATION OF RepeatPlot }?

Michael

On Mon, Nov 7, 2011 at 1:49 PM, Amit Patel  wrote:
> Hi
>
> I have implented boxplots in my script to create box plots
>
> BoxplotsCheck <- readline(prompt = "Would you like to create boxplots for any 
> Feature? (y/n):")
>   if (BoxplotsCheck  == "y"){
>     BoxplotsFeature <- readline(prompt = "Which Feature would you like to 
> create a Boxplot for?:")
>     BoxplotsFeature <- as.numeric(BoxplotsFeature)
>     BoxplotsData <- as.numeric(which(PCIList == BoxplotsFeature))
>     BoxplotsData <- TotalIntensityList[BoxplotsData,]
>     BoxplotsHeading <- paste("Tukey boxplot (including outliers) for PCI ", 
> BoxplotsFeature , sep = "")
>     bplot(as.numeric(BoxplotsData), GroupingList, style = "tukey", outlier = 
> TRUE,
>   col="red", main = BoxplotsHeading,
>     xlab = "Groups", ylab = "Normalised Intensity", plot = TRUE)
>     BoxplotsFilename <- paste(BoxplotsFeature, "_Boxplot", sep = "")
>     savePlot(filename = "BoxplotsFilename", type = "jpeg", device = 
> dev.cur(), restoreConsole = TRUE)
>
>
> RepeatPlot <- readline(prompt = "Would you like to create another boxplot for 
> any Feature? (y/n):")
> }
>
>
> If the user inputs "y" for BoxplotsCheck then a boxplot is saved and creatyed 
> based on a user choice.
>
> I want to include the option to do another boxplot if needed (i.e. another 
> user prompt after saveplot returning another y or n for the variable 
> "RepeatPlot "  ) how can i do this. I guess some kind of loop continuing 
> whileRepeatPlot == y
>
> Can anyone help
>
>        [[alternative HTML version deleted]]
>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>

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

2011-11-07 Thread Amit Patel
Hi

I have implented boxplots in my script to create box plots

BoxplotsCheck <- readline(prompt = "Would you like to create boxplots for any 
Feature? (y/n):")
  if (BoxplotsCheck  == "y"){
    BoxplotsFeature <- readline(prompt = "Which Feature would you like to 
create a Boxplot for?:")
    BoxplotsFeature <- as.numeric(BoxplotsFeature)
    BoxplotsData <- as.numeric(which(PCIList == BoxplotsFeature))
    BoxplotsData <- TotalIntensityList[BoxplotsData,]
    BoxplotsHeading <- paste("Tukey boxplot (including outliers) for PCI ", 
BoxplotsFeature , sep = "")
    bplot(as.numeric(BoxplotsData), GroupingList, style = "tukey", outlier = 
TRUE, 
  col="red", main = BoxplotsHeading,
    xlab = "Groups", ylab = "Normalised Intensity", plot = TRUE)
    BoxplotsFilename <- paste(BoxplotsFeature, "_Boxplot", sep = "")
    savePlot(filename = "BoxplotsFilename", type = "jpeg", device = dev.cur(), 
restoreConsole = TRUE)
    

RepeatPlot <- readline(prompt = "Would you like to create another boxplot for 
any Feature? (y/n):")
}


If the user inputs "y" for BoxplotsCheck then a boxplot is saved and creatyed 
based on a user choice.

I want to include the option to do another boxplot if needed (i.e. another user 
prompt after saveplot returning another y or n for the variable "RepeatPlot "  
) how can i do this. I guess some kind of loop continuing whileRepeatPlot == y

Can anyone help

[[alternative HTML version deleted]]

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


Re: [R] help with formula for clogit

2011-11-07 Thread Thomas Lumley
On Tue, Nov 8, 2011 at 4:19 AM, 1Rnwb  wrote:
> I would like to know if clogit function can be used as below
> clogit(group~., data=dataframe)
>

Not usefully.  That syntax does not specify a strata() term, which is
why the computation is very slow and probably not what you intended.

   -thomas

-- 
Thomas Lumley
Professor of Biostatistics
University of Auckland

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


Re: [R] logistric regression: model revision

2011-11-07 Thread Dennis Murphy
Since you didn't provide a reproducible example, here are a couple of
possibilities to check, but I have utterly no idea if they're
applicable to your problem or not:

 * does costdis1 consist of 0's and 1's?
 * is costdis1 a factor?

In the first model, you treat costdis1 as a pure quadratic and in the
second model, it is a linear term. The two models are not nested.
Modeling a term as a pure quadratic is a very strong assumption - the
more usual practice is to fit both a linear and quadratic term in
costdis1 to allow more flexibility in the fitted surface, but that
would require costdis1 to be numeric.

HTH,
Dennis

On Mon, Nov 7, 2011 at 7:58 AM, Sally Ann Sims  wrote:
> Hello,
>
> I am working on fitting a logistic regression model to my dataset.  I removed 
> the squared term in the second version of the model, but my model output is 
> exactly the same.
>
> Model version 1:  
> GRP_GLM<-glm(HB_NHB~elev+costdis1^2,data=glm_1,family=binomial(link=logit))
> summary(GRP_GLM)
>
>
> Model version 2:  
> QM_1<-glm(HB_NHB~elev+costdis1,data=glm_2,family=binomial(link=logit))
> summary(QM_1)
>
>
> The call in version 2 has changed:
> Call:
> glm(formula = HB_NHB ~ elev + costdis1, family = binomial(link = logit),
>    data = glm_2)
> But I’m getting the exact same results as I did in the model where costdis1 
> is squared.
>
> Any ideas what I might do to correct this?  Thank you.
>
> Sally
>        [[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] Estimate of intercept in loglinear model

2011-11-07 Thread David Winsemius


On Nov 7, 2011, at 12:59 PM, Colin Aitken wrote:


How does R estimate the intercept term \alpha in a loglinear
model with Poisson model and log link for a contingency table of  
counts?


(E.g., for a 2-by-2 table {n_{ij}) with \log(\mu) = \alpha +  
\beta_{i} + \gamma_{j})


I fitted such a model and checked the calculations by hand. I   
agreed with the main effect terms but not the intercept.  
Interestingly,  I agreed with the fitted value provided by R for the  
first cell {11} in the table.


If my estimate of intercept = \hat{\alpha}, my estimate of the  
fitted value for the first cell = exp(\hat{\alpha}) but R seems to  
be doing something else for the estimate of the intercept.


However if I check the  R $fitted_value for n_{11} it agrees with my  
exp(\hat{\alpha}).


	I would expect that with the corner-point parametrization, the  
estimates for a 2 x 2 table would correspond to expected frequencies  
exp(\alpha), exp(\alpha + \beta), exp(\alpha + \gamma), exp(\alpha +  
\beta + \gamma). The MLE of \alpha appears to be log(n_{.1} * n_{1.}/ 
n_{..}), but this is not equal to the intercept given by R in the  
example I tried.


With thanks in anticipation,

Colin Aitken


--
Professor Colin Aitken,
Professor of Forensic Statistics,


Do you suppose you could provide a data-corpse for us to dissect?

Noting the tag line for every posting 

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


--

David Winsemius, MD
West Hartford, CT

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


Re: [R] Problema with Excel files

2011-11-07 Thread David Winsemius


On Nov 7, 2011, at 12:57 PM, Silvano wrote:


Hi,

I have a Excel file with three spreadsheets: PlanA, PlanB and PlanC.
I'm trying to read the three spreadsheets and then adding them  
together.

But, when I try read the PlanA there is an error message:


rm(list=ls())
setwd('C:/Test/Dados/Teste')
require(RODBC)
Arquivo = odbcConnectExcel('T070206_1347.xls')
(Geral = sqlFetch(Arquivo, 'PlanA'))
(Lactacao = sqlFetch(Arquivo, 'PlanB'))

Erro em as.POSIXlt.character(x, tz, ...) :
character string is not in a standard unambiguous format


I don't know what's happening. Can anyone help me?


It's a guess without the data, but have you got a date column in the  
spreadsheet with a non-standard format? If so, can you change it to  
-MM-DD in the format/Date/Custom (or some such) panel?





Thanks a lot,

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

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


David Winsemius, MD
West Hartford, CT

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


[R] Estimate of intercept in loglinear model

2011-11-07 Thread Colin Aitken

How does R estimate the intercept term \alpha in a loglinear
 model with Poisson model and log link for a contingency table of counts?

(E.g., for a 2-by-2 table {n_{ij}) with \log(\mu) = \alpha + \beta_{i} + 
\gamma_{j})


I fitted such a model and checked the calculations by hand. I  agreed 
with the main effect terms but not the intercept. Interestingly,  I 
agreed with the fitted value provided by R for the first cell {11} in 
the table.


If my estimate of intercept = \hat{\alpha}, my estimate of the fitted 
value for the first cell = exp(\hat{\alpha}) but R seems to be doing 
something else for the estimate of the intercept.


However if I check the  R $fitted_value for n_{11} it agrees with my 
exp(\hat{\alpha}).


	I would expect that with the corner-point parametrization, the 
estimates for a 2 x 2 table would correspond to expected frequencies 
exp(\alpha), exp(\alpha + \beta), exp(\alpha + \gamma), exp(\alpha + 
\beta + \gamma). The MLE of \alpha appears to be log(n_{.1} * 
n_{1.}/n_{..}), but this is not equal to the intercept given by R in the 
example I tried.


With thanks in anticipation,

Colin Aitken


--
Professor Colin Aitken,
Professor of Forensic Statistics,
School of Mathematics, King’s Buildings, University of Edinburgh,
Mayfield Road, Edinburgh, EH9 3JZ.

Tel:0131 650 4877
E-mail:  c.g.g.ait...@ed.ac.uk
Fax :  0131 650 6553
http://www.maths.ed.ac.uk/~cgga


The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.

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

2011-11-07 Thread Silvano

Hi,

I have a Excel file with three spreadsheets: PlanA, PlanB 
and PlanC.
I'm trying to read the three spreadsheets and then adding 
them together.

But, when I try read the PlanA there is an error message:


rm(list=ls())
setwd('C:/Test/Dados/Teste')
require(RODBC)
Arquivo = odbcConnectExcel('T070206_1347.xls')
(Geral = sqlFetch(Arquivo, 'PlanA'))
(Lactacao = sqlFetch(Arquivo, 'PlanB'))

Erro em as.POSIXlt.character(x, tz, ...) :
 character string is not in a standard unambiguous format


I don't know what's happening. Can anyone help me?

Thanks a lot,

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

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


Re: [R] Error: could not find function "MLearn"

2011-11-07 Thread horseatingweeds
Thanks Dave. I thought I had run library(MLInterface), but I looked back, and
it was library(MLearn) I was running. Silly me... 

It's chugging away now. 

--
View this message in context: 
http://r.789695.n4.nabble.com/Error-could-not-find-function-MLearn-tp3998805p4005626.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Dunif and Punif

2011-11-07 Thread Peter Langfelder
On Mon, Nov 7, 2011 at 8:49 AM, michele donato  wrote:
> Hi,
> I am trying to use dunif and runif
> however, I have two problems:
> if I do
>
> dunif(1:10, min=1, max=10)
>
> I get 10 values, which summed give me 1.
> I understand that the probability is computed as f(x) = 1 / (max-min)
> but in this case it looks wrong: I have 10 values, each one
> equiprobable, and the probability for each one should be 0.1 and not
> 0.1 (which is, consistently with the definition, 1/9)
>
> It looks like one of the extremes is not considered in the computation
> of the probability, but then it's assigned a probability anyway.
>
> Similar problem with punif.
>
> if I do
> punif(1, min=1, max=10)
> I get 0 as result, as if the lower extreme is not considered, which is
> not consistent with the description where min <= x <= max
> If the lower extreme is not considered because cdf(x) = p(X not p(X<=x)} the problem stands in p(X<11) which should be the sum of
> everything. ( P(1) + P(2) + ... + P(10) )
>
> What is happening here?

The uniform distribution is continuous.
Your interval has length 9 (10-1 = 9), so the density 1/9. Multiplied
by 10 it gives you your answer. Same for the cumulative probability
distribution (punif) - it is zero at x=1 because that's where your
interval starts.

Peter

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

2011-11-07 Thread Richard Saba
Does anyone know if the  bootstrap  CI intervals generated by the irf() 
function (impulse response function) in the " vars"  package are bias corrected?
Thanks,
Richard Saba

[[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] Dunif and Punif

2011-11-07 Thread R. Michael Weylandt
A point of clarification:

dDIST() sometimes gives a pmf, e.g., dpois(). But dunif() is a pdf.

Sorry for the typo.

Michael

On Mon, Nov 7, 2011 at 12:08 PM, R. Michael Weylandt
 wrote:
> In short, the unif() distribution corresponds to the continuous
> uniform distribution, not the discrete.
>
> Longer: dDIST() doesn't give a pmf so summing it isn't what you are
> looking for: it gives a pdf. For punif() consider P\{X <= 1\} when X
> is distributed on [1, 10]. Clearly this has probability zero because
> it can only occur for one out of uncountably many values -- though
> this notion should be made more precise using a little bit of measure
> theory.
>
> Michael
>
>
> On Mon, Nov 7, 2011 at 11:49 AM, michele donato
>  wrote:
>> Hi,
>> I am trying to use dunif and runif
>> however, I have two problems:
>> if I do
>>
>> dunif(1:10, min=1, max=10)
>>
>> I get 10 values, which summed give me 1.
>> I understand that the probability is computed as f(x) = 1 / (max-min)
>> but in this case it looks wrong: I have 10 values, each one
>> equiprobable, and the probability for each one should be 0.1 and not
>> 0.1 (which is, consistently with the definition, 1/9)
>>
>> It looks like one of the extremes is not considered in the computation
>> of the probability, but then it's assigned a probability anyway.
>>
>> Similar problem with punif.
>>
>> if I do
>> punif(1, min=1, max=10)
>> I get 0 as result, as if the lower extreme is not considered, which is
>> not consistent with the description where min <= x <= max
>> If the lower extreme is not considered because cdf(x) = p(X> not p(X<=x)} the problem stands in p(X<11) which should be the sum of
>> everything. ( P(1) + P(2) + ... + P(10) )
>>
>> What is happening here?
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/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] Dunif and Punif

2011-11-07 Thread R. Michael Weylandt
In short, the unif() distribution corresponds to the continuous
uniform distribution, not the discrete.

Longer: dDIST() doesn't give a pmf so summing it isn't what you are
looking for: it gives a pdf. For punif() consider P\{X <= 1\} when X
is distributed on [1, 10]. Clearly this has probability zero because
it can only occur for one out of uncountably many values -- though
this notion should be made more precise using a little bit of measure
theory.

Michael


On Mon, Nov 7, 2011 at 11:49 AM, michele donato
 wrote:
> Hi,
> I am trying to use dunif and runif
> however, I have two problems:
> if I do
>
> dunif(1:10, min=1, max=10)
>
> I get 10 values, which summed give me 1.
> I understand that the probability is computed as f(x) = 1 / (max-min)
> but in this case it looks wrong: I have 10 values, each one
> equiprobable, and the probability for each one should be 0.1 and not
> 0.1 (which is, consistently with the definition, 1/9)
>
> It looks like one of the extremes is not considered in the computation
> of the probability, but then it's assigned a probability anyway.
>
> Similar problem with punif.
>
> if I do
> punif(1, min=1, max=10)
> I get 0 as result, as if the lower extreme is not considered, which is
> not consistent with the description where min <= x <= max
> If the lower extreme is not considered because cdf(x) = p(X not p(X<=x)} the problem stands in p(X<11) which should be the sum of
> everything. ( P(1) + P(2) + ... + P(10) )
>
> What is happening here?
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Dunif and Punif

2011-11-07 Thread michele donato
Hi,
I am trying to use dunif and runif
however, I have two problems:
if I do

dunif(1:10, min=1, max=10)

I get 10 values, which summed give me 1.
I understand that the probability is computed as f(x) = 1 / (max-min)
but in this case it looks wrong: I have 10 values, each one
equiprobable, and the probability for each one should be 0.1 and not
0.1 (which is, consistently with the definition, 1/9)

It looks like one of the extremes is not considered in the computation
of the probability, but then it's assigned a probability anyway.

Similar problem with punif.

if I do
punif(1, min=1, max=10)
I get 0 as result, as if the lower extreme is not considered, which is
not consistent with the description where min <= x <= max
If the lower extreme is not considered because cdf(x) = p(Xhttps://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] function that load variables

2011-11-07 Thread Bert Gunter
1. Full disclosure. I have not followed this thread closely. My comment
concerns only:

On Mon, Nov 7, 2011 at 8:35 AM, Jeff Newmiller wrote:

> A much better solution is to make separate functions for each object you
> import, and return an object from the function to be assigned in the
> calling environment. This will be far less confusing to read later.
> ---
> Jeff NewmillerThe .   .  Go Live...
>

--"It ain't necessarily so" (from Porgy and Bess -- Google it)
 (assuming I have understood the issues)

For example, given several data sets of identical sets of pollution
monitors at different sites and/or times, it would probably make more sense
to import them together into a list so that they could be easily analyzed
in parallel (via e.g. lapply(..)) , combined into one structure, etc. ,
rather than littering the global environment with separate objects.

Cheers,
Bert

[[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] function that load variables

2011-11-07 Thread Jeff Newmiller
A much better solution is to make separate functions for each object you 
import, and return an object from the function to be assigned in the calling 
environment. This will be far less confusing to read later.
---
Jeff NewmillerThe .   .  Go Live...
DCN:Basics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
--- 
Sent from my phone. Please excuse my brevity.

"R. Michael Weylandt"  wrote:

>Perhaps you mean to use
>
>load(, envir = .GlobalEnv)
>
>Currently you load up the variables in the function environment but
>then they are thrown away when the function ends.
>
>Michael
>
>On Mon, Nov 7, 2011 at 8:40 AM, Alaios  wrote:
>> Dear all,
>> I have saved few variable names into local files,
>> I wanted to make a function that load this files and "generates" the
>variable names into my working environment. I have tried to do that as
>a function but my problem is
>>
>> that this function does not return the variable names
>>
>>
>> load_data<-function(path,Reload=FALSE){
>>
>>     if (Reload==TRUE){
>>
>>       print("Loading results")
>>
>>       # FirstSet
>>       load(file=paste(path,'first',sep=""))
>>       first<-Set
>>
>>       # SecondSet
>>       load(file=paste(path,'second',sep=""))
>>       second<-Set
>>
>> ..(part omittted here)
>>
>>       save( first, second,(part omitted here)...,
>file=paste(path,'Results',sep=""))
>>     }
>>
>>     return (load(file=paste(path,'Results',sep="")))
>>
>> }
>>
>> so my idea was the following:
>> I call the function and it retuns the values first,second,... loaded
>into the current working space.
>> If I want to refresh them, something has changed to the firstDataSet
>I set the function's variable Reload=True and thus all the data are
>refreshed.
>> The problem is not that the return statement I ahve at the end of the
>function does not return the loaded variable to the working environment
>but only the status of the load command.
>>
>> Do you know how I can change that so my function returns also Loaded
>Variable names to the environment?
>>
>> Alex
>>        [[alternative HTML version deleted]]
>>
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>>
>
>__
>R-help@r-project.org mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] Problem working with dates

2011-11-07 Thread Paul Miller
Hi Michael and David,

Thank you both for your reply to my question. Problem solved. I'm finding that 
my level of success with R is a little uneven thus far. I'm sometimes surprised 
by the things I can do, but then am even more surprised by the simple things I 
struggle with.

Appreciate your help.

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] R-bash beginneR

2011-11-07 Thread Jeff Newmiller
This is not an R question. Use the print function in R and use backticks in 
bash.
---
Jeff NewmillerThe .   .  Go Live...
DCN:Basics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
--- 
Sent from my phone. Please excuse my brevity.

"David A."  wrote:

>
>Hi,
>
>I am trying to run some R commands into my bash scripts and want to use
>shell variables in the R commands and store the output of R objects
>into shell variables for further usage in downstream analyses. So far I
>have managed the first, but how to get values out of R script? I am
>using  "here documents" (as a starter, maybe something else is simpler
>or better; suggestions greatly appreciated).
>
>A basic random example:
>
>#!/bin/sh
>MYVAR=2
>R --slave --quiet --no-save 
>z<-x/$MYVAR
>zz<-x*$MYVAR
>EEE 
>
>
>How get the values of z and zz into shell variables?
>
>
>Thanks
>
>D
> 
>   [[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] R-bash beginner

2011-11-07 Thread David A.

Hi,

I am trying to run some R commands into my bash scripts and want to use shell 
variables in the R commands and store the output of R objects into shell 
variables for further usage in downstream analyses. So far I have managed the 
first, but how to get values out of R script? I am using  "here documents" (as 
a starter, maybe something else is simpler or better; suggestions greatly 
appreciated).

A basic random example:

#!/bin/sh
MYVAR=2
R --slave --quiet --no-save 

Re: [R] R in batch mode packages loading question

2011-11-07 Thread Prof Brian Ripley

On Mon, 7 Nov 2011, PALMIER Patrick (Responsable de groupe) - CETE NP/TM/ST 
wrote:


Thank you for your response, but this is not exactly what I need

We are working on a tool that automatically generate R scripts adapted
to our surveys databases.
When we want to do a table, we select interactively fields, associated
labels, functions for an automatic crosstable for example
Then, the tool executes R in batch mode with the script produced by the tool
The "many scripts" correspond to the many crosstables people want to do.
It is not possible produce these different scripts and execute all of
them in a unique script with source.

For example, people want to do a crosstable, the tool produce a r script
that generate the result. Then, the user want to do the same crosstable
but on a subset or with different labels. Then, the tools produces
another r script, and execute R which reloads at each time all the
neeeded packages.

Is there a way to avoid this thing and to load packages only once?


You have to load them once per R session.  So you could organize your 
work to use a single session, as Duncan suggested.  And that session 
could wait for input (using something like Rserve).


If your packages are taking too long to load, fix the packages. 
Well-written packages load in milliseconds: after all R itself manages 
to load several large packages in 100ms or so.





Than you in advance

*Patrick PALMIER**
***


Le 07/11/2011 15:20, > Duncan Murdoch (par Internet) a écrit :
On 07/11/2011 5:49 AM, PALMIER Patrick (Responsable de groupe) - CETE 
NP/TM/ST wrote:

Hello,


I use R in batch mode. Each time, I execute a script, R is loading each
packages I need in my script. That's Ok
But, I had to execute many scripts , and each time R is re-loading the
corresponding packages, which take to much time

Is it possible ask R to load the packages only once, and stay in memory
in background for further scripts, which would avoid to load the
packages in each script, or if you have another solution that need to
only load packages once in the first scripts, so that further scripts do
not need to load these packages too.


Write one script that has a sequence of calls to source() to run the other 
scripts.


You'll need to be careful that unintentional leftover objects and settings 
from one script don't affect the others; you may also want to use the 
"echo=TRUE" option when you source, so you see the commands as they are 
executed.


Duncan Murdoch




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



--
Brian D. Ripley,  rip...@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] logistric regression: model revision

2011-11-07 Thread David Winsemius


On Nov 7, 2011, at 10:58 AM, Sally Ann Sims wrote:


Hello,

I am working on fitting a logistic regression model to my dataset.   
I removed the squared term in the second version of the model, but  
my model output is exactly the same.


Model version 1:  GRP_GLM<-glm(HB_NHB~elev 
+costdis1^2,data=glm_1,family=binomial(link=logit))

summary(GRP_GLM)


Model version 2:  QM_1<-glm(HB_NHB~elev 
+costdis1,data=glm_2,family=binomial(link=logit))

summary(QM_1)


The call in version 2 has changed:
Call:
glm(formula = HB_NHB ~ elev + costdis1, family = binomial(link =  
logit),

   data = glm_2)
But I’m getting the exact same results as I did in the model where  
costdis1 is squared.


Are you sure that you got output that correctly modeled the  
costdis1^2? I would ahve guessed that you would have needed to use :


 GRP_GLM<-glm(HB_NHB~elev+I(costdis1^2), data=glm_1,  
family=binomial(link=logit))


?I

The "^" in model formulas is for composing interactions.

?formula



Any ideas what I might do to correct this?  Thank you.

Sally
[[alternative HTML version deleted]]


And please post in plain text.

--

David Winsemius, MD
West Hartford, CT

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


Re: [R] R in batch mode packages loading question

2011-11-07 Thread Andrew Ziem
Try the fork() function in the package multicore (if your system supports it)


Andrew


-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of PALMIER Patrick (Responsable de groupe) - CETE NP/TM/ST
Sent: Monday, November 07, 2011 3:49 AM
To: r-help@r-project.org
Subject: [R] R in batch mode packages loading question

Hello,


I use R in batch mode. Each time, I execute a script, R is loading each 
packages I need in my script. That's Ok But, I had to execute many scripts , 
and each time R is re-loading the corresponding packages, which take to much 
time

Is it possible ask R to load the packages only once, and stay in memory in 
background for further scripts, which would avoid to load the packages in each 
script, or if you have another solution that need to only load packages once in 
the first scripts, so that further scripts do not need to load these packages 
too.


Thanks in advance
-- 

*Patrick PALMIER**
**Centre d'Études Techniques de l'Équipement Nord - Picardie Département 
Transport Mobilités */*Responsable du groupe Systèmes de Transports*//* */2, 
rue de Bruxelles, BP 275
59019 Lille cedex
FRANCE
Tél: +33 (0) 3 20 49 60 70
Fax: +33 (0) 3 20 49 63 69


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

2011-11-07 Thread Sally Ann Sims
Hello,

I am working on fitting a logistic regression model to my dataset.  I removed 
the squared term in the second version of the model, but my model output is 
exactly the same.  

Model version 1:  
GRP_GLM<-glm(HB_NHB~elev+costdis1^2,data=glm_1,family=binomial(link=logit))
summary(GRP_GLM)


Model version 2:  
QM_1<-glm(HB_NHB~elev+costdis1,data=glm_2,family=binomial(link=logit))
summary(QM_1)


The call in version 2 has changed:  
Call:
glm(formula = HB_NHB ~ elev + costdis1, family = binomial(link = logit), 
data = glm_2)
But I’m getting the exact same results as I did in the model where costdis1 
is squared.

Any ideas what I might do to correct this?  Thank you.

Sally
[[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] Lower bounds on selfStart function not working

2011-11-07 Thread Schatzi
I tested the "optim" function and that is returning non-negative parameter
values (meaning they are bound by the lower limits), but I think those are
the starting estimates for the nlsList model which is then finding negative
values for the solution.

-
In theory, practice and theory are the same. In practice, they are not - Albert 
Einstein
--
View this message in context: 
http://r.789695.n4.nabble.com/Lower-bounds-on-selfStart-function-not-working-tp3999231p4001986.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] R in batch mode packages loading question

2011-11-07 Thread PALMIER Patrick (Responsable de groupe) - CETE NP/TM/ST

Thank you for your response, but this is not exactly what I need

We are working on a tool that automatically generate R scripts adapted
to our surveys databases.
When we want to do a table, we select interactively fields, associated
labels, functions for an automatic crosstable for example
Then, the tool executes R in batch mode with the script produced by the tool
The "many scripts" correspond to the many crosstables people want to do.
It is not possible produce these different scripts and execute all of
them in a unique script with source.

For example, people want to do a crosstable, the tool produce a r script
that generate the result. Then, the user want to do the same crosstable
but on a subset or with different labels. Then, the tools produces
another r script, and execute R which reloads at each time all the
neeeded packages.

Is there a way to avoid this thing and to load packages only once?


Than you in advance

*Patrick PALMIER**
***


Le 07/11/2011 15:20, > Duncan Murdoch (par Internet) a écrit :
On 07/11/2011 5:49 AM, PALMIER Patrick (Responsable de groupe) - CETE 
NP/TM/ST wrote:

Hello,


I use R in batch mode. Each time, I execute a script, R is loading each
packages I need in my script. That's Ok
But, I had to execute many scripts , and each time R is re-loading the
corresponding packages, which take to much time

Is it possible ask R to load the packages only once, and stay in memory
in background for further scripts, which would avoid to load the
packages in each script, or if you have another solution that need to
only load packages once in the first scripts, so that further scripts do
not need to load these packages too.


Write one script that has a sequence of calls to source() to run the 
other scripts.


You'll need to be careful that unintentional leftover objects and 
settings from one script don't affect the others; you may also want to 
use the "echo=TRUE" option when you source, so you see the commands as 
they are executed.


Duncan Murdoch




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


Re: [R] How much time a process need?

2011-11-07 Thread Uwe Ligges



On 07.11.2011 14:32, Alaios wrote:

So I just need to get the

user  system elapsed
   0.460   0.048  67.366


user value and convert the seconds to days and then to hours ? Right?

What about this elapsed field?


Yes, the elapsed time in seconds.

Uwe Ligges









From: Uwe Ligges
To: Alaios
Cc: "R-help@r-project.org"
Sent: Monday, November 7, 2011 1:27 PM
Subject: Re: [R] How much time a process need?



On 07.11.2011 11:09, Alaios wrote:

Dear all,
I have finished a large function that takes around 1 day to finish.
I was using system.time(callmyfunction()) to measure how much time it needed to 
finish, my problem is that I do not know how to interpret their numbers.
I was looking to convert these results to something more readably like.
"This function took 1 Day 2 hours and 35 minutes to complete."

How I can convert the system.time output to something like that?



system.time() responds in seconds, hence you can apply simple arithmetic
to get days, hours and minutes.

Uwe Ligges





B.R
Alex

 [[alternative HTML version deleted]]

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


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


Re: [R] How do I return to the row values of a matrix after computing distances

2011-11-07 Thread David Winsemius


On Nov 7, 2011, at 8:06 AM, qqh5011 wrote:


##Package Needed
library(fields)

## Assumptions
set.seed(123)
nsim<-5
p<-2

##Generate Random Matrix G
G <- matrix(runif(p*nsim),nsim,p)

##Set Empty Matraces dmax and dmin
dmax<- matrix(data=NA,nrow=nsim,ncol=p)
dmin<- matrix(data=NA,nrow=nsim,ncol=p)

## Loop to Fill dmax and dmin
for(i in 1:nsim) {

dmax[i]<- max(rdist(G[i,,drop=FALSE],G))
dmin[i]<- min(rdist(G[i,,drop=FALSE],G[-i,])) }

I filled the dmax and dmin with the distance values I calculated,  
but what I really want to fill them with are the rows in G. What  
should I do? I tried "which" function but it did not work. Thank you  
in advance



Dear qq5011 ... AKA user1033763;

The practice of cross-posting questions to StackOverFlow and rhelp  
within hours of each other is deprecated, at least on on rhelp.


http://stackoverflow.com/questions/8036831/how-to-return-to-the-qualifying-rows-of-original-data

If you don't get an answer within some reasonable interval (measured  
in days, not hours) then feel free to post a follow-up ... with  
citation of the first posting.




qqh5011
[[alternative HTML version deleted]]


Posting in HTML is likewise deprecated. Please read the Posting Guide  
were both of these issues and many other sensible requests for  
professional behavior are detailed



PLEASE do read the posting guide http://www.R-project.org/posting-guide.html



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


(You did do that, and please continue to do so.)
--

David Winsemius, MD
West Hartford, CT

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


[R] Lower bounds on selfStart function not working

2011-11-07 Thread Schatzi
I adapted a selfStart function and the lower bounds are not working. The
parameter "b" is negative, whereas I would like the lower bound to be zero.
Any ideas? Thanks.

Here is my code (I am still figuring out how to easily make replicable
examples):
A<-1.75
mu<-.2
l<-2
b<-0
x<-seq(0,18,.25)
create.y<-function(x){
y<-b+A/(1+exp(4*mu/A*(l-x)+2))
return(y)
}
ys<-create.y(x)
yvec<-(rep(ys,5))*(.95+runif(length(x)*5)/10)
Trt<-factor(c(rep("A1",length(x)),rep("A2",length(x)),rep("A3",length(x)),rep("A4",length(x)),rep("A5",length(x
Data<-data.frame(Trt,rep(x,5),yvec)
names(Data)<-c("Trt","x","y")

NewData<-groupedData(y~x|Trt,data=Data)

powrDpltInit <-
function(mCall, LHS, data) {
   xy <- sortedXyData(mCall[["x"]],LHS,data)
   A.s  <- max(xy$y)-min(xy$y)
   mu.s  <- A.s/7.5
   l.s <- 0
   b.s<- max(min(xy$y),0.1)
   value  <- c(A.s, l.s, mu.s, b.s)

#function to optimize
func1 <- function(value) {
   A.s  <- value[1]
   mu.s  <- value[2]
   l.s <- value[3]
   b.s<- value[4]
  y1<-rep(0,length(xy$x)) # generate vector for predicted y (y1) to evaluate
against observed y
  for(cnt in 1:length(xy$x)){
  y1[cnt]<- b.s+A.s/(1+exp(4*mu.s/A.s*(l.s-x[cnt])+2))}  #predicting y1 for
values of y
  evl<-sum((xy$y-y1)^2) #sum of squares is function to minimize
  return(evl)}

#optimizing
oppar<-optim(c(A.s , mu.s , l.s , b.s),func1,method="L-BFGS-B",
lower=c(0.0001,0.0,0.0,0.0),
control=list(maxit=2000,trace=TRUE))

#saving optimized parameters
value<-c(oppar$par[1L],oppar$par[2L],oppar$par[3L],oppar$par[4L])

   names(value) <- mCall[c("A","mu","l","b")]
   value

}

SSpowrDplt<-selfStart(~b+A/(1+exp(4*mu/A*(l-x)+2)),initial=powrDpltInit,
parameters=c("A","mu","l","b"))

test1<-nlsList(SSpowrDplt,NewData)
coef(test1)

-
In theory, practice and theory are the same. In practice, they are not - Albert 
Einstein
--
View this message in context: 
http://r.789695.n4.nabble.com/Lower-bounds-on-selfStart-function-not-working-tp3999231p3999231.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] help with formula for clogit

2011-11-07 Thread 1Rnwb
I would like to know if clogit function can be used as below
clogit(group~., data=dataframe)

When I try to use in above format it takes a long time, I would appreciate
some pointers to get multiple combinations tested.

set.seed(100)
 d=data.frame(x=rnorm(20)+5,
 x1=rnorm(20)+5,
 x2=rnorm(20)+5,
 x3=rnorm(20)+5,
 x4=rnorm(20)+5,
 x5=rnorm(20)+5,
 x6=rnorm(20)+5,
 x7=rnorm(20)+5,
 x8=rnorm(20)+5,
group=rep(c(1,2),10), Age=rnorm(20)+35,strata=c(rep(1,10), rep(2,10))) 

nam=names(d)[1:9]
results <- c("Protein", "OR", "p-val")
pc3=combinations(n=length(nam),r=2)

for (len in 1:dim(pc3)[2])
 {
  prs=pc3[len,]
  mols=nam[prs]
  d2=d[,c(mols,'group','Age','strata')]
  log.reg<-clogit(group~.,data=d2)
  a = summary(log.reg)$conf.int
  z= summary(log.reg)$coefficients[1,4]  #ncol in coefficients is 3 * number
of parameters
  pval  = 2*pnorm(-abs(z))
  res2 = c(paste('IL8+',molecule,sep=''), paste (round(a[1,1],2), " ("  ,
round(a[1,3],2), " - " , round(a[1,4],2), ")" , sep=""), pval)
  results  = rbind (results ,res2 )
}

Thanks
Sharad

--
View this message in context: 
http://r.789695.n4.nabble.com/help-with-formula-for-clogit-tp3998967p3998967.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Error: could not find function "MLearn"

2011-11-07 Thread David Winsemius


On Nov 7, 2011, at 9:30 AM, horseatingweeds wrote:


I'm getting this error when I try to run the function MLearn():

Error: could not find function "MLearn"


The usual reason for a newbie not getting a function is that they  
failed to do one of these:


library(MLInterface)
require(MLInterface)

You didn't refer to MLInterface as a package but that is my guess  as  
to what you installed. Installation puts it in your library but you  
also need to load it in an open workspace.





I have the MLInterface tools installed. But when I look for MLearn
"??MLearn" but I don't find it. The closest thing I find is the method
MLearn_new() under MLInterfaces. I've tried replacing MLearn() with
MLearn_new() in my script, but I still get the same error, this time:

Error: could not find function "MLearn_new"

Any ideas what I'm doing wrong here? Thanks.

R version 2.13.4, Biocinstall version 2.8.4, on Ubuntu 10.04

--
View this message in context: 
http://r.789695.n4.nabble.com/Error-could-not-find-function-MLearn-tp3998805p3998805.html
Sent from the R help mailing list archive at Nabble.com.

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


David Winsemius, MD
West Hartford, CT

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


[R] Plotting a network in a "star" mode

2011-11-07 Thread anat
Dear R experts,

I have a network constructed through an adjacency matrix (square matrix)
using the "network" package in R.
I'm interested in plotting this network, but in a star-mode, which means I
have one node (the first column or row)i want
to be located in the center of the network and all the other around it.

I read the network.plot documentation, but there I could only find 3
available methods (the options available for "mode"), which did not meet my
needs.

My matrix looks as follows:
6 nodes, "1" appears when an edge is connecting 2 nodes.

[,1] [,2] [,3] [,4] [,5] [,6]
[1,]011111
[2,]101111
[3,]110111
[4,]111010
[5,]111101
[6,]111010

I would like to plot a network with 6 nodes, so that the first one is in the
middle.
Can you please advice me how to do that?

Thank you,
Anat 


--
View this message in context: 
http://r.789695.n4.nabble.com/Plotting-a-network-in-a-star-mode-tp3998920p3998920.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Problem working with dates

2011-11-07 Thread R. Michael Weylandt
I think you are making the transform much more complicated than it needs to be:

Suppose you have a data frame with a bunch of things that look like
dates but are really factors:

Then the following transform should work from factor to Date:

df <- as.Date(as.character(df), format = "%Y/%m/%d")

and to address the mistyped element:

df[df == "11/2321931"] <- "11/23/1931"

You should probably do this before the conversion to date type. If you
want to do it in a look up-ish sort of way, this is probably better:

within(Demo, DOB[Subject == 108945] <- "11/23/1931")

Michael


On Mon, Nov 7, 2011 at 9:39 AM, Paul Miller  wrote:
> Hello All,
>
> I've been reading books about R for awhile now and am in the process of 
> replicating the SAS analyses from an old report. I want to be sure that I can 
> do all the things I need to in R before using it in my daily work.
>
> So far, I've managed to read in all my data and have done some data 
> manipulation. I'm having trouble with fixing an error in a date variable 
> though, and was hoping someone could help.
>
> One of the patients in my data has a DOB incorrectly entered as:
>
> '11/23/21931'
>
> Their DOB should be:
>
> '11/23/1931'
>
> How can I correct this problem before calculating age in the code below?
> DOB starts out as a factor in the Demo dataframe but then is converted into a 
> date. So I had thought the ifelse that follows could be used to correct the 
> problem, but this doesn't seem to be the case.
>
> Thanks,
>
> Paul
>
> Demo_Char <- within(Demo, {
> DateCompleted <- as.Date(DateCompleted, format = "%m/%d/%Y")
> DOB <- as.Date(DOB, format = "%m/%d/%Y")
> DOB <- ifelse(Subject==108945, as.Date("1931-11-23"), DOB)
> Age <- as.integer((DateCompleted - DOB) / 365.25)
> })
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Error: could not find function "MLearn"

2011-11-07 Thread horseatingweeds
I'm getting this error when I try to run the function MLearn():

Error: could not find function "MLearn"

I have the MLInterface tools installed. But when I look for MLearn
"??MLearn" but I don't find it. The closest thing I find is the method
MLearn_new() under MLInterfaces. I've tried replacing MLearn() with
MLearn_new() in my script, but I still get the same error, this time:

Error: could not find function "MLearn_new"

Any ideas what I'm doing wrong here? Thanks.

R version 2.13.4, Biocinstall version 2.8.4, on Ubuntu 10.04

--
View this message in context: 
http://r.789695.n4.nabble.com/Error-could-not-find-function-MLearn-tp3998805p3998805.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] How do I return to the row values of a matrix after computing distances

2011-11-07 Thread qqh5011
##Package Needed
library(fields)

## Assumptions
set.seed(123)
nsim<-5
p<-2

##Generate Random Matrix G
G <- matrix(runif(p*nsim),nsim,p)

##Set Empty Matraces dmax and dmin
dmax<- matrix(data=NA,nrow=nsim,ncol=p)
dmin<- matrix(data=NA,nrow=nsim,ncol=p)

## Loop to Fill dmax and dmin
for(i in 1:nsim) {

dmax[i]<- max(rdist(G[i,,drop=FALSE],G))
dmin[i]<- min(rdist(G[i,,drop=FALSE],G[-i,])) }

I filled the dmax and dmin with the distance values I calculated, but what I 
really want to fill them with are the rows in G. What should I do? I tried 
"which" function but it did not work. Thank you in advance




qqh5011
[[alternative HTML version deleted]]

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


Re: [R] How to do a target value search analogous to Excel Solver

2011-11-07 Thread jolo999
Works fine. Thanks for the quick reply!!

--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-do-a-target-value-search-analogous-to-Excel-Solver-tp3998347p3998729.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] nproc parameter in efpFunctional

2011-11-07 Thread bonda
Thank you very much, it works now!
Best regards,
J

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

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


Re: [R] Problem working with dates

2011-11-07 Thread David Winsemius


On Nov 7, 2011, at 9:39 AM, Paul Miller wrote:


Hello All,

I've been reading books about R for awhile now and am in the process  
of replicating the SAS analyses from an old report. I want to be  
sure that I can do all the things I need to in R before using it in  
my daily work.


So far, I've managed to read in all my data and have done some data  
manipulation. I'm having trouble with fixing an error in a date  
variable though, and was hoping someone could help.


One of the patients in my data has a DOB incorrectly entered as:

'11/23/21931'

Their DOB should be:

'11/23/1931'

How can I correct this problem before calculating age in the code  
below?
DOB starts out as a factor in the Demo dataframe but then is  
converted into a date. So I had thought the ifelse that follows  
could be used to correct the problem, but this doesn't seem to be  
the case.


Thanks,

Paul



Why not fix the single error first?

Demo[ Demo$Subject==108945, "DateCompleted"] <- '11/23/1931'

Then you can skip the time-consuming ifelse() inside the within() call.

--
David


Demo_Char <- within(Demo, {
DateCompleted <- as.Date(DateCompleted, format = "%m/%d/%Y")
DOB <- as.Date(DOB, format = "%m/%d/%Y")
DOB <- ifelse(Subject==108945, as.Date("1931-11-23"), DOB)
Age <- as.integer((DateCompleted - DOB) / 365.25)
})

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


David Winsemius, MD
West Hartford, CT

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


[R] Problem working with dates

2011-11-07 Thread Paul Miller
Hello All,

I've been reading books about R for awhile now and am in the process of 
replicating the SAS analyses from an old report. I want to be sure that I can 
do all the things I need to in R before using it in my daily work.

So far, I've managed to read in all my data and have done some data 
manipulation. I'm having trouble with fixing an error in a date variable 
though, and was hoping someone could help.

One of the patients in my data has a DOB incorrectly entered as:

'11/23/21931' 

Their DOB should be:

'11/23/1931'

How can I correct this problem before calculating age in the code below?
DOB starts out as a factor in the Demo dataframe but then is converted into a 
date. So I had thought the ifelse that follows could be used to correct the 
problem, but this doesn't seem to be the case. 

Thanks,

Paul

Demo_Char <- within(Demo, {
DateCompleted <- as.Date(DateCompleted, format = "%m/%d/%Y")
DOB <- as.Date(DOB, format = "%m/%d/%Y")
DOB <- ifelse(Subject==108945, as.Date("1931-11-23"), DOB)
Age <- as.integer((DateCompleted - DOB) / 365.25)
})

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

2011-11-07 Thread PALMIER Patrick (Responsable de groupe) - CETE NP/TM/ST
Thank you for your response, but this is not exactly what I need

We are working on a tool that automatically generate R scripts adapted 
to our surveys databases.
When we want to do a table, we select interactively fields, associated 
labels, functions for an automatic crosstable for example
Then, the tool executes R in batch mode with the script produced by the tool
The "many scripts" correspond to the many crosstables people want to do. 
It is not possible produce these different scripts and execute all of 
them in a unique script with source.

For example, people want to do a crosstable, the tool produce a r script 
that generate the result. Then, the user want to do the same crosstable 
but on a subset or with different labels. Then, the tools produces 
another r script, and execute R which reloads at each time all the 
neeeded packages.

Is there a way to avoid this thing and to load packages only once?


Than you in advance

*Patrick PALMIER**
**Centre d'Études Techniques de l'Équipement Nord - Picardie
Département Transport Mobilités
*/*Responsable du groupe Systèmes de Transports*//*
*/2, rue de Bruxelles, BP 275
59019 Lille cedex
FRANCE
Tél: +33 (0) 3 20 49 60 70
Fax: +33 (0) 3 20 49 63 69


Le 07/11/2011 15:20, > Duncan Murdoch (par Internet) a écrit :
> On 07/11/2011 5:49 AM, PALMIER Patrick (Responsable de groupe) - CETE 
> NP/TM/ST wrote:
>> Hello,
>>
>>
>> I use R in batch mode. Each time, I execute a script, R is loading each
>> packages I need in my script. That's Ok
>> But, I had to execute many scripts , and each time R is re-loading the
>> corresponding packages, which take to much time
>>
>> Is it possible ask R to load the packages only once, and stay in memory
>> in background for further scripts, which would avoid to load the
>> packages in each script, or if you have another solution that need to
>> only load packages once in the first scripts, so that further scripts do
>> not need to load these packages too.
>
> Write one script that has a sequence of calls to source() to run the 
> other scripts.
>
> You'll need to be careful that unintentional leftover objects and 
> settings from one script don't affect the others; you may also want to 
> use the "echo=TRUE" option when you source, so you see the commands as 
> they are executed.
>
> Duncan Murdoch
>
>

[[alternative HTML version deleted]]

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


Re: [R] How to write a shapefile with projection

2011-11-07 Thread Monica Pisica

Hi Patrick,

Thanks for letting me know. I mostly use rgdal to read and write rasters so 
until now i kind of ignore other functionality. Unfortunately i supposed that a 
package dedicated to shapefiles would be the answer and had the functionality i 
needed. But rgdal does a nice job in saving my files as i need. It is good to 
know how to add the projection file to the shapefiles for the future, if it is 
not generated from the onset.

Thanks again,

Monica


> Date: Sat, 5 Nov 2011 14:27:29 +0100
> From: patrick.giraud...@univ-fcomte.fr
> To: pisican...@hotmail.com
> CC: r-help@r-project.org
> Subject: re: How to write a shapefile with projection
>
> > Hi,
> >
> > Sorry i have put such a detailed question to the list about writing a 
> > shapefile with projection. I realized that if i use writeOGR from rgdal and 
> > not the other write shapefile functions i can get a shapefile with 
> > projection recognized by ArcGIS. The command is (in case anybody wonders):
> >
> > ?writeOGR(crest.sp, "I:\\LA_levee\\Shape", "llev_crest_pts6", driver = 
> > "ESRI Shapefile")
> >
> > where crest.sp is a spatial point data frame with projection.
> >
> > Thanks,
> >
> > Monica
>
> Indeed.
>
> writePointsShape() does not write the projection file, but using the
> function showWKT from rgdal, you can also create one like that:
>
> writePointsShape(crest.sp,"crest")
> cat(showWKT(proj4string(crest.sp)),file="crest.prj")
>
> Patrick
>
>
  
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 in batch mode packages loading question

2011-11-07 Thread Duncan Murdoch
On 07/11/2011 5:49 AM, PALMIER Patrick (Responsable de groupe) - CETE 
NP/TM/ST wrote:

Hello,


I use R in batch mode. Each time, I execute a script, R is loading each
packages I need in my script. That's Ok
But, I had to execute many scripts , and each time R is re-loading the
corresponding packages, which take to much time

Is it possible ask R to load the packages only once, and stay in memory
in background for further scripts, which would avoid to load the
packages in each script, or if you have another solution that need to
only load packages once in the first scripts, so that further scripts do
not need to load these packages too.


Write one script that has a sequence of calls to source() to run the 
other scripts.


You'll need to be careful that unintentional leftover objects and 
settings from one script don't affect the others; you may also want to 
use the "echo=TRUE" option when you source, so you see the commands as 
they are executed.


Duncan Murdoch

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


Re: [R] How to use 'prcomp' with CLUSPLOT?

2011-11-07 Thread R. Michael Weylandt
Happy to look at it further, but I don't have access to
"fitnw$cluster" so i can't run clusplot, modified or unmodified.

If you would, create a test data set using dput() for all the needed objects.

Michael

On Fri, Nov 4, 2011 at 6:18 PM, jo  wrote:
> Hello Michael,
>
> Thank you for replying to my post!  That was an interesting solution - good
> to know, but I am now getting a different error:
> /Error in if (length(clus) != n) stop("The clustering vector is of incorrect
> length") :
>  argument is of length zero/
> which brought me here:
> https://svn.r-project.org/R-packages/trunk/cluster/R/plotpart.q
> I am trying to figure that out now...
>
> FYI, as a test set, one could just delete columns until they are <= to the
> number of rows...
>
> clusplot has some nice extras, but I am also looking at just plotting
> w/pca...
>
>
> Thank you again,
> Jo
>
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/How-to-use-prcomp-with-CLUSPLOT-tp3989022p3991868.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

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


  1   2   >