Re: [R] ASExtras library

2018-07-10 Thread Duncan Mackay
Hi

I was trying to find a file on my computer when the ASReml directory showed
up on the directory tree. 

The ASExtras may be part of the R interface/standalone of ASReml available
in Splus as well.
I think the interface to Splus came first

>From what I can remember ASReml R extra packages had a different name than
ASExtras. Is it the Splus distributed package name?
There is an asremlPlus package that is still valid 

Regards

Duncan 

Duncan Mackay
Department of Agronomy and Soil Science
University of New England
Armidale NSW 2350

-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of radmuzom .
Sent: Thursday, 5 July 2018 07:34
To: David Winsemius; Mehrshad Barary; r-help@r-project.org
Subject: Re: [R] ASExtras library

The package appears to be referenced in the package "agridat" -
ftp://cran.r-project.org/pub/R/web/packages/agridat/agridat.pdf (Pg 55).
However, even I tried searching for it and there seems to be no reference
other than this source.

Regards,
radmuzom

From: R-help  on behalf of David Winsemius

Sent: Wednesday, July 4, 2018 9:22 PM
To: Mehrshad Barary
Cc: r-help@r-project.org
Subject: Re: [R] ASExtras library
  


> On Jul 3, 2018, at 6:34 PM, Mehrshad Barary  wrote:
> 
> Hi Everyone,
> 
> Does anybody know how I can get ASExtras library?

It would be helpful if you would provide information about your reasons for
assuming this package's existence. Cannot find it in CRAN (including a
search for 'ASExtra'), BioConductor, GitHub, or the Archives, or even with
Google for that matter.

https://cran.r-project.org/src/contrib/Archive/

And within R parlance 'library' not a synonym for 'package'. Libraries are
where you store packages. And `library('pkg_name')` is a command for loading
a package.


> Thanks
> Mehrshad
> 
> -- 
> Mehrshad Barary
> Senior Lecturer in Crop Ecophysiology
> Department of Agronomy and Plant Breeding
> Faculty of Agriculture
> Ilam University
> Tel: (+98)8412227019-21
> Fax: (+98)8412227015
> 
>    [[alternative HTML version deleted]]

And R help is a plain-text mailing list. Please read the Posting Guide.

> 
> __
> 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-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] Generate N random numbers with a given probability and condition

2018-07-10 Thread Bert Gunter
You need to heed Rolf's advice.

N random integers by definition cannot have a fixed sum.

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, Jul 10, 2018 at 5:11 PM, Nelly Reduan  wrote:

