[R] lattice: adding information on number of observations

2009-12-01 Thread RINNER Heinrich
Dear R-users,

I am using R version 2.9.1 and lattice 0.17-26 under windows.
In a lattice boxplot, I would like to add information on how many observations 
each singel boxplot is based upon.

For example (the basic plot):
# Begin R-code
library(lattice)
dat <- data.frame(panvar = rep(c("A","B","A","B"), c(3,7,4,6)), grp = 
rep(c("grp1", "grp2"), c(10,10)), val = rnorm(20))
dat
bwplot(val ~ grp | panvar, data = dat)
# End R-code

As in my real life data the number of observations in each subgroup will be 
quite different, I would like to include the number of observations each 
boxplot is based upon.
Aggregation will tell me the numbers:
# Begin R-code
aggregate(dat$val, by = list(dat$panvar, dat$grp), FUN = length)
# End R-code
But how to match these numbers with the plot (so that for example "n=3" will be 
written as text beneath panel A/group1)?

Any advice would be appreciated;
kind regards
Heinrich.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 run to or more R consoles on Mac OS X?

2009-12-01 Thread chronos.phenomena

Thanks Don

Sent from my iPhone

On 2 Dec 2009, at 06:16, "Don MacQueen [via R]" 
 wrote:

> If myscript.r has as its first line:
>
>#! /usr/bin/Rscript
>
> and you make it executable
> chmod +x myscript.r
>
> Then you can run it by giving the command
>
>./myscript.r
>
>
> -Don
>
> At 3:03 PM -0800 11/30/09, chronos.phenomena wrote:
>
> >Thanks... that worked
> >
> >is there a way to run r script?
> >
> >for example open -n /Applications/R.app myscript.r
> >
> >
> >when I use this syntax... I get my script file opened but not  
> executed :(
> >
> >Thanks in advance
> >
> >
> >
> >Ken Knoblauch wrote:
> >>
> >>  chronos.phenomena  gmail.com> writes:
> >>
> >>>
> >>>
> >>>  This is really annoying me... when I click R application icon  
> it brings
> >>>  already opened session in the focus and it DOESN'T open new  
> session
> >>>
> >>>  any ideas?
> >>
> >>  In Leopard from a terminal, you can try
> >>
> >>  open -n /Applications/R.app
> >>
> >>  to open as many copies of the app as you like.  Be careful though,
> >>  because these inherit environment variables from the terminal
> >>  session, not necessarily the same as those when running the
> >>  app from the Finder.  I was bitten by that the first time I
> >>  tried this.
> >>
> >>  Ken
> >>
> >>  --
> >>  Ken Knoblauch
> >>  Inserm U846
> >>  Stem-cell and Brain Research Institute
> >>  Department of Integrative Neurosciences
> >>  18 avenue du Doyen Lépine
> >>  69500 Bron
> >>  France
> >>  tel: +33 (0)4 72 91 34 77
> >>  fax: +33 (0)4 72 91 34 61
> >>  portable: +33 (0)6 84 10 64 10
> >>  http://*www.*sbri.fr/members/kenneth-knoblauch.html
> >>
> >>  __
> >>  [hidden email] mailing list
> >>  https://*stat.ethz.ch/mailman/listinfo/r-help
> >>  PLEASE do read the posting guide
> >>  http://*www.*R-project.org/posting-guide.html
> >>  and provide commented, minimal, self-contained, reproducible code.
> >>
> >>
> >
> >--
> >View this message in context:
> >http://*n4.nabble.com/How-do-I-run-to-or-more-R-consoles-on-Mac-OS-X-tp930979p931723.html
> >Sent from the R help mailing list archive at Nabble.com.
> >
> >__
> >[hidden email] mailing list
> >https://*stat.ethz.ch/mailman/listinfo/r-help
> >PLEASE do read the posting guide 
> >http://*www.*R-project.org/posting-guide.html
> >and provide commented, minimal, self-contained, reproducible code.
>
>
> -- 
> -
> Don MacQueen
> Lawrence Livermore National Laboratory
> Livermore, CA, USA
> 925-423-1062
> [hidden email]
>
> __
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>
> View message @ 
> http://n4.nabble.com/How-do-I-run-to-or-more-R-consoles-on-Mac-OS-X-tp930979p932807.html
> To unsubscribe from Re: How do I run to or more R consoles on Mac OS  
> X?, click here.
>

-- 
View this message in context: 
http://n4.nabble.com/How-do-I-run-to-or-more-R-consoles-on-Mac-OS-X-tp930979p932846.html
Sent from the R help mailing list archive at Nabble.com.

[[alternative HTML version deleted]]

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


Re: [R] Multiple grouping on the X axis.

2009-12-01 Thread Jim Lemon

On 12/02/2009 05:07 AM, Munin wrote:

I am trying to plot data with multiple logical and physical groups using
R.  Below is a sample of the kind of data I am working with and the desired
output.  We have a jmp script that can do the same thing, but at ~$200 a
year the licensing is counterproductive.  Thanks for any help.

Data input: Loaded from a CSV file.
Physical_1 Logical_1 Logical_2 Data_1 Data_2
x   Y   Z2  54   56
x   Y2 Z2  53   55
x   Y3 Z2  52   54
x2 Y   Z60   58
x2 Y2 Z59   57
x2 Y3 Z58   56
x3 Y   Z56   53
x3 Y2 Z55   52
x3 Y3 Z54   51
x4 Y   Z2  52   55
x4 Y2 Z2   51   54
x4 Y3 Z2   50   53


I need the graph to be grouped as follows:
-
|Y|Y2|Y3|Y|Y2|Y3|Y|Y2|Y3|Y|Y2|Y3|
-
| X|  X4  |  X2   |  X3  |
-
|   Z   |Z2 |
-

Again, any help would be appreciated.
   

Hi Munin,
Look at hierobarp in the plotrix package. The current version doesn't 
have the recently programmed option to pass a list of arrays with the 
values, so if you want this capability, I will email the new code.


Jim

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

2009-12-01 Thread Megh

Thanks Ista for your mail. Here I wanted to have control on color-pallet. It
is because, here my entire plot window is subdivided in 3 sub-plots
horizontally, on basis if a factor-variable which contains three factors, 
using facet_grid(). Each sub-plot contains scatter-plot. I want to color the
points of each scatter-plot based on the corresponding factor (contained in
factor-variable). Therefore as you might agree in this case, there is no
need for additional color-pallet as the factor-description is handled by
facet_grid() function itself.

Any better idea how I can hide color-pallet?

Thanks,



Ista Zahn wrote:
> 
> There was a recent discussion of the ggplot2 mailing list about a
> similar issue. The first question is how will people know what the
> colors mean if you remove the legend?
> 
> -Ish
> 
> On Tue, Dec 1, 2009 at 11:41 PM, Megh  wrote:
>>
>> Let consider following plot :
>>
>> p <- ggplot(mtcars, aes(mpg, wt))
>>     p + geom_point(colour="grey50", size = 4) + geom_point(aes(colour =
>> cyl))
>>
>> Now I want R to hide the color-pallet on "cyl", placed in the right edge
>> completely. Can anyone please guide me how to do that?
>>
>> Thanks,
>> --
>> View this message in context:
>> http://n4.nabble.com/A-ggplot-question-tp932775p932775.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.
>>
> 
> 
> 
> -- 
> Ista Zahn
> Graduate student
> University of Rochester
> Department of Clinical and Social Psychology
> http://yourpsyche.org
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 

-- 
View this message in context: 
http://n4.nabble.com/A-ggplot-question-tp932775p932837.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] explanation for left-side behaviour

2009-12-01 Thread Don MacQueen

Read the help page for substr().
It says that the first argument should be a character vector.
The only one that works is the one where you gave it a character vector.

You said only third one "works". But you didn't explain what you mean 
by "works". It's always a good idea on r-help to show both what you 
expected, and what you actually got, so that people can understand 
exactly what the question is.


To explain a little further, let me number your three approaches.

[1]  substr(values,2,3) <- ".."

[2] substr(as.character(values),2,3) <- ".."

values <- as.character(values)
[3] substr(values,2,3) <- ".."

With regard to case [1]
It makes no sense to replace character substrings in a factor. 
factors are really numbers, not characters. It's just that they have 
additional attributes that make them (sometimes) print as if the were 
characters. But they're not. And the error message (that you didn't 
report) says exactly that.


With regard to case [2]:
values and as.character(values) are not the same thing.
Therefore, replacing substrings in as.character(values) is not the 
same as replacing substrings in values. In this case, I would 
interpret the error message to indicate that R is trying to replace 
characters in a function. That makes sense, because you supplied a 
function, namely, as.character().


Case [3] works because you supplied a character vector.

-Don

At 9:57 AM +0100 12/1/09, Antje wrote:

Hi there,

I'm pretty sure that it's written down somewhere but I cannot find it so far.

The little example shows different approaches to replace a 
substring. Only the last one works. I think it has something to do 
with the fact that "substr" is used on the left side. Can anybody 
refer to an explanation for this behaviour?


Thanks a lot in advance!

Antje



values <- factor(c(rep("abc",3), rep("bcd",3), rep("cde",3)))

substr(values,2,3) <- ".."
substr(as.character(values),2,3) <- ".."

values <- as.character(values)
substr(values,2,3) <- ".."

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



--
-
Don MacQueen
Lawrence Livermore National Laboratory
Livermore, CA, USA
925-423-1062
m...@llnl.gov

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

2009-12-01 Thread xlr82sas



ychu066 wrote:
> 
> my teachers doesnt understand R and I don't know how to use SAS.  
> Anyone interested in translating my codes to test whether your SAS codes
> are as good as R???
>  I can test it on SAS codes once you have translated it  
> 
> 
> 
> regards:working:
> 

It is quite easy to convert R to SAS IML. Here is an example of R/S+ code
and SAS IML code. It is not exactly the same problem but is very colse.

I find IML has much of the same functiionality of R, but R blows SAS away
with the 2000+ packages out there.

R/S+ CODE

a=c(2,2,1,0,1,0,1,5,1,1,0,2,2,2,2,1,1,2,3,0,0,0,1,1,0,2,1,1,1,1,0,1,0,1,1,1,1,0,1,1,15,27,0,0,0,0,0,0)
b=c(355,389,773,213,231,43,120,105,381,283,294,561,276,416,393,202,103,210,135,196,122,175,55,38,561,114,147,230,88,167,116,1171,706,203,287,253,313,162,441,393,2620,1429,101,232,70,25,196,676)
c=c(0,1,1,1,0,1,0,2,0,0,1,0,1,0,1,1,2,0,1,0,1,1,0,0,2,3,0,0,0,0,0,0,0,2,0,0,0,0,0,0,9,41,0,0,0,0,0,0)
d=c(176,206,184,108,116,46,124,112,384,135,301,142,278,212,197,105,97,107,138,96,119,172,58,38,274,108,143,242,88,172,61,377,325,183,280,272,154,160,112,124,2625,2854,51,115,75,24,195,225)
n <- a+b+c+d
Rr <- (c+d)/(a+b)
k.T <- 1/(Rr+1)
k.C <- Rr/(Rr+1)
OR.i <- ((a+k.T)*(d+k.C))/((b+k.T)*(c+k.C))
varlnOR.i <- 1/(a+k.T)+1/(b+k.T)+1/(c+k.C)+1/(d+k.C)
w.i <- 1/varlnOR.i
plogOR.i <- sum(w.i*log(OR.i))/sum(w.i)
pvarlogOR.i <- 1/sum(w.i)
pOR.iv.i <- exp(plogOR.i)
l.pOR.iv.i <- exp(plogOR.i-qnorm(.975)*sqrt(pvarlogOR.i))
u.pOR.iv.i <- exp(plogOR.i+qnorm(.975)*sqrt(pvarlogOR.i))

SAS CODE

Just to read a bunch of columns rom s SAS dataset(dataframe in R)
use inv1st(keep=Key)  ;read all var _num_ into keyxpo;
use inv1st(keep=TrtEvn)   ;read all var _num_ into axpo;
use inv1st(keep=TrtNonEvn);read all var _num_ into bxpo;
use inv1st(keep=CtlEvn)   ;read all var _num_ into cxpo;
use inv1st(keep=CtlNonEvn);read all var _num_ into dxpo;

/* Vertical to horizontal */
a=axpo`;  * The apostrophe means transpose;
b=bxpo`;
c=cxpo`;
d=dxpo`;
key=keyxpo`;

Rr=(c+d)/(a+b); * ratio of control vs trtment group sizes;
k_T=1/(Rr+1);
k_C=Rr/(Rr+1);

OR_C_R = ((a+k_T)#(d+k_C))/((b+k_T)#(c+k_C));
VAR_OR_C_R = 1/(a+k_T) + 1/(b+k_T) + 1/(c+k_C) + 1/(d+k_C);
W_R = 1/VAR_OR_C_R;

LOG_OR_IV_R = sum(W_R#log(OR_C_R))/sum(W_R);
VAR_LOG_OR_IV_R = 1/sum(W_R);

OR_IV_R = exp(LOG_OR_IV_R);
OR_IV_UP_R = exp(LOG_OR_IV_R + probit(.975)#sqrt(VAR_LOG_OR_IV_R));
OR_IV_LOW_R = exp(LOG_OR_IV_R - probit(.975)#sqrt(VAR_LOG_OR_IV_R));

CC_TA=shape({0},1,3,0);
CC_TA= OR_IV_R||OR_IV_LOW_R||OR_IV_UP_R;
create CC_TA from CC_TA;append from CC_TA;

-- 
View this message in context: 
http://n4.nabble.com/Translation-from-R-codes-to-SAS-tp819110p932816.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] How do I run to or more R consoles on Mac OS X?

2009-12-01 Thread Don MacQueen

If myscript.r has as its first line:

  #! /usr/bin/Rscript

and you make it executable
   chmod +x myscript.r

Then you can run it by giving the command

  ./myscript.r


-Don

At 3:03 PM -0800 11/30/09, chronos.phenomena wrote:

Thanks... that worked

is there a way to run r script?

for example open -n /Applications/R.app myscript.r


when I use this syntax... I get my script file opened but not executed :(

Thanks in advance



Ken Knoblauch wrote:


 chronos.phenomena  gmail.com> writes:




 This is really annoying me... when I click R application icon it brings
 already opened session in the focus and it DOESN'T open new session

 any ideas?


 In Leopard from a terminal, you can try

 open -n /Applications/R.app

 to open as many copies of the app as you like.  Be careful though,
 because these inherit environment variables from the terminal
 session, not necessarily the same as those when running the
 app from the Finder.  I was bitten by that the first time I
 tried this.

 Ken

 --
 Ken Knoblauch
 Inserm U846
 Stem-cell and Brain Research Institute
 Department of Integrative Neurosciences
 18 avenue du Doyen Lépine
 69500 Bron
 France
 tel: +33 (0)4 72 91 34 77
 fax: +33 (0)4 72 91 34 61
 portable: +33 (0)6 84 10 64 10
 http://*www.*sbri.fr/members/kenneth-knoblauch.html

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




--
View this message in context: 
http://*n4.nabble.com/How-do-I-run-to-or-more-R-consoles-on-Mac-OS-X-tp930979p931723.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.



--
-
Don MacQueen
Lawrence Livermore National Laboratory
Livermore, CA, USA
925-423-1062
m...@llnl.gov

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

2009-12-01 Thread Don MacQueen

This looks like a job for match().


 vec = c("C", "A", "B")

 dataDF = data.frame(A1 = c("B", "A", "C"), A2 = c(1,2,3))


 dataDF[match(dataDF$A1,vec),]

  A1 A2
3  C  3
2  A  2
1  B  1

-Don


At 10:36 PM -0500 12/1/09, Hao Cen wrote:

Hi,



I have a a vector  and a data frame with two columns

vec = c("C", "A", "B")

dataDF = data.frame(A1 = c("B", "A", "C"), A2 = c(1,2,3))



I would like to sort the data frame by column A1 such that the order of
elements in A1 is as the same as in vec.



After the ordering, the data frame would be

A1   A2

C 3

A 2

B 1



Any suggestions would be appreciated.



Thanks in advance



Jeff


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



--
-
Don MacQueen
Lawrence Livermore National Laboratory
Livermore, CA, USA
925-423-1062
m...@llnl.gov

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


Re: [R] How to export a function from a package and access it only by specifying the namespace?

2009-12-01 Thread Sharpie


Peng Yu wrote:
> 
> Then I try the package 'try.package' in an R session. I'm wondering
> why neither 'my_test_f' and 'try.package::my_test_f' work. 
> 

The error message you got below clearly explains this-- you did not export
my_test_f in your NAMESPACE file.  To access unexported functions, you must
use the ':::' operator:

  try.package:::my_test_f()



Peng Yu wrote:
> 
> Why 'my_test_g' can be accessed with 'try.package::' and without
> 'try.package::'?
> 

Because you exported it in the NAMESPACE file.



Peng Yu wrote:
> 
> Is there a way to make  'my_test_g' accessible only by specifying the
> namespace 'try.package::'?
> 

No.

The purpose of the '::' operator is for those cases where multiple packages
are loaded that each export a function with the same name.  This is known as
"masking" and the last loaded package will contribute the dominant
function-- i.e. the function the gets called when the user types
"functionName()" and not "packageName::functionName()".  The "::" operator
allows the selection of functions that are masked by the dominant function.

If you really want to conceal a function from user-level code, don't export
it and it will only be accessible via the ":::" operator.



Peng Yu wrote:
> 
>> library(try.package)
>> try.package::my_test_g
> function ()
> {
> print("Helloggg")
> }
> 
>> my_test_g
> function ()
> {
> print("Helloggg")
> }
> 
>> my_test_f
> Error: object "my_test_f" not found
>> try.package::my_test_f
> Error: 'my_test_f' is not an exported object from 'namespace:try.package'
> 
-- 
View this message in context: 
http://n4.nabble.com/How-to-export-a-function-from-a-package-and-access-it-only-by-specifying-the-namespace-tp932776p932798.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] A ggplot question

2009-12-01 Thread Ista Zahn
There was a recent discussion of the ggplot2 mailing list about a
similar issue. The first question is how will people know what the
colors mean if you remove the legend?

-Ish

On Tue, Dec 1, 2009 at 11:41 PM, Megh  wrote:
>
> Let consider following plot :
>
> p <- ggplot(mtcars, aes(mpg, wt))
>     p + geom_point(colour="grey50", size = 4) + geom_point(aes(colour =
> cyl))
>
> Now I want R to hide the color-pallet on "cyl", placed in the right edge
> completely. Can anyone please guide me how to do that?
>
> Thanks,
> --
> View this message in context: 
> http://n4.nabble.com/A-ggplot-question-tp932775p932775.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.
>



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

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


[R] How to export a function from a package and access it only by specifying the namespace?

2009-12-01 Thread Peng Yu
I have the following test package.

$ ls
DESCRIPTION  man  NAMESPACE  R
$ cat DESCRIPTION
Package: try.package
Type: Package
Title: What the package does (short line)
Version: 1.0
Date: 2009-10-26
Author: Who wrote it
Maintainer: Who to complain to 
Description: More about what it does (maybe more than one line)
License: What license is it under?
LazyLoad: yes
$ cat NAMESPACE
export(
my_test_g
)
$ ls R
my_test_f.R  randomxx.R
$ for f in R/*.R; do echo $f; cat $f;done
R/my_test_f.R
my_test_f<-function() {
  print("Hello")
}
R/randomxx.R
my_test_g<-function() {
  print("Helloggg")
}




I install the package by

R CMD INSTALL -l /path/to/R_user --no-docs my_package

`my_package' is the directory where the package is in.

Then I try the package 'try.package' in an R session. I'm wondering
why neither 'my_test_f' and 'try.package::my_test_f' work. Why
'my_test_g' can be accessed with 'try.package::' and without
'try.package::'?

Is there a way to make  'my_test_g' accessible only by specifying the
namespace 'try.package::'?

> library(try.package)
> try.package::my_test_g
function ()
{
print("Helloggg")
}

> my_test_g
function ()
{
print("Helloggg")
}

> my_test_f
Error: object "my_test_f" not found
> try.package::my_test_f
Error: 'my_test_f' is not an exported object from 'namespace:try.package'

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

2009-12-01 Thread Megh

Let consider following plot :

p <- ggplot(mtcars, aes(mpg, wt))
 p + geom_point(colour="grey50", size = 4) + geom_point(aes(colour =
cyl))

Now I want R to hide the color-pallet on "cyl", placed in the right edge
completely. Can anyone please guide me how to do that?

Thanks,
-- 
View this message in context: 
http://n4.nabble.com/A-ggplot-question-tp932775p932775.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] Re How to remove R banner?

2009-12-01 Thread Charlotte Maia
Hi,

Annoying
I love it (except possibly when re-directing standard out to a file).

I think it's one of the command line options (in which case, it will
be clearly documented).
No idea how it works on the GUI systems (maybe an option somewhere...).

In saying that, I have to assume that if people (you?) want control
over R, they are using the *command line in the first place. The GUI
systems represent a complete loss of control (esp the mac version,
omg).

There's always that in-between group who use Emacs/ESS, won't go there...

*I use gnome-terminal + bash, plus a mixture of text editors.

regards
-- 
Charlotte Maia
http://sites.google.com/site/maiagx/home

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


