Re: [R] Pull data from Tally 9.1 to R studio

2017-08-23 Thread David Winsemius

> On Aug 22, 2017, at 11:31 PM, jagan krishnan via R-help 
>  wrote:
> 
> Hi all,
> This is Jagan.i have been provided a task of analyzing sales data of a 
> company in R programming...Just wanted to know,how can I pull Tally 9.1 
> software data into R programming dataframe.
> Waiting eagerly for your inputs.
> With Regards,Jagannathan Krishnan
> Sent from Yahoo Mail on Android 
> 
>  On Tue, Aug 22, 2017 at 10:47 AM, jagan krishnan 
> wrote:   Hi all,
> This is Jagan.i have been provided a task of analyzing sales data of a 
> company in R programming...Just wanted to know,how can I pull Tally 9.1 
> software data into R programming dataframe.
> Waiting eagerly for your inputs.

Are we supposed to know what "Tally 9.1 software data" might look like?


> With Regards,Jagannathan Krishnan
> 
> Sent from Yahoo Mail on Android  
> 
>   [[alternative HTML version deleted]]

A Posting Guide was prepared for you. I suggest that you should read it.

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

David Winsemius
Alameda, CA, USA

'Any technology distinguishable from magic is insufficiently advanced.'   
-Gehm's Corollary to Clarke's Third Law

__
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] Vibration signal prediction in R

2017-08-23 Thread Dhivya Narayanasamy
I have a vibration signal coming accelerometer. I converted this signal from*
m/s^2* to *mm/s*. Now I am supposed to predict this vibration signal in R
using historical data. (Please see the attached picture of vibration
signal).

Can I use this vibration signal just like that to the prediction using
predictive Models or Do i need to do some processing technique before doing
prediction?  Are there any blogs or websites for this vibration prediction
using R ? All i could found was blogs using "fft" function on vibration in
R. but My aim is to do *prediction of vibration signal in time domain*
using packages in R.

I am interested to know how this signal can be used in prediction in R? Any
help is much appreciated.

Thank you.
Dhivya
__
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] likert Package

2017-08-23 Thread Richard M. Heiberger
## There is a bug in likert:::plot.likert.
## The centered argument is not handled correctly.
## In addition to centering, it also flips the order.
## Here it is:

likert:::plot.likert(results, type = "bar", centered = TRUE,  ## correct order
 group.order = c("Band 3", "Band 4"))
likert:::plot.likert(results, type = "bar", centered = FALSE, ## wrong order
 group.order = c("Band 3", "Band 4"))

## I am including the maintainer of the likert package in the cc for
this response.


## In the meantime, you can get the picture you want from the likert
## plot in the HH package.
##
## install.packages("HH") ## if you don't have HH yet.
##
## this uses the same colors as the likert:::plot.likert function.
## See ?likert.options for details
lpl.col <- c(low.color = "#D8B365", neutral.color = "grey90",
high.color = "#5AB4AC")
HH::plot.likert(results, col=lpl.col,
main="equivalent to 'centered=TRUE' with different layout")
HH::plot.likert(results, col=lpl.col, ReferenceZero=0,
main="equivalent to 'centered=FALSE' with different layout")

## HH::plot.likert defaults to a different layout than likert::plot.likert
## this makes the necessary changes to get the intended plot
results.renamed <- results
names(results.renamed[[1]])[1:2] <- names(results[[1]])[2:1]


HH::plot.likert(results.renamed, col=lpl.col,  layout=c(1, 5),
main="equivalent to 'centered=TRUE'")
HH::plot.likert(results.renamed, col=lpl.col, ReferenceZero=0, layout=c(1, 5),
main="equivalent to 'centered=FALSE'")



## for completeness, this is how to get the intended plot directly
from the HH package

df2 <- reshape2::melt(df, id.vars="band")
df3 <- aggregate(factor(value) ~ band + variable, data=df2, FUN=table)
HH::likert(band ~ . | variable , data=df3, as.percent=TRUE, layout=c(1,5),
   col=lpl.col,
main="equivalent to 'centered=TRUE' with different layout")
HH::likert(band ~ . | variable , data=df3, as.percent=TRUE, layout=c(1,5),
   col=lpl.col, ReferenceZero=0,
main="equivalent to 'centered=FALSE' with different layout")

