Re: [R] Deleting the last value of a vector

2011-04-18 Thread helin_susam
if you have a vector like as follows;

r=c(1,2,3,4,5)

then use

r2=r[1:length(r)-1] 

--
View this message in context: 
http://r.789695.n4.nabble.com/Deleting-the-last-value-of-a-vector-tp3456363p3456388.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] Windows 7, update.packages problem: "unable to move temporary installation"?

2011-04-18 Thread Joshua Wiley
Hi Tal,

Three thoughts, not sure if any of them would pan out in your case.

1) Run R as an administrator
2) Shift your library location out of Program Files
3) just use install.packages("MASS"), the only downside is you'd have
to know the packages you wanted to update rather than just
update.packages() which will update everything you need at once for
you.

Best regards,

Josh

On Sun, Apr 17, 2011 at 11:57 PM, Tal Galili  wrote:
> Hello all,
>
> I am using R 2.13.0 with windows 7, after giving my user full privileges to
> the R folder (as described
> here
> ).
> This allows me to install new packages just fine.
>
> However, when using update.packages(), to update existing packages, I keep
> getting the following error (for example, when updating the MASS package):
>
> package 'MASS' successfully unpacked and MD5 sums checked
> Warning: unable to move temporary installation 'C:\Program
> Files\R\R-2.13.0\library\file6cae3bcf\MASS' to 'C:\Program
> Files\R\R-2.13.0\library\MASS'
>
> Any suggestions on how to fix this?
>
>
> Thanks,
> Tal
>
>
> Contact
> Details:---
> Contact me: tal.gal...@gmail.com |  972-52-7275845
> Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
> www.r-statistics.com (English)
> --
>
>        [[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.
>



-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.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] Location of libraries in Windows

2011-04-18 Thread Mario Valle
I'm preparing to install 2.13, so I need a clarification about package 
location on disk.


On window the packages I have installed are under 
C:\Users\mvalle\R\win-library\2.12

and the ones that come with R are under "C:\Program Files\R\library"

If I execute update.packages() from the R gui, it fails because it finds 
e.g. Matrix as a package that should be updated

but the process cannot write under R\library.

I failed to change permissions for this directory (I tried hard...) so 
I'm forced to run Rterm.exe as administrator just to

update packages.

I would ask if moving all directories (except maybe base) from R\library to
R\win-library\2.12 could be a "good thing to do". Or should I simply not 
update packages that come with R?


Thanks for your help!
mario

--
Ing. Mario Valle
Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle
Swiss National Supercomputing Centre (CSCS)  | Tel:  +41 (91) 610.82.60
v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax:  +41 (91) 610.82.82

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


Re: [R] Location of libraries in Windows

2011-04-18 Thread Mario Valle
The best method to solve a problem is to send a mail to the list. One 
second later you find the problem has just been solved for someone else...
The solution is here: 
http://www.r-statistics.com/2011/04/how-to-upgrade-r-on-windows-7/

Anyway, my question about folder location remains.
Thanks!
mario

On 18-Apr-11 09:22, Mario Valle wrote:
I'm preparing to install 2.13, so I need a clarification about package 
location on disk.


On window the packages I have installed are under 
C:\Users\mvalle\R\win-library\2.12

and the ones that come with R are under "C:\Program Files\R\library"

If I execute update.packages() from the R gui, it fails because it 
finds e.g. Matrix as a package that should be updated

but the process cannot write under R\library.

I failed to change permissions for this directory (I tried hard...) so 
I'm forced to run Rterm.exe as administrator just to

update packages.

I would ask if moving all directories (except maybe base) from 
R\library to
R\win-library\2.12 could be a "good thing to do". Or should I simply 
not update packages that come with R?


Thanks for your help!
mario



--
Ing. Mario Valle
Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle
Swiss National Supercomputing Centre (CSCS)  | Tel:  +41 (91) 610.82.60
v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax:  +41 (91) 610.82.82

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


Re: [R] RJMCMC.

2011-04-18 Thread Oscar Rueda
Dear Marcus,

As others have pointed out, RJaCGH uses Reversible Jump MCMC to fit a 
non-homogeneous Hidden Markov Model to array CGH data, but it can be used for 
other applications too.
It can be easily adapted to homogeneous HMMs and even to mixed models. It also 
contains implementations of additional MCMC techniques such as delayed 
rejection or coupled parallel chains, so probably it is a good start for 
learning RJMCMC.
Hope it helps,
Oscar


On 17/4/11 01:31, "Marcus Vinicius"  wrote:

Dear R users,
I´m studying about Bayesian Statistics. In this context, please, anyone have
some basic script of RJMCMC (Reversible Jump Markov chain Monte Carlo) in R
or WinBUGS?
My aim is to learn how to implement this methodology.
Thanks a lot.
Marcus Vinicius

[[alternative HTML version deleted]]




Oscar M. Rueda, PhD.
Postdoctoral Research Fellow, Breast Cancer Functional Genomics.
Cancer Research UK Cambridge Research Institute.
Li Ka Shing Centre, Robinson Way.
Cambridge CB2 0RE
England



This communication is from Cancer Research UK. Our website is at 
www.cancerresearchuk.org. We are a registered charity in England and Wales 
(1089464) and in Scotland (SC041666) and a company limited by guarantee 
registered in England and Wales under number 4325234. Our registered address is 
Angel Building, 407 St John Street, London, EC1V 4AD. Our central telephone 
number is 020 7242 0200.
 
This communication and any attachments contain information which is 
confidential and may also be privileged.   It is for the exclusive use of the 
intended recipient(s).  If you are not the intended recipient(s) please note 
that any form of disclosure, distribution, copying or use of this communication 
or the information in it or in any attachments is strictly prohibited and may 
be unlawful.  If you have received this communication in error, please notify 
the sender and delete the email and destroy any copies of it.
 
E-mail communications cannot be guaranteed to be secure or error free, as 
information could be intercepted, corrupted, amended, lost, destroyed, arrive 
late or incomplete, or contain viruses.  We do not accept liability for any 
such matters or their consequences.  Anyone who communicates with us by e-mail 
is taken to accept the risks in doing so.
[[alternative HTML version deleted]]

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


Re: [R] Box plot with 5th and 95th percentiles instead of 1.5 * IQR: problems implementing an existing solution...

2011-04-18 Thread Uwe Ligges



On 17.04.2011 13:08, Paul Raftery wrote:

Hi all,

I'm just getting started with R and I would appreciate some help. I'm having
trouble creating a boxplot with whiskers at the 95th and 5th percentiles
instead of at 1.5 * IQR. I have read the relevant documentation, and checked
existing mails on this topic. I found a small modification that should work
: https://stat.ethz.ch/pipermail/r-help/2001-November/016817.html and tried
to implement it.

Basically, it says to replace boxplot.stats with:

myboxplot.stats<-  function (x, coef = NULL, do.conf = TRUE, do.out =
TRUE)
{
   nna<- !is.na(x)
   n<- sum(nna)
   stats<- quantile(x, c(.05,.25,.5,.75,.95), na.rm = TRUE)
   iqr<- diff(stats[c(2, 4)])
   out<- x<  stats[1] | x>  stats[5]
   conf<- if (do.conf)
 stats[3] + c(-1.58, 1.58) * diff(stats[c(2, 4)])/sqrt(n)
   list(stats = stats, n = n, conf = conf, out = x[out&  nna])
}

I entered the new function, and used fix(boxplot.default) to modify
boxplot.default so that it references myboxplot.stats instead of the
original boxplot.stats function.

If I now type boxplot.default, I can see that the code has been modified as
expected. However, I get the exact same result as before when I create a
boxplot - it shows the whiskers at 1.5 * IQR. You can test this out by
creating a boxplot from the iris dataset supplied with R using
boxplot(iris$Sepal.Length ~ iris$Species). You see that the boxplot is the
same before and after the fix.  Does anybody know why this occurs, and how I
can get around this issue?


Frank answered how to solve it using his functions. In order to do it 
your way, you need to change the boxplot.default function within its 
NAMESPACE, e.g. using fixInNamespace.


Otherwise you could also just call
  z <- boxplot()
then modify the relevant parts of the object z
and plot it using
  bxp(z)
afterwards.

Best,
Uwe







Thanks,


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


Re: [R] Location of libraries in Windows

2011-04-18 Thread Uwe Ligges



On 18.04.2011 09:29, Mario Valle wrote:

The best method to solve a problem is to send a mail to the list. One
second later you find the problem has just been solved for someone else...
The solution is here:
http://www.r-statistics.com/2011/04/how-to-upgrade-r-on-windows-7/
Anyway, my question about folder location remains.
Thanks!
mario

On 18-Apr-11 09:22, Mario Valle wrote:

I'm preparing to install 2.13, so I need a clarification about package
location on disk.

On window the packages I have installed are under
C:\Users\mvalle\R\win-library\2.12
and the ones that come with R are under "C:\Program Files\R\library"

If I execute update.packages() from the R gui, it fails because it
finds e.g. Matrix as a package that should be updated
but the process cannot write under R\library.

I failed to change permissions for this directory (I tried hard...) so
I'm forced to run Rterm.exe as administrator just to
update packages.

I would ask if moving all directories (except maybe base) from
R\library to
R\win-library\2.12 could be a "good thing to do". Or should I simply
not update packages that come with R?


You can install new versions of those package to R\win-library\2.12, 
then those versions will take precedence.


Uwe Ligges


Thanks for your help!
mario





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

2011-04-18 Thread Alaios
Dear all,

I would like to ask your help concerning 
converting a mapply function to lapply. The reason is that I would like to use 
mclapply which requires lapply syntax.

The command I would like to convert is:
F2[i+1,j+1]<-sum(mapply(Fwithcellvalue,i=i,j=j,a=cells[,2],b=cells[,4],c=cells[,1],d=cells[,3],e=cells[,5]))

Could you please help me understand how I should change it?


Best Regards
Alex

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

2011-04-18 Thread Alaios
It seems you were right.
Now I can easily access my struct and substruct like this

# all.str[[1]]] Gives access to the first struct of per.sr.struct which 
containts 101 times the xorder,yorder,estimation.sr
# all.str[[1]][[2]] Gives access to the second substruct of all.str[[1]]
# all.str[[1]][[2]][[3]] Gives access to the matrix.

Now I would like to ask you if in R cran I can make struct assignments like 
this 


all.str[[i]]<-TempApproxstruct


where all.str[[i]] is  a list that contains 100 times the
 $ :List of 3
  ..$ xorder   : int 0
  ..$ yoder: int 0
  ..$ estimation.sr: logi [1:256, 1:256] NA NA NA NA NA NA ...
 $ :List of 3
  ..$ xorder   : int 0
  ..$ yoder: int 0
  ..$ estimation.sr: logi [1:256, 1:256] NA NA NA NA NA NA ...
 and so on

where str(temp.per.sr.struct) is a list that contains 100 times the
 $ :List of 3
  ..$ xorder   : int 0
  ..$ yoder: int 0
  ..$ estimation.sr: logi [1:256, 1:256] NA NA NA NA NA NA ...
 $ :List of 3
  ..$ xorder   : int 0
  ..$ yoder: int 0
  ..$ estimation.sr: logi [1:256, 1:256] NA NA NA NA NA NA ...
  [list output truncated]
...and so on.

Will R understand this kind of assignments or not?

I would like to thank you in advance for your help
Best Regards
Alex









--- On Sat, 4/16/11, Ben Bolker  wrote:

> From: Ben Bolker 
> Subject: Re: [R] Help me create a hyper-structure
> To: r-h...@stat.math.ethz.ch
> Date: Saturday, April 16, 2011, 3:39 PM
> Alaios 
> yahoo.com> writes:
> 
> > 
> > Dear all 
> > I would like to have in R a big struct containing a
> smaller struct. 
> > 
> > 1) I would like to have a small struct with the
> following three fields
> > xorder (an integer ranging from 0 to 20)
> > yorder (an integer ranging from 0 to 20)
> > estimated (a 256*256 matrix)
> > 
> > 2) I would like to have 10 elements of the struct
> above
> > for that I wrote the following:
> > 
> Estimationstruct <- function ( xorder, yorder,
> estimated) {
>   list (xorder= xorder,
> yorder=yorder,estimated=estimated)
> }
> 
> per.sr.struct <- replicate(10,
>          
>    Estimationstruct(0L,0L,matrix(nrow=256,ncol=256)),
>    simplify=FALSE)
> 
> > That one worked.
> > per.sr.struct contains 10 elements and each one of
> that contains 1).
> 
> all.sr.struct
> <-   replicate(20,per.sr.struct,simplify=FALSE)
> 
> > The idea is to have 20 all.sr.stuct and each element
> > to contain one per.sr.struct.
> 
>   I think you just missed simplify=FALSE in the last
> step ...
> 
> __
> R-help@r-project.org
> mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Box plot with 5th and 95th percentiles instead of 1.5 * IQR: problems implementing an existing solution...

2011-04-18 Thread Paul Raftery
Thank you both. Both solutions worked fine, but I'll probably end up going
with

fixInNamespace(boxplot.default, "graphics")

as it allows me to use previously written script without making any further
changes.

Thanks again,
Regards,
Paul

2011/4/18 Uwe Ligges 

>
>
> On 17.04.2011 13:08, Paul Raftery wrote:
>
>> Hi all,
>>
>> I'm just getting started with R and I would appreciate some help. I'm
>> having
>> trouble creating a boxplot with whiskers at the 95th and 5th percentiles
>> instead of at 1.5 * IQR. I have read the relevant documentation, and
>> checked
>> existing mails on this topic. I found a small modification that should
>> work
>> : https://stat.ethz.ch/pipermail/r-help/2001-November/016817.html and
>> tried
>> to implement it.
>>
>> Basically, it says to replace boxplot.stats with:
>>
>> myboxplot.stats<-  function (x, coef = NULL, do.conf = TRUE, do.out =
>> TRUE)
>> {
>>   nna<- !is.na(x)
>>   n<- sum(nna)
>>   stats<- quantile(x, c(.05,.25,.5,.75,.95), na.rm = TRUE)
>>   iqr<- diff(stats[c(2, 4)])
>>   out<- x<  stats[1] | x>  stats[5]
>>   conf<- if (do.conf)
>> stats[3] + c(-1.58, 1.58) * diff(stats[c(2, 4)])/sqrt(n)
>>   list(stats = stats, n = n, conf = conf, out = x[out&  nna])
>> }
>>
>> I entered the new function, and used fix(boxplot.default) to modify
>> boxplot.default so that it references myboxplot.stats instead of the
>> original boxplot.stats function.
>>
>> If I now type boxplot.default, I can see that the code has been modified
>> as
>> expected. However, I get the exact same result as before when I create a
>> boxplot - it shows the whiskers at 1.5 * IQR. You can test this out by
>> creating a boxplot from the iris dataset supplied with R using
>> boxplot(iris$Sepal.Length ~ iris$Species). You see that the boxplot is the
>> same before and after the fix.  Does anybody know why this occurs, and how
>> I
>> can get around this issue?
>>
>
> Frank answered how to solve it using his functions. In order to do it your
> way, you need to change the boxplot.default function within its NAMESPACE,
> e.g. using fixInNamespace.
>
> Otherwise you could also just call
>  z <- boxplot()
> then modify the relevant parts of the object z
> and plot it using
>  bxp(z)
> afterwards.
>
> Best,
> Uwe
>
>
>
>
>
>
>> Thanks,
>>
>


-- 
Regards,
Paul


=
Contact Details
=
Paul Raftery, BEng(Hons) (Mech), Fulbright Fellow, PhD
http://www.paulraftery.com/
 
Postdoctoral Research Engineer
Informatics Research Unit for Sustainable Engineering (IRUSE)
http://www.iruse.ie/

Department of Civil Engineering,
National University of Ireland, Galway,
University Road,
Galway,
Ireland.

Landline: +353 91 49 3086
Mobile: +353 85 124 7947
Skype: praftery