Re: [R] How to remove R banner?

2009-12-01 Thread Sharpie


Peng Yu wrote:
> 
> I always see a banner like the following, which is annoying. I'm
> wondering how to disable it.
> 
> R version 2.7.1 (2008-06-23)
> Copyright (C) 2008 The R Foundation for Statistical Computing
> ISBN 3-900051-07-0
> 
> R is free software and comes with ABSOLUTELY NO WARRANTY.
> You are welcome to redistribute it under certain conditions.
> Type 'license()' or 'licence()' for distribution details.
> 
>   Natural language support but running in an English locale
> 
> R is a collaborative project with many contributors.
> Type 'contributors()' for more information and
> 'citation()' on how to cite R or R packages in publications.
> 
> Type 'demo()' for some demos, 'help()' for on-line help, or
> 'help.start()' for an HTML browser interface to help.
> Type 'q()' to quit R.
> 

Launch R from the command line and specify the --quiet flag:

  R --quiet

I'm not sure if this functionality can be invoked using the GUI versions.

-Charlie
-- 
View this message in context: 
http://n4.nabble.com/How-to-remove-R-banner-tp932756p932768.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] How to remove R banner?

2009-12-01 Thread Ben Bolker
Peng Yu  gmail.com> writes:

> I always see a banner like the following, which is annoying. I'm
> wondering how to disable it.

R --quiet

(it took about 8 seconds to find this with R --help)

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


Re: [R] sort a data frame by a vector

2009-12-01 Thread David Winsemius


On Dec 1, 2009, at 10:59 PM, jim holtman wrote:

The factor statement should have been:  (missed the 'vec' on the  
first reading)


dataDF$A1 <- factor(dataDF$A1, levels=vec)


It's not necessary to alter the data.frame. You can use the results of  
the construction above as the row index and still keep the original  
order:


> dataDF[factor(dataDF$A1, levels=vec), ]
  A1 A2
3  C  3
2  A  2
1  B  1

> dataDF
  A1 A2
1  B  1
2  A  2
3  C  3

--
David.


On Tue, Dec 1, 2009 at 10:57 PM, jim holtman   
wrote:

Is this what you want:


dataDF = data.frame(A1 = c("B", "A", "C"), A2 = c(1,2,3))
dataDF

 A1 A2
1  B  1
2  A  2
3  C  3

dataDF[order(dataDF$A1),]

 A1 A2
2  A  2
1  B  1
3  C  3




If you want the sequence "CAB" then you will have to change the
factors in column 1:


dataDF$A1 <- factor(dataDF$A1, levels=c("C", "A", "B"))
dataDF[order(dataDF$A1),]

 A1 A2
3  C  3
2  A  2
1  B  1





On Tue, Dec 1, 2009 at 10:36 PM, Hao Cen  wrote:

Hi,



I have a a vector  and a data frame with two columns

vec = c("C", "A", "B")

dataDF = data.frame(A1 = c("B", "A", "C"), A2 = c(1,2,3))



I would like to sort the data frame by column A1 such that the  
order of

elements in A1 is as the same as in vec.



After the ordering, the data frame would be

A1   A2

C 3

A 2

B 1



Any suggestions would be appreciated.



Thanks in advance



Jeff


   [[alternative HTML version deleted]]

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





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

What is the problem that you are trying to solve?





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

What is the problem that you are trying to solve?

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


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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


Re: [R] Replying to Posts Within Same Thread

2009-12-01 Thread David Winsemius


On Dec 1, 2009, at 10:42 PM, Charlotte Maia wrote:


On 12/2/09, John Sorkin  wrote:
I don't know what you are doing wrong because I don't know exactly  
what you are doing. I do know that I don't have your problem when I  
simply reply to a message without touching the subject line.

John


Could you clarify the notion of "simply reply".
There is no obvious reply links in either the archive page, or the  
digest.


True. The archive does not expose the message headers. I have not  
figured out whether is is even possible to respond to a message on the  
Archive. Some people use Gmane or Nabble, but I think most use a mail- 
client. Responding to the digest can break threads.




In the case, where someone sends me an email, such have you have done,
I can simply reply.

However, in general this option is not available.


I am wondering why it wouldn't be? This particular message is threaded  
with the posting you made a little over an hour ago, whereas some of  
your replies in the last few days have been orphaned from the posting  
you responded to (as you have noticed). You can look at the threaded  
archive here (as I suspect you already know):


https://stat.ethz.ch/pipermail/r-help/

Best
--
David.


--
Charlotte Maia
http://sites.google.com/site/maiagx/home



--
David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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


Re: [R] sort a data frame by a vector

2009-12-01 Thread jim holtman
The factor statement should have been:  (missed the 'vec' on the first reading)

dataDF$A1 <- factor(dataDF$A1, levels=vec)