On Wed, Aug 23, 2017 at 9:38 PM, Jeff Reichman  wrote:
> R- Help Forum
>
>
>
> Working with the "likert" package and I can't figure out why my "bar" graphs
> are backwards (see attached). The percentages are place correctly but the
> bars are backwards.
>
>
>
> #Sample code
>
> # libraries
>
> library(likert)
>
>
>
> # create data
>
> band <- c("Band 3","Band 3","Band 3","Band 3","Band 3","Band 3","Band
> 3","Band 3","Band 3","Band 3",
>
>   "Band 4","Band 4","Band 4","Band 4","Band 4","Band 4","Band
> 4","Band 4","Band 4","Band 4")
>
> q1 <- factor(c(1,1,2,2,2,2,1,1,1,2,1,1,1,1,1,3,2,1,1,1),levels =
> c("1","2","3"))
>
> q2 <- factor(c(1,1,1,1,1,1,1,1,1,1,2,2,1,1,1,1,1,1,1,1),levels =
> c("1","2","3"))
>
> q3 <- factor(c(2,2,2,2,2,2,2,2,2,2,1,3,2,2,2,2,2,2,2,2),levels =
> c("1","2","3"))
>
> q4 <- factor(c(3,3,3,3,3,3,3,3,2,1,2,2,3,3,3,3,3,3,3,3),levels =
> c("1","2","3"))
>
> q5 <- factor(c(2,2,2,2,3,1,1,2,2,2,2,3,3,3,3,3,3,1,1,3),levels =
> c("1","2","3"))
>
>
>
> df <- data.frame(band,q1,q2,q3,q4,q5)
>
>
>
> summary(df)
>
> results <- likert(df[,2:6])
>
> summary(results)
>
>
>
> # bar plot, this plots correctly
>
> plot(results, type="bar")
>
>
>
> # group by 'Band Level', this plots the bars backwards
>
> results <- likert(df[,2:6], grouping = df$band)
>
> plot(results, type = "bar", centered = FALSE, group.order = c("Band 3",
> "Band 4"))
>
>
>
>
> __
> 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.


Re: [R] likert Package

2017-08-23 Thread Jeff Newmiller
Please don't start a new thread with the same question. My usual suggestion at 
this point would be for you to respond to the answers that have already been 
posted to your last question, but I think at this point that you need to 
correspond directly with the maintainer of the likert package. 
-- 
Sent from my phone. Please excuse my brevity.

On August 23, 2017 6:38:26 PM PDT, Jeff Reichman   
wrote:
>R- Help Forum
>
> 
>
>Working with the "likert" package and I can't figure out why my "bar"
>graphs
>are backwards (see attached). The percentages are place correctly but
>the
>bars are backwards.
>
> 
>
>#Sample code
>
># libraries
>
>library(likert)
>
> 
>
># create data
>
>band <- c("Band 3","Band 3","Band 3","Band 3","Band 3","Band 3","Band
>3","Band 3","Band 3","Band 3",
>
>  "Band 4","Band 4","Band 4","Band 4","Band 4","Band 4","Band
>4","Band 4","Band 4","Band 4")
>
>q1 <- factor(c(1,1,2,2,2,2,1,1,1,2,1,1,1,1,1,3,2,1,1,1),levels =
>c("1","2","3"))
>
>q2 <- factor(c(1,1,1,1,1,1,1,1,1,1,2,2,1,1,1,1,1,1,1,1),levels =
>c("1","2","3"))
>
>q3 <- factor(c(2,2,2,2,2,2,2,2,2,2,1,3,2,2,2,2,2,2,2,2),levels =
>c("1","2","3"))
>
>q4 <- factor(c(3,3,3,3,3,3,3,3,2,1,2,2,3,3,3,3,3,3,3,3),levels =
>c("1","2","3"))
>
>q5 <- factor(c(2,2,2,2,3,1,1,2,2,2,2,3,3,3,3,3,3,1,1,3),levels =
>c("1","2","3"))
>
> 
>
>df <- data.frame(band,q1,q2,q3,q4,q5)
>
> 
>
>summary(df)
>
>results <- likert(df[,2:6])
>
>summary(results)
>
> 
>
># bar plot, this plots correctly
>
>plot(results, type="bar")
>
> 
>
># group by 'Band Level', this plots the bars backwards
>
>results <- likert(df[,2:6], grouping = df$band)
>
>plot(results, type = "bar", centered = FALSE, group.order = c("Band 3",
>"Band 4"))
>
> 

__
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] likert Package

2017-08-23 Thread Jeff Reichman
R- Help Forum

 

Working with the "likert" package and I can't figure out why my "bar" graphs
are backwards (see attached). The percentages are place correctly but the
bars are backwards.

 

#Sample code

# libraries

library(likert)

 

# create data

band <- c("Band 3","Band 3","Band 3","Band 3","Band 3","Band 3","Band
3","Band 3","Band 3","Band 3",

  "Band 4","Band 4","Band 4","Band 4","Band 4","Band 4","Band
4","Band 4","Band 4","Band 4")

q1 <- factor(c(1,1,2,2,2,2,1,1,1,2,1,1,1,1,1,3,2,1,1,1),levels =
c("1","2","3"))

q2 <- factor(c(1,1,1,1,1,1,1,1,1,1,2,2,1,1,1,1,1,1,1,1),levels =
c("1","2","3"))

q3 <- factor(c(2,2,2,2,2,2,2,2,2,2,1,3,2,2,2,2,2,2,2,2),levels =
c("1","2","3"))

q4 <- factor(c(3,3,3,3,3,3,3,3,2,1,2,2,3,3,3,3,3,3,3,3),levels =
c("1","2","3"))

q5 <- factor(c(2,2,2,2,3,1,1,2,2,2,2,3,3,3,3,3,3,1,1,3),levels =
c("1","2","3"))

 

df <- data.frame(band,q1,q2,q3,q4,q5)

 

summary(df)

results <- likert(df[,2:6])

summary(results)

 

# bar plot, this plots correctly

plot(results, type="bar")

 

# group by 'Band Level', this plots the bars backwards

results <- likert(df[,2:6], grouping = df$band)

plot(results, type = "bar", centered = FALSE, group.order = c("Band 3",
"Band 4"))

 

__
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] boot.stepAIC fails with computed formula

2017-08-23 Thread Bert Gunter
Thanks.

I suspect that would help to track down the problem in the underlying
code, but I am not sufficiently motivated to do so. Perhaps the
maintainer will if he sees this thread.

Cheers,
Bert


Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Wed, Aug 23, 2017 at 4:07 PM, Heinz Tuechler  wrote:
> It seems that if you build the formula as a character string, and postpone
> the "as.formula" into the lm call, it works.
>
> instead of
> frm1 <- as.formula(paste(trg,"~1"))
> use
> frm1a <- paste(trg,"~1")
> and then
> strt <- lm(as.formula(frm1a),dat)
>
> regards,
>
> Heinz
>
> Stephen O'hagan wrote/hat geschrieben on/am 23.08.2017 12:07:
>>
>> Until I get a fix that works, a work-around would be to rename the 'y1'
>> column, used a fixed formula, and rename it back afterwards.
>>
>> Thanks for your help.
>> SGO.
>>
>> -Original Message-
>> From: Bert Gunter [mailto:bgunter.4...@gmail.com]
>> Sent: 22 August 2017 20:38
>> To: Stephen O'hagan 
>> Cc: r-help@r-project.org
>> Subject: Re: [R] boot.stepAIC fails with computed formula
>>
>> OK, here's the problem. Continuing with your example:
>>
>> strt1 <- lm(y1 ~1, dat)
>> strt2 <- lm(frm1,dat)
>>
>>
>>> strt1
>>
>>
>> Call:
>> lm(formula = y1 ~ 1, data = dat)
>>
>> Coefficients:
>> (Intercept)
>>   41.73
>>
>>> strt2
>>
>>
>> Call:
>> lm(formula = frm1, data = dat)
>>
>> Coefficients:
>> (Intercept)
>>   41.73
>>
>>
>> Note that the formula objects of the lm object are different: strt2 does
>> not evaluate the formula. So presumably boot.step.AIC does no evaluation and
>> therefore gets confused with the errors you saw. So you need to get the
>> evaluated formula into the lm object. This can be done, e.g. via:
>>
>>> strt2 <- eval(substitute(lm(form,data = dat), list(form = frm1)))
>>
>>
>> ## yielding
>>
>>> strt2
>>
>>
>> Call:
>> lm(formula = y1 ~ 1, data = dat)
>>
>> Coefficients:
>> (Intercept)
>>   41.73
>>
>> So this looks like it should fix the problem, but alas no, the
>> boot.stepAIC call still fails with the same error message. Here's why:
>>
>>> identical(strt$call, strt2$call)
>>
>> [1] FALSE
>>
>> So one might rightfully ask, what the heck is going on here?! Further
>> digging:
>>
>>> str(strt$call)
>>
>>  language lm(formula = y1 ~ 1, data = dat)
>>
>>> str(strt2$call)
>>
>>  language lm(formula = y1 ~ 1, data = dat)
>>
>> These certainly look identical! -- but of course they're not:
>>
>>> names(strt$call)
>>
>> [1] """formula" "data"
>>>
>>> names(strt2$call)
>>
>> [1] """formula" "data"
>>
>> So the difference must lie in the formula component, right? ...
>>
>>> strt$call$formula
>>
>> y1 ~ 1
>>>
>>> strt2$call$formula
>>
>> y1 ~ 1
>>
>> So, thus far, huhh? But..
>>
>>> class(strt2$call$formula)
>>
>> [1] "formula"
>>
>>> class(strt$call$formula)
>>
>> [1] "call"
>>
>> So I think therein lies the critical difference that is screwing things
>> up. NOTE: If I am wrong about this someone **PLEASE** correct me.
>>
>> I see no clear workaround for this other than to explicitly avoid
>> passing a formula in the lm() call with y~1 or y ~ .   I think the
>> real fix is to make the  boot.stepAIC function smarter in how it handles
>> its formula argument, and that is above my paygrade (and degree of interest)
>> . You should probably email the maintainer, who may not monitor this list.
>> But give it a day or so to give someone else a chance to correct me if I'm
>> wrong.
>>
>>
>> HTH.
>>
>> Cheers,
>>
>> Bert
>> Bert Gunter
>>
>> "The trouble with having an open mind is that people keep coming along and
>> sticking things into it."
>> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>>
>>
>> On Tue, Aug 22, 2017 at 8:17 AM, Stephen O'hagan
>>  wrote:
>>>
>>> I'm trying to use boot.stepAIC for feature selection; I need to be able
>>> to specify the name of the dependent variable programmatically, but this
>>> appear to fail:
>>>
>>> In R-Studio with MS R Open 3.4:
>>>
>>> library(bootStepAIC)
>>>
>>> #Fake data
>>> n<-200
>>>
>>> x1 <- runif(n, -3, 3)
>>> x2 <- runif(n, -3, 3)
>>> x3 <- runif(n, -3, 3)
>>> x4 <- runif(n, -3, 3)
>>> x5 <- runif(n, -3, 3)
>>> x6 <- runif(n, -3, 3)
>>> x7 <- runif(n, -3, 3)
>>> x8 <- runif(n, -3, 3)
>>> y1 <- 42+x3 + 2*x6 + 3*x8 + runif(n, -0.5, 0.5)
>>>
>>> dat <- data.frame(x1,x2,x3,x4,x5,x6,x7,x8,y1)
>>> #the real data won't have these names...
>>>
>>> cn <- names(dat)
>>> trg <- "y1"
>>> xvars <- cn[cn!=trg]
>>>
>>> frm1<-as.formula(paste(trg,"~1"))
>>> frm2<-as.formula(paste(trg,"~ 1 + ",paste(xvars,collapse = "+")))
>>>
>>> strt=lm(y1~1,dat) # boot.stepAIC Works fine
>>>
>>> #strt=do.call("lm",list(frm1,data=dat)) ## boot.stepAIC FAILS ##
>>>
>>> #strt=lm(frm1,dat) ## boot.stepAIC FAILS ##
>>>
>>> limit<-5
>>>
>>>
>>> 

Re: [R] Getting all possible combinations

2017-08-23 Thread Duncan Murdoch

On 23/08/2017 6:25 PM, Bert Gunter wrote:

Doesn't sort by size of subgroup. I interpret the phrase I asterisked as:


You were fooled by Peter's tricky single negative.

Duncan Murdoch



Your code does the following:

First subsets of size 1 are given.
Then all subsets of size 2.
Then all subsets of size 3.
etc.

Your code does not do this (quite).

If you meant something else, then please clarify.

Cheers,
Bert


Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Wed, Aug 23, 2017 at 3:14 PM, peter dalgaard  wrote:



On 23 Aug 2017, at 23:12 , Bert Gunter  wrote:


This points to a different algorithm where you write 0:(2^n-1) as n-digit 
binary numbers and chose items corresponding to the 1s. That won't give the 
combinations **sorted by size of selected subgroup** though. Something like 
this:


No it doesn't.
-- Bert


Doesn't what? Do what I say it won't??

-pd

--
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Office: A 4.23
Email: pd@cbs.dk  Priv: pda...@gmail.com











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


Re: [R] boot.stepAIC fails with computed formula

2017-08-23 Thread Heinz Tuechler
It seems that if you build the formula as a character string, and 
postpone the "as.formula" into the lm call, it works.


instead of
frm1 <- as.formula(paste(trg,"~1"))
use
frm1a <- paste(trg,"~1")
and then
strt <- lm(as.formula(frm1a),dat)

regards,

Heinz

Stephen O'hagan wrote/hat geschrieben on/am 23.08.2017 12:07:

Until I get a fix that works, a work-around would be to rename the 'y1' column, 
used a fixed formula, and rename it back afterwards.

Thanks for your help.
SGO.

-Original Message-
From: Bert Gunter [mailto:bgunter.4...@gmail.com]
Sent: 22 August 2017 20:38
To: Stephen O'hagan 
Cc: r-help@r-project.org
Subject: Re: [R] boot.stepAIC fails with computed formula

OK, here's the problem. Continuing with your example:

strt1 <- lm(y1 ~1, dat)
strt2 <- lm(frm1,dat)



strt1


Call:
lm(formula = y1 ~ 1, data = dat)

Coefficients:
(Intercept)
  41.73


strt2


Call:
lm(formula = frm1, data = dat)

Coefficients:
(Intercept)
  41.73


Note that the formula objects of the lm object are different: strt2 does not 
evaluate the formula. So presumably boot.step.AIC does no evaluation and 
therefore gets confused with the errors you saw. So you need to get the 
evaluated formula into the lm object. This can be done, e.g. via:


strt2 <- eval(substitute(lm(form,data = dat), list(form = frm1)))


## yielding


strt2


Call:
lm(formula = y1 ~ 1, data = dat)

Coefficients:
(Intercept)
  41.73

So this looks like it should fix the problem, but alas no, the boot.stepAIC 
call still fails with the same error message. Here's why:


identical(strt$call, strt2$call)

[1] FALSE

So one might rightfully ask, what the heck is going on here?! Further digging:


str(strt$call)

 language lm(formula = y1 ~ 1, data = dat)


str(strt2$call)

 language lm(formula = y1 ~ 1, data = dat)

These certainly look identical! -- but of course they're not:


names(strt$call)

[1] """formula" "data"

names(strt2$call)

[1] """formula" "data"

So the difference must lie in the formula component, right? ...


strt$call$formula

y1 ~ 1

strt2$call$formula

y1 ~ 1

So, thus far, huhh? But..


class(strt2$call$formula)

[1] "formula"


class(strt$call$formula)

[1] "call"

So I think therein lies the critical difference that is screwing things up. 
NOTE: If I am wrong about this someone **PLEASE** correct me.

I see no clear workaround for this other than to explicitly avoid
passing a formula in the lm() call with y~1 or y ~ .   I think the
real fix is to make the  boot.stepAIC function smarter in how it handles its 
formula argument, and that is above my paygrade (and degree of interest) . You 
should probably email the maintainer, who may not monitor this list. But give 
it a day or so to give someone else a chance to correct me if I'm wrong.


HTH.

Cheers,

Bert
Bert Gunter

"The trouble with having an open mind is that people keep coming along and sticking 
things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Tue, Aug 22, 2017 at 8:17 AM, Stephen O'hagan  
wrote:

I'm trying to use boot.stepAIC for feature selection; I need to be able to 
specify the name of the dependent variable programmatically, but this appear to 
fail:

In R-Studio with MS R Open 3.4:

library(bootStepAIC)

#Fake data
n<-200

x1 <- runif(n, -3, 3)
x2 <- runif(n, -3, 3)
x3 <- runif(n, -3, 3)
x4 <- runif(n, -3, 3)
x5 <- runif(n, -3, 3)
x6 <- runif(n, -3, 3)
x7 <- runif(n, -3, 3)
x8 <- runif(n, -3, 3)
y1 <- 42+x3 + 2*x6 + 3*x8 + runif(n, -0.5, 0.5)

dat <- data.frame(x1,x2,x3,x4,x5,x6,x7,x8,y1)
#the real data won't have these names...

cn <- names(dat)
trg <- "y1"
xvars <- cn[cn!=trg]

frm1<-as.formula(paste(trg,"~1"))
frm2<-as.formula(paste(trg,"~ 1 + ",paste(xvars,collapse = "+")))

strt=lm(y1~1,dat) # boot.stepAIC Works fine

#strt=do.call("lm",list(frm1,data=dat)) ## boot.stepAIC FAILS ##

#strt=lm(frm1,dat) ## boot.stepAIC FAILS ##

limit<-5


stp=stepAIC(strt,direction='forward',steps=limit,
scope=list(lower=frm1,upper=frm2))

bst <- boot.stepAIC(strt,dat,B=50,alpha=0.05,direction='forward',steps=limit,
scope=list(lower=frm1,upper=frm2))

b1 <- bst$Covariates
ball <- data.frame(b1)
names(ball)=unlist(trg)

Any ideas?

Cheers,
SOH


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




Re: [R] Flummoxed by gsub().

2017-08-23 Thread William Dunlap via R-help
Note that the "doubled brackets" are not essential to this usage.
[:characterClass:] is recognized inside of square brackets as a shortcut
for listing a bunch of characters.  You can mix it with other characters or
character classes inside a set of square brackets.

E.g., the following pattern matches letters, digits, and the dollar and
percent signs.

> gsub("[$[:alpha:]%[:digit:]]", "-", c("$6 is 50% of $12.00"))
[1] "-- -- --- -- ---.--"


Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Wed, Aug 23, 2017 at 3:39 PM, Rolf Turner 
wrote:

> On 24/08/17 02:46, Bert Gunter wrote:
>
>> Inline.
>>
>> -- Bert
>>
>>
>> Bert Gunter
>>
>> "The trouble with having an open mind is that people keep coming along
>> and sticking things into it."
>> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>>
>>
>> On Wed, Aug 23, 2017 at 2:29 AM, Rolf Turner 
>> wrote:
>>
>>>
>>> On 23/08/17 18:33, Stefan Evert wrote:
>>>
>>>
 On 23 Aug 2017, at 07:45, Rolf Turner  wrote:
>
> My reading of ?regex led me to believe that
>
>  gsub("[:alpha:]","",x)
>
> should give the result that I want.
>


 That's looking for any of the characters a, l, p, h, : .

>>>
>>>
>>> OK.  I see that now.  I don't think that it's really stated anywhere
>>> that to
>>> search for (and possibly change) any one of a string of characters you
>>> enclose that string of characters in brackets [  ].
>>>
>>> The first example from ?grep makes this "clear" (for some value of the
>>> word
>>> "clear") once you understand what this example is on about.
>>>
>>> So it's "obvious" once you've been shown, and totally opaque until then.
>>>
>>
>> Well, "obviousness" is in the mind of the beholder, but, from ?regexp:
>>
>> "A character class is a list of characters enclosed between [ and ]
>> which matches any single character in that list; "... (at the end of
>> the above section)
>>
>> "For example, [[:alnum:]] means [0-9A-Za-z] "...
>>
>> Note the doubled brackets. So seems pretty explicit to me.
>>
>
> Well, yes.  Once it's pointed out it's "obvious".  But it's buried pretty
> deeply in a large mass of text, and I didn't see it until you pointed it
> out.
>
> If *I* had written the help file, it would be much more perspicuous.
>
> cheers,
>
> Rolf
>
> --
> Technical Editor ANZJS
> Department of Statistics
> University of Auckland
> Phone: +64-9-373-7599 ext. 88276
>
> __
> 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/posti
> ng-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] Scaling Matrix in qda() function in MASS package

2017-08-23 Thread Bert Gunter
You need to learn how to access code for nonexported methods.  See ? "::"

> methods(qda)
[1] qda.data.frame* qda.default*qda.formula*qda.matrix*
see '?methods' for accessing help and source code

Shows you that the methods are not exported from the namespace. Hence
you need to use the triple colon operator to see their code:

> MASS:::qda

Once you have the code, I presume this will answer your question.

Cheers,
Bert


Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Wed, Aug 23, 2017 at 2:44 PM, Souradeep Chattapadhyay
 wrote:
> Hello,
>I am Souradeep Chattopadhyay and I am a graduate student at Iowa
> State University Department of Statistics.
>
> Can anyone please explain the mathematical formulation behind the scaling
> matrix returned by the qda function in MASS package. I want to understand
> how this scaling matrix is derived from the inputs given to the qda
> function.
>
> Example Code
>
> The following example is using the banknote data in the MCLUST package.
>
> *Code*
>
> require(MASS)
> require(mclust)
> data(banknote)
> quad<-qda(banknote[,-1], grouping=banknote$Status, method="mle")
> quad$scaling
>
>
> Scaling matrix returned by qda for this data is
>
> , , counterfeit
>
> 12  3
>  4 5  6
> Length   2.853988  1.069414 -0.05279774  0.750531723 -0.2053821  0.6986088
> Left0.00 -4.208108 -3.04707132 -0.026804815 -0.8644062
> -1.1088947
> Right  0.00  0.00  4.27383763  0.003205759  0.3313675  1.3865888
> Bottom   0.00  0.00  0.  0.917596063 -0.8707772  0.7274894
> Top 0.00  0.00  0.  0.0 -2.2041415
>  0.6956074
> Diagonal 0.00  0.00  0.  0.0  0.000-2.1879157
>
> , , genuine
>
> 1 2   34
>   5   6
> Length  2.592911 -1.169164  0.6105339 -0.3614352 -0.2520496 -0.5281743
> Left   0.00  3.027882  2.2392994 -0.2842368 -1.2092325  0.6927868
> Right0.00  0.00 -3.8684746 -0.3972362 -0.4177546 -0.1062555
> Bottom 0.00  0.00  0.000  1.6376150  1.7274240  0.3969998
> Top   0.00  0.00  0.000  0.000  2.3022115  0.6318543
> Diagonal 0.00  0.00  0.000  0.000  0.000  2.4516680
>
>
>
> Thanks and Regards
>
> Souradeep
>
> [[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.


Re: [R] Flummoxed by gsub().

2017-08-23 Thread Rolf Turner

On 24/08/17 02:46, Bert Gunter wrote:

Inline.

-- Bert


Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Wed, Aug 23, 2017 at 2:29 AM, Rolf Turner  wrote:


On 23/08/17 18:33, Stefan Evert wrote:




On 23 Aug 2017, at 07:45, Rolf Turner  wrote:

My reading of ?regex led me to believe that

 gsub("[:alpha:]","",x)

should give the result that I want.



That's looking for any of the characters a, l, p, h, : .



OK.  I see that now.  I don't think that it's really stated anywhere that to
search for (and possibly change) any one of a string of characters you
enclose that string of characters in brackets [  ].

The first example from ?grep makes this "clear" (for some value of the word
"clear") once you understand what this example is on about.

So it's "obvious" once you've been shown, and totally opaque until then.


Well, "obviousness" is in the mind of the beholder, but, from ?regexp:

"A character class is a list of characters enclosed between [ and ]
which matches any single character in that list; "... (at the end of
the above section)

"For example, [[:alnum:]] means [0-9A-Za-z] "...

Note the doubled brackets. So seems pretty explicit to me.


Well, yes.  Once it's pointed out it's "obvious".  But it's buried 
pretty deeply in a large mass of text, and I didn't see it until you 
pointed it out.


If *I* had written the help file, it would be much more perspicuous.

cheers,

Rolf

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] Scaling Matrix in qda() function in MASS package

2017-08-23 Thread Souradeep Chattapadhyay
Hello,
   I am Souradeep Chattopadhyay and I am a graduate student at Iowa
State University Department of Statistics.

