[R] Plotting Mean in plotting degree distribution

2014-03-13 Thread Cyberstarlet
Hi, Please help! I need to plot a degree distribution.

so far (see below) i have the following but the problem: i'm plotting the 
graph. instead I need to plot the degree distribution.

library(igraph)

dat- read.graph(file=tf.net, format=pajek)

dat- as.undirected(dat, mode = c(each))

is.directed(dat)

[1] FALSE

degree.distribution(dat, cumulative = TRUE, loops = FALSE)

[1] 1.0 0.792857143 0.478571429 0.292857143 0.192857143 0.142857143 
0.114285714 0.085714286
[9] 0.078571429 0.071428571 0.064285714 0.05000 0.035714286 0.028571429 
0.028571429 0.014285714

[17] 0.014285714 0.007142857 0.007142857 0.007142857 0.007142857 0.007142857 
0.007142857 0.007142857
[25] 0.007142857 0.007142857 0.007142857 0.007142857 0.007142857 0.007142857 
0.007142857 0.007142857

[33] 0.007142857 0.007142857 0.007142857 0.007142857 0.007142857 0.007142857 
0.007142857 0.007142857
[41] 0.007142857 0.007142857 0.007142857 0.007142857 0.007142857 0.007142857 
0.007142857

plot(dat) 


the file tf.net can be found at http://fileshare.csb.univie.ac.at/cheat14/INPUT/

any help much appreciated!


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
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] Colorspace: bug in HLS conversion?

2014-03-13 Thread Michael Gauland
I just started using the colorspace package, and converting between RGB and
HLS is not working as I expect.  In particular, converting RGB(0,0,0) to HLS
then back to RGB seems broken:

# as(as(RGB(0, 0, 0), HLS), RGB)
 R G B
[1,] 1 1 0

That is, converting black to HLS then back again produces yellow!

Other values I've tried work as expected (i.e., I get the same RGB value out
as I put in).

Is this a bug in the code, or in my understanding of colour conversions?

Kind Regards,
Mike

__
R-help@r-project.org mailing list
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] Error installing extrafonts from local zip file

2014-03-13 Thread Robin.Thomson
I am making my first submission to Plos One and am trying to install the 
extrafonts package to obtain Arial for the figures. extrafonts was archived 
at the end of last month so I downloaded first the extrafont_0.16.tar.gz file 
and then the older extrafont_0.15.tar.gz file. 

I selected Install packages(s) from local zip file from the Packages menu of 
my installation of R x64 3.0.0 

I got:

 utils:::menuInstallLocal()
Error in read.dcf(file.path(pkgname, DESCRIPTION), c(Package, Type)) : 
  cannot open the connection
In addition: Warning messages:
1: In unzip(zipname, exdir = dest) : error 1 in extracting from zip file
2: In read.dcf(file.path(pkgname, DESCRIPTION), c(Package, Type)) :
  cannot open compressed file 'extrafont_0.15.tar.gz/DESCRIPTION', probable 
reason 'No such file or directory'

When I unzip these gz files using Winzip I do find a DESCRIPTION file. 

What am I doing wrong?

Thanks
Robin

__
R-help@r-project.org mailing list
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] Colorspace: bug in HLS conversion?

2014-03-13 Thread Pascal Oettli
Hi,

I cannot reproduce your result:

R as(as(RGB(0, 0, 0), HLS), RGB)
 R G B
[1,] 0 0 0

You probably should provide the output of sessionInfo().

Regards,
Pascal



On Thu, Mar 13, 2014 at 7:41 AM, Michael Gauland mikely...@amuri.net wrote:
 I just started using the colorspace package, and converting between RGB and
 HLS is not working as I expect.  In particular, converting RGB(0,0,0) to HLS
 then back to RGB seems broken:

 # as(as(RGB(0, 0, 0), HLS), RGB)
  R G B
 [1,] 1 1 0

 That is, converting black to HLS then back again produces yellow!

 Other values I've tried work as expected (i.e., I get the same RGB value out
 as I put in).

 Is this a bug in the code, or in my understanding of colour conversions?

 Kind Regards,
 Mike

 __
 R-help@r-project.org mailing list
 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.



-- 
Pascal Oettli
Project Scientist
JAMSTEC
Yokohama, Japan

__
R-help@r-project.org mailing list
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] Colorspace: bug in HLS conversion?

2014-03-13 Thread Achim Zeileis

On Wed, 12 Mar 2014, Michael Gauland wrote:


I just started using the colorspace package, and converting between RGB and
HLS is not working as I expect.  In particular, converting RGB(0,0,0) to HLS
then back to RGB seems broken:

   # as(as(RGB(0, 0, 0), HLS), RGB)
 R G B
   [1,] 1 1 0

That is, converting black to HLS then back again produces yellow!


I can't reproduce this. I get 0,0,0 as expected.


Other values I've tried work as expected (i.e., I get the same RGB value out
as I put in).

Is this a bug in the code, or in my understanding of colour conversions?


Maybe you are using an old version of colorspace? For version 1.1-1 
(from two years ago, version 1.2-4 is current) the NEWS file says:


o Bug fix in HLS_to_RGB conversion for s == 0.


Kind Regards,
Mike

__
R-help@r-project.org mailing list
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
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] NAG (NAGFWrapper) or any optimization package recommended?

2014-03-13 Thread jpm miao
Hi,

   Is there any optimization package in R recommended for general purposes
(constrained, unconstrained, etc)?

   Has anyone used the function in NAGFWrapper package

http://www.nag.co.uk/numeric/R/r-package

   Are the optimization functions therein available for free?

   Thanks,

Miao

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
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 installing extrafonts from local zip file

2014-03-13 Thread Prof Brian Ripley

On 13/03/2014 04:31, robin.thom...@csiro.au wrote:

I am making my first submission to Plos One and am trying to install the extrafonts 
package to obtain Arial for the figures. extrafonts was archived at the end 
of last month so I downloaded first the extrafont_0.16.tar.gz file and then the older 
extrafont_0.15.tar.gz file.


Those are not zip files.  You need to use (at the command line)

R CMD INSTALL extrafont_0.16.tar.gz

(assuming you have already installed the dependencies).

However, I suggest you use R 3.1.0 alpha which has support for Arial 
built in.



I selected Install packages(s) from local zip file from the Packages menu of 
my installation of R x64 3.0.0

I got:


utils:::menuInstallLocal()

Error in read.dcf(file.path(pkgname, DESCRIPTION), c(Package, Type)) :
   cannot open the connection
In addition: Warning messages:
1: In unzip(zipname, exdir = dest) : error 1 in extracting from zip file
2: In read.dcf(file.path(pkgname, DESCRIPTION), c(Package, Type)) :
   cannot open compressed file 'extrafont_0.15.tar.gz/DESCRIPTION', probable 
reason 'No such file or directory'

When I unzip these gz files using Winzip I do find a DESCRIPTION file.

What am I doing wrong?

Thanks
Robin

__
R-help@r-project.org mailing list
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.




--
Brian D. Ripley,  rip...@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

__
R-help@r-project.org mailing list
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] UTF-8 characters in pandoc template variables using knitr

2014-03-13 Thread ONKELINX, Thierry
Dear all,

Consider the simpel RMarkdown file below. I've saved it as test.md with UTF-8 
encoding. Notice that I have embedded a custom pandoc variable 'test' in the 
file. This variable holds an UTF-8 character ©.

%My title
%The authorslist
!--pandoc
format: latex
V: test:Copyright notice. © copyright holder
--
# First section

fgsdfg jsdksdfgsdfg

Now I try to compile it from within R using knitr.

library(knitr)
pandoc(test.md, format = latex)

knitr inserts an extra character in the system command to pandoc. I assume it 
has something to do with the encoding. Any suggestions on how to solve this?

executing pandoc -V test:Copyright notice. © copyright holder  -f markdown 
-t latex -o test.pdf test.md

I've posted the question last week on StackOverflow 
(http://stackoverflow.com/questions/22198832/utf-8-characters-in-pandoc-template-variables-using-knitr)
 but did not got any response.

Best regards,

Thierry

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
+ 32 2 525 02 51
+ 32 54 43 61 85
thierry.onkel...@inbo.be
www.inbo.be

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

* * * * * * * * * * * * * D I S C L A I M E R * * * * * * * * * * * * *
Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en 
binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is 
door een geldig ondertekend document.
The views expressed in this message and any annex are purely those of the 
writer and may not be regarded as stating an official position of INBO, as long 
as the message is not confirmed by a duly signed document.

__
R-help@r-project.org mailing list
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] NAG (NAGFWrapper) or any optimization package recommended?

2014-03-13 Thread Berend Hasselman

On 13-03-2014, at 09:50, jpm miao miao...@gmail.com wrote:

 Hi,
 
   Is there any optimization package in R recommended for general purposes
 (constrained, unconstrained, etc)?
 

See CRAN Task Views, Optimization. http://cran.r-project.org/web/views/

   Has anyone used the function in NAGFWrapper package
 
 http://www.nag.co.uk/numeric/R/r-package
 
   Are the optimization functions therein available for free?
 

Well not from what I could read on that webpage.
See the second paragraph in the section labelled “Installation”.
The NAG library is not free.

Berend

__
R-help@r-project.org mailing list
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] UTF-8 characters in pandoc template variables using knitr

2014-03-13 Thread Prof Brian Ripley

And what did the maintainer say?  (See the posting guide.)

On 13/03/2014 09:11, ONKELINX, Thierry wrote:

Dear all,

Consider the simpel RMarkdown file below. I've saved it as test.md with UTF-8 
encoding. Notice that I have embedded a custom pandoc variable 'test' in the 
file. This variable holds an UTF-8 character ©.

%My title
%The authorslist
!--pandoc
format: latex
V: test:Copyright notice. © copyright holder
--
# First section

fgsdfg jsdksdfgsdfg

Now I try to compile it from within R using knitr.

library(knitr)
pandoc(test.md, format = latex)

knitr inserts an extra character in the system command to pandoc. I assume it 
has something to do with the encoding. Any suggestions on how to solve this?

executing pandoc -V test:Copyright notice. © copyright holder  -f markdown -t latex -o 
test.pdf test.md

I've posted the question last week on StackOverflow 
(http://stackoverflow.com/questions/22198832/utf-8-characters-in-pandoc-template-variables-using-knitr)
 but did not got any response.

Best regards,

Thierry

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
+ 32 2 525 02 51
+ 32 54 43 61 85
thierry.onkel...@inbo.be
www.inbo.be

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

* * * * * * * * * * * * * D I S C L A I M E R * * * * * * * * * * * * *
Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en 
binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is 
door een geldig ondertekend document.
The views expressed in this message and any annex are purely those of the 
writer and may not be regarded as stating an official position of INBO, as long 
as the message is not confirmed by a duly signed document.

__
R-help@r-project.org mailing list
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.




--
Brian D. Ripley,  rip...@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

__
R-help@r-project.org mailing list
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] replace duplicates with 0

