[R] About change columns and specific rows in R

2017-05-22 Thread lily li
Hi R users,

I have a question about manipulating the dataframe. I want to create a new
dataframe, and to multiply rows with different seasons for different
constants.

DF
year   month   day   product1   product2   product3
1981 1  1 18  5620
1981 1  2 19  4522
1981 1  3 16  4828
1981 1  4 19  5021
1981 2  1 17  4925
1981 2  2 20  4723
1981 2  3 21  5227

For example, how to multiply product1 in month1 by 3.1, and to multiply
product3 in month2 by 2.0? I wrote the code like this but does not work.
Thanks for your help.

DF['month'==1, ]$product1_1 = DF['month'==1, ]$product1 * 3.1;
DF['month'==2, ]$product3_1 = DF['month'==1, ]$product3 * 2.0;

[[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] problem with system.file

2017-05-22 Thread Jeff Newmiller
Did not look to me like Windows was a factor here... OP referred to 
/home/paumarc/Bam. I think the issue was trying to access his own data using an 
inappropriate function.
-- 
Sent from my phone. Please excuse my brevity.

On May 22, 2017 3:22:06 PM PDT, Jim Lemon  wrote:
>Windows. A funny name for a operating system that doesn't let you see
>anything.
>
>Jim
>
>On Mon, May 22, 2017 at 11:59 PM, Pau Marc Muñoz Torres
> wrote:
>> i could make it worl, thanks for your help, it was usefull
>>
>> Pau Marc Muñoz Torres
>> skype: pau_marc
>> http://www.linkedin.com/in/paumarc
>> http://www.researchgate.net/profile/Pau_Marc_Torres3/info/
>>
>>
>> 2017-05-22 15:38 GMT+02:00 Pau Marc Muñoz Torres :
>>
>>> hi to you both
>>>
>>>  You are right peter, I probably miss understood the system.file
>function.
>>> I was trying to use it with a package from bioconductor and when i
>saw that
>>> it didn't work for me, I tested with readxl and still do not
>working, so I
>>> am doing something wrong with system.file
>>>
>>> the original script was
>>>
>>>
>>> library(SICtools)
>>>
>>> bam1 <- system.file(package='SICtools','extdata','example1.bam')
>>>
>>> the example1.bam file is supposed to be at the working directory (i
>>> changed the directory using setwd()), it was changed to
>/home/paumarc/Bam
>>>
>>>  i tried to change extdata for my working directory but it did not
>work
>>>
>>> thanks
>>>
>>> Pau Marc Muñoz Torres
>>> skype: pau_marc
>>> http://www.linkedin.com/in/paumarc
>>> http://www.researchgate.net/profile/Pau_Marc_Torres3/info/
>>>
>>>
>>> 2017-05-22 14:53 GMT+02:00 peter dalgaard :
>>>

 > On 22 May 2017, at 14:43 , Pau Marc Muñoz Torres
>
 wrote:
 >
 > Hello everybody
 >
 > I am trying to use system.file but it returns not file found
 >
 > what I have done is
 >
 >> sample <- system.file("results.xlsx","estdata", package =
 > "readxl",mustWork = TRUE)
 > Error in system.file("results.xlsx", "estdata", package =
>"readxl",
 > mustWork = TRUE) :
 >  no file found
 >
 > i have checked the path was correct and the file exists with
 >
 > FILES <- file.path("results.xlsx")
 > present <- file.exists(FILES)
 >
 > and it returned a true values. Anyone can tell me which can be
>the
 problem ?

 Not if you don't tell us WHERE you expect to find the file...

 Where is it located, and what is the value of FILES above?

 It is not unlikely that you misunderstande what system.file() is
>supposed
 to do.

 -pd


 >
 > thanks
 >
 > Pau Marc Muñoz Torres
 > skype: pau_marc
 > http://www.linkedin.com/in/paumarc
 > http://www.researchgate.net/profile/Pau_Marc_Torres3/info/
 >
 >   [[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/posti
 ng-guide.html
 > and provide commented, minimal, self-contained, reproducible
>code.

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










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

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

Re: [R] problem with system.file

2017-05-22 Thread Jim Lemon
Windows. A funny name for a operating system that doesn't let you see anything.

Jim

On Mon, May 22, 2017 at 11:59 PM, Pau Marc Muñoz Torres
 wrote:
> i could make it worl, thanks for your help, it was usefull
>
> Pau Marc Muñoz Torres
> skype: pau_marc
> http://www.linkedin.com/in/paumarc
> http://www.researchgate.net/profile/Pau_Marc_Torres3/info/
>
>
> 2017-05-22 15:38 GMT+02:00 Pau Marc Muñoz Torres :
>
>> hi to you both
>>
>>  You are right peter, I probably miss understood the system.file function.
>> I was trying to use it with a package from bioconductor and when i saw that
>> it didn't work for me, I tested with readxl and still do not working, so I
>> am doing something wrong with system.file
>>
>> the original script was
>>
>>
>> library(SICtools)
>>
>> bam1 <- system.file(package='SICtools','extdata','example1.bam')
>>
>> the example1.bam file is supposed to be at the working directory (i
>> changed the directory using setwd()), it was changed to /home/paumarc/Bam
>>
>>  i tried to change extdata for my working directory but it did not work
>>
>> thanks
>>
>> Pau Marc Muñoz Torres
>> skype: pau_marc
>> http://www.linkedin.com/in/paumarc
>> http://www.researchgate.net/profile/Pau_Marc_Torres3/info/
>>
>>
>> 2017-05-22 14:53 GMT+02:00 peter dalgaard :
>>
>>>
>>> > On 22 May 2017, at 14:43 , Pau Marc Muñoz Torres 
>>> wrote:
>>> >
>>> > Hello everybody
>>> >
>>> > I am trying to use system.file but it returns not file found
>>> >
>>> > what I have done is
>>> >
>>> >> sample <- system.file("results.xlsx","estdata", package =
>>> > "readxl",mustWork = TRUE)
>>> > Error in system.file("results.xlsx", "estdata", package = "readxl",
>>> > mustWork = TRUE) :
>>> >  no file found
>>> >
>>> > i have checked the path was correct and the file exists with
>>> >
>>> > FILES <- file.path("results.xlsx")
>>> > present <- file.exists(FILES)
>>> >
>>> > and it returned a true values. Anyone can tell me which can be the
>>> problem ?
>>>
>>> Not if you don't tell us WHERE you expect to find the file...
>>>
>>> Where is it located, and what is the value of FILES above?
>>>
>>> It is not unlikely that you misunderstande what system.file() is supposed
>>> to do.
>>>
>>> -pd
>>>
>>>
>>> >
>>> > thanks
>>> >
>>> > Pau Marc Muñoz Torres
>>> > skype: pau_marc
>>> > http://www.linkedin.com/in/paumarc
>>> > http://www.researchgate.net/profile/Pau_Marc_Torres3/info/
>>> >
>>> >   [[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/posti
>>> ng-guide.html
>>> > and provide commented, minimal, self-contained, reproducible code.
>>>
>>> --
>>> Peter Dalgaard, Professor,
>>> Center for Statistics, Copenhagen Business School
>>> Solbjerg Plads 3, 2000 Frederiksberg, Denmark
>>> Phone: (+45)38153501
>>> Office: A 4.23
>>> Email: pd@cbs.dk  Priv: pda...@gmail.com
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>
>
> [[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] Duplicate row names are not allowed

2017-05-22 Thread Jeff Newmiller
Start with the Posting Guide mentioned at the bottom of this email.  Note that 
only a very few types of attachments are permitted on this list... yours 
apparently were not. We generally find that providing a reproducible example 
that includes the data in the R code and the statements that cause difficulty 
all together [1][2][3] conveys questions with as little room for 
misunderstanding as possible.

It does seem like there is something wrong with your data import code  that is 
confusing data that belongs inside the data frame with row names. Just what the 
problem is depends on what code you used to import your data and how that data 
is stored in the file. You need to learn how to use the str function to examine 
your data, and getting us a reprex will help us help you. 

[1] 
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example

[2] http://adv-r.had.co.nz/Reproducibility.html

[3] https://cran.r-project.org/web/packages/reprex/index.html
-- 
Sent from my phone. Please excuse my brevity.

On May 22, 2017 12:02:46 PM PDT, ville iiskola via R-help 
 wrote:
>Hi
>I read a book where was shown an example how to create a probability
>model with mlogit. I tried to do like the instruction said but i get
>error message that "duplicate row names are not allowed". What could i
>do to fix it?
>
>I had the data in excel and imported it to R using R commander. I
>attach the data file and print sqreen of my code to here if somebody
>could help the novice. Ville

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

Re: [R] R truncating decimal places

2017-05-22 Thread William Dunlap via R-help
Do not compute the log likelihood as the log of the product of
probabilities.  Instead compute it as the sum of logs of probabilities.
The latter is less likely to underflow (go below c. 0^-309).

Most (all?) of the built-in probability density functions have a 'log'
argument; when log=TRUE you get the log of the density.

E.g.,

> x <- 1:100
> log(prod(dnorm( (x-50)/2 )))
[1] -Inf
> sum(dnorm( (x-50)/2, log=TRUE ))
[1] -10510.64
>
> log(prod(dnorm( (x-50)/20 )))
[1] -196.0814
> sum(dnorm( (x-50)/20, log=TRUE ))
[1] -196.0814



Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Mon, May 22, 2017 at 12:10 PM, Andrea Goijman 
wrote:

> Hello list,
>
> I' trying to estimate a log likelihood function from my data.
> I apply the mean to all my simulations, and I get something like this:
>
> apply(likelihood, c(2, 3, 4), mean,na.rm=TRUE)
> , , 1
>
>  [,1]   [,2]   [,3]  [,4]  [,5][,6]
>  [,7]
>   [1,] 0.73162327 0.81197093 0.58216435 0.7295733 0.8930731 0.971775402
> 0.8882391
>   [2,] 0.73162327 0.81197093 0. 0.7295733 0.8930731 0.971775402
> 0.8882391
>
> If you note, there is a 0. value, and it seems that R is truncating
> it as a zero, because when I apply the log
>
> apply(likelihood, c(2, 3, 4), mean,na.rm=TRUE)
>
> I get a "-inf" at that position...
>
>
> How do I avoid R truncating this value?
>
> Thanks!
>
> Andrea
>
> [[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] R truncating decimal places

2017-05-22 Thread Andrea Goijman
Hello list,

I' trying to estimate a log likelihood function from my data.
I apply the mean to all my simulations, and I get something like this:

apply(likelihood, c(2, 3, 4), mean,na.rm=TRUE)
, , 1

 [,1]   [,2]   [,3]  [,4]  [,5][,6]
 [,7]
  [1,] 0.73162327 0.81197093 0.58216435 0.7295733 0.8930731 0.971775402
0.8882391
  [2,] 0.73162327 0.81197093 0. 0.7295733 0.8930731 0.971775402
0.8882391

If you note, there is a 0. value, and it seems that R is truncating
it as a zero, because when I apply the log

apply(likelihood, c(2, 3, 4), mean,na.rm=TRUE)

I get a "-inf" at that position...


How do I avoid R truncating this value?

Thanks!

Andrea

[[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] Duplicate row names are not allowed

2017-05-22 Thread ville iiskola via R-help
Hi
I read a book where was shown an example how to create a probability model with 
mlogit. I tried to do like the instruction said but i get error message that 
"duplicate row names are not allowed". What could i do to fix it?

I had the data in excel and imported it to R using R commander. I attach the 
data file and print sqreen of my code to here if somebody could help the 
novice. Ville__
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] Logical Operators' inconsistent Behavior

2017-05-22 Thread William Michels via R-help
Evaluation of the NOT, AND, OR logical statements below in MySQL
5.5.30-log Community Server (GPL) replicate R's truth tables for NOT,
AND, OR. See MySQL queries (below), which are in agreement with R
truth table code posted in this thread:


bash-3.2$ mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 346
Server version: 5.5.30-log MySQL Community Server (GPL)
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> SELECT FALSE, NULL, TRUE;
+---+--+--+
| FALSE | NULL | TRUE |
+---+--+--+
| 0 | NULL |1 |
+---+--+--+
1 row in set (0.00 sec)

mysql> SELECT NOT FALSE, NOT NULL, NOT TRUE;
+---+--+--+
| NOT FALSE | NOT NULL | NOT TRUE |
+---+--+--+
| 1 | NULL |0 |
+---+--+--+
1 row in set (0.00 sec)

mysql> SELECT FALSE AND FALSE,
-> FALSE AND NULL,
-> FALSE AND TRUE;
+-+++
| FALSE AND FALSE | FALSE AND NULL | FALSE AND TRUE |
+-+++
|   0 |  0 |  0 |
+-+++
1 row in set (0.00 sec)

mysql> SELECT NULL AND NULL,
-> NULL AND TRUE,
-> TRUE AND TRUE;
+---+---+---+
| NULL AND NULL | NULL AND TRUE | TRUE AND TRUE |
+---+---+---+
|  NULL |  NULL | 1 |
+---+---+---+
1 row in set (0.00 sec)

mysql> SELECT TRUE OR TRUE,
-> NULL OR TRUE,
-> FALSE OR TRUE;
+--+--+---+
| TRUE OR TRUE | NULL OR TRUE | FALSE OR TRUE |
+--+--+---+
|1 |1 | 1 |
+--+--+---+
1 row in set (0.00 sec)

mysql> SELECT NULL OR NULL,
-> FALSE OR NULL,
-> FALSE OR FALSE;
+--+---++
| NULL OR NULL | FALSE OR NULL | FALSE OR FALSE |
+--+---++
| NULL |  NULL |  0 |
+--+---++
1 row in set (0.00 sec)

mysql>


HTH,

Bill

William Michels, Ph.D.


On Sun, May 21, 2017 at 7:00 AM, Hadley Wickham  wrote:
> On Fri, May 19, 2017 at 6:38 AM, S Ellison  wrote:
>>> TRUE & FALSE is FALSE but TRUE & TRUE is TRUE, so TRUE & NA could be
>>> either TRUE or FALSE and consequently is NA.
>>>
>>> OTOH FALSE & (anything) is FALSE so FALSE & NA is FALSE.
>>>
>>> As I said *think* about it; don't just go with your immediate knee-jerk
>>> (simplistic) reaction.
>>
>> Hmm... not sure that was quite fair to the OP. Yes,  FALSE &  == 
>> FALSE. But 'NA' does not mean 'anything'; it means 'missing' (see ?'NA'). It 
>> is much less obvious that FALSE &  should generate a non-missing 
>> value. SQL, for example, generally  takes the view that any expression 
>> involving 'missing' is 'missing'.
>
> That's not TRUE ;)
>
> sqlite> select (3 > 2) OR NULL;
> 1
>
> sqlite> select (4 < 3) AND NULL;
> 0
>
> Hadley
>
>
> --
> http://hadley.nz
>
> __
> 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] problem with system.file

2017-05-22 Thread Pau Marc Muñoz Torres
i could make it worl, thanks for your help, it was usefull

Pau Marc Muñoz Torres
skype: pau_marc
http://www.linkedin.com/in/paumarc
http://www.researchgate.net/profile/Pau_Marc_Torres3/info/


2017-05-22 15:38 GMT+02:00 Pau Marc Muñoz Torres :

> hi to you both
>
>  You are right peter, I probably miss understood the system.file function.
> I was trying to use it with a package from bioconductor and when i saw that
> it didn't work for me, I tested with readxl and still do not working, so I
> am doing something wrong with system.file
>
> the original script was
>
>
> library(SICtools)
>
> bam1 <- system.file(package='SICtools','extdata','example1.bam')
>
> the example1.bam file is supposed to be at the working directory (i
> changed the directory using setwd()), it was changed to /home/paumarc/Bam
>
>  i tried to change extdata for my working directory but it did not work
>
> thanks
>
> Pau Marc Muñoz Torres
> skype: pau_marc
> http://www.linkedin.com/in/paumarc
> http://www.researchgate.net/profile/Pau_Marc_Torres3/info/
>
>
> 2017-05-22 14:53 GMT+02:00 peter dalgaard :
>
>>
>> > On 22 May 2017, at 14:43 , Pau Marc Muñoz Torres 
>> wrote:
>> >
>> > Hello everybody
>> >
>> > I am trying to use system.file but it returns not file found
>> >
>> > what I have done is
>> >
>> >> sample <- system.file("results.xlsx","estdata", package =
>> > "readxl",mustWork = TRUE)
>> > Error in system.file("results.xlsx", "estdata", package = "readxl",
>> > mustWork = TRUE) :
>> >  no file found
>> >
>> > i have checked the path was correct and the file exists with
>> >
>> > FILES <- file.path("results.xlsx")
>> > present <- file.exists(FILES)
>> >
>> > and it returned a true values. Anyone can tell me which can be the
>> problem ?
>>
>> Not if you don't tell us WHERE you expect to find the file...
>>
>> Where is it located, and what is the value of FILES above?
>>
>> It is not unlikely that you misunderstande what system.file() is supposed
>> to do.
>>
>> -pd
>>
>>
>> >
>> > thanks
>> >
>> > Pau Marc Muñoz Torres
>> > skype: pau_marc
>> > http://www.linkedin.com/in/paumarc
>> > http://www.researchgate.net/profile/Pau_Marc_Torres3/info/
>> >
>> >   [[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/posti
>> ng-guide.html
>> > and provide commented, minimal, self-contained, reproducible code.
>>
>> --
>> Peter Dalgaard, Professor,
>> Center for Statistics, Copenhagen Business School
>> Solbjerg Plads 3, 2000 Frederiksberg, Denmark
>> Phone: (+45)38153501
>> Office: A 4.23
>> Email: pd@cbs.dk  Priv: pda...@gmail.com
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>

[[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] problem with system.file

2017-05-22 Thread Pau Marc Muñoz Torres
hi to you both

 You are right peter, I probably miss understood the system.file function.
I was trying to use it with a package from bioconductor and when i saw that
it didn't work for me, I tested with readxl and still do not working, so I
am doing something wrong with system.file

the original script was


library(SICtools)

bam1 <- system.file(package='SICtools','extdata','example1.bam')

the example1.bam file is supposed to be at the working directory (i changed
the directory using setwd()), it was changed to /home/paumarc/Bam

 i tried to change extdata for my working directory but it did not work

thanks

Pau Marc Muñoz Torres
skype: pau_marc
http://www.linkedin.com/in/paumarc
http://www.researchgate.net/profile/Pau_Marc_Torres3/info/


2017-05-22 14:53 GMT+02:00 peter dalgaard :

>
> > On 22 May 2017, at 14:43 , Pau Marc Muñoz Torres 
> wrote:
> >
> > Hello everybody
> >
> > I am trying to use system.file but it returns not file found
> >
> > what I have done is
> >
> >> sample <- system.file("results.xlsx","estdata", package =
> > "readxl",mustWork = TRUE)
> > Error in system.file("results.xlsx", "estdata", package = "readxl",
> > mustWork = TRUE) :
> >  no file found
> >
> > i have checked the path was correct and the file exists with
> >
> > FILES <- file.path("results.xlsx")
> > present <- file.exists(FILES)
> >
> > and it returned a true values. Anyone can tell me which can be the
> problem ?
>
> Not if you don't tell us WHERE you expect to find the file...
>
> Where is it located, and what is the value of FILES above?
>
> It is not unlikely that you misunderstande what system.file() is supposed
> to do.
>
> -pd
>
>
> >
> > thanks
> >
> > Pau Marc Muñoz Torres
> > skype: pau_marc
> > http://www.linkedin.com/in/paumarc
> > http://www.researchgate.net/profile/Pau_Marc_Torres3/info/
> >
> >   [[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.
>
> --
> Peter Dalgaard, Professor,
> Center for Statistics, Copenhagen Business School
> Solbjerg Plads 3, 2000 Frederiksberg, Denmark
> Phone: (+45)38153501
> Office: A 4.23
> Email: pd@cbs.dk  Priv: pda...@gmail.com
>
>
>
>
>
>
>
>
>
>

[[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] How to extract text contexts after clustering.

2017-05-22 Thread David L Carlson
As Ismail notes, you did not give us your code, only a few disconnected bits of 
your code. Assuming that by "top 1 group" you mean the largest group, here is a 
reproducible example:

# First create a reproducible set of data
set.seed(42)
mydata <- matrix(rnorm(300, 50, 10), 100, 3)
# A matrix with 100 rows and 3 columns of random normal variates

# Run kmeans and look at the structure of the returned object
mydata.km <- kmeans(mydata, centers=10)
str(mydata.km)
List of 9
 $ cluster : int [1:100] 5 9 3 6 1 1 10 1 10 8 ...
 $ centers : num [1:10, 1:3] 53.8 31.8 54.5 40.1 61 ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr [1:10] "1" "2" "3" "4" ...
  .. ..$ : NULL
 $ totss   : num 29069
 $ withinss: num [1:10] 601 868 443 1242 717 ...
 $ tot.withinss: num 6554
 $ betweenss   : num 22515
 $ size: int [1:10] 13 10 9 11 10 5 7 14 13 8
 $ iter: int 3
 $ ifault  : int 0
 - attr(*, "class")= chr "kmeans"

# "size" is the number of observation in each cluster
# "cluster" is the cluster membership for each observation

which.max(mydata.km$size)
[1] 8
table(mydata.km$cluster)

 1  2  3  4  5  6  7  8  9 10 
13 10  9 11 10  5  7 14 13  8 

# which.max() shows you which cluster is the 
# largest, cluster number 8
# By sorting "size" you lost the information
# about which cluster was the largest
# table() shows you the number of observations in each cluster
# You can see that cluster 8 has 14 observations
# Now print the 14 observations that belong to cluster 8

mydata[mydata.km$cluster == 8, ]
  [,1] [,2] [,3]
 [1,] 49.37286 51.19161 48.14622
 [2,] 47.21211 44.95783 49.15892
 [3,] 56.35950 46.17666 50.37415
 [4,] 47.15747 44.87350 48.67912
 [5,] 48.28083 51.24702 44.78204
 [6,] 45.69531 45.71741 48.25982
 [7,] 47.42731 43.86328 55.15668
 [8,] 54.55450 55.67621 47.28236
 [9,] 56.42899 47.26354 51.90019
[10,] 50.89833 41.99718 50.46564
[11,] 55.81824 51.63207 53.83847
[12,] 50.88440 53.68807 44.30694
[13,] 48.79103 52.94654 56.35514
[14,] 45.23826 46.54912 54.46041

-
David L Carlson
Department of Anthropology
Texas A University
College Station, TX 77840-4352


-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Ismail SEZEN
Sent: Sunday, May 21, 2017 10:09 PM
To: θ ” 
Cc: r-help@r-project.org
Subject: Re: [R] How to extract text contexts after clustering.

1- PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
2- PLEASE, first _read_ help for kmeans (?kmeans) function before using 
function.

> On 22 May 2017, at 05:33, θ ”  wrote:
> 
> hi:
> I need to extract the text contexts of top 1 group after clustering.
> But I have no idea how to sort the cluster size then extract the contexts of 
> top 1 clusters.

There isn’t a _top_ cluster for kmeans algorithm. There are _only_ clusters!

> 
> here is my cluster code:
> 
>> file <- read.csv("SiC CMP.csv", header = TRUE)

We don’t know what is in file$Main.IPC.

>> cluster_k<-length(unique(file$Main.IPC))
>> cl <- kmeans(IPC_Dtm , cluster_k)

What is IPC_Dtm?

> 
> 
> I have tried use��
> 
>> sort(cl$size, decreasing=T)

if you read the documentation, you would know cl$size means the number of 
points in each cluster. So, why do you sort them?

> [1] 341 107 104  80  51  22  15  11  10   8   8   5   5   5   4   4   4   3   
> 3   2   2
> [22]   2   2   2   2   2   2   1   1   1   1   1   1   1   1   1   1   1   1  
>  1   1   1
> [43]   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1
> 
> But I have no idea how to extract the contexts of top 1 cluster.

If you read the _Value_ section of kmeans documentation, you will have an idea 
how to extract context by using cl$cluster.

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

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

Re: [R] Identyfing rows with specific conditions

2017-05-22 Thread Bert Gunter
You haven't said whether your "table" is a matrix or data frame.
Presumably the latter.

Nor have you answered my question about whether order of your meal
code pairs matters.

Another question: can meals be replicated for an ID or are they all different?

Finally, is this a homework assignment or class project of some sort?
Or is it a real task -- i.e., what is the context?

Again, be sure to cc the list.

-- Bert
Bert Gunter

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


On Mon, May 22, 2017 at 1:56 AM, Allaisone 1  wrote:
> Hi Bert ..,
>
>
> The number of meals differ from one customer to other customer. You may find
> one customer with only one meal and another one with 2,3 or even rarely 30
> meals. You may also
>
> find no meal at all for some customers so the entire row takes the missing
> value "\N" . Any
>
> row starts with the meals codes first, then all missing values are to the
> right end of the table.
>
> 
> From: Bert Gunter 
> Sent: 22 May 2017 03:11:11
> To: Allaisone 1
> Cc: r-help@r-project.org
> Subject: Re: [R] Identyfing rows with specific conditions
>
> Clarification:
>
> Does each customer have the same number of meals or do they differ
> from customer to customer? If the latter, how are missing meals
> notated? Do they always occur at the (right) end or can they occur
> anywhere in the row?
>
> Presumably each customer ID can have many different meal code
> combinations, right ?(since they can have 30 different meals with
> potentially 30 choose 2 = 435 combinations apiece)
>
> Please make sure you reply to the list, not just to me, as I may not
> pursue this further but am just trying to clarify for anyone else who
> may wish to help.
>
>
> 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 Sun, May 21, 2017 at 5:10 PM, Allaisone 1  wrote:
>>
>> Hi All..,
>>
>> I have 2 tables. The first one contains 2 columns with the headers say
>> "meal A code" & "meal B code " in a table called "Meals" with 2000 rows each
>> of which with a different combination of meals(unique combination per row).
>>
>>
>>>Meals
>>
>> meal A code  meal B code
>>
>> 1  34   66
>>
>> 2   89  39
>>
>> 3   25   77
>>
>> The second table(customers) shows customers ids in the first column with
>> Meals codes(M) next to each customer. There are about 300,000 customers
>> (300,000 rows).
>>
>>> Customers
>>  1 2 3   4..30
>>  id   M1  M2   M3
>> 1   15  773425
>> 2   11  2534 39
>> 385 89 2577
>> .
>> .
>> 300,000
>>
>> I would like to identify all customers ids who have had each meal
>> combination in the first table so the final output would be the first table
>> with ids attached next to each meal combination in each row like this:
>>
>>>IdsMeals
>>
>>
>>   MAcode  MBcode  ids
>>
>> 1 343911
>>
>> 2 25   34  15   11
>>
>> 3  25 7715   85
>>
>> Would you please suggest any solutions to this problem?
>>
>> Regards
>>
>> [[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] problem with system.file

2017-05-22 Thread Ulrik Stervbo
What is your version of readxl?

In my version 1.0, there is no directory called estdata, but there is one
called extdata. However, in that directory there is no file called
"results.xlsx"

Either it was there once and has now gone missing or "results.xlsx" your
own file? It looks like the latter - and in which case, there is no point
in using system.file. Rather you should use read_xlsx([path/file]).

HTH
Ulrik

On Mon, 22 May 2017 at 14:44 Pau Marc Muñoz Torres 
wrote:

> Hello everybody
>
>  I am trying to use system.file but it returns not file found
>
> what I have done is
>
> > sample <- system.file("results.xlsx","estdata", package =
> "readxl",mustWork = TRUE)
> Error in system.file("results.xlsx", "estdata", package = "readxl",
> mustWork = TRUE) :
>   no file found
>
> i have checked the path was correct and the file exists with
>
> FILES <- file.path("results.xlsx")
> present <- file.exists(FILES)
>
> and it returned a true values. Anyone can tell me which can be the problem
> ?
>
> thanks
>
> Pau Marc Muñoz Torres
> skype: pau_marc
> http://www.linkedin.com/in/paumarc
> http://www.researchgate.net/profile/Pau_Marc_Torres3/info/
>
> [[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] problem with system.file

2017-05-22 Thread peter dalgaard

> On 22 May 2017, at 14:43 , Pau Marc Muñoz Torres  wrote:
> 
> Hello everybody
> 
> I am trying to use system.file but it returns not file found
> 
> what I have done is
> 
>> sample <- system.file("results.xlsx","estdata", package =
> "readxl",mustWork = TRUE)
> Error in system.file("results.xlsx", "estdata", package = "readxl",
> mustWork = TRUE) :
>  no file found
> 
> i have checked the path was correct and the file exists with
> 
> FILES <- file.path("results.xlsx")
> present <- file.exists(FILES)
> 
> and it returned a true values. Anyone can tell me which can be the problem ?

Not if you don't tell us WHERE you expect to find the file... 

Where is it located, and what is the value of FILES above?

It is not unlikely that you misunderstande what system.file() is supposed to do.

-pd


> 
> thanks
> 
> Pau Marc Muñoz Torres
> skype: pau_marc
> http://www.linkedin.com/in/paumarc
> http://www.researchgate.net/profile/Pau_Marc_Torres3/info/
> 
>   [[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.

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

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

[R] problem with system.file

2017-05-22 Thread Pau Marc Muñoz Torres
Hello everybody

 I am trying to use system.file but it returns not file found

what I have done is

> sample <- system.file("results.xlsx","estdata", package =
"readxl",mustWork = TRUE)
Error in system.file("results.xlsx", "estdata", package = "readxl",
mustWork = TRUE) :
  no file found

i have checked the path was correct and the file exists with

FILES <- file.path("results.xlsx")
present <- file.exists(FILES)

and it returned a true values. Anyone can tell me which can be the problem ?

thanks

Pau Marc Muñoz Torres
skype: pau_marc
http://www.linkedin.com/in/paumarc
http://www.researchgate.net/profile/Pau_Marc_Torres3/info/

[[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] problem with

2017-05-22 Thread Pau Marc Muñoz Torres
Hello everybody

 I am trying to use system.file but it returns not file found

what I have done is

> sample <- system.file("results.xlsx","estdata", package =
"readxl",mustWork = TRUE)
Error in system.file("results.xlsx", "estdata", package = "readxl",
mustWork = TRUE) :
  no file found

i have checked the path was correct and the file exists with

FILES <- file.path("results.xlsx")
present <- file.exists(FILES)

and it returned a true values. Anyone can tell me which can be the problem ?

thanks


Pau Marc Muñoz Torres
skype: pau_marc
http://www.linkedin.com/in/paumarc
http://www.researchgate.net/profile/Pau_Marc_Torres3/info/

[[alternative HTML version deleted]]

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

[R] R - datatable formatting with javascript

2017-05-22 Thread Krzysiek Gniady
I'm trying to format datatable in R using DT package. I have code like this:

library(data.table)
library(DT)
data<-data.table(rbind(c(1,2,3),c(4,5,6)))
colnames(data)<- c('A','B','c')

datatable(data, rownames=F,
  colnames=c('A','B','C'),
  class='stripe cell-border hover',
  options=list(
pageLength=100,
dom='ltp',
initComplete = JS("
  function(settings, json) {
  $(this.api().table().body()).css({
  'background-color': 'red',
  'outline-color': 'red',
  'margin':'100px',
  'color': 'violet',
  'text-align': 'center',
  'font-family': 'Courier New',
  'border-radius': '25px'
  });
  $(this.api().table().header()).css({
  'background-color': '#000',
  'color': '#fff',
  'outline-color': 'red',
  'margin':'100px',
  'text-align': 'center',
  'font-family': 'Courier New',
  'border-radius': '25px'
  });
  }
  ")
),
  caption = htmltools::tags$caption(
style = 'caption-side: top; text-align: center; color:black;
font-size:200% ;','Table'),
  filter=list(position = 'top')
  )

And I have problem with javascript in function JS(). It modifies background
color (but only in header), font color and style. But commands to align
text or round corners don't work.

Why does it work like that? And how can I modify code to format this other
things?


Regards,

Jeddite

[[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] Forecast using VAR model

2017-05-22 Thread Dhivya Narayanasamy
Hi Jon,

sorry for the inconvenience. I have done it in plain text now.

I am building a VAR model to forecast of bivariate time series. But it
shows flat forecast and i am in need of correcting  it. Is there any way to
correct this flat forecast?  or Do i have to go with other models?

Code:

> datax.zoo <- read.zoo(datax)
> datax.ts <- ts(datax.zoo)
> v1b <- VARselect(datax.ts, lag.max = 10, type = "const")
> v1b$selection
AIC(n)  HQ(n)  SC(n) FPE(n)
10  7  3 10
> var7 = VAR(datax.ts, p=7)
> serial.test(var7, lags.pt=10, type = "PT.asymptotic")

Portmanteau Test (asymptotic)

data:  Residuals of VAR object var7
Chi-squared = 31.991, df = 12, p-value = 0.001388

> gf1 <- forecast(var7, h = 600)
> plot(gf1, main = "var7")
> grangertest(datax.ts[,1] ~ datax.ts[,2], order = 7)
Granger causality test

Model 1: datax.ts[, 1] ~ Lags(datax.ts[, 1], 1:7) + Lags(datax.ts[, 2], 1:7)
Model 2: datax.ts[, 1] ~ Lags(datax.ts[, 1], 1:7)
  Res.Df Df  FPr(>F)
1   9968
2   9975 -7 20.852 < 2.2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
> grangertest(datax.ts[,2] ~  datax.ts[,1], order = 7)
Granger causality test

Model 1: datax.ts[, 2] ~ Lags(datax.ts[, 2], 1:7) + Lags(datax.ts[, 1], 1:7)
Model 2: datax.ts[, 2] ~ Lags(datax.ts[, 2], 1:7)
  Res.Df Df  F   Pr(>F)
1   9968
2   9975 -7 3.0918 0.002948 **
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1



The P value from "Portmanteau Test" is very much less than << 0.05 for
lagged value 7. Is this correct?
I have added my plot and raw data in the attachment for your further
reference. Thank you.



Regards| Mit freundlichen Grüßen,
> Dhivya Narayanasamy


Regards| Mit freundlichen Grüßen,

Dhivya Narayanasamy

Contact No: +91-8438505020

On Sun, May 21, 2017 at 5:40 PM, John C Frain  wrote:

> It would be much easier to see what you are doing if you reposted in plain
> text.
>
> John C Frain
> 3 Aranleigh Park
> Rathfarnham
> Dublin 14
> Ireland
> www.tcd.ie/Economics/staff/frainj/home.html
> mailto:fra...@tcd.ie
> mailto:fra...@gmail.com
>
> On 21 May 2017 at 06:05, Dhivya Narayanasamy 
> wrote:
>
>> I am building a VAR model to forecast of bivariate timeseries. But it
>> shows
>> flat forecast.
>>
>> So I would like to use recursive window forecasting technique using VAR
>> model. Will it give what i expect (Avoid flat forecast) ? or should i have
>> to go with other package.
>>
>> > datax.zoo <- read.zoo(datax)> datax.ts <- ts(datax.zoo)> v1b <-
>> VARselect(datax.ts, lag.max = 10, type = "const")> v1b
>> $selection
>> AIC(n)  HQ(n)  SC(n) FPE(n)
>>  9  7  5  9
>>
>> $criteria
>>   1234
>> 567
>> AIC(n) 9.686513 9.657172 9.632444 9.625856
>> 9.621148 9.619425 9.615396
>> HQ(n)  9.688951 9.661234 9.638131 9.633167
>> 9.630085 9.629987 9.627583
>> SC(n)  9.693514 9.668839 9.648778 9.646856
>> 9.646815 9.649759 9.650397
>> FPE(n) 16099.014774 15633.507506 15251.665643 15151.510512
>> 15080.352425 15054.392389 14993.864861
>>   89   10
>> AIC(n) 9.615430 9.615116 9.615990
>> HQ(n)  9.629241 9.630552 9.633051
>> SC(n)  9.655098 9.659451 9.664991
>> FPE(n) 14994.366572 14989.661383 15002.762011
>> > var7 = VAR(datax.ts, p=7)> serial.test(var7, lags.pt=10, type =
>> "PT.asymptotic")
>>
>> Portmanteau Test (asymptotic)
>>
>> data:  Residuals of VAR object var7Chi-squared = 22.745, df = 12,
>> p-value = 0.02997
>> > grangertest(datax.ts[,1] ~ datax.ts[,2], order = 7)Granger causality
>> test
>> Model 1: datax.ts[, 1] ~ Lags(datax.ts[, 1], 1:7) + Lags(datax.ts[,
>> 2], 1:7)Model 2: datax.ts[, 1] ~ Lags(datax.ts[, 1], 1:7)
>>   Res.Df Df  FPr(>F)1   56862
>> 5693 -7 16.105 < 2.2e-16 ***---Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01
>> ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1> grangertest(datax.ts[,2] ~  datax.ts[,1],
>> order = 7)Granger causality test
>> Model 1: datax.ts[, 2] ~ Lags(datax.ts[, 2], 1:7) + Lags(datax.ts[,
>> 1], 1:7)Model 2: datax.ts[, 2] ~ Lags(datax.ts[, 2], 1:7)
>>   Res.Df Df  F Pr(>F)1   5686 2   5693 -7 1.5618
>> 0.1418
>> > g <- forecast(var7, h = 600)> plot(g)
>>
>>
>> Also the 'P' value  from portmanteau test shows auto correlation is
>> present
>> is my VAR model. Here is my raw data you can find :
>> https://drive.google.com/file/d/0B7I0DT-PiG4RenVkdXV3OFJLYVk
>> /view?usp=sharing
>>
>>
>> Thank you.
>>
>> Regards
>> > Dhivya Narayanasamy
>>
>> [[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/posti
>> ng-guide.html
>> and provide commented, 

[R] JMdesign package

2017-05-22 Thread Bernard North

Dear R list


I wonder please if anyone has experience they can share of the JMdesign package 
that performs sample sized for (surviival/longitudinal) joint models and is 
based on the paper "Sample size and power determination in joint modeling of 
longitudinal and survival data " by Chen et al (Statistics  in Medicine 2011) .

If so I do have a few queries please.

  1.  the vignette states that JMdesign can work when �the variance-covariance 
matrix Sigma_theta is unknown.� This is the the covariance matrix of the 
intercept, linear and quadratic effects of the longitudinal profiles of the 
longitudinal (time-dependent) variable thats affecting event time.

I wonder if that refers to the input SigmaTheta to the R function powerLongSurv 
in the package  ? Because it looks to me as though most of the examples in the 
vignette do supply a value for that matrix and it errors if its missing. I 
realise section 3.2 of the Liddy Chen paper does refer to the unknown 
covariance matrix situation

  2.  I�m also a little confused as to what is meant in the JMdesign vignette 
by �Example 1� and "formula 4.6". Do these refer to the Chen paper ? I can�t 
see a formula denoted 4.6.

  3.  The original Chen paper refers on page 3 to two possible objectives: 1)  
power for testing the effect of the longitudinal trajectory and 2) power for 
testing the effect of a fixed covariate, eg treatment, that affects the 
trajectory (and therefore indirectly survival) but also has a direct effect on 
survival.
Does the power calculation in the current JMdesign package only provide power 
of the first test ?  I think it does but from the paper both calculations are 
possible.

  4.  Can anyone help with how to estimate the covariance matrix of the 
intercept, linear and quadratic effects for the Sigma_theta input. I thought 
theVarCorr output from a lmer mixed model analysis of the profiles might 
provide the elements for that matrix

my apologies for so many questions - many thanks for any thoughts on any of them

best wishes
Bernard

[[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] Identyfing rows with specific conditions

2017-05-22 Thread Allaisone 1
Hi Again..,


All of my 2 tables are data.frames and the order of meals does not matter. Meal 
A =2 and Meal B= 15 is the same as Meal A=15 and Meal B= 2.


From: Bert Gunter 
Sent: 22 May 2017 03:19:57
To: Allaisone 1
Cc: r-help@r-project.org
Subject: Re: [R] Identyfing rows with specific conditions

More clarification:

Are your "tables" matrices or data frames? (If you don't know what
this means, you need to spend a little time with a e.g. web tutorial
to learn).

Also, does Meal A Meal B order count? -- i.e. is Meal A = 2, Meal B =
15 the same as Meal A = 15 and Meal B = 2?  This is important.

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 Sun, May 21, 2017 at 5:10 PM, Allaisone 1  wrote:
>
> Hi All..,
>
> I have 2 tables. The first one contains 2 columns with the headers say "meal 
> A code" & "meal B code " in a table called "Meals" with 2000 rows each of 
> which with a different combination of meals(unique combination per row).
>
>
>>Meals
>
> meal A code  meal B code
>
> 1  34   66
>
> 2   89  39
>
> 3   25   77
>
> The second table(customers) shows customers ids in the first column with 
> Meals codes(M) next to each customer. There are about 300,000 customers 
> (300,000 rows).
>
>> Customers
>  1 2 3   4..30
>  id   M1  M2   M3
> 1   15  773425
> 2   11  2534 39
> 385 89 2577
> .
> .
> 300,000
>
> I would like to identify all customers ids who have had each meal combination 
> in the first table so the final output would be the first table with ids 
> attached next to each meal combination in each row like this:
>
>>IdsMeals
>
>
>   MAcode  MBcode  ids
>
> 1 343911
>
> 2 25   34  15   11
>
> 3  25 7715   85
>
> Would you please suggest any solutions to this problem?
>
> Regards
>
> [[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] RC class composition

2017-05-22 Thread Mohan.Radhakrishnan
Hi,

The last line should give me the value of 'amount'. Is the syntax wrong ?

Measurement <- setRefClass("Measurement",
  fields = list(subject = Subject,
 quantity = Quantity))

s <- Subject$new(id = 100)

u <- CompoundUnit$new(  micrograms = 100,
  cubicmeter = 1 )

q <- Quantity$new(amount = 100,
 units = u )

m <- Measurement$new(subject = s,
  quantity = q)
print( m$quantity$amount )

Thanks,
Mohan
This e-mail and any files transmitted with it are for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
If you are not the intended recipient(s), please reply to the sender and 
destroy all copies of the original message. Any unauthorized review, use, 
disclosure, dissemination, forwarding, printing or copying of this email, 
and/or any action taken in reliance on the contents of this e-mail is strictly 
prohibited and may be unlawful. Where permitted by applicable law, this e-mail 
and other e-mail communications sent to and from Cognizant e-mail addresses may 
be monitored.

[[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-es] En la salida pone otro grafico R+LaTeX*LyX con documentos "hijos"

2017-05-22 Thread Juan Abasolo
¡Solucionado!

Remedio de vieja:
Invocar en  otro chunk diferente con la mágica frase:

rm(list=ls(all=TRUE))

cerrar el chunk y ahí sí, hacer los conjuros debidos para generar el
gráfico.

Funcionó!

Que quede documentado por si a alguien más le pasa. Si algún gurú, además,
puede explicarlo para que deje de creer en lo mágico de la informática...
Todavía mejor.

Buen domingo

2017-05-20 7:38 GMT+02:00 Juan Abasolo :

> Buenas;
> Estoy ya en la corrección de la tesis a contrareloj y un director me dijo:
> "esto no ahí, va acá". Digamos:
>
> 1 cap
> 2 cap
>   * quitar de acá
> 3 cap
>   * poner acá
> 4 cap
>
> Estoy usando LyX, una especie de front-end para LaTeX. Lo tengo
> organizado, más o menos, a un documento por capitulo, aunque hay alguno en
> el que van más de un capitulo. Todo anidado en un documento padre-madre que
> lo contiene todo.
> En cada capítulo llamo a R mediante un chunk y el primero de la serie
> suele comenzar, por si acaso, así, para borrar cualquier cosa que haya
> antes:
>
> rm(list=ls(all=TRUE))
>
> Todos los documentos (padres e hijos) están en una sola carpeta y todos
> los elementos de R en diversas carpetas, que corresponden a la información
> de cada capítulo.
>
> Problema:
> Al generar el PDF de toda la tesis, el grafico que incluye no es el que
> debería, sino el siguiente (?!!).
>
> Tesis
>  3 capitulo
>R grafico 0k1
>R grafico 0k n
>R GRAFICO KO KK :-(
>  4 capitulo
>(sin graficos R)
>  5 capitulo
>R tabla ok 1
>R tabla ok n
>R grafico Ok (el que aparece arriba tb)
>R etcetera tablas y graficos ok
>
> Puedo contar que el chunk ese en cuestión empieza con el
> rm(list=ls(all=TRUE)) mencionado arriba; carga datos de un csv y genera el
> grafico.
> Si genero el PDF solamente del capítulo ese en cuestión, sale bien el
> gráfico que tiene que salir.
>
> Doctores, ¿es grave? ¿Qué tratamiento me recomiendan?
>
> Juan
>

[[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] Error with installed.packages with R 3.4.0 on Windows

2017-05-22 Thread Martin Morgan

On 05/22/2017 05:10 AM, Patrick Connolly wrote:

On Fri, 28-Apr-2017 at 07:04PM +0200, peter dalgaard wrote:

|>
|> > On 28 Apr 2017, at 12:08 , Duncan Murdoch  wrote:
|> >
|> > On 28/04/2017 4:45 AM, Thierry Onkelinx wrote:
|> >> Dear Peter,
|> >>
|> >> It actually breaks install.packages(). So it is not that innocent.
|> >
|> > I don't think he meant that it is harmless, he meant that the fix is easy, 
and is in place in R-patched and R-devel.  You should use R-patched and you won't 
have the problem.
|>
|> Read more carefully: I said that the _fix_ is harmless for this case, but 
might not be so in general.
|>
|> -pd


Apparently it isn't harmless.


install.packages("withr")

Error in readRDS(dest) : error reading from connection


that seems like a plain-old network connectivity issue, or perhaps an 
issue with the CRAN mirror you're using. Can you debug on your end, e.g,.


  options(error=recover)
  install.packages("withr")
  ...

then select the 'frame' where the error occurs, look around

  ls()

find the value of 'dest', and e.g., try to open dest in your  browser.

Martin Morgan







sessionInfo()

R version 3.4.0 Patched (2017-05-19 r72713)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 14.04.5 LTS

Matrix products: default
BLAS: /home/hrapgc/local/R-patched/lib/libRblas.so
LAPACK: /home/hrapgc/local/R-patched/lib/libRlapack.so

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

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

other attached packages:
[1] lattice_0.20-35

loaded via a namespace (and not attached):
[1] compiler_3.4.0 tools_3.4.0grid_3.4.0




Has anyone a workaround?




This email message may contain legally privileged and/or...{{dropped:2}}

__
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] Error with installed.packages with R 3.4.0 on Windows

2017-05-22 Thread Patrick Connolly
On Fri, 28-Apr-2017 at 07:04PM +0200, peter dalgaard wrote:

|> 
|> > On 28 Apr 2017, at 12:08 , Duncan Murdoch  wrote:
|> > 
|> > On 28/04/2017 4:45 AM, Thierry Onkelinx wrote:
|> >> Dear Peter,
|> >> 
|> >> It actually breaks install.packages(). So it is not that innocent.
|> > 
|> > I don't think he meant that it is harmless, he meant that the fix is easy, 
and is in place in R-patched and R-devel.  You should use R-patched and you 
won't have the problem.
|> 
|> Read more carefully: I said that the _fix_ is harmless for this case, but 
might not be so in general.
|> 
|> -pd


Apparently it isn't harmless.  

> install.packages("withr")
Error in readRDS(dest) : error reading from connection
>

> 
> sessionInfo()
R version 3.4.0 Patched (2017-05-19 r72713)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 14.04.5 LTS

Matrix products: default
BLAS: /home/hrapgc/local/R-patched/lib/libRblas.so
LAPACK: /home/hrapgc/local/R-patched/lib/libRlapack.so

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

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

other attached packages:
[1] lattice_0.20-35

loaded via a namespace (and not attached):
[1] compiler_3.4.0 tools_3.4.0grid_3.4.0
> 

Has anyone a workaround?

-- 
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.   
   ___Patrick Connolly   
 {~._.~}   Great minds discuss ideas
 _( Y )_ Average minds discuss events 
(:_~*~_:)  Small minds discuss people  
 (_)-(_)  . Eleanor Roosevelt
  
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.

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