On Tue, Dec 1, 2009 at 10:57 PM, jim holtman  wrote:
> Is this what you want:
>
>> dataDF = data.frame(A1 = c("B", "A", "C"), A2 = c(1,2,3))
>> dataDF
>  A1 A2
> 1  B  1
> 2  A  2
> 3  C  3
>> dataDF[order(dataDF$A1),]
>  A1 A2
> 2  A  2
> 1  B  1
> 3  C  3
>>
>
> If you want the sequence "CAB" then you will have to change the
> factors in column 1:
>
>> dataDF$A1 <- factor(dataDF$A1, levels=c("C", "A", "B"))
>> dataDF[order(dataDF$A1),]
>  A1 A2
> 3  C  3
> 2  A  2
> 1  B  1
>>
>
>
> On Tue, Dec 1, 2009 at 10:36 PM, Hao Cen  wrote:
>> Hi,
>>
>>
>>
>> I have a a vector  and a data frame with two columns
>>
>> vec = c("C", "A", "B")
>>
>> dataDF = data.frame(A1 = c("B", "A", "C"), A2 = c(1,2,3))
>>
>>
>>
>> I would like to sort the data frame by column A1 such that the order of
>> elements in A1 is as the same as in vec.
>>
>>
>>
>> After the ordering, the data frame would be
>>
>> A1           A2
>>
>> C             3
>>
>> A             2
>>
>> B             1
>>
>>
>>
>> Any suggestions would be appreciated.
>>
>>
>>
>> Thanks in advance
>>
>>
>>
>> Jeff
>>
>>
>>        [[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
>
>
> --
> Jim Holtman
> Cincinnati, OH
> +1 513 646 9390
>
> What is the problem that you are trying to solve?
>



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

What is the problem that you are trying to solve?

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


[R] How to remove R banner?

2009-12-01 Thread Peng Yu
I always see a banner like the following, which is annoying. I'm
wondering how to disable it.

R version 2.7.1 (2008-06-23)
Copyright (C) 2008 The R Foundation for Statistical Computing
ISBN 3-900051-07-0

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
I

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

2009-12-01 Thread milton ruser
not ellegant.. but...

vecDF = data.frame(A1=c("C", "A", "B"))
vecDF$A1.order=1:dim(vecDF)
vecDF
dataDF = data.frame(A1 = c("B", "A", "C"), A2 = c(1,2,3))
dataDF2<-merge(vecDF, dataDF,
by=intersect(colnames(vecDF),colnames(dataDF)))
dataDF2
dataDF2.ord<-dataDF2[order(dataDF2$A1.order),]
dataDF2.ord

milton

On Tue, Dec 1, 2009 at 10:36 PM, Hao Cen  wrote:

> Hi,
>
>
>
> I have a a vector  and a data frame with two columns
>
> vec = c("C", "A", "B")
>
> dataDF = data.frame(A1 = c("B", "A", "C"), A2 = c(1,2,3))
>
>
>
> I would like to sort the data frame by column A1 such that the order of
> elements in A1 is as the same as in vec.
>
>
>
> After the ordering, the data frame would be
>
> A1   A2
>
> C 3
>
> A 2
>
> B 1
>
>
>
> Any suggestions would be appreciated.
>
>
>
> Thanks in advance
>
>
>
> Jeff
>
>
>[[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


Re: [R] sort a data frame by a vector

2009-12-01 Thread jim holtman
Is this what you want:

> dataDF = data.frame(A1 = c("B", "A", "C"), A2 = c(1,2,3))
> dataDF
  A1 A2
1  B  1
2  A  2
3  C  3
> dataDF[order(dataDF$A1),]
  A1 A2
2  A  2
1  B  1
3  C  3
>

If you want the sequence "CAB" then you will have to change the
factors in column 1:

> dataDF$A1 <- factor(dataDF$A1, levels=c("C", "A", "B"))
> dataDF[order(dataDF$A1),]
  A1 A2
3  C  3
2  A  2
1  B  1
>


On Tue, Dec 1, 2009 at 10:36 PM, Hao Cen  wrote:
> Hi,
>
>
>
> I have a a vector  and a data frame with two columns
>
> vec = c("C", "A", "B")
>
> dataDF = data.frame(A1 = c("B", "A", "C"), A2 = c(1,2,3))
>
>
>
> I would like to sort the data frame by column A1 such that the order of
> elements in A1 is as the same as in vec.
>
>
>
> After the ordering, the data frame would be
>
> A1           A2
>
> C             3
>
> A             2
>
> B             1
>
>
>
> Any suggestions would be appreciated.
>
>
>
> Thanks in advance
>
>
>
> Jeff
>
>
>        [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



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

What is the problem that you are trying to solve?

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


Re: [R] Normal tests disagree?

2009-12-01 Thread Ben Bolker
milton ruser  gmail.com> writes:

> 
> Hi there,
> 
> Could you provide a minimum reproducible code, please.
> Bests
> 
> milton
> 
> On Tue, Dec 1, 2009 at 6:11 PM,  charter.net> wrote:
> 
> > If I have data that I feed into shapio.test and jarque.bera.test yet they
> > seem to disagree. What do I use for a decision?
> >
> > For my data set I have p.value of 0.05496421 returned from the shapiro.test
> > and 0.882027 returned from the jarque.bera.test. I have included the data
> > set below.
> >
> > Thank you.
> >
> > Kevin

It depends why you are testing for normality.
How big a departure are you looking for, and how will those
departures affect your inference? How easily can you adopt
a robust approach so that it won't matter so much if the
data are normally distributed?

## "Residuals" data only
x = c(-0.449735723758323, 0.281461045050074, 
0.591383050911335, 0.239998659520616, 
0.00343879474063987, -2.64372061292663, 0.381630655290173, 
-1.79543281552347, 
1.90631012440313, -0.256232543929779, 1.83452602676812, 
-1.06869719416837, 
1.04378655286183, 0.232655831328322, -0.939084802643773,
 0.854132879285335, 
-1.71217066877156, 1.28040273099582, -0.386415431325857, -0.769127669783483, 
-0.810996835089867, 0.0477292147635991, 0.294672848750557, -0.0841330473924862, 
0.231663729192233, -0.601790650547443, 0.285635768516625, -0.96315495955862, 
1.52188112949994, -0.826092842933196, 1.91937201229077, -0.317789483136924, 
-0.865011007394312, -0.0281604973711276, -0.123887049811822, 
-0.0327727730592468, -0.0654939600771254, 0.279247739913908, 
0.167606602923418, 0.189533097427477, 0.402062194225847, 1.97150984262995, 
-2.27538477532968, 1.89091792097945, 0.0251732151287081, -0.2349741808124, 
-0.659332058368173, 0.127284768034285, -1.42838560676513, 0.617689775286461, 
-0.034243005247084, -0.304574261133836, 0.128679369916751, -0.657479389968652, 
0.608766068692517, 1.928147708694, -0.172644961366165, -0.453255508263169, 
-1.09903330959344)

shapiro.test(x)
library(tseries)
jarque.bera.test(x)

## Replicates results: p=0.059 vs 0.88
## Wikipedia article on Jarque-Bera test suggests chi-squared
## approximation isn't very good for small-to-moderate data sets

qqnorm(x)
## or ...
library(lattice)
qqmath(~x,
   prepanel = prepanel.qqmathline,
   panel = function(x, ...) {
 panel.qqmathline(x, ...)
 panel.qqmath(x, ...)
   })

hist(x)

## and just to add to the confusion ...
library(nortest)
ad.test(x)


  Bottom line: I would say the data don't *look* particularly
normal, and the anderson-darling test fairly conclusively
rejects normality, but it really depends what you want to 
do with the data ...

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

2009-12-01 Thread Charlotte Maia
On 12/2/09, John Sorkin  wrote:
> I don't know what you are doing wrong because I don't know exactly what you 
> are doing. I do know that I don't have your problem when I simply reply to a 
> message without touching the subject line.
> John

Could you clarify the notion of "simply reply".
There is no obvious reply links in either the archive page, or the digest.

In the case, where someone sends me an email, such have you have done,
I can simply reply.

However, in general this option is not available.

-- 
Charlotte Maia
http://sites.google.com/site/maiagx/home

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

2009-12-01 Thread Hao Cen
Hi,

 

I have a a vector  and a data frame with two columns

vec = c("C", "A", "B")

dataDF = data.frame(A1 = c("B", "A", "C"), A2 = c(1,2,3))

 

I would like to sort the data frame by column A1 such that the order of
elements in A1 is as the same as in vec.

 

After the ordering, the data frame would be

A1   A2

C 3

A 2

B 1

 

Any suggestions would be appreciated.

 

Thanks in advance

 

Jeff


[[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] Is there a function to test if all the elements in a vector are unique

2009-12-01 Thread Rolf Turner


On 2/12/2009, at 3:48 PM, Peng Yu wrote:

On Tue, Dec 1, 2009 at 8:24 PM, Rolf Turner  
 wrote:


On 2/12/2009, at 3:09 PM, Peng Yu wrote:

   


Here is my sessionInfo().


   [Snotty comment deleted.]


sessionInfo()


R version 2.7.1 (2008-06-23)


   

   If you're going to use a version which is that antiquated
   then you can expect a great many things not to work.

   Version 2.10.1 is about to be released, for crying out loud!


Are are package installations backward compatible?


Mostly.

Will R code that works in order installations work in the new  
installations?


Mostly.

R-core go to a great deal of effort to make new releases backward
compatible and to make sure that old code doesn't get broken.
Sometimes, however, there's just no help for it, and things get
broken.  Usually there are plenty of warnings in the ``news'',
and the breaks can of course always be fixed.  This is R, after all.

cheers,

Rolf Turner

##
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}

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


Re: [R] Replying to Posts Within Same Thread

2009-12-01 Thread John Sorkin
I don't know what you are doing wrong because I don't know exactly what you are 
doing. I do know that I don't have your problem when I simply reply to a 
message without touching the subject line.
John 
-Original Message-
From: Charlotte Maia 
To:  

Sent: 12/1/2009 9:48:06 PM
Subject: [R] Replying to Posts Within Same Thread

Hi,

When I reply to a post, it generally appears as a separate thread,
rather than branching off the original post.

Anyone know what I'm doing wrong?

Noting I am currently receiving a couple of the lists in digest form.


kind regards
-- 
Charlotte Maia
http://sites.google.com/site/maiagx/home

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

Confidentiality Statement:
This email message, including any attachments, is for th...{{dropped:6}}

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

2009-12-01 Thread Wincent
Hi, R-2.10.0 was released and R-2.10.1 is to be released soon. I don't
think there is any problem with cran.

Best

2009/12/2 Hiroto Miyoshi :
>
> Dear R users, and Dr. Delagard
>
> I got an R-announce message which tells that
> R-2.10.0 will be released on December 4, 2009.
>
> Houever, it seems the R of that version was already
> released. At leased I made sure that the R of that version
> was in Cran and Univ. of Tsukuba, and also Univ. of Toronto.
>
> And that version is quite odd because each package is in
> a folder whih is named coffin. I am seriously worrying that
> Cran site is hacked and someone might have placed a mallicious
> version.
>
> Please do take a look at the version and make sure if it is
> really a valid version.
>
> Sincerely
>
> Hiroto
>
>
> --
> --
> Hiroto Miyoshi
> hiroto_miyo...@nexyzbb.ne.jp
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



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

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

2009-12-01 Thread Charlie Sharpsteen
On Tue, Dec 1, 2009 at 6:19 PM, Hiroto Miyoshi
 wrote:
>
> Dear R users, and Dr. Delagard
>
> I got an R-announce message which tells that
> R-2.10.0 will be released on December 4, 2009.

According to the message I received it was the first patch release,
2.10.1, that was announced not 2.10.0.

-Charlie

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

2009-12-01 Thread Charlotte Maia
Hi,

When I reply to a post, it generally appears as a separate thread,
rather than branching off the original post.

Anyone know what I'm doing wrong?

Noting I am currently receiving a couple of the lists in digest form.


kind regards
-- 
Charlotte Maia
http://sites.google.com/site/maiagx/home

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Is there a function to test if all the elements in a vector are unique

2009-12-01 Thread Peng Yu
On Tue, Dec 1, 2009 at 8:24 PM, Rolf Turner  wrote:
>
> On 2/12/2009, at 3:09 PM, Peng Yu wrote:
>
>        
>
>> Here is my sessionInfo().
>
>        [Snotty comment deleted.]
>
>>> sessionInfo()
>>
>> R version 2.7.1 (2008-06-23)
>
>        
>
>        If you're going to use a version which is that antiquated
>        then you can expect a great many things not to work.
>
>        Version 2.10.1 is about to be released, for crying out loud!

Are are package installations backward compatible? Will R code that
works in order installations work in the new installations?

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

2009-12-01 Thread Hiroto Miyoshi


Dear R users, and Dr. Delagard

I got an R-announce message which tells that
R-2.10.0 will be released on December 4, 2009.

Houever, it seems the R of that version was already
released. At leased I made sure that the R of that version
was in Cran and Univ. of Tsukuba, and also Univ. of Toronto.

And that version is quite odd because each package is in
a folder whih is named coffin. I am seriously worrying that
Cran site is hacked and someone might have placed a mallicious
version.

Please do take a look at the version and make sure if it is
really a valid version.

Sincerely

Hiroto


--
--
Hiroto Miyoshi
hiroto_miyo...@nexyzbb.ne.jp

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Is there a function to test if all the elements in a vector are unique

2009-12-01 Thread Rolf Turner


On 2/12/2009, at 3:09 PM, Peng Yu wrote:




Here is my sessionInfo().


[Snotty comment deleted.]


sessionInfo()

R version 2.7.1 (2008-06-23)




If you're going to use a version which is that antiquated
then you can expect a great many things not to work.

Version 2.10.1 is about to be released, for crying out loud!

cheers,

Rolf Turner

##
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}

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


Re: [R] Container/Collection Object to keep data structures and object

2009-12-01 Thread Rolf Turner


On 2/12/2009, at 3:08 PM, Sharpie wrote:




Amir Liu wrote:


In l[3] <- matrix(1:4, 2, 2) :
  number of items to replace is not a multiple of replacement length



When inserting single entries into a list list, you should use the  
'[[ ]]'

notation.  Use '[ ]' when you want to extract multiple entries or copy
multiple entries from one list to another:

  l <- list()
  l[[ 1 ]] <- 5
  l[[ 2 ]] <- 'cd'
  l[[ 3 ]] <- matrix( 1:4, 2, 2 )

  l
  [[1]]
  [1] 5

  [[2]]
  [1] "cd"

  [[3]]
[,1] [,2]
  [1,]13
  [2,]24

Hope this helps!


The key issue is that l[3] is a ***list*** of length 1 whose single  
entry
is the object that was the third entry of ``l''.  But l[[3]] is  
***the object***
that was the third entry of ``l''.  It's like the difference a box  
containing

the third chocolate from a box of chocolates and that third chocolate.

cheers,

Rolf Turner

##
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}

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


Re: [R] Is there a function to test if all the elements in a vector are unique

2009-12-01 Thread Peng Yu
On Tue, Dec 1, 2009 at 8:04 PM, Jorge Ivan Velez
 wrote:
>
> I guess it depends on which version of R you are using. My sessionInfo()
> follows. What's yours?
> R> sessionInfo()
> R version 2.10.0 Patched (2009-10-26 r50212)
> i386-pc-mingw32
> locale:
> [1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United
> States.1252
> [3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
>
> [5] LC_TIME=English_United States.1252
> attached base packages:
> [1] stats     graphics  grDevices utils     datasets  methods   base
> loaded via a namespace (and not attached):
> [1] tools_2.10.0
> HTH,
> Jorge
> On Tue, Dec 1, 2009 at 8:57 PM, Peng Yu  wrote:
>>
>> On Tue, Dec 1, 2009 at 7:46 PM, Jorge Ivan Velez
>>  wrote:
>> > Try this:
>> > R> apropos('any')
>> > R> ?anyDuplicated
>> > HTH,
>> > Jorge
>> >
>> > On Tue, Dec 1, 2009 at 8:32 PM, Peng Yu  wrote:
>> >>
>> >> On Tue, Dec 1, 2009 at 1:40 AM, Karl Ove Hufthammer 
>> >> wrote:
>> >> > On Tue, 1 Dec 2009 14:48:04 +1100 Remko Duursma
>> >> > 
>> >> > wrote:
>> >> >> any(duplicated(c(1,2,2)))
>> >> >
>> >> > or
>> >> > anyDuplicated(c(1,2,2))
>> >> > which is slightly more efficient.
>> >>
>> >> I don't find anyDuplicated(). Which package is it from?
>>
>> Here are what I got.
>>
>> > apropos('any')
>> [1] "any"          "argsAnywhere" ".__C__ANY"    "getAnywhere"
>> > ?anyDuplicated
>> No documentation for 'anyDuplicated' in specified packages and libraries:
>> you could try 'help.search("anyDuplicated")'


Here is my sessionInfo(). BTW, it is generally not a good idea to top
post in mailing list or newsgroup, because it breaks the message flow.

> sessionInfo()
R version 2.7.1 (2008-06-23)
x86_64-pc-linux-gnu

locale:
LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=C;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C

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

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Container/Collection Object to keep data structures and object

2009-12-01 Thread Sharpie


Amir Liu wrote:
> 
> In l[3] <- matrix(1:4, 2, 2) :
>   number of items to replace is not a multiple of replacement length
> 

When inserting single entries into a list list, you should use the '[[ ]]'
notation.  Use '[ ]' when you want to extract multiple entries or copy
multiple entries from one list to another:

  l <- list()
  l[[ 1 ]] <- 5
  l[[ 2 ]] <- 'cd'
  l[[ 3 ]] <- matrix( 1:4, 2, 2 )

  l
  [[1]]
  [1] 5

  [[2]]
  [1] "cd"

  [[3]]
[,1] [,2]
  [1,]13
  [2,]24

Hope this helps!

-Charlie
-- 
View this message in context: 
http://n4.nabble.com/Container-Collection-Object-to-keep-data-structures-and-object-tp932656p932693.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Is there a function to test if all the elements in a vector are unique

2009-12-01 Thread Jorge Ivan Velez
I guess it depends on which version of R you are using. My sessionInfo()
follows. What's yours?

R> sessionInfo()
R version 2.10.0 Patched (2009-10-26 r50212)
i386-pc-mingw32

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United
States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C

[5] LC_TIME=English_United States.1252

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

loaded via a namespace (and not attached):
[1] tools_2.10.0

HTH,
Jorge

On Tue, Dec 1, 2009 at 8:57 PM, Peng Yu  wrote:

> On Tue, Dec 1, 2009 at 7:46 PM, Jorge Ivan Velez
>  wrote:
> > Try this:
> > R> apropos('any')
> > R> ?anyDuplicated
> > HTH,
> > Jorge
> >
> > On Tue, Dec 1, 2009 at 8:32 PM, Peng Yu  wrote:
> >>
> >> On Tue, Dec 1, 2009 at 1:40 AM, Karl Ove Hufthammer 
> >> wrote:
> >> > On Tue, 1 Dec 2009 14:48:04 +1100 Remko Duursma <
> remkoduur...@gmail.com>
> >> > wrote:
> >> >> any(duplicated(c(1,2,2)))
> >> >
> >> > or
> >> > anyDuplicated(c(1,2,2))
> >> > which is slightly more efficient.
> >>
> >> I don't find anyDuplicated(). Which package is it from?
>
> Here are what I got.
>
> > apropos('any')
> [1] "any"  "argsAnywhere" ".__C__ANY""getAnywhere"
> > ?anyDuplicated
> No documentation for 'anyDuplicated' in specified packages and libraries:
> you could try 'help.search("anyDuplicated")'
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


Re: [R] Is there a function to test if all the elements in a vector are unique

2009-12-01 Thread Peng Yu
On Tue, Dec 1, 2009 at 7:46 PM, Jorge Ivan Velez
 wrote:
> Try this:
> R> apropos('any')
> R> ?anyDuplicated
> HTH,
> Jorge
>
> On Tue, Dec 1, 2009 at 8:32 PM, Peng Yu  wrote:
>>
>> On Tue, Dec 1, 2009 at 1:40 AM, Karl Ove Hufthammer 
>> wrote:
>> > On Tue, 1 Dec 2009 14:48:04 +1100 Remko Duursma 
>> > wrote:
>> >> any(duplicated(c(1,2,2)))
>> >
>> > or
>> > anyDuplicated(c(1,2,2))
>> > which is slightly more efficient.
>>
>> I don't find anyDuplicated(). Which package is it from?

Here are what I got.

> apropos('any')
[1] "any"  "argsAnywhere" ".__C__ANY""getAnywhere"
> ?anyDuplicated
No documentation for 'anyDuplicated' in specified packages and libraries:
you could try 'help.search("anyDuplicated")'

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Container/Collection Object to keep data structures and object

2009-12-01 Thread Amir Liu



Here is an example of how I attempt to add elements to a given list denoted as 
l:

> l <- list()
> l
list()
> l[1] <- 5
> l
[[1]]
[1] 5

> l[2] <- "cd"
> l
[[1]]
[1] 5

[[2]]
[1] "cd"

> l[3] <- matrix(1:4,2,2)
Warning message:
In l[3] <- matrix(1:4, 2, 2) :
  number of items to replace is not a multiple of replacement length




> Date: Tue, 1 Dec 2009 17:31:41 -0800
> From: ch...@sharpsteen.net
> To: r-help@r-project.org
> Subject: Re: [R] Container/Collection Object to keep data structures and 
> object
>
>
>
> Amir Liu wrote:
>>
>> I want to have a collection object that can store objects. In R I only saw
>> lists. But these only seem to be able to handle basic objects like numbers
>> and strings. Whenever I tried to add more complicated objects or just very
>> simple data structures like matrices I would get an error like:
>>
>> "number of items to replace is not a multiple of replacement length"
>>
>> What is the general purpose collection object in R to store more complex
>> objects, or how are these things generally approached?
>>
>>
>> Kind Regards,
>>
>> Amir
>>
>
> Lists should be capable of holding any arbitrary R object. How are you
> trying to insert components such as a matrix?
> --
> View this message in context: 
> http://n4.nabble.com/Container-Collection-Object-to-keep-data-structures-and-object-tp932656p932666.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.
  
_
Add your Gmail and Yahoo! Mail email accounts into Hotmail - it's easy

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] ''system(cmd) : make not found'' error during package install

2009-12-01 Thread Duncan Murdoch

Matthew Anaka wrote:

Hello,
I've been using various packages in R for a few years now to analyse 
genomics data but I've just come up with some errors for which I canÂ’t seem to 
find a solution. HereÂ’s the situation:


  

source("http://harlequin.jax.org/rmodel/packages/downloadRmodel.R";)
getRmodelHuman()


also installing the dependency ‘rmodel’

trying URL 'http://harlequin.jax.org/rmodel/packages//rmodel_1.0.36.tar.gz'
Content type 'application/x-gzip' length 10238618 bytes (9.8 Mb)
opened URL
downloaded 9.8 Mb

trying URL 
'http://harlequin.jax.org/rmodel/packages//hgfocusrmodelcdf_1.3.tar.gz'
Content type 'application/x-gzip' length 2581708 bytes (2.5 Mb)
opened URL
downloaded 2.5 Mb

* installing *source* package 'rmodel' ...
** libs
  making DLL ...
Warning in system(cmd) : make not found
  ... done
ERROR: compilation failed for package 'rmodel'
* removing 'C:/PROGRA~1/R/R-210~1.0/library/rmodel'
* installing *source* package 'hgfocusrmodelcdf' ...
** R
** data
** preparing package for lazy loading
** help
*** installing help indices
** building package indices ...
** MD5 sums
* DONE (hgfocusrmodelcdf)

The downloaded packages are in
‘C:\Documents and Settings\localuser\Local 
Settings\Temp\RtmpjuG3ea\downloaded_packagesÂ’
Warning messages:
1: In install.packages(pkgs = "hgfocusrmodelcdf", contriburl = server,  :
  installation of package 'rmodel' had non-zero exit status


Of course if I try to load the package afterwards:
  

library(rmodel)


Error in library(rmodel) : there is no package called 'rmodel'

I havenÂ’t had any luck with reading other mailing lists or searching google 
for how to deal with this system(cmd) error, or the issue of ‘non-zero exit 
statusÂ’ in a non-linux environment (IÂ’m running R on windows).

Any help would be greatly appreciated; my apology if this is not the correct 
forum to ask this sort of questions.
You are trying to install a source package, and you're missing the tools 
to compile it (or don't have them set up properly). See the Installation 
and Administration manual, or my web site www.murdoch-sutherland.com/Rtools.


Duncan Murdoch

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


[R] Passing additional argument to be numerically integrated function

2009-12-01 Thread Amir Liu


Hi,

I try to use the numerical integration functionality of R to integrate a 
univariate (1D) function. Below I am integrating function const1 which works 
nicely as expected. But for some reasons I need to pass to my function that I 
want to integrate an additional parameter. If it were object-oriented I just 
would invoke some setter methods onto a object providing functionality 
described in function constX and then pass this object on. And according to the 
help page the function can have more than one argument, just the first needs to 
be the argument vector for the integration function:

- f: an R function taking a numeric first argument and returning a numeric 
vector of the same length.  Returning a non-finite element will generate an 
error.

But let us say I have an additional argument called nb that I want to pass as 
well. How would I pass this second argument (and possibly more additional 
arguments) to make case 2 work, i.e. how this is expressed in R syntax?


"integ" <- function() {

  # case 1: no argument for function to be integrated
  # integrate box function of height 1 from 0 to 2
  val <- integrate(const1,0,2)
  print(val)

  # case 2: one ore more argument for function to be integrated
  # integrate box function of height nb from 0 to 2
  nb <- 5
  val1 <- integrate(constX,0,2)
  print(val1)

}

"const1" <- function(x) {
 return(rep(1,length(x)))
}

"constX" <- function(x,nb) {
 return(rep(nb,length(nb)))
}


Kind Regards,

Amir
--


  
_
View your other email accounts from your Hotmail inbox. Add them now.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Is there a function to test if all the elements in a vector are unique

2009-12-01 Thread Jorge Ivan Velez
Try this:

R> apropos('any')
R> ?anyDuplicated

HTH,
Jorge


On Tue, Dec 1, 2009 at 8:32 PM, Peng Yu  wrote:

> On Tue, Dec 1, 2009 at 1:40 AM, Karl Ove Hufthammer 
> wrote:
> > On Tue, 1 Dec 2009 14:48:04 +1100 Remko Duursma 
> > wrote:
> >> any(duplicated(c(1,2,2)))
> >
> > or
> > anyDuplicated(c(1,2,2))
> > which is slightly more efficient.
>
> I don't find anyDuplicated(). Which package is it from?
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


Re: [R] Normal tests disagree?

2009-12-01 Thread milton ruser
Hi there,

Could you provide a minimum reproducible code, please.
Bests

milton

On Tue, Dec 1, 2009 at 6:11 PM,  wrote:

> If I have data that I feed into shapio.test and jarque.bera.test yet they
> seem to disagree. What do I use for a decision?
>
> For my data set I have p.value of 0.05496421 returned from the shapiro.test
> and 0.882027 returned from the jarque.bera.test. I have included the data
> set below.
>
> Thank you.
>
> Kevin
>
>
> "Category","Period","Residual"
> "CHILD HATS, WIGS & MASKS",1/1/2005,-0.449735723758323
> "CHILD HATS, WIGS & MASKS",2/1/2005,0.281461045050074
> "CHILD HATS, WIGS & MASKS",3/1/2005,0.591383050911335
> "CHILD HATS, WIGS & MASKS",4/1/2005,0.239998659520616
> "CHILD HATS, WIGS & MASKS",5/1/2005,0.00343879474063987
> "CHILD HATS, WIGS & MASKS",6/1/2005,-2.64372061292663
> "CHILD HATS, WIGS & MASKS",7/1/2005,0.381630655290173
> "CHILD HATS, WIGS & MASKS",8/1/2005,-1.79543281552347
> "CHILD HATS, WIGS & MASKS",9/1/2005,1.90631012440313
> "CHILD HATS, WIGS & MASKS",10/1/2005,-0.256232543929779
> "CHILD HATS, WIGS & MASKS",11/1/2005,1.83452602676812
> "CHILD HATS, WIGS & MASKS",12/1/2005,-1.06869719416837
> "CHILD HATS, WIGS & MASKS",1/1/2006,1.04378655286183
> "CHILD HATS, WIGS & MASKS",2/1/2006,0.232655831328322
> "CHILD HATS, WIGS & MASKS",3/1/2006,-0.939084802643773
> "CHILD HATS, WIGS & MASKS",4/1/2006,0.854132879285335
> "CHILD HATS, WIGS & MASKS",5/1/2006,-1.71217066877156
> "CHILD HATS, WIGS & MASKS",6/1/2006,1.28040273099582
> "CHILD HATS, WIGS & MASKS",7/1/2006,-0.386415431325857
> "CHILD HATS, WIGS & MASKS",8/1/2006,-0.769127669783483
> "CHILD HATS, WIGS & MASKS",9/1/2006,-0.810996835089867
> "CHILD HATS, WIGS & MASKS",10/1/2006,0.0477292147635991
> "CHILD HATS, WIGS & MASKS",11/1/2006,0.294672848750557
> "CHILD HATS, WIGS & MASKS",12/1/2006,-0.0841330473924862
> "CHILD HATS, WIGS & MASKS",1/1/2007,0.231663729192233
> "CHILD HATS, WIGS & MASKS",2/1/2007,-0.601790650547443
> "CHILD HATS, WIGS & MASKS",3/1/2007,0.285635768516625
> "CHILD HATS, WIGS & MASKS",4/1/2007,-0.963154959558619
> "CHILD HATS, WIGS & MASKS",5/1/2007,1.52188112949994
> "CHILD HATS, WIGS & MASKS",6/1/2007,-0.826092842933196
> "CHILD HATS, WIGS & MASKS",7/1/2007,1.91937201229077
> "CHILD HATS, WIGS & MASKS",8/1/2007,-0.317789483136924
> "CHILD HATS, WIGS & MASKS",9/1/2007,-0.865011007394312
> "CHILD HATS, WIGS & MASKS",10/1/2007,-0.0281604973711276
> "CHILD HATS, WIGS & MASKS",11/1/2007,-0.123887049811822
> "CHILD HATS, WIGS & MASKS",12/1/2007,-0.0327727730592468
> "CHILD HATS, WIGS & MASKS",1/1/2008,-0.0654939600771254
> "CHILD HATS, WIGS & MASKS",2/1/2008,0.279247739913908
> "CHILD HATS, WIGS & MASKS",3/1/2008,0.167606602923418
> "CHILD HATS, WIGS & MASKS",4/1/2008,0.189533097427477
> "CHILD HATS, WIGS & MASKS",5/1/2008,0.402062194225847
> "CHILD HATS, WIGS & MASKS",6/1/2008,1.97150984262995
> "CHILD HATS, WIGS & MASKS",7/1/2008,-2.27538477532968
> "CHILD HATS, WIGS & MASKS",8/1/2008,1.89091792097945
> "CHILD HATS, WIGS & MASKS",9/1/2008,0.0251732151287081
> "CHILD HATS, WIGS & MASKS",10/1/2008,-0.2349741808124
> "CHILD HATS, WIGS & MASKS",11/1/2008,-0.659332058368173
> "CHILD HATS, WIGS & MASKS",12/1/2008,0.127284768034285
> "CHILD HATS, WIGS & MASKS",1/1/2009,-1.42838560676513
> "CHILD HATS, WIGS & MASKS",2/1/2009,0.617689775286461
> "CHILD HATS, WIGS & MASKS",3/1/2009,-0.034243005247084
> "CHILD HATS, WIGS & MASKS",4/1/2009,-0.304574261133836
> "CHILD HATS, WIGS & MASKS",5/1/2009,0.128679369916751
> "CHILD HATS, WIGS & MASKS",6/1/2009,-0.657479389968652
> "CHILD HATS, WIGS & MASKS",7/1/2009,0.608766068692517
> "CHILD HATS, WIGS & MASKS",8/1/2009,1.92814770869400
> "CHILD HATS, WIGS & MASKS",9/1/2009,-0.172644961366165
> "CHILD HATS, WIGS & MASKS",10/1/2009,-0.453255508263169
> "CHILD HATS, WIGS & MASKS",11/1/2009,-1.09903330959344
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


Re: [R] draw a box at 10% lower and upper in scatter plot

2009-12-01 Thread Peter Alspach
Tena koe Roslina

Check:

?rect
?quantile

Perhaps those two functions will give you what you want.

HTH 

Peter Alspach

> -Original Message-
> From: r-help-boun...@r-project.org 
> [mailto:r-help-boun...@r-project.org] On Behalf Of Roslina Zakaria
> Sent: Wednesday, 2 December 2009 12:24 p.m.
> To: r-help@r-project.org
> Subject: [R] draw a box at 10% lower and upper in scatter plot
> 
> 
> Hi,
>  
> I would like to draw a box at each corner of lower 10% and 
> upper 10% in the scatter plot on(0,1)*(0,1)  to indicate the 
> lower and upper tail.  I hope somebody can help me.
>  
> Here is my code:
> ## scatter plot
> plot(hume_uni[,2],beec_uni[,2], pch=19, xlab="Hume_uni", 
> ylab="Beec_uni", col= "blue") title(main="Scatter plot of 
> uniformised data of Hume and Beechworth", font.main= 4) 
> abline(lm(hume_uni[,2]~beec_uni[,2]), col= "red").
>  
> Thank you so much fro any help given.
> 
> 
> 
> 
>   
>   [[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] Is there a function to test if all the elements in a vector are unique

2009-12-01 Thread Peng Yu
On Tue, Dec 1, 2009 at 1:40 AM, Karl Ove Hufthammer  wrote:
> On Tue, 1 Dec 2009 14:48:04 +1100 Remko Duursma 
> wrote:
>> any(duplicated(c(1,2,2)))
>
> or
> anyDuplicated(c(1,2,2))
> which is slightly more efficient.

I don't find anyDuplicated(). Which package is it from?

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] ''system(cmd) : make not found'' error during package install

2009-12-01 Thread Matthew Anaka
Hello,
I've been using various packages in R for a few years now to analyse 
genomics data but I've just come up with some errors for which I can’t seem to 
find a solution. Here’s the situation:


> source("http://harlequin.jax.org/rmodel/packages/downloadRmodel.R";)
> getRmodelHuman()
also installing the dependency ‘rmodel’

trying URL 'http://harlequin.jax.org/rmodel/packages//rmodel_1.0.36.tar.gz'
Content type 'application/x-gzip' length 10238618 bytes (9.8 Mb)
opened URL
downloaded 9.8 Mb

trying URL 
'http://harlequin.jax.org/rmodel/packages//hgfocusrmodelcdf_1.3.tar.gz'
Content type 'application/x-gzip' length 2581708 bytes (2.5 Mb)
opened URL
downloaded 2.5 Mb

* installing *source* package 'rmodel' ...
** libs
  making DLL ...
Warning in system(cmd) : make not found
  ... done
ERROR: compilation failed for package 'rmodel'
* removing 'C:/PROGRA~1/R/R-210~1.0/library/rmodel'
* installing *source* package 'hgfocusrmodelcdf' ...
** R
** data
** preparing package for lazy loading
** help
*** installing help indices
** building package indices ...
** MD5 sums
* DONE (hgfocusrmodelcdf)

The downloaded packages are in
‘C:\Documents and Settings\localuser\Local 
Settings\Temp\RtmpjuG3ea\downloaded_packages’
Warning messages:
1: In install.packages(pkgs = "hgfocusrmodelcdf", contriburl = server,  :
  installation of package 'rmodel' had non-zero exit status


Of course if I try to load the package afterwards:
> library(rmodel)
Error in library(rmodel) : there is no package called 'rmodel'

I haven’t had any luck with reading other mailing lists or searching google 
for how to deal with this system(cmd) error, or the issue of ‘non-zero exit 
status’ in a non-linux environment (I’m running R on windows).

Any help would be greatly appreciated; my apology if this is not the correct 
forum to ask this sort of questions.

Cheers,
Matthew Anaka


This communication is intended only for the named recipient and may contain 
information that is confidential, legally privileged or subject to copyright; 
the Ludwig Institute for Cancer Research does not waiver any rights if you have 
received this communication in error. The views expressed in this communication 
are those of the sender and do not necessarily reflect the views of the Ludwig 
Institute for Cancer Research.


[[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] Reformat x axis

2009-12-01 Thread Peter Alspach
Tena koe M Haywood

I haven't a clue about SAS FORMAT, but R does have the ability to
specify the axis ticks, labels and titles in pretty much any way you
might require.  See ?axis and also ?text

HTH 

Peter Alspach 

> -Original Message-
> From: r-help-boun...@r-project.org 
> [mailto:r-help-boun...@r-project.org] On Behalf Of d haywood
> Sent: Wednesday, 2 December 2009 1:28 p.m.
> To: r-help@r-project.org
> Subject: [R] Reformat x axis
> 
> 
> Hi
> 
> I am trying to do a simple XY plot with a dataset that has 
> dates stored as integers . I would like to have the X values 
> displayed as dates. I realize I could do this by converting 
> the x values to dates first, However, does R have the ability 
> like SAS FORMAT, for example, of reformatting the values of 
> variables as part of the plot routine?
> 
> Thanks
> 
> D Haywood
> 
> _
> Get more out of Hotmail Check out the latest features today
> 
> out-to-get-even-better
>   [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 

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


Re: [R] Container/Collection Object to keep data structures and object

2009-12-01 Thread Sharpie


Amir Liu wrote:
> 
> I want to have a collection object that can store objects. In R I only saw
> lists. But these only seem to be able to handle basic objects like numbers
> and strings. Whenever I tried to add more complicated objects or just very
> simple data structures like matrices I would get an error like:
> 
> "number of items to replace is not a multiple of replacement length"
> 
> What is the general purpose collection object in R to store more complex
> objects, or how are these things generally approached?
> 
> 
> Kind Regards,
> 
> Amir
> 

Lists should be capable of holding any arbitrary R object.  How are you
trying to insert components such as a matrix?
-- 
View this message in context: 
http://n4.nabble.com/Container-Collection-Object-to-keep-data-structures-and-object-tp932656p932666.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Partial correlations and p-values

2009-12-01 Thread dadrivr

I am trying to calculate a partial correlation and p-values.  Unfortunately,
the results in R are different than what SPSS gives.

Here is an example in R (calculating the partial correlation of x and y,
controlling for z1 and z2):

x <- c(1,20,14,30,9,4,8)
y <- c(5,6,7,9,NA,10,6)
z1 <- c(13,8,16,14,26,13,20)
z2 <- c(12,NA,2,5,8,16,13)
fmx <- lm(x ~ z1 + z2, na.action = na.exclude)
fmy <- lm(y ~ z1 + z2, na.action = na.exclude)
yres <- resid(fmy)
xres <- resid(fmx)
cor(xres, yres, use = "p")
ct <- cor.test(xres, yres)
ct$estimate
ct$p.value

R give me:
r = .65, p = .23

However, SPSS calculates:
r = .46, p = .70

I think something may be different with R's handling of missing data, as
when I replace the NA's with values, R and SPSS give the same r-values,
albeit different p-values still.  I am doing pairwise case exclusion in both
R and SPSS.  Any ideas why I'm getting different values?  Is something wrong
with my formula in R?  Any help would be greatly appreciated.  Thanks!


Peter Ehlers wrote:
> 
> 
> dadrivr wrote:
>> The variables have the same length, but with different numbers of missing
>> values (NA).  As a result, the residuals calculations (xres & yres) have
>> different lengths, and I cannot compute the correlation between the two
>> (error of incompatible dimensions - see example below).  Is there a way,
>> when calculating residuals, to leave the NAs in the residual calculation
>> and
>> output? Thanks!
>> 
>> x <- c(1,20,14,NA,9)
>> y <- c(5,6,7,9,10)
>> z <- c(13,NA,16,14,NA)
>> xres <- residuals(lm(x ~ z))
>> yres <- residuals(lm(y ~ z))
>> cor(xres, yres)
>> ct <- cor.test(xres, yres)
>> ct$estimate
>> ct$p.value
>> 
> 
> Well, your example above just uses two points for the x on z
> regression and that gives zero-residuals. Let's use
> something a bit more realistic:
> 
> set.seed(123)
> x <- rnorm(5)
> y <- rnorm(5)
> z <- rnorm(5)
> x[sample(5,1)] <- NA
> z[sample(5,1)] <- NA
> fmx <- lm(x ~ z, na.action = na.exclude)
> fmy <- lm(y ~ z, na.action = na.exclude)
> yres <- resid(fmy)
> xres <- resid(fmx)
> cor(xres, yres, use = "p")  # -0.95978
> ct <- cor.test(xres, yres)
> ct$estimate  # -0.95978
> ct$p.value   # 0.04021994
> 
> Check out the 'na.exclude' action in lm(): it preserves
> the length of the residual vector. Then the 'use='
> argument to cor() uses pairwise complete observations.
> cor.test() will do that automatically.
> 
>   -Peter Ehlers
> 
>> 
>> Ista Zahn wrote:
>>> 1) Think about what you did wrong. It doesn't make sense to do
>>> correlation/regression with variables of different lengths. You can
>>> have missing values in one or more variables, if that's what you mean.
>>> Just code them NA.
>>>
>>> 2) Just add in the predictors, e.g.
>>> residuals(lm(y ~ z1 + z2))
>>>
>>> -Ista
>>>
>>> On Wed, Nov 11, 2009 at 10:34 PM, dadrivr  wrote:
 Awesome, that's what I was looking for. Â I have two additional
 questions:
 (1)
 What can I do if the variables are of different lengths? (2) How do I
 update
 the formula if I want to control for more than one variable.

 Let's take the following example:
 x <- c(1,20,14,7,9)
 y <- c(5,6,7,9,10,11)
 z <- c(13,27,16,5,4,17,20)
 a <- c(4,6,7,1)

 xres <- residuals(lm(x ~ z))
 yres <- residuals(lm(y ~ z))
 cor(xres, yres)
 ct <- cor.test(xres, yres)
 ct$estimate
 ct$p.value

 How do I update the above formula to:
 (1) take into account that the variables are of different lengths? Â I
 get
 an
 error when calculating the residuals.
 (2) control for z and a (i.e., more than one variable)?

 Thanks so much for your help.


 Peter Ehlers wrote:
>
> dadrivr wrote:
>> I'm trying to write code to calculate partial correlations (along
>> with
>> p-values). Â I'm new to R, and I don't know how to do this. Â I have
>> searched
>> and come across different functions, but I haven't been able to get
>> any
>> of
>> them to work (for example, pcor and pcor.test from the ggm package).
>>
>> In the following example, I am trying to compute the correlation
>> between
>> x
>> and y, while controlling for z (partial correlation):
>>
>> x <- c(1,20,14,7,9)
>> y <- c(5,6,7,9,10)
>> z <- c(13,27,16,5,4)
>>
>> What function can I append to this to find this partial correlation?
>> Many
>> thanks!
> I'm not sure what you need, but does this give you what
> you want:
>
> xres <- residuals(lm(x ~ z))
> yres <- residuals(lm(y ~ z))
> cor(xres, yres)
> # [1] 0.9778857
>
> or
>
> ct <- cor.test(xres, yres)
> ct$estimate  # 0.9978857
> ct$p.value   # 0.003934582
>
> Â  -Peter Ehlers
>
>>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://ww

[R] Container/Collection Object to keep data structures and object

2009-12-01 Thread Amir Liu




I want to have a collection object that can store objects. In R I only saw 
lists. But these only seem to be able to handle basic objects like numbers and 
strings. Whenever I tried to add more complicated objects or just very simple 
data structures like matrices I would get an error like:

"number of items to replace is not a multiple of replacement length"

What is the general purpose collection object in R to store more complex 
objects, or how are these things generally approached?


Kind Regards,

Amir

  
_
Use Hotmail to send and receive mail from your different email accounts

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Distance between sets of points in transformed environmental space

2009-12-01 Thread Charlotte Maia
Hi Corrado,

I was thinking about this some more.

Maybe you could use a linear discriminate, i.e. a (hyper)plane that
partitions your points into two sets, such that the misclassification
rate is minimised.

Closeness could be regarded as the number of misclassified points.
Two sets would be distant, if no points are misclassified.

I am assuming there is a standard function in R to do this, no idea
what it is though. Plus this is a reasonably well known technique.

Again the size of the sets needs to be accounted for.
As well as the question, does the distance of set A from B, need to be
the same as the distance of set B from A. Both the nearest neighbour
approach and the discriminant approach, don't necessarily satisfy this
condition.

regards
-- 
Charlotte Maia
http://sites.google.com/site/maiagx/home

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

2009-12-01 Thread d haywood

Hi

I am trying to do a simple XY plot with a dataset that has dates stored as 
integers . I would like to have the X values displayed as dates. I realize I 
could do this by converting the x values to dates first, However, does R have 
the ability like SAS FORMAT, for example, of reformatting the values of 
variables as part of the plot routine?

Thanks

D Haywood
  
_
Get more out of Hotmail Check out the latest features today

out-to-get-even-better
[[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] Error when running Conditional Logit Model

2009-12-01 Thread Hien Nguyen

Dear R-helpers,

I am very new to R and trying to run the conditional logit model using 
"clogit " command.
I have more than 4000 observations in my dataset and try to predict the 
dependent variable from 14 independent variables. My command is as follows


clmtest1 <- 
clogit(Pin~Income+Bus+Pop+Urbpro+Health+Student+Grad+NE+NW+NCC+SCC+CH+SE+MRD+strata(IDD),data=clmdata)


However, it produces the following errors:

Error in fitter(X, Y, strats, offset, init, control, weights = weights,  :
 NA/NaN/Inf in foreign function call (arg 6)
In addition: Warning messages:
1: In Surv(rep(1, 4096L), Pinmig) : Invalid status value, converted to NA
2: In fitter(X, Y, strats, offset, init, control, weights = weights,  :
 Ran out of iterations and did not converge

I search the error message from R forums but it does not say anything 
for Conditional Logit Model.


Please check for me what it says and what should I do to solve it.

Thanks a lot for your help

Hien Nguyen

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Aligning Diagonally Oriented Labels Under Bar Chart

2009-12-01 Thread Peter Alspach
Tena koe Jason

Is this an example of what you want?

temp <- barplot(3:17)
text(temp, rep(-0.5, length(3:17)), LETTERS[3:17], srt=45, adj=1)

HTH 

Peter Alspach 

> -Original Message-
> From: r-help-boun...@r-project.org 
> [mailto:r-help-boun...@r-project.org] On Behalf Of Jason Rupert
> Sent: Wednesday, 2 December 2009 12:16 p.m.
> To: R-help@r-project.org
> Subject: [R] Aligning Diagonally Oriented Labels Under Bar Chart
> 
> I searched the forms (i.e., R Search) and come up with the 
> following suggested link:
>  
> http://cran.r-project.org/doc/FAQ/R-FAQ.html#How-can-I-create-
> rotated-axis-labels_003f
> 
> I tried to implement what I believe was being implied by that 
> URL and came up with the below:
> 
> barplot(WorldPhones[1,],
>     ylim=c(0, 5),
>     axes=FALSE, ann=FALSE,
>     col=terrain.colors(length(WorldPhones[1,])),
>     xaxt = "n",  xlab = "")
> 
> text(1:dim(WorldPhones)[1], par("usr")[3] - 0.1, srt = 45, adj = 1,
>  labels = as.character(colnames(WorldPhones)), xpd = TRUE)
> 
> box()
> 
> 
> Unfortunately the labels are not aligned with the appropriate 
> bars.  I believe I am missing something small in order to 
> have the text properly aligned underneath the appropriate bars.   
> 
> Are there any suggestions for correcting this mis-alignment?  
> 
> Thank you again for any additional feedback, links, hints or 
> insights.  
> 
> 
> 
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 

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


[R] draw a box at 10% lower and upper in scatter plot

2009-12-01 Thread Roslina Zakaria

Hi,
 
I would like to draw a box at each corner of lower 10% and upper 10% in the 
scatter plot on(0,1)*(0,1)  to indicate the lower and upper tail.  I hope 
somebody can help me.
 
Here is my code:
## scatter plot
plot(hume_uni[,2],beec_uni[,2], pch=19, xlab="Hume_uni", ylab="Beec_uni", col= 
"blue")  
title(main="Scatter plot of uniformised data of Hume and Beechworth", 
font.main= 4)
abline(lm(hume_uni[,2]~beec_uni[,2]), col= "red").
 
Thank you so much fro any help given.




  
[[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] Normal tests disagree?

2009-12-01 Thread rkevinburton
If I have data that I feed into shapio.test and jarque.bera.test yet they seem 
to disagree. What do I use for a decision?

For my data set I have p.value of 0.05496421 returned from the shapiro.test and 
0.882027 returned from the jarque.bera.test. I have included the data set below.

Thank you.

Kevin


"Category","Period","Residual"
"CHILD HATS, WIGS & MASKS",1/1/2005,-0.449735723758323
"CHILD HATS, WIGS & MASKS",2/1/2005,0.281461045050074
"CHILD HATS, WIGS & MASKS",3/1/2005,0.591383050911335
"CHILD HATS, WIGS & MASKS",4/1/2005,0.239998659520616
"CHILD HATS, WIGS & MASKS",5/1/2005,0.00343879474063987
"CHILD HATS, WIGS & MASKS",6/1/2005,-2.64372061292663
"CHILD HATS, WIGS & MASKS",7/1/2005,0.381630655290173
"CHILD HATS, WIGS & MASKS",8/1/2005,-1.79543281552347
"CHILD HATS, WIGS & MASKS",9/1/2005,1.90631012440313
"CHILD HATS, WIGS & MASKS",10/1/2005,-0.256232543929779
"CHILD HATS, WIGS & MASKS",11/1/2005,1.83452602676812
"CHILD HATS, WIGS & MASKS",12/1/2005,-1.06869719416837
"CHILD HATS, WIGS & MASKS",1/1/2006,1.04378655286183
"CHILD HATS, WIGS & MASKS",2/1/2006,0.232655831328322
"CHILD HATS, WIGS & MASKS",3/1/2006,-0.939084802643773
"CHILD HATS, WIGS & MASKS",4/1/2006,0.854132879285335
"CHILD HATS, WIGS & MASKS",5/1/2006,-1.71217066877156
"CHILD HATS, WIGS & MASKS",6/1/2006,1.28040273099582
"CHILD HATS, WIGS & MASKS",7/1/2006,-0.386415431325857
"CHILD HATS, WIGS & MASKS",8/1/2006,-0.769127669783483
"CHILD HATS, WIGS & MASKS",9/1/2006,-0.810996835089867
"CHILD HATS, WIGS & MASKS",10/1/2006,0.0477292147635991
"CHILD HATS, WIGS & MASKS",11/1/2006,0.294672848750557
"CHILD HATS, WIGS & MASKS",12/1/2006,-0.0841330473924862
"CHILD HATS, WIGS & MASKS",1/1/2007,0.231663729192233
"CHILD HATS, WIGS & MASKS",2/1/2007,-0.601790650547443
"CHILD HATS, WIGS & MASKS",3/1/2007,0.285635768516625
"CHILD HATS, WIGS & MASKS",4/1/2007,-0.963154959558619
"CHILD HATS, WIGS & MASKS",5/1/2007,1.52188112949994
"CHILD HATS, WIGS & MASKS",6/1/2007,-0.826092842933196
"CHILD HATS, WIGS & MASKS",7/1/2007,1.91937201229077
"CHILD HATS, WIGS & MASKS",8/1/2007,-0.317789483136924
"CHILD HATS, WIGS & MASKS",9/1/2007,-0.865011007394312
"CHILD HATS, WIGS & MASKS",10/1/2007,-0.0281604973711276
"CHILD HATS, WIGS & MASKS",11/1/2007,-0.123887049811822
"CHILD HATS, WIGS & MASKS",12/1/2007,-0.0327727730592468
"CHILD HATS, WIGS & MASKS",1/1/2008,-0.0654939600771254
"CHILD HATS, WIGS & MASKS",2/1/2008,0.279247739913908
"CHILD HATS, WIGS & MASKS",3/1/2008,0.167606602923418
"CHILD HATS, WIGS & MASKS",4/1/2008,0.189533097427477
"CHILD HATS, WIGS & MASKS",5/1/2008,0.402062194225847
"CHILD HATS, WIGS & MASKS",6/1/2008,1.97150984262995
"CHILD HATS, WIGS & MASKS",7/1/2008,-2.27538477532968
"CHILD HATS, WIGS & MASKS",8/1/2008,1.89091792097945
"CHILD HATS, WIGS & MASKS",9/1/2008,0.0251732151287081
"CHILD HATS, WIGS & MASKS",10/1/2008,-0.2349741808124
"CHILD HATS, WIGS & MASKS",11/1/2008,-0.659332058368173
"CHILD HATS, WIGS & MASKS",12/1/2008,0.127284768034285
"CHILD HATS, WIGS & MASKS",1/1/2009,-1.42838560676513
"CHILD HATS, WIGS & MASKS",2/1/2009,0.617689775286461
"CHILD HATS, WIGS & MASKS",3/1/2009,-0.034243005247084
"CHILD HATS, WIGS & MASKS",4/1/2009,-0.304574261133836
"CHILD HATS, WIGS & MASKS",5/1/2009,0.128679369916751
"CHILD HATS, WIGS & MASKS",6/1/2009,-0.657479389968652
"CHILD HATS, WIGS & MASKS",7/1/2009,0.608766068692517
"CHILD HATS, WIGS & MASKS",8/1/2009,1.92814770869400
"CHILD HATS, WIGS & MASKS",9/1/2009,-0.172644961366165
"CHILD HATS, WIGS & MASKS",10/1/2009,-0.453255508263169
"CHILD HATS, WIGS & MASKS",11/1/2009,-1.09903330959344

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Aligning Diagonally Oriented Labels Under Bar Chart

2009-12-01 Thread Jason Rupert
I searched the forms (i.e., R Search) and come up with the following suggested 
link:
 http://cran.r-project.org/doc/FAQ/R-FAQ.html#How-can-I-create-rotated-axis-labels_003f

I tried to implement what I believe was being implied by that URL and came up 
with the below:

barplot(WorldPhones[1,], 
    ylim=c(0, 5),
    axes=FALSE, ann=FALSE, 
    col=terrain.colors(length(WorldPhones[1,])), 
    xaxt = "n",  xlab = "")

text(1:dim(WorldPhones)[1], par("usr")[3] - 0.1, srt = 45, adj = 1,
 labels = as.character(colnames(WorldPhones)), xpd = TRUE)

box()


Unfortunately the labels are not aligned with the appropriate bars.  I believe 
I am missing something small in order to have the text properly aligned 
underneath the appropriate bars.   

Are there any suggestions for correcting this mis-alignment?  

Thank you again for any additional feedback, links, hints or insights.  




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

2009-12-01 Thread rkevinburton
If I have data that I feed into shapio.test and jarque.bera.test yet they seem 
to disagree. What do I use for a decision?

For my data set I have p.value of 0.05496421 returned from the shapiro.test and 
0.882027 returned from the jarque.bera.test. I have included the data set below.

Thank you.

Kevin


"Category","Period","Residual"
"CHILD HATS, WIGS & MASKS",1/1/2005,-0.449735723758323
"CHILD HATS, WIGS & MASKS",2/1/2005,0.281461045050074
"CHILD HATS, WIGS & MASKS",3/1/2005,0.591383050911335
"CHILD HATS, WIGS & MASKS",4/1/2005,0.239998659520616
"CHILD HATS, WIGS & MASKS",5/1/2005,0.00343879474063987
"CHILD HATS, WIGS & MASKS",6/1/2005,-2.64372061292663
"CHILD HATS, WIGS & MASKS",7/1/2005,0.381630655290173
"CHILD HATS, WIGS & MASKS",8/1/2005,-1.79543281552347
"CHILD HATS, WIGS & MASKS",9/1/2005,1.90631012440313
"CHILD HATS, WIGS & MASKS",10/1/2005,-0.256232543929779
"CHILD HATS, WIGS & MASKS",11/1/2005,1.83452602676812
"CHILD HATS, WIGS & MASKS",12/1/2005,-1.06869719416837
"CHILD HATS, WIGS & MASKS",1/1/2006,1.04378655286183
"CHILD HATS, WIGS & MASKS",2/1/2006,0.232655831328322
"CHILD HATS, WIGS & MASKS",3/1/2006,-0.939084802643773
"CHILD HATS, WIGS & MASKS",4/1/2006,0.854132879285335
"CHILD HATS, WIGS & MASKS",5/1/2006,-1.71217066877156
"CHILD HATS, WIGS & MASKS",6/1/2006,1.28040273099582
"CHILD HATS, WIGS & MASKS",7/1/2006,-0.386415431325857
"CHILD HATS, WIGS & MASKS",8/1/2006,-0.769127669783483
"CHILD HATS, WIGS & MASKS",9/1/2006,-0.810996835089867
"CHILD HATS, WIGS & MASKS",10/1/2006,0.0477292147635991
"CHILD HATS, WIGS & MASKS",11/1/2006,0.294672848750557
"CHILD HATS, WIGS & MASKS",12/1/2006,-0.0841330473924862
"CHILD HATS, WIGS & MASKS",1/1/2007,0.231663729192233
"CHILD HATS, WIGS & MASKS",2/1/2007,-0.601790650547443
"CHILD HATS, WIGS & MASKS",3/1/2007,0.285635768516625
"CHILD HATS, WIGS & MASKS",4/1/2007,-0.963154959558619
"CHILD HATS, WIGS & MASKS",5/1/2007,1.52188112949994
"CHILD HATS, WIGS & MASKS",6/1/2007,-0.826092842933196
"CHILD HATS, WIGS & MASKS",7/1/2007,1.91937201229077
"CHILD HATS, WIGS & MASKS",8/1/2007,-0.317789483136924
"CHILD HATS, WIGS & MASKS",9/1/2007,-0.865011007394312
"CHILD HATS, WIGS & MASKS",10/1/2007,-0.0281604973711276
"CHILD HATS, WIGS & MASKS",11/1/2007,-0.123887049811822
"CHILD HATS, WIGS & MASKS",12/1/2007,-0.0327727730592468
"CHILD HATS, WIGS & MASKS",1/1/2008,-0.0654939600771254
"CHILD HATS, WIGS & MASKS",2/1/2008,0.279247739913908
"CHILD HATS, WIGS & MASKS",3/1/2008,0.167606602923418
"CHILD HATS, WIGS & MASKS",4/1/2008,0.189533097427477
"CHILD HATS, WIGS & MASKS",5/1/2008,0.402062194225847
"CHILD HATS, WIGS & MASKS",6/1/2008,1.97150984262995
"CHILD HATS, WIGS & MASKS",7/1/2008,-2.27538477532968
"CHILD HATS, WIGS & MASKS",8/1/2008,1.89091792097945
"CHILD HATS, WIGS & MASKS",9/1/2008,0.0251732151287081
"CHILD HATS, WIGS & MASKS",10/1/2008,-0.2349741808124
"CHILD HATS, WIGS & MASKS",11/1/2008,-0.659332058368173
"CHILD HATS, WIGS & MASKS",12/1/2008,0.127284768034285
"CHILD HATS, WIGS & MASKS",1/1/2009,-1.42838560676513
"CHILD HATS, WIGS & MASKS",2/1/2009,0.617689775286461
"CHILD HATS, WIGS & MASKS",3/1/2009,-0.034243005247084
"CHILD HATS, WIGS & MASKS",4/1/2009,-0.304574261133836
"CHILD HATS, WIGS & MASKS",5/1/2009,0.128679369916751
"CHILD HATS, WIGS & MASKS",6/1/2009,-0.657479389968652
"CHILD HATS, WIGS & MASKS",7/1/2009,0.608766068692517
"CHILD HATS, WIGS & MASKS",8/1/2009,1.92814770869400
"CHILD HATS, WIGS & MASKS",9/1/2009,-0.172644961366165
"CHILD HATS, WIGS & MASKS",10/1/2009,-0.453255508263169
"CHILD HATS, WIGS & MASKS",11/1/2009,-1.09903330959344

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] coding negative effects in categorical dummy variables

2009-12-01 Thread andre74

Hello,

I have a problem with categorical variables and dummy encoding. I've a
factor and
for each pair (i,j) with i != j, I'd like to fit 
res ~ a*x[i] - b*x[j]. A brief example with 3 variables:

a - b = 2
b - c = -1
c - a = 0

Thus I fitted the following model: 

fit <- lm(result ~ X + Y) 

where Y is just the negative of X, means y[i] = -x[i]. 

But I don't want to double the variables. Thus I used the coding:

ht <- unclass(X)
at <- unclass(Y)
cnt<-0
for(j in 1:100) # number of equations
{ 
   cnt<-cnt+1
   y[cnt,at[j]]=1;
   y[cnt,ht[j]]=-1;  
} 
 
fit <- lm(res ~ y[-length(y)]) # omit singularities.

>From the equations above 
a - b = 2
b - c = -1
c - a = 0

a  bcres
--
1 -10   2
0  1   -1  -1
-1 0   10 

Since this matrix is singular. I omit last column (c) 
and replaced it by intercept:

Change to 
ab   c(intercept)   res
1   -1   1 2   
01   1  -1
-1  01 0

and solved this. But somehow this incorrect.
I stuck in this since a couple of while. Does
anybody know how to solve this? Maybe solve.QP 
is an answer to this? 

Please help 
-- 
View this message in context: 
http://n4.nabble.com/coding-negative-effects-in-categorical-dummy-variables-tp932611p932611.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] write.csv fails with $ operator invalid for atomic

2009-12-01 Thread ggraves

It was in some documentation along with using data.frame and other entries that 
didn't work.  Can't explain why I didn't try it "as is".
 
Gregory A. Graves
Lead Scientist
REstoration COoordination and VERification (RECOVER) 
Restoration Sciences Department
South Florida Water Management District
Phones:  DESK:  561 / 682 - 2429
  CELL:  561 / 719 - 8157
 



From: John Kane-2 [via R] [mailto:ml-node+932595-1696738...@n4.nabble.com]
Sent: Tue 12/1/2009 5:12 PM
To: Graves, Gregory
Subject: Re: [R] write.csv fails with $ operator invalid for atomic


Where does the table come from? 

write.csv(t, file = "t.csv") 

looks like it would work 



--- On Tue, 12/1/09, ggraves <[hidden email] 
 > wrote: 


> From: ggraves <[hidden email] 
>  > 
> Subject: [R]  write.csv fails with $ operator invalid for atomic 
> To: [hidden email] 
>   
> Received: Tuesday, December 1, 2009, 1:36 PM 
> 
> I want to export a csv file so I can do other things with 
> it. 
> 
> I issue this command to break down years as to whether it 
> was windy or not: 
> 
> t<-tapply(TURB,list(year,windy),mean,na.rm=T) 
> 
> which results in: 
> 
> > t 
> no
>yes 
> 1990 21.516514  39.86400 
> 1991 13.580435  28.87500 
> 1992 12.171429  22.93913 
> 1993 21.550893  26.41200 
> 1994 12.003913  40.76928 
> 1995 14.707917  35.39057 
> 1996 22.041765  44.54927 
> 1997 17.577625  31.60761 
> 1998 26.283978  34.36190 
> 1999 14.597922  43.85804 
> 2000 30.805139  63.06042 
> 2001 23.204545  36.64634 
> 2002 21.062791  32.86696 
> 2003 14.487111  33.68727 
> 2004 36.294595  73.38125 
> 2005 49.089583 114.28333 
> 2006 44.941667  89.37917 
> 2007 57.456667  70.00435 
> 2008 52.251163  89.83864 
> 2009 24.212821  37.49375 
> 
> when I issue this command 
> 
> write.csv(t$table, file = "t.csv") 
> 
> I get the error 
> 
> ERROR $ operator is invalid for atomic vectors 
> 
> ?? 
> 
> 
> -- 
> View this message in context: 
> http://n4.nabble.com/write-csv-fails-with-operator-invalid-for-atomic-tp932414p932414.html
> Sent from the R help mailing list archive at Nabble.com. 
> 
> __ 
> [hidden email] 
>   
> mailing list 
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, 
> reproducible code. 
> 


  __ 
Yahoo! Canada Toolbar: Search from anywhere on the web, and bookmark your 
favourite sites. Download it now 
http://ca.toolbar.yahoo.com  . 

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





View message @ 
http://n4.nabble.com/write-csv-fails-with-operator-invalid-for-atomic-tp932414p932595.html
 
To unsubscribe from write.csv fails with $ operator invalid for atomic, click 
here < (link removed) > . 


-- 
View this message in context: 
http://n4.nabble.com/write-csv-fails-with-operator-invalid-for-atomic-tp932414p932605.html
Sent from the R help mailing list archive at Nabble.com.

[[alternative HTML version deleted]]

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


Re: [R] write.csv fails with $ operator invalid for atomic

2009-12-01 Thread John Kane
Where does the table come from?

write.csv(t, file = "t.csv")

looks like it would work



--- On Tue, 12/1/09, ggraves  wrote:

> From: ggraves 
> Subject: [R]  write.csv fails with $ operator invalid for atomic
> To: r-help@r-project.org
> Received: Tuesday, December 1, 2009, 1:36 PM
> 
> I want to export a csv file so I can do other things with
> it.
> 
> I issue this command to break down years as to whether it
> was windy or not:
> 
> t<-tapply(TURB,list(year,windy),mean,na.rm=T)
> 
> which results in:
> 
> > t
>             no   
>    yes
> 1990 21.516514  39.86400
> 1991 13.580435  28.87500
> 1992 12.171429  22.93913
> 1993 21.550893  26.41200
> 1994 12.003913  40.76928
> 1995 14.707917  35.39057
> 1996 22.041765  44.54927
> 1997 17.577625  31.60761
> 1998 26.283978  34.36190
> 1999 14.597922  43.85804
> 2000 30.805139  63.06042
> 2001 23.204545  36.64634
> 2002 21.062791  32.86696
> 2003 14.487111  33.68727
> 2004 36.294595  73.38125
> 2005 49.089583 114.28333
> 2006 44.941667  89.37917
> 2007 57.456667  70.00435
> 2008 52.251163  89.83864
> 2009 24.212821  37.49375
> 
> when I issue this command
> 
> write.csv(t$table, file = "t.csv")
> 
> I get the error
> 
> ERROR $ operator is invalid for atomic vectors
> 
> ??
> 
> 
> -- 
> View this message in context: 
> http://n4.nabble.com/write-csv-fails-with-operator-invalid-for-atomic-tp932414p932414.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.
> 


  __
Yahoo! Canada Toolbar: Search from anywhere on the web, and bookmark your 
favourite sites. Download it now
http://ca.toolbar.yahoo.com.

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


Re: [R] How to compute contrast where there are interaction terms in the linear model?

2009-12-01 Thread Charles C. Berry

On Tue, 1 Dec 2009, Peng Yu wrote:


Could somebody recommend some textbook how to compute contrast when
there are interactions terms? "Applied Linear Regression Models"
(book) mentioned contrast, but I cannot extend it to the case where
there are interaction terms.



Textbook? Schmextbook!

You have the power of R at your fingertips!

Use it to explore concepts you are trying to wrap your brain around!



df <- expand.grid(x1=1:20,x2=factor(letters[1:2]))
vanilla <- model.matrix(~0+poly(x1,degree=3), df )
matplot(row( vanilla) , vanilla, type='b')
inter <-  model.matrix(~0+poly(x1,degree=3):x2, df )
matplot(row( inter ) , inter, type='b')




Chuck


Charles C. Berry(858) 534-2098
Dept of Family/Preventive Medicine
E mailto:cbe...@tajo.ucsd.edu   UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901

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

2009-12-01 Thread Hongbo Zhu
Hi,

I am using R 2.9.0.  It seems the documentation for the calculation of
Canberra distance using stats::dist is ambiguous. Does anyone have the
original definition given in the Lance & Williams paper from Aust. Comput.
J. 1, 15-20, 1967?

When there are zeros at certain position in both vectors, they are not
omitted as documented in the function (see below). Instead, Canberra
distance is calculated as described in Frédéric Chiroleu's post (
http://tolstoy.newcastle.edu.au/R/e3/help/07/10/1370.html )
d(x,y) = (NZ + 1)/NZ * sum(abs(x-y)/(x+y)), where NZ is the number of
none-zero positions. This can also be seen from the example given in the
document for stats::dist (see below).
However, when there is no such a position where the values are zero in both
vectors, the Canberra distance is calculated using the formula given in the
document.

Examples:

> dist(rbind(c(1,2,3,4), c(2,3,4,5)), method='canberra')
  1
2 0.7873016

> dist(rbind(c(1,2,3,4,0), c(2,3,4,5,0)), method='canberra')
 1
2 0.984127


> help(dist)
dist  package:stats  R Documentation

Distance Matrix Computation
 ..

 'canberra': sum(|x_i - y_i| / |x_i + y_i|).  Terms with zero
  numerator and denominator are omitted from the sum and
  treated as if the values were missing.

 ## example of binary and canberra distances.
 x <- c(0, 0, 1, 1, 1, 1)
 y <- c(1, 0, 1, 1, 0, 1)
 dist(rbind(x,y), method= "binary")
 ## answer 0.4 = 2/5
 dist(rbind(x,y), method= "canberra")
 ## answer 2 * (6/5)

Thanks!
-- 
Hongbo

[[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 compute contrast where there are interaction terms in the linear model?

2009-12-01 Thread Peng Yu
Could somebody recommend some textbook how to compute contrast when
there are interactions terms? "Applied Linear Regression Models"
(book) mentioned contrast, but I cannot extend it to the case where
there are interaction terms.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Cut intervals (character) to numeric midpoint; regex problem

2009-12-01 Thread David Winsemius

On Dec 1, 2009, at 3:28 PM, Gabor Grothendieck wrote:

> Try this:
>
> > library(gsubfn)
> > strapply(testvec, "[-+.0-9]+", as.numeric, simplify = ~  
> colMeans(cbind(...)))
> [1] -5.8500 -2.9800 -2.8160 -2.7120 -2.6325 -2.5680

Very, nice. Also tried on some other valid ("200,2") and  
invalid )"2..2") numbers as it has worked as expected. It did not  
accept "--2.597" but that hardly seems to be a plausible result from a  
cut operation.

-- 
David.

>
>
> On Tue, Dec 1, 2009 at 3:14 PM, David Winsemius  > wrote:
> I'm sitting here chuckling. Your solution is just so "pure".
>
> I would offer an enhancement. When I tested with my cuts that had  
> "-" before the digits, you solution dropped them, so my suggestion  
> for the pattern would be:   "[-[:digit:].]+"
>
> I will admit that I thought it might fail with positive numbers but  
> it does not seem to:
>
> > interv <- strapply(testvec, "[-[:digit:].]+", as.numeric, simplify  
> = TRUE)
> > interv
>   [,1] [,2]   [,3]   [,4]   [,5]   [,6]   [,7][,8]   [, 
> 9] [,10]
> [1,] -8.616   -3.084 -2.876 -2.756 -2.668 -2.597 -1.008 -1.  
> 0.9914 1.000
> [2,] -3.084   -2.876 -2.756 -2.668 -2.597 -2.539 -1.000 -0.9922  
> 1. 1.009
>
> I was not able to get that pattern to give acceptable results in  
> gsubfn, so I obviously need to study this more closely.
>
> -- 
> David.
>
>
> On Dec 1, 2009, at 2:47 PM, Gabor Grothendieck wrote:
>
> You also might want to look at
>
> demo("gsubfn-cut")
>
>
> On Tue, Dec 1, 2009 at 2:41 PM, David Winsemius  > wrote:
> Starting with the head of a 499 element matrix whose column names  
> are now the labels trom a cut() operation, I needed to get to a  
> vector of midpoints to serve as the basis for plotting a calibration  
> curve ( exp(linear predictor) vs.  :
>
> > dput(head(dimnames(mtcal)[2][[1]])) # was starting point
>
>
> testvec <- c("(-8.616,-3.084]", "(-3.084,-2.876]",  
> "(-2.876,-2.756]", "(-2.756,-2.668]",
> "(-2.668,-2.597]", "(-2.597,-2.539]")
>
> I started this message with the thought of requesting an answer but  
> kept asking myself if I really had check the docs and tested my  
> understanding. I eventually solved it using the gsubfn from the  
> gsubfn package:
>
> testintvl <-as.numeric(gsubfn("\\((-?[[:digit:]]+.?[[:digit:]]*),
> (-?[[:digit:]]+.?[[:digit:]]*)\\]",
> ~ (as.numeric(x)+as.numeric(y))/2,  testvec))
>
> # I did discover that carriage returns in the middle of the pattern  
> will not give desired results, so if this is broken by your mail- 
> client, be sure to rejoin in the console.
>
> The extra "?"'s after the decimal point are in there because I had 4  
> NA's around the median linear predictor:
>
> > dimnames(mtcal)[2][[1]][which(is.na(testintvl))]
> [1] "(-1.008,-1]"  "(-1,-0.9922]" "(0.9914,1]"   "(1,1.009]"
>
> So a better test vector would be:
>
> testvec <- c("(-8.616,-3.084]", "(-3.084,-2.876]",  
> "(-2.876,-2.756]", "(-2.756,-2.668]",
> "(-2.668,-2.597]", "(-2.597,-2.539]", "(-1.008,-1]",   
> "(-1,-0.9922]", "(0.9914,1]", "(1,1.009]" )
>
> > testintvl <-as.numeric(gsubfn("\\((-?[[:digit:]]+.?[[:digit:]]*), 
> (-?[[:digit:]]+.?[[:digit:]]*)\\]",
> + ~ (as.numeric(x)+as.numeric(y))/2,  testvec))
>
> > testintvl
>  [1] -5.8500 -2.9800 -2.8160 -2.7120 -2.6325 -2.5680 -1.0040  
> -0.9961  0.9957  1.0045
>
> I offer this to those who may feel regex challenged (as I often do).  
> The gsubfn function is pretty slick. I don't see an author listed  
> for the function, but the author of the package documents is Gabor  
> Grothendieck.
>
> --
>
> David Winsemius, MD
> Heritage Laboratories
> West Hartford, CT
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>
> David Winsemius, MD
> Heritage Laboratories
> West Hartford, CT
>
>

David Winsemius, MD
Heritage Laboratories
West Hartford, CT


[[alternative HTML version deleted]]

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


Re: [R] ggplot legend for multiple time series

2009-12-01 Thread hadley wickham
Because of the combinatorial nature of ggplot2, it is simply not
possible to provide an example that illustrates every single
combination of options.  There are already over 600 example graphics
in the package - if you can't find one that exactly meets your need,
you need to buy the book and learn more about the rich theory
underlying the package.

Hadley

On Tue, Dec 1, 2009 at 2:02 PM, Edwin Sun  wrote:
>
> Hello - Thank you so much for the help. It works perfectly. I guess that as
> many have pointed out, ggplot is a great package but there is a lack of
> documentation and examples.
>
> Edwin Sun
>
>
> baptiste auguie-5 wrote:
>>
>> Hi,
>>
>> I don't understand why you used scale_manual_colour if you want only
>> black lines. To have different line types in the legend you can map
>> the linetype to the data,
>>
>>
>> huron <- data.frame(year=1875:1972, level=LakeHuron)
>>
>> ggplot(huron, aes(year)) +
>>    geom_line(aes(y=level+5, linetype="above")) +
>>    geom_line(aes(y=level-5, linetype="below")) +
>>    scale_linetype_manual("offset", c(1, 2))
>>
>> HTH,
>>
>> baptiste
>> 2009/12/1 Edwin Sun :
>>>
>>> Hello All,
>>>
>>> I am trying to create a legend for a black-white graph. The package I use
>>> is
>>> ggplot2. It can add colors to the legend key but not line types. Can you
>>> please help?
>>>
>>> # example from Wickman (2009, ggplot2 – elegant graphics for data
>>> analysis,
>>> page 109)
>>>
>>> library(ggplot2)
>>> huron <- data.frame(year=1875:1972, level=LakeHuron)
>>> ggplot(huron, aes(year)) +
>>>    geom_line(aes(y=level+5, colour="above")) +
>>>    geom_line(aes(y=level-5, colour="below")) +
>>>    scale_colour_manual("Direction", c("above"="black", "below"="black"))
>>>
>>> Thanks,
>>>
>>>
>>> Edwin
>>>
>>> Changyou Sun, Ph.D.
>>> Associate Professor
>>> Natural Resource Policy & Economics
>>> Box 9681, Department of Forestry
>>> Mississippi State University
>>> Mississippi State, MS 39762
>>>
>>> #363 Thompson Hall
>>> (662) 325 7271 (ph), 325 8726 (fax)
>>> c...@cfr.msstate.edu
>>> www.cfr.msstate.edu/forestry
>>> --
>>> View this message in context:
>>> http://n4.nabble.com/ggplot-legend-for-multiple-time-series-tp932430p932430.html
>>> Sent from the R help mailing list archive at Nabble.com.
>>>
>>> __
>>> R-help@r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide
>>> http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>>>
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>>
>
> --
> View this message in context: 
> http://n4.nabble.com/ggplot-legend-for-multiple-time-series-tp932430p932491.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.
>



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

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


Re: [R] Cut intervals (character) to numeric midpoint; regex problem

2009-12-01 Thread Gabor Grothendieck
Try this:

> library(gsubfn)
> strapply(testvec, "[-+.0-9]+", as.numeric, simplify = ~
colMeans(cbind(...)))
[1] -5.8500 -2.9800 -2.8160 -2.7120 -2.6325 -2.5680


On Tue, Dec 1, 2009 at 3:14 PM, David Winsemius wrote:

> I'm sitting here chuckling. Your solution is just so "pure".
>
> I would offer an enhancement. When I tested with my cuts that had "-"
> before the digits, you solution dropped them, so my suggestion for the
> pattern would be:   "[-[:digit:].]+"
>
> I will admit that I thought it might fail with positive numbers but it does
> not seem to:
>
> > interv <- strapply(testvec, "[-[:digit:].]+", as.numeric, simplify =
> TRUE)
> > interv
>   [,1] [,2]   [,3]   [,4]   [,5]   [,6]   [,7][,8]   [,9] [,10]
> [1,] -8.616   -3.084 -2.876 -2.756 -2.668 -2.597 -1.008 -1. 0.9914
> 1.000
> [2,] -3.084   -2.876 -2.756 -2.668 -2.597 -2.539 -1.000 -0.9922 1.
> 1.009
>
> I was not able to get that pattern to give acceptable results in gsubfn, so
> I obviously need to study this more closely.
>
> --
> David.
>
>
> On Dec 1, 2009, at 2:47 PM, Gabor Grothendieck wrote:
>
>  You also might want to look at
>>
>> demo("gsubfn-cut")
>>
>>
>> On Tue, Dec 1, 2009 at 2:41 PM, David Winsemius 
>> wrote:
>> Starting with the head of a 499 element matrix whose column names are now
>> the labels trom a cut() operation, I needed to get to a vector of midpoints
>> to serve as the basis for plotting a calibration curve ( exp(linear
>> predictor) vs.  :
>>
>> > dput(head(dimnames(mtcal)[2][[1]])) # was starting point
>>
>>
>> testvec <- c("(-8.616,-3.084]", "(-3.084,-2.876]", "(-2.876,-2.756]",
>> "(-2.756,-2.668]",
>> "(-2.668,-2.597]", "(-2.597,-2.539]")
>>
>> I started this message with the thought of requesting an answer but kept
>> asking myself if I really had check the docs and tested my understanding. I
>> eventually solved it using the gsubfn from the gsubfn package:
>>
>> testintvl <-as.numeric(gsubfn("\\((-?[[:digit:]]+.?[[:digit:]]*),
>> (-?[[:digit:]]+.?[[:digit:]]*)\\]",
>> ~ (as.numeric(x)+as.numeric(y))/2,  testvec))
>>
>> # I did discover that carriage returns in the middle of the pattern will
>> not give desired results, so if this is broken by your mail-client, be sure
>> to rejoin in the console.
>>
>> The extra "?"'s after the decimal point are in there because I had 4 NA's
>> around the median linear predictor:
>>
>> > dimnames(mtcal)[2][[1]][which(is.na(testintvl))]
>> [1] "(-1.008,-1]"  "(-1,-0.9922]" "(0.9914,1]"   "(1,1.009]"
>>
>> So a better test vector would be:
>>
>> testvec <- c("(-8.616,-3.084]", "(-3.084,-2.876]", "(-2.876,-2.756]",
>> "(-2.756,-2.668]",
>> "(-2.668,-2.597]", "(-2.597,-2.539]", "(-1.008,-1]",  "(-1,-0.9922]",
>> "(0.9914,1]", "(1,1.009]" )
>>
>> > testintvl
>> <-as.numeric(gsubfn("\\((-?[[:digit:]]+.?[[:digit:]]*),(-?[[:digit:]]+.?[[:digit:]]*)\\]",
>> + ~ (as.numeric(x)+as.numeric(y))/2,  testvec))
>>
>> > testintvl
>>  [1] -5.8500 -2.9800 -2.8160 -2.7120 -2.6325 -2.5680 -1.0040 -0.9961
>>  0.9957  1.0045
>>
>> I offer this to those who may feel regex challenged (as I often do). The
>> gsubfn function is pretty slick. I don't see an author listed for the
>> function, but the author of the package documents is Gabor Grothendieck.
>>
>> --
>>
>> David Winsemius, MD
>> Heritage Laboratories
>> West Hartford, CT
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>>
> David Winsemius, MD
> Heritage Laboratories
> West Hartford, CT
>
>

[[alternative HTML version deleted]]

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


Re: [R] median for time data

2009-12-01 Thread uvilla

Thanks you both

Jannis now it is working!!. I just have one mor request, please!
How I'm suppose to make a boxplot with anfang, when working with times, it
just have on the y axis some decimal number which make no sense. i need the
time to appear in the y axis in order to see the median in the boxplot


Thanks again!!!



Jannis v. Buttlar wrote:
> 
> 
> 
> uvilla schrieb:
>> When I use strptime() I just get NA NA NA
>> I`m new at using R, must finisth this work thoug
>> 
>> I guess Im doing totally wrong, actually everytime i try to use "POSIXct"
>> it
>> doesn`t work
>> 
> 
> If you have a look at help(strptime) you find that you have to specify 
> the format in which you time is written.
> 
> Try
> 
> strptime("08:10:10","%H:%M:%S")
> 
> The stuff after the comma in the "" is the way to give strptime the
> format.
> 
> Now you only have use
> 
> strptime(vectorwithyourtime,"%H:%M:%S")
> 
> and you should get a vector with R format times out of it. It uses 
> todays date though but for your calculations this should work. This 
> POSIXct format is not very handy to use though, so you perhaps better 
> consider using library(chron) as Gabor suggested.
> 
> 
> 
> 
>> Thanks a lot
>> 
>> 
>> 
>> Jannis wrote:
>>> Hi,
>>>
>>>
>>> try to convert this to the R time format "POSIXct" or "POSIXlt" via 
>>> strptime(). Then you can simply substract them. I am not sure whether a 
>>> median can be calculated though (should be possible as POSIXct stores 
>>> the value as seconds since 1970)
>>>
>>> Best
>>> Jannis
>>>
>>> uvilla schrieb:
 Hi everybody

 How do I do to calculate the median and average of a colum of time data
 like
 this: "8:50:10". I also need to plot the time difference between two
 colums
 Thanks a lot
>>> __
>>> R-help@r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide
>>> http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>>>
>>>
>>
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 

-- 
View this message in context: 
http://n4.nabble.com/median-for-time-data-tp932287p932511.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Cut intervals (character) to numeric midpoint; regex problem

2009-12-01 Thread David Winsemius

I'm sitting here chuckling. Your solution is just so "pure".

I would offer an enhancement. When I tested with my cuts that had "-"  
before the digits, you solution dropped them, so my suggestion for the  
pattern would be:   "[-[:digit:].]+"


I will admit that I thought it might fail with positive numbers but it  
does not seem to:


> interv <- strapply(testvec, "[-[:digit:].]+", as.numeric, simplify  
= TRUE)

> interv
   [,1] [,2]   [,3]   [,4]   [,5]   [,6]   [,7][,8]   [, 
9] [,10]
[1,] -8.616   -3.084 -2.876 -2.756 -2.668 -2.597 -1.008 -1. 0.9914  
1.000
[2,] -3.084   -2.876 -2.756 -2.668 -2.597 -2.539 -1.000 -0.9922 1.  
1.009


I was not able to get that pattern to give acceptable results in  
gsubfn, so I obviously need to study this more closely.


--
David.

On Dec 1, 2009, at 2:47 PM, Gabor Grothendieck wrote:


You also might want to look at

demo("gsubfn-cut")


On Tue, Dec 1, 2009 at 2:41 PM, David Winsemius > wrote:
Starting with the head of a 499 element matrix whose column names  
are now the labels trom a cut() operation, I needed to get to a  
vector of midpoints to serve as the basis for plotting a calibration  
curve ( exp(linear predictor) vs.  :


> dput(head(dimnames(mtcal)[2][[1]])) # was starting point


testvec <- c("(-8.616,-3.084]", "(-3.084,-2.876]",  
"(-2.876,-2.756]", "(-2.756,-2.668]",

"(-2.668,-2.597]", "(-2.597,-2.539]")

I started this message with the thought of requesting an answer but  
kept asking myself if I really had check the docs and tested my  
understanding. I eventually solved it using the gsubfn from the  
gsubfn package:


testintvl <-as.numeric(gsubfn("\\((-?[[:digit:]]+.?[[:digit:]]*),
(-?[[:digit:]]+.?[[:digit:]]*)\\]",
~ (as.numeric(x)+as.numeric(y))/2,  testvec))

# I did discover that carriage returns in the middle of the pattern  
will not give desired results, so if this is broken by your mail- 
client, be sure to rejoin in the console.


The extra "?"'s after the decimal point are in there because I had 4  
NA's around the median linear predictor:


> dimnames(mtcal)[2][[1]][which(is.na(testintvl))]
[1] "(-1.008,-1]"  "(-1,-0.9922]" "(0.9914,1]"   "(1,1.009]"

So a better test vector would be:

testvec <- c("(-8.616,-3.084]", "(-3.084,-2.876]",  
"(-2.876,-2.756]", "(-2.756,-2.668]",
"(-2.668,-2.597]", "(-2.597,-2.539]", "(-1.008,-1]",   
"(-1,-0.9922]", "(0.9914,1]", "(1,1.009]" )


> testintvl <-as.numeric(gsubfn("\\((-?[[:digit:]]+.?[[:digit:]]*), 
(-?[[:digit:]]+.?[[:digit:]]*)\\]",

+ ~ (as.numeric(x)+as.numeric(y))/2,  testvec))

> testintvl
 [1] -5.8500 -2.9800 -2.8160 -2.7120 -2.6325 -2.5680 -1.0040  
-0.9961  0.9957  1.0045


I offer this to those who may feel regex challenged (as I often do).  
The gsubfn function is pretty slick. I don't see an author listed  
for the function, but the author of the package documents is Gabor  
Grothendieck.


--

David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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



David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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


Re: [R] ggplot legend for multiple time series

2009-12-01 Thread Edwin Sun

Hello - Thank you so much for the help. It works perfectly. I guess that as
many have pointed out, ggplot is a great package but there is a lack of
documentation and examples. 

Edwin Sun


baptiste auguie-5 wrote:
> 
> Hi,
> 
> I don't understand why you used scale_manual_colour if you want only
> black lines. To have different line types in the legend you can map
> the linetype to the data,
> 
> 
> huron <- data.frame(year=1875:1972, level=LakeHuron)
> 
> ggplot(huron, aes(year)) +
>geom_line(aes(y=level+5, linetype="above")) +
>geom_line(aes(y=level-5, linetype="below")) +
>scale_linetype_manual("offset", c(1, 2))
> 
> HTH,
> 
> baptiste
> 2009/12/1 Edwin Sun :
>>
>> Hello All,
>>
>> I am trying to create a legend for a black-white graph. The package I use
>> is
>> ggplot2. It can add colors to the legend key but not line types. Can you
>> please help?
>>
>> # example from Wickman (2009, ggplot2 – elegant graphics for data
>> analysis,
>> page 109)
>>
>> library(ggplot2)
>> huron <- data.frame(year=1875:1972, level=LakeHuron)
>> ggplot(huron, aes(year)) +
>>    geom_line(aes(y=level+5, colour="above")) +
>>    geom_line(aes(y=level-5, colour="below")) +
>>    scale_colour_manual("Direction", c("above"="black", "below"="black"))
>>
>> Thanks,
>>
>>
>> Edwin
>>
>> Changyou Sun, Ph.D.
>> Associate Professor
>> Natural Resource Policy & Economics
>> Box 9681, Department of Forestry
>> Mississippi State University
>> Mississippi State, MS 39762
>>
>> #363 Thompson Hall
>> (662) 325 7271 (ph), 325 8726 (fax)
>> c...@cfr.msstate.edu
>> www.cfr.msstate.edu/forestry
>> --
>> View this message in context:
>> http://n4.nabble.com/ggplot-legend-for-multiple-time-series-tp932430p932430.html
>> Sent from the R help mailing list archive at Nabble.com.
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 

-- 
View this message in context: 
http://n4.nabble.com/ggplot-legend-for-multiple-time-series-tp932430p932491.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Cut intervals (character) to numeric midpoint; regex problem

2009-12-01 Thread Henrique Dallazuanna
Perhaps this shoul work too:

sapply(strsplit(gsub("^\\W|\\W$", "", testvec), ","),
function(x)sum(as.numeric(x))/2)

On Tue, Dec 1, 2009 at 5:41 PM, David Winsemius  wrote:
> Starting with the head of a 499 element matrix whose column names are now
> the labels trom a cut() operation, I needed to get to a vector of midpoints
> to serve as the basis for plotting a calibration curve ( exp(linear
> predictor) vs.  :
>
>> dput(head(dimnames(mtcal)[2][[1]])) # was starting point
>
>
> testvec <- c("(-8.616,-3.084]", "(-3.084,-2.876]", "(-2.876,-2.756]",
> "(-2.756,-2.668]",
> "(-2.668,-2.597]", "(-2.597,-2.539]")
>
> I started this message with the thought of requesting an answer but kept
> asking myself if I really had check the docs and tested my understanding. I
> eventually solved it using the gsubfn from the gsubfn package:
>
> testintvl <-as.numeric(gsubfn("\\((-?[[:digit:]]+.?[[:digit:]]*),
> (-?[[:digit:]]+.?[[:digit:]]*)\\]",
> ~ (as.numeric(x)+as.numeric(y))/2,  testvec))
>
> # I did discover that carriage returns in the middle of the pattern will not
> give desired results, so if this is broken by your mail-client, be sure to
> rejoin in the console.
>
> The extra "?"'s after the decimal point are in there because I had 4 NA's
> around the median linear predictor:
>
>> dimnames(mtcal)[2][[1]][which(is.na(testintvl))]
> [1] "(-1.008,-1]"  "(-1,-0.9922]" "(0.9914,1]"   "(1,1.009]"
>
> So a better test vector would be:
>
> testvec <- c("(-8.616,-3.084]", "(-3.084,-2.876]", "(-2.876,-2.756]",
> "(-2.756,-2.668]",
> "(-2.668,-2.597]", "(-2.597,-2.539]", "(-1.008,-1]",  "(-1,-0.9922]",
> "(0.9914,1]", "(1,1.009]" )
>
>> testintvl
>> <-as.numeric(gsubfn("\\((-?[[:digit:]]+.?[[:digit:]]*),(-?[[:digit:]]+.?[[:digit:]]*)\\]",
> + ~ (as.numeric(x)+as.numeric(y))/2,  testvec))
>
>> testintvl
>  [1] -5.8500 -2.9800 -2.8160 -2.7120 -2.6325 -2.5680 -1.0040 -0.9961  0.9957
>  1.0045
>
> I offer this to those who may feel regex challenged (as I often do). The
> gsubfn function is pretty slick. I don't see an author listed for the
> function, but the author of the package documents is Gabor Grothendieck.
>
> --
>
> David Winsemius, MD
> Heritage Laboratories
> West Hartford, CT
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



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

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


Re: [R] An R vs. SAS Discrepancy: How do I determine which is correct?

2009-12-01 Thread Kevin E. Thorpe

Thanks to an insightful comment from Jeremy Miles, who politely
pointed out my thick-headed moment, I know what happened.

The sex variable was coded as 1/2 in the SAS data, but was a factor
in the R data and so became a properly coded dummy variable.

Sorry for the obvious question and answer.

Kevin E. Thorpe wrote:

I was messing around with some data in R and SAS (the reason is
unimportant) fitting a multiple linear regression and got a
curious discrepancy.  The data set is too big to post, but if
someone wants it, I can send it.

So, here are the (partial) results:

 From R:

Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 61.114341.48065  41.275  < 2e-16 ***
sexWomen 2.911080.35753   8.1425e-16 ***
diabp0.206750.01504  13.746  < 2e-16 ***
age -0.080850.02088  -3.871 0.000110 ***

 From SAS (sorry about word-wrap if it happens):

  Parameter Estimates

Parameter Standard
 Variable   Label DF EstimateError 
 t Value


 Intercept  Intercept  1 58.20326  1.57802 
   36.88
 SEXSEX1  2.91108  0.35753 
8.14
 DIABP  Diastolic BP mmHg  1  0.20675  0.01504 
   13.75
 AGEAge (years) at examination 1 -0.08085  0.02088 
   -3.87


  Parameter Estimates

 Variable   Label DF  Pr > |t|

 Intercept  Intercept  1<.0001
 SEXSEX1<.0001
 DIABP  Diastolic BP mmHg  1<.0001
 AGEAge (years) at examination 10.0001

The curious thihs is that all parameter estimates agree except the
intercept.  In R I also computed the coefficients directly using
(X'X)^(-1) X' y and get the same coefficients as lm() have me.
Also, ols() in Design agrees with lm()

As far as I can tell, the data used in R and SAS are identical.  So,
whose answer is correct and how do I prove it?  Here's my sessionInfo
(yes, I know my version of R is oldish).

 > sessionInfo()
R version 2.8.0 (2008-10-20)
i686-pc-linux-gnu

locale:
LC_CTYPE=en_US;LC_NUMERIC=C;LC_TIME=en_US;LC_COLLATE=C;LC_MONETARY=C;LC_MESSAGES=en_US;LC_PAPER=en_US;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US;LC_IDENTIFICATION=C 



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

other attached packages:
[1] Design_2.2-0survival_2.35-4 Hmisc_3.6-0 lattice_0.17-25

loaded via a namespace (and not attached):
[1] cluster_1.12.0 grid_2.8.0




--
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] ggplot legend for multiple time series

2009-12-01 Thread baptiste auguie
Hi,

I don't understand why you used scale_manual_colour if you want only
black lines. To have different line types in the legend you can map
the linetype to the data,


huron <- data.frame(year=1875:1972, level=LakeHuron)

ggplot(huron, aes(year)) +
   geom_line(aes(y=level+5, linetype="above")) +
   geom_line(aes(y=level-5, linetype="below")) +
   scale_linetype_manual("offset", c(1, 2))

HTH,

baptiste
2009/12/1 Edwin Sun :
>
> Hello All,
>
> I am trying to create a legend for a black-white graph. The package I use is
> ggplot2. It can add colors to the legend key but not line types. Can you
> please help?
>
> # example from Wickman (2009, ggplot2 – elegant graphics for data analysis,
> page 109)
>
> library(ggplot2)
> huron <- data.frame(year=1875:1972, level=LakeHuron)
> ggplot(huron, aes(year)) +
>    geom_line(aes(y=level+5, colour="above")) +
>    geom_line(aes(y=level-5, colour="below")) +
>    scale_colour_manual("Direction", c("above"="black", "below"="black"))
>
> Thanks,
>
>
> Edwin
>
> Changyou Sun, Ph.D.
> Associate Professor
> Natural Resource Policy & Economics
> Box 9681, Department of Forestry
> Mississippi State University
> Mississippi State, MS 39762
>
> #363 Thompson Hall
> (662) 325 7271 (ph), 325 8726 (fax)
> c...@cfr.msstate.edu
> www.cfr.msstate.edu/forestry
> --
> View this message in context: 
> http://n4.nabble.com/ggplot-legend-for-multiple-time-series-tp932430p932430.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

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


Re: [R] Cut intervals (character) to numeric midpoint; regex problem

2009-12-01 Thread Gabor Grothendieck
You also might want to look at

demo("gsubfn-cut")


On Tue, Dec 1, 2009 at 2:41 PM, David Winsemius wrote:

> Starting with the head of a 499 element matrix whose column names are now
> the labels trom a cut() operation, I needed to get to a vector of midpoints
> to serve as the basis for plotting a calibration curve ( exp(linear
> predictor) vs.  :
>
> > dput(head(dimnames(mtcal)[2][[1]])) # was starting point
>
>
> testvec <- c("(-8.616,-3.084]", "(-3.084,-2.876]", "(-2.876,-2.756]",
> "(-2.756,-2.668]",
> "(-2.668,-2.597]", "(-2.597,-2.539]")
>
> I started this message with the thought of requesting an answer but kept
> asking myself if I really had check the docs and tested my understanding. I
> eventually solved it using the gsubfn from the gsubfn package:
>
> testintvl <-as.numeric(gsubfn("\\((-?[[:digit:]]+.?[[:digit:]]*),
> (-?[[:digit:]]+.?[[:digit:]]*)\\]",
> ~ (as.numeric(x)+as.numeric(y))/2,  testvec))
>
> # I did discover that carriage returns in the middle of the pattern will
> not give desired results, so if this is broken by your mail-client, be sure
> to rejoin in the console.
>
> The extra "?"'s after the decimal point are in there because I had 4 NA's
> around the median linear predictor:
>
> > dimnames(mtcal)[2][[1]][which(is.na(testintvl))]
> [1] "(-1.008,-1]"  "(-1,-0.9922]" "(0.9914,1]"   "(1,1.009]"
>
> So a better test vector would be:
>
> testvec <- c("(-8.616,-3.084]", "(-3.084,-2.876]", "(-2.876,-2.756]",
> "(-2.756,-2.668]",
> "(-2.668,-2.597]", "(-2.597,-2.539]", "(-1.008,-1]",  "(-1,-0.9922]",
> "(0.9914,1]", "(1,1.009]" )
>
> > testintvl
> <-as.numeric(gsubfn("\\((-?[[:digit:]]+.?[[:digit:]]*),(-?[[:digit:]]+.?[[:digit:]]*)\\]",
> + ~ (as.numeric(x)+as.numeric(y))/2,  testvec))
>
> > testintvl
>  [1] -5.8500 -2.9800 -2.8160 -2.7120 -2.6325 -2.5680 -1.0040 -0.9961
>  0.9957  1.0045
>
> I offer this to those who may feel regex challenged (as I often do). The
> gsubfn function is pretty slick. I don't see an author listed for the
> function, but the author of the package documents is Gabor Grothendieck.
>
> --
>
> David Winsemius, MD
> Heritage Laboratories
> West Hartford, CT
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[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] An R vs. SAS Discrepancy: How do I determine which is correct?

2009-12-01 Thread Kevin E. Thorpe

I was messing around with some data in R and SAS (the reason is
unimportant) fitting a multiple linear regression and got a
curious discrepancy.  The data set is too big to post, but if
someone wants it, I can send it.

So, here are the (partial) results:

From R:

Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 61.114341.48065  41.275  < 2e-16 ***
sexWomen 2.911080.35753   8.1425e-16 ***
diabp0.206750.01504  13.746  < 2e-16 ***
age -0.080850.02088  -3.871 0.000110 ***

From SAS (sorry about word-wrap if it happens):

  Parameter Estimates

Parameter Standard
 Variable   Label DF EstimateError 
 t Value


 Intercept  Intercept  1 58.20326  1.57802 
   36.88
 SEXSEX1  2.91108  0.35753 
8.14
 DIABP  Diastolic BP mmHg  1  0.20675  0.01504 
   13.75
 AGEAge (years) at examination 1 -0.08085  0.02088 
   -3.87


  Parameter Estimates

 Variable   Label DF  Pr > |t|

 Intercept  Intercept  1<.0001
 SEXSEX1<.0001
 DIABP  Diastolic BP mmHg  1<.0001
 AGEAge (years) at examination 10.0001

The curious thihs is that all parameter estimates agree except the
intercept.  In R I also computed the coefficients directly using
(X'X)^(-1) X' y and get the same coefficients as lm() have me.
Also, ols() in Design agrees with lm()

As far as I can tell, the data used in R and SAS are identical.  So,
whose answer is correct and how do I prove it?  Here's my sessionInfo
(yes, I know my version of R is oldish).

> sessionInfo()
R version 2.8.0 (2008-10-20)
i686-pc-linux-gnu

locale:
LC_CTYPE=en_US;LC_NUMERIC=C;LC_TIME=en_US;LC_COLLATE=C;LC_MONETARY=C;LC_MESSAGES=en_US;LC_PAPER=en_US;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US;LC_IDENTIFICATION=C

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

other attached packages:
[1] Design_2.2-0survival_2.35-4 Hmisc_3.6-0 lattice_0.17-25

loaded via a namespace (and not attached):
[1] cluster_1.12.0 grid_2.8.0

--
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

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

2009-12-01 Thread Rolf Turner


On 1/12/2009, at 8:32 PM, Karl Ove Hufthammer wrote:




Exercise to the reader:

Note that
sapply(split(x, ff, drop=TRUE), sum)
gives you the values of (just) the non-empty levels.

Now, why does
  sapply(split(x, ff), sum, drop=TRUE)
give the wrong value (1) for these levels, while
  sapply(split(x, ff), sum, drop=FALSE)
gives the the correct value?

(The answer should be fairly obvious, but it's an easy mistake to  
make.)


That is ***CUTE***.  I had to think long and hard to see what was  
going on.

(But then I'm never very quick out of the blocks. :-) )

cheers,

Rolf Turner

##
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}

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


[R] Cut intervals (character) to numeric midpoint; regex problem

2009-12-01 Thread David Winsemius
Starting with the head of a 499 element matrix whose column names are  
now the labels trom a cut() operation, I needed to get to a vector of  
midpoints to serve as the basis for plotting a calibration curve  
( exp(linear predictor) vs.  :


> dput(head(dimnames(mtcal)[2][[1]])) # was starting point


testvec <- c("(-8.616,-3.084]", "(-3.084,-2.876]", "(-2.876,-2.756]",  
"(-2.756,-2.668]",

"(-2.668,-2.597]", "(-2.597,-2.539]")

I started this message with the thought of requesting an answer but  
kept asking myself if I really had check the docs and tested my  
understanding. I eventually solved it using the gsubfn from the gsubfn  
package:


testintvl <-as.numeric(gsubfn("\\((-?[[:digit:]]+.?[[:digit:]]*),
(-?[[:digit:]]+.?[[:digit:]]*)\\]",
~ (as.numeric(x)+as.numeric(y))/2,  testvec))

# I did discover that carriage returns in the middle of the pattern  
will not give desired results, so if this is broken by your mail- 
client, be sure to rejoin in the console.


The extra "?"'s after the decimal point are in there because I had 4  
NA's around the median linear predictor:


> dimnames(mtcal)[2][[1]][which(is.na(testintvl))]
[1] "(-1.008,-1]"  "(-1,-0.9922]" "(0.9914,1]"   "(1,1.009]"

So a better test vector would be:

testvec <- c("(-8.616,-3.084]", "(-3.084,-2.876]", "(-2.876,-2.756]",  
"(-2.756,-2.668]",
"(-2.668,-2.597]", "(-2.597,-2.539]", "(-1.008,-1]",  "(-1,-0.9922]",  
"(0.9914,1]", "(1,1.009]" )


> testintvl <-as.numeric(gsubfn("\\((-?[[:digit:]]+.?[[:digit:]]*),(-? 
[[:digit:]]+.?[[:digit:]]*)\\]",

+ ~ (as.numeric(x)+as.numeric(y))/2,  testvec))

> testintvl
 [1] -5.8500 -2.9800 -2.8160 -2.7120 -2.6325 -2.5680 -1.0040 -0.9961   
0.9957  1.0045


I offer this to those who may feel regex challenged (as I often do).  
The gsubfn function is pretty slick. I don't see an author listed for  
the function, but the author of the package documents is Gabor  
Grothendieck.


--

David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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


Re: [R] LMER: How to specify Random Effects

2009-12-01 Thread Ubuntu Diego

Thanks for your feedback.
Actually Plant is nested since High and Low are qualitative relative 
values (High in Michigan is not the same as High in Sienna).



S Ellison wrote:

The Plant classification is not nested; it's an effect across all
countires and states and probably a fixed effct (assuming you want to
measure its size or significance). But the state is nested in country.

That would suggest to me 
lmer(Reaction~Drug+Plant+(1|Country/State),...)


(or Plant*Drug, if you want an interaction)

However, though your states are nested in countrythey are readily
identifiable by lmer as different for each country (you do not have
country1: State1, State2..., Country2:State1,State2..) so the nesting by
country probably doesn't need to be specified. I think the above would,
_in this case_ be almost identical to 


lmer(Reaction~Drug+Plant+(1|Country)+(1|State),...)





  

Ubuntu Diego  01/12/2009 16:22:09 >>>


I saw different specifications for Random Effects and I'm confused
about 
the use of "/" and  the use of "(0+...|)" .
Let say we have a nested structure where some countries have some 
several plants in different states and we measure the reaction to a

drug.

The list of Countries = USA, France, Italy
The States for USA = Michigan, Florida, California
The States for France =  Paris, Orleans
The States for Italy =  Venezia, Sienna, Florence, Rome, Napoli ,
Sicilia

Plants were classified as High and Low

is this the way to specify a possible model ?

lmer(Reaction ~ Drug + (1| Country / State / Plant) , data)

or should I use something like this
A) lmer(Reaction ~ Drug + (0| Country / State / Plant) , data)
B) lmer(Reaction ~ Drug + (1| Country ) + (0+Country | State / Plant) ,

data)
C) lmer(Reaction ~ Drug + (1| Country ) + (0+Country | State / Plant) +

(0+Country + State | Plant), data)
D) lmer(Reaction ~ Drug + (1| Country ) + (0+Country | State ) + 
(0+Country + State | Plant), data)


