[R] exp / log scaled version of cut?

2022-02-03 Thread Fredrik Karlsson
Dear list,

For tasks involving people its often good to work with ages in exp or log
scale, since either not much or very much happens in the first 10 years of
life, and much less (or much more) happens the following years. For tables
with age range summary statistics, I sometimes would like to have a
function that would for instance cut a range of values into breaks exp()
scale equidistance bins, but with unconverted values in the labels.

Similar to the way log / exp scaling of figure axis tick marks work, but
with a factor returned.

i have not been able to find such a function. Is there one?

Thanks!

Fredrik Karlsson


-- 
"Life is like a trumpet - if you don't put anything into it, you don't get
anything out of it."

[[alternative HTML version deleted]]

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


Re: [R] Variable labels

2021-05-13 Thread Fredrik Karlsson
Hi,

I am sorry but I don't understand your question, Generally, "clicking" is
not something you can assume to be implemented for anything in R.
However, if you read the manual for the package

 https://gdemin.github.io/expss/

you get an example at the bottom where an illustration of how the package
can be used to create Excel tables which would then be easy to interact
with through clicking.
Is that what you wanted?

Fredrik

On Thu, May 13, 2021 at 4:49 AM Steven Yen  wrote:

> I insert variable with the expss function as shown below. No error
> message. My question is, how to save the variable labels in the data
> frame so that I can click to read the labels. Thank you.
>
> mydata<-read_excel("data/Excel/hseinv.xlsx",na=".")
> library(expss)
> mydata=apply_labels(mydata,
>  year   ="1947-1988",
>  inv="real housing inv, millions $",
>  pop="population, 1000s",
>  price  ="housing price index; 1982 = 1",
>  linv   ="log(inv)",
>  lpop   ="log(pop)",
>  lprice  ="log(price)",
>  t   ="time trend: t=1,...,42",
>  invpc   ="per capita inv: inv/pop",
>  linvpc  ="log(invpc)",
>  lprice_1="lprice[_n-1]",
>  linvpc_1="linvpc[_n-1]",
>  gprice  ="lprice - lprice_1",
>  ginvpc  ="linvpc - linvpc_1")
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>


-- 
"Life is like a trumpet - if you don't put anything into it, you don't get
anything out of it."

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
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 loop in folders

2020-04-25 Thread Fredrik Karlsson
Hi,

I am sorry if I am misunderstanding what you are trying to do here, but can
you simplify it this way?
 (unfortualtely, this is untested since I dont have a suitable set of files
and a directory structure to test against)

dbifiles <- list.files(pattern="*.dbi",recursive=TRUE)

csvfiles <- gsub("dbi$","csv",dbifiles)

for(i in seq_along(csvfiles)){

df <- read.dbf(dbfiles[i])

write.csv( df, file =csvfiles[i])

}

or something along these lines?

Fredrik

On Fri, Apr 24, 2020 at 4:08 PM Shubhasmita Sahani <
shubhasmita.sah...@gmail.com> wrote:

> Hi Everyone,
> I am trying to loop through the folders in the major working directory.
> Read the dbf file into the data frame then save the data frame as CSV file
> in another folder.
> For this, I have written this code, But not able to figure out where it is
> going wrong. Any ideas will be of great support.
>
>
>  setwd(choose.dir())
>  csvpath= "C:/plan/Learning/dummydata/csv/"
>  a<-list.dirs()
>  inpath<-"C:/workplan/Q2/Project1"
>
>  for (folder in list.dirs()[-1]) {
>
>path<-setwd(paste0("inpath",folder))
>dbf<-list.files(path, pattern = "*ward.dbf")
>df <- read.dbf(dbf)
>dbfname<-basename(dbf)
>name<-file_path_sans_ext(dbfname)  # get the name of the file like
> agra_ward
>write.csv( df, file = paste0("csvpath",name,"csv"))
>print(path)
>
>  }
>
>
>
>
>
> --
> Thanks & Regards,
> Shubhasmita Sahani
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>


-- 
"Life is like a trumpet - if you don't put anything into it, you don't get
anything out of it."

[[alternative HTML version deleted]]

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


Re: [R] Creating Dummy Var in R for regression?

2016-08-08 Thread Fredrik Karlsson
Hi,

please also have a look at the 'cut' function.Very handa function for these
types of situations.

Best,

Fredrik

On Sun, Aug 7, 2016 at 8:10 PM, Shivi Bhatia  wrote:

> Thank you Jeremiah and all others for the assistance. This really helped.
>
> On Sat, Aug 6, 2016 at 5:01 AM, jeremiah rounds 
> wrote:
>
> > Something like:
> >
> > d  =  data.frame(score = sample(1:10, 100, replace=TRUE))
> > d$score_t = "low"
> > d$score_t[d$score > 3] = "medium"
> > d$score_t[d$score >7 ] = "high"
> > d$score_t = factor(d$score_t, levels = c("low", "medium", "high"),
> > ordered=TRUE)  #set ordered = FALSE for dummy variables
> > X = model.matrix(~score_t, data=d)
> > X
> >
> >
> >
> > On Fri, Aug 5, 2016 at 3:23 PM, Shivi Bhatia 
> wrote:
> >
> >> Thanks you all for the assistance. This really helps.
> >>
> >> Hi Bert: While searching nabble i got to know R with factors variables
> >> there is no need to create dummy variable. However please consider this
> >> situation:
> >> I am in the process of building a logistic regression model on NPS data.
> >> The outcome variable is CE i.e. customer experience which has 3 rating
> so
> >> ordinal logistic regression will be used. However most of my variables
> are
> >> categorical. For instance one of the variable is agent knowledge which
> is
> >> a
> >> 10 point scale.
> >>
> >> This agent knowledge is again a 3 rated scale: high medium low hence i
> >> need
> >> to group these 10 values into 3 groups & then as you suggested i can
> >> directly enter them in the model without creating n-1 categories.
> >>
> >> I have worked on SAS extensively hence found this a bit confusing.
> >>
> >> Thanks for the help.
> >>
> >> On Sat, Aug 6, 2016 at 2:30 AM, Bert Gunter 
> >> wrote:
> >>
> >> > Just commenting on the email subject, not the content (which you have
> >> > already been helped with): there is no need to *ever* create a dummy
> >> > variable for regression in R if what you mean by this is what is
> >> > conventionally meant. R will create the model matrix with appropriate
> >> > "dummy variables" for factors as needed. See ?contrasts and ?C for
> >> > relevant details and/or consult an appropriate R tutorial.
> >> >
> >> > Of course, if this is not what you meant, than ignore.
> >> >
> >> > Cheers,
> >> > Bert
> >> >
> >> >
> >> > Bert Gunter
> >> >
> >> > "The trouble with having an open mind is that people keep coming along
> >> > and sticking things into it."
> >> > -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
> >> >
> >> >
> >> > On Fri, Aug 5, 2016 at 1:49 PM,   wrote:
> >> > > Hello,
> >> > >
> >> > > Your ifelse will never work because
> >> > > reasons$salutation== "Mr" & reasons$salutation=="Father" is always
> >> FALSE
> >> > > and so is reasons$salutation=="Mrs" & reasons$salutation=="Miss".
> >> > > Try instead | (or), not & (and).
> >> > >
> >> > > Hope this helps,
> >> > >
> >> > > Rui Barradas
> >> > >
> >> > >
> >> > >
> >> > > Citando Shivi Bhatia :
> >> > >
> >> > >> Dear Team,
> >> > >>
> >> > >> I need help with the below code in R:
> >> > >>
> >> > >> gender_rec<- c('Dr','Father','Mr'=1, 'Miss','MS','Mrs'=2, 3)
> >> > >>
> >> > >> reasons$salutation<- gender_rec[reasons$salutation].
> >> > >>
> >> > >> This code gives me the correct output but it overwrites the
> >> > >> reason$salutation variable. I need to create a new variable gender
> to
> >> > >> capture gender details and leave salutation as it is.
> >> > >>
> >> > >> i tried the below syntax but it is converting all to 1.
> >> > >>
> >> > >> reasons$gender<- ifelse(reasons$salutation== "Mr" &
> >> reasons$salutation==
> >> > >> "Father","Male", ifelse(reasons$salutation=="Mrs" &
> >> > reasons$salutation==
> >> > >> "Miss","Female",1))
> >> > >>
> >> > >> Please suggest.
> >> > >>
> >> > >> [[alternative HTML version deleted]]
> >> > >>
> >> > >> __
> >> > >> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> >> > >> https://stat.ethz.ch/mailman/listinfo/r-help
> >> > >> PLEASE do read the posting guide
> >> > >> http://www.R-project.org/posting-guide.htmland provide commented,
> >> > >> minimal, self-contained, reproducible code.
> >> > >
> >> > >
> >> > >
> >> > > [[alternative HTML version deleted]]
> >> > >
> >> > > __
> >> > > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> >> > > https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
> >> 

[R] L1 penalized regression fails to predict from model

2016-06-20 Thread Fredrik Karlsson
Dear list,

Sorry for this cross-post from StackOverflow, but I see that SO was maybe
the wrong forum for this question. Too package specific and

Ok, what I am trying to do is to predict from an L1 penalized regression.
This falls due to a data set dimension problem that I cannot figure out.

The procedure I'm using is the following:

require(penalized)# neg contains negative data# pos contains positive data

Now, the procedure below aims to construct comparable (balanced in terms os
positive and negative cases) training and validation data sets.

# 50% negative training set
negSamp <- neg %>% sample_frac(0.5) %>% as.data.frame()# Negative validation set
negCompl <- neg[setdiff(row.names(neg),row.names(negSamp)),]# 50%
positive training set
posSamp <- pos %>% sample_frac(0.5) %>% as.data.frame()# Positive validation set
posCompl <- pos[setdiff(row.names(pos),row.names(posSamp)),]# Combine sets
validat <- rbind(negSamp,posSamp)
training <- rbind(negCompl,posCompl)

Ok, so here we now have two comparable sets.

[1] FALSE  TRUE> dim(training)[1] 1061  381> dim(validat)[1] 1060
381> identical(names(training),names(validat))[1] TRUE

I fit the model to the training set without a problem (and I've tried using
a range of Lambda1 values here). But, fitting the model to the validation
data set fails, with a just odd error description.

> fit <- 
> penalized(VoiceTremor,training[-1],data=training,lambda1=40,standardize=TRUE)#
>  nonzero coefficients: 13> fit2 <- predict(fit, penalized=validat[-1], 
> data=validat)
Error in .local(object, ...) :
  row counts of "penalized", "unpenalized" and/or "data" do not match

Just to make sure that this is not due to some NA's in the data set:

> identical(validat,na.omit(validat))[1] TRUE

Oddly enough, I may generate some new data that is comparable to the proper
data set:

> data.frame(VoiceTremor="NVT",matrix(rnorm(38),nrow=1000,ncol=380) ) -> neg
> data.frame(VoiceTremor="VT",matrix(rnorm(38),nrow=1000,ncol=380) ) -> 
> pos> dim(pos)[1] 1000  381> dim(neg)[1] 1000  381

