Re: [R] Loop Autoregression

2014-06-02 Thread PIKAL Petr
Hi

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
 project.org] On Behalf Of Jonas Ulbrich
 Sent: Sunday, June 01, 2014 1:51 PM
 To: R-help@r-project.org
 Subject: [R] Loop Autoregression

 Hello everybody, I have to confess that I am relatively new to R.

 My problem is the following one:

 I have a data set of 500 values. For each value I wanna make prediction
 of four steps ahead via autogregression. Because I have to repeat this
 procedure on three other data sets I wanna make a loop. (Manual
 calculation would take ages.) My idea which does not work looks is as
 follows:

 x-NULL
 for (i in 1:500){

 x[i]-predict(ar(y[i],order.max=1,method=yule-walker,intercept=TRUE,
 n.used=500, n.ahead=4))
 }

We have no idea what is y and y[i]. I presume that y is vector and y[i] is one 
item from this vector, hence the error as n.used is actually 1 and order.max is 
also 1.

 ar((lh)[1])
Error in ar.yw.default(x, aic = aic, order.max = order.max, na.action = 
na.action,  :
  'order.max' must be = 1


you can find how to use ar in its help page.
?ar

Also your parentheses are mismatched. Most probably you want

predict(ar(y,order.max=1,method=yule-walker,intercept=TRUE,n.used=500), 
n.ahead=4)

Regards
Petr




 Doing this I only get an error request that the value of order.maX
 needs to be smaller than n.used. But this is the case. Isn't it?

 Best Regards

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


Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a jsou určeny 
pouze jeho adresátům.
Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě neprodleně 
jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho kopie vymažte ze 
svého systému.
Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento email 
jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat.
Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou modifikacemi či 
zpožděním přenosu e-mailu.

V případě, že je tento e-mail součástí obchodního jednání:
- vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření smlouvy, a 
to z jakéhokoliv důvodu i bez uvedení důvodu.
- a obsahuje-li nabídku, je adresát oprávněn nabídku bezodkladně přijmout; 
Odesílatel tohoto e-mailu (nabídky) vylučuje přijetí nabídky ze strany příjemce 
s dodatkem či odchylkou.
- trvá odesílatel na tom, že příslušná smlouva je uzavřena teprve výslovným 
dosažením shody na všech jejích náležitostech.
- odesílatel tohoto emailu informuje, že není oprávněn uzavírat za společnost 
žádné smlouvy s výjimkou případů, kdy k tomu byl písemně zmocněn nebo písemně 
pověřen a takové pověření nebo plná moc byly adresátovi tohoto emailu případně 
osobě, kterou adresát zastupuje, předloženy nebo jejich existence je adresátovi 
či osobě jím zastoupené známá.

This e-mail and any documents attached to it may be confidential and are 
intended only for its intended recipients.
If you received this e-mail by mistake, please immediately inform its sender. 
Delete the contents of this e-mail with all attachments and its copies from 
your system.
If you are not the intended recipient of this e-mail, you are not authorized to 
use, disseminate, copy or disclose this e-mail in any manner.
The sender of this e-mail shall not be liable for any possible damage caused by 
modifications of the e-mail or by delay with transfer of the email.

In case that this e-mail forms part of business dealings:
- the sender reserves the right to end negotiations about entering into a 
contract in any time, for any reason, and without stating any reasoning.
- if the e-mail contains an offer, the recipient is entitled to immediately 
accept such offer; The sender of this e-mail (offer) excludes any acceptance of 
the offer on the part of the recipient containing any amendment or variation.
- the sender insists on that the respective contract is concluded only upon an 
express mutual agreement on all its aspects.
- the sender of this e-mail informs that he/she is not authorized to enter into 
any contracts on behalf of the company except for cases in which he/she is 
expressly authorized to do so in writing, and such authorization or power of 
attorney is submitted to the recipient or the person represented by the 
recipient, or the existence of such authorization is known to the recipient of 
the person represented by the recipient.
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Question about setdiff()

2014-06-02 Thread Raphael Päbst
Hello everyone, I have a question which is probably rooted in my lack
of understanding when it comes to math.

I just did the following:

v - c(1:20)
w - c(11:30)
setdiff(v, w)

and got:
1 2 3 4 5 6 7 8 9 10

Then I did the following:
setdiff(w, v)
and got, not surprisingly:
21 22 23 24 25 26 27 28 29 30

Now I was originally expecting to get bot with the first call of
setdiff(v, w) and couldn't find any reason not to expect this from
?setdiff()

Am I missing somethin vital here or does setdiff() always give me the
elements of the first set that are not in the second one and not those
which are exclusive to either one, just dropping the ones in the
intersection of both sets?

Many Thanks in advance

Raphael

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


Re: [R] Question about setdiff()

2014-06-02 Thread Jeff Newmiller
About time for you to adjust your expectations... looks right to me from both a 
mathematical sense and as the functions are designed.
---
Jeff NewmillerThe .   .  Go Live...
DCN:jdnew...@dcn.davis.ca.usBasics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
--- 
Sent from my phone. Please excuse my brevity.

On June 1, 2014 11:57:42 PM PDT, Raphael Päbst raphael.pae...@gmail.com 
wrote:
Hello everyone, I have a question which is probably rooted in my lack
of understanding when it comes to math.

I just did the following:

v - c(1:20)
w - c(11:30)
setdiff(v, w)

and got:
1 2 3 4 5 6 7 8 9 10

Then I did the following:
setdiff(w, v)
and got, not surprisingly:
21 22 23 24 25 26 27 28 29 30

Now I was originally expecting to get bot with the first call of
setdiff(v, w) and couldn't find any reason not to expect this from
?setdiff()

Am I missing somethin vital here or does setdiff() always give me the
elements of the first set that are not in the second one and not those
which are exclusive to either one, just dropping the ones in the
intersection of both sets?

Many Thanks in advance

Raphael

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

2014-06-02 Thread Pascal Oettli
Hello,

From the help page: Performs *set* union, intersection, (asymmetric!)
difference, equality and membership on two vectors.

Hope this helps,
Pascal


On Mon, Jun 2, 2014 at 3:57 PM, Raphael Päbst raphael.pae...@gmail.com wrote:
 Hello everyone, I have a question which is probably rooted in my lack
 of understanding when it comes to math.

 I just did the following:

 v - c(1:20)
 w - c(11:30)
 setdiff(v, w)

 and got:
 1 2 3 4 5 6 7 8 9 10

 Then I did the following:
 setdiff(w, v)
 and got, not surprisingly:
 21 22 23 24 25 26 27 28 29 30

 Now I was originally expecting to get bot with the first call of
 setdiff(v, w) and couldn't find any reason not to expect this from
 ?setdiff()

 Am I missing somethin vital here or does setdiff() always give me the
 elements of the first set that are not in the second one and not those
 which are exclusive to either one, just dropping the ones in the
 intersection of both sets?

 Many Thanks in advance

 Raphael

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



-- 
Pascal Oettli
Project Scientist
JAMSTEC
Yokohama, Japan

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


Re: [R] Conditional mean for groups, new variables

2014-06-02 Thread arun


Hi,
Regarding your first comment, you didn't provide any reproducible example. So I 
created one with SCHOOLID's as alphabets.  According to your original post, you 
had a read dataset with 36000 SCHOOLIDs.  Suppose, if I created the SCHOOLIDs 
using:
 length(outer(LETTERS,1:2000,paste,sep=))
#[1] 52000

#Please note that I am creating only 6 columns as an example
set.seed(42)
rev1 - data.frame(SCHOOLID = sample(outer(LETTERS,1:1000,paste,sep=),36e3, 
replace=TRUE), matrix(sample(180, 36e3*5,replace=TRUE), ncol=5, 
dimnames=list(NULL, c(MATH, AGE, STO2Q01, BFMJ, 
BMMJ))),stringsAsFactors=FALSE)      
 dim(rev1)
#[1] 36000 6


res1 - aggregate(rev1[,-1], list(SCHOOLID=rev1[,1]), mean,na.rm=TRUE)
 dim(res1)
#[1] 26010 6
 head(res1,2)
# SCHOOLID  MATH AGE STO2Q01 BFMJ BMMJ
#1   A1 107.5  30    41.5   75  149
#2 A100 159.5 132   107.0   66   15
colMeans(rev1[rev1$SCHOOLID==A1,-1])
#   MATH AGE STO2Q01    BFMJ    BMMJ 
#  107.5    30.0    41.5    75.0   149.0 


#I am not following the second statement.  Please provide a reproducible 
example using ?dput().
May be you want results in this form:

rev2 - data.frame(SCHOOLID=rev1[,1], sapply(rev1[-1],function(x) ave(x, 
rev1[,1], FUN= mean, na.rm=TRUE)))

A.K.


I'm sorry, but it does not :(
It gives results maximum only for first 26 schools (according to the number of 
letters in the alphabet). And according to the result it counts not an avreage 
values of the factors. 


On Sunday, June 1, 2014 8:37 PM, arun smartpink...@yahoo.com wrote:
Hi,
May be this helps:


set.seed(42)
rev1 - data.frame(SCHOOLID=sample(LETTERS[1:4],20,replace=TRUE), 
matrix(sample(25, 20*5,replace=TRUE), ncol=5, dimnames=list(NULL, c(MATH, 
AGE, STO2Q01, BFMJ, BMMJ))),stringsAsFactors=FALSE)  
res1 - aggregate(rev1[,-1], list(SCHOOLID=rev1[,1]), mean,na.rm=TRUE)
res1
#if you need to change the names
res2 - setNames(aggregate(rev1[,-1], list(SCHOOLID=rev1[,1]), 
mean,na.rm=TRUE), c(SCHOOLID, paste(colnames(rev1)[-1], MEAN,sep=_)))
res2

A.K.


Hello! I have a problem, I want to calculate conditional mean for my dataset. 
First, I attach it:
rev-read.csv(MATH1.csv, header=T, sep=;, dec=,)
attach(rev)
I have 65 observations (test score) and 36000 groups (schoolid)
I need to calculate the mean for every group (schoolid) for the all my 
variables (MATH, AGE, ST02Q01,BFMJ,BMMJ. Actually, I have 34 varables, I just 
don't want to list them here)  and then to create new variables for obtained 
new columns, because I want to estimate a new regression for the new obtained 
average values.
The following method is not appropriate for me, because it gives me in result a 
table with schoolid and the average for one variables, and I don't know how to 
extract the MATH coulmn with average values from the table with results to the 
worklist separately(environment).
aggregate( MATH~SCHOOLID, rev, mean)
How can I solve this problem? Thank for help!

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


Re: [R] Question about setdiff()

2014-06-02 Thread Raphael Päbst
Thanks everyone!
It is just as I expected, I just didn't understand how setdiff() works.

Raphael

On 6/2/14, Pascal Oettli kri...@ymail.com wrote:
 Hello,

 From the help page: Performs *set* union, intersection, (asymmetric!)
 difference, equality and membership on two vectors.

 Hope this helps,
 Pascal


 On Mon, Jun 2, 2014 at 3:57 PM, Raphael Päbst raphael.pae...@gmail.com
 wrote:
 Hello everyone, I have a question which is probably rooted in my lack
 of understanding when it comes to math.

 I just did the following:

 v - c(1:20)
 w - c(11:30)
 setdiff(v, w)

 and got:
 1 2 3 4 5 6 7 8 9 10

 Then I did the following:
 setdiff(w, v)
 and got, not surprisingly:
 21 22 23 24 25 26 27 28 29 30

 Now I was originally expecting to get bot with the first call of
 setdiff(v, w) and couldn't find any reason not to expect this from
 ?setdiff()

 Am I missing somethin vital here or does setdiff() always give me the
 elements of the first set that are not in the second one and not those
 which are exclusive to either one, just dropping the ones in the
 intersection of both sets?

 Many Thanks in advance

 Raphael

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



 --
 Pascal Oettli
 Project Scientist
 JAMSTEC
 Yokohama, Japan


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Updates from the useR! 2014 organizing committee

2014-06-02 Thread Jeroen Ooms
Hi all,

We are exactly one month away from the useR! 2014 conference [1]. Time
for an update from the organizing committee.

This weekend, registrations passed the 500 mark, which is a new record
for useR! according to data collected by Gergely Daróczi [2]. Yet,
there is plenty of additional capacity, both for the conference
itself, as well as the beautiful on-campus housing at UCLA. We hope to
see many more registrations over the upcoming weeks and appreciate all
help in spreading the word to friends and colleagues that (should) use
R, but might not be actively following the blogs or mailing lists.

To those who are unsure whether to attend, we want to emphasize that
useR! is not just for seasoned professionals, but has lots to offer to
any R user. Abstracts and (free) tutorials cover a great diversity of
topics in both research and industry applications, ranging from
introductory to very advanced. The conference provides a great
opportunity to learn and mingle with the community, and is interesting
for beginner as well as experienced R users.

Tutorials this year are included with the conference ticket and no
separate registration is required. All registrants will receive an
email survey asking which tutorial they would like to attend, if any.
This information will be used for scheduling purposes and to
facilitate communication between presenters and participants (e.g.
distribution of preparation material).

Finally, we urge international guests to verify that their visa or
visa-waiver documents are valid to enter the United States. Citizens
from visa-waiver countries [3] that do not already have a US visa,
must apply online for an ESTA travel authorization at least 72 hours
prior to departure. Once approved, the ESTA is generally valid for a
period of 2 years, so now would be a good time to complete this
process.

We look forward to seeing all of you in California! Please keep an eye
on the conference website, which is continuously updated with most
recent news and information as it becomes available.

Best,

Jeroen, on behalf of the organizing committee


[1] http://user2014.stat.ucla.edu/
[2] http://rapporter.net/custom/R-activity/data/Rstats.csv
[3] http://www.esta.us/visa_waiver_countries.html

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


Re: [R] Plotting issues with -par(mfrow=c(r,c))- after -boot-

2014-06-02 Thread Clive Nicholas
On 1 June 2014 22:07, Jeff Newmiller jdnew...@dcn.davis.ca.us wrote:



 Read ?plot.boot, in particular the Side Effects section. Not a very
 friendly function... you will have to modify it if you wish to proceed.


Thank you. I shall check this out later and may return with queries,
but only if absolutely necessary.


 --
 Clive Nicholas

 My colleagues in the social sciences talk a great deal about methodology.
 I prefer to call it style. -- Freeman J. Dyson

[[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] Plotting issues with -par(mfrow=c(r,c))- after -boot-

2014-06-02 Thread Clive Nicholas
The help page is of no help at all in this respect, which is probably what
you were saying in different words.

Essentially, then, there is no solution, as I certainly wouldn't know how
to go about reconfiguring -boot-. That sounds like more trouble than it is
worth.

On 1 June 2014 22:07, Jeff Newmiller jdnew...@dcn.davis.ca.us wrote:

 Read ?plot.boot, in particular the Side Effects section. Not a very
 friendly function... you will have to modify it if you wish to proceed.
 ---
 Jeff NewmillerThe .   .  Go Live...
 DCN:jdnew...@dcn.davis.ca.usBasics: ##.#.   ##.#.  Live
 Go...
   Live:   OO#.. Dead: OO#..  Playing
 Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
 /Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
 ---
 Sent from my phone. Please excuse my brevity.

 On June 1, 2014 1:20:45 PM PDT, Clive Nicholas cliveli...@googlemail.com
 wrote:
 R 3.1.0 / RStudio 0.98.507 / OpenSUSE Linux 13.1
 
 I'm having difficulties getting -par(mfrow=c(r,c))- to work as it
 should
 after running bootstrapped regression models using -boot-. An example
 (tested):
 
 test=data.frame(A=rnorm(500, mean=2.72, sd=5.36),

 B=sample(c(12,20,24,28,32),size=500,prob=c(0.333,0.026,0.026,0.436,0.179),replace=TRUE),

 C=sample(c(0,1),size=500,prob=c(0.5,0.5),replace=TRUE),D=sample(c(0,1),size=500,prob=c(0.564,0.436),replace=TRUE))
 library(boot)
 bs=function(formula, data, indices) {
  test=data[indices,]
  fit=lm(formula, data=test)
  return(coef(fit))
 }
 results=boot(data=test, statistic=bs, R=1, formula=A~B+C+D+C*D)
 results
 
 When I run
 
 par(mfrow=c(2,2))
 
 and then
 
 plot(results, index=2)
 plot(results, index=3)
 plot(results, index=4)
 plot(results, index=5)
 
 the plots display in full size only, as they are called, and not as one
 combined image of four plots. This problem also happened to me last
 year
 under earlier versions of R in Kubuntu Linux.
 
 This command worked fine when I first started using R in Linux, I don't
 think I'm doing much wrong in this instance and I would welcome any
 explanation as to what exactly is going on here, as well as a solution.




-- 
Clive Nicholas

My colleagues in the social sciences talk a great deal about methodology.
I prefer to call it style. -- Freeman J. Dyson

[[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] Smoothed HR for interaction term in coxph model

2014-06-02 Thread Therneau, Terry M., Ph.D.



On 05/30/2014 05:00 AM, r-help-requ...@r-project.org wrote:



I have a dataset with 2 treatments and want to assess the effect of a
continous covariate on the Hazard ratio between treatment A and B.  I want a
smoothed interaction term which I have modelled below with the following
code:



surv.fit - coxph(my.surv ~ pspline(CONTINUOUS, df=0) + factor(DICHOTOMOUS)
+  pspline(CONTINUOUS, df=0)*factor(DICHOTOMOUS), data = datanew2)



and consequently I would like to obtain a smoothed plot of the hazard ratio
between treatment A and B on the y-axis with the continuous covariate on the
x-axis.  As termplot ignores interaction terms, I was wondering if anyone
has seen anything like this before and can advise on the best way to do it.




You have 2 problems.
 1. The pspline code's maximization routine simply can't cope with two terms that both 
have df=0, i.e., asking it to find the best degrees of freedom.  You have to choose df 
yourself.  (Making the code smarter has been on my TODO list for years, and will likely 
remain there a while longer.)


 2. What you want to do is harder than you think.  For definiteness assume that we have 
CONTINUOUS= age and DICHO= sex.  Then one wants a smooth curve of risk vs age for the 
males, and a separate one for the females.

For a smoothing spline, that means two penalties, one attached to each term.
   People get sloppy about the term interaction.  For two categorical variables what 
needs to be done is clear, namely to have one coefficient for each unique combination. 
Software will add the batch of coefficients for us automatically when a * is placed in 
the formula.  For continuous variables the use of * in a formula adds the product of the 
two terms, which is not an interaction except in very special circumstances.


  Between the two of these, an interaction times a pspline term is doomed to fail. 
(Another update for the package -- I need to print an error message in this case).


 Products of coefficients will work for ns() terms and an interaction.

Terry T.

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


Re: [R] Question about setdiff()

2014-06-02 Thread arun
Hi,
Please check this link:
http://r.789695.n4.nabble.com/meaning-of-asymmetric-on-help-page-for-intersect-td877408.html

union(setdiff(v,w), setdiff(w,v))


#or in this case

setdiff(union(v,w),intersect(v,w))
#or
 setdiff(c(v,w),c(v,w)[duplicated(c(v,w))])
A.K.


.pae...@gmail.com wrote:

Hello everyone, I have a question which is probably rooted in my lack
of understanding when it comes to math.

I just did the following:

v - c(1:20)
w - c(11:30)
setdiff(v, w)

and got:
1 2 3 4 5 6 7 8 9 10

Then I did the following:
setdiff(w, v)
and got, not surprisingly:
21 22 23 24 25 26 27 28 29 30

Now I was originally expecting to get bot with the first call of
setdiff(v, w) and couldn't find any reason not to expect this from
?setdiff()

Am I missing somethin vital here or does setdiff() always give me the
elements of the first set that are not in the second one and not those
which are exclusive to either one, just dropping the ones in the
intersection of both sets?

Many Thanks in advance

Raphael

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

2014-06-02 Thread Igor Sosa Mayor
laura tomé tomelaur...@yahoo.es writes:

 Hola,

 Estoy todavía dando mis primeros pasos en R y una de las cosas que
 tengo que hacer es trabajar con un csv de 16 GB. Consta de 10
 columnas, 7 númericas

escribe a la lista en español, que está aquí: 
https://stat.ethz.ch/mailman/listinfo/r-help-es

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


[R] Error clmm(){ordinal}

2014-06-02 Thread adesgroux
Dear all,

I am trying to run the function clmm() on a data table composed as following
:
http://r.789695.n4.nabble.com/file/n4691592/datatable.png 

I have 187 pea lines assessed on 4 years * 2 locations * 3 blocs * 15
plantes for disease resistance. Disease resistance is assessed with a 0-to-5
scale which made an ordinal variable.
Here is the script a wrote :

Tab.INRCh=read.csv(INRChamp201013.csv,sep=;)
Tab.INRCh$Year=as.factor(Tab.INRCh$Year)
Tab.INRCh$RRI-factor(Tab.INRCh$RRI,levels=c(5,4,3,2,1,0),ordered=TRUE)
Tab.INRCh$RRI_DHW1-factor(Tab.INRCh$RRI_DHW1,levels=c(5,4,3,2,1,0),ordered=TRUE)
Tab.INRCh$RRI_DHW2-factor(Tab.INRCh$RRI_DHW2,levels=c(5,4,3,2,1,0),ordered=TRUE)

Modele=clmm(RRI~Line+RRI_DHW1+RRI_DHW2+(1|Year)+(1|Location)+(1|Not)+(1|Bloc)+(1|Plante),data=Tab.INRCh,na.action=na.omit)

I want to create this modele to run function Anova() to know if disease
resistance is different among lines.

When I run the script, I have an error : 
Erreur : all(sapply(gfl, nlevels)  2) is not TRUE
I can't find anything about it on the internet...
Can someone help me on this?

Thanks
Best regards
Aurore



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

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


Re: [R] Error clmm(){ordinal}

2014-06-02 Thread Rune Haubo
It's telling you that one or more of the grouping factors for the
random-effect terms has less than three levels. From what you write,
this seems to apply to Location: you may want to treat it as a
fixed-effect instead.

Hope this helps,
Rune

On 2 June 2014 14:00, adesgroux aurore.desgr...@rennes.inra.fr wrote:
 Dear all,

 I am trying to run the function clmm() on a data table composed as following
 :
 http://r.789695.n4.nabble.com/file/n4691592/datatable.png

 I have 187 pea lines assessed on 4 years * 2 locations * 3 blocs * 15
 plantes for disease resistance. Disease resistance is assessed with a 0-to-5
 scale which made an ordinal variable.
 Here is the script a wrote :

Tab.INRCh=read.csv(INRChamp201013.csv,sep=;)
Tab.INRCh$Year=as.factor(Tab.INRCh$Year)
Tab.INRCh$RRI-factor(Tab.INRCh$RRI,levels=c(5,4,3,2,1,0),ordered=TRUE)
Tab.INRCh$RRI_DHW1-factor(Tab.INRCh$RRI_DHW1,levels=c(5,4,3,2,1,0),ordered=TRUE)
Tab.INRCh$RRI_DHW2-factor(Tab.INRCh$RRI_DHW2,levels=c(5,4,3,2,1,0),ordered=TRUE)

Modele=clmm(RRI~Line+RRI_DHW1+RRI_DHW2+(1|Year)+(1|Location)+(1|Not)+(1|Bloc)+(1|Plante),data=Tab.INRCh,na.action=na.omit)

 I want to create this modele to run function Anova() to know if disease
 resistance is different among lines.

 When I run the script, I have an error :
 Erreur : all(sapply(gfl, nlevels)  2) is not TRUE
 I can't find anything about it on the internet...
 Can someone help me on this?

 Thanks
 Best regards
 Aurore



 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Error-clmm-ordinal-tp4691592.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] Problem with rbind.fill

2014-06-02 Thread Bill Bentley
Thanks everyone.  These messages, especially Jorge's, helped me figure it
out.Apparently when the reshape package loaded, the plyr package didn't
and I didn't a) notice and more importantly b) didn't realize it needed to
be.   In researching it I did find out that the function is in the plyr
package and thought I had installed it too but guess I did it wrong.  Just
the normal problems of a beginner.  I'm also traveling and on a crappy
internet connection where half of everything I do on the web fails!

 

Bill

(sorry for the html in my original message.  I did read the rules but forgot
to do it)

 

 

From: Jorge I Velez [mailto:jorgeivanve...@gmail.com] 
Sent: Sunday, June 01, 2014 10:49 PM
To: Bill Bentley
Cc: R Help
Subject: Re: [R] Problem with rbind.fill

 

Hi Bill,

 

You need

 

require(plyr)

?rbind.fill

 

and then the rest of the code you already tried.

 

Best,

Jorge.-

 

On Mon, Jun 2, 2014 at 3:49 AM, Bill Bentley valuetr...@gmail.com wrote:

The following works as it should...

 both-rbind(females,males)

 both

  workshop gender q1 q2 q3 q4

11  f  1  1  5  1

22  f  2  1  4  1

31  f  2  2  4  3

51  m  4  5  2  4

62  m  5  4  5  5

82  m  4  5  5  5



Next I changed the objects males and females so they had different numbers
of variables and used rbind again and got an error which I expected.



 both - rbind(females, males)

Error in rbind(deparse.level, ...) :

  numbers of columns of arguments do not match



Next I attached the 'reshape' library and tried to use rbind.fill but as the
code below shows, it does NOT work.   The library seems to load ok (no error
message) and appears in the list when I use the library() command.



 library(reshape)

 both - rbind.fill(females, males)

Error: could not find function rbind.fill



The book I'm following does this the same way and it works for them.   I've
re-downloaded and installed the reshape package but to no avail.  Not sure
what to do.  Can't find an answer in help.  I'm a brand new R user.   Any
suggestions what I'm doing wrong?   Thanks!












[[alternative HTML version deleted]]

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

 


[[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] Bootstrapping Tukey Kramer:

2014-06-02 Thread Alexis Billings
Hi,

I have run a Tukey Kramer on my mixed effects models (using lmer). However,
I have non-normal data that can't really be transformed because it includes
negative numbers. So, I have opted to use a parametric bootstrap to deal
with the violation of the assumptions.

Here is my code for the mixed effects models and the parametric bootstraps,
which runs fine.

T.chicka.full-lmer(Chicka ~ Stimuli + Playback + (1|House) + (1|Season),
na.action=na.exclude, data=chick, REML = F)


T.chicka.null-lmer(Chicka ~ Playback + (1|House) + (1|Season), na.action=
na.exclude, data=chick, REML = F)


T.chicka.full

anova(T.chicka.null, T.chicka.full)


#BOOTSTRAPPING#

chicka.boot-numeric(1000)

for(i in 1:1000){

chicka.est - unlist(simulate(T.chicka.null))

null.chicka-lmer(chicka.est ~ 1 + (1|House[!is.na(chick$Chicka)]) + (1|
Season[!is.na(chick$Chicka)]), na.action=na.exclude, REML=F)

alt.chicka- lmer(chicka.est ~ Stimuli[!is.na(chick$Chicka)] + (1|House[!
is.na(chick$Chicka)]) + (1|Season[!is.na(chick$Chicka)]), na.action=
na.exclude, REML=F)

chicka.boot[i] - 2*(logLik(alt.chicka) - logLik(null.chicka))

}

(sum(chicka.boot  26.656) + 1)/1000 #p-value = 0.001

hist(chicka.boot)

However, I am trying to run a parametric bootstrap on my Tukey Kramer code,
but cannot figure out how to combine them. Below is my code for the Tukey
Kramer.

#TUKEYS#

comp.T.chicka - glht(T.chicka.full, linfct = mcp(Stimuli=Tukey))

print(summary(comp.T.chicka))


chick$stimuliplayback - interaction(chick$Stimuli, chick$Playback)

model.T.chicka - lmer(Chicka ~ stimuliplayback + (1|House) + (1|Season),
na.action=na.exclude, data=chick)

comp.stimuli.playback - glht(model.T.chicka, linfct=mcp(stimuliplayback=
Tukey))

summary(comp.stimuli.playback)


If anyone knows how to incorporate the Tukey Kramer code into the
parametric bootstrap code I would appreciate any help I can get.
Alternatively, if anyone has suggestions for another way to bootstrap Tukey
Kramer I would also be so appreciative.

Thank you!
A

-- 
Alexis Billings
PhD Candidate, Bioacoustics Lab
Organismal Biology and Ecology
Division of Biological Sciences
University of Montana

[[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] Time Series

2014-06-02 Thread wayne schlemitz

John:

The data that I sent you did you receive it? If so what thoughts or suggestions 
do you have for plotting the time series?

I am not sure what is going wrong and getting multi plot of same.

Thank you
Wayne Schlemitz
schmtz...@yahoo.com



On Saturday, May 24, 2014 11:34 AM, John Kane jrkrid...@inbox.com wrote:
 


No raw data.  Sent is as text (csv) or use dput() to include it in the email.

John Kane
Kingston ON Canada


 -Original Message-
 From: schmtz...@yahoo.com
 Sent: Fri, 23 May 2014 08:02:31 -0700 (PDT)
 To: r-help@r-project.org
 Subject: [R] Time Series
 
 Dear Sir:
 I am trying to plot a time series from the following code:
 
 test - read.table(/home/wayne/inr2a.txt, header = TRUE, quote=, sep
 = ;)
 x2 - ts(data=test, frequency = 80, start = c(2012,11), end = c(2014,5))
 plot.ts(x2, xlab=Date, ylab=Inr, main=X2 - Time Series,
 ylim=c(1.0,4.0),pch=16, col=black)
 
 What I get is multi plots that print 3x across the plot.
 
 Using R 2.15.2-1 on Ubuntu Natty
 Attached is the raw data.
 
 Thank you for any suggestions.
 Wayne
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


Protect your computer files with professional cloud backup.

Learn more at http://backup.pcrx.com/mail
[[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] testing and comparing transformations to get a gaussian distribution

2014-06-02 Thread Diederick Stoffers
Hi guys,

I distinctly remember having used an R toolbox that compared different 
transformation with regard to normality stats in the past, can’t find anything 
on google. Does anybody have a clue?

Thanks,

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


Re: [R] testing and comparing transformations to get a gaussian distribution

2014-06-02 Thread Greg Snow
There is the boxcox function in the MASS package that will look at the
Box Cox family of transformations.

On Mon, Jun 2, 2014 at 9:15 AM, Diederick Stoffers d.stoff...@gmail.com wrote:
 Hi guys,

 I distinctly remember having used an R toolbox that compared different 
 transformation with regard to normality stats in the past, can’t find 
 anything on google. Does anybody have a clue?

 Thanks,

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



-- 
Gregory (Greg) L. Snow Ph.D.
538...@gmail.com

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


[R] HAC standard errors

2014-06-02 Thread Nick Pretnar
Hello,

I am having a great amount of difficulty running a simple linear regression 
model with entity and time fixed effects and HAC standard errors. I have a data 
set with 3 million observations and 30 variables. My data is structured as 
follows:

NAMESTATE   YEARY   X1  X2
1   1   20121   1   1
2   1   20121   2   7
3   1   20121   1   2   
4   2   20122   4   5   

etc. ... For every state in every year, there are about 10,000 row vectors 
corresponding to individual observations. This is not a longitudinal dataset: 
an individual surveyed in year 2000 in state 1 is never spoken to again. 
Nonetheless, I still wish to control for geographical and time fixed effects. 
To do so, I run the following:

 load(data.frame.rda)
 library(sandwich)
 library(pcse)
 model - lm(data.frame$Y ~ data.frame$X1 + data.frame$X2 + 
 as.factor(data.frame$state) + as.factor(data.frame$year))
 vcovHAC(model, prewhite = FALSE, adjust = FALSE, sandwich = TRUE, ar.method = 
 ols)

R will not return any results, yet acts as if it is computing the results. This 
goes on for 4 hours or more. 

I wanted to run the following:

 library(pcse)
 model - lm(data.frame$Y ~ data.frame$X1 + data.frame$X2 + 
 as.factor(data.frame$state) + as.factor(data.frame$year))
 model.pcse - pcse(model, groupN = data.frame$state, groupT = data.frame$year)

But I get the error:
 Error in pcse(model, groupN = BRFSS_OBESEBALANCED$X_STATE, groupT = 
 BRFSS_OBESEBALANCED$YEAR) : 
  There cannot be more than nCS*nTS rows in the using data!

If there are any workarounds for this problem, I would greatly appreciate 
learning about them. 

Thanks,

Nicholas Pretnar
University of Missouri, Economics
npret...@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] Skipping .Rd files and using Org-mode instead?

2014-06-02 Thread Kevin Wright
Have you tried the roxygen2 package?

To speak as Rolf does, I usually f--k things up  by working with Rd files
directly (typically mismatched braces) and find that one really nice thing
about roxygen is that I don't have to mess with braces.

Kevin



On Sat, May 31, 2014 at 5:28 PM, Thorsten Jolitz tjol...@gmail.com wrote:

 Rolf Turner r.tur...@auckland.ac.nz writes:

  On 01/06/14 03:52, Thorsten Jolitz wrote:
 
  Hi List,
 
  it seems that .Rd files are just an intermediary format used for
  exporting to txt, html and latex when creating an R package.
 
  How flexible is the R package mechanism? Would it possible to skip .Rd
  files alltogether, write the docs with another tool (e.g. Emacs
  Org-mode), export them to txt, html and latex, and include these
  exported files in the package?
 
  Or does the R package mechanism simply expect the .Rd files to be there,
  so that there is no way avoiding the .Rd format?
 
  (1) I am not an expert, but my reading of Writing R Extension
  Packages indicates to me that, yes, .Rd format is necessary.

 I thought that too, but wasn't completely sure

  (2) Why would you want to fuck things up by dodging around .Rd (R
  documentation) files?  Amongst other things, these allow for
  consistency cross-checking by the package checking facility.

 Thats indeed a good reason to stick with the .Rd files

  (3) The .Rd syntax is easy to learn and quite powerful.  Get off your
  duff and learn it.

 .Rd syntax in not really intimidating, thats not the problem. Thanks for
 the answer anyway.

 --
 cheers,
 Thorsten

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




-- 
Kevin Wright

[[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 with polychoric correlation in psych library

2014-06-02 Thread Simon Kiss
Hello I have a data.frame of 32 variables, all are ordered factors. str(dat) 
returns the following
'data.frame':   32 obs. of  43 variables:
 $ q1a: Ord.factor w/ 6 levels Strongly Disagree..: 3 4 2 5 NA NA 5 5 3 5 ...
 $ q1b: Ord.factor w/ 6 levels Strongly Disagree..: 3 NA 4 NA NA NA NA 5 4 4 
...
 $ q1c: Ord.factor w/ 6 levels Strongly Disagree..: NA NA 5 5 NA 4 NA 5 NA 5 
...
 $ q1d: Ord.factor w/ 6 levels Strongly Disagree..: 5 NA 5 NA NA 5 NA 5 NA 4 
...
 $ q1e: Ord.factor w/ 6 levels Strongly Disagree..: 5 NA NA 5 5 NA NA 5 5 NA 
...
 $ q1f: Ord.factor w/ 6 levels Strongly Disagree..: 4 5 5 5 5 5 5 4 5 5 ...

I'm trying to come up with a polychoric correlation matrix for these, and so I 
convert them to numeric values:
'data.frame':   32 obs. of  43 variables:
 $ q1a: num  3 4 2 5 NA NA 5 5 3 5 ...
 $ q1b: num  3 NA 4 NA NA NA NA 5 4 4 ...
 $ q1c: num  NA NA 5 5 NA 4 NA 5 NA 5 ...
 $ q1d: num  5 NA 5 NA NA 5 NA 5 NA 4 ...

and try: 
library(psych)
polychoric(values, na.rm=TRUE), but this returns the following error


The items do not have an equal number of response alternatives, global set to 
FALSE
Error in poly[1, ] : incorrect number of dimensions
In addition: Warning message:
In mclapply(seq_len(n), do_one, mc.preschedule = mc.preschedule,  :
  all scheduled cores encountered errors in user code

Can anyone provide any guidance?
Thanks, Simon Kiss

*
Simon J. Kiss, PhD
Assistant Professor, Wilfrid Laurier University
73 George Street
Brantford, Ontario, Canada
N3T 2C9
Cell: +1 905 746 7606

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


Re: [R] Skipping .Rd files and using Org-mode instead?

2014-06-02 Thread Charles Berry
Kevin Wright kw.stat at gmail.com writes:

 
 Have you tried the roxygen2 package?
 

I have.

org-mode + roxygen2 + inline is what was used to make this package:

http://www.bioconductor.org/packages/release/bioc/html/geneRxCluster.html

Everything from the DESCRIPTION file to the C-code to the vignette reside 
in a single org-mode file. Tangling and running a few src-blocks to 
roxygenize() (the documentation and other directives) and to create the
.Call() wrappers (for the C-code) creates the package. 

(I exported the vignette using org-ravel --- that's another story.)

---

And if it isn't obvious from what Kevin said, something like this:

#+BEGIN_SRC R :tangle foo.R :dir path-to-package-R-dir
  ##' foo, but not bar
  ##'
  ##' execute the identity op
  ##' @title foo
  ##' @param x any variable
  ##' @return the input value unaltered
  ##' @author Mee Myself Andaye
  foo -
  function(x) x
#+END_SRC


will serve as a start. `M-x ess-roxy-update-entry' will generate a 
template for all the comment lines, which roxygen2 uses to create Rd and 
other package components.

When in a src-edit buffer, ESS has a bunch of ess-roxy-* functions, like 
ess-roxy-update-entry to generate the template, and ess-roxy-preview-* to 
see how things render. Pulldown the ESS-Roxygen menu to see some good 
choices.

HTH,

Chuck

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


Re: [R] Help with polychoric correlation in psych library

2014-06-02 Thread William Revelle
Simon,
As is usually the case with problems with a package, if you write the 
author/maintainer, you are more likely to get an answer.

In this case, I just happened to be readiing R-help (t is the end of the term 
and I am relaxing).

I am happy to look at this if you would send me the data set.

What version of the psych package are you using?



Bill

On Jun 2, 2014, at 3:49 PM, Simon Kiss sjk...@gmail.com wrote:

 Hello I have a data.frame of 32 variables, all are ordered factors. str(dat) 
 returns the following
 'data.frame': 32 obs. of  43 variables:
 $ q1a: Ord.factor w/ 6 levels Strongly Disagree..: 3 4 2 5 NA NA 5 5 3 5 
 ...
 $ q1b: Ord.factor w/ 6 levels Strongly Disagree..: 3 NA 4 NA NA NA NA 5 4 
 4 ...
 $ q1c: Ord.factor w/ 6 levels Strongly Disagree..: NA NA 5 5 NA 4 NA 5 NA 
 5 ...
 $ q1d: Ord.factor w/ 6 levels Strongly Disagree..: 5 NA 5 NA NA 5 NA 5 NA 
 4 ...
 $ q1e: Ord.factor w/ 6 levels Strongly Disagree..: 5 NA NA 5 5 NA NA 5 5 
 NA ...
 $ q1f: Ord.factor w/ 6 levels Strongly Disagree..: 4 5 5 5 5 5 5 4 5 5 ...
 
 I'm trying to come up with a polychoric correlation matrix for these, and so 
 I convert them to numeric values:
 'data.frame': 32 obs. of  43 variables:
 $ q1a: num  3 4 2 5 NA NA 5 5 3 5 ...
 $ q1b: num  3 NA 4 NA NA NA NA 5 4 4 ...
 $ q1c: num  NA NA 5 5 NA 4 NA 5 NA 5 ...
 $ q1d: num  5 NA 5 NA NA 5 NA 5 NA 4 ...
 
 and try: 
 library(psych)
 polychoric(values, na.rm=TRUE), but this returns the following error
 
 
 The items do not have an equal number of response alternatives, global set to 
 FALSE
 Error in poly[1, ] : incorrect number of dimensions
 In addition: Warning message:
 In mclapply(seq_len(n), do_one, mc.preschedule = mc.preschedule,  :
  all scheduled cores encountered errors in user code
 
 Can anyone provide any guidance?
 Thanks, Simon Kiss
 
 *
 Simon J. Kiss, PhD
 Assistant Professor, Wilfrid Laurier University
 73 George Street
 Brantford, Ontario, Canada
 N3T 2C9
 Cell: +1 905 746 7606
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 

William Revellehttp://personality-project.org/revelle.html
Professor  http://personality-project.org
Department of Psychology   http://www.wcas.northwestern.edu/psych/
Northwestern Universityhttp://www.northwestern.edu/
Use R for psychology http://personality-project.org/r
It is 5 minutes to midnighthttp://www.thebulletin.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] Conditional mean for groups, new variables

2014-06-02 Thread arun
Hi,
If you want to extract only particular variables, check ?subset, ?Extract.
Using my first example:
aggregate(MATH~SCHOOLID,rev1, mean)[,-1,drop=FALSE]
#  MATH
#1 14.5
#2 17.2
#3 13.71429
#4 13.8
# more than one variable
res1 - 

aggregate(rev1[,-1], list(SCHOOLID=rev1[,1]), mean,na.rm=TRUE) ##Column1 is 
SCHOOLID
res1New - res1[,-1] 
res1New
#  MATH  AGE   STO2Q01  BFMJ BMMJ
#1 14.5 10.5 15.50  8.00 14.0
#2 17.2  7.6 10.20 18.60 12.8
#3 13.71429 17.28571  9.142857  9.857143 17.85714
#4 13.8 15.3 13.67 11.67 11.0
#or
 res1[!grepl(SCHOOLID, colnames(res1))]
A.K.


I tried to explain all the things that I want to do in this picture :) Sorry, 
if it's not so understandable, but I tried :) 




On Monday, June 2, 2014 4:02 AM, arun smartpink...@yahoo.com wrote:


Hi,
Regarding your first comment, you didn't provide any reproducible example. So I 
created one with SCHOOLID's as alphabets.  According to your original post, you 
had a read dataset with 36000 SCHOOLIDs.  Suppose, if I created the SCHOOLIDs 
using:
 length(outer(LETTERS,1:2000,paste,sep=))
#[1] 52000

#Please note that I am creating only 6 columns as an example
set.seed(42)
rev1 - data.frame(SCHOOLID = sample(outer(LETTERS,1:1000,paste,sep=),36e3, 
replace=TRUE), matrix(sample(180, 36e3*5,replace=TRUE), ncol=5, 
dimnames=list(NULL, c(MATH, AGE, STO2Q01, BFMJ, 
BMMJ))),stringsAsFactors=FALSE)      
 dim(rev1)
#[1] 36000 6


res1 - aggregate(rev1[,-1], list(SCHOOLID=rev1[,1]), mean,na.rm=TRUE)
 dim(res1)
#[1] 26010 6
 head(res1,2)
# SCHOOLID  MATH AGE STO2Q01 BFMJ BMMJ
#1   A1 107.5  30    41.5   75  149
#2 A100 159.5 132   107.0   66   15
colMeans(rev1[rev1$SCHOOLID==A1,-1])
#   MATH AGE STO2Q01    BFMJ    BMMJ 
#  107.5    30.0    41.5    75.0   149.0 


#I am not following the second statement.  Please provide a reproducible 
example using ?dput().
May be you want results in this form:

rev2 - data.frame(SCHOOLID=rev1[,1], sapply(rev1[-1],function(x) ave(x, 
rev1[,1], FUN= mean, na.rm=TRUE)))

A.K.


I'm sorry, but it does not :(
It gives results maximum only for first 26 schools (according to the number of 
letters in the alphabet). And according to the result it counts not an avreage 
values of the factors. 





On Sunday, June 1, 2014 8:37 PM, arun smartpink...@yahoo.com wrote:
Hi,
May be this helps:


set.seed(42)
rev1 - data.frame(SCHOOLID=sample(LETTERS[1:4],20,replace=TRUE), 
matrix(sample(25, 20*5,replace=TRUE), ncol=5, dimnames=list(NULL, c(MATH, 
AGE, STO2Q01, BFMJ, BMMJ))),stringsAsFactors=FALSE)  
res1 - aggregate(rev1[,-1], list(SCHOOLID=rev1[,1]), mean,na.rm=TRUE)
res1
#if you need to change the names
res2 - setNames(aggregate(rev1[,-1], list(SCHOOLID=rev1[,1]), 
mean,na.rm=TRUE), c(SCHOOLID, paste(colnames(rev1)[-1], MEAN,sep=_)))
res2

A.K.


Hello! I have a problem, I want to calculate conditional mean for my dataset. 
First, I attach it:
rev-read.csv(MATH1.csv, header=T, sep=;, dec=,)
attach(rev)
I have 65 observations (test score) and 36000 groups (schoolid)
I need to calculate the mean for every group (schoolid) for the all my 
variables (MATH, AGE, ST02Q01,BFMJ,BMMJ. Actually, I have 34 varables, I just 
don't want to list them here)  and then to create new variables for obtained 
new columns, because I want to estimate a new regression for the new obtained 
average values.
The following method is not appropriate for me, because it gives me in result a 
table with schoolid and the average for one variables, and I don't know how to 
extract the MATH coulmn with average values from the table with results to the 
worklist separately(environment).
aggregate( MATH~SCHOOLID, rev, mean)
How can I solve this problem? Thank for help!

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


Re: [R-es] Encontrar un comando

2014-06-02 Thread rubenfcasal
Hola Marta,

 No me quedó muy claro lo que quieres, pero entiendo que tienes una 
base de datos (codeBoats o DBx) que quieres filtrar. Tienes que dar 
mas información sobre la base de datos y las variables, ¿cuál es la 
variable que tiene las artes de pesca? gears?, ¿cómo están codificadas 
las artes de pesca?
 Los resultados de la función str() aplicada a la base de datos en 
cuestión pueden ser de ayuda...

 Un saludo,
 Rubén FC

El 02/06/2014 12:57, Marta valdes lopez escribió:
 Hola¡¡

 Tengo un script que estoy leyendo pero no se que comando tengo que utilizar
 para que aparezca la informacion que quiero.Tengo unas licencias de barcos
 y cuando he leido el archivo de licencias me gustaria saber el comando para
 que me aparezcan los tipos de artes de pesca para yo elegir sobre los que
 quiero trabajar.Probe con levels (gears) pero nada.
 Envio el script que he leido hasta ahora aver si alguien puede ayudarme.

 #Select boats by gear actaul gears in database:   MOVED to the beginning
 #NotLic; not licensed
 #PLL; pelagic longline
 #BLL; bottom longline
 #BLL / PLL; bottom and pelagic longline
 #BLL / HL; bottom longlineand handline
 #PoleLine; pole and line for tuna
 #Troll; trolling
 #PoleLine / PLL / BLL / Traps; all gears
 #OUT; out of the fihsing fleet
 codeBoats- read.csv(E:/My Documents/Telmo/7_AZORES work/Fishing
 effort/DB/ALL/CODES_2002-2010New.csv, sep=,,header=TRUE)
 #Laptop
codeBoats$CODIGO-gsub(^\\s+|\\s+$, , codeBoats$CODIGO)
   #Assigning a Fishing license based on Boat and Year
DBx$gear-codeBoats$Lic[match(paste(DBx$Boat,DBx$Year),
 paste(codeBoats$CODIGO,codeBoats$Year))]
  #ddd- DBx[DBx$calcSpeed %in% NA,]
  # z-length(ddd$gear)
z0-length(DBx$gear)

 AQUI seria donde quisiera que aparecieran las artes y yo poder elegir el
 poleline para solo trabajar con esa arte.
 No se si me he explicado bien..si hay algo que no esta claro preguntarme.

 Muchas gracias, un saludo

   [[alternative HTML version deleted]]



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


[[alternative HTML version deleted]]

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


Re: [R-es] Compilación de un archivo C en R.

2014-06-02 Thread JOSE ALBERTO CANDELARIA BARRERA

Muchas gracias Daniel

Ha funcionado la rutina desde otro ordenador.

Un saludo
Alberto


daniel daniel...@gmail.com dijo:


José Alberto,

Me parece que el mensaje de error es de Windows y no de R. ¿Se abre alguna
ventana de Windows con mas detalles sobre el error? ¿Tienes todos los
programas sobre los cuales fuzzyC_main.dll dependa? ¿lo intentaste en algún
otro ordenador, preferentemente con otro OS? ¿estas seguro que todos los
programas involucrados sean para 64 bits?

Suerte,

Daniel Merino


El 2 de junio de 2014, 11:31, JOSE ALBERTO CANDELARIA BARRERA 
jocan...@est-econ.uc3m.es escribió:


Buenas tardes

Es la primera ocasión que escribo en este foro de dudas sobre R y les
quiero comentar mi problema.

Tengo un archivo fuzzyC_main.c que está escrito en C y lo he logrado
compilar por medio del comando  R CMD SHLIB fuzzyC_main.c obteniendo dos
archivos:

fuzzyC_main.o and fuzzyC_main.dll

La cuestión es que cuando uso el comand dyn.load(fuzzyC_main.dll) en R
me envía el siguiente errorÑ

 dyn.load(fuzzyC_main.dll)



Error en inDL(x, as.logical(local), as.logical(now), ...) :  unable to
load shared object 'E:/MBAQM-Subjects/GA/Fuzzy_Code/fuzzyC_main.dll':
 LoadLibrary failure:  %1 no es una aplicación Win32 válida.

No entiedo porqué me dice que no es una aplicación Win32 válida (mi OS es
Windows a 64 bits). Lo que yo tengo en mi path es lo siguiente:

C:\Windows\system32;C:\Windows;C:\Windows\System32\
Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files
(x86)\MiKTeX 2.9\miktex\bin\;C:\Program 
Files\MATLAB\R2010a\runtime\win64;C:\Program
Files\MATLAB\R2010a\bin;C:\Program Files 
(x86)\QuickTime\QTSystem\;C:\Rtools\bin;

C:\R\Tcl\bin; C:\Rtools\MinGW\bin; C:\Program Files\R\R-3.1.0\bin\x64;
C:\Program Files\RStudio\bin\x64; C:\Program Files\R\R-3.0.2\bin\x64;
C:\Program Files\R\R-3.0.3\bin\x64

Será conveniente que borre los directorios que dicen System32? Alguien
ayudeme por favor.

Un cordial saludo.
Alberto
--
Universidad Carlos III de Madrid

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





--
Daniel





--
Universidad Carlos III de Madrid

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


Re: [R-es] Compilación de un archivo C en R.

2014-06-02 Thread daniel
Me alegro,

Por lo tanto. falta en el primer ordenador algún dll en versión 64 bits que
necesita fuzzyC_main.dll y que  esta presente en el segundo.

Daniel Merino


El 2 de junio de 2014, 14:20, JOSE ALBERTO CANDELARIA BARRERA 
jocan...@est-econ.uc3m.es escribió:

 Muchas gracias Daniel

 Ha funcionado la rutina desde otro ordenador.

 Un saludo
 Alberto


 daniel daniel...@gmail.com dijo:


  José Alberto,

 Me parece que el mensaje de error es de Windows y no de R. ¿Se abre alguna
 ventana de Windows con mas detalles sobre el error? ¿Tienes todos los
 programas sobre los cuales fuzzyC_main.dll dependa? ¿lo intentaste en
 algún
 otro ordenador, preferentemente con otro OS? ¿estas seguro que todos los
 programas involucrados sean para 64 bits?

 Suerte,

 Daniel Merino


 El 2 de junio de 2014, 11:31, JOSE ALBERTO CANDELARIA BARRERA 
 jocan...@est-econ.uc3m.es escribió:

  Buenas tardes

 Es la primera ocasión que escribo en este foro de dudas sobre R y les
 quiero comentar mi problema.

 Tengo un archivo fuzzyC_main.c que está escrito en C y lo he logrado
 compilar por medio del comando  R CMD SHLIB fuzzyC_main.c obteniendo dos
 archivos:

 fuzzyC_main.o and fuzzyC_main.dll

 La cuestión es que cuando uso el comand dyn.load(fuzzyC_main.dll) en R
 me envía el siguiente errorÑ

  dyn.load(fuzzyC_main.dll)


  Error en inDL(x, as.logical(local), as.logical(now), ...) :  unable to
 load shared object 'E:/MBAQM-Subjects/GA/Fuzzy_Code/fuzzyC_main.dll':
  LoadLibrary failure:  %1 no es una aplicación Win32 válida.

 No entiedo porqué me dice que no es una aplicación Win32 válida (mi OS es
 Windows a 64 bits). Lo que yo tengo en mi path es lo siguiente:

 C:\Windows\system32;C:\Windows;C:\Windows\System32\
 Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files
 (x86)\MiKTeX 2.9\miktex\bin\;C:\Program Files\MATLAB\R2010a\runtime\
 win64;C:\Program
 Files\MATLAB\R2010a\bin;C:\Program Files (x86)\QuickTime\QTSystem\;C:\
 Rtools\bin;
 C:\R\Tcl\bin; C:\Rtools\MinGW\bin; C:\Program Files\R\R-3.1.0\bin\x64;
 C:\Program Files\RStudio\bin\x64; C:\Program Files\R\R-3.0.2\bin\x64;
 C:\Program Files\R\R-3.0.3\bin\x64

 Será conveniente que borre los directorios que dicen System32? Alguien
 ayudeme por favor.

 Un cordial saludo.
 Alberto
 --
 Universidad Carlos III de Madrid

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




 --
 Daniel




 --
 Universidad Carlos III de Madrid




-- 
Daniel

[[alternative HTML version deleted]]

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