[R] Math elements in panel headers of lattice plots?

2006-08-03 Thread Fredrik Karlsson
Hi,

I would like to put a math expression in the header of a panel.
Acctually, I need to substitute the 'a' to a script-a in a
transcription contained in the factor by which the data set is
divided. So, /spak/ should be /spAk/ where A should be a script-a.
I guessed that math expressions would be the way to go on this..


Is this possible?

/Fredrik

-- 

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

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] Two sets of axis in a lattice plot?

2006-06-22 Thread Fredrik Karlsson
Dear list,

Is it possible to have lattice provide two different ordinate axis,
one on the right side and one of the left side of the plot?

I would like to make a xyplot with x both in a linear scale and in a
log-approximate scale.

Thank you in advance.

/Fredrik

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


[R] Increase the number of plotting characters in dotplot (lattice)?

2006-05-10 Thread Fredrik Karlsson
Dear list,

I am using the dotplot function of lattice and like it very much.
However, in some of the plots, I have more than 7 categories that I
would like to represent by different plotting characters in the graph,
which is  a problem. For the categories after the 7th, the plotting
characters are recycled, creating a confisuing graph indeed.

So, my question is: how do I increase the number of unique plotting characters?

/Fredrik

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


Re: [R] forcing apply() to return data frame

2006-04-21 Thread Fredrik Karlsson
Hi,

There is a frameApply fynction in the library gdata from the gregmisc package.
The manual says it is like the function 'by', but returns a data.frame.

Maybe this is something for you?

/Fredrik



2006/4/21, Federico Calboli [EMAIL PROTECTED]:
 Hi All,

 I am (almost) successfully using apply() to apply a function recursively
 on a data matrix. The function is question is as.genotype() from the
 library 'genetics'

 apply(subset(chr1, names$breed == 'lab'),2,as.genotype,sep =)

 Unfortuantely apply puts it's results into a matrix object rather than a
 data frame, tranforming my factors into numerics and making the results
 useless.

 Is there a way of forcing apply() to return a data frame rather than a
 matrix?

 Cheers,

 Federico


 --
 Federico C. F. Calboli
 Department of Epidemiology and Public Health
 Imperial College, St Mary's Campus
 Norfolk Place, London W2 1PG

 Tel  +44 (0)20 7594 1602 Fax (+44) 020 7594 3193

 f.calboli [.a.t] imperial.ac.uk
 f.calboli [.a.t] gmail.com

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


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


Re: [R] prop.table on three-way table?

2006-04-20 Thread Fredrik Karlsson
Hi marc,

I did not manage ctab to do this for me. Again, I am probably using it
wrong, but I don't know that the problem is.

You asked for a more illustrated example, so here goes:

Take this table:

 ftable(table(sample(paste(dim1_no,1:5,sep=),10,replace=TRUE),
sample(paste(dim2_no,1:5,sep=),10,replace=TRUE),
sample(paste(dim3_no,1:5,sep=),10,replace=TRUE)))

   dim3_no1 dim3_no2 dim3_no3 dim3_no5

dim1_no1 dim2_no1 0000
 dim2_no2 0020
 dim2_no3 0000
 dim2_no4 0000
 dim2_no5 0000
dim1_no2 dim2_no1 0000
 dim2_no2 0000
 dim2_no3 0000
 dim2_no4 0000
 dim2_no5 0101
dim1_no3 dim2_no1 0000
 dim2_no2 0000
 dim2_no3 0010
 dim2_no4 0000
 dim2_no5 0000
dim1_no4 dim2_no1 1000
 dim2_no2 0000
 dim2_no3 0000
 dim2_no4 0000
 dim2_no5 1000
dim1_no5 dim2_no1 0000
 dim2_no2 0100
 dim2_no3 1000
 dim2_no4 0100
 dim2_no5 0000


Now, I would like to get the per cent occurrence of each level of
dim3_noX witin the cells by dim1 and dim2. Thus, for this part section
of the table above:

   dim3_no1 dim3_no2 dim3_no3 dim3_no5
dim1_no2 dim2_no1 0000
 dim2_no2 0000
 dim2_no3 0000
 dim2_no4 0000
 dim2_no5 0101

I would like to get:

   dim3_no1 dim3_no2 dim3_no3 dim3_no5
dim1_no2 dim2_no1 0000
 dim2_no2 0000
 dim2_no3 0000
 dim2_no4 0000
 dim2_no5 00.500.5

since dim3_no2 represented 50% of the frequency within the cell
created by dim1_no2 and dim2_no5.


Hope that helped clarify my previous explanation of the problem.

/Fredrik

2006/4/19, Marc Schwartz (via MN) [EMAIL PROTECTED]:
 On Wed, 2006-04-19 at 16:39 +0200, Fredrik Karlsson wrote:
  Dear list,
 
  I am trying to create a three-way table with percent occurrence
  instead of raw frequencies. However, I cannot get the results I
  expected:
 
  I have the following table:
 
   ftable(table( mannerDF$agem, mannerDF$target, mannerDF$manner ))
  snip
  50 bak 0 0   0 0   1 0
 pak 0 0   0 0   3 0
 sak 0 1   0 0   0 0
 spak0 0   0 0   0 0
 
  Now, If I use the prop-table function, I newer get a 1 ratio in any cell:
 
 
 
  With 'margin=1':
 
  50 bak0. 0. 0. 0. 0.2000 0.
 pak0. 0. 0. 0. 0.6000 0.
 sak0. 0.2000 0. 0. 0. 0.
 spak   0. 0. 0. 0. 0. 0.
 
  With 'margin=2':
 
  50 bak   0.0 0.0 0.0 0.0 0.004347826 
  0.0
 pak   0.0 0.0 0.0 0.0 0.010752688 
  0.0
 sak   0.0 0.005747126 0.0 0.0 0.0 
  0.0
 spak  0.0 0.0 0.0 0.0 0.0 
  0.0
 
  With 'margin=3':
 
  50 bak   0.0 0.0 0.0 0.0 0.001373626 
  0.0
 pak   0.0 0.0 0.0 0.0 0.004120879 
  0.0
 sak   0.0 0.008695652 0.0 0.0 0.0 
  0.0
 spak  0.0 0.0 0.0 0.0 0.0 
  0.0
 
  What I was looking for is this:
 
 
  50 bak 0 0   0 0   1 0
 pak 0 0   0 0   1 0
 sak 0 1   0 0   0 0
 spak0 0   0 0   0 0
 
  (With more digits)
 
  Am I doing something stupid?

 I may be missing what you

[R] prop.table on three-way table?

2006-04-19 Thread Fredrik Karlsson
Dear list,