Thanks

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


***
This email and any attachments are confidential. Any u...{{dropped:9}}


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


[R] ggplot legend for multiple time series

2009-12-01 Thread Edwin Sun

Hello All,

I am trying to create a legend for a black-white graph. The package I use is
ggplot2. It can add colors to the legend key but not line types. Can you
please help?

# example from Wickman (2009, ggplot2 – elegant graphics for data analysis,
page 109)

library(ggplot2)
huron <- data.frame(year=1875:1972, level=LakeHuron)
ggplot(huron, aes(year)) +
geom_line(aes(y=level+5, colour="above")) +
geom_line(aes(y=level-5, colour="below")) +
scale_colour_manual("Direction", c("above"="black", "below"="black"))

Thanks,


Edwin

Changyou Sun, Ph.D.
Associate Professor
Natural Resource Policy & Economics
Box 9681, Department of Forestry
Mississippi State University
Mississippi State, MS 39762

#363 Thompson Hall
(662) 325 7271 (ph), 325 8726 (fax)
c...@cfr.msstate.edu
www.cfr.msstate.edu/forestry
-- 
View this message in context: 
http://n4.nabble.com/ggplot-legend-for-multiple-time-series-tp932430p932430.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] ggplot legend for multiple time series

2009-12-01 Thread Changyou Sun
Hello All,

 