2014-03-13 Thread catalin roibu
Dear all!

Is there a possibility to replace all duplicates values in data frame with
0?

Thank you very much!



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

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
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] replace duplicates with 0

2014-03-13 Thread Pascal Oettli
Hello,

Dis you at least search?

?duplicated

Regards,
Pascal

On Thu, Mar 13, 2014 at 9:35 PM, catalin roibu catalinro...@gmail.com wrote:
 Dear all!

 Is there a possibility to replace all duplicates values in data frame with
 0?

 Thank you very much!



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

 [[alternative HTML version deleted]]

 __
 R-help@r-project.org mailing list
 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.



-- 
Pascal Oettli
Project Scientist
JAMSTEC
Yokohama, Japan

__
R-help@r-project.org mailing list
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] replace duplicates with 0

2014-03-13 Thread Rui Barradas

Hello,

See ?duplicated
Something like

dat1[duplicated(dat1), ] - 0

Hope this helps,

Rui Barradas

Em 13-03-2014 12:35, catalin roibu escreveu:

Dear all!

Is there a possibility to replace all duplicates values in data frame with
0?

Thank you very much!





__
R-help@r-project.org mailing list
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] replace duplicates with 0

2014-03-13 Thread Jorge I Velez
Hi Catalin,

The following should give you some ideas:

set.seed(123)
x - rpois(50, 2)
x
idx - duplicated(x)
x[idx] - 0
x

Best,
Jorge.-



On Thu, Mar 13, 2014 at 11:35 PM, catalin roibu catalinro...@gmail.comwrote:

 Dear all!

 Is there a possibility to replace all duplicates values in data frame with
 0?

 Thank you very much!



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

 [[alternative HTML version deleted]]

 __
 R-help@r-project.org mailing list
 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
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] Downloading a RData file and problem with loading it

2014-03-13 Thread varin sacha
Hi all,

I have downloaded the file 5.R.RData and I am trying to load it into R using 
load(5.R.RData) 
But it doesn't work.What's wrong,
Many thanks 
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
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] Downloading a RData file and problem with loading it

2014-03-13 Thread Jeff Newmiller
Do you really think we can answer this? Ok, the file is not a valid RData file, 
or was corrupted in the file transfer. Was that helpful? If not, try being 
specific (what URL did this file come from? Which version of R? What was the 
output of session in sessionInfo()?) and posting in plain text as the Posting 
Guide advises you to (that is a hint... go read it).
---
Jeff NewmillerThe .   .  Go Live...
DCN:jdnew...@dcn.davis.ca.usBasics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
--- 
Sent from my phone. Please excuse my brevity.

On March 13, 2014 6:22:45 AM PDT, varin sacha varinsa...@yahoo.fr wrote:
Hi all,

I have downloaded the file 5.R.RData�and I am trying to load it into R
using load(5.R.RData)�
But it doesn't work.What's wrong,
Many thanks�
   [[alternative HTML version deleted]]





__
R-help@r-project.org mailing list
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
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] behaviour of rows and colomns suppression in a matrix

2014-03-13 Thread Olivier ETERRADOSSI
Hi  List,
while running a script on a set of matrices I came into a case I would not
have guessed to arrive.
Below is  a small toy example to illustrate the case.
Of course there is a simple workaround (using a simple test), but why does
this occur, and shouldn’t it be corrected ?

More probably I miss a point, but which one ? Is this behavior obtained on
purpose and why ?
Sorry if it’s a FAQ… I didn’t find my way to it.
(And sorry for multiple posting if any : I got a warning from r-bounce but
did not understand it).
Thanks, Olivier


#
# toy example 1 (no problem with this one)

toy.matrix.1-matrix(c(1,0,1,1,0,1,0,0,0),3,3)
# getting the marginal sums
margin.Rows- apply(toy.matrix.1,MARGIN=1,FUN=sum)
margin.Cols- apply(toy.matrix.1,MARGIN=2,FUN=sum)
#giving a threshold for lines and columns suppression
thresh-0
# finding the items to remove
unused.rows-which(margin.Rows=thresh)    # unused.rows == 2
unused.cols-which(margin.Cols=thresh)    # unused.cols == 3
TM1-toy.matrix.1
TM1-TM1[-unused.rows,]
TM1-TM1[,-unused.cols]
TM1
# [,1] [,2]
#[1,]    1    1
#[2,]    1    1         # OK
##

# toy example 2 (oops, no rows to suppress…)

toy.matrix.2-matrix(c(1,1,1,1,1,1,0,0,0),3,3)
# getting the marginal sums
margin.Rows- apply(toy.matrix.2,MARGIN=1,FUN=sum)
margin.Cols- apply(toy.matrix.2,MARGIN=2,FUN=sum)
#giving a threshold for lines and columns suppression
thresh-0
unused.rows-which(margin.Rows=thresh) # unused.rows ==
integer(0)
unused.cols-which(margin.Cols=thresh)  # unused.cols == 3
TM2-toy.matrix.2
TM2-TM2[-unused.rows,]
TM2-TM2[,-unused.cols]
TM2
#  [,1] [,2]    # empty...
###
# I was expecting :
# [,1] [,2]
#[1,]    1    1
#[2,]    1    1
#[3,]    1    1

# which of course is obtained using :
TM2-toy.matrix.2
if(length(unused.rows) !=0) {TM2-TM2[-unused.rows,]}
if(length(unused.rows) !=0 ){TM2-TM2[,-unused.cols]}
TM2

__
R-help@r-project.org mailing list
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] change date format

2014-03-13 Thread catalin roibu
Dear all!

I have a new problem with the date format in a data frame. I have rainfall
records extracted from an automatic meteo station. In the same data frame
(with 1 records) the date is in 2 formats like that:
4/15/11 11:49 AM
5.6.11 2:51 PM

My question is how to modify date format for all records with this format
type: 4/15/11 11:49 AM.

Thank you!
Best regards!

Catalin

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

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
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] behaviour of rows and colomns suppression in a matrix

2014-03-13 Thread Sarah Goslee
Hi,

Your basic problem seems to be that you expect R to take

TM2[0, ]

as meaning not to subset anything, rather than to take only row 0,
which doesn't exist:

R TM2[0,]
 [,1] [,2] [,3]

There's a hint in

?[

which says:

  An index value of 'NULL' is treated as if it were
  'integer(0)'.


Here are two alternative formulations of your task:
# safer method 1

used.rows-which(margin.Rows  thresh)
used.cols-which(margin.Cols  thresh)
TM2[used.rows, used.cols]

# safer method 2

unused.rows- margin.Rows=thresh
unused.cols- margin.Cols=thresh
TM2[!unused.rows, !unused.cols]

Sarah

On Thu, Mar 13, 2014 at 10:02 AM, Olivier ETERRADOSSI
olivier.eterrado...@mines-ales.fr wrote:
 Hi  List,
 while running a script on a set of matrices I came into a case I would not
 have guessed to arrive.
 Below is  a small toy example to illustrate the case.
 Of course there is a simple workaround (using a simple test), but why does
 this occur, and shouldn't it be corrected ?

 More probably I miss a point, but which one ? Is this behavior obtained on
 purpose and why ?
 Sorry if it's a FAQ... I didn't find my way to it.
 (And sorry for multiple posting if any : I got a warning from r-bounce but
 did not understand it).
 Thanks, Olivier


 #
 # toy example 1 (no problem with this one)

 toy.matrix.1-matrix(c(1,0,1,1,0,1,0,0,0),3,3)
 # getting the marginal sums
 margin.Rows- apply(toy.matrix.1,MARGIN=1,FUN=sum)
 margin.Cols- apply(toy.matrix.1,MARGIN=2,FUN=sum)
 #giving a threshold for lines and columns suppression
 thresh-0
 # finding the items to remove
 unused.rows-which(margin.Rows=thresh)# unused.rows == 2
 unused.cols-which(margin.Cols=thresh)# unused.cols == 3
 TM1-toy.matrix.1
 TM1-TM1[-unused.rows,]
 TM1-TM1[,-unused.cols]
 TM1
 # [,1] [,2]
 #[1,]11
 #[2,]11 # OK
 ##

 # toy example 2 (oops, no rows to suppress...)

 toy.matrix.2-matrix(c(1,1,1,1,1,1,0,0,0),3,3)
 # getting the marginal sums
 margin.Rows- apply(toy.matrix.2,MARGIN=1,FUN=sum)
 margin.Cols- apply(toy.matrix.2,MARGIN=2,FUN=sum)
 #giving a threshold for lines and columns suppression
 thresh-0
 unused.rows-which(margin.Rows=thresh) # unused.rows ==
 integer(0)
 unused.cols-which(margin.Cols=thresh)  # unused.cols == 3
 TM2-toy.matrix.2
 TM2-TM2[-unused.rows,]
 TM2-TM2[,-unused.cols]
 TM2
 #  [,1] [,2]# empty...
 ###
 # I was expecting :
 # [,1] [,2]
 #[1,]11
 #[2,]11
 #[3,]11

 # which of course is obtained using :
 TM2-toy.matrix.2
 if(length(unused.rows) !=0) {TM2-TM2[-unused.rows,]}
 if(length(unused.rows) !=0 ){TM2-TM2[,-unused.cols]}
 TM2

-- 
Sarah Goslee
http://www.functionaldiversity.org

__
R-help@r-project.org mailing list
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 of columns when merging two data frames

2014-03-13 Thread Stefano Sofia
Dear list users,
I have two data frames df1 and df2, where the columns of df1 are

Sensor_RM Place_RM Station_RM Y_init_RM M_init_RM D_init_RM Y_fin_RM M_fin_RM 
D_fin_RM

and the columns of df2 are

Sensor_RM Station_RM Place_RM Province_RM Region_RM Net_init_RM 
GaussBoaga_EST_RM GaussBoaga_NORD_RM Gradi_Long_RM Primi_Long_RM 
Secondi_Long_RM Gradi_Lat_RM Primi_Lat_RM Secondi_Lat_RM Long_Cent_RM 
Lat_Cent_RM Height_RM

When I merge the two data frames through

df3 - merge(df1, df2, by=c(Sensor_RM, Station_RM))

I get a new data frame with columns

Sensor_RM Station_RM Place_RM.x Y_init_RM M_init_RM D_init_RM Y_fin_RM M_fin_RM 
D_fin_RM Place_RM.y Province_RM Region_RM Net_init_RM GaussBoaga_EST_RM 
GaussBoaga_NORD_RM Gradi_Long_RM Primi_Long_RM Secondi_Long_RM Gradi_Lat_RM 
Primi_Lat_RM Secondi_Lat_RM Long_Cent_RM Lat_Cent_RM Height_RM

I am sure that df1$Place_RM and df2$Place_RM are equal. I checked it from the 
shell using awk and diff.
Why then I have a duplicate of Place_RM, i.e. Place_RM.x and Place_RM.y, and 
only of them?

Thank you for your help
Stefano




AVVISO IMPORTANTE: Questo messaggio di posta elettronica può contenere 
informazioni confidenziali, pertanto è destinato solo a persone autorizzate 
alla ricezione. I messaggi di posta elettronica per i client di Regione Marche 
possono contenere informazioni confidenziali e con privilegi legali. Se non si 
è il destinatario specificato, non leggere, copiare, inoltrare o archiviare 
questo messaggio. Se si è ricevuto questo messaggio per errore, inoltrarlo al 
mittente ed eliminarlo completamente dal sistema del proprio computer. Ai sensi 
dell’art. 6 della DGR n. 1394/2008 si segnala che, in caso di necessità ed 
urgenza, la risposta al presente messaggio di posta elettronica può essere 
visionata da persone estranee al destinatario.
IMPORTANT NOTICE: This e-mail message is intended to be received only by 
persons entitled to receive the confidential information it may contain. E-mail 
messages to clients of Regione Marche may contain information that is 
confidential and legally privileged. Please do not read, copy, forward, or 
store this message unless you are an intended recipient of it. If you have 
received this message in error, please forward it to the sender and delete it 
completely from your computer system.

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
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] change date format

