Re: [R] Transposing forecasts results from nnetar function and turn them into a data frame

2017-03-17 Thread Rui Barradas

Hello,

By running the code of the OP, I've come to the conclusion that 
print.forecast calls print.data.frame:


forecast:::print.forecast
function (x, ...)
{
print(as.data.frame(x))
}



But I'm unable to get what the OP wants by call as.data.frame(...).
Here is the code with some made up data.

library(forecast)
library(tseries)

DAT <- data.frame(x = sample(100, 100, TRUE))

TSdata <- ts(DAT[,1], start=c(1994,10), frequency=12)
TSmodel <- nnetar(TSdata)
TSmodelForecast <- forecast(TSmodel, h=24)
TSmodelForecast

str(as.data.frame(TSmodelForecast))

Hope this helps,

Rui Barradas

Em 17-03-2017 20:48, Jim Lemon escreveu:

Hi Paul,
When manipulating any R object, the first thing to ascertain is what it is:

class(TSmodelForecast)

should give you useful information.

str(TSmodelForecast)

should give you more. Because of the wealth of defined data structures
in R, it is difficult to manipulate them without this information. I
suspect that your output is something like a time series object, and
once that is known, it should not be too hard to display its contents
in the way you want.

Jim


On Sat, Mar 18, 2017 at 7:12 AM, Paul Bernal  wrote:

Dear Jim,

Hope you are doing great. I tried to do what you suggested but R send an
error message saying that $ operator is invalid for atomic vectors.

The format of the forecasts are as follows: forecasted years are as rows,
and forecasted months are in columns what I want to do is to have two
colums, one with the forecasted dates in (MMM- format) and the second
column with the actual forecast results.

The output that is giving me hard time is the forecast output from nnetar
model.

Thanks for your valuable support,

Best of regards,

Paul


2017-03-16 18:23 GMT-05:00 Jim Lemon :


Hi Paul,
It looks like the information that is printed is in:

TSModelForecast$mean

If str(TSModelForecast$mean) returns something like a list with two
components, you can probably use something like this:

paste(format(TSModelForecast$mean$Date,"%b-%Y"),
  TSModelForecast$mean$Forecast,sep="-",collapse="\n")

It also might be in TSModelForecast$fitted

Jim


On Fri, Mar 17, 2017 at 5:34 AM, Paul Bernal 
wrote:

Dear friends,

I am currently using R version 3.3.3 (64-bit) and used the following
code
to generate forecasts:


library(forecast)

library(tseries)


 ‘tseries’ version: 0.10-35

 ‘tseries’ is a package for time series analysis and computational
finance.

 See ‘library(help="tseries")’ for details.



DAT<-read.csv("TrainingData.csv")

TSdata<-ts(DAT[,1], start=c(1994,10), frequency=12)

TSmodel<-nnetar(TSdata)

TSmodelForecast<-forecast(TSmodel, h=24)

TSmodelForecast


The problem is that the output comes in this fashion:

 JanFebMarAprMayJun JulAug
Sep   Oct
  201710  20  15  40 9 8 21
21
 19 18
  201834  15   76  10  11

The format I would like to have is the following:

Date Forecast
Jan-2017   10
Feb-2017   20
Mar-2017   15
Apr-201740
May-2017   9
Jun-20178
Jul-2017 21
Aug-2017   21
Sep-2017   19
etc  etc

Is there a way to make the results look like this?

Attached is a dataset as a reference.

Best regards,

Paul
__
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] Transposing forecasts results from nnetar function and turn them into a data frame

2017-03-17 Thread Paul Bernal
Dear Jim,

Thank you for your valuable replies. So variable mf5 has the forecasts for
a fitted nnetar model.

Below is the class and the str(mf5) output. Maybe with this information I
am sharing with you, hopefully you can give me some more guidance.

Again, thank you so much!

> class(mf5)
[1] "forecast"
>
> str(mf5)
List of 16
 $ x: Time-Series [1:377] from 1986 to 2017: 48 40 44 35 44 42 39
37 41 36 ...
 $ m: num 12
 $ p: num 25
 $ P: num 1
 $ scalex   :List of 2
  ..$ center: num 38.1
  ..$ scale : num 10.9
 $ size : num 13
 $ subset   : int [1:377] 1 2 3 4 5 6 7 8 9 10 ...
 $ model:List of 20
  ..$ :List of 15
  .. ..$ n: num [1:3] 25 13 1
  .. ..$ nunits   : int 40
  .. ..$ nconn: num [1:41] 0 0 0 0 0 0 0 0 0 0 ...
  .. ..$ conn : num [1:352] 0 1 2 3 4 5 6 7 8 9 ...
  .. ..$ nsunits  : num 39
  .. ..$ decay: num 0
  .. ..$ entropy  : logi FALSE
  .. ..$ softmax  : logi FALSE
  .. ..$ censored : logi FALSE
  .. ..$ value: num 5.83
  .. ..$ wts  : num [1:352] -1.081 2.199 0.734 1.358 1.115 ...
  .. ..$ convergence  : int 1
  .. ..$ fitted.values: num [1:352, 1] 0.246 0.439 -0.357 1.325 -0.195 ...
  .. .. ..- attr(*, "dimnames")=List of 2
  .. .. .. ..$ : NULL
  .. .. .. ..$ : NULL
  .. ..$ residuals: num [1:352, 1] -0.0754 0.00853 -0.0242 -0.05026
0.0898 ...
  .. .. ..- attr(*, "dimnames")=List of 2
  .. .. .. ..$ : NULL
  .. .. .. ..$ : NULL
  .. ..$ call : language nnet.default(x = x, y = y, size = ..1,
linout = linout, trace = trace)
  .. ..- attr(*, "class")= chr "nnet"
  ..$ :List of 15
  .. ..$ n: num [1:3] 25 13 1
  .. ..$ nunits   : int 40
  .. ..$ nconn: num [1:41] 0 0 0 0 0 0 0 0 0 0 ...
  .. ..$ conn : num [1:352] 0 1 2 3 4 5 6 7 8 9 ...
  .. ..$ nsunits  : num 39
  .. ..$ decay: num 0
  .. ..$ entropy  : logi FALSE
  .. ..$ softmax  : logi FALSE
  .. ..$ censored : logi FALSE
  .. ..$ value: num 2.54
  .. ..$ wts  : num [1:352] -7.113 4.668 -0.801 -5.487 2.751 ...
  .. ..$ convergence  : int 1
  .. ..$ fitted.values: num [1:352, 1] 0.145 0.443 -0.401 1.286 -0.158 ...
  .. .. ..- attr(*, "dimnames")=List of 2
  .. .. .. ..$ : NULL
  .. .. .. ..$ : NULL
  .. ..$ residuals: num [1:352, 1] 0.0258 0.0037 0.02 -0.0107 0.0528 ...
  .. .. ..- attr(*, "dimnames")=List of 2
  .. .. .. ..$ : NULL
  .. .. .. ..$ : NULL
  .. ..$ call : language nnet.default(x = x, y = y, size = ..1,
linout = linout, trace = trace)
  .. ..- attr(*, "class")= chr "nnet"
  ..$ :List of 15
  .. ..$ n: num [1:3] 25 13 1
  .. ..$ nunits   : int 40
  .. ..$ nconn: num [1:41] 0 0 0 0 0 0 0 0 0 0 ...
  .. ..$ conn : num [1:352] 0 1 2 3 4 5 6 7 8 9 ...
  .. ..$ nsunits  : num 39
  .. ..$ decay: num 0
  .. ..$ entropy  : logi FALSE
  .. ..$ softmax  : logi FALSE
  .. ..$ censored : logi FALSE
  .. ..$ value: num 1.1
  .. ..$ wts  : num [1:352] -2.24 -0.698 -0.243 -2.575 4.073 ...
  .. ..$ convergence  : int 1
  .. ..$ fitted.values: num [1:352, 1] 0.2466 0.2986 -0.4369 1.3053 -0.0965
...
  .. .. ..- attr(*, "dimnames")=List of 2
  .. .. .. ..$ : NULL
  .. .. .. ..$ : NULL
  .. ..$ residuals: num [1:352, 1] -0.07551 0.14845 0.056 -0.03027
-0.00844 ...
  .. .. ..- attr(*, "dimnames")=List of 2
  .. .. .. ..$ : NULL
  .. .. .. ..$ : NULL
  .. ..$ call : language nnet.default(x = x, y = y, size = ..1,
linout = linout, trace = trace)
  .. ..- attr(*, "class")= chr "nnet"
  ..$ :List of 15
  .. ..$ n: num [1:3] 25 13 1
  .. ..$ nunits   : int 40
  .. ..$ nconn: num [1:41] 0 0 0 0 0 0 0 0 0 0 ...
  .. ..$ conn : num [1:352] 0 1 2 3 4 5 6 7 8 9 ...
  .. ..$ nsunits  : num 39
  .. ..$ decay: num 0
  .. ..$ entropy  : logi FALSE
  .. ..$ softmax  : logi FALSE
  .. ..$ censored : logi FALSE
  .. ..$ value: num 1.8
  .. ..$ wts  : num [1:352] 0.427 1.89 -0.705 -3.121 -1.134 ...
  .. ..$ convergence  : int 1
  .. ..$ fitted.values: num [1:352, 1] 0.11 0.37 -0.38 1.25 -0.15 ...
  .. .. ..- attr(*, "dimnames")=List of 2
  .. .. .. ..$ : NULL
  .. .. .. ..$ : NULL
  .. ..$ residuals: num [1:352, 1] 0.06113 0.07689 -0.00135 0.02279
0.04491 ...
  .. .. ..- attr(*, "dimnames")=List of 2
  .. .. .. ..$ : NULL
  .. .. .. ..$ : NULL
  .. ..$ call : language nnet.default(x = x, y = y, size = ..1,
linout = linout, trace = trace)
  .. ..- attr(*, "class")= chr "nnet"
  ..$ :List of 15
  .. ..$ n: num [1:3] 25 13 1
  .. ..$ nunits   : int 40
  .. ..$ nconn: num [1:41] 0 0 0 0 0 0 0 0 0 0 ...
  .. ..$ conn : num [1:352] 0 1 2 3 4 5 6 7 8 9 ...
  .. ..$ nsunits  : num 39
  .. ..$ decay: num 0
  .. ..$ entropy  : logi FALSE
  .. ..$ softmax  : logi FALSE
  .. ..$ censored : logi FALSE
  .. ..$ value: num 2.67
  .. ..$ wts  

Re: [R] Transposing forecasts results from nnetar function and turn them into a data frame

2017-03-17 Thread Jim Lemon
Hi Paul,
When manipulating any R object, the first thing to ascertain is what it is:

class(TSmodelForecast)

should give you useful information.

str(TSmodelForecast)

should give you more. Because of the wealth of defined data structures
in R, it is difficult to manipulate them without this information. I
suspect that your output is something like a time series object, and
once that is known, it should not be too hard to display its contents
in the way you want.

Jim


On Sat, Mar 18, 2017 at 7:12 AM, Paul Bernal  wrote:
> Dear Jim,
>
> Hope you are doing great. I tried to do what you suggested but R send an
> error message saying that $ operator is invalid for atomic vectors.
>
> The format of the forecasts are as follows: forecasted years are as rows,
> and forecasted months are in columns what I want to do is to have two
> colums, one with the forecasted dates in (MMM- format) and the second
> column with the actual forecast results.
>
> The output that is giving me hard time is the forecast output from nnetar
> model.
>
> Thanks for your valuable support,
>
> Best of regards,
>
> Paul
>
>
> 2017-03-16 18:23 GMT-05:00 Jim Lemon :
>>
>> Hi Paul,
>> It looks like the information that is printed is in:
>>
>> TSModelForecast$mean
>>
>> If str(TSModelForecast$mean) returns something like a list with two
>> components, you can probably use something like this:
>>
>> paste(format(TSModelForecast$mean$Date,"%b-%Y"),
>>  TSModelForecast$mean$Forecast,sep="-",collapse="\n")
>>
>> It also might be in TSModelForecast$fitted
>>
>> Jim
>>
>>
>> On Fri, Mar 17, 2017 at 5:34 AM, Paul Bernal 
>> wrote:
>> > Dear friends,
>> >
>> > I am currently using R version 3.3.3 (64-bit) and used the following
>> > code
>> > to generate forecasts:
>> >
>> >> library(forecast)
>> >>
>> >> library(tseries)
>> >
>> > ‘tseries’ version: 0.10-35
>> >
>> > ‘tseries’ is a package for time series analysis and computational
>> > finance.
>> >
>> > See ‘library(help="tseries")’ for details.
>> >
>> >
>> >> DAT<-read.csv("TrainingData.csv")
>> >>
>> >> TSdata<-ts(DAT[,1], start=c(1994,10), frequency=12)
>> >>
>> >> TSmodel<-nnetar(TSdata)
>> >>
>> >> TSmodelForecast<-forecast(TSmodel, h=24)
>> >>
>> >> TSmodelForecast
>> >
>> > The problem is that the output comes in this fashion:
>> >
>> > JanFebMarAprMayJun JulAug
>> > Sep   Oct
>> >  201710  20  15  40 9 8 21
>> > 21
>> > 19 18
>> >  201834  15   76  10  11
>> >
>> > The format I would like to have is the following:
>> >
>> > Date Forecast
>> > Jan-2017   10
>> > Feb-2017   20
>> > Mar-2017   15
>> > Apr-201740
>> > May-2017   9
>> > Jun-20178
>> > Jul-2017 21
>> > Aug-2017   21
>> > Sep-2017   19
>> > etc  etc
>> >
>> > Is there a way to make the results look like this?
>> >
>> > Attached is a dataset as a reference.
>> >
>> > Best regards,
>> >
>> > Paul
>> > __
>> > 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] SOLVED: inadverted reordering of a df column when it is copied to another df