I am trying to create a three-way table with percent occurrence
instead of raw frequencies. However, I cannot get the results I
expected:

I have the following table:

 ftable(table( mannerDF$agem, mannerDF$target, mannerDF$manner ))
snip
50 bak 0 0   0 0   1 0
   pak 0 0   0 0   3 0
   sak 0 1   0 0   0 0
   spak0 0   0 0   0 0

Now, If I use the prop-table function, I newer get a 1 ratio in any cell:



With 'margin=1':

50 bak0. 0. 0. 0. 0.2000 0.
   pak0. 0. 0. 0. 0.6000 0.
   sak0. 0.2000 0. 0. 0. 0.
   spak   0. 0. 0. 0. 0. 0.

With 'margin=2':

50 bak   0.0 0.0 0.0 0.0 0.004347826 0.0
   pak   0.0 0.0 0.0 0.0 0.010752688 0.0
   sak   0.0 0.005747126 0.0 0.0 0.0 0.0
   spak  0.0 0.0 0.0 0.0 0.0 0.0

With 'margin=3':

50 bak   0.0 0.0 0.0 0.0 0.001373626 0.0
   pak   0.0 0.0 0.0 0.0 0.004120879 0.0
   sak   0.0 0.008695652 0.0 0.0 0.0 0.0
   spak  0.0 0.0 0.0 0.0 0.0 0.0

What I was looking for is this:


50 bak 0 0   0 0   1 0
   pak 0 0   0 0   1 0
   sak 0 1   0 0   0 0
   spak0 0   0 0   0 0

(With more digits)

Am I doing something stupid?

/Fredrik

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


[R] Extra \input command in Sweave created figures.

2006-04-18 Thread Fredrik Karlsson
Dear list,

I am using Sweave to generate figures and tables for my thesis. Now, I
have run into the problem that all of a sudden, Sweave produces not
only an \includegraphics command, but a
\include command as well. This breakes LaTeX processing.

This is an example:

The code:


\begin{figure}[htbp]
  \centering
mannerSimpleSkal,fig=T,height=5=
sel -   mannerDF$target %in% c(skal,kal,sal,gal) 
mannerDF$onsetLength == 1
print(
  dotplot(
  
prop.table(table(mannerDF$agem[sel],mannerDF$target[sel],mannerDF$manner[sel]),1)
  ,auto.key=list(
 space=right
 )
  )
  )
@
\caption[Relative frequence of occurence for each manner of
articulation in simple productions of Skal,kal,gal and
sal]{Relative frequence of occurence for each manner of
 articulation in simple productions of the skal,kal,gal and sal
 target words.}
  \label{fig:manner-skal-simple}
\end{figure}

Produces this LaTeX output when run through Sweave:



\begin{figure}[htbp]
  \centering
\input{manner-mannerSimpleSkal}
\includegraphics{manner-mannerSimpleSkal}
\caption[Relative frequence of occurence for each manner of
articulation in simple productions of Skal,kal,gal and
sal]{Relative frequence of occurence for each manner of
 articulation in simple productions of the skal,kal,gal and sal
 target words.}
  \label{fig:manner-skal-simple}
\end{figure}

What is causing the extra \input? I had this problem once before, but
was enable then to fix the problem by randomly adding and removing
blank space. Now, this problem seem to have occured in 18 figures,
which means I would like to find the acctual problem this time rather
than trying to remove the symptoms.

Thankful for all the help I could get.

/Fredrik

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


Re: [R] barchart in black white with 10 categories?

2006-04-03 Thread Fredrik Karlsson
Thank you Deepayan for your reply.

Using your example, I was able to get bars in greyscale that separates
nicelly in Black and white. However, I cannot get the key to do the
same. All I can do, using hte col argument of
simpleKey, is to get the legend text to shade go through all the grey
scales, with color boxes
by the text.

print(
  barchart(
  prop.table(pd,margin=1),
  auto.key=list(
  space=right,
  col=gray.colors(10)
 ),
  xlab=Relative Frequency,
  ylab=Age (months),
  col = gray.colors(10)
  )
)



On 4/3/06, Deepayan Sarkar [EMAIL PROTECTED] wrote:
 On 4/1/06, Fredrik Karlsson [EMAIL PROTECTED] wrote:
  Dear list,
 
  I am trying to plot  a barchart (from lattice) in B  W, with 10
  categories per bar.
  It seems that the colours are recycled after reachingcategory number
  7, which creates a problem interpreting the chart. I therefore have
  two questions:
 
  1) How do I get more shades?

 Use the col argument:

 barchart(site ~ yield | year, data = barley, groups = variety,
  stack = TRUE, auto.key = TRUE, col = gray.colors(10))

 or change the appropriate settings (the name of which is different in
 R 2.2.x and 2.3.x, but see show.settings() in either case).

 Deepayan
 --
 http://www.stat.wisc.edu/~deepayan/



--
My Gentoo + PVR-350 + IVTV + MythTV blog is on
http://gentoomythtv.blogspot.com/

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


[R] barchart in black white with 10 categories?

2006-04-01 Thread Fredrik Karlsson
Dear list,

I am trying to plot  a barchart (from lattice) in B  W, with 10
categories per bar.
It seems that the colours are recycled after reachingcategory number
7, which creates a problem interpreting the chart. I therefore have
two questions:

1) How do I get more shades?

2) Does anyone have a theme to share with me with distinctive shades
in Black  White?


Thankful for all the help I can get.

/Fredrik

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


Re: [R] Repeated measures aov with post hoc tests?

2006-01-12 Thread Fredrik Karlsson
Dear list,

I posted the message below a cople of days ago, and have not been able
to find any solution to this. I do really want some help.

/Fredrik