2014-03-13 Thread MacQueen, Don
I would use gsub() to change instances like 5.6.11 to 5/6/11.
Hopefully, both versions have month and day in the same order.

-Don
-- 
Don MacQueen

Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062





On 3/13/14 6:57 AM, catalin roibu catalinro...@gmail.com wrote:

Dear all!

I have a new problem with the date format in a data frame. I have rainfall
records extracted from an automatic meteo station. In the same data frame
(with 1 records) the date is in 2 formats like that:
4/15/11 11:49 AM
5.6.11 2:51 PM

My question is how to modify date format for all records with this format
type: 4/15/11 11:49 AM.

Thank you!
Best regards!

Catalin

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

   [[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
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
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 of columns when merging two data frames

2014-03-13 Thread MacQueen, Don
You have duplicates after merging because, although you know they are the
same, the R merge() function does not. And the people who wrote that
function knew that sometimes two columns with the same name are not
identical.

Since you know that the columns are identical, drop the column from one of
the two data frames before merging.

-Don

-- 
Don MacQueen

Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062





On 3/13/14 8:19 AM, Stefano Sofia stefano.so...@regione.marche.it
wrote:

Dear list users,
I have two data frames df1 and df2, where the columns of df1 are

Sensor_RM Place_RM Station_RM Y_init_RM M_init_RM D_init_RM Y_fin_RM
M_fin_RM D_fin_RM

and the columns of df2 are

Sensor_RM Station_RM Place_RM Province_RM Region_RM Net_init_RM
GaussBoaga_EST_RM GaussBoaga_NORD_RM Gradi_Long_RM Primi_Long_RM
Secondi_Long_RM Gradi_Lat_RM Primi_Lat_RM Secondi_Lat_RM Long_Cent_RM
Lat_Cent_RM Height_RM

When I merge the two data frames through

df3 - merge(df1, df2, by=c(Sensor_RM, Station_RM))

I get a new data frame with columns

Sensor_RM Station_RM Place_RM.x Y_init_RM M_init_RM D_init_RM Y_fin_RM
M_fin_RM D_fin_RM Place_RM.y Province_RM Region_RM Net_init_RM
GaussBoaga_EST_RM GaussBoaga_NORD_RM Gradi_Long_RM Primi_Long_RM
Secondi_Long_RM Gradi_Lat_RM Primi_Lat_RM Secondi_Lat_RM Long_Cent_RM
Lat_Cent_RM Height_RM

I am sure that df1$Place_RM and df2$Place_RM are equal. I checked it from
the shell using awk and diff.
Why then I have a duplicate of Place_RM, i.e. Place_RM.x and Place_RM.y,
and only of them?

Thank you for your help
Stefano




AVVISO IMPORTANTE: Questo messaggio di posta elettronica può contenere
informazioni confidenziali, pertanto è destinato solo a persone
autorizzate alla ricezione. I messaggi di posta elettronica per i client
di Regione Marche possono contenere informazioni confidenziali e con
privilegi legali. Se non si è il destinatario specificato, non leggere,
copiare, inoltrare o archiviare questo messaggio. Se si è ricevuto questo
messaggio per errore, inoltrarlo al mittente ed eliminarlo completamente
dal sistema del proprio computer. Ai sensi dell¹art. 6 della DGR n.
1394/2008 si segnala che, in caso di necessità ed urgenza, la risposta al
presente messaggio di posta elettronica può essere visionata da persone
estranee al destinatario.
IMPORTANT NOTICE: This e-mail message is intended to be received only by
persons entitled to receive the confidential information it may contain.
E-mail messages to clients of Regione Marche may contain information that
is confidential and legally privileged. Please do not read, copy,
forward, or store this message unless you are an intended recipient of
it. If you have received this message in error, please forward it to the
sender and delete it completely from your computer system.

   [[alternative HTML version deleted]]


__
R-help@r-project.org mailing list
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] outlier detection in nonlinear regression

2014-03-13 Thread anders . mehler

Dear useR's,
 
I have several biological data sets from laboratory experiments
where a few experiments failed completely due to bacterial 
contamination. Such cases can easily be seen by eye as outliers.
 
Fitting a Michaelis-Menten kinetics works well with robust nonlinear
regression from package robustbase, but this helps me only partly 
because I need to remove the outliers for a subsequent analysis, 
so I need a reproducible automatic method.
 
I tried the following two heuristic approaches by either using the 
robust weights directly (A) or by applying a 3-sigma rule to the 
residuals (B), see example below.
 
My question: Is there any method available in R that is less heuristic 
than this?

Thank you in advance
 
Anders
 

library(robustbase)

## create data
set.seed(375)
x - rep(0:10, 3)
y - 5 * x / (2 + x) + rnorm(x, sd = 0.2)

## make outliers
y[c(3, 5, 10)] - y[c(3, 5, 10)] + c(2, -1, -2)

## robust regression
m - nlrob(y ~ a * x /(b + x),
   data = list(x = x, y = y),
   start = list(a = 1, b = 1))
summary(m)
xnew - list(x = seq(0, 10, 0.1))
plot(x, y)
lines(xnew$x, predict(m, newdata = xnew))

## A) use robust weights to detect outliers
##    ?? how to select a critical value?
outA - m$rweight  0.5
points(x[outA], y[outA], pch = 16, col = red)

## B) use 3 sigma of residuals to detect outliers
eps  - residuals(m)
outB - abs(eps)  (3 * sd(eps))
points(x[outB], y[outB], pch = 3, col = blue)

__
R-help@r-project.org mailing list
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 of columns when merging two data frames

2014-03-13 Thread Marc Schwartz

On Mar 13, 2014, at 10:19 AM, Stefano Sofia stefano.so...@regione.marche.it 
wrote:

 Dear list users,
 I have two data frames df1 and df2, where the columns of df1 are
 
 Sensor_RM Place_RM Station_RM Y_init_RM M_init_RM D_init_RM Y_fin_RM M_fin_RM 
 D_fin_RM
 
 and the columns of df2 are
 
 Sensor_RM Station_RM Place_RM Province_RM Region_RM Net_init_RM 
 GaussBoaga_EST_RM GaussBoaga_NORD_RM Gradi_Long_RM Primi_Long_RM 
 Secondi_Long_RM Gradi_Lat_RM Primi_Lat_RM Secondi_Lat_RM Long_Cent_RM 
 Lat_Cent_RM Height_RM
 
 When I merge the two data frames through
 
 df3 - merge(df1, df2, by=c(Sensor_RM, Station_RM))
 
 I get a new data frame with columns
 
 Sensor_RM Station_RM Place_RM.x Y_init_RM M_init_RM D_init_RM Y_fin_RM 
 M_fin_RM D_fin_RM Place_RM.y Province_RM Region_RM Net_init_RM 
 GaussBoaga_EST_RM GaussBoaga_NORD_RM Gradi_Long_RM Primi_Long_RM 
 Secondi_Long_RM Gradi_Lat_RM Primi_Lat_RM Secondi_Lat_RM Long_Cent_RM 
 Lat_Cent_RM Height_RM
 
 I am sure that df1$Place_RM and df2$Place_RM are equal. I checked it from the 
 shell using awk and diff.
 Why then I have a duplicate of Place_RM, i.e. Place_RM.x and Place_RM.y, and 
 only of them?
 
 Thank you for your help
 Stefano
 


From the Details section of ?merge:

If the columns in the data frames not used in merging have any common names, 
these have suffixes (.x and .y by default) appended to try to make the 
names of the result unique. If this is not possible, an error is thrown.


If you don't want both columns in the resultant data frame, use them in the 
'by' argument or remove one of them prior to merge()ing. If you use them in the 
'by' argument, be sure that they will be compared as exactly equal, which can 
be problematic if they are floating point values. If so, you would be better of 
subsetting one of the source data frames to remove the column first:

  df3 - merge(df1, 
   subset(df2, select = -Place_RM),
   by=c(Sensor_RM, Station_RM))
  

Regards,

Marc Schwartz

__
R-help@r-project.org mailing list
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 question about intraindividual variables

2014-03-13 Thread Nastassia Hajal
I am creating variables representing intraindividual means and standard
deviations for longitudinal data with the following code:

data$TraitHAPPYmean - with(data, ave(Happy, ID, FUN=function(x) mean(x,
na.rm=TRUE) )  )



data$TraitHAPPYsd - with(data, ave(Happy, ID, FUN=function(x) sd(x,
na.rm=TRUE) )  )

where 'Happy' is the variable that was collected at multiple timepoint,
'ID' is the grouping variable, and TraitHAPPYMean  SD are the new
variables. I'd like to also create a variable that just returns the # of
cases for each grouping variable (ID). For example, some IDs might have 10
cases of Happy that went into the intraindividual mean, while others have
only 5.

I realize that this is probably a very basic question, but I just cannot
figure it out! Thanks.

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
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] Estimate LA/AIDS elasticities with Heckman correction in R

2014-03-13 Thread Belinda Archibong
Hi,

I've been trying to figure out the code to estimate the LA/AIDS model
with the inverse mills ratio from the Heckman-2 step to correct for
zero consumption in R with no luck. Could someone please direct me on
how to do this in R?

Thanks,

Belinda A.

__
R-help@r-project.org mailing list
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] change date format

2014-03-13 Thread arun
Try:
vec1 - c(4/15/11 11:49 AM, 6/12/12 2:30 PM, 5.6.11 2:51 PM)
vec2 - gsub([.],/,vec1)
A.K.




