Re: [R] Counting enumerated items in each element of a character vector

2017-04-25 Thread Michael Hannon
Thanks, Ista.  I thought there might be a "tidy" way to do this, but I
hadn't use stringr.

-- Mike


On Tue, Apr 25, 2017 at 8:47 PM, Ista Zahn  wrote:
> stringr::str_count (and stringi::stri_count that it wraps) interpret
> the pattern argument as a regular expression by default.
>
> Best,
> Ista
>
> On Tue, Apr 25, 2017 at 11:40 PM, Michael Hannon
>  wrote:
>> I like Boris's "Hadley" solution.  For the record, I've appended a
>> version that uses regular expressions, the only benefit of which is
>> that it could be generalized to find more-complicated patterns.
>>
>> -- Mike
>>
>> counts <- sapply(text1, function(next_string) {
>> loc_example <- length(gregexpr("Example", next_string)[[1]])
>> loc_example
>> }, USE.NAMES=FALSE)
>>
>>> counts
>> [1] 5 5 5 5
>>>
>>
>> On Tue, Apr 25, 2017 at 5:33 PM, Boris Steipe  
>> wrote:
>>> I should add: there's a str_count() function in the stringr package.
>>>
>>> library(stringr)
>>> str_count(text1, "Example")
>>> # [1] 5 5 5 5
>>>
>>> I guess that would be the neater solution.
>>>
>>> B.
>>>
>>>
>>>
 On Apr 25, 2017, at 8:23 PM, Boris Steipe  wrote:

 How about:

 unlist(lapply(strsplit(text1, "Example"), function(x) { length(x) - 1 } ))


 Splitting your string on the five "Examples" in each gives six elements. 
 length(x) - 1 is the number of
 matches. You can use any regex instead of "example" if you need to tweak 
 what you are looking for.


 B.




> On Apr 25, 2017, at 8:14 PM, Dan Abner  wrote:
>
> Hi all,
>
> I am looking for a streamlined way of counting the number of enumerated
> items are each element of a character vector. For example:
>
>
> text1<-c("This is an example.
> List 1
> 1) Example 1
> 2) Example 2
> 10) Example 10
> List 2
> 1) Example 1
> 2) Example 2
> These have been examples.","This is another example.
> List 1
> 1. Example 1
> 2. Example 2
> 10. Example 10
> List 2
> 1. Example 1
> 2. Example 2
> These have been examples.","This is a third example. List 1 1) Example 1.
> 2) Example 2. 10) Example 10. List 2 1) Example 1. 2) Example 2. These 
> have
> been examples."
> ,"This is a fourth example. List 1 1. Example 1. 2. Example 2. 10. Example
> 10. List 2 Example 1. 2. Example 2. These have been examples.")
>
> text1
>
> ===
>
> I would like the result to be c(5,5,5,5). Notice that sometimes there are
> leading hard returns, other times not. Sometimes are there separate lists
> and the same numbers are used in the enumerated items multiple times 
> within
> each character string. Sometimes the leading numbers for the enumerated
> items exceed single digits. Notice that the delimiter may be ) or a period
> (.). If the delimiter is a period and there are hard returns (example 2),
> then I expect that will be easy enough to differentiate sentences ending
> with a number from enumerated items. However, I imagine it would be much
> more difficult to differentiate the two for example 4.
>
> Any suggestions are appreciated.
>
> Best,
>
> Dan
>
>  [[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.
>>>
>>> __
>>> 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 

Re: [R] Counting enumerated items in each element of a character vector

2017-04-25 Thread Ista Zahn
stringr::str_count (and stringi::stri_count that it wraps) interpret
the pattern argument as a regular expression by default.

Best,
Ista

On Tue, Apr 25, 2017 at 11:40 PM, Michael Hannon
 wrote:
> I like Boris's "Hadley" solution.  For the record, I've appended a
> version that uses regular expressions, the only benefit of which is
> that it could be generalized to find more-complicated patterns.
>
> -- Mike
>
> counts <- sapply(text1, function(next_string) {
> loc_example <- length(gregexpr("Example", next_string)[[1]])
> loc_example
> }, USE.NAMES=FALSE)
>
>> counts
> [1] 5 5 5 5
>>
>
> On Tue, Apr 25, 2017 at 5:33 PM, Boris Steipe  
> wrote:
>> I should add: there's a str_count() function in the stringr package.
>>
>> library(stringr)
>> str_count(text1, "Example")
>> # [1] 5 5 5 5
>>
>> I guess that would be the neater solution.
>>
>> B.
>>
>>
>>
>>> On Apr 25, 2017, at 8:23 PM, Boris Steipe  wrote:
>>>
>>> How about:
>>>
>>> unlist(lapply(strsplit(text1, "Example"), function(x) { length(x) - 1 } ))
>>>
>>>
>>> Splitting your string on the five "Examples" in each gives six elements. 
>>> length(x) - 1 is the number of
>>> matches. You can use any regex instead of "example" if you need to tweak 
>>> what you are looking for.
>>>
>>>
>>> B.
>>>
>>>
>>>
>>>
 On Apr 25, 2017, at 8:14 PM, Dan Abner  wrote:

 Hi all,

 I am looking for a streamlined way of counting the number of enumerated
 items are each element of a character vector. For example:


 text1<-c("This is an example.
 List 1
 1) Example 1
 2) Example 2
 10) Example 10
 List 2
 1) Example 1
 2) Example 2
 These have been examples.","This is another example.
 List 1
 1. Example 1
 2. Example 2
 10. Example 10
 List 2
 1. Example 1
 2. Example 2
 These have been examples.","This is a third example. List 1 1) Example 1.
 2) Example 2. 10) Example 10. List 2 1) Example 1. 2) Example 2. These have
 been examples."
 ,"This is a fourth example. List 1 1. Example 1. 2. Example 2. 10. Example
 10. List 2 Example 1. 2. Example 2. These have been examples.")

 text1

 ===

 I would like the result to be c(5,5,5,5). Notice that sometimes there are
 leading hard returns, other times not. Sometimes are there separate lists
 and the same numbers are used in the enumerated items multiple times within
 each character string. Sometimes the leading numbers for the enumerated
 items exceed single digits. Notice that the delimiter may be ) or a period
 (.). If the delimiter is a period and there are hard returns (example 2),
 then I expect that will be easy enough to differentiate sentences ending
 with a number from enumerated items. However, I imagine it would be much
 more difficult to differentiate the two for example 4.

 Any suggestions are appreciated.

 Best,

 Dan

  [[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.
>>
>> __
>> 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] Counting enumerated items in each element of a character vector

2017-04-25 Thread Michael Hannon
I like Boris's "Hadley" solution.  For the record, I've appended a
version that uses regular expressions, the only benefit of which is
that it could be generalized to find more-complicated patterns.

-- Mike

counts <- sapply(text1, function(next_string) {
loc_example <- length(gregexpr("Example", next_string)[[1]])
loc_example
}, USE.NAMES=FALSE)

> counts
[1] 5 5 5 5
>

On Tue, Apr 25, 2017 at 5:33 PM, Boris Steipe  wrote:
> I should add: there's a str_count() function in the stringr package.
>
> library(stringr)
> str_count(text1, "Example")
> # [1] 5 5 5 5
>
> I guess that would be the neater solution.
>
> B.
>
>
>
>> On Apr 25, 2017, at 8:23 PM, Boris Steipe  wrote:
>>
>> How about:
>>
>> unlist(lapply(strsplit(text1, "Example"), function(x) { length(x) - 1 } ))
>>
>>
>> Splitting your string on the five "Examples" in each gives six elements. 
>> length(x) - 1 is the number of
>> matches. You can use any regex instead of "example" if you need to tweak 
>> what you are looking for.
>>
>>
>> B.
>>
>>
>>
>>
>>> On Apr 25, 2017, at 8:14 PM, Dan Abner  wrote:
>>>
>>> Hi all,
>>>
>>> I am looking for a streamlined way of counting the number of enumerated
>>> items are each element of a character vector. For example:
>>>
>>>
>>> text1<-c("This is an example.
>>> List 1
>>> 1) Example 1
>>> 2) Example 2
>>> 10) Example 10
>>> List 2
>>> 1) Example 1
>>> 2) Example 2
>>> These have been examples.","This is another example.
>>> List 1
>>> 1. Example 1
>>> 2. Example 2
>>> 10. Example 10
>>> List 2
>>> 1. Example 1
>>> 2. Example 2
>>> These have been examples.","This is a third example. List 1 1) Example 1.
>>> 2) Example 2. 10) Example 10. List 2 1) Example 1. 2) Example 2. These have
>>> been examples."
>>> ,"This is a fourth example. List 1 1. Example 1. 2. Example 2. 10. Example
>>> 10. List 2 Example 1. 2. Example 2. These have been examples.")
>>>
>>> text1
>>>
>>> ===
>>>
>>> I would like the result to be c(5,5,5,5). Notice that sometimes there are
>>> leading hard returns, other times not. Sometimes are there separate lists
>>> and the same numbers are used in the enumerated items multiple times within
>>> each character string. Sometimes the leading numbers for the enumerated
>>> items exceed single digits. Notice that the delimiter may be ) or a period
>>> (.). If the delimiter is a period and there are hard returns (example 2),
>>> then I expect that will be easy enough to differentiate sentences ending
>>> with a number from enumerated items. However, I imagine it would be much
>>> more difficult to differentiate the two for example 4.
>>>
>>> Any suggestions are appreciated.
>>>
>>> Best,
>>>
>>> Dan
>>>
>>>  [[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.
>
> __
> 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] Counting enumerated items in each element of a character vector

2017-04-25 Thread Boris Steipe
I should add: there's a str_count() function in the stringr package.

library(stringr)
str_count(text1, "Example")
# [1] 5 5 5 5

I guess that would be the neater solution.

B.



> On Apr 25, 2017, at 8:23 PM, Boris Steipe  wrote:
> 
> How about:
> 
> unlist(lapply(strsplit(text1, "Example"), function(x) { length(x) - 1 } ))
> 
> 
> Splitting your string on the five "Examples" in each gives six elements. 
> length(x) - 1 is the number of
> matches. You can use any regex instead of "example" if you need to tweak what 
> you are looking for.
> 
> 
> B.
> 
> 
> 
> 
>> On Apr 25, 2017, at 8:14 PM, Dan Abner  wrote:
>> 
>> Hi all,
>> 
>> I am looking for a streamlined way of counting the number of enumerated
>> items are each element of a character vector. For example:
>> 
>> 
>> text1<-c("This is an example.
>> List 1
>> 1) Example 1
>> 2) Example 2
>> 10) Example 10
>> List 2
>> 1) Example 1
>> 2) Example 2
>> These have been examples.","This is another example.
>> List 1
>> 1. Example 1
>> 2. Example 2
>> 10. Example 10
>> List 2
>> 1. Example 1
>> 2. Example 2
>> These have been examples.","This is a third example. List 1 1) Example 1.
>> 2) Example 2. 10) Example 10. List 2 1) Example 1. 2) Example 2. These have
>> been examples."
>> ,"This is a fourth example. List 1 1. Example 1. 2. Example 2. 10. Example
>> 10. List 2 Example 1. 2. Example 2. These have been examples.")
>> 
>> text1
>> 
>> ===
>> 
>> I would like the result to be c(5,5,5,5). Notice that sometimes there are
>> leading hard returns, other times not. Sometimes are there separate lists
>> and the same numbers are used in the enumerated items multiple times within
>> each character string. Sometimes the leading numbers for the enumerated
>> items exceed single digits. Notice that the delimiter may be ) or a period
>> (.). If the delimiter is a period and there are hard returns (example 2),
>> then I expect that will be easy enough to differentiate sentences ending
>> with a number from enumerated items. However, I imagine it would be much
>> more difficult to differentiate the two for example 4.
>> 
>> Any suggestions are appreciated.
>> 
>> Best,
>> 
>> Dan
>> 
>>  [[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.

__
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] Counting enumerated items in each element of a character vector

2017-04-25 Thread Boris Steipe
How about:

unlist(lapply(strsplit(text1, "Example"), function(x) { length(x) - 1 } ))


Splitting your string on the five "Examples" in each gives six elements. 
length(x) - 1 is the number of
matches. You can use any regex instead of "example" if you need to tweak what 
you are looking for.


B.




> On Apr 25, 2017, at 8:14 PM, Dan Abner  wrote:
> 
> Hi all,
> 
> I am looking for a streamlined way of counting the number of enumerated
> items are each element of a character vector. For example:
> 
> 
> text1<-c("This is an example.
> List 1
> 1) Example 1
> 2) Example 2
> 10) Example 10
> List 2
> 1) Example 1
> 2) Example 2
> These have been examples.","This is another example.
> List 1
> 1. Example 1
> 2. Example 2
> 10. Example 10
> List 2
> 1. Example 1
> 2. Example 2
> These have been examples.","This is a third example. List 1 1) Example 1.
> 2) Example 2. 10) Example 10. List 2 1) Example 1. 2) Example 2. These have
> been examples."
> ,"This is a fourth example. List 1 1. Example 1. 2. Example 2. 10. Example
> 10. List 2 Example 1. 2. Example 2. These have been examples.")
> 
> text1
> 
> ===
> 
> I would like the result to be c(5,5,5,5). Notice that sometimes there are
> leading hard returns, other times not. Sometimes are there separate lists
> and the same numbers are used in the enumerated items multiple times within
> each character string. Sometimes the leading numbers for the enumerated
> items exceed single digits. Notice that the delimiter may be ) or a period
> (.). If the delimiter is a period and there are hard returns (example 2),
> then I expect that will be easy enough to differentiate sentences ending
> with a number from enumerated items. However, I imagine it would be much
> more difficult to differentiate the two for example 4.
> 
> Any suggestions are appreciated.
> 
> Best,
> 
> Dan
> 
>   [[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.


[R] Counting enumerated items in each element of a character vector

2017-04-25 Thread Dan Abner
Hi all,

I am looking for a streamlined way of counting the number of enumerated
items are each element of a character vector. For example:


text1<-c("This is an example.
List 1
1) Example 1
2) Example 2
10) Example 10
List 2
1) Example 1
2) Example 2
These have been examples.","This is another example.
List 1
1. Example 1
2. Example 2
10. Example 10
List 2
1. Example 1
2. Example 2
These have been examples.","This is a third example. List 1 1) Example 1.
2) Example 2. 10) Example 10. List 2 1) Example 1. 2) Example 2. These have
been examples."
,"This is a fourth example. List 1 1. Example 1. 2. Example 2. 10. Example
10. List 2 Example 1. 2. Example 2. These have been examples.")