Can anyone please explain the mathematical formulation behind the scaling
matrix returned by the qda function in MASS package. I want to understand
how this scaling matrix is derived from the inputs given to the qda
function.

Example Code

The following example is using the banknote data in the MCLUST package.

*Code*

require(MASS)
require(mclust)
data(banknote)
quad<-qda(banknote[,-1], grouping=banknote$Status, method="mle")
quad$scaling


Scaling matrix returned by qda for this data is

, , counterfeit

12  3
 4 5  6
Length   2.853988  1.069414 -0.05279774  0.750531723 -0.2053821  0.6986088
Left0.00 -4.208108 -3.04707132 -0.026804815 -0.8644062
-1.1088947
Right  0.00  0.00  4.27383763  0.003205759  0.3313675  1.3865888
Bottom   0.00  0.00  0.  0.917596063 -0.8707772  0.7274894
Top 0.00  0.00  0.  0.0 -2.2041415
 0.6956074
Diagonal 0.00  0.00  0.  0.0  0.000-2.1879157

, , genuine

1 2   34
  5   6
Length  2.592911 -1.169164  0.6105339 -0.3614352 -0.2520496 -0.5281743
Left   0.00  3.027882  2.2392994 -0.2842368 -1.2092325  0.6927868
Right0.00  0.00 -3.8684746 -0.3972362 -0.4177546 -0.1062555
Bottom 0.00  0.00  0.000  1.6376150  1.7274240  0.3969998
Top   0.00  0.00  0.000  0.000  2.3022115  0.6318543
Diagonal 0.00  0.00  0.000  0.000  0.000  2.4516680



Thanks and Regards

Souradeep

[[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] Getting all possible combinations

2017-08-23 Thread Bert Gunter
Doesn't sort by size of subgroup. I interpret the phrase I asterisked as:

Your code does the following:

First subsets of size 1 are given.
Then all subsets of size 2.
Then all subsets of size 3.
etc.

Your code does not do this (quite).

If you meant something else, then please clarify.

Cheers,
Bert


Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Wed, Aug 23, 2017 at 3:14 PM, peter dalgaard  wrote:
>
>> On 23 Aug 2017, at 23:12 , Bert Gunter  wrote:
>>
>>> This points to a different algorithm where you write 0:(2^n-1) as n-digit 
>>> binary numbers and chose items corresponding to the 1s. That won't give the 
>>> combinations **sorted by size of selected subgroup** though. Something like 
>>> this:
>>
>> No it doesn't.
>> -- Bert
>
> Doesn't what? Do what I say it won't??
>
> -pd
>
> --
> Peter Dalgaard, Professor,
> Center for Statistics, Copenhagen Business School
> Solbjerg Plads 3, 2000 Frederiksberg, Denmark
> Phone: (+45)38153501
> Office: A 4.23
> Email: pd@cbs.dk  Priv: pda...@gmail.com
>
>
>
>
>
>
>
>
>

__
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] Getting all possible combinations

2017-08-23 Thread peter dalgaard

> On 23 Aug 2017, at 23:12 , Bert Gunter  wrote:
> 
>> This points to a different algorithm where you write 0:(2^n-1) as n-digit 
>> binary numbers and chose items corresponding to the 1s. That won't give the 
>> combinations **sorted by size of selected subgroup** though. Something like 
>> this:
> 
> No it doesn't.
> -- Bert

Doesn't what? Do what I say it won't??

-pd

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Office: A 4.23
Email: pd@cbs.dk  Priv: pda...@gmail.com

__
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] Getting all possible combinations

2017-08-23 Thread Bert Gunter
Inline.

-- Bert
Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Wed, Aug 23, 2017 at 1:58 PM, peter dalgaard  wrote:
>
>> On 23 Aug 2017, at 20:51 , Ista Zahn  wrote:
>>
>> On Wed, Aug 23, 2017 at 12:35 PM, Bert Gunter  wrote:
>>> ummm, Ista, it's 2^n.
>>
>> ummm yes ug.
>>
>
> You didn't really say otherwise: sum(choose(n,0:n)) == 2^n by the binomial 
> expansion of (1+1)^n (but you knew that)
>
> This points to a different algorithm where you write 0:(2^n-1) as n-digit 
> binary numbers and chose items corresponding to the 1s. That won't give the 
> combinations **sorted by size of selected subgroup** though. Something like 
> this:

No it doesn't.
-- Bert

>
> M <- as.matrix(do.call(expand.grid, rep(list(0:1),5)))
> mode(M) <- "logical"
> apply(M,1,function(i)LETTERS[1:5][i])
>
> -pd
>
>
>> My point is, if the number of groups is large, check it before hand.
>> If you can check it without embarrassing yourself in public like I did
>> that's even better.
>>
>> Best,
>> Ista
>>
>>>
>>> Cheers,
>>> Bert
>>>
>>>
>>> Bert Gunter
>>>
>>> "The trouble with having an open mind is that people keep coming along
>>> and sticking things into it."
>>> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>>>
>>>
>>> On Wed, Aug 23, 2017 at 8:52 AM, Ista Zahn  wrote:
 On Wed, Aug 23, 2017 at 11:33 AM, Christofer Bogaso
  wrote:
> Hi again,
>
> I am exploring if R can help me to get all possible combinations of
> members in a group.
>
> Let say I have a group with 5 members : A, B, C, D, E
>
> Now I want to generate all possible unique combinations with all
> possible lengths from that group e.g.
>
> 1st combination : A
> 2nd combination : B
> .
> 5th combination : E
> 6th combination : A, B
> 7th combination : B, C
> 
> last combination: A, B, C, D, E
>
> Ideally, I have a fairly large group so am looking for some
> programmatic way to generate all possible combinations.

 Be careful, the number of combinations grows pretty quickly. You can
 calculate the number ahead of time with

 sum(choose(n, 1:n))

 where n is the number of values in your group.

 --Ista

>
> Any help will be highly appreciated.
>
> Thanks for your time.
>
> __
> 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.
>>
>> __
>> 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.
>
> --
> Peter Dalgaard, Professor,
> Center for Statistics, Copenhagen Business School
> Solbjerg Plads 3, 2000 Frederiksberg, Denmark
> Phone: (+45)38153501
> Office: A 4.23
> Email: pd@cbs.dk  Priv: pda...@gmail.com
>
>
>
>
>
>
>
>
>

__
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] Getting all possible combinations

2017-08-23 Thread peter dalgaard

> On 23 Aug 2017, at 20:51 , Ista Zahn  wrote:
> 
> On Wed, Aug 23, 2017 at 12:35 PM, Bert Gunter  wrote:
>> ummm, Ista, it's 2^n.
> 
> ummm yes ug.
> 

You didn't really say otherwise: sum(choose(n,0:n)) == 2^n by the binomial 
expansion of (1+1)^n (but you knew that)

This points to a different algorithm where you write 0:(2^n-1) as n-digit 
binary numbers and chose items corresponding to the 1s. That won't give the 
combinations sorted by size of selected subgroup though. Something like this:

M <- as.matrix(do.call(expand.grid, rep(list(0:1),5)))
mode(M) <- "logical"
apply(M,1,function(i)LETTERS[1:5][i])

-pd


> My point is, if the number of groups is large, check it before hand.
> If you can check it without embarrassing yourself in public like I did
> that's even better.
> 
> Best,
> Ista
> 
>> 
>> Cheers,
>> Bert
>> 
>> 
>> Bert Gunter
>> 
>> "The trouble with having an open mind is that people keep coming along
>> and sticking things into it."
>> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>> 
>> 
>> On Wed, Aug 23, 2017 at 8:52 AM, Ista Zahn  wrote:
>>> On Wed, Aug 23, 2017 at 11:33 AM, Christofer Bogaso
>>>  wrote:
 Hi again,
 
 I am exploring if R can help me to get all possible combinations of
 members in a group.
 
 Let say I have a group with 5 members : A, B, C, D, E
 
 Now I want to generate all possible unique combinations with all
 possible lengths from that group e.g.
 
 1st combination : A
 2nd combination : B
 .
 5th combination : E
 6th combination : A, B
 7th combination : B, C
 
 last combination: A, B, C, D, E
 
 Ideally, I have a fairly large group so am looking for some
 programmatic way to generate all possible combinations.
>>> 
>>> Be careful, the number of combinations grows pretty quickly. You can
>>> calculate the number ahead of time with
>>> 
>>> sum(choose(n, 1:n))
>>> 
>>> where n is the number of values in your group.
>>> 
>>> --Ista
>>> 
 
 Any help will be highly appreciated.
 
 Thanks for your time.
 
 __
 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.
> 
> __
> 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.

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Office: A 4.23
Email: pd@cbs.dk  Priv: pda...@gmail.com

__
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] Getting all possible combinations

2017-08-23 Thread Ista Zahn
On Wed, Aug 23, 2017 at 12:35 PM, Bert Gunter  wrote:
> ummm, Ista, it's 2^n.

ummm yes ug.

My point is, if the number of groups is large, check it before hand.
If you can check it without embarrassing yourself in public like I did
that's even better.

Best,
Ista

>
> Cheers,
> Bert
>
>
> Bert Gunter
>
> "The trouble with having an open mind is that people keep coming along
> and sticking things into it."
> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>
>
> On Wed, Aug 23, 2017 at 8:52 AM, Ista Zahn  wrote:
>> On Wed, Aug 23, 2017 at 11:33 AM, Christofer Bogaso
>>  wrote:
>>> Hi again,
>>>
>>> I am exploring if R can help me to get all possible combinations of
>>> members in a group.
>>>
>>> Let say I have a group with 5 members : A, B, C, D, E
>>>
>>> Now I want to generate all possible unique combinations with all
>>> possible lengths from that group e.g.
>>>
>>> 1st combination : A
>>> 2nd combination : B
>>> .
>>> 5th combination : E
>>> 6th combination : A, B
>>> 7th combination : B, C
>>> 
>>> last combination: A, B, C, D, E
>>>
>>> Ideally, I have a fairly large group so am looking for some
>>> programmatic way to generate all possible combinations.
>>
>> Be careful, the number of combinations grows pretty quickly. You can
>> calculate the number ahead of time with
>>
>> sum(choose(n, 1:n))
>>
>> where n is the number of values in your group.
>>
>> --Ista
>>
>>>
>>> Any help will be highly appreciated.
>>>
>>> Thanks for your time.
>>>
>>> __
>>> 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.

__
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] likert Package

2017-08-23 Thread Richard M. Heiberger
most likely you have a factor with default levels which are not
ordered the way you want them to be ordered.
You can reorder the levels with the factor function.  If you still
need help after adjusting the order of the levels, then
please send the data to the list by including the output of
dput(data)
in the body of your email.

The name "data" is a bad name for your dataset as it conflicts with
the data function and the data= argument
to many functions.

On Tue, Aug 22, 2017 at 8:51 PM, Jeff Reichman  wrote:
> R- Help Forum
>
>
>
> Working with the "likert" package and find that my "bar" graphs are
> backwards (see attached)
>
>
>
>> summary(results)
>
>   Item low neutral high meansd
>
> 4   Q4   5  15   80 2.75 0.5501196
>
> 5   Q5  20  40   40 2.20 0.7677719
>
> 1   Q1  65  305 1.40 0.5982430
>
> 3   Q3   5  905 2.00 0.3244428
>
> 2   Q2  90  100 1.10 0.3077935
>
>
>
>> results <- likert(data[,2:6], grouping = data$Group)
>> plot(results, type = "bar", centered = FALSE, group.order = c("Band 3",
> "Band 4"))
>
> In the attached figure the percentages appear correct but the bars are
> backwards (or appear to be backwards)
>
>
>
>
> __
> 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.


[R] cross validation in random forest using rfcv functin

2017-08-23 Thread Elahe chalabi via R-help
Any responds?!



On Wednesday, August 23, 2017 5:50 AM, Elahe chalabi via R-help 
 wrote:



Hi all,


I would like to do cross validation in random forest using rfcv function. As 
the documentation for this package says:


rfcv(trainx, trainy, cv.fold=5, scale="log", step=0.5, mtry=function(p) max(1, 
floor(sqrt(p))), recursive=FALSE, ...)


however I don't know how to build trianx and trainy for my data set, and I 
could not understand the way trainx is built in the package documentation 
example for iris data set.

Here is my data set and I want to do cross validation to see accuracy in 
classifying Alzheimer and Control Group:


str(data)

'data.frame':499 obs. of  606 variables:

$ Gender: int  0 0 0 0 0 1 1 1 1 1 ...

$ NumOfWords: num  157 111 163 176 100 124 201 100 76 101

$ NumofLivings  : int  6 6 9 4 3 5 3 3 4 3 ...

$ NumofStopWords: num  77 45 87 91 46 64 104 37 32 41 ...

.

.

$ Group : Factor w/ 2 levels "Alzheimer","Control","Control"..:


So basically trainy should be data$Group but how about trainx? Could anyone 
help me in this?



Thanks for any help!

Elahe

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


[R] MCMCglmm issue