On Thursday, March 13, 2014 9:57 AM, catalin roibu catalinro...@gmail.com 
wrote:
Dear all!

I have a new problem with the date format in a data frame. I have rainfall
records extracted from an automatic meteo station. In the same data frame
(with 1 records) the date is in 2 formats like that:
4/15/11 11:49 AM
5.6.11 2:51 PM

My question is how to modify date format for all records with this format
type: 4/15/11 11:49 AM.

Thank you!
Best regards!

Catalin

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

    [[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
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
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] behaviour of rows and colomns suppression in a matrix

2014-03-13 Thread arun
Hi,
You could use:
 TM2[!margin.Rows =thresh,!margin.Cols =thresh]
# [,1] [,2]
#[1,]    1    1
#[2,]    1    1
#[3,]    1    1


#For the first case:
TM1[!margin.Rows =thresh,!margin.Cols =thresh]
# [,1] [,2]
#[1,]    1    1
#[2,]    1    1



A.K.





On Thursday, March 13, 2014 10:02 AM, Olivier ETERRADOSSI 
olivier.eterrado...@mines-ales.fr wrote:
Hi  List,
while running a script on a set of matrices I came into a case I would not
have guessed to arrive.
Below is  a small toy example to illustrate the case.
Of course there is a simple workaround (using a simple test), but why does
this occur, and shouldn’t it be corrected ?

More probably I miss a point, but which one ? Is this behavior obtained on
purpose and why ?
Sorry if it’s a FAQ… I didn’t find my way to it.
(And sorry for multiple posting if any : I got a warning from r-bounce but
did not understand it).
Thanks, Olivier


#
# toy example 1 (no problem with this one)

toy.matrix.1-matrix(c(1,0,1,1,0,1,0,0,0),3,3)
# getting the marginal sums
margin.Rows- apply(toy.matrix.1,MARGIN=1,FUN=sum)
margin.Cols- apply(toy.matrix.1,MARGIN=2,FUN=sum)
#giving a threshold for lines and columns suppression
thresh-0
# finding the items to remove
unused.rows-which(margin.Rows=thresh)    # unused.rows == 2
unused.cols-which(margin.Cols=thresh)    # unused.cols == 3
TM1-toy.matrix.1
TM1-TM1[-unused.rows,]
TM1-TM1[,-unused.cols]
TM1
# [,1] [,2]
#[1,]    1    1
#[2,]    1    1         # OK
##

# toy example 2 (oops, no rows to suppress…)

toy.matrix.2-matrix(c(1,1,1,1,1,1,0,0,0),3,3)
# getting the marginal sums
margin.Rows- apply(toy.matrix.2,MARGIN=1,FUN=sum)
margin.Cols- apply(toy.matrix.2,MARGIN=2,FUN=sum)
#giving a threshold for lines and columns suppression
thresh-0
unused.rows-which(margin.Rows=thresh) # unused.rows ==
integer(0)
unused.cols-which(margin.Cols=thresh)  # unused.cols == 3
TM2-toy.matrix.2
TM2-TM2[-unused.rows,]
TM2-TM2[,-unused.cols]
TM2
#  [,1] [,2]    # empty...
###
# I was expecting :
# [,1] [,2]
#[1,]    1    1
#[2,]    1    1
#[3,]    1    1

# which of course is obtained using :
TM2-toy.matrix.2
if(length(unused.rows) !=0) {TM2-TM2[-unused.rows,]}
if(length(unused.rows) !=0 ){TM2-TM2[,-unused.cols]}
TM2

__
R-help@r-project.org mailing list
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
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] Intraindividual means, SDs, and n's

2014-03-13 Thread arun
Hi,
Try:
 set.seed(42)
 dat1 - data.frame(Happy=sample(c(NA,1:25),40,replace=TRUE),ID=rep(1:5,each=8))

 with(dat1,ave(Happy,ID,FUN=function(x) sum(!is.na(x
#or
library(plyr)
 
ddply(dat1,.(ID),mutate,mean=mean(Happy,na.rm=TRUE),SD=sd(Happy,na.rm=TRUE),n=sum(!is.na(Happy)))



#or you could use:
library(psych)
with(dat1,describeBy(Happy,ID,mat=TRUE))[,4:6]
#   n mean   sd
#11 8 15.75000 7.611082
#12 8 16.25000 6.296257
#13 8 16.12500 9.508455
#14 8 15.0 7.230886
#15 6 15.16667 6.765107

A.K.







I am creating variables representing intraindividual means and standard 
deviations for longitudinal data with the following code: 

data$TraitHAPPYmean - with(data, ave(Happy, ID, FUN=function(x) mean(x, 
na.rm=TRUE) )  ) 

 

data$TraitHAPPYsd - with(data, ave(Happy, ID, FUN=function(x) sd(x, 
na.rm=TRUE) )  ) 

I'd like to also create a variable that just returns the # of 
cases for each grouping variable (ID). For example, some IDs might have 
10 cases of Happy (the target measure here), while others have only 5. 

I realize that this is probably a very basic question, but I just cannot figure 
it out! Thanks.

__
R-help@r-project.org mailing list
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] creating table with sequences of numbers based on the table

2014-03-13 Thread arun
Hi,
Try:
Either

tab - read.table(text=pop Freq
1   1   30
2   2   25
3   3   30
4   4   30
5   5   30
6   6   30
7   7   30,sep=,header=TRUE)

indx - rep(1:nrow(tab),tab$Freq)
tab1 - transform(tab[indx,],ind=ave(seq_along(indx),indx,FUN=seq_along))[,-2]
#or
tab2 -  transform(tab[indx,],ind=unlist(sapply(tab$Freq,seq)))[,-2]
identical(tab1,tab2)
#[1] TRUE
#or
tab3 - transform(tab[indx,], ind= 
with(tab,seq_len(sum(Freq))-rep(cumsum(c(0L,Freq[-length(Freq)])),Freq)))[,-2]
identical(tab1,tab3)
#[1] TRUE

A.K.


I have a problem with transfering one table to another automatically. From 
table like this: 

 tab 
  pop Freq 
1       1   30 
2       2   25 
3       3   30 
4       4   30 
5       5   30 
6       6   30 
7       7   30 

I want to use number of individuals (freq) and then in next 
table just list them with following numbers (depending on total number 
of individuals) 
Like this: 
in 
pop        ind 
  
1              1 
1              2 
1              3 
1              4 
.               . 
.               . 
1              30 
2              1 
2              2 
2              3 
2              4 
.               . 
2              25 
3              1 
3              2 
.               . 
.               . 

How can i do it? I think i have to use loops but so far I failed. 
Thank you in advance, 
Best, 
Malgorzata Gazda

__
R-help@r-project.org mailing list
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] behaviour of rows and colomns suppression in a matrix

2014-03-13 Thread Olivier ETERRADOSSI
Thank you Sarah,

But no, I was not expecting this. For me integer(0) is not 0.
That's why I finally tested length(unused.rows), which is 0 when
unused.rows is integer(0).

Olivier


-Message d'origine-
De : Sarah Goslee [mailto:sarah.gos...@gmail.com]
Envoyé : jeudi 13 mars 2014 16:12
À : Olivier ETERRADOSSI
Cc : r-help
Objet : Re: [R] behaviour of rows and colomns suppression in a matrix

Hi,

Your basic problem seems to be that you expect R to take

TM2[0, ]

as meaning not to subset anything, rather than to take only row 0, which
doesn't exist:

R TM2[0,]
 [,1] [,2] [,3]

There's a hint in

?[

which says:

  An index value of 'NULL' is treated as if it were
  'integer(0)'.


Here are two alternative formulations of your task:
# safer method 1

used.rows-which(margin.Rows  thresh)
used.cols-which(margin.Cols  thresh)
TM2[used.rows, used.cols]

# safer method 2

unused.rows- margin.Rows=thresh
unused.cols- margin.Cols=thresh
TM2[!unused.rows, !unused.cols]

Sarah

On Thu, Mar 13, 2014 at 10:02 AM, Olivier ETERRADOSSI
olivier.eterrado...@mines-ales.fr wrote:
 Hi  List,
 while running a script on a set of matrices I came into a case I would
 not have guessed to arrive.
 Below is  a small toy example to illustrate the case.
 Of course there is a simple workaround (using a simple test), but why
 does this occur, and shouldn't it be corrected ?

 More probably I miss a point, but which one ? Is this behavior
 obtained on purpose and why ?
 Sorry if it's a FAQ... I didn't find my way to it.
 (And sorry for multiple posting if any : I got a warning from r-bounce
 but did not understand it).
 Thanks, Olivier


 #
 # toy example 1 (no problem with this one)

 toy.matrix.1-matrix(c(1,0,1,1,0,1,0,0,0),3,3)
 # getting the marginal sums
 margin.Rows- apply(toy.matrix.1,MARGIN=1,FUN=sum)
 margin.Cols- apply(toy.matrix.1,MARGIN=2,FUN=sum)
 #giving a threshold for lines and columns suppression
 thresh-0
 # finding the items to remove
 unused.rows-which(margin.Rows=thresh)# unused.rows == 2
 unused.cols-which(margin.Cols=thresh)# unused.cols == 3
 TM1-toy.matrix.1
 TM1-TM1[-unused.rows,]
 TM1-TM1[,-unused.cols]
 TM1
 # [,1] [,2]
 #[1,]11
 #[2,]11 # OK
 ##

 # toy example 2 (oops, no rows to suppress...)

 toy.matrix.2-matrix(c(1,1,1,1,1,1,0,0,0),3,3)
 # getting the marginal sums
 margin.Rows- apply(toy.matrix.2,MARGIN=1,FUN=sum)
 margin.Cols- apply(toy.matrix.2,MARGIN=2,FUN=sum)
 #giving a threshold for lines and columns suppression
 thresh-0
 unused.rows-which(margin.Rows=thresh) # unused.rows ==
 integer(0)
 unused.cols-which(margin.Cols=thresh)  # unused.cols == 3
 TM2-toy.matrix.2
 TM2-TM2[-unused.rows,]
 TM2-TM2[,-unused.cols]
 TM2
 #  [,1] [,2]# empty...
 ###
 # I was expecting :
 # [,1] [,2]
 #[1,]11
 #[2,]11
 #[3,]11

 # which of course is obtained using :
 TM2-toy.matrix.2
 if(length(unused.rows) !=0) {TM2-TM2[-unused.rows,]}
 if(length(unused.rows) !=0 ){TM2-TM2[,-unused.cols]}
 TM2

--
Sarah Goslee
http://www.functionaldiversity.org

__
R-help@r-project.org mailing list
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] behaviour of rows and colomns suppression in a matrix

2014-03-13 Thread Sarah Goslee
On Thu, Mar 13, 2014 at 11:51 AM, Olivier ETERRADOSSI
olivier.eterrado...@mines-ales.fr wrote:
 Thank you Sarah,

 But no, I was not expecting this. For me integer(0) is not 0.
 That's why I finally tested length(unused.rows), which is 0 when
 unused.rows is integer(0).

Also from

?[

i, j, ...: indices specifying elements to extract or replace.  Indices
  are 'numeric' or 'character' vectors or empty (missing) or
  'NULL'.  Numeric values are coerced to integer as by
  'as.integer' (and hence truncated towards zero).  Character
  vectors will be matched to the 'names' of the object (or for
  matrices/arrays, the 'dimnames'): see 'Character indices'
  below for further details.

So yes, in this case 0 is treated as integer(0).

When you have problems that seem odd to you, carefully reading the
relevant help is always a good place to start.

Sarah

__
R-help@r-project.org mailing list
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] How to get the adjusted R squared from GLS() estimator

2014-03-13 Thread Yuan, Rebecca
Hello,

Although lm() gives a way to get the adjusted R squared by

adjr2  - summary(mdl)$adj.r.squared


I cannot find a way to extract the adjusted R squared from gls(), any hint?

Thanks,

Rebecca

--
This message, and any attachments, is for the intended r...{{dropped:5}}

__
R-help@r-project.org mailing list
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] behaviour of rows and colomns suppression in a matrix

2014-03-13 Thread Olivier ETERRADOSSI
Thank you, Arun and Sarah

I was not trying to take row 0 that does not exist, rather  trying not to 
take (I wrote TM[- unused.rows,]) something that does not exist.

So what I understand from Arun's answer is that I was badly using MINUS with 
a vector instead of NOT with a logical.

Olivier

-Message d'origine-
De : arun [mailto:smartpink...@yahoo.com]
Envoyé : jeudi 13 mars 2014 16:13
À : r-help@r-project.org
Cc : Olivier ETERRADOSSI
Objet : Re: [R] behaviour of rows and colomns suppression in a matrix

Hi,
You could use:
 TM2[!margin.Rows =thresh,!margin.Cols =thresh] # [,1] [,2] #[1,]1 
1 #[2,]11 #[3,]11


#For the first case:
TM1[!margin.Rows =thresh,!margin.Cols =thresh] # [,1] [,2] #[1,]1 
1 #[2,]11



A.K.





On Thursday, March 13, 2014 10:02 AM, Olivier ETERRADOSSI 
olivier.eterrado...@mines-ales.fr wrote:
Hi  List,
while running a script on a set of matrices I came into a case I would not 
have guessed to arrive.
Below is  a small toy example to illustrate the case.
Of course there is a simple workaround (using a simple test), but why does 
this occur, and shouldn’t it be corrected ?

More probably I miss a point, but which one ? Is this behavior obtained on 
purpose and why ?
Sorry if it’s a FAQ… I didn’t find my way to it.
(And sorry for multiple posting if any : I got a warning from r-bounce but 
did not understand it).
Thanks, Olivier


#
# toy example 1 (no problem with this one)

toy.matrix.1-matrix(c(1,0,1,1,0,1,0,0,0),3,3)
# getting the marginal sums
margin.Rows- apply(toy.matrix.1,MARGIN=1,FUN=sum)
margin.Cols- apply(toy.matrix.1,MARGIN=2,FUN=sum)
#giving a threshold for lines and columns suppression
thresh-0
# finding the items to remove
unused.rows-which(margin.Rows=thresh)# unused.rows == 2
unused.cols-which(margin.Cols=thresh)# unused.cols == 3
TM1-toy.matrix.1
TM1-TM1[-unused.rows,]
TM1-TM1[,-unused.cols]
TM1
# [,1] [,2]
#[1,]11
#[2,]11 # OK 
##

# toy example 2 (oops, no rows to suppress…)

toy.matrix.2-matrix(c(1,1,1,1,1,1,0,0,0),3,3)
# getting the marginal sums
margin.Rows- apply(toy.matrix.2,MARGIN=1,FUN=sum)
margin.Cols- apply(toy.matrix.2,MARGIN=2,FUN=sum)
#giving a threshold for lines and columns suppression
thresh-0
unused.rows-which(margin.Rows=thresh) # unused.rows ==
integer(0)
unused.cols-which(margin.Cols=thresh)  # unused.cols == 3
TM2-toy.matrix.2
TM2-TM2[-unused.rows,]
TM2-TM2[,-unused.cols]
TM2
#  [,1] [,2]# empty...
###
# I was expecting :
# [,1] [,2]
#[1,]11
#[2,]11
#[3,]11

# which of course is obtained using :
TM2-toy.matrix.2
if(length(unused.rows) !=0) {TM2-TM2[-unused.rows,]}
if(length(unused.rows) !=0 ){TM2-TM2[,-unused.cols]}
TM2

__
R-help@r-project.org mailing list
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
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] behaviour of rows and colomns suppression in a matrix