> Thank you very much for your reply.
>
>
> By omitting the probability, the expected results could be:
>
>
> c(2, 0, 0, 0, 0, 0, 1, 0, 5, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0)
>
>
> c(0, 0, 1, 0, 0, 1, 1, 0, 6, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0)
>
>
> If I omit the probability, I would like to generate N random positive
> integers that sum to M and the integers would be selected from a uniform
> distribution.
>
>
> Many thanks for your time
>
> Nell
>
>
> 
> De : Rolf Turner 
> Envoyé : mercredi 4 juillet 2018 16:11:11
> À : Nelly Reduan
> Cc : r-help@r-project.org
> Objet : Re: [R] Generate N random numbers with a given probability and
> condition
>
>
> On 05/07/18 10:21, Nelly Reduan wrote:
>
> > Dear all,
> >
> > I would like to generate N random numbers with a given probability and
> condition but I'm not sure how to do this.
> > For example, I have N = 20 and the vector from which to choose is seq(0,
> 10, 1). I have tested:
> >
> > x <- sample(seq(0, 10, 1), 20, replace=TRUE, prob=rep(0.28,
> times=length(seq(0, 10, 1
> >
> > But I don�t know how to put the condition sum(x) <= max(seq(0, 10, 1)).
> > Many thanks for your time.
>
> Your thinking requires considerable clarification.
>
> (1) Note that seq(0,10,1) is just 0, 1, 2, ..., 10.
>
> (2) Hence length(seq(0,10,1)) is 11.
>
> (3) Likewise max(seq(0,10,1)) is 10.
>
> (4) Your prob vector is *constant* --- so specifying "prob" makes
>  no difference --- the result is the same as if you omitted "prob".
>
> (5) You need to think carefully about what you really mean by "random".
>  In what way do you want the final result to be "random"?
>
> I expect that the lecturer who assigned this problem to you  needs to
> clarify his/her thinking as well.
>
> cheers,
>
> Rolf Turner
>
> --
> Technical Editor ANZJS
> Department of Statistics
> University of Auckland
> Phone: +64-9-373-7599 ext. 88276
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/
> posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


Re: [R] Generate N random numbers with a given probability and condition

2018-07-10 Thread Jim Lemon
Hi Nell,
I may not have the right idea about this, but I think you need to do
this in two steps if it can be done. Let's say you want a sequence of
20 (N) numbers between 0 and 10 that sums to 10 (M). You can enumerate
the monotonically increasing sequences like this:

c(0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1)
c(0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,2)
...
c(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10)

So if you select one of these sequences at random, there will be a
further set of sequences that are permutations of it. By randomly
selecting one of those permutations, I think you can solve your
problem. However, this is going to be computationally intensive, with
the set of permutations being very large for large N. Here is an
example using N = M = 5:

# enumerate the sequences = M
rs5<-list(c(1,1,1,1,1),c(0,1,1,1,2),c(0,0,1,1,3),c(0,0,0,1,4),
 c(0,0,1,2,2),c(0,0,0,2,3),c(0,0,0,0,5))
library(crank)
# generate the permutations for one sequence (120 in this case)
rs5_s1<-permute(rs5[[sample(1:length(rs5),1)]])
# select one of the permutations at random
rs5_s1[sample(1:dim(rs5_s1)[1],1),]
[1] 4 0 1 0 0

Jim

On Wed, Jul 11, 2018 at 10:11 AM, Nelly Reduan  wrote:
> Thank you very much for your reply.
>
>
> By omitting the probability, the expected results could be:
>
>
> c(2, 0, 0, 0, 0, 0, 1, 0, 5, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0)
>
>
> c(0, 0, 1, 0, 0, 1, 1, 0, 6, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0)
>
>
> If I omit the probability, I would like to generate N random positive 
> integers that sum to M and the integers would be selected from a uniform 
> distribution.
>
>
> Many thanks for your time
>
> Nell
>
>
> 
> De : Rolf Turner 
> Envoyé : mercredi 4 juillet 2018 16:11:11
> À : Nelly Reduan
> Cc : r-help@r-project.org
> Objet : Re: [R] Generate N random numbers with a given probability and 
> condition
>
>
> On 05/07/18 10:21, Nelly Reduan wrote:
>
>> Dear all,
>>
>> I would like to generate N random numbers with a given probability and 
>> condition but I'm not sure how to do this.
>> For example, I have N = 20 and the vector from which to choose is seq(0, 10, 
>> 1). I have tested:
>>
>> x <- sample(seq(0, 10, 1), 20, replace=TRUE, prob=rep(0.28, 
>> times=length(seq(0, 10, 1
>>
>> But I don�t know how to put the condition sum(x) <= max(seq(0, 10, 1)).
>> Many thanks for your time.
>
> Your thinking requires considerable clarification.
>
> (1) Note that seq(0,10,1) is just 0, 1, 2, ..., 10.
>
> (2) Hence length(seq(0,10,1)) is 11.
>
> (3) Likewise max(seq(0,10,1)) is 10.
>
> (4) Your prob vector is *constant* --- so specifying "prob" makes
>  no difference --- the result is the same as if you omitted "prob".
>
> (5) You need to think carefully about what you really mean by "random".
>  In what way do you want the final result to be "random"?
>
> I expect that the lecturer who assigned this problem to you  needs to
> clarify his/her thinking as well.
>
> cheers,
>
> Rolf Turner
>
> --
> Technical Editor ANZJS
> Department of Statistics
> University of Auckland
> Phone: +64-9-373-7599 ext. 88276
>
> [[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] Generate N random numbers with a given probability and condition

2018-07-10 Thread Nelly Reduan
Thank you very much for your reply.


By omitting the probability, the expected results could be:


c(2, 0, 0, 0, 0, 0, 1, 0, 5, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0)


c(0, 0, 1, 0, 0, 1, 1, 0, 6, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0)


If I omit the probability, I would like to generate N random positive integers 
that sum to M and the integers would be selected from a uniform distribution.


Many thanks for your time

Nell



De : Rolf Turner 
Envoyé : mercredi 4 juillet 2018 16:11:11
À : Nelly Reduan
Cc : r-help@r-project.org
Objet : Re: [R] Generate N random numbers with a given probability and condition


On 05/07/18 10:21, Nelly Reduan wrote:

> Dear all,
>
> I would like to generate N random numbers with a given probability and 
> condition but I'm not sure how to do this.
> For example, I have N = 20 and the vector from which to choose is seq(0, 10, 
> 1). I have tested:
>
> x <- sample(seq(0, 10, 1), 20, replace=TRUE, prob=rep(0.28, 
> times=length(seq(0, 10, 1
>
> But I don�t know how to put the condition sum(x) <= max(seq(0, 10, 1)).
> Many thanks for your time.

Your thinking requires considerable clarification.

(1) Note that seq(0,10,1) is just 0, 1, 2, ..., 10.

(2) Hence length(seq(0,10,1)) is 11.

(3) Likewise max(seq(0,10,1)) is 10.

(4) Your prob vector is *constant* --- so specifying "prob" makes
 no difference --- the result is the same as if you omitted "prob".

(5) You need to think carefully about what you really mean by "random".
 In what way do you want the final result to be "random"?

I expect that the lecturer who assigned this problem to you  needs to
clarify his/her thinking as well.

cheers,

Rolf Turner

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

[[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] Revolutions blog: June 2018 roundup

2018-07-10 Thread David Smith (CDA) via R-help
Since 2008, Microsoft staff and guests have written about R at the Revolutions
blog (http://blog.revolutionanalytics.com) and every month I post a summary of
articles from the previous month of particular interest to readers of r-help.

In case you missed them, here are some articles related to R from the
month of June:

An animated visualization of global migration, created in R by Guy Abel:
http://blog.revolutionanalytics.com/2018/06/global-migration-animated-with-r.html

My take on the question, Should you learn R or Python for data science?
http://blog.revolutionanalytics.com/2018/06/python-or-r.html

The BBC and Financial Times use R -- without post-processing -- for publication
graphics: http://blog.revolutionanalytics.com/2018/06/ft-bbc-uses-r.html

"Handling Strings in R", a free e-book by Gaston Sanchez, has been updated:
http://blog.revolutionanalytics.com/2018/06/handling-strings-with-r.html

My AI, Machine Learning and Data Science roundup for June 2018:
http://blog.revolutionanalytics.com/2018/06/ai-roundup-june-2018.html

The PYPL Popularity of Languages Index ranks R as the 7th most popular
programming language: 
http://blog.revolutionanalytics.com/2018/06/pypl-programming-language-trends.html

The "lime" package provides tools for interpreting machine learning models in R:
http://blog.revolutionanalytics.com/2018/06/lime-package.html

An R vignette by Paige Bailey on detecting unconscious bias in predictive
models: http://blog.revolutionanalytics.com/2018/06/understanding-bias.html

Microsoft R Open 3.5.0 has been released
http://blog.revolutionanalytics.com/2018/06/microsoft-r-open-350-now-available.html
(with a subsequent fix for Debian systems:
http://blog.revolutionanalytics.com/2018/06/hotfix-for-mro-350-on-linux.html)

Slides from the webinar, What's New in Azure for Machine Learning and AI:
http://blog.revolutionanalytics.com/2018/06/whats-new-in-azure-for-machine-learning-and-ai.html

And some general interest stories (not necessarily related to R):

* The Curvature Blindness Illusion:
  http://blog.revolutionanalytics.com/2018/06/because-its-friday-wavy-lines.html

* Lioness v Wrestlers in tug-of-war:
  
http://blog.revolutionanalytics.com/2018/06/because-its-friday-the-lioness-sleeps-tonight.html

* A comedian imagines an AI writing a TV commercial:
  
http://blog.revolutionanalytics.com/2018/06/because-its-friday-olive-garden.html

* A fur seal, transcribed:
  http://blog.revolutionanalytics.com/2018/06/because-its-friday-sealese.html

* An architecture error and a near-disaster in NYC:
  
http://blog.revolutionanalytics.com/2018/06/because-its-friday-buildings-shake.html

As always, thanks for the comments and please keep sending suggestions to
me at david...@microsoft.com or via Twitter (I'm @revodavid).

Cheers,
# David

-- 
David M Smith 
Developer Advocate, Microsoft Cloud & Enterprise 
Tel: +1 (312) 9205766 (Chicago IL, USA)
Twitter: @revodavid | Blog:  http://blog.revolutionanalytics.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] select.list cuts results to 100 characters on Win 10 when graphics = TRUE

2018-07-10 Thread Sergei Ko
mstring1 <- c("123456789012345678901234567890123456789012345678901234567890
123456789012345678901234567890123456789012345678901234567890")

mstring2 <- c("123456789012345678901234567890123456789012345678901234567890
1234567890123456789012345678901234567890123456789012345678901234567890")


vec.in <- c(mstring1,mstring2)



res1 <- select.list(vec.in, graphics = TRUE)

res2 <- select.list(vec.in, graphics = FALSE)



nchar(res1)

nchar(res2)



platform   x86_64-w64-mingw32
arch   x86_64
os mingw32
system x86_64, mingw32
status
major  3
minor  5.0
year   2018
month  04
day23
svn rev74626
language   R
version.string R version 3.5.0 (2018-04-23)
nickname   Joy in Playing

[[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] Something simple not working in group_by

2018-07-10 Thread Sumitrajit Dhar
Hello everyone,

I figured it out late last night. I was loading both dplyr and plyr and that 
was causing the problem. Loading plyr after dplyr leads to the faulty behavior. 
Just loading dplyr gives you expected behavior. Sorry for the confusion and 
false alarm.

Regards,
Sumit

> On Jul 10, 2018, at 2:48 AM, Eric Berger  wrote:
> 
> Hi Sumit,
> I was not able to reproduce this problem.
> I tried it in both R 3.5.1 and R 3.4.4. 
> Both gave the expected output (which differs from yours.)
> 
> Eric
> 
> 
> On Tue, Jul 10, 2018 at 1:32 AM, Bert Gunter  > wrote:
> Dunno.
> 
> But if I understand correctly, here's a base R way to do it:
> 
> (## using your m)
> 
> > m$total <- with(m,ave(score,id,FUN = cumsum))
> > m
>   id score total
> 1  1 6 6
> 2  1 612
> 3  2 6 6
> 4  2 3 9
> 5  3 3 3
> 6  3 3 6
> 
> 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 Mon, Jul 9, 2018 at 2:35 PM, Sumitrajit Dhar  >
> wrote:
> 
> > Hi Folks,
> >
> > I am trying to get a group_by cumsum using:
> >
> > R version 3.5.0 (2018-04-23) -- "Joy in Playing"
> > Copyright (C) 2018 The R Foundation for Statistical Computing
> > Platform: x86_64-apple-darwin15.6.0 (64-bit)
> >
> > Here is an example of a simple construct that is not working.
> >
> > m <- data.frame( id = rep(1:3, each=2), score = rep(c(6,3), each=3) )
> >
> > m %>% group_by(id) %>% mutate(total = cumsum(score))
> >
> > My output:
> >
> > # A tibble: 6 x 3
> > # Groups:   id [3]
> >  id score total
> > 
> > 1 1 6 6
> > 2 1 612
> > 3 2 618
> > 4 2 321
> > 5 3 324
> > 6 3 327
> >
> > What am I missing? Thanks in advance.
> >
> > Regards,
> > Sumit
> >
> >
> > __
> > R-help@r-project.org  mailing list -- To 
> > UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help 
> > 
> > PLEASE do read the posting guide http://www.R-project.org/ 
> > 
> > posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
> >
> 
> [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org  mailing list -- To 
> UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help 
> 
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html 
> 
> and provide commented, minimal, self-contained, reproducible code.
> 

__
R-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] inconsistency in display of character vector....

2018-07-10 Thread PIKAL Petr
Hi

What about

dat<-as.data.frame(tibble.dat)

Cheers
Petr
Osobn� �daje: Informace o zpracov�n� a ochran� osobn�ch �daj� obchodn�ch 
partner� PRECHEZA a.s. jsou zve�ejn�ny na: 
https://www.precheza.cz/zasady-ochrany-osobnich-udaju/ | Information about 
processing and protection of business partner's personal data are available on 
website: https://www.precheza.cz/en/personal-data-protection-principles/
D�v�rnost: Tento e-mail a jak�koliv k n�mu p�ipojen� dokumenty jsou d�v�rn� a 
podl�haj� tomuto pr�vn� z�vazn�mu prohl�en� o vylou�en� odpov�dnosti: 
https://www.precheza.cz/01-dovetek/ | This email and any documents attached to 
it may be confidential and are subject to the legally binding disclaimer: 
https://www.precheza.cz/en/01-disclaimer/

From: akshay kulkarni [mailto:akshay...@hotmail.com]
Sent: Tuesday, July 10, 2018 1:43 PM
To: Eric Berger ; PIKAL Petr 
Cc: R help Mailing list 
Subject: Re: [R] inconsistency in display of character vector

dear members,
 I've gone through debug(update.snlcqn)  
(update.snlcqn is the above function) and  I think the problem lies in 
read_excel returning a tibble...any suggestions on how to convert it to a 
regular data frame? Any other packages that read xls files as a regular data 
frame?

Very many thanks for your time and effort
Yours sincerely,
AKSHAY M KULKARNI


From: Eric Berger mailto:ericjber...@gmail.com>>
Sent: Monday, July 9, 2018 12:15 PM
To: PIKAL Petr
Cc: akshay kulkarni; R help Mailing list
Subject: Re: [R] inconsistency in display of character vector

>  If (identical(snlcqn, snlcqna)) snlcqn else snlcqna

??

Why not just always return snicqna ?


On Mon, Jul 9, 2018 at 9:43 AM, PIKAL Petr 
mailto:petr.pi...@precheza.cz>> wrote:
Hi

You definitely should not use HTML formated mail. This is plain text mailing 
list for reason.

If you experience space between "NSE/" and pasted second part, you should read 
paste help page which states

paste (..., sep = " ", collapse = NULL)

so it has space as separator.

You should use paste0 if you want to get rid of separating space or axplicitely 
state
paste (..., sep = "")

> lneq <- c()
> for (i in 1:10) lneq[i] <- letters[i]
> lneq
 [1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j"
> snlcqna<-LETTERS[1:10]
> for (j in 1:10) snlcqna[j] <- paste("NSE/",lneq[j])
> snlcqna
 [1] "NSE/ a" "NSE/ b" "NSE/ c" "NSE/ d" "NSE/ e" "NSE/ f" "NSE/ g" "NSE/ h"
 [9] "NSE/ i" "NSE/ j"
> for (j in 1:10) snlcqna[j] <- paste0("NSE/",lneq[j])
> snlcqna
 [1] "NSE/a" "NSE/b" "NSE/c" "NSE/d" "NSE/e" "NSE/f" "NSE/g" "NSE/h" "NSE/i"
[10] "NSE/j"

Cheers
Petr

Osobn� �daje: Informace o zpracov�n� a ochran� osobn�ch �daj� obchodn�ch 
partner� PRECHEZA a.s. jsou zve�ejn�ny na: 
https://www.precheza.cz/zasady-ochrany-osobnich-udaju/ | Information about 
processing and protection of business partner's personal data are available on 
website: https://www.precheza.cz/en/personal-data-protection-principles/
D�v�rnost: Tento e-mail a jak�koliv k n�mu p�ipojen� dokumenty jsou d�v�rn� a 
podl�haj� tomuto pr�vn� z�vazn�mu prohl�en� o vylou�en� odpov�dnosti: 
https://www.precheza.cz/01-dovetek/ | This email and any documents attached to 
it may be confidential and are subject to the legally binding disclaimer: 
https://www.precheza.cz/en/01-disclaimer/

> -Original Message-
> From: R-help 
> [mailto:r-help-boun...@r-project.org] On 
> Behalf Of akshay
> kulkarni
> Sent: Sunday, July 8, 2018 2:38 PM
> To: R help Mailing list mailto:r-help@r-project.org>>
> Subject: [R] Fw: inconsistency in display of character vector
>
> dear members,
>  The mail is not showing the spaces between [192]
> "NSE/YESBANK" and  [193] "NSE/ZEEL" ...Actually there is a lot of empty spaces
> between the two.!!
>
> 
> From: R-help 
> mailto:r-help-boun...@r-project.org>> on behalf 
> of akshay kulkarni
> mailto:akshay...@hotmail.com>>
> Sent: Sunday, July 8, 2018 5:58 PM
> To: R help Mailing  list
> Subject: [R] inconsistency in display of character vector
>
> dear members,
> I have the following code to update the list of 
> stocks:
>
> function (snlcqn)
> {
>   lneq <- c()
>   URL <- "https://canmoney.in/Intraday%20scrip.xls";
>   file.string <- tempfile()
>
>   download.file(URL,file.string)
>
>   IDT <- read_excel(file.string)
>
>   leq <- IDT[,1]
>
>   for(i in 1:length(leq)){
>   lneq[i] <- substr(leq[i],1,(nchar(leq[i])-2))}
>
>   for(j in 1:length(lneq)){
>   snlcqna[j] <- paste("NSE/",lneq[j])}
>
>   if(identical(snlcqn,snlcqna) == "FALSE"){
>   return(snlcqna) }
>
>   else{
> 

Re: [R] inconsistency in display of character vector....

2018-07-10 Thread Eric Berger
Hi Akshay,
Package "openxlsx" has function read.xlsx() which returns a data frame.

HTH,
Eric


On Tue, Jul 10, 2018 at 2:43 PM, akshay kulkarni 
wrote:

> dear members,
>  I've gone through debug(update.snlcqn)
> (update.snlcqn is the above function) and  I think the problem lies in
> read_excel returning a tibble...any suggestions on how to convert it to a
> regular data frame? Any other packages that read xls files as a regular
> data frame?
>
> Very many thanks for your time and effort
> Yours sincerely,
> AKSHAY M KULKARNI
>
> --
> *From:* Eric Berger 
> *Sent:* Monday, July 9, 2018 12:15 PM
> *To:* PIKAL Petr
> *Cc:* akshay kulkarni; R help Mailing list
> *Subject:* Re: [R] inconsistency in display of character vector
>
> >  If (identical(snlcqn, snlcqna)) snlcqn else snlcqna
>
> ??
>
> Why not just always return snicqna ?
>
>
> On Mon, Jul 9, 2018 at 9:43 AM, PIKAL Petr  wrote:
>
> Hi
>
> You definitely should not use HTML formated mail. This is plain text
> mailing list for reason.
>
> If you experience space between "NSE/" and pasted second part, you should
> read paste help page which states
>
> paste (..., sep = " ", collapse = NULL)
>
> so it has space as separator.
>
> You should use paste0 if you want to get rid of separating space or
> axplicitely state
> paste (..., sep = "")
>
> > lneq <- c()
> > for (i in 1:10) lneq[i] <- letters[i]
> > lneq
>  [1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j"
> > snlcqna<-LETTERS[1:10]
> > for (j in 1:10) snlcqna[j] <- paste("NSE/",lneq[j])
> > snlcqna
>  [1] "NSE/ a" "NSE/ b" "NSE/ c" "NSE/ d" "NSE/ e" "NSE/ f" "NSE/ g" "NSE/
> h"
>  [9] "NSE/ i" "NSE/ j"
> > for (j in 1:10) snlcqna[j] <- paste0("NSE/",lneq[j])
> > snlcqna
>  [1] "NSE/a" "NSE/b" "NSE/c" "NSE/d" "NSE/e" "NSE/f" "NSE/g" "NSE/h"
> "NSE/i"
> [10] "NSE/j"
>
> Cheers
> Petr
>
> Osobní údaje: Informace o zpracování a ochraně osobních údajů obchodních
> partnerů PRECHEZA a.s. jsou zveřejněny na: https://www.precheza.cz/zasady
> -ochrany-osobnich-udaju/ | Information about processing and protection of
> business partner's personal data are available on website:
> https://www.precheza.cz/en/personal-data-protection-principles/
> Důvěrnost: Tento e-mail a jakékoliv k němu připojené dokumenty jsou
> důvěrné a podléhají tomuto právně závaznému prohlášení o vyloučení
> odpovědnosti: https://www.precheza.cz/01-dovetek/ | This email and any
> documents attached to it may be confidential and are subject to the legally
> binding disclaimer: https://www.precheza.cz/en/01-disclaimer/
>
> > -Original Message-
> > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of akshay
> > kulkarni
> > Sent: Sunday, July 8, 2018 2:38 PM
> > To: R help Mailing list 
> > Subject: [R] Fw: inconsistency in display of character vector
> >
> > dear members,
> >  The mail is not showing the spaces between
> [192]
> > "NSE/YESBANK" and  [193] "NSE/ZEEL" ...Actually there is a lot of empty
> spaces
> > between the two.!!
> >
> > 
> > From: R-help  on behalf of akshay kulkarni
> > 
> > Sent: Sunday, July 8, 2018 5:58 PM
> > To: R help Mailing  list
> > Subject: [R] inconsistency in display of character vector
> >
> > dear members,
> > I have the following code to update the list
> of stocks:
> >
> > function (snlcqn)
> > {
> >   lneq <- c()
> >   URL <- "https://canmoney.in/Intraday%20scrip.xls";
> >   file.string <- tempfile()
> >
> >   download.file(URL,file.string)
> >
> >   IDT <- read_excel(file.string)
> >
> >   leq <- IDT[,1]
> >
> >   for(i in 1:length(leq)){
> >   lneq[i] <- substr(leq[i],1,(nchar(leq[i])-2))}
> >
> >   for(j in 1:length(lneq)){
> >   snlcqna[j] <- paste("NSE/",lneq[j])}
> >
> >   if(identical(snlcqn,snlcqna) == "FALSE"){
> >   return(snlcqna) }
> >
> >   else{
> >   return(snlcqn)  }
> >
> > }
> > snlcqn is the list of present stocks and snlcqna is the list of updated
> stocks.
> > The problem is the return object, instead of getting displayed in
> contiguous list,
> > is getting displayed with lots of spaces...( I am using R on a LINUX
> RHEL AWS
> > instance):
> >
> > [192] "NSE/YESBANK"
> > [193] "NSE/ZEEL"
> >
> > Why is this happening? How can I get the return object as a contiguous
> list?
> > Very many thanks for your time and effort...
> > yours sincerely,
> > AKSHAY M KULKARNI
> >
> > [[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEA

Re: [R] inconsistency in display of character vector....

2018-07-10 Thread akshay kulkarni
dear members,
 I've gone through debug(update.snlcqn)  
(update.snlcqn is the above function) and  I think the problem lies in 
read_excel returning a tibble...any suggestions on how to convert it to a 
regular data frame? Any other packages that read xls files as a regular data 
frame?

Very many thanks for your time and effort
Yours sincerely,
AKSHAY M KULKARNI


From: Eric Berger 
Sent: Monday, July 9, 2018 12:15 PM
To: PIKAL Petr
Cc: akshay kulkarni; R help Mailing list
Subject: Re: [R] inconsistency in display of character vector

>  If (identical(snlcqn, snlcqna)) snlcqn else snlcqna

??

Why not just always return snicqna ?


On Mon, Jul 9, 2018 at 9:43 AM, PIKAL Petr 
mailto:petr.pi...@precheza.cz>> wrote:
Hi

You definitely should not use HTML formated mail. This is plain text mailing 
list for reason.

If you experience space between "NSE/" and pasted second part, you should read 
paste help page which states

paste (..., sep = " ", collapse = NULL)

so it has space as separator.

You should use paste0 if you want to get rid of separating space or axplicitely 
state
paste (..., sep = "")

> lneq <- c()
> for (i in 1:10) lneq[i] <- letters[i]
> lneq
 [1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j"
> snlcqna<-LETTERS[1:10]
> for (j in 1:10) snlcqna[j] <- paste("NSE/",lneq[j])
> snlcqna
 [1] "NSE/ a" "NSE/ b" "NSE/ c" "NSE/ d" "NSE/ e" "NSE/ f" "NSE/ g" "NSE/ h"
 [9] "NSE/ i" "NSE/ j"
> for (j in 1:10) snlcqna[j] <- paste0("NSE/",lneq[j])
> snlcqna
 [1] "NSE/a" "NSE/b" "NSE/c" "NSE/d" "NSE/e" "NSE/f" "NSE/g" "NSE/h" "NSE/i"
[10] "NSE/j"

Cheers
Petr

Osobn� �daje: Informace o zpracov�n� a ochran� osobn�ch �daj� obchodn�ch 
partner� PRECHEZA a.s. jsou zve�ejn�ny na: 
https://www.precheza.cz/zasady-ochrany-osobnich-udaju/ | Information about 
processing and protection of business partner's personal data are available on 
website: https://www.precheza.cz/en/personal-data-protection-principles/
D�v�rnost: Tento e-mail a jak�koliv k n�mu p�ipojen� dokumenty jsou d�v�rn� a 
podl�haj� tomuto pr�vn� z�vazn�mu prohl�en� o vylou�en� odpov�dnosti: 
https://www.precheza.cz/01-dovetek/ | This email and any documents attached to 
it may be confidential and are subject to the legally binding disclaimer: 
https://www.precheza.cz/en/01-disclaimer/

> -Original Message-
> From: R-help 
> [mailto:r-help-boun...@r-project.org] On 
> Behalf Of akshay
> kulkarni
> Sent: Sunday, July 8, 2018 2:38 PM
> To: R help Mailing list mailto:r-help@r-project.org>>
> Subject: [R] Fw: inconsistency in display of character vector
>
> dear members,
>  The mail is not showing the spaces between [192]
> "NSE/YESBANK" and  [193] "NSE/ZEEL" ...Actually there is a lot of empty spaces
[[elided Hotmail spam]]
>
> 
> From: R-help 
> mailto:r-help-boun...@r-project.org>> on behalf 
> of akshay kulkarni
> mailto:akshay...@hotmail.com>>
> Sent: Sunday, July 8, 2018 5:58 PM
> To: R help Mailing  list
> Subject: [R] inconsistency in display of character vector
>
> dear members,
> I have the following code to update the list of 
> stocks:
>
> function (snlcqn)
> {
>   lneq <- c()
>   URL <- "https://canmoney.in/Intraday%20scrip.xls";
>   file.string <- tempfile()
>
>   download.file(URL,file.string)
>
>   IDT <- read_excel(file.string)
>
>   leq <- IDT[,1]
>
>   for(i in 1:length(leq)){
>   lneq[i] <- substr(leq[i],1,(nchar(leq[i])-2))}
>
>   for(j in 1:length(lneq)){
>   snlcqna[j] <- paste("NSE/",lneq[j])}
>
>   if(identical(snlcqn,snlcqna) == "FALSE"){
>   return(snlcqna) }
>
>   else{
>   return(snlcqn)  }
>
> }
> snlcqn is the list of present stocks and snlcqna is the list of updated 
> stocks.
> The problem is the return object, instead of getting displayed in contiguous 
> list,
> is getting displayed with lots of spaces...( I am using R on a LINUX RHEL AWS
> instance):
>
> [192] "NSE/YESBANK"
> [193] "NSE/ZEEL"
>
> Why is this happening? How can I get the return object as a contiguous list?
> Very many thanks for your time and effort...
> yours sincerely,
> AKSHAY M KULKARNI
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To 
> UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>   [[alternative HTML version deleted]]
>
> __

Re: [R] (no subject)

2018-07-10 Thread Werning, Jan-Philipp

Hi,

thanks a lot! Now it works.

Yours

Jan

Am 10.07.2018 um 09:00 schrieb PIKAL Petr 
mailto:petr.pi...@precheza.cz>>:

Hi

see in line

-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Werning, Jan-
Philipp
Sent: Monday, July 9, 2018 9:42 PM
To: r-help@r-project.org
Subject: [R] (no subject)

Dear all,


In the end I try to run a system dynamics simulation in R using the package
deSolve.
Therefore I need an auxiliary list (auxs) the model can refer to when it the
functions need an auxiliary value.

I used a manual list:

auxs <- c( aSplitSN=0.4 , aSplitLN=0.6, aSplitSR1=0 , aSplitLR1=1, aSplitSR2=0 ,
aSplitLR2=1, aSplitSR3=0 , aSplitLR3=1, aSalesNR=0.92, aSalesRR=0.08, […])

This is vector not list.
auxs <- c( aSplitSN=0.4 , aSplitLN=0.6, aSplitSR1=0 , aSplitLR1=1, aSplitSR2=0)
is.vector(auxs)
[1] TRUE
is.list(auxs)
[1] FALSE


this way everything worked well.

Now I want to use a matrix with different values for each of the auxiliaries in
order to run different scenarios. Therefore I created a csv document wich I read
in:

csv1  <- read.csv("180713_Taguchi Robust Design Test_180709_1745.csv", sep
= ";")

list_csv <- csv1[1,]

which is probably data frame

test<-vec[1,]
is.vector(test)
[1] FALSE
is.list(test)
[1] TRUE
is.data.frame(test)
[1] TRUE



namesauxs <- names(list_csv)

auxs1 <- as.numeric(list_csv)

names(auxs1) <- namesauxs

auxs <- auxs1


Looking at the global environment section in R studio, now both are the same,
in the value section as "Numed num"

I do not know rstudio but you could check two objects by
?identical


Yet, the model will not run using these values ultimately coming from the csv.

I wonder why do you use as.numeric in the first instance. You coud use

auxs1 <- unlist(csv1[1,])
and you should get named numeric vector. Maybe there are problems when reading 
numbers from csv file. You could check it e.g. by

str(auxs1)


What am I doing wrong here?

It would be great if you could help.

Thanks a lot in advance

Yours

Jan





[[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.
Osobní údaje: Informace o zpracování a ochraně osobních údajů obchodních 
partnerů PRECHEZA a.s. jsou zveřejněny na: 
https://www.precheza.cz/zasady-ochrany-osobnich-udaju/ | Information about 
processing and protection of business partner’s personal data are available on 
website: https://www.precheza.cz/en/personal-data-protection-principles/
Důvěrnost: Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a 
podléhají tomuto právně závaznému prohláąení o vyloučení odpovědnosti: 
https://www.precheza.cz/01-dovetek/ | This email and any documents attached to 
it may be confidential and are subject to the legally binding disclaimer: 
https://www.precheza.cz/en/01-disclaimer/



[[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] Something simple not working in group_by

2018-07-10 Thread Eric Berger
Hi Sumit,
I was not able to reproduce this problem.
I tried it in both R 3.5.1 and R 3.4.4.
Both gave the expected output (which differs from yours.)

Eric


On Tue, Jul 10, 2018 at 1:32 AM, Bert Gunter  wrote:

> Dunno.
>
> But if I understand correctly, here's a base R way to do it:
>
> (## using your m)
>
> > m$total <- with(m,ave(score,id,FUN = cumsum))
> > m
>   id score total
> 1  1 6 6
> 2  1 612
> 3  2 6 6
> 4  2 3 9
> 5  3 3 3
> 6  3 3 6
>
> 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 Mon, Jul 9, 2018 at 2:35 PM, Sumitrajit Dhar 
> wrote:
>
> > Hi Folks,
> >
> > I am trying to get a group_by cumsum using:
> >
> > R version 3.5.0 (2018-04-23) -- "Joy in Playing"
> > Copyright (C) 2018 The R Foundation for Statistical Computing
> > Platform: x86_64-apple-darwin15.6.0 (64-bit)
> >
> > Here is an example of a simple construct that is not working.
> >
> > m <- data.frame( id = rep(1:3, each=2), score = rep(c(6,3), each=3) )
> >
> > m %>% group_by(id) %>% mutate(total = cumsum(score))
> >
> > My output:
> >
> > # A tibble: 6 x 3
> > # Groups:   id [3]
> >  id score total
> > 
> > 1 1 6 6
> > 2 1 612
> > 3 2 618
> > 4 2 321
> > 5 3 324
> > 6 3 327
> >
> > What am I missing? Thanks in advance.
> >
> > Regards,
> > Sumit
> >
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/
> > posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
> >
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/
> posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[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] (no subject)

2018-07-10 Thread PIKAL Petr
Hi

see in line

> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Werning, Jan-
> Philipp
> Sent: Monday, July 9, 2018 9:42 PM
> To: r-help@r-project.org
> Subject: [R] (no subject)
>
> Dear all,
>
>
> In the end I try to run a system dynamics simulation in R using the package
> deSolve.
> Therefore I need an auxiliary list (auxs) the model can refer to when it the
> functions need an auxiliary value.
>
> I used a manual list:
>
> auxs <- c( aSplitSN=0.4 , aSplitLN=0.6, aSplitSR1=0 , aSplitLR1=1, 
> aSplitSR2=0 ,
> aSplitLR2=1, aSplitSR3=0 , aSplitLR3=1, aSalesNR=0.92, aSalesRR=0.08, […])

This is vector not list.
> auxs <- c( aSplitSN=0.4 , aSplitLN=0.6, aSplitSR1=0 , aSplitLR1=1, 
> aSplitSR2=0)
> is.vector(auxs)
[1] TRUE
> is.list(auxs)
[1] FALSE
>
>
> this way everything worked well.
>
> Now I want to use a matrix with different values for each of the auxiliaries 
> in
> order to run different scenarios. Therefore I created a csv document wich I 
> read
> in:
>
> csv1  <- read.csv("180713_Taguchi Robust Design Test_180709_1745.csv", sep
> = ";")
>
> list_csv <- csv1[1,]

which is probably data frame

> test<-vec[1,]
> is.vector(test)
[1] FALSE
> is.list(test)
[1] TRUE
> is.data.frame(test)
[1] TRUE
>

>
> namesauxs <- names(list_csv)
>
>  auxs1 <- as.numeric(list_csv)
>
>  names(auxs1) <- namesauxs
>
>  auxs <- auxs1
>
>
> Looking at the global environment section in R studio, now both are the same,
> in the value section as "Numed num"

I do not know rstudio but you could check two objects by
?identical

>
> Yet, the model will not run using these values ultimately coming from the csv.

I wonder why do you use as.numeric in the first instance. You coud use

auxs1 <- unlist(csv1[1,])
and you should get named numeric vector. Maybe there are problems when reading 
numbers from csv file. You could check it e.g. by

str(auxs1)

>
> What am I doing wrong here?
>
> It would be great if you could help.
>
> Thanks a lot in advance
>
> Yours
>
> Jan
>
>
>
>
>
> [[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.
Osobní údaje: Informace o zpracování a ochraně osobních údajů obchodních 
partnerů PRECHEZA a.s. jsou zveřejněny na: 
https://www.precheza.cz/zasady-ochrany-osobnich-udaju/ | Information about 
processing and protection of business partner’s personal data are available on 
website: https://www.precheza.cz/en/personal-data-protection-principles/
Důvěrnost: Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a 
podléhají tomuto právně závaznému prohláąení o vyloučení odpovědnosti: 
https://www.precheza.cz/01-dovetek/ | This email and any documents attached to 
it may be confidential and are subject to the legally binding disclaimer: 
https://www.precheza.cz/en/01-disclaimer/

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