2017-08-23 Thread Bert Plants
When I try to use the following code, I get the error message shown. This
is quite confusing to me, insofar as family is a recognized argument for
MCMCglmm. Can anyone spot an obvious glitch?

 model1 <-MCMCglmm(fixed = NoRRVpos ~ Year, random = ~County,
family="zipoisson", data=Rabies_Project_Init)Error in MCMCglmm(fixed =
NoRRVpos ~ Year, random = ~County, family = "zipoisson",  :
  For error structures involving multinomial data with more than 2
categories, or zero-infalted/altered/hurdle modelsIn addition: Warning
message:Unknown or uninitialised column: 'family'.


Thanks

Bert

[[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] Comparing 2 dale columns

2017-08-23 Thread William Dunlap via R-help
: Thanks. But when I apply your codes I get all NA instead of TRUE and FALSE

You need to show a self-contained example of your problem, one that others
can copy and paste into their R sessions.  E.g.,

data <- read.table(header=TRUE, stringsAsFactors=FALSE, text="
COL1   COL2
6/1/14 5/1/15
7/1/14 5/1/15")
data$COL1<- as.Date(data$COL1, format="%d/%m/%y")
data$COL2<- as.Date(data$COL2, format="%d/%m/%y")
str(data)
#'data.frame':   2 obs. of  2 variables:
# $ COL1: Date, format: "2014-01-06" "2014-01-07"
# $ COL2: Date, format: "2015-01-05" "2015-01-05"
transform(data, `Col2>Col1` = COL2 > COL1, `Col2-Col1` = COL2 - COL1,
check.names=FALSE)
#COL1   COL2 Col2>Col1 Col2-Col1
#1 2014-01-06 2015-01-05  TRUE  364 days
#2 2014-01-07 2015-01-05  TRUE  363 days


Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Wed, Aug 23, 2017 at 9:09 AM, Patrick Casimir  wrote:

>
> Thanks. But when I apply your codes I get all NA instead of TRUE and FALSE
>
> 
> From: PIKAL Petr 
> Sent: Wednesday, August 23, 2017 11:20:00 AM
> To: Patrick Casimir; r-help@r-project.org
> Subject: RE: Comparing 2 dale columns
>
> Hi
>
> your code is wrong.
>
> I get
> > test<-read.table("clipboard", header=T)
> > str(test)
> 'data.frame':   2 obs. of  2 variables:
>  $ COL1: Factor w/ 2 levels "6/1/14","7/1/14": 1 2
>  $ COL2: Factor w/ 1 level "5/1/15": 1 1
> > test$COL2<- as.Date(as.character(test$COL2, format="%y/%m/%d"))
> > test$COL1<- as.Date(as.character(test$COL1, format="%y/%m/%d"))
>
>^^^
> incorrect parentheses position, wrong y,m,d
>
> Using correct syntax I get correct result.
>
> > test$COL2<- as.Date(test$COL2, format="%d/%m/%y")
> > test$COL1<- as.Date(test$COL1, format="%d/%m/%y")
> >
> > test$COL2 > test$COL1
> [1] TRUE TRUE
> > test
> COL1   COL2
> 1 2014-01-06 2015-01-05
> 2 2014-01-07 2015-01-05
> >
>
> Cheers
> Petr
>
> > -Original Message-
> > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Patrick
> > Casimir
> > Sent: Wednesday, August 23, 2017 4:54 PM
> > To: r-help@r-project.org
> > Subject: [R] Comparing 2 dale columns
> >
> > Dear R fellows,
> >
> >
> > I created a new column Date_flag to compare the dates of COL1 and COL2
> > using the code below. But it showed that 5/1/15 is greater than 6/1/2014
> and
> > 5/1/2015 greater than
> > 7/1/2014 despite the year is greater. How do I fix that? I did try to
> format as
> > %y/%m/%d
> >
> >  but it does not fix that.
> >
> >
> > data$Date_Flag <- ifelse(data$COL2 > data$COL1, 0,1)
> >
> >
> > COL1   COL2
> > 6/1/14 5/1/15
> > 7/1/14 5/1/15
> >
> >
> > data$COL2<- as.Date(as.character(data$COL2, format="%y/%m/%d"))
> > data$COL1<- as.Date(as.character(data$COL1, format="%y/%m/%d"))
> >
> >
> >   [[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://na01.safelinks.protection.outlook.com/?url=
> https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-help&
> data=02%7C01%7Cpatrcasi%40nova.edu%7Cbf182d25cae845ec841c08d4ea3a7139%
> 7C2c2b2d312e3e4df1b571fb37c042ff1b%7C0%7C0%7C636390984126927971=
> Tait17GF8fuEBwFnDZHCgnc7v88yXqAxpTX7W76O1cA%3D=0
> > PLEASE do read the posting guide https://na01.safelinks.
> protection.outlook.com/?url=http%3A%2F%2Fwww.R-project.
> org%2Fposting-guide.html=02%7C01%7Cpatrcasi%40nova.edu%
> 7Cbf182d25cae845ec841c08d4ea3a7139%7C2c2b2d312e3e4df1b571fb37c042
> ff1b%7C0%7C0%7C636390984126927971=H3xZXXDLx4sN23A4HoUp1bElRZfWfP
> T1HbOaRMSDCjI%3D=0
> > and provide commented, minimal, self-contained, reproducible code.
>
> 
> Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a jsou
> určeny pouze jeho adresátům.
> Jestliľe jste obdrľel(a) tento e-mail omylem, informujte laskavě
> neprodleně jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho kopie
> vymaľte ze svého systému.
> Nejste-li zamýąleným adresátem tohoto emailu, nejste oprávněni tento email
> jakkoliv uľívat, roząiřovat, kopírovat či zveřejňovat.
> Odesílatel e-mailu neodpovídá za eventuální ąkodu způsobenou modifikacemi
> či zpoľděním přenosu e-mailu.
>
> V případě, ľe je tento e-mail součástí obchodního jednání:
> - vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření
> smlouvy, a to z jakéhokoliv důvodu i bez uvedení důvodu.
> - a obsahuje-li nabídku, je adresát oprávněn nabídku bezodkladně přijmout;
> Odesílatel tohoto e-mailu (nabídky) vylučuje přijetí nabídky ze strany
> příjemce s dodatkem či odchylkou.
> - trvá odesílatel na tom, ľe přísluąná smlouva je uzavřena teprve
> výslovným dosaľením shody na vąech jejích náleľitostech.
> - odesílatel tohoto emailu informuje, ľe není oprávněn uzavírat za
> společnost ľádné smlouvy s výjimkou případů, kdy k tomu byl písemně zmocněn
> nebo písemně pověřen a takové pověření nebo plná 

Re: [R] Getting all possible combinations

2017-08-23 Thread Spencer Graves



On 2017-08-23 11:35 AM, Bert Gunter wrote:

ummm, Ista, it's 2^n.



  or (2^n-1) if the empty set is not considered as a "combination" 
;-)  spencer


Cheers,
Bert


Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Wed, Aug 23, 2017 at 8:52 AM, Ista Zahn  wrote:

On Wed, Aug 23, 2017 at 11:33 AM, Christofer Bogaso
 wrote:

Hi again,

I am exploring if R can help me to get all possible combinations of
members in a group.

Let say I have a group with 5 members : A, B, C, D, E

Now I want to generate all possible unique combinations with all
possible lengths from that group e.g.

1st combination : A
2nd combination : B
.
5th combination : E
6th combination : A, B
7th combination : B, C

last combination: A, B, C, D, E

Ideally, I have a fairly large group so am looking for some
programmatic way to generate all possible combinations.

Be careful, the number of combinations grows pretty quickly. You can
calculate the number ahead of time with

sum(choose(n, 1:n))

where n is the number of values in your group.

--Ista


Any help will be highly appreciated.

Thanks for your time.

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

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

Re: [R] Getting all possible combinations

2017-08-23 Thread Bert Gunter
ummm, Ista, it's 2^n.

Cheers,
Bert


Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Wed, Aug 23, 2017 at 8:52 AM, Ista Zahn  wrote:
> On Wed, Aug 23, 2017 at 11:33 AM, Christofer Bogaso
>  wrote:
>> Hi again,
>>
>> I am exploring if R can help me to get all possible combinations of
>> members in a group.
>>
>> Let say I have a group with 5 members : A, B, C, D, E
>>
>> Now I want to generate all possible unique combinations with all
>> possible lengths from that group e.g.
>>
>> 1st combination : A
>> 2nd combination : B
>> .
>> 5th combination : E
>> 6th combination : A, B
>> 7th combination : B, C
>> 
>> last combination: A, B, C, D, E
>>
>> Ideally, I have a fairly large group so am looking for some
>> programmatic way to generate all possible combinations.
>
> Be careful, the number of combinations grows pretty quickly. You can
> calculate the number ahead of time with
>
> sum(choose(n, 1:n))
>
> where n is the number of values in your group.
>
> --Ista
>
>>
>> Any help will be highly appreciated.
>>
>> Thanks for your time.
>>
>> __
>> 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.

__
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] Comparing 2 dale columns

2017-08-23 Thread Patrick Casimir

Thanks. But when I apply your codes I get all NA instead of TRUE and FALSE


From: PIKAL Petr 
Sent: Wednesday, August 23, 2017 11:20:00 AM
To: Patrick Casimir; r-help@r-project.org
Subject: RE: Comparing 2 dale columns

Hi

your code is wrong.

I get
> test<-read.table("clipboard", header=T)
> str(test)
'data.frame':   2 obs. of  2 variables:
 $ COL1: Factor w/ 2 levels "6/1/14","7/1/14": 1 2
 $ COL2: Factor w/ 1 level "5/1/15": 1 1
> test$COL2<- as.Date(as.character(test$COL2, format="%y/%m/%d"))
> test$COL1<- as.Date(as.character(test$COL1, format="%y/%m/%d"))

 ^^^
incorrect parentheses position, wrong y,m,d

Using correct syntax I get correct result.

> test$COL2<- as.Date(test$COL2, format="%d/%m/%y")
> test$COL1<- as.Date(test$COL1, format="%d/%m/%y")
>
> test$COL2 > test$COL1
[1] TRUE TRUE
> test
COL1   COL2
1 2014-01-06 2015-01-05
2 2014-01-07 2015-01-05
>

Cheers
Petr

> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Patrick
> Casimir
> Sent: Wednesday, August 23, 2017 4:54 PM
> To: r-help@r-project.org
> Subject: [R] Comparing 2 dale columns
>
> Dear R fellows,
>
>
> I created a new column Date_flag to compare the dates of COL1 and COL2
> using the code below. But it showed that 5/1/15 is greater than 6/1/2014 and
> 5/1/2015 greater than
> 7/1/2014 despite the year is greater. How do I fix that? I did try to format 
> as
> %y/%m/%d
>
>  but it does not fix that.
>
>
> data$Date_Flag <- ifelse(data$COL2 > data$COL1, 0,1)
>
>
> COL1   COL2
> 6/1/14 5/1/15
> 7/1/14 5/1/15
>
>
> data$COL2<- as.Date(as.character(data$COL2, format="%y/%m/%d"))
> data$COL1<- as.Date(as.character(data$COL1, format="%y/%m/%d"))
>
>
>   [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-help=02%7C01%7Cpatrcasi%40nova.edu%7Cbf182d25cae845ec841c08d4ea3a7139%7C2c2b2d312e3e4df1b571fb37c042ff1b%7C0%7C0%7C636390984126927971=Tait17GF8fuEBwFnDZHCgnc7v88yXqAxpTX7W76O1cA%3D=0
> PLEASE do read the posting guide 
> https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.R-project.org%2Fposting-guide.html=02%7C01%7Cpatrcasi%40nova.edu%7Cbf182d25cae845ec841c08d4ea3a7139%7C2c2b2d312e3e4df1b571fb37c042ff1b%7C0%7C0%7C636390984126927971=H3xZXXDLx4sN23A4HoUp1bElRZfWfPT1HbOaRMSDCjI%3D=0
> and provide commented, minimal, self-contained, reproducible code.


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

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

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

In case that this e-mail forms part of business dealings:
- the sender reserves the right to end negotiations about entering into a 
contract in any time, for any reason, and without stating any reasoning.
- if the e-mail contains an offer, the recipient is entitled to immediately 
accept such offer; The sender of this 

Re: [R] Comparing 2 dale columns

2017-08-23 Thread Patrick Casimir
Hi Mark,


Instead of 1 and 0. It generates NA

 NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA




From: Mark Sharp 
Sent: Wednesday, August 23, 2017 11:28:39 AM
To: Patrick Casimir
Cc: r-help@r-project.org
Subject: Re: [R] Comparing 2 dale columns

Patrick,

## Run the following script an notice the different values of the dataframe 
"data" in each instance.

# I understand you have done something like the following:
data <- data.frame(COL1 = c("6/1/14", "7/1/14"),
   COL2 = c("5/1/15", "5/1/15"), stringsAsFactors = FALSE)
data$Date_Flag <- ifelse(data$COL2 > data$COL1, 0,1)
data
data$COL2 <- as.Date(as.character(data$COL2, format = "%y/%m/%d"))
data$COL1 <- as.Date(as.character(data$COL1, format = "%y/%m/%d"))
data$Date_Flag <- ifelse(data$COL2 > data$COL1, 0,1)
data

# What you may want instead is the following:
data <- data.frame(COL1 = c("6/1/14", "7/1/14"),
   COL2 = c("5/1/15", "5/1/15"), stringsAsFactors = FALSE)
data
## strptime() converts the character vector to POSIXct so you do not necessarily
## need the as.Date. However, they are not the same and you may need the Date
## class.
data$COL2 <- as.Date(strptime(data$COL2, format = "%m/%d/%y"))
data$COL1 <- as.Date(strptime(data$COL1, format = "%m/%d/%y"))
data
data$Date_Flag <- ifelse(data$COL2 > data$COL1, 0,1)
data


R. Mark Sharp, Ph.D.
msh...@txbiomed.org





> On Aug 23, 2017, at 9:53 AM, Patrick Casimir  wrote:
>
> data$Date_Flag <- ifelse(data$COL2 > data$COL1, 0,1)
>
>
> COL1   COL2
> 6/1/14 5/1/15
> 7/1/14 5/1/15
>
>
> data$COL2<- as.Date(as.character(data$COL2, format="%y/%m/%d"))
> data$COL1<- as.Date(as.character(data$COL1, format="%y/%m/%d"))
>

CONFIDENTIALITY NOTICE: This e-mail and any files and/or...{{dropped:13}}

__
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] Getting all possible combinations

2017-08-23 Thread Ista Zahn
On Wed, Aug 23, 2017 at 11:33 AM, Christofer Bogaso
 wrote:
> Hi again,
>
> I am exploring if R can help me to get all possible combinations of
> members in a group.
>
> Let say I have a group with 5 members : A, B, C, D, E
>
> Now I want to generate all possible unique combinations with all
> possible lengths from that group e.g.
>
> 1st combination : A
> 2nd combination : B
> .
> 5th combination : E
> 6th combination : A, B
> 7th combination : B, C
> 
> last combination: A, B, C, D, E
>
> Ideally, I have a fairly large group so am looking for some
> programmatic way to generate all possible combinations.

Be careful, the number of combinations grows pretty quickly. You can
calculate the number ahead of time with

sum(choose(n, 1:n))

where n is the number of values in your group.

--Ista

>
> Any help will be highly appreciated.
>
> Thanks for your time.
>
> __
> 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.


Re: [R] Getting all possible combinations

2017-08-23 Thread Bert Gunter
Please at least do a basic internet search before posting here.
Searching on "R combinations" brought up the combn() function, which
you can use in a simple loop to get your answer:

> lapply(seq_len(5), FUN = function(x)combn(LETTERS[1:5], x))
## You can use a for() loop if you prefer

[[1]]
 [,1] [,2] [,3] [,4] [,5]
[1,] "A"  "B"  "C"  "D"  "E"

[[2]]
 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
[1,] "A"  "A"  "A"  "A"  "B"  "B"  "B"  "C"  "C"  "D"
[2,] "B"  "C"  "D"  "E"  "C"  "D"  "E"  "D"  "E"  "E"

[[3]]
 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
[1,] "A"  "A"  "A"  "A"  "A"  "A"  "B"  "B"  "B"  "C"
[2,] "B"  "B"  "B"  "C"  "C"  "D"  "C"  "C"  "D"  "D"
[3,] "C"  "D"  "E"  "D"  "E"  "E"  "D"  "E"  "E"  "E"

[[4]]
 [,1] [,2] [,3] [,4] [,5]
[1,] "A"  "A"  "A"  "A"  "B"
[2,] "B"  "B"  "B"  "C"  "C"
[3,] "C"  "C"  "D"  "D"  "D"
[4,] "D"  "E"  "E"  "E"  "E"

[[5]]
 [,1]
[1,] "A"
[2,] "B"
[3,] "C"
[4,] "D"
[5,] "E"



Cheers,
Bert


Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Wed, Aug 23, 2017 at 8:33 AM, Christofer Bogaso
 wrote:
> Hi again,
>
> I am exploring if R can help me to get all possible combinations of
> members in a group.
>
> Let say I have a group with 5 members : A, B, C, D, E
>
> Now I want to generate all possible unique combinations with all
> possible lengths from that group e.g.
>
> 1st combination : A
> 2nd combination : B
> .
> 5th combination : E
> 6th combination : A, B
> 7th combination : B, C
> 
> last combination: A, B, C, D, E
>
> Ideally, I have a fairly large group so am looking for some
> programmatic way to generate all possible combinations.
>
> Any help will be highly appreciated.
>
> Thanks for your time.
>
> __
> 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.


Re: [R] Getting all possible combinations

2017-08-23 Thread Ista Zahn
lapply(1:5, function(x) combn(groups, x))

or perhaps

unlist(lapply(1:5, function(x) combn(groups, x, FUN = paste, collapse = ", ")))

Best,
Ista

On Wed, Aug 23, 2017 at 11:33 AM, Christofer Bogaso
 wrote:
> Hi again,
>
> I am exploring if R can help me to get all possible combinations of
> members in a group.
>
> Let say I have a group with 5 members : A, B, C, D, E
>
> Now I want to generate all possible unique combinations with all
> possible lengths from that group e.g.
>
> 1st combination : A
> 2nd combination : B
> .
> 5th combination : E
> 6th combination : A, B
> 7th combination : B, C
> 
> last combination: A, B, C, D, E
>
> Ideally, I have a fairly large group so am looking for some
> programmatic way to generate all possible combinations.
>
> Any help will be highly appreciated.
>
> Thanks for your time.
>
> __
> 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.


[R] Getting all possible combinations

2017-08-23 Thread Christofer Bogaso
Hi again,

I am exploring if R can help me to get all possible combinations of
members in a group.

Let say I have a group with 5 members : A, B, C, D, E

Now I want to generate all possible unique combinations with all
possible lengths from that group e.g.

1st combination : A
2nd combination : B
.
5th combination : E
6th combination : A, B
7th combination : B, C

last combination: A, B, C, D, E

Ideally, I have a fairly large group so am looking for some
programmatic way to generate all possible combinations.

Any help will be highly appreciated.

Thanks for your time.

__
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] Comparing 2 dale columns

2017-08-23 Thread Mark Sharp
Patrick,

## Run the following script an notice the different values of the dataframe 
"data" in each instance.

# I understand you have done something like the following:
data <- data.frame(COL1 = c("6/1/14", "7/1/14"),
   COL2 = c("5/1/15", "5/1/15"), stringsAsFactors = FALSE)
data$Date_Flag <- ifelse(data$COL2 > data$COL1, 0,1)
data
data$COL2 <- as.Date(as.character(data$COL2, format = "%y/%m/%d"))
data$COL1 <- as.Date(as.character(data$COL1, format = "%y/%m/%d"))
data$Date_Flag <- ifelse(data$COL2 > data$COL1, 0,1)
data

# What you may want instead is the following:
data <- data.frame(COL1 = c("6/1/14", "7/1/14"),
   COL2 = c("5/1/15", "5/1/15"), stringsAsFactors = FALSE)
data
## strptime() converts the character vector to POSIXct so you do not necessarily
## need the as.Date. However, they are not the same and you may need the Date
## class.
data$COL2 <- as.Date(strptime(data$COL2, format = "%m/%d/%y"))
data$COL1 <- as.Date(strptime(data$COL1, format = "%m/%d/%y"))
data
data$Date_Flag <- ifelse(data$COL2 > data$COL1, 0,1)
data


R. Mark Sharp, Ph.D.
msh...@txbiomed.org





> On Aug 23, 2017, at 9:53 AM, Patrick Casimir  wrote:
>
> data$Date_Flag <- ifelse(data$COL2 > data$COL1, 0,1)
>
>
> COL1   COL2
> 6/1/14 5/1/15
> 7/1/14 5/1/15
>
>
> data$COL2<- as.Date(as.character(data$COL2, format="%y/%m/%d"))
> data$COL1<- as.Date(as.character(data$COL1, format="%y/%m/%d"))
>

CONFIDENTIALITY NOTICE: This e-mail and any files and/or...{{dropped:10}}

__
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] Comparing 2 dale columns

2017-08-23 Thread PIKAL Petr
Hi

your code is wrong.

I get
> test<-read.table("clipboard", header=T)
> str(test)
'data.frame':   2 obs. of  2 variables:
 $ COL1: Factor w/ 2 levels "6/1/14","7/1/14": 1 2
 $ COL2: Factor w/ 1 level "5/1/15": 1 1
> test$COL2<- as.Date(as.character(test$COL2, format="%y/%m/%d"))
> test$COL1<- as.Date(as.character(test$COL1, format="%y/%m/%d"))

 ^^^
incorrect parentheses position, wrong y,m,d

Using correct syntax I get correct result.

> test$COL2<- as.Date(test$COL2, format="%d/%m/%y")
> test$COL1<- as.Date(test$COL1, format="%d/%m/%y")
>
> test$COL2 > test$COL1
[1] TRUE TRUE
> test
COL1   COL2
1 2014-01-06 2015-01-05
2 2014-01-07 2015-01-05
>

Cheers
Petr

> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Patrick
> Casimir
> Sent: Wednesday, August 23, 2017 4:54 PM
> To: r-help@r-project.org
> Subject: [R] Comparing 2 dale columns
>
> Dear R fellows,
>
>
> I created a new column Date_flag to compare the dates of COL1 and COL2
> using the code below. But it showed that 5/1/15 is greater than 6/1/2014 and
> 5/1/2015 greater than
> 7/1/2014 despite the year is greater. How do I fix that? I did try to format 
> as
> %y/%m/%d
>
>  but it does not fix that.
>
>
> data$Date_Flag <- ifelse(data$COL2 > data$COL1, 0,1)
>
>
> COL1   COL2
> 6/1/14 5/1/15
> 7/1/14 5/1/15
>
>
> data$COL2<- as.Date(as.character(data$COL2, format="%y/%m/%d"))
> data$COL1<- as.Date(as.character(data$COL1, format="%y/%m/%d"))
>
>
>   [[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.


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

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

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

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

Re: [R] strange nlme augpred behaviour

2017-08-23 Thread PIKAL Petr
Hi

Well, yes I tried it about two weeks ago but my post did not get through as it 
still awaits moderator approval. I could check which column is offending but 
actually it is only minor nuisance, I can live with selection of columns before 
fitting a model. What seems to me strange is that both full dataset and only 
selected colums gave me identical fit results but only one works within augPred.

Cheers
Petr

> -Original Message-
> From: Bert Gunter [mailto:bgunter.4...@gmail.com]
> Sent: Wednesday, August 23, 2017 4:50 PM
> To: PIKAL Petr 
> Cc: r-help mailing list 
> Subject: Re: [R] strange nlme augpred behaviour
>
> Better posted on r-sig-mixed-models , no?
>
> Cheers,
> Bert
>
>
> Bert Gunter
>
> "The trouble with having an open mind is that people keep coming along and
> sticking things into it."
> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>
>
> On Wed, Aug 23, 2017 at 5:17 AM, PIKAL Petr  wrote:
> > Dear all
> >
> > I encountered strange behaviour of augPred with virtually the same
> > data
> >
> > First I made groupedData object.
> >> mar.g<-groupedData(rutilizace~doba|int, data=mar)
> >
> > When I perform nlme on complete dataset I get an error with augPred
> >> fit<-nlsList(rutilizace~SSasymp(doba, Asym, R0,  lrc), data=mar.g)
> > Warning message:
> > c("1 error caught in nls(y ~ cbind(1 - exp(-exp(lrc) * x), exp(-exp(lrc) * 
> > x)), data
> = xy, : singular gradient", "1 error caught in start = list(lrc = lrc), 
> algorithm =
> \"plinear\"): singular gradient")
> >> fit1<-nlme(fit)
> >> plot(augPred(fit1, level=0:1))
> > Error in `[[<-.data.frame`(`*tmp*`, nm, value = c(6L, 6L, 6L, 6L, 8L,  :
> >   replacement has 60 rows, data has 12
> >
> > However when I make subset of my data to keep only affected collumns.
> >>
> >> mar.g<-mar.g[,c(3,4, 21)]
> >
> >> fit<-nlsList(rutilizace~SSasymp(doba, Asym, R0,  lrc), data=mar.g)
> > Warning message:
> > c("1 error caught in nls(y ~ cbind(1 - exp(-exp(lrc) * x), exp(-exp(lrc) * 
> > x)), data
> = xy, : singular gradient", "1 error caught in start = list(lrc = lrc), 
> algorithm =
> \"plinear\"): singular gradient")
> >> fit2<-nlme(fit)
> >> plot(augPred(fit2, level=0:1))
> >>
> > augPred works as a charm.
> >
> > When I compare fit1 and fit2 they are equal
> >> all.equal(fit1, fit2)
> > [1] TRUE
> >>
> >
> > Does anybody know where I should try to search for problems?
> >
> > Best regards
> > Petr
> >
> >> traceback()
> > 6: stop(sprintf(ngettext(N, "replacement has %d row, data has %d",
> >"replacement has %d rows, data has %d"), N, nrows), domain =
> > NA)
> > 5: `[[<-.data.frame`(`*tmp*`, nm, value = c(1L, 1L, 1L, 1L, 5L,
> >5L, 5L, 5L, 9L, 9L, 9L, 9L, 4L, 4L, 4L, 4L, 8L, 8L, 8L, 8L, 12L,
> >12L, 12L, 12L, 3L, 3L, 3L, 3L, 7L, 7L, 7L, 7L, 11L, 11L, 11L,
> >11L, 1L, 1L, 1L, 1L, 5L, 5L, 5L, 5L, 9L, 9L, 9L, 9L, 2L, 2L,
> >2L, 2L, 6L, 6L, 6L, 6L, 10L, 10L, 10L, 10L))
> > 4: `[[<-`(`*tmp*`, nm, value = c(1L, 1L, 1L, 1L, 5L, 5L, 5L, 5L,
> >9L, 9L, 9L, 9L, 4L, 4L, 4L, 4L, 8L, 8L, 8L, 8L, 12L, 12L, 12L,
> >12L, 3L, 3L, 3L, 3L, 7L, 7L, 7L, 7L, 11L, 11L, 11L, 11L, 1L,
> >1L, 1L, 1L, 5L, 5L, 5L, 5L, 9L, 9L, 9L, 9L, 2L, 2L, 2L, 2L, 6L,
> >6L, 6L, 6L, 10L, 10L, 10L, 10L))
> > 3: gsummary(data, groups = groups)
> > 2: augPred.lme(fit1, level = 0:1)
> > 1: augPred(fit1, level = 0:1)
> >
> >> version
> >_
> > platform   x86_64-w64-mingw32
> > arch   x86_64
> > os mingw32
> > system x86_64, mingw32
> > status Under development (unstable)
> > major  3
> > minor  5.0
> > year   2017
> > month  07
> > day31
> > svn rev73003
> > language   R
> > version.string R Under development (unstable) (2017-07-31 r73003)
> > nickname   Unsuffered Consequences
> >>
> >
> > Package nlme version 3.1-131
> >
> >
> > 
.
> > __
> > 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.


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

V případě, že je tento e-mail součástí obchodního jednání:
- vyhrazuje si odesílatel právo ukončit kdykoliv jednání o 

[R] Comparing 2 dale columns

2017-08-23 Thread Patrick Casimir
Dear R fellows,


I created a new column Date_flag to compare the dates of COL1 and COL2 using 
the code
below. But it showed that 5/1/15 is greater than 6/1/2014 and 5/1/2015 greater 
than
7/1/2014 despite the year is greater. How do I fix that? I did try to format as 
%y/%m/%d

 but it does not fix that.


data$Date_Flag <- ifelse(data$COL2 > data$COL1, 0,1)


COL1   COL2
6/1/14 5/1/15
7/1/14 5/1/15


data$COL2<- as.Date(as.character(data$COL2, format="%y/%m/%d"))
data$COL1<- as.Date(as.character(data$COL1, format="%y/%m/%d"))


[[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] strange nlme augpred behaviour

2017-08-23 Thread Bert Gunter
Better posted on r-sig-mixed-models , no?

Cheers,
Bert


Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Wed, Aug 23, 2017 at 5:17 AM, PIKAL Petr  wrote:
> Dear all
>
> I encountered strange behaviour of augPred with virtually the same data
>
> First I made groupedData object.
>> mar.g<-groupedData(rutilizace~doba|int, data=mar)
>
> When I perform nlme on complete dataset I get an error with augPred
>> fit<-nlsList(rutilizace~SSasymp(doba, Asym, R0,  lrc), data=mar.g)
> Warning message:
> c("1 error caught in nls(y ~ cbind(1 - exp(-exp(lrc) * x), exp(-exp(lrc) * 
> x)), data = xy, : singular gradient", "1 error caught in start = list(lrc 
> = lrc), algorithm = \"plinear\"): singular gradient")
>> fit1<-nlme(fit)
>> plot(augPred(fit1, level=0:1))
> Error in `[[<-.data.frame`(`*tmp*`, nm, value = c(6L, 6L, 6L, 6L, 8L,  :
>   replacement has 60 rows, data has 12
>
> However when I make subset of my data to keep only affected collumns.
>>
>> mar.g<-mar.g[,c(3,4, 21)]
>
>> fit<-nlsList(rutilizace~SSasymp(doba, Asym, R0,  lrc), data=mar.g)
> Warning message:
> c("1 error caught in nls(y ~ cbind(1 - exp(-exp(lrc) * x), exp(-exp(lrc) * 
> x)), data = xy, : singular gradient", "1 error caught in start = list(lrc 
> = lrc), algorithm = \"plinear\"): singular gradient")
>> fit2<-nlme(fit)
>> plot(augPred(fit2, level=0:1))
>>
> augPred works as a charm.
>
> When I compare fit1 and fit2 they are equal
>> all.equal(fit1, fit2)
> [1] TRUE
>>
>
> Does anybody know where I should try to search for problems?
>
> Best regards
> Petr
>
>> traceback()
> 6: stop(sprintf(ngettext(N, "replacement has %d row, data has %d",
>"replacement has %d rows, data has %d"), N, nrows), domain = NA)
> 5: `[[<-.data.frame`(`*tmp*`, nm, value = c(1L, 1L, 1L, 1L, 5L,
>5L, 5L, 5L, 9L, 9L, 9L, 9L, 4L, 4L, 4L, 4L, 8L, 8L, 8L, 8L, 12L,
>12L, 12L, 12L, 3L, 3L, 3L, 3L, 7L, 7L, 7L, 7L, 11L, 11L, 11L,
>11L, 1L, 1L, 1L, 1L, 5L, 5L, 5L, 5L, 9L, 9L, 9L, 9L, 2L, 2L,
>2L, 2L, 6L, 6L, 6L, 6L, 10L, 10L, 10L, 10L))
> 4: `[[<-`(`*tmp*`, nm, value = c(1L, 1L, 1L, 1L, 5L, 5L, 5L, 5L,
>9L, 9L, 9L, 9L, 4L, 4L, 4L, 4L, 8L, 8L, 8L, 8L, 12L, 12L, 12L,
>12L, 3L, 3L, 3L, 3L, 7L, 7L, 7L, 7L, 11L, 11L, 11L, 11L, 1L,
>1L, 1L, 1L, 5L, 5L, 5L, 5L, 9L, 9L, 9L, 9L, 2L, 2L, 2L, 2L, 6L,
>6L, 6L, 6L, 10L, 10L, 10L, 10L))
> 3: gsummary(data, groups = groups)
> 2: augPred.lme(fit1, level = 0:1)
> 1: augPred(fit1, level = 0:1)
>
>> version
>_
> platform   x86_64-w64-mingw32
> arch   x86_64
> os mingw32
> system x86_64, mingw32
> status Under development (unstable)
> major  3
> minor  5.0
> year   2017
> month  07
> day31
> svn rev73003
> language   R
> version.string R Under development (unstable) (2017-07-31 r73003)
> nickname   Unsuffered Consequences
>>
>
> Package nlme version 3.1-131
>
>
> 
> Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a jsou 
> určeny pouze jeho adresátům.
> Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě neprodleně 
> jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho kopie vymažte ze 
> svého systému.
> Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento email 
> jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat.
> Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou modifikacemi či 
> zpožděním přenosu e-mailu.
>
> V případě, že je tento e-mail součástí obchodního jednání:
> - vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření smlouvy, 
> a to z jakéhokoliv důvodu i bez uvedení důvodu.
> - a obsahuje-li nabídku, je adresát oprávněn nabídku bezodkladně přijmout; 
> Odesílatel tohoto e-mailu (nabídky) vylučuje přijetí nabídky ze strany 
> příjemce s dodatkem či odchylkou.
> - trvá odesílatel na tom, že příslušná smlouva je uzavřena teprve výslovným 
> dosažením shody na všech jejích náležitostech.
> - odesílatel tohoto emailu informuje, že není oprávněn uzavírat za společnost 
> žádné smlouvy s výjimkou případů, kdy k tomu byl písemně zmocněn nebo písemně 
> pověřen a takové pověření nebo plná moc byly adresátovi tohoto emailu 
> případně osobě, kterou adresát zastupuje, předloženy nebo jejich existence je 
> adresátovi či osobě jím zastoupené známá.
>
> This e-mail and any documents attached to it may be confidential and are 
> intended only for its intended recipients.
> If you received this e-mail by mistake, please immediately inform its sender. 
> Delete the contents of this e-mail with all attachments and its copies from 
> your system.
> If you are not the intended recipient of this e-mail, you are not authorized 
> to use, disseminate, copy or disclose this e-mail in any manner.
> The sender of this e-mail 