2014-03-13 Thread Olivier ETERRADOSSI
Yes, that's usually what I'm doing...
Here I didn't guess that the answer was in [ !
I already noticed that it's sometimes easier to locate something very
technical or statistically smart than obvious things (because we think we
know, or think we have already read 10 times the basics...)  ;-)
O.

-Message d'origine-
De : Sarah Goslee [mailto:sarah.gos...@gmail.com]
Envoyé : jeudi 13 mars 2014 16:59
À : Olivier ETERRADOSSI
Cc : r-help
Objet : Re: [R] behaviour of rows and colomns suppression in a matrix

On Thu, Mar 13, 2014 at 11:51 AM, Olivier ETERRADOSSI
olivier.eterrado...@mines-ales.fr wrote:
 Thank you Sarah,

 But no, I was not expecting this. For me integer(0) is not 0.
 That's why I finally tested length(unused.rows), which is 0 when
 unused.rows is integer(0).

Also from

?[

i, j, ...: indices specifying elements to extract or replace.  Indices
  are 'numeric' or 'character' vectors or empty (missing) or
  'NULL'.  Numeric values are coerced to integer as by
  'as.integer' (and hence truncated towards zero).  Character
  vectors will be matched to the 'names' of the object (or for
  matrices/arrays, the 'dimnames'): see 'Character indices'
  below for further details.

So yes, in this case 0 is treated as integer(0).

When you have problems that seem odd to you, carefully reading the
relevant help is always a good place to start.

Sarah

__
R-help@r-project.org mailing list
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] SL 6.5 R from source; should I update texlive? if yes, how to point configure to new binary.

2014-03-13 Thread stephen sefick
Hello all,

I would like to install R from source on a SL 6.5 box. I have everything I
need except for inconsolata.sty and zi4.sty not found. I am thinking of
installing latex 2013 from https://www.tug.org/texlive/.

The tex binary will be installed in a different folder.

1. How do I tell ./configure to look to this directory for the tex binary?

or

2. Is there something easier that I am overlooking?

I appreciate all of the help.

--Stephen Sefick
**
Auburn University
Biological Sciences
331 Funchess Hall
Auburn, Alabama
36849
**
sas0...@auburn.edu
http://www.auburn.edu/~sas0025
**

Let's not spend our time and resources thinking about things that are so
little or so large that all they really do for us is puff us up and make us
feel like gods.  We are mammals, and have not exhausted the annoying little
problems of being mammals.

-K. Mullis

A big computer, a complex algorithm and a long time does not equal
science.

  -Robert Gentleman

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
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] create dataframe using structure ()

2014-03-13 Thread Luigi Marongiu
dear all,
I have tried to create a dataframe using the structure() function, but it
did not really work. In column 1 i have the row number, in column 2 and 3
factors (8 and 4 levels respectively) and in column 4 the actual data.
any clue on what went wrong?
best regards
luigi

my.data-structure(list(
column_1 = 1:32,
column_2 = structure(c(1, 2, 3, 4, 5, 6, 7, 8,
1, 2, 3, 4, 5, 6, 7, 8,
1, 2, 3, 4, 5, 6, 7, 8,
1, 2, 3, 4, 5, 6, 7, 8),
.Label =
c(Unstimulated, ESAT6, CFP10, Rv3615c, Rv2654, Rv3879,
Rv3873, PHA),
class = factor),
column_3 =
structure(c(1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3,
3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4), .Label = c(bd, 2m, 1m,
0.5m), class = factor),
column_4 =
c(71.62097178, 2.892223468, 144.8618621, 40.90079262, 37.0516856,
32.78206822, 72.44424152, 1512.516293, 3164.748333, 1092.634557,
28733.20269, 1207.87783, 729.6090973, 151.8706088, 241.2466141,
9600.963594, 682.865522, 5869.375226, 554.8924896, 2982.759858,
7690.028092, 40.37298719, 942.3549279, 3403.679967, 103.9862389,
35.28562613, 321.5985377, 0.274424607, 3352.874906, 93.76421187,
21.3709382, 4193.183281),
.Names = c(row, stimulation, type, copy), class = data.frame))
attach(my.data)

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
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] centroid of diamond

2014-03-13 Thread al Vel
Hello R users,
I am trying to make a baricentric diagram like the ternary plot, but with 4
edges. I want to know how to calculate the centroid of the diamond. The 4
edges are A, B, C, D. If value of A=B=C=D, then the point should be at the
centre of the diamond. If AB and B=C=D=0, Then the point should be at the
corner of A.

For diamond, how to convert the value of A,B,C,D into cartesian
co-ordinates ?. if x1,x2,y1,y2 are A,B,C,D, then someone suggested:

  new_point - function(x1, x2, y1, y2, grad=1.73206){
b1 - y1-(grad*x1)
b2 - y2-(-grad*x2)
M - matrix(c(grad, -grad, -1,-1), ncol=2)
intercepts - as.matrix(c(b1,b2))
t_mat - -solve(M) %*% intercepts
data.frame(x=t_mat[1,1], y=t_mat[2,1])
  }
But this is not working. Please do suggest some help.
thanks and best regards,
Alaguraj.V

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
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 bug on survival library Windows 7

2014-03-13 Thread CASTELLI christel
Dear All,

I have updated my OS - Windows 7, and I found a situation where R stops working
with reported error R for Windows GUI front-end has stopped working.  My 
script worked before (on windows XP).

The error occured when I perform this:

coxph(Surv(time,event)~F11_rs2036914+frailty(n), data=base)

from survival library.

If I delete the specification frailty(n) this works! But I have clustered data 
and need this specification.

Here is my system information:
R version 3.0.2 (2013-09-25)
Platform: x86_64-w64-mingw32/x64 (64-bit)
locale:
[1] LC_COLLATE=French_France.1252  LC_CTYPE=French_France.1252
[3] LC_MONETARY=French_France.1252 LC_NUMERIC=C
[5] LC_TIME=French_France.1252
attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base


Do someone meet this problem?

Anyone has some idea how to avoid this crash in Windows 7 system?

Note that I can't go back on windows XP because my institution do the choice of 
windows 7.