and run the procedure above, and then the prediction step works!

How come?

What could be wrong with my second (not training) data set?

Fredrik

-- 
"Life is like a trumpet - if you don't put anything into it, you don't get
anything out of it."

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] ggplot: geom_line with only pairs of points connected

2012-12-12 Thread Fredrik Karlsson
Dear list,

I've been using plotmeans {gplots} a lot before, and found the
connect argument to be quite useful.
I've moved to ggplot for several reasons, but would still like to
connect lines conditionally, somehow.
Is it possible to do?

Small example:

df - data.frame(cat=LETTERS[1:4],num=rnorm(4))
ggplot(df, aes(x=cat, y=num)) + geom_point()  +
geom_line(aes(x=as.numeric(cat), y=num))

In this plot, I would like to be able to make the second line (the one
between B and C) not be there.

What I've come up with is this (instead using geom_segment):

df - data.frame(cat=LETTERS[1:4],num=rnorm(4))
dfdf 
-cbind(df[seq(from=1,by=2,along.with=df),],df[seq(from=2,by=2,along.with=df),])
names(dfdf) - c(cat,num,cat2,num2)
ggplot(df, aes(x=cat, y=num)) + geom_point()  +
geom_segment(aes(x=cat,xend=cat2,y=num,yend=num2),data=dfdf)

Hoewever, in a more extended example (where df is more complex and
also contains factors used for grouping and faceting) this becomes a
bit cumbersome.

Is there a better way to do this?

/Fredrik

--
Life is like a trumpet - if you don't put anything into it, you don't
get anything out of it.

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


Re: [R] Math labels in .eps files

2012-06-05 Thread Fredrik Karlsson
Dear Professor Ripley,

Thank you for your prompt answer. Indeed, cairo_ps solved the problem for me.

Thank you!

Fredrik 

5 jun 2012 kl. 11:51 skrev Prof Brian Ripley rip...@stats.ox.ac.uk:

 On 04/06/2012 17:25, Fredrik Karlsson wrote:
 Dear list,
 
 I have non-ascii labels that I want to include somethow in a .eps file for
 inclusion into a LateX document. Is this possible?
 
 What I see is that the (attached)  png file looks ok but the .eps renders
 all non-ascii labels at the bottom as [..].
 
 
 I've searched around enough to learn that including math labels in a .eps
 is a problem. Hower, is there a solution too somewhere?
 
 I don't think it is a problem: see ?plotmath.  But the problem here is that 
 you seem to want glyphs not in the plotmath set.
 
 You have neither told us your platform nor the R code you used (as requested 
 in the posting guide), so we cannot reproduce this.  But see ?postscript and 
 its section 'Encodings'.  You need to specify a PostScript encoding which 
 contains your glyphs ... if there is one. Note too
 
 See Also:
 
 ‘cairo_ps’ for another device that can produce PostScript.
 
 -- 
 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] Using ddply within a function by argument transfer

2012-03-06 Thread Fredrik Karlsson
Dear list,

A follow up on this thread - the solution I ended up with does indeed
involve parse().
However, it does the job, and it is more efficient than what I came up with
in my other attempts.


suspicious.vowels - function(data,factors,vowelcolumn,f1,f2) {


  for(currfac in c(factors,vowelcolumn,f1,f2)){
if(!currfac %in% names(data)){
  stop(Factor ',currfac,' does not exist in the data frame. Please
provide only valid column names.)
}
  }
   # The dirty hack!
facs - paste(factors,collapse=,)
mycall -
paste(ddply(data,.(,facs,),summarize,norms=vector.space(,f1,,,f2,)[[3]],angles=vector.space(,f2,,,f2,)[[4]]),sep=)
nADatap - parse(text=mycall)
nAData - eval(nADatap))
.
}

However, if anyone would like to weigh in with a more structured solution,
I would very much appreciate the opportunity to learn how this _should_
really be done.

/Fredrik

On Mon, Mar 5, 2012 at 2:11 AM, David Winsemius dwinsem...@comcast.netwrote:


 On Mar 4, 2012, at 6:28 PM, Fredrik Karlsson wrote:

  Hi Joshua,

 Yes, sorry - I attached an .rda file - maybe it was squashed.


 The old version of the Posting Guide warned readers that only 'txt' files
 and 'pdf's would be acceptable attachments. I think the new modified Guide
 is less specific. You could ahve posted the output of dput on the object
 and given it an extension of .txt so that your email client would have
 labeled it properly at the right mime-type.

 --

 David Winsemius, MD
 West Hartford, CT




-- 
Life is like a trumpet - if you don't put anything into it, you don't get
anything out of it.

[[alternative HTML version deleted]]

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


Re: [R] Using ddply within a function by argument transfer

2012-03-04 Thread Fredrik Karlsson
Hi,

Sorry all - I will provide a reproducable version of this. I am still
seeing the same problem - maybe it is due to me having to use summarize?
Anyway, here is an example (using the data set attached):

Two test functions:

insidefun - function(x){

  return(x+1)
}

testfun - function(data,factors,x){

  datOrig - ddply(.data=data,
   .variables=as.quoted(factors),
   .fun=summarize,
   norm=insidefun(x)
   )

}

 testfun(pb,c(Type,Sex,Speaker),F1)
Error in insidefun(x) : object 'x' not found

Now, if I call ddply directly, it works:

 head(ddply(pb,.(Type,Sex,Speaker),summarize,norm=insidefun(F1)),4)
  Type Sex Speaker norm
1c   f  62  461
2c   f  62  401
3c   f  62  601
4c   f  62  611

I'm sure I'm doing something stupid - and of course I see that the ddply call
inside the function will have to do some processing in order to get the
arguments in the right mode/class - but I don't know how.

/Fredrik




On Sun, Mar 4, 2012 at 6:44 AM, David Winsemius dwinsem...@comcast.netwrote:


 On Mar 4, 2012, at 12:20 AM, Fredrik Karlsson wrote:

  Hi Michael,

 No, sorry - that is neither the problem or the solution.

  suspicious.vowels(pb,c(Type,**Sex,Vowel),F1,F2)

 Error in mean(y, na.rm = na.rm) : object 'f1' not found


 Obviously you have still failed to offer reproducible code to go along
 wiht your questions, but I would observe that in R that f1 is NOT going to
 equal F1.

 --


 /Fredrik

 On Sat, Mar 3, 2012 at 7:04 PM, R. Michael Weylandt 
 michael.weyla...@gmail.com wrote:

  Untested, but it might be simpler than that:

 suspicious.vowels(pb,c(Type,**Sex,Vowel),F1,F2)

 Note that F1 is in quotes but F2 isn't.

 Michael

 On Sat, Mar 3, 2012 at 5:46 PM, Fredrik Karlsson dargo...@gmail.com
 wrote:

 Dear list,

 Sorry, but I cannot get my head around how and I could pass arguments

 along

 to high-level functions. What I have is a function that would benefit

 from

 me using ddply from the plyr package.
 However, I cannot get the arguments passing part right.

 So, this is my function:

  suspicious.vowels -

 function(data,factors,f1,f2,**evaluate.original.params=TRUE) {

 datOrig - ddply(.data=data,
  .variables=as.quoted(factors),
  .fun=summarize,
  norm=vector.space(f1,f2)[[**Vector norms]]
  )


 print(datOrig)

 }

 Of course, if I try to call this function, I get an error message
 telling
 me that the f1 argument does not exist:

  suspicious.vowels(pb,c(Type,**Sex,Vowel),F1,F2)

 Error in mean(y, na.rm = na.rm) : object 'f1' not found

 However, the corresponding ddply call, when called from the console,
 does
 work:



  head(ddply(pb,as.quoted(c(**Type,Sex,Vowel)),**
 summarize,norm=vector.space(**F1,F2)[[Vector

 norms]]),4)
 Type Sex Vowel norm
 1c   faa 250.1570
 2c   faa 497.2711
 3c   faa 172.3108
 4c   faa 109.4464
 ...

 So, how do I modify the function to pass the arguments that I supply
 correctly? I cannot get my head around this enough to find the correct
 combination of deparse /substitute /... to get this right.

 I would be thankful for all the help I could get on this.

 /Fredrik

 --
 Life is like a trumpet - if you don't put anything into it, you don't

 get

 anything out of it.

  [[alternative HTML version deleted]]

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

 http://www.R-project.org/**posting-guide.htmlhttp://www.R-project.org/posting-guide.html

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





 --
 Life is like a trumpet - if you don't put anything into it, you don't get
 anything out of it.

[[alternative HTML version deleted]]

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


 David Winsemius, MD
 West Hartford, CT




-- 
Life is like a trumpet - if you don't put anything into it, you don't get
anything out of it.
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Using ddply within a function by argument transfer

2012-03-04 Thread Fredrik Karlsson
Hi Joshua,

Yes, sorry - I attached an .rda file - maybe it was squashed.
Anyway, yes, I agree with you that the function in the present state would
not be of very much help to an end user (and your right in thinking that
this is not the end implementation of the function, just an example). I too
cannot find a combination of candidate functions that work.
What I need is the ability for the user to specify the columns in data to
be processed by ddply and the data frame itself. So far I have not been
able to do this using ddply - I guess I'll have to roll my own using for
loops and data frame subsetting or something similar.

Thank you for trying!

/Fredrik