Re: [R] Flummoxed by gsub().

2017-08-23 Thread Bert Gunter
Inline.

-- Bert


Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Wed, Aug 23, 2017 at 2:29 AM, Rolf Turner  wrote:
>
> On 23/08/17 18:33, Stefan Evert wrote:
>
>>
>>> On 23 Aug 2017, at 07:45, Rolf Turner  wrote:
>>>
>>> My reading of ?regex led me to believe that
>>>
>>> gsub("[:alpha:]","",x)
>>>
>>> should give the result that I want.
>>
>>
>> That's looking for any of the characters a, l, p, h, : .
>
>
> OK.  I see that now.  I don't think that it's really stated anywhere that to
> search for (and possibly change) any one of a string of characters you
> enclose that string of characters in brackets [  ].
>
> The first example from ?grep makes this "clear" (for some value of the word
> "clear") once you understand what this example is on about.
>
> So it's "obvious" once you've been shown, and totally opaque until then.

Well, "obviousness" is in the mind of the beholder, but, from ?regexp:

"A character class is a list of characters enclosed between [ and ]
which matches any single character in that list; "... (at the end of
the above section)

"For example, [[:alnum:]] means [0-9A-Za-z] "...

Note the doubled brackets. So seems pretty explicit to me.

Cheers,
Bert