Sincerely,


Christel Castelli, PhD
Ingénieur biostatisticien
Responsable de la cellule médico-économie
Département BESPIM
CHU de Nîmes

__
R-help@r-project.org mailing list
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] create dataframe using structure ()

2014-03-13 Thread William Dunlap
 I have tried to create a dataframe using the structure() function,
Why do you want to do this?

 but it did not really work.
Use str() or dput() to compare this to a data.frame made in the usual
way.  You have .Names and class being arguments to list() instead of
to structure() and you didn't supply any row.names in the call to structure.

Also, why call your columns column_n in one place and row, stimulation,
... in another?   Is that why you didn't want to call data.frame in the first 
place,
so you could make the column names variable?

Bill Dunlap
TIBCO Software
wdunlap tibco.com


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
 Behalf
 Of Luigi Marongiu
 Sent: Thursday, March 13, 2014 11:59 AM
 To: r-help@r-project.org
 Subject: [R] create dataframe using structure ()
 
 dear all,
 I have tried to create a dataframe using the structure() function, but it
 did not really work. In column 1 i have the row number, in column 2 and 3
 factors (8 and 4 levels respectively) and in column 4 the actual data.
 any clue on what went wrong?
 best regards
 luigi
 
 my.data-structure(list(
 column_1 = 1:32,
 column_2 = structure(c(1, 2, 3, 4, 5, 6, 7, 8,
 1, 2, 3, 4, 5, 6, 7, 8,
 1, 2, 3, 4, 5, 6, 7, 8,
 1, 2, 3, 4, 5, 6, 7, 8),
 .Label =
 c(Unstimulated, ESAT6, CFP10, Rv3615c, Rv2654, Rv3879,
 Rv3873, PHA),
 class = factor),
 column_3 =
 structure(c(1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3,
 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4), .Label = c(bd, 2m, 1m,
 0.5m), class = factor),
 column_4 =
 c(71.62097178, 2.892223468, 144.8618621, 40.90079262, 37.0516856,
 32.78206822, 72.44424152, 1512.516293, 3164.748333, 1092.634557,
 28733.20269, 1207.87783, 729.6090973, 151.8706088, 241.2466141,
 9600.963594, 682.865522, 5869.375226, 554.8924896, 2982.759858,
 7690.028092, 40.37298719, 942.3549279, 3403.679967, 103.9862389,
 35.28562613, 321.5985377, 0.274424607, 3352.874906, 93.76421187,
 21.3709382, 4193.183281),
 .Names = c(row, stimulation, type, copy), class = data.frame))
 attach(my.data)
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 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
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] create dataframe using structure ()

2014-03-13 Thread Rui Barradas

Hello,

You're misplacing one close parenthesis. See the commented lines below.


structure(list(
column_1 = 1:32,
column_2 = structure(c(1, 2, 3, 4, 5, 6, 7, 8,
1, 2, 3, 4, 5, 6, 7, 8,
1, 2, 3, 4, 5, 6, 7, 8,
1, 2, 3, 4, 5, 6, 7, 8),
.Label =
c(Unstimulated, ESAT6, CFP10, Rv3615c, Rv2654, Rv3879,
Rv3873, PHA),
class = factor),
column_3 =
structure(c(1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3,
3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4), .Label = c(bd, 2m, 1m,
0.5m), class = factor),
column_4 =
c(71.62097178, 2.892223468, 144.8618621, 40.90079262, 37.0516856,
32.78206822, 72.44424152, 1512.516293, 3164.748333, 1092.634557,
28733.20269, 1207.87783, 729.6090973, 151.8706088, 241.2466141,
9600.963594, 682.865522, 5869.375226, 554.8924896, 2982.759858,
7690.028092, 40.37298719, 942.3549279, 3403.679967, 103.9862389,
35.28562613, 321.5985377, 0.274424607, 3352.874906, 93.76421187,
21.3709382, 4193.183281)),  # close 2 )) here
.Names = c(row, stimulation, type, copy), row.names = c(NA,
-32L), class = data.frame)  # and only one ) after df


Hope this helps,

Rui Barradas

Em 13-03-2014 18:58, Luigi Marongiu escreveu:

dear all,
I have tried to create a dataframe using the structure() function, but it
did not really work. In column 1 i have the row number, in column 2 and 3
factors (8 and 4 levels respectively) and in column 4 the actual data.
any clue on what went wrong?
best regards
luigi

my.data-structure(list(
column_1 = 1:32,
column_2 = structure(c(1, 2, 3, 4, 5, 6, 7, 8,
1, 2, 3, 4, 5, 6, 7, 8,
1, 2, 3, 4, 5, 6, 7, 8,
1, 2, 3, 4, 5, 6, 7, 8),
.Label =
c(Unstimulated, ESAT6, CFP10, Rv3615c, Rv2654, Rv3879,
Rv3873, PHA),
class = factor),
column_3 =
structure(c(1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3,
3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4), .Label = c(bd, 2m, 1m,
0.5m), class = factor),
column_4 =
c(71.62097178, 2.892223468, 144.8618621, 40.90079262, 37.0516856,
32.78206822, 72.44424152, 1512.516293, 3164.748333, 1092.634557,
28733.20269, 1207.87783, 729.6090973, 151.8706088, 241.2466141,
9600.963594, 682.865522, 5869.375226, 554.8924896, 2982.759858,
7690.028092, 40.37298719, 942.3549279, 3403.679967, 103.9862389,
35.28562613, 321.5985377, 0.274424607, 3352.874906, 93.76421187,
21.3709382, 4193.183281),
.Names = c(row, stimulation, type, copy), class = data.frame))
attach(my.data)

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
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
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 bug on survival library Windows 7

2014-03-13 Thread Ben Bolker
CASTELLI christel christel.CASTELLI at chu-nimes.fr writes:

 
 Dear All,
 
 I have updated my OS - Windows 7, and I found a 
 situation where R stops working
 with reported error R for Windows GUI front-end has 
 stopped working.  My script worked before (on windows XP).
 
 The error occured when I perform this:
 
 coxph(Surv(time,event)~F11_rs2036914+frailty(n), data=base)
 
 from survival library.
 
 If I delete the specification frailty(n) this works! But I have clustered
data and need this specification.
 
 Here is my system information:
 R version 3.0.2 (2013-09-25)
 Platform: x86_64-w64-mingw32/x64 (64-bit)
 locale:
 [1] LC_COLLATE=French_France.1252  LC_CTYPE=French_France.1252
 [3] LC_MONETARY=French_France.1252 LC_NUMERIC=C
 [5] LC_TIME=French_France.1252
 attached base packages:
 [1] stats graphics  grDevices utils datasets  methods   base
 
 Do someone meet this problem?
 
 Anyone has some idea how to avoid this crash in Windows 7 system?
 
 Note that I can't go back on windows XP because 
 my institution do the choice of windows 7.
 
 Sincerely,
 
 Christel Castelli, PhD
 Ingénieur biostatisticien
 Responsable de la cellule médico-économie
 Département BESPIM
 CHU de Nîmes
 
 
  You may get lucky and discover that someone else has seen a very
similar symptom, but it is very most likely that you will have to
produce a reproducible example http://tinyurl.com/reproducible-000.
That means that (1) you provide data, or simulated data, that
(2) reliably produces this crash in a clean session on your machine
(for some kinds of bugs the best you can do may be if I run this
1000 times in succession it almost always crashes) (3) can produce
this crash on someone else's machine (same version of R, same OS,
perhaps the same locale).

  Googling for this problem suggests it may be a memory exhaustion
issue: http://r.789695.n4.nabble.com/
  r-for-windows-gui-front-end-has-stopped-working-td459.html

(broken URL)

  How much memory do you have, how big is your data set?

__
R-help@r-project.org mailing list
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] creating table with sequences of numbers based on the table

2014-03-13 Thread Dennis Murphy
Less coding with plyr:

tab - read.table(text=pop Freq
1   1   30
2   2   25
3   3   30
4   4   30
5   5   30
6   6   30
7   7   30,sep=,header=TRUE)

# Function to do the work on each row
f - function(pop, Freq) data.frame(ind = seq_len(Freq))

library(plyr)
u - mdply(tab, f)[, -2]

Dennis

On Thu, Mar 13, 2014 at 8:01 AM, arun smartpink...@yahoo.com wrote:
 Hi,
 Try:
 Either

 tab - read.table(text=pop Freq
 1   1   30
 2   2   25
 3   3   30
 4   4   30
 5   5   30
 6   6   30
 7   7   30,sep=,header=TRUE)

 indx - rep(1:nrow(tab),tab$Freq)
 tab1 - transform(tab[indx,],ind=ave(seq_along(indx),indx,FUN=seq_along))[,-2]
 #or
 tab2 -  transform(tab[indx,],ind=unlist(sapply(tab$Freq,seq)))[,-2]
 identical(tab1,tab2)
 #[1] TRUE
 #or
 tab3 - transform(tab[indx,], ind= 
 with(tab,seq_len(sum(Freq))-rep(cumsum(c(0L,Freq[-length(Freq)])),Freq)))[,-2]
 identical(tab1,tab3)
 #[1] TRUE

 A.K.


 I have a problem with transfering one table to another automatically. From 
 table like this:

 tab
   pop Freq
 1   1   30
 2   2   25
 3   3   30
 4   4   30
 5   5   30
 6   6   30
 7   7   30

 I want to use number of individuals (freq) and then in next
 table just list them with following numbers (depending on total number
 of individuals)
 Like this:
 in
 popind

 1  1
 1  2
 1  3
 1  4
 .   .
 .   .
 1  30
 2  1
 2  2
 2  3
 2  4
 .   .
 2  25
 3  1
 3  2
 .   .
 .   .

 How can i do it? I think i have to use loops but so far I failed.
 Thank you in advance,
 Best,
 Malgorzata Gazda

 __
 R-help@r-project.org mailing list
 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
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] creating table with sequences of numbers based on the table

2014-03-13 Thread Arunkumar Srinivasan
I think this'll be way simpler and also faster:

ans - data.frame(pop = rep.int(tab$pop, tab$Freq), ind=sequence(tab$Freq))

Arun

From: Dennis Murphy djmu...@gmail.com
Reply: Dennis Murphy djmu...@gmail.com
Date: March 13, 2014 at 9:57:20 PM
To: arun smartpink...@yahoo.com
Cc: R help r-help@r-project.org
Subject:  Re: [R] creating table with sequences of numbers based on the table  

Less coding with plyr:  

tab - read.table(text=pop Freq  
1 1 30  
2 2 25  
3 3 30  
4 4 30  
5 5 30  
6 6 30  
7 7 30,sep=,header=TRUE)  

# Function to do the work on each row  
f - function(pop, Freq) data.frame(ind = seq_len(Freq))  

library(plyr)  
u - mdply(tab, f)[, -2]  