text1

===

I would like the result to be c(5,5,5,5). Notice that sometimes there are
leading hard returns, other times not. Sometimes are there separate lists
and the same numbers are used in the enumerated items multiple times within
each character string. Sometimes the leading numbers for the enumerated
items exceed single digits. Notice that the delimiter may be ) or a period
(.). If the delimiter is a period and there are hard returns (example 2),
then I expect that will be easy enough to differentiate sentences ending
with a number from enumerated items. However, I imagine it would be much
more difficult to differentiate the two for example 4.

Any suggestions are appreciated.

Best,

Dan

[[alternative HTML version deleted]]

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


Re: [R] R Date Time

2017-04-25 Thread Dirk Eddelbuettel

On 25 April 2017 at 18:05, Duncan Murdoch wrote:
| On 25/04/2017 5:41 PM, Dirk Eddelbuettel wrote:
| >
| > On 25 April 2017 at 16:04, Jeff Reichman wrote:
| > | R Users
| > |
| > | Having problems converting the following DTG into an R recognized 
date/time
| > | field
| > |
| > | 01-01-2016T14:02:23.325
| > |
| > | Would I separate it into a date field and time filed then put it back
| > | together???
| >
| > The anytime package (on CRAN) does this (and other date or datetime input
| > variants) without requiring a format:
| >
| >   R> library(anytime)
| >   R> anytime("01-01-2016T14:02:23.325")
| >   [1] "2016-01-01 14:02:23.325 CST"
| 
| How does it decide between MDY and DMY orderings in dates?  Doesn't 
| matter for this example, but it would for "01-02-2016T14:02:23.325"

See 

http://dirk.eddelbuettel.com/code/anytime.html

https://github.com/eddelbuettel/anytime

https://github.com/eddelbuettel/anytime/blob/master/src/anytime.cpp#L43-L106

for overview(s), some comments, notes and in particular the set of formats.

It has a strong preference for sane (ie ISO formats) but in the case of
ambiguity it (grudingly) prefers the (silly) US way:

R> anytime("01-02-2003")
[1] "2003-01-02 CST"
R>

But I try not to miss an opportunity that the format should really not be used.

Dirk

-- 
http://dirk.eddelbuettel.com | @eddelbuettel | e...@debian.org

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


Re: [R] R Date Time

2017-04-25 Thread Duncan Murdoch

On 25/04/2017 5:41 PM, Dirk Eddelbuettel wrote:


On 25 April 2017 at 16:04, Jeff Reichman wrote:
| R Users
|
| Having problems converting the following DTG into an R recognized date/time
| field
|
| 01-01-2016T14:02:23.325
|
| Would I separate it into a date field and time filed then put it back
| together???

The anytime package (on CRAN) does this (and other date or datetime input
variants) without requiring a format:

  R> library(anytime)
  R> anytime("01-01-2016T14:02:23.325")
  [1] "2016-01-01 14:02:23.325 CST"


How does it decide between MDY and DMY orderings in dates?  Doesn't 
matter for this example, but it would for "01-02-2016T14:02:23.325"


Duncan Murdoch

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


Re: [R] R Date Time

2017-04-25 Thread Dirk Eddelbuettel

On 25 April 2017 at 16:04, Jeff Reichman wrote:
| R Users
| 
| Having problems converting the following DTG into an R recognized date/time
| field
| 
| 01-01-2016T14:02:23.325
| 
| Would I separate it into a date field and time filed then put it back
| together???

The anytime package (on CRAN) does this (and other date or datetime input
variants) without requiring a format:

  R> library(anytime)
  R> anytime("01-01-2016T14:02:23.325")
  [1] "2016-01-01 14:02:23.325 CST"
  R>

Dirk

-- 
http://dirk.eddelbuettel.com | @eddelbuettel | e...@debian.org

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


Re: [R] R Date Time

2017-04-25 Thread William Dunlap via R-help
> z <- as.POSIXct("01-01-2016T14:02:23.325", format="%d-%m-%YT%H:%M:%OS")
> dput(z)
structure(1451685743.325, class = c("POSIXct", "POSIXt"), tzone = "")
> z
[1] "2016-01-01 14:02:23 PST"
> format(z, "%H:%M:%OS3 on %b %d, %Y")
[1] "14:02:23.325 on Jan 01, 2016"

(Don't separate the date and time parts because some times don't exist on
some days.)


Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Tue, Apr 25, 2017 at 2:04 PM, Jeff Reichman 
wrote:

> R Users
>
>
>
> Having problems converting the following DTG into an R recognized date/time
> field
>
>
>
> 01-01-2016T14:02:23.325
>
>
>
> Would I separate it into a date field and time filed then put it back
> together???
>
>
>
> Jeff
>
>
> [[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] R Date Time

2017-04-25 Thread Duncan Murdoch

On 25/04/2017 5:04 PM, Jeff Reichman wrote:

R Users



Having problems converting the following DTG into an R recognized date/time
field



01-01-2016T14:02:23.325



Would I separate it into a date field and time filed then put it back
together???



This appears to work (though I'm not sure whether you are using MDY or 
DMY; I used DMY):


strptime("01-01-2016T14:02:23.325", format="%d-%m-%YT%H:%M:%OS")

Duncan Murdoch

__
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] R Date Time

2017-04-25 Thread Jeff Reichman
R Users

 

Having problems converting the following DTG into an R recognized date/time
field

 

01-01-2016T14:02:23.325

 

Would I separate it into a date field and time filed then put it back
together???

 

Jeff