>
>> What you meant to say was
>>
>> gsub("[[:alpha:]]","",x)
>>
>> i.e. the character class [:alpha:] within a character set.
>
>
> Yup.  Got it.  Thanks very much.
>
> cheers,
>
> Rolf
>
> --
> Technical Editor ANZJS
> Department of Statistics
> University of Auckland
> Phone: +64-9-373-7599 ext. 88276
>
> __
> 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.


Re: [R] How to benchmark speed of load/readRDS correctly

2017-08-23 Thread Ismail SEZEN
First of all I want to mention the _warmup_ parameter to _control_argument of 
microbenchmark function. Default value is 2 and function runs the code 2 times 
before count the time intervals.
See ?microbenchmark

> However, the first iteration always takes the longest. I'm wondering if I 
> should take the first value as best guess.

So, at least for the microbenchmark function, the maximum iteration time in 
microbenchmark result is not relevant to first iteration but may be relevant to 
another processes/factors that reach the file system at the same time with your 
code.

Also we can examine the underlying code of load and readRDS functions. Simply, 
type _load_ and _readRDS_ in the terminal and see the codes.

# readRDS
function (file, refhook = NULL) 
{
if (is.character(file)) {
con <- gzfile(file, "rb")
on.exit(close(con))
}
else if (inherits(file, "connection")) 
con <- if (inherits(file, "gzfile") || inherits(file, 
"gzcon")) 
file
else gzcon(file)
else stop("bad 'file' argument")
.Internal(unserializeFromConn(con, refhook))
}

link to unserializeFromConn -> 
https://github.com/wch/r-source/blob/94cd276ed0eef865e01fcf4e96925d9373cc5799/src/main/serialize.c#L2246

# load
function (file, envir = parent.frame(), verbose = FALSE) 
{
if (is.character(file)) {
con <- gzfile(file)
on.exit(close(con))
magic <- readChar(con, 5L, useBytes = TRUE)
if (!length(magic)) 
stop("empty (zero-byte) input file")
if (!grepl("RD[AX]2\\n", magic)) {
if (grepl("RD[ABX][12]\\r", magic)) 
stop("input has been corrupted, with LF replaced by CR")
warning(sprintf("file %s has magic number '%s'\\n", 
sQuote(basename(file)), gsub("[\\n\\r]*", "", magic)), 
"  ", "Use of save versions prior to 2 is deprecated", 
domain = NA, call. = FALSE)
return(.Internal(load(file, envir)))
}
}
else if (inherits(file, "connection")) {
con <- if (inherits(file, "gzfile") || inherits(file, 
"gzcon")) 
file
else gzcon(file)
}
else stop("bad 'file' argument")
if (verbose) 
cat("Loading objects:\\n")
.Internal(loadFromConn2(con, envir, verbose))
}

link to loadFromConn2 -> 
https://github.com/wch/r-source/blob/c1093fa1073fef6404869f26a1be6ef5bd2aa0fd/src/main/saveload.c#L2329

both use an internal function called “unserializeFromConn” and “ 
loadFromConn2”. You can examine them at attached links in the text.

Even if we don’t know C/C++, we can conclude that both functions have similar 
codes to read the data. Also _load_ function has much lines of codes than 
_readRDS_ function to check some bytes. (this also may create a small 
difference as you find out in your tests, see mean and median)

Additionally, I want to discuss another aspect. Why are there 2 functions 
called _readRDS_ and _load_?

Because they have different purposses. You use _load _function to read/load 
bulk saved variables by _save_ function and you use _readRDS_ function to 
read/load a single variable saved by _saveRDS_ function. So, it is inevitable 
both functions are optimized for different purposes. This is something like 
compare apple and pear altough both are fruits. Sometimes you want to eat apple 
but sometimes pear.

Aas a result, if I need to save and read a single R object, I prefer 
readRDS/saveRDS couple. If I need to serialize multiple object to a file, I use 
the load/save couple.

> On 23 Aug 2017, at 15:40,  
>  wrote:
> 
> Hi there
> 
> Thanks for your answers. I didn't expect that this would be so complex. 
> Honestly, I don't understand everything you wrote since I'm not an IT 
> specialist. But I read something that reading *.rds files is faster than 
> loading *.Rdata and I wanted to proof that for my system and R version. But 
> thanks anyway for your time.
> 
> Cheers Raphael
> 
> 
>> -Ursprüngliche Nachricht-
>> Von: Jeff Newmiller [mailto:jdnew...@dcn.davis.ca.us]
>> Gesendet: Dienstag, 22. August 2017 18:33
>> An: J C Nash ; r-help@r-project.org; Felber Raphael
>> Agroscope 
>> Betreff: Re: [R] How to benchmark speed of load/readRDS correctly
>> 
>> Caching happens, both within the operating system and within the C
>> standard library. Ostensibly the intent for those caches is to help
>> performance, but you are right that different low-level caching algorithms
>> can be a poor match for specific application level use cases such as copying
>> files or parsing text syntax. However, the OS and even the specific file
>> system drivers (e.g. ext4 on flash disk or FAT32 on magnetic media) can
>> behave quite differently for the same application level use case, so a 
>> generic
>> discussion at the R language level 

[R] cross validation in random forest using rfcv functin

2017-08-23 Thread Elahe chalabi via R-help
Hi all,


I would like to do cross validation in random forest using rfcv function. As 
the documentation for this package says:


rfcv(trainx, trainy, cv.fold=5, scale="log", step=0.5, mtry=function(p) max(1, 
floor(sqrt(p))), recursive=FALSE, ...)


however I don't know how to build trianx and trainy for my data set, and I 
could not understand the way trainx is built in the package documentation 
example for iris data set.

Here is my data set and I want to do cross validation to see accuracy in 
classifying Alzheimer and Control Group:


str(data)

'data.frame':499 obs. of  606 variables:

$ Gender: int  0 0 0 0 0 1 1 1 1 1 ...

$ NumOfWords: num  157 111 163 176 100 124 201 100 76 101

$ NumofLivings  : int  6 6 9 4 3 5 3 3 4 3 ...

$ NumofStopWords: num  77 45 87 91 46 64 104 37 32 41 ...

.

.

$ Group : Factor w/ 2 levels "Alzheimer","Control","Control"..:


So basically trainy should be data$Group but how about trainx? Could anyone 
help me in this?



Thanks for any help!

Elahe

__
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] cross validation in random forest rfcv functin

2017-08-23 Thread Elahe chalabi via R-help
Hi all,

I would like to do cross validation in random forest using rfcv function. As 
the documentation for this package says:

rfcv(trainx, trainy, cv.fold=5, scale="log", step=0.5, mtry=function(p) max(1, 
floor(sqrt(p))), recursive=FALSE, ...)

however I don't know how to build trianx and trainy for my data set, and I 
could not understand the way trainx is built in the package documentation 
example for iris data set.
Here is my data set and I want to do cross validation to see accuracy in 
classifying Alzheimer and Control Group:

str(data)
'data.frame':   499 obs. of  606 variables:
$ Gender: int  0 0 0 0 0 1 1 1 1 1 ...
$ NumOfWords: num  157 111 163 176 100 124 201 100 76 101
$ NumofLivings  : int  6 6 9 4 3 5 3 3 4 3 ...
$ NumofStopWords: num  77 45 87 91 46 64 104 37 32 41 ...
.
.
$ Group : Factor w/ 2 levels "Alzheimer","Control","Control"..:

So basically trainy should be data$Group but how about trainx? Could anyone 
help me in this?


Thanks for any help!
Elahe

__
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] How to benchmark speed of load/readRDS correctly

2017-08-23 Thread raphael.felber
Hi there

Thanks for your answers. I didn't expect that this would be so complex. 
Honestly, I don't understand everything you wrote since I'm not an IT 
specialist. But I read something that reading *.rds files is faster than 
loading *.Rdata and I wanted to proof that for my system and R version. But 
thanks anyway for your time.

Cheers Raphael


