[R] Why is options(digits = 1) displays two digits?

2017-03-21 Thread Tal Galili
This may have been asked before, but I don't understand the behavior
of options(digits = 1) for vectors containing values such as 0.01

For example, why is this happening:
options(digits = 1)
> 0.01
[1] 0.01


More examples:
> options(digits = 7)
> 0.1
[1] 0.1
> 0.01
[1] 0.01
> 0.11
[1] 0.11
> c(0.1,0.01)
[1] 0.10 0.01
> options(digits = 1)
> 0.1
[1] 0.1
> 0.01
[1] 0.01
> 0.11
[1] 0.1
> c(0.1,0.01)
[1] 0.10 0.01
>

The help file in ?options says:
digits:
controls the number of digits to print when printing numeric values. It is
a suggestion only.


Is this what is mean by "It is a suggestion only." ?

[[alternative HTML version deleted]]

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


[R] Is a list an atomic object? (or is there an issue with the help page of ?tapply ?)

2017-02-04 Thread Tal Galili
In the help page of ?tapply it says that the first argument (X) is "an
atomic object, typically a vector."

However, tapply seems to be able to handle list objects. For example:

###

l <- as.list(1:10)
is.atomic(l) # FALSE
index <- c(rep(1,5),rep(2,5))
tapply(l,index,unlist)

> tapply(l,index,unlist)
$`1`
[1] 1 2 3 4 5

$`2`
[1]  6  7  8  9 10


###