On 1/10/06, Fredrik Karlsson [EMAIL PROTECTED] wrote:
 Dear list,

 I would like to perform an analysis on the following model:

 aov(ampratio ~ Type * Place * agemF + Error(speakerid/Place) ,data=aspvotwork)

 using the approach from http://www.psych.upenn.edu/~baron/rpsych/rpsych.html .

 Now, I got the test results, wich indicate a significant interaction
 and main effects of the agemF variable. How do I find at what level of
 agemF the effect may be found.

 How do I do this?

 I found a reference to TukeyHSD in the archives, but I cannot use it:

  TukeyHSD(aov(ampratio ~ Type * Place * agemF + 
  Error(speakerid/Place),data=aspvotwork))
 Error in TukeyHSD(aov(ampratio ~ Type * Place * agemF +
 Error(speakerid/Place),  :
 no applicable method for TukeyHSD

 Please help me.

 /Fredrik



--
My Gentoo + PVR-350 + IVTV + MythTV blog is on
http://gentoomythtv.blogspot.com/

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


[R] Repeated measures aov with post hoc tests?

2006-01-10 Thread Fredrik Karlsson
Dear list,

I would like to perform an analysis on the following model:

aov(ampratio ~ Type * Place * agemF + Error(speakerid/Place) ,data=aspvotwork)

using the approach from http://www.psych.upenn.edu/~baron/rpsych/rpsych.html .

Now, I got the test results, wich indicate a significant interaction
and main effects of the agemF variable. How do I find at what level of
agemF the effect may be found.

How do I do this?

I found a reference to TukeyHSD in the archives, but I cannot use it:

 TukeyHSD(aov(ampratio ~ Type * Place * agemF + 
 Error(speakerid/Place),data=aspvotwork))
Error in TukeyHSD(aov(ampratio ~ Type * Place * agemF +
Error(speakerid/Place),  :
no applicable method for TukeyHSD

Please help me.

/Fredrik

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


[R] Really supress output from Sweave

2005-11-23 Thread Fredrik Karlsson
Hi,

I am using Sweave for chapters in my thesis that contain results.
In the beginning of each chapter, I use this to load libraries I need.

init,echo=FALSE,quiet=TRUE=
library(gplots)
library(Hmisc)
library(e1071)

@


What I want is, of course, to supress messages written by this code,
but what I get in the end is X-init.tex with this the contents below.
How do I really supress it?

/Fredrik

Type library(help='Hmisc'), ?Overview, or ?Hmisc.Overview')
to see overall documentation.

NOTE:Hmisc no longer redefines [.factor to drop unused levels when
subsetting.  To get the old behavior of Hmisc type dropUnusedLevels().

Attaching package: 'Hmisc'


The following object(s) are masked from package:gdata :

 reorder.factor


The following object(s) are masked from package:car :

 recode


The following object(s) are masked from package:stats :

 ecdf
\end{Soutput}
\begin{Soutput}
Loading required package: class

Attaching package: 'e1071'


The following object(s) are masked from package:Hmisc :

 impute


The following object(s) are masked from package:gtools :

 permutations


The following object(s) are masked from package:foreign :

 read.octave
\end{Soutput}
\begin{Soutput}
Attaching package: 'xtable'


The following object(s) are masked _by_ .GlobalEnv :

 digits


The following object(s) are masked from package:Hmisc :

 label label-
\end{Soutput}
\end{Schunk}

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


Re: [R] Problems with Shapiro Wilk's test of normality.

2005-11-10 Thread Fredrik Karlsson
Never mind,

I solved it myself. It was an NA problem.

/Fredrik

On 11/9/05, Fredrik Karlsson [EMAIL PROTECTED] wrote:
 Hi,

 I am trying to create a table with information from Shapiro Wilk's
 test of normality.
 However, it fails due to lack of sample size, it says, but the way I
 see it, this is not a problem.
 (See the table of sample sizes (almost) at the bottom).

 Applying a different function using a similar ftable call is not a
 problem (See the bottom table).

 This is R 2.1.0 on Linux (Gentoo).

 /Fredrik

  shapiro.p.value - function(x){
 +   if(length(! is.na(x))  3  length(! is.na(x))  5000 ){
 + p - shapiro.test(x)$p.value
 + return(p)
 +}else{
 +  return(NA)
 +  }
 + }
 
  distribution.table.fun - function(x,na.rm=T,digits=1){
 +
 +   if(length(! is.na(x))  3  length(! is.na(x))  5000){
 +# shapTest - shapiro.test(x)
 +# W - shapTest$statistic
 + W - W
 +   }
 +
 +
 +
 +   shap - shapiro.p.value(x)
 +   stars - ''
 +   premark - ''
 +   postmark - ''
 +   if(length(x)  10){
 +   premark - '\\textit{'
 +   postmark - '}'
 +   }
 +
 +   #skapa stjärnor
 +   if(! is.na(shap)){
 + if( shap = 0.001 ){
 +   stars - '***'
 + }else{
 +   if( shap = 0.01 ){
 + stars - '**'
 +   }else{
 + if( shap = 0.05 ){
 +   stars - '*'
 + }
 +
 +   }
 +
 + }
 +
 + outstr - paste(premark,'W=',W,',p=',shap,postmark,stars,sep=)
 +   }
 +   else{
 + outstr -  
 +   }
 +
 +
 +   return(outstr)
 +
 + }
 
  ftable(tapply(aspvotwork$ampratio,list(Place=aspvotwork$Place,Age=aspvotwork$agemF,voicetype=aspvotwork$Type),FUN=length
   ))
voicetype Voiced Voiceless unaspirated Voiceless aspirated
 Place  Age
 Velar  18 - 24   4441  34
24 - 30   7081  71
30 - 36   5966  64
36 - 42   2527  22
42 - 48   2223  23
48 - 54   12 9   7
 Dental 18 - 24   4861  54
24 - 30   82   101  89
30 - 36   5782  72
36 - 42   1931  34
42 - 48   2533  31
48 - 54   1012  14
 Labial 18 - 24   74   141  84
24 - 30  142   264 162
30 - 36  124   213 148
36 - 42   5091  50
42 - 48   4982  64
48 - 54   1726  16
  ftable(tapply(aspvotwork$ampratio,list(Place=aspvotwork$Place,Age=aspvotwork$agemF,voicetype=aspvotwork$Type),FUN=distribution.table.fun,digits=4))
 Error in shapiro.test(x) : sample size must be between 3 and 5000
 

 ftable(tapply(aspvotwork$ampratio,list(Place=aspvotwork$Place,Age=aspvotwork$agemF,voicetype=aspvotwork$Type),FUN=mean,digits=4,na.rm=TRUE
 ))
voicetypeVoiced Voiceless unaspirated Voiceless aspirated
 Place  Age
 Velar  18 - 24   0.4816810 0.4461307   0.4513994
24 - 30   0.5289028 0.4778686   0.4888445
30 - 36   0.5452949 0.5208633   0.4756369
36 - 42   0.5631310 0.4697789   0.4709779
42 - 48   0.4968318 0.4174068   0.4088855
48 - 54   0.3057712 0.4483639   0.4561953
 Dental 18 - 24   0.4058078 0.4596251   0.4091731
24 - 30   0.4609731 0.4502778   0.4483340
30 - 36   0.5095430 0.4726149   0.4315419
36 - 42   0.4935719 0.4687774   0.4528758
42 - 48   0.4344465 0.4220429   0.4362018
48 - 54   0.3697664 0.4338549   0.4897856
 Labial 18 - 24   0.4327926 0.4879985   0.4503917
24 - 30   0.5309634 0.4839031   0.5927699
30 - 36   0.4094516 0.757   0.3964693
36 - 42   0.5010130 0.480   0.4540598
42 - 48   0.4949510 0.4329442   0.3935921
48 - 54   0.5217893 0.5124186   0.5011346
 



--
My Gentoo + PVR-350 + IVTV + MythTV

[R] Problems with Shapiro Wilk's test of normality.

2005-11-09 Thread Fredrik Karlsson
Hi,

I am trying to create a table with information from Shapiro Wilk's
test of normality.
However, it fails due to lack of sample size, it says, but the way I
see it, this is not a problem.
(See the table of sample sizes (almost) at the bottom).

Applying a different function using a similar ftable call is not a
problem (See the bottom table).

This is R 2.1.0 on Linux (Gentoo).

/Fredrik

 shapiro.p.value - function(x){
+   if(length(! is.na(x))  3  length(! is.na(x))  5000 ){
+ p - shapiro.test(x)$p.value
+ return(p)
+}else{
+  return(NA)
+  }
+ }

 distribution.table.fun - function(x,na.rm=T,digits=1){
+
+   if(length(! is.na(x))  3  length(! is.na(x))  5000){
+# shapTest - shapiro.test(x)
+# W - shapTest$statistic
+ W - W
+   }
+
+
+
+   shap - shapiro.p.value(x)
+   stars - ''
+   premark - ''
+   postmark - ''
+   if(length(x)  10){
+   premark - '\\textit{'
+   postmark - '}'
+   }
+
+   #skapa stjärnor
+   if(! is.na(shap)){
+ if( shap = 0.001 ){
+   stars - '***'
+ }else{
+   if( shap = 0.01 ){
+ stars - '**'
+   }else{
+ if( shap = 0.05 ){
+   stars - '*'
+ }
+
+   }
+
+ }
+
+ outstr - paste(premark,'W=',W,',p=',shap,postmark,stars,sep=)
+   }
+   else{
+ outstr -  
+   }
+
+
+   return(outstr)
+
+ }

 ftable(tapply(aspvotwork$ampratio,list(Place=aspvotwork$Place,Age=aspvotwork$agemF,voicetype=aspvotwork$Type),FUN=length
  ))
   voicetype Voiced Voiceless unaspirated Voiceless aspirated
Place  Age
Velar  18 - 24   4441  34
   24 - 30   7081  71
   30 - 36   5966  64
   36 - 42   2527  22
   42 - 48   2223  23
   48 - 54   12 9   7
Dental 18 - 24   4861  54
   24 - 30   82   101  89
   30 - 36   5782  72
   36 - 42   1931  34
   42 - 48   2533  31
   48 - 54   1012  14
Labial 18 - 24   74   141  84
   24 - 30  142   264 162
   30 - 36  124   213 148
   36 - 42   5091  50
   42 - 48   4982  64
   48 - 54   1726  16
 ftable(tapply(aspvotwork$ampratio,list(Place=aspvotwork$Place,Age=aspvotwork$agemF,voicetype=aspvotwork$Type),FUN=distribution.table.fun,digits=4))
Error in shapiro.test(x) : sample size must be between 3 and 5000

   
ftable(tapply(aspvotwork$ampratio,list(Place=aspvotwork$Place,Age=aspvotwork$agemF,voicetype=aspvotwork$Type),FUN=mean,digits=4,na.rm=TRUE
))
   voicetypeVoiced Voiceless unaspirated Voiceless aspirated
Place  Age
Velar  18 - 24   0.4816810 0.4461307   0.4513994
   24 - 30   0.5289028 0.4778686   0.4888445
   30 - 36   0.5452949 0.5208633   0.4756369
   36 - 42   0.5631310 0.4697789   0.4709779
   42 - 48   0.4968318 0.4174068   0.4088855
   48 - 54   0.3057712 0.4483639   0.4561953
Dental 18 - 24   0.4058078 0.4596251   0.4091731
   24 - 30   0.4609731 0.4502778   0.4483340
   30 - 36   0.5095430 0.4726149   0.4315419
   36 - 42   0.4935719 0.4687774   0.4528758
   42 - 48   0.4344465 0.4220429   0.4362018
   48 - 54   0.3697664 0.4338549   0.4897856
Labial 18 - 24   0.4327926 0.4879985   0.4503917
   24 - 30   0.5309634 0.4839031   0.5927699
   30 - 36   0.4094516 0.757   0.3964693
   36 - 42   0.5010130 0.480   0.4540598
   42 - 48   0.4949510 0.4329442   0.3935921
   48 - 54   0.5217893 0.5124186   0.5011346


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


[R] Convert ftable to latex?

2005-08-30 Thread Fredrik Karlsson
Dear list, 

I cannot make the latex command to output a ftable objet the way I
want it. Is it posible?
I found a post in the archives saying that one should use the rgroup
and n.rgroup arguments to supply the row names, but so far I have been
unsuccessful.

This is what I have:

 (ftable(tapply(worksub$vot,list(votcat=worksub$votcat,age=worksub$agemF,voicetype=worksub$Type),FUN=distribution.table.fun,digits=4))
  - ftab)
  voicetype  Voiced   Voiceless
unaspirated Voiceless aspirated
votcatage
Prevoiced 18 - 24   46.6158 (0;-1.6652) 40.7417
(0;-0.6489) 48.4164 (0;-1.0483)
  24 - 30   50.5716 (0;-1.4244)**   43.4056
(-1;-0.4537)*** 24.204 (0;-2.1416)
  30 - 36   44.4439 (0;-1.182)* 51.0996
(0;-1.5241)***  32.1219 (0;-1.5007)
  36 - 42   40.8604 (-1;-0.3423)40.6045
(-1;-0.408)**   32.7949 (0;-2.75)
  42 - 48   46.301 (0;-1.1878)  21.6894
(0;-1.7041) NA (NA;NA)
  48 - 54   38.0151 (-1;-0.7878)*   27.6954
(-1;0.0396)*NA (NA;NA)
Short lag 18 - 24   7.5719 (1;0.4391)***9.7039
(1;-0.2938)***   8.5525 (1;-0.4063)***
  24 - 30   8.3466 (1;-0.3122)***   9.8524
(0;-0.887)***11.4154 (0;-1.2267)***
  30 - 36   9.4509 (1;-0.0795)***   9.0177
(1;-0.2654)***   9.441 (0;-0.7625)
  36 - 42   9.4921 (1;-0.1835)***   10.107 (0;-0.72)**
 10.912 (0;-1.3619)
  42 - 48   7.8254 (1;1.016)**  9.5687 (0;-0.9019)
 10.6842 (-1;0.0719)*
  48 - 54   7.7332 (1;1.2834)** 9.4626
(1;0.3173)***10.0508 (0;-1.4876)
Long lag  18 - 24   16.7312 (0;-1.7286) 21.4786
(2;2.4726)**41.6646 (1;-0.6796)***
  24 - 30   29.5637 (1;-0.0951)**   37.4517
(1;0.1032)***   38.2729 (1;-0.3249)***
  30 - 36   23.0214 (0;-1.3023) 35.0403
(1;0.9176)***   36.0989 (1;-0.2141)***
  36 - 42   10.579 (1;0.3292)   31.4878
(0;-1.2475) 38.0472 (1;-0.3049)**
  42 - 48   17.9077 (1;-1.2857) 26.8651
(1;0.0221)***   30.5705 (1;-0.5866)***
  48 - 54   18.832 (0;-2.)  40.375 (1;-1.417)*
 26.2463 (1;0.4025)***
 latex(ftab,cgroup=attributes(ftab)$col.vars$voicetype, 
 rgroup=attributes(ftab)$row.vars$votcat, n.rgroup=c(6,6,6),file=)
% latex.default(ftab, cgroup = attributes(ftab)$col.vars$voicetype,   
  rgroup = attributes(ftab)$row.vars$votcat, n.rgroup = c(6, 
6, 6), file = )
%
\begin{table}[!tbp]
 \begin{center}
 \begin{tabular}{lclcl}\hline\hline
\multicolumn{1}{c}{\bfseries Voiced}
\multicolumn{1}{c}{\bfseries }
\multicolumn{1}{c}{\bfseries Voiceless unaspirated}
\multicolumn{1}{c}{\bfseries }
\multicolumn{1}{c}{\bfseries Voiceless aspirated}
\\ \cline{1-5}
\multicolumn{1}{c}{}
\multicolumn{1}{c}{}
\multicolumn{1}{c}{}
\multicolumn{1}{c}{}
\multicolumn{1}{c}{}
\\ \hline
\\
46.6158 (0;-1.6652)40.7417 (0;-0.6489)48.4164 (0;-1.0483)\\
50.5716 (0;-1.4244)**43.4056 (-1;-0.4537)***24.204 (0;-2.1416)\\
44.4439 (0;-1.182)*51.0996 (0;-1.5241)***32.1219 (0;-1.5007)\\
40.8604 (-1;-0.3423)40.6045 (-1;-0.408)**32.7949 (0;-2.75)\\
46.301 (0;-1.1878)21.6894 (0;-1.7041)NA (NA;NA)\\
38.0151 (-1;-0.7878)*27.6954 (-1;0.0396)*NA (NA;NA)\\
\hline
\\
7.5719 (1;0.4391)***9.7039 (1;-0.2938)***8.5525 (1;-0.4063)***\\
8.3466 (1;-0.3122)***9.8524 (0;-0.887)***11.4154 (0;-1.2267)***\\
9.4509 (1;-0.0795)***9.0177 (1;-0.2654)***9.441 (0;-0.7625)\\
9.4921 (1;-0.1835)***10.107 (0;-0.72)**10.912 (0;-1.3619)\\
7.8254 (1;1.016)**9.5687 (0;-0.9019)10.6842 (-1;0.0719)*\\
7.7332 (1;1.2834)**9.4626 (1;0.3173)***10.0508 (0;-1.4876)\\
\hline
\\
16.7312 (0;-1.7286)21.4786 (2;2.4726)**41.6646 (1;-0.6796)***\\
29.5637 (1;-0.0951)**37.4517 (1;0.1032)***38.2729 (1;-0.3249)***\\
23.0214 (0;-1.3023)35.0403 (1;0.9176)***36.0989 (1;-0.2141)***\\
10.579 (1;0.3292)31.4878 (0;-1.2475)38.0472 (1;-0.3049)**\\
17.9077 (1;-1.2857)26.8651 (1;0.0221)***30.5705 (1;-0.5866)***\\
18.832 (0;-2.)40.375 (1;-1.417)*26.2463 (1;0.4025)***\\
\hline
\end{tabular}

\end{center}

\end{table}

 

As you can see, I do not get any row names, and I want two layers of
them (votcat and age in the formula). Column names work ok.

Please, help me recreate the table above in latex form (if it is
indeed possible).

/Fredrik

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


Re: [R] Convert ftable to latex?

2005-08-30 Thread Fredrik Karlsson
Thank you so much David. 

That example provided me with enough information for me to convert the
table to latex, with
subdivisions intact.

/Fredrik

On 8/30/05, David Whiting [EMAIL PROTECTED] wrote:
 Hi Fredrik,
 
 What you need to do is to massage your table a little to get it into the
 appropriate structure and then use the rgroup and n.rgroup options.
 Here's an example using the Titanic data that come with R. Note that
 this is not necessarily (or even remotely likely?) the best way to get
 your data into the shape required, but hopefully it shows you what, in
 general, you need to do. You might find that you don't need to use
 ftable at all, you might find other ways of creating the table you need.
 In the example below, note in particular what x and x2 look like.
 
  library(Hmisc)
  x - ftable(Titanic, row.vars = 1:2)
  x
  Age  Child Adult
  SurvivedNo YesNo Yes
 Class Sex
 1st   Male0   5   118  57
   Female  0   1 4 140
 2nd   Male0  11   154  14
   Female  0  1313  80
 3rd   Male   35  13   387  75
   Female 17  1489  76
 Crew  Male0   0   670 192
   Female  0   0 3  20
  x.row.vars - attr(x, row.vars)
  col1 - x.row.vars[[1]]
  col2 - rep(x.row.vars[[2]], 4)
  x2 - data.frame(sex=col2, x[ ,])
  colnames(x2) - c(Sex, No, Yes, No, Yes)
  x2
  Sex No Yes  No Yes
 1   Male  0   5 118  57
 2 Female  0   1   4 140
 3   Male  0  11 154  14
 4 Female  0  13  13  80
 5   Male 35  13 387  75
 6 Female 17  14  89  76
 7   Male  0   0 670 192
 8 Female  0   0   3  20
  latex(x2,
 +   title=,
 +   rowname=,
 +   rgroup=col1,
 +   cgroup=c(, Child, Adult),
 +   n.cgroup=c(1, 2, 2),
 +   n.rgroup=rep(2, 4)
 +   )
 
 
 HTH.
 
 Dave
 
 
 Fredrik Karlsson wrote:
  Dear list,
 
  I cannot make the latex command to output a ftable objet the way I
  want it. Is it posible?
  I found a post in the archives saying that one should use the rgroup
  and n.rgroup arguments to supply the row names, but so far I have been
  unsuccessful.
 
  This is what I have:
 
 
 (ftable(tapply(worksub$vot,list(votcat=worksub$votcat,age=worksub$agemF,voicetype=worksub$Type),FUN=distribution.table.fun,digits=4))
  - ftab)
 
voicetype  Voiced   Voiceless
  unaspirated Voiceless aspirated
  votcatage
  Prevoiced 18 - 24   46.6158 (0;-1.6652) 40.7417
  (0;-0.6489) 48.4164 (0;-1.0483)
24 - 30   50.5716 (0;-1.4244)**   43.4056
  (-1;-0.4537)*** 24.204 (0;-2.1416)
30 - 36   44.4439 (0;-1.182)* 51.0996
  (0;-1.5241)***  32.1219 (0;-1.5007)
36 - 42   40.8604 (-1;-0.3423)40.6045
  (-1;-0.408)**   32.7949 (0;-2.75)
42 - 48   46.301 (0;-1.1878)  21.6894
  (0;-1.7041) NA (NA;NA)
48 - 54   38.0151 (-1;-0.7878)*   27.6954
  (-1;0.0396)*NA (NA;NA)
  Short lag 18 - 24   7.5719 (1;0.4391)***9.7039
  (1;-0.2938)***   8.5525 (1;-0.4063)***
24 - 30   8.3466 (1;-0.3122)***   9.8524
  (0;-0.887)***11.4154 (0;-1.2267)***
30 - 36   9.4509 (1;-0.0795)***   9.0177
  (1;-0.2654)***   9.441 (0;-0.7625)
36 - 42   9.4921 (1;-0.1835)***   10.107 (0;-0.72)**
   10.912 (0;-1.3619)
42 - 48   7.8254 (1;1.016)**  9.5687 (0;-0.9019)
   10.6842 (-1;0.0719)*
48 - 54   7.7332 (1;1.2834)** 9.4626
  (1;0.3173)***10.0508 (0;-1.4876)
  Long lag  18 - 24   16.7312 (0;-1.7286) 21.4786
  (2;2.4726)**41.6646 (1;-0.6796)***
24 - 30   29.5637 (1;-0.0951)**   37.4517
  (1;0.1032)***   38.2729 (1;-0.3249)***
30 - 36   23.0214 (0;-1.3023) 35.0403
  (1;0.9176)***   36.0989 (1;-0.2141)***
36 - 42   10.579 (1;0.3292)   31.4878
  (0;-1.2475) 38.0472 (1;-0.3049)**
42 - 48   17.9077 (1;-1.2857) 26.8651
  (1;0.0221)***   30.5705 (1;-0.5866)***
48 - 54   18.832 (0;-2.)  40.375 (1;-1.417)*
   26.2463 (1;0.4025)***
 
 latex(ftab,cgroup=attributes(ftab)$col.vars$voicetype, 
 rgroup=attributes(ftab)$row.vars$votcat, n.rgroup=c(6,6,6),file=)
 
  % latex.default(ftab, cgroup = attributes(ftab)$col.vars$voicetype,
rgroup = attributes(ftab)$row.vars$votcat, n.rgroup = c(6,
  6, 6), file = )
  %
  \begin{table}[!tbp]
   \begin{center}
   \begin{tabular}{lclcl}\hline\hline
  \multicolumn{1}{c}{\bfseries Voiced}
  \multicolumn{1}{c}{\bfseries }
  \multicolumn{1}{c}{\bfseries Voiceless unaspirated}
  \multicolumn{1}{c}{\bfseries }
  \multicolumn{1}{c}{\bfseries Voiceless aspirated}
  \\ \cline{1-5}
  \multicolumn{1}{c}{}
  \multicolumn{1}{c}{}
  \multicolumn{1}{c}{}
  \multicolumn{1}{c}{}
  \multicolumn{1}{c}{}
  \\ \hline
  \\
  46.6158 (0

[R] How do I make a Sweave + latex table out of this ?

2005-08-18 Thread Fredrik Karlsson
Dear list,

I have a table that I would like to convert to latex for inclusion
into a Sweave file.


 round(ftable(prop.table(xtabs(~agemF + votcat + Type , 
 data=work),margin=2))*100,1)
  Type Voiced Voiceless unaspirated Voiceless aspirated
agemF   votcat 
18 - 24 Prevoiced 2.6   8.7 2.3
 Short lag 5.8   6.7 5.1
Long lag  1.0   1.9 2.9
24 - 30 Prevoiced15.1  10.5 1.7
 Short lag 9.2  15.3 5.8
Long lag  3.5   8.115.8
30 - 36 Prevoiced12.8  14.0 2.6
Short lag10.2  14.2 3.0
Long lag  2.3   5.522.2
36 - 42 Prevoiced 4.4   6.4 0.6
   Short lag 4.0   5.9 1.5
   Long lag  1.3   2.9 9.4
42 - 48 Prevoiced 6.4   2.3 0.3
   Short lag 3.0   2.8 1.4
   Long lag  0.6   7.7 8.8
48 - 54 Prevoiced 4.9   4.1 0.3
Short lag 2.0   2.7 1.3
 Long lag  0.3   0.9 4.7


However, I have not been able to use this as a table. The Hmisc latex
command only accepts the input if I first convert it to a data.frame
format, and that makes the output much more difficult to read as it
duplicates the category levels of agemF.

Is there a way to do this?


/Fredrik Karlsson

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


[R] Not loading libraries

2005-08-10 Thread Fredrik Karlsson
Dear list,

I have a bunch of libraries that are automatically loaded when I start
the R environment. How do I remove them?

Output:
[EMAIL PROTECTED]:~/dokument/Thesis/Book$ make
Making file voicing.tex from voicing.Rnw
Loading Tcl/Tk interface ... done
Loading required package: tcltk
Loading required package: rgl
Loading required package: zoo
Loading required package: strucchange
Loading required package: sandwich
Loading required package: relimp
Loading required package: nnet
Loading required package: graphics
Loading required package: grDevices
Loading required package: stats
Loading required package: nlme
Loading required package: mvtnorm
Loading required package: multcomp
Loading required package: mgcv
This is mgcv 1.3-1
Loading required package: MASS
Loading required package: lmtest
Loading required package: lattice
Loading required package: grid
Loading required package: foreign
Loading required package: effects
Loading required package: car
Loading required package: abind
 library(tools); Sweave(voicing.Rnw)


/Fredrik

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


Re: [R] Not loading libraries

2005-08-10 Thread Fredrik Karlsson
Dear list,

I'm sorry about not providing all the necessary details. The R call is: 

library(tools); Sweave(\$*.Rnw\) | R --no-save -q

Using the --vanilla switch, I am able to keep the libraries  from
loading, but since I need some of the datasets in the .RData file, my
call to Sweave fails.
I have not been able to find loading of libraries in an ,Rprofile, and
my options contains this:

 options(defaultPackages)
$defaultPackages
[1] datasets  utils grDevices graphics  stats methods  

Prof. Ripley is right when assuming that the libraries are loaded
because of me trying out the Rcmdr GUI and then doing a save.image().
What I did not know was that I managed to  save the loading of
libraries at the same time. This is what I would like to undo.

/Fredrik




On 8/10/05, Prof Brian Ripley [EMAIL PROTECTED] wrote:
 On Wed, 10 Aug 2005, Fredrik Karlsson wrote:
 
  I have a bunch of libraries that are automatically loaded when I start
  the R environment. How do I remove them?
 
 By undoing what you did to get them there.
 
 `make' is not the usual way to start R: try R --vanilla and see what
 happens (probably none of this).  Then read ?Startup and try just 'R'.
 
 My guess is that has something to do loading Rcmdr afer having set R to
 run with no default packages, but we have no evidence of how you ran R.
 
  Output:
  [EMAIL PROTECTED]:~/dokument/Thesis/Book$ make
  Making file voicing.tex from voicing.Rnw
  Loading Tcl/Tk interface ... done
  Loading required package: tcltk
  Loading required package: rgl
  Loading required package: zoo
  Loading required package: strucchange
  Loading required package: sandwich
  Loading required package: relimp
  Loading required package: nnet
  Loading required package: graphics
  Loading required package: grDevices
  Loading required package: stats
  Loading required package: nlme
  Loading required package: mvtnorm
  Loading required package: multcomp
  Loading required package: mgcv
  This is mgcv 1.3-1
  Loading required package: MASS
  Loading required package: lmtest
  Loading required package: lattice
  Loading required package: grid
  Loading required package: foreign
  Loading required package: effects
  Loading required package: car
  Loading required package: abind
  library(tools); Sweave(voicing.Rnw)
  
 
 --
 Brian D. Ripley,  [EMAIL PROTECTED]
 Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
 University of Oxford, Tel:  +44 1865 272861 (self)
 1 South Parks Road, +44 1865 272866 (PA)
 Oxford OX1 3TG, UKFax:  +44 1865 272595


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


Re: [R] Groups in histograms?

2005-08-09 Thread Fredrik Karlsson
Dear list,

Sorry for answering my own post, but I have had partial sucess in
this. With the panel function below, I get separate histograms in each
panel using the group argument.

histogram(~vot | agem, nint=50,data=work,groups=Type, subset=agem  24
 agem  30, panel=panel.grouphist,type=count,ylim=c(0,20),auto.key=T)

panel.grouphist - function(x,groups,...){
  add - T
  grouplevels - unique(groups)
  ngroups - length(grouplevels)
  
  for(i in 1:ngroups){
gcol - trellis.par.get(superpose.fill)$col[i]
gx - x[groups == grouplevels[i]]
panel.histogram(gx,col=gcol,...)
  }

}

However, the color I get in the key using simpleKey is not the same as
the one in the the plot.
How do I get the two functions to use the same color scale?

/Fredrik

On 8/8/05, Fredrik Karlsson [EMAIL PROTECTED] wrote:
 Hi Gary,
 
 I have found this, but it is not exactly what I am looking for.
 What I need is the groups to be inside of a single panel, not in
 different panels.
 Kind of like an histogram version of the xyplot(Y ~ X1,
 groups=X2,panel=panel.superpose) command. (I hope this is correct).
 
 /Fredrik
 
 On 8/8/05, Gary Collins [EMAIL PROTECTED] wrote:
  Have a look at the histogram function in the Lattice package.
 
  if x are your data to be displayed and y is your grouping variable you
  can just do
 
   histogram(~x|y)
 
  HTH
  Gary
 
  On 08/08/05, Fredrik Karlsson [EMAIL PROTECTED] wrote:
   Dear list,
  
   I would like to create histograms for up to three groups, with
   distincive colour/pattern, in a trellis panel. However, I have not
   been able to find a way to do this. histogram does not seem to have a
   group argument.
  
   Please help.
  
   /Fredrik
  
   __
   R-help@stat.math.ethz.ch mailing list
   https://stat.ethz.ch/mailman/listinfo/r-help
   PLEASE do read the posting guide! 
   http://www.R-project.org/posting-guide.html
  
 

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


[R] Groups in histograms?

2005-08-08 Thread Fredrik Karlsson
Dear list,

I would like to create histograms for up to three groups, with
distincive colour/pattern, in a trellis panel. However, I have not
been able to find a way to do this. histogram does not seem to have a
group argument.

Please help.

/Fredrik

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


Re: [R] Groups in histograms?

2005-08-08 Thread Fredrik Karlsson
Hi Gary,

I have found this, but it is not exactly what I am looking for. 
What I need is the groups to be inside of a single panel, not in
different panels.
Kind of like an histogram version of the xyplot(Y ~ X1,
groups=X2,panel=panel.superpose) command. (I hope this is correct).

/Fredrik

On 8/8/05, Gary Collins [EMAIL PROTECTED] wrote:
 Have a look at the histogram function in the Lattice package.
 
 if x are your data to be displayed and y is your grouping variable you
 can just do
 
  histogram(~x|y)
 
 HTH
 Gary
 
 On 08/08/05, Fredrik Karlsson [EMAIL PROTECTED] wrote:
  Dear list,
 
  I would like to create histograms for up to three groups, with
  distincive colour/pattern, in a trellis panel. However, I have not
  been able to find a way to do this. histogram does not seem to have a
  group argument.
 
  Please help.
 
  /Fredrik
 
  __
  R-help@stat.math.ethz.ch mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide! 
  http://www.R-project.org/posting-guide.html
 
 


-- 
My Gentoo + PVR-350 + IVTV + MythTV blog is on  
http://gentoomythtv.blogspot.com/

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


[R] wapply from gplots -- How do I get a local estimate of variance?

2005-06-17 Thread Fredrik Karlsson
Dear list,

I am trying to plot the local variance in a moving window on a
dataset. The function that I am trying to use for this is wapply from
gtools.

However, from the lattice panel function code:

snip
cat(x)
cat(y)
wapply(x,y,method=range,width=1/10,fun=sd,na.rm=TRUE) - outvar
/snip

I get:

snip
109 109 109 109 109 109 116 116 116 116 119 119 123 123 123 123 127
127 133 133 133 133 133 138 138 138 138 138 138 138 138138 138 138 142
142 142 142 142 142 142 147 147 147 147 147 158 158 158 158 158 158
158 158 158 158 158 158 158
20.234 28.431 10.762 45.613 15.028 10.775 18.516 13.371 18.516 13.371
20.61 31.08 9.338 210.77 11.927 39.438 -35.079 15.872 12.272
9.1122.665 7.355 22.057 -49.289 11.212 16.236 20.654 16.236 20.654
15.181 57.271 37.513 57.271 37.513 8.518 -108.517 -14.444 10.702 4.482
16.422 23.003 42.451 12.998 42.451 12.998 14.292 5.945 7.115 16.079
-13.172 10.62 16.079 -13.172 10.62 16.079 -13.172 10.62 20.477 22.656
Error in var(x, na.rm = na.rm) : 'x' is empty
/snip

What am I doing wrong with this? The variables that I think is
supplied to the var function does not seem to be empty like the error
message suggests.

The gplots package is from the 2.0.7 version of the gregmisc bundle.


/Fredrik Karlsson

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


[R] Subset with selection variable from function argument. Is there another way?

2005-05-11 Thread Fredrik Karlsson
Dear list,

I'm making my current code more generic and would like some advise.
The basic problem is subset and the name of the column to be compared
for selection.

What I've come up with is 

 data(mammals)
 set - bottompremolars
 subset(mammals, eval(parse(file=,text=set))  2)

This seems a bit odd.  Is there a nicer way?

/Fredrik

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


[R] Maxima/minima of loess line?

2004-08-24 Thread Fredrik Karlsson
Dear list,

I've produced a loess line that I would like to investigate in terms of 
local/global maxima and minima. How would you do this?

Thank you in advance.

/Fredrik Karlsson

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


Re: [R] R and unix tool 'screen'

2004-01-28 Thread Fredrik Karlsson
Hej Giampiero!

Odd. Using Screen version 3.09.11 and R-1.8.0 on a
Debian system, R does not trap C-a. I can fire up R in a screen, create
a new screen with C-a c and even detach/reattach the screen session.
The terminal emulator is xterm.

Perhaps you are using a terminal that traps the C-a? (just a wild 
guess..).

Mvh,

/Fredrik Karlsson

On Tue, Jan 27, 2004 at 06:02:53PM +0100, Giampiero Salvi wrote:
 I have problems running R with screen. For those who don't know,
 screen is a unix tool that is quite handy if you want to leave
 a process (that outputs to tty) running when you logout, and
 then recover the session later on.
 
 It works like this:
 1) run 'screen': you get a normal prompt as if you were in a normal
 shell.
 2) run whatever command you like
 3) press 'C-a d' to detach the session. Now you can logoff if you like
 4) when you want to recover the session type 'screen -r'
 
 The problem is that R seems to catch the 'C-a' signal, and nothing happens.
 Since there is no way to detach the screen, there is no use to it either.
 
 Is there a way around this problem?
 
 Giampiero

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] bartlett.test in a cell?

2003-12-11 Thread Fredrik Karlsson
Dear list,

I want to apply the bartlett test of homogenity of variance between two
groups in a cell, which in turn is  created by a number of factors.

Is there a way to do this without having a zillion loops around the
data? I've played around with tapply and aggregate, but it seems the
problem with these approaches is that the 'groups' variable will have
to be supplied.

Any thoughts on how I might do this?

/Fredrik

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] Help regarding repeated measures needed.

2003-09-28 Thread Fredrik Karlsson
Dear list, 

I feel that I have to contact you for help with the data set I
collected. It concerns longitudinal data from acoustic measurements
conducted at monthly invervals during the development of a group of
children. In the synchronic perspective, I have found that it is highly
unlikely that the data is normally distributed. Furthermore, other
studies have shown a decreasing variance with increasing age.

So, what I want to ask you is: 

1) What do I do with this data. Is it possible to do statistical
analysis on this?

2) What approach do you recommend? What are the potential draw-backs?

3) Do you have some litterature suggestions for me?

4) If there is something that I can do, is it implemented in R? 


I'm sure that you can tell that I would be happy for any help I could
get on this issue.

/Fredrik Karlsson

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] sqlSave() Question

2003-04-05 Thread Fredrik Karlsson
Hi,

I asked the same question to this list previously this week. 
The solution to the problem may be to use the 'case' argument to
odbcConnect. 

See my previous post as well as the reply by Prof. Ripley.

/Fredrik Karlsson



On Fri, Apr 04, 2003 at 04:57:59PM -0600, Minghua Yao wrote:
 All,
 
 I am new in R. I found sqlSave() doesn't work for our Oracle9i. The
 following was the message:
 
  sqlSave(channel, USArrests, rownames=state)
 Error in sqlColumns(channel, tablename) : USArrests : table not found on
 channel
 Check case parameter in odbcConnect
 
 
 sqlQuery() works OK.
 
 Please help. Thanks.
 
 -MY
 
 __
 [EMAIL PROTECTED] mailing list
 https://www.stat.math.ethz.ch/mailman/listinfo/r-help

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] RODBC sqlSave problem.

2003-04-01 Thread Fredrik Karlsson
Dear list,

Being new to both the postgres database, ODBC and the RODBC interface, I
am somewhat confused by some of the problems I am experiencing trying to
connect R to the database.

Whai I am trying is basically the example part of the help file for the 
sqlSave function:

 library(RODBC)
 odbcConnect(theodor) - channel
 data(USArrests)
 sqlSave(channel, USArrests, verbose = TRUE)
Query: CREATE TABLE USArrests  (rownames varchar(255)  ,Murder float8
,Assault int4  ,UrbanPop int4  ,Rape float8  )
Error in sqlSave(channel, USArrests, verbose = TRUE) : 
[RODBC] ERROR: Could not SQLExecute

When issuing this comamnd, a table is created in the specified database,
with fields corresponding to names(USArrests), except in lower case, but 
the fiels contain no data. 

Does anyone know the reason for this? One of my guesses is that the
table and field names are converted into lower cases by the database
manager, which would result in an error due to  non-existent symbols
when RODBC tries to inser the data.
Is this a possibility? Does anyone know how to investigate this?

Are there alternative explanations?

I would, of course, be extremely greateful for all the help I can get.



/Fredrik Karlsson

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] Regexpr capturing in R?

2002-12-21 Thread Fredrik Karlsson


msg.pgp
Description: PGP message