> -Ursprüngliche Nachricht-
> Von: Jeff Newmiller [mailto:jdnew...@dcn.davis.ca.us]
> Gesendet: Dienstag, 22. August 2017 18:33
> An: J C Nash ; r-help@r-project.org; Felber Raphael
> Agroscope 
> Betreff: Re: [R] How to benchmark speed of load/readRDS correctly
> 
> Caching happens, both within the operating system and within the C
> standard library. Ostensibly the intent for those caches is to help
> performance, but you are right that different low-level caching algorithms
> can be a poor match for specific application level use cases such as copying
> files or parsing text syntax. However, the OS and even the specific file
> system drivers (e.g. ext4 on flash disk or FAT32 on magnetic media) can
> behave quite differently for the same application level use case, so a generic
> discussion at the R language level (this mailing list) can be almost 
> impossible
> to sort out intelligently.
> --
> Sent from my phone. Please excuse my brevity.
> 
> On August 22, 2017 7:11:39 AM PDT, J C Nash 
> wrote:
> >Not convinced Jeff is completely right about this not concerning R,
> >since I've found that the application language (R, perl, etc.) makes a
> >difference in how files are accessed by/to OS. He is certainly correct
> >that OS (and versions) are where the actual reading and writing
> >happens, but sometimes the call to those can be inefficient. (Sorry,
> >I've not got examples specifically for file reads, but had a case in
> >computation where there was an 800% i.e., 8 fold difference in
> >timing with R, which rather took my breath away. That's probably been
> >sorted now.) The difficulty in making general statements is that a
> >rather full set of comparisons over different commands, datasets, OS
> >and version variants is needed before the general picture can emerge.
> >Using microbenchmark when you need to find the bottlenecks is how I'd
> >proceed, which OP is doing.
> >
> >About 30 years ago, I did write up some preliminary work, never
> >published, on estimating the two halves of a copy, that is, the reading
> >from file and storing to "memory" or a different storage location. This
> >was via regression with a singular design matrix, but one can get a
> >minimal length least squares solution via svd. Possibly relevant today
> >to try to get at slow links on a network.
> >
> >JN
> >
> >On 2017-08-22 09:07 AM, Jeff Newmiller wrote:
> >> You need to study how reading files works in your operating system.
> >This question is not about R.
> >>
__
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] How to benchmark speed of load/readRDS correctly

2017-08-23 Thread raphael.felber
Hi Bill

Thanks for your answer and the explanations. I tried to use garbage collection 
but I'm still not satisfied with the result. Maybe the question was not stated 
clear enough. I want to test the speed of reading/loading of data into R when a 
'fresh' R session is started (or even after a new start of the computer).

To understand what really happens, I tried:
r1 <- sapply(1:1, function(x) { gc(); t <- system.time(n <- 
readRDS('file.Rdata'))[3]; rm(n); gc(); return(t)})

and found a similar behavior as you; here and then the time is much larger, but 
the times are not as stable as in your example. Highest values are up to 50 
times larger than most of the other times (8 sec vs 0.15 sec), even with 
garbage collection. I assume with the code above the time spent for garbage 
collection isn't measured.

However, the first iteration always takes the longest. I'm wondering if I 
should take the first value as best guess.

Cheers Raphael
Von: William Dunlap [mailto:wdun...@tibco.com]
Gesendet: Dienstag, 22. August 2017 19:13
An: Felber Raphael Agroscope 
Cc: r-help@r-project.org
Betreff: Re: [R] How to benchmark speed of load/readRDS correctly

Note that if you force a garbage collection each iteration the times are more 
stable.  However, on the average it is faster to let the garbage collector 
decide when to leap into action.

mb_gc <- microbenchmark::microbenchmark(gc(), { x <- as.list(sin(1:5e5)); x <- 
unlist(x) / cos(1:5e5) ; sum(x) }, times=1000, control=list(order="inorder"))
with(mb_gc, plot(time[expr!="gc()"]))
with(mb_gc, quantile(1e-6*time[expr!="gc()"], c(0, .5, .75, .9, .95, .99, 1)))
#   0%   50%   75%   90%   95%   99%  100%
# 59.33450  61.33954  63.43457  66.23331  68.93746  74.45629 158.09799



Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Tue, Aug 22, 2017 at 9:26 AM, William Dunlap 
> wrote:
The large value for maximum time may be due to garbage collection, which 
happens periodically.   E.g., try the following, where the unlist(as.list()) 
creates a lot of garbage.  I get a very large time every 102 or 51 iterations 
and a moderately large time more often

mb <- microbenchmark::microbenchmark({ x <- as.list(sin(1:5e5)); x <- unlist(x) 
/ cos(1:5e5) ; sum(x) }, times=1000)
plot(mb$time)
quantile(mb$time * 1e-6, c(0, .5, .75, .90, .95, .99, 1))
#   0%   50%   75%   90%   95%   99%  100%
# 59.04446  82.15453 102.17522 180.36986 187.52667 233.42062 249.33970
diff(which(mb$time > quantile(mb$time, .99)))
# [1] 102  51 102 102 102 102 102 102  51
diff(which(mb$time > quantile(mb$time, .95)))
# [1]  6 41  4 47  4 40  7  4 47  4 33 14  4 47  4 47  4 47  4 47  4 47  4  6 41
#[26]  4  6  7  9 25  4 47  4 47  4 47  4 22 25  4 33 14  4  6 41  4 47  4 22



Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Tue, Aug 22, 2017 at 5:53 AM, 
> 
wrote:
Dear all

I was thinking about efficient reading data into R and tried several ways to 
test if load(file.Rdata) or readRDS(file.rds) is faster. The files file.Rdata 
and file.rds contain the same data, the first created with save(d, ' 
file.Rdata', compress=F) and the second with saveRDS(d, ' file.rds', 
compress=F).

First I used the function microbenchmark() and was a astonished about the max 
value of the output.

FIRST TEST:
> library(microbenchmark)
> microbenchmark(
+   n <- readRDS('file.rds'),
+   load('file.Rdata')
+ )
Unit: milliseconds
  expr minlq
   meanmedianuq   
max  neval
n <- readRDS(fl1)106.5956  109.6457 237.3844  
117.8956  141.9921  10934.162   100
 load(fl2)  295.0654  301.8162335.6266  
308.3757  319.6965  1915.706  100

It looks like the max value is an outlier.

So I tried:
SECOND TEST:
> sapply(1:10, function(x) system.time(n <- readRDS('file.rds'))[3])
elapsed   elapsed   elapsed   elapsed   
elapsed   elapsed   elapsed   
elapsed elapsed   elapsed
  10.50   0.11   0.11   
0.11   0.10   0.11  
 0.11   0.11   0.12 
  0.12
> sapply(1:10, function(x) system.time(load'flie.Rdata'))[3])
elapsed   elapsed   elapsed   elapsed   
elapsed   elapsed   elapsed   
elapsed elapsed   elapsed
   1.86

[R] strange nlme augpred behaviour

2017-08-23 Thread PIKAL Petr
Dear all

I encountered strange behaviour of augPred with virtually the same data

First I made groupedData object.
> mar.g<-groupedData(rutilizace~doba|int, data=mar)