I am trying to create a legend for a black-white graph. The package I
use is ggplot2. It can add colors to the legend key but not line types.
Can you please help?

 

# example from Wickman (2009, ggplot2 - elegant graphics for data
analysis, page 109)

 

library(ggplot2)

huron <- data.frame(year=1875:1972, level=LakeHuron)

ggplot(huron, aes(year)) +

geom_line(aes(y=level+5, colour="above")) +

geom_line(aes(y=level-5, colour="below")) +

scale_colour_manual("Direction", c("above"="black",
"below"="black"))

 

Thanks,

 

 

Edwin

 

Changyou Sun, Ph.D.

Associate Professor

Natural Resource Policy & Economics

Box 9681, Department of Forestry

Mississippi State University

Mississippi State, MS 39762

 

#363 Thompson Hall

(662) 325 7271 (ph), 325 8726 (fax)

c...@cfr.msstate.edu

www.cfr.msstate.edu/forestry

 


[[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 grouping on the X axis.

2009-12-01 Thread Munin

   I am trying to plot data with multiple logical and physical groups using
R.  Below is a sample of the kind of data I am working with and the desired
output.  We have a jmp script that can do the same thing, but at ~$200 a
year the licensing is counterproductive.  Thanks for any help.

Data input: Loaded from a CSV file.
Physical_1 Logical_1 Logical_2 Data_1 Data_2
x   Y   Z2  54   56
x   Y2 Z2  53   55
x   Y3 Z2  52   54
x2 Y   Z60   58
x2 Y2 Z59   57
x2 Y3 Z58   56
x3 Y   Z56   53
x3 Y2 Z55   52
x3 Y3 Z54   51
x4 Y   Z2  52   55
x4 Y2 Z2   51   54
x4 Y3 Z2   50   53


I need the graph to be grouped as follows:
-
|Y|Y2|Y3|Y|Y2|Y3|Y|Y2|Y3|Y|Y2|Y3|
-
| X|  X4  |  X2   |  X3  |
-
|   Z   |Z2 |
-

   Again, any help would be appreciated.
-- 
View this message in context: 
http://n4.nabble.com/Multiple-grouping-on-the-X-axis-tp932397p932397.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] median for time data

2009-12-01 Thread Jannis v. Buttlar



uvilla schrieb:

When I use strptime() I just get NA NA NA
I`m new at using R, must finisth this work thoug

I guess Im doing totally wrong, actually everytime i try to use "POSIXct" it
doesn`t work



If you have a look at help(strptime) you find that you have to specify 
the format in which you time is written.


Try

strptime("08:10:10","%H:%M:%S")

The stuff after the comma in the "" is the way to give strptime the format.

Now you only have use

strptime(vectorwithyourtime,"%H:%M:%S")

and you should get a vector with R format times out of it. It uses 
todays date though but for your calculations this should work. This 
POSIXct format is not very handy to use though, so you perhaps better 
consider using library(chron) as Gabor suggested.






Thanks a lot



Jannis wrote:

Hi,


try to convert this to the R time format "POSIXct" or "POSIXlt" via 
strptime(). Then you can simply substract them. I am not sure whether a 
median can be calculated though (should be possible as POSIXct stores 
the value as seconds since 1970)


Best
Jannis

uvilla schrieb:

Hi everybody

How do I do to calculate the median and average of a colum of time data
like
this: "8:50:10". I also need to plot the time difference between two
colums
Thanks a lot

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






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


[R] write.csv fails with $ operator invalid for atomic

2009-12-01 Thread ggraves

I want to export a csv file so I can do other things with it.

I issue this command to break down years as to whether it was windy or not:

t<-tapply(TURB,list(year,windy),mean,na.rm=T)

which results in:

> t
no   yes
1990 21.516514  39.86400
1991 13.580435  28.87500
1992 12.171429  22.93913
1993 21.550893  26.41200
1994 12.003913  40.76928
1995 14.707917  35.39057
1996 22.041765  44.54927
1997 17.577625  31.60761
1998 26.283978  34.36190
1999 14.597922  43.85804
2000 30.805139  63.06042
2001 23.204545  36.64634
2002 21.062791  32.86696
2003 14.487111  33.68727
2004 36.294595  73.38125
2005 49.089583 114.28333
2006 44.941667  89.37917
2007 57.456667  70.00435
2008 52.251163  89.83864
2009 24.212821  37.49375

when I issue this command

write.csv(t$table, file = "t.csv")

I get the error

ERROR $ operator is invalid for atomic vectors

??


-- 
View this message in context: 
http://n4.nabble.com/write-csv-fails-with-operator-invalid-for-atomic-tp932414p932414.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Learning R

2009-12-01 Thread Dr. Thomas W. MacFarland
Hi Julia:

I am sure that you will find many useful resources as you attempt to learn
R.

If time permits, please look at the Tegrity-based video that I’ve prepared
for my students:

http://tegrity1.acast.nova.edu/tegrityUtils/GetCourseListing.aspx?Session_In
fo=7KmTs8Wkvvr0/Q0TsCfcur4RNGDvBGYk0jY+RNouoFosZ5zARrXkT5Sh6Kna2HKM 

The video is about one hour in length, it is specific to the needs of
beginners, and it covers the type of concerns that you post in your message.

If you do not have prior experience with Tegrity-based videos, you can
easily show the entire screen just by clicking on the screen maximize icon,
on the right side of the screen.  You can then toggle between full screen
and partial screen by using the Escape (Esc) key.

Good luck with R and your program of studies.  However, you may want to
allow for more than two months to learn R, even if you are a quick study.  

Best wishes.

Dr. Thomas W. MacFarland

-
Thomas W. MacFarland, Ed.D.
Senior Research Associate; Institutional Effectiveness and Associate
Professor
Nova Southeastern University
Voice 954-262-5395  Fax 954-262-3970  tom...@nsu.nova.edu

Julia Cains wrote:
> Dear R helpers,
> 
> Almost 15 days back I have become member of this very active and wonderful
group. So far I have been only raising  queries and in turn got them solved
too and I really thank for the spirit this group member show when it comes
to the guidance.
> 
> I wish to learn R language and I have given 2 months time for this. Can
anyone please guide me as how do I begin i.e. from basics to advance.
> 
> R is such a vast thing to learn, so I wish to learn it step by step
without getting lost at any stage.
> 
> Please guide me where do I start and upgrade myself to higher level step
by step.
> 
> Regards
> 
> Julia
> 


-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of r-help-requ...@r-project.org
Sent: Tuesday, December 01, 2009 6:00 AM
To: r-help@r-project.org
Subject: R-help Digest, Vol 82, Issue 1

Send R-help mailing list submissions to
r-help@r-project.org

To subscribe or unsubscribe via the World Wide Web, visit
https://stat.ethz.ch/mailman/listinfo/r-help
or, via email, send a message with subject or body 'help' to
r-help-requ...@r-project.org

You can reach the person managing the list at
r-help-ow...@r-project.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of R-help digest..."

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

2009-12-01 Thread Gabor Grothendieck
Specify that your input is of class yearmon (as opposed to Date class) and
also correct the format specification as per the percent codes in ?strptime

library(zoo)
z <- read.zoo("clipboard", FUN = as.yearmon, format = "%b-%y")



On Tue, Dec 1, 2009 at 12:55 PM, Megh  wrote:

>
> In my Excel file, I have data in following format :
>
> Feb-07  38.49
> Mar-07  39.95
> Apr-07  37.47
> May-07  35.77
> Jun-07  32.96
> Jul-07  33.27
>
> I tried to copy this data as a time series using following code :
>
> library(zoo)
> dat <- read.zoo(file="clipboard", format="%m-%y")
>
> However getting following error :
>
> Error in read.zoo(file = "clipboard", format = "%m-%y") :
>  index has bad entries at data rows: 1 2 3 4 5 6
>
> Can anyone please guide me what is the right way to do that?
>
> Thanks,
>
> --
> View this message in context:
> http://n4.nabble.com/Problem-in-reading-data-tp932386p932386.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.
>

[[alternative HTML version deleted]]

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


[R] Testing the significance of gradients in trends

2009-12-01 Thread Steve Murray

Dear all,

I want to determine if the slopes of the trends I have in my plot are 
significantly different from each other (I have 2 time-series trends). What 
statistical test is most suitable for this purpose and is it available in the R 
base package?

Many thanks,

Steve
  
_
Use Hotmail to send and receive mail from your different email accounts

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

2009-12-01 Thread Gabor Grothendieck
# input

library(chron)
tt <- times(c("8:50:10", "9:40:20", "10:55:45"))
tt2 <- times(c("01:00:00", "02:00:00", "03:00:00"))
tt
tt2

# calc median and differences (although it will give results as fractions of
a day if there are negative results)

median(tt)
tt - tt2
tt2 - tt

On Tue, Dec 1, 2009 at 10:46 AM, uvilla  wrote:

>
> Hi everybody
>
> How do I do to calculate the median and average of a colum of time data
> like
> this: "8:50:10". I also need to plot the time difference between two colums
> Thanks a lot
> --
> View this message in context:
> http://n4.nabble.com/median-for-time-data-tp932287p932287.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.
>

[[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] median for time data

2009-12-01 Thread uvilla

Thanks a lot for your answer Jannis.
Actually, I should have specified what I`m trying to do.
I have a datafame which 3 colums, one is the "person ID", second is "Anfag"
and third is "Ende". The two time colums are in this way: "8:50:10", so I
have to calculate the medan of the Anfag colum and to determine the length
of the route.
When I use strptime() I just get NA NA NA
I`m new at using R, must finisth this work thoug

I guess Im doing totally wrong, actually everytime i try to use "POSIXct" it
doesn`t work

Thanks a lot



Jannis wrote:
> 
> Hi,
> 
> 
> try to convert this to the R time format "POSIXct" or "POSIXlt" via 
> strptime(). Then you can simply substract them. I am not sure whether a 
> median can be calculated though (should be possible as POSIXct stores 
> the value as seconds since 1970)
> 
> Best
> Jannis
> 
> uvilla schrieb:
>> Hi everybody
>> 
>> How do I do to calculate the median and average of a colum of time data
>> like
>> this: "8:50:10". I also need to plot the time difference between two
>> colums
>> Thanks a lot
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 

-- 
View this message in context: 
http://n4.nabble.com/median-for-time-data-tp932287p932402.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] Problem in reading data

2009-12-01 Thread Megh

In my Excel file, I have data in following format :

Feb-07  38.49
Mar-07  39.95
Apr-07  37.47
May-07  35.77
Jun-07  32.96
Jul-07  33.27

I tried to copy this data as a time series using following code :

library(zoo)
dat <- read.zoo(file="clipboard", format="%m-%y")

However getting following error :

Error in read.zoo(file = "clipboard", format = "%m-%y") : 
  index has bad entries at data rows: 1 2 3 4 5 6

Can anyone please guide me what is the right way to do that?

Thanks,

-- 
View this message in context: 
http://n4.nabble.com/Problem-in-reading-data-tp932386p932386.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] eigenvalues of complex matrices

2009-12-01 Thread Ravi Varadhan
Hi,

You haven't given us much information.  

You might actually have the same eigenvalues, but don't recognize that due
to possibly different orderings.  Complex numbers do not possess ordering.
Therefore, there is no natural way to report complex eigenvalues.  In R, the
complex eigenvalues are ordered in decreasing order of the absolute value of
"real" part, whereas in Matlab it may be that they are ordered in terms of
the modulus (absolute value) of the complex number.

I have used "arpack" before to obtain the first few dominant eigenvalues,
and the same issue of different "ordering" of eigenvalues also applies
there. 


Ravi.


---

Ravi Varadhan, Ph.D.

Assistant Professor, The Center on Aging and Health

Division of Geriatric Medicine and Gerontology 

Johns Hopkins University

Ph: (410) 502-2619

Fax: (410) 614-9625

Email: rvarad...@jhmi.edu

Webpage:
http://www.jhsph.edu/agingandhealth/People/Faculty_personal_pages/Varadhan.h
tml

 





-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of David Scherrer
Sent: Tuesday, December 01, 2009 11:36 AM
To: r-help@r-project.org
Subject: [R] eigenvalues of complex matrices

Dear all,

I want to compute the eigenvalues of a complex matrix for some statistics.
Comparing it to its matlab/octave sibling, I don't get the same eigenvalues
in R computing it from the exact same matrix.

In R, I used eigen() and arpack() that give different eigenvalues. In
matlab/octave I used eig() and eigs() that give out the same eigenvalues but
different to the R ones.
For real matrices, R and matlab/octave are consistent.

Does anybody know what could go on here and how I could get consistent
eigenvalues in R? Since I definitely want to do the analysis in R.

Many thanks,
David

[[alternative HTML version deleted]]

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

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


Re: [R] Starting estimates for nls Exponential Fit

2009-12-01 Thread Katharine Mullen
If you could reformulate your model as alpha * (y0 + E^t) then you could
use nls with alg="plinear" (alpha then would be eliminated from the
nonlinear param and treated as conditionally linear) and this would help
with convergence.

Else you can try package DEoptim to get the starting values; the advantage
over optim is that you need then lower and upper bounds on the parameters,
not more starting values; the bounds however should be appropriate and as
tight as possible.

Also: by default nls uses max. 50 iter.  Depending on where you start off
you may need more than this.

##

ExponValues <- c(2018.34,2012.54,2018.85,2023.52,2054.58,2132.61,2247.17,
 2468.32,2778.47)

ExponCycles <- c(17,18,19,20,21,22,23,24,25)

library(DEoptim)

mod <- function(x) x[1] + x[2]*x[3]^ExponCycles
fun <- function(x) sum((ExponValues-mod(x))^2)

ss <- DEoptim(fun, lower=rep(0,3), upper=c(10e7, 10, 10),
  control=list(trace=FALSE))

pa <- ss$optim$bestmem

## now have par est that give OK fit
matplot(cbind(ExponValues, mod(pa)),type="l")

names(pa) <- c("Y0", "a", "E")

## fit w/port and GN
Emodel<- nls(ExponValues ~ (Y0 + a*(E^ExponCycles)),
 start=pa, algorithm="port",
 control=list(maxiter=1000, warnOnly=TRUE))

Emodel1 <- nls(ExponValues ~ (Y0 + a*(E^ExponCycles)), start=pa,
 control=list(maxiter=1000, warnOnly=TRUE))

## fit
matplot(cbind(ExponValues, fitted(Emodel), fitted(Emodel1)),type="l")

On Tue, 1 Dec 2009, Anto wrote:

>
> Hello everyone,
>
> I have come across a bit of an odd problem: I am currently analysing data
> PCR reaction data of which part is behaving exponential. I would like to fit
> the exponential part to the following:
>
> y0 + alpha * E^t
>
> In which Y0 is the groundphase, alpha a fluorescence factor, E the
> efficiency of the reaction & t is time (in cycles)
>
> I can get this to work for most of my reactions, but part fails the nls fit
> (Convergence failure: iteration limit reached without convergence). This
> mainly has to do with the starting estimates for the nls function. I have
> used various 'smart' ways of calculating starting estimates (grid searches,
> optim(), etc.) but however close the starting estimates are to the actual
> values, nls still fails for many datasets.
>
> The weirdest thing is, I have one set of starting estimates (alpha= 0.5 and
> E=1.85) which are totaly arbitray and these DO work for, say 99% of the
> datasets. I don't know why this is and I don't why my 'good estimates' do
> not work. I am desperatly seeking a way of calculating working starting
> estimates for my nls function. Can anybody give me a hand?
>
> thanks,
>
> Anto
>
> R version 2.9.2
>
> example dataset:
>
> ExponValues
> [1] 2018.34 2012.54 2018.85 2023.52 2054.58 2132.61 2247.17 2468.32 2778.47
>
> ExponCycles
> [1] 17 18 19 20 21 22 23 24 25
>
>
> Example starting estimate calculation
>
> Y0 <- ExponValues[1]
> E <-
> weighted.mean((ExponValues-eY0)[-1][-1]/(ExponValues-eY0)[-1][-(length(ExponValues)-1)],(1-abs(seq(-1,1,length=(length(ExponValues)-2)))^3)^3)
> alpha <-
> weighted.mean((ExponValues[-1]-ExponValues[-length(ExponValues)])/((E^ExponCycles[-1])-(E^ExponCycles[-length(ExponCycles)])),(1-abs(seq(-1,1,length=(length(ExponCycles)-1)))^3)^3)
>
>
> Optional parameter optimisation:
>
> Esp <-
> optim(c(Y0=eY0,a=alpha,E=E),function(x){return(sum(abs(ExponValues-(x[1]+x[2]*x[3]^ExponCycles})$par
>
>
> nls function:
>
> Emodel<-try(nls(ExponValues ~ (Y0 + a*(E^ExponCycles)) , start= Esp,
> algorithm="port"),silent=TRUE)
> --
> View this message in context: 
> http://n4.nabble.com/Starting-estimates-for-nls-Exponential-Fit-tp932230p932230.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

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


Re: [R] "subset" or "condition" as argument to a function

2009-12-01 Thread baptiste auguie
Hi,

an alternative to parse() is to use quote and bquote,

set.seed(123)
d = data.frame(a=letters[1:5], b=1:10, c=sample(0:1, 10, repl=TRUE))

cond1 <- quote(a=="b")
cond2 <- quote(b < 6)
cond3 <- bquote(.(cond1) & .(cond2))

subset(d, eval(cond1))
subset(d, eval(cond2))
subset(d, eval(cond3))

HTH,

baptiste



2009/12/1 William Dunlap :
>> -Original Message-
>> From: r-help-boun...@r-project.org
>> [mailto:r-help-boun...@r-project.org] On Behalf Of Santosh
>> Sent: Tuesday, December 01, 2009 7:39 AM
>> To: r-help@r-project.org
>> Subject: Re: [R] "subset" or "condition" as argument to a function
>>
>> Dear R gurus..
>> I had tried out some suggestions sent to me privately..and
>> unfortunately,
>> they did not work..
>>
>> To use a condiition in a subset, the associated dataframe needs to be
>> attached and detached, which I found cumbersome to use if
>> using more than 1
>> dataframe (with different dimensions) with same condition. I
>> would highly
>> appreciate your suggestions to overcome this problem.. Please
>> see my example
>> of usage I am trying to implement. Please note that the
>> "cond' takes in the
>> character instead of logical values...
>>
>> cond1 <- 'group==1&sales>200'
>> cond2 <- 'group==2&sales>200'
>> cond3 <- 'group==3&sales>200'
>>
>> d1 <- subset(dat,subset=cond1)
>> plot(y~x,data=dat,subset=cond1,type='b')
>
> The subset argument to plot (and many similar functions)
> must be given as a literal expression, not a string that
> could be parsed into an expression nor the name of an object
> containing an expression nor a function call that evaluates
> to an expression.  This design is handy for interactive
> use but painful in programatic use.  One way to deal with
> it is to use do.call, which evaluates all the arguments to
> the function and then calls the function with the arguments
> given literally.  Replace the above plot call with
>  do.call("plot", list(y~x,data=dat,subset=parse(text=cond1),type='b'))
> and see if you get what you want.
>
> Bill Dunlap
> Spotfire, TIBCO Software
> wdunlap tibco.com
>
>> lines(y~x,data=dat,subset=cond2)
>> points(y~x,data=dat,subset=paste(cond1,cond2,sep='&'),col='blue')
>> points(y~x,data=d1,subset=cond3,col='red')
>>
>> If I try the above, I get the following error message:
>> *Error in subset.data.frame(dat, cond) : 'subset' must
>> evaluate to logical*
>>
>> If you could also suggest references implementing similar
>> code, I would
>> highly appreciate it.
>> Thanks so much,
>>
>> Santosh
>>
>> On Mon, Nov 23, 2009 at 6:38 PM, Santosh
>>  wrote:
>>
>> > Thanks... I would try it out..
>> >  -santosh
>> >
>> >
>> > On Sat, Nov 21, 2009 at 12:04 AM, Bernardo Rangel Tura <
>> > t...@centroin.com.br> wrote:
>> >
>> >> On Fri, 2009-11-20 at 17:40 -0800, Santosh wrote:
>> >> > Dear Rxperts!
>> >> >
>> >> > I was wondering if it is possible to write a function
>> which can take in
>> >> > argument of a subset or condition.. Of course, I am aware of the
>> >> alternate
>> >> > methods like coplot, par.plot, xyplot etc... I am specifically
>> >> interested in
>> >> > using conditions/subsets with "plot"..
>> >> >
>> >> > A simple fragmented example is shown here..
>> >> >
>> >> > pltit <- function(y,x,dat,dat1,dat2,sbst) {
>> >> > plot(y~x, data=dat, subset=sbst)
>> >> > lines(y~x,data=dat1, subset=subst)
>> >> > points(y~x,data=dat2,subset=subst)
>> >> > }
>> >> >
>> >> > pltit(profit,weeks,dat=zone1, sbst='group==1&sales>200')
>> >> >
>> >> > Could you also suggest pointers/references/examples on
>> efficient ways to
>> >> > plot simulated data overlaid with observed data?
>> >> >
>> >> > Have a good weekend!
>> >>
>> >>
>> >>
>> >
>>
>>       [[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

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


Re: [R] Error message when logical indexing vecor is all FALSE

2009-12-01 Thread jim holtman
?try

On Tue, Dec 1, 2009 at 12:22 PM, Jannis  wrote:
> Dears,
>
>
> is there any way to "switch off" or work around the error message that
> pops up when I do something like:
>
>
> A<-B['logical vector']
>
>
> and when 'logical vector' only consists of FALSE values? My problem is
> that this message always kicks me out of my loops and always testing via
> an if clause whether 'logical vector' contains any TRUE values is much
> too complex due to many different conditions and several of the above
> statements (and actually it seems to make my code really slow).
>
>
> Cheers
> Jannis
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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?

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


[R] Error message when logical indexing vecor is all FALSE

2009-12-01 Thread Jannis

Dears,


is there any way to "switch off" or work around the error message that
pops up when I do something like:


A<-B['logical vector']


and when 'logical vector' only consists of FALSE values? My problem is
that this message always kicks me out of my loops and always testing via
an if clause whether 'logical vector' contains any TRUE values is much
too complex due to many different conditions and several of the above
statements (and actually it seems to make my code really slow).


Cheers
Jannis

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

2009-12-01 Thread Alfredo Alessandrini
Hi,

I've this time series:

> ts_evi
Time Series:
Start = c(2000, 4)
End = c(2002, 7)
Frequency = 23
 [1] 0.1948306 0.1930461 0.1905792 0.1848909 0.1893624 0.1811400 0.1678140
 [8] 0.1750714 0.3100132 0.3495946 0.4103353 0.4973740 0.4937490 0.4031435
[15] 0.3503787 0.2755022 0.2304617 0.2284854 0.2166127 0.2046744 0.2002691
[22] 0.1935237 0.1782539 0.1827050 0.1771288 0.1736177 0.1674035 0.1673382
[29] 0.1676010 0.1735880 0.1734465 0.2634710 0.2833674 0.3706685 0.4634188
[36] 0.4815648 0.4274418 0.3676624 0.2849945 0.2311094 0.2145767 0.2134797
[43] 0.2021141 0.1960431 0.1894779 0.1854458 0.1768988 0.1755865 0.1697464
[50] 0.1735197
> cycle(ts_evi)
Time Series:
Start = c(2000, 4)
End = c(2002, 7)
Frequency = 23
 [1]  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23  1  2  3  4  5
[26]  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23  1  2  3  4  5  6  7



What's the better method for obtain monthly value?


Thanks,

Alfredo

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


[R] problem with RWeka Weka_control RandomForest

2009-12-01 Thread Itziar Frades Alzueta






Dear All,



I am finding trouble trying to build a Wrapper using random forest to
evaluate the subsets:



I do:

nombi <-
make_Weka_filter("weka/filters/supervised/attribute/AttributeSelection")

datbin<- nombi(gene ~., data=X1X2X4X5W, control =Weka_control(
S=list("weka.attributeSelection.GeneticSearch"),
E=list("weka.attributeSelection.WrapperSubsetEval"),B =
list("weka.classifiers.trees.RandomForest")))



I get the following error:

Exception in thread "main" java.lang.Exception: Illegal options: -B
weka.classifiers.trees.RandomForest

  at weka.core.Utils.checkForRemainingOptions(Unknown Source)

  at
weka.filters.supervised.attribute.AttributeSelection.setOptions(Unknown
Source)



I tryied specifying more parameters and got the same error:



I do:

datbin<- nombi(gene ~., data=X1X2X3X4W,  control =Weka_control(
S=list("weka.attributeSelection.GeneticSearch"),
E=list("weka.attributeSelection.WrapperSubsetEval"),B =
list("weka.classifiers.trees.RandomForest -F 5 -T 0.01 -R 1 -- -I 10 -K
0 -S 1")))



I get the following error:

Exception in thread "main" java.lang.Exception: Illegal options: -B
weka.classifiers.trees.RandomForest -F 5 -T 0.01 -R 1 -- -I 10 -K 0 -S 1


  at weka.core.Utils.checkForRemainingOptions(Unknown Source)

  at
weka.filters.supervised.attribute.AttributeSelection.setOptions(Unknown
Source)



Regards,

Itziar frades




 

 

 



This e-mail is from CIC bioGUNE. The e-mail and any files transmitted with it 
are confidential and intended solely for the use of the individual or entity to 
whom they are addressed. Any unauthorised dissemination or copying of this 
e-mail or its attachments, and any use or disclosure of any information 
contained in them, is strictly prohibited and may be illegal. If you have 
received this e-mail in error, please notify or telephone + 34 944 06 13 00 and 
delete it from your system.

[[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] median for time data

2009-12-01 Thread Jannis

Hi,


try to convert this to the R time format "POSIXct" or "POSIXlt" via 
strptime(). Then you can simply substract them. I am not sure whether a 
median can be calculated though (should be possible as POSIXct stores 
the value as seconds since 1970)


Best
Jannis

uvilla schrieb:

Hi everybody

How do I do to calculate the median and average of a colum of time data like
this: "8:50:10". I also need to plot the time difference between two colums
Thanks a lot


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

2009-12-01 Thread Achim Zeileis

On Tue, 1 Dec 2009, Itziar Frades Alzueta wrote:


Dear All,



I am finding trouble trying to guild a Wrapper using random forest to
evaluate the subsets:



I do:

nombi <-
make_Weka_filter("weka/filters/supervised/attribute/AttributeSelection")

datbin<- nombi(gene ~., data=X1X2X4X5W, control =Weka_control(
S=list("weka.attributeSelection.GeneticSearch"),
E=list("weka.attributeSelection.WrapperSubsetEval"),B =
list("weka.classifiers.trees.RandomForest")))



I get the following error:

Exception in thread "main" java.lang.Exception: Illegal options: -B
weka.classifiers.trees.RandomForest


The error is fairly explicit, isn't it? There is no -B option for 
AttributeSelection, see

  WOW("weka/filters/supervised/attribute/AttributeSelection")

hth,
Z


 at weka.core.Utils.checkForRemainingOptions(Unknown Source)

 at
weka.filters.supervised.attribute.AttributeSelection.setOptions(Unknown
Source)



I tryied specifying more parameters and got the same error:



I do:

datbin<- nombi(gene ~., data=X1X2X3X4W,  control =Weka_control(
S=list("weka.attributeSelection.GeneticSearch"),
E=list("weka.attributeSelection.WrapperSubsetEval"),B =
list("weka.classifiers.trees.RandomForest -F 5 -T 0.01 -R 1 -- -I 10 -K
0 -S 1")))



I get the following error:

Exception in thread "main" java.lang.Exception: Illegal options: -B
weka.classifiers.trees.RandomForest -F 5 -T 0.01 -R 1 -- -I 10 -K 0 -S 1


 at weka.core.Utils.checkForRemainingOptions(Unknown Source)

 at
weka.filters.supervised.attribute.AttributeSelection.setOptions(Unknown
Source)












This e-mail is from CIC bioGUNE. The e-mail and any files transmitted with it 
are confidential and intended solely for the use of the individual or entity to 
whom they are addressed. Any unauthorised dissemination or copying of this 
e-mail or its attachments, and any use or disclosure of any information 
contained in them, is strictly prohibited and may be illegal. If you have 
received this e-mail in error, please notify or telephone + 34 944 06 13 00 and 
delete it from your system.

[[alternative HTML version deleted]]

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




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


Re: [R] "subset" or "condition" as argument to a function

2009-12-01 Thread William Dunlap
> -Original Message-
> From: r-help-boun...@r-project.org 
> [mailto:r-help-boun...@r-project.org] On Behalf Of Santosh
> Sent: Tuesday, December 01, 2009 7:39 AM
> To: r-help@r-project.org
> Subject: Re: [R] "subset" or "condition" as argument to a function
> 
> Dear R gurus..
> I had tried out some suggestions sent to me privately..and 
> unfortunately,
> they did not work..
> 
> To use a condiition in a subset, the associated dataframe needs to be
> attached and detached, which I found cumbersome to use if 
> using more than 1
> dataframe (with different dimensions) with same condition. I 
> would highly
> appreciate your suggestions to overcome this problem.. Please 
> see my example
> of usage I am trying to implement. Please note that the 
> "cond' takes in the
> character instead of logical values...
> 
> cond1 <- 'group==1&sales>200'
> cond2 <- 'group==2&sales>200'
> cond3 <- 'group==3&sales>200'
> 
> d1 <- subset(dat,subset=cond1)
> plot(y~x,data=dat,subset=cond1,type='b')

The subset argument to plot (and many similar functions)
must be given as a literal expression, not a string that
could be parsed into an expression nor the name of an object
containing an expression nor a function call that evaluates
to an expression.  This design is handy for interactive
use but painful in programatic use.  One way to deal with
it is to use do.call, which evaluates all the arguments to
the function and then calls the function with the arguments
given literally.  Replace the above plot call with
  do.call("plot", list(y~x,data=dat,subset=parse(text=cond1),type='b'))
and see if you get what you want.

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com 

> lines(y~x,data=dat,subset=cond2)
> points(y~x,data=dat,subset=paste(cond1,cond2,sep='&'),col='blue')
> points(y~x,data=d1,subset=cond3,col='red')
> 
> If I try the above, I get the following error message:
> *Error in subset.data.frame(dat, cond) : 'subset' must 
> evaluate to logical*
> 
> If you could also suggest references implementing similar 
> code, I would
> highly appreciate it.
> Thanks so much,
> 
> Santosh
> 
> On Mon, Nov 23, 2009 at 6:38 PM, Santosh 
>  wrote:
> 
> > Thanks... I would try it out..
> >  -santosh
> >
> >
> > On Sat, Nov 21, 2009 at 12:04 AM, Bernardo Rangel Tura <
> > t...@centroin.com.br> wrote:
> >
> >> On Fri, 2009-11-20 at 17:40 -0800, Santosh wrote:
> >> > Dear Rxperts!
> >> >
> >> > I was wondering if it is possible to write a function 
> which can take in
> >> > argument of a subset or condition.. Of course, I am aware of the
> >> alternate
> >> > methods like coplot, par.plot, xyplot etc... I am specifically
> >> interested in
> >> > using conditions/subsets with "plot"..
> >> >
> >> > A simple fragmented example is shown here..
> >> >
> >> > pltit <- function(y,x,dat,dat1,dat2,sbst) {
> >> > plot(y~x, data=dat, subset=sbst)
> >> > lines(y~x,data=dat1, subset=subst)
> >> > points(y~x,data=dat2,subset=subst)
> >> > }
> >> >
> >> > pltit(profit,weeks,dat=zone1, sbst='group==1&sales>200')
> >> >
> >> > Could you also suggest pointers/references/examples on 
> efficient ways to
> >> > plot simulated data overlaid with observed data?
> >> >
> >> > Have a good weekend!
> >>
> >>
> >>
> >
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 

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


[R] problem with RWeka Weka_control RandomForest

2009-12-01 Thread Itziar Frades Alzueta
Dear All,



I am finding trouble trying to guild a Wrapper using random forest to
evaluate the subsets:



I do:

nombi <-
make_Weka_filter("weka/filters/supervised/attribute/AttributeSelection")

datbin<- nombi(gene ~., data=X1X2X4X5W, control =Weka_control(
S=list("weka.attributeSelection.GeneticSearch"),
E=list("weka.attributeSelection.WrapperSubsetEval"),B =
list("weka.classifiers.trees.RandomForest")))



I get the following error:

Exception in thread "main" java.lang.Exception: Illegal options: -B
weka.classifiers.trees.RandomForest

  at weka.core.Utils.checkForRemainingOptions(Unknown Source)

  at
weka.filters.supervised.attribute.AttributeSelection.setOptions(Unknown
Source)



I tryied specifying more parameters and got the same error:



I do:

datbin<- nombi(gene ~., data=X1X2X3X4W,  control =Weka_control(
S=list("weka.attributeSelection.GeneticSearch"),
E=list("weka.attributeSelection.WrapperSubsetEval"),B =
list("weka.classifiers.trees.RandomForest -F 5 -T 0.01 -R 1 -- -I 10 -K
0 -S 1")))



I get the following error:

Exception in thread "main" java.lang.Exception: Illegal options: -B
weka.classifiers.trees.RandomForest -F 5 -T 0.01 -R 1 -- -I 10 -K 0 -S 1


  at weka.core.Utils.checkForRemainingOptions(Unknown Source)

  at
weka.filters.supervised.attribute.AttributeSelection.setOptions(Unknown
Source)




 

 

 



This e-mail is from CIC bioGUNE. The e-mail and any files transmitted with it 
are confidential and intended solely for the use of the individual or entity to 
whom they are addressed. Any unauthorised dissemination or copying of this 
e-mail or its attachments, and any use or disclosure of any information 
contained in them, is strictly prohibited and may be illegal. If you have 
received this e-mail in error, please notify or telephone + 34 944 06 13 00 and 
delete it from your system.

[[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] Package is loaded but functions are not exported

2009-12-01 Thread Saptarshi Guha
I have no idea why I used the \\, the perils of copy and pasting from
some other package or source .
So, heres the thing, did R regex interpreter change? How come my
export stopped working?
Thank you
Regards
Saptarshi


On Tue, Dec 1, 2009 at 11:28 AM, Romain Francois
 wrote:
> You probably just want : exportPattern("^rh")
>
> What did you expect the backslash to do ?
>
> On 12/01/2009 05:18 PM, Saptarshi Guha wrote:
>>
>> Hello,
>> I wrote a package, which in the NAMESPACE file exports functions like
>> this:
>>
>> exportPattern("^\\rh")
>>
>> On R-2.8 (Linux, 64), upon loading the package I have the rh functions
>> present.
>>
>> On R-2.10, Mac OS X, (32 bit), it builds, loads, but the functions are not
>> loaded, i.e the only function is rhyper (which is not from my package).
>>
>> Is there something wrong with my package setup?
>>
>> Regards
>> Saptarshi
>
> --
> Romain Francois
> Professional R Enthusiast
> +33(0) 6 28 91 30 30
> http://romainfrancois.blog.free.fr
> |- http://tr.im/FtUu : new package : highlight
> |- http://tr.im/EAD5 : LondonR slides
> `- http://tr.im/BcPw : celebrating R commit #5
>
>

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


  1   2   >