Hence, does it mean a list an atomic object? (which I thought it wasn't) or
is the help for tapply needs updating?
(or some third option I'm missing?)

Thanks.





Contact
Details:---
Contact me: tal.gal...@gmail.com |
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--

[[alternative HTML version deleted]]

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


Re: [R] colored table

2016-05-30 Thread Tal Galili
Hell Naresh,

If to add to what others already wrote, there is also the new {heatmaply
} package, which enable
you to create *interactive* heatmaps. For examples, you can view the
vignette here:
https://cran.r-project.org/web/packages/heatmaply/vignettes/heatmaply.html

With regards,
Tal




Contact
Details:---
Contact me: tal.gal...@gmail.com |
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--


On Sat, May 28, 2016 at 4:10 PM, Naresh Gurbuxani <
naresh_gurbux...@hotmail.com> wrote:

> I want to print a table where table elements are colored according to the
> frequency of the bin.  For example, consider below table.
>
> Function values that I would like to print in the table
>
> x.eq.minus1  x.eq.zero  x.eq.plus1
> y.eq.minus1 -20 10-5
> y.eq.zero -10  6 22
> y.eq.plus1-810   -14
>
>
> Frequency table to color the above table
>
> x.eq.minus1  x.eq.zero  x.eq.plus1
> y.eq.minus1 0.05 0.15   0.1
> y.eq.zero 0.07 0.3   0.08
> y.eq.plus10.050.15   0.05
>
>
> In the resulting table, the element for (x = 0, y = 0) will be 6.  This
> will be printed with a dark color background.  The element for (x = -1, y =
> -1) will be -20.  This will be printed with a light color background.  And
> so on.
>
> Thanks for your help,
> Naresh
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


Re: [R] Using MASS::boxcox for a single variable gives different results than the original paper

2015-10-12 Thread Tal Galili
Peter and John - thank you both for the answers.


Tal




Contact
Details:---
Contact me: tal.gal...@gmail.com |
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--


On Mon, Oct 12, 2015 at 4:45 PM, Fox, John  wrote:

> Dear Tal,
>
> MASS:boxcox() evaluates the pseudo-log-likelihood at a pre-specified
> vector of values of the transformation parameter lambda. In your example,
>
> > head(a$x)
> [1] -2.00 -1.959596 -1.919192 -1.878788 -1.838384 -1.797980
>
> Which accounts, I think, for the small difference in the answer.
>
> I hope this helps,
>  John
>
> -
> John Fox, Professor
> McMaster University
> Hamilton, Ontario
> Canada L8S 4M4
> Web: socserv.mcmaster.ca/jfox
>
>
>
> > -Original Message-----
> > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Tal
> Galili
> > Sent: October 12, 2015 9:32 AM
> > To: r-help@r-project.org
> > Subject: Re: [R] Using MASS::boxcox for a single variable gives
> different results
> > than the original paper
> >
> > After trying this with the function "estimateTransform" from {car}, it
> returns
> > values similar to my solution rather than the one from MASS::boxcox:
> >
> >
> > # Toy data
> > 
> > set.seed(13241089)
> > x <- rnorm(1000, 10)
> > x2 <- x**2 # we want to transform x2 to something more normal
> >
> >
> >
> > # using MASS::boxcox
> > 
> >
> > mle <- function(BC) {
> > with(BC, x[which.max(y)])
> > }
> >
> > ONES <- rep(1, length(x2))
> > a <- MASS::boxcox(lm(x2 ~ ONES))
> > mle(a)
> > # lambda:
> > # 0.42424
> >
> >
> >
> > # using estimateTransform from car
> > 
> >
> > # Same result as the paper: !
> > library(car)
> > ONES <- rep(1, length(x2))
> > estimateTransform(X=data.frame(x = ONES), Y = x2) # lambda:
> > # 0.40782
> >
> > (just as with my own function in the previous email)
> >
> >
> >
> > What am I missing?
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > Contact
> > Details:---
> > Contact me: tal.gal...@gmail.com |
> > Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
> > www.r-statistics.com (English)
> >
> --
> >
> >
> > On Mon, Oct 12, 2015 at 12:17 PM, Tal Galili 
> wrote:
> >
> > > Hello all,
> > >
> > > Given a set of observations, I would like to find lambda for a boxcox
> > > transformation so to get a symmetric/normal result as possible.
> > >
> > > I try to use MASS::boxcox, but get different results than when using
> > > the formula from the original box-cox paper (link
> > > <http://www.jstor.org/stable/2984418?seq=1#page_scan_tab_contents>).
> > >
> > > I probably have made an error somewhere, but I can't figure out where.
> > >
> > > Here is an example in which the lambda by MASS::boxcox is 0.42424,
> > > while by the formula from the paper I get 0.40782.
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > # Toy data
> > > 
> > > set.seed(13241089)
> > > x <- rnorm(1000, 10)
> > > x2 <- x**2 # we want to transform x2 to something more normal
> > > plot(density(x2))
> > >
> > > # using MASS::boxcox
> > > 
> > >
> > > zpoints <- function(y) {
> > > n <- length(y)
> > > qnorm(ppoints(n))[order(order(y))]
> > > }
> > > mle <- function(BC) {
> > > with(BC, x[which.max(y)])
> > > }
> > >
> > > a <- MASS::boxcox(x2 ~ zpoints(x2))
> > > mle(a)
> > > # lambda:
> > > # 0.42424
> > >
> > >
> > >
> > > # using formula from the paper
> > > 
> > >
> > > loglik_lambda <- function(l, y) {
> > > GM <- exp(mean(log(y)))
> > > if(l==0) x <- log(y)*GM else x <- (y^l-1)/ (l * GM^(l-1) ) #  if(l==0)
> > > x <- log(y) else x <- (y^l-1)/ (l )
> > > sd(x)
> > > }
> > > fo <- function(l) loglik_lambda(l, y = x2) V_fo <- Vectorize(fo)
> > > V_fo(2)
> > > curve(V_fo, -.5,1.5)
> > > optimize(V_fo, c(-3,3))
> > > # lambda:
> > > # 0.40782
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> >
> >   [[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


Re: [R] Using MASS::boxcox for a single variable gives different results than the original paper

2015-10-12 Thread Tal Galili
After trying this with the function "estimateTransform" from {car}, it
returns values similar to my solution rather than the one from MASS::boxcox:


# Toy data

set.seed(13241089)
x <- rnorm(1000, 10)
x2 <- x**2 # we want to transform x2 to something more normal



# using MASS::boxcox


mle <- function(BC) {
with(BC, x[which.max(y)])
}

ONES <- rep(1, length(x2))
a <- MASS::boxcox(lm(x2 ~ ONES))
mle(a)
# lambda:
# 0.42424



# using estimateTransform from car


# Same result as the paper: !
library(car)
ONES <- rep(1, length(x2))
estimateTransform(X=data.frame(x = ONES), Y = x2)
# lambda:
# 0.40782

(just as with my own function in the previous email)



What am I missing?









Contact
Details:---
Contact me: tal.gal...@gmail.com |
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--


On Mon, Oct 12, 2015 at 12:17 PM, Tal Galili  wrote:

> Hello all,
>
> Given a set of observations, I would like to find lambda for a boxcox
> transformation so to get a symmetric/normal result as possible.
>
> I try to use MASS::boxcox, but get different results than when using the
> formula from the original box-cox paper (link
> <http://www.jstor.org/stable/2984418?seq=1#page_scan_tab_contents>).
>
> I probably have made an error somewhere, but I can't figure out where.
>
> Here is an example in which the lambda by MASS::boxcox is 0.42424, while
> by the formula from the paper I get 0.40782.
>
>
>
>
>
>
>
>
> # Toy data
> 
> set.seed(13241089)
> x <- rnorm(1000, 10)
> x2 <- x**2 # we want to transform x2 to something more normal
> plot(density(x2))
>
> # using MASS::boxcox
> 
>
> zpoints <- function(y) {
> n <- length(y)
> qnorm(ppoints(n))[order(order(y))]
> }
> mle <- function(BC) {
> with(BC, x[which.max(y)])
> }
>
> a <- MASS::boxcox(x2 ~ zpoints(x2))
> mle(a)
> # lambda:
> # 0.42424
>
>
>
> # using formula from the paper
> 
>
> loglik_lambda <- function(l, y) {
> GM <- exp(mean(log(y)))
> if(l==0) x <- log(y)*GM else x <- (y^l-1)/ (l * GM^(l-1) )
> #  if(l==0) x <- log(y) else x <- (y^l-1)/ (l )
> sd(x)
> }
> fo <- function(l) loglik_lambda(l, y = x2)
> V_fo <- Vectorize(fo)
> V_fo(2)
> curve(V_fo, -.5,1.5)
> optimize(V_fo, c(-3,3))
> # lambda:
> # 0.40782
>
>
>
>
>
>
>
>
>
>
>
>
>

[[alternative HTML version deleted]]

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


[R] Using MASS::boxcox for a single variable gives different results than the original paper

2015-10-12 Thread Tal Galili
Hello all,

Given a set of observations, I would like to find lambda for a boxcox
transformation so to get a symmetric/normal result as possible.

I try to use MASS::boxcox, but get different results than when using the
formula from the original box-cox paper (link
).

I probably have made an error somewhere, but I can't figure out where.

Here is an example in which the lambda by MASS::boxcox is 0.42424, while by
the formula from the paper I get 0.40782.








# Toy data

set.seed(13241089)
x <- rnorm(1000, 10)
x2 <- x**2 # we want to transform x2 to something more normal
plot(density(x2))

# using MASS::boxcox


zpoints <- function(y) {
n <- length(y)
qnorm(ppoints(n))[order(order(y))]
}
mle <- function(BC) {
with(BC, x[which.max(y)])
}

a <- MASS::boxcox(x2 ~ zpoints(x2))
mle(a)
# lambda:
# 0.42424



# using formula from the paper


loglik_lambda <- function(l, y) {
GM <- exp(mean(log(y)))
if(l==0) x <- log(y)*GM else x <- (y^l-1)/ (l * GM^(l-1) )
#  if(l==0) x <- log(y) else x <- (y^l-1)/ (l )
sd(x)
}
fo <- function(l) loglik_lambda(l, y = x2)
V_fo <- Vectorize(fo)
V_fo(2)
curve(V_fo, -.5,1.5)
optimize(V_fo, c(-3,3))
# lambda:
# 0.40782

[[alternative HTML version deleted]]

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


[R] Making as.hclust.phylo for non binary trees work?

2015-10-01 Thread Tal Galili
Dear R-help mailing list (and Emmanuel, the ape package maintainer),

I would like to change a non binary phylo object to hclust, but this does
not seem to work smoothly.

Here is a small R code to demonstrate the problem:

# an hclust tree with 3 branches from the root
hc <- hclust(dist(c(1:2, 4,5, 7,8)), method = "single")
plot(hc)

# we can change it to phylo just fine:
library(ape)
phy <- as.phylo(hc)
plot(phy)
# for some reason it claims the object is binary
is.binary.tree(phy) # TRUE

# it turns to hclust
hc2 <- as.hclust(phy)
# but the plotting fails:
plot(hc2)
# Error in plot.hclust(hc2) : 'merge' matrix has invalid contents
cutree(hc2, 2) # works, but doesn't give any warning that it actually can't
provide with only 2 clusters...



Thanks upfront for any help.

Best,
Tal



Contact
Details:---
Contact me: tal.gal...@gmail.com |
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--

[[alternative HTML version deleted]]

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


Re: [R] R and AWS

2015-08-01 Thread Tal Galili
How about this:
"Setting Rstudio server using Amazon Web Services (AWS) – a step by step
(screenshots) tutorial"





Contact
Details:---
Contact me: tal.gal...@gmail.com |
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--


On Thu, Jul 30, 2015 at 3:41 PM, My List  wrote:

> Hello All,
>
> I wanted to know if there is a quick tutorial which I could be pointed to,
> for the understanding of setting R and R studio on Amazon web services.
>
> Thanks in Advance,
> Harmeet
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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

2015-07-25 Thread Tal Galili
Following what Erich wrote, if you are on Windows, there is also a
step-by-step screenshot guide for upgrading R using the installr package:

http://www.r-statistics.com/2015/06/a-step-by-step-screenshots-tutorial-for-upgrading-r-on-windows/



Contact
Details:---
Contact me: tal.gal...@gmail.com |
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--


On Sat, Jul 25, 2015 at 10:24 AM, Erich Neuwirth <
erich.neuwi...@univie.ac.at> wrote:

> If you are running R on Windows,
> there is the package installr which will help you with the process
> of upgrading.
>
> And item 2.8 in the R for Windows FAQ has some information about upgrading
> also.
> > On 25 Jul 2015, at 06:41, Waqas Shafqat  wrote:
> >
> > Dear sir,
> >
> > I am using currently R 3.1.3. But i wnat to upgrade this version to R
> 3.2.0
> > but i am feared that the libraries which i have installed may be remove?
> > please guide me.
> >
> > thanks
> > --
> > Waqas Shafqat Chattha
> > Ph. D Scholar
> > Department of Plant Breeding and Genetics
> > University of Agriculture, Faisalabad
> > Pakistan
> >
> >   [[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


[R] Using "line" (Tukey's robust line) on 3 observations?

2014-12-04 Thread Tal Galili
By accident I came across the following example:

x <- 1:3
y <- 1:3
line(x, y) # returns:

Call:
line(x, x)

Coefficients:
[1]  -2   2


While when using 1:4, it will give the more reasonable 0,1 coefficients.

I imagine this is in the way it calculate the quantiles (i.e.: a "feature").
Can someone help in explaining this?


Thanks,
Tal









Contact
Details:---
Contact me: tal.gal...@gmail.com |
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--

[[alternative HTML version deleted]]

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


Re: [R] wilcox.test - difference between p-values of R and online calculators

2014-09-03 Thread Tal Galili
It seems your numbers has ties. What happens if you run wilcox.test with
correct=FALSE, will the results be the same as the online calculators?



Contact
Details:---
Contact me: tal.gal...@gmail.com |
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--



On Wed, Sep 3, 2014 at 3:54 AM, W Bradley Knox  wrote:

> Hi.
>
> I'm taking the long-overdue step of moving from using online calculators to
> compute results for Mann-Whitney U tests to a more streamlined system
> involving R.
>
> However, I'm finding that R computes a different result than the 3 online
> calculators that I've used before (all of which approximately agree). These
> calculators are here:
>
> http://elegans.som.vcu.edu/~leon/stats/utest.cgi
> http://vassarstats.net/utest.html
> http://www.socscistatistics.com/tests/mannwhitney/
>
> An example calculation is
>
>
> *wilcox.test(c(359,359,359,359,359,359,335,359,359,359,359,359,359,359,359,359,359,359,359,359,359,303,359,359,359),c(332,85,359,359,359,220,231,300,359,237,359,183,286,355,250,105,359,359,298,359,359,359,28.6,359,359,128))*
>
> which prints
>
>
>
>
>
>
>
>
>
> *Wilcoxon rank sum test with continuity correction  data: c(359, 359, 359,
> 359, 359, 359, 335, 359, 359, 359, 359, 359, and c(332, 85, 359, 359, 359,
> 220, 231, 300, 359, 237, 359, 183, 359, 359, 359, 359, 359, 359, 359, 359,
> 359, 303, 359, 359, and 286, 355, 250, 105, 359, 359, 298, 359, 359, 359,
> 28.6, 359, 359) and 359, 128)  W = 485, p-value = 0.0002594 alternative
> hypothesis: true location shift is not equal to 0 Warning message: In
> wilcox.test.default(c(359, 359, 359, 359, 359, 359, 335, 359, : cannot
> compute exact p-value with ties*
>
>
> However, all of the online calculators find p-values close to 0.0025, 10x
> the value output by R. All results are for a two-tailed case. Importantly,
> the W value computed by R *does agree* with the U values output by the
> first two online calculators listed above, yet it has a different p-value.
>
> Can anyone shed some light on how and why R's calculation differs from that
> of these online calculators? Thanks for your time.
>
> 
> W. Bradley Knox, PhD
> http://bradknox.net
> bradk...@mit.edu
>
> [[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] Is there an ID3 implementation in R?

2014-09-02 Thread Tal Galili
Dear Ista and Christian - this works wonderfully, thank you!




Contact
Details:---
Contact me: tal.gal...@gmail.com |
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--



On Tue, Sep 2, 2014 at 7:05 PM, Ista Zahn  wrote:

> This is explained in the RWeka vignette, but briefly:
>
> ## load RWeka
> library(RWeka)
> ## look for a package providing id3
> WPM("refresh-cache")
> WPM("list-packages", "available") ## look for id3
> ## install package providing id3
> WPM("install-package", "simpleEducationalLearningSchemes")
> ## load the package
> WPM("load-package", "simpleEducationalLearningSchemes")
> ## make classifier
> ID3 <- make_Weka_classifier("weka/classifiers/trees/Id3")
> ## test it out.
> DF2 <- read.arff(system.file("arff", "contact-lenses.arff",
>  package = "RWeka"))
> ID3(`contact-lenses` ~ ., data = DF2)
>
>
> Best,
> Ista
>
> On Tue, Sep 2, 2014 at 11:42 AM, Christian Schulz 
> wrote:
> > Yes with: make_Weka_classifier(name, class = NULL, handlers = list(),
> init =
> > NULL)
> > HTH, Christian
> >
> >
> >
> >> Hi Wensui,
> >>
> >> When I looked at their docs:
> >> http://cran.r-project.org/web/packages/RWeka/RWeka.pdf
> >> It appeared they only have a connection to:
> >> J48
> >> LMT
> >> M5P
> >> DecisionStump
> >>
> >> Is it possible to connect it to:
> >> http://www.cs.tufts.edu/~ablumer/weka/doc/weka.classifiers.Id3.html
> >>
> >> If so, how?
> >>
> >> Thanks.
> >>
> >>
> >>
> >>
> >> Contact
> >> Details:-----------
> >> Contact me: tal.gal...@gmail.com |
> >> Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew)
> |
> >> www.r-statistics.com (English)
> >>
> >>
> --
> >>
> >>
> >>
> >> On Tue, Sep 2, 2014 at 6:13 PM, Wensui Liu  wrote:
> >>
> >>> Rweka
> >>> On Sep 2, 2014 11:04 AM, "Tal Galili"  wrote:
> >>>
> >>>> Dear R help mailing list,
> >>>>
> >>>> I am looking for an ID3 implementation in R. I know that there are
> many
> >>>> other decision tree algorithms already implemented (via rpart, tree,
> >>>> caret,
> >>>> C50, etc., etc.), but for research purposes I would like to reproduce
> >>>> the
> >>>> result of running ID3.
> >>>>
> >>>> I was not able to find such an implementation when searching in any of
> >>>> the
> >>>> following:
> >>>> http://rseek.org/
> >>>> http://finzi.psych.upenn.edu/search.html
> >>>> http://cran.r-project.org/web/views/MachineLearning.html
> >>>>
> >>>> Any suggestions?
> >>>>
> >>>> Thanks,
> >>>> Tal
> >>>>
> >>>>
> >>>> Contact
> >>>> Details:---
> >>>> Contact me: tal.gal...@gmail.com |
> >>>> Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il
> (Hebrew) |
> >>>> www.r-statistics.com (English)
> >>>>
> >>>>
> >>>>
> --
> >>>>
> >>>>  [[alternative HTML version deleted]]
> >>>>
> >>>> __
> >>>> R-help@r-project.org mailing list
> >>>> https://stat.ethz.ch/mailman/listinfo/r-help
> >>>> PLEASE do read the posting guide
> >>>> http://www.R-project.org/posting-guide.html
> >>>> and provide commented, minimal, self-contained, reproducible code.
> >>>>
> >> [[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.
>

[[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 an ID3 implementation in R?

2014-09-02 Thread Tal Galili
Hi Wensui,

When I looked at their docs:
http://cran.r-project.org/web/packages/RWeka/RWeka.pdf
It appeared they only have a connection to:
J48
LMT
M5P
DecisionStump

Is it possible to connect it to:
http://www.cs.tufts.edu/~ablumer/weka/doc/weka.classifiers.Id3.html

If so, how?

Thanks.




Contact
Details:---
Contact me: tal.gal...@gmail.com |
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--



On Tue, Sep 2, 2014 at 6:13 PM, Wensui Liu  wrote:

> Rweka
> On Sep 2, 2014 11:04 AM, "Tal Galili"  wrote:
>
>> Dear R help mailing list,
>>
>> I am looking for an ID3 implementation in R. I know that there are many
>> other decision tree algorithms already implemented (via rpart, tree,
>> caret,
>> C50, etc., etc.), but for research purposes I would like to reproduce the
>> result of running ID3.
>>
>> I was not able to find such an implementation when searching in any of the
>> following:
>> http://rseek.org/
>> http://finzi.psych.upenn.edu/search.html
>> http://cran.r-project.org/web/views/MachineLearning.html
>>
>> Any suggestions?
>>
>> Thanks,
>> Tal
>>
>>
>> Contact
>> Details:---
>> Contact me: tal.gal...@gmail.com |
>> Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
>> www.r-statistics.com (English)
>>
>> --
>>
>> [[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>

[[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] Is there an ID3 implementation in R?

2014-09-02 Thread Tal Galili
Dear R help mailing list,

I am looking for an ID3 implementation in R. I know that there are many
other decision tree algorithms already implemented (via rpart, tree, caret,
C50, etc., etc.), but for research purposes I would like to reproduce the
result of running ID3.

I was not able to find such an implementation when searching in any of the
following:
http://rseek.org/
http://finzi.psych.upenn.edu/search.html
http://cran.r-project.org/web/views/MachineLearning.html

Any suggestions?

Thanks,
Tal


Contact
Details:---
Contact me: tal.gal...@gmail.com |
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--

[[alternative HTML version deleted]]

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


Re: [R] Split PVClust plot

2014-08-30 Thread Tal Galili
Hi Tom,

There is a "as.dendrogram.pvclust" function in the package dendextend.
(it is on CRAN: http://cran.r-project.org/web/packages/dendextend/)

You can run:

install.packages('dendextend')
library(dendextend)
result2  <- as.dendrogram(result)
# You can then also use the "prune" function in dendextend, to get the
subtree you are interested in.

Also, there is an example of pvclust in the package vignette (just
search pvclust
here):
http://cran.r-project.org/web/packages/dendextend/vignettes/introduction.html
The example shows how to highlight significant branches (with line width
and color).

With regards,
Tal






Contact
Details:---
Contact me: tal.gal...@gmail.com |
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--



On Tue, Jul 29, 2014 at 12:40 AM, Worthington, Thomas A <
thomas.worthing...@okstate.edu> wrote:

> Dear All
>
> I'm using PVClust to perform hierarchical clustering, for the output plot
> I can control most of the graphical I need, however the plot is large and I
> would like to split it vertically into two panels one above the other. Is
> there a way to plot only part of a PVClust plot, I tried to convert it to a
> dendrogram with
>
> result2  = as.dendrogram(result)
>
> however I get the error message "no applicable method for 'as.dendrogram'
> applied to an object of class "pvclust". I also wondered whether it would
> be possible to convert to a phylogenetic tree and use the functions in the
> 'ape' package?
>
> Any suggestion on how to split up a PVclust plot would be greatly
> appreciated  (code for the plot below)
>
> Thanks
> Tom
>
>
> result <- pvclust(df.1, method.dist="uncentered",
> method.hclust="average",nboot=10)
> par(mar=c(0,0,0,0))
> par(oma=c(0,0,0,0))
> plot(result, print.pv =FALSE, col.pv=c("red","",""), print.num=FALSE,
> float = 0.02, font=1,
> axes=T, cex =0.85, main="", sub="", xlab="", ylab= "",
> labels=NULL, hang=-1)
> pvrect(result, alpha=0.95)
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] about rect.hclust

2014-04-26 Thread Tal Galili
Thank you for mentioning the
dendextendpackage
Gregory.

As I mention in the package, the dendextend package implements a similar
function as in the dendroextra. The big difference between the two is that
the dendextend package has an implementation of the "cutree" function for
dendrograms (making it possible to not have to go through the hclust object
in order to perform it). This is helpful when using non-standard
dendrograms that can not be turned into an hclust object (via
as.hclust.dendrogram).
Also, the dendextend package includes many other functions for dendrogram
manipulation which might be helpful.

Here is a quick example that can give you a sense of the possibilities:


install.packages("dendextend")
require(dendextend)

# pdf("dendextend_example.pdf")
dend <- as.dendrogram(hclust(dist(USArrests), "ave"))
d1=color_branches(dend, k=5, col = c(3,1,1,4,1))
plot(d1) # selective coloring of branches :)
d2=color_branches(d1,k=5)
plot(d2) # getting rainbow_hcl colors for each cluster (the default)
d3=color_branches(d1,5,groupLabels=TRUE) # adding numbers to the branches
plot(d3)
d4=color_labels(d3, k=5, col = c(3,1,1,4,1)) # color labels by cluster
plot(d4)
d5=color_labels(d4, col = c("red", "orange")) # color labels from left to
right
plot(d5)
# dev.off()

Here is the output:
https://www.dropbox.com/s/vii83jd9xnbmuv7/dendextend_example.pdf

Also, there is a (rough draft) of a vignettes for the package here:
https://github.com/talgalili/dendextend/blob/master/vignettes/dendextend-tutorial.pdf?raw=true

Feedback is welcome.

Best,
Tal









Contact
Details:---
Contact me: tal.gal...@gmail.com |
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--



On Sat, Apr 26, 2014 at 10:36 AM, Gregory Jefferis wrote:

>
> On 26 Apr 2014, at 06:41, Gregory Jefferis  wrote:
>
> > # plot dendrogram coloured by cluster:
> > ##
> > library(dendroextras)
> > cluc=colour_clusters(clu, k=3, groupLabels =TRUE)
> > plot(cluc)
>
> There was a typo in an argument name for colour_clusters in my earlier
> response (thanks to Dennis Murphy for pointing this out). Correction in
> above.
>
> Fancier versions are also possible:
>
> plot(colour_clusters(clu, k=3, groupLabels = as.roman))
>
> Best,
>
> Greg.
> [[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] How to implement a recurring "check for updates" for R and packages?

2014-04-09 Thread Tal Galili
Thank you very much for the reply Henrik, you gave great pointers for me to
look at.

I am now curious about R.cache (although I am not sure it will help in my
case, I'll need to look at it further).

Also, I was debating if to use R-help or R-devel for this, since I was not
sure from the description text <http://www.r-project.org/mail.html>if it is
intended for developing R (as in "R base"), or R package development in
general (well, now I know).

With regards,
Tal





Contact
Details:---
Contact me: tal.gal...@gmail.com |
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--



On Wed, Apr 9, 2014 at 7:41 PM, Henrik Bengtsson wrote:

> [Sounds like a question for R-devel]
>
> On Wed, Apr 9, 2014 at 5:02 AM, Tal Galili  wrote:
> > Hello all,
> >
> >
> > I wish to add to the
> > installr<http://cran.r-project.org/web/packages/installr/>package the
> > ability to check for new versions of R once every X units of
> > time (maybe once every two weeks).
> >
> > I would like to keep a time stamp somewhere, that would stay persistent
> > across R sessions (i.e.: that if I turn R off and then back on, it would
> > keep track of the last time it checked for a new R version).
> > It would be best if I could save some file, maybe in the installr package
> > folder, that would keep track of that.
> >
> > Any suggestions or "best practice" on how to implement something like
> that?
>
> I'm not aware of any standards for where to store site- and/or
> user-specific R settings that are persistent across session.  It would
> certainly nice to have a standard, instead of everyone inventing their
> own.
>
> Either way, before starting it is useful (even if you don't distribute
> via CRAN) if you're aware of the following passage from
> http://cran.r-project.org/web/packages/policies.html provides a fair
> guideline:
>
> "- Packages should not write in the users’ home filespace, nor
> anywhere else on the file system apart from the R session’s temporary
> directory (or during installation in the location pointed to by
> TMPDIR: and such usage should be cleaned up). Installing into the
> system’s R installation (e.g., scripts to its bin directory) is not
> allowed.
> Limited exceptions may be allowed in interactive sessions if the
> package obtains confirmation from the user."
>
> Then have a look the R.cache package.  It is used for caching objects
> to file, e.g. memoization of computational expensive results.  It
> addresses the above policy in the following way:
>
> 1. It checks whether ~/.Rcache/ exists or not.  If it exists, it is
> assumed that it already has the user's permission.
>
> 2  Otherwise, if in an interactive R session, it asks the user for
> permission to create that directory.  If successful it is created (and
> it drops an informative README.txt file in there too), otherwise it
> uses a temporary directory.
>
> Here is what it looks like to first time you load R.cache:
>
> > library(R.cache)
> The R.cache package needs to create a directory that will hold cache
> files. It is convenient to use one in the user's home directory,
> because it remains also after restarting R. Do you wish to create the
> '~/.Rcache/' directory? If not, a temporary directory
> (C:\Users\hb\AppData\Local\Temp\Rtmp61upx7/.Rcache) that is specific
> to this R session will be used. [Y/n]:
>
> You can use a similar strategy.  You could also use R.cache for you
> own purposes, e.g.
>
> readURL <- function(url, maxAge=10*24*3600, force=FALSE, ...) {
>   library("R.cache")
>   dirs <- "installr"  # => Caching to ~/.Rcache/installr/
>   key <- list(method="readURL", url=url)
>
>   # Check for cached results
>   bfr <- loadCache(key=key, dirs=dirs)
>   when <- attr(bfr, "when")
>
>   # Recent enough results already available?
>   if (!force && !is.null(when) && (Sys.time()-maxAge <= when))
> return(bfr);
>
>   # Download and memoize
>   bfr <- readLines(url)
>   attr(bfr, "when") <- Sys.time()
>   saveCache(bfr, key=key, dirs=dirs)
>
>   bfr
> } # readURL()
>
> That would memoize the results from CRAN (for 10 days by default); you
> can of course cache the parsed R version etc, but I leave that to you.
>
> /Henrik
> (author of R.cache)
>
> >
> > Thanks,
> > Tal
> >
> >
> >
> >
> >

[R] How to implement a recurring "check for updates" for R and packages?

2014-04-09 Thread Tal Galili
Hello all,


I wish to add to the
installrpackage the
ability to check for new versions of R once every X units of
time (maybe once every two weeks).

I would like to keep a time stamp somewhere, that would stay persistent
across R sessions (i.e.: that if I turn R off and then back on, it would
keep track of the last time it checked for a new R version).
It would be best if I could save some file, maybe in the installr package
folder, that would keep track of that.

Any suggestions or "best practice" on how to implement something like that?

Thanks,
Tal





Contact
Details:---
Contact me: tal.gal...@gmail.com |
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--

[[alternative HTML version deleted]]

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


[R] Package development: overriding a function from one package with a function from another?

2014-02-19 Thread Tal Galili
Dear R users,

I am currently working on developing two packages, below is a simplified
version of my problem:

In package A I have some functions (say "sum_twice"), and I it calls to
another function inside the package (say "slow_sum").
However, in package B, I wrote another function (say "fast_sum"), with
which I wish to replace the slow function in package A.

Now, how do I manage this "overriding" of the "slow_sum" function with the
"fast_sum" function?

Here is a simplified example of such functions (just to illustrate):



##
# Functions in package A

slow_sum <- function(x) {
sum_x <- 0
for(i in seq_along(x)) sum_x <- sum_x + x[i]
 sum_x
}

sum_twice <- function(x) {
x2 <- rep(x,2)
slow_sum(x2)
}

##
# A function in package B
fast_sum <- function(x) { sum(x) }




If I only do something like:
slow_sum <- fast_sum
This would not work, since "sum_twice" uses "slow_sum" from the NAMESPACE
of package A.

I tried using the following function when loading package "B":

assignInNamespace(x = "slow_sum", value = B:::fast_sum, ns = "A")

This indeed works, however, it makes the CRAN checks return both a NOTE on
how I should not use ":::", and also a warning for using assignInNamespace
(since it is supposed to not be very safe).



However, I am at a loss.
What would be a way to have "sum_twice" use "fast_sum" instead of
"slow_sum"?


Thank you upfront for any feedback or suggestion,
With regards,
Tal



Contact
Details:---
Contact me: tal.gal...@gmail.com |
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--

[[alternative HTML version deleted]]

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


[R] Basic question: why does a scatter plot of a variable against itself works like this?

2013-11-06 Thread Tal Galili
Hello all,

I just noticed the following behavior of plot:
x <- c(1,2,9)
plot(x ~ x) # this is just like doing:
plot(x)
# when maybe we would like it to give this:
plot(x ~ c(x))
# the same as:
plot(x ~ I(x))

I was wondering if there is some reason for this behavior.


Thanks,
Tal



Contact
Details:---
Contact me: tal.gal...@gmail.com |
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--

[[alternative HTML version deleted]]

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


[R] Reproducing density(..., kernel='rectangular', width=1) using convolve? (for educational purposes)

2013-10-21 Thread Tal Galili
Hello dear R-help members,

I am currently teaching students on kernel density estimators, and I was
hoping to show them an animation of the convolution which is taking place
in the "density" function. I wrote a (somewhat clunky) piece of code to
reproduce the density function, but I seem to get rather different results
(which means I am missing something).

If any of you are in the mood to help and see what is wrong (or if you have
your own piece of code which already does this), it would be lovely for
future students who are studying this method.

Here is the code I got thus far:


 The function to reproduce
set.seed(13413)
some_data <- c(round(rnorm(100)))
plot(density(some_data, kernel='rectangular', width=1, n = 10**5), lwd = 3)

 The attempt
convolve_new <- function(data_range, kernel_range, data_fun, kernel_fun,
normalize = TRUE) {
   # data_range, kernel_range - MUST have the same length

   # if we have the range of a kernel function and of the data function
   # we would like to have one move over the other without any problems.
   y_data_fun <- data_fun(data_range)
   y_kernel_fun <- kernel_fun(kernel_range)
   n_kernel <- length(y_kernel_fun)
   n_data <- length(y_kernel_fun)
   conv_vec <- convolve(y_data_fun, rev(y_kernel_fun), type = "o")

   items_to_remove <- floor(n_kernel/2)
   conv_vec <- head(conv_vec,-items_to_remove)
   conv_vec <- tail(conv_vec,-items_to_remove)

   dx <- ifelse(normalize, mean(diff(data_range)), 1)# this is dx
   conv_vec  * dx
}


w_R_01 <- function(u) {
   ifelse(abs(u)<=.5 & u >=0,1,0)
}


# fun1 <- dnorm # kernel
fun1 <- w_R # kernel
# fun2 <- w_R_01 # data
fun2 <-  # data
   function(x) {
  sapply(x, function(y) sum(some_data %in% y))
   }
# fun2(1)


# the_data_range <- seq(-2,2, by = .01)
the_data_range <- sort(c(seq(min(some_data),max(some_data), by = .01),
some_data))
the_kernel_range <- the_data_range
convo_the_range <- convolve_new(the_data_range, the_kernel_range, fun2,
fun1)
the_animation_range <- seq(-2,2, by = .2)
# plot(convo_the_range/sum(convo_the_range)~the_range, type = "l")

for(i in the_animation_range) {
#curve(fun2,
#  from = min(the_data_range), to = max(the_data_range), ylim =
c(0,3),
#  n=10**3)
   plot(fun2(the_data_range) ~ the_data_range, type= "h")
   abline(v = i, lty = 2, col = "purple", lwd = 2)
   temp_fun1 <- function(x) {fun1(x-i)}
   curve(temp_fun1,
 from = min(the_animation_range), to = max(the_animation_range),
add = TRUE,
 n=10**3, lwd = 3, col = 2)
#temp_convolution_range <- function(x) {convolution_range(x, fun1 =
temp_fun1, fun2 = fun2)}
##curve(convolution_range, from = -3, to =3, add = TRUE)
   ss<- the_data_range<=i
   lines(convo_the_range[ss]~the_data_range[ss], type = "l", col = 3, lwd =
3)
   rug(some_data)
}



Thanks,
Tal


Contact
Details:---
Contact me: tal.gal...@gmail.com |
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--

[[alternative HTML version deleted]]

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


Re: [R] No P.values in polr summary

2013-10-19 Thread Tal Galili
Vincent,
I believe Prof. Ripley is referring to this:
http://www.stats.ox.ac.uk/pub/MASS4/



Contact
Details:---
Contact me: tal.gal...@gmail.com |
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--



On Sat, Oct 19, 2013 at 3:22 PM, vincent guyader
wrote:

> 2013/10/19 Prof Brian Ripley 
>
> > On 18/10/2013 15:01, Vincent Guyader wrote:
> >
> >> Hi everyone,
> >>
> >> If I compute a "Ordered Logistic or Probit Regression" with the polr
> >> function from MASS package. the summary give me : coefficients, Standard
> >> error and Tvalue.. but  not directly the p.value.
> >>
> >>
> >> I can compute "manualy" the Pvalue, but Is there a way to directly
> obtain
> >> the pa.value, and I wonder why the p.valeu is not directly calculated,
> is
> >> there a reason?
> >>
> >
> > How are you going to calculate the P values?  Have you read the book for
> > which this is support software?: it explains why such Wald tests are
> > inappropriate and that the asymptotic theory can be wildly misleading.
> >
>
> Hi,
>
> thanks for your answer.
> to have the P.value I use this code :
> http://www.ats.ucla.edu/stat/r/dae/ologit.htm
>
> pnorm(abs(ctable[, "t value"]), lower.tail = FALSE) * 2
>
> It give the same result as Stata, but you are right i'm not sure that it's
> good. Could you please tell me which book you are talking about.
>
> Regards
>
>
>
>
> >
> >> exemple :
> >>
> >> house.plr <- polr(Sat ~ Infl + Type + Cont, weights = Freq, data =
> >> housing)
> >> house.plr
> >> summary(house.plr, digits = 3)
> >>
> >>
> >>
> >>
> >> Regards
> >>
> >> [[alternative HTML version deleted]]
> >>
> >> __**
> >> R-help@r-project.org mailing list
> >> https://stat.ethz.ch/mailman/**listinfo/r-help<
> https://stat.ethz.ch/mailman/listinfo/r-help>
> >> PLEASE do read the posting guide http://www.R-project.org/**
> >> posting-guide.html 
> >> and provide commented, minimal, self-contained, reproducible code.
> >>
> >>  PLEASE do.
> >
> > --
> > Brian D. Ripley,  rip...@stats.ox.ac.uk
> > Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~**ripley/<
> http://www.stats.ox.ac.uk/~ripley/>
> > University of Oxford, Tel:  +44 1865 272861 (self)
> > 1 South Parks Road, +44 1865 272866 (PA)
> > Oxford OX1 3TG, UKFax:  +44 1865 272595
> >
> > __**
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/**listinfo/r-help<
> https://stat.ethz.ch/mailman/listinfo/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.
>

[[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] raster package: OpenStreetMap broken on Ubuntu, works on Mac

2013-09-23 Thread Tal Galili
Jos had e-mailed me that he found a fix to this problem (after he had
originally asked me, and I sent him to R-help/ the package maintainer), so
I thought of keeping this thread updated with his reply:

After Jos communicated with the maintainers about this, the fix is to
install the raster package from here:

install.packages("raster",
repos="http://R-Forge.R-project.org
")

It is a development version but it got installed on his machine without
glitches and after that it started working.


With regards,
Tal




Contact
Details:---
Contact me: tal.gal...@gmail.com |
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--



On Sat, Sep 21, 2013 at 8:32 AM, Prof Brian Ripley wrote:

> What did the OpenStreetMap maintainer say (see the posting guide)?
> Hint: he and the raster maintainer are aware of their problem, and a
> correction is way overdue.
>
> The issue is not Ubuntu vs Mac but the order in which packages are
> installed (and for binary packages that is when they were installed to be
> packaged).
>
>
> On 21/09/2013 00:57, jos wrote:
>
>> Hi,
>> I'm a novice in R and I was trying to play with OpenStreetMap package as
>> in a few examples on the web. And the examples worked on my Mac but on
>> Ubuntu (12.04) they fail to work. The simplest one is:
>>
>> library(OpenStreetMap)
>> library(rgdal)
>> map <- openmap(c(70,-179), c(-70,179))
>> plot(map)
>>
>> (OpenStreetMap, rgdal, rJava etc..) packages have to be installed first.
>>
>> On the Mac - it worked without any problems from the first try (shows a
>> picture of world map). On Ubuntu, I get:
>>
>> 'merge' is not an exported object from 'namespace:raster'
>>
>> when I execute the "openmap" function.
>>
>> Now, at first I thought that the problem was in different library
>> versions and it was quite a pain to make ubuntu install everything I wanted
>> (rgdal being the biggest - unless one knows exactly what to look for on the
>> internet, instructions are vague and there is a lot of outdated versions
>> out there). But even after that, when version numbers matched on both OSes
>> in R console, it still failed to work on Ubuntu. So the versions are:
>>
>>
>>
>> library(rgdal)
>> Loading required package: sp
>> rgdal: version: 0.8-11, (SVN revision 479M)
>> Geospatial Data Abstraction Library extensions to R successfully loaded
>> Loaded GDAL runtime: GDAL 1.9.2, released 2012/10/08
>> Path to GDAL shared files: /usr/local/share/gdal
>> Loaded PROJ.4 runtime: Rel. 4.8.0, 6 March 2012, [PJ_VERSION: 480]
>> Path to PROJ.4 shared files: (autodetected)
>>
>>
>>
>> Still didn't work with identical output on both machines. Then I thought
>> that the problem must be in "raster" library, but both have the same
>> version number:
>>
>>
>> packageVersion("raster")
>> [1] ‘2.1.49’
>>
>> but after showing all the functions in "raster" package, although both
>> have 235 elements:
>>
>>
>> basevals <- ls(pos="package:raster")
>> basevals
>>
>>
>> the Mac one has "merge" listed and Ubuntu - doesn't. Also on Mac, the
>> array begins with "%in%" and on Ubuntu with "addLayer"... so there is more
>> than one inconsistency and "merge" is actually breaking openmap().
>>
>> My questions are:
>> *is this a bug?
>> *is there a workaround (eg. can I "export" merge from raster namespace
>> myself by copying potentially the code from Mac)?
>>
>>
>> Thanks in advance,
>>
>> J
>>
>
>
> --
> Brian D. Ripley,  rip...@stats.ox.ac.uk
> Professor of Applied Statistics,  
> http://www.stats.ox.ac.uk/~**ripley/
> University of Oxford, Tel:  +44 1865 272861 (self)
> 1 South Parks Road, +44 1865 272866 (PA)
> Oxford OX1 3TG, UKFax:  +44 1865 272595
>
>
> __**
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/**listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/**
> posting-guide.html 
> and provide commented, minimal, self-contained, reproducible code.
>

[[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] Installing package from website

2013-08-27 Thread Tal Galili
Henrik solution is probably just what you need, but just to mention a
similar solution, there is also:

if (!require('installr')) install.packages('installr'); require('installr')
install.packages.zip("zip_URL")

(the source code is here:
https://github.com/talgalili/installr/blob/master/R/install.r)

And if two packages created the same function, I am wondering if this might
be a worthwhile patch to add to "install.packages" (but there are more
important things to do first, I imagine).

Best,
Tal








Contact
Details:---
Contact me: tal.gal...@gmail.com |
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--



On Tue, Aug 27, 2013 at 4:33 PM, Henrik Bengtsson wrote:

> On Sun, Aug 25, 2013 at 10:55 AM, Christofer Bogaso
>  wrote:
> > Hello again,
> >
> > I need to install Rmpi package from this
> > http://www.stats.uwo.ca/faculty/yu/Rmpi/download/windows/MPICH2
> >
> > I was wondering if there is any direct way to install this in R. The
> > trivial method would obviously be download and save the required zip file
> > in the local disk and install it from there.
>
> R.utils::installPackages(url)
>
> /Henrik
>
> >
> > Any idea?
> >
> > Thanks and regards,
> >
> > [[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.
>

[[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] download.file error - corrupt: Can't read SAT; charset=binary'

2013-08-22 Thread Tal Galili
Quick update - I think most of the problem is resolved.
After more checks (following Uwe comments):
1) I see that the installer file runs properly when I set "mode='wb'", and
fails when "mode='w'" (so that solves why some of the time the installer
didn't run)
2) I still get the error massage mentioned before (e.g: "Composite Document
File V2 Document, corrupt: Can't read SAT, etc..."). I don't know what it
means, or if it is important (since the installer now runs properly).

Tal




Contact
Details:---
Contact me: tal.gal...@gmail.com |
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
----------



On Thu, Aug 22, 2013 at 8:52 PM, Tal Galili  wrote:

> Dear Uwe,
>
> Here is the updated code and error massage I get:
>
> exe_URL = 'http://pandoc.googlecode.com/files/pandoc-1.11.1.msi'
> exe_filename <- file.path(tempdir(), basename(exe_URL))
> download.file(exe_URL, destfile = exe_filename, mode = "wb", method=
> "internal")
> #
> ### Error massage:
>  trying URL 'http://pandoc.googlecode.com/files/pandoc-1.11.1.msi'
> Content type 'Composite Document File V2 Document, corrupt: Can't read
> SAT; charset=binary' length 5799936 bytes (5.5 Mb)
> opened URL
> downloaded 5.5 Mb
>
>
> 1) I am very sorry about the chipped previous massage (it is a side effect
> of some form of "reply" in gmail, which I have not noticed before).
> 2) I'm sorry about using the wrong function name - it comes with the
> "installr" package, since I have it running on startup, I was blind to see
> the code was not standard. Also, now that I know such a function exists in
> base R, I will move to using it.
>
> Best,
> Tal
>
>
>
>
>
>
>
>
>
> Contact
> Details:---
> Contact me: tal.gal...@gmail.com |
> Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
> www.r-statistics.com (English)
>
> --
>
>
>
> On Thu, Aug 22, 2013 at 12:12 PM, Uwe Ligges <
> lig...@statistik.tu-dortmund.de> wrote:
>
>> Tal,
>>
>> please quote the whole message!
>> I had to look for the original one now.
>>
>> And then I found that code was not reproducible for me:
>>
>>
>>  exe_URL = 
>> 'http://pandoc.googlecode.com/**files/pandoc-1.11.1.msi<http://pandoc.googlecode.com/files/pandoc-1.11.1.msi>
>> '
>>  exe_filename <- file.path(tempdir(), file.name.from.url(exe_URL))
>>
>> Error in file.path(tempdir(), file.name.from.url(exe_URL)) :
>>   could not find function "file.name.from.url"
>>
>> and I do not know such a function. From its name I can guess
>>
>>  basename(exe_URL)
>>
>> is the base function that does the trick.
>>
>> So please specify full and reproducible code that shows the error,
>> including and does not contain any additional quirks like the mode="w"
>>
>>
>> Anyway, the installer works for me downloaded with the method I indicated
>> before.
>>
>> Best,
>> Uwe Ligges
>>
>>
>>
>>
>>
>> On 22.08.2013 07:23, Tal Galili wrote:
>>
>>> Dear Uwe,
>>> My apologies - my original code had mode="wb", which also *does not* work
>>>
>>> and produce the errors I've mentioned in the previous e-mail.
>>>
>>> The code I pasted had mode ="w", since that is one of the versions I've
>>> played with (which also does not work).
>>>
>>>   With regards,
>>> Tal
>>>
>>>
>>>
>>>
>>>
>>> On Wed, Aug 21, 2013 at 11:45 PM, Uwe Ligges <
>>> lig...@statistik.tu-dortmund.**de >
>>> wrote:
>>>
>>>  Uwe
>>>>
>>>
>>>
>>>
>>>
>>>
>>> Contact
>>> Details:--**--**---
>>> Contact me: tal.gal...@gmail.com |
>>> Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
>>> www.r-statistics.com (English)
>>> --**--**
>>> --**
>>>
>>> [[alternative HTML version deleted]]
>>>
>>> __**
>>> R-help@r-project.org mailing list
>>> https://stat.ethz.ch/mailman/**listinfo/r-help<https://stat.ethz.ch/mailman/listinfo/r-help>
>>> PLEASE do read the posting guide http://www.R-project.org/**
>>> posting-guide.html <http://www.R-project.org/posting-guide.html>
>>> and provide commented, minimal, self-contained, reproducible code.
>>>
>>>
>

[[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] download.file error - corrupt: Can't read SAT; charset=binary'

2013-08-22 Thread Tal Galili
Dear Uwe,

Here is the updated code and error massage I get:

exe_URL = 'http://pandoc.googlecode.com/files/pandoc-1.11.1.msi'
exe_filename <- file.path(tempdir(), basename(exe_URL))
download.file(exe_URL, destfile = exe_filename, mode = "wb", method=
"internal")
#
### Error massage:
trying URL 'http://pandoc.googlecode.com/files/pandoc-1.11.1.msi'
Content type 'Composite Document File V2 Document, corrupt: Can't read SAT;
charset=binary' length 5799936 bytes (5.5 Mb)
opened URL
downloaded 5.5 Mb


1) I am very sorry about the chipped previous massage (it is a side effect
of some form of "reply" in gmail, which I have not noticed before).
2) I'm sorry about using the wrong function name - it comes with the
"installr" package, since I have it running on startup, I was blind to see
the code was not standard. Also, now that I know such a function exists in
base R, I will move to using it.

Best,
Tal









Contact
Details:---
Contact me: tal.gal...@gmail.com |
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--



On Thu, Aug 22, 2013 at 12:12 PM, Uwe Ligges <
lig...@statistik.tu-dortmund.de> wrote:

> Tal,
>
> please quote the whole message!
> I had to look for the original one now.
>
> And then I found that code was not reproducible for me:
>
>
>  exe_URL = 
> 'http://pandoc.googlecode.com/**files/pandoc-1.11.1.msi<http://pandoc.googlecode.com/files/pandoc-1.11.1.msi>
> '
>  exe_filename <- file.path(tempdir(), file.name.from.url(exe_URL))
>
> Error in file.path(tempdir(), file.name.from.url(exe_URL)) :
>   could not find function "file.name.from.url"
>
> and I do not know such a function. From its name I can guess
>
>  basename(exe_URL)
>
> is the base function that does the trick.
>
> So please specify full and reproducible code that shows the error,
> including and does not contain any additional quirks like the mode="w"
>
>
> Anyway, the installer works for me downloaded with the method I indicated
> before.
>
> Best,
> Uwe Ligges
>
>
>
>
>
> On 22.08.2013 07:23, Tal Galili wrote:
>
>> Dear Uwe,
>> My apologies - my original code had mode="wb", which also *does not* work
>>
>> and produce the errors I've mentioned in the previous e-mail.
>>
>> The code I pasted had mode ="w", since that is one of the versions I've
>> played with (which also does not work).
>>
>>   With regards,
>> Tal
>>
>>
>>
>>
>>
>> On Wed, Aug 21, 2013 at 11:45 PM, Uwe Ligges <
>> lig...@statistik.tu-dortmund.**de >
>> wrote:
>>
>>  Uwe
>>>
>>
>>
>>
>>
>>
>> Contact
>> Details:--**--**---
>> Contact me: tal.gal...@gmail.com |
>> Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
>> www.r-statistics.com (English)
>> --**--**
>> --**
>>
>> [[alternative HTML version deleted]]
>>
>> __**
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/**listinfo/r-help<https://stat.ethz.ch/mailman/listinfo/r-help>
>> PLEASE do read the posting guide http://www.R-project.org/**
>> posting-guide.html <http://www.R-project.org/posting-guide.html>
>> and provide commented, minimal, self-contained, reproducible code.
>>
>>

[[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] Windows "The system cannot find the path specified" error when submitting R in batch mode

2013-08-21 Thread Tal Galili
Hello James,
Does this answer your question:
http://stackoverflow.com/questions/14956887/problems-executing-script-from-command-line-in-r-error-message-cannot-find-pat
?





Contact
Details:---
Contact me: tal.gal...@gmail.com |
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--



On Mon, Aug 19, 2013 at 10:06 PM, James Hackett
wrote:

> This is an R and operating system related question. I am not able to
> submit an R program to be executed in batch mode by Windows. I have
> confirmed the location of the R.exe file. I am following the directions I
> found in Quick-R, but neither of the following work from a DOS prompt ...
>
> D:\chip\Projects\Crescendo Bioscience\Studies\024-CL-01 - BRASS
> FM\biostat\programs\R\024-CL-01 - BRASS FM - Manuscript>"C:\Program
> Files\R\R-2.15.2\bin\R.exe" CMD BATCH "boxplotByMBDAAndCRP.R"
> The system cannot find the path specified.
>
> D:\chip\Projects\Crescendo Bioscience\Studies\024-CL-01 - BRASS
> FM\biostat\programs\R\024-CL-01 - BRASS FM - Manuscript>"C:\Program
> Files\R\R-2.15.2\bin\R.exe" CMD BATCH "D:\chip\Projects\Crescendo
> Bioscience\Studies\024-CL-01 - BRASS FM\biostat\programs\R\024-CL-01 -
> BRASS FM - Manuscript\boxplotByMBDAAndCRP.R"
> The system cannot find the path specified.
>
>
>
> Thank you for any help you can provide,
> Chip
>
> James "Chip" Hackett, Ph.D. | Statistical Consultant | Hackett &
> Associates, Inc. | c...@hackettassociates.net | 408.416.3747 (Office) |
> 805.509.0741 (Mobile)
>
> The material in this transmission may contain confidential information
> intended only for the  addressee. If you are not the addressee, any
> disclosure or use of this information by you is strictly prohibited. If you
> have received this transmission in error, please delete it, destroy all
> copies, and notify the sender immediately by reply or by calling
> 1-408-416-3747.
>
>
>
> [[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] download.file error - corrupt: Can't read SAT; charset=binary'

2013-08-21 Thread Tal Galili
Dear Uwe,
My apologies - my original code had mode="wb", which also *does not* work
and produce the errors I've mentioned in the previous e-mail.

The code I pasted had mode ="w", since that is one of the versions I've
played with (which also does not work).

 With regards,
Tal





On Wed, Aug 21, 2013 at 11:45 PM, Uwe Ligges <
lig...@statistik.tu-dortmund.de> wrote:

> Uwe





Contact
Details:---
Contact me: tal.gal...@gmail.com |
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--

[[alternative HTML version deleted]]

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


[R] download.file error - corrupt: Can't read SAT; charset=binary'

2013-08-21 Thread Tal Galili
Dear R-help mailing list memebers,

I encountered the following error, and I'd be happy for ideas on how to fix
it:


# using R 3.0.1 on Windows 7:
exe_URL = 'http://pandoc.googlecode.com/files/pandoc-1.11.1.msi'
exe_filename <- file.path(tempdir(), file.name.from.url(exe_URL))
download.file(exe_URL, destfile = exe_filename, mode = "w", method=
"internal")

### output error :
trying URL 'http://pandoc.googlecode.com/files/pandoc-1.11.1.msi'
Content type 'Composite Document File V2 Document, corrupt: Can't read SAT;
charset=binary' length 5799936 bytes (5.5 Mb)
opened URL
downloaded 5.5 Mb

### another error:
And then when I try to execute the file (it is a windows installer), I get
the error:
"This installation package could not be opened. Contact the application
vendor to verify that this is a valid Windows installer package."

Downloading the file manually and running it does work.


Any suggestions?

Thanks.





Contact
Details:---
Contact me: tal.gal...@gmail.com |
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--

[[alternative HTML version deleted]]

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


Re: [R] p values for partial correlations

2013-08-07 Thread Tal Galili
A short self contained code would help us help you.

You can try using "str" on the output of the command you are using, and try
to understand where the p.value is located.



Tal


Contact
Details:---
Contact me: tal.gal...@gmail.com |
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--



On Wed, Aug 7, 2013 at 10:01 PM, Demetrio Luis Guadagnin <
dlguadag...@gmail.com> wrote:

> Dear:
> I needed to calculate partial correlations and used the package corpcor for
> that purpose.
> The output doesnot provide p values and I was unable to find information or
> posts on how to get them.
> Does someone can help me?
> Thanks.
>
> --
> Dr. Demetrio Luis Guadagnin
> Conservação e Manejo de Vida Silvestre
> Universidade Federal do Rio Grande do Sul
> Departamento de Ecologia
> Av. Bento Gonçalves 9500
> Setor 4, Prédio 43422, Sala 105
> Caixa Postal 15007 - 91501-970 Porto Alegre RS
> Fone: (51) 3308 6774
> Fax: (51) 3308 7626
> dlguadag...@gmail.com
> Skype: demetriolguadagnin
>
> [[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] MDA

2013-08-07 Thread Tal Galili
Hi Tjun,

It sounds like you need to go on an NA hunt (e.g: find your missing values
in the data).

Maybe try running this code:

ss <- which(apply(is.na(forsen[,-f]), 1, sum)>0)
forsen[ss,-f]

And try to see if you can find these rows.
You can also use the above data to find which rows to remove and see if
that solves your problem.

You might have an empty column or something like that - that is also worth
checking.


Best,
Tal


Contact
Details:---
Contact me: tal.gal...@gmail.com |
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--



On Tue, Aug 6, 2013 at 10:51 AM, Tjun Kiat Teo  wrote:

> I am trying to use the package mda
>
> And this is my command
>
> mdfit<-mda(factor(forsen[,f]) ~ .,data=forsen[,-f],subclasses=sc)
>
> But I keep getting this error message on a particular data set
>
> Error in maxdist[l] <- x[l, i] :
>   NAs are not allowed in subscripted assignments
>
> Can anyone help ? Thanks
>
>
> Regards
>
> Tjun Kiat
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


[R] Is it possible (/reasonable) to write an as.RefClass function for R "list" class?

2013-07-26 Thread Tal Galili
Hello all.


I am interested in creating a mutable "list" object in R.

Ideally I would do it through something like this:

x <- list(a = list(1:4), b = "miao", c = 4:1)
x_RC <- as.RefClass(x)
attr(x_RC[[2]], "I am") <- "string"
x_RC[[3]] <- x_RC[[3]]+1
x_new <- as.list(x_RC)

Is that reasonably possible to create? Or does that make little/no-sense?

Thanks.




Contact
Details:---
Contact me: tal.gal...@gmail.com |
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--

[[alternative HTML version deleted]]

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


Re: [R] Why do tabs disappear when pasted into the R console?

2013-06-03 Thread Tal Galili
Very interesting, thank you.
However, after disabling the tab completion, the RGUI still can't
distinguish pasted tabs.  e.g:

# Running:

Sys.setenv(R_COMPLETION=FALSE)
Sys.getenv("R_COMPLETION")

a = read.table( text=
"
1 2
3 4
")
a

# will result in: (instead of two columns)
  V1
1 12
2 34





Contact
Details:---
Contact me: tal.gal...@gmail.com |
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--



On Mon, Jun 3, 2013 at 5:11 PM, Prof Brian Ripley wrote:

> On 03/06/2013 14:48, peter dalgaard wrote:
>
>>
>> On Jun 3, 2013, at 15:22 , Sarah Goslee wrote:
>>
>>  Pasting tabs into the console works for me on linux, which suggests
>>> that you need to provide more information about your OS and all the
>>> other usual things.
>>>
>>
>> Which console and which Linux?
>>
>> Anyways, the thing that usually gets in the way is tab-completion. If you
>> expect pasting to work exactly as if the same characters were typed at the
>> keyboard, you can't really expect that TAB will not try to autocomplete
>> commands and filenames. I don't know whether there's a way to temporarily
>> disable completion.
>>
>
> There are lots of consoles and completion mechanisms.  But on RGui (at
> least this seems to be Windows), this is controlled by the environment
> variable R_COMPLETION and that can be set during a session.  Its help says
>
>  ‘R_COMPLETION’: Optional.  If set to ‘FALSE’, command-line
>   completion is not used.  (Not used by Mac OS GUI.)
>
> and ??completion gets you there.
>
>
>
>  -pf
>>
>>
>>> Sarah
>>>
>>> On Mon, Jun 3, 2013 at 9:15 AM, Tal Galili  wrote:
>>>
>>>> Hello Dear R-help Members,
>>>>
>>>> I have noticed that when pasting text with "tab" in it to the R console
>>>> it
>>>> eliminates the tab. Whereas, when pasted into the R Editor, the tab is
>>>> preserved.
>>>> For example, pasting this:
>>>> "1997 7680"
>>>> In the R Console will result in:
>>>> "19977680"
>>>>
>>>> Is there a way to preserve the tab?
>>>> This would allow (for example) to use read.table with a table copied
>>>> from
>>>> website/libre-office/excel such as:
>>>>
>>>> a = read.table( text=
>>>> "
>>>> 1 2
>>>> 3 4
>>>> ")
>>>> a
>>>>
>>>> I understand I can use readClipboard directly, but I wonder if there is
>>>> a
>>>> way to use it while the text is kept in the R Editor.
>>>>
>>>>
>>>> With regards,
>>>> Tal
>>>>
>>>
>>>
>>> --
>>> Sarah Goslee
>>> http://www.**functionaldiversity.org<http://www.functionaldiversity.org>
>>>
>>> __**
>>> R-help@r-project.org mailing list
>>> https://stat.ethz.ch/mailman/**listinfo/r-help<https://stat.ethz.ch/mailman/listinfo/r-help>
>>> PLEASE do read the posting guide http://www.R-project.org/**
>>> posting-guide.html <http://www.R-project.org/posting-guide.html>
>>> and provide commented, minimal, self-contained, reproducible code.
>>>
>>
>>
>
> --
> Brian D. Ripley,  rip...@stats.ox.ac.uk
> Professor of Applied Statistics,  
> http://www.stats.ox.ac.uk/~**ripley/<http://www.stats.ox.ac.uk/~ripley/>
> University of Oxford, Tel:  +44 1865 272861 (self)
> 1 South Parks Road, +44 1865 272866 (PA)
> Oxford OX1 3TG, UKFax:  +44 1865 272595
>
>
> __**
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/**listinfo/r-help<https://stat.ethz.ch/mailman/listinfo/r-help>
> PLEASE do read the posting guide http://www.R-project.org/**
> posting-guide.html <http://www.R-project.org/posting-guide.html>
> and provide commented, minimal, self-contained, reproducible code.
>

[[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] Why do tabs disappear when pasted into the R console?

2013-06-03 Thread Tal Galili
My apologies Sarah, you are right, here:


 sessionInfo()
R version 3.0.0 (2013-04-03)
Platform: i386-w64-mingw32/i386 (32-bit)

locale:
[1] LC_COLLATE=Hebrew_Israel.1255  LC_CTYPE=Hebrew_Israel.1255
 LC_MONETARY=Hebrew_Israel.1255
[4] LC_NUMERIC=C   LC_TIME=Hebrew_Israel.1255

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

other attached packages:
[1] plyr_1.8   jpeg_0.1-4

loaded via a namespace (and not attached):
[1] tools_3.0.0



Contact
Details:---
Contact me: tal.gal...@gmail.com |
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--



On Mon, Jun 3, 2013 at 4:22 PM, Sarah Goslee  wrote:

> Pasting tabs into the console works for me on linux, which suggests
> that you need to provide more information about your OS and all the
> other usual things.
>
> Sarah
>
> On Mon, Jun 3, 2013 at 9:15 AM, Tal Galili  wrote:
> > Hello Dear R-help Members,
> >
> > I have noticed that when pasting text with "tab" in it to the R console
> it
> > eliminates the tab. Whereas, when pasted into the R Editor, the tab is
> > preserved.
> > For example, pasting this:
> > "1997 7680"
> > In the R Console will result in:
> > "19977680"
> >
> > Is there a way to preserve the tab?
> > This would allow (for example) to use read.table with a table copied from
> > website/libre-office/excel such as:
> >
> > a = read.table( text=
> > "
> > 1 2
> > 3 4
> > ")
> > a
> >
> > I understand I can use readClipboard directly, but I wonder if there is a
> > way to use it while the text is kept in the R Editor.
> >
> >
> > With regards,
> > Tal
>
>
> --
> Sarah Goslee
> http://www.functionaldiversity.org
>

[[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] Why do tabs disappear when pasted into the R console?

2013-06-03 Thread Tal Galili
Hello Dear R-help Members,

I have noticed that when pasting text with "tab" in it to the R console it
eliminates the tab. Whereas, when pasted into the R Editor, the tab is
preserved.
For example, pasting this:
"1997 7680"
In the R Console will result in:
"19977680"

Is there a way to preserve the tab?
This would allow (for example) to use read.table with a table copied from
website/libre-office/excel such as:

a = read.table( text=
"
1 2
3 4
")
a

I understand I can use readClipboard directly, but I wonder if there is a
way to use it while the text is kept in the R Editor.


With regards,
Tal

[[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] Packages on R 3.0.0

2013-04-03 Thread Tal Galili
Hello all,

I see that R 3.0.0 is announced (hurray!), and have a question regarding
this line in the NEWS file:
"Packages need to be (re-)installed under this version (3.0.0) of R."

Assuming I copy my packages to the new library folder and run
"update.packages" will it be enough?  Or is there anything more to do? for
example - for packages that I have which are already of the latest version
- would I still need to use "install.packages()" on them?

Thanks,
Tal







Contact
Details:---
Contact me: tal.gal...@gmail.com |
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--

[[alternative HTML version deleted]]

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


[R] 100 most read R posts for 2012 (from the R blogosphere)

2012-12-31 Thread Tal Galili
Hello dear R-help members.

While trying to avoid posting on this list about news from r-bloggers.com,
I hope it is o.k. by you if I share the list I made of 100 "most read" R
articles from the blogosphere, based on the analytics data gathered on
r-bloggers.com

You can see the full list at this link:
http://www.r-statistics.com/2013/01/100-most-read-r-posts-for-2012-stats-from-r-bloggers-big-data-visualization-data-manipulation-and-other-languages/

And just as a teaser, here are the top 12 posts (with number of views in
parenthesis):

Select operations on R data frames
(42,742)<http://r-bloggers.com/select-operations-on-r-data-frames/>
Julia, I Love You (22,405) <http://r-bloggers.com/julia-i-love-you/>
R at 12,000 Cores (22,584) <http://r-bloggers.com/r-at-12000-cores/>
An R programmer looks at Julia
(17,172)<http://r-bloggers.com/an-r-programmer-looks-at-julia/>
Adding a legend to a plot
(16,413)<http://r-bloggers.com/adding-a-legend-to-a-plot/>
Solving easy problems the hard way
(13,201)<http://r-bloggers.com/solving-easy-problems-the-hard-way/>
The Best Statistical Programming Language is …Javascript?
(11,047)<http://r-bloggers.com/the-best-statistical-programming-language-is-?%E2%82%AC%C2%A6javascript/>
Step up your R capabilities with new tools for increased productivity
(9,758)<http://r-bloggers.com/step-up-your-r-capabilities-with-new-tools-for-increased-productivity/>
How I cracked Troyis (the online flash game)
(9,527)<http://r-bloggers.com/how-i-cracked-troyis-the-online-flash-game/>
Setting graph margins in R using the par() function and lots of cow milk
(9,549)<http://r-bloggers.com/setting-graph-margins-in-r-using-the-par-function-and-lots-of-cow-milk/>
Creating surface plots (8,705)<http://r-bloggers.com/creating-surface-plots/>
Running R on an iPhone/iPad with RStudio
(8,903)<http://r-bloggers.com/running-r-on-an-iphoneipad-with-rstudio/>

I am grateful for the energy so many of you are putting into the R project,
and the R community - thank you!
Happy new year!

Yours,
Tal Galili




Contact
Details:---
Contact me: tal.gal...@gmail.com |
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--

[[alternative HTML version deleted]]

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


[R] What is behind class coercion of a factor into a character

2012-10-22 Thread Tal Galili
Hello all,

Please review the following simple code:

# make a factor:
x <- factor(c("one", "two"))
   # what should be the output to the following expression?
c(x, "3")# <===  
   # I expected it to be as the output of:
c(as.character(x), "3")
   # But in fact, the output is what would happen if we had ran the
next line:
c(as.character(as.numeric(x)), "3")
   # p.s: c(x, 3) would of course behave differently...

I imagine the above behavior is a "feature" (not a bug), but I am curious
as to what is the rational behind it.  Is it because of computational
efficiency, or something that fixes some case study?

Thanks,
Tal

[[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] The difference between chisq.test binom.test and pbinom

2012-08-21 Thread Tal Galili
Dear Peter,
Your explanation makes perfect sense, thank you.


With regards,
Tal

Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--




On Tue, Aug 21, 2012 at 2:08 AM, Peter Ehlers  wrote:

> On 2012-08-20 12:24, Tal Galili wrote:
>
>> Hello all,
>> I am trying to understand the different results I am getting from the
>> following 3 commands:
>>
>> chisq.test(c(62,50), p = c(0.512,1-0.512), correct = F) # p-value = 0.3788
>> binom.test(x=62,n=112, p= 0.512) # p-value = 0.3961
>> 2*(1-pbinom(62,112, .512)) # p-value = 0.329
>>
>> Well, the binom.test was supposed to be "exact" and give the same results
>> as the pbinom, while the chisq.test relies on the normal asymptotics.  So
>> I
>> would imagine the binom.test should be equal to one of the other two
>> lines,
>> but it is not.
>>
>> The same happens for larger numbers as well:
>>
>> chisq.test(c(1395,1278), p = c(0.512,1-0.512), correct = F)
>> # chisq.test(c(1395,1278), p = c(0.512,1-0.512), simulate.p.value= T)
>> binom.test(x=1395,n=2673, p= 0.512)
>> 2*(1-pbinom(1395,2673, .512))
>>
>
> Let's first dispense with the chisq.test value; that uses the Normal
> approximation and the calculation is trivial; the other two don't.
>
> Let's do a one-sided test:
>
>  binom.test(x=62, n=112, p=.512, alternative="greater")$p.value
>  # 0.2161936
>
> Compare with:
>
>  pbinom(61, 112, .512, lower.tail=FALSE)
>  # 0.2161936
>
> Why '61' instead of '62'? Because we want to include 62 in the
> upper tail probability.
>
> Now it's just a matter of how to calculate the lower tail probability
> in binom.test. Hint: it's not just set equal to the upper tail
> probability (hence no '2*xxx').
> The expected value (under H0) is 112*0.51 = 57.12.
> Thus 62 is 4.88 ~ 5 units higher than the EV.
> Now calculate the probability of an outcome that is 5 units *less*
> (or lower) than the EV:
>
>  pbinom(52, 112, .512)
>  # 0.1799121
>
> Add the two probabilities to get:
>
>  0.2161936 + 0.1799121
>  # 0.3961057
>
> and that's what binom.test() reports.
> For details, have a look at the binom.test code.
>
> Peter Ehlers
>
>
>>
>> I'd be happy to know what I might be missing.
>>
>> Thanks,
>> Tal
>>
>>
>> Contact
>> Details:--**--**---
>> Contact me: tal.gal...@gmail.com |  972-52-7275845
>> Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
>> www.r-statistics.com (English)
>> --**--**
>> --**
>>
>> [[alternative HTML version deleted]]
>>
>> __**
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/**listinfo/r-help<https://stat.ethz.ch/mailman/listinfo/r-help>
>> PLEASE do read the posting guide http://www.R-project.org/**
>> posting-guide.html <http://www.R-project.org/posting-guide.html>
>> and provide commented, minimal, self-contained, reproducible code.
>>
>>
>

[[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] The difference between chisq.test binom.test and pbinom

2012-08-20 Thread Tal Galili
Hello all,
I am trying to understand the different results I am getting from the
following 3 commands:

chisq.test(c(62,50), p = c(0.512,1-0.512), correct = F) # p-value = 0.3788
binom.test(x=62,n=112, p= 0.512) # p-value = 0.3961
2*(1-pbinom(62,112, .512)) # p-value = 0.329

Well, the binom.test was supposed to be "exact" and give the same results
as the pbinom, while the chisq.test relies on the normal asymptotics.  So I
would imagine the binom.test should be equal to one of the other two lines,
but it is not.

The same happens for larger numbers as well:

chisq.test(c(1395,1278), p = c(0.512,1-0.512), correct = F)
# chisq.test(c(1395,1278), p = c(0.512,1-0.512), simulate.p.value= T)
binom.test(x=1395,n=2673, p= 0.512)
2*(1-pbinom(1395,2673, .512))


I'd be happy to know what I might be missing.

Thanks,
Tal


Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--

[[alternative HTML version deleted]]

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


Re: [R] How to convert data to 'normal' if they are in the form of standard scientific notations?

2012-08-07 Thread Tal Galili
Try:

options(scipen = 9)


Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--




On Tue, Aug 7, 2012 at 11:11 AM, Petr PIKAL  wrote:

> Hi
>
> >
> > Dear Jean
> >
> > Thanks a lot for your help.
> >
> > The reason I did not provide producible code is that my work started
> with
> > reading in some large csv files, e.g. the data is not created by myself.
> >  But the data is from the same data provider so I would expect to
> receive
> > data in exactly same data format.
> >
> >
> > I use "read.csv" to read the data in. My major curious is that by using
> > exactly same code as I provided in my email, e.g. 'as.factor' why one of
> > them work (e.g. convert the numerical data to factor) but the other  one
> > remains numerical with scientific notation?  So, in R, how do I check if
> > the data format are different for these two files in their original csv
> > files, which  might cause the different results..?
> >
> > Also I tried your code and created some reproducible examples, but still
> > can not make it work as in your example
>
> a<-c(2.0e+9,2.1e+9)
> is.numeric(a)
> [1] TRUE
> a.f<-factor(a)
> is.numeric(a.f)
> [1] FALSE
> is.factor(a.f)
> [1] TRUE
>
> so factor comes correctly
>
> print(a,digits=12)
> [1] 2.0e+09 2.1e+09
>
> print(a, digits=21)
> [1] 20.000 21.000
>
> b<-c(3000,3100)
> print(b,digits=5)
> [1] 3.0e+07 3.1e+07
>
> So the printed result depends probably on your local setting.
> See also ?options help page. And maybe also ?format and ?sprintf
>
> Regards
> Petr
>
>
> >
> >
> > > a<-c(2.0e+9,2.1e+9)> print(a,digits=4)[1] 20 21  # I
> > expected to see 2.0e+9 here...?> print(a,digits=7)[1] 20
> > 21  # Think here I should expect same 2.0e+9?>
> getOption("digits")
> > # Checking my default number of digits now..[1] 7> b<-c(3000,
> > 3100)> print(b)[1] 3000 3100   # This is what I expected
>
> > to see> print(b,digits=5)[1] 3000 3100   # I'm so confused why
> it
> > is not working, e.g. printing 3.0e+9!> getOption("digits")   # checking
> > again, but now I would expect it has being changed to 5[1] 7
> >
> >
> > Any thoughts please...?
> >
> > Thanks
> > HJ
> >
> >
> > On Mon, Aug 6, 2012 at 7:04 PM, Jean V Adams  wrote:
> >
> > > HJ,
> > >
> > > You don't provide any reproducible code, so I had to make up my own.
> > >
> > > dat <- data.frame(a=letters[1:5], x=c(20110911001084, 20110911001084,
> > > 20110911001084, 20110911001084, 20110911001084),
> > > y=c(2.10004e+12, 2.10004e+12, 2.10004e+12, 2.10004e+12,
> > > 2.10004e+12))
> > >
> > > In my example, the long numbers print out without scientific notation.
> > >
> > > dat
> > >   a  x y
> > > 1 a 20110911001084 210004000
> > > 2 b 20110911001084 210004000
> > > 3 c 20110911001084 210004000
> > > 4 d 20110911001084 210004000
> > > 5 e 20110911001084 210004000
> > >
> > > I can make it print with scientific notation using the digits argument
> to
> > > the print() function.
> > >
> > > print(dat, digits=3)
> > >   ax   y
> > > 1 a 2.01e+13 2.1e+12
> > > 2 b 2.01e+13 2.1e+12
> > > 3 c 2.01e+13 2.1e+12
> > > 4 d 2.01e+13 2.1e+12
> > > 5 e 2.01e+13 2.1e+12
> > >
> > > What is your default number of digits?
> > > getOption("digits")
> > >
> > > Jean
> > >
> > >
> > > HJ YAN  wrote on 08/06/2012 11:14:17 AM:
> > >
> > > >
> > > > Dear R users
> > > >
> > > > I read two csv data files into R and  called them Tem1 and Tem5.
> > > >
> > > > For the first column, data in Tem1 has 13 digits where in Tem5 there
> are
> > > 14
> > > > digits for each observation.
> > > >
> > > > Originally there are 'numerical' as can be seen in my code below.
> But
> > > how
> > > > can I display/convert them using other form rather than scientific
> > > > notations which seems a standard/default?
> > > >
> > > >  I want them to be in the form like '20110911001084', but I'm very
> > > confused
> > > > why when I used 'as.factor' call it works for my 'Tem1' but not for
> > > > 'Tem5'...??
> > > >
> > > >
> > > > Many thanks!
> > > >
> > > > HJ
> > > >
> > > > > Tem1[1:5,1][1] 2.10004e+12 2.10004e+12 2.10004e+12 2.10004e+12 2.
> > > > 10004e+12> Tem5[1:5,1][1] 2.011091e+13 2.011091e+13 2.011091e+13 2.
> > >
> > > > 011091e+13 2.011091e+13> class(Tem1[1:5,1])[1] "numeric"> class(Tem5
> > > > [1:5,1])[1] "numeric"> as.factor(Tem1[1:5,1])[1] 2.10004e+12 2.
> > > > 10004e+12 2.10004e+12 2.10004e+12 2.10004e+12
> > > > Levels: 2.10004e+12> as.factor(Tem5[1:5,1])[1] 20110911001084
> > > > 20110911001084 20110911001084 20110911001084 20110911001084
> > > > Levels: 20110911001084
> > >
> >
> >[[alternative HTML versi

Re: [R] EM for missing data

2012-07-21 Thread Tal Galili
Hello Ya.

I am no expert, so I am eager to read suggestions from other people in the
mailing list.  But just a few pointers I am (somewhat) sure of -

You can try using this package:
http://cran.r-project.org/web/packages/imputation/imputation.pdf
And use something like kNNImpute.  KNN solving is a type of EM.

In any event, an imputation based on EM is also based on some assumption of
the underlying distribution of the data (observable and missing).  From
what I see here:
http://www.youtube.com/watch?v=xEkJxl6mmQ0
It seems that the EM of SPSS often assumed a (multi?!) normal distribution
of the data.  Which is a stronger assumption than what knn will use.  Also
the function I linked to has a CV option to check how stable the imputation
process is.

If you are looking for more options just google R+imputation.  There are
numerous packages and functions for this.

Good luck,
Tal





Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--




On Sat, Jul 21, 2012 at 2:55 PM, ya  wrote:

> Hi list,
>
> I am wondering if there is a way to use EM algorithm to handle missing
> data and get a completed data set in R?
>
> I usually do it in SPSS because EM in SPSS kind of "fill in" the estimated
> value for the missing data, and then the completed dataset can be saved and
> used for further analysis. But I have not found a way to get the a
> completed data set like this in R or SAS. With Amelia or MICE, the missing
> data set were imputed a couple of times, and the new imputed datasets were
> not combined. I understand that the parameter estimation can still be done
> in the way of combination of estimates from each imputed data set, but it
> would be more convenient to have a combined dataset to do some analysis,
> for example, ANOVA with IVs having more than two categories. In this case,
> the only way to get the main effect of the whole IV is to estimate
> parameters in a single data set(as far as I know). If the separated imputed
> data sets were used, then the main effect showed in the result were for
> each category of the IV, respectively. I figured sometimes the readers and
> reviewers would like to see how bi!
>  g the effect for the whole IV instead of the effect of each category of
> that IV.
>
> This is one of the reasons I can not fully move to R from SPSS. So any
> suggestions?
>
> Thank you very much.
>
>
>
>
> ya
> [[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] median comparison tests

2012-07-20 Thread Tal Galili
You can do a transformation on your Y, and than use the normal tools.
Using something like a median test is not advisable due to low power, and a
wilcox.test is considered a better choice (although the meaning is more
complex when observations are not symmetrically distributed).

If you wish to perform a one way anova, which is non parametric, you can
use:
?kruskal.test
And after that you can use the tools suggested here by David
Winsemius
:
http://r.789695.n4.nabble.com/post-hoc-test-with-kruskal-test-td898661.html

With regards,
Tal



Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--




On Thu, Jul 19, 2012 at 11:14 PM, Data Analytics Corp. <
w...@dataanalyticscorp.com> wrote:

> Hi,
>
> A client has a consumption measure on each of four products.  The sample
> size is 75.  The consumption distributions are highly skewed for each
> product.  He would like a pairwise comparison test of the products, much
> like Tukey's HSD but using medians rather than means.  Is there such a
> median comparison test in R?
>
> Thanks,
>
> Walt
>
> 
>
> Walter R. Paczkowski, Ph.D.
> Data Analytics Corp.
> 44 Hamilton Lane
> Plainsboro, NJ 08536
> 
> (V) 609-936-8999
> (F) 609-936-3733
> w...@dataanalyticscorp.com
> www.dataanalyticscorp.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] loop through and modify multiple data frames

2012-06-28 Thread Tal Galili
Hi Jan,
You can do it in two ways.  The simplest one is the following.

The first option is to use $.  Here is how:
dogs <- data.frame(a = 1:10, b = 10:1)
dogs$c <- dogs$a+dogs$b
dogs


The second way it to use
?within


Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--




On Thu, Jun 28, 2012 at 12:10 PM, Jan Näs  wrote:

> Hi
>
> Newbie question:
>
> I have a set of data frames that I want to do the same calculations on
> each.
> I've found out that I can put them in a list and loop through the list
> to do the calculation, but not put the results back into each
> data.frame..
>
> For example three data frames cats, dogs, birds
>
> where >cats
>
> name eats_kg
> 1 bob 3
> 2 garfield 4
> 3 chuck 6
>
> and dogs and birds are similar but not same length.
>
> On each data frame I now want to add a column with cost of food by
> calculating "eats_kg"*price of food.
>
> So question is, can I put all data frames into one loop which returns
> a new column for each?
>
> Ive tried
>
> MyList <- list(cast,dog,birds)
>
> for(i in 1:length(MyList)){
> price <- as.data.frame(myList[i])[,2] * cost
> .. and then Im stuck. How can I put "price" back into each data frame?
>
> Thanks in advance.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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 teat

2012-05-12 Thread Tal Galili
Hi Soheila,
There you go:

median.test<-function(y1,y2){
  z<-c(y1,y2)
  g <- rep(1:2, c(length(y1),length(y2)))
  m<-median(z)
  fisher.test(z<=m,g)$p.value
}

group1 <- c(2, 2, 5, 5, 4, 3, 1, 5,5,5,5,5)
group2 <- c(3, 1, 3, 1, 4, 1, 1, 1, 7, 1, 1, 1, 1, 1, 2)
boxplot(group1, group2)
median.test(group2 ,group1)



Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--




On Sat, May 12, 2012 at 12:23 PM, Soheila Khodakarim
wrote:

> Dear All
>
> Is there any function for "median test" in R?
>
> Best Regards,
> Soheila
>
>[[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] Dotchart showing mean and median by group

2012-05-09 Thread Tal Galili
Hello dear Gabor,

First - thank you for this solution!

Second - I see that the text that is added around the axes is a tiny bit
shifted - causing a slight blur of the text.  Does it happen only on
Windows?  Can it be fixed?



Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--




On Wed, May 9, 2012 at 4:20 PM, Gabor Grothendieck
wrote:

> On Wed, May 9, 2012 at 3:25 AM, maxbre  wrote:
> > Given this example
> >
> > mean.values<-colMeans(VADeaths)
> >
> > mean.values<-apply(VADeaths, 2, mean)
> > median.values<-apply(VADeaths, 2, median)
> >
> > dotchart(VADeaths, gdata=mean.values)
> > dotchart(VADeaths, gdata=median.values)
> >
> > is it possible to “combine” a single dotchart showing both the mean and
> the
> > median for each single group (with different plotting symbols)?
> >
>
> Try this:
>
> dotchart(VADeaths, gdata=mean.values)
> par(new = TRUE)
> dotchart(VADeaths, gdata=median.values, gpch = 20)
>
> --
> Statistics & Software Consulting
> GKX Group, GKX Associates Inc.
> tel: 1-877-GKX-GROUP
> email: ggrothendieck at gmail.com
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[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] Dotchart showing mean and median by group

2012-05-09 Thread Tal Galili
Hi Max,
I see that "dotchart" does not have a "add" parameter.
For the fun of it, I added this feature, you can see the source code of the
new function here:
https://raw.github.com/talgalili/R-code-snippets/master/dotchart.with.add.r
With your example at the end of the file.

Here is a page showing the changes I've made to the original function, so
to enable this feature:
https://github.com/talgalili/R-code-snippets/commit/26b4104085808e6bcad49573ca2e060332467f39
This may not be the prettiest way, if someone on the list has ideas for
improvement, please let me know.

Cheers,
Tal

Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--




On Wed, May 9, 2012 at 10:25 AM, maxbre  wrote:

> Given this example
>
> mean.values<-colMeans(VADeaths)
>
> mean.values<-apply(VADeaths, 2, mean)
> median.values<-apply(VADeaths, 2, median)
>
> dotchart(VADeaths, gdata=mean.values)
> dotchart(VADeaths, gdata=median.values)
>
> is it possible to “combine” a single dotchart showing both the mean and the
> median for each single group (with different plotting symbols)?
>
> …is it that possible with the use of the standard graphics or it is
> necessary (better) to use of a different package?
>
> Any example for this in my favourite (even almost always too much complex
> for myself) package lattice?
>
> thank you
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/Dotchart-showing-mean-and-median-by-group-tp4619597.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] file path

2012-05-09 Thread Tal Galili
Hi Wincent,
Have a look at:
?file.path



Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--




On Wed, May 9, 2012 at 11:03 AM, Wincent  wrote:

> Dear all, is there any function to assert whether a file path is
> legitimate, and to convert any potential file path to a legitimate
> file path?
>
> I automate a batch of files and write them to plain text files with
> cat(). The file argument of cat() is generated automatically which may
> contain characters such as ? < >, unacceptable in Windows OS. What I
> do at this moment is to strip such characters off with gsub(). Is
> there any direct way to make legitimate file path without detailed
> knowledge about the naming rule specific to a OS?
>
> Best
>
> --
> Wincent Ronggui HUANG
> Sociology Department of Fudan University
> PhD of City University of Hong Kong
> http://homepage.fudan.edu.cn/rghuang/cv/
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Binomial GLM, chisq.test, or?

2012-05-07 Thread Tal Galili
Hi Lincoln,
Some thoughts:
1) Did you intend to use  "cohort" as a factor and not as a numeric? (at
least that is what it looks like in your output)
2) Is there a strong correlation between "cohort" and the
other explanatory variables you are trying in your model?




Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--




On Mon, May 7, 2012 at 10:28 AM, lincoln  wrote:

> Thanks Tal for answering,
>
> Anyway I still have no idea on why the binomial GLM is missing the
> relationship between the response variable and the explanatory variable
> "cohort".
>
> Is there anyone who might help me to understand this?
>
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/Binomial-GLM-chisq-test-or-tp4608941p4614184.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] Correct use of ddply with own function

2012-05-05 Thread Tal Galili
Hi Johannes ,

Try this:

var1 <- rep(c("a","b"),c(100,100))
var2 <- runif(200,1,50)
df.test <- data.frame(var1,var2)

fn <- function(x){
x <- x$var2
   x1 <- sort(x)
   x2 <- seq(length(x))
   x3 <- x2/max(x2)
   df <- data.frame(x1,x2,x3)
   df
}

require(plyr)
ddply(df.test,.(var1),fn)



I think it should do what you've asked.



Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--




On Sat, May 5, 2012 at 12:51 PM, Johannes Radinger  wrote:

> Hi,
>
> I am really confused how ddply work, so maybe you can help me.
>
> I created a function that sorts a vector etc.
>
> fn <- function(x){
>x1 <- sort(x)
>x2 <- seq(length(x))
>x3 <- x2/max(x2)
>df <- data.frame(x1,x2,x3)
>df
> }
>
> Probably this is not the best form of the function, but at least it
> produces what I want (data to plot a cumulative count curve).
> This function works on a single vector but I have a melted dataframe like:
>
> var1 <- rep(c("a","b"),c(100,100))
> var2 <- runif(200,1,50)
> df.test <- data.frame(var1,var2)
>
> ..and I want to apply that function on var2 but splitted by the variable
> var1. I think this might be a case for ddply...
>
> anything like: ddply(df.test,.(var1),fn(var2))...
> maybe someone know how to do that (modifying my function and applying it
> on a splitted dataframe).
>
> Best regards,
>
> Johannes
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Binomial GLM, chisq.test, or?

2012-05-04 Thread Tal Galili
Without going deeply into your analysis, 2 comments:

1) Use the anova command to test two nested models using:
anova(model1, model2, test="Chisq")

2) glm's are non-trivial models (at least to me), be sure to google for
some tutorials in order to understand what you are looking at...

Cheers,
Tal





Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--




On Fri, May 4, 2012 at 6:38 PM, lincoln  wrote:

> Hi,
>
> I have a data set with 999 observations, for each of them I have data on
> four variables:
> site, colony, gender (quite a few NA values), and cohort.
>
> This is how the data set looks like:
> > str(dispersal)
> 'data.frame':   999 obs. of  4 variables:
>  $ site  : Factor w/ 2 levels "1","2": 1 1 1 1 1 1 1 1 2 2 ...
>  $ gender: Factor w/ 2 levels "0","1": NA NA 2 1 2 NA 1 2 2 NA ...
>  $ colony: Factor w/ 2 levels "main","other": 2 2 2 2 2 2 2 2 2 2 ...
>  $ cohort: Factor w/ 11 levels "1996","2000",..: 8 8 8 8 8 8 8 8 8 6 ...
>
> Now, I want to estimate if sites 1 and site 2 differ on some of the other
> variables. For instance there are relatively more males in site 1 with
> respect to site 2, more individuals of the main colony in site 2 with
> respect to site 1 and this sort of things.
>
> I thought I might do a binomial GLM considering as response variable the
> site, I tried to run the more general model to have a look to
> overdispersion
> but I believe there is something wrong even before worrying about
> overdispersion. I know (I did a chisq.test) that cohort2004 is very
> diversly
> represented between the two sites but it is not reflected in the results of
> GLM. Here there are the results of chisq.test and the GLM:
>
> 1)
> />
>
> age_cohort<-as.table(rbind(c(142,95,46,33,14,59,18,12,7,1,0),c(258,144,54,70,20,11,6,8,2,3,1)))
> > dimnames(age_cohort)<-list(site=c("M","D"),
> +
> cohorts=c(2010,2009,2008,2007,2006,2004,2003,2002,2001,2000,1996))
> > age_cohort
>cohorts
> site 2010 2009 2008 2007 2006 2004 2003 2002 2001 2000 1996
>   M  142   95   46   33   14   59   18   12710
>   D  258  144   54   70   20   1168231
> > (Xsqagec <- chisq.test(age_cohort))  # Prints test summary
>
>Pearson's Chi-squared test
>
> data:  age_cohort
> X-squared = 82.6016, df = 10, p-value = 1.549e-13
>
> Mensajes de aviso perdidos
> In chisq.test(age_cohort) : Chi-squared approximation may be incorrect
> > Xsqagec$observed   # observed counts
>cohorts
> site 2010 2009 2008 2007 2006 2004 2003 2002 2001 2000 1996
>   M  142   95   46   33   14   59   18   12710
>   D  258  144   54   70   20   1168231
> > Xsqagec$expected   # expected counts under the null
>cohorts
> site 2010 2009 2008 2007 2006 2004 2003
>   M 170.1195 101.6464 42.52988 43.80578 14.46016 29.77092 10.20717
>   D 229.8805 137.3536 57.47012 59.19422 19.53984 40.22908 13.79283
>cohorts
> site  2002 2001 2000  1996
>   M  8.505976 3.827689 1.701195 0.4252988
>   D 11.494024 5.172311 2.298805 0.5747012
> > Xsqagec$residuals  # Pearson residuals
>cohorts
> site   2010   2009   2008   2007   2006
>   M -2.1559111 -0.6592367  0.5321050 -1.6326395 -0.1210101
>   D  1.8546283  0.5671101 -0.4577448  1.4044825  0.1040993
>cohorts
> site   2004   2003   2002   2001   2000
>   M  5.3569686  2.4391720  1.1980192  1.6214643 -0.5376032
>   D -4.6083465 -2.0983042 -1.0305993 -1.3948690  0.4624746
>cohorts
> site   1996
>   M -0.6521494
>   D  0.5610132
> > Xsqagec$stdres # standardized residuals
>cohorts
> site   2010   2009   2008   2007   2006
>   M -3.6665549 -0.9962228  0.7397057 -2.2733888 -0.1623984
>   D  3.6665549  0.9962228 -0.7397057  2.2733888  0.1623984
>cohorts
> site   2004   2003   2002   2001   2000
>   M  7.3264142  3.2566808  1.5962909  2.1485311 -0.7105713
>   D -7.3264142 -3.2566808 -1.5962909 -2.1485311  0.7105713
>cohorts
> site   1996
>   M -0.8606814
>   D  0.8606814
> /
>
>
> 2)
> /> model1<-glm(site~gender*colony*cohort,binomial)
> > summary(model1)
>
> Call:
> glm(formula = site ~ gender * colony * cohort, family = binomial)
>
> Deviance Residuals:
> Min1QMedian3Q   Max
> -1.84648  -0.96954  -0.00036   1.11269   2.03933
>
> Coefficients: (12 not defined because of singularities)
> Estimate Std. Error z value
> (Intercept)-1.657e+01  2.400e+03  -0.007
> gender1-2.231e-01  9.220e-01  -0.242
> colonyother 9.531e-02  8.006e-01   0.119
> cohort2002  1.717e-08  3.393

Re: [R] read multiple dataset at one time

2012-04-30 Thread Tal Galili
Without more information on the format of the files, or any other thing, it
is hard to give a full answer.
But shortly: yes, it is possible.

With a bit more details:
You can combine:
readLines (or read.table, or what ever will work for your file), with
list.files
And run through them with a for loop.

Now that I am writing this, I am wondering if it could be possible to do
this in some parallel function, instead of with a loop...




On Mon, Apr 30, 2012 at 9:32 PM, ya  wrote:

>
>
> Hi,
>
> Is it possible to read, say 100 dat files in one time? I want to combine
> these 100 data set into one single dat file.
>
> Any suggestions?
>
> Thank you very much.
>
> ya
>[[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] r2 and p value dispaly in table

2012-04-29 Thread Tal Galili
I am not sure why you would want it, but here it is:

individual <- c(1,1,6,8,8,9,9,9,12,12)
day <- c(4,17,12,12,17,3,9,22,13,20)
condition <- c(0.72, 0.72, 0.67, 0.73, 0.76, 0.65, 0.68, 0.78, 0.73, 0.71)

test1 <- data.frame(individual, day, condition)
test1

library(plyr)

result=ddply(test1, "individual", function(x) {
   model <- lm(condition ~ day, data = x)
   F <- as.numeric((summary(model))$fstatistic)
   ss <- sum(is.nan(F)) >0 # any(is.nan(F)) # any(is.na(F)) |
   P <- ifelse(!ss, 1-pf(F[1], F[2],F[3])  , NA)
   data.frame(coef(model), r.squared = summary(model)$r.squared, p.value =
P)
 })

result



Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--




On Sun, Apr 29, 2012 at 3:58 PM, Kristi Glover wrote:

>  Hi Tal,
> Thank you so much for the help. I am afraid that I could not make you
> understand of my problem. The code you wrote is for whole data set, but I
> wanted to do regression based on "Individual" and put coefficient, r2 and p
> value. Individual is group variable.
>
> Here I again run the script
>
>
> > individual <- c(1,1,6,8,8,9,9,9,12,12)
> > day <- c(4,17,12,12,17,3,9,22,13,20)
> > condition <- c(0.72, 0.72, 0.67, 0.73, 0.76, 0.65, 0.68, 0.78, 0.73,
> 0.71)
> > test1 <- data.frame(individual, day, condition)
> > test1
>individual day condition
> 1   1   4  0.72
> 2   1  17  0.72
> 3   6  12  0.67
> 4   8  12  0.73
> 5   8  17  0.76
> 6   9   3  0.65
> 7   9   9  0.68
> 8   9  22  0.78
> 9  12  13  0.73
> 10 12  20  0.71
> > library(plyr)
> > result=ddply(test1, "individual", function(x) {
> +   model <- lm(condition ~ day, data = x)
> +   coef(model)
> + })
> > result
>   individual (Intercept)   day
> 1  1   0.720 -4.039638e-18
> 2  6   0.670NA
> 3  8   0.658  6.00e-03
> 4  9   0.6242403  6.978799e-03
> 5 12   0.7671429 -2.857143e-03
> >
> in the result table: I want to add two columns with the information of r2
> and p value.
> I hope you understand my problem. thaks for allyour help. I am learning R.
> cheers
> kristi
>
>
> --
> From: tal.gal...@gmail.com
> Date: Sun, 29 Apr 2012 12:13:08 +0300
> Subject: Re: [R] r2 and p value dispaly in table
> To: kristi.glo...@hotmail.com
> CC: r-help@r-project.org
>
>
> You came close.
>
> Here is how it might be done:
>
> individual <- rep(c(1,1,6,8,8,9,9,9,12,12),2)
> day <- rep(c(4,17,12,12,17,3,9,22,13,20),2)
> condition <- rep(c(0.72, 0.72, 0.67, 0.73, 0.76, 0.65, 0.68, 0.78, 0.73,
> 0.71),2)
> test <- data.frame(individual, day, condition)
>
> #ind.id <- unique(test$individual)
> #ind.list <- lapply(1:length(ind.id), function(i){ subset(test,
> test$individual==ind.id[i])})
> #lms <- lapply(ind.list, lm, formula=condition~day)
>
> require(plyr)
> func1 <- function(...)
> {
> lm(condition~day, data = test)
> }
> lms <- lapply(1:10, func1)
> lms
>
> func2 <- function(fit)
> {
> F <- (summary(fit))$fstatistic
> P <- 1-pf(F[1], F[2],F[3]) # notice how we must calculate the p-value
>  data.frame(r.squared = summary(fit)$r.squared, p.value = P)
> }
> ldply(lms, func2)
>
>
>
>
> Contact
> Details:---
> Contact me: tal.gal...@gmail.com |  972-52-7275845
> Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
> www.r-statistics.com (English)
>
> --
>
>
>
>
> On Sun, Apr 29, 2012 at 9:04 AM, Kristi Glover 
> wrote:
>
>
> Hello R User,
> I was trying to display r.squared and p value in table from regression,
> but I could not display these parameters in the table (matrix)
>
> for example
> individual <- c(1,1,6,8,8,9,9,9,12,12)
> day <- c(4,17,12,12,17,3,9,22,13,20)
> condition <- c(0.72, 0.72, 0.67, 0.73, 0.76, 0.65, 0.68, 0.78, 0.73, 0.71)
> test <- data.frame(individual, day, condition)
> ind.id <- unique(test$individual)
> ind.list <- lapply(1:length(ind.id), function(i){ subset(test,
> test$individual==ind.id[i])})
> lms <- lapply(ind.list, lm, formula=condition~day)
> ldply(lms, function(x) x$coefficients)
> here I can display coefficients, here I need to write code for r2.squared
>
> I tried with following script
>
> summary(ldply(lms, function(x) )$r.squared, $p value)
> but it did not work.
>
> can any one help me?
>
> thanks
> Kristi
>
>
>
>[[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

Re: [R] r2 and p value dispaly in table

2012-04-29 Thread Tal Galili
You came close.

Here is how it might be done:

individual <- rep(c(1,1,6,8,8,9,9,9,12,12),2)
day <- rep(c(4,17,12,12,17,3,9,22,13,20),2)
condition <- rep(c(0.72, 0.72, 0.67, 0.73, 0.76, 0.65, 0.68, 0.78, 0.73,
0.71),2)
test <- data.frame(individual, day, condition)

#ind.id <- unique(test$individual)
#ind.list <- lapply(1:length(ind.id), function(i){ subset(test,
test$individual==ind.id[i])})
#lms <- lapply(ind.list, lm, formula=condition~day)

require(plyr)
func1 <- function(...)
{
lm(condition~day, data = test)
}
lms <- lapply(1:10, func1)
lms

func2 <- function(fit)
{
F <- (summary(fit))$fstatistic
P <- 1-pf(F[1], F[2],F[3]) # notice how we must calculate the p-value
 data.frame(r.squared = summary(fit)$r.squared, p.value = P)
}
ldply(lms, func2)




Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--




On Sun, Apr 29, 2012 at 9:04 AM, Kristi Glover wrote:

>
> Hello R User,
> I was trying to display r.squared and p value in table from regression,
> but I could not display these parameters in the table (matrix)
>
> for example
> individual <- c(1,1,6,8,8,9,9,9,12,12)
> day <- c(4,17,12,12,17,3,9,22,13,20)
> condition <- c(0.72, 0.72, 0.67, 0.73, 0.76, 0.65, 0.68, 0.78, 0.73, 0.71)
> test <- data.frame(individual, day, condition)
> ind.id <- unique(test$individual)
> ind.list <- lapply(1:length(ind.id), function(i){ subset(test,
> test$individual==ind.id[i])})
> lms <- lapply(ind.list, lm, formula=condition~day)
> ldply(lms, function(x) x$coefficients)
> here I can display coefficients, here I need to write code for r2.squared
>
> I tried with following script
>
> summary(ldply(lms, function(x) )$r.squared, $p value)
> but it did not work.
>
> can any one help me?
>
> thanks
> Kristi
>
>
>
>[[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] searchina a pattern in a string

2012-04-24 Thread Tal Galili
If it was only numbers with no dashes or up to 2 dashes, you can do it like
this:

require(stringr)
STRING <- "my no is 9876543210 is personal no and my official no is
123-456-8907. you
can use any of these"
str_extract_all( STRING , "[0-9]+-*[0-9]+-*[0-9]+")

(and then clean the numbers...)



Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--




On Tue, Apr 24, 2012 at 5:52 PM, arunkumar  wrote:

> I have a long string. i want to sepearate a 10 digit phone no from it.
>
> eg
>
>
> "my no is 9876543210 is personal no and my official no is 123-456-8907. you
> can use any of these"
>
> i want to seperate the 9876543210 and 123-456-8907 from this. therev may be
> many phone nos in the string. how to do it
>
> -
> Thanks in Advance
>Arun
> --
> View this message in context:
> http://r.789695.n4.nabble.com/searchina-a-pattern-in-a-string-tp4583740p4583740.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] Script Help Or Excel Add-in

2012-04-21 Thread Tal Galili
Hi Ben,

1) Have a look at:
http://rcom.univie.ac.at/download.html

2) I do not know.

Good luck,
Tal


Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--




On Sat, Apr 21, 2012 at 6:06 PM, bscully  wrote:

> Hello,
>
> I have been using R/S+ for years and love the software.  Still a novice but
> I can do what i need to.
>
> Anyway, I am working on a forecasting project and would like to create a
> script that automates the following steps:
> order data by X
> Create groupings 1...N
> Separate test data set
> run regression on each group
> Determine result.  (A mathematical formula is run on the forecasted output)
> Repeat for test set
> Review results
>
> I have no idea how to do this script in S+.  Working in excel would make
> this much easier so my question is twofold:
>
> 1) I am running windows 7, MS Office 2010 and i dont have an excel add-in
> for S+.  Does one exist?  Does one exist for R?  An installation link would
> be very helpful.
>
> 2) How can i create the above script in R/S+ to automate my research.
>
>
> Any help would be greatly appreciated!
>
> Thank you,
>
> Ben
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/Script-Help-Or-Excel-Add-in-tp4576572p4576572.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] Problem with Tukey test

2012-04-20 Thread Tal Galili
Hi,
I can not reproduce your problem.

Can you use ?dput, and try to create a self contained example?

Here is my attempt:

warpbreaks1 <- warpbreaks
warpbreaks1[1,1] <- NA
fm1 <- aov(breaks ~ tension, data = warpbreaks1)
summary(fm1)
TukeyHSD(fm1)


Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--




On Fri, Apr 20, 2012 at 4:21 PM, danipaty13  wrote:

> I'm new using R im trying to do a tukey test, but when i see the results
> the
> p value results in NA im guessing its because i have missing values but im
> not sure how to fix it
>
> AnovaModel.2 <- aov(area ~ trat, data=apilados)
>
> > summary(AnovaModel.2)
>Df Sum Sq Mean Sq F valuePr(>F)
> trat 4  11847 2961.76  9.9905 1.500e-06 ***
> Residuals   76  22531 296.46
> ---
> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
> 14 observations deleted due to missingness
>
> > numSummary(apilados$area , groups=apilados$trat, statistics=c("mean",
> > "sd"))
>   mean sd  n NA
> X1 79.29625 15.06667 16  3
> X2 77.43400 10.64849 15  4
> X3 71.19895 15.85500 19  0
> X4 77.80938 24.67359 16  3
> X5 45.97200 16.65112 15  4
>
> > TukeyHSD(AnovaModel.2)
>  Tukey multiple comparisons of means
>95% family-wise confidence level
>
> Fit: aov(formula = area ~ trat, data = apilados)
>
> $trat
> diff  lwr upr p adj
> X2-X1  -1.862250  NA  NANA
> X3-X1  -8.097303  NA  NANA
> X4-X1  -1.486875  NA  NANA
> X5-X1 -33.324250  NA  NANA
> X3-X2  -6.235053  NA  NANA
> X4-X2   0.375375  NA  NANA
> X5-X2 -31.462000  NA  NANA
> X4-X3   6.610428  NA  NANA
> X5-X3 -25.226947  NA  NANA
> X5-X4 -31.837375  NA  NANA
>
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/Problem-with-Tukey-test-tp4573945p4573945.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] working with environments to ensure code quality for long R scripts

2012-04-19 Thread Tal Galili
Hi Alexander,
Saving full environments is possible, but it is very easy to start loosing
track on where each variable came from.
You might want to use this process:
http://www.r-bloggers.com/a-better-way-of-saving-and-loading-objects-in-r/
It depends on how many variables you work with, but it might help.

Another way is to do all of the work through Sweave, and combine it with
caching:  http://cran.r-project.org/web/packages/cacheSweave/index.html
This will ensure that every code chunk will keep the variables you created,
without the need to re-run the code from scratch.

For extracting data from outside sources, I would often use the first
method, and for analysis I would use the later option.

Good luck,
Tal


Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--




On Thu, Apr 19, 2012 at 11:15 AM, Alexander wrote:

> Hello, I am working under R2.11 Windows and currently I work on a big R
> progjet which executes different R script in a row. Every R script
> represents a module. As every module depends of the variables created in
> the
> modules previously executed, I want to be shure, that I don't create or
> change a variable in a scriptwithout being aware that this affects the
> results in a later executed script. Therefore, I was think to save all
> important variables to keep in a seperate "backup" environment. Everytime a
> script starts, it loads the variables of the "backup" environment in
> .GlobalEnv. At the end of the script, I want to add all new obtained
> variables to the "backup" environment (and check automaticaly if any
> variables of "backup"environment is going to be overwritten) and clean the
> workspace .GlobalEnv to start the next script neat and tidy. What do you
> think of this solution? Does anyone have better ideas or experience to
> share?
>
> Thank you in advance
>
> Alexander
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/working-with-environments-to-ensure-code-quality-for-long-R-scripts-tp4570195p4570195.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] enableJIT(2) causes major slow-up in rpart

2012-04-14 Thread Tal Galili
Hello deari Uwe,

What you explain about enableJIT makes sense, except that I would not
expect it to slow down the function in an order of magnitude.
If it was only adding a constant time to the startup time, I would
understand, but I suspect that this is not the case here.  For example, see
this code:

enableJIT(0) #  making sure that JIT is off
#[1] 3
fo <- function() {for(i in 1:100) {rpart(Kyphosis ~ Age + Number + Start,
data=kyphosis)}}
system.time(fo())
#   user  system elapsed
#   0.700.020.78
enableJIT(3)
# [1] 0
system.time(fo())
#   user  system elapsed
#  10.310.00   10.36

If I understand enableJIT, it shoudl compile the functions inside fo and
rpart once (hence the slower startup time), but once that is done, there
should not be an extra overhead.  Am I missing something here?

With regards,
Tal






Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--




On Fri, Apr 13, 2012 at 12:47 PM, Uwe Ligges <
lig...@statistik.tu-dortmund.de> wrote:

>
>
> On 12.04.2012 23:15, Tal Galili wrote:
>
>> Hello,
>>
>> Due to exploration of the JIT capabilities offered through the {compiler}
>> package, I came by the fact that using enableJIT(2) can *slow* the rpart
>>
>> function (from the {rpart} package) by a magnitude of about 10 times.
>>
>> Here is an example code to run:
>>
>> library(rpart)
>> require(compiler)
>>
>> enableJIT(0) # just making sure that JIT is off # We could also use
>> enableJIT(1) and it would be fine
>> fo<- function() {rpart(Kyphosis ~ Age + Number + Start, data=kyphosis)}
>> system.time(fo())
>> #   user  system elapsed
>> #  0   0   0   # this can also be 0.01 sometimes.
>>
>> enableJIT(2)  # also happens for enableJIT(3)
>> system.time(fo())
>> #   user  system elapsed
>> #   0.120.000.12
>>
>>
> Because the overhead for JIT is considerable for this example and the time
> critical parts of rpart are written in compiled code already.
>
> JIT compilers are good for inefficiently written R code such as loops that
> could be avoided by vectorized operations. JIT cannot optimize runtime for
> code already written in C (or written in excellent R code).
>
> Uwe Ligges
>
>
>
>
>
>
>
>> Which brings me to my *questions*:
>>
>> 1) Is this a bug or a feature?
>> 2) If this is a feature, what is causing it? (or put another way, can one
>> predict ahead of time the implications of using enableJIT(2) or
>> enableJIT(3) on his code?)
>>
>>
>> *Links*:
>>
>> A post I recently wrote about my exploration of JIT -
>> www.r-statistics.com/2012/04/**speed-up-your-r-code-using-a-**
>> just-in-time-jit-compiler/<http://www.r-statistics.com/2012/04/speed-up-your-r-code-using-a-just-in-time-jit-compiler/>
>> The question asked on SO regarding the limitations of JIT:
>> http://stackoverflow.com/**questions/10106736/possible-**
>> shortcomings-for-using-jit-**with-r<http://stackoverflow.com/questions/10106736/possible-shortcomings-for-using-jit-with-r>
>>
>> Thanks,
>> Tal
>>
>>
>>
>> Contact
>> Details:--**--**---
>> Contact me: tal.gal...@gmail.com |  972-52-7275845
>> Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
>> www.r-statistics.com (English)
>> --**--**
>> --**
>>
>>[[alternative HTML version deleted]]
>>
>> __**
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/**listinfo/r-help<https://stat.ethz.ch/mailman/listinfo/r-help>
>> PLEASE do read the posting guide http://www.R-project.org/**
>> posting-guide.html <http://www.R-project.org/posting-guide.html>
>> and provide commented, minimal, self-contained, reproducible code.
>>
>

[[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] enableJIT(2) causes major slow-up in rpart

2012-04-13 Thread Tal Galili
Thank you very much Luke,

With regards,
Tal


Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--




On Fri, Apr 13, 2012 at 11:58 PM,  wrote:

> The level 2 is a heuristic meant to help with certain kinds of
> programming idioms. It isn't always going to work.  In this case
> trace(cmpfun) will show three functions being compiled each time
> through. Not sure why -- I'll try to find out and see if it can be
> avoided.
>
> luke
>
>
> On Thu, 12 Apr 2012, Tal Galili wrote:
>
>  Hello,
>>
>> Due to exploration of the JIT capabilities offered through the {compiler}
>> package, I came by the fact that using enableJIT(2) can *slow* the rpart
>>
>> function (from the {rpart} package) by a magnitude of about 10 times.
>>
>> Here is an example code to run:
>>
>> library(rpart)
>> require(compiler)
>>
>> enableJIT(0) # just making sure that JIT is off # We could also use
>> enableJIT(1) and it would be fine
>> fo <- function() {rpart(Kyphosis ~ Age + Number + Start, data=kyphosis)}
>> system.time(fo())
>> #   user  system elapsed
>> #  0   0   0   # this can also be 0.01 sometimes.
>>
>> enableJIT(2)  # also happens for enableJIT(3)
>> system.time(fo())
>> #   user  system elapsed
>> #   0.120.000.12
>>
>>
>> Which brings me to my *questions*:
>>
>> 1) Is this a bug or a feature?
>> 2) If this is a feature, what is causing it? (or put another way, can one
>> predict ahead of time the implications of using enableJIT(2) or
>> enableJIT(3) on his code?)
>>
>>
>> *Links*:
>>
>> A post I recently wrote about my exploration of JIT -
>> www.r-statistics.com/2012/04/**speed-up-your-r-code-using-a-**
>> just-in-time-jit-compiler/<http://www.r-statistics.com/2012/04/speed-up-your-r-code-using-a-just-in-time-jit-compiler/>
>> The question asked on SO regarding the limitations of JIT:
>> http://stackoverflow.com/**questions/10106736/possible-**
>> shortcomings-for-using-jit-**with-r<http://stackoverflow.com/questions/10106736/possible-shortcomings-for-using-jit-with-r>
>>
>> Thanks,
>> Tal
>>
>>
>>
>> Contact
>> Details:--**--**---
>> Contact me: tal.gal...@gmail.com |  972-52-7275845
>> Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
>> www.r-statistics.com (English)
>> --**--**
>> --**
>>
>>[[alternative HTML version deleted]]
>>
>> __**
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/**listinfo/r-help<https://stat.ethz.ch/mailman/listinfo/r-help>
>> PLEASE do read the posting guide http://www.R-project.org/**
>> posting-guide.html <http://www.R-project.org/posting-guide.html>
>> and provide commented, minimal, self-contained, reproducible code.
>>
>>
> --
> Luke Tierney
> Chair, Statistics and Actuarial Science
> Ralph E. Wareham Professor of Mathematical Sciences
> University of Iowa  Phone: 319-335-3386
> Department of Statistics andFax:   319-335-3017
>   Actuarial Science
> 241 Schaeffer Hall  email:   luke-tier...@uiowa.edu
> Iowa City, IA 52242 WWW:  http://www.stat.uiowa.edu
>

[[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] enableJIT(2) causes major slow-up in rpart

2012-04-12 Thread Tal Galili
Hello,

Due to exploration of the JIT capabilities offered through the {compiler}
package, I came by the fact that using enableJIT(2) can *slow* the rpart
function (from the {rpart} package) by a magnitude of about 10 times.

Here is an example code to run:

library(rpart)
require(compiler)

enableJIT(0) # just making sure that JIT is off # We could also use
enableJIT(1) and it would be fine
fo <- function() {rpart(Kyphosis ~ Age + Number + Start, data=kyphosis)}
system.time(fo())
#   user  system elapsed
#  0   0   0   # this can also be 0.01 sometimes.

enableJIT(2)  # also happens for enableJIT(3)
system.time(fo())
#   user  system elapsed
#   0.120.000.12


Which brings me to my *questions*:
1) Is this a bug or a feature?
2) If this is a feature, what is causing it? (or put another way, can one
predict ahead of time the implications of using enableJIT(2) or
enableJIT(3) on his code?)


*Links*:
A post I recently wrote about my exploration of JIT -
www.r-statistics.com/2012/04/speed-up-your-r-code-using-a-just-in-time-jit-compiler/
The question asked on SO regarding the limitations of JIT:
http://stackoverflow.com/questions/10106736/possible-shortcomings-for-using-jit-with-r

Thanks,
Tal



Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--

[[alternative HTML version deleted]]

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


Re: [R] Recode Variable

2012-04-12 Thread Tal Galili
Hi David,
You bring up a good question.  I am not sure what is the "right" way to
solve it.  But here is a simple solution I put together:

x = c(1:10,5)
y = x
x[c(2,3)] <- NA

# reproducing the problem:
y[x==5]

na2F <- function(x) {
x2 <- x
x2[is.na(x)] <- F
x2
}
na2F(x==5)

# "solved"
y[na2F(x==5)]


I'd be happy to see other solutions to it.

With regards,
Tal



Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--




On Thu, Apr 12, 2012 at 12:08 PM, David Studer  wrote:

> Hello everybody,
>
> I know this is pretty basic stuff, but could anyone explain me how to
> recode a single value of a variable
> into a missing value?
>
> I used to do it like this:
>
> myData[myData$var1==5;"var1"]<-NA # recode value "5" into "NA"
>
> But the column "var1" already contains NAs, which
> results in the following error message:
>
> "missing values are not allowed in subscripted assignments of data frames"
>
> Thank you very much for any advice!
>
> 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.
>

[[alternative HTML version deleted]]

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


Re: [R] How to get the SS and MS from oneway.test?

2012-04-09 Thread Tal Galili
>From what I can see the function does not give back this information
(either in the print output or the output object structure itself).

The thing is that I have never studied the statistic used for this test, so
I am not sure how it works and if giving the SS MS is meaningful or not.
But if you want to dig in, simply write in R the command:
oneway.test

The code that seems to be relevant is near the end:
}
else {
m <- sum(w.i * m.i)/sum.w.i
STATISTIC <- sum(w.i * (m.i - m)^2)/((k - 1) * (1 + 2 *
(k - 2) * tmp))
PARAMETER <- c(k - 1, 1/(3 * tmp))
PVAL <- pf(STATISTIC, k - 1, 1/(3 * tmp), lower.tail = FALSE)
METHOD <- paste(METHOD, "(not assuming equal variances)")
}

So you could simply copy paste the full code of the function and edit it to
extract this information...







Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--




On Tue, Apr 10, 2012 at 5:16 AM, lulumecindy  wrote:

> Hello everyone:
>I'm a new member of this group.
>I have a question about "oneway.test".
>When I use "anova(lm())" to analysis the
> ANOVA,
>I can get the information about Sum Sq  and Mean
> Sq.
>(The R code and the results are as follows.)
>
>  > anova(lm(BackCalac~factor(Assay),data=Control))
> Analysis of Variance Table
> Response: BackCalac
>  Df  Sum Sq Mean Sq F valuePr(>F)
> factor(Assay)  4 270.846  67.711  56.219 1.345e-10 ***
> Residuals 20  24.088   1.204
>
>But it default the variances are the same.
>If the variances aren't equal. I need to use the
> "oneway.test" method.
>Because oneway.test has the option about
> "var.equal=F".
>Here, I have a question about "oneway.test",
>How can I get "SS", and "MS" information from
> "oneway.test"?
>My R code and the results are as follows.
>Thank you very much.  :)
>
> > oneway.test(BackCalac~factor(Assay), var.equal=T,data=Control)
>One-way analysis of means
> data:  BackCalac and factor(Assay)
> F = 56.2191, num df = 4, denom df = 20, p-value = 1.345e-10
> > oneway.test(BackCalac~factor(Assay), var.equal=F,data=Control)
>One-way analysis of means (not assuming equal variances)
> data:  BackCalac and factor(Assay)
> F = 92.8834, num df = 4.000, denom df = 9.625, p-value = 1.165e-07
>
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/How-to-get-the-SS-and-MS-from-oneway-test-tp4544417p4544417.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] Siegel-Tukey test for equal variability (code)

2012-03-11 Thread Tal Galili
Update:
The siegel Tukey code is now fixed (both on the github page, and the blog's
post):
https://github.com/talgalili/R-code-snippets/blob/master/siegel.tukey.r
http://www.r-statistics.com/2010/02/siegel-tukey-a-non-parametric-test-for-equality-in-variability-r-code/


Best,
Tal




On Sat, Mar 10, 2012 at 12:05 AM, Tal Galili  wrote:

> With coordination with the code's author (Daniel),
> The updated code has been uploaded to github here:
> https://github.com/talgalili/R-code-snippets/blob/master/siegel.tukey.r
> And also the following post was updated with the code:
>
> http://www.r-statistics.com/2010/02/siegel-tukey-a-non-parametric-test-for-equality-in-variability-r-code/
>
> I suspect that the code still needs some tweaks so it will be able to take
> care of two vectors of different lengths.
>
>
> Tal
>
> Contact
> Details:---
> Contact me: tal.gal...@gmail.com |  972-52-7275845
> Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
> www.r-statistics.com (English)
>
> --
>
>
>
>
> On Fri, Mar 9, 2012 at 11:11 PM, Daniel Malter  wrote:
>
>> #The code of rank 1 in the previous post should have read
>> #rank1<-apply(iterator1,1,function(x) x+base1)
>> #corrected code below
>>
>>
>> siegel.tukey=function(x,y,id.col=TRUE,adjust.median=F,rnd=-1,alternative="two.sided",mu=0,paired=FALSE,exact=FALSE,correct=TRUE,
>> conf.int=FALSE,conf.level=0.95){
>> if(id.col==FALSE){
>>   data=data.frame(c(x,y),rep(c(0,1),c(length(x),length(y
>>   } else {
>>data=data.frame(x,y)
>>   }
>>  names(data)=c("x","y")
>>  data=data[order(data$x),]
>>  if(rnd>-1){data$x=round(data$x,rnd)}
>>
>>  if(adjust.median==T){
>>cat("\n","Adjusting medians...","\n",sep="")
>>data$x[data$y==0]=data$x[data$y==0]-(median(data$x[data$y==0]))
>>data$x[data$y==1]=data$x[data$y==1]-(median(data$x[data$y==1]))
>>  }
>>  cat("\n","Median of group 1 = ",median(data$x[data$y==0]),"\n",sep="")
>>  cat("Median of group 2 = ",median(data$x[data$y==1]),"\n","\n",sep="")
>>  cat("Testing median differences...","\n")
>>  print(wilcox.test(data$x[data$y==0],data$x[data$y==1]))
>>
>>
>>  cat("Performing Siegel-Tukey rank transformation...","\n","\n")
>>
>> sort.x<-sort(data$x)
>> sort.id<-data$y[order(data$x)]
>>
>> data.matrix<-data.frame(sort.x,sort.id)
>>
>> base1<-c(1,4)
>> iterator1<-matrix(seq(from=1,to=length(x),by=4))-1
>> rank1<-apply(iterator1,1,function(x) x+base1)
>>
>> iterator2<-matrix(seq(from=2,to=length(x),by=4))
>> base2<-c(0,1)
>> rank2<-apply(iterator2,1,function(x) x+base2)
>>
>> #print(rank1)
>> #print(rank2)
>>
>> if(length(rank1)==length(rank2)){
>>
>>  rank<-c(rank1[1:floor(length(x)/2)],rev(rank2[1:ceiling(length(x)/2)]))
>>} else{
>>
>>  rank<-c(rank1[1:ceiling(length(x)/2)],rev(rank2[1:floor(length(x)/2)]))
>> }
>>
>>
>> unique.ranks<-tapply(rank,sort.x,mean)
>> unique.x<-as.numeric(as.character(names(unique.ranks)))
>>
>> rank.matrix<-data.frame(unique.x,unique.ranks)
>>
>> ST.matrix<-merge(data.matrix,rank.matrix,by.x="sort.x",by.y="unique.x")
>>
>> print(ST.matrix)
>>
>> cat("\n","Performing Siegel-Tukey test...","\n",sep="")
>>
>> ranks0<-ST.matrix$unique.ranks[ST.matrix$sort.id==0]
>> ranks1<-ST.matrix$unique.ranks[ST.matrix$sort.id==1]
>>
>> cat("\n","Mean rank of group 0: ",mean(ranks0),"\n",sep="")
>> cat("Mean rank of group 1: ",mean(ranks1),"\n",sep="")
>>
>>
>> print(wilcox.test(ranks0,ranks1,alternative=alternative,mu=mu,paired=paired,exact=exact,correct=correct,
>> conf.int=conf.int,conf.level=conf.level))
>> }
>>
>> Examples:
>>
>> x <- c(33, 62, 84, 85, 88, 93, 97, 4, 16, 48, 51, 66, 98)
>> id <- c(0,0,0,0,0,0,0,1,1,1,1,1,1)
>>
>> siegel.tukey(x,id,adjust.median=F,exact=T)
>>
>> x<-c(0,0,1,4,4,5,5,6,6,9,10,10)
>> id<-c(0,0,0,1,1,1,1,1,1,0,0,0)
>>
>> siegel.tukey(x,id)
>>
>> x <- c(85,

Re: [R] Siegel-Tukey test for equal variability (code)

2012-03-09 Thread Tal Galili
With coordination with the code's author (Daniel),
The updated code has been uploaded to github here:
https://github.com/talgalili/R-code-snippets/blob/master/siegel.tukey.r
And also the following post was updated with the code:
http://www.r-statistics.com/2010/02/siegel-tukey-a-non-parametric-test-for-equality-in-variability-r-code/

I suspect that the code still needs some tweaks so it will be able to take
care of two vectors of different lengths.


Tal

Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--




On Fri, Mar 9, 2012 at 11:11 PM, Daniel Malter  wrote:

> #The code of rank 1 in the previous post should have read
> #rank1<-apply(iterator1,1,function(x) x+base1)
> #corrected code below
>
>
> siegel.tukey=function(x,y,id.col=TRUE,adjust.median=F,rnd=-1,alternative="two.sided",mu=0,paired=FALSE,exact=FALSE,correct=TRUE,
> conf.int=FALSE,conf.level=0.95){
> if(id.col==FALSE){
>   data=data.frame(c(x,y),rep(c(0,1),c(length(x),length(y
>   } else {
>data=data.frame(x,y)
>   }
>  names(data)=c("x","y")
>  data=data[order(data$x),]
>  if(rnd>-1){data$x=round(data$x,rnd)}
>
>  if(adjust.median==T){
>cat("\n","Adjusting medians...","\n",sep="")
>data$x[data$y==0]=data$x[data$y==0]-(median(data$x[data$y==0]))
>data$x[data$y==1]=data$x[data$y==1]-(median(data$x[data$y==1]))
>  }
>  cat("\n","Median of group 1 = ",median(data$x[data$y==0]),"\n",sep="")
>  cat("Median of group 2 = ",median(data$x[data$y==1]),"\n","\n",sep="")
>  cat("Testing median differences...","\n")
>  print(wilcox.test(data$x[data$y==0],data$x[data$y==1]))
>
>
>  cat("Performing Siegel-Tukey rank transformation...","\n","\n")
>
> sort.x<-sort(data$x)
> sort.id<-data$y[order(data$x)]
>
> data.matrix<-data.frame(sort.x,sort.id)
>
> base1<-c(1,4)
> iterator1<-matrix(seq(from=1,to=length(x),by=4))-1
> rank1<-apply(iterator1,1,function(x) x+base1)
>
> iterator2<-matrix(seq(from=2,to=length(x),by=4))
> base2<-c(0,1)
> rank2<-apply(iterator2,1,function(x) x+base2)
>
> #print(rank1)
> #print(rank2)
>
> if(length(rank1)==length(rank2)){
>
>  rank<-c(rank1[1:floor(length(x)/2)],rev(rank2[1:ceiling(length(x)/2)]))
>} else{
>
>  rank<-c(rank1[1:ceiling(length(x)/2)],rev(rank2[1:floor(length(x)/2)]))
> }
>
>
> unique.ranks<-tapply(rank,sort.x,mean)
> unique.x<-as.numeric(as.character(names(unique.ranks)))
>
> rank.matrix<-data.frame(unique.x,unique.ranks)
>
> ST.matrix<-merge(data.matrix,rank.matrix,by.x="sort.x",by.y="unique.x")
>
> print(ST.matrix)
>
> cat("\n","Performing Siegel-Tukey test...","\n",sep="")
>
> ranks0<-ST.matrix$unique.ranks[ST.matrix$sort.id==0]
> ranks1<-ST.matrix$unique.ranks[ST.matrix$sort.id==1]
>
> cat("\n","Mean rank of group 0: ",mean(ranks0),"\n",sep="")
> cat("Mean rank of group 1: ",mean(ranks1),"\n",sep="")
>
>
> print(wilcox.test(ranks0,ranks1,alternative=alternative,mu=mu,paired=paired,exact=exact,correct=correct,
> conf.int=conf.int,conf.level=conf.level))
> }
>
> Examples:
>
> x <- c(33, 62, 84, 85, 88, 93, 97, 4, 16, 48, 51, 66, 98)
> id <- c(0,0,0,0,0,0,0,1,1,1,1,1,1)
>
> siegel.tukey(x,id,adjust.median=F,exact=T)
>
> x<-c(0,0,1,4,4,5,5,6,6,9,10,10)
> id<-c(0,0,0,1,1,1,1,1,1,0,0,0)
>
> siegel.tukey(x,id)
>
> x <- c(85,106,96, 105, 104, 108, 86)
> id<-c(0,0,1,1,1,1,1)
>
> siegel.tukey(x,id)
>
>
> x<-c(177,200,227,230,232,268,272,297,47,105,126,142,158,172,197,220,225,230,262,270)
> id<-c(rep(0,8),rep(1,12))
>
> siegel.tukey(x,id,adjust.median=T)
>
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/Siegel-Tukey-test-for-equal-variability-code-tp1565053p4460705.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] Create a list object in a loop

2012-03-09 Thread Tal Galili
Hi Aurelie,
Please give this a look:
http://www.nealgroothuis.name/introduction-to-data-types-and-objects-in-r/

And see if this resolves most, or all, of your questions...


Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--




On Fri, Mar 9, 2012 at 5:48 PM, Aurelie Cosandey Godin wrote:

> Dear all,
>
> I'm trying to create a list of point patterns ppp.object {spatstat} in a
> loop.
> My dataset looks like this:
>
>> names(OT1);head(OT1);dim(OT1)
>[1] "EID"   "latitude"  "longitude" "month" "year"  "CPUE"
>  "TSUM"
>[8] "fTSUM"
>EID latitude longitude month year CPUE TSUM fTSUM
>1   167-1-1996-1135 67.7 -61.81667 9 199600 F
>2  167-10-1996-1135 67.71667 -59.18333 9 199600 F
>3 167-100-1996-1135 67.86667 -59.410 199600 F
>4 167-101-1996-1135 67.95000 -59.5833310 199600 F
>5 167-102-1996-1135 68.1 -59.7666710 199600 F
>6 167-103-1996-1135 67.81667 -59.3833310 199600 F
>[1] 27078
>
> What I would like to do is to select data for each of my month and create
> a ppp.object.
>
>> sort(unique(OT1$month))
>[1]  7  8  9 10 11 12
>
> The following loop works and I can see each of my figures:
>
>for(i in sort(unique(OT1$month))){
>  a<-OT1[OT1$month==i,]
>  b<-ppp(a$longitude,a$latitude,marks=a$fTSUM,window=newW)
>  plot(b,main=i)
>}
>
> How can I access each of my ppp.objects? I've tried adding a list() in the
> loop command such that I can access the data but without any success... Any
> help would be much appreciated!
>
> Thank you!
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] how to see inbuilt function(cor.test) & how to get p-value from t-value(test of significance) ?

2012-03-07 Thread Tal Galili
Try:

getAnywhere(cor.test.default)





Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--




On Wed, Mar 7, 2012 at 8:36 AM, sagarnikam123 wrote:

> i can see source code of function
>
> > cor
> function (x, y = NULL, use = "everything", method = c("pearson",
>"kendall", "spearman"))
> {
>na.method <- pmatch(use, c("all.obs", "complete.obs",
> "pairwise.complete.obs",
>"everything", "na.or.complete"))
>
> -
> but for cor.test,i gives
>
> > cor.test
> function (x, ...)
> UseMethod("cor.test")
> 
> 
>
>
> -
> i want p-value calculation formula also,i have t-values(test of
> significance)
>
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/how-to-see-inbuilt-function-cor-test-how-to-get-p-value-from-t-value-test-of-significance-tp4452454p4452454.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] Non-parametric test for repeated measures and post-hoc single comparisons in R?

2012-02-19 Thread Tal Galili
The following post would not answer your question at full, but might give
some good code/information:
http://www.r-statistics.com/2010/02/post-hoc-analysis-for-friedmans-test-r-code/




Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--




On Sun, Feb 19, 2012 at 8:25 PM,  wrote:

> Some attribute x from 17 individuals was recorded repeatedly on 6 time
> points using a Likert scale with 7 distractors. Which statistical test(s)
> can I apply to check whether the changes along the 6 time points were
> significant?
>
> set.seed( 123 )
> x <- matrix( sample( 1:7, 17*6, repl=T ),
>  nrow = 17, byrow = TRUE,
>  dimnames = list(1:17, paste( 'T', 1:6, sep='' ))
> )
>
> I found the Friedman test and the Quade test for testing the overall
> hypothesis.
>
> friedman.test( x )
> quade.test( x )
>
> However, the R help files, my text books (Bortz, Lienert and Boehnke,
> 2008; Köhler, Schachtel and Voleske, 2007; both German), and the Wikipedia
> texts differ in what they propose as requirements for the tests. R says
> that data need to be unreplicated. I read 'unreplicated' as 'not-repeated',
> but is that right? If so, the example, in contrast, in friedman.test()
> appears to use indeed repeated measures. Yet, Wikipedia says the contrary
> that is to say the test is good especially if data represents repeated
> measures. The text books say either (in the same paragraph, which is very
> confusing). What is right?
>
> In addition, what would be an appropriate test for post-hoc single
> comparisons for the indication which column differs from others
> significantly?
>
> Bortz, Lienert, Boehnke (2008). Verteilungsfreie Methoden in der
> Biostatistik. Berlin: Springer
> Köhler, Schachtel, Voleske (2007). Biostatistik: Eine Einführung für
> Biologen und Agrarwissenschaftler. Berlin: Springer
>
> --
> Sascha Vieweg, saschav...@gmail.com
>
> __**
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/**listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/**
> posting-guide.html 
> and provide commented, minimal, self-contained, reproducible code.
>

[[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] Counting occurences of variables in a dataframe

2012-02-11 Thread Tal Galili
Hello Kai

This looks like a fun question.

Here is my solution, I'd be curious to see solutions by other people here.
It can also be tweaked in various ways, and easily put into a function
(actually, if you do it - please put it back online :) )
The only thing that might require some work is the rearranging of the
columns.

Cheers,
Tal



##
# Loading the functions
##
# Making sure we can source code from github
source("
http://www.r-statistics.com/wp-content/uploads/2012/01/source_https.r.txt";)
# This is based on code first discussed here:
##
http://www.r-statistics.com/2012/01/printing-nested-tables-in-r-bridging-between-the-reshape-and-tables-packages/

# Reading in the function for using merge that reserves order
source_https("
https://raw.github.com/talgalili/R-code-snippets/master/merge.data.frame.r";)




##
# Make Data
knames <-c('ab', 'aa', 'ac', 'ad', 'ab', 'ac', 'aa', 'ad','ae', 'af')
kdate <- as.Date( c('20111001', '2002', '20101001', '20100315',
'20101201', '20110105', '20101001', '20110504', '20110603', '20110201'),
format="%Y%m%d")
kdata <- data.frame (knames, kdate)
kdata$kdate <- as.character(kdata$kdate)

##
# Calculate counts
tmp <- data.frame(table(kdata$kdate))
colnames(tmp)[1] <- "kdate"
tmp[,1] <- as.character(tmp[,1])

# Based on this:
#
http://www.r-statistics.com/2012/01/merging-two-data-frame-objects-while-preserving-the-rows-order/
merge.data.frame(kdata ,tmp ,keep_order = "x")

### Solution:
 kdate knames Freq
9  2011-10-01 ab1
10 2011-11-02 aa1
2  2010-10-01 ac2
1  2010-03-15 ad1
4  2010-12-01 ab1
5  2011-01-05 ac1
3  2010-10-01 aa2
7  2011-05-04 ad1
8  2011-06-03 ae1
6  2011-02-01 af1






Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--




On Sat, Feb 11, 2012 at 8:17 PM, Kai Mx  wrote:

> Hi everybody,
> I have a large dataframe similar to this one:
> knames <-c('ab', 'aa', 'ac', 'ad', 'ab', 'ac', 'aa', 'ad','ae', 'af')
> kdate <- as.Date( c('20111001', '2002', '20101001', '20100315',
> '20101201', '20110105', '20101001', '20110504', '20110603', '20110201'),
> format="%Y%m%d")
> kdata <- data.frame (knames, kdate)
> I would like to add a new variable to the dataframe counting the
> occurrences of different values in knames in their order of appearance
> (according to the date as in indicated in kdate). The solution should be a
> variable with the values 2,2,1,1,1,2,1,2,1,1. I could do it with a loop,
> but there must be a more elegant way to this.
>
> Thanks!
>
> Best,
>
> Kai
>
>[[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] Rearanging Data

2012-02-08 Thread Tal Galili
oops, I meant:

sub <-  Claims [ Claims$Year="Y1",]



Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--




On Thu, Feb 9, 2012 at 9:53 AM, Tal Galili  wrote:

> sub <-  Claims [ Year="Y1",]

[[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] Rearanging Data

2012-02-08 Thread Tal Galili
Hi Kevin,

Try using ?dput for putting your code on the list, so people could easily
import and play with it.
I think you probably need to do this:

sub <- subset(Claims, Year="Y1")

This also should work:

sub <-  Claims [ Year="Y1",]


Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--




On Thu, Feb 9, 2012 at 4:48 AM, kevin123  wrote:

> sub <- subset(Claims, Year=Y1)
>

[[alternative HTML version deleted]]

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


Re: [R] box.cox

2012-02-07 Thread Tal Galili
I stand corrected - thank you for the clarification John.


Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--




On Tue, Feb 7, 2012 at 4:12 PM, John Fox  wrote:

> Dear Tal and Rosario,
>
> The bcPower() function in the car package computes Box-Cox power
> transformations; boxcox() in the MASS package estimates the response
> transformation parameter for the Box-Cox regression model (actually the
> profile log-likelihood for a range of variables of the parameter). The two
> functions do different things. The boxCox() function in the car package is
> a
> slight generalization of boxcox(), allowing for other families of
> transformations than the Box-Cox powers; the powerTransform() function in
> the car package is more general still, in that it will handle multivariate
> transformations, both conditional (like the Box-Cox regression model) and
> unconditional.
>
> bcPower() was named box.cox() in earlier versions of the car package,
> associated with the first edition of the R [and S-PLUS] Companion to
> Applied
> Regression. In newer versions of the package, associated with the second
> edition of the book, written with Sandy Weisberg, this and other functions
> have been renamed to remove periods in function names. The older,
> "deprecated," names of the functions are retained as a courtesy to readers
> of the first edition.
>
> Best,
>  John
>
> 
> John Fox
> Senator William McMaster
>  Professor of Social Statistics
> Department of Sociology
> McMaster University
> Hamilton, Ontario, Canada
> http://socserv.mcmaster.ca/jfox
>
>
>
> > -Original Message-
> > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> > project.org] On Behalf Of Tal Galili
> > Sent: February-07-12 2:50 AM
> > To: Rosario Garcia Gil
> > Cc: r-help@R-project.org
> > Subject: Re: [R] box.cox
> >
> > Use:
> >
> > library(MASS)
> > ?boxcox
> >
> >
> > Contact
> > Details:---
> > Contact me: tal.gal...@gmail.com |  972-52-7275845 Read me:
> > www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | www.r-
> > statistics.com (English)
> > --
> > 
> >
> >
> >
> >
> > On Tue, Feb 7, 2012 at 8:47 AM, Rosario Garcia Gil
> > wrote:
> >
> > > Hello
> > >
> > > I am using box.cox() and I get this error message:
> > >
> > > Warning message:
> > > 'box.cox' is deprecated.
> > > Use 'bcPower' instead.
> > > See help("Deprecated") and help("car-deprecated").
> > >
> > >
> > > I went to help but I did not understand the explanation, I am still
> > > wondering what is really happening.
> > >
> > > Thanks
> > > /R
> > > __
> > > R-help@r-project.org mailing list
> > > https://stat.ethz.ch/mailman/listinfo/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.
>
>

[[alternative HTML version deleted]]

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


Re: [R] box.cox

2012-02-06 Thread Tal Galili
Use:

library(MASS)
?boxcox


Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--




On Tue, Feb 7, 2012 at 8:47 AM, Rosario Garcia Gil
wrote:

> Hello
>
> I am using box.cox() and I get this error message:
>
> Warning message:
> 'box.cox' is deprecated.
> Use 'bcPower' instead.
> See help("Deprecated") and help("car-deprecated").
>
>
> I went to help but I did not understand the explanation, I am still
> wondering what is really happening.
>
> Thanks
> /R
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Suggestion for "drop the loser" design and analysis in R?

2012-02-06 Thread Tal Galili
Hello all,

I would like to plan and analyse a study with "k" treatments (one of which
is a "control"), with some binary outcome, in order to find the "best"
treatment (e.g: the one with a high number of "successes").
If this was done with a fixed sample size, the analysis is well known.
 However, I would rather be able to "drop" treatment(s), if at any (or some
specific) point in the analysis, I find it (or them) inferior to the
control.

*What correction/analysis might I use in order to find the "best
treatment", while dropping "bad treatments" during the experiment?*

After searching through google scholar, the most relevant article I found
was "Drop-the-losers design: Binomial case" by Michael W. Sill , Allan R.
Sampson -
yet I was not able to find an implementation for their ideas.

Thanks up front for any lead/idea on this topic.


(p.s: this question was also cross-posted to
http://stats.stackexchange.com/questions/22355/suggestion-for-drop-the-loser-design-and-analysis-in-r
)

With regards,
Tal

Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--

[[alternative HTML version deleted]]

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


Re: [R] how to avoid writing index in write.table command

2012-02-05 Thread Tal Galili
write.table(..., row.names = FALSE)
(not row.name )



Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--




On Sun, Feb 5, 2012 at 9:53 AM, sagarnikam123 wrote:

> how to avoid writing index of variable in write.table command,
> e.g. output--->
>
> index,character,state
> "1" "M" "2"
> "2" "K" "3"
> "3" "R" "1"
> "4" "E" "1"
> "5" "S" "1"
> "6" "H" "1"
> "7" "K" "1"
> "8" "H" "1"
> "9" "A" "1"
> "10" "E" "3"
> "11" "Q" "1"
>
> i tried col.name=FALSE & row.name=FALSE but it can't
>
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/how-to-avoid-writing-index-in-write-table-command-tp4358557p4358557.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] Problem with xtable- rescaling a table

2012-02-05 Thread Tal Galili
Dear Ista,

Do you happen to know of a way to use the {tabularx} LaTeX pacakge, so to
have it work with xtables?

I would rather have my columns adjust themselves then to rotate my table.

Thank you in advance,
Tal




Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--




On Sat, Feb 4, 2012 at 10:46 PM, Ista Zahn  wrote:

> Hi Aurelien,
>
> You just need to put the \caption outside the scalebox command, like this:
>
>  \documentclass[11pt]{report}
> \usepackage{rotating}
>  %\usepackage[counterclockwise]{rotating}
> \usepackage{graphics}
> \usepackage{float}
>
>
> \pagestyle{empty}
>
>
> \begin{document}
> \begin{sidewaystable}[ht]
> \centering
> \scalebox{0.7}{
>
> % latex table generated in R 2.13.1 by xtable 1.6-0 package
> % Wed Feb  1 10:29:25 2012
> \begin{tabular}{ccc}
>  \hline
>  & V1 & V2 \\
>  \hline
>  &  &  \\
>  6.91 & 500.00 & 4.00 \\
>  400.00 &  & 400.00 \\
>   \hline
> \end{tabular}
> }
> \caption{Title}
> \end{sidewaystable}
> \end{document}
>
> Best,
> Ista
>
>
>
> On Wednesday, February 01, 2012 10:37:47 AM Aurélien PHILIPPOT wrote:
>
> Thanks Ista.
> Your suggestion works.
> When I make the option floating=F, the caption no longer appears in the Tex
> code generated by xtable. If I had \caption {Title} in the code, it does
> not
> seem to work.
>  \documentclass[11pt]{report}
> \usepackage{rotating}
>  %\usepackage[counterclockwise]{rotating}
> \usepackage{graphics}
> \usepackage{float}
>
>
> \pagestyle{empty}
>
>
> \begin{document}
> \begin{sidewaystable}[ht]
> \scalebox{0.7}{
>
>
> % latex table generated in R 2.13.1 by xtable 1.6-0 package
> % Wed Feb  1 10:29:25 2012
> \begin{tabular}{ccc}
>  \hline
>  & V1 & V2 \\
>  \hline
>  &  &  \\
>  6.91 & 500.00 & 4.00 \\
>  400.00 &  & 400.00 \\
>   \hline
> \end{tabular}
> \caption{Title}
> }
> \end{sidewaystable}
> \end{document}
>
>
> So, I am faced with a dilemma. If I use the code from my previous email, I
> could have the landscape and the title work, but if I incorporate scalebox
> in
> Latex it does not work. If I use the floating=F solution, I can rescale and
> landscape, but I have troubles having a caption. That's weird.
>
>
> Best,
> Aurelien
>
>
>
>
>
>
> 2012/2/1 Ista Zahn 
> Hi,
>
> It looks like you need scalebox inside the sidewaystable environment. If
> you
> must use scalebox, one solution is to use floating=FALSE when you call
> print.xtable, and insert the table environment directly in LaTeX, like
> this:
>
> \begin{sidewaystable}[ht]
> \scalebox{0.7}{
> <>=
> print(outfile, include.rownames=F, floating = FALSE)
> @
> }
> \end{sidewaystable}
>
> Alternatively, since the size of the table is determined by the size of the
> text in the table, you can just tell LaTeX to use a smaller font, e.g.
>
> <>=
> print(outfile, include.rownames=F, floating.environment='sidewaystable',
> size
> = "scriptsize")
> @
>
> Best,
> Ista
>
>
> On Tuesday, January 31, 2012 11:41:27 PM Aurélien PHILIPPOT wrote:
> > Dear R users,
> > I am new to Latex and I am using the R package xtable to generate tables.
> > I want to produce a table that is very long.  in the landscape format,
> but
> > I would need to rescale the table so that it fits in the page. xtable
> > enables me to have the landscape format, but I cannot rescale it, and
> there
> > seems to be a problem, if I use scalebox in Latex on my output produced
> > with stable and the option sidewaystable. Do you know any way to achieve
> > this result with xtable or another R package?
> >
> > Let's look at the following example:
> > In R, I use the following code
> >
> > ##
> > outfile<- matrix(nrow=3, ncol=3)
> > outfile[2,1]<- 6.912
> > outfile[3,1]<- 400
> > outfile[2,2]<- 8.9722
> > outfile[2,2]<- 500
> > outfile[2,3]<- 4.00
> > outfile[3,3]<- 400
> >
> >
> >
> > library(xtable)
> > outfile<- data.frame(outfile)
> > colnames(outfile)<- c(" ","V1", "V2")
> >
> > outfile<- xtable(outfile, caption= "Title", include.rownames=F,
> > align=rep("c", 4), digit=2)
> > print(outfile, include.rownames=F, floating.environment='sidewaystable')
> > 
> >
> > I was wondering if it is possible to rescale in Latex when  the code was
> > generated through xtable.  Indeed, when I run the latex table obtained
> from
> > xtable, and use scale box, it does not work (and the problem comes from
> > scalebox, which works otherwise).
> >
> > \documentclass[11pt]{report}
> >
> > \usepackage{rotating}
> >
> >  %\usepackage[counterclockwise]{rotating}
> >
> > \usepackage{graphics}
> >
> > \usepackage{float}
> >
> >
> > \pagestyle{empty}
> >
> >
> > \begin{document}
> >
> > \scalebox{0.70} { %resize
> >
> >
> > % latex table generated in R 2.13.1 by xtable 1.6-0 package
> >
> > % Tue Jan 31 23:26:10 201

[R] Using {tabularx} latex package with the {xtable} package?

2012-02-03 Thread Tal Galili
I am trying to solve the problem of having a latex table (produced using
the xtable , then
inserted to a latex file using Sweave), exceeding the margins of my LaTeX
document.

I found that one such solution can be based on the
tabularx package,
and I am wondering what would be the best way to implement it (or if there
is a better solution I am overlooking).

Right now the only way I am thinking of is to edit print.xtable so it would
work with the tabularx LaTeX package. Any other suggestions would be most
welcomed.

Thanks.

Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--

[[alternative HTML version deleted]]

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


Re: [R] question of merging two dataframes

2012-01-31 Thread Tal Galili
Hi there,
The command for merging is:
merge

Can you please clarify by which variable you wish to merge by?
Can you maybe use ?dput function in order to give a self contained R code
example of your data - and the output you wish to get?


Best,
Tal



Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--




On Tue, Jan 31, 2012 at 8:51 PM, freezhu8  wrote:

> Suppose I have two data frames A and B
> A has three variables and B also has three variables.
> I would like to merge these two database but the requirement to merge
> is that the value of the second column in database A is less than the
> value of the second column in database B. Is there a R code to do
> this? Thanks
>
> Dataframe A:   V1a   V2a   V3a
>   1  2  3 5
>   2  3  4 6
>   3
> Dataframe B:   V1b  V2b V3b
>  1  2   5  9
>  2  9   2  7
> Dataframe C should be:   V1a   V2a  V3a  V1b   V2b   V3b
> 1  23  5  2   5   9
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/question-of-merging-two-dataframes-tp4345469p4345469.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] Generate data - function

2012-01-31 Thread Tal Galili
Hi Val

Look at the help file for
?curve
To get the plot.

You also need to decide what relevant function will fit the graphs you need.
Without knowing what your purpose is, I can not help you on that.




Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--




On Tue, Jan 31, 2012 at 5:03 PM, Val  wrote:

> Hi All,
>
> I want generate data using R that follows the shape of graphs (A and B) in
> the attached file.  Can anybody suggest me what function fits for each
> graph?
>
> Your help is highly appreciated in advance
> Val
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Getting htmlParse to work with Hebrew? (on windows)

2012-01-30 Thread Tal Galili
Hello dear R-help mailing list.



I wish to be able to have htmlParse work well with Hebrew, but it keeps to
scramble the Hebrew text in pages I feed into it.

For example:

# why can't I parse the Hebrew correctly?

library(RCurl)
library(XML)
u = "http://humus101.com/?p=2737";
a = getURL(u)
a # Here - the hebrew is fine.
a2 <- htmlParse(a)
a2 # Here it is a mess...

None of these seem to fix it:

htmlParse(a, encoding = "utf-8")

htmlParse(a, encoding = "iso8859-8")

This is my locale:

> Sys.getlocale()

[1] 
"LC_COLLATE=Hebrew_Israel.1255;LC_CTYPE=Hebrew_Israel.1255;LC_MONETARY=Hebrew_Israel.1255;LC_NUMERIC=C;LC_TIME=Hebrew_Israel.1255"
>

Any suggestions?


Thanks up front,
Tal



Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--

[[alternative HTML version deleted]]

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


Re: [R] nice report generator?

2012-01-30 Thread Tal Galili
Helloe dear Duncan, Gabor, Michael and others,

After taking some time, I wrote a bridge function between a "cast_df"
object from the {reshape} package into a table in Duncan's new {tables}
package.

The motivation was to make "cast_df" table prettier in the R terminal, as
well as allow us to export a pretty version of the table to latex (using
Hmisc::latex, on the output of tabular.cast_df)

The code is now available on:
http://www.r-statistics.com/2012/01/printing-nested-tables-in-r-bridging-between-the-reshape-and-tables-packages/

I would be happy for any input/revisions/suggestions from you.

With regards,
Tal



Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--




On Thu, Dec 8, 2011 at 8:37 PM, Tal Galili  wrote:

> reasonably

[[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] help with Box plot

2012-01-27 Thread Tal Galili
Hi Gianni,

Have a look at this function:
http://hosho.ees.hokudai.ac.jp/~kubo/Rdoc/library/gplots/html/plotCI.html

And please also read this:
http://en.wikipedia.org/wiki/Box_plot
So to know how a boxplot is constructed...



Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--




On Fri, Jan 27, 2012 at 4:47 PM, gianni lavaredo
wrote:

> Dear researchers
>
> I wish to plot a box plot without the mean line (the black line) and the i
> wish a full line for the standard deviation
>
> This is an example
>
> mytest <-
> c(2.1,2.6,2.7,3.2,4.1,4.3,5.2,5.1,4.8,1.8,1.4,2.5,2.7,3.1,2.6,2.8)
> boxplot(mytest)
>
>
> really thanks
>
> Gianni
>
>[[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] Why was the ‘doSMP’ package removed from CRAN?

2012-01-26 Thread Tal Galili
Thank you for the explanation Uwe.

With regards,
Tal


Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--




On Thu, Jan 26, 2012 at 10:42 AM, Uwe Ligges <
lig...@statistik.tu-dortmund.de> wrote:

>
>
> On 26.01.2012 09:39, Barry Rowlingson wrote:
>
>> On Thu, Jan 26, 2012 at 8:02 AM, Uwe Ligges
>> >
>>  wrote:
>>
>>>
>>>
>>> On 25.01.2012 22:20, Tal Galili wrote:
>>>
>>
>>  Does any one know the reason for this?
>>>> Is this a technical or a legal (e.g: license) issue?
>>>>
>>>
>>>
>>>
>>> If legal issues were the reason, you had not found it in the archives
>>> anymore.
>>>
>>>
>>  Licensing can change - as a copyright holder I could decide the next
>> release of my package is going to be under a proprietary license that
>> doesn't allow redistribution. Any code already released under
>> something like the GPL can't be forcibly removed, and people can make
>> new forks from those, but if I'm the only person writing it and I
>> decide to change the license and the latest free version isn't
>> compatible with the current version of R then I'd expect to see the
>> old versions in the archives and no version for the latest version of
>> R.
>>
>>  Last checkin at R-forge was only six weeks ago, and 1.0-3 installs
>> fine on my latest R:
>>
>>  
>> https://r-forge.r-project.org/**scm/?group_id=950<https://r-forge.r-project.org/scm/?group_id=950>
>>
>> I suspect they just haven't pushed it to R-forge yet. Cockup before
>> conspiracy.
>>
>> Barry
>>
>
> Before people start with even more speculations: Reason is that the
> revoIPC package does no compile on modern versions of gcc and hence has
> been archived, doSMP depends on it and therefore went to the archives as
> well.
>
> Uwe Ligges
>

[[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] Why was the ‘doSMP’ package removed from CRAN?

2012-01-25 Thread Tal Galili
Hello dear list,

I just noticed that:

Package ‘doSMP’ was removed from the CRAN repository.
http://cran.r-project.org/web/packages/doSMP/index.html

Does any one know the reason for this?
Is this a technical or a legal (e.g: license) issue?


Thanks,
Tal



Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--

[[alternative HTML version deleted]]

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


Re: [R] Splitting up large set of survey data into categories

2012-01-24 Thread Tal Galili
Hi andreas,
Please give a sample of your data, and how you want it to be after the
manipulation.
Consider using
?dput



Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--




On Tue, Jan 24, 2012 at 11:54 AM, ak13  wrote:

> Hi,
>
> I am a total newbie to R so I apologize if the answer to my question is too
> obvious.  I a data set of the following form:
>
>
>
>
>
>Date
>V1
>V...
>VN
>Region
>Industry
>
>
>
>22/03/1995 23:01:12
>1
>3
>2
>15
>A
>
>
>
>21/03/1995 21:01:12
>3
>3
>1
>9
>C
>
>
>
>1/04/1995 17:01:06
>3
>2
>1
>3
>B
>
>
>
> Now I would like to analyze the data in the data.frame by Region, Industry,
> Date (I would like to collapse the whole think to weekly data) and by the
> three different answering options {1,2,3} in V1...VN. In stata which I used
> before i did this step by step with a loop over all questions (V1...VN):
> egen pos_`X'=total(`X'==1), by(industry week_year); egen
> pos_`X'=total(`X'==2, by(industry week_year). This step-by-step procedure
> works because stata, even if the dates are displayed as weeks, doesn't
> aggregate the values immediately. Unfortunately there seems to be no
> command
> which works exactly in the same manner as by() (from stata) in R. My by now
> most successful attempt accomplish the above described task was by using:
>
> as.data.frame(tapply(euwifo[,1]=1, list(df$date, df$region, df$industry),
> mean))
>
> (where date is formatted as ISO-weekly %U)
> Of course I would have to loop this over all questions (20) and all
> answering possibilities (3) but at least it gives me an out put of the
> structure:
>
>
>
>
>
> .
>industry.region
>Industry.region
>industry.region
>industry.region
>
>
>
> 10-1995
>32
>45
>10
>9
>
>
>
> 15-1995
>2
>47
>5
>6
>
>
>
> I could live with that because I could recombine the so created different
> dataframes thenafter. My problem however is tapply doesn't preserve the
> dataframe's format as a time series (xts). This means R aggregates by time
> (week) (and industry and region) but the weeks on the x-axis are not in the
> right order. I also tried to apply.weekly() but this doesn't seem to do
> what
> I want to do.
>
> Could anyone give me a hint how i could to this? Maybe with formatting the
> data frame as time series data beforehand with preserving this during that
> procedure. And maybe somebody also has an idea how I can maybe avoid all
> this looping.
>
> I would appreciate it very much much if somebody of you could give me a
> hint!
>
> Best regards,
>
> Andreas
>
>
>
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/Splitting-up-large-set-of-survey-data-into-categories-tp4323327p4323327.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.
>

[[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] debug package: mtrace fails

2012-01-24 Thread Tal Galili
Hi Deivit,
Can you offer a self contained example of r code when the function fails
for you?


Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--




On Tue, Jan 24, 2012 at 1:40 PM, deivit  wrote:

> Hi all,
>
> Since three month ago I started working with R professionally, I never did
> it before, so I am such a newbie.
> I am having some problems using the 'debug' package. I love this package,
> but most of the times I wanna use it it just fails :P
>
> When typing at prompt 'mtrace(myfunct)' most of the times I get the
> following error:
> "Error in x[[i]] : subscript out of bounds"
>
> I can't understand whats happening and I couldn't find any help surfing the
> net. I have the feeling it might be because of my coding style or something
> similar.
>
> Any help will be highly appreciated :)
>
> Thanks in advance!
> see ya
>
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/debug-package-mtrace-fails-tp4323546p4323546.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] cacheSweave questions (usage and forward compatibility)

2012-01-19 Thread Tal Galili
Hello all,

I would like to ask several questions regarding cacheSweave:
1) Is there a way to set "cache=true" globally? (I tried it
using \SweaveOpts but it didn't seem to work)
 2) Is there a way to "flush" specific cache once it is created? (other
then erasing the entire cache directory)?  Changing the code in the code
chunk seems to do it, but I am not sure to what extent.  For example - if I
add at the end of the code chunk a number (say 1 - that will be printed),
it will reevaluate the code chunk.  However, if I remove that number, it
will not re-evaluate the code chunk.
3) To what extent does cacheSweave rely on Sweave? For example: I see that
the latest Sweave document is from October 31, 2011 while the latest update
to cacheSweave is from 2011-07-23.  Does that mean that there are new
features or bug fixes that are introduced to Sweave which are not available
through cacheSweave?  (from the manual it says that cacheSweave is based on
the code version of R 2.5.0.  What does that mean in terms of
features/bugs?)

Thank you for your help,
Tal







Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--

[[alternative HTML version deleted]]

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


Re: [R] Sweave question - Setting Soutput code chunks to stay inside page margins?

2012-01-19 Thread Tal Galili
Hi Yihui,
The "a's" case happens when, for example, one prints some long equation
function without using spaces in it.  It happened to me in something I
wrote which I will write now while including spaces if I had known it would
solve the issue, but I have yet to have found one (for Sweave, that is :)  )

BTW - I will play with knitr as some point, but I am still looking for
solution within my current toolset.


Tal




Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--




On Thu, Jan 19, 2012 at 10:47 AM, Yihui Xie  wrote:

> s such an extreme case that is unlikely
> to happen in real life. As long as y
>

[[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] Sweave question - Setting Soutput code chunks to stay inside page margins?

2012-01-19 Thread Tal Galili
Hello all,

Sometimes I get to make an R code chunk (in Sweave) which is longer then
the margins of the page. Is there a way to force it to "go to the next
line" (in Sweave) once that happens?

Here are two cases this happens in the resulting .tex file (one is a "hard"
case, and the other is simpler)

\begin{Schunk}
\begin{Sinput}

> print("aa")
\end{Sinput}
\begin{Soutput}
[1] 
"aa"
\end{Soutput}
\end{Schunk}


\begin{Schunk}
\begin{Soutput}

Some Table

Model 1: SCIM_2_total ~ (I(AMS_2_total^3) + I(AMS_2_total^2) +
AMS_2_total) + fox

Model 2: SCIM_2_total ~ (I(AMS_2_total^2) + AMS_2_total) + fox

\end{Soutput}
\end{Schunk}


I understand this can be "fixed" from the r side by doing something that
will break lines for outputs, but that will require me to go through any
relevant print command and modify it (I rather find a global solution,
naturally...)


Thanks,
Tal



Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--

[[alternative HTML version deleted]]

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


Re: [R] visualization for k-mean clustering

2012-01-18 Thread Tal Galili
Hi Mukul,
If you are talking about the steps of the algorithm, then Yihui answered
your question..
If you are looking for visualizing the resulting clusters, there is the
clustergram function:
http://www.r-statistics.com/2010/06/clustergram-visualization-and-diagnostics-for-cluster-analysis-r-code/




Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--




On Tue, Jan 17, 2012 at 5:21 PM, Yihui Xie  wrote:

> You mean the process of clustering (the algorithm)? Have you looked at
> kmeans.ani() in the animation package?
>
> Regards,
> Yihui
> --
> Yihui Xie 
> Phone: 515-294-2465 Web: http://yihui.name
> Department of Statistics, Iowa State University
> 2215 Snedecor Hall, Ames, IA
>
>
>
> On Tue, Jan 17, 2012 at 2:48 AM, mukul purva 
> wrote:
> > hello,
> > i want a visualization of the k-mean clustering.which one method
> > will be best for visualization??
> >
> >
> >
> > thnkx
> >
> >[[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.
>

[[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] Reshape with multiple aggregation functions

2012-01-18 Thread Tal Galili
This sounds like a job for the melt/cast scheme for the reshape package.
There is a tutorial for using it here:
http://www.r-statistics.com/2012/01/aggregation-and-restructuring-data-from-r-in-action/

Good luck,
Tal


Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--




On Wed, Jan 18, 2012 at 11:21 AM, dimitris fekas  wrote:

> I have a data frame and I would like to reshape it to wide format while at
> the same time applying different aggregate functions to each column AND at
> times multiple aggregate functions:
>
> test1 = data.frame(
> id = c(rep('101',8),rep('102',8)),
> phase  = rep(c('D','D','L','L'),4),
> day = rep(c('1','1','1','1','2','2','2','2'),2),
> col1 = c(rep(1,8),rep(2,8)),
> col2 = c(runif(8,min=0,max=1),runif(8,min=0,max=10))
> )
>
> In this example, I would like to end up with 2 rows (for the 2 ids) and
> different columns for phase-day. Values of col1
> should just be summed and for col 2 there should be a column with the
> mean AND one with standard deviation for each phase-day combination.
>
> Obviously the real data have much more number of columns therefore I guess
> I will need to provide a list of functions?
>
> Thank you in advance!
>
>[[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] R for Windows: Is there a function/package that enables Win32 API Calls?

2012-01-16 Thread Tal Galili
Wouldn't that be possbile to do through the
?system
function?


Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--




On Mon, Jan 16, 2012 at 9:45 PM, Ajay Askoolum  wrote:

> I am looking for a means to call Win32 API calls from R for Windows. Is
> that possible?
>
> Thanks.
>
>[[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


Re: [R] kruskal wallis post hoc?

2012-01-12 Thread Tal Galili
Hi Iasonas ,
This is a stat question and not an R question.
But the general answer is that it could happen :)

The R question would have been if their is a Tukey HSD for kruskel.test,
the answer is yes:
http://stats.stackexchange.com/questions/17342/is-there-a-nonparametric-equivalent-of-tukey-hsd
But if you didn't get any significant result from the pairwise comparison,
I would say that the post hoc correction wouldn't help you (it could be
that the reason for this significance is based on some weird contrast...)

Best,
Tal





Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--




On Thu, Jan 12, 2012 at 8:35 AM, Iasonas Lamprianou wrote:

> Dear all,
>
> I run a kruskal wallis test and found significant results. Then, I
> conducted all pairwise comparisons and found no significant results. Could
> anyone please give me a hint as to why this happens or redirect me towards
> a specific web page where I can find more info? (I used alpha=5% and made
> no bonferroni or other correction for the pairwise comparisons)
> Thank you
>
>
> Dr. Iasonas Lamprianou
> Department of Social and Political Sciences
> University of Cyprus
>[[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] plot rq lm

2012-01-06 Thread Tal Galili
I asked a while ago what diagnostic plots exists for quantile regression,
here:
http://stats.stackexchange.com/questions/19291/what-diagnostic-plots-exists-for-quantile-regression
And had received no answer.

I hope some more information will become available regarding this.

Best,
Tal



Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--




On Wed, Jan 4, 2012 at 7:52 PM, agent dunham  wrote:

> Dear Community,
>
> I'd like to plot an rq object the same way I do with a lm one, is it
> possible? Something like this
>
> plot(rqmodel , 1:4, id.labels=rownames(pga1)); where
>
> rqmodel <- rq(log(vd) ~ v1 + log(v2) +log(v3) + v4 + v5 ,data =dat)
>
>
> Thanks in advance and apologies, I'm pretty newbie with this,
> u...@host.com
>
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/plot-rq-lm-tp4262170p4262170.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] Is it possible to "right align" text in R graphics?

2012-01-03 Thread Tal Galili
And I forgot to include the link to the image, here it is:

http://dl.dropbox.com/u/5371432/right-to-left-text%20example%202.png






On Wed, Jan 4, 2012 at 12:30 AM, Tal Galili  wrote:

> Thanks to an e-mail from David, I realized that non-Hebrew speakers will
> not be able to know how a proper right-to-left output should look like
> (sorry for not thinking about it myself...)
>
> Here is some example code of how the output should look like vs how it
> currently looks.
> This is shown only for the main parameter, but the same issue will come up
> when using ?title or ?text
>
> Two points to mention again:
> 1) This is not a huge problem for me personally, but I believe that in the
> long term, if such an issue can be fixed, it would have been nice.  It will
> allow all of the right-to-left languages to use R for plotting in their own
> language (That included, for example, all of the Arabic world...
> http://en.wikipedia.org/wiki/Right-to-left ).
> 2) I fear that this type of issue needs to be handled by someone familiar
> with the guts of the R graphics code.  I am not even sure if I should post
> this here or on the R-devel mailing list.  Your advise will be very welcome.
>
>
> Here is the example code:
>
> par(mfrow = c(1,2))
> plot(1:10, main = "שלום (טקסט)", sub = "The order of text is not 
> right to
> left")
> plot(1:10, main = "(שלום (טקסט", sub = "This is how the output should 
> have
> looked like")
>
> # A more complex example:
> plot(1:10, main = "שלום (טקסט) מידע על Subject 1", sub = "The 
> order of
> text is not right to left")
> plot(1:10, main = " Subject 1 שלום (טקסט) מידע על", sub = "This 
> is how the
> output should have looked like")
>
> # An even more complex example:
> par(mfrow = c(1,1))
> plot(1:10, main = "שלום (טקסט) מידע על Subject 1 וגם קצת 
> מידע על subject
> 2", sub = "The order of text is not right to left")
> # I am not sure how to fix this actually...
>
>
> Happy new year,
> Tal
>
>
> Contact
> Details:---
> Contact me: tal.gal...@gmail.com |  972-52-7275845
> Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
> www.r-statistics.com (English)
>
> --
>
>
>
>
> On Thu, Dec 29, 2011 at 6:52 PM, Tal Galili  wrote:
>
>> Hello all,
>>
>> The following line of code includes a right-to-left language text, yet
>> the R graphics engine displays it from left to right.  One problem this
>> causes is when there are parenthesis in the test, here is a basic example?
>>
>> plot(1:10, main = "שלום (טקסט)")
>>
>> Is there a way to make sure the text is displayed from right to left?
>>
>> Many thanks for any suggestions,
>> Tal
>>
>>
>> Contact
>> Details:---
>> Contact me: tal.gal...@gmail.com |  972-52-7275845
>> Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
>> www.r-statistics.com (English)
>>
>> --
>>
>>
>>
>

[[alternative HTML version deleted]]

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


Re: [R] Is it possible to "right align" text in R graphics?

2012-01-03 Thread Tal Galili
Thanks to an e-mail from David, I realized that non-Hebrew speakers will
not be able to know how a proper right-to-left output should look like
(sorry for not thinking about it myself...)

Here is some example code of how the output should look like vs how it
currently looks.
This is shown only for the main parameter, but the same issue will come up
when using ?title or ?text

Two points to mention again:
1) This is not a huge problem for me personally, but I believe that in the
long term, if such an issue can be fixed, it would have been nice.  It will
allow all of the right-to-left languages to use R for plotting in their own
language (That included, for example, all of the Arabic world...
http://en.wikipedia.org/wiki/Right-to-left ).
2) I fear that this type of issue needs to be handled by someone familiar
with the guts of the R graphics code.  I am not even sure if I should post
this here or on the R-devel mailing list.  Your advise will be very welcome.


Here is the example code:

par(mfrow = c(1,2))
plot(1:10, main = "שלום (טקסט)", sub = "The order of text is not right 
to
left")
plot(1:10, main = "(שלום (טקסט", sub = "This is how the output should 
have
looked like")

# A more complex example:
plot(1:10, main = "שלום (טקסט) מידע על Subject 1", sub = "The 
order of text
is not right to left")
plot(1:10, main = " Subject 1 שלום (טקסט) מידע על", sub = "This 
is how the
output should have looked like")

# An even more complex example:
par(mfrow = c(1,1))
plot(1:10, main = "שלום (טקסט) מידע על Subject 1 וגם קצת 
מידע על subject
2", sub = "The order of text is not right to left")
# I am not sure how to fix this actually...


Happy new year,
Tal


Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
------




On Thu, Dec 29, 2011 at 6:52 PM, Tal Galili  wrote:

> Hello all,
>
> The following line of code includes a right-to-left language text, yet the
> R graphics engine displays it from left to right.  One problem this causes
> is when there are parenthesis in the test, here is a basic example?
>
> plot(1:10, main = "שלום (טקסט)")
>
> Is there a way to make sure the text is displayed from right to left?
>
> Many thanks for any suggestions,
> Tal
>
>
> Contact
> Details:---
> Contact me: tal.gal...@gmail.com |  972-52-7275845
> Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
> www.r-statistics.com (English)
>
> --
>
>
>

[[alternative HTML version deleted]]

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


Re: [R] Is it possible to "right align" text in R graphics?

2012-01-03 Thread Tal Galili
Hello Majid,
When you say the text renders correctly on one but not the other, you mean
the fonts, or the directionality?



Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--




On Tue, Jan 3, 2012 at 8:14 AM, Majid Einian  wrote:

>
> Incidentally, gMail (on Windows) correctly rendered the Hebrew
>> ("Shalom Olam"), so it would seem that this probably is a plotting
>> issue rather than an OS issue
>
>
> I  tested a Persian text with this kind of parentheses in linux and
> windows, and it seem it is indeed an OS issue. The text renders correct on
> my linux 2.6.32 i686 system with R 2.14.1 but incorrect on my  windows 7
> (6.1.7600) 32 bit system with R 2.14.0.
> --
> Majid Einian,
> PhD Candidate in "Economics",
> Graduate School of Management and Economics,
> Sharif University of Technology,
> Tehran, IRAN
>
>

[[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 it possible to "right align" text in R graphics?

2012-01-01 Thread Tal Galili
Hi Duncan,
Thank you for your reply.
I am also using Win 7.
And I would be surprised if this would be different in any OS.

I guess the answer is that there is no way for making text in a graph in R
be "right-to-left".

Thanks again, and happy new year,
Tal


Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--




On Sun, Jan 1, 2012 at 5:34 AM, Duncan Mackay wrote:

> Hi Tal
>
> I think it might be an OS problem whether it is a graphics as well I do
> not know.
>
> I Just copied and pasted the line into R and it seems ok
>
> OS win 7
> version
> platform   i386-pc-mingw32
> arch   i386
> os mingw32
> system i386, mingw32
> status
> major  2
> minor  14.1
> year   2011
> month  12
> day22
> svn rev57956
> language   R
> version.string R version 2.14.1 (2011-12-22)
>
> Regards
>
> Regards
>
> Duncan Mackay
> Department of Agronomy and Soil Science
> University of New England
> ARMIDALE NSW 2351
> Email: home mac...@northnet.com.au
>
>
> At 02:52 30/12/2011, you wrote:
>
>> Content-Type: text/plain
>> Content-Disposition: inline
>> Content-length: 796
>>
>>
>> Hello all,
>>
>> The following line of code includes a right-to-left language text, yet the
>> R graphics engine displays it from left to right.  One problem this causes
>> is when there are parenthesis in the test, here is a basic example?
>>
>> plot(1:10, main = "×©×œ×•×  (טקסט)")
>>
>>
>> Is there a way to make sure the text is displayed from right to left?
>>
>> Many thanks for any suggestions,
>> Tal
>>
>>
>> Contact
>> Details:--**--**---
>> Contact me: tal.gal...@gmail.com |  972-52-7275845
>> Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
>> www.r-statistics.com (English)
>> --**--**
>> --**
>>
>>[[alternative HTML version deleted]]
>>
>>
>> __**
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/**listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/**
>> posting-guide.html 
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
> __**
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/**listinfo/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 it possible to "right align" text in R graphics?

2011-12-30 Thread Tal Galili
Hi Bert,
Thank you for the idea - but this will only move the text to different
sides of the text...

Right-to-left languages are a known issue in open source projects
(libreoffice, WordPress, etc...)

Any advice on who should I contact regarding this?
(Not that it is urgent for me, but long term - this is a relevant feature
for using R for non English outputs)


Happy new year everyone,
Tal


Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--




On Fri, Dec 30, 2011 at 12:48 AM, Bert Gunter wrote:

> Tal:
>
> Does the "adj" argument for ?par (and also in text()) not do this for you?
>
> Incidentally, gMail (on Windows) correctly rendered the Hebrew
> ("Shalom Olam"), so it would seem that this probably is a plotting
> issue rather than an OS issue. However, I confess that my knees turn
> to jelly with discussions of locales and non-"standard:" fonts, so
> maybe I'm wrong about this.
>
> Cheers,
> Bert
>
> On Thu, Dec 29, 2011 at 2:18 PM, Tal Galili  wrote:
> > Thank you for the reply Jean, but no, it would not fix it :)
> >
> > plot(1:10, main=rev.string("שלום (עולם)"))
> >
> > What would "fix" it is if I had added a number after the parenthesis, but
> > that is a hack, not a solution...
> > plot(1:10, main="שלום (עולם) 1")
> >
> >
> >
> > Contact
> > Details:---
> > Contact me: tal.gal...@gmail.com |  972-52-7275845
> > Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
> > www.r-statistics.com (English)
> >
> --
> >
> >
> >
> >
> > On Fri, Dec 30, 2011 at 12:12 AM, Jean V Adams  wrote:
> >
> >>
> >> Tal Galili wrote on 12/29/2011 10:52:55 AM:
> >>
> >>
> >> > Hello all,
> >> >
> >> > The following line of code includes a right-to-left language text, yet
> >> the
> >> > R graphics engine displays it from left to right.  One problem this
> >> causes
> >> > is when there are parenthesis in the test, here is a basic example?
> >> >
> >> > plot(1:10, main = "×©×œ×•× (טקסט)")
> >>
> >> >
> >> > Is there a way to make sure the text is displayed from right to left?
> >> >
> >> > Many thanks for any suggestions,
> >> > Tal
> >> >
> >> >
> >> > Contact
> >> > Details:---
> >> > Contact me: tal.gal...@gmail.com |  972-52-7275845
> >> > Read me:
> >> www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
> >> > www.r-statistics.com (English)
> >> >
> >>
> --
> >>
> >>
> >> I'm not sure if this is what you're after, but this function reverses
> the
> >> string, character by character and swaps parentheses around.
> >>
> >> rev.string <- function(x) {
> >> revx.indiv <- rev(unlist(strsplit(x, "")))
> >> revx.indiv2 <- revx.indiv
> >> revx.indiv2[revx.indiv=="("] <- ")"
> >> revx.indiv2[revx.indiv==")"] <- "("
> >> paste(revx.indiv2, collapse="")
> >> }
> >> plot(1:10, main=rev.string("ש×?×?× (×?קס×?)"))
> >>
> >>
> >> Jean
> >
> >[[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.
> >
>
>
>
> --
>
> Bert Gunter
> Genentech Nonclinical Biostatistics
>
> Internal Contact Info:
> Phone: 467-7374
> Website:
>
> http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm
>

[[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 it possible to "right align" text in R graphics?

2011-12-29 Thread Tal Galili
Thank you for the reply Jean, but no, it would not fix it :)

plot(1:10, main=rev.string("שלום (עולם)"))

What would "fix" it is if I had added a number after the parenthesis, but
that is a hack, not a solution...
plot(1:10, main="שלום (עולם) 1")



Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--




On Fri, Dec 30, 2011 at 12:12 AM, Jean V Adams  wrote:

>
> Tal Galili wrote on 12/29/2011 10:52:55 AM:
>
>
> > Hello all,
> >
> > The following line of code includes a right-to-left language text, yet
> the
> > R graphics engine displays it from left to right.  One problem this
> causes
> > is when there are parenthesis in the test, here is a basic example?
> >
> > plot(1:10, main = "×©×œ×•× (טקסט)")
>
> >
> > Is there a way to make sure the text is displayed from right to left?
> >
> > Many thanks for any suggestions,
> > Tal
> >
> >
> > Contact
> > Details:---
> > Contact me: tal.gal...@gmail.com |  972-52-7275845
> > Read me:
> www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
> > www.r-statistics.com (English)
> >
> --
>
>
> I'm not sure if this is what you're after, but this function reverses the
> string, character by character and swaps parentheses around.
>
> rev.string <- function(x) {
> revx.indiv <- rev(unlist(strsplit(x, "")))
> revx.indiv2 <- revx.indiv
> revx.indiv2[revx.indiv=="("] <- ")"
> revx.indiv2[revx.indiv==")"] <- "("
> paste(revx.indiv2, collapse="")
> }
> plot(1:10, main=rev.string("ש×?×?× (×?קס×?)"))
>
>
> Jean

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


  1   2   3   4   5   6   7   8   >