Dennis  

On Thu, Mar 13, 2014 at 8:01 AM, arun smartpink...@yahoo.com wrote:  
 Hi,  
 Try:  
 Either  
  
 tab - read.table(text=pop Freq  
 1 1 30  
 2 2 25  
 3 3 30  
 4 4 30  
 5 5 30  
 6 6 30  
 7 7 30,sep=,header=TRUE)  
  
 indx - rep(1:nrow(tab),tab$Freq)  
 tab1 - 
 transform(tab[indx,],ind=ave(seq_along(indx),indx,FUN=seq_along))[,-2]  
 #or  
 tab2 - transform(tab[indx,],ind=unlist(sapply(tab$Freq,seq)))[,-2]  
 identical(tab1,tab2)  
 #[1] TRUE  
 #or  
 tab3 - transform(tab[indx,], ind= 
 with(tab,seq_len(sum(Freq))-rep(cumsum(c(0L,Freq[-length(Freq)])),Freq)))[,-2]
   
 identical(tab1,tab3)  
 #[1] TRUE  
  
 A.K.  
  
  
 I have a problem with transfering one table to another automatically. From 
 table like this:  
  
 tab  
 pop Freq  
 1 1 30  
 2 2 25  
 3 3 30  
 4 4 30  
 5 5 30  
 6 6 30  
 7 7 30  
  
 I want to use number of individuals (freq) and then in next  
 table just list them with following numbers (depending on total number  
 of individuals)  
 Like this:  
 in  
 pop ind  
  
 1 1  
 1 2  
 1 3  
 1 4  
 . .  
 . .  
 1 30  
 2 1  
 2 2  
 2 3  
 2 4  
 . .  
 2 25  
 3 1  
 3 2  
 . .  
 . .  
  
 How can i do it? I think i have to use loops but so far I failed.  
 Thank you in advance,  
 Best,  
 Malgorzata Gazda  
  
 __  
 R-help@r-project.org mailing list  
 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  
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
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 get the adjusted R squared from GLS() estimator

2014-03-13 Thread Greg Snow
Well if I had it and you asked nicely, then I would be happy to give
it to you.  Oh, you mean the gls function, not GLS as my initials (my
parents are OLS and WLS, perhaps I was destined to regress), sorry.

The gls function in the nlme package (is that the one that you are
asking about? or is there another gls function?) fits using maximum
likelihood (or restricted maximum likelihood) rather than looking at
sums of squares, so an adjusted r-squared is not a direct result like
in ordinary least squares.  The idea of r-squared does not really
translate well to models beyond ordinary least squares (see
fortune(252), fortune(253), and fortune(254)), so adjusted r-squared
would not either.

There are other measures of overall model fit that penalize or adjust
for the number of terms in the model, e.g. AIC and BIC, perhaps one of
those would be better for what you are trying to accomplish.

One possibility would be to square the correlation between the
original y-values and the predicted y-values (y-hats) as an estimate
of r-squared, then apply the same adjustment
(http://en.wikipedia.org/wiki/Adjusted_R-squared#Adjusted_R2), but
there is no guarantee that it has the same effect for the generalized
model (might be an interesting project for a student to look at this
by simulation).  I would suggest looking into AIC or BIC instead.

On Thu, Mar 13, 2014 at 9:59 AM, Yuan, Rebecca
rebecca.y...@bankofamerica.com wrote:
 Hello,

 Although lm() gives a way to get the adjusted R squared by

 adjr2  - summary(mdl)$adj.r.squared


 I cannot find a way to extract the adjusted R squared from gls(), any hint?

 Thanks,

 Rebecca

 --
 This message, and any attachments, is for the intended...{{dropped:14}}

__
R-help@r-project.org mailing list
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] creating table with sequences of numbers based on the table

2014-03-13 Thread William Dunlap
Or use sequence() and rep(), as in
  u1 - with(tab, data.frame(pop=rep(pop,Freq), ind=sequence(Freq)))
I think that u1 is the same as your u.

Bill Dunlap
TIBCO Software
wdunlap tibco.com


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
 Behalf
 Of Dennis Murphy
 Sent: Thursday, March 13, 2014 1:55 PM
 To: arun
 Cc: R help
 Subject: Re: [R] creating table with sequences of numbers based on the table
 
 Less coding with plyr:
 
 tab - read.table(text=pop Freq
 1   1   30
 2   2   25
 3   3   30
 4   4   30
 5   5   30
 6   6   30
 7   7   30,sep=,header=TRUE)
 
 # Function to do the work on each row
 f - function(pop, Freq) data.frame(ind = seq_len(Freq))
 
 library(plyr)
 u - mdply(tab, f)[, -2]
 
 Dennis
 
 On Thu, Mar 13, 2014 at 8:01 AM, arun smartpink...@yahoo.com wrote:
  Hi,
  Try:
  Either
 
  tab - read.table(text=pop Freq
  1   1   30
  2   2   25
  3   3   30
  4   4   30
  5   5   30
  6   6   30
  7   7   30,sep=,header=TRUE)
 
  indx - rep(1:nrow(tab),tab$Freq)
  tab1 - 
  transform(tab[indx,],ind=ave(seq_along(indx),indx,FUN=seq_along))[,-2]
  #or
  tab2 -  transform(tab[indx,],ind=unlist(sapply(tab$Freq,seq)))[,-2]
  identical(tab1,tab2)
  #[1] TRUE
  #or
  tab3 - transform(tab[indx,], ind= 
  with(tab,seq_len(sum(Freq))-rep(cumsum(c(0L,Freq[-
 length(Freq)])),Freq)))[,-2]
  identical(tab1,tab3)
  #[1] TRUE
 
  A.K.
 
 
  I have a problem with transfering one table to another automatically. From 
  table like
 this:
 
  tab
pop Freq
  1   1   30
  2   2   25
  3   3   30
  4   4   30
  5   5   30
  6   6   30
  7   7   30
 
  I want to use number of individuals (freq) and then in next
  table just list them with following numbers (depending on total number
  of individuals)
  Like this:
  in
  popind
 
  1  1
  1  2
  1  3
  1  4
  .   .
  .   .
  1  30
  2  1
  2  2
  2  3
  2  4
  .   .
  2  25
  3  1
  3  2
  .   .
  .   .
 
  How can i do it? I think i have to use loops but so far I failed.
  Thank you in advance,
  Best,
  Malgorzata Gazda
 
  __
  R-help@r-project.org mailing list
  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
 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
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] creating table with sequences of numbers based on the table

2014-03-13 Thread David Carlson
I think we're down to counting the number of characters in each
solution! Arun's 3 two-line versus your two-line solution (not
counting loading plyr). How about three short lines?

pop - rep(1:nrow(tab), tab$Freq)
ind - unlist(sapply(tab$Freq, seq_len))
tab2 - data.frame(pop, ind)

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

-Original Message-
From: r-help-boun...@r-project.org
[mailto:r-help-boun...@r-project.org] On Behalf Of Dennis Murphy
Sent: Thursday, March 13, 2014 3:55 PM
To: arun
Cc: R help
Subject: Re: [R] creating table with sequences of numbers based
on the table

Less coding with plyr:

tab - read.table(text=pop Freq
1   1   30
2   2   25
3   3   30
4   4   30
5   5   30
6   6   30
7   7   30,sep=,header=TRUE)

# Function to do the work on each row
f - function(pop, Freq) data.frame(ind = seq_len(Freq))

library(plyr)
u - mdply(tab, f)[, -2]

Dennis

On Thu, Mar 13, 2014 at 8:01 AM, arun smartpink...@yahoo.com
wrote:
 Hi,
 Try:
 Either

 tab - read.table(text=pop Freq
 1   1   30
 2   2   25
 3   3   30
 4   4   30
 5   5   30
 6   6   30
 7   7   30,sep=,header=TRUE)

 indx - rep(1:nrow(tab),tab$Freq)
 tab1 -
transform(tab[indx,],ind=ave(seq_along(indx),indx,FUN=seq_along)
)[,-2]
 #or
 tab2 -
transform(tab[indx,],ind=unlist(sapply(tab$Freq,seq)))[,-2]
 identical(tab1,tab2)
 #[1] TRUE
 #or
 tab3 - transform(tab[indx,], ind=
with(tab,seq_len(sum(Freq))-rep(cumsum(c(0L,Freq[-length(Freq)])
),Freq)))[,-2]
 identical(tab1,tab3)
 #[1] TRUE

 A.K.


 I have a problem with transfering one table to another
automatically. From table like this:

 tab
   pop Freq
 1   1   30
 2   2   25
 3   3   30
 4   4   30
 5   5   30
 6   6   30
 7   7   30

 I want to use number of individuals (freq) and then in next
 table just list them with following numbers (depending on
total number
 of individuals)
 Like this:
 in
 popind

 1  1
 1  2
 1  3
 1  4
 .   .
 .   .
 1  30
 2  1
 2  2
 2  3
 2  4
 .   .
 2  25
 3  1
 3  2
 .   .
 .   .

 How can i do it? I think i have to use loops but so far I
failed.
 Thank you in advance,
 Best,
 Malgorzata Gazda

 __
 R-help@r-project.org mailing list
 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
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
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] centroid of diamond

2014-03-13 Thread Rolf Turner


Your question makes absolutely no sense at all.  See inline below.

On 14/03/14 08:03, al Vel wrote:

Hello R users,
I am trying to make a baricentric diagram like the ternary plot, but with 4
edges. I want to know how to calculate the centroid of the diamond.


Which centroid?  A diamond (convex quadrilateral?) has 3 well defined 
centroids, in general all different.



The 4 edges are A, B, C, D.


Are A, B, C, and D the *lengths* of the edges?  Or are they just labels 
for the edges?



If value of A=B=C=D, then the point should be at the
centre of the diamond. If AB and B=C=D=0,


Since we are apparently talking about numerical values here it would 
seem that A, B, C, and D are the lengths of the sides.  How can you have 
a diamond (convex quadrilateral?) with 3 sides of length 0 and the 
other non-zero?



Then the point should be at the corner of A.


What ***on earth*** does the corner of A mean?


For diamond, how to convert the value of A,B,C,D into cartesian
co-ordinates ?. if x1,x2,y1,y2 are A,B,C,D, then someone suggested:

   new_point - function(x1, x2, y1, y2, grad=1.73206){
 b1 - y1-(grad*x1)
 b2 - y2-(-grad*x2)
 M - matrix(c(grad, -grad, -1,-1), ncol=2)
 intercepts - as.matrix(c(b1,b2))
 t_mat - -solve(M) %*% intercepts
 data.frame(x=t_mat[1,1], y=t_mat[2,1])
   }
But this is not working. Please do suggest some help.


Try using Google.  Wikipedia has a good article on quadrilaterals and 
outlines a procedure for finding the area centroid (I presume that's 
what you actually want) of a convex quadrilateral.