2017-03-17 Thread Karl Schilling


Dear All:

it seems I have solved my reordering issue, and to thank all those who 
answered, I briefly list the mistake I made.


I stared out from some data.frame holding values x and a grouping 
factor. Actually, my factor was a number (but not numeric) which was, 
however, not ordered. So it would go something like 1 1 1 2 2 2 4 4 4 3 3 3.


Then I performed some calculation on subsets of x defined by this factor 
using by(x, factor, function).


I then converted the result from the list obtained to a data.frame, and 
from this data.frame I copied one column into my original data.frame. 
The point I apparently missed was that the list obtained using "by", was 
ordered based on the factor (i.e. 1,1,1,2,2,2,3,3,3,4,4,4), and the same 
was true for the df I generated from this list.


Thank you for all your input

Karl



On 17.03.2017 16:16, Thierry Onkelinx wrote:
> Dear Karl,
>
> This is hard to investigate without a reproducible example.
>
> 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-03-17 16:05 GMT+01:00 Karl Schilling :
>> Dear all:
>>
>> I have two data.frames A and B of the same number of rows (about 
40,000). I
>> realized that when I copy column x from data.frame A to B, the order 
of this

>> column  gets changed. This seems to affect only values in rownumbers > ~
>> 35/36,000. It also happens in any of the following three approaches:
>>
>> A$x <- B$x
>>
>> x <- B$x (here, x is still in the correct order)
>> B$x <- x : now x is reordered
>>
>> B <- cbind(A, B$x)
>>
>> I am working with Windows7Pro/64bit, R 3.3.3, and RStudio 0.99.903.
>>
>> Any help would be appreciated.
>>
>> Best regards
>>
>> Karl Schilling
>>
>> __
>> 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] inadverted reordering of a df column when it is copied to another df

2017-03-17 Thread William Dunlap via R-help
But note that m:n does not always produce an integer sequence.  It does when
the output can be accurately represented as an integer sequence, it
does not care
if the inputs were integer or numeric.
  > class( (2^31-10):(2^31-2) )
  [1] "integer"
  > class( (2^31-10):(2^31) ) # biggest integer is as.integer(2^31-1)
  [1] "numeric"
  > str(1.7:3.7)
   num [1:3] 1.7 2.7 3.7
  > str(1.0:3.0)
   int [1:3] 1 2 3
Bill Dunlap
TIBCO Software
wdunlap tibco.com


On Fri, Mar 17, 2017 at 10:53 AM, Rui Barradas  wrote:
> Hello,
>
> Not an answer to the OP's statement, but
>
>> class(1L:4L)
> [1] "integer"
>> class(1:4)
> [1] "integer"
>
> When using m:n there's no need for mL  or nL.
>
> Rui Barradas
>
> Em 17-03-2017 16:58, Jeff Newmiller escreveu:
>>
>> Reprex confirming Bert:
>>
>> A <- data.frame( y = 1L:4L )
>> B <- data.frame( x = 1L:4L )
>> A$x <- B$x
>> plot(B$x)
>>
>> #' ![](http://i.imgur.com/cXSFsBh.png)
>>
>> Care to demonstrate for us, Karl?
>>
>> https://cran.r-project.org/web/packages/reprex/README.html
>>
>> On Fri, 17 Mar 2017, Bert Gunter wrote:
>>
>>> You are wrong. No reordering occurs.
>>>
>>> Cheers,
>>> Bert
>>>
>>> Bert Gunter
>>>
>>> "The trouble with having an open mind is that people keep coming along
>>> and sticking things into it."
>>> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>>>
>>>
>>> On Fri, Mar 17, 2017 at 8:05 AM, Karl Schilling
>>>  wrote:

 Dear all:

 I have two data.frames A and B of the same number of rows (about
 40,000). I
 realized that when I copy column x from data.frame A to B, the order
 of this
 column  gets changed. This seems to affect only values in rownumbers > ~
 35/36,000. It also happens in any of the following three approaches:

 A$x <- B$x

 x <- B$x (here, x is still in the correct order)
 B$x <- x : now x is reordered

 B <- cbind(A, B$x)

 I am working with Windows7Pro/64bit, R 3.3.3, and RStudio 0.99.903.

 Any help would be appreciated.

 Best regards

 Karl Schilling

 __
 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.
>>>
>>
>>
>> ---
>> Jeff NewmillerThe .   .  Go
>> Live...
>> DCN:Basics: ##.#.   ##.#.  Live
>> Go...
>>Live:   OO#.. Dead: OO#..  Playing
>> Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
>> /Software/Embedded Controllers)   .OO#.   .OO#.
>> rocks...1k
>>
>> __
>> 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] inadverted reordering of a df column when it is copied to another df

2017-03-17 Thread Rui Barradas

Hello,

Not an answer to the OP's statement, but

> class(1L:4L)
[1] "integer"
> class(1:4)
[1] "integer"

When using m:n there's no need for mL  or nL.

Rui Barradas

Em 17-03-2017 16:58, Jeff Newmiller escreveu:

Reprex confirming Bert:

A <- data.frame( y = 1L:4L )
B <- data.frame( x = 1L:4L )
A$x <- B$x
plot(B$x)

#' ![](http://i.imgur.com/cXSFsBh.png)

Care to demonstrate for us, Karl?

https://cran.r-project.org/web/packages/reprex/README.html

On Fri, 17 Mar 2017, Bert Gunter wrote:


You are wrong. No reordering occurs.

Cheers,
Bert

Bert Gunter

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


On Fri, Mar 17, 2017 at 8:05 AM, Karl Schilling
 wrote:

Dear all:

I have two data.frames A and B of the same number of rows (about
40,000). I
realized that when I copy column x from data.frame A to B, the order
of this
column  gets changed. This seems to affect only values in rownumbers > ~
35/36,000. It also happens in any of the following three approaches:

A$x <- B$x

x <- B$x (here, x is still in the correct order)
B$x <- x : now x is reordered

B <- cbind(A, B$x)

I am working with Windows7Pro/64bit, R 3.3.3, and RStudio 0.99.903.

Any help would be appreciated.

Best regards

Karl Schilling

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



---
Jeff NewmillerThe .   .  Go Live...
DCN:Basics: ##.#.   ##.#.  Live Go...
   Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k

__
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] lagging over consecutive pairs of rows in dataframe

2017-03-17 Thread Bert Gunter
Evan:

Yes, I stand partially corrected. You have the concept correct, but R
implements it differently than SAS.

I think what you want for your approach is diff():

evens <-  (seq_len(nrow(mydata)) %% 2) == 0
newdat <-data.frame(exp=mydata[evens,1 ],reslt= diff(mydata[,2])[evens[-1]])

... which seems neater to me than what I offered previously.

Cheers,
Bert

Bert Gunter

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