[[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] Multiple-Response Analysis: Cleaning of Duplicate Codes

2017-04-25 Thread Boris Steipe
How about:

d_sample_1 <- floor(d_sample/100) * 100

for (i in 1:nrow(d_sample_1)) {
d_sample_1[i, duplicated(unlist(d_sample_1[i, ]))] <- NA 
}


B.


> On Apr 25, 2017, at 1:10 PM, Bert Gunter  wrote:
> 
> If I understand you correctly, one way is:
> 
>> z <- rep(LETTERS[1:3],4)
>> z
> [1] "A" "B" "C" "A" "B" "C" "A" "B" "C" "A" "B" "C"
>> z[!duplicated(z)]
> [1] "A" "B" "C"
> 
> 
> ?duplicated
> 
> -- 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, Apr 25, 2017 at 9:36 AM,   wrote:
>> Hi All,
>> 
>> in my current project I am working with multiple-response questions
>> (MRSets):
>> 
>> -- Coding --
>> 100 Main Code 1
>> 110 Sub Code 1.1
>> 120 Sub Code 1.2
>> 130 Sub Code 1.3
>> 
>> 200 Main Code 2
>> 210 Sub Code 2.1
>> 220 Sub Code 2.2
>> 230 Sub Code 2.3
>> 
>> 300 Main Code 3
>> 310 Sub Code 3.1
>> 320 Sub Code 3.2
>> 
>> The coding for the variables is to detailed. Therefore I have recoded all
>> sub codes to the respective main code, e.g. all 110, 120 and 130 to 100,
>> all 210, 220 and 230 to 200 and all 310, 320 and 330 to 300.
>> 
>> Now it happens that some respondents get several times the same main code.
>> If the coding was done for respondent 1 with 120 and 130 after recoding
>> the values are 100 and 100. If I count this, it would mean that I weight
>> the multiple values of this respondent by factor 2. This is not my aim. I
>> would like to count the 100 for the respective respondent only once.
>> 
>> Here is my script so far:
>> 
>> # -- cut --
>> 
>> library(expss)
>> 
>> d_sample <-
>>  structure(
>>list(
>>  c05_01 = c(
>>110,
>>110,
>>130,
>>110,
>>110,
>>110,
>>110,
>>110,
>>110,
>>110,
>>110,
>>999,
>>110,
>>495,
>>160,
>>110,
>>410
>>  ),
>>  c05_02 = c(NA,
>> NA, 120, NA, NA, 150, NA, NA, 170, 160, NA, NA, NA, NA,
>> 170,
>> NA, 130),
>>  c05_03 = c(NA, NA, NA, NA, NA, NA, NA, NA, NA, 410,
>> NA, NA, NA, NA, NA, NA, NA),
>>  c05_04 = c(
>>NA_real_,
>>NA_real_,
>>NA_real_,
>>NA_real_,
>>NA_real_,
>>NA_real_,
>>NA_real_,
>>NA_real_,
>>NA_real_,
>>NA_real_,
>>NA_real_,
>>NA_real_,
>>NA_real_,
>>NA_real_,
>>NA_real_,
>>NA_real_,
>>NA_real_
>>  ),
>>  c05_05 = c(
>>NA_real_,
>>NA_real_,
>>NA_real_,
>>NA_real_,
>>NA_real_,
>>NA_real_,
>>NA_real_,
>>NA_real_,
>>NA_real_,
>>NA_real_,
>>NA_real_,
>>NA_real_,
>>NA_real_,
>>NA_real_,
>>NA_real_,
>>NA_real_,
>>NA_real_
>>  )
>>),
>>.Names = c("c05_01",
>>   "c05_02", "c05_03", "c05_04", "c05_05"),
>>row.names = c(
>>  "1",
>>  "2",
>>  "3",
>>  "4",
>>  "5",
>>  "10",
>>  "11",
>>  "12",
>>  "13",
>>  "14",
>>  "15",
>>  "20",
>>  "21",
>>  "22",
>>  "23",
>>  "24",
>>  "25"
>>),
>>class = "data.frame"
>>  )
>> 
>> c05_xx_r01 <- d_sample %>%
>>  select(starts_with("c05_")) %>%
>>  recode(c(
>>110 %thru% 195 ~ 100,
>>210 %thru% 295 ~ 200,
>>310 %thru% 395 ~ 300,
>>410 %thru% 495 ~ 400,
>>510 %thru% 595 ~ 500,
>>810 %thru% 895 ~ 800,
>>910 %thru% 999 ~ 900))
>> names(c05_xx_r01) <- paste0("c05_0", 1:5, "_r01")
>> d_sample <- cbind(d_sample, c05_xx_r01)
>> 
>> # -- cut --
>> 
>> I would like to eliminate all duplicates codes, e. g. 100 and 100 for
>> respondents in row 3, 6, 13, 14 and 15 to 100 only once:
>> 
>> # -- cut --
>> d_sample_1 <-
>>  structure(
>>list(
>>  c05_01 = c(
>>110,
>>110,
>>130,
>>110,
>>110,
>>110,
>>110,
>>110,
>>110,
>>110,
>>110,
>>999,
>>110,
>>495,
>>160,
>>110,
>>410
>>  ),
>>  c05_02 = c(NA,
>> NA, 120, NA, NA, 150, NA, NA, 170, 160, NA, NA, NA, NA,
>> 170,
>> NA, 130),
>>  c05_03 = c(NA, NA, NA, NA, NA, NA, NA, NA, NA, 410,
>> NA, NA, NA, NA, NA, NA, NA),
>>  c05_04 = c(
>>NA_real_,
>>NA_real_,
>>NA_real_,
>>NA_real_,
>>NA_real_,
>>NA_real_,
>>NA_real_,
>>NA_real_,
>>NA_real_,
>>NA_real_,
>>NA_real_,
>>NA_real_,
>>NA_real_,
>>NA_real_,
>>NA_real_,
>>NA_real_,
>>NA_real_
>>  ),
>>  c05_05 = c(
>>NA_real_,
>>NA_real_,
>>

Re: [R] Multiple-Response Analysis: Cleaning of Duplicate Codes

2017-04-25 Thread Bert Gunter
If I understand you correctly, one way is:

> z <- rep(LETTERS[1:3],4)
> z
 [1] "A" "B" "C" "A" "B" "C" "A" "B" "C" "A" "B" "C"
> z[!duplicated(z)]
[1] "A" "B" "C"


?duplicated

-- 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, Apr 25, 2017 at 9:36 AM,   wrote:
> Hi All,
>
> in my current project I am working with multiple-response questions
> (MRSets):
>
> -- Coding --
> 100 Main Code 1
> 110 Sub Code 1.1
> 120 Sub Code 1.2
> 130 Sub Code 1.3
>
> 200 Main Code 2
> 210 Sub Code 2.1
> 220 Sub Code 2.2
> 230 Sub Code 2.3
>
> 300 Main Code 3
> 310 Sub Code 3.1
> 320 Sub Code 3.2
>
> The coding for the variables is to detailed. Therefore I have recoded all
> sub codes to the respective main code, e.g. all 110, 120 and 130 to 100,
> all 210, 220 and 230 to 200 and all 310, 320 and 330 to 300.
>
> Now it happens that some respondents get several times the same main code.
> If the coding was done for respondent 1 with 120 and 130 after recoding
> the values are 100 and 100. If I count this, it would mean that I weight
> the multiple values of this respondent by factor 2. This is not my aim. I
> would like to count the 100 for the respective respondent only once.
>
> Here is my script so far:
>
> # -- cut --
>
> library(expss)
>
> d_sample <-
>   structure(
> list(
>   c05_01 = c(
> 110,
> 110,
> 130,
> 110,
> 110,
> 110,
> 110,
> 110,
> 110,
> 110,
> 110,
> 999,
> 110,
> 495,
> 160,
> 110,
> 410
>   ),
>   c05_02 = c(NA,
>  NA, 120, NA, NA, 150, NA, NA, 170, 160, NA, NA, NA, NA,
> 170,
>  NA, 130),
>   c05_03 = c(NA, NA, NA, NA, NA, NA, NA, NA, NA, 410,
>  NA, NA, NA, NA, NA, NA, NA),
>   c05_04 = c(
> NA_real_,
> NA_real_,
> NA_real_,
> NA_real_,
> NA_real_,
> NA_real_,
> NA_real_,
> NA_real_,
> NA_real_,
> NA_real_,
> NA_real_,
> NA_real_,
> NA_real_,
> NA_real_,
> NA_real_,
> NA_real_,
> NA_real_
>   ),
>   c05_05 = c(
> NA_real_,
> NA_real_,
> NA_real_,
> NA_real_,
> NA_real_,
> NA_real_,
> NA_real_,
> NA_real_,
> NA_real_,
> NA_real_,
> NA_real_,
> NA_real_,
> NA_real_,
> NA_real_,
> NA_real_,
> NA_real_,
> NA_real_
>   )
> ),
> .Names = c("c05_01",
>"c05_02", "c05_03", "c05_04", "c05_05"),
> row.names = c(
>   "1",
>   "2",
>   "3",
>   "4",
>   "5",
>   "10",
>   "11",
>   "12",
>   "13",
>   "14",
>   "15",
>   "20",
>   "21",
>   "22",
>   "23",
>   "24",
>   "25"
> ),
> class = "data.frame"
>   )
>
> c05_xx_r01 <- d_sample %>%
>   select(starts_with("c05_")) %>%
>   recode(c(
> 110 %thru% 195 ~ 100,
> 210 %thru% 295 ~ 200,
> 310 %thru% 395 ~ 300,
> 410 %thru% 495 ~ 400,
> 510 %thru% 595 ~ 500,
> 810 %thru% 895 ~ 800,
> 910 %thru% 999 ~ 900))
> names(c05_xx_r01) <- paste0("c05_0", 1:5, "_r01")
> d_sample <- cbind(d_sample, c05_xx_r01)
>
> # -- cut --
>
> I would like to eliminate all duplicates codes, e. g. 100 and 100 for
> respondents in row 3, 6, 13, 14 and 15 to 100 only once:
>
> # -- cut --
> d_sample_1 <-
>   structure(
> list(
>   c05_01 = c(
> 110,
> 110,
> 130,
> 110,
> 110,
> 110,
> 110,
> 110,
> 110,
> 110,
> 110,
> 999,
> 110,
> 495,
> 160,
> 110,
> 410
>   ),
>   c05_02 = c(NA,
>  NA, 120, NA, NA, 150, NA, NA, 170, 160, NA, NA, NA, NA,
> 170,
>  NA, 130),
>   c05_03 = c(NA, NA, NA, NA, NA, NA, NA, NA, NA, 410,
>  NA, NA, NA, NA, NA, NA, NA),
>   c05_04 = c(
> NA_real_,
> NA_real_,
> NA_real_,
> NA_real_,
> NA_real_,
> NA_real_,
> NA_real_,
> NA_real_,
> NA_real_,
> NA_real_,
> NA_real_,
> NA_real_,
> NA_real_,
> NA_real_,
> NA_real_,
> NA_real_,
> NA_real_
>   ),
>   c05_05 = c(
> NA_real_,
> NA_real_,
> NA_real_,
> NA_real_,
> NA_real_,
> NA_real_,
> NA_real_,
> NA_real_,
> NA_real_,
> NA_real_,
> NA_real_,
> NA_real_,
> NA_real_,
> NA_real_,
> NA_real_,
> NA_real_,
> NA_real_
>   ),
>   c05_01_r01 = c(
> 100,
> 

Re: [R] asking for help

2017-04-25 Thread Saifuddin, Miah Mohammad
Dear Altruist,


Thank you so much.


This does it.


I shall keep connected.


Regards,

Miah



From: Anthoni, Peter (IMK) 
Sent: Tuesday, April 25, 2017 8:38 AM
To: Saifuddin, Miah Mohammad
Cc: Thomas Mailund; r-help@r-project.org; PIKAL Petr
Subject: Re: [R] asking for help

Hi,

the cut function might be helpful.

vec=1: 163863
fcut=cut(vec,seq(1, 163863+1,by= 6069),include.lowest = T,right=F)
aggregate(vec,by=list(fcut),min)
aggregate(vec,by=list(fcut),max)

cheers
Peter



On 25. Apr 2017, at 14:33, PIKAL Petr 
> wrote:

Hi

-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Thomas
Mailund
Sent: Tuesday, April 25, 2017 11:20 AM
To: r-help@r-project.org; Saifuddin, Miah Mohammad
>
Subject: Re: [R] asking for help

If you write something like

indices <- rep(1:(163863/6069), each = 6069)

You can get similar result by

indices2 <- 0:163862%/%6069

but starting with zero.

or the same with
indices2 <- (0:163862%/%6069)+1

Cheers
Petr


you can get the i’th block of rows with

table[indices == i,]

It looks like a little more work than a loop would be since you have to run
through all rows for each block, but the implicit loop in this approach is 
likely
to be faster than an explicit for-loop.

Cheers
 Thomas

On 25 Apr 2017, 07.01 +0200, Saifuddin, Miah Mohammad
>, 
wrote:
I have a data frame having 163863 values. I want to subset it so that each set
has 6069 values in it. for example 1:6069 as first, 6070: 6070+6068 as second.
how can I do that, preferably in a loop.


TIA

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


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 

[R] R 3.4.0 on Windows 7 Home Premium installed apparently fine, but packages failing to load ...

2017-04-25 Thread Jan Galkowski
Hello!

I welcome the new *R* 3.4.0.  I installed it on my Windows 7 Home
Premium [Service Pack 1, updated to latest, running on an HP AMD(Phenom)
II 955 X4 Processor, 3.20 GHz, 16 GB RAM, 64-bit, with lots of free
storage on disk and a solid state disk for virtual cache]. It was
installed atop the previous *R* version.
I tried the usual *update.packages(ask=FALSE)* and found many instances
of packages, e.g., *ctmm*, *SweaveListingUtils*, *plotly*,
*scatterplot3d*, *startupmsg *which failed to install, apparently
because of an attempt to include an install of i386 instead of only x64.
I was using the Berkeley mirror via *https:*> 
> R version 3.4.0 (2017-04-21) -- "You Stupid Darkness" 
> Copyright (C) 2017 The R Foundation for Statistical Computing
> Platform: x86_64-w64-mingw32/x64 (64-bit)

I opted *not* to install from source those packages requiring
compilation, although Rtools was installed and when installing a package
before, FORTRAN compilations succeed. I also have an MSVC++ installed,
but I've not gotten that to work on Windows, unlike when I install on
Ubuntu machines.
Unfortunately, install at least for these packages fails:

Do you want to install from sources the packages which need compilation?y/n: n
Package which is only available in source form, and may need
compilation of  C/C++/Fortran: ‘gpclib’
Do you want to attempt to install these from sources?
y/n: n
trying URL '
https://mirrors.nics.utk.edu/cran/bin/windows/contrib/3.4/crosstalk_1.0.0.zip'Content
 type 'application/zip' length 598840 bytes (584 KB)
downloaded 584 KB

trying URL '
https://mirrors.nics.utk.edu/cran/bin/windows/contrib/3.4/deldir_0.1-12.zip'Content
 type 'application/zip' length 173098 bytes (169 KB)
downloaded 169 KB

trying URL '
https://mirrors.nics.utk.edu/cran/bin/windows/contrib/3.4/distr_2.6.zip'Content 
type 'application/zip' length 2226722 bytes (2.1 MB)
downloaded 2.1 MB

trying URL '
https://mirrors.nics.utk.edu/cran/bin/windows/contrib/3.4/distrEx_2.6.zip'Content
 type 'application/zip' length 720392 bytes (703 KB)
downloaded 703 KB

trying URL '
https://mirrors.nics.utk.edu/cran/bin/windows/contrib/3.4/foreign_0.8-67.zip'Content
 type 'application/zip' length 309745 bytes (302 KB)
downloaded 302 KB

trying URL '
https://mirrors.nics.utk.edu/cran/bin/windows/contrib/3.4/gam_1.14-3.zip'Content
 type 'application/zip' length 319049 bytes (311 KB)
downloaded 311 KB

trying URL '
https://mirrors.nics.utk.edu/cran/bin/windows/contrib/3.4/lattice_0.20-34.zip'Content
 type 'application/zip' length 731408 bytes (714 KB)
downloaded 714 KB

trying URL '
https://mirrors.nics.utk.edu/cran/bin/windows/contrib/3.4/MASS_7.3-45.zip'Content
 type 'application/zip' length 1173817 bytes (1.1 MB)
downloaded 1.1 MB

trying URL '
https://mirrors.nics.utk.edu/cran/bin/windows/contrib/3.4/rpart_4.1-10.zip'Content
 type 'application/zip' length 950721 bytes (928 KB)
downloaded 928 KB

trying URL '
https://mirrors.nics.utk.edu/cran/bin/windows/contrib/3.4/sem_3.1-8.zip'Content 
type 'application/zip' length 1110127 bytes (1.1 MB)
downloaded 1.1 MB

trying URL '
https://mirrors.nics.utk.edu/cran/bin/windows/contrib/3.4/SparseM_1.76.zip'Content
 type 'application/zip' length 952285 bytes (929 KB)
downloaded 929 KB

trying URL '
https://mirrors.nics.utk.edu/cran/bin/windows/contrib/3.4/survival_2.41-2.zip'Content
 type 'application/zip' length 5426933 bytes (5.2 MB)
downloaded 5.2 MB

trying URL '
https://mirrors.nics.utk.edu/cran/bin/windows/contrib/3.4/VineCopula_2.1.1.zip'Content
 type 'application/zip' length 1106702 bytes (1.1 MB)
downloaded 1.1 MB

package ‘crosstalk’ successfully unpacked and MD5 sums checked
package ‘deldir’ successfully unpacked and MD5 sums checked
package ‘distr’ successfully unpacked and MD5 sums checked
package ‘distrEx’ successfully unpacked and MD5 sums checked
package ‘foreign’ successfully unpacked and MD5 sums checked
package ‘gam’ successfully unpacked and MD5 sums checked
package ‘lattice’ successfully unpacked and MD5 sums checked
package ‘MASS’ successfully unpacked and MD5 sums checked
package ‘rpart’ successfully unpacked and MD5 sums checked
package ‘sem’ successfully unpacked and MD5 sums checked
package ‘SparseM’ successfully unpacked and MD5 sums checked
package ‘survival’ successfully unpacked and MD5 sums checked
package ‘VineCopula’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
C:\Users\Jan\AppData\Local\Temp\Rtmpyekpgu\downloaded_packages
installing the source packages ‘ctmm’, ‘plotly’, ‘scatterplot3d’,
‘startupmsg’, ‘SweaveListingUtils’
trying URL '
https://mirrors.nics.utk.edu/cran/src/contrib/ctmm_0.3.6.tar.gz'Content type 
'application/x-gzip' length 731682 bytes (714 KB)
downloaded 714 KB

trying URL '
https://mirrors.nics.utk.edu/cran/src/contrib/plotly_4.6.0.tar.gz'Content type 
'application/x-gzip' length 980458 bytes (957 KB)
downloaded 957 KB

trying URL '

Re: [R] Delayed evaluation / lazy expression evaluation

2017-04-25 Thread Thomas Mailund
If anyone are interested, I found a solution for lazy lists. A simplified 
version of their construction and access looks like this:

nil <- function() NULL
cons <- function(car, cdr) {
  force(car)
  force(cdr)
  function() list(car = car, cdr = cdr)
}

is_nil <- function(lst) is.null(lst())
car <- function(lst) lst()$car
cdr <- function(lst) lst()$cdr

An invariant is that a list is always a thunk that evaluates to either NULL or 
a list tha contains car and cdr where cdr is another list (i.e. a thunk).

Operations on lists can be made lazy by wrapping them in a thunk that returns 
an evaluated promise. The laziness comes from wrapping an expression in a 
promise and by evaluating this promise we make it behave like the un-wrapped 
list would do.

So we can, for example, implement lazy reversal and concatenation like this:

reverse <- function(lst) {
  do_reverse <- function(lst) {
    result <- nil
    while (!is_nil(lst)) {
      result <- cons(car(lst), result)
      lst <- cdr(lst)
    }
    result
  }

  force(lst)
  lazy_thunk <- function(lst) {
    function() lst()
  }
  lazy_thunk(do_reverse(lst))
}

cat <- function(l1, l2) {
  do_cat <- function(l1, l2) {
    rev_l1 <- nil
    while (!is_nil(l1)) {
      rev_l1 <- cons(car(l1), rev_l1)
      l1 <- cdr(l1)
    }
    result <- l2
    while (!is_nil(rev_l1)) {
      result <- cons(car(rev_l1), result)
      rev_l1 <- cdr(rev_l1)
    }
    result
  }

  force(l1)
  force(l2)
  lazy_thunk <- function(lst) {
    function() lst()
  }
  lazy_thunk(do_cat(l1, l2))
}


As an example of how this laziness works, we can test concatenation. 
Concatenating two lists is a fast operation, because we don’t actually evaluate 
the concatenation, but when we access the list afterward we pay for both the 
concatenation and the access.

vector_to_list <- function(v) {
  lst <- nil
  for (x in v) lst <- cons(x, lst)
  reverse(lst)
}

l1 <- vector_to_list(1:1)
l2 <- vector_to_list(1:1)

library(microbenchmark)
microbenchmark(lst <- cat(l1, l2), times = 1) # fast operation
microbenchmark(car(lst), times = 1) # slow operation
microbenchmark(car(lst), times = 1) # faster operation


Of course, such a lazy list implementation is just a slow way of implementing 
lists, but it makes it possible to exploit a combination of amortised analysis 
and persistent data structures to implement queues 
http://www.westpoint.edu/eecs/SiteAssets/SitePages/Faculty%20Publication%20Documents/Okasaki/jfp95queue.pdf


Cheers

On 24 Apr 2017, 16.35 +0200, Thomas Mailund , wrote:
> Hi, I’m playing around with ways of implementing lazy evaluation of 
> expressions. In R, function arguments are evaluated as promises but 
> expressions are evaluated immediately, so I am trying to wrap expressions in 
> thunks—functions with no arguments that evaluate an expression—to get 
> something the resembles lazy evaluation of expressions.
>
> As an example, consider this:
>
> lazy <- function(value) {
>   function() value
> }
>
> f <- lazy((1:10)[1])
>
> If we evaluate f we have to create the long vector and then get the first 
> element. We delay the evaluation to f so the first time we call f we should 
> see a slow operation and if we evaluate it again we should see faster 
> evaluations. If you run this benchmark, you will see that this is indeed what 
> we get:
>
> library(microbenchmark)
> microbenchmark(f(), times = 1)
> microbenchmark(f(), times = 1)
> microbenchmark(f(), times = 1)
> microbenchmark(f(), times = 1)
>
> Now, I want to use this to implement lazy linked lists. It is not 
> particularly important why I want to do this, but if you are interested, it 
> is because you can implement persistent queues with amortised constant time 
> operations this way, which is what I am experimenting with.
>
> I have this implementation of linked lists:
>
> list_cons <- function(elem, lst)
>   structure(list(head = elem, tail = lst), class = "linked_list")
>
> list_nil <- list_cons(NA, NULL)
> empty_list <- function() list_nil
> is_empty.linked_list <- function(x) identical(x, list_nil)
>
>
> You can implement it simpler using NULL as an empty list, but this particular 
> implementation lets me use polymorphism to implement different versions of 
> data structures — the reasoning is explained in chapter 2 of a book I’m 
> working on: https://www.dropbox.com/s/qdnjc0bx4yivl8r/book.pdf?dl=0
>
> Anyway, that list implementation doesn’t evaluate the lists lazily, so I am 
> trying to wrap these lists in calls to lazy().
>
> A simple implementation looks like this:
>
>
> lazy_empty_list <- lazy(empty_list())
> lazy_cons <- function(elm, lst) {
>   lazy(list_cons(elm, lst()))
> }
>
> Now, this works fine for adding an element to an empty list:
>
> lst <- lazy_cons(2, lazy_empty_list)
> lst()
>
> It also works fine if I add another element to an expression for constructing 
> a list:
>
> lst <- lazy_cons(1, lazy_cons(2, lazy_empty_list))
> lst()
>
> I can construct lists as 

[R] Multiple-Response Analysis: Cleaning of Duplicate Codes

2017-04-25 Thread G . Maubach
Hi All,

in my current project I am working with multiple-response questions 
(MRSets):

-- Coding --
100 Main Code 1
110 Sub Code 1.1
120 Sub Code 1.2
130 Sub Code 1.3

200 Main Code 2
210 Sub Code 2.1
220 Sub Code 2.2
230 Sub Code 2.3

300 Main Code 3
310 Sub Code 3.1
320 Sub Code 3.2

The coding for the variables is to detailed. Therefore I have recoded all 
sub codes to the respective main code, e.g. all 110, 120 and 130 to 100, 
all 210, 220 and 230 to 200 and all 310, 320 and 330 to 300.

Now it happens that some respondents get several times the same main code. 
If the coding was done for respondent 1 with 120 and 130 after recoding 
the values are 100 and 100. If I count this, it would mean that I weight 
the multiple values of this respondent by factor 2. This is not my aim. I 
would like to count the 100 for the respective respondent only once.

Here is my script so far:

# -- cut --

library(expss)

d_sample <-
  structure(
list(
  c05_01 = c(
110,
110,
130,
110,
110,
110,
110,
110,
110,
110,
110,
999,
110,
495,
160,
110,
410
  ),
  c05_02 = c(NA,
 NA, 120, NA, NA, 150, NA, NA, 170, 160, NA, NA, NA, NA, 
170,
 NA, 130),
  c05_03 = c(NA, NA, NA, NA, NA, NA, NA, NA, NA, 410,
 NA, NA, NA, NA, NA, NA, NA),
  c05_04 = c(
NA_real_,
NA_real_,
NA_real_,
NA_real_,
NA_real_,
NA_real_,
NA_real_,
NA_real_,
NA_real_,
NA_real_,
NA_real_,
NA_real_,
NA_real_,
NA_real_,
NA_real_,
NA_real_,
NA_real_
  ),
  c05_05 = c(
NA_real_,
NA_real_,
NA_real_,
NA_real_,
NA_real_,
NA_real_,
NA_real_,
NA_real_,
NA_real_,
NA_real_,
NA_real_,
NA_real_,
NA_real_,
NA_real_,
NA_real_,
NA_real_,
NA_real_
  )
),
.Names = c("c05_01",
   "c05_02", "c05_03", "c05_04", "c05_05"),
row.names = c(
  "1",
  "2",
  "3",
  "4",
  "5",
  "10",
  "11",
  "12",
  "13",
  "14",
  "15",
  "20",
  "21",
  "22",
  "23",
  "24",
  "25"
),
class = "data.frame"
  )

c05_xx_r01 <- d_sample %>%
  select(starts_with("c05_")) %>%
  recode(c(
110 %thru% 195 ~ 100,
210 %thru% 295 ~ 200,
310 %thru% 395 ~ 300,
410 %thru% 495 ~ 400,
510 %thru% 595 ~ 500,
810 %thru% 895 ~ 800,
910 %thru% 999 ~ 900))
names(c05_xx_r01) <- paste0("c05_0", 1:5, "_r01")
d_sample <- cbind(d_sample, c05_xx_r01)

# -- cut --

I would like to eliminate all duplicates codes, e. g. 100 and 100 for 
respondents in row 3, 6, 13, 14 and 15 to 100 only once:

# -- cut --
d_sample_1 <-
  structure(
list(
  c05_01 = c(
110,
110,
130,
110,
110,
110,
110,
110,
110,
110,
110,
999,
110,
495,
160,
110,
410
  ),
  c05_02 = c(NA,
 NA, 120, NA, NA, 150, NA, NA, 170, 160, NA, NA, NA, NA, 
170,
 NA, 130),
  c05_03 = c(NA, NA, NA, NA, NA, NA, NA, NA, NA, 410,
 NA, NA, NA, NA, NA, NA, NA),
  c05_04 = c(
NA_real_,
NA_real_,
NA_real_,
NA_real_,
NA_real_,
NA_real_,
NA_real_,
NA_real_,
NA_real_,
NA_real_,
NA_real_,
NA_real_,
NA_real_,
NA_real_,
NA_real_,
NA_real_,
NA_real_
  ),
  c05_05 = c(
NA_real_,
NA_real_,
NA_real_,
NA_real_,
NA_real_,
NA_real_,
NA_real_,
NA_real_,
NA_real_,
NA_real_,
NA_real_,
NA_real_,
NA_real_,
NA_real_,
NA_real_,
NA_real_,
NA_real_
  ),
  c05_01_r01 = c(
100,
100,
100,
100,
100,
100,
100,
100,
100,
100,
100,
900,
100,
400,
100,
100,
400
  ),
  c05_02_r01 = c(NA, NA, NA, NA, NA, NA, NA, NA,
 NA, NA, NA, NA, NA, NA, NA, NA, 100),
  c05_03_r01 = c(NA, NA,
 NA, NA, NA, NA, NA, NA, NA, 400, NA, NA, NA, NA, NA, 
NA, NA),
  c05_04_r01 = c(NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
 NA, NA, NA, NA, NA, NA),
  c05_05_r01 = c(NA, NA, NA, NA, NA,
 NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA)
),
.Names = c(
  "c05_01",
  "c05_02",
  "c05_03",
  "c05_04",
  "c05_05",
  "c05_01_r01",
  "c05_02_r01",
  "c05_03_r01",
  

Re: [R] asking for help

2017-04-25 Thread Anthoni, Peter (IMK)
Hi,

the cut function might be helpful.

vec=1: 163863
fcut=cut(vec,seq(1, 163863+1,by= 6069),include.lowest = T,right=F)
aggregate(vec,by=list(fcut),min)
aggregate(vec,by=list(fcut),max)

cheers
Peter



On 25. Apr 2017, at 14:33, PIKAL Petr 
> wrote:

Hi

-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Thomas
Mailund
Sent: Tuesday, April 25, 2017 11:20 AM
To: r-help@r-project.org; Saifuddin, Miah Mohammad
>
Subject: Re: [R] asking for help

If you write something like

indices <- rep(1:(163863/6069), each = 6069)

You can get similar result by

indices2 <- 0:163862%/%6069

but starting with zero.

or the same with
indices2 <- (0:163862%/%6069)+1

Cheers
Petr


you can get the i’th block of rows with

table[indices == i,]

It looks like a little more work than a loop would be since you have to run
through all rows for each block, but the implicit loop in this approach is 
likely
to be faster than an explicit for-loop.

Cheers
 Thomas

On 25 Apr 2017, 07.01 +0200, Saifuddin, Miah Mohammad
>, 
wrote:
I have a data frame having 163863 values. I want to subset it so that each set
has 6069 values in it. for example 1:6069 as first, 6070: 6070+6068 as second.
how can I do that, preferably in a loop.


TIA

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


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 

Re: [R] R-3.4.0 and survival_2.41-3 ..

2017-04-25 Thread Göran Broström



On 2017-04-25 10:34, Martin Maechler wrote:

Göran Broström 
on Tue, 25 Apr 2017 10:22:48 +0200 writes:


> I installed R-3.4.0 and got problems with the survival package, for 
instance
> 
>> library(survival)
>> mort <- data.frame(exit = 1:4, event = rep(1, 4), x = c(0, 1, 0, 1))
>> fit <- coxph(Surv(exit, event) ~ x, data = mort)
> Error in fitter(X, Y, strats, offset, init, control, weights = weights,  :
> object 'Ccoxmart' not found
> -

> No problems with R-3.3.3 and the same (latest) survival version, which
> makes me think that something is going on in my R installation rather
> than in the survival package.

> Thanks for any hint,

> Göran

>> sessionInfo()
> R version 3.4.0 (2017-04-21)
> Platform: x86_64-pc-linux-gnu (64-bit)
> Running under: Ubuntu 16.04.2 LTS

> Matrix products: default
> BLAS: /usr/lib/openblas-base/libblas.so.3
> LAPACK: /usr/lib/libopenblasp-r0.2.18.so

> locale:
> [1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C
> [3] LC_TIME=sv_SE.UTF-8LC_COLLATE=en_US.UTF-8
> [5] LC_MONETARY=sv_SE.UTF-8LC_MESSAGES=en_US.UTF-8
> [7] LC_PAPER=sv_SE.UTF-8   LC_NAME=C
> [9] LC_ADDRESS=C   LC_TELEPHONE=C
> [11] LC_MEASUREMENT=sv_SE.UTF-8 LC_IDENTIFICATION=C

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

> other attached packages:
> [1] survival_2.41-3

> loaded via a namespace (and not attached):
> [1] compiler_3.4.0  Matrix_1.2-8splines_3.4.0   grid_3.4.0
> [5] lattice_0.20-35

I'm 99.5% sure that you are using more than just the default
library of package (a very good thing - we have been doing the
same for years).

We have in NEWS for R 3.4.0

  > PACKAGE INSTALLATION:

  >   [...]

  >   [...]

  >   • Packages which register native routines for .C or .Fortran need
  > to be re-installed for this version (unless installed with
  > R-devel SVN revision r72375 or later).

and Prof Brian Ripley did announce that nicely and early on R-devel.
==> https://hypatia.math.ethz.ch/pipermail/r-devel/2017-March/073940.html

==> You have to re-install quite a few packages for R 3.4.0,
 __if__ they use .C() or .Fortran()

When we've e-talked about the issue within R-core,
Uwe Ligges noted we should really ask everyone to run

  update.packages(checkBuilt=TRUE)


A small nuisance with this is that I end up with two versions of the 
survival package (and other recommended packages), since I cannot write 
to /usr/lib/R/library. However, this is obviously a problem suitable to 
present on R-SIG-Debian. See you there.


Göran



after an update to a new major (meaning "R-x.y.0") release of R
and **not** re-use packages {inside R-x.y.z}
that were installed with R-x.(y-1).z'  ..

and of course Uwe is right:
We should ask others to do it _and_ do it ourselves.

Anyway it _is_ considerably more important for the 3.4.0
release.

Martin Maechler
ETH Zurich (and R Core team)




__
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] asking for help

2017-04-25 Thread PIKAL Petr
Hi

> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Thomas
> Mailund
> Sent: Tuesday, April 25, 2017 11:20 AM
> To: r-help@r-project.org; Saifuddin, Miah Mohammad
> 
> Subject: Re: [R] asking for help
>
> If you write something like
>
> indices <- rep(1:(163863/6069), each = 6069)

You can get similar result by

indices2 <- 0:163862%/%6069

but starting with zero.

or the same with
indices2 <- (0:163862%/%6069)+1

Cheers
Petr

>
> you can get the i’th block of rows with
>
> table[indices == i,]
>
> It looks like a little more work than a loop would be since you have to run
> through all rows for each block, but the implicit loop in this approach is 
> likely
> to be faster than an explicit for-loop.
>
> Cheers
>  Thomas
>
> On 25 Apr 2017, 07.01 +0200, Saifuddin, Miah Mohammad
> , wrote:
> I have a data frame having 163863 values. I want to subset it so that each set
> has 6069 values in it. for example 1:6069 as first, 6070: 6070+6068 as second.
> how can I do that, preferably in a loop.
>
>
> TIA
>
> [[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.


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 the posting 

Re: [R] R-3.4.0 and survival_2.41-3 ..

2017-04-25 Thread Göran Broström
Right, normally this is how it works for me when I install R from 
source. In this case, on this computer, I use the debian/ubuntu 
packaging, and then it is necessary to 'rebuild' packages, obviously.


Thanks, Göran

On 2017-04-25 12:20, Viechtbauer Wolfgang (SP) wrote:

Sort of an obvious approach, but after every upgrade (regardless if
it is major/minor), I just delete my entire personal library and
reinstall everything from scratch. For this, I have a script that
includes just a bunch of install.packages() calls. Like:

install.packages(c("lme4", "glmmML", "MCMCglmm"))
install.packages(c("psych", "GPArotation", "sem", "lavaan")) [...]

I split things up a bit, based on the purpose/topic (along the lines
of http://www.wvbauer.com/doku.php/rpackages) to keep things
organized.

This may not be the most efficient method if you use hundreds of
packages, but works for me.

Best, Wolfgang



__
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] Frequency of Combinations

2017-04-25 Thread Thierry Onkelinx
Dear Mustafa,

Please keep the mailing list in cc.

Since you claim to have written the code, you can share the code so we can
review it. That makes more sense than having us to write code for you...

Best regards,

ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and
Forest
team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
Kliniekstraat 25
1070 Anderlecht
Belgium

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to say
what the experiment died of. ~ Sir Ronald Aylmer Fisher
The plural of anecdote is not data. ~ Roger Brinner
The combination of some data and an aching desire for an answer does not
ensure that a reasonable answer can be extracted from a given body of data.
~ John Tukey

2017-04-24 19:24 GMT+02:00 abo dalash :

> Dear Thierry
>
> Many thanks for your cooperation. I'm trying to apply the steps you have
> mentioned. If you don't mind, could you please type the entire codes after
> these functions so I can make sure that I have done everything correctly. I
> mean the details inside the ().
>
> Many thanks
>  Regards
>
>
>
> Sent from my Samsung device
>
>
>  Original message 
> From: Thierry Onkelinx 
> Date: 24/04/2017 3:43 p.m. (GMT+00:00)
> To: abo dalash 
> Cc: "r-help@R-project.org" 
> Subject: Re: [R] Frequency of Combinations
>
> Dear Mustafa,
>
> I'd recommend the packages readxls to import the data, tidyr to transform
> the data into long format and dplyr to select the data.
>
> 1. read the data into R with read_excel()
> 2. transform sheet 1 into a long format with gather(). The result is one
> row for each patient / drug combination
> 3. select the relevant drugs in sheet 2 with filter()
> 4. join long sheet 1 and filtered sheet2 with inner_join()
> 5. summarise() the drug codes and names after group_by(patient_id)
> 6. count() the number of drug codes.
>
> Best regards,
>
> ir. Thierry Onkelinx
> Instituut voor natuur- en bosonderzoek / Research Institute for Nature and
> Forest
> team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
> Kliniekstraat 25
> 1070 Anderlecht
> Belgium
>
> To call in the statistician after the experiment is done may be no more
> than asking him to perform a post-mortem examination: he may be able to say
> what the experiment died of. ~ Sir Ronald Aylmer Fisher
> The plural of anecdote is not data. ~ Roger Brinner
> The combination of some data and an aching desire for an answer does not
> ensure that a reasonable answer can be extracted from a given body of data.
> ~ John Tukey
>
> 2017-04-24 7:07 GMT+02:00 abo dalash :
>
>> Hi there
>>
>> I have data set with 500,000 patients (rows) and the first column is
>> Patient I'D Number, columns from 2 to 20 are Drug1,Drug 2,...,Drug 20 so
>> each row starts with the patient ID and the remaining of cells in the row
>> are codes for names of the treatments taken by the patient. Number of
>> treatments differ between patients. For example, there are patients with 3
>> treatments only and patients with 20 drugs. The unique number of treatments
>> in the entire data set is about 6700 drugs. However, I'm interested in
>> studying only 128 drugs, these drugs are listed in a second sheet as code
>> numbers associated with their meanings (names of drugs representing the
>> code). I'm interested in identifying the most frequently used DRUG
>> COMBINATIONS between only the 128 drugs among the 6700 drugs. The structure
>> of the Excell file to be used in analysis is like this:
>>
>> -Sheet 1( the entire data set):-
>> 1   Patient IDDrug1Drug2 Drug 20.
>> 2  1125454655
>> 3  1126  60   55 45
>> .
>> .
>> 500,000
>>
>> -Sheet 2 (list of codes meanings for only the drugs of interest):
>>
>> 1Drug code meaning
>> 245Simvastatin
>> 355Aspirin
>> 460Paracetamol
>> .
>> 128
>>
>> The desired output I'm looking for :
>>
>>  Drug codes  Meaning  Frequency
>> 45+55   Simvastatin  2
>>  +Aspirin
>> 60+55 Aspirin+   1
>> Paracetamol
>> 60+45 Simvastatin+1
>> Paracetamol
>>
>> Please note the the final output does not include any combination
>> containing drug 46 as this is not in the list of drugs preferred to be
>> studied which are mentioned in sheet 2.
>>
>> Could you please help me which R codes and packages should be used to run
>> this analyisis?
>>
>> Regards
>> Mustafa
>>
>> [[alternative HTML version deleted]]
>>
>> 

Re: [R] R-3.4.0 and survival_2.41-3 ..

2017-04-25 Thread Viechtbauer Wolfgang (SP)
Sort of an obvious approach, but after every upgrade (regardless if it is 
major/minor), I just delete my entire personal library and reinstall everything 
from scratch. For this, I have a script that includes just a bunch of 
install.packages() calls. Like:

install.packages(c("lme4", "glmmML", "MCMCglmm"))
install.packages(c("psych", "GPArotation", "sem", "lavaan"))
[...]

I split things up a bit, based on the purpose/topic (along the lines of 
http://www.wvbauer.com/doku.php/rpackages) to keep things organized.

This may not be the most efficient method if you use hundreds of packages, but 
works for me.

Best,
Wolfgang

-- 
Wolfgang Viechtbauer, Ph.D., Statistician | Department of Psychiatry and
Neuropsychology | Maastricht University | P.O. Box 616 (VIJV1) | 6200 MD
Maastricht, The Netherlands | +31 (43) 388-4170 | http://www.wvbauer.com

>-Original Message-
>From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Göran
>Broström
>Sent: Tuesday, April 25, 2017 11:00
>To: Martin Maechler
>Cc: r-help@r-project.org
>Subject: Re: [R] R-3.4.0 and survival_2.41-3 ..
>
>Thanks Martin,
>
>that helped!
>
>Göran
>
>On 2017-04-25 10:34, Martin Maechler wrote:
>>> Göran Broström 
>>> on Tue, 25 Apr 2017 10:22:48 +0200 writes:
>>
>> > I installed R-3.4.0 and got problems with the survival package,
>for instance
>> > 
>> >> library(survival)
>> >> mort <- data.frame(exit = 1:4, event = rep(1, 4), x = c(0, 1, 0,
>1))
>> >> fit <- coxph(Surv(exit, event) ~ x, data = mort)
>> > Error in fitter(X, Y, strats, offset, init, control, weights =
>weights,  :
>> > object 'Ccoxmart' not found
>> > -
>>
>> > No problems with R-3.3.3 and the same (latest) survival version,
>which
>> > makes me think that something is going on in my R installation
>rather
>> > than in the survival package.
>>
>> > Thanks for any hint,
>>
>> > Göran
>>
>> >> sessionInfo()
>> > R version 3.4.0 (2017-04-21)
>> > Platform: x86_64-pc-linux-gnu (64-bit)
>> > Running under: Ubuntu 16.04.2 LTS
>>
>> > Matrix products: default
>> > BLAS: /usr/lib/openblas-base/libblas.so.3
>> > LAPACK: /usr/lib/libopenblasp-r0.2.18.so
>>
>> > locale:
>> > [1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C
>> > [3] LC_TIME=sv_SE.UTF-8LC_COLLATE=en_US.UTF-8
>> > [5] LC_MONETARY=sv_SE.UTF-8LC_MESSAGES=en_US.UTF-8
>> > [7] LC_PAPER=sv_SE.UTF-8   LC_NAME=C
>> > [9] LC_ADDRESS=C   LC_TELEPHONE=C
>> > [11] LC_MEASUREMENT=sv_SE.UTF-8 LC_IDENTIFICATION=C
>>
>> > attached base packages:
>> > [1] stats graphics  grDevices utils datasets  methods
>base
>>
>> > other attached packages:
>> > [1] survival_2.41-3
>>
>> > loaded via a namespace (and not attached):
>> > [1] compiler_3.4.0  Matrix_1.2-8splines_3.4.0   grid_3.4.0
>> > [5] lattice_0.20-35
>>
>> I'm 99.5% sure that you are using more than just the default
>> library of package (a very good thing - we have been doing the
>> same for years).
>>
>> We have in NEWS for R 3.4.0
>>
>>   > PACKAGE INSTALLATION:
>>
>>   >   [...]
>>
>>   >   [...]
>>
>>   >   • Packages which register native routines for .C or .Fortran need
>>   > to be re-installed for this version (unless installed with
>>   > R-devel SVN revision r72375 or later).
>>
>> and Prof Brian Ripley did announce that nicely and early on R-devel.
>> ==> https://hypatia.math.ethz.ch/pipermail/r-devel/2017-
>March/073940.html
>>
>> ==> You have to re-install quite a few packages for R 3.4.0,
>>  __if__ they use .C() or .Fortran()
>>
>> When we've e-talked about the issue within R-core,
>> Uwe Ligges noted we should really ask everyone to run
>>
>>update.packages(checkBuilt=TRUE)
>>
>> after an update to a new major (meaning "R-x.y.0") release of R
>> and **not** re-use packages {inside R-x.y.z}
>> that were installed with R-x.(y-1).z'  ..
>>
>> and of course Uwe is right:
>> We should ask others to do it _and_ do it ourselves.
>>
>> Anyway it _is_ considerably more important for the 3.4.0
>> release.
>>
>> Martin Maechler
>> ETH Zurich (and R Core team)
__
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] The effect of tolerance in all.equal()

2017-04-25 Thread Martin Maechler
> Ashim Kapoor 
> on Tue, 25 Apr 2017 14:02:18 +0530 writes:

> Dear all,
> I am not able to understand the interplay of absolute vs relative and
> tolerance in the use of all.equal

> If I want to find out if absolute differences between 2 numbers/vectors 
are
> bigger than a given tolerance I would do:

> all.equal(1,1.1,scale=1,tol= .1)

> If I want to find out if relative differences between 2 numbers/vectors 
are
> bigger than a given tolerance I would do :

> all.equal(1,1.1,tol=.1)

> 
##

> I can also do :

> all.equal(1,3,tol=1)

> to find out if the absolute difference is bigger than 1.But here I won't 
be
> able to detect absolute differences smaller than 1 in this case,so I don't
> think that this is a good way.

> My query is: what is the reasoning behind all.equal returning the absolute
> difference if the tolerance >= target and relative difference if tolerance
> < target?
(above, it istol  >/<=  |target|  ie. absolute value)


The following are desiderata / restrictions :

1) Relative tolerance is needed to keep things scale-invariant
   i.e.,  all.equal(x, y)  and  all.equal(1000 * x, 1000 * y)
   should typically be identical for (almost) all (x,y).

   ==> "the typical behavior should use relative error tolerance"

2) when x or y (and typically both!) are very close to zero it
   is typically undesirable to keep relative tolerances (in the
   boundary case, they _are_ zero exactly, and "relative error" is undefined).
   E.g., for most purposes, 3.45e-15 and 1.23e-17 should be counted as
   equal to zero and hence to themselves.

1) and 2) are typically reconciled by switching from relative to absolute
when the arguments are close to zero (*).

The exact cutoff at which to switch from relative to absolute
(or a combination of the two) is somewhat arbitrary(*2) and for
all.equal() has been made in the 1980's (or even slightly
earlier?) when all.equal() was introduced into the S language at
Bell labs AFAIK. Maybe John Chambers (or Rick Becker or ...,
but they may not read R-help) knows more.
*2) Then, the choice for all.equal() is in some way "least arbitrary", 
using c = 1 in the more general   tolerance >= c*|target|  framework.

*) There have been alternatives in "the (applied numerical
 analysis / algorithm) literature" seen in published algorithms,
 but I don't have any example ready.
 Notably some of these alternatives are _symmetric_ in (x,y)
 where all.equal() was designed to be asymmetric using names
 'target' and 'current'.

The alternative idea is along the following thoughts:

Assume that for "equality" we want _both_ relative and
absolute (e := tolerance) "equality"
 
   |x - y| < e (|x|+|y|)/2  (where you could use |y| or |x| 
 instead of their mean; all.equal()
 uses |target|)
   |x - y| < e * e1  (where e1 = 1, or e1 = 10^-7..)

If you add the two inequalities you get

   |x - y| < e (e1 + |x+y|/2)

as check which is a "mixture" of relative and absolute tolerance.

With a somewhat long history, my gut feeling would nowadays
actually prefer this (I think with a default of e1 = e) - which
does treat x and y symmetrically.

Note that convergence checks in good algorithms typically check
for _both_ relative and absolute difference (each with its
tolerance providable by the user), and the really good ones for
minimization do  check for (approximate) gradients also being
close to zero - as old timers among us should have learned from
Doug Bates ... but now I'm really diverging.

Last but not least some  R  code at the end,  showing that the *asymmetric*
nature of all.equal() may lead to somewhat astonishing (but very
logical and as documented!) behavior.

Martin

> Best Regards,
> Ashim


> ## The "data" to use:
> epsQ <- lapply(seq(12,18,by=1/2), function(P) bquote(10^-.(P))); names(epsQ) 
> <- sapply(epsQ, deparse); str(epsQ)
List of 13
 $ 10^-12  : language 10^-12
 $ 10^-12.5: language 10^-12.5
 $ 10^-13  : language 10^-13
 $ 10^-13.5: language 10^-13.5
 $ 10^-14  : language 10^-14
 $ 10^-14.5: language 10^-14.5
 $ 10^-15  : language 10^-15
 $ 10^-15.5: language 10^-15.5
 $ 10^-16  : language 10^-16
 $ 10^-16.5: language 10^-16.5
 $ 10^-17  : language 10^-17
 $ 10^-17.5: language 10^-17.5
 $ 10^-18  : language 10^-18

> str(lapply(epsQ, function(tl) all.equal(3.45e-15, 1.23e-17, tol = eval(tl
List of 13
 $ 10^-12  : logi TRUE
 $ 10^-12.5: logi TRUE
 $ 10^-13  : logi TRUE
 $ 10^-13.5: logi TRUE
 $ 10^-14  : logi TRUE
 $ 10^-14.5: chr "Mean relative difference: 0.9964348"
 $ 10^-15  : chr "Mean relative difference: 0.9964348"
 $ 10^-15.5: chr "Mean relative difference: 0.9964348"
 $ 10^-16  : chr "Mean relative difference: 0.9964348"
 $ 10^-16.5: chr "Mean relative 

Re: [R] asking for help

2017-04-25 Thread Thomas Mailund
If you write something like

indices <- rep(1:(163863/6069), each = 6069)

you can get the i’th block of rows with

table[indices == i,]

It looks like a little more work than a loop would be since you have to run 
through all rows for each block, but the implicit loop in this approach is 
likely to be faster than an explicit for-loop.

Cheers
 Thomas

On 25 Apr 2017, 07.01 +0200, Saifuddin, Miah Mohammad 
, wrote:
I have a data frame having 163863 values. I want to subset it so that each set 
has 6069 values in it. for example 1:6069 as first, 6070: 6070+6068 as second. 
how can I do that, preferably in a loop.


TIA

[[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] R-3.4.0 and survival_2.41-3 ..

2017-04-25 Thread Göran Broström

Thanks Martin,

that helped!

Göran

On 2017-04-25 10:34, Martin Maechler wrote:

Göran Broström 
on Tue, 25 Apr 2017 10:22:48 +0200 writes:


> I installed R-3.4.0 and got problems with the survival package, for 
instance
> 
>> library(survival)
>> mort <- data.frame(exit = 1:4, event = rep(1, 4), x = c(0, 1, 0, 1))
>> fit <- coxph(Surv(exit, event) ~ x, data = mort)
> Error in fitter(X, Y, strats, offset, init, control, weights = weights,  :
> object 'Ccoxmart' not found
> -

> No problems with R-3.3.3 and the same (latest) survival version, which
> makes me think that something is going on in my R installation rather
> than in the survival package.

> Thanks for any hint,

> Göran

>> sessionInfo()
> R version 3.4.0 (2017-04-21)
> Platform: x86_64-pc-linux-gnu (64-bit)
> Running under: Ubuntu 16.04.2 LTS

> Matrix products: default
> BLAS: /usr/lib/openblas-base/libblas.so.3
> LAPACK: /usr/lib/libopenblasp-r0.2.18.so

> locale:
> [1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C
> [3] LC_TIME=sv_SE.UTF-8LC_COLLATE=en_US.UTF-8
> [5] LC_MONETARY=sv_SE.UTF-8LC_MESSAGES=en_US.UTF-8
> [7] LC_PAPER=sv_SE.UTF-8   LC_NAME=C
> [9] LC_ADDRESS=C   LC_TELEPHONE=C
> [11] LC_MEASUREMENT=sv_SE.UTF-8 LC_IDENTIFICATION=C

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

> other attached packages:
> [1] survival_2.41-3

> loaded via a namespace (and not attached):
> [1] compiler_3.4.0  Matrix_1.2-8splines_3.4.0   grid_3.4.0
> [5] lattice_0.20-35

I'm 99.5% sure that you are using more than just the default
library of package (a very good thing - we have been doing the
same for years).

We have in NEWS for R 3.4.0

  > PACKAGE INSTALLATION:

  >   [...]

  >   [...]

  >   • Packages which register native routines for .C or .Fortran need
  > to be re-installed for this version (unless installed with
  > R-devel SVN revision r72375 or later).

and Prof Brian Ripley did announce that nicely and early on R-devel.
==> https://hypatia.math.ethz.ch/pipermail/r-devel/2017-March/073940.html

==> You have to re-install quite a few packages for R 3.4.0,
 __if__ they use .C() or .Fortran()

When we've e-talked about the issue within R-core,
Uwe Ligges noted we should really ask everyone to run

  update.packages(checkBuilt=TRUE)

after an update to a new major (meaning "R-x.y.0") release of R
and **not** re-use packages {inside R-x.y.z}
that were installed with R-x.(y-1).z'  ..

and of course Uwe is right:
We should ask others to do it _and_ do it ourselves.

Anyway it _is_ considerably more important for the 3.4.0
release.

Martin Maechler
ETH Zurich (and R Core team)




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

Re: [R] R-3.4.0 and survival_2.41-3 ..

2017-04-25 Thread Martin Maechler
> Göran Broström 
> on Tue, 25 Apr 2017 10:22:48 +0200 writes:

> I installed R-3.4.0 and got problems with the survival package, for 
instance
> 
>> library(survival)
>> mort <- data.frame(exit = 1:4, event = rep(1, 4), x = c(0, 1, 0, 1))
>> fit <- coxph(Surv(exit, event) ~ x, data = mort)
> Error in fitter(X, Y, strats, offset, init, control, weights = weights,  :
> object 'Ccoxmart' not found
> -

> No problems with R-3.3.3 and the same (latest) survival version, which 
> makes me think that something is going on in my R installation rather 
> than in the survival package.

> Thanks for any hint,

> Göran

>> sessionInfo()
> R version 3.4.0 (2017-04-21)
> Platform: x86_64-pc-linux-gnu (64-bit)
> Running under: Ubuntu 16.04.2 LTS

> Matrix products: default
> BLAS: /usr/lib/openblas-base/libblas.so.3
> LAPACK: /usr/lib/libopenblasp-r0.2.18.so

> locale:
> [1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C
> [3] LC_TIME=sv_SE.UTF-8LC_COLLATE=en_US.UTF-8
> [5] LC_MONETARY=sv_SE.UTF-8LC_MESSAGES=en_US.UTF-8
> [7] LC_PAPER=sv_SE.UTF-8   LC_NAME=C
> [9] LC_ADDRESS=C   LC_TELEPHONE=C
> [11] LC_MEASUREMENT=sv_SE.UTF-8 LC_IDENTIFICATION=C

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

> other attached packages:
> [1] survival_2.41-3

> loaded via a namespace (and not attached):
> [1] compiler_3.4.0  Matrix_1.2-8splines_3.4.0   grid_3.4.0
> [5] lattice_0.20-35

I'm 99.5% sure that you are using more than just the default
library of package (a very good thing - we have been doing the
same for years).

We have in NEWS for R 3.4.0

  > PACKAGE INSTALLATION:

  >   [...]

  >   [...]

  >   • Packages which register native routines for .C or .Fortran need
  > to be re-installed for this version (unless installed with
  > R-devel SVN revision r72375 or later).

and Prof Brian Ripley did announce that nicely and early on R-devel.
==> https://hypatia.math.ethz.ch/pipermail/r-devel/2017-March/073940.html

==> You have to re-install quite a few packages for R 3.4.0,
 __if__ they use .C() or .Fortran() 

When we've e-talked about the issue within R-core, 
Uwe Ligges noted we should really ask everyone to run

  update.packages(checkBuilt=TRUE)

after an update to a new major (meaning "R-x.y.0") release of R
and **not** re-use packages {inside R-x.y.z}
that were installed with R-x.(y-1).z'  ..

and of course Uwe is right:
We should ask others to do it _and_ do it ourselves.

Anyway it _is_ considerably more important for the 3.4.0
release.

Martin Maechler
ETH Zurich (and R Core team)

__
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] The effect of tolerance in all.equal()

2017-04-25 Thread Ashim Kapoor
Dear all,

I am not able to understand the interplay of absolute vs relative and
tolerance in the use of all.equal

If I want to find out if absolute differences between 2 numbers/vectors are
bigger than a given tolerance I would do:

all.equal(1,1.1,scale=1,tol= .1)

If I want to find out if relative differences between 2 numbers/vectors are
bigger than a given tolerance I would do :

all.equal(1,1.1,tol=.1)

##

I can also do :

all.equal(1,3,tol=1)

to find out if the absolute difference is bigger than 1.But here I won't be
able to detect absolute differences smaller than 1 in this case,so I don't
think that this is a good way.

My query is: what is the reasoning behind all.equal returning the absolute
difference if the tolerance >= target and relative difference if tolerance
< target?

Best Regards,
Ashim

[[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] R-3.4.0 and survival_2.41-3

2017-04-25 Thread Göran Broström

I installed R-3.4.0 and got problems with the survival package, for instance


> library(survival)
> mort <- data.frame(exit = 1:4, event = rep(1, 4), x = c(0, 1, 0, 1))
> fit <- coxph(Surv(exit, event) ~ x, data = mort)
Error in fitter(X, Y, strats, offset, init, control, weights = weights,  :
  object 'Ccoxmart' not found
-

No problems with R-3.3.3 and the same (latest) survival version, which 
makes me think that something is going on in my R installation rather 
than in the survival package.


Thanks for any hint,

Göran

> sessionInfo()
R version 3.4.0 (2017-04-21)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.2 LTS

Matrix products: default
BLAS: /usr/lib/openblas-base/libblas.so.3
LAPACK: /usr/lib/libopenblasp-r0.2.18.so

locale:
 [1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C
 [3] LC_TIME=sv_SE.UTF-8LC_COLLATE=en_US.UTF-8
 [5] LC_MONETARY=sv_SE.UTF-8LC_MESSAGES=en_US.UTF-8
 [7] LC_PAPER=sv_SE.UTF-8   LC_NAME=C
 [9] LC_ADDRESS=C   LC_TELEPHONE=C
[11] LC_MEASUREMENT=sv_SE.UTF-8 LC_IDENTIFICATION=C

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

other attached packages:
[1] survival_2.41-3

loaded via a namespace (and not attached):
[1] compiler_3.4.0  Matrix_1.2-8splines_3.4.0   grid_3.4.0
[5] lattice_0.20-35

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

Re: [R] R 3.4.0 problem installation

2017-04-25 Thread Berend Hasselman

> On 25 Apr 2017, at 08:21, catalin roibu  wrote:
> 
> Dear all,
> 
> I have a problem with the newest R version. I'm trying to install a
> specific package dplR how need the gpm package and I have this error on my
> macbook (OS Sierra):
> 
>> install.packages("dplR")
> also installing the dependency ‘gmp’
> 
> Packages which are only available in source form, and may
>  need compilation of C/C++/Fortran: ‘gmp’ ‘dplR’
> Do you want to attempt to install these from sources?
> y/n: y
> installing the source packages ‘gmp’, ‘dplR’
> 
> trying URL 'https://cran.rstudio.com/src/contrib/gmp_0.5-13.1.tar.gz'
> Content type 'application/x-gzip' length 131321 bytes (128 KB)
> ==
> downloaded 128 KB
> 
> trying URL 'https://cran.rstudio.com/src/contrib/dplR_1.6.5.tar.gz'
> Content type 'application/x-gzip' length 1672999 bytes (1.6 MB)
> ==
> downloaded 1.6 MB
> 
> * installing *source* package ‘gmp’ ...
> ** package ‘gmp’ successfully unpacked and MD5 sums checked
> creating cache ./config.cache
> checking for __gmpz_ui_sub in -lgmp... no
> configure: error: GNU MP not found, or not 4.1.4 or up, see
> http://gmplib.org
> ERROR: configuration failed for package ‘gmp’
> * removing
> ‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library/gmp’
> Warning in install.packages :
>  installation of package ‘gmp’ had non-zero exit status
> ERROR: dependency ‘gmp’ is not available for package ‘dplR’
> * removing
> ‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library/dplR’
> Warning in install.packages :
>  installation of package ‘dplR’ had non-zero exit status
> 
> The downloaded source packages are in
> ‘/private/var/folders/c5/6g4vbk5x55586m8ky2v_6pbcgn/T/RtmprYzSE8/downloaded_packages’
> 
> 
> All the others packages work in good conditions.
> Please help me to solve this annoying situation.
> 


This should have been sent to the R-SIG-Mac mailinglist.

If you look on CRAN for the packages Rmpfr and gmp you will see that both 
packages are not available in binary form for OS X El Capitan.  You'll have to 
wait or try to compile  gmp and mpfr relevant packages from source first before 
installing Rmpfr.
I don't know the reason for the non-availability.

Berend Hasselman

> Best regards!
> 
> CR
> 
> -- 
> 
> -
> -
> Catalin-Constantin ROIBU
> ​
> Lecturer PhD, Forestry engineer
> Forestry Faculty of Suceava
> Str. Universitatii no. 13, Suceava, 720229, Romania
> office phone  +4 0230 52 29 78, ext. 531
> mobile phone+4 0745 53 18 01
> FAX:+4 0230 52 16 64
> silvic.usv.ro 
> 
> 
> 
>   Sent with Mailtrack
> 
> <#>
> 
>   [[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.

[R] R 3.4.0 problem installation

2017-04-25 Thread catalin roibu
Dear all,

I have a problem with the newest R version. I'm trying to install a
specific package dplR how need the gpm package and I have this error on my
macbook (OS Sierra):

> install.packages("dplR")
also installing the dependency ‘gmp’

Packages which are only available in source form, and may
  need compilation of C/C++/Fortran: ‘gmp’ ‘dplR’
Do you want to attempt to install these from sources?
y/n: y
installing the source packages ‘gmp’, ‘dplR’

trying URL 'https://cran.rstudio.com/src/contrib/gmp_0.5-13.1.tar.gz'
Content type 'application/x-gzip' length 131321 bytes (128 KB)
==
downloaded 128 KB

trying URL 'https://cran.rstudio.com/src/contrib/dplR_1.6.5.tar.gz'
Content type 'application/x-gzip' length 1672999 bytes (1.6 MB)
==
downloaded 1.6 MB

* installing *source* package ‘gmp’ ...
** package ‘gmp’ successfully unpacked and MD5 sums checked
creating cache ./config.cache
checking for __gmpz_ui_sub in -lgmp... no
configure: error: GNU MP not found, or not 4.1.4 or up, see
http://gmplib.org
ERROR: configuration failed for package ‘gmp’
* removing
‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library/gmp’
Warning in install.packages :
  installation of package ‘gmp’ had non-zero exit status
ERROR: dependency ‘gmp’ is not available for package ‘dplR’
* removing
‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library/dplR’
Warning in install.packages :
  installation of package ‘dplR’ had non-zero exit status

The downloaded source packages are in
‘/private/var/folders/c5/6g4vbk5x55586m8ky2v_6pbcgn/T/RtmprYzSE8/downloaded_packages’


All the others packages work in good conditions.
Please help me to solve this annoying situation.

Best regards!

CR

-- 

-
-
Catalin-Constantin ROIBU
​
Lecturer PhD, Forestry engineer
Forestry Faculty of Suceava
Str. Universitatii no. 13, Suceava, 720229, Romania
office phone  +4 0230 52 29 78, ext. 531
mobile phone+4 0745 53 18 01
FAX:+4 0230 52 16 64
silvic.usv.ro 



   Sent with Mailtrack

<#>

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