cheers,

Rolf Turner

__
R-help@r-project.org mailing list
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] create dataframe using structure ()

2014-03-13 Thread arun
Hi,
Try:
 my.data - structure(list(column_1 = 1:32, 
column_2 = structure(c(1, 2, 3, 4, 5, 6, 7, 8,
1, 2, 3, 4, 5, 6, 7, 8,
1, 2, 3, 4, 5, 6, 7, 8,
1, 2, 3, 4, 5, 6, 7, 8), .Label = c(Unstimulated, ESAT6, CFP10, 
Rv3615c, Rv2654, Rv3879,
Rv3873, PHA), class = factor),
column_3= structure(c(1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3,
3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4), .Label = c(bd, 2m, 1m,
0.5m), class = factor),
column_4 = structure(c(71.62097178, 2.892223468, 144.8618621, 40.90079262, 
37.0516856,
32.78206822, 72.44424152, 1512.516293, 3164.748333, 1092.634557,
28733.20269, 1207.87783, 729.6090973, 151.8706088, 241.2466141,
9600.963594, 682.865522, 5869.375226, 554.8924896, 2982.759858,
7690.028092, 40.37298719, 942.3549279, 3403.679967, 103.9862389,
35.28562613, 321.5985377, 0.274424607, 3352.874906, 93.76421187,
21.3709382, 4193.183281))), .Names = c(row, stimulation, type, copy), 
row.names= c(NA,-32L), class = data.frame)

str(my.data)
'data.frame':    32 obs. of  4 variables:
 $ row    : int  1 2 3 4 5 6 7 8 9 10 ...
 $ stimulation: Factor w/ 8 levels Unstimulated,..: 1 2 3 4 5 6 7 8 1 2 ...
 $ type   : Factor w/ 4 levels bd,2m,1m,..: 1 1 1 1 1 1 1 1 2 2 ...
 $ copy   : num  71.62 2.89 144.86 40.9 37.05 ...

A.K.


dear all, 
I have tried to create a dataframe using the structure() function, but it 
did not really work. In column 1 i have the row number, in column 2 and 3 
factors (8 and 4 levels respectively) and in column 4 the actual data. 
any clue on what went wrong? 
best regards 
luigi 

my.data-structure(list( 
column_1 = 1:32, 
column_2 = structure(c(1, 2, 3, 4, 5, 6, 7, 8, 
1, 2, 3, 4, 5, 6, 7, 8, 
1, 2, 3, 4, 5, 6, 7, 8, 
1, 2, 3, 4, 5, 6, 7, 8), 
.Label = 
c(Unstimulated, ESAT6, CFP10, Rv3615c, Rv2654, Rv3879, 
Rv3873, PHA), 
class = factor), 
column_3 = 
structure(c(1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 
3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4), .Label = c(bd, 2m, 1m, 
0.5m), class = factor), 
column_4 = 
c(71.62097178, 2.892223468, 144.8618621, 40.90079262, 37.0516856, 
32.78206822, 72.44424152, 1512.516293, 3164.748333, 1092.634557, 
28733.20269, 1207.87783, 729.6090973, 151.8706088, 241.2466141, 
9600.963594, 682.865522, 5869.375226, 554.8924896, 2982.759858, 
7690.028092, 40.37298719, 942.3549279, 3403.679967, 103.9862389, 
35.28562613, 321.5985377, 0.274424607, 3352.874906, 93.76421187, 
21.3709382, 4193.183281), 
.Names = c(row, stimulation, type, copy), class = data.frame)) 
attach(my.data)

__
R-help@r-project.org mailing list
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] boxplot with x-axis time

2014-03-13 Thread giuseppe calamita
Dear R-users,
I want to plot boxplots of a single variable collected a few times during 
almost one year and I would like the x-axis to recognize the date-class of the 
variable.

I found some topics in the archive but:
- some questions were poorly posed 
(http://r.789695.n4.nabble.com/Boxplot-with-dates-td896401.html)  and so with 
no answer; 
- others, only address the topic of have the date on the x-axes ordered 
(http://r.789695.n4.nabble.com/Using-boxplot-in-a-daily-time-series-td843060.html#a843061);
- finally, another topic 
(http://r.789695.n4.nabble.com/Boxplot-position-on-X-axis-relative-to-it-s-value-td2196020.html)is
 quite close to what I need but it is not exactly the same.

I attached a simulated data.frame: it 2-column, the1-st are date and the 2-nd 
is the variable.
Here the code I use: 

pippo- read.csv(pippo.csv)
pippo$date- as.Date(pippo$date, format=%Y-%m-%d)

boxplot(V ~ date, data=pippo)

I would like that the x-axis look like in this plot
plot(V ~ date, data=pippo)
where the thick reproduce the right time of the year .

Thank you for your help__
R-help@r-project.org mailing list
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] Creating a box plot with whiskers when I only have mean, sd and n

2014-03-13 Thread Frederik Borup
Dear all,

I want to create a boxplot with whiskers. I want to compare several
studies. For each study I have

   1. mean
   2. standard deviation (sd)
   3. name
   4. number of observations (n)

How can i do this in R ?

normally I would type
 bxp
or
boxplot

but this is not allowed when I only know mean and sd


-- 
Frederik Borup

MD, Ph.D.-stud.

Accident Analysis Group (UAG)

The Department of Orthopaedic Surgery, Odense University Hospital (OUH)

The Department of Orthopaedic Surgery, SLB Kolding

University of Southern Denmark (SDU)

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
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] Negative binomial models and censored observations

2014-03-13 Thread Tim Marcella
Hi,

I am working with hurdle models in the pscl package to model zero inflated
overdispersed count data and want to incorporate censored observations into
the equation. 33% of the observed positive count data is right censored,
i.e. subject lost to follow up during the duration of the study. Can this
be accounted for in the hurdle() function?

Thanks, Tim

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
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] Creating a box plot with whiskers when I only have mean, sd and n

2014-03-13 Thread Rolf Turner

On 14/03/14 08:52, Frederik Borup wrote:

Dear all,

I want to create a boxplot with whiskers. I want to compare several
studies. For each study I have

1. mean
2. standard deviation (sd)
3. name
4. number of observations (n)

How can i do this in R ?

normally I would type

bxp

or

boxplot


but this is not allowed when I only know mean and sd.


(1) Read the help for bxp.
(2) Think about what you want your box and whiskers to *represent* given 
that you only know the summary statistics.  (Is it *really* meaningful 
to create a boxplot in such circumstances?)
(3) If you can figure that out, then create an appropriate argument (a 
list) for bxp() and call bxp() with that argument.


cheers,

Rolf Turner

__
R-help@r-project.org mailing list
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] GLM vs GAM

2014-03-13 Thread Ehsan Karim
Dear R-list,

I am wondering whether anyone could explain what'd be the difference between 
running a 'generalized additive regression' versus 'generalized linear 
regression' with splines. 

Are they same models theoretically? My apologies if this is a silly question. 
Any comments or direction to references will be highly appreciated.

Thanks in advance,

Ehsan


#
set.seed(545)
require(mgcv)
n - 200
x1 - c(rnorm(n), 1+rnorm(n))
x2 - sqrt(c(rnorm(n,4),rnorm(n,6)))
y - c(rep(0,n), rep(1,n))
#
# GAM version
#
r1 - gam(y~s(x1, bs = cr)+s(x2, bs = cr),family=binomial)
pr1 - predict(r1, type='response')
summary(pr1)
hist(pr1)
#
# GLM version
#
r2 - glm(y~ns(x1)+ns(x2),family=binomial)
pr2 - predict(r2, type='response')
summary(pr2)
hist(pr2)
#
# Results
#
 summary(pr1)
     Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
0.394 0.0550200 0.5027000 0.500 0.9322000 1.000 
 summary(pr2)
     Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
0.403 0.0573300 0.5229000 0.500 0.9159000 0.9992000 
  
__
R-help@r-project.org mailing list
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] Colorspace: bug in HLS conversion?

2014-03-13 Thread Michael Gauland
Achim Zeileis Achim.Zeileis at uibk.ac.at writes:
 Maybe you are using an old version of colorspace? For version 1.1-1 
 (from two years ago, version 1.2-4 is current) the NEWS file says:
 ...

That was it--thanks!

As a developer, I should know enough to check the release notes...

--Mike

__
R-help@r-project.org mailing list
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] centroid of diamond

2014-03-13 Thread Jim Lemon

On 03/14/2014 06:03 AM, al Vel wrote:

Hello R users,
I am trying to make a baricentric diagram like the ternary plot, but with 4
edges. I want to know how to calculate the centroid of the diamond. The 4
edges are A, B, C, D. If value of A=B=C=D, then the point should be at the
centre of the diamond. If AB and B=C=D=0, Then the point should be at the
corner of A.

For diamond, how to convert the value of A,B,C,D into cartesian
co-ordinates ?. if x1,x2,y1,y2 are A,B,C,D, then someone suggested:

   new_point- function(x1, x2, y1, y2, grad=1.73206){
 b1- y1-(grad*x1)
 b2- y2-(-grad*x2)
 M- matrix(c(grad, -grad, -1,-1), ncol=2)
 intercepts- as.matrix(c(b1,b2))
 t_mat- -solve(M) %*% intercepts
 data.frame(x=t_mat[1,1], y=t_mat[2,1])
   }
But this is not working. Please do suggest some help.
thanks and best regards,
Alaguraj.V


Hi Alaguraj,
A lot depends upon what you mean by diamond. A rhombus is out because 
you say that the lengths of the sides can be different (and as you note, 
the answer is easy). If you mean a parallelogram (opposite sides are 
equal) the answer is also easy, the intersection of the lines joining 
opposite vertices. If you mean a kite (sides of equal length are 
adjacent) it is a matter of finding the point along the line joining the 
two vertices that join the two sets of equal sides. I suspect that what 
you have to calculate is the centroid of a quadrilateral with arbitrary 
length sides. We can probably assume that it is convex, as Rolf noted, 
as the centroid may be outside quadrilaterals that are very concave 
(think boomerang, sport). So if you could tell us a bit more about what 
constraints you wish to place on your quadrilateral, somebody may be 
able to help.


Jim

__
R-help@r-project.org mailing list
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] Creating a box plot with whiskers when I only have mean, sd and n

2014-03-13 Thread Jim Lemon

On 03/14/2014 06:52 AM, Frederik Borup wrote:

Dear all,

I want to create a boxplot with whiskers. I want to compare several
studies. For each study I have

1. mean
2. standard deviation (sd)
3. name
4. number of observations (n)

How can i do this in R ?

normally I would type

bxp

or

boxplot


but this is not allowed when I only know mean and sd



Hi Frederik,
You may want box.heresy in the plotrix package.

Jim

__
R-help@r-project.org mailing list
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.