On Fri, Mar 17, 2017 at 10:25 AM, Evan Cooch  wrote:
>
>
> On 3/17/2017 1:19 PM, Bert Gunter wrote:
>>
>> Evan:
>>
>> You misunderstand the concept of a lagged variable.
>
>
> Well, lag in R, perhaps (and by my own admission). In SAS, thats exactly how
> it works.:
>
> data test;
> input exp rslt;
> cards;
> 
> *;
>
>
> data test2; set test; by exp;
> diff=rslt-lag(rslt);
>   if last.exp;
>
>>
>> Ulrik:
>>
>> Well, yes, that is certainly a general solution that works. However,
>> given the *specific* structure described by the OP, an even more
>> direct (maybe more efficient?) way to do it just uses (logical)
>> subscripting:
>>
>> odds <-  (seq_len(nrow(mydata)) %% 2) == 1
>> newdat <-data.frame(mydata[odds,1 ],mydata[!odds,2] - mydata[odds,2])
>> names(newdat) <- names(mydata)
>>
>
> Interesting - thanks!
>
>
>>
>> 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 Fri, Mar 17, 2017 at 9:58 AM, Ulrik Stervbo 
>> wrote:
>>>
>>> Hi Evan
>>>
>>> you can easily do this by applying diff() to each exp group.
>>>
>>> Either using dplyr:
>>> library(dplyr)
>>> mydata %>%
>>>group_by(exp) %>%
>>>summarise(difference = diff(rslt))
>>>
>>> Or with base R
>>> aggregate(mydata, by = list(group = mydata$exp), FUN = diff)
>>>
>>> HTH
>>> Ulrik
>>>
>>>
>>> On Fri, 17 Mar 2017 at 17:34 Evan Cooch  wrote:
>>>
 Suppose I have a dataframe that looks like the following:

 n=2
 mydata <- data.frame(exp = rep(1:5,each=n), rslt =
 c(12,15,7,8,24,28,33,15,22,11))
 mydata
  exp rslt
 11   12
 21   15
 327
 428
 53   24
 63   28
 74   33
 84   15
 95   22
 10   5   11

 The variable 'exp' (for experiment') occurs in pairs over consecutive
 rows -- 1,1, then 2,2, then 3,3, and so on. The first row in a pair is
 the 'control', and the second is a 'treatment'. The rslt column is the
 result.

 What I'm trying to do is create a subset of this dataframe that consists
 of the exp number, and the lagged difference between the 'control' and
 'treatment' result.  So, for exp=1, the difference is (15-12)=3. For
 exp=2,  the difference is (8-7)=1, and so on. What I'm hoping to do is
 take mydata (above), and turn it into

exp  diff
 1   1  3
 2   2  1
 3   3  4
 4   4  -18
 5   5  -11

 The basic 'trick' I can't figure out is how to create a lagged variable
 between the second row (record) for a given level of exp, and the first
 row for that exp.  This is easy to do in SAS (which I'm more familiar
 with), but I'm struggling with the equivalent in R. The brute force
 approach  I thought of is to simply split the dataframe into to (one
 even rows, one odd rows), merge by exp, and then calculate a difference.
 But this seems to require renaming the rslt column in the two new
 dataframes so they are different in the merge (say, rslt_cont n the odd
 dataframe, and rslt_trt in the even dataframe), allowing me to calculate
 a difference between the two.

 While I suppose this would work, I'm wondering if I'm missing a more
 elegant 'in place' approach that doesn't require me to split the data
 frame and do every via a merge.

 Suggestions/pointers to the obvious welcome. I've tried playing with
 lag, and some approaches using lag in the zoo package,  but haven't
 found the magic trick. The problem (meaning, what I can't figure out)
 seems to be conditioning the lag on the level of exp.

 Many thanks...


 mydata <-*data.frame*(x = c(20,35,45,55,70), n = rep(50,5), y =
 c(6,17,26,37,44))



  [[alternative HTML version deleted]]

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

>>>  [[alternative HTML version deleted]]
>>>
>>> 

Re: [R] lagging over consecutive pairs of rows in dataframe

2017-03-17 Thread Bert Gunter
Evan:

You misunderstand the concept of a lagged variable.

Ulrik:

Well, yes, that is certainly a general solution that works. However,
given the *specific* structure described by the OP, an even more
direct (maybe more efficient?) way to do it just uses (logical)
subscripting:

odds <-  (seq_len(nrow(mydata)) %% 2) == 1
newdat <-data.frame(mydata[odds,1 ],mydata[!odds,2] - mydata[odds,2])
names(newdat) <- names(mydata)

Cheers,
Bert



Bert Gunter

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


On Fri, Mar 17, 2017 at 9:58 AM, Ulrik Stervbo  wrote:
> Hi Evan
>
> you can easily do this by applying diff() to each exp group.
>
> Either using dplyr:
> library(dplyr)
> mydata %>%
>   group_by(exp) %>%
>   summarise(difference = diff(rslt))
>
> Or with base R
> aggregate(mydata, by = list(group = mydata$exp), FUN = diff)
>
> HTH
> Ulrik
>
>
> On Fri, 17 Mar 2017 at 17:34 Evan Cooch  wrote:
>
>> Suppose I have a dataframe that looks like the following:
>>
>> n=2
>> mydata <- data.frame(exp = rep(1:5,each=n), rslt =
>> c(12,15,7,8,24,28,33,15,22,11))
>> mydata
>> exp rslt
>> 11   12
>> 21   15
>> 327
>> 428
>> 53   24
>> 63   28
>> 74   33
>> 84   15
>> 95   22
>> 10   5   11
>>
>> The variable 'exp' (for experiment') occurs in pairs over consecutive
>> rows -- 1,1, then 2,2, then 3,3, and so on. The first row in a pair is
>> the 'control', and the second is a 'treatment'. The rslt column is the
>> result.
>>
>> What I'm trying to do is create a subset of this dataframe that consists
>> of the exp number, and the lagged difference between the 'control' and
>> 'treatment' result.  So, for exp=1, the difference is (15-12)=3. For
>> exp=2,  the difference is (8-7)=1, and so on. What I'm hoping to do is
>> take mydata (above), and turn it into
>>
>>   exp  diff
>> 1   1  3
>> 2   2  1
>> 3   3  4
>> 4   4  -18
>> 5   5  -11
>>
>> The basic 'trick' I can't figure out is how to create a lagged variable
>> between the second row (record) for a given level of exp, and the first
>> row for that exp.  This is easy to do in SAS (which I'm more familiar
>> with), but I'm struggling with the equivalent in R. The brute force
>> approach  I thought of is to simply split the dataframe into to (one
>> even rows, one odd rows), merge by exp, and then calculate a difference.
>> But this seems to require renaming the rslt column in the two new
>> dataframes so they are different in the merge (say, rslt_cont n the odd
>> dataframe, and rslt_trt in the even dataframe), allowing me to calculate
>> a difference between the two.
>>
>> While I suppose this would work, I'm wondering if I'm missing a more
>> elegant 'in place' approach that doesn't require me to split the data
>> frame and do every via a merge.
>>
>> Suggestions/pointers to the obvious welcome. I've tried playing with
>> lag, and some approaches using lag in the zoo package,  but haven't
>> found the magic trick. The problem (meaning, what I can't figure out)
>> seems to be conditioning the lag on the level of exp.
>>
>> Many thanks...
>>
>>
>> mydata <-*data.frame*(x = c(20,35,45,55,70), n = rep(50,5), y =
>> c(6,17,26,37,44))
>>
>>
>>
>> [[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.

__
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] lagging over consecutive pairs of rows in dataframe

2017-03-17 Thread Ulrik Stervbo
Hi Evan

you can easily do this by applying diff() to each exp group.

Either using dplyr:
library(dplyr)
mydata %>%
  group_by(exp) %>%
  summarise(difference = diff(rslt))

Or with base R
aggregate(mydata, by = list(group = mydata$exp), FUN = diff)

HTH
Ulrik


On Fri, 17 Mar 2017 at 17:34 Evan Cooch  wrote:

> Suppose I have a dataframe that looks like the following:
>
> n=2
> mydata <- data.frame(exp = rep(1:5,each=n), rslt =
> c(12,15,7,8,24,28,33,15,22,11))
> mydata
> exp rslt
> 11   12
> 21   15
> 327
> 428
> 53   24
> 63   28
> 74   33
> 84   15
> 95   22
> 10   5   11
>
> The variable 'exp' (for experiment') occurs in pairs over consecutive
> rows -- 1,1, then 2,2, then 3,3, and so on. The first row in a pair is
> the 'control', and the second is a 'treatment'. The rslt column is the
> result.
>
> What I'm trying to do is create a subset of this dataframe that consists
> of the exp number, and the lagged difference between the 'control' and
> 'treatment' result.  So, for exp=1, the difference is (15-12)=3. For
> exp=2,  the difference is (8-7)=1, and so on. What I'm hoping to do is
> take mydata (above), and turn it into
>
>   exp  diff
> 1   1  3
> 2   2  1
> 3   3  4
> 4   4  -18
> 5   5  -11
>
> The basic 'trick' I can't figure out is how to create a lagged variable
> between the second row (record) for a given level of exp, and the first
> row for that exp.  This is easy to do in SAS (which I'm more familiar
> with), but I'm struggling with the equivalent in R. The brute force
> approach  I thought of is to simply split the dataframe into to (one
> even rows, one odd rows), merge by exp, and then calculate a difference.
> But this seems to require renaming the rslt column in the two new
> dataframes so they are different in the merge (say, rslt_cont n the odd
> dataframe, and rslt_trt in the even dataframe), allowing me to calculate
> a difference between the two.
>
> While I suppose this would work, I'm wondering if I'm missing a more
> elegant 'in place' approach that doesn't require me to split the data
> frame and do every via a merge.
>
> Suggestions/pointers to the obvious welcome. I've tried playing with
> lag, and some approaches using lag in the zoo package,  but haven't
> found the magic trick. The problem (meaning, what I can't figure out)
> seems to be conditioning the lag on the level of exp.
>
> Many thanks...
>
>
> mydata <-*data.frame*(x = c(20,35,45,55,70), n = rep(50,5), y =
> c(6,17,26,37,44))
>
>
>
> [[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] inadverted reordering of a df column when it is copied to another df

2017-03-17 Thread Jeff Newmiller

Reprex confirming Bert:

A <- data.frame( y = 1L:4L )
B <- data.frame( x = 1L:4L )
A$x <- B$x
plot(B$x)

#' ![](http://i.imgur.com/cXSFsBh.png)

Care to demonstrate for us, Karl?

https://cran.r-project.org/web/packages/reprex/README.html

On Fri, 17 Mar 2017, Bert Gunter wrote:


You are wrong. No reordering occurs.

Cheers,
Bert

Bert Gunter

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


On Fri, Mar 17, 2017 at 8:05 AM, Karl Schilling
 wrote:

Dear all:

I have two data.frames A and B of the same number of rows (about 40,000). I
realized that when I copy column x from data.frame A to B, the order of this
column  gets changed. This seems to affect only values in rownumbers > ~
35/36,000. It also happens in any of the following three approaches:

A$x <- B$x

x <- B$x (here, x is still in the correct order)
B$x <- x : now x is reordered

B <- cbind(A, B$x)

I am working with Windows7Pro/64bit, R 3.3.3, and RStudio 0.99.903.

Any help would be appreciated.

Best regards

Karl Schilling

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



---
Jeff NewmillerThe .   .  Go Live...
DCN:Basics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k

__
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] lagging over consecutive pairs of rows in dataframe

2017-03-17 Thread Evan Cooch
Suppose I have a dataframe that looks like the following:

n=2
mydata <- data.frame(exp = rep(1:5,each=n), rslt = 
c(12,15,7,8,24,28,33,15,22,11))
mydata
exp rslt
11   12
21   15
327
428
53   24
63   28
74   33
84   15
95   22
10   5   11

The variable 'exp' (for experiment') occurs in pairs over consecutive 
rows -- 1,1, then 2,2, then 3,3, and so on. The first row in a pair is 
the 'control', and the second is a 'treatment'. The rslt column is the 
result.

What I'm trying to do is create a subset of this dataframe that consists 
of the exp number, and the lagged difference between the 'control' and 
'treatment' result.  So, for exp=1, the difference is (15-12)=3. For 
exp=2,  the difference is (8-7)=1, and so on. What I'm hoping to do is 
take mydata (above), and turn it into

  exp  diff
1   1  3
2   2  1
3   3  4
4   4  -18
5   5  -11

The basic 'trick' I can't figure out is how to create a lagged variable 
between the second row (record) for a given level of exp, and the first 
row for that exp.  This is easy to do in SAS (which I'm more familiar 
with), but I'm struggling with the equivalent in R. The brute force 
approach  I thought of is to simply split the dataframe into to (one 
even rows, one odd rows), merge by exp, and then calculate a difference. 
But this seems to require renaming the rslt column in the two new 
dataframes so they are different in the merge (say, rslt_cont n the odd 
dataframe, and rslt_trt in the even dataframe), allowing me to calculate 
a difference between the two.

While I suppose this would work, I'm wondering if I'm missing a more 
elegant 'in place' approach that doesn't require me to split the data 
frame and do every via a merge.

Suggestions/pointers to the obvious welcome. I've tried playing with 
lag, and some approaches using lag in the zoo package,  but haven't 
found the magic trick. The problem (meaning, what I can't figure out) 
seems to be conditioning the lag on the level of exp.

Many thanks...


mydata <-*data.frame*(x = c(20,35,45,55,70), n = rep(50,5), y = 
c(6,17,26,37,44))



[[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] inadverted reordering of a df column when it is copied to another df

2017-03-17 Thread Thierry Onkelinx
Dear Karl,

This is hard to investigate without a reproducible example.

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-03-17 16:05 GMT+01:00 Karl Schilling :
> Dear all:
>
> I have two data.frames A and B of the same number of rows (about 40,000). I
> realized that when I copy column x from data.frame A to B, the order of this
> column  gets changed. This seems to affect only values in rownumbers > ~
> 35/36,000. It also happens in any of the following three approaches:
>
> A$x <- B$x
>
> x <- B$x (here, x is still in the correct order)
> B$x <- x : now x is reordered
>
> B <- cbind(A, B$x)
>
> I am working with Windows7Pro/64bit, R 3.3.3, and RStudio 0.99.903.
>
> Any help would be appreciated.
>
> Best regards
>
> Karl Schilling
>
> __
> 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] inadverted reordering of a df column when it is copied to another df

2017-03-17 Thread Bert Gunter
You are wrong. No reordering occurs.

Cheers,
Bert




Bert Gunter

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


On Fri, Mar 17, 2017 at 8:05 AM, Karl Schilling
 wrote:
> Dear all:
>
> I have two data.frames A and B of the same number of rows (about 40,000). I
> realized that when I copy column x from data.frame A to B, the order of this
> column  gets changed. This seems to affect only values in rownumbers > ~
> 35/36,000. It also happens in any of the following three approaches:
>
> A$x <- B$x
>
> x <- B$x (here, x is still in the correct order)
> B$x <- x : now x is reordered
>
> B <- cbind(A, B$x)
>
> I am working with Windows7Pro/64bit, R 3.3.3, and RStudio 0.99.903.
>
> Any help would be appreciated.
>
> Best regards
>
> Karl Schilling
>
> __
> 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] inadverted reordering of a df column when it is copied to another df

2017-03-17 Thread Karl Schilling

Dear all:

I have two data.frames A and B of the same number of rows (about 
40,000). I realized that when I copy column x from data.frame A to B, 
the order of this column  gets changed. This seems to affect only values 
in rownumbers > ~ 35/36,000. It also happens in any of the following 
three approaches:


A$x <- B$x

x <- B$x (here, x is still in the correct order)
B$x <- x : now x is reordered

B <- cbind(A, B$x)

I am working with Windows7Pro/64bit, R 3.3.3, and RStudio 0.99.903.

Any help would be appreciated.

Best regards

Karl Schilling

__
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] add median value and standard deviation bar to lattice plot

2017-03-17 Thread Bert Gunter
If I understand you correcty, I suggest you consult a local
statistician. Individual data points *cannot* have "confidence
intervals."  So you clearly need some statistical guidance, which is
not what this list is about.

Cheers,
Bert


Bert Gunter

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


On Fri, Mar 17, 2017 at 1:27 AM, Luigi Marongiu
 wrote:
> dear Bert,
> the code as I read it draws 30 median lines, one for each cluster.
> what I am looking for is a function that will plot 190 individual
> confidence intervals, one for each measurement. would the code cover
> even that instance?
> regards
> luigi
>
> On Thu, Mar 16, 2017 at 2:41 PM, Bert Gunter  wrote:
>> Just add whatever further code to decorate the groups as you like
>> within the panel.groups function. I believe I have given you
>> sufficient information in my code for you to do that if you study the
>> code carefully. Depending on what you decide to do -- which is
>> statistical and OT here (and not something I would offer specific
>> advice on remotely anyway) -- you may also have to pass down
>> additional arguments based on computations that you do with *all* the
>> data from *all* groups together.
>>
>> Cheers,
>> Bert
>>
>>
>> Bert Gunter
>>
>> "The trouble with having an open mind is that people keep coming along
>> and sticking things into it."
>> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>>
>>
>> On Thu, Mar 16, 2017 at 1:38 AM, Luigi Marongiu
>>  wrote:
>>> dear Bert,
>>> thank you for the solution, it worked perfectly. However I still would
>>> like to know how reliable are the dots that are plotted, that is why i
>>> would like to have individual bars on each dot (if possible). the
>>> standard deviation maybe is not the right tool and the confidence
>>> interval is perhaps better, but the procedure should be the same: draw
>>> an arrow from the lower to the upper limit. is that possible?
>>> regards,
>>> luigi
>>>
>>> PS sorry for the formatting, usually plain text is my default; it
>>> should have switched to html when i replied to a previous email but
>>> the difference does not show up when i type...
>>>
>>> On Wed, Mar 15, 2017 at 4:28 PM, Bert Gunter  wrote:
 There may be a specific function that handles this for you, but to
 roll your own, you need a custom panel.groups function, not the
 default. You need to modify the panel function (which is
 panel.superpose by default) to pass down the "col" argument to the
 panel.segments call in the panel.groups function.

 This should get you started:

 useOuterStrips(
strip = strip.custom(par.strip.text = list(cex = 0.75)),
strip.left = strip.custom(par.strip.text = list(cex = 0.75)),
stripplot(
   average ~ type|target+cluster,
   panel = function(x,y,col,...)
  panel.superpose(x,y,col=col,...),
   panel.groups = function(x,y,col,...){
  panel.stripplot(x,y,col=col,...)
  m <- median(y)
  panel.segments(x0 = x[1] -.5, y0 = m,
 x1 = x[1] +.5, y1 = m,
 col=col, lwd=2
 )
   },
   my.data,
   groups = type,
   pch=1,
   jitter.data = TRUE,
   main = "Group-wise",
   xlab = expression(bold("Target")), ylab = 
 expression(bold("Reading")),
   col = c("grey", "green", "red"),
   par.settings = list(strip.background = list(col=c("paleturquoise",
 "grey"))),
   scales = list(alternating = FALSE, x=list(draw=FALSE)),
   key = list(
  space = "top",
  columns = 3,
  text = list(c("Blank", "Negative", "Positive"), col="black"),
  rectangles = list(col=c("grey", "green", "red"))
   )
)
 )

 FWIW, I think adding 1 sd bars is a bad idea statistically.

 And though it made no difference here, please post in pain text, not HTML.

 Bert Gunter

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


 On Wed, Mar 15, 2017 at 2:22 AM, Luigi Marongiu
  wrote:
> Dear all,
> I am analyzing some multivariate data that is organized like this:
> 1st variable = cluster (A or B)
> 2nd variable = target (a, b, c, d, e)
> 3rd variable = type (blank, negative, positive)
> 4th variable = sample (the actual name of the sample)
> 5th variable = average (the actual reading -- please not that this is the
> mean of 

Re: [R] [FORGED] standard error for regression coefficients corresponding to factor levels

2017-03-17 Thread Doran, Harold
Just to do a better job in what is perhaps more "R-ish" w.r.t least squares 
calculations, here is perhaps a better example

ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14)
trt <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69)
group <- gl(2, 10, 20, labels = c("Ctl","Trt"))
weight <- c(ctl, trt)
lm.D9 <- lm(weight ~ group)

X <- model.matrix(lm.D9)
Xqr <- qr(X)
Q <- qr.Q(Xqr)
R <- qr.R(Xqr)


### this is same as just (X'X)^-1
 chol2inv(R)

### Compared to the prior way I mentioned

 solve(crossprod(X))

-Original Message-
From: Doran, Harold 
Sent: Friday, March 17, 2017 5:06 AM
To: Rolf Turner ; li li 
Cc: r-help 
Subject: Re: [R] [FORGED] standard error for regression coefficients 
corresponding to factor levels

A slightly more ³R-ish² way of doing

S <- solve(t(X)%*%X)

Is to instead use

S <- solve(crossprod(X))

And the idea idea of inverting the SSCP matrix only and not actually solving 
the linear system is not so great, which is why it is better to do as Rolf is 
suggesting and get all things you need from lm, which uses decompositions and 
not the algebraic representations for the solution to the linear system.

On 3/16/17, 7:41 PM, "Rolf Turner"  wrote:

>
>You have been posting to the R-help list long enough so that you should 
>have learned by now *not* to post in html.  Your code is mangled so as 
>to be unreadable.
>
>A few comments:
>
>(1) Your data frame "data1" seems to have a mysterious (and 
>irrelevant?) column named "data1" as well.
>
>(2) The covariance matrix of your coefficient estimates is indeed (as 
>you hint) a constant multiple of (X^T X)^{-1}.  So do:
>
> X <- model.matrix(~response*week,data=data1)
> S <- solve(t(X)%*%X)
> print(S)
>
>and you will see the same pattern of constancy that your results exhibit.
>
>(3) You could get the results you want much more easily, without all 
>the fooling around buried in your (illegible) code, by doing:
>
> mod <- lm(response ~ (region - 1)/week,data=data1)
> summary(mod)
>
>cheers,
>
>Rolf Turner
>
>--
>Technical Editor ANZJS
>Department of Statistics
>University of Auckland
>Phone: +64-9-373-7599 ext. 88276
>
>On 17/03/17 07:26, li li wrote:
>> Hi all,
>>   I have the following data called "data1". After fitting the ancova 
>>model  with different slopes and intercepts for each region, I 
>>calculated the  regression coefficients and the corresponding standard 
>>error. The standard  error (for intercept or for slope) are all the 
>>same for different regions.
>> Is there something wrong?
>>   I know the SE is related to (X^T X)^-1, where X is design matrix. 
>>So does  this happen whenever each factor level has the same set of 
>>values for  "week"?
>>  Thanks.
>>  Hanna
>>
>>
>>
>>> mod <- lm(response ~ region*week, data1)> tmp <- coef(summary(mod))> 
>>>res <- matrix(NA, 5,4)> res[1,1:2] <- tmp[1,1:2]> res[2:5,1] <- 
>>>tmp[1,1]+tmp[2:5,1]> res[2:5,2] <- sqrt(tmp[2:5,2]^2-tmp[1,2]^2)> 
>>>res[1,3:4] <- tmp[6,1:2]> res[2:5,3] <- tmp[6,1]+tmp[7:10,1]> 
>>>res[2:5,4] <- sqrt(tmp[7:10,2]^2-tmp[6,2]^2)
>>
>>> colnames(res) <- c("intercept", "intercept SE", "slope", "slope SE")>
>>>rownames(res) <- letters[1:5]> res   intercept intercept SE
>>>slope   slope SE
>> a 0.18404464   0.08976301 -0.018629310 0.01385073
>> b 0.17605666   0.08976301 -0.022393789 0.01385073
>> c 0.16754130   0.08976301 -0.022367770 0.01385073
>> d 0.12554452   0.08976301 -0.017464385 0.01385073
>> e 0.06153256   0.08976301  0.007714685 0.01385073
>>
>>
>>
>>
>>
>>
>>
>>> data1week region response
>> 5  3  c  0.057325067
>> 6  6  c  0.066723632
>> 7  9  c -0.025317808
>> 12 3  d  0.024692613
>> 13 6  d  0.021761492
>> 14 9  d -0.099820335
>> 19 3  c  0.119559235
>> 20 6  c -0.054456186
>> 21 9  c  0.078811180
>> 26 3  d  0.091667189
>> 27 6  d -0.053400777
>> 28 9  d  0.090754363
>> 33 3  c  0.163818085
>> 34 6  c  0.008959741
>> 35 9  c -0.115410852
>> 40 3  d  0.193920693
>> 41 6  d -0.087738914
>> 42 9  d  0.004987542
>> 47 3  a  0.121332285
>> 48 6  a -0.020202707
>> 49 9  a  0.037295785
>> 54 3  b  0.214304603
>> 55 6  b -0.052346480
>> 56 9  b  0.082501222
>> 61 3  a  0.053540767
>> 62 6  a -0.019182819
>> 63 9  a -0.057629113
>> 68 3  b  0.068592791
>> 69 6  b -0.123298216
>> 70 9  b -0.230671818
>> 75 3  a  0.330741562
>> 76 6  a  0.013902905
>> 77 9  a  0.190620360
>> 82 3  b  0.151002874
>> 83 6  b  0.086177696
>> 84 9  b  0.178982656
>> 89 3  e  0.062974799
>> 90 6  e  0.062035391
>> 91 9  e  0.206200831
>> 96 3  e  0.123102197
>> 97 6  e  0.040181790
>> 98 9  e  

Re: [R-es] ebook sobre R, gratuitos donde bajar?

2017-03-17 Thread Mauricio Monsalvo
Hola.
No sé si el formato es el que querés, pero a mi me resultan muy útiles:
http://r4ds.had.co.nz/
https://bookdown.org/rdpeng/artofdatascience/
https://bookdown.org/rdpeng/exdata/
Otrosí:
Gráficos: https://bookdown.org/paulcbauer/idv2/
Una esquelita muy útil, al menos para mi:
https://www.rstudio.com/wp-content/uploads/2015/04/ggplot2-spanish.pdf
Método Comparado: https://bookdown.org/bomeara/comparative-methods/
Para Cs Sociales (aunque con referencias al RCommander y en pdf:
https://cran.r-project.org/doc/contrib/Chicana-Introduccion_al_uso_de_R.pdf
Por lo demás, entiendo que hay cientos...


El 17 de marzo de 2017, 11:06, Horacio  escribió:

> Buenas y perdón si se preguntó antes donde es posible bajar libros
> sobre R en formato ebook de manera gratuita,,,
>
> Saludos y Gracias,,,
>
> ___
> R-help-es mailing list
> R-help-es@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-es
>



-- 
Mauricio

[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


Re: [R] weird ggplot geom_segment behaviour

2017-03-17 Thread PIKAL Petr
Hi John

Thierry already pointed me to propper direction. The key for such „zooming“ is 
to use coord_cartesian(xlim ...) which is stated, as I finally found, in xlim 
help page.

Thanks
Petr


From: John Kane [mailto:jrkrid...@yahoo.ca]
Sent: Friday, March 17, 2017 2:44 PM
To: PIKAL Petr ; r-help@r-project.org
Subject: Re: [R] weird ggplot geom_segment behaviour

Hi Petr,
It "seems" to be linked to the =/- 14 days that you are using for the limits.



The code below should  restore one more bar. After that I don't know.



p2 <- p+geom_segment(alpha=.4, size=3)+xlim(c(today()-21, today()+21))+
  geom_vline(xintercept=as.numeric(today()), colour="pink", size=5)
p2

On Friday, March 17, 2017 9:16 AM, PIKAL Petr 
> wrote:

Dear all

I try to limit geom segment plot by xlim and encounter weird behaviour.

Here is my data

> dput(temp)
temp <- structure(list(ukol = c("externí kalcinace", "povrchová úprava UVS30",
"Testy mletí UVS30", "změna koncentrace olejových disperzí",
"Mletí povrchově upravené UVS30", "mikronizace cg300"), start = 
structure(c(17245,
17203, 17252, 17257, 17238, 17224), class = "Date"), end = structure(c(17256,
17242, 17235, 17286, 17249, 17256), class = "Date"), pracovnik = c("BAĎURA 
Richard",
"BAĎURA Richard", "BAĎURA Richard", "BAĎURA Richard", "BAĎURA Richard",
"BAĎURA Richard")), .Names = c("ukol", "start", "end", "pracovnik"
), row.names = c(27L, 35L, 49L, 53L, 59L, 79L), class = "data.frame")

#and the code

library(ggplot2)
library(lubridate)

p <- ggplot(temp, aes(x=start, y=ukol, xend=end, yend=ukol))

#This code produces correct graph.

p+geom_segment(alpha=.4, size=3)+
geom_vline(xintercept=as.numeric(today()), colour="pink", size=5)

#However for some reason I need to limit x axis and use xlim

p+geom_segment(alpha=.4, size=3)+xlim(c(today()-14, today()+14))+
geom_vline(xintercept=as.numeric(today()), colour="pink", size=5)

#The code issues warning and prevents three segments to be drawn.
#Is it expected behaviour? Or it is a bug somewhere.

> sessionInfo()
R Under development (unstable) (2017-01-11 r71964)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 10586)

locale:
[1] LC_COLLATE=Czech_Czech Republic.1250  LC_CTYPE=Czech_Czech Republic.1250
LC_MONETARY=Czech_Czech Republic.1250 LC_NUMERIC=C  
LC_TIME=Czech_Czech Republic.1250

attached base packages:
[1] statsdatasets  utilsgrDevices graphics  methods  base

other attached packages:
[1] ggplot2_2.2.1  tidyr_0.6.1readxl_0.1.1lubridate_1.6.0 
lattice_0.20-34 fun_0.1

loaded via a namespace (and not attached):
[1] Rcpp_0.12.8  dplyr_0.5.0  assertthat_0.1  R6_2.2.0
grid_3.4.0  plyr_1.8.4  DBI_0.5-1gtable_0.2.0magrittr_1.5   
 scales_0.4.1stringi_1.1.2
[12] lazyeval_0.2.0  tools_3.4.0  stringr_1.1.0munsell_0.4.3
compiler_3.4.0  colorspace_1.3-2 tibble_1.2
>
Best regards
Petr Pikal

"Kdo vždy myslí, že se učí,
bude vlasti chlouba.
Kdo si myslí, že dost umí,
začíná být trouba."
Karel Havlíček Borovský





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 

[R-es] ebook sobre R, gratuitos donde bajar?

2017-03-17 Thread Horacio
Buenas y perdón si se preguntó antes donde es posible bajar libros
sobre R en formato ebook de manera gratuita,,,

Saludos y Gracias,,,

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


Re: [R] weird ggplot geom_segment behaviour

2017-03-17 Thread John Kane via R-help
Hi Petr,It "seems" to be linked to the =/- 14 days that you are using for the 
limits.

The code below should  restore one more bar. After that I don't know.

p2 <- p+geom_segment(alpha=.4, size=3)+xlim(c(today()-21, today()+21))+
  geom_vline(xintercept=as.numeric(today()), colour="pink", size=5)
p2 

On Friday, March 17, 2017 9:16 AM, PIKAL Petr  
wrote:
 

 Dear all

I try to limit geom segment plot by xlim and encounter weird behaviour.

Here is my data

> dput(temp)
temp <- structure(list(ukol = c("externí kalcinace", "povrchová úprava UVS30",
"Testy mletí UVS30", "změna koncentrace olejových disperzí",
"Mletí povrchově upravené UVS30", "mikronizace cg300"), start = 
structure(c(17245,
17203, 17252, 17257, 17238, 17224), class = "Date"), end = structure(c(17256,
17242, 17235, 17286, 17249, 17256), class = "Date"), pracovnik = c("BAĎURA 
Richard",
"BAĎURA Richard", "BAĎURA Richard", "BAĎURA Richard", "BAĎURA Richard",
"BAĎURA Richard")), .Names = c("ukol", "start", "end", "pracovnik"
), row.names = c(27L, 35L, 49L, 53L, 59L, 79L), class = "data.frame")

#and the code

library(ggplot2)
library(lubridate)

p <- ggplot(temp, aes(x=start, y=ukol, xend=end, yend=ukol))

#This code produces correct graph.

p+geom_segment(alpha=.4, size=3)+
geom_vline(xintercept=as.numeric(today()), colour="pink", size=5)

#However for some reason I need to limit x axis and use xlim

p+geom_segment(alpha=.4, size=3)+xlim(c(today()-14, today()+14))+
geom_vline(xintercept=as.numeric(today()), colour="pink", size=5)

#The code issues warning and prevents three segments to be drawn.
#Is it expected behaviour? Or it is a bug somewhere.

> sessionInfo()
R Under development (unstable) (2017-01-11 r71964)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 10586)

locale:
[1] LC_COLLATE=Czech_Czech Republic.1250  LC_CTYPE=Czech_Czech Republic.1250    
LC_MONETARY=Czech_Czech Republic.1250 LC_NUMERIC=C                          
LC_TIME=Czech_Czech Republic.1250

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

other attached packages:
[1] ggplot2_2.2.1  tidyr_0.6.1    readxl_0.1.1    lubridate_1.6.0 
lattice_0.20-34 fun_0.1

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.8      dplyr_0.5.0      assertthat_0.1  R6_2.2.0        
grid_3.4.0      plyr_1.8.4      DBI_0.5-1        gtable_0.2.0    magrittr_1.5   
 scales_0.4.1    stringi_1.1.2
[12] lazyeval_0.2.0  tools_3.4.0      stringr_1.1.0    munsell_0.4.3    
compiler_3.4.0  colorspace_1.3-2 tibble_1.2
>
Best regards
Petr Pikal

"Kdo vždy myslí, že se učí,
bude vlasti chlouba.
Kdo si myslí, že dost umí,
začíná být trouba."
Karel Havlíček Borovský



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 

Re: [R] weird ggplot geom_segment behaviour

2017-03-17 Thread PIKAL Petr
Dear Thierry

Thanks, works great. My bad, after your advice I went through help page for 
xlim and found, that this behaviour is quite clearly stated there. I focused on 
geom_segment where I did not (obviously) find any clue.

Best regards
Petr

> -Original Message-
> From: Thierry Onkelinx [mailto:thierry.onkel...@inbo.be]
> Sent: Friday, March 17, 2017 2:30 PM
> To: PIKAL Petr 
> Cc: r-help@r-project.org
> Subject: Re: [R] weird ggplot geom_segment behaviour
>
> Dear Petr,
>
> Don't use xlim() but rather coord_cartesian(xlim = ...). See
> https://rpubs.com/INBOstats/zoom_in
>
> 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-03-17 14:15 GMT+01:00 PIKAL Petr :
> > Dear all
> >
> > I try to limit geom segment plot by xlim and encounter weird behaviour.
> >
> > Here is my data
> >
> >> dput(temp)
> > temp <- structure(list(ukol = c("externí kalcinace", "povrchová úprava
> > UVS30", "Testy mletí UVS30", "změna koncentrace olejových disperzí",
> > "Mletí povrchově upravené UVS30", "mikronizace cg300"), start =
> > structure(c(17245, 17203, 17252, 17257, 17238, 17224), class =
> > "Date"), end = structure(c(17256, 17242, 17235, 17286, 17249, 17256),
> > class = "Date"), pracovnik = c("BAĎURA Richard", "BAĎURA Richard",
> > "BAĎURA Richard", "BAĎURA Richard", "BAĎURA Richard", "BAĎURA
> Richard")), .Names = c("ukol", "start", "end", "pracovnik"
> > ), row.names = c(27L, 35L, 49L, 53L, 59L, 79L), class = "data.frame")
> >
> > #and the code
> >
> > library(ggplot2)
> > library(lubridate)
> >
> > p <- ggplot(temp, aes(x=start, y=ukol, xend=end, yend=ukol))
> >
> > #This code produces correct graph.
> >
> > p+geom_segment(alpha=.4, size=3)+
> > geom_vline(xintercept=as.numeric(today()), colour="pink", size=5)
> >
> > #However for some reason I need to limit x axis and use xlim
> >
> > p+geom_segment(alpha=.4, size=3)+xlim(c(today()-14, today()+14))+
> > geom_vline(xintercept=as.numeric(today()), colour="pink", size=5)
> >
> > #The code issues warning and prevents three segments to be drawn.
> > #Is it expected behaviour? Or it is a bug somewhere.
> >
> >> sessionInfo()
> > R Under development (unstable) (2017-01-11 r71964)
> > Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10
> > x64 (build 10586)
> >
> > locale:
> > [1] LC_COLLATE=Czech_Czech Republic.1250  LC_CTYPE=Czech_Czech
> Republic.1250LC_MONETARY=Czech_Czech Republic.1250 LC_NUMERIC=C
> LC_TIME=Czech_Czech Republic.1250
> >
> > attached base packages:
> > [1] stats datasets  utils grDevices graphics  methods   base
> >
> > other attached packages:
> > [1] ggplot2_2.2.1   tidyr_0.6.1 readxl_0.1.1lubridate_1.6.0 
> > lattice_0.20-
> 34 fun_0.1
> >
> > loaded via a namespace (and not attached):
> >  [1] Rcpp_0.12.8  dplyr_0.5.0  assertthat_0.1   R6_2.2.0 
> > grid_3.4.0
> plyr_1.8.4   DBI_0.5-1gtable_0.2.0 magrittr_1.5 
> scales_0.4.1
> stringi_1.1.2
> > [12] lazyeval_0.2.0   tools_3.4.0  stringr_1.1.0munsell_0.4.3
> compiler_3.4.0   colorspace_1.3-2 tibble_1.2
> >>
> > Best regards
> > Petr Pikal
> >
> > "Kdo vždy myslí, že se učí,
> > bude vlasti chlouba.
> > Kdo si myslí, že dost umí,
> > začíná být trouba."
> > Karel Havlíček Borovský
> >
> >
> > 
> > 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 

Re: [R] Reversing table()

2017-03-17 Thread Mark Sharp
Kevin,

The short answer is no.

The function table() takes in the vectors provided as arguments, counts the 
number of occurrences of each category by adding the integer 1L to a bin (one 
for each category or factor level), and at the end it returns the counts in 
each bin. Since it does not return the vectors, those values that went into the 
function do not survive the trip.

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





> On Mar 17, 2017, at 7:23 AM, Kevin E. Thorpe  wrote:
>
> I am wondering if there is a way to undo the results of table().
>
> For example if you had a table that looked like the result of table(x, y) or
> table(x, y, z) is there a simple/elegant way to reverse the process to get the
> "original" x, y and z vectors?
>
> Thanks,
>
> Kevin
>
> --
> Kevin E. Thorpe
> Head of Biostatistics,  Applied Health Research Centre (AHRC)
> Li Ka Shing Knowledge Institute of St. Michael's Hospital
> Assistant Professor, Dalla Lana School of Public Health
> University of Toronto
> email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016
>
> __
> R-help@r-project.org mailing list -- 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.

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

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


Re: [R] Reversing table()

2017-03-17 Thread PIKAL Petr
Is this what you want?

http://opensourceconnections.com/blog/2016/09/17/expanding-data-frequency-table-r-stata/

Cheers
Petr

> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Kevin E.
> Thorpe
> Sent: Friday, March 17, 2017 1:23 PM
> To: r-help 
> Subject: [R] Reversing table()
>
> I am wondering if there is a way to undo the results of table().
>
> For example if you had a table that looked like the result of table(x, y) or
> table(x, y, z) is there a simple/elegant way to reverse the process to get the
> "original" x, y and z vectors?
>
> Thanks,
>
> Kevin
>
> --
> Kevin E. Thorpe
> Head of Biostatistics,  Applied Health Research Centre (AHRC) Li Ka Shing
> Knowledge Institute of St. Michael's Hospital Assistant Professor, Dalla Lana
> School of Public Health University of Toronto
> email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016
>
> __
> R-help@r-project.org mailing list -- 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 guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Re: [R] weird ggplot geom_segment behaviour

2017-03-17 Thread Thierry Onkelinx
Dear Petr,

Don't use xlim() but rather coord_cartesian(xlim = ...). See
https://rpubs.com/INBOstats/zoom_in

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-03-17 14:15 GMT+01:00 PIKAL Petr :
> Dear all
>
> I try to limit geom segment plot by xlim and encounter weird behaviour.
>
> Here is my data
>
>> dput(temp)
> temp <- structure(list(ukol = c("externí kalcinace", "povrchová úprava UVS30",
> "Testy mletí UVS30", "změna koncentrace olejových disperzí",
> "Mletí povrchově upravené UVS30", "mikronizace cg300"), start = 
> structure(c(17245,
> 17203, 17252, 17257, 17238, 17224), class = "Date"), end = structure(c(17256,
> 17242, 17235, 17286, 17249, 17256), class = "Date"), pracovnik = c("BAĎURA 
> Richard",
> "BAĎURA Richard", "BAĎURA Richard", "BAĎURA Richard", "BAĎURA Richard",
> "BAĎURA Richard")), .Names = c("ukol", "start", "end", "pracovnik"
> ), row.names = c(27L, 35L, 49L, 53L, 59L, 79L), class = "data.frame")
>
> #and the code
>
> library(ggplot2)
> library(lubridate)
>
> p <- ggplot(temp, aes(x=start, y=ukol, xend=end, yend=ukol))
>
> #This code produces correct graph.
>
> p+geom_segment(alpha=.4, size=3)+
> geom_vline(xintercept=as.numeric(today()), colour="pink", size=5)
>
> #However for some reason I need to limit x axis and use xlim
>
> p+geom_segment(alpha=.4, size=3)+xlim(c(today()-14, today()+14))+
> geom_vline(xintercept=as.numeric(today()), colour="pink", size=5)
>
> #The code issues warning and prevents three segments to be drawn.
> #Is it expected behaviour? Or it is a bug somewhere.
>
>> sessionInfo()
> R Under development (unstable) (2017-01-11 r71964)
> Platform: x86_64-w64-mingw32/x64 (64-bit)
> Running under: Windows 10 x64 (build 10586)
>
> locale:
> [1] LC_COLLATE=Czech_Czech Republic.1250  LC_CTYPE=Czech_Czech Republic.1250  
>   LC_MONETARY=Czech_Czech Republic.1250 LC_NUMERIC=C  
> LC_TIME=Czech_Czech Republic.1250
>
> attached base packages:
> [1] stats datasets  utils grDevices graphics  methods   base
>
> other attached packages:
> [1] ggplot2_2.2.1   tidyr_0.6.1 readxl_0.1.1lubridate_1.6.0 
> lattice_0.20-34 fun_0.1
>
> loaded via a namespace (and not attached):
>  [1] Rcpp_0.12.8  dplyr_0.5.0  assertthat_0.1   R6_2.2.0 
> grid_3.4.0   plyr_1.8.4   DBI_0.5-1gtable_0.2.0 
> magrittr_1.5 scales_0.4.1 stringi_1.1.2
> [12] lazyeval_0.2.0   tools_3.4.0  stringr_1.1.0munsell_0.4.3
> compiler_3.4.0   colorspace_1.3-2 tibble_1.2
>>
> Best regards
> Petr Pikal
>
> "Kdo vždy myslí, že se učí,
> bude vlasti chlouba.
> Kdo si myslí, že dost umí,
> začíná být trouba."
> Karel Havlíček Borovský
>
>
> 
> 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 

Re: [R-es] Pregunta (debate) sobre licencia R

2017-03-17 Thread javier.ruben.marcuzzi
Estimado Miguel

Se entiende lo que usted dice, por estos lados todo está realizado por el IMPI, 
que es el organismo estatal que tiene como función la protección de lo 
relacionado a propiedad intelectual, registro de marcas, etc.

Hay distintas formas, puse el ejemplo de un cuadro porque en una capacitación 
donde había una empresa, pequeña, familiar, pero vive de hacer artículos con 
arcilla, el caso de sus creaciones no eran patentables, pero si por diseño o 
por la parte de arte, en definitiva tenían dos puertas para acceder a la 
protección de su creación.

Por otro lado, las bases de datos, seguro que sí (por estos lados), el software 
tiene partes o formas de protección, los procedimientos matemáticos no se 
patentables, pero sí los industriales, ¿si mi industria es el procedimiento de 
cálculo?, o algo más controvertido, el ADN no es patentable ni nada que por sí 
solo se pueda reproducir en la naturaleza, sin embargo hay una ley de semillas 
y problemas legales de muchos millones con la parte de agricultura de Estados 
Unidos, nuestras legislaciones son distintas.

En lo que a nosotros nos sirve, yo tengo un título que tiene relación médico 
paciente, se que la base de datos profesional tiene una legislación distinta 
pero la base de datos puede ser patentada, ahora, se abre una puerta muy grande 
con R, por dos caminos, uno es el R dentro de sqlserver y creo que oracle 
también, es decir R como procedimiento almacenado dentro de la base de datos 
patentada, y por otro lado Microsoft azure anunció la disponibilidad de sus 
abogados para protección intelectual, aunque desconozco los detalles. Ahora, 
como compatibilizar la protección o mecanismo ofrecido por Microsoft, la 
legislación europea, la de Argentina, etc., no tengo ni idea, pero está la 
posibilidad de ingresar a la protección legal de invención por medio de Estados 
Unidos, por lo menos ellos tendrían que negociar con cualquiera de nosotros si 
la posibilidad de Microsoft es viable (no leí los detalles de sus 
ofrecimientos).

¿Alguno de ustedes exploró azure como protección?, ¿El ofrecimiento de 
Microsoft de su departamento y experiencia legal?

Javier Rubén Marcuzzi


De: miguel.angel.rodriguez.mui...@sergas.es
Enviado: viernes, 17 de marzo de 2017 9:13
Para: javier.ruben.marcu...@gmail.com; fjr...@hotmail.com; 
r-help-es@r-project.org
Asunto: Re: [R-es] Pregunta (debate) sobre licencia R

Hola Javier.
No hay que confundir el registro de patentes (que tiene que ver con las 
"invenciones") o, como lo llama vuestro INPI, "la propiedad industrial", con 
los derechos de autor de una obra. La Monalisa no es patentable puesto que no 
es una invención; es una creación artistica y, como tal, los derechos de la 
misma sólo pueden ser ejecutados por el autor o bajo su consentimiento. 
De hecho, este es el debate al que me refería antes (je, je, je)... es el 
software una invención? (y, por tanto, patentable) o es una creación, una obra? 
Nota: En España un "programa de ordenador" NO es patentable "per se" (en virtud 
del Convenio de la Patente Europea).. pero en determinados casos y como parte 
de una invención sí que se puede patentar el conjunto.
Tema interesante, controvertido y que tiene MUCHO que ver con R, con la 
investigación y con la industria.
Un saludo,
Miguel.


El 17/03/2017 a las 12:52, javier.ruben.marcu...@gmail.com escribió:
Estimados
 
Sobre el registros, por estos lados el registro es o no es necesario, depende 
la persona, en otros términos, supongamos que pinto un cuadro, lo coloco en las 
redes sociales, hay publicación, pero luego aparece en la tapa de una revista 
muy cara, en ese caso hay registros que dicen que soy el autor, puedo reclamar, 
sin embargo estaría complicado que alguien acepte que yo pinte La Geoconda 
(Monalisa), ahora otro puede presentarse en la oficina de propiedad intelectual 
y decir que lo que yo escribí (sin nombrarme) es de él, y no nunca me entero 
hasta que me lo reclame.
 
En Argentina (que funciona distinto o similar) la parte (organismo) del estado 
se llama IMPI, lleva registros de patentes, logos de empresas, obras de arte, 
software, base de datos, lógicamente no es necesario avisar al estado la 
propiedad de una persona como puede ser la de un automóvil o casa, pero se 
puede realizar el registro, y me comentaron casos reales donde realizando la 
cola había dos personas para lo mismo, y el primero que llega gana, porque esos 
trámites tienen fecha y hora de inicio, lógicamente son temas legales, que 
dependen de cosas que no estamos acostumbrados en esta lista, pero en Argentina 
si desea puede hacer un registro de su propiedad, pero solo sirve en Argentina. 
 
Javier Rubén Marcuzzi
 
De: miguel.angel.rodriguez.mui...@sergas.es
Enviado: viernes, 17 de marzo de 2017 7:27
Para: fjr...@hotmail.com; r-help-es@r-project.org
Asunto: Re: [R-es] Pregunta (debate) sobre licencia R
 
Efectivamente, la protección y cobertura legal, frente al incumplimiento de la 
licencia, es la misma 

[R] weird ggplot geom_segment behaviour

2017-03-17 Thread PIKAL Petr
Dear all

I try to limit geom segment plot by xlim and encounter weird behaviour.

Here is my data

> dput(temp)
temp <- structure(list(ukol = c("externí kalcinace", "povrchová úprava UVS30",
"Testy mletí UVS30", "změna koncentrace olejových disperzí",
"Mletí povrchově upravené UVS30", "mikronizace cg300"), start = 
structure(c(17245,
17203, 17252, 17257, 17238, 17224), class = "Date"), end = structure(c(17256,
17242, 17235, 17286, 17249, 17256), class = "Date"), pracovnik = c("BAĎURA 
Richard",
"BAĎURA Richard", "BAĎURA Richard", "BAĎURA Richard", "BAĎURA Richard",
"BAĎURA Richard")), .Names = c("ukol", "start", "end", "pracovnik"
), row.names = c(27L, 35L, 49L, 53L, 59L, 79L), class = "data.frame")

#and the code

library(ggplot2)
library(lubridate)

p <- ggplot(temp, aes(x=start, y=ukol, xend=end, yend=ukol))

#This code produces correct graph.

p+geom_segment(alpha=.4, size=3)+
geom_vline(xintercept=as.numeric(today()), colour="pink", size=5)

#However for some reason I need to limit x axis and use xlim

p+geom_segment(alpha=.4, size=3)+xlim(c(today()-14, today()+14))+
geom_vline(xintercept=as.numeric(today()), colour="pink", size=5)

#The code issues warning and prevents three segments to be drawn.
#Is it expected behaviour? Or it is a bug somewhere.

> sessionInfo()
R Under development (unstable) (2017-01-11 r71964)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 10586)

locale:
[1] LC_COLLATE=Czech_Czech Republic.1250  LC_CTYPE=Czech_Czech Republic.1250
LC_MONETARY=Czech_Czech Republic.1250 LC_NUMERIC=C  
LC_TIME=Czech_Czech Republic.1250

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

other attached packages:
[1] ggplot2_2.2.1   tidyr_0.6.1 readxl_0.1.1lubridate_1.6.0 
lattice_0.20-34 fun_0.1

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.8  dplyr_0.5.0  assertthat_0.1   R6_2.2.0 
grid_3.4.0   plyr_1.8.4   DBI_0.5-1gtable_0.2.0 
magrittr_1.5 scales_0.4.1 stringi_1.1.2
[12] lazyeval_0.2.0   tools_3.4.0  stringr_1.1.0munsell_0.4.3
compiler_3.4.0   colorspace_1.3-2 tibble_1.2
>
Best regards
Petr Pikal

"Kdo vždy myslí, že se učí,
bude vlasti chlouba.
Kdo si myslí, že dost umí,
začíná být trouba."
Karel Havlíček Borovský



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 

[R] Reversing table()

2017-03-17 Thread Kevin E. Thorpe
I am wondering if there is a way to undo the results of table().

For example if you had a table that looked like the result of table(x, y) or 
table(x, y, z) is there a simple/elegant way to reverse the process to get the 
"original" x, y and z vectors?

Thanks,

Kevin

-- 
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's Hospital
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
R-help@r-project.org mailing list -- 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-es] Pregunta (debate) sobre licencia R

2017-03-17 Thread miguel.angel.rodriguez.muinos
Hola Javier.

No hay que confundir el registro de patentes (que tiene que ver con las 
"invenciones") o, como lo llama vuestro INPI, "la propiedad industrial", con 
los derechos de autor de una obra. La Monalisa no es patentable puesto que no 
es una invención; es una creación artistica y, como tal, los derechos de la 
misma sólo pueden ser ejecutados por el autor o bajo su consentimiento.

De hecho, este es el debate al que me refería antes (je, je, je)... es el 
software una invención? (y, por tanto, patentable) o es una creación, una obra?

Nota: En España un "programa de ordenador" NO es patentable "per se" (en virtud 
del Convenio de la Patente Europea).. pero en determinados casos y como parte 
de una invención sí que se puede patentar el conjunto.

Tema interesante, controvertido y que tiene MUCHO que ver con R, con la 
investigación y con la industria.

Un saludo,
Miguel.


El 17/03/2017 a las 12:52, 
javier.ruben.marcu...@gmail.com 
escribió:
Estimados

Sobre el registros, por estos lados el registro es o no es necesario, depende 
la persona, en otros términos, supongamos que pinto un cuadro, lo coloco en las 
redes sociales, hay publicación, pero luego aparece en la tapa de una revista 
muy cara, en ese caso hay registros que dicen que soy el autor, puedo reclamar, 
sin embargo estaría complicado que alguien acepte que yo pinte La Geoconda 
(Monalisa), ahora otro puede presentarse en la oficina de propiedad intelectual 
y decir que lo que yo escribí (sin nombrarme) es de él, y no nunca me entero 
hasta que me lo reclame.

En Argentina (que funciona distinto o similar) la parte (organismo) del estado 
se llama IMPI, lleva registros de patentes, logos de empresas, obras de arte, 
software, base de datos, lógicamente no es necesario avisar al estado la 
propiedad de una persona como puede ser la de un automóvil o casa, pero se 
puede realizar el registro, y me comentaron casos reales donde realizando la 
cola había dos personas para lo mismo, y el primero que llega gana, porque esos 
trámites tienen fecha y hora de inicio, lógicamente son temas legales, que 
dependen de cosas que no estamos acostumbrados en esta lista, pero en Argentina 
si desea puede hacer un registro de su propiedad, pero solo sirve en Argentina.

Javier Rubén Marcuzzi

De: 
miguel.angel.rodriguez.mui...@sergas.es
Enviado: viernes, 17 de marzo de 2017 7:27
Para: fjr...@hotmail.com; 
r-help-es@r-project.org
Asunto: Re: [R-es] Pregunta (debate) sobre licencia R

Efectivamente, la protección y cobertura legal, frente al incumplimiento de la 
licencia, es la misma independientemente del tipo elegido para la obra. En caso 
de conflicto o incumplimiento, la última palabra la tienen las autoridades 
competentes.


Tampoco es necesario registrarla en ningún sitio (eso se hace en el caso de las 
patentes, pero esa ya es otra historia -y otro debate-).


Un saludo,

Miguel.








Nota: A información contida nesta mensaxe e os seus posibles documentos 
adxuntos é privada e confidencial e está dirixida únicamente ó seu 
destinatario/a. Se vostede non é o/a destinatario/a orixinal desta mensaxe, por 
favor elimínea. A distribución ou copia desta mensaxe non está autorizada.

Nota: La información contenida en este mensaje y sus posibles documentos 
adjuntos es privada y confidencial y está dirigida únicamente a su 
destinatario/a. Si usted no es el/la destinatario/a original de este mensaje, 
por favor elimínelo. La distribución o copia de este mensaje no está autorizada.

See more languages: http://www.sergas.es/aviso-confidencialidad

[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


Re: [R-es] Pregunta (debate) sobre licencia R

2017-03-17 Thread Fernando Arce via R-help-es
 blockquote, div.yahoo_quoted { margin-left: 0 !important; border-left:1px 
#715FFA solid !important; padding-left:1ex !important; background-color:white 
!important; } Puedes escribir el código que quieras y darle l licencia que 
quieras, siempre que no violes licencias de otros paquetes (welcome to 
r-base).Yo me he encontrado mas de una vez con paquetes que incluían procesos 
(funciones) que eran libres, pero no gratis, salvo para usos académicos. Yo los 
podía usar libremente y gratuitamente para temas académicos pero no para 
consultoría...Saludos!Fer


Sent from Yahoo Mail for iPhone


On Friday, March 17, 2017, 3:45 am, Francisco Rodríguez  
wrote:

Hola buenos d�as, una pregunta que quiero realizar de R sobre el tema de la 
licencia y que me inquieta un poco, a ver si alguien me la puede responder de 
un modo suficientemente claro o referirme a alg�n sitio donde informarme porque 
yo por el momento estoy un poco liado.


Imaginemos el siguiente ejemplo. Una empresa crea un software totalmente basado 
en R para comercializarlo o alguien realiza un proyecto de consultor�a (a modo 
freelance) con este fin, ... (o ejemplo con esa idea)


Pregunta 1: Si yo me entero de ese desarrollo �Tendr�a yo derecho a exigir que 
se me pase el c�digo fuente de todo lo realizado o de que estuviese disponible 
para su descarga?


Pregunta 2: Si alguien de forma (seguro no �tica e ilegal no s� si las dos 
cosas o una de ellas) colgase en alg�n sitio el c�digo fuente y alguien lo 
descargase y lo revendiese �Tendr�a el creador derecho a ser idemnizado por 
plagio?


Un saludo y muchas gracias por las respuestas que me deis

    [[alternative HTML version deleted]]
___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es



[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es

Re: [R-es] Pregunta (debate) sobre licencia R

2017-03-17 Thread miguel.angel.rodriguez.muinos
Efectivamente, la protección y cobertura legal, frente al incumplimiento de la 
licencia, es la misma independientemente del tipo elegido para la obra. En caso 
de conflicto o incumplimiento, la última palabra la tienen las autoridades 
competentes.


Tampoco es necesario registrarla en ningún sitio (eso se hace en el caso de las 
patentes, pero esa ya es otra historia -y otro debate-).


Un saludo,

Miguel.



El 17/03/2017 a las 11:07, Francisco Rodríguez escribió:

Gracias Miguel Angel, me queda todo mucho mas claro, es que con el tema legal 
no tengo mucho conocimiento y me invento (o me hacen inventar) algunas cosas, 
con tu explicación y con la de los anteriores me queda claro, es que alguna 
cosa que he escuchado por allí y que me daba un poco de miedo ya que alguno ha 
argumentado en alguna reunion para criticar el software libre y es el tema de 
la licencia en si, que no da proteccion ninguna a su uso por cualquiera, pero 
el problema aqui seria similar al caso de una licencia de software privado, lo 
unico que protege es que por ejemplo en el caso de SAS, ademas de todo lo demas 
necesitas tener derecho de uso del software (es decir, estar dentro del club, 
lo cual no es facil como sabeis) y eso lo complica aun mas, pero si lo tienes y 
haces un plagio, desde luego vendra todo el tema de autoria y derechos de autor.

Un saludo, na razie











Nota: A información contida nesta mensaxe e os seus posibles documentos 
adxuntos é privada e confidencial e está dirixida únicamente ó seu 
destinatario/a. Se vostede non é o/a destinatario/a orixinal desta mensaxe, por 
favor elimínea. A distribución ou copia desta mensaxe non está autorizada.

Nota: La información contenida en este mensaje y sus posibles documentos 
adjuntos es privada y confidencial y está dirigida únicamente a su 
destinatario/a. Si usted no es el/la destinatario/a original de este mensaje, 
por favor elimínelo. La distribución o copia de este mensaje no está autorizada.

See more languages: http://www.sergas.es/aviso-confidencialidad

[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


Re: [R-es] Pregunta (debate) sobre licencia R

2017-03-17 Thread miguel.angel.rodriguez.muinos
Hola Francisco.

Todavía hoy en día existen muchas dudas sobre las licencias de software
(propiedad, derechos, costes, ...).

Voy a intentar hacer un pequeño resumen de cómo veo yo el tema:

Por un lado está la AUTORÍA; es decir, quién es el autor intelectual de
la obra en cuestión (programa y/o documentación, por ejemplo) . El autor
es la persona (o grupo de personas) que ha creado (pensado, escrito,
...) la obra.

Por otro lado está el propietario de los derechos de esa obra, que suele
ser el autor a no ser que se indique lo contrario de alguna manera (por
ejemplo, si trabajas en una empresa puede que tengas un contrato que le
cede los derechos de explotación, distribución, etc  a dicha empresa).
Ese propietario de los derechos  estipula cómo (en qué condiciones)
puede acceder el resto del mundo a dicha obra y qué puede hacer con
ella. Eso es la LICENCIA (que, como digo, consiste en una serie de
términos y/o condiciones de uso).

Hay varios tipos de licencias pero podríamos categorizarlas de la
siguiente manera:

 - Licencias privativas -> Las licencias que estipulan que la obra
tiene "todos los derechos reservados". No se puede hacer nada sin el
consentimiento expreso del propietario de los derechos.

 - Licencias NO privativas -> Las que conceden ciertos derechos a la
obra en cuestión. Hay muchos tipos dependiendo de las "libertades" que
permitan. Las más comunes son las licencias GNU/GPL (el propietario de
los derechos permite el uso, modificación, distribución de la obra pero
el resultado ha de tener la misma licencia que el original y el código
debe estar accesible públicamente) y las Creative Commons (que exigen
reconocer la autoría de la obra y permiten modificar ciertos aspectos
como son si se permite el uso para fines comerciales, si se puede
modificar y/o si se pueden crear obras derivadas)

Es decir, toda obra DEBE tener estipuladas las condiciones de uso de la
misma a través de la licencia. Hasta ahora, me imagino que por inercia,
cuando una obra no especifica el tipo de licencia que posee, se
sobreentiende que es una licencia privativa con todos lo derechos
reservados (no se puede publicar, modificar, cambiar, distribuir,
generar obras derivadas, vender, ...)

Para finalizar, comentarte que el coste de la obra (si hay que pagarla o
no) es independiente de los derechos de uso de la misma. Es decir, hay
software publicado bajo licencias libres que es de pago y software
privativo que es gratuito, por poner algún ejemplo.

Yendo, ahora, a contestar a tus preguntas

Si alguien desarrolla un programa con R debe especificar qué tipo de
licencia tiene su obra y así podremos actuar en consecuencia. Hay casos
que son muy claros, por ejemplo si publicas un paquete en CRAN estás
licenciando tu código de una manera determinada (es una de las
exigencias de CRAN) .. creo recordar que son GPL, AGPL, BSD, MIT, ...
Otra cosa es si haces un programa y no lo pones a disposición de la
Comunidad (sólo permites su uso, por ejemplo)... por eso es TAN
importante especificar la licencia de las obras.

De la misma manera, tendrías derecho a exigirle el código fuente si
estuviésemos hablando de software libre (de fuentes abiertas) licenciado
bajo  GPL o CC... pero seguramente en ese caso ya tendrías acceso al mismo.

Y, para finalizar, si alguien publica su código fuente DEBE especificar
bajo qué licencia lo hace. Si es una licencia privativa no podrías
modificarlo, venderlo,  y ahí ya entraríamos en problemas legales
que habría que resolver recurriendo a la justicia (en el lugar que
corresponda).

Resumiendo: El software tiene autor y derechos legales... si no se
especifica lo contrario debemos asumir que sus derechos están reservados
y no podemos disponer de él libremente a no ser que nos lo permitan
explícitamente. Y si se especifican los derecho legales, tendremos que
ser consecuentes con lo que se nos permite hacer en la licencia del mismo.

Espero no haberme extendido demasiado.

Un Saludo,
--
Miguel Ángel Rodríguez Muíños
Asesor Informático
Dirección Xeral de Saúde Pública
Consellería de Sanidade
Xunta de Galicia
http://dxsp.sergas.es




El 16/03/2017 a las 17:43, Francisco Rodríguez escribió:
> Hola buenos d�as, una pregunta que quiero realizar de R sobre el tema de la 
> licencia y que me inquieta un poco, a ver si alguien me la puede responder de 
> un modo suficientemente claro o referirme a alg�n sitio donde informarme 
> porque yo por el momento estoy un poco liado.
>
>
> Imaginemos el siguiente ejemplo. Una empresa crea un software totalmente 
> basado en R para comercializarlo o alguien realiza un proyecto de consultor�a 
> (a modo freelance) con este fin, ... (o ejemplo con esa idea)
>
>
> Pregunta 1: Si yo me entero de ese desarrollo �Tendr�a yo derecho a exigir 
> que se me pase el c�digo fuente de todo lo realizado o de que estuviese 
> disponible para su descarga?
>
>
> Pregunta 2: Si alguien de forma (seguro no �tica e ilegal no s� si las dos 
> cosas o una de ellas) colgase en 

Re: [R] bnlearn impute problem

2017-03-17 Thread Marco Scutari
Dear Ross,

On 17 March 2017 at 06:25,   wrote:
> I am having a problem running the "impute" function from the bnlearn
> package.

I assume you referred to the online documentation instead of the
manuals that come with the package? I included impute() in bnlearn
4.1, so you will have to upgrade to use it.

Cheers,
Marco

-- 
Marco Scutari, Ph.D.
Lecturer in Statistics, Department of Statistics
University of Oxford, United Kingdom

__
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] [FORGED] standard error for regression coefficients corresponding to factor levels

2017-03-17 Thread Doran, Harold
A slightly more ³R-ish² way of doing

S <- solve(t(X)%*%X)

Is to instead use

S <- solve(crossprod(X))

And the idea idea of inverting the SSCP matrix only and not actually
solving the linear system is not so great, which is why it is better to do
as Rolf is suggesting and get all things you need from lm, which uses
decompositions and not the algebraic representations for the solution to
the linear system.

On 3/16/17, 7:41 PM, "Rolf Turner"  wrote:

>
>You have been posting to the R-help list long enough so that you should
>have learned by now *not* to post in html.  Your code is mangled so as
>to be unreadable.
>
>A few comments:
>
>(1) Your data frame "data1" seems to have a mysterious (and irrelevant?)
>column named "data1" as well.
>
>(2) The covariance matrix of your coefficient estimates is indeed (as
>you hint) a constant multiple of (X^T X)^{-1}.  So do:
>
> X <- model.matrix(~response*week,data=data1)
> S <- solve(t(X)%*%X)
> print(S)
>
>and you will see the same pattern of constancy that your results exhibit.
>
>(3) You could get the results you want much more easily, without all the
>fooling around buried in your (illegible) code, by doing:
>
> mod <- lm(response ~ (region - 1)/week,data=data1)
> summary(mod)
>
>cheers,
>
>Rolf Turner
>
>-- 
>Technical Editor ANZJS
>Department of Statistics
>University of Auckland
>Phone: +64-9-373-7599 ext. 88276
>
>On 17/03/17 07:26, li li wrote:
>> Hi all,
>>   I have the following data called "data1". After fitting the ancova
>>model
>> with different slopes and intercepts for each region, I calculated the
>> regression coefficients and the corresponding standard error. The
>>standard
>> error (for intercept or for slope) are all the same for different
>>regions.
>> Is there something wrong?
>>   I know the SE is related to (X^T X)^-1, where X is design matrix. So
>>does
>> this happen whenever each factor level has the same set of values for
>> "week"?
>>  Thanks.
>>  Hanna
>>
>>
>>
>>> mod <- lm(response ~ region*week, data1)> tmp <- coef(summary(mod))>
>>>res <- matrix(NA, 5,4)> res[1,1:2] <- tmp[1,1:2]> res[2:5,1] <-
>>>tmp[1,1]+tmp[2:5,1]> res[2:5,2] <- sqrt(tmp[2:5,2]^2-tmp[1,2]^2)>
>>>res[1,3:4] <- tmp[6,1:2]> res[2:5,3] <- tmp[6,1]+tmp[7:10,1]>
>>>res[2:5,4] <- sqrt(tmp[7:10,2]^2-tmp[6,2]^2)
>>
>>> colnames(res) <- c("intercept", "intercept SE", "slope", "slope SE")>
>>>rownames(res) <- letters[1:5]> res   intercept intercept SE
>>>slope   slope SE
>> a 0.18404464   0.08976301 -0.018629310 0.01385073
>> b 0.17605666   0.08976301 -0.022393789 0.01385073
>> c 0.16754130   0.08976301 -0.022367770 0.01385073
>> d 0.12554452   0.08976301 -0.017464385 0.01385073
>> e 0.06153256   0.08976301  0.007714685 0.01385073
>>
>>
>>
>>
>>
>>
>>
>>> data1week region response
>> 5  3  c  0.057325067
>> 6  6  c  0.066723632
>> 7  9  c -0.025317808
>> 12 3  d  0.024692613
>> 13 6  d  0.021761492
>> 14 9  d -0.099820335
>> 19 3  c  0.119559235
>> 20 6  c -0.054456186
>> 21 9  c  0.078811180
>> 26 3  d  0.091667189
>> 27 6  d -0.053400777
>> 28 9  d  0.090754363
>> 33 3  c  0.163818085
>> 34 6  c  0.008959741
>> 35 9  c -0.115410852
>> 40 3  d  0.193920693
>> 41 6  d -0.087738914
>> 42 9  d  0.004987542
>> 47 3  a  0.121332285
>> 48 6  a -0.020202707
>> 49 9  a  0.037295785
>> 54 3  b  0.214304603
>> 55 6  b -0.052346480
>> 56 9  b  0.082501222
>> 61 3  a  0.053540767
>> 62 6  a -0.019182819
>> 63 9  a -0.057629113
>> 68 3  b  0.068592791
>> 69 6  b -0.123298216
>> 70 9  b -0.230671818
>> 75 3  a  0.330741562
>> 76 6  a  0.013902905
>> 77 9  a  0.190620360
>> 82 3  b  0.151002874
>> 83 6  b  0.086177696
>> 84 9  b  0.178982656
>> 89 3  e  0.062974799
>> 90 6  e  0.062035391
>> 91 9  e  0.206200831
>> 96 3  e  0.123102197
>> 97 6  e  0.040181790
>> 98 9  e  0.121332285
>> 1033  e  0.147557564
>> 1046  e  0.062035391
>> 1059  e  0.144965770
>>
>>  [[alternative HTML version deleted]]
>
>__
>R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] add median value and standard deviation bar to lattice plot

2017-03-17 Thread Luigi Marongiu
dear Bert,
the code as I read it draws 30 median lines, one for each cluster.
what I am looking for is a function that will plot 190 individual
confidence intervals, one for each measurement. would the code cover
even that instance?
regards
luigi

On Thu, Mar 16, 2017 at 2:41 PM, Bert Gunter  wrote:
> Just add whatever further code to decorate the groups as you like
> within the panel.groups function. I believe I have given you
> sufficient information in my code for you to do that if you study the
> code carefully. Depending on what you decide to do -- which is
> statistical and OT here (and not something I would offer specific
> advice on remotely anyway) -- you may also have to pass down
> additional arguments based on computations that you do with *all* the
> data from *all* groups together.
>
> Cheers,
> Bert
>
>
> Bert Gunter
>
> "The trouble with having an open mind is that people keep coming along
> and sticking things into it."
> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>
>
> On Thu, Mar 16, 2017 at 1:38 AM, Luigi Marongiu
>  wrote:
>> dear Bert,
>> thank you for the solution, it worked perfectly. However I still would
>> like to know how reliable are the dots that are plotted, that is why i
>> would like to have individual bars on each dot (if possible). the
>> standard deviation maybe is not the right tool and the confidence
>> interval is perhaps better, but the procedure should be the same: draw
>> an arrow from the lower to the upper limit. is that possible?
>> regards,
>> luigi
>>
>> PS sorry for the formatting, usually plain text is my default; it
>> should have switched to html when i replied to a previous email but
>> the difference does not show up when i type...
>>
>> On Wed, Mar 15, 2017 at 4:28 PM, Bert Gunter  wrote:
>>> There may be a specific function that handles this for you, but to
>>> roll your own, you need a custom panel.groups function, not the
>>> default. You need to modify the panel function (which is
>>> panel.superpose by default) to pass down the "col" argument to the
>>> panel.segments call in the panel.groups function.
>>>
>>> This should get you started:
>>>
>>> useOuterStrips(
>>>strip = strip.custom(par.strip.text = list(cex = 0.75)),
>>>strip.left = strip.custom(par.strip.text = list(cex = 0.75)),
>>>stripplot(
>>>   average ~ type|target+cluster,
>>>   panel = function(x,y,col,...)
>>>  panel.superpose(x,y,col=col,...),
>>>   panel.groups = function(x,y,col,...){
>>>  panel.stripplot(x,y,col=col,...)
>>>  m <- median(y)
>>>  panel.segments(x0 = x[1] -.5, y0 = m,
>>> x1 = x[1] +.5, y1 = m,
>>> col=col, lwd=2
>>> )
>>>   },
>>>   my.data,
>>>   groups = type,
>>>   pch=1,
>>>   jitter.data = TRUE,
>>>   main = "Group-wise",
>>>   xlab = expression(bold("Target")), ylab = expression(bold("Reading")),
>>>   col = c("grey", "green", "red"),
>>>   par.settings = list(strip.background = list(col=c("paleturquoise",
>>> "grey"))),
>>>   scales = list(alternating = FALSE, x=list(draw=FALSE)),
>>>   key = list(
>>>  space = "top",
>>>  columns = 3,
>>>  text = list(c("Blank", "Negative", "Positive"), col="black"),
>>>  rectangles = list(col=c("grey", "green", "red"))
>>>   )
>>>)
>>> )
>>>
>>> FWIW, I think adding 1 sd bars is a bad idea statistically.
>>>
>>> And though it made no difference here, please post in pain text, not HTML.
>>>
>>> Bert Gunter
>>>
>>> "The trouble with having an open mind is that people keep coming along
>>> and sticking things into it."
>>> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>>>
>>>
>>> On Wed, Mar 15, 2017 at 2:22 AM, Luigi Marongiu
>>>  wrote:
 Dear all,
 I am analyzing some multivariate data that is organized like this:
 1st variable = cluster (A or B)
 2nd variable = target (a, b, c, d, e)
 3rd variable = type (blank, negative, positive)
 4th variable = sample (the actual name of the sample)
 5th variable = average (the actual reading -- please not that this is the
 mean of different measures with an assumed normal distribution, but the
 assumption might not always be true)
 6th variable = stdev (the standard deviation associated with each reading)
 7th variable = ll (lower limit that is average stdev)
 8th variable = ul (upper limit that is average + stdev)

 I am plotting the data using lattice's stripplot and I would need to add:
 1. an error bar for each measurement. the bar should be possibly coloured
 in light grey and semitransparent to reduce the noise of the plot.
 2. a type-based median bar to show differences in measurements between
 blanks, 

Re: [R] Percent transformation

2017-03-17 Thread Christoph Puschmann
Dear All,

Thank you for helping me out.

First, I am sorry for adding a HTML element. I was not aware of it. I simply 
copy and pasted the output of mat_data from R studio.

Second, no it is not homework. It was part of a side project at work.

Third, thank you Jeff. Your comment was really productive. I discovered two 
alternatives:
1) mat_data = as.matrix(sapply(x[,2:ncol(x)], percent))
2) mat_data = as.matrix(sapply(x[,2:ncol(x)], as.numeric)*100)
mat_data = round(mat_data,1)

Regards,

Christoph

> On 15 Mar 2017, at 5:32 pm, Jeff Newmiller  wrote:
> 
> Your x variable is a data frame. The scales::percent() function does not work 
> on data frames. It might work on the individual columns in the data frame. 
> You probably ought to re-read your preferred introduction to R material on 
> the difference between data frames and the columns in data frames. 
> 
> Try
> 
> scales::percent( sp[[ 1 ]] )
> 
> Do beware that that function converts your numbers into character strings, 
> unlike Excel. It is often more practical to simply multiply by 100 and forego 
> the percent sign. 
> -- 
> Sent from my phone. Please excuse my brevity.
> 
> On March 14, 2017 2:19:59 PM PDT, Christoph Puschmann 
>  wrote:
>> Hello all,
>> 
>> I am having a problem of transforming decimals into percentage.
>> Specifically, I get the following error message:
>> 
>> "Error in UseMethod("round_any") :
>> no applicable method for 'round_any' applied to an object of class
>> “data.frame"
>> 
>> My code looks the following:
>> 
>> x <- sp[1:5,2:6]
>> x = percent(x)
>> 
>> My Data:
>> 
>> SD  D   N   A   SA
>> 
>> 
>> 
>> 
>> 
>> 
>> 1
>> 
>> 0.005769231
>> 
>> -0.14230769
>> 
>> 0.071153846
>> 
>> 0.09615385
>> 
>> -0.030769231
>> 
>> 2
>> 
>> -0.057692308
>> 
>> -0.08461538
>> 
>> 0.038461538
>> 
>> 0.01923077
>> 
>> 0.084615385
>> 
>> 3
>> 
>> -0.076923077
>> 
>> -0.10384615
>> 
>> 0.221153846
>> 
>> -0.04423077
>> 
>> 0.003846154
>> 
>> 4
>> 
>> -0.167307692
>> 
>> -0.13653846
>> 
>> -0.003846154
>> 
>> 0.16153846
>> 
>> 0.146153846
>> 
>> 5
>> 
>> 0.0
>> 
>> -0.01923077
>> 
>> 0.011538462
>> 
>> 0.21923077
>> 
>> -0.2115384
>> 
>> All help would be appreciated. Thank you.
>> 
>> Christoph
>> 
>> 
>> 
>> 
>>  [[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] bnlearn impute problem

2017-03-17 Thread ross.chapman
Hi all,

 

I am having a problem running the "impute" function from the bnlearn
package.

 

I have tried running the example in the documentation  as follows:

 

with.missing.data = gaussian.test

with.missing.data[sample(nrow(with.missing.data), 500), "F"] = NA

fitted = bn.fit(model2network("[A][B][E][G][C|A:B][D|B][F|A:D:E:G]"),

   gaussian.test)

 

imputed = impute(fitted, with.missing.data)

 

Which then returns the error message:

 

Error: could not find function "impute"

 

Can you please indicate what I am doing wrong here?

 

My R version is:

 

platform   x86_64-w64-mingw32  
arch   x86_64  
os mingw32 
system x86_64, mingw32 
status 
major  3   
minor  3.1 
year   2016
month  06  
day21  
svn rev70800   
language   R   
version.string R version 3.3.1 (2016-06-21)
nickname   Bug in Your Hair

 

My bnlearn version is 4.0.

 

Many thanks

 

Ross


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