[[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] URL Scan

2011-04-18 Thread Barry Rowlingson
On Sun, Apr 17, 2011 at 11:56 PM, jmsc  wrote:
> The site does not require a login/password. Another way to access the first
> site would be to go to the second site, click Connecticut, click Canterbury,
> CT, enter the online database, click search under Query by Location with
> nothing in the search fields, and click the first property. Viewing the
> frame source on this page redirects to the second site.

 it doesn't require a login/pass, but it uses session cookies to
simulate a logged-in user (there's even a log out button that clears
the session).

> Also, could you direct me to or give me some instructions on scanning from
> sites that do require a login/password? Thanks.

 I had a quick look for R-help posts on this ( RSiteSearch("cookies"),
RSiteSearch("session") etc) but didn't find much. You probably want to
install  RCurl and look at the examples.

 Generally what happens is that a successful login, or in this case
just visiting the database front page, causes the web server to send
back a 'cookie' with a long ID number in it. For every further access
to that web site your browser includes the cookie. The server then
looks up the ID, goes 'yup, this is a valid session', and sends you
the page you want. If the cookie isn't there, or the ID isn't valid
(and the ID numbers are big enough to make guessing impractical), then
you get the default page.

Barry

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


Re: [R] mapply to lapply

2011-04-18 Thread Andreas Borg

My solution would be to use an index variable that goes from 1 to the number of 
rows that are to be processed, along with a helper function which calls 
Fwithcellvalue with the suitable arguments:

F2[i+1,j+1]<-sum(lapply(1:nrow(cells), function(rowInd) 
Fwithcellvalue(i=i,j=j,a=cells[rowInd,2],b=cells[rowInd,4],c=cells[rowInd,1],d=cells[rowInd,3],e=cells[rowInd,5]))



Best regards,

Andreas

Alaios schrieb:

Dear all,

I would like to ask your help concerning 
converting a mapply function to lapply. The reason is that I would like to use 
mclapply which requires lapply syntax.


The command I would like to convert is:
F2[i+1,j+1]<-sum(mapply(Fwithcellvalue,i=i,j=j,a=cells[,2],b=cells[,4],c=cells[,1],d=cells[,3],e=cells[,5]))

Could you please help me understand how I should change it?


Best Regards
Alex

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

  



--
Andreas Borg
Medizinische Informatik

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

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

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

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


Re: [R] different colors in a segplot centers (package latticeExtra)

2011-04-18 Thread Deepayan Sarkar
On Mon, Apr 18, 2011 at 4:10 AM, barbara costa  wrote:
> Hi,
> how can I change colors in the centers of my segplot?
> I'm not interested in coloring the lines (Standard error limits) but the
> centers (means)?
>  here's my code:
>
>
> segplot(reorder(factor(Species), MeanBiom)  ~ MinSEBiom + MaxSEBiom ,
> data=dfRatioAftBefBiom, draw.bands = FALSE, centers = MeanBiom,
> col=as.numeric (Commercial.Value))

Try 'col.symbol' instead of 'col'.

-Deepayan

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


Re: [R] regression and lmer

2011-04-18 Thread Iasonas Lamprianou
Dear all, 

I hope this is the right place to ask this question.

I am reviewing a research where the analyst(s) are using a linear 
regression model. The dependent variable (DV) is a continuous measure. 
The independent variables (IVs) are a mixture of linear and categorical 
variables.

The 
author investigates whether performance (DV - continuous linear) is a 
function of age (continuous IV1 - measured in years), previous 
performance (continuous IV2), country (categorical IV3 - six countries), the 
percentage of PhD graduates in each country (continuous IV4 - 
country level data - apparently only six different percentages since we 
have only six countries) and population of country (continuous IV5 - country 
level data - again only six numbers here, one for each country population).

My own opinion is that the lm function cannot be used with country 
level data as IVs (for example IV4 and IV5 cannot be entered into the 
model because they are country level data). If IV4 and IV5 are included 
in the model, it is possible that the model will not be able to be 
defined because we only have six countries and it is very likely that 
the levels of counties (IV3) may be confounding with IV4 and IV5. This 
also calls for multicollinearity issues, right? I would like to suggest 
to the analyst to use lmer using the IV3 as a random variable and  IV4 
and IV5 as IV at the second level of the two-level model. 


The questions are: (a) Is it true that IV4 and IV5 cannot be entered in a 
one-level regression if we also have IV3?, (b) can I use an lm function to 
check for multicollinearity 
between IV3, IV4 and IV5?  and (c) If we use a two-level regression 
model, does lmer cope well with only six coutnries as a random effect?

Thank you for your help

Jason
[[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] Deleting the last value of a vector

2011-04-18 Thread Allan Engelhardt
This is unlikely to be the kind of operation where speed is essential, 
but nevertheless on my build of 2.14.0 (with byte compiled base packages):

stopifnot(getRversion()>= "2.14")
library("compiler")

f1<- function (x, n) head(x, length(x) - n)# suggested by baptiste auguie
f2<-  function (x, n) x[ seq(1, length(x) - n) ]# suggested by baptiste 
auguie
f3<- function (x, n) x[ - seq(length(x), by=-1, length=n) ]   # suggested by 
baptiste auguie
f4<- function (x, n) head(x, -n)# Suggested by Petr PIKAL
f5<- function (x, n) x[ seq_len(length(x) - n) ]# My variation on f2
c1<- cmpfun(f1,options = list(optimize = 3))# Undocumented (?) default is 2
c2<- cmpfun(f2,options = list(optimize = 3))
c3<- cmpfun(f3,options = list(optimize = 3))
c4<- cmpfun(f4,options = list(optimize = 3))
c5<- cmpfun(f5,options = list(optimize = 3))
library("rbenchmark")
set.seed(42)
x<- runif(1e6)

n<- 1
benchmark(f1(x, n), f2(x, n), f3(x, n), f4(x, n), f5(x, n),
   c1(x, n), c2(x, n), c3(x, n), c4(x, n), c5(x, n),
   columns = c("test", "elapsed", "relative"),
   order = "relative", replications = 1e3)
#test elapsed relative
# 7  c2(x, n)  17.483 1.00
# 10 c5(x, n)  17.600 1.006692
# 1  f1(x, n)  22.782 1.303094
# 2  f2(x, n)  23.054 1.318652
# 4  f4(x, n)  23.498 1.344049
# 9  c4(x, n)  23.547 1.346851
# 6  c1(x, n)  23.752 1.358577
# 5  f5(x, n)  23.892 1.366585
# 3  f3(x, n)  27.209 1.556312
# 8  c3(x, n)  27.296 1.561288
## So c{2,5} are fastest, .3 slowest, and the rest much the same

n<- 1e5
benchmark(f1(x, n), f2(x, n), f3(x, n), f4(x, n), f5(x, n),
   c1(x, n), c2(x, n), c3(x, n), c4(x, n), c5(x, n),
   columns = c("test", "elapsed", "relative"),
   order = "relative", replications = 1e3)
#test elapsed relative
# 10 c5(x, n)  14.729 1.00
# 7  c2(x, n)  14.939 1.014258
# 5  f5(x, n)  18.544 1.259013
# 2  f2(x, n)  18.557 1.259895
# 6  c1(x, n)  18.695 1.269265
# 4  f4(x, n)  18.718 1.270826
# 9  c4(x, n)  18.729 1.271573
# 1  f1(x, n)  18.729 1.271573
# 3  f3(x, n)  20.836 1.414624
# 8  c3(x, n)  20.958 1.422907
## As before

n<- 1
enableJIT(2)# Will also optimise rbenchmark::benchmark.
benchmark(f1(x, n), f2(x, n), f3(x, n), f4(x, n), f5(x, n),
   c1(x, n), c2(x, n), c3(x, n), c4(x, n), c5(x, n),
   columns = c("test", "elapsed", "relative"),
   order = "relative", replications = 1e3)
#test elapsed relative
# 7  c2(x, n)  15.035 1.00
# 10 c5(x, n)  15.076 1.002727
# 2  f2(x, n)  15.258 1.014832
# 9  c4(x, n)  15.313 1.018490
# 5  f5(x, n)  15.327 1.019421
# 6  c1(x, n)  15.402 1.024410
# 4  f4(x, n)  15.430 1.026272
# 1  f1(x, n)  15.594 1.037180
# 3  f3(x, n)  18.238 1.213036
# 8  c3(x, n)  18.245 1.213502
## No difference between the c. and f. functions here


So as long as you don't use the .3 functions you should be OK.

Allan
http://www.cybaea.net/Blogs/Data/

On 18/04/11 07:07, Petr PIKAL wrote:
> Hi
>
> r-help-boun...@r-project.org napsal dne 18.04.2011 04:51:20:
>
>> Or perhaps even more parsimoniously (by a couple of characters) -
>>
>> r<- c(1, 2, 3, 4, 5)
>> r2<-r[-length(r)]
> Maybe even shorter
>
> head(x,-1)
>
> Regards
> Petr
>
>
>> Min-Han
>>
>> On Sun, Apr 17, 2011 at 10:23 PM, Daisy Englert Duursma<
>> daisy.duur...@gmail.com>  wrote:
>>
>>> A easier solution:
>>>
>>> r<- c(1, 2, 3, 4, 5)
>>> r2<-r[1:length(r)-1]
>>>
>>>
>>>
>>>
>>> On Mon, Apr 18, 2011 at 10:51 AM, empyrean  wrote:
 Hey guys,

 I've search a few threads about deleting a value from a vector, but
> no
>>> one
 has addressed this question so far.

 I want to delete the last value from a string of values

 I have:

 r = [ 1, 2, 3, 4, 5 ], and i want to make r2 = to [ 1, 2, 3, 4]

 So that r2 is just like r, except that it missing the final value.

 Thanks,

 --
 View this message in context:
>>> http://r.789695.n4.nabble.com/Deleting-the-last-value-of-a-vector-
>> tp3456363p3456363.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.

>>>
>>>
>>> --
>>> Daisy Englert Duursma
>>> Department of Biological Sciences
>>> Room E8C156
>>> Macquarie University, North Ryde, NSW 210
>>> Australia
>>>
>>> Tel +61 2 9850 9256
>>>
>>> __
>>> R-help@r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/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

Re: [R] Create matrices for time series

2011-04-18 Thread mathijsdevaan
Thanks a lot!

Given the calculations below, I would like to generate a data.frame in which
the value of case 8029 (i) in 1998 = sum (element c(i,j) * element
final1(1,j) * 1st eigenvalue 1998 * element final2 (i,j)) * (1/sum
final2(i)) in which j are all other cases in year 1998 and i IS NOT j?
so for 8029 in 1998 = (0.9072184 * -0.5093407 * 3.64178798 * 0 + 0.8733873 *
-0.4763885 * 3.64178798 * 1 + 0.9058216 * -0.5072112 * 3.64178798 * 1) *
(1/3) = -1.06281276

Using this formula, I would like to generate a list per year (1997 - 1999)
with all unique cases (1998 = 8025, 8026, 8027, 8029) in that year and the
outcome of the formula.

I've been trying to run this formula, but I am having a hard time connecting
each element to each other element. Could anyone please help me? Thanks in
advance!
 
library(zoo)

DF1 = data.frame(read.table(textConnection("B  C  D  E  F  G
8025  1995  0  4  1  2
8025  1997  1  1  3  4
8026  1995  0  7  0  0
8026  1996  1  2  3  0
8026  1997  1  2  3  1
8026  1998  6  0  0  4
8026  1999  3  7  0  3
8027  1997  1  2  3  9
8027  1998  1  2  3  1
8027  1999  6  0  0  2
8028  1999  3  7  0  0
8029  1995  0  2  3  3
8029  1998  1  2  3  2
8029  1999  6  0  0  1"),head=TRUE,stringsAsFactors=FALSE))

a <- read.zoo(DF1, split = 1, index = 2, FUN = identity)
sum.na <- function(x) if (any(!is.na(x))) sum(x, na.rm = TRUE) else NA
b <- rollapply(a, 3,  sum.na, align = "right", partial = TRUE)
newDF <- lapply(1:nrow(b), function(i)
   prop.table(na.omit(matrix(b[i,], nc = 4, byrow = TRUE,
   dimnames = list(unique(DF1$B), names(DF1)[-1:-2]))), 1))
names(newDF) <- time(a)
c<-lapply(newDF, function(mat) tcrossprod(mat / sqrt(rowSums(mat^2
d <- lapply(c, function(x) eigen(x, symmetric = TRUE, only.values = FALSE,
EISPACK = FALSE))


DF2 = data.frame(read.table(textConnection("  A  B  C
80  8025  1995
80  8026  1995
80  8029  1995
81  8026  1996
82  8025  1997
82  8026  1997
83  8025  1997
83  8027  1997
90  8026  1998
90  8027  1998
90  8029  1998
84  8026  1999
84  8027  1999
85  8028  1999
85  8029  1999"),head=TRUE,stringsAsFactors=FALSE))

e <- function(y) crossprod(table(DF2[DF2$C %in% y, 1:2])) 
years <- sort(unique(DF2$C)) 
f <- as.data.frame(embed(years, 3)) 
g<-lapply(split(f, f[, 1]), e)
library(sna)
h<-event2dichot(g, method="absolute", thresh=0.99)


--
View this message in context: 
http://r.789695.n4.nabble.com/Create-matrices-for-time-series-tp3449005p3456958.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] covariance matrix: a erro and simple mixed model question, but id not know answer sorry

2011-04-18 Thread Maya Joshi
Let me clarify the output I want to create:

Source   X1 (var)  X2  (var)   X1&X2
(cov)
gen   var(X1)  var(X2)
 cov(x1X2)
block var(X1)   var(X2)
cov(x1x2)
error/ res var(x1)   var(x2)
 cov(x1x2)

I need to do posterior analysis out of this table

Thanks in advance

Maya


On Sun, Apr 17, 2011 at 9:59 PM, Maya Joshi  wrote:

> Dear list
>
> I need your help: Execuse me for my limited R knowledge.
>
> #example data set
> set.seed (134)
> lm=c(1:4)
>
> block = c(rep(lm,6))
>
> gen <- c(rep(1, 4), rep(2, 4), rep(3, 4), rep(4, 4),rep(5, 4),rep(6, 4))
>
> X1 = c( rnorm (4, 10, 4), rnorm (4, 12, 6), rnorm (4, 10, 7),rnorm (4, 5,
> 2), rnorm (4, 8, 4), rnorm (4,7, 2))
>
> X2 = X1 + rnorm(length(X1), 0,3)
>
> yvar <- c(X1, X2)
>
> X <- c(rep( 1, length(X1)), rep( 2, length(X2))) # dummy x variable
>
> dataf <- data.frame(as.factor(block), as.factor(gen), as.factor(X), yvar )
>
>
>
> My objective to estimate variance-covariance between two variables X1 and
> X2. Means that I need to fit something like unstructure (UN) covariance
> structure.
>
>
>
> Question 1: I got the following error
>
> require("lme4");
>
> fm1Gen <- lmer(yvar ~ X + gen +(1|block), data= dataf) # Question 1:
> should I consider X fixed or random
>
>
>
> Error in model.frame.default(data = dataf, formula = yvar ~ X + gen +  :
>   variable lengths differ (found for 'gen')
>
>
>
> A tried nlme too.
>
> require(nlme)
>
> fm2Gen <- lme(yvar ~ X + gen,  random= ~ 1|block, data= dataf)
>
> Error in model.frame.default(formula = ~yvar + X + gen + block, data =
> list( :
>   variable lengths differ (found for 'gen') # similar error
>
>
>
> Question 2: How can get I covariance matrix between X1 and X2 either using
> lme4 or lmer.
>
>X1X2
>
> X1   Var (X1) Cov(X1,X2)
>
> X2   Cov(X1, X2)  Var(X2)
>
>
>
> Should I put gen in the model to do this? Should I specify something in "*
> correlation* =  "
>
> Thank you for your time
>
> Maya
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

[[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] as.Date error

2011-04-18 Thread David Winsemius


On Apr 17, 2011, at 7:24 PM, Wonjae Lee wrote:



Thank you for replying the as.Date error question.

I have one more question as below.
I used cbind command, and data x changed, 2010-11-16 to 14929,  
2010-11-17 to

14930.
What happened to them?
What should I do to see -mm-dd format data?


x=c("11/16/2010","11/17/2010","11/18/2010","11/19/2010")
x=as.Date(x,"%m/%d/%Y")
x

[1] "2010-11-16" "2010-11-17" "2010-11-18" "2010-11-19"

y=c(1753.75,15077,1759.35,15078)
cbind(x,y)

xy
[1,] 14929  1753.75
[2,] 14930 15077.00
[3,] 14931  1759.35
[4,] 14932 15078.00



cbind.default will return a matrix which needs to have all of its  
elements of the same type, so your dates were coerced to numeric since  
their internal representation is as integers.


Had you created x as a data.frame, then cbind would have called  
cbind.data.frame which was probably what you wanted to happen.


> xdat <-data.frame(x=as.Date(x,"%m/%d/%Y"))
> cbind(xdat,y)
   xy
1 2010-11-16  1753.75
2 2010-11-17 15077.00
3 2010-11-18  1759.35
4 2010-11-19 15078.00

--

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] (no subject)

2011-04-18 Thread Ramnath R
Hai

 From which CRAN mirror can get the package ‘LPP2005REC’

Ram

[[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] Color Key in RColorBrewer

2011-04-18 Thread chakri
Jsut a quick note - I found answer to my query. color scale can be retained
by break command
> breaks=seq(0,1,0.025)

--
View this message in context: 
http://r.789695.n4.nabble.com/Color-Key-in-RColorBrewer-tp3455953p3456955.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] XML Packge for Windows XP and R 2.12.

2011-04-18 Thread kschaber
Hello,

I am looking for the XML Package for Windows or any package, which would
enable me to use the function "xmlTreeParse". In a thread dating from
2001, the same question is raised:

>>Griffith Feeney wrote:
>>
>> Has anyone gotten the XML package (R News 1-1:24) with R running on
Windows
>> (95 or 98 or 2000)? I've looked at the omegahat, expat and libxml web
>> pages, looks like compiling from source (of which I have little
experience)
>> will be necessary. I'm wondering how difficult it might prove to be. Any
>> suggestions would be appreciated.

>A windows binary version is available at
>http://cran.r-project.org/bin/windows/contrib

>Uwe Ligges


As for Feeney compiling from source is not a preferable option for me, as
I have no experience on that. In the link provided by Uwe Ligges, I could
not locate the file I am looking for (xml.** zip).

Thanks a lot for your help,
Katrin Schaber

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


Re: [R] (no subject)

2011-04-18 Thread Philipp Pagel
On Mon, Apr 18, 2011 at 04:11:57PM +0530, Ramnath R wrote:
> Hai
> 
>  From which CRAN mirror can get the package ?LPP2005REC?

As the first hit of a google search for "LPP2005REC" told me it
is not a package but a dataset in package timeSeries.

cu
Philipp

-- 
Dr. Philipp Pagel
Lehrstuhl für Genomorientierte Bioinformatik
Technische Universität München
Wissenschaftszentrum Weihenstephan
Maximus-von-Imhof-Forum 3
85354 Freising, Germany
http://webclu.bio.wzw.tum.de/~pagel/

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


Re: [R] mapply to lapply

2011-04-18 Thread Alaios
Dear Andreas,
I would like to thank you for your reply.
I have tried two alternatives but none of the two worked out:

F2[i+1,j+1]<-sum(lapply(1:nrow(cells), function(rowInd) 
Fwithcellvalue(i=i,j=j,a=cells[rowInd,2],b=cells[rowInd,4],c=cells[rowInd,1],d=cells[rowInd,3],e=cells[rowInd,5])))

this one is executed : takes like 2 mins to return(which is normal) but returns 
the following

^@Error in sum(lapply(1:nrow(cells), function(rowInd) Fwithcellvalue(i = i,  : 
  invalid 'type' (list) of argument


afterwards I tried to change the function definition so to pass i,j inside:

This one does not execute at all 

F2[i+1,j+1]<-sum(lapply(1:nrow(cells), function(rowInd,i,j) 
Fwithcellvalue(i=i,j=j,a=cells[rowInd,2],b=cells[rowInd,4],c=cells[rowInd,1],d=cells[rowInd,3],e=cells[rowInd,5])))
Error in paste("f", i, j, "(a,b,c,d)", sep = "") : 
  argument "i" is missing, with no default


What do you think I should try out now?

Vielen Dank
Alex

--- On Mon, 4/18/11, Andreas Borg  wrote:

> From: Andreas Borg 
> Subject: Re: [R] mapply to lapply
> To: "Alaios" 
> Cc: R-help@r-project.org
> Date: Monday, April 18, 2011, 11:10 AM
> My solution would be to use an index
> variable that goes from 1 to the number of rows that are to
> be processed, along with a helper function which calls
> Fwithcellvalue with the suitable arguments:
> 
> F2[i+1,j+1]<-sum(lapply(1:nrow(cells), function(rowInd)
> Fwithcellvalue(i=i,j=j,a=cells[rowInd,2],b=cells[rowInd,4],c=cells[rowInd,1],d=cells[rowInd,3],e=cells[rowInd,5]))
> 
> 
> Best regards,
> 
> Andreas
> 
> Alaios schrieb:
> > Dear all,
> > 
> > I would like to ask your help concerning converting a
> mapply function to lapply. The reason is that I would like
> to use mclapply which requires lapply syntax.
> > 
> > The command I would like to convert is:
> >
> F2[i+1,j+1]<-sum(mapply(Fwithcellvalue,i=i,j=j,a=cells[,2],b=cells[,4],c=cells[,1],d=cells[,3],e=cells[,5]))
> > 
> > Could you please help me understand how I should
> change it?
> > 
> > 
> > Best Regards
> > Alex
> > 
> > __
> > R-help@r-project.org
> mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained,
> reproducible code.
> > 
> >   
> 
> 
> -- Andreas Borg
> Medizinische Informatik
> 
> UNIVERSITÄTSMEDIZIN
> der Johannes Gutenberg-Universität
> Institut für Medizinische Biometrie, Epidemiologie und
> Informatik
> Obere Zahlbacher Straße 69, 55131 Mainz
> www.imbei.uni-mainz.de
> 
> Telefon +49 (0) 6131 175062
> E-Mail: b...@imbei.uni-mainz.de
> 
> Diese E-Mail enthält vertrauliche und/oder rechtlich
> geschützte Informationen. Wenn Sie nicht der
> richtige Adressat sind oder diese E-Mail irrtümlich
> erhalten haben, informieren Sie bitte sofort den
> Absender und löschen Sie diese Mail. Das unerlaubte
> Kopieren sowie die unbefugte Weitergabe
> dieser Mail und der darin enthaltenen Informationen ist
> nicht gestattet.
> 
>

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


Re: [R] (no subject)

2011-04-18 Thread David Winsemius


On Apr 18, 2011, at 6:41 AM, Ramnath R wrote:


Hai

From which CRAN mirror can get the package ‘LPP2005REC’


What makes you think any CRAN mirror should have such package?

--

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] plot and lines with time series data

2011-04-18 Thread Fred
Dear all,

I am doing some time series analysis with R now. The problem is, when
I create a time series object using "ts" function, then after fitting
the model, the predicted values cannot be plotted with "ts" object
together using "lines". ie.

ts.series<-ts(x,start, end)
plot(ts.series)
lines(predict(fit.model))

This doesn't work.

Does anyone know about how to make it work ?

Thank you very much

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


Re: [R] plot and lines with time series data

2011-04-18 Thread Fred
Figure it out. Just make predicted value "ts" object as well.

On Apr 18, 9:20 pm, Fred  wrote:
> Dear all,
>
> I am doing some time series analysis with R now. The problem is, when
> I create a time series object using "ts" function, then after fitting
> the model, the predicted values cannot be plotted with "ts" object
> together using "lines". ie.
>
> ts.series<-ts(x,start, end)
> plot(ts.series)
> lines(predict(fit.model))
>
> This doesn't work.
>
> Does anyone know about how to make it work ?
>
> Thank you very much
>
> __
> r-h...@r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guidehttp://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] XML Packge for Windows XP and R 2.12.

2011-04-18 Thread Prof Brian Ripley

On Mon, 18 Apr 2011, kscha...@rzg.mpg.de wrote:


Hello,

I am looking for the XML Package for Windows or any package, which would
enable me to use the function "xmlTreeParse". In a thread dating from
2001, the same question is raised:


Wow, a deacde ago!

Why don't you simply use your menus to install the binary version: 
that will work (but note that the posting guide asked you to update 
your R *before* posting).





Griffith Feeney wrote:

Has anyone gotten the XML package (R News 1-1:24) with R running on

Windows

(95 or 98 or 2000)? I've looked at the omegahat, expat and libxml web
pages, looks like compiling from source (of which I have little

experience)

will be necessary. I'm wondering how difficult it might prove to be. Any
suggestions would be appreciated.



A windows binary version is available at
http://cran.r-project.org/bin/windows/contrib



Uwe Ligges



As for Feeney compiling from source is not a preferable option for me, as
I have no experience on that. In the link provided by Uwe Ligges, I could
not locate the file I am looking for (xml.** zip).

Thanks a lot for your help,
Katrin Schaber

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] help in neural networks package for simple 1d tsa-prediction

2011-04-18 Thread c2r
I am also looking for a sample to predict values for a simple 1d time series.
I did look at various library-samples as in
neuralnet,AMORE,nnet,RSNNS,Qrnn,monmlp e.t.c. 
but did not find a simple 1d-sample that forecasts like in the following
simple arima-sample:

library(TSA)
x = arima.sim(list(order=c(1,0,1), ar=.9, ma=-.5), n=100) # simulate some
data
x.fit = arima(x, order = c(1, 0, 1)) # fit the model and print the results
x.fore=predict(x.fit, n.ahead=10)  
# plot the forecasts
U = x.fore$pred + 2*x.fore$se
L = x.fore$pred - 2*x.fore$se
minx=min(x,L)
maxx=max(x,U)
ts.plot(x,x.fore$pred,col=1:2, ylim=c(minx,maxx))
lines(U, col="blue", lty="dashed")
lines(L, col="blue", lty="dashed") 

Did you meanwhile find a working sample or can anyone show a nn-sample here
to predict
the arima.sim series x from above sample with ploting the next 10 forecasted
values ?


--
View this message in context: 
http://r.789695.n4.nabble.com/help-in-neural-networks-package-tp2133927p3457207.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] mapply to lapply

2011-04-18 Thread Kenn Konstabel
On Mon, Apr 18, 2011 at 2:10 PM, Alaios  wrote:
> Dear Andreas,
> I would like to thank you for your reply.
> I have tried two alternatives but none of the two worked out:
>
> F2[i+1,j+1]<-sum(lapply(1:nrow(cells), function(rowInd) 
> Fwithcellvalue(i=i,j=j,a=cells[rowInd,2],b=cells[rowInd,4],c=cells[rowInd,1],d=cells[rowInd,3],e=cells[rowInd,5])))
>
> this one is executed : takes like 2 mins to return(which is normal) but 
> returns the following
>
> ^@Error in sum(lapply(1:nrow(cells), function(rowInd) Fwithcellvalue(i = i,  :
>  invalid 'type' (list) of argument

The lapply part worked but for sum you need a vector rather than a
list (which is the result of lapply). So e.g. sum(unlist(lapply(.
something .))) should work.

KK

>
>
> afterwards I tried to change the function definition so to pass i,j inside:
>
> This one does not execute at all
>
> F2[i+1,j+1]<-sum(lapply(1:nrow(cells), function(rowInd,i,j) 
> Fwithcellvalue(i=i,j=j,a=cells[rowInd,2],b=cells[rowInd,4],c=cells[rowInd,1],d=cells[rowInd,3],e=cells[rowInd,5])))
> Error in paste("f", i, j, "(a,b,c,d)", sep = "") :
>  argument "i" is missing, with no default
>
>
> What do you think I should try out now?
>
> Vielen Dank
> Alex
>
> --- On Mon, 4/18/11, Andreas Borg  wrote:
>
>> From: Andreas Borg 
>> Subject: Re: [R] mapply to lapply
>> To: "Alaios" 
>> Cc: R-help@r-project.org
>> Date: Monday, April 18, 2011, 11:10 AM
>> My solution would be to use an index
>> variable that goes from 1 to the number of rows that are to
>> be processed, along with a helper function which calls
>> Fwithcellvalue with the suitable arguments:
>>
>> F2[i+1,j+1]<-sum(lapply(1:nrow(cells), function(rowInd)
>> Fwithcellvalue(i=i,j=j,a=cells[rowInd,2],b=cells[rowInd,4],c=cells[rowInd,1],d=cells[rowInd,3],e=cells[rowInd,5]))
>>
>>
>> Best regards,
>>
>> Andreas
>>
>> Alaios schrieb:
>> > Dear all,
>> >
>> > I would like to ask your help concerning converting a
>> mapply function to lapply. The reason is that I would like
>> to use mclapply which requires lapply syntax.
>> >
>> > The command I would like to convert is:
>> >
>> F2[i+1,j+1]<-sum(mapply(Fwithcellvalue,i=i,j=j,a=cells[,2],b=cells[,4],c=cells[,1],d=cells[,3],e=cells[,5]))
>> >
>> > Could you please help me understand how I should
>> change it?
>> >
>> >
>> > Best Regards
>> > Alex
>> >
>> > __
>> > R-help@r-project.org
>> mailing list
>> > https://stat.ethz.ch/mailman/listinfo/r-help
>> > PLEASE do read the posting guide 
>> > http://www.R-project.org/posting-guide.html
>> > and provide commented, minimal, self-contained,
>> reproducible code.
>> >
>> >
>>
>>
>> -- Andreas Borg
>> Medizinische Informatik
>>
>> UNIVERSITÄTSMEDIZIN
>> der Johannes Gutenberg-Universität
>> Institut für Medizinische Biometrie, Epidemiologie und
>> Informatik
>> Obere Zahlbacher Straße 69, 55131 Mainz
>> www.imbei.uni-mainz.de
>>
>> Telefon +49 (0) 6131 175062
>> E-Mail: b...@imbei.uni-mainz.de
>>
>> Diese E-Mail enthält vertrauliche und/oder rechtlich
>> geschützte Informationen. Wenn Sie nicht der
>> richtige Adressat sind oder diese E-Mail irrtümlich
>> erhalten haben, informieren Sie bitte sofort den
>> Absender und löschen Sie diese Mail. Das unerlaubte
>> Kopieren sowie die unbefugte Weitergabe
>> dieser Mail und der darin enthaltenen Informationen ist
>> nicht gestattet.
>>
>>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

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


Re: [R] plot and lines with time series data

2011-04-18 Thread Gabor Grothendieck
On Mon, Apr 18, 2011 at 7:20 AM, Fred  wrote:
> Dear all,
>
> I am doing some time series analysis with R now. The problem is, when
> I create a time series object using "ts" function, then after fitting
> the model, the predicted values cannot be plotted with "ts" object
> together using "lines". ie.
>
> ts.series<-ts(x,start, end)
> plot(ts.series)
> lines(predict(fit.model))
>
> This doesn't work.
>
> Does anyone know about how to make it work ?

Its hard to tell what did not work without a complete example but try
replacing lm with dyn$lm. Using built in Nile:

library(dyn)
fit.model <- dyn$lm(Nile ~ time(Nile))
plot(Nile)
lines(predict(fit.model))
-- 
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] Deleting the last value of a vector

2011-04-18 Thread Kenn Konstabel
On Mon, Apr 18, 2011 at 4:14 AM, helin_susam  wrote:
> if you have a vector like as follows;
>
> r=c(1,2,3,4,5)
>
> then use
>
> r2=r[1:length(r)-1]

Umm ... this works and gives the intended answer but does so in an ugly way --

1:length(r)-1 is equivalent to (1:length(r))-1 or 0:(length(r)-1) --
in other words, you get a sequence from 0 to 4. The result of r[0] is,
curiously, integer(0) (but if you think about it, it might just as
well be an error), so you get the intended result but what you
probably actually meant is

r2=r[1:(length(r)-1)]

# or

r2=r[1:seq_len(length(r)-1)]


KK

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


Re: [R] Stepwise Regression with no Origin

2011-04-18 Thread Zd Gibbs
Thanks for this help. I'll read the documentation and see if I can work through 
the problem. I actually look forward to Mr. Harrell's reply. I have been taught 
that stepwise is not a good approach to use and should be avoided at all costs, 
so he may give me a cogent argument. The problem I posted came from my 
supervisor to me or I wouldn't be trying to work through the stepwise 
procedure. 
But on the brightside, it gives me an opportunity to learn something in R.

Zeda.





From: Uwe Ligges 

Cc: r-help@r-project.org
Sent: Fri, April 15, 2011 10:28:10 AM
Subject: Re: [R] Stepwise Regression with no Origin



On 12.04.2011 21:52, Zd Gibbs wrote:
> Sorry, the first version was incomplete. I'm trying again.
>
> I am running a regression equation and i want to enter in 12 IV then stepwise
> enter 8 variables and not have an origin.
>
> DV is "shfl".
> I  want to enter in the following 12 independent dummy variables
> ajan
> bfeb
> cmar
> dapr
> emay
> fjun
>
> And then I want to enter in a stepwise fashion
> slag6
> slag7
> slag8
> slag9
> slag10
> slag11
> slag12
>
> And finally, I want there to be no origin.
>
> I've done simple regression, but nothing quite like this.


See ?step which allows to specify minimal, maximal models as well as 
forward stepwise selection.

BTW: Someone called Frank Harrell will shortly let you know about 
possible problems in model interpretation when using stepwise variable 
selection.

Best,
Uwe Ligges

> I would appreciate your help.
>
> Thanks
>
> Zeda
>     [[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] regression and lmer

2011-04-18 Thread Mike Marchywka








Date: Mon, 18 Apr 2011 03:27:40 -0700
From: lampria...@yahoo.com
To: r-help@r-project.org
Subject: Re: [R] regression and lmer


Dear all,

I hope this is the right place to ask this question.
 
( hotmail not marking your text sorry I can';t find option to change that  )
opinions vary but mods seem to let this by and personally it
seems appropriate to discuss general questions about what R 
can do. 

( end my text ) 

I am reviewing a research where the analyst(s) are using a linear
regression model. The dependent variable (DV) is a continuous measure.
The independent variables (IVs) are a mixture of linear and categorical
variables.

( my text ) 

No one wants to do homework or do your job for free but open
free peer review should not be a problem philosophically. 

( / my text, afraid to use less-than for inciting hotmail ) 


The
author investigates whether performance (DV - continuous linear) is a
function of age (continuous IV1 - measured in years), previous
performance (continuous IV2), country (categorical IV3 - six countries), the 
percentage of PhD graduates in each country (continuous IV4 -
country level data - apparently only six different percentages since we
have only six countries) and population of country (continuous IV5 - country 
level data - again only six numbers here, one for each country population).

My own opinion is that the lm function cannot be used with country
level data as IVs (for example IV4 and IV5 cannot be entered into the
model because they are country level data). If IV4 and IV5 are included
in the model, it is possible that the model will not be able to be
defined because we only have six countries and it is very likely that
the levels of counties (IV3) may be confounding with IV4 and IV5. This
also calls for multicollinearity issues, right? I would like to suggest
to the analyst to use lmer using the IV3 as a random variable and  IV4
and IV5 as IV at the second level of the two-level model.


The questions are: (a) Is it true that IV4 and IV5 cannot be entered in a
one-level regression if we also have IV3?, (b) can I use an lm function to 
check for multicollinearity
between IV3, IV4 and IV5?  and (c) If we use a two-level regression
model, does lmer cope well with only six coutnries as a random effect?

( my txt)

So you have presumably a large number of test subjects per country and a small 
number
( n~6 ) of countries. You could ask a number of questions such as, " do the 
mean performances
change from country to country by more than that expected given the observed 
distributions of
performances within country?" You could also ask a question like, " if I try to 
describe performance
as a function of country attriubte what fitting parameters minimize an error 
between fit and observation?"
Apparently author tried to write an expression like 

average_performance= a[country_index] + m1*some_attribute_of_country + m2* 
some_other_attribute_of_country + b

and then expected the fittring algoright to pick a[i], b,m1, and m2 in such a 
way as to minimize
the resulting error. The reported fits hopefully minimize the error function 
but then you need
to exmaine the second derivative in various directions, so you have to ask how 
the error varies
as you change a[i],b,m1, and m2. ( Ignore b right now and assume it s included 
in a[i]). 
I guess if you can find a direction where the error can not change due to these 
contraints then
it would seem to be impossible for the fit to come up with unique values. If 
you change
each a[i] and m1 by some amounts, for example, can you pick those amounts to 
not change anything? 



( /my text ) 



Thank you for your help

Jason
[[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] Deleting the last value of a vector

2011-04-18 Thread jim holtman
Why not use 'head'

> head(1:10, -1)
[1] 1 2 3 4 5 6 7 8 9
> head(1, -1)
numeric(0)
> head(integer(0), -1)
integer(0)


On Mon, Apr 18, 2011 at 8:13 AM, Kenn Konstabel  wrote:
> On Mon, Apr 18, 2011 at 4:14 AM, helin_susam  wrote:
>> if you have a vector like as follows;
>>
>> r=c(1,2,3,4,5)
>>
>> then use
>>
>> r2=r[1:length(r)-1]
>
> Umm ... this works and gives the intended answer but does so in an ugly way --
>
> 1:length(r)-1 is equivalent to (1:length(r))-1 or 0:(length(r)-1) --
> in other words, you get a sequence from 0 to 4. The result of r[0] is,
> curiously, integer(0) (but if you think about it, it might just as
> well be an error), so you get the intended result but what you
> probably actually meant is
>
> r2=r[1:(length(r)-1)]
>
> # or
>
> r2=r[1:seq_len(length(r)-1)]
>
>
> KK
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?

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


[R] Rsquared for anova

2011-04-18 Thread Dorien Herremans
Thanks Dieter,

Even if I use lm(), I get the following output:

> summary(fit)
             Df  Sum Sq Mean Sq F value    Pr(>F)
nh1            1   324.0  323.99  139.13 < 2.2e-16 ***
nh2            1   723.1  723.12  310.53 < 2.2e-16 ***
nh3            1  1794.2 1794.21  770.49 < 2.2e-16 ***
Residuals   4604 10721.2    2.33
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’


no R squared to be found.

The lm() output gives this:

> summary(fit)
             Df  Sum Sq Mean Sq F value    Pr(>F)
nh1            1   324.0  323.99  139.13 < 2.2e-16 ***
nh2            1   723.1  723.12  310.53 < 2.2e-16 ***
nh3            1  1794.2 1794.21  770.49 < 2.2e-16 ***
Residuals   4604 10721.2    2.33
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’

I just want to see how wel the model fits...


Another strange thing. I did the same calculations in SPSS and got
different results, among others, higher p values. lm() and aov() just
do linear regressions (anova) right? I tried with the same factorial
variables (without interaction effects to test).

Thanks!




On 15 April 2011 18:07, Dieter Menne  wrote:
>
> dorien wrote:
>>
>> I calculate an anova test in the following way:
>>
>> ... aov example
>>
>> I want to check the fit of the model with Rsquared
>>
>
> Try summary(lm(...)) instead.
>
> Dieter
>
>
>
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/Rsquared-for-anova-tp3452399p3452434.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.
>



--
Dorien Herremans

Department of Environment, Technology and Technology Management
Faculty of Applied Economics
University of Antwerp

B.513
Prinsstraat 13
2000 Antwerp
Belgium
+32 3 265 41 25



-- 
Dorien Herremans

Department of Environment, Technology and Technology Management
Faculty of Applied Economics
University of Antwerp

B.513
Prinsstraat 13
2000 Antwerp
Belgium
+32 3 265 41 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] (no subject)

2011-04-18 Thread Ramnath R
Hai,

Where can i get the dataset votes.repub
Ram

[[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] (no subject)

2011-04-18 Thread Ramnath R
Hai
i just wanted to know how we can find the package of  a dataset, eg: how can
i find the package in which the  dataset *iris* is present
Ram

[[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] altering identity column

2011-04-18 Thread Bodnar Laszlo EB_HU
Hi there,

I have a huge dataframe containing 70,000 observations.

I have filtered this dataframe (let it's name be "transformed_dataframe") as I 
wanted to select only those observations which are greater than or equal to 
60,001 regarding the very first identity column.

So I have a transformed dataframe now including 10,000 obeservations (from 
60,001 - to 70,000) and if you send "head(transformed_dataframe)" into R it 
looks like this:

variable1   variable2   variable3   
variable4   ...
60 001  ...... ...  
  ...
60 002  ...... ...  
  ...
60 003  ...... ...  
  ...
60 004  ...... ...  
  ...
60 005  ...... ...  
  ...

Sending "tail(transformed_dataframe)" into R it is going to be something like:

variable1   variable2   variable3   
variable4   ...
69 996  ...... ...  
  ...
69 997  ...... ...  
  ...
69 998  ... ... ... 
   ...
69 999  ...... ...  
  ...
70 000  ...... ...  
  ...


Now is there a quick way to alter this indexing of rows in case of my 
"transformed_dataframe"? I mean, I would like to get indices 1, 2, 3, etc... 
instead of 60 001, 60 002, 60 003 etc...

So by sending "head(transformed_dataframe)" and "tail(transformed_dataframe)" I 
would like to see:

variable1   variable2   variable3   
variable4   ...
1  .........
...
2  .........
...
3  .........
...
4  .........
...
5  .........
...

and

variable1   variable2   variable3   
variable4   ...
9 996.........  
  ...
9 997.........
...
9 998.........  
  ...
9 999.........  
  ...
10 000  .........   
 ...

Thank you very much, best regards,

Laszlo

Ez az e-mail és az összes hozzá tartozó csatolt melléklet titkos és/vagy 
jogilag, szakmailag vagy más módon védett információt tartalmazhat. 
Amennyiben nem Ön a levél címzettje akkor a levél tartalmának közlése, 
reprodukálása, másolása, vagy egyéb más úton történő terjesztése, 
felhasználása szigorúan tilos. Amennyiben tévedésből kapta meg ezt az 
üzenetet kérjük azonnal értesítse az üzenet küldőjét. Az Erste Bank 
Hungary Zrt. (EBH) nem vállal felelősséget az információ teljes és pontos 
- címzett(ek)hez történő - eljuttatásáért, valamint semmilyen 
késésért, kapcsolat megszakadásból eredő hibáért, vagy az információ 
felhasználásából vagy annak megbízhatatlanságából eredő kárért.

Az üzenetek EBH-n kívüli küldője vagy címzettje tudomásul veszi és 
hozzájárul, hogy az üzenetekhez más banki alkalmazott is hozzáférhet az 
EBH folytonos munkamenetének biztosítása érdekében.


This e-mail and any attached files are confidential and/...{{dropped:19}}

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


Re: [R] Rsquared for anova

2011-04-18 Thread Dieter Menne

Dorien Herremans wrote:
> 
> 
> Even if I use lm(), I get the following output:
> 
>> summary(fit)
>  Df  Sum Sq Mean Sq F valuePr(>F)
> nh11   324.0  323.99  139.13 < 2.2e-16 ***
> nh21   723.1  723.12  310.53 < 2.2e-16 ***
> nh31  1794.2 1794.21  770.49 < 2.2e-16 ***
> Residuals   4604 10721.22.33
> ---
> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’
> 

You probably used the wrong fit. I get your results, when I use
summary(aov), instead of summary(lm())

Dieter

d = data.frame(nh1 = sample(letters[1:2],4000,TRUE),
   nh2 = sample(letters[1:2],4000,TRUE),
   nh3 = sample(letters[1:2],4000,TRUE),
   x = rnorm(4000))

summary(lm(x~nh1+nh2+nh3,data=d))
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.015170.03121  -0.4860.627
nh1b 0.019900.03116   0.6390.523
nh2b-0.029320.03116  -0.9410.347
nh3b 0.028140.03116   0.9030.367

Residual standard error: 0.9851 on 3996 degrees of freedom
Multiple R-squared: 0.0005315,  Adjusted R-squared: -0.0002189 
F-statistic: 0.7083 on 3 and 3996 DF,  p-value: 0.5469 



summary(aov(x~nh1+nh2+nh3,data=d))
> summary(aov(x~nh1+nh2+nh3,data=d))
  Df Sum Sq Mean Sq F value Pr(>F)
nh110.4 0.40556  0.4179 0.5180
nh210.9 0.86530  0.8916 0.3451
nh310.8 0.79142  0.8155 0.3666
Residuals   3996 3878.2 0.97052   
>

I suggest you kill your history file and your workspace, and try again from
scratch. I never use these, but always start from scratch with my program
(self-consistent) in the text editor.


Dieter


--
View this message in context: 
http://r.789695.n4.nabble.com/Rsquared-for-anova-tp3452399p3457451.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] searching for datasets; was: (no subject)

2011-04-18 Thread Uwe Ligges

Please use a sensible subject line.
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html

In this case, the first hit found by Google tells us it is in "cluster".

Uwe Ligges


On 18.04.2011 14:58, Ramnath R wrote:

Hai,

Where can i get the dataset votes.repub
Ram

[[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] (no subject)

2011-04-18 Thread Uwe Ligges



On 18.04.2011 14:58, Ramnath R wrote:

Hai
i just wanted to know how we can find the package of  a dataset, eg: how can
i find the package in which the  dataset *iris* is present


Type

?iris

Uwe Ligges



Ram

[[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] (no subject)

2011-04-18 Thread David Winsemius


On Apr 18, 2011, at 8:58 AM, Ramnath R wrote:


Hai
i just wanted to know how we can find the package of  a dataset, eg:  
how can

i find the package in which the  dataset *iris* is present


?data

--

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] (no subject)

2011-04-18 Thread Alexander Engelhardt

Am 18.04.2011 14:58, schrieb Ramnath R:

Hai
i just wanted to know how we can find the package of  a dataset, eg: how can
i find the package in which the  dataset *iris* is present
Ram


Hi,

if you have the package installed, go
> ?iris
to find out which package it belongs to.

If not, just google "R iris" and click the links until you land here:
http://stat.ethz.ch/R-manual/R-patched/library/datasets/html/iris.html

it says iris {datasets} in the top line. Package "datasets".

Try it yourself, maybe with "votes.repub".

 -- Alex

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


Re: [R] (no subject)

2011-04-18 Thread Ramnath R
Hai,

Where can i get the dataset votes.repub
Ram


On Mon, Apr 18, 2011 at 4:11 PM, Ramnath R  wrote:

> Hai
>
>  From which CRAN mirror can get the package ‘LPP2005REC’
>
> Ram
>

[[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] mapply to lapply

2011-04-18 Thread Alaios
Thanks you very much.
You made it work!
Cheers

--- On Mon, 4/18/11, Kenn Konstabel  wrote:

> From: Kenn Konstabel 
> Subject: Re: [R] mapply to lapply
> To: "Alaios" 
> Cc: R-help@r-project.org
> Date: Monday, April 18, 2011, 1:06 PM
> On Mon, Apr 18, 2011 at 2:10 PM,
> Alaios 
> wrote:
> > Dear Andreas,
> > I would like to thank you for your reply.
> > I have tried two alternatives but none of the two
> worked out:
> >
> > F2[i+1,j+1]<-sum(lapply(1:nrow(cells),
> function(rowInd)
> Fwithcellvalue(i=i,j=j,a=cells[rowInd,2],b=cells[rowInd,4],c=cells[rowInd,1],d=cells[rowInd,3],e=cells[rowInd,5])))
> >
> > this one is executed : takes like 2 mins to
> return(which is normal) but returns the following
> >
> > ^@Error in sum(lapply(1:nrow(cells), function(rowInd)
> Fwithcellvalue(i = i,  :
> >  invalid 'type' (list) of argument
> 
> The lapply part worked but for sum you need a vector rather
> than a
> list (which is the result of lapply). So e.g.
> sum(unlist(lapply(.
> something .))) should work.
> 
> KK
> 
> >
> >
> > afterwards I tried to change the function definition
> so to pass i,j inside:
> >
> > This one does not execute at all
> >
> > F2[i+1,j+1]<-sum(lapply(1:nrow(cells),
> function(rowInd,i,j)
> Fwithcellvalue(i=i,j=j,a=cells[rowInd,2],b=cells[rowInd,4],c=cells[rowInd,1],d=cells[rowInd,3],e=cells[rowInd,5])))
> > Error in paste("f", i, j, "(a,b,c,d)", sep = "") :
> >  argument "i" is missing, with no default
> >
> >
> > What do you think I should try out now?
> >
> > Vielen Dank
> > Alex
> >
> > --- On Mon, 4/18/11, Andreas Borg 
> wrote:
> >
> >> From: Andreas Borg 
> >> Subject: Re: [R] mapply to lapply
> >> To: "Alaios" 
> >> Cc: R-help@r-project.org
> >> Date: Monday, April 18, 2011, 11:10 AM
> >> My solution would be to use an index
> >> variable that goes from 1 to the number of rows
> that are to
> >> be processed, along with a helper function which
> calls
> >> Fwithcellvalue with the suitable arguments:
> >>
> >> F2[i+1,j+1]<-sum(lapply(1:nrow(cells),
> function(rowInd)
> >>
> Fwithcellvalue(i=i,j=j,a=cells[rowInd,2],b=cells[rowInd,4],c=cells[rowInd,1],d=cells[rowInd,3],e=cells[rowInd,5]))
> >>
> >>
> >> Best regards,
> >>
> >> Andreas
> >>
> >> Alaios schrieb:
> >> > Dear all,
> >> >
> >> > I would like to ask your help concerning
> converting a
> >> mapply function to lapply. The reason is that I
> would like
> >> to use mclapply which requires lapply syntax.
> >> >
> >> > The command I would like to convert is:
> >> >
> >>
> F2[i+1,j+1]<-sum(mapply(Fwithcellvalue,i=i,j=j,a=cells[,2],b=cells[,4],c=cells[,1],d=cells[,3],e=cells[,5]))
> >> >
> >> > Could you please help me understand how I
> should
> >> change it?
> >> >
> >> >
> >> > Best Regards
> >> > Alex
> >> >
> >> >
> __
> >> > R-help@r-project.org
> >> mailing list
> >> > https://stat.ethz.ch/mailman/listinfo/r-help
> >> > PLEASE do read the posting guide 
> >> > http://www.R-project.org/posting-guide.html
> >> > and provide commented, minimal,
> self-contained,
> >> reproducible code.
> >> >
> >> >
> >>
> >>
> >> -- Andreas Borg
> >> Medizinische Informatik
> >>
> >> UNIVERSITÄTSMEDIZIN
> >> der Johannes Gutenberg-Universität
> >> Institut für Medizinische Biometrie,
> Epidemiologie und
> >> Informatik
> >> Obere Zahlbacher Straße 69, 55131 Mainz
> >> www.imbei.uni-mainz.de
> >>
> >> Telefon +49 (0) 6131 175062
> >> E-Mail: b...@imbei.uni-mainz.de
> >>
> >> Diese E-Mail enthält vertrauliche und/oder
> rechtlich
> >> geschützte Informationen. Wenn Sie nicht der
> >> richtige Adressat sind oder diese E-Mail
> irrtümlich
> >> erhalten haben, informieren Sie bitte sofort den
> >> Absender und löschen Sie diese Mail. Das
> unerlaubte
> >> Kopieren sowie die unbefugte Weitergabe
> >> dieser Mail und der darin enthaltenen
> Informationen ist
> >> nicht gestattet.
> >>
> >>
> >
> > __
> > R-help@r-project.org
> mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained,
> reproducible code.
> >
>

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

2011-04-18 Thread Sutton-Charani
Hello every one,

I am a PhD student in Statistics, for my work I had to modify the rpart code
and use it to build some decision trees.
I thought I managed, but I noticed some strangeness in the trees I got by
using the modified rpart.
I'd like to ask you if I did the right modification:

In fact in rpart it is the gini measure that I would like to modify:

as far as I know the gini measure is of the form gini(t) =1 -
sum(i=1:n)[Fi(t)] with Fi(t)=Ni(t)/N(t)=p(t)

I wanted to replace this measure by m(t) =
1-0.5sum(i=1:n)[Fi(t)log2(Fi(t)+1)]

When I look into the rpart package, in the src, in gini.c, I found 

static double gini_impure1(p) double p; {  return(1 - p*p); }

which I replaced by 

static double gini_impure1(p) double p; {  return(1-0.5*p*log2(p+1)); }

am I right?

Thank you 

Nicolas


--
View this message in context: 
http://r.789695.n4.nabble.com/Modify-rpart-tp3457430p3457430.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] (no subject)

2011-04-18 Thread Ramnath R
Hai
i just wanted to know how we can find the package of  a dataset, eg: how can
i find the package in which the  dataset *iris* is present
Ram


On Mon, Apr 18, 2011 at 6:02 PM, Ramnath R  wrote:

> Hai,
>
> Where can i get the dataset votes.repub
> Ram
>
>
>
> On Mon, Apr 18, 2011 at 4:11 PM, Ramnath R  wrote:
>
>> Hai
>>
>>  From which CRAN mirror can get the package ‘LPP2005REC’
>>
>> Ram
>>
>
>

[[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] (no subject)

2011-04-18 Thread David Winsemius


On Apr 18, 2011, at 8:58 AM, Ramnath R wrote:


Hai,

Where can i get the dataset votes.repub


Time for you to do your own searching.

--
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] Help me create a hyper-structure

2011-04-18 Thread Ben Bolker
On 11-04-18 04:45 AM, Alaios wrote:
> It seems you were right.
> Now I can easily access my struct and substruct like this
> 
> # all.str[[1]]] Gives access to the first struct of per.sr.struct which 
> containts 101 times the xorder,yorder,estimation.sr
> # all.str[[1]][[2]] Gives access to the second substruct of all.str[[1]]
> # all.str[[1]][[2]][[3]] Gives access to the matrix.
> 
> Now I would like to ask you if in R cran I can make struct assignments like 
> this 
> 
> 
> all.str[[i]]<-TempApproxstruct
> 
> 
> where all.str[[i]] is  a list that contains 100 times the
>  $ :List of 3
>   ..$ xorder   : int 0
>   ..$ yoder: int 0
>   ..$ estimation.sr: logi [1:256, 1:256] NA NA NA NA NA NA ...
>  $ :List of 3
>   ..$ xorder   : int 0
>   ..$ yoder: int 0
>   ..$ estimation.sr: logi [1:256, 1:256] NA NA NA NA NA NA ...
>  and so on
> 
> where str(temp.per.sr.struct) is a list that contains 100 times the
>  $ :List of 3
>   ..$ xorder   : int 0
>   ..$ yoder: int 0
>   ..$ estimation.sr: logi [1:256, 1:256] NA NA NA NA NA NA ...
>  $ :List of 3
>   ..$ xorder   : int 0
>   ..$ yoder: int 0
>   ..$ estimation.sr: logi [1:256, 1:256] NA NA NA NA NA NA ...
>   [list output truncated]
> ...and so on.
> 
> Will R understand this kind of assignments or not?

  Why don't you just try it and see what happens ... ?

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


Re: [R] Rsquared for anova

2011-04-18 Thread Ben Bolker
Dorien Herremans  ua.ac.be> writes:

> 
> Thanks Dieter,
> 
> Even if I use lm(), I get the following output:
> 
> > summary(fit)
>              Df  Sum Sq Mean Sq F value    Pr(>F)
> nh1            1   324.0  323.99  139.13 < 2.2e-16 ***
> nh2            1   723.1  723.12  310.53 < 2.2e-16 ***
> nh3            1  1794.2 1794.21  770.49 < 2.2e-16 ***
> Residuals   4604 10721.2    2.33
> ---
> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’
> 
> no R squared to be found.
> 

  Really ??

  When I run the example in ?lm I get:

> summary(lm.D9)

Call:
lm(formula = weight ~ group)

Residuals:
Min  1Q  Median  3Q Max 
-1.0710 -0.4938  0.0685  0.2462  1.3690 

Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept)   5.0320 0.2202  22.850 9.55e-15 ***
groupTrt -0.3710 0.3114  -1.1910.249
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 

Residual standard error: 0.6964 on 18 degrees of freedom
Multiple R-squared: 0.07308,Adjusted R-squared: 0.02158 
F-statistic: 1.419 on 1 and 18 DF,  p-value: 0.249 

Note the last three lines.  I would be shocked if there
weren't a similar set of information in your output ...

  Your output looks like the result of summary(aov(...))


> Another strange thing. I did the same calculations in SPSS and got
> different results, among others, higher p values. lm() and aov() just
> do linear regressions (anova) right? I tried with the same factorial
> variables (without interaction effects to test).

   There are a lot of things that could be different. Are
you treating factors (categorical predictors) as numeric by
accident?  

> 
> Thanks!
> 
> On 15 April 2011 18:07, Dieter Menne  menne-biomed.de> 
> wrote:
> >
> > dorien wrote:
> >>
> >> I calculate an anova test in the following way:
> >>
> >> ... aov example
> >>
> >> I want to check the fit of the model with Rsquared
> >>
> >
> > Try summary(lm(...)) instead.
> >
> > Dieter
> >
> >
> >
> > --
> > View this message in context:
http://r.789695.n4.nabble.com/Rsquared-for-anova-tp3452399p3452434.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.
> >
> 
> --
> Dorien Herremans
> 
> Department of Environment, Technology and Technology Management
> Faculty of Applied Economics
> University of Antwerp
> 
> B.513
> Prinsstraat 13
> 2000 Antwerp
> Belgium
> +32 3 265 41 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] (no subject)

2011-04-18 Thread Uwe Ligges
This is a bug in the very recent version of the plyr package. Its 
maintainer has been notified and promised an update.


Uwe Ligges


On 17.04.2011 22:51, Bryan Hanson wrote:

Is there any news on this issue?  I have the same problem but on a Mac.  I
have upgraded R and updated the built packages.  The console output and
sessionInfo are below.  The problem is triggered by library(ggplot2) my
.Rprofile  If I do library(ggplot2) after the aborted start up ggplot2 is
loaded properly, and I can manually do everything in my .Rprofile and my
configuration is as originally intended.  Thanks, Bryan

Console Output:

Loading required package: reshape
Loading required package: plyr

Attaching package: 'reshape'

The following object(s) are masked from 'package:plyr':

 rename, round_any

Loading required package: grid
Loading required package: proto
Error in rename(x, .base_to_ggplot) : could not find function "setNames"
Error : unable to load R code in package 'ggplot2'
Error: package/namespace load failed for 'ggplot2'
[R.app GUI 1.40 (5751) x86_64-apple-darwin9.8.0]

[History restored from /Users/bryanhanson/.Rhistory]

and here is my session info after the aborted start up:

R version 2.13.0 (2011-04-13)
Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)

locale:
[1] en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages:
[1] proto_0.3-9.1   reshape_0.8.4   plyr_1.5.1  lattice_0.19-23

* Original Post from Stephen Sefick


I have just upgraded to R 2.13 and have library(ggplot2) in my
.Rprofile (among other things).  when i start R I get an error
message.  Has something in the start up scripts changed?  Is there a
better way to specify the library calls in .Rprofile?  Thanks for all
of the help in advance.

Error:

Loading required package: grid
Loading required package: proto
Error in rename(x, .base_to_ggplot) : could not find function "setNames"
Error : unable to load R code in package 'ggplot2'
Error: package/namespace load failed for 'ggplot2'
[Previously saved workspace restored]


Computer 1:

R version 2.13.0 (2011-04-13)
Platform: x86_64-pc-linux-gnu (64-bit)

locale:
  [1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C
  [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8
  [5] LC_MONETARY=C  LC_MESSAGES=en_US.UTF-8
  [7] LC_PAPER=en_US.UTF-8   LC_NAME=C
  [9] LC_ADDRESS=C   LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

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

other attached packages:
[1] proto_0.3-9.1 reshape_0.8.4 plyr_1.5.1

Computer 2

R version 2.13.0 (2011-04-13)
Platform: x86_64-pc-linux-gnu (64-bit)

locale:
  [1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C
  [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8
  [5] LC_MONETARY=C  LC_MESSAGES=en_US.UTF-8
  [7] LC_PAPER=en_US.UTF-8   LC_NAME=C
  [9] LC_ADDRESS=C   LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

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

other attached packages:
[1] proto_0.3-9.1 reshape_0.8.4 plyr_1.5.1



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


Re: [R] (no subject)

2011-04-18 Thread Petr PIKAL
Hi

r-help-boun...@r-project.org napsal dne 18.04.2011 14:32:11:

> Hai,
> 
> Where can i get the dataset votes.repub
> Ram

Use your favourite browser, put R votes.repub in its search facilities and 
you shall be lucky enough to get it from first several hits.

If you have installed R you can start program and issue

??votes.repub

Separate window with

Help files with alias or concept or title matching ‘votes.repub’ using
regular expression matching:


cluster::votes.repubVotes for Republican Candidate in Presidential
Elections

pops up.

Regards
Petr


> 
> 
> On Mon, Apr 18, 2011 at 4:11 PM, Ramnath R  wrote:
> 
> > Hai
> >
> >  From which CRAN mirror can get the package ‘LPP2005REC’
> >
> > Ram
> >
> 
>[[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] altering identity column

2011-04-18 Thread Ben Bolker
 Bodnar Laszlo EB_HU  erstebank.hu> writes:

>  [snip snip ] 

> So I have a transformed dataframe now including 10,000 obeservations
> (from 60,001 - to 70,000) and if you send
> "head(transformed_dataframe)" into R it looks like this:

  [snip] > 

> Now is there a quick way to alter this indexing of rows in case of
> my "transformed_dataframe"? I mean, I would


rownames(newdata) <- 1:nrow(newdata)

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


Re: [R] Rsquared for anova

2011-04-18 Thread Dorien Herremans
Omg Dieter, thanks so much... I just had to q() and R... that solved
it :-) excellent! finally got the R2 :-)

On 18 April 2011 15:12, Ben Bolker  wrote:
> Dorien Herremans  ua.ac.be> writes:
>
>>
>> Thanks Dieter,
>>
>> Even if I use lm(), I get the following output:
>>
>> > summary(fit)
>>              Df  Sum Sq Mean Sq F value    Pr(>F)
>> nh1            1   324.0  323.99  139.13 < 2.2e-16 ***
>> nh2            1   723.1  723.12  310.53 < 2.2e-16 ***
>> nh3            1  1794.2 1794.21  770.49 < 2.2e-16 ***
>> Residuals   4604 10721.2    2.33
>> ---
>> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’
>>
>> no R squared to be found.
>>
>
>  Really ??
>
>  When I run the example in ?lm I get:
>
>> summary(lm.D9)
>
> Call:
> lm(formula = weight ~ group)
>
> Residuals:
>    Min      1Q  Median      3Q     Max
> -1.0710 -0.4938  0.0685  0.2462  1.3690
>
> Coefficients:
>            Estimate Std. Error t value Pr(>|t|)
> (Intercept)   5.0320     0.2202  22.850 9.55e-15 ***
> groupTrt     -0.3710     0.3114  -1.191    0.249
> ---
> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
>
> Residual standard error: 0.6964 on 18 degrees of freedom
> Multiple R-squared: 0.07308,    Adjusted R-squared: 0.02158
> F-statistic: 1.419 on 1 and 18 DF,  p-value: 0.249
>
>    Note the last three lines.  I would be shocked if there
> weren't a similar set of information in your output ...
>
>  Your output looks like the result of summary(aov(...))
>
>
>> Another strange thing. I did the same calculations in SPSS and got
>> different results, among others, higher p values. lm() and aov() just
>> do linear regressions (anova) right? I tried with the same factorial
>> variables (without interaction effects to test).
>
>   There are a lot of things that could be different. Are
> you treating factors (categorical predictors) as numeric by
> accident?
>
>>
>> Thanks!
>>
>> On 15 April 2011 18:07, Dieter Menne  menne-biomed.de> 
>> wrote:
>> >
>> > dorien wrote:
>> >>
>> >> I calculate an anova test in the following way:
>> >>
>> >> ... aov example
>> >>
>> >> I want to check the fit of the model with Rsquared
>> >>
>> >
>> > Try summary(lm(...)) instead.
>> >
>> > Dieter
>> >
>> >
>> >
>> > --
>> > View this message in context:
> http://r.789695.n4.nabble.com/Rsquared-for-anova-tp3452399p3452434.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.
>> >
>>
>> --
>> Dorien Herremans
>>
>> Department of Environment, Technology and Technology Management
>> Faculty of Applied Economics
>> University of Antwerp
>>
>> B.513
>> Prinsstraat 13
>> 2000 Antwerp
>> Belgium
>> +32 3 265 41 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.
>



-- 
Dorien Herremans

Department of Environment, Technology and Technology Management
Faculty of Applied Economics
University of Antwerp

B.513
Prinsstraat 13
2000 Antwerp
Belgium
+32 3 265 41 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] reporting lme results

2011-04-18 Thread Ben Bolker
Pennell, Tanya  exeter.ac.uk> writes:

> I have used lme4 and I have found a significant result 
> when using anova to compare model 1 and model 2 (where I
> took out an interaction).
> 
> The result looks like this:
> model.3: DIFFERENCE ~ (1 | MALE.ID)
> model.2: DIFFERENCE ~ MALE.SPECIES + (1 | MALE.ID)
> DfAICBIC  logLik  Chisq Chi Df Pr(>Chisq)
> model.3  3 1379.7 1387.1 -686.86
> model.2  4 1374.1 1384.0 -683.05 7.6235  1   0.005761 **
> ---
> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
> 
> Just wondering how I would report this in a scientific paper?
> 

  I would say (for example) that a likelihood ratio test of
the effect of species on the difference was significant
(log-likelihood difference=3.81, p=0.0058).

  Or something like that.

  Questions like this might be more appropriate on the
r-sig-mixed-models list.

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

2011-04-18 Thread Duncan Murdoch

On 18/04/2011 4:45 AM, Alaios wrote:

It seems you were right.
Now I can easily access my struct and substruct like this

# all.str[[1]]] Gives access to the first struct of per.sr.struct which 
containts 101 times the xorder,yorder,estimation.sr
# all.str[[1]][[2]] Gives access to the second substruct of all.str[[1]]
# all.str[[1]][[2]][[3]] Gives access to the matrix.


Something that may not be obvious is that

all.str[[1]][[2]][[3]]


can also be written as

all.str[[c(1,2,3)]]


This is useful when the structure is an irregular shape, because the vector 
c(1,2,3) could be stored in a variable, and on the next call it could have a 
different length.

Be careful though:  all.str[c(1,2,3)] (with single brackets) means something 
quite different:  it means

list(all.str[[1]], all.str[[2]], all.str[[3]])

i.e. a subset of the top level indices.

Duncan Murdoch



Now I would like to ask you if in R cran I can make struct assignments like this


 all.str[[i]]<-TempApproxstruct


where all.str[[i]] is  a list that contains 100 times the
  $ :List of 3
   ..$ xorder   : int 0
   ..$ yoder: int 0
   ..$ estimation.sr: logi [1:256, 1:256] NA NA NA NA NA NA ...
  $ :List of 3
   ..$ xorder   : int 0
   ..$ yoder: int 0
   ..$ estimation.sr: logi [1:256, 1:256] NA NA NA NA NA NA ...
 and so on

where str(temp.per.sr.struct) is a list that contains 100 times the
  $ :List of 3
   ..$ xorder   : int 0
   ..$ yoder: int 0
   ..$ estimation.sr: logi [1:256, 1:256] NA NA NA NA NA NA ...
  $ :List of 3
   ..$ xorder   : int 0
   ..$ yoder: int 0
   ..$ estimation.sr: logi [1:256, 1:256] NA NA NA NA NA NA ...
   [list output truncated]
...and so on.

Will R understand this kind of assignments or not?

I would like to thank you in advance for your help
Best Regards
Alex









--- On Sat, 4/16/11, Ben Bolker  wrote:

>  From: Ben Bolker
>  Subject: Re: [R] Help me create a hyper-structure
>  To: r-h...@stat.math.ethz.ch
>  Date: Saturday, April 16, 2011, 3:39 PM
>  Alaios
>  yahoo.com>  writes:
>
>  >
>  >  Dear all
>  >  I would like to have in R a big struct containing a
>  smaller struct.
>  >
>  >  1) I would like to have a small struct with the
>  following three fields
>  >  xorder (an integer ranging from 0 to 20)
>  >  yorder (an integer ranging from 0 to 20)
>  >  estimated (a 256*256 matrix)
>  >
>  >  2) I would like to have 10 elements of the struct
>  above
>  >  for that I wrote the following:
>  >
>  Estimationstruct<- function ( xorder, yorder,
>  estimated) {
> list (xorder= xorder,
>  yorder=yorder,estimated=estimated)
>  }
>
>  per.sr.struct<- replicate(10,
>  
>  Estimationstruct(0L,0L,matrix(nrow=256,ncol=256)),

>  simplify=FALSE)
>
>  >  That one worked.
>  >  per.sr.struct contains 10 elements and each one of
>  that contains 1).
>
>  all.sr.struct
>  <-   replicate(20,per.sr.struct,simplify=FALSE)
>
>  >  The idea is to have 20 all.sr.stuct and each element
>  >  to contain one per.sr.struct.
>
> I think you just missed simplify=FALSE in the last
>  step ...
>
>  __
>  R-help@r-project.org
>  mailing list
>  https://stat.ethz.ch/mailman/listinfo/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] Help me create a hyper-structure

2011-04-18 Thread Alaios
Thank you very much . That was really helpful.
I will keep this email for future reference

Regards

--- On Mon, 4/18/11, Duncan Murdoch  wrote:

> From: Duncan Murdoch 
> Subject: Re: [R] Help me create a hyper-structure
> To: "Alaios" 
> Cc: r-h...@stat.math.ethz.ch, "Ben Bolker" 
> Date: Monday, April 18, 2011, 2:31 PM
> On 18/04/2011 4:45 AM, Alaios wrote:
> > It seems you were right.
> > Now I can easily access my struct and substruct like
> this
> >
> > # all.str[[1]]] Gives access to the first struct of
> per.sr.struct which containts 101 times the
> xorder,yorder,estimation.sr
> > # all.str[[1]][[2]] Gives access to the second
> substruct of all.str[[1]]
> > # all.str[[1]][[2]][[3]] Gives access to the matrix.
> 
> Something that may not be obvious is that
> 
> all.str[[1]][[2]][[3]]
> 
> 
> can also be written as
> 
> all.str[[c(1,2,3)]]
> 
> 
> This is useful when the structure is an irregular shape,
> because the vector c(1,2,3) could be stored in a variable,
> and on the next call it could have a different length.
> 
> Be careful though:  all.str[c(1,2,3)] (with single
> brackets) means something quite different:  it means
> 
> list(all.str[[1]], all.str[[2]], all.str[[3]])
> 
> i.e. a subset of the top level indices.
> 
> Duncan Murdoch
> 
> 
> > Now I would like to ask you if in R cran I can make
> struct assignments like this
> >
> >
> >      all.str[[i]]<-TempApproxstruct
> >
> >
> > where all.str[[i]] is  a list that contains 100
> times the
> >   $ :List of 3
> >    ..$ xorder   
>    : int 0
> >    ..$ yoder        :
> int 0
> >    ..$ estimation.sr: logi [1:256, 1:256] NA
> NA NA NA NA NA ...
> >   $ :List of 3
> >    ..$ xorder   
>    : int 0
> >    ..$ yoder        :
> int 0
> >    ..$ estimation.sr: logi [1:256, 1:256] NA
> NA NA NA NA NA ...
> >  and so on
> >
> > where str(temp.per.sr.struct) is a list that contains
> 100 times the
> >   $ :List of 3
> >    ..$ xorder   
>    : int 0
> >    ..$ yoder        :
> int 0
> >    ..$ estimation.sr: logi [1:256, 1:256] NA
> NA NA NA NA NA ...
> >   $ :List of 3
> >    ..$ xorder   
>    : int 0
> >    ..$ yoder        :
> int 0
> >    ..$ estimation.sr: logi [1:256, 1:256] NA
> NA NA NA NA NA ...
> >    [list output truncated]
> > ...and so on.
> >
> > Will R understand this kind of assignments or not?
> >
> > I would like to thank you in advance for your help
> > Best Regards
> > Alex
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > --- On Sat, 4/16/11, Ben Bolker 
> wrote:
> >
> > >  From: Ben Bolker
> > >  Subject: Re: [R] Help me create a
> hyper-structure
> > >  To: r-h...@stat.math.ethz.ch
> > >  Date: Saturday, April 16, 2011, 3:39 PM
> > >  Alaios
> > >  yahoo.com>  writes:
> > >
> > >  >
> > >  >  Dear all
> > >  >  I would like to have in R a big
> struct containing a
> > >  smaller struct.
> > >  >
> > >  >  1) I would like to have a small
> struct with the
> > >  following three fields
> > >  >  xorder (an integer ranging from
> 0 to 20)
> > >  >  yorder (an integer ranging from
> 0 to 20)
> > >  >  estimated (a 256*256 matrix)
> > >  >
> > >  >  2) I would like to have 10
> elements of the struct
> > >  above
> > >  >  for that I wrote the following:
> > >  >
> > >  Estimationstruct<- function ( xorder,
> yorder,
> > >  estimated) {
> > >     list (xorder= xorder,
> > >  yorder=yorder,estimated=estimated)
> > >  }
> > >
> > >  per.sr.struct<- replicate(10,
> > >  
> > >     
> Estimationstruct(0L,0L,matrix(nrow=256,ncol=256)),
> > >      simplify=FALSE)
> > >
> > >  >  That one worked.
> > >  >  per.sr.struct contains 10
> elements and each one of
> > >  that contains 1).
> > >
> > >  all.sr.struct
> > > 
> <-   replicate(20,per.sr.struct,simplify=FALSE)
> > >
> > >  >  The idea is to have 20
> all.sr.stuct and each element
> > >  >  to contain one per.sr.struct.
> > >
> > >     I think you just missed
> simplify=FALSE in the last
> > >  step ...
> > >
> > > 
> __
> > >  R-help@r-project.org
> > >  mailing list
> > >  https://stat.ethz.ch/mailman/listinfo/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] mapply to lapply

2011-04-18 Thread Andreas Borg

Hi Alex,

sorry, I wasn't aware that sum does not work with listst. replace 
"lapply" with "sapply" or place the call in "unlist".


Your second example does not work as you have to provide the additional 
arguments to the inner function in lapply:


lapply(1:nrow(cells), function(rowInd, i, j), [your function goes here], 
i=i, j=j)


Viele Grüße,

Andreas

Alaios schrieb:

Dear Andreas,
I would like to thank you for your reply.
I have tried two alternatives but none of the two worked out:

F2[i+1,j+1]<-sum(lapply(1:nrow(cells), function(rowInd) 
Fwithcellvalue(i=i,j=j,a=cells[rowInd,2],b=cells[rowInd,4],c=cells[rowInd,1],d=cells[rowInd,3],e=cells[rowInd,5])))

this one is executed : takes like 2 mins to return(which is normal) but returns 
the following

^@Error in sum(lapply(1:nrow(cells), function(rowInd) Fwithcellvalue(i = i,  : 
  invalid 'type' (list) of argument



afterwards I tried to change the function definition so to pass i,j inside:

This one does not execute at all 


F2[i+1,j+1]<-sum(lapply(1:nrow(cells), function(rowInd,i,j) 
Fwithcellvalue(i=i,j=j,a=cells[rowInd,2],b=cells[rowInd,4],c=cells[rowInd,1],d=cells[rowInd,3],e=cells[rowInd,5])))
Error in paste("f", i, j, "(a,b,c,d)", sep = "") : 
  argument "i" is missing, with no default



What do you think I should try out now?

Vielen Dank
Alex

--- On Mon, 4/18/11, Andreas Borg  wrote:

  

From: Andreas Borg 
Subject: Re: [R] mapply to lapply
To: "Alaios" 
Cc: R-help@r-project.org
Date: Monday, April 18, 2011, 11:10 AM
My solution would be to use an index
variable that goes from 1 to the number of rows that are to
be processed, along with a helper function which calls
Fwithcellvalue with the suitable arguments:

F2[i+1,j+1]<-sum(lapply(1:nrow(cells), function(rowInd)
Fwithcellvalue(i=i,j=j,a=cells[rowInd,2],b=cells[rowInd,4],c=cells[rowInd,1],d=cells[rowInd,3],e=cells[rowInd,5]))


Best regards,

Andreas

Alaios schrieb:


Dear all,

I would like to ask your help concerning converting a
  

mapply function to lapply. The reason is that I would like
to use mclapply which requires lapply syntax.


The command I would like to convert is:

  

F2[i+1,j+1]<-sum(mapply(Fwithcellvalue,i=i,j=j,a=cells[,2],b=cells[,4],c=cells[,1],d=cells[,3],e=cells[,5]))


Could you please help me understand how I should
  

change it?


Best Regards
Alex

__
R-help@r-project.org
  

mailing list


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

reproducible code.

   
  

-- Andreas Borg
Medizinische Informatik

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

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

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





  



--
Andreas Borg
Medizinische Informatik

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

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

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

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


Re: [R] altering identity column

2011-04-18 Thread David Winsemius


On Apr 18, 2011, at 9:02 AM, Bodnar Laszlo EB_HU wrote:


Hi there,

I have a huge dataframe containing 70,000 observations.

I have filtered this dataframe (let it's name be  
"transformed_dataframe") as I wanted to select only those  
observations which are greater than or equal to 60,001 regarding the  
very first identity column.


I am guessing that what you want is something like

dfrm2 <- transformed_dataframe[rownames(transformed_dataframe) >=  
"60001" , ]


Or perhaps (if you carrying the thousands separator into the rownames:

dfrm2 <- transformed_dataframe[rownames(transformed_dataframe) >=  
"60,001" , ]


Or if you are using spaces then:

dfrm2 <- transformed_dataframe[rownames(transformed_dataframe) >= "60  
001" , ]


This would involve much less guessing if you offered the results of:

 str(transformed_dataframe)



So I have a transformed dataframe now including 10,000 obeservations  
(from 60,001 - to 70,000) and if you send  
"head(transformed_dataframe)" into R it looks like this:


   variable1   variable2
variable3   variable4   ...
60  
001 
  ...... ......
60  
002 
  ...... ......
60  
003 
  ...... ......
60  
004 
  ...... ......
60  
005 
  ...... ......


Sending "tail(transformed_dataframe)" into R it is going to be  
something like:


   variable1   variable2
variable3   variable4   ...
69  
996 
  ...... ......
69  
997 
  ...... ......
69  
998 
  ... ... ......
69  
999 
  ...... ......
70  
000 
  ...... ......



Now is there a quick way to alter this indexing of rows in case of  
my "transformed_dataframe"? I mean, I would like to get indices 1,  
2, 3, etc... instead of 60 001, 60 002, 60 003 etc...


rownames(transformed_dataframe) <- 1:1




So by sending "head(transformed_dataframe)" and  
"tail(transformed_dataframe)" I would like to see:


   variable1   variable2
variable3   variable4   ...
1 
  ............
2 
  ............
3 
  ............
4 
  ............
5 
  ............


and

   variable1   variable2
variable3   variable4   ...
9  
996 
............
9  
997 
............
9  
998 
............
9  
999 
............
10  
000 
  ............


Thank you very much, best regards,

Laszlo
__



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] how to extract options for a function call

2011-04-18 Thread fisken
Hi, I'm having some difficulties formulating this question.

But what I want,
is to extract the options associated with a parameter for a function.

e.g.
method = c("Nelder-Mead", "BFGS", "CG", "L-BFGS-B", "SANN")
in the optim function.

So I would like to have a vector with
c("Nelder-Mead", "BFGS", "CG", "L-BFGS-B", "SANN")


Or for instance the 'method' in the dist function can be supplied with
euclidian,maximum,manhatten, canberra,binary,minkowski.

Is there someway to extract this so I would have a vector with
c("euclidian","maximum","manhatten", "canberra","binary","minkowski").


Thanks

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


[R] Help with cleaning a corpus

2011-04-18 Thread vintersorg123
Hi!

I created a corpus and I started to clean through this piece of code:

txt <-tm_map(txt,removeWords, stopwords("spanish"))
txt <-tm_map(txt,stripWhitespace)
txt <-tm_map(txt,tolower)
txt <-tm_map(txt,removeNumbers)
txt <-tm_map(txt,removePunctuation)

But something happpended: some of the documents  in the corpus became empty,
this is a problem when i try to make a document term matrix with tfidf. 
Is there any way to eliminate  automatically a document if it become empty? 

Or manually, how could i get the lenght of every document?

hope you can help me! thanks a lot

greetings!


--
View this message in context: 
http://r.789695.n4.nabble.com/Help-with-cleaning-a-corpus-tp3457649p3457649.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] how to extract options for a function call

2011-04-18 Thread S Ellison


>>> fisken  18/04/2011 14:56:56 >>>
>But what I want,
>is to extract the options associated with a parameter for a function.

Try 
?formals

S Ellison

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

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


Re: [R] how to extract options for a function call

2011-04-18 Thread Henrique Dallazuanna
Try this:

For optim:
eval(formals(optim)$method)

For dist function:
 eval(body(dist)[[3]][[3]])

On Mon, Apr 18, 2011 at 10:56 AM, fisken  wrote:
> Hi, I'm having some difficulties formulating this question.
>
> But what I want,
> is to extract the options associated with a parameter for a function.
>
> e.g.
> method = c("Nelder-Mead", "BFGS", "CG", "L-BFGS-B", "SANN")
> in the optim function.
>
> So I would like to have a vector with
> c("Nelder-Mead", "BFGS", "CG", "L-BFGS-B", "SANN")
>
>
> Or for instance the 'method' in the dist function can be supplied with
> euclidian,maximum,manhatten, canberra,binary,minkowski.
>
> Is there someway to extract this so I would have a vector with
> c("euclidian","maximum","manhatten", "canberra","binary","minkowski").
>
>
> Thanks
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



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

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


Re: [R] Geographic distance between lat-long points in R?

2011-04-18 Thread Scott Chamberlain
Hi Curt, 

Thanks for the help. 

According to that blogpost you sent, I am using the function gcd.hf using the 
Haversine formula. I wrapped it up in a function called CalcDists so that I can 
get a distance matrix between N sites. 

I don't know much about calculating distances, so does this seem like a good 
way to go (using Haversine that is)?


# Convert degrees to radians
deg2rad <- function(deg) return(deg*pi/180)

# Calculates the geodesic distance between two points specified by 
# radian latitude/longitude using the Haversine formula
gcd.hf <- function(long1, lat1, long2, lat2) {
R <- 6371 # Earth mean radius [km]
delta.long <- (long2 - long1)
delta.lat <- (lat2 - lat1)
a <- sin(delta.lat/2)^2 + cos(lat1) * cos(lat2) * sin(delta.long/2)^2
c <- 2 * asin(min(1,sqrt(a)))
d = R * c
return(d) # Distance in km
}

# Fxn to calculate matrix of distances between each two sites
CalcDists <- function(latlongs) {
name <- list(rownames(latlongs), rownames(latlongs))
n <- nrow(latlongs)
z <- matrix(0, n, n, dimnames = name)
for (i in 1:n) {
for (j in 1:n) z[i, j] <- gcd.hf(long1 = latlongs[i, 1], 
lat1 = latlongs[i, 2], long2 = latlongs[j, 1], lat2 = latlongs[j,2])
}
z <- as.dist(z)
return(z)
}



Scott
On Monday, April 11, 2011 at 5:00 PM, seeliger.c...@epamail.epa.gov wrote: 
> > A comparison of some geographic distance calculations is provided at 
> > http://pineda-krch.com/2010/11/23/great-circle-distance-calculations-in-r/ 
> > , along with code for calculating the Vincenty inverse formula, which 
> > relies on the WGS-84 ellipsoid approximations.
> 
> You know, Scott, I should have included some test results of that method. 
> Comparing the distances with Arc 9 indicates that the accuracy varies with 
> location and whether there is a longitudinal difference in the two points. 
> Comparing calculation results for points shifted 0 secs to 10 degrees North, 
> West and Northwest from a 'base' point, the relative errors (defined as 
> (Arc9.distance - Vincenty.distance)/Arc9.distance) range up to 0.08 in AK, 
> AZ, CA, MT, NE, NM, UT, WA and WY, and range only up to 0.009 otherwise. In 
> the special case of zero longitudinal offset (North-South distances only), 
> the relative error ranges to 0.006 in those states and to 2E-7 otherwise. 
> 
> Let us know if you can do better, 
> cur
> 
>  -- 
>  Curt Seeliger, Data Ranger
>  Raytheon Information Services - Contractor to ORD
> seeliger.c...@epa.gov
>  541/754-4638
> 

[[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 extract options for a function call

2011-04-18 Thread fisken
thanks

2011/4/18 S Ellison :
>
>
 fisken  18/04/2011 14:56:56 >>>
>>But what I want,
>>is to extract the options associated with a parameter for a function.
>
> Try
> ?formals
>
> S Ellison
>
> ***
> This email and any attachments are confidential. Any u...{{dropped:9}}

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


Re: [R] side by side histogram after splitting data by year

2011-04-18 Thread Peter Ehlers

On 2011-04-17 16:29, jim holtman wrote:

Will one of these do it for you:


str(x)

'data.frame':   550 obs. of  5 variables:
  $ year: Factor w/ 2 levels "one","two": 1 1 1 1 1 1 1 1 1 1 ...
  $ size: Factor w/ 2 levels "large","small": 2 2 2 2 2 2 2 2 2 2 ...
  $ distance: num  30.9 121.5 46.1 46.1 46.1 ...
  $ taken   : int  10 2 12 1 4 1 10 3 5 5 ...
  $ mass: num  13.88 2.78 16.65 1.39 5.55 ...

require(lattice)
histogram(~taken|year, x)
histogram(~taken|year*size, x)



Jeff,

I would use lattice (or ggplot2) as well. But you
may want to look at the histbackback() function in
pkg Hmisc.

Peter Ehlers

[...snip...]




On Sun, Apr 17, 2011 at 10:51 AM, Stratford, Jeffrey
  wrote:

Hi everyone,



I'm looking to produce a side-by-side histogram of the number of trips
taken by jays with a particular number of acorns after accounting for
year (year "one" and year "two"). I know this involves indexing first
then creating a histogram but I'm not sure how I'd do this. I want to
explore the possibilities that jays are altering their strategies in
different years.  Data are below.



This is a common need for myself so any help would be greatly
appreciated!



Thanks,



Jeff



[...snip...]


--
Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?

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


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


Re: [R] (no subject)

2011-04-18 Thread Hadley Wickham
Yes, it's fixed and a new version of plyr has been pushed up to cran -
hopefully will be available for download soon.  In the meantime, I
think you can fix it by running library(stats) before
library(ggplot2).

Hadley

On Sun, Apr 17, 2011 at 3:51 PM, Bryan Hanson  wrote:
> Is there any news on this issue?  I have the same problem but on a Mac.  I
> have upgraded R and updated the built packages.  The console output and
> sessionInfo are below.  The problem is triggered by library(ggplot2) my
> .Rprofile  If I do library(ggplot2) after the aborted start up ggplot2 is
> loaded properly, and I can manually do everything in my .Rprofile and my
> configuration is as originally intended.  Thanks, Bryan
>
> Console Output:
>
> Loading required package: reshape
> Loading required package: plyr
>
> Attaching package: 'reshape'
>
> The following object(s) are masked from 'package:plyr':
>
>    rename, round_any
>
> Loading required package: grid
> Loading required package: proto
> Error in rename(x, .base_to_ggplot) : could not find function "setNames"
> Error : unable to load R code in package 'ggplot2'
> Error: package/namespace load failed for 'ggplot2'
> [R.app GUI 1.40 (5751) x86_64-apple-darwin9.8.0]
>
> [History restored from /Users/bryanhanson/.Rhistory]
>
> and here is my session info after the aborted start up:
>
> R version 2.13.0 (2011-04-13)
> Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)
>
> locale:
> [1] en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8
>
> attached base packages:
> [1] stats     graphics  grDevices utils     datasets  grid      methods
> base
>
> other attached packages:
> [1] proto_0.3-9.1   reshape_0.8.4   plyr_1.5.1      lattice_0.19-23
>
> * Original Post from Stephen Sefick
>
>
> I have just upgraded to R 2.13 and have library(ggplot2) in my
> .Rprofile (among other things).  when i start R I get an error
> message.  Has something in the start up scripts changed?  Is there a
> better way to specify the library calls in .Rprofile?  Thanks for all
> of the help in advance.
>
> Error:
>
> Loading required package: grid
> Loading required package: proto
> Error in rename(x, .base_to_ggplot) : could not find function "setNames"
> Error : unable to load R code in package 'ggplot2'
> Error: package/namespace load failed for 'ggplot2'
> [Previously saved workspace restored]
>
>
> Computer 1:
>
> R version 2.13.0 (2011-04-13)
> Platform: x86_64-pc-linux-gnu (64-bit)
>
> locale:
>  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
>  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8
>  [5] LC_MONETARY=C              LC_MESSAGES=en_US.UTF-8
>  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C
>  [9] LC_ADDRESS=C               LC_TELEPHONE=C
> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
>
> attached base packages:
> [1] stats     graphics  grDevices utils     datasets  grid      methods
> [8] base
>
> other attached packages:
> [1] proto_0.3-9.1 reshape_0.8.4 plyr_1.5.1
>
> Computer 2
>
> R version 2.13.0 (2011-04-13)
> Platform: x86_64-pc-linux-gnu (64-bit)
>
> locale:
>  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
>  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8
>  [5] LC_MONETARY=C              LC_MESSAGES=en_US.UTF-8
>  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C
>  [9] LC_ADDRESS=C               LC_TELEPHONE=C
> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
>
> attached base packages:
> [1] stats     graphics  grDevices utils     datasets  grid      methods
> [8] base
>
> other attached packages:
> [1] proto_0.3-9.1 reshape_0.8.4 plyr_1.5.1
>
> --
> Stephen Sefick
> 
> | Auburn University                                         |
> | Biological Sciences                                      |
> | 331 Funchess Hall                                       |
> | Auburn, Alabama                                         |
> | 36849                                                           |
> |___|
> | sas0...@auburn.edu                                  |
> | http://www.auburn.edu/~sas0025                 |
> |___|
>
>
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/no-subject-tp3454416p3456100.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.
>



-- 
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/

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


[R] From nested loop to mclapply

2011-04-18 Thread Alaios
Dear all,
I am trying to find a decent way to speed up my code.

So far I have used mclapply with really good results (parallel version of 
lapply). I have a nested loop that I would like to help me convert it to lapply

for (i in seq(from=-1,to=1-2/ncol(sr),length=ncol(sr))){
  for (j in seq(from=-1,to=1-2/nrow(sr),length=nrow(sr))){ 
estimatedsr[findCoord(c(i,j),sr)[1],findCoord(c(i,j),sr)[2]  
]<-fxy(c(i,j))
  }

So far I have converted some one-depth for loops to lapply but I am not sure If 
I can use lapply to convert a nested loop to something simpler.

Best Regards
Alex

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Reorder a data frame according a column randomly reordered.

2011-04-18 Thread Mohammad Tanvir Ahamed
Hello all , 
I have a data frame like this 

X1X2X3
11815
22916
331017
441118
551219
661320
771421

now i want to randomly reorder the variable X2  but the row element should be 
same 
as for example 

X1X2X3
12916
251219
331017
471421
561320
61815
741118

how can i do that ??

Hint : 
this could be helpful : 

if X2 is only a vector like this 
X2<-c(8,9,10,11,12,13,14)

so i can easily reorder it by using sample commend 
sample (X2 , size=length(X2), replace=FALSE)
 
may be i have to use lapply commend with sample commend .


/...Tanvir Ahamed

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

2011-04-18 Thread Jim Silverton
I am using storey's qvalue package but I keep on getting errors. Why is
this?

> qvalue(p, lambda=0.5)$pi0
[1] "ERROR: p-values not in valid range."
Error in qvalue(p, lambda = 0.5)$pi0 :
  $ operator is invalid for atomic vectors


-- 
Thanks,
Jim.

[[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] Avoiding loop

2011-04-18 Thread Filoche
Hi everyone.

I'm using matrix product such as : 


#Generate some data
NCols = 5
NRows = 5
A = matrix(runif(NCols*NRows), ncol=NCols) 
B = matrix(runif(NCols*NRows), ncol=NCols) 

#First calculation
R = A%*%B


for(i in 1:100)
{
R = R%*%B
}


I would like to know if it was possible to avoid the loop by using something
like mapply or anything else.

Tx in advance,
Phil

--
View this message in context: 
http://r.789695.n4.nabble.com/Avoiding-loop-tp3457963p3457963.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] Multiple Groups CFA in Lavaan

2011-04-18 Thread JTMajor
Hello,

I am trying to do a multiple groups CFA in lavaan and I get the following
error message:

Error in cov(data.obs, use = "pairwise") : 'x' is empty

I'm not sure what this message is referring to, can anyone help me?

Thanks

--
View this message in context: 
http://r.789695.n4.nabble.com/Multiple-Groups-CFA-in-Lavaan-tp3457971p3457971.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] Using jitter function with differing variable lengths

2011-04-18 Thread Uwe Ligges



On 18.04.2011 04:11, Danica Horrell wrote:

Hi,

I am trying to make a scatter plot with 4 different categories using the
jitter function.  My code returns a variable length error and will not plot
because my four categories have different numbers of samples.  When I delete
samples from my spreadsheet so that each of the categories has the same
number of variables, it plots just fine.

Is there any way to get around this and plot all of my samples using jitter?



That should work right way with the right code. Yours probably isn't right.

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


In that case, we could probably show what you need to improve.

Uwe Ligges




Thanks for the 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.


Re: [R] Multiple Groups CFA in Lavaan

2011-04-18 Thread Uwe Ligges



On 18.04.2011 18:10, JTMajor wrote:

Hello,

I am trying to do a multiple groups CFA in lavaan and I get the following
error message:

Error in cov(data.obs, use = "pairwise") : 'x' is empty

I'm not sure what this message is referring to, can anyone help me?



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


Where is your code and where is your data?

Uwe Ligges



Thanks

--
View this message in context: 
http://r.789695.n4.nabble.com/Multiple-Groups-CFA-in-Lavaan-tp3457971p3457971.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] Reorder a data frame according a column randomly reordered.

2011-04-18 Thread Uwe Ligges



On 18.04.2011 17:04, Mohammad Tanvir Ahamed wrote:

Hello all ,
I have a data frame like this

X1X2X3
11815
22916
331017
441118
551219
661320
771421

now i want to randomly reorder the variable X2  but the row element should be 
same
as for example

X1X2X3
12916
251219
331017
471421
561320
61815
741118

how can i do that ??

Hint :
this could be helpful :

if X2 is only a vector like this
X2<-c(8,9,10,11,12,13,14)

so i can easily reorder it by using sample commend
sample (X2 , size=length(X2), replace=FALSE)




Yes, and then replace X2 with your reordered X2.

Uwe Ligges






may be i have to use lapply commend with sample commend .


/...Tanvir Ahamed

[[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] converting data.frame into a numeric ( integer) form

2011-04-18 Thread Uwe Ligges



On 17.04.2011 19:29, Haillie wrote:

Hi Everyone,

I am relatively new to R and would appreciate your help on this problem that
I encontered this morning.
When running an ordinal IRT model using Ratings package on R, I keep getting
this error message.

ord.out<-ordrating(UNORD, burnin = 1000, mcmc = 40,000, thin = 400, tune =
1, verbose = 1000, seed = NA)

Error in as.vector(as.integer(Y)) :
   (list) object cannot be coerced to type 'integer'

UNORD is my data.frame


... but ?ordrating tells you it must be a matrix rather than a data.frame.

Uwe Ligges



and it is in the form of delimited CSV file without
either row or column name.
According to the help page on Ordinal ratings, Y should be "a Matrix of data
to be analyzed. Entries must be integers from 1; : : : ;C or NA where C is
the number of ordinal categories. Items are on the rows and subjects are on
the columns." I am confused because my data.frame only contains numerica
values of 1,2,3, and NA. I checked and my NAs were all numeric.

Any help or advice you could provide on this issue would be greatly
appreciated. Thank you very much.
I would like to thank all the R experts navigating this forum in advance.

Sincerely,
Haillie

--
View this message in context: 
http://r.789695.n4.nabble.com/converting-data-frame-into-a-numeric-integer-form-tp3455811p3455811.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] heatmap.2 - change column & row locations; angle / rotate

2011-04-18 Thread Karl Brand

Hi Chakravarthy,

[dont forget to Cc the list for useRs with the same Q.]

If you're trying to reuduce the isze of your row or column labels, i 
think the following arguments of heatmap.2 {gplots} is what you want to 
adjust- 'cexCol' and 'cexRow'.


Specifically on my question that you ask about, i found the BioC forum 
helpful:


http://permalink.gmane.org/gmane.science.biology.informatics.conductor/30112

And in fact the phylotemp() function by default pretty much did exactly 
what i needed, available here:


http://phylotemp.microeco.org/

However, it was pointed out to me  that some times the best way to get 
it just right is using more basic functions, which for heatmaps would be 
image(). See:


https://www.stat.math.ethz.ch/pipermail/bioconductor/2010-August/034995.html

hth,

karl


On 04/18/2011 10:38 AM, chakri2...@yahoo.co.in wrote:

Dear Karl Brand,

I am facing same problem as you have faced before (see appended mail below). I 
am writing to you to find out whether you have found a solution !

I asked a similar question in R-forum 
(http://r.789695.n4.nabble.com/How-to-save-heatmap-as-image-or-pdf-td3412542.html#a3413871).

Any pointers would be greatly appreciated

Thanks
Chakravarthy
Junior Research Fellow
Tata Institute of Fundamental Research
Bangalore, India


Esteemed R user's,

I'm struggling to achieve some details of a heatmap using heatmap.2():

1. Change label locations, for both rows&  columns from the default
right&  bottom, to left and top.
Can this be done within heatmap.2()? Or do i need to suppress this
default behavior (how) and call a new function to relabel (what)
specifying locations?

2. Change the angle of the labels.
By default column labels are 90deg anti-clock-wise from horizontal. How
to bring them back to horizontal? Or better, rotate 45deg clock-wise
from horizontal (ie., rotate 135deg a.clock.wise from default)?

Any suggestions or pointers to helpful resources greatly appreciated,

Karl



--
Karl Brand 
Department of Genetics
Erasmus MC
Dr Molewaterplein 50
3015 GE Rotterdam
P +31 (0)10 704 3455 | F +31 (0)10 704 4743 | M +31 (0)642 777 268

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


Re: [R] qvalue

2011-04-18 Thread Peter Langfelder
On Mon, Apr 18, 2011 at 9:12 AM, Jim Silverton  wrote:
> I am using storey's qvalue package but I keep on getting errors. Why is
> this?
>
>> qvalue(p, lambda=0.5)$pi0
> [1] "ERROR: p-values not in valid range."
> Error in qvalue(p, lambda = 0.5)$pi0 :
>  $ operator is invalid for atomic vectors

Some of your p-values are likely outside the range [0, 1]. In such
cases the function prints out the error message and returns a single
number 0. Trying to take a component of a single number produces the
second error message you see.

Check your p-values - all need to be finite and within the range [0, 1].

HTH,

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.


Re: [R] altering identity column

2011-04-18 Thread jim holtman
row.names(transformed_dataframe) <- NULL

2011/4/18 Bodnar Laszlo EB_HU :
> Hi there,
>
> I have a huge dataframe containing 70,000 observations.
>
> I have filtered this dataframe (let it's name be "transformed_dataframe") as 
> I wanted to select only those observations which are greater than or equal to 
> 60,001 regarding the very first identity column.
>
> So I have a transformed dataframe now including 10,000 obeservations (from 
> 60,001 - to 70,000) and if you send "head(transformed_dataframe)" into R it 
> looks like this:
>
>                        variable1           variable2           variable3      
>      variable4           ...
> 60 001              ...                    ...                     ...        
>             ...
> 60 002              ...                    ...                     ...        
>             ...
> 60 003              ...                    ...                     ...        
>             ...
> 60 004              ...                    ...                     ...        
>             ...
> 60 005              ...                    ...                     ...        
>             ...
>
> Sending "tail(transformed_dataframe)" into R it is going to be something like:
>
>                        variable1           variable2           variable3      
>      variable4           ...
> 69 996              ...                    ...                     ...        
>             ...
> 69 997              ...                    ...                     ...        
>             ...
> 69 998              ...                     ...                     ...       
>              ...
> 69 999              ...                    ...                     ...        
>             ...
> 70 000              ...                    ...                     ...        
>             ...
>
>
> Now is there a quick way to alter this indexing of rows in case of my 
> "transformed_dataframe"? I mean, I would like to get indices 1, 2, 3, etc... 
> instead of 60 001, 60 002, 60 003 etc...
>
> So by sending "head(transformed_dataframe)" and "tail(transformed_dataframe)" 
> I would like to see:
>
>            variable1           variable2           variable3           
> variable4           ...
> 1          ...                    ...                    ...                  
>   ...
> 2          ...                    ...                    ...                  
>   ...
> 3          ...                    ...                    ...                  
>   ...
> 4          ...                    ...                    ...                  
>   ...
> 5          ...                    ...                    ...                  
>   ...
>
> and
>
>                        variable1           variable2           variable3      
>      variable4           ...
> 9 996                ...                    ...                    ...        
>             ...
> 9 997    ...                    ...                    ...                    
> ...
> 9 998                ...                    ...                    ...        
>             ...
> 9 999                ...                    ...                    ...        
>             ...
> 10 000              ...                    ...                    ...         
>            ...
>
> Thank you very much, best regards,
>
> Laszlo
> 
> Ez az e-mail és az összes hozzá tartozó csatolt melléklet titkos és/vagy 
> jogilag, szakmailag vagy más módon védett információt tartalmazhat. 
> Amennyiben nem Ön a levél címzettje akkor a levél tartalmának közlése, 
> reprodukálása, másolása, vagy egyéb más úton történő terjesztése, 
> felhasználása szigorúan tilos. Amennyiben tévedésből kapta meg ezt az 
> üzenetet kérjük azonnal értesítse az üzenet küldőjét. Az Erste Bank Hungary 
> Zrt. (EBH) nem vállal felelősséget az információ teljes és pontos - 
> címzett(ek)hez történő - eljuttatásáért, valamint semmilyen késésért, 
> kapcsolat megszakadásból eredő hibáért, vagy az információ felhasználásából 
> vagy annak megbízhatatlanságából eredő kárért.
>
> Az üzenetek EBH-n kívüli küldője vagy címzettje tudomásul veszi és 
> hozzájárul, hogy az üzenetekhez más banki alkalmazott is hozzáférhet az EBH 
> folytonos munkamenetének biztosítása érdekében.
>
>
> This e-mail and any attached files are confidential and/...{{dropped:19}}
>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>



-- 
Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project

Re: [R] Print out data frames into neat images

2011-04-18 Thread Ista Zahn
Hi Santosh,
There are at least three general possibilites:

1) latex (via xtable, Hmisc, r2lh, reporttools ...)
2) html (via xtable, r2lh, R2HTML, hwritter, HTMLUtils ...)
3) graphics (via gridExtra, tableplot ...)

Best,
Ista

On Sun, Apr 17, 2011 at 11:46 PM, Santosh Srinivas
 wrote:
> Hi Group,
>
> I often need to print out data frames with results of analysis into a
> neat little image to copy and paste into documents. I need apply
> formatting like bold, currency signs, number formats, header shading
> etc.
> I currently output the data into csv and format using good old excel.
>
> Any suggestions if there are packages to help with such activities (to
> some level of basic functionality).
> I know that formatting can get quite adhoc but just wondering if there
> is anyway to output reasonably standard output.
>
> (I'm borrowing this idea from javascript plugins that can do such
> activities in the HTML5 world).
>
> Thanks,
> Santosh
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Ista Zahn
Graduate student
University of Rochester
Department of Clinical and Social Psychology
http://yourpsyche.org

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


Re: [R] From nested loop to mclapply

2011-04-18 Thread Allan Engelhardt
Try help("expand.grid", package="base") for one way to create the 
combinations of (i,j) outside the loop, or perhaps vignette("nested", 
package="foreach") which does it "automatically" (rather: naturally).


Allan

On 18/04/11 16:53, Alaios wrote:

Dear all,
I am trying to find a decent way to speed up my code.

So far I have used mclapply with really good results (parallel version of 
lapply). I have a nested loop that I would like to help me convert it to lapply

for (i in seq(from=-1,to=1-2/ncol(sr),length=ncol(sr))){
  for (j in seq(from=-1,to=1-2/nrow(sr),length=nrow(sr))){
estimatedsr[findCoord(c(i,j),sr)[1],findCoord(c(i,j),sr)[2]  
]<-fxy(c(i,j))
  }

So far I have converted some one-depth for loops to lapply but I am not sure If 
I can use lapply to convert a nested loop to something simpler.

Best Regards
Alex

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


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


[R] How to remove the double or single quote from a string (unquote?)?

2011-04-18 Thread JingJiang Yan

Is there a function to get a string without a pair of quotes around it?

I have several expressions like:
glm(V12 ~ V3, family=binomial, data=df1)
glm(V12 ~ V4, family=binomial, data=df1)
...
glm(V12 ~ V8, family=binomial, data=df1)

As you can see, the only differences among them are V3 ... V8.
Because sometimes several of these expressions are performed many times,
I want to use a variable "i" to change the V3 ... V8. I did this with:

> i <- 3:8
> glm(V12 ~ paste("V", i, sep=""), family=binomial, data=df1)

However, it seems the paste always returns a variable name with a pair 
of quotes, which were wrong in such condition.
I only find a function "sQuote" to add quotes to a string, and it looks 
I am looking for an opposite function of it.

Any advice will be appreciated.

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


Re: [R] altering identity column

2011-04-18 Thread Peter Ehlers

On 2011-04-18 06:15, Ben Bolker wrote:

  Bodnar Laszlo EB_HU  erstebank.hu>  writes:


  [snip snip ]



So I have a transformed dataframe now including 10,000 obeservations
(from 60,001 - to 70,000) and if you send
"head(transformed_dataframe)" into R it looks like this:


   [snip]>


Now is there a quick way to alter this indexing of rows in case of
my "transformed_dataframe"? I mean, I would



rownames(newdata)<- 1:nrow(newdata)


or, perhaps a bit simpler

 rownames(newdata) <- NULL

Peter Ehlers

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 remove the double or single quote from a string(unquote?)?

2011-04-18 Thread Gerrit Eichner

Hi, Jing Jiang,

maybe

as.formula( paste( "V12 ~ V", i, sep = ""))

inside the call to glm() does what you need.

Hth  --  Gerrit


On Tue, 19 Apr 2011, JingJiang Yan wrote:


Is there a function to get a string without a pair of quotes around it?

I have several expressions like:
glm(V12 ~ V3, family=binomial, data=df1)
glm(V12 ~ V4, family=binomial, data=df1)
...
glm(V12 ~ V8, family=binomial, data=df1)

As you can see, the only differences among them are V3 ... V8.
Because sometimes several of these expressions are performed many times,
I want to use a variable "i" to change the V3 ... V8. I did this with:


i <- 3:8
glm(V12 ~ paste("V", i, sep=""), family=binomial, data=df1)


However, it seems the paste always returns a variable name with a pair of 
quotes, which were wrong in such condition.
I only find a function "sQuote" to add quotes to a string, and it looks I am 
looking for an opposite function of it.

Any advice will be appreciated.

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



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

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


Re: [R] How to remove the double or single quote from a string (unquote?)?

2011-04-18 Thread Allan Engelhardt
This should be a FAQ: you are confusing the value with its printed 
representation.  Try


print(paste("V", 3:8, sep=""), quote=FALSE)

to see that there are no quotes, and you may want to read up on 
help("as.formula", package="stats") which has the examples you are 
searching for.


Allan

On 18/04/11 17:38, JingJiang Yan wrote:

Is there a function to get a string without a pair of quotes around it?

I have several expressions like:
glm(V12 ~ V3, family=binomial, data=df1)
glm(V12 ~ V4, family=binomial, data=df1)
...
glm(V12 ~ V8, family=binomial, data=df1)

As you can see, the only differences among them are V3 ... V8.
Because sometimes several of these expressions are performed many times,
I want to use a variable "i" to change the V3 ... V8. I did this with:

> i <- 3:8
> glm(V12 ~ paste("V", i, sep=""), family=binomial, data=df1)

However, it seems the paste always returns a variable name with a pair 
of quotes, which were wrong in such condition.
I only find a function "sQuote" to add quotes to a string, and it 
looks I am looking for an opposite function of it.

Any advice will be appreciated.

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

2011-04-18 Thread Duarte Viana
Hello all,

In the following example, one sobol index for one parameter (the first
order index for parameter b) is larger than 1. Shouldn´t the indices
have a range of [0,1]?

# Code for a decoupled approach example:

X1<-data.frame(a=runif(100,20,30),b=runif(100,0.1,0.5))
X2<-data.frame(a=runif(100,20,30),b=runif(100,0.1,0.5))

library(sensitivity)

x<-sobol2002(model=NULL,X1,X2,nboot=100)

resp<-x$X$a*x$X$b   # Example of model output

tell(x,y=resp)

print(x)

# End

Result

Call:
sobol2002(model = NULL, X1 = X1, X2 = X2, nboot = 100)

Model runs: 400

First order indices:
originalbias std. error  min. c.i. max. c.i.
a 0.08852067 -0.01317529  0.1227359 -0.2126156 0.3132482
b 1.24009414  0.01207408  0.4018650  0.2074935 1.8574080

Total indices:
   original bias std. error  min. c.i. max. c.i.
a 0.1172252  0.018504397  0.1501931 -0.1456118 0.4896815
b 0.4323300 -0.004814019  0.2692777 -0.1669219 1.0103819



What am I doing wrong? Or the approach has some limitation that I
might be disregarding?
Thanks for any clarification on this.

Duarte Viana

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


Re: [R] Using jitter function with differing variable lengths

2011-04-18 Thread Don McKenzie

A reproducible example would really help here.


On 17-Apr-11, at 7:11 PM, Danica Horrell wrote:


Hi,

I am trying to make a scatter plot with 4 different categories  
using the
jitter function.  My code returns a variable length error and will  
not plot
because my four categories have different numbers of samples.  When  
I delete
samples from my spreadsheet so that each of the categories has the  
same

number of variables, it plots just fine.

Is there any way to get around this and plot all of my samples  
using jitter?


Thanks for the 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.


Why does the universe go to all the bother of existing?
-- Stephen Hawking




Don McKenzie, Research Ecologist
Pacific WIldland Fire Sciences Lab
US Forest Service

Affiliate Professor
School of Forest Resources, College of the Environment
CSES Climate Impacts Group
University of Washington

desk: 206-732-7824
cell: 206-321-5966
d...@uw.edu
donaldmcken...@fs.fed.us

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


Re: [R] Avoiding loop

2011-04-18 Thread Dennis Murphy
Hi:

Try the expm package. Using your example,

> R = A%*%B
> for(i in 1:100)
+ {
+R = R%*%B
+ }
> R
 [,1] [,2] [,3] [,4] [,5]
[1,] 9.934879e+47 1.098761e+48 8.868476e+47 7.071831e+47 6.071370e+47
[2,] 1.492692e+48 1.650862e+48 1.332468e+48 1.062526e+48 9.122090e+47
[3,] 6.693145e+47 7.402373e+47 5.974708e+47 4.764305e+47 4.090293e+47
[4,] 5.895689e+47 6.520416e+47 5.262850e+47 4.196661e+47 3.602954e+47
[5,] 8.347321e+47 9.231830e+47 7.451326e+47 5.941778e+47 5.101187e+47

library(expm)
# The matrix power function is an operator % ^ %
> A %*% (B %^% 101)
 [,1] [,2] [,3] [,4] [,5]
[1,] 9.934879e+47 1.098761e+48 8.868476e+47 7.071831e+47 6.071370e+47
[2,] 1.492692e+48 1.650862e+48 1.332468e+48 1.062526e+48 9.122090e+47
[3,] 6.693145e+47 7.402373e+47 5.974708e+47 4.764305e+47 4.090293e+47
[4,] 5.895689e+47 6.520416e+47 5.262850e+47 4.196661e+47 3.602954e+47
[5,] 8.347321e+47 9.231830e+47 7.451326e+47 5.941778e+47 5.101187e+47

> system.time(replicate(1000, A %*% (B %^% 101)))
   user  system elapsed
   0.020.000.01
> system.time(replicate(1000, {R = A%*%B
+ for(i in 1:100)
+ {
+R = R%*%B
+ }  }))
   user  system elapsed
   0.150.000.15

HTH,
Dennis


On Mon, Apr 18, 2011 at 9:06 AM, Filoche  wrote:
> Hi everyone.
>
> I'm using matrix product such as :
>
>
> #Generate some data
> NCols = 5
> NRows = 5
> A = matrix(runif(NCols*NRows), ncol=NCols)
> B = matrix(runif(NCols*NRows), ncol=NCols)
>
> #First calculation
> R = A%*%B
>
>
> for(i in 1:100)
> {
>        R = R%*%B
> }
>
>
> I would like to know if it was possible to avoid the loop by using something
> like mapply or anything else.
>
> Tx in advance,
> Phil
>
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/Avoiding-loop-tp3457963p3457963.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

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


[R] Fayez_how to make the colored panels in lattice xyplot

2011-04-18 Thread aziz4

Hi all,

Consider I am want to lattice.xyplot following car's data for different brands 
and different gas mileages:

car1 Toyota 40
car2 Toyota 38
car3 Honda 39
car4 Honda 32
car5 Honda 35
car6 Honda 32
car7 Mitsubishi 27
car8 Mitsubishi 34
car9 Mitsubishi 33

Now first I want to make three panels for the three brands.

Secondly, for each brand I want to lattice.xyplot cars against the mileage in a 
scale from say 25 to 45.

Thirdly, I want to color the different ranges of the scale. For instance, 
scale-range of mileage from 25 to 30 colored light-red, 31 to 35: light orange, 
36 to 40: light blue and so on.

Is it possible to do that in R. Specifically the coloring part in the 
multi-panels.

Best,
Fayez
Grad Student Bioinformatics
UIUC

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


Re: [R] Avoiding loop

2011-04-18 Thread Filoche
Hi sire.

This is exactly what I was looking for, thank you.

With regards,
Phil

--
View this message in context: 
http://r.789695.n4.nabble.com/Avoiding-loop-tp3457963p3458152.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] no solution yet, please help: extract p-value from mixed model in kinship package

2011-04-18 Thread Juliet Hannah
Maybe the pedigree is not set up correctly. If this is the case, the
kinship matrix will not be constructed correctly. I see that in this
example,
the diagonal terms differ.

diag(kmat)

lmekin runs fine for me, and I can extract p-values with:

   lmekinfit <- lmekin(...)
   pval <- lmekinfit$ctable;



On Fri, Apr 15, 2011 at 9:30 AM, Ram H. Sharma  wrote:
>  I am making the question clear. Please help.
>
>
>
>> Dear R experts
>>
>> I was using kinship package to fit mixed model with kinship matrix.
>> The package looks like lme4, but I could find a way to extract p-value
>> out of it. I need to extract is as I need to analyse large number of
>> variables (> 1).
>>
>> Please help me:
>>
>> require(kinship)
>>
>> #Generating random example  data
>>
>
>
>> #pedigree data*
>
>
> id <- 1:100
>
> dadid <- c(rep(0, 5), rep(1, 5), rep(3, 5), rep(5, 5), rep(7, 10),
> rep(9, 10), rep(11, 10), rep(13, 10), rep(15, 10), rep(17, 10),
> rep(19, 10), rep(21, 10))
>
> momid <- c(rep(0, 5), rep(2, 5), rep(4, 5), rep(6, 5), rep(8, 10),
> rep(10, 10), rep(12, 10), rep(14, 10), rep(16, 10), rep(18, 10),
> rep(20, 10), rep(22, 10) )
>
> ped <- data.frame(id, dadid, momid)
>
> # *kmatrix**
>
>> cfam <- makefamid(ped$id,ped$momid, ped$dadid)
>>
>> kmat <- makekinship(cfam, ped$id, ped$momid, ped$dadid)
>>
>> #*x and y variables
> *
>
>> set.seed(3456)
>>
>> dat <- sample(c(-1,0,1), 1, replace = TRUE)
>>
>> snpmat<- data.frame(matrix(dat, ncol = 100))
>>
>> names(snpmat) <- c(paste ("VR",1:100, sep='' ))
>>
>> yvar <- rnorm(100, 30, 5)
>> covtrait <-  rnorm(100, 10, 5)
>>
>> mydata <- data.frame(id, yvar, covtrait, snpmat)
>>
> #**mixed model in lmekin
> ***
>
>>
>> fmod <- lmekin(yvar ~ mydata[,3] , data= mydata, random = ~1|id,
>> varlist=list(kmat)) $coefficients[2,4] # does not work
>>
>> # **error
>> message
>
>
>
>> Error message:
>
> Error in lmekin(yvar ~ mydata[, 3], data = mydata, random = ~1 | id, varlist
> = list(kmat))$coefficients[2,  :
>  incorrect number of dimensions
> In addition: Warning message:
> In coxme.varcheck(ncluster, varlist, n, gvars, groups, sparse, rescale,  :
>  Diagonal of variance matrix is not constant
>
> #**ultimate target: to put in
> loop***
>
>> Ultimately I want to put into the loop:
>>
>> for(i in 3:length(mydata)) {
>>
>> P <- vector (mode="numeric", length = 1000)
>>
>> P[i] <- lmekin(yvar~ mydata[,i] , data= mydata, random = ~1|id,
>> varlist=list(kmat)) $coefficients[2,4]
>>
>> }
>>
>
>
>> Same errors: I tried lme4 conventioned but did not work !
>
>
>
>> I can extract fixed effects as well as I do in lme4
>>  b <- fixef(fit1)
>>
>
>
>> Error in UseMethod("fixef") :
>>   no applicable method for 'fixef' applied to an object of class "lmekin"
>>
>>
>> --
>>
>> Ram H
>>
>
>
>
> --
>
> Ram H
>
>        [[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] using "aggregate" when variable names contain spaces

2011-04-18 Thread Dimitri Liakhovitski
Hello!

my data set has many variables. Unfortuantely, many of those variables
contain spaces in their names.
I need advice on: how to refer to variable names in the formula for
"aggregate". See example below:

### Generating example data set:
mydate = rep(seq(as.Date("2008-12-01"), length = 3, by = "month"),4)
value1=c(1,10,100,2,20,200,3,30,300,4,40,400)
value2=c(1.1,10.1,100.1,2.1,20.1,200.1,3.1,30.1,300.1,4.1,40.1,400.1)
example<-data.frame(mydate=mydate,value1=value1,value2=value2)
example$group<-c(rep("group1",3),rep("group2",3),rep("group1",3),rep("group2",3))
exampe$group<-as.factor(exampe$group)

### Generating variable names with spaces:
names(example)<-c("mydate", "my value 1","my value 2","group")

### Trying to aggregate - but it's not working. Clearly, my reference
to variable names is incorrect:
mynames<-names(example)
example.agg1<-aggregate(cbind(mynames)~group+mydate,sum,data=example)


Thank you very much!

-- 
Dimitri Liakhovitski
Ninah Consulting
www.ninah.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] mcmc simulation

2011-04-18 Thread Peter Francis
Dear List,

I am reading a method and am unsure how to do something similar, so have come 
here for advice!

I have a observed value and a expected value generated from a null model.  I am 
looking to see if observed - expected is significantly different from zero.

So in the method in the paper it states: " .. significance of difference from 
zero was tested with Markov chain Monte Carlo simulation"

I have installed the package mcmc as this seemed a good place to start but i am 
unsure what function to call?

I have 600 data points in a data frame called diversity, where the observed 
value is called, well observed and the expected.. expected! 

Thanks for any advice.

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] Import dbf file

2011-04-18 Thread new2R
Hi 

I am new to R. I am trying to import dbf file using read.dbf but getting
error message "object read.dbf is not found.

Please help in this regard.

Thank you


--
View this message in context: 
http://r.789695.n4.nabble.com/Import-dbf-file-tp3458366p3458366.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] URL Scan

2011-04-18 Thread jmsc
Ok thanks for the suggestion. I will look into that.

On Mon, Apr 18, 2011 at 5:27 AM, Barry Rowlingson [via R] <
ml-node+3457010-2013527485-230...@n4.nabble.com> wrote:

> On Sun, Apr 17, 2011 at 11:56 PM, jmsc <[hidden 
> email]>
> wrote:
> > The site does not require a login/password. Another way to access the
> first
> > site would be to go to the second site, click Connecticut, click
> Canterbury,
> > CT, enter the online database, click search under Query by Location with
> > nothing in the search fields, and click the first property. Viewing the
> > frame source on this page redirects to the second site.
>
>  it doesn't require a login/pass, but it uses session cookies to
> simulate a logged-in user (there's even a log out button that clears
> the session).
>
> > Also, could you direct me to or give me some instructions on scanning
> from
> > sites that do require a login/password? Thanks.
>
>  I had a quick look for R-help posts on this ( RSiteSearch("cookies"),
> RSiteSearch("session") etc) but didn't find much. You probably want to
> install  RCurl and look at the examples.
>
>  Generally what happens is that a successful login, or in this case
> just visiting the database front page, causes the web server to send
> back a 'cookie' with a long ID number in it. For every further access
> to that web site your browser includes the cookie. The server then
> looks up the ID, goes 'yup, this is a valid session', and sends you
> the page you want. If the cookie isn't there, or the ID isn't valid
> (and the ID numbers are big enough to make guessing impractical), then
> you get the default page.
>
> Barry
>
> __
> [hidden 
> email]mailing 
> list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>
> --
>  If you reply to this email, your message will be added to the discussion
> below:
> http://r.789695.n4.nabble.com/URL-Scan-tp3456084p3457010.html
>  To unsubscribe from URL Scan, click 
> here.
>
>


--
View this message in context: 
http://r.789695.n4.nabble.com/URL-Scan-tp3456084p3458336.html
Sent from the R help mailing list archive at Nabble.com.
[[alternative HTML version deleted]]

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


[R] "object read.dbf" is not found

2011-04-18 Thread new2R
Hi 

I am new to R. I am trying to import dbf file using read.dbf but getting
error message "object read.dbf" is not found. 

Please help in this regard. 

Thank you 

--
View this message in context: 
http://r.789695.n4.nabble.com/object-read-dbf-is-not-found-tp3458409p3458409.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 two lines - Ancova: lm or aov?

2011-04-18 Thread Anne Kirsten Bowser
Hello!

I have measurements (length and volume) of fish collected in two years. I
want to know if the the relationship between length and volume is the same
for both years. The number of fish measured is different for each year. I
don't know whether lm or aov is more appropriate to use.

Here are the two output options:

Call:
lm(formula = Volume ~ Length * Year)

Residuals:
 Min   1Q   Median   3Q  Max
-1.35062 -0.42695 -0.02234  0.29789  1.78540

Coefficients:
  Estimate Std. Error t value Pr(>|t|)
(Intercept)  -8.699125   0.543372 -16.010   <2e-16 ***
Length0.151462   0.006708  22.578   <2e-16 ***
Year1 1.627903   1.168158   1.394   0.1660
Length:Year1 -0.024259   0.014510  -1.672   0.0972 .
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.6016 on 119 degrees of freedom
Multiple R-squared: 0.8384, Adjusted R-squared: 0.8343
F-statistic: 205.8 on 3 and 119 DF,  p-value: < 2.2e-16


AND for aov:


   Df  Sum Sq Mean Sq  F valuePr(>F)
Length  1 219.457 219.457 606.4349 < 2.2e-16 ***
Year  1   2.970   2.970   8.2073  0.004934 **
Length:Year   1   1.012   1.012   2.7952  0.097173 .
Residuals 119  43.064   0.362
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1


Thanks very much for any help.
Kirsten

[[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] Alignment of lines within barplot bars

2011-04-18 Thread Greg Snow
Sorry I took so long to get back on this, I have been out of town.

For your case you need to provide adjustments for both the x and y to 
updateusr, try this:

library(TeachingDemos)
tmp <- barplot(c(1.5,40),yaxt='n',names.arg=1:2,ylim=c(0,1.25*40))
axis(4)
tmp2 <- par('usr')
updateusr(tmp[1:2], tmp2[3:4], 1:2, c(0,0.022) )
points( 1:2, c(0.01, 0.02), pch=16 )
axis(2)


You can make further adjustments to the new y axis by changing the 0.022 in the 
updateusr call.

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


> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> project.org] On Behalf Of snowboarder101
> Sent: Friday, April 08, 2011 2:26 PM
> To: r-help@r-project.org
> Subject: Re: [R] Alignment of lines within barplot bars
> 
> Thanks for the reply. I looked at this before as I saw you had posted
> this,
> but this either doesn't work in my situation, or I am using it wrong.
> 
> Take the example in the function:
> 
> tmp <- barplot(1:4)
> updateusr(tmp[1:2], 0:1, 1:2, 0:1)
> lines(1:4, c(1,3,2,2), lwd=3, type='b',col='red')
> 
> But I want to use par(new=T) and plot(), so:
> 
> tmp <- barplot(1:4)
> par(new=T)
> updateusr(tmp[1:2], 0:1, 1:2, 0:1)
> plot(1:4, c(1,3,2,2), lwd=3, type='b',col='red')
> 
> The reason I do this is that the y-axis then corresponds to my plot()
> data.
> In my specific case, it's more like this:
> 
> tmp <- barplot(c(1.5,40),yaxt='n',names.arg=1:2,ylim=c(0,1.25*40))
> axis(4)
> par(new=T)
> updateusr(tmp[1:2], 1:2)
> plot(1:2,c(0.01,0.02),xaxt='n',pch=16)
> 
> I want those points in the middle of the bars... but I want to keep the
> y-axis labels from the second plot. the par(new=T) probably wipes out
> the
> coordinates, so I'm not sure how use this?
> 
> Thanks Again.
> 
> 
> --
> View this message in context: http://r.789695.n4.nabble.com/Alignment-
> of-lines-within-barplot-bars-tp2533115p3437369.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] using "aggregate" when variable names contain spaces

2011-04-18 Thread David Winsemius


On Apr 18, 2011, at 3:19 PM, Dimitri Liakhovitski wrote:


Hello!

my data set has many variables. Unfortuantely, many of those variables
contain spaces in their names.
I need advice on: how to refer to variable names in the formula for
"aggregate". See example below:

### Generating example data set:
mydate = rep(seq(as.Date("2008-12-01"), length = 3, by = "month"),4)
value1=c(1,10,100,2,20,200,3,30,300,4,40,400)
value2=c(1.1,10.1,100.1,2.1,20.1,200.1,3.1,30.1,300.1,4.1,40.1,400.1)
example<-data.frame(mydate=mydate,value1=value1,value2=value2)
example$group<-c(rep("group1",3),rep("group2",3),rep("group1", 
3),rep("group2",3))

exampe$group<-as.factor(exampe$group)

### Generating variable names with spaces:
names(example)<-c("mydate", "my value 1","my value 2","group")

### Trying to aggregate - but it's not working. Clearly, my reference
to variable names is incorrect:
mynames<-names(example)
example.agg1<-aggregate(cbind(mynames)~group+mydate,sum,data=example)


Use backticks:

> aggregate(`my value 1` + `my value 2` ~group+mydate,sum,data=example)
   group mydate `my value 1` + `my value 2`
1 group1 2008-12-01 8.2
2 group2 2008-12-0112.2
3 group1 2009-01-0180.2
4 group2 2009-01-01   120.2
5 group1 2009-02-01   800.2
6 group2 2009-02-01  1200.2





--

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] Import dbf file

2011-04-18 Thread David Winsemius


On Apr 18, 2011, at 2:41 PM, new2R wrote:


Hi

I am new to R. I am trying to import dbf file using read.dbf but  
getting

error message "object read.dbf is not found.


The message suggests that you have not loaded the `foreign` package.


Please help in this regard.


?require

--

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.


  1   2   >