On Sun, Mar 4, 2012 at 12:50 PM, Joshua Wiley jwiley.ps...@gmail.comwrote:

 Hi,

 Still no data (either not attached or a format the mail server
 scrubs), but I made some up.  ddply seems to be a bit tricky in that
 it holds off evaluating its arguments.  I honestly am not sure how to
 get around that---no amount of fancy footwork with eval() or quote()
 is going to change the internals of ddply.  The easiest approach seems
 to be to change the call to it in the first place.  You cannot do this
 by passing arguments, but you can by using subsitute() to have your
 test function construct and then evaluate the ddply() call.  Here is a
 working example:

 require(plyr)

 pb - data.frame(Type = sample(6, 30, TRUE),
 Sex = sample(0:1, 30, TRUE),
 Speaker = sample(3, 30, TRUE),
 F1 = rnorm(30))

 insidefun - function(x){
  return(x+1)
 }

 testfun - function(data, factors, x, fun = quote(summarize)) {
  arglist - list(data = data, factors = as.quoted(factors), fun = fun, x =
 x)
  myd - substitute(ddply(.data=data,
.variables=factors, .fun = fun, norm = x), arglist)
  out - eval(myd)
  return(out)
 }

 testfun(pb, c(Type,Sex,Speaker), x = quote(insidefun(F1)))

 By the way, in its present state, this is essentially a painfully
 complex wrapper to ddply and your code would probably be less buggy
 and easier to understand just using ddply, but presumably you are
 planning to have some other stuff go on in the real testfun().

 Cheers,

 Josh

 On Sun, Mar 4, 2012 at 9:06 AM, Fredrik Karlsson dargo...@gmail.com
 wrote:
  Hi,
 
  Sorry all - I will provide a reproducable version of this. I am still
  seeing the same problem - maybe it is due to me having to use summarize?
  Anyway, here is an example (using the data set attached):
 
  Two test functions:
 
  insidefun - function(x){
 
   return(x+1)
  }
 
  testfun - function(data,factors,x){
 
   datOrig - ddply(.data=data,
.variables=as.quoted(factors),
.fun=summarize,
norm=insidefun(x)
)
 
  }
 
  testfun(pb,c(Type,Sex,Speaker),F1)
  Error in insidefun(x) : object 'x' not found
 
  Now, if I call ddply directly, it works:
 
  head(ddply(pb,.(Type,Sex,Speaker),summarize,norm=insidefun(F1)),4)
   Type Sex Speaker norm
  1c   f  62  461
  2c   f  62  401
  3c   f  62  601
  4c   f  62  611
 
  I'm sure I'm doing something stupid - and of course I see that the ddply
 call
  inside the function will have to do some processing in order to get the
  arguments in the right mode/class - but I don't know how.
 
  /Fredrik
 
 
 
 
  On Sun, Mar 4, 2012 at 6:44 AM, David Winsemius dwinsem...@comcast.net
 wrote:
 
 
  On Mar 4, 2012, at 12:20 AM, Fredrik Karlsson wrote:
 
   Hi Michael,
 
  No, sorry - that is neither the problem or the solution.
 
   suspicious.vowels(pb,c(Type,**Sex,Vowel),F1,F2)
 
  Error in mean(y, na.rm = na.rm) : object 'f1' not found
 
 
  Obviously you have still failed to offer reproducible code to go along
  wiht your questions, but I would observe that in R that f1 is NOT going
 to
  equal F1.
 
  --
 
 
  /Fredrik
 
  On Sat, Mar 3, 2012 at 7:04 PM, R. Michael Weylandt 
  michael.weyla...@gmail.com wrote:
 
   Untested, but it might be simpler than that:
 
  suspicious.vowels(pb,c(Type,**Sex,Vowel),F1,F2)
 
  Note that F1 is in quotes but F2 isn't.
 
  Michael
 
  On Sat, Mar 3, 2012 at 5:46 PM, Fredrik Karlsson dargo...@gmail.com
  wrote:
 
  Dear list,
 
  Sorry, but I cannot get my head around how and I could pass arguments
 
  along
 
  to high-level functions. What I have is a function that would benefit
 
  from
 
  me using ddply from the plyr package.
  However, I cannot get the arguments passing part right.
 
  So, this is my function:
 
   suspicious.vowels -
 
  function(data,factors,f1,f2,**evaluate.original.params=TRUE) {
 
  datOrig - ddply(.data=data,
   .variables=as.quoted(factors),
   .fun=summarize,
   norm=vector.space(f1,f2)[[**Vector norms]]
   )
 
 
  print(datOrig)
 
  }
 
  Of course, if I try to call this function, I get an error message
  telling
  me that the f1 argument does not exist:
 
   suspicious.vowels(pb,c(Type,**Sex,Vowel),F1,F2)
 
  Error in mean(y

[R] Using ddply within a function by argument transfer

2012-03-03 Thread Fredrik Karlsson
Dear list,

Sorry, but I cannot get my head around how and I could pass arguments along
to high-level functions. What I have is a function that would benefit from
me using ddply from the plyr package.
However, I cannot get the arguments passing part right.

So, this is my function:

 suspicious.vowels -
function(data,factors,f1,f2,evaluate.original.params=TRUE) {

  datOrig - ddply(.data=data,
.variables=as.quoted(factors),
.fun=summarize,
norm=vector.space(f1,f2)[[Vector norms]]
)


  print(datOrig)

}

Of course, if I try to call this function, I get an error message telling
me that the f1 argument does not exist:

 suspicious.vowels(pb,c(Type,Sex,Vowel),F1,F2)
Error in mean(y, na.rm = na.rm) : object 'f1' not found

However, the corresponding ddply call, when called from the console, does
work:


head(ddply(pb,as.quoted(c(Type,Sex,Vowel)),summarize,norm=vector.space(F1,F2)[[Vector
norms]]),4)
  Type Sex Vowel norm
1c   faa 250.1570
2c   faa 497.2711
3c   faa 172.3108
4c   faa 109.4464
...

So, how do I modify the function to pass the arguments that I supply
correctly? I cannot get my head around this enough to find the correct
combination of deparse /substitute /... to get this right.

I would be thankful for all the help I could get on this.

/Fredrik

-- 
Life is like a trumpet - if you don't put anything into it, you don't get
anything out of it.

[[alternative HTML version deleted]]

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


Re: [R] Using ddply within a function by argument transfer

2012-03-03 Thread Fredrik Karlsson
Hi Michael,

No, sorry - that is neither the problem or the solution.

 suspicious.vowels(pb,c(Type,Sex,Vowel),F1,F2)
Error in mean(y, na.rm = na.rm) : object 'f1' not found


/Fredrik

On Sat, Mar 3, 2012 at 7:04 PM, R. Michael Weylandt 
michael.weyla...@gmail.com wrote:

 Untested, but it might be simpler than that:

 suspicious.vowels(pb,c(Type,Sex,Vowel),F1,F2)

 Note that F1 is in quotes but F2 isn't.

 Michael

 On Sat, Mar 3, 2012 at 5:46 PM, Fredrik Karlsson dargo...@gmail.com
 wrote:
  Dear list,
 
  Sorry, but I cannot get my head around how and I could pass arguments
 along
  to high-level functions. What I have is a function that would benefit
 from
  me using ddply from the plyr package.
  However, I cannot get the arguments passing part right.
 
  So, this is my function:
 
  suspicious.vowels -
  function(data,factors,f1,f2,evaluate.original.params=TRUE) {
 
   datOrig - ddply(.data=data,
 .variables=as.quoted(factors),
 .fun=summarize,
 norm=vector.space(f1,f2)[[Vector norms]]
 )
 
 
   print(datOrig)
 
  }
 
  Of course, if I try to call this function, I get an error message telling
  me that the f1 argument does not exist:
 
  suspicious.vowels(pb,c(Type,Sex,Vowel),F1,F2)
  Error in mean(y, na.rm = na.rm) : object 'f1' not found
 
  However, the corresponding ddply call, when called from the console, does
  work:
 
 
 
 head(ddply(pb,as.quoted(c(Type,Sex,Vowel)),summarize,norm=vector.space(F1,F2)[[Vector
  norms]]),4)
   Type Sex Vowel norm
  1c   faa 250.1570
  2c   faa 497.2711
  3c   faa 172.3108
  4c   faa 109.4464
  ...
 
  So, how do I modify the function to pass the arguments that I supply
  correctly? I cannot get my head around this enough to find the correct
  combination of deparse /substitute /... to get this right.
 
  I would be thankful for all the help I could get on this.
 
  /Fredrik
 
  --
  Life is like a trumpet - if you don't put anything into it, you don't
 get
  anything out of it.
 
 [[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.




-- 
Life is like a trumpet - if you don't put anything into it, you don't get
anything out of it.

[[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] Multiple comparisons of lme model - interactions?

2012-02-10 Thread Fredrik Karlsson
Dear list,

Please excuse my ignorance, but I'm trying to model some data using the lme
package. vot is a numeric response, and condition, location and obs are all
categories.
This works:

 anova(vot.lme - lme(vot ~ condition * location *
obs,data=mergedCodesL,random= ~1 |patient))
   numDF denDF  F-value p-value
(Intercept)1  1898 462.7519  .0001
condition  2  1898   8.4126  0.0002
location   112   0.0272  0.8718
obs2  1898 472.5526  .0001
condition:location 2  1898   1.0467  0.3513
condition:obs  4  1898   1.0683  0.3706
location:obs   2  1898   9.7067  0.0001
condition:location:obs 4  1898   4.6143  0.0010


If I then would like to do post-hoc testing, I found in the email archives
that I could use the glht function of multcomp - something like

summary(glht(vot.lme, linfct=mcp(obs = Tukey)))

However, if I would like to investigate the condition:location:obs -
interaction. What do I do then?


Best!

/Fredrik
-- 
Life is like a trumpet - if you don't put anything into it, you don't get
anything out of it.

[[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] Finding suspicious data points?

2012-01-26 Thread Fredrik Karlsson
Dear list,

I would like to find data points that at least should be checked one more
time before I process them further.
I've had a look at the outliers package for this, and the outliers function
in that package, but it appears to only return one value.

An example:

 outlier(c(1:3,rnorm(1000,mean=10,sd=300)))
[1] 1

I think at least 1,2 and 3 should be checked in this case.


Any ideas on how to achieve this in R?

Actually, the real data I will be investigating consist of vector norms and
angles (in an attempt to identify either very short, very long vectors, or
vectors pointing in an odd angle for the category to which it has been
assigned) so a 2D method would be even better.

I would much appreciate any help I can get on this,

/Fredrik



-- 
Life is like a trumpet - if you don't put anything into it, you don't get
anything out of it.

[[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] Constructing an additional key inside of a lattice panel

2011-08-18 Thread Fredrik Karlsson
Dear Deepayan,

Thank you for your quick and enlightening reply. I'll try making a modifies
version of the two functions and see what I end up with..

However, out of pure curiosity, what is wrong with the legend I
constructed below:

   legend=list(corner=list(
 fun=draw.key,
 args=list(
   key=list(text=
 list(myFactorLevels),
 lines=list(
   lty=1:length(myFactorLevels))
 ),
   draw=TRUE
   )
 ),x=0,y=1

It gives me nothing (not even an error message :-)), so I have no idea about
what I did wrong here.

I would very much appreciate any insight on this.

/Fredrik


On Wed, Aug 17, 2011 at 2:57 PM, Deepayan Sarkar
deepayan.sar...@gmail.comwrote:

 On Tue, Aug 16, 2011 at 4:35 PM, Fredrik Karlsson dargo...@gmail.com
 wrote:
  Hi,
 
  I would like to add an additional key inside of a panel based on a factor
  that is not the groups argument.
  I've tried using the panel.key function in latticeExtras, but I cannot
 get
  the line types the way I want it.
 
  Using my factor myGroups, I've tried this:
 
  panel.key(text=levels(myGroups),lines=TRUE,points=FALSE,corner =
  c(0,.98),key=list(lines=list(lty=1:length(levels(myGroups)
 
  I then get the key where I want it, the text is right, but line types are
  not correct (always lty=1, I think).
 
  Any ideas on how I could solve this?

 Well, trying to add undocumented arguments and hoping they will
 magically work usually doesn't help.

 panel.key() works using simpleKey(), which by design is simple but not
 flexible. In particular, it will not allow you to set 'lty' directly,
 and instead use the values from the theme currently in use.

 You _can_ change the theme also, using a different argument; e.g.,

 library(lattice)
 library(latticeExtra)

 xyplot(1 ~ 1,
   panel = function(...) {
   panel.xyplot(...)
   panel.key(text = month.name[1:2],lines=TRUE,points=FALSE,
 corner = c(0,.98))
   },
   par.settings = simpleTheme(lty = 1:2))

 But I don't know if that interferes with the rest of your call.

 If all else fails, panel.key() is not a very complicated function, so
 you can take inspiration from it and write your own version that
 replaces the line

key - simpleKey(text, ...)

 with

key - something else

 where something else describes the legend that you want.

 -Deepayan




-- 
Life is like a trumpet - if you don't put anything into it, you don't get
anything out of it.

[[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] Constructing an additional key inside of a lattice panel

2011-08-17 Thread Fredrik Karlsson
Dear list,

following up on my own post, I have now started trying constructing a
legend argument to xyplot that would work, based on the examples in
Sarkar's book.

I'm now at a state where I have a legend that does not throw an error, but
no legend is displayed:


   legend=list(corner=list(
 fun=draw.key,
 args=list(
   key=list(text=
 list(myFactorLevels),
 lines=list(
   lty=1:length(myFactorLevels))
 ),
   draw=TRUE
   )
 ),x=0,y=1



Where myFactorLevels contains the levels I want displayed (e.i. the levels
of myGroups in my previous attempt).

Please, why is this legend not displayed?

/Fredrik

On Tue, Aug 16, 2011 at 1:05 PM, Fredrik Karlsson dargo...@gmail.comwrote:

 Hi,

 I would like to add an additional key inside of a panel based on a factor
 that is not the groups argument.
 I've tried using the panel.key function in latticeExtras, but I cannot get
 the line types the way I want it.

 Using my factor myGroups, I've tried this:

 panel.key(text=levels(myGroups),lines=TRUE,points=FALSE,corner =
 c(0,.98),key=list(lines=list(lty=1:length(levels(myGroups)

 I then get the key where I want it, the text is right, but line types are
 not correct (always lty=1, I think).

 Any ideas on how I could solve this?



 /Fredrik



 --
 Life is like a trumpet - if you don't put anything into it, you don't get
 anything out of it.




-- 
Life is like a trumpet - if you don't put anything into it, you don't get
anything out of it.

[[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] Constructing an additional key inside of a lattice panel

2011-08-16 Thread Fredrik Karlsson
Hi,

I would like to add an additional key inside of a panel based on a factor
that is not the groups argument.
I've tried using the panel.key function in latticeExtras, but I cannot get
the line types the way I want it.

Using my factor myGroups, I've tried this:

panel.key(text=levels(myGroups),lines=TRUE,points=FALSE,corner =
c(0,.98),key=list(lines=list(lty=1:length(levels(myGroups)

I then get the key where I want it, the text is right, but line types are
not correct (always lty=1, I think).

Any ideas on how I could solve this?



/Fredrik



-- 
Life is like a trumpet - if you don't put anything into it, you don't get
anything out of it.

[[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] current.panel.limits() of lattice returning NaN limits - why?

2011-08-12 Thread Fredrik Karlsson
Hi,

I need a custom axis function for a plot, but it seems
that current.panel.limits() sometimes returns NaN limits for the plot, which
it much harder to calculate anything sensible.
An illustration:

Given this axis function:


vs.axis - function(...){
   xlim - current.panel.limits()$xlim
   ylim - current.panel.limits()$ylim

   # Debug code
   print(list(ylim=ylim,xlim=xlim))

   xat - pretty(seq(xlim[1],xlim[2],100),n=5)
   yat - pretty(seq(ylim[1],ylim[2],100),n=4)
   xlab - sub(-,,as.character(xat))
   ylab - sub(-,,as.character(yat))
   panel.axis(side=top,at=xat,labels=xlab)
   panel.axis(side=right,at=yat,labels=ylab)
}

and the attached data set, I get this output:

 xyplot(F1 ~F2,data=pb,axis=vs.axis)
$ylim
[1] NaN NaN

$xlim
[1]  346.5 3823.5

Error in if (del == 0  to == 0) return(to) :
  missing value where TRUE/FALSE needed

What's wrong? Is there a more robust way of getting the x- and y- limits?

/Fredrik

-- 
Life is like a trumpet - if you don't put anything into it, you don't get
anything out of it.
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Passing on groups argument to xyplot within a plotting function

2011-08-11 Thread Fredrik Karlsson
Hi,

I am constructing a plotting function that I would like to behave like
plotting functions within the lattice package. It takes a groups argument,
which I process, and then I would like to pass that argument on to the
xyplot function for the actual plotting. However, what ever I do, get an
error that the variable is missing.

A short illustration:

Given the data set

 names(pb)
[1] TypeSex Speaker Vowel   IPA F0  F1
[8] F2  F3

and these test functions:

TESTFUN - function(x,data,groups){

  xyplot(x,data=data,groups=groups)
}

TESTFUN2 - function(x,data,groups){

  xyplot(x,data=data,groups=substitute(groups))
}

TESTFUN3 - function(x,data,groups){
  groups - eval(substitute(groups), data, environment(x))

  xyplot(x,data=data,groups=groups)
}

I fail to get groups to be passed on to xyplot correctly:

 TESTFUN(F1 ~ F2,data=pb,groups=Type)
Error in eval(expr, envir, enclos) : object 'groups' not found
 TESTFUN2(F1 ~ F2,data=pb,groups=Type)
Error in prepanel.default.function(groups = groups, x = c(2280L, 2400L,  :
  object 'groups' not found
 TESTFUN3(F1 ~ F2,data=pb,groups=Type)
Error in eval(expr, envir, enclos) : object 'groups' not found

Please help me understand what I am doing wrong.

/Fredrik

-- 
Life is like a trumpet - if you don't put anything into it, you don't get
anything out of it.

[[alternative HTML version deleted]]

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


[R] How do I make proper use of the by() function?

2011-06-10 Thread Fredrik Karlsson
Dear list,

I have a function that uses values from two vectors  and spits out one new
vector  based on all the values of the two original vectors, and with the
same length as them.
Ok, I would now like to be able to apply that function simply on two columns
in a data frame, divided by the levels of factors in the data frame.

I'm trying to use by() for this, but the output is too hard to use. What I
am doing is this:

by(df, list(df$Factor1,df$Factor2),function(x)
my_function(x$col1,x$col2),simplify=TRUE)

and the output is too complex to be used in a simple way. Actually, I just
want something like a data frame, where the results vectors are placed in
one column and the conditions under which they were produced (i.e. the
values of the factors according to which the data set were divided) in other
columns.

This does not seem to be provided by by(), and aggregate only provides me
with the ability to use values from one column, right?
So, are there other functions I could use?

Thanks!

/Fredrik

-- 
Life is like a trumpet - if you don't put anything into it, you don't get
anything out of it.

[[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] Display data.frame as tree?

2011-05-17 Thread Fredrik Karlsson
Dear list,

I have a data.frame with aggregated frequencies of occurrence of two-way
(and in one case three-way) features in my observations. Like this:


location condition transient fricationmrallvoiced  correctstop
vpresent frequency
1   STNPOSTON  TRUE FALSE FALSE FALSETRUE
 FALSE11
2   STN   POSTOFF FALSE  TRUE FALSE FALSE   FALSE
TRUE23
3   cZi   POSTOFF FALSE  TRUE FALSE FALSE   FALSE
TRUE34
4   STNPOSTON FALSE  TRUE FALSE FALSE   FALSE
TRUE23
5   cZiPOSTON FALSE  TRUE FALSE FALSE   FALSE
TRUE22

For visualisation, I would like to show this data as a (classification) tree
(if possible). Like this:


/\
location  STN cZi
 / \  \  / \  \
condition  PRE OFF ON PRE OFF ON
/\ /\  /\  /\  /\  /\


.. and so on (I'm sure you get the idea) with frequencies in the leaves.

Is there any way to do this already? Just thought I'd ask before I  dive
into one of the many tree drawing packages out there or roll my own in
graphviz.

Thank you!

/Fredrik


-- 
Life is like a trumpet - if you don't put anything into it, you don't get
anything out of it.

[[alternative HTML version deleted]]

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


[R] How to reshape wide format data.frame to long format?

2011-01-20 Thread Fredrik Karlsson
Dear list,

I need to convert this data.frame

 names(codesM)
 [1] keyAMR.pa1.M  AMR.pa2.M  AMR.pa3.M  AMR.pa4.M
 [6] AMR.pa5.M  AMR.pa6.M  AMR.pa7.M  AMR.pa8.M  AMR.pa9.M
[11] AMR.pa10.M AMR.ta1.M  AMR.ta2.M  AMR.ta3.M  AMR.ta4.M
[16] AMR.ta5.M  AMR.ta6.M  AMR.ta7.M  AMR.ta8.M  AMR.ta9.M
[21] AMR.ta10.M AMR.ka1.M  AMR.ka2.M  AMR.ka3.M  AMR.ka4.M
[26] AMR.ka5.M  AMR.ka6.M  AMR.ka7.M  AMR.ka8.M  AMR.ka9.M
[31] AMR.ka10.M SMR.pa1.M  SMR.pa2.M  SMR.pa3.M  SMR.pa4.M
[36] SMR.pa5.M  SMR.pa6.M  SMR.pa7.M  SMR.pa8.M  SMR.pa9.M
[41] SMR.pa10.M SMR.ta1.M  SMR.ta2.M  SMR.ta3.M  SMR.ta4.M
[46] SMR.ta5.M  SMR.ta6.M  SMR.ta7.M  SMR.ta8.M  SMR.ta9.M
[51] SMR.ta10.M SMR.ka1.M  SMR.ka2.M  SMR.ka3.M  SMR.ka4.M
[56] SMR.ka5.M  SMR.ka6.M  SMR.ka7.M  SMR.ka8.M  SMR.ka9.M
[61] SMR.ka10.M
 dim(codesM)
[1] 42 61

into a 3 x  2501 data.frame where the key variable is kept, the
values in columns 2-61 above is inserted into a values column and
the name of the column is inserted in a third column (variable
perhaps).

Like

key variable  value
POSTOFF_1_1AMR.pa1.M   5
POSTOFF_1_1AMR.pa2.M   3


I think I should be able to do this using the reshape function, but
I cannot get it to work. I think I need some help to understand
this...


(If I could split the variable into three separate columns splitting
by ., that would be even better.)

I appreciate all the help I could get.

/Fredrik

-- 
Life is like a trumpet - if you don't put anything into it, you don't
get anything out of it.

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


Re: [R] Any way to apply TWO functions with tapply()?

2010-05-07 Thread Fredrik Karlsson
Hi,

What you can do is define your own function which takes a vector of
values, computes the statistics you want and then returns a string
which displays the output the way you want it. Then use this function
in your tapply call.

like (untested)

mySummary - function(x) {

  paste(mean(x),sd(x),sep=,)

}

tapply(data$response, list(data$targets, data$conditions) ,mySummary)

Of course, if you need a different output format, then you'll have to
adapt the paste call.

/Fredrik

On Fri, May 7, 2010 at 11:39 AM, Phil Wieland phw...@gmx.de wrote:

 I need to compute the mean and the standard deviation of a data set and would
 like to have the results in one table/data frame. I call tapply() two times
 and do then merge the resulting tables to have them all in one table. Is
 there any way to tell tapply() to use the functions mean and sd within one
 function call? Something like tapply(data$response, list(data$targets,
 data$conditions), c(mean, sd)).

 Thanks in advance.
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Any-way-to-apply-TWO-functions-with-tapply-tp2133924p2133924.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.




-- 
Life is like a trumpet - if you don't put anything into it, you don't
get anything out of it.

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


Re: [R] Converting dollar value (factors) to numeric

2010-05-05 Thread Fredrik Karlsson
Hi,

Something similar to this maybe?

 test - as.factor($111.11)
 test
[1] $111.11
Levels: $111.11
 as.numeric(substring(as.character(test),2))
[1] 111.11

To be applied to your data.frame columns.

/Fredrik

On Wed, May 5, 2010 at 9:16 AM, Wang, Kevin (SYD) kevinw...@kpmg.com.au wrote:
 Hi,

 I'm trying to read in a bunch of CSV files into R where many columns are
 coded like $111.11.  When reading them in they are treated as factors.

 I'm wondering if there is an easy way to convert them into numeric in R
 (as I don't want to modify the source data)?  I've done some searches
 and can't seem to find an easy way to do this.

 I apologise if this is a trivial question, I haven't been using R for a
 while.

 Many thanks in advance!

 Cheers

 Kev

 Kevin Wang
 Senior Advisor, Health and Human Services Practice
 Government Advisory Services

 KPMG
 10 Shelley Street
 Sydney  NSW  2000  Australia

 Tel   +61 2 9335 8282
 Fax   +61 2 9335 7001

 kevinw...@kpmg.com.au

 Protect the environment: think before you print




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




-- 
Life is like a trumpet - if you don't put anything into it, you don't
get anything out of it.

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


[R] Best option for exporting data frame to SPSS?

2009-09-01 Thread Fredrik Karlsson
Dear list,

I am leaving my old position and now need to convert my R data frames
into a format that can be used by an SPSS user replacing me, without
running into conversion problems.
The data set consists of strings in UTF8 encoding and values in double
precision floats. The data set is not terribly large, but I had bit
problems getting it into R due to the large number of unfortunate
characters in the strings (', #,  and so on) so I was just wondering
if there is any way to get the data into a SPSS friendly format (other
than tab-separated files) so that a minimum of conversion is done in
between the two systems.
A data base file (SQLite) would be ideal, but unfortunatelly, I don't
think the recieving end would be able to handle it, i.e. get the data
into SPSS.

Sorry for asking this on the list, but I have found lots of
information about getting data safelly _into_ R in the archive, but
far les about exporting data out of R.

Please give me your best tip.

/Fredrik

 --
Life is like a trumpet - if you don't put anything into it, you don't
get anything out of it.

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


[R] Surpress one panel in lattice plot..?

2009-08-23 Thread Fredrik Karlsson
Dear list,

I have a two character vector with two different values in them (two
each, that is). Naturally, when I use these vectors as grouping
factors in a lattice plot, I get four panels.
Now, one of the possible four combinations will never have data, so
one panel will always be empty. So now my question is: can I force R /
Lattice not to print it, and give me only the 3 filled panels?

I have tried adding layout=c(3,1) to the list of arguments, but that
gives me one plot that looks like I want it to, and then a new plot
with just the empty panel. I use this in an odfWeave document, so just
getting the last (empty) plot in the output is not really what I want.

I do of course appreciate all the help I can get on this.

/Fredrik

-- 
Life is like a trumpet - if you don't put anything into it, you don't
get anything out of it.

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


Re: [R] Selecting groups with R

2009-08-21 Thread Fredrik Karlsson
Hi John,

I would guess that your Color column is a factor, with three levels
(RED,BLUE,WHITE), which means that they will all be included in
the output of a table() call, even if they are empty. Try

dataset - transform(dataset, Color=as.character(Color))

or something similar and then create the table.

/Fredrik

On Fri, Aug 21, 2009 at 11:08 PM, jlwoodardjohn.wood...@wayne.edu wrote:

 I have a data set similar to the following:

 Color  Score
 RED      10
 RED      13
 RED      12
 WHITE   22
 WHITE   27
 WHITE   25
 BLUE     18
 BLUE     17
 BLUE     16

 and I am trying to to select just the values of Color that are equal to RED
 or WHITE, excluding the BLUE.

 I've tried the following:
 myComp1-subset(dataset, Color ==RED | Color == WHITE)
 myComp1-subset(dataset, Color != BLUE)
 myComp1-dataset[which(dataset$Color != BLUE),]

 Each of the above lines successfully excludes the BLUE subjects, but the
 BLUE category is still present in my data set; that is, if I try
 table(Color)  I get

 RED  WHITE  BLUE
 82     151      0

 If I try to do a t-test (since I've presumably gone from three groups to two
 groups), I get:
 Error in if (stderr  10 * .Machine$double.eps * max(abs(mx), abs(my)))
 stop(data are essentially constant) :
  missing value where TRUE/FALSE needed
 In addition: Warning message:
 In mean.default(y) : argument is not numeric or logical: returning NA

 and describe.by(score,Color) gives me descriptives for RED and WHITE, and
 BLUE also shows up as NULL.

 How can I eliminate the BLUE category completely so I can do a t-test using
 Color (with just the RED and WHITE subjects)?

 Many thanks in advance!!

 John



 --
 View this message in context: 
 http://www.nabble.com/Selecting-groups-with-R-tp25088073p25088073.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.




-- 
Life is like a trumpet - if you don't put anything into it, you don't
get anything out of it.

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


Re: [R] Stata file Import and Analysis in R

2009-06-29 Thread Fredrik Karlsson
Hi,

You should install the foreign package and try the read.dta function.
I don't know whether the size of your fiel will be a problem, but you
would try it at least.

/Fredrik


On Mon, Jun 29, 2009 at 1:58 PM, saurav pathakpathak.sau...@gmail.com wrote:
 Hi
 I have a  stata data set (.dta file) of size 600 MB, I need to import it in
 R and do a 2SLS multilevel analysis on the data set. I would eb grateful if
 help is provided for the first part of how to import this big file from
 Stata to R and then how to open the imported Stata file in R?
 Kindly help
 Thanks in advance

 --
 Dr.Saurav Pathak
 PhD, Univ.of.Florida
 Mechanical Engineering
 Doctoral Student
 Innovation and Entrepreneurship
 Imperial College Business School
 s.patha...@imperial.ac.uk
 0044-7795321121

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




-- 
Life is like a trumpet - if you don't put anything into it, you don't
get anything out of it.

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


[R] How do I get just the two last tokens of each string in a vector?

2009-06-26 Thread Fredrik Karlsson
Dear list,

Sorry for asking this very silly question on the list, but I seem to
have made my life complicated by going into string manipulation in
vectors.
What I need is to get the last part of a sting (the two last tokens,
separated by a space), and of course, this should be done for all
strings in a vector, creating a new vector of exual size.

So,

a - c( %L H*L L*H H%, %L H* H%,  %L L*H %,   %L L*H % )

should be made into a vector

 c( L*H H%, H* H%,  L*H %,   L*H % )

I have tried strsplit, but it seems to produce a structure I cannot
get to work in this context. Any ideas on how to solve this?

Thankful for all the help I can get.

/Fredrik


-- 
Life is like a trumpet - if you don't put anything into it, you don't
get anything out of it.

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


Re: [R] How do I get just the two last tokens of each string in a vector?

2009-06-26 Thread Fredrik Karlsson
HI Jim,

Thank you! Works perfectly.

/Fredrik

On Fri, Jun 26, 2009 at 1:00 PM, jim holtmanjholt...@gmail.com wrote:
 This should do it

 a - c( %L H*L L*H H%, %L H* H%,  %L L*H %,   %L L*H % )
 # split the strings
 x - strsplit(a, ' ')
 # get last two tokens
 sapply(x, function(.tokens) paste(tail(.tokens, 2), collapse=' '))
 [1] L*H H% H* H%  L*H %  L*H %




 On Fri, Jun 26, 2009 at 7:21 AM, Fredrik Karlsson dargo...@gmail.com
 wrote:

 Dear list,

 Sorry for asking this very silly question on the list, but I seem to
 have made my life complicated by going into string manipulation in
 vectors.
 What I need is to get the last part of a sting (the two last tokens,
 separated by a space), and of course, this should be done for all
 strings in a vector, creating a new vector of exual size.

 So,

 a - c( %L H*L L*H H%, %L H* H%,  %L L*H %,   %L L*H % )

 should be made into a vector

  c( L*H H%, H* H%,  L*H %,   L*H % )

 I have tried strsplit, but it seems to produce a structure I cannot
 get to work in this context. Any ideas on how to solve this?

 Thankful for all the help I can get.

 /Fredrik


 --
 Life is like a trumpet - if you don't put anything into it, you don't
 get anything out of it.

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



 --
 Jim Holtman
 Cincinnati, OH
 +1 513 646 9390

 What is the problem that you are trying to solve?




-- 
Life is like a trumpet - if you don't put anything into it, you don't
get anything out of it.

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


[R] Lattice group colors?

2009-06-22 Thread Fredrik Karlsson
Dear list,

I have been struggling to find how I would go about changing the
bakground colors of groups in a lattice barchart in a way so that the
auto.key generated also does the right thing and pick it up for the
key.
I have used the col argument (which I guess is sent to par()) in a
way so that the colors are like I would want them, but now I guess I
need to know which part part of the theme I need to change in order to
make this change permanent for all the plots, and all the keys.

I am of course thankful for all the help I can get.

(Also, how does one know these things about the theme variables? Is
there some documentation somewhere?)

/Fredrik

-- 
Life is like a trumpet - if you don't put anything into it, you don't
get anything out of it.

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


[R] Urgent - odfWeave produces graphs /images with Read-Error

2009-06-17 Thread Fredrik Karlsson
Dear list,

I have been working on a report with around 60 images in it, and
everything has been fine, until now. I find that the image output that
is produced by odfWeave produces images that are NOT readable by
OpenOffice or NeoOffice. I get empty boxes with Read-Error written in
them. While generating the file using odfWeave, I can see them being
generated on the screen, and they all seem fine.

Have anybody seen this before? Is there a way around it?

/Fredrik

-- 
Life is like a trumpet - if you don't put anything into it, you don't
get anything out of it.

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


[R] Fwd: Urgent - odfWeave produces graphs /images with Read-Error

2009-06-17 Thread Fredrik Karlsson
-- Forwarded message --
From: Fredrik Karlsson dargo...@gmail.com
Date: Wed, Jun 17, 2009 at 11:10 AM
Subject: Re: [R] Urgent - odfWeave produces graphs /images with Read-Error
To: Ronggui Huang ronggui.hu...@gmail.com


Hi Ronggui,

Thank you for this! In some of the graphs, the code that was
copy-and-pasted did indeed not include the print command.

Thank you for pointing this out!

/Fredrik

On Wed, Jun 17, 2009 at 10:41 AM, Ronggui Huang ronggui.hu...@gmail.com wrote:

 If you use lattice to produce the figures, you need to wrap them in print, 
 say,
 =
 print(xyplot(y~x,data=dat))
 @

 Ronggui

 2009/6/17 Fredrik Karlsson dargo...@gmail.com:
  Dear list,
 
  I have been working on a report with around 60 images in it, and
  everything has been fine, until now. I find that the image output that
  is produced by odfWeave produces images that are NOT readable by
  OpenOffice or NeoOffice. I get empty boxes with Read-Error written in
  them. While generating the file using odfWeave, I can see them being
  generated on the screen, and they all seem fine.
 
  Have anybody seen this before? Is there a way around it?
 
  /Fredrik
 
  --
  Life is like a trumpet - if you don't put anything into it, you don't
  get anything out of it.
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 



 --
 HUANG Ronggui, Wincent
 PhD Candidate
 Dept of Public and Social Administration
 City University of Hong Kong
 Home page: http://asrr.r-forge.r-project.org/rghuang.html



--
Life is like a trumpet - if you don't put anything into it, you don't
get anything out of it.



-- 
Life is like a trumpet - if you don't put anything into it, you don't
get anything out of it.

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


Re: [R] Creating a variable which is the sum of equal rows in a dataframe

2009-05-04 Thread Fredrik Karlsson
Hi Cecilia,

You can use table for this:

#Generate a dataframe
 dat.df - data.frame(Firm = 
 sample(c(500600700,500600800,500600800),6,replace=TRUE),Banks=sample(c(Citybank,CGD,DES,Bank1),6,replace=TRUE)
   )

#Get the counts in a table format
 with(dat.df, table(Firm,Banks))
   Banks
FirmBank1 CGD Citybank DES
  500600700 0   01   0
  500600800 2   11   1

#Or, if you prefer the data.frame format, you can reshape it.
 as.data.frame(with(dat.df, table(Firm,Banks)))
   FirmBanks Freq
1 500600700Bank10
2 500600800Bank12
3 500600700  CGD0
4 500600800  CGD1
5 500600700 Citybank1
6 500600800 Citybank1
7 500600700  DES0
8 500600800  DES1

Hope this helps.

/Fredrik

On Mon, May 4, 2009 at 1:19 PM, Cecilia Carmo cecilia.ca...@ua.pt wrote:
 Hi everyone:

 I need to count the number of banks of each firm in my data. The firm is
 identified by the fiscal number. The banks of each firm appears like this:

 Firm                     Banks
 500600700          Citybank
 500600700          CGD
 500600700          BES
 500600800          Citybank
 500600800          Bank1
 500600900          CGD
 …

 I want to obtain the following dataframe:
 Firm            numberofbanks
 500600700          3
 500600800          2
 500600900          1
 …

 This is a question of counting the times each firm appears, but I don’t know
 which function do this. If anyone could help me I appreciate.

 Thank you in advance for the help you could give me,

 Cecilia Carmo (Portugal)

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




-- 
Life is like a trumpet - if you don't put anything into it, you don't
get anything out of it.

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


[R] Retrieving the context

2009-03-30 Thread Fredrik Karlsson
Dear list,

I have a general problem that I really don't know how to solve efficiently
in R. Lets say we have a sequence of things, like for instance a string of
words, that is stored in a file. We need all the words in a table format, so
therefore we create an id for the word, that links the word to a file and
the position of the word within the file, like:

#In this case a very short file
 strsplit(This is a text string, wich is stored in the file myfile,
)[[1]] - mystring
#Now, store in a data.frame
 mydf - data.frame(strings=mystring,
word_id=paste(myfile,1:length(mystring),sep=_))
 mydf
   strings   word_id
1 This  myfile_1
2   is  myfile_2
3a  myfile_3
4 text  myfile_4
5  string,  myfile_5
6 wich  myfile_6
7   is  myfile_7
8   stored  myfile_8
9   in  myfile_9
10 the myfile_10
11file myfile_11
12  myfile myfile_12

Now, I would like to see all the words 'is' in a user defined window: so
see_context(is,mydf,1) would give
This is a
wich is stored

and see_context(is,mydf,2) would show two words before and after.. and so
on.

Any ideas on how to solve this kind of problem in R?

/Fredrik


-- 
Life is like a trumpet - if you don't put anything into it, you don't get
anything out of it.

[[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] Analogy for %in% for the whole columns (rather than individual values)

2009-03-26 Thread Fredrik Karlsson
Hi Dimitri,

What about this:


 with(a, x == y) - a$equal
 a
 xy equal
1 john mary FALSE
2 mary mary  TRUE
3 mary john FALSE
4 john john  TRUE

/Fredrik

On Thu, Mar 26, 2009 at 7:48 PM, Dimitri Liakhovitski ld7...@gmail.comwrote:

 Hello!

 I have a matrix a with 2 variables (see below) that contain character
 strings.
 I need to create a 3rd variable that contains True if the value in
 column x is equal to the value in column y. The code below does it.

 a-data.frame(x=c(john, mary, mary,
 john),y=c(mary,mary,john,john))
 a$x-as.character(a$x)
 a$y-as.character(a$y)
 a$equal-NA
 for(i in 1:nrow(a)) {a[i,3]-a[i,1] %in% a[i,2]}

 I was wondering if one can do it faster, without doing it row-by-row
 as I did it. Maybe there is a faster way to compare 2 columns?

 Thank you very much!

 --
 Dimitri Liakhovitski
 MarketTools, Inc.
 dimitri.liakhovit...@markettools.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.




-- 
Life is like a trumpet - if you don't put anything into it, you don't get
anything out of it.

[[alternative HTML version deleted]]

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


[R] ANOVA and TukeyHSD disagrees?

2009-03-20 Thread Fredrik Karlsson
Dear list,

Sorry for posting a borderline statistical question on the list, but hte
SPSS people around me just stares at me blankly when refering to tests with
any term other than ANOVA and post-hoc. I would appreciate any insight on
how this all is possible:

I have a model fitted by aov() stored in ppdur, which gives this result
when using ANOVA:

 anova(ppdur)
Analysis of Variance Table

Response: PAPositionPercentOfVoweldur
  Df  Sum Sq Mean Sq F value  Pr(F)
UtteranceType   4   247316183  2.7642 0.02696 *
SyllLable   1   14584   14584  6.5202 0.01094 *
Cycle   1 798 798  0.3566 0.55067
Speaker 299754987  2.2297 0.10855
Label   120082008  0.8979 0.34377
UtteranceType:SyllLable 4   152103803  1.7001 0.14854
UtteranceType:Cycle 4   131923298  1.4745 0.20855
SyllLable:Cycle 1   11306   11306  5.0545 0.02497 *
UtteranceType:Speaker   7   137211960  0.8764 0.52488
SyllLable:Speaker   21291 645  0.2885 0.74951
Cycle:Speaker   2   107535377  2.4038 0.09135 .
UtteranceType:Label 43579 895  0.4000 0.80871
SyllLable:Label 144994499  2.0114 0.15670
Cycle:Label 1 229 229  0.1022 0.74929
Speaker:Label   21241 620  0.2774 0.75788
UtteranceType:SyllLable:Cycle   3 473 158  0.0705 0.97571
UtteranceType:SyllLable:Speaker 6   139192320  1.0372 0.40006
UtteranceType:Cycle:Speaker 31221 407  0.1820 0.90865
SyllLable:Cycle:Speaker 21457 729  0.3258 0.72210
UtteranceType:SyllLable:Label   238231911  0.8545 0.42607
UtteranceType:Cycle:Label   385662855  1.2766 0.28160
SyllLable:Cycle:Label   135753575  1.5983 0.20669
UtteranceType:Speaker:Label 42658 664  0.2970 0.87990
SyllLable:Speaker:Label 2 139  70  0.0311 0.96938
Cycle:Speaker:Label 2   135996800  3.0400 0.04866 *
UtteranceType:SyllLable:Cycle:Speaker   220151008  0.4505 0.63757
UtteranceType:SyllLable:Cycle:Label 1  11  11  0.0051 0.94328
UtteranceType:SyllLable:Speaker:Label   1 603 603  0.2695 0.60386
Residuals 539 12056052237
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Ok now, when I want to know where the differences are, I get this result
from TukeyHSD:


 TukeyHSD(ppdur,c(Cycle:Speaker:Label ),ordered=TRUE)
  Tukey multiple comparisons of means
95% family-wise confidence level
factor levels have been ordered

Fit: aov(formula = PAPositionPercentOfVoweldur ~ UtteranceType * SyllLable *
Cycle * Speaker * Label, data =PABTSub)

$`Cycle:Speaker:Label`
difflwr   upr p adj
3:Andrea:!H*L-1:Lavinia:!H*L   2.6069140 -37.499300  42.71313 1.000
1:Vito:!H*L-1:Lavinia:!H*L 8.7764075 -85.090794 102.64361 1.000
3:Andrea:H*L-1:Lavinia:!H*L   12.3411960 -18.883688  43.56608 0.9792814
1:Vito:H*L-1:Lavinia:!H*L 15.0416018 -32.746962  62.83017 0.9968844
1:Andrea:H*L-1:Lavinia:!H*L   15.2934976 -17.987036  48.57403 0.9379977
1:Lavinia:H*L-1:Lavinia:!H*L  16.9297832 -14.670124  48.52969 0.8394874
3:Lavinia:H*L-1:Lavinia:!H*L  18.3218965 -13.445765  50.08956 0.7631935
3:Lavinia:!H*L-1:Lavinia:!H*L 20.9338365 -19.932636  61.80031 0.8761167
3:Vito:!H*L-1:Lavinia:!H*L24.3874104 -18.890036  67.66486 0.7894161
3:Vito:H*L-1:Lavinia:!H*L 27.8865684  -6.758302  62.53144 0.2589397
1:Andrea:!H*L-1:Lavinia:!H*L  28.8093072 -18.979256  76.59787 0.7077134
1:Vito:!H*L-3:Andrea:!H*L  6.1694934 -87.982875 100.32186 1.000
3:Andrea:H*L-3:Andrea:!H*L 9.7342820 -22.337674  41.80624 0.9977466
1:Vito:H*L-3:Andrea:!H*L  12.4346877 -35.911602  60.78098 0.9995138
1:Andrea:H*L-3:Andrea:!H*L12.6865836 -21.389960  46.76313 0.9870844
1:Lavinia:H*L-3:Andrea:!H*L   14.3228692 -18.114318  46.76006 0.9529437
3:Lavinia:H*L-3:Andrea:!H*L   15.7149825 -16.885651  48.31562 0.9149770
3:Lavinia:!H*L-3:Andrea:!H*L  18.3269225 -23.190369  59.84421 0.9530401
3:Vito:!H*L-3:Andrea:!H*L 21.7804964 -22.112036  65.67303 0.8978922
3:Vito:H*L-3:Andrea:!H*L  25.2796544 -10.130570  60.68988 0.4470040
1:Andrea:!H*L-3:Andrea:!H*L   26.2023932 -22.143897  74.54868 0.821
3:Andrea:H*L-1:Vito:!H*L   3.5647885 -87.160916  94.29049 1.000
1:Vito:H*L-1:Vito:!H*L 6.2651943 -91.407252 103.93764 1.000
1:Andrea:H*L-1:Vito:!H*L   6.5170902 -84.936471  97.97065 1.000
1:Lavinia:H*L-1:Vito:!H*L  8.1533757 -82.702082  99.00883 1.000

Re: [R] odfWeave : change of text style of output is ignored

2009-03-20 Thread Fredrik Karlsson
Dear Max,

I was including the settings in my document, but I also tried setting it
from the command line. This resulted in more of a change, but only in that
the ttBlue now being defined as black rather than blue. So, some effect, but
not all the way.

Here is the session info:

 sessionInfo()
R version 2.8.1 (2008-12-22)
i386-apple-darwin8.11.1

locale:
sv_SE.UTF-8/sv_SE.UTF-8/C/C/sv_SE.UTF-8/sv_SE.UTF-8

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

other attached packages:
[1] car_1.2-12  nlme_3.1-90 odfWeave_0.7.9  XML_2.3-0
lattice_0.17-20

loaded via a namespace (and not attached):
[1] MASS_7.2-46grid_2.8.1 latticeExtra_0.5-4

/Fredrik



On Fri, Mar 20, 2009 at 4:06 PM, Max Kuhn mxk...@gmail.com wrote:

 Did you do this within the document, or prior to running odfWeave?

 Also, please provide the output of sessionInfo() after starting odfWeave.

 Max

 On Fri, Mar 20, 2009 at 11:03 AM, Fredrik Karlsson dargo...@gmail.com
 wrote:
  Dear list,
 
  The output of my embedded code sections come out in the style ttBlue
 wich
  is Times New Roman and Blue when I open document. I would like to change
  this to a fixed witdth font, smaller and less blue by using style
  definitions in the document, but it really does not affect the output.
 
  I tried including
 
  getStyleDefs() - styl
  styl$ttBlue$fontname - Courier
  styl$ttBlue$fontSize - 9pt
  styl$ttBlue$fontColor - #00
  setStyleDefs(styl)
 
  at the beginning of the document, but the output is still blue, not fixed
  width and still 10pt.
 
  Any ideas on how to get this to work?
 
  /Fredrik
 
  --
  Life is like a trumpet - if you don't put anything into it, you don't
 get
  anything out of it.
 
 [[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.
 



 --

 Max




-- 
Life is like a trumpet - if you don't put anything into it, you don't get
anything out of it.

[[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] Last char of a string in a list - list of strings

2009-03-18 Thread Fredrik Karlsson
Dear list,

This seems like a very simple problem, but I am failing to loose a
dimension (I think).
I have list, like this:

...
[2072] !H*L L%   %L   H*L  L%   %L   H*L  H*L  L%
%L   H*L  !H*L L%   %L   %L   %L   %L   H*L  !H*L
[2091] L%   H*   %L   H*L  L_%  %L   %H   %H   !H*L
%H   H*   %H   %H   H%   H*   !H*L H*L  !H*L H*
[2110] H*L  L_%  %L   %L   H*L  L*H  H%   %H   L*H
H%   %H   H*L  %H   %L   H*L  %H   %L   H*L  L%
[2129] %L   H*L  !H*L L%   %L   H*L  %L   H*L  %H
H*L  %L

What I would like to do is

1) Remove all the %!*0 characters
2) Get the last character of what remains for each string
3) Get a list, comparable to the one above, but with only one
character (so, the last three data points would become list(H,L,L)

I tried

 strsplit(gsub([*_!%0]*,,TADescSub$ExtendedLabel,),)

but that gives me something like:

...
[[2136]]
[1] H L

[[2137]]
[1] H

[[2138]]
[1] H L

[[2139]]
[1] L

So, what am I doing wrong?

/Fredrik

-- 
Life is like a trumpet - if you don't put anything into it, you don't
get anything out of it.

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


Re: [R] Last char of a string in a list - list of strings

2009-03-18 Thread Fredrik Karlsson
Dear Gabor,

Thank you very much for this very helpful suggestion. Indeed, I was
making it too complicated by spliting the string into a vector.

Thank you!

/Fredrik

On Wed, Mar 18, 2009 at 3:37 PM, Gabor Grothendieck
ggrothendi...@gmail.com wrote:
 Try this:

 L - c(!H*L, L%, %L, H*L, L%, %L, H*L, H*L, L%,
 + %L, H*L, !H*L, L%, %L, %L, %L, %L, H*L, !H*L,
 + L%, H*, %L, H*L, L_%, %L, %H, %H, !H*L, %H,
 + H*, %H, %H, H%, H*, !H*L, H*L, !H*L, H*, H*L,
 + L_%, %L, %L, H*L, L*H, H%, %H, L*H, H%, %H,
 + H*L, %H, %L, H*L, %H, %L, H*L, L%, %L, H*L,
 + !H*L, L%, %L, H*L, %L, H*L, %H, H*L, %L)

 sub(.*([^*_!%0])[*_!%0]*$, \\1, x)
  [1] L L L L L L L L L L L L L L L L
 L L L L H L L L L H H L H H H H H
 H L L L H
 [39] L L L L L H H H H H H L H L L H
 L L L L L L L L L L L H L L


 On Wed, Mar 18, 2009 at 11:10 AM, Fredrik Karlsson dargo...@gmail.com wrote:
 Dear list,

 This seems like a very simple problem, but I am failing to loose a
 dimension (I think).
 I have list, like this:

 ...
 [2072] !H*L L%   %L   H*L  L%   %L   H*L  H*L  L%
 %L   H*L  !H*L L%   %L   %L   %L   %L   H*L  !H*L
 [2091] L%   H*   %L   H*L  L_%  %L   %H   %H   !H*L
 %H   H*   %H   %H   H%   H*   !H*L H*L  !H*L H*
 [2110] H*L  L_%  %L   %L   H*L  L*H  H%   %H   L*H
 H%   %H   H*L  %H   %L   H*L  %H   %L   H*L  L%
 [2129] %L   H*L  !H*L L%   %L   H*L  %L   H*L  %H
 H*L  %L

 What I would like to do is

 1) Remove all the %!*0 characters
 2) Get the last character of what remains for each string
 3) Get a list, comparable to the one above, but with only one
 character (so, the last three data points would become list(H,L,L)

 I tried

 strsplit(gsub([*_!%0]*,,TADescSub$ExtendedLabel,),)

 but that gives me something like:

 ...
 [[2136]]
 [1] H L

 [[2137]]
 [1] H

 [[2138]]
 [1] H L

 [[2139]]
 [1] L

 So, what am I doing wrong?

 /Fredrik

 --
 Life is like a trumpet - if you don't put anything into it, you don't
 get anything out of it.

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





-- 
Life is like a trumpet - if you don't put anything into it, you don't
get anything out of it.

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


[R] odfWeave problem Error in xmlEventParse

2009-02-24 Thread Fredrik Karlsson
Dear list,

Sorry for bothering you with a pure odfSweave question, but I just ran
into a problem that I cannot find the cause of.
Anyonse seen this before? This file used to work, but not anymore.

Would apreciate all the help I could get.

/Fredrik


---

 odfWeave(Descriptives/IPDesc.odt,IPDescOut.odt)
  Copying  Descriptives/IPDesc.odt
  Setting wd to
/var/folders/IV/IVKgtoUIF3CjOMG8RfyjoTU/-Tmp-//RtmpPbfKbO/odfWeave24150415398
  Unzipping ODF file using unzip -o IPDesc.odt
Archive:  IPDesc.odt

  Removing  IPDesc.odt
  Creating a Pictures directory

  Pre-processing the contents
 extracting: mimetype
   creating: Configurations2/statusbar/
  inflating: Configurations2/accelerator/current.xml
   creating: Configurations2/floater/
   creating: Configurations2/popupmenu/
   creating: Configurations2/progressbar/
   creating: Configurations2/menubar/
   creating: Configurations2/toolbar/
   creating: Configurations2/images/Bitmaps/
  inflating: layout-cache
  inflating: content.xml
  inflating: styles.xml
 extracting: meta.xml
  inflating: Thumbnails/thumbnail.png
  inflating: settings.xml
  inflating: META-INF/manifest.xml
  Sweaving  content.Rnw

  Writing to file content_1.xml
  Processing code chunks ...
1 : term verbatim(label=Init)
2 : term xml(label=IPTransSummary_SL)
3 : term xml(label=IPTransSummary_SP)
4 : term xml(label=IPTransSummary_SL_CY)
5 : term xml(label=IPTransSummary_SP_CY)
6 : term xml(label=IPTransSummary_SP_CY_SE)
7 : term xml(label=IPTransSummary_SL_IPL)
8 : term xml(label=IPTransSummary_SP_IPL)
9 : term xml(label=IP_CY_SL_mean)
   10 : term xml(label=IP_CY_SL_sd)
   11 : term verbatim(label=IPLenWords_CY_SL_bwplot)
   12 : term verbatim(label=IPLenWords_SL_CY_bwplot)
   13 : term xml(label=IP_CY_SP_mean)
   14 : term xml(label=IP_CY_SP_sd)
   15 : term verbatim(label=IPLenWords_CY_SP_bwplot)
   16 : term verbatim(label=IPLenWords_SP_CY_bwplot)
   17 : term xml(label=IP_CY_SL_mean)
   18 : term xml(label=IP_CY_SL_sd)
   19 : term verbatim(label=IPLenSylls_CY_SL_bwplot)
   20 : term verbatim(label=IPLenSylls_SL_CY_bwplot)
   21 : term xml(label=IP_CY_SP_mean)
   22 : term xml(label=IP_CY_SP_sd)
   23 : term verbatim(label=IPLenSylls_CY_SP_bwplot)
   24 : term verbatim(label=IPLenSylls_SP_CY_bwplot)
   25 : term verbatim(label=IplenCalc)
   26 : term xml(label=WordLenSyll_CY_SL_mean)
   27 : term xml(label=WordLenSyll_CY_SL_sd)
   28 : term verbatim(label=WordLenSyll_CY_SL_bwplot)
   29 : term verbatim(label=WordLenSyll_SL_CY_bwplot)
   30 : term xml(label=WordLenSyll_CY_SP_mean)
   31 : term xml(label=WordLenSyll_CY_SP_sd)
   32 : term verbatim(label=WordLenSyll_CY_SP_bwplot)
   33 : term verbatim(label=WordLenSyll_SP_CY_bwplot)
   34 : term verbatim(label=CleanTA)
   35 : term xml(label=IP_PA_CY_SL_mean)
   36 : term xml(label=IP_PA_CY_SL_sd)
   37 : term verbatim(label=IPLenTones_CY_SL_bwplot)
   38 : term verbatim(label=IPLenTones_SL_CY_bwplot)
   39 : term xml(label=IP_PA_CY_SP_mean)
   40 : term xml(label=IP_PA_CY_SP_sd)
   41 : term verbatim(label=IPLenTones_CY_SP_bwplot)
   42 : term verbatim(label=IPLenTones_SP_CY_bwplot)
   43 : term verbatim(label=IPClassrm)
   44 : term verbatim(label=IPClassDistRelRM_PA_SL_CY_Fig)
   45 : term verbatim(label=IPClassDistRelRM_PA_CY_SL_Fig)
   46 : term verbatim(label=IPClassDistRelRM_PA_CY_SP_Fig)
   47 : term xml(label=IPTrans_TS_SL_count)
   48 :(label=IPTrans_TS_SP_count)
   49 : term verbatim(label=close)

  'content_1.xml' has been Sweaved

  Removing content.xml

  Post-processing the contents
Error in xmlEventParse(infile, handlers = handlers, trim = FALSE,
state = state) :
  attempt to apply non-function
In addition: Warning message:
closing unused connection 3 (content.xml)


---



-- 
Life is like a trumpet - if you don't put anything into it, you don't
get anything out of it.

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


[R] Grouped bwplots?

2009-02-20 Thread Fredrik Karlsson
Dear list,

I am sorry for asking you this, but I am trying to do again what I
thought I have done before, although this time it does not work.

So, given the data set:

 testdf - data.frame(grfak=sample(c(One,Two),size=100,replace=TRUE), 
 panfak= sample(c(Yes,No),size=100,replace=TRUE), xfak= 
 sample(c(Yep,Nope),size=100,replace=TRUE),  d=rnorm(100))

I would like to do:

 bwplot(d ~ xfak | panfak,data=testdf, groups= grfak)

where the groups argument makes a difference (as in dividing each box
into two by group).
Is this possible to do? If so, what I am doing wrong?


/Fredrik

-- 
Life is like a trumpet - if you don't put anything into it, you don't
get anything out of it.

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


[R] Grayscale figures in odfWeave?

2009-01-12 Thread Fredrik Karlsson
Dear list,

I am sorry if this is a FAQ, but I have just started using odfWeave
for report construction and it seems not to behave exactly like
Sweave.
I want to get my figures in grayscale, but the tip given in the FAQ of
Sweave http://www.stat.uni-muenchen.de/~leisch/Sweave/FAQ.html#x1-1A.8
only produces gray scale images in the screen output, not in the odf
document.
This is my init code:

Init,echo=false=
library(lattice)
ltheme - canonical.theme(color = FALSE) ## in-built BW theme
ltheme$strip.background$col - transparent ## change strip bg
lattice.options(default.theme = ltheme)  ## set as default

@

What am I doing wrong?

/Fredrik

-- 
Life is like a trumpet - if you don't put anything into it, you don't
get anything out of it.

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


[R] Change in Lattice bwplot?

2008-12-16 Thread Fredrik Karlsson
Dear list,

Sorry for asking this question, but has something changed in the
syntax for bwplot in Lattice? In an old publication, I used

 bwplot( VOTMS ~gender |type * group,
 data=merge(vot,words,by=ord),
 nint=30,
 horizontal=F,
 layout=c(3,3),
 box.ratio=0.8)

which produced a lovelly 3x3 lattice plot with one box/gender in each
panel. Now, I try

 bwplot( SyllableNucleusDiff ~ SourceLanguage,data=Hstar,horizontal=F)

to get just a simple 1x1 panel plot with groups (which I will then of
course make into a panel plot by adding | factor1 +factor2...), but I
get a Syntax error.
So, has anything changed, or am I just doing something very silly?

/Fredrik

-- 
Life is like a trumpet - if you don't put anything into it, you don't
get anything out of it.

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


[R] TukeyHSD and 0.0000000

2008-11-05 Thread Fredrik Karlsson
Dear list,

Sorry to ask you this, but I just ran a TukeyHSD on an model with a
two thee level factors as independent variables and a numeric score
dependent variable.
The aov gives a significant interaction effect, and using the
TukeyHSD, I get almost every row to be exactly 0.000. Should I be
worried??

/Fredrik

-- 
Life is like a trumpet - if you don't put anything into it, you don't
get anything out of it.

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


Re: [R] TukeyHSD and 0.0000000

2008-11-05 Thread Fredrik Karlsson
Hi,

Sorry about that. Sure, here is some further information:


 summary(InekeReduc)
 segorg intorg l2group mani  score
 Belfast:3782   Belfast:3782   1: 2604   1   :2480   Min.   :  1.000
 L2 :7502   L2 :7440   2:12462   2   :2542   1st Qu.:  1.000
 German :3782   German :3844 3   :2480   Median :  2.000
 4   :2480   Mean   :  3.011
 5   :2480   3rd Qu.:  5.000
 NA's:2604   Max.   :  6.000
 NA's   :200.000
 summary( fit - aov( score ~ segorg * intorg ,data=InekeReduc) )
 Df Sum Sq Mean Sq  F valuePr(F)
segorg2  150257512 2219.063  2.2e-16 ***
intorg2   1019 509  150.441  2.2e-16 ***
segorg:intorg 4164  41   12.086 8.299e-10 ***
Residuals 14857  50297   3
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
200 observations deleted due to missingness
 TukeyHSD(fit,segorg:intorg)
  Tukey multiple comparisons of means
95% family-wise confidence level

Fit: aov(formula = score ~ segorg * intorg, data = InekeReduc)

$`segorg:intorg`
  diff lwrupr p adj
L2:Belfast-Belfast:Belfast  1.59590485  1.33909758  1.8527121 0.000
German:Belfast-Belfast:Belfast  3.04430961  2.71827718  3.3703420 0.000
Belfast:L2-Belfast:Belfast  0.24375305 -0.01369296  0.5011991 0.0801617
L2:L2-Belfast:Belfast   1.55958957  1.30211188  1.8170673 0.000
German:L2-Belfast:Belfast   2.96873225  2.71126512  3.2261994 0.000
Belfast:German-Belfast:Belfast  0.44195992  0.12355001  0.7603698 0.0005667
L2:German-Belfast:Belfast   2.36192845  2.10440839  2.6194485 0.000
German:German-Belfast:Belfast   3.42962398  3.0098  3.7481470 0.000
German:Belfast-L2:Belfast   1.44840476  1.19092315  1.7058864 0.000
Belfast:L2-L2:Belfast  -1.35215180 -1.51425695 -1.1900466 0.000
L2:L2-L2:Belfast   -0.03631527 -0.19847075  0.1258402 0.9988643
German:L2-L2:Belfast1.37282740  1.21068871  1.5349661 0.000
Belfast:German-L2:Belfast  -1.15394493 -1.40170389 -0.9061860 0.000
L2:German-L2:Belfast0.76602360  0.60380087  0.9282463 0.000
German:German-L2:Belfast1.83371914  1.58581484  2.0816234 0.000
Belfast:L2-German:Belfast  -2.80055656 -3.05867524 -2.5424379 0.000
L2:L2-German:Belfast   -1.48472003 -1.74287033 -1.2265697 0.000
German:L2-German:Belfast   -0.07557736 -0.33371711  0.1825624 0.9925827
Belfast:German-German:Belfast  -2.60234969 -2.92130373 -2.2833957 0.000
L2:German-German:Belfast   -0.68238116 -0.94057371 -0.4241886 0.000
German:German-German:Belfast0.38531438  0.06624743  0.7043813 0.0056382
L2:L2-Belfast:L21.31583652  1.15267135  1.4790017 0.000
German:L2-Belfast:L22.72497920  2.56183071  2.8881277 0.000
Belfast:German-Belfast:L2   0.19820687 -0.05021410  0.4466278 0.2441352
L2:German-Belfast:L22.11817540  1.95494338  2.2814074 0.000
German:German-Belfast:L23.18587093  2.93730501  3.4344369 0.000
German:L2-L2:L2 1.40914267  1.24594419  1.5723412 0.000
Belfast:German-L2:L2   -1.11762966 -1.36608347 -0.8691758 0.000
L2:German-L2:L2 0.80233887  0.63905689  0.9656209 0.000
German:German-L2:L2 1.87003441  1.62143567  2.1186331 0.000
Belfast:German-German:L2   -2.52677233 -2.77521518 -2.2783295 0.000
L2:German-German:L2-0.60680380 -0.77006911 -0.4435385 0.000
German:German-German:L2 0.46089174  0.21230395  0.7094795 0.003
L2:German-Belfast:German1.91996853  1.67147082  2.1684662 0.000
German:German-Belfast:German2.98766407  2.67639017  3.2989380 0.000
German:German-L2:German 1.06769554  0.81905292  1.3163382 0.000

/Fredrik

On Wed, Nov 5, 2008 at 1:15 PM, hadley wickham [EMAIL PROTECTED] wrote:
 On Wed, Nov 5, 2008 at 5:42 AM, Fredrik Karlsson [EMAIL PROTECTED]
wrote:
 Dear list,

 Sorry to ask you this, but I just ran a TukeyHSD on an model with a
 two thee level factors as independent variables and a numeric score
 dependent variable.
 The aov gives a significant interaction effect, and using the
 TukeyHSD, I get almost every row to be exactly 0.000. Should I be
 worried??

 You should be worried that you did not provide any information to
 reproduce your problem.  How can you expect anyone else to give you
 advice?

 Hadley


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




-- 
Life is like a trumpet - if you don't put anything into it, you don't get
anything out of it.

[[alternative HTML version deleted]]

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

[R] Reversed but positive axis in trellis plots?

2008-03-05 Thread Fredrik Karlsson
Hi,

In my discpipline, it is common to plot one acoustic property on a
positive scale but from top to bottom on the ordinate and the same for
another measurement on the abscissa.
So, the origin of the plot is on the top right of the plot, with
increasing values to the left /down. This is to highlight the
correlation between the acoustic measurement and the position of the
forming structure, for instance when teaching it to students.

The grouping ability of the trellis plot is quite handy whan plotting
many instances of the same thing, so I was wondering if it is possible
to make a trellis xyplot behave this way?
Converting all values to negative and changing labels to the negative
of the negative seems one solution to the reverseness of the axes, but
how do I change the position? Is it possible?

/Fredrik

-- 
Give up learning, and put an end to your troubles.

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