When I perform nlme on complete dataset I get an error with augPred
> fit<-nlsList(rutilizace~SSasymp(doba, Asym, R0,  lrc), data=mar.g)
Warning message:
c("1 error caught in nls(y ~ cbind(1 - exp(-exp(lrc) * x), exp(-exp(lrc) * x)), 
data = xy, : singular gradient", "1 error caught in start = list(lrc = 
lrc), algorithm = \"plinear\"): singular gradient")
> fit1<-nlme(fit)
> plot(augPred(fit1, level=0:1))
Error in `[[<-.data.frame`(`*tmp*`, nm, value = c(6L, 6L, 6L, 6L, 8L,  :
  replacement has 60 rows, data has 12

However when I make subset of my data to keep only affected collumns.
>
> mar.g<-mar.g[,c(3,4, 21)]

> fit<-nlsList(rutilizace~SSasymp(doba, Asym, R0,  lrc), data=mar.g)
Warning message:
c("1 error caught in nls(y ~ cbind(1 - exp(-exp(lrc) * x), exp(-exp(lrc) * x)), 
data = xy, : singular gradient", "1 error caught in start = list(lrc = 
lrc), algorithm = \"plinear\"): singular gradient")
> fit2<-nlme(fit)
> plot(augPred(fit2, level=0:1))
>
augPred works as a charm.

When I compare fit1 and fit2 they are equal
> all.equal(fit1, fit2)
[1] TRUE
>

Does anybody know where I should try to search for problems?

Best regards
Petr

> traceback()
6: stop(sprintf(ngettext(N, "replacement has %d row, data has %d",
   "replacement has %d rows, data has %d"), N, nrows), domain = NA)
5: `[[<-.data.frame`(`*tmp*`, nm, value = c(1L, 1L, 1L, 1L, 5L,
   5L, 5L, 5L, 9L, 9L, 9L, 9L, 4L, 4L, 4L, 4L, 8L, 8L, 8L, 8L, 12L,
   12L, 12L, 12L, 3L, 3L, 3L, 3L, 7L, 7L, 7L, 7L, 11L, 11L, 11L,
   11L, 1L, 1L, 1L, 1L, 5L, 5L, 5L, 5L, 9L, 9L, 9L, 9L, 2L, 2L,
   2L, 2L, 6L, 6L, 6L, 6L, 10L, 10L, 10L, 10L))
4: `[[<-`(`*tmp*`, nm, value = c(1L, 1L, 1L, 1L, 5L, 5L, 5L, 5L,
   9L, 9L, 9L, 9L, 4L, 4L, 4L, 4L, 8L, 8L, 8L, 8L, 12L, 12L, 12L,
   12L, 3L, 3L, 3L, 3L, 7L, 7L, 7L, 7L, 11L, 11L, 11L, 11L, 1L,
   1L, 1L, 1L, 5L, 5L, 5L, 5L, 9L, 9L, 9L, 9L, 2L, 2L, 2L, 2L, 6L,
   6L, 6L, 6L, 10L, 10L, 10L, 10L))
3: gsummary(data, groups = groups)
2: augPred.lme(fit1, level = 0:1)
1: augPred(fit1, level = 0:1)

> version
   _
platform   x86_64-w64-mingw32
arch   x86_64
os mingw32
system x86_64, mingw32
status Under development (unstable)
major  3
minor  5.0
year   2017
month  07
day31
svn rev73003
language   R
version.string R Under development (unstable) (2017-07-31 r73003)
nickname   Unsuffered Consequences
>

Package nlme version 3.1-131



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

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

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

In case that this e-mail forms part of business dealings:
- the sender reserves the right to end negotiations about entering into a 
contract in any time, for any reason, and without stating any reasoning.
- if the e-mail contains an offer, the recipient is entitled to immediately 
accept such offer; The sender of this e-mail (offer) excludes any acceptance of 
the offer on the part of the 

Re: [R] boot.stepAIC fails with computed formula

2017-08-23 Thread Stephen O'hagan
As far as I can tell from the docs, strt & frm1 should be the simplest model, 
'y1~1', since we’re doing stepAIC in the forward direction.

I found that using 'y1~.' for frm2 doesn't always work, hence the explicit 
enumeration of the xvars into a full formula. I had forgotten that you don't 
need the +1 term.

With real data, if you start from the most complex model and go backwards, 
stepAIC just over-fits and gives up  [for same reason I set the steps 
parameter].

Cheers,
SGO

-Original Message-
From: Bert Gunter [mailto:bgunter.4...@gmail.com] 
Sent: 22 August 2017 18:51
To: Stephen O'hagan 
Cc: r-help@r-project.org
Subject: Re: [R] boot.stepAIC fails with computed formula

SImplify your call to lm using the "." argument instead of manipulating 
formulas.
> strt <- lm(y1 ~ ., data = dat)

and you do not need to explicitly specify the "1+" on the rhs for lm, so

> frm2<-as.formula(paste(trg," ~  ", paste(xvars,collapse = "+")))
works fine, too.

Anyway, doing this gives (but see end of output)"


bst <- boot.stepAIC(strt,data =
dat,B=50,alpha=0.05,direction='forward',steps=limit,
  scope=list(lower=frm1,upper=frm2))

> bst

Summary of Bootstrapping the 'stepAIC()' procedure for

Call:
lm(formula = y1 ~ ., data = dat)

Bootstrap samples: 50
Direction: forward
Penalty: 2 * df

Covariates selected
   (%)
x1 100
x2 100
x3 100
x4 100
x5 100
x6 100
x7 100
x8 100

Coefficients Sign
   + (%) - (%)
x3   100 0
x6   100 0
x8   100 0
x19010
x28614
x76238
x44456
x5 0   100

Stat Significance
   (%)
x3 100
x6 100
x8 100
x5  34
x2  20
x1  16
x4  10
x7   4


The stepAIC() for the original data-set gave

Call:
lm(formula = y1 ~ x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8, data = dat)

Coefficients:
(Intercept)   x1   x2   x3   x4   x5
  42.008824 0.012304 0.010925 0.976469-0.005183-0.021041
 x6   x7   x8
   2.000649 0.004461 3.007071


Stepwise Model Path
Analysis of Deviance Table

Initial Model:
y1 ~ x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8

Final Model:
y1 ~ x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8


  Step Df Deviance Resid. Df Resid. Dev AIC
1191   16.14592 -485.33


HOWEVER, I do not know why your failed calls failed. In view of the above, it 
appears to be a bug in the formula interface, so if you do not get a 
satisfactory answer here (i.e. I am wrong about this), you should contact the 
maintainer.

Cheers,
Bert


Bert Gunter

"The trouble with having an open mind is that people keep coming along and 
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Tue, Aug 22, 2017 at 10:08 AM, Steve O'Hagan  
wrote:
> The error is "the model fit failed in 50 bootstrap samples
> Error: non-character argument"
>
> Cheers,
> SOH.
>
>
> On 22/08/2017 17:52, Bert Gunter wrote:
>>
>> Failed?  What was the error message?
>>
>> Cheers,
>>
>> Bert
>>
>>
>> Bert Gunter
>>
>> "The trouble with having an open mind is that people keep coming 
>> along and sticking things into it."
>> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>>
>>
>> On Tue, Aug 22, 2017 at 8:17 AM, Stephen O'hagan 
>>  wrote:
>>>
>>> I'm trying to use boot.stepAIC for feature selection; I need to be 
>>> able to specify the name of the dependent variable programmatically, 
>>> but this appear to fail:
>>>
>>> In R-Studio with MS R Open 3.4:
>>>
>>> library(bootStepAIC)
>>>
>>> #Fake data
>>> n<-200
>>>
>>> x1 <- runif(n, -3, 3)
>>> x2 <- runif(n, -3, 3)
>>> x3 <- runif(n, -3, 3)
>>> x4 <- runif(n, -3, 3)
>>> x5 <- runif(n, -3, 3)
>>> x6 <- runif(n, -3, 3)
>>> x7 <- runif(n, -3, 3)
>>> x8 <- runif(n, -3, 3)
>>> y1 <- 42+x3 + 2*x6 + 3*x8 + runif(n, -0.5, 0.5)
>>>
>>> dat <- data.frame(x1,x2,x3,x4,x5,x6,x7,x8,y1)
>>> #the real data won't have these names...
>>>
>>> cn <- names(dat)
>>> trg <- "y1"
>>> xvars <- cn[cn!=trg]
>>>
>>> frm1<-as.formula(paste(trg,"~1"))
>>> frm2<-as.formula(paste(trg,"~ 1 + ",paste(xvars,collapse = "+")))
>>>
>>> strt=lm(y1~1,dat) # boot.stepAIC Works fine
>>>
>>> #strt=do.call("lm",list(frm1,data=dat)) ## boot.stepAIC FAILS ##
>>>
>>> #strt=lm(frm1,dat) ## boot.stepAIC FAILS ##
>>>
>>> limit<-5
>>>
>>>
>>> stp=stepAIC(strt,direction='forward',steps=limit,
>>>  scope=list(lower=frm1,upper=frm2))
>>>
>>> bst <-
>>> boot.stepAIC(strt,dat,B=50,alpha=0.05,direction='forward',steps=limit,
>>>  scope=list(lower=frm1,upper=frm2))
>>>
>>> b1 <- bst$Covariates
>>> ball <- data.frame(b1)
>>> names(ball)=unlist(trg)
>>>
>>> Any ideas?
>>>
>>> Cheers,
>>> SOH
>>>
>>>
>>>  [[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 

Re: [R] boot.stepAIC fails with computed formula

2017-08-23 Thread Stephen O'hagan
Until I get a fix that works, a work-around would be to rename the 'y1' column, 
used a fixed formula, and rename it back afterwards.

Thanks for your help.
SGO.

-Original Message-
From: Bert Gunter [mailto:bgunter.4...@gmail.com] 
Sent: 22 August 2017 20:38
To: Stephen O'hagan 
Cc: r-help@r-project.org
Subject: Re: [R] boot.stepAIC fails with computed formula

OK, here's the problem. Continuing with your example:

strt1 <- lm(y1 ~1, dat)
strt2 <- lm(frm1,dat)


> strt1

Call:
lm(formula = y1 ~ 1, data = dat)

Coefficients:
(Intercept)
  41.73

> strt2

Call:
lm(formula = frm1, data = dat)

Coefficients:
(Intercept)
  41.73


Note that the formula objects of the lm object are different: strt2 does not 
evaluate the formula. So presumably boot.step.AIC does no evaluation and 
therefore gets confused with the errors you saw. So you need to get the 
evaluated formula into the lm object. This can be done, e.g. via:

> strt2 <- eval(substitute(lm(form,data = dat), list(form = frm1)))

## yielding

> strt2

Call:
lm(formula = y1 ~ 1, data = dat)

Coefficients:
(Intercept)
  41.73

So this looks like it should fix the problem, but alas no, the boot.stepAIC 
call still fails with the same error message. Here's why:

> identical(strt$call, strt2$call)
[1] FALSE

So one might rightfully ask, what the heck is going on here?! Further digging:

> str(strt$call)
 language lm(formula = y1 ~ 1, data = dat)

> str(strt2$call)
 language lm(formula = y1 ~ 1, data = dat)

These certainly look identical! -- but of course they're not:

> names(strt$call)
[1] """formula" "data"
> names(strt2$call)
[1] """formula" "data"

So the difference must lie in the formula component, right? ...

> strt$call$formula
y1 ~ 1
> strt2$call$formula
y1 ~ 1

So, thus far, huhh? But..

> class(strt2$call$formula)
[1] "formula"

> class(strt$call$formula)
[1] "call"

So I think therein lies the critical difference that is screwing things up. 
NOTE: If I am wrong about this someone **PLEASE** correct me.

I see no clear workaround for this other than to explicitly avoid
passing a formula in the lm() call with y~1 or y ~ .   I think the
real fix is to make the  boot.stepAIC function smarter in how it handles its 
formula argument, and that is above my paygrade (and degree of interest) . You 
should probably email the maintainer, who may not monitor this list. But give 
it a day or so to give someone else a chance to correct me if I'm wrong.


HTH.

Cheers,

Bert
Bert Gunter

"The trouble with having an open mind is that people keep coming along and 
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Tue, Aug 22, 2017 at 8:17 AM, Stephen O'hagan  
wrote:
> I'm trying to use boot.stepAIC for feature selection; I need to be able to 
> specify the name of the dependent variable programmatically, but this appear 
> to fail:
>
> In R-Studio with MS R Open 3.4:
>
> library(bootStepAIC)
>
> #Fake data
> n<-200
>
> x1 <- runif(n, -3, 3)
> x2 <- runif(n, -3, 3)
> x3 <- runif(n, -3, 3)
> x4 <- runif(n, -3, 3)
> x5 <- runif(n, -3, 3)
> x6 <- runif(n, -3, 3)
> x7 <- runif(n, -3, 3)
> x8 <- runif(n, -3, 3)
> y1 <- 42+x3 + 2*x6 + 3*x8 + runif(n, -0.5, 0.5)
>
> dat <- data.frame(x1,x2,x3,x4,x5,x6,x7,x8,y1)
> #the real data won't have these names...
>
> cn <- names(dat)
> trg <- "y1"
> xvars <- cn[cn!=trg]
>
> frm1<-as.formula(paste(trg,"~1"))
> frm2<-as.formula(paste(trg,"~ 1 + ",paste(xvars,collapse = "+")))
>
> strt=lm(y1~1,dat) # boot.stepAIC Works fine
>
> #strt=do.call("lm",list(frm1,data=dat)) ## boot.stepAIC FAILS ##
>
> #strt=lm(frm1,dat) ## boot.stepAIC FAILS ##
>
> limit<-5
>
>
> stp=stepAIC(strt,direction='forward',steps=limit,
> scope=list(lower=frm1,upper=frm2))
>
> bst <- boot.stepAIC(strt,dat,B=50,alpha=0.05,direction='forward',steps=limit,
> scope=list(lower=frm1,upper=frm2))
>
> b1 <- bst$Covariates
> ball <- data.frame(b1)
> names(ball)=unlist(trg)
>
> Any ideas?
>
> Cheers,
> SOH
>
>
> [[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.


Re: [R] Flummoxed by gsub().

2017-08-23 Thread Rolf Turner

On 23/08/17 18:41, PIKAL Petr wrote:

Hi Rolf

I am not at all an expert in regex but

gsub("[[:alpha:]]","",x)

Works as you expected. Do not ask me why.


Thanks Petr.  Stefan Evert's explanation clarified the issue.  Which I 
must say *needed* some clarification!


cheers,

Rolf

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] Flummoxed by gsub().

2017-08-23 Thread Rolf Turner


On 23/08/17 18:33, Stefan Evert wrote:




On 23 Aug 2017, at 07:45, Rolf Turner  wrote:

My reading of ?regex led me to believe that

gsub("[:alpha:]","",x)

should give the result that I want.


That's looking for any of the characters a, l, p, h, : .


OK.  I see that now.  I don't think that it's really stated anywhere 
that to search for (and possibly change) any one of a string of 
characters you enclose that string of characters in brackets [  ].


The first example from ?grep makes this "clear" (for some value of the 
word "clear") once you understand what this example is on about.


So it's "obvious" once you've been shown, and totally opaque until then.


What you meant to say was

gsub("[[:alpha:]]","",x)

i.e. the character class [:alpha:] within a character set.


Yup.  Got it.  Thanks very much.

cheers,

Rolf

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] Rounding of problem with sum command in R

2017-08-23 Thread Marc Girondot via R-help

Le 22/08/2017 à 16:26, niharika singhal a écrit :

Hello I have a vector
v=c(0.0886,0.1744455,0.1379778,0.1209769,0.1573065,0.1134463,0.2074027)
when i do
sum(v)
or
0.0886+0.1744455+0.1379778+0.1209769+0.1573065+0.1134463+0.2074027
i am getting output as 1
But if i add them manually i get
1.0026
I do not want to round of my value since it effect my code further
Can anyone suggest how can i avoid this.

Thanks & Regards
Niharika Singhal

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


> print(sum(v), digits = 12)
[1] 1.0016

__
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] likert Package

2017-08-23 Thread Uwe Ligges

If this is not docuemnted that way, write to the package maintainer.

Best,
Uwe Ligges




On 23.08.2017 02:51, Jeff Reichman   wrote:

R- Help Forum

  


Working with the "likert" package and find that my "bar" graphs are
backwards (see attached)

  


summary(results)


   Item low neutral high meansd

4   Q4   5  15   80 2.75 0.5501196

5   Q5  20  40   40 2.20 0.7677719

1   Q1  65  305 1.40 0.5982430

3   Q3   5  905 2.00 0.3244428

2   Q2  90  100 1.10 0.3077935

  


results <- likert(data[,2:6], grouping = data$Group)
plot(results, type = "bar", centered = FALSE, group.order = c("Band 3",

"Band 4"))
  
In the attached figure the percentages appear correct but the bars are

backwards (or appear to be backwards)

  



Figure.png




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


[R] Pull data from Tally 9.1 to R studio

2017-08-23 Thread jagan krishnan via R-help
Hi all,
This is Jagan.i have been provided a task of analyzing sales data of a company 
in R programming...Just wanted to know,how can I pull Tally 9.1 software data 
into R programming dataframe.
Waiting eagerly for your inputs.
With Regards,Jagannathan Krishnan
Sent from Yahoo Mail on Android 
 
  On Tue, Aug 22, 2017 at 10:47 AM, jagan krishnan 
wrote:   Hi all,
This is Jagan.i have been provided a task of analyzing sales data of a company 
in R programming...Just wanted to know,how can I pull Tally 9.1 software data 
into R programming dataframe.
Waiting eagerly for your inputs.
With Regards,Jagannathan Krishnan

Sent from Yahoo Mail on Android  

[[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] Data too big for a specific library package to handle

2017-08-23 Thread Kevin Parent via R-help
I know there are ways around the 'can't allocate a vector of size x GB' errors, 
but I'm stumped. 
So my raw data has >7 million rows and eight columns. That's not a problem 
itself.
Using the confreq package (for configural frequency analysis), I take my data 
and run it through the package's dat2fre function. This converts to a class 
called 'Pfreq.'  (Looks like a data frame to me, but R recognizes it as 
different.) It is now smaller, a little less than a million rows, and one 
column added. It's one row for every possible permutation, with the new column 
a frequency count, though in my case, 99% are 0s.
However, this data is meaningless by itself and I need to run it through the 
packages' CFA command for the main analysis, but when I do, I invariably get 
the 'can't allocate' error. The CFA command only works with the Pfreq class as 
input.
I usually run 64-bit R under Linux but get the error. So I used a Windows 
machine at work (forget which version of Windows, but it runs 64-bit R), but I 
still get the error.
The problem with most memory allocation workarounds is that what I'm doing 
creates a non-standard, library-specific data structure. Most workarounds are 
designed for very large vectors, data frames, lists, matrices, etc., not for 
very large 'Pfreqs'.
Any help?
The script below will simulate my data set with random data, but it takes 
several minutes to run and may eat up your resources until it's finished.
rm(list=ls(all=T))require(confreq)set.seed(1066)
observations<- 
as.factor(rep(replicate(6,paste(sample(c(LETTERS,letters),sample(15)),collapse=''),simplify=vector),times=100))source<-as.factor(c(rep('A',times=300),rep('B',times=300)))
 #(observations come from one of two sources)
factor.1<-as.factor(replicate(600,sample(c(TRUE,FALSE),1)))factor.2<-as.factor(replicate(600,sample(c(TRUE,FALSE),1)))factor.3<-as.factor(replicate(600,sample(c(TRUE,FALSE),1)))factor.4<-as.factor(replicate(600,sample(c(TRUE,FALSE),1)))factor.5<-as.factor(replicate(600,sample(c(TRUE,FALSE),1)))factor.6<-as.factor(replicate(600,sample(c(TRUE,FALSE),1)))factor.7<-as.factor(replicate(600,sample(c(TRUE,FALSE),1)))factor.8<-as.factor(replicate(600,sample(c(TRUE,FALSE),1)))
x<-data.frame(observations,source,factor.1, factor.2, factor.3, factor.4, 
factor.5, factor.6, factor.7, factor.8)
x<-dat2fre(x)
analysis<-CFA(x) #error: cannot allocate vector of size 2.1 Gb (the error 
message for the real data indicates 56 Gb)
 _ Kevin Parent, Ph.D Korea Maritime University Vice Chairman of Education 
and Training, Korea Toastmasters http://grou.ps/koreatoastmasters 
Schoolmasters, http://grou.ps/schoolmasters/home
[[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] Flummoxed by gsub().

2017-08-23 Thread PIKAL Petr
Hi Rolf

I am not at all an expert in regex but

gsub("[[:alpha:]]","",x)

Works as you expected. Do not ask me why.

Cheers
Petr


> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Rolf Turner
> Sent: Wednesday, August 23, 2017 7:46 AM
> To: r-help mailing list 
> Subject: [R] Flummoxed by gsub().
>
>
> I have a vector (say "x") of the form
>
>  [1] "mung5"  "mung10" "mung20" "gorp5"  "gorp10" "gorp20"
>
> I want to extract just the numbers (strings of digits) that appear at the end 
> of
> the strings in "x".
>
> My reading of ?regex led me to believe that
>
>  gsub("[:alpha:]","",x)
>
> should give the result that I want.  However it returns
>
>  [1] "mung5"  "mung10" "mung20" "gor5"   "gor10"  "gor20"
>
> i.e. it chops the last letter out of the "gorp" string, but nothing else.
>
> I am completely bewildered by this behaviour and can see no rationale for it
> nor any way to adjust my syntax to get what I want.
>
> A bit of Googling led me to the information that
>
>  gsub("\\D","",x)
>
> should work, and indeed it does, giving:
>
>  [1] "5"  "10" "20" "5"  "10" "20"
>
> OM!  (Apparently "\D" means *not* a digit.)
>
> So I have *a* solution to my problem.  However I would really like to know why
> the  the first idea I tried did not work and what it is 
> actually
> *doing*!
>
> Anybody?
>
> cheers,
>
> Rolf Turner
>
> --
> Technical Editor ANZJS
> Department of Statistics
> University of Auckland
> Phone: +64-9-373-7599 ext. 88276
>
> __
> 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.


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

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

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

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

Re: [R] Flummoxed by gsub().

2017-08-23 Thread Stefan Evert

> On 23 Aug 2017, at 07:45, Rolf Turner  wrote:
> 
> My reading of ?regex led me to believe that
> 
>gsub("[:alpha:]","",x)
> 
> should give the result that I want. 

That's looking for any of the characters a, l, p, h, : .

What you meant to say was

gsub("[[:alpha:]]","",x)

i.e. the character class [:alpha:] within a character set.

Best,
Stefan

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