Re: [R] R plot-par(mfrow=c(x,y)) on multiple pages

2016-01-20 Thread Mohsen Jafarikia
Dear Jim,

Your wild guess was a good guess :=)

Thanks to you and Sarah for your comments.

Regards,
Mohsen


On Wed, Jan 20, 2016 at 6:08 PM, Jim Lemon  wrote:
> Hi Mohsen,
> I'll have a wild guess at this. I suspect that you have either calculated a
> value for the ylim= argument or used explicit values for ylim= in the first
> plot, then propagated the error by copying and pasting.
>
> Jim
>
> On Thu, Jan 21, 2016 at 8:56 AM, Mohsen Jafarikia 
> wrote:
>>
>> Thanks very much for the comment.
>>
>> I was also wondering why all the y-axis on all 12 plots are similar to
>> the first plot. I have 12 plots and scale of the values for these
>> plots are different. It seems R is using the x-axis for each
>> individual plot correctly but y-axis is the same for all 12 graphs.
>>
>> Regards,
>> Mohsen
>>
>>
>

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


[R] strange answer when using 'aggregate()' with a formula

2016-01-20 Thread Chel Hee Lee
Could you kindly test the following codes?  It is because I found 
strange answer when 'aggregate()' is used with a formula.


I am trying to count how many missing data entries are in each group.  
For this exercise, I created data as below:


> tmp <- data.frame(grp=c(2,3,2,3), y=c(NA, 0.5, 3, 0.5))
> tmp
  grp   y
1   2  NA
2   3 0.5
3   2 3.0
4   3 0.5

I see that observations (variable y) can be grouped into two groups 
(variable grp).  For group 2, y has NA and 3.0.  For group 3, y has 0.5 
and 0.5.  Hence, the number of missing values is 1 and 0 for group 2 and 
3, respectively.   This work can be done using 'aggregate()' in the 
'stats' package as below:


> aggregate(x=tmp$y, by=list(grp=tmp$grp), function(x) sum(is.na(x)))
  grp x
1   2 1
2   3 0

A formula can be used as below:

> aggregate(y~grp, data=tmp, function(x) sum(is.na(x)))
  grp y
1   2 0
2   3 0

What a surprise!  Is this a bug?  I would appreciate if you share the 
results after testing the codes.   Thank you so much for your helps in 
advance!


Chel Hee Lee

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


[R] tcltk: write '[' and ']' in a table cell

2016-01-20 Thread Dalthorp, Daniel
I know it should not be difficult to write the string:

i<-4
j<-17
lbl<-paste0("[", i, ", ", j, "]")

# to a table, but I'm having a devil of a time trying to figure out how to
do it.
# the following gives lbl surrounded by braces.

tt<-tktoplevel()
tfr <- tkframe(tt)
tkgrid(tfr)
junk<-tclArray()
junk[[0,0]]<-lbl
table1<-tkwidget(tfr,"table", rows=1, cols=1, variable=junk)
tkgrid(table1)


How to write without the braces?

Any quick suggestions would be very much appreciated...I've burned much
time trying to figure this should-be-simple problem out.

Thanks!



-- 
Dan Dalthorp, PhD
USGS Forest and Rangeland Ecosystem Science Center
Forest Sciences Lab, Rm 189
3200 SW Jefferson Way
Corvallis, OR 97331
ph: 541-750-0953
ddalth...@usgs.gov

[[alternative HTML version deleted]]

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


Re: [R] Fwd:

2016-01-20 Thread Jim Lemon
Hi maryam,
I think you have just restricted yourself to zero and negative numbers for
the new cases. Well, I suppose there are imaginary numbers...

Jim


On Thu, Jan 21, 2016 at 8:26 AM, maryam firoozi via R-help <
r-help@r-project.org> wrote:

> Hello,
> i made a population about 4500 individual.this has two sex(female and
> male).they had pedigree.
> i wanted to enter new indiviual but their ID of indiviual mustnot be same
> perivous and their ID number mustnot be bigger than 4500.
> first population's ID number is 1:4500.
> how can i handel it?
>
> Sent from my iPhone
>
> Begin forwarded message:
>
> > From: maryam firoozi 
> > Date: January 18, 2016 at 1:14:56 AM GMT+3:30
> > To: r-help@r-project.org
> >
> > hello,
> > we want to do genomic blup in r.i know that use pedigree package.
> > the formule is
> > gblup( P~1,data=ped[,c('ID','P')],M=M,lambda=1/h2-1)
> > P:phenotype variance
> > ped:pedigree
> > M: matrix marker or genotype
> > my ped has 4500 ID.but my M has 9000 individual.becasue i have two row
> for each ID in M matrix becasue each ID has two haplotype.how can i solve
> it.the formula didnt solve.
> > sincerely
> >
> >
> > Sent from my iPhone
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


Re: [R] Splitting strings in data files R

2016-01-20 Thread David Winsemius

> On Jan 20, 2016, at 3:33 PM, Zilefac Elvis  wrote:
> 
> I did not want to include attachments but as they are requested I am 
> attaching the original files.
> File1=dx701S001
> 
> File2= dt402DAF0

These are fixed width files. The "upper-left corner of the file looks like this 
in a text editor:

402DAF0,LEADER AIRPORT   ,SK,station joined,Daily adjusted 
precipitation, mm, Updated to December 2014
1923  1 
-.99M-.99M-.99M-.99M-.99M-.99M-.99M-.99M-.99M-.99M-.99M-.99M-
1923  2 
-.99M-.99M-.99M-.99M-.99M-.99M-.99M-.99M-.99M-.99M-.99M-.99M-
1923  3 
-.99M-.99M-.99M-.99M-.99M-.99M-.99M-.99M-.99M-.99M-.99M-.99M-
1923  4 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 
0.00 0.00 0.00 0.00  
1923  5 0.00 0.00 0.00 0.0010.83 0.00 0.00 0.00 
0.00 0.00 0.00 0.00  
1923  6 6.87 0.00 0.00 0.00 0.00 0.00 5.52 0.00 
0.00 0.00 0.00 0.00  
1923  7 0.00 0.00 0.00 0.00 2.09 0.00 7.91 1.57 
3.65 0.00 0.00 0.00  
1923  8 0.00 0.00 0.00 0.00 0.00 0.00 0.00 8.12 
0.00 0.00 0.00 0.00  
1923  9 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 
0.00 0.00 0.00 0.00  
1923 10 0.00 0.00 0.00 0.00 0.00 0.00 0.00 4.17 
0.00 0.00 0.00 0.00  
1923 11 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 
0.00 0.00 0.00 0.00  
1923 12 0.11T0.00 0.00 0.00 0.00 0.00 0.00 0.00 
0.00 0.00 0.00 0.00  
1924  1 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 
0.00 0.00 6.27 0.00  
1924  2 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 
0.00 0.00 0.00 0.00  

So the convention of the file authors is to define location boundaries for 
numeric values (eight characters wide, after the first two) and then the 
interleaved columns (one character wide) are some sort of annotation. You can 
see two such annotation types here but I can see several others (T,A,C at the 
very least) in a text editor. One is clearly "M" for missing and the other that 
can be seen here is "T" of unknown import. Clearly -.99 is a missing value.

You need to use the read.fwf function in package foreign (shipped with every 
full copy of R). It's possible that you also want to loop through these files 
with readLines just to get the first line, but it's clearly not a column header 
line.

-- 
David.

> 
> I read them into R using:
> 
> temp1 = list.files(pattern="*.txt") # list all text file names in your 
> working directory 
> myfiles = lapply(temp1, read.delim)# 
> 
> The started processing them with:
> 
> res<-lapply(temp1,function(x) {con <- file(x);Lines1<- 
> readLines(con);close(con); 
> Lines2<-Lines1[-1]; 
> Lines3<- str_split(Lines2,"-.99M")})
> 
> Thanks
> AT
> 
> 
> 
> 
> 
> 
> On Wednesday, January 20, 2016 4:47 PM, David Winsemius 
>  wrote:
> 
>> On Jan 20, 2016, at 12:53 PM, Zilefac Elvis via R-help 
>>  wrote:
>> 
>> 
>> 
>> 
>> Please I need help processing  files with strings in R. All the files have 
>> two patterns (thus,examine separately):
> 
> You do need help, that much is clear. But the first thing to do is retrace 
> your initial data-entry steps. You have used the wrong read-function. The 
> data in the input file either whitespace-separated (or fixed width format and 
> you apparently thought it was a CSV-file.
> 
> Asking us to no work with this mess is just unreasonable. Post the original 
> input file.
> 
> -- 
> David.
> 
> 
>> Pattern 1 (see file1 below): Delete Lines 1,2 & 4 in file1. Line 3 contains 
>> the column names. Then find anything as.character and delete. Please do not 
>> delete any values (e.g. delete T in 0.21T). Also find -999.99M,-999.99 and 
>> replace with with NA.
>> 
>> File1 output format should be: Year Month Day_1 Day_2 ... Day_31  ## so all 
>> months should 31 days. Months with <31 days should have NA where appropraite 
>> (e.g. Feb 30=NA, 31=NA)
>> 
>> Pattern 2 (see file2 below): Delete Line 1 in file2.Then find anything 
>> as.character and delete. Please do not delete any values (e.g. delete T in 
>> 0.21T). Also find -999.99M,-999.99 and replace with withNA. File2 has no 
>> column names. Please do not include any. 
>> File2 output format: Year Month Day_1 Day_2 ... Day_31 but no column names
>> 
>> Here is a simple reproducible example for both files/cases: 
>> 
>> 
>> 

Re: [R] R editor for Mac

2016-01-20 Thread Sandeep Rana
Christopher,
Download TextWrangler from App store. I’m using it and its very convenient.

Regards,
Sunny


> On 20-Jan-2016, at 11:52 PM, Christofer Bogaso  
> wrote:
> 
> Hi,
> 
> Could you please suggest a good R editor for Mac OS X (10.7.5)
> Previously my operating system was Windows and there I used Notepad++,
> I really had very nice experience with it. However I dont see any Mac
> version is available for Mac.
> 
> Appreciate your positive feedback.
> 
> Thanks and regards,
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.


[[alternative HTML version deleted]]

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

[R] Fwd:

2016-01-20 Thread maryam firoozi via R-help
Hello,
i made a population about 4500 individual.this has two sex(female and 
male).they had pedigree.
i wanted to enter new indiviual but their ID of indiviual mustnot be same 
perivous and their ID number mustnot be bigger than 4500.
first population's ID number is 1:4500.
how can i handel it?

Sent from my iPhone

Begin forwarded message:

> From: maryam firoozi 
> Date: January 18, 2016 at 1:14:56 AM GMT+3:30
> To: r-help@r-project.org
> 
> hello,
> we want to do genomic blup in r.i know that use pedigree package.
> the formule is
> gblup( P~1,data=ped[,c('ID','P')],M=M,lambda=1/h2-1)
> P:phenotype variance
> ped:pedigree
> M: matrix marker or genotype
> my ped has 4500 ID.but my M has 9000 individual.becasue i have two row for 
> each ID in M matrix becasue each ID has two haplotype.how can i solve it.the 
> formula didnt solve.
> sincerely
> 
> 
> Sent from my iPhone

[[alternative HTML version deleted]]

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


Re: [R] strange answer when using 'aggregate()' with a formula

2016-01-20 Thread Fox, John
Dear Chel Hee Lee,

With the formula method, the default na.action is na.omit; thus,

> aggregate(y~grp, data=tmp, function(x) sum(is.na(x)), na.action=na.pass)
  grp y
1   2 1
2   3 0

I hope this helps,
 John

-
John Fox, Professor
McMaster University
Hamilton, Ontario
Canada L8S 4M4
Web: socserv.mcmaster.ca/jfox


> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Chel Hee Lee
> Sent: January 21, 2016 5:08 AM
> To: R-help@r-project.org
> Subject: [R] strange answer when using 'aggregate()' with a formula
> 
> Could you kindly test the following codes?  It is because I found strange 
> answer
> when 'aggregate()' is used with a formula.
> 
> I am trying to count how many missing data entries are in each group.
> For this exercise, I created data as below:
> 
>  > tmp <- data.frame(grp=c(2,3,2,3), y=c(NA, 0.5, 3, 0.5))  > tmp
>grp   y
> 1   2  NA
> 2   3 0.5
> 3   2 3.0
> 4   3 0.5
> 
> I see that observations (variable y) can be grouped into two groups (variable
> grp).  For group 2, y has NA and 3.0.  For group 3, y has 0.5 and 0.5.  
> Hence, the
> number of missing values is 1 and 0 for group 2 and
> 3, respectively.   This work can be done using 'aggregate()' in the
> 'stats' package as below:
> 
>  > aggregate(x=tmp$y, by=list(grp=tmp$grp), function(x) sum(is.na(x)))
>grp x
> 1   2 1
> 2   3 0
> 
> A formula can be used as below:
> 
>  > aggregate(y~grp, data=tmp, function(x) sum(is.na(x)))
>grp y
> 1   2 0
> 2   3 0
> 
> What a surprise!  Is this a bug?  I would appreciate if you share the
> results after testing the codes.   Thank you so much for your helps in
> advance!
> 
> Chel Hee Lee
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] R editor for Mac

2016-01-20 Thread William Michels via R-help
Hello Christofer!

For text-editing the R.app GUI has always been fabulous. An old
mainstay on the Mac (after Apple's TextEdit) has been TextWrangler,
and its big-brother, BBEdit. For development RStudio is quite nice,
and--based partly on RStudio's offering of a Vim-compatibility
mode--Vim has become a recent interest, although it has a steep
learning curve. Of course, Vim itself is already available at the
Terminal command line, but more Mac-like version named MacVim is
available at:

https://github.com/b4winckler/macvim/releases

Further instructions on using Vim with R are available here:
http://manuals.bioinformatics.ucr.edu/home/programming-in-r/vim-r

BTW, it looks like you're using an older version of Mac OS X (Lion,
version 10.7.5) released in 2012. So some of the text editors
mentioned by others in this thread may not be their "latest and
greatest." Also, while you can run R version 3.2.1 right now (current
R version is 3.2.3), the R Mac page says "NOTE: the binary support for
OS X before Mavericks (10.9) is being phased out, we do not expect
further releases!" See:

https://cran.r-project.org/bin/macosx/

Mac OS X is now at version 10.11.4 (El Capitan). Wikipedia says some
Macs all the way back to 2007 can run El Capitan (see
https://en.wikipedia.org/wiki/OS_X_El_Capitan), so there may be an
upgrade path for you, if not all the way to El Capitan (10.11) then
maybe up to Mavericks (10.9), to keep you from having to compile
future R-versions from source. Finally, you should consider checking
out the R-Sig-Mac mailing list for further Mac-specific info:

https://stat.ethz.ch/mailman/listinfo/r-sig-mac

HTH,

Bill

W. Michels, Ph.D.


On Wed, Jan 20, 2016 at 10:22 AM, Christofer Bogaso
 wrote:

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


Re: [R] Survival::coxph (clogit), survConcordance vs. summary(fit) concordance

2016-01-20 Thread Joe Ceradini
Thanks for pointing that out, Chris. That was a thoughtless typo on my part
when I was simplifying my model for the sake of posting.

I've run a whole set of models without any problems/warning. My main
question is regarding the difference between the concordance estimate that
summary(fit) reports and the concordance estimated with survConcordance,
particularly in relation to estimating clogit model performance. Also,
whether or not I should be concerned about the giant SE estimate I get for
concordance from summary(fit). This is within the context of a 1:1
case-control study (1 case and 1 control per strata).

Corrected model:
fit <- clogit(resp ~ x1 + x2 + strata(ID) + cluster(site), method ="efron",
data = dat)
Where resp is 1's and 0's, and x1 and x2 are both continuous.

The rest of the code and output details should be in my original post.

Thanks.
Joe

On Wed, Jan 20, 2016 at 6:11 AM, Andrews, Chris 
wrote:

> I only get the digest, sorry if this has already been answered.
>
> When I run your code (after creating some data) I get a warning that
> "weights are ignored in clogit".  This is a result of miscalling the clogit
> function.  The first 2 commas should be +s.
>
> library(survival)
> nn <- 1000
> dat <- data.frame(resp = rbinom(nn, 1, 0.5), x1=rnorm(nn), x2=rnorm(nn),
> ID = rep(seq(nn/2), e=2), site = rep(seq(nn/10), e=10))
> fit <- clogit(resp ~ x1 + x2, strata(ID), cluster(site), method ="efron",
> data = dat) # warning
> fit <- clogit(resp ~ x1 + x2 + strata(ID) + cluster(site), method
> ="efron", data = dat) # no warning
> summary(fit)
>
> Chris
>
> -Original Message-
> From: Joe Ceradini [mailto:joecerad...@gmail.com]
> Sent: Tuesday, January 19, 2016 12:48 PM
> To: r-help@r-project.org
> Subject: [R] Survival::coxph (clogit), survConcordance vs. summary(fit)
> concordance
>
> Hi,
>
> I'm running conditional logistic regression with survival::clogit. I have
> "1-1 case-control" data, i.e., there is 1 case and 1 control in each
> strata.
>
> Model:
> fit <- clogit(resp ~ x1 + x2, strata(ID), cluster(site), method ="efron",
> data = dat)
> Where resp is 1's and 0's, and x1 and x2 are both continuous.
>
> Predictors are both significant. A snippet of summary(fit):
> Concordance= 0.763  (se = 0.5 )
> Rsquare= 0.304   (max possible= 0.5 )
> Likelihood ratio test= 27.54  on 2 df,   p=1.047e-06
> Wald test= 17.19  on 2 df,   p=0.0001853
> Score (logrank) test = 17.43  on 2 df,   p=0.0001644,   Robust = 6.66
>  p=0.03574
>
> The concordance estimate seems good but the SE is HUGE.
>
> I get a very different estimate from the survConcordance function, which I
> know says computes concordance for a "single continuous covariate", but it
> runs on my model with 2 continuous covariates
>
> survConcordance(Surv(rep(1, 76L), resp) ~ predict(fit), dat)
> n= 76
> Concordance= 0.9106648 se= 0.09365047
> concordant  discordant   tied.risk   tied.timestd(c-d)
>  1315.   129. 0.   703.   270.4626
>
> Are both of these concordance estimates valid but providing different
> information?
> Is one more appropriate for measuring "performance" (in the AUC sense) of
> conditional logistic models?
> Is it possible that the HUGE SE estimate represents a convergence problem
> (no warnings were thrown when fit the model), or is this model just
> useless?
>
> Thanks!
> --
> Cooperative Fish and Wildlife Research Unit
> Zoology and Physiology Dept.
> University of Wyoming
> joecerad...@gmail.com / 914.707.8506
> wyocoopunit.org
>
> [[alternative HTML version deleted]]
>
>
> **
> Electronic Mail is not secure, may not be read every day, and should not
> be used for urgent or sensitive issues
>



-- 
Cooperative Fish and Wildlife Research Unit
Zoology and Physiology Dept.
University of Wyoming
joecerad...@gmail.com / 914.707.8506
wyocoopunit.org

[[alternative HTML version deleted]]

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


Re: [R] R editor for Mac

2016-01-20 Thread Roy Mendelssohn - NOAA Federal
Hi:

Both the default Mac OS X installation of R  (with the GUI) as well as RStudio, 
have very nice editors for coding in R.

-Roy

> On Jan 20, 2016, at 10:22 AM, Christofer Bogaso  
> wrote:
> 
> Hi,
> 
> Could you please suggest a good R editor for Mac OS X (10.7.5)
> Previously my operating system was Windows and there I used Notepad++,
> I really had very nice experience with it. However I dont see any Mac
> version is available for Mac.
> 
> Appreciate your positive feedback.
> 
> Thanks and regards,
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

**
"The contents of this message do not reflect any position of the U.S. 
Government or NOAA."
**
Roy Mendelssohn
Supervisory Operations Research Analyst
NOAA/NMFS
Environmental Research Division
Southwest Fisheries Science Center
***Note new address and phone***
110 Shaffer Road
Santa Cruz, CA 95060
Phone: (831)-420-3666
Fax: (831) 420-3980
e-mail: roy.mendelss...@noaa.gov www: http://www.pfeg.noaa.gov/

"Old age and treachery will overcome youth and skill."
"From those who have been given much, much will be expected" 
"the arc of the moral universe is long, but it bends toward justice" -MLK Jr.

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


Re: [R] R editor for Mac

2016-01-20 Thread Rich Shepard

On Wed, 20 Jan 2016, Christofer Bogaso wrote:


Could you please suggest a good R editor for Mac OS X (10.7.5) Previously
my operating system was Windows and there I used Notepad++, I really had
very nice experience with it. However I dont see any Mac version is
available for Mac.


  Emacs might already be available on your system. Yes, it's complex but
worth learning. (It's been called the only editor with a built-in operating
system.) It also supports ESS which is a R mode that is very helpful.

Rich

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


[R] Simple syntax question (I think)

2016-01-20 Thread Bert Gunter
Could someone please explain to me my mal-understanding of the
following, which I expected to give the same results without errors.

TIA.

-- Bert

> z <-  list(x=1)
> z[[2]] <- 3
> z
$x
[1] 1

[[2]]
[1] 3

> list(x = 1)[[2]] <- 3
Error in list(x = 1)[[2]] <- 3 :
  target of assignment expands to non-language object
>
> sessionInfo()

R version 3.2.3 (2015-12-10)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.11.2 (El Capitan)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] utilsdatasets toolsstatsgraphics splines  grid
methods  base

other attached packages:
[1] nlme_3.1-122lattice_0.20-33

loaded via a namespace (and not attached):
[1] grDevices_3.2.3 strucplot_0.5



Bert Gunter

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

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


[R] problem of interpretation using mediation package

2016-01-20 Thread kende jan
Dear all,
I am using the package mediation in order to perform a parametric mediation
analysis on survival data. I have 8 variables:

- Mediator
- Treat
- time (days)
- death (event)
- X1-X4 (confounding variables)

I ran the following code to estimate the causal mediation effects.

med.m = lm(Mediator ~ Treat + X1 + X2 + X3 + X4)
med.y = survreg(Surv(time, death) ~ Treat + X1 + X2 + X3 + Mediator + X4)
med.out <- mediate(med.m, med.y, treat = "Treat", mediator = "Mediator")
summary(med.out)

Here are the output provided by this script:

Causal Mediation Analysis

Quasi-Bayesian Confidence Intervals

                           Estimate 95% CI Lower 95% CI Upper p-value
ACME (control)           -3.68e+02    -1.27e+03    -3.34e+01    0.01
ACME (treated)           -1.47e+02    -4.46e+02    -1.67e+01    0.01
ADE (control)            -3.76e+03    -1.18e+04    -5.93e+02    0.00
ADE (treated)            -3.54e+03    -1.14e+04    -5.53e+02    0.00
Total Effect             -3.91e+03    -1.20e+04    -6.79e+02    0.00
Prop. Mediated (control)  9.56e-02     1.55e-02     2.36e-01    0.01
Prop. Mediated (treated)  3.82e-02     7.03e-03     1.49e-01    0.01
ACME (average)           -2.57e+02    -8.36e+02    -2.46e+01    0.01
ADE (average)            -3.65e+03    -1.16e+04    -5.78e+02    0.00
Prop. Mediated (average)  6.69e-02     1.17e-02     1.90e-01    0.01

Sample Size Used: 713


Simulations: 1000

My problem is that I do not understand how to interpret the value of the
estimate obtained for the ACME (control) parameter.
I know that when the response variable (Y) is binary, this estimate can be
interpreted as the increase in terms of probability of the event for control
subjects.
What is the good interpretation when the response variable (Y) in the model
is a survival object ?
Does it indicates here a decrease expressed in number of days (368) ?
According to the Prop. Mediated (average) value (i.e last row of the table),
can I conclude that about 6.69% of the total effect of Treat on Y is
explained by the indirect effect of Mediator ?

Thanks for your consideration,

Best regards,

Kendejan
[[alternative HTML version deleted]]

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

[R] spline.correlog (ncf package) - Error message: tol must be strictly positive and finite

2016-01-20 Thread Diego Pavon
Dear all

I am trying to run the spline.correlogram in package ncf to check for
spatial autocorrelation in the residuals of my models, but I get an error
message:

Error in smooth.spline(u, v, df = df) :
  'tol' must be strictly positive and finite


I have googled the error and I got to the website
http://www.inside-r.org/packages/cran/ncf/docs/spline.correlog

However, I could not figure out how to solve this error. My data consists
in a time series (29 years) of counts in 92 sites in Finland. I have run
the model I wanted and then I want to use the residuals to check for
spatial autocorrelation. Hence, my code looks like:

DucksCorr <- spline.correlog(x=Ducks2[, "Lon"],
   y=Ducks2[, "Lat"],
   z=Ducks2[, "Resid"],
   xmax=FALSE)

When I run this code, I get the error message. I have removed NAs (although
this can deal with it) and coordinates are correct and also the residuals.
Do you have an idea or suggestions on how to deal with this error message?

Thank you very much for your time and help!

Best

Diego

-- 
*Diego Pavón Jordán*

*Finnish Museum of Natural History*
*PO BOX 17 *

*Helsinki. Finland*



*0445061210https://tuhat.halvi.helsinki.fi/portal/en/persons/diego-pavon-jordan%288d5db37c-eddd-4fca-92cd-9c9956a42b4a%29.html
http://www.linkedin.com/profile/view?id=170617924=nav_responsive_tab_profile
https://helsinki.academia.edu/DiegoPavon
*

[[alternative HTML version deleted]]

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

Re: [R] R editor for Mac

2016-01-20 Thread Duncan Murdoch

On 20/01/2016 1:22 PM, Christofer Bogaso wrote:

Hi,

Could you please suggest a good R editor for Mac OS X (10.7.5)
Previously my operating system was Windows and there I used Notepad++,
I really had very nice experience with it. However I dont see any Mac
version is available for Mac.

Appreciate your positive feedback.


RStudio is probably best on both OS X and Windows.A nice advantage 
is that it looks the same on both, so you can move back and forth.


I only know two negatives:

 - I still don't like the tiled window.  I often work on a small 
screen, and it's not enough space.


 - The editor still changes file endings to native format whenever it 
saves.  It would be better if it handled both Windows and Unix line 
endings in both systems, and left them alone unless the user asked them 
to be changed.


The positives are too numerous to list here.

Duncan Murdoch

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


[R] R editor for Mac

2016-01-20 Thread Christofer Bogaso
Hi,

Could you please suggest a good R editor for Mac OS X (10.7.5)
Previously my operating system was Windows and there I used Notepad++,
I really had very nice experience with it. However I dont see any Mac
version is available for Mac.

Appreciate your positive feedback.

Thanks and regards,

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


Re: [R] (no subject)

2016-01-20 Thread ruipbarradas
Hello,

Please respond to the list, not just to me.
If you just want the first vector ofm the matrices, try the following.

fun <- function(..., n, replace = FALSE){
    m <- do.call(rbind, list(...))
    idx <- sample(nrow(m), n, replace = replace)
    m[idx, 1]
}

n <- 3 * nrow(Young.list1) * 0.25
fun(Young.list1, Young.list2, Young.list3, n = n, replace = FALSE)

Hope this helps,

Rui Barradas
Citando MARYAM :

> Hello, I want to select randomly to three matrix with fixed  
> number.for example i want to select 25% from three matrix  
> randomly(select first column of each matrix). On Dey 30, 1394 AP, at  
> 0:05, ruipbarra...@sapo.pt wrote:
>  
>>  

Hello,

What do you want to sample? Rows? With or without replacement? You  
need to give us more information on what you want.

Start by seeing the help page for ?sample

Hope this helps,

Rui Barradas
 

Citando MARYAM :

> Dear mr/madam
> I have 3 matrix with 20 rows and 3 columns like this: I want to  
> sample randomly from three matrix and put it in a vector.How can i  
> do that?
>
> Young.list1<- matrix(NA,nrow= 20,ncol=3)
> Young.list1[,1]<- 1:20
> Young.list1[,2]<- 0.6
> Young.list1[,3]<- 500
> colnames(Young.list1)<- c("ID","r","EBV")
> ###
> Young.list2<- matrix(NA,nrow= 20,ncol=3)
> Young.list2[,1]<- 21:40
> Young.list2[,2]<- 0.7
> Young.list2[,3]<- 600
> colnames(Young.list2)<- c("ID","r","EBV")
> ###
> Young.list3<- matrix(NA,nrow= 20,ncol=3)
> Young.list3[,1]<- 41:60
> Young.list3[,2]<- 0.8
> Young.list3[,3]<- 700
> colnames(Young.list3)<- c("ID","r","EBV")
>         [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide  
> http://www.R-project.org/posting-guide.htmland[1] provide commented,  
> minimal, self-contained, reproducible code.

 

 

Ligações:
-
[1] http://www.r-project.org/posting-guide.htmland

[[alternative HTML version deleted]]

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

[R] Error using Rhipe

2016-01-20 Thread Paulo Moniz
I am integrating with R Hadoop using Rhipe and my configuration is as follows:
• Ubuntu 14.


• Hadoop 1.0.3




• R 3.2.2




• Rhipe 0.73.1



• library rJava installed



When starting at the R environment  rhinit  () the following message appears:



> rhinit ()



Rhipe: Using Rhipe.jar file 

Initializing Rhipe v0.73 

Error in .jnew("org/godhuli/rhipe/PersonalServer") :
java.lang.NoClassDefFoundError: org/apache/hadoop/fs/FSDataInputStream





Already researched enough in other forums and so far have not got a solution.

I count on the help of lords, I thank you.
[[alternative HTML version deleted]]

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

Re: [R] Simple syntax question (I think)

2016-01-20 Thread Marc Schwartz

> On Jan 20, 2016, at 12:26 PM, Bert Gunter  wrote:
> 
> Could someone please explain to me my mal-understanding of the
> following, which I expected to give the same results without errors.
> 
> TIA.
> 
> -- Bert
> 
>> z <-  list(x=1)
>> z[[2]] <- 3
>> z
> $x
> [1] 1
> 
> [[2]]
> [1] 3
> 
>> list(x = 1)[[2]] <- 3
> Error in list(x = 1)[[2]] <- 3 :
>  target of assignment expands to non-language object


Bert,

I will take a stab at this.

In the first case, you are adding a new element to an existing list object, so 
works as expected:

# Create a new list 'z'
z <-  list(x = 1)

> z
$x
[1] 1


# Now, add a new unnamed element in the list
z[[2]] <- 3

> z
$x
[1] 1

[[2]]
[1] 3


In the second case, you are attempting to subset a list that does not yet exist 
and assign a value to an element of a non-existent object:

> list(x = 1)[[2]]
Error in list(x = 1)[[2]] : subscript out of bounds

> list(x = 1)[[2]] <- 3
Error in list(x = 1)[[2]] <- 3 : 
  target of assignment expands to non-language object


If this was to work, the parser would have to evaluate the command in a left to 
right fashion, first creating the list with an element 'x' and then adding the 
new element to it as a second step, much as you did explicitly in the first 
approach.

You get somewhat similar behavior with a vector, albeit the error is perhaps a 
bit more clear:

> Vec
Error: object 'Vec' not found

> Vec[2] <- 3
Error in Vec[2] <- 3 : object 'Vec' not found

Vec <- 1

> Vec
[1] 1

Vec[2] <- 2

> Vec
[1] 1 2


Regards,

Marc 

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


Re: [R] Simple syntax question (I think)

2016-01-20 Thread Duncan Murdoch

On 20/01/2016 2:21 PM, Bert Gunter wrote:

Thanks Marc.

Actually, I think the cognate construction for a vector (which is what
a list is also) is:

> vector("numeric",2)[2] <-  3
Error in vector("numeric", 2)[2] <- 3 :
   target of assignment expands to non-language object

but this works:

> "[<-"(vector("numeric",2),2,3)
[1] 0 3

I would have thought the 2 versions should be identical, but as you
allude, there are apparently subtleties in the parsing/evaluation that
I do not understand, so that the explicit functional form is parsed
and evaluated differently than the implicit one. The obvious message,
though, is: don't do this!

I suspect there is a reference to this somewhere in the R Language
definition  or elsewhere, and if so, I would appreciate someone
referring me to it -- RTFM certainly applies!


There's a detailed discussion in the Language Reference.  Search for 
"complex assignment", or look in section 3.4.4 Subset assignment. The 
big difference between the two expressions you give is in the final 
assignment of the result of the "[<-" function to the referenced 
variable.  In your first case there's no referenced variable, just an 
expression vector("numeric",2), so you get the error, just as you would with


vector("numeric",2) <- c(0, 3)

Duncan Murdoch

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


Re: [R] R editor for Mac

2016-01-20 Thread Franklin Bretschneider
Dear Christofer Bogaso,


Re:


> Could you please suggest a good R editor for Mac OS X (10.7.5)



Indeed, as Roy Mendelssohn wrote, the editor built into "R.app", the GUI 
program which is part of the standard R for OS X, has a beautiful editor, 
complete with syntax colouring and bracket balancing. And one can run only one 
or a few lines from a script at wish.
I couldn't wish myself more.

Success and best wishes,

Frank
--





Franklin Bretschneider
Dept of Biology
Utrecht University
brets...@xs4all.nl

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


Re: [R] R editor for Mac

2016-01-20 Thread boB Rudis
If you don't want to run RStudio, Sublime Text has both great R code
syntax highlighting/formatting and a REPL mode for an interactive
console in-editor.

Atom also has decent R support.

They both play well with "Dash" which is an alternative way (separate
app) to lookup R docs on OS X.

On Wed, Jan 20, 2016 at 2:22 PM, Franklin Bretschneider
 wrote:
> Dear Christofer Bogaso,
>
>
> Re:
>
>
>> Could you please suggest a good R editor for Mac OS X (10.7.5)
>
>
>
> Indeed, as Roy Mendelssohn wrote, the editor built into "R.app", the GUI 
> program which is part of the standard R for OS X, has a beautiful editor, 
> complete with syntax colouring and bracket balancing. And one can run only 
> one or a few lines from a script at wish.
> I couldn't wish myself more.
>
> Success and best wishes,
>
> Frank
> --
>
>
>
>
>
> Franklin Bretschneider
> Dept of Biology
> Utrecht University
> brets...@xs4all.nl
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] R editor for Mac

2016-01-20 Thread Duncan Murdoch

On 20/01/2016 2:22 PM, Franklin Bretschneider wrote:

Dear Christofer Bogaso,


Re:


> Could you please suggest a good R editor for Mac OS X (10.7.5)



Indeed, as Roy Mendelssohn wrote, the editor built into "R.app", the GUI 
program which is part of the standard R for OS X, has a beautiful editor, complete with 
syntax colouring and bracket balancing. And one can run only one or a few lines from a 
script at wish.
I couldn't wish myself more.


R.app looks nicer than RStudio (no tiling), but it is missing a lot of 
functionality.


 - the debugger
 - the integration with other tools provided by RStudio, like Shiny, 
RMarkdown, htmlwidgets, package building tools, etc.

 - the integration with source code management.
 - session management (i.e. it's easier to shut down and restart R, 
which you frequently need to do when developing and testing packages)
 - syntax checking hints in the editor (not just for R, for some other 
languages too).


I think Emacs + ESS matches (exceeds if you count non-R stuff) RStudio 
in functionality, but it is much harder to learn.


Duncan Murdoch

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


Re: [R] Simple syntax question (I think)

2016-01-20 Thread Bert Gunter
Thanks Marc.

Actually, I think the cognate construction for a vector (which is what
a list is also) is:

> vector("numeric",2)[2] <-  3
Error in vector("numeric", 2)[2] <- 3 :
  target of assignment expands to non-language object

but this works:

> "[<-"(vector("numeric",2),2,3)
[1] 0 3

I would have thought the 2 versions should be identical, but as you
allude, there are apparently subtleties in the parsing/evaluation that
I do not understand, so that the explicit functional form is parsed
and evaluated differently than the implicit one. The obvious message,
though, is: don't do this!

I suspect there is a reference to this somewhere in the R Language
definition  or elsewhere, and if so, I would appreciate someone
referring me to it -- RTFM certainly applies!

Cheers,
Bert

Bert Gunter

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


On Wed, Jan 20, 2016 at 10:57 AM, Marc Schwartz  wrote:
>
>> On Jan 20, 2016, at 12:26 PM, Bert Gunter  wrote:
>>
>> Could someone please explain to me my mal-understanding of the
>> following, which I expected to give the same results without errors.
>>
>> TIA.
>>
>> -- Bert
>>
>>> z <-  list(x=1)
>>> z[[2]] <- 3
>>> z
>> $x
>> [1] 1
>>
>> [[2]]
>> [1] 3
>>
>>> list(x = 1)[[2]] <- 3
>> Error in list(x = 1)[[2]] <- 3 :
>>  target of assignment expands to non-language object
>
>
> Bert,
>
> I will take a stab at this.
>
> In the first case, you are adding a new element to an existing list object, 
> so works as expected:
>
> # Create a new list 'z'
> z <-  list(x = 1)
>
>> z
> $x
> [1] 1
>
>
> # Now, add a new unnamed element in the list
> z[[2]] <- 3
>
>> z
> $x
> [1] 1
>
> [[2]]
> [1] 3
>
>
> In the second case, you are attempting to subset a list that does not yet 
> exist and assign a value to an element of a non-existent object:
>
>> list(x = 1)[[2]]
> Error in list(x = 1)[[2]] : subscript out of bounds
>
>> list(x = 1)[[2]] <- 3
> Error in list(x = 1)[[2]] <- 3 :
>   target of assignment expands to non-language object
>
>
> If this was to work, the parser would have to evaluate the command in a left 
> to right fashion, first creating the list with an element 'x' and then adding 
> the new element to it as a second step, much as you did explicitly in the 
> first approach.
>
> You get somewhat similar behavior with a vector, albeit the error is perhaps 
> a bit more clear:
>
>> Vec
> Error: object 'Vec' not found
>
>> Vec[2] <- 3
> Error in Vec[2] <- 3 : object 'Vec' not found
>
> Vec <- 1
>
>> Vec
> [1] 1
>
> Vec[2] <- 2
>
>> Vec
> [1] 1 2
>
>
> Regards,
>
> Marc
>

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


Re: [R] Simple syntax question (I think)

2016-01-20 Thread William Dunlap via R-help
Note that the expression
   x[1] <- 10
is equivalent not to
   `[<-`(x, 1, value=10)
but to
   x <- `[<-`(x, 1, value=10)
so there is no conflict between your two expressions.

Saying
   c(1,2,3) <- `[<-`(c(1,2,3), 1, value=10)
is not allowed because there is no name to assign something to.

There are a few cases where an expression without a name on
the left side would make sense, as in
   environment()[["x"]] <- 12
instead of
   thisEnvir <- environment()
   thisEnvir[["x"]] <- 12
but that is not allowed (in the interests of having consistent rules).



Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Wed, Jan 20, 2016 at 11:21 AM, Bert Gunter 
wrote:

> Thanks Marc.
>
> Actually, I think the cognate construction for a vector (which is what
> a list is also) is:
>
> > vector("numeric",2)[2] <-  3
> Error in vector("numeric", 2)[2] <- 3 :
>   target of assignment expands to non-language object
>
> but this works:
>
> > "[<-"(vector("numeric",2),2,3)
> [1] 0 3
>
> I would have thought the 2 versions should be identical, but as you
> allude, there are apparently subtleties in the parsing/evaluation that
> I do not understand, so that the explicit functional form is parsed
> and evaluated differently than the implicit one. The obvious message,
> though, is: don't do this!
>
> I suspect there is a reference to this somewhere in the R Language
> definition  or elsewhere, and if so, I would appreciate someone
> referring me to it -- RTFM certainly applies!
>
> Cheers,
> Bert
>
> Bert Gunter
>
> "The trouble with having an open mind is that people keep coming along
> and sticking things into it."
> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>
>
> On Wed, Jan 20, 2016 at 10:57 AM, Marc Schwartz 
> wrote:
> >
> >> On Jan 20, 2016, at 12:26 PM, Bert Gunter 
> wrote:
> >>
> >> Could someone please explain to me my mal-understanding of the
> >> following, which I expected to give the same results without errors.
> >>
> >> TIA.
> >>
> >> -- Bert
> >>
> >>> z <-  list(x=1)
> >>> z[[2]] <- 3
> >>> z
> >> $x
> >> [1] 1
> >>
> >> [[2]]
> >> [1] 3
> >>
> >>> list(x = 1)[[2]] <- 3
> >> Error in list(x = 1)[[2]] <- 3 :
> >>  target of assignment expands to non-language object
> >
> >
> > Bert,
> >
> > I will take a stab at this.
> >
> > In the first case, you are adding a new element to an existing list
> object, so works as expected:
> >
> > # Create a new list 'z'
> > z <-  list(x = 1)
> >
> >> z
> > $x
> > [1] 1
> >
> >
> > # Now, add a new unnamed element in the list
> > z[[2]] <- 3
> >
> >> z
> > $x
> > [1] 1
> >
> > [[2]]
> > [1] 3
> >
> >
> > In the second case, you are attempting to subset a list that does not
> yet exist and assign a value to an element of a non-existent object:
> >
> >> list(x = 1)[[2]]
> > Error in list(x = 1)[[2]] : subscript out of bounds
> >
> >> list(x = 1)[[2]] <- 3
> > Error in list(x = 1)[[2]] <- 3 :
> >   target of assignment expands to non-language object
> >
> >
> > If this was to work, the parser would have to evaluate the command in a
> left to right fashion, first creating the list with an element 'x' and then
> adding the new element to it as a second step, much as you did explicitly
> in the first approach.
> >
> > You get somewhat similar behavior with a vector, albeit the error is
> perhaps a bit more clear:
> >
> >> Vec
> > Error: object 'Vec' not found
> >
> >> Vec[2] <- 3
> > Error in Vec[2] <- 3 : object 'Vec' not found
> >
> > Vec <- 1
> >
> >> Vec
> > [1] 1
> >
> > Vec[2] <- 2
> >
> >> Vec
> > [1] 1 2
> >
> >
> > Regards,
> >
> > Marc
> >
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


Re: [R] R editor for Mac

2016-01-20 Thread Berend Hasselman

> On 20 Jan 2016, at 20:22, Franklin Bretschneider  wrote:
> 
> Dear Christofer Bogaso,
> 
> 
> Re:
> 
> 
>> Could you please suggest a good R editor for Mac OS X (10.7.5)
> 
> 
> 
> Indeed, as Roy Mendelssohn wrote, the editor built into "R.app", the GUI 
> program which is part of the standard R for OS X, has a beautiful editor, 
> complete with syntax colouring and bracket balancing. And one can run only 
> one or a few lines from a script at wish.
> I couldn't wish myself more.
> 

Another nice editor for R is Textmate.

Berend

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


Re: [R] Simple syntax question (I think)

2016-01-20 Thread Bert Gunter
Thanks to both Bill and Duncan for their help. As I said, my
mal-understanding of the syntax.

Best,
Bert
Bert Gunter

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


On Wed, Jan 20, 2016 at 11:51 AM, Duncan Murdoch
 wrote:
> On 20/01/2016 2:21 PM, Bert Gunter wrote:
>>
>> Thanks Marc.
>>
>> Actually, I think the cognate construction for a vector (which is what
>> a list is also) is:
>>
>> > vector("numeric",2)[2] <-  3
>> Error in vector("numeric", 2)[2] <- 3 :
>>target of assignment expands to non-language object
>>
>> but this works:
>>
>> > "[<-"(vector("numeric",2),2,3)
>> [1] 0 3
>>
>> I would have thought the 2 versions should be identical, but as you
>> allude, there are apparently subtleties in the parsing/evaluation that
>> I do not understand, so that the explicit functional form is parsed
>> and evaluated differently than the implicit one. The obvious message,
>> though, is: don't do this!
>>
>> I suspect there is a reference to this somewhere in the R Language
>> definition  or elsewhere, and if so, I would appreciate someone
>> referring me to it -- RTFM certainly applies!
>
>
> There's a detailed discussion in the Language Reference.  Search for
> "complex assignment", or look in section 3.4.4 Subset assignment. The big
> difference between the two expressions you give is in the final assignment
> of the result of the "[<-" function to the referenced variable.  In your
> first case there's no referenced variable, just an expression
> vector("numeric",2), so you get the error, just as you would with
>
> vector("numeric",2) <- c(0, 3)
>
> Duncan Murdoch

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


Re: [R] Splitting strings in data files R

2016-01-20 Thread Mark Sharp
Looks like homework.


R. Mark Sharp, Ph.D.
Director of Primate Records Database
Southwest National Primate Research Center
Texas Biomedical Research Institute
P.O. Box 760549
San Antonio, TX 78245-0549
Telephone: (210)258-9476
e-mail: msh...@txbiomed.org







> On Jan 20, 2016, at 2:53 PM, R. Help  wrote:
>
>
>
>
> Please I need help processing  files with strings in R. All the files have 
> two patterns (thus,examine separately):
> Pattern 1 (see file1 below): Delete Lines 1,2 & 4 in file1. Line 3 contains 
> the column names. Then find anything as.character and delete. Please do not 
> delete any values (e.g. delete T in 0.21T). Also find -999.99M,-999.99 and 
> replace with with NA.
>
> File1 output format should be: Year Month Day_1 Day_2 ... Day_31  ## so all 
> months should 31 days. Months with <31 days should have NA where appropraite 
> (e.g. Feb 30=NA, 31=NA)
>
> Pattern 2 (see file2 below): Delete Line 1 in file2.Then find anything 
> as.character and delete. Please do not delete any values (e.g. delete T in 
> 0.21T). Also find -999.99M,-999.99 and replace with withNA. File2 has no 
> column names. Please do not include any.
> File2 output format: Year Month Day_1 Day_2 ... Day_31 but no column names
>
> Here is a simple reproducible example for both files/cases:
>
>
> file1=list(df1,df1)df1=list(structure(list(X7011982.DONNACONAQC..station.joined..Homogenized.daily.maximum.temperature..Deg.Celcius...Updated.to.December.2014
>  
> =structure(c(20L,19L,21L,1L,2L,3L,4L,5L,6L,7L,8L,9L,10L,11L,12L,13L,14L,15L,16L,17L,18L),.Label
>  =c(" 1918  7 
> -.9M-.9M-.9M-.9M-.9M-.9M-.9M-.9M-.9M-.9M-.9M-.9M-.9M-.9M-.9M-.9M
>   23.6a  25.9a  25.8a  24.9a  24.9a  29.6a  27.4a  24.5a  28.5a  28.5a  30.1a 
>  25.3a  28.5a  19.6a  24.1a"," 1918  8   23.7a  18.6a  17.6a  19.0a  23.7a  
> 24.7a  18.6a  22.6a  20.1a  21.4a  22.6a  24.9a  24.1a  23.2a  22.0a  17.6a  
> 19.0a  19.0a  23.7a  24.1a  24.9a  27.9a  26.2a  22.6a  24.0a  25.4a  21.4a  
> 24.4a  19.0a  22.6a  23.7a"," 1918  9   22.0a  22.0a  24.0a  19.0a  14.4a  
> 11.2a  17.1a  18.1a  19.0a  12.0a  13.5a   9.6a  11.2a  10.7a  18.1a  18.1a  
> 16.3a  14.4a  14.3a  15.9a  10.1a   9.8a  11.3a  11.4a  13.6a  14.4a   9.3a   
> 9.6a   9.2a   8.4a-99!
 99!
> .9M"," 1918 109.3a   9.5a  11.3a  10.2a   9.9a-.9M   4.6a-.9M   
> 9.8a  13.6a  17.0a  15.2a  15.1a  15.9a   8.1a   9.3a   8.8a   6.0a   8.7a   
> 9.8a   9.8a  10.7a  11.3a   9.5a  10.7a-.9M  10.7a  16.9a  17.1a  10.7a  
> 12.7a"," 1918 118.8a-.9M   4.0a   3.4a   4.0a   6.6a   4.0a   7.3a   
> 8.1a   7.3a   2.5a   3.4a   7.7a   6.1a   2.2a   4.0a   4.6a   2.5a   2.2a   
> 1.6a   2.2a   3.0a  -3.4a   2.5a   1.6a  -3.4a   2.1a   0.0a   2.6a   
> 0.6a-.9M"," 1918 12  -10.1a  -8.3a  -6.3a  -5.5a  -5.1a  -7.2a-.9M  
> -3.4a  -2.2a  -5.5a  -6.0a  -3.4a   0.6a   3.0a   4.7a   0.6a  -5.0a  -6.4a  
> -5.9a  -2.2a   1.2a   4.0a   5.3a-.9M  -2.2a  -5.5a  -7.5a  -9.6a  -7.3a  
> -6.6a-.9M"," 1919  12.5a   0.0a  -7.3a  -6.7a  -6.6a  -9.2a  -5.9a  
> -0.7a  -2.9a  -13.2a  -8.0a  -17.1a  -7.4a  -4.0a  -5.5a   0.6a  -7.1a  -5.5a 
>  -2.2a  -7.6a  -7.0a  -3.4a  -2.2a  -6.7a  -8.0a  -2.9a  -1.5a  -5.9a  -5.5a  
> -5.8a  -3.4a"," 1919  2 -.9M   0.0a  -4.0a  -3.4a  -1.5a  -2.1a  -!
 3!
> .4a  -7.2a  -2.8a  -5.5a  -6.7a  -5.1a  -2.1a  -2.1a   1.2a  -2.1a  -5
> .9a  -2.8a  -4.5a  -4.5a  -3.4a   2.1a   0.0a   0.0a   1.2a  -2.1a  -8.3a  
> -6.6a-.9M-.9M-.9M"," 1919  3 -.9M   0.0a   1.6a   1.7a  -5.1a 
>  -6.7a  -5.1a  -3.4a  -2.0a   1.2a   3.4a   1.2a  -8.3a  -7.9a  -3.4a  -2.0a  
>  1.2a   3.4a   6.6a   1.2a   6.6a   1.2a   6.6a   6.6a   3.4a  10.7a   6.6a   
> 6.6a   0.6a   0.6a  -6.8a"," 1919  4   -5.9a  -3.4a   2.1a   3.4a   3.0a   
> 3.0a   8.1a   8.1a   6.0a   2.1a   6.6a   8.5a   6.0a   1.7a   4.7a   2.4a   
> 2.1a   8.5a   1.2a   1.7a   9.6a   8.6a  12.8a   9.5a  -2.8a   9.8a   4.7a  
> 10.7a   6.6a  11.2a-.9M"," 1919  5   16.4a   8.5a   9.4a   6.0a  10.7a   
> 9.8a   8.5a  13.6a  14.4a-.9M  16.4a  19.0a  23.2a  16.9a  17.0a  19.6a  
> 11.3a   9.4a  12.1a  17.2a  15.2a  17.0a  15.2a  17.5a  10.2a  22.6a  14.5a  
> 22.0a  24.9a  23.8a  19.0a"," 1919  6   17.7a  25.4a  31.2a  25.3a  26.8a  
> 22.0a  15.8a  19.0a  12.7a  19.6a  19.0a  24.5a  25.1a  27.4a  26.8a  19.0a  
> 20.8a  26.8a  27.9a  25.8a  20.1a  17.7a  19.0a  32.4a  30.7a  22.6!
 a !
>  19.0a  13.6a  17.5a  24.1a-.9M"," 1919  7   23.7a  24.4a  27.9a  29.6a  
> 23.7a  21.3a  23.7a  20.1a  23.7a  21.3a  17.0a  17.8a  23.7a  27.4a  18.2a  
> 23.2a  24.5a  26.2a  25.8a  27.9a  29.0a  25.3a  25.1a  23.9a  22.6a  23.9a  
> 20.8a  25.8a  20.1a  23.2a  23.7a"," 1919  8   20.8a  18.2a  20.1a  20.1a  
> 25.1a  20.8a  24.6a  18.5a  17.6a  22.0a  24.0a  23.2a  24.0a  24.0a  20.8a  
> 24.0a  23.7a  23.8a  17.1a  23.8a  24.6a  23.8a  19.6a  24.0a  24.0a  16.9a  
> 18.2a  18.6a  18.6a  

[R] Splitting strings in data files R

2016-01-20 Thread Zilefac Elvis via R-help



Please I need help processing  files with strings in R. All the files have two 
patterns (thus,examine separately):
Pattern 1 (see file1 below): Delete Lines 1,2 & 4 in file1. Line 3 contains the 
column names. Then find anything as.character and delete. Please do not delete 
any values (e.g. delete T in 0.21T). Also find -999.99M,-999.99 and replace 
with with NA.

File1 output format should be: Year Month Day_1 Day_2 ... Day_31  ## so all 
months should 31 days. Months with <31 days should have NA where appropraite 
(e.g. Feb 30=NA, 31=NA)

Pattern 2 (see file2 below): Delete Line 1 in file2.Then find anything 
as.character and delete. Please do not delete any values (e.g. delete T in 
0.21T). Also find -999.99M,-999.99 and replace with withNA. File2 has no column 
names. Please do not include any. 
File2 output format: Year Month Day_1 Day_2 ... Day_31 but no column names

Here is a simple reproducible example for both files/cases: 


file1=list(df1,df1)df1=list(structure(list(X7011982.DONNACONAQC..station.joined..Homogenized.daily.maximum.temperature..Deg.Celcius...Updated.to.December.2014
 
=structure(c(20L,19L,21L,1L,2L,3L,4L,5L,6L,7L,8L,9L,10L,11L,12L,13L,14L,15L,16L,17L,18L),.Label
 =c(" 1918  7 
-.9M-.9M-.9M-.9M-.9M-.9M-.9M-.9M-.9M-.9M-.9M-.9M-.9M-.9M-.9M-.9M
  23.6a  25.9a  25.8a  24.9a  24.9a  29.6a  27.4a  24.5a  28.5a  28.5a  30.1a  
25.3a  28.5a  19.6a  24.1a"," 1918  8   23.7a  18.6a  17.6a  19.0a  23.7a  
24.7a  18.6a  22.6a  20.1a  21.4a  22.6a  24.9a  24.1a  23.2a  22.0a  17.6a  
19.0a  19.0a  23.7a  24.1a  24.9a  27.9a  26.2a  22.6a  24.0a  25.4a  21.4a  
24.4a  19.0a  22.6a  23.7a"," 1918  9   22.0a  22.0a  24.0a  19.0a  14.4a  
11.2a  17.1a  18.1a  19.0a  12.0a  13.5a   9.6a  11.2a  10.7a  18.1a  18.1a  
16.3a  14.4a  14.3a  15.9a  10.1a   9.8a  11.3a  11.4a  13.6a  14.4a   9.3a   
9.6a   9.2a   8.4a-!
 .9M"," 1918 109.3a   9.5a  11.3a  10.2a   9.9a-.9M   4.6a-.9M   
9.8a  13.6a  17.0a  15.2a  15.1a  15.9a   8.1a   9.3a   8.8a   6.0a   8.7a   
9.8a   9.8a  10.7a  11.3a   9.5a  10.7a-.9M  10.7a  16.9a  17.1a  10.7a  
12.7a"," 1918 118.8a-.9M   4.0a   3.4a   4.0a   6.6a   4.0a   7.3a   
8.1a   7.3a   2.5a   3.4a   7.7a   6.1a   2.2a   4.0a   4.6a   2.5a   2.2a   
1.6a   2.2a   3.0a  -3.4a   2.5a   1.6a  -3.4a   2.1a   0.0a   2.6a   
0.6a-.9M"," 1918 12  -10.1a  -8.3a  -6.3a  -5.5a  -5.1a  -7.2a-.9M  
-3.4a  -2.2a  -5.5a  -6.0a  -3.4a   0.6a   3.0a   4.7a   0.6a  -5.0a  -6.4a  
-5.9a  -2.2a   1.2a   4.0a   5.3a-.9M  -2.2a  -5.5a  -7.5a  -9.6a  -7.3a  
-6.6a-.9M"," 1919  12.5a   0.0a  -7.3a  -6.7a  -6.6a  -9.2a  -5.9a  
-0.7a  -2.9a  -13.2a  -8.0a  -17.1a  -7.4a  -4.0a  -5.5a   0.6a  -7.1a  -5.5a  
-2.2a  -7.6a  -7.0a  -3.4a  -2.2a  -6.7a  -8.0a  -2.9a  -1.5a  -5.9a  -5.5a  
-5.8a  -3.4a"," 1919  2 -.9M   0.0a  -4.0a  -3.4a  -1.5a  -2.1a  -3!
 .4a  -7.2a  -2.8a  -5.5a  -6.7a  -5.1a  -2.1a  -2.1a   1.2a  -2.1a  -5
.9a  -2.8a  -4.5a  -4.5a  -3.4a   2.1a   0.0a   0.0a   1.2a  -2.1a  -8.3a  
-6.6a-.9M-.9M-.9M"," 1919  3 -.9M   0.0a   1.6a   1.7a  -5.1a  
-6.7a  -5.1a  -3.4a  -2.0a   1.2a   3.4a   1.2a  -8.3a  -7.9a  -3.4a  -2.0a   
1.2a   3.4a   6.6a   1.2a   6.6a   1.2a   6.6a   6.6a   3.4a  10.7a   6.6a   
6.6a   0.6a   0.6a  -6.8a"," 1919  4   -5.9a  -3.4a   2.1a   3.4a   3.0a   3.0a 
  8.1a   8.1a   6.0a   2.1a   6.6a   8.5a   6.0a   1.7a   4.7a   2.4a   2.1a   
8.5a   1.2a   1.7a   9.6a   8.6a  12.8a   9.5a  -2.8a   9.8a   4.7a  10.7a   
6.6a  11.2a-.9M"," 1919  5   16.4a   8.5a   9.4a   6.0a  10.7a   9.8a   
8.5a  13.6a  14.4a-.9M  16.4a  19.0a  23.2a  16.9a  17.0a  19.6a  11.3a   
9.4a  12.1a  17.2a  15.2a  17.0a  15.2a  17.5a  10.2a  22.6a  14.5a  22.0a  
24.9a  23.8a  19.0a"," 1919  6   17.7a  25.4a  31.2a  25.3a  26.8a  22.0a  
15.8a  19.0a  12.7a  19.6a  19.0a  24.5a  25.1a  27.4a  26.8a  19.0a  20.8a  
26.8a  27.9a  25.8a  20.1a  17.7a  19.0a  32.4a  30.7a  22.6a !
  19.0a  13.6a  17.5a  24.1a-.9M"," 1919  7   23.7a  24.4a  27.9a  29.6a  
23.7a  21.3a  23.7a  20.1a  23.7a  21.3a  17.0a  17.8a  23.7a  27.4a  18.2a  
23.2a  24.5a  26.2a  25.8a  27.9a  29.0a  25.3a  25.1a  23.9a  22.6a  23.9a  
20.8a  25.8a  20.1a  23.2a  23.7a"," 1919  8   20.8a  18.2a  20.1a  20.1a  
25.1a  20.8a  24.6a  18.5a  17.6a  22.0a  24.0a  23.2a  24.0a  24.0a  20.8a  
24.0a  23.7a  23.8a  17.1a  23.8a  24.6a  23.8a  19.6a  24.0a  24.0a  16.9a  
18.2a  18.6a  18.6a  23.2a  20.8a"," 1919  9   24.0a  21.3a  24.4a  18.1a  
19.0a  19.0a  17.7a  11.4a  10.7a  12.7a  15.2a  15.2a  18.6a  12.7a  15.2a  
10.1a  12.0a  12.7a  19.6a  18.5a  28.5a  28.5a  10.7a  14.5a  15.8a  11.3a  
11.3a  20.8a  23.2a  11.3a-.9M"," 1919 10   11.3a   8.2a   8.2a  16.4a  
10.7a  17.5a   7.7a   6.0a  11.3a   7.3a  12.1a   7.7a  10.2a  15.9a  18.2a   
9.0a  10.7a   9.8a   8.2a   7.3a   7.7a   8.9a   9.5a  12.1a  10.2a  10.2a   
4.0a  10.7a   2.9a   5.3a   

Re: [R] R plot-par(mfrow=c(x,y)) on multiple pages

2016-01-20 Thread Sarah Goslee
Use a device like pdf() or postscript() that supports multiple pages.
Or start a new default device with dev.new() so you can see two
figures simultaneously.

Sarah

On Wed, Jan 20, 2016 at 3:37 PM, Mohsen Jafarikia  wrote:
> Hello everyone:
>
> I have 12 plots that I am using par(mfrow=c(3,2)) to have 6 of them in
> a single page. R only prints the 6 first graph in a single page. Any
> comments how I can ask R to print all 12 graphs in two pages.
>
> Thanks very much,
> Mohsen
>

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


[R] R plot-par(mfrow=c(x,y)) on multiple pages

2016-01-20 Thread Mohsen Jafarikia
Hello everyone:

I have 12 plots that I am using par(mfrow=c(3,2)) to have 6 of them in
a single page. R only prints the 6 first graph in a single page. Any
comments how I can ask R to print all 12 graphs in two pages.

Thanks very much,
Mohsen

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


Re: [R] tcltk tkwidget(..."table")

2016-01-20 Thread Dalthorp, Daniel
Thanks, Peter.

I'm sure that's right, but it requires knowing: (1) that there's something
called the "width subcommand", and (2) how to format the call to that
command/subcommand.

I was able to do it eventually but only after a few hours of effort
searching the web for help.

E.g. with a table (called table1) with 3 columns and want to set widths to
30, 5, and 5:

colwidths<-c(30, 5, 5)

for(i in 1:3) {
  tcl(table1, "width", i - 1, colwidths[i])
}



On Wed, Jan 20, 2016 at 3:07 PM, peter dalgaard  wrote:

>
> > On 19 Jan 2016, at 20:48 , Dalthorp, Daniel  wrote:
> >
> > Does anyone know a simple way to create a tcltk table with columns of
> > varying widths?
>
> Create a table, then set the width of the columns with the width
> subcommand?
>
> -pd
>
>
> pathName width ?col? ?value col value ...? If no col is specified, returns
> a list describing all cols for which a width has been set. If col is
> specified with no value, it prints out the width of that col in characters
> (positive number) or pixels (negative number). If one or more col-value
> pairs are specified, then it sets each col to be that width in characters
> (positive number) or pixels (negative number). If value is default, then
> the col uses the default width, specified by -colwidth.
>
>
>
> >
> > -Dan
> >
> >
> >
> > --
> > Dan Dalthorp, PhD
> > USGS Forest and Rangeland Ecosystem Science Center
> > Forest Sciences Lab, Rm 189
> > 3200 SW Jefferson Way
> > Corvallis, OR 97331
> > ph: 541-750-0953
> > ddalth...@usgs.gov
> >
> >   [[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>
> --
> Peter Dalgaard, Professor,
> Center for Statistics, Copenhagen Business School
> Solbjerg Plads 3, 2000 Frederiksberg, Denmark
> Phone: (+45)38153501
> Office: A 4.23
> Email: pd@cbs.dk  Priv: pda...@gmail.com
>
>
>
>
>
>
>
>
>
>


-- 
Dan Dalthorp, PhD
USGS Forest and Rangeland Ecosystem Science Center
Forest Sciences Lab, Rm 189
3200 SW Jefferson Way
Corvallis, OR 97331
ph: 541-750-0953
ddalth...@usgs.gov

[[alternative HTML version deleted]]

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


Re: [R] (no subject)

2016-01-20 Thread Jim Lemon
Hi Maryam,

c(Young.list1[sample(1:20,5),],
 Young.list2[sample(1:20,5),],
 Young.list3[sample(1:20,5),])
# or for a more general solution
nrows<-dim(Young.list1)[1]
c(Young.list1[sample(1:nrows,nrows/4),],
 Young.list2[sample(1:nrows,nrows/4),],
 Young.list3[sample(1:nrows,nrows/4),])

Jim


On Wed, Jan 20, 2016 at 9:03 PM, maryam firoozi <
firoozi_maryam6...@yahoo.com> wrote:

> thanks for repling.can you help me how to select randomely 25% from three
> mattix and put it in a vector.
>
>

[[alternative HTML version deleted]]

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


Re: [R] tcltk tkwidget(..."table")

2016-01-20 Thread peter dalgaard

> On 19 Jan 2016, at 20:48 , Dalthorp, Daniel  wrote:
> 
> Does anyone know a simple way to create a tcltk table with columns of
> varying widths?

Create a table, then set the width of the columns with the width subcommand?

-pd


pathName width ?col? ?value col value ...? If no col is specified, returns a 
list describing all cols for which a width has been set. If col is specified 
with no value, it prints out the width of that col in characters (positive 
number) or pixels (negative number). If one or more col-value pairs are 
specified, then it sets each col to be that width in characters (positive 
number) or pixels (negative number). If value is default, then the col uses the 
default width, specified by -colwidth.



> 
> -Dan
> 
> 
> 
> -- 
> Dan Dalthorp, PhD
> USGS Forest and Rangeland Ecosystem Science Center
> Forest Sciences Lab, Rm 189
> 3200 SW Jefferson Way
> Corvallis, OR 97331
> ph: 541-750-0953
> ddalth...@usgs.gov
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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

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


Re: [R] R plot-par(mfrow=c(x,y)) on multiple pages

2016-01-20 Thread Jim Lemon
Hi Mohsen,
I'll have a wild guess at this. I suspect that you have either calculated a
value for the ylim= argument or used explicit values for ylim= in the first
plot, then propagated the error by copying and pasting.

Jim

On Thu, Jan 21, 2016 at 8:56 AM, Mohsen Jafarikia 
wrote:

> Thanks very much for the comment.
>
> I was also wondering why all the y-axis on all 12 plots are similar to
> the first plot. I have 12 plots and scale of the values for these
> plots are different. It seems R is using the x-axis for each
> individual plot correctly but y-axis is the same for all 12 graphs.
>
> Regards,
> Mohsen
>
>
>

[[alternative HTML version deleted]]

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


[R] Gsarima and Method

2016-01-20 Thread Lorenzo Isella

Dear All,
While tuning some time series model with gsarima (which is primarily a
wrapper for arima) from the astsa package, I encounter the following
error message

Error in stats::arima(xdata, order = c(p, d, q), seasonal = list(order
= c(P,  :
 non-stationary seasonal AR part from CSS

According to what I found here

http://bit.ly/1QmTJtu

for a case with the arima function, the solution is to add method="ML"
to the call to arima, but it is not clear at all to me how to
introduce it in the sarima function.
Any help is appreciated
Regards

Lorenzo

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


[R] adehabitat and tcltk

2016-01-20 Thread Emiliano Manzo
Hi there,

is anybody knows how to install adehabitat on latest release? because r said 
that need tcltk but this package is not available for the latest version.

Can anybody help me?


Emiliano Manzo
emiliano.ma...@gmail.com

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


Re: [R] Splitting strings in data files R

2016-01-20 Thread David Winsemius

> On Jan 20, 2016, at 12:53 PM, Zilefac Elvis via R-help  
> wrote:
> 
> 
> 
> 
> Please I need help processing  files with strings in R. All the files have 
> two patterns (thus,examine separately):

You do need help, that much is clear. But the first thing to do is retrace your 
initial data-entry steps. You have used the wrong read-function. The data in 
the input file either whitespace-separated (or fixed width format and you 
apparently thought it was a CSV-file.

Asking us to no work with this mess is just unreasonable. Post the original 
input file.

-- 
David.

> Pattern 1 (see file1 below): Delete Lines 1,2 & 4 in file1. Line 3 contains 
> the column names. Then find anything as.character and delete. Please do not 
> delete any values (e.g. delete T in 0.21T). Also find -999.99M,-999.99 and 
> replace with with NA.
> 
> File1 output format should be: Year Month Day_1 Day_2 ... Day_31  ## so all 
> months should 31 days. Months with <31 days should have NA where appropraite 
> (e.g. Feb 30=NA, 31=NA)
> 
> Pattern 2 (see file2 below): Delete Line 1 in file2.Then find anything 
> as.character and delete. Please do not delete any values (e.g. delete T in 
> 0.21T). Also find -999.99M,-999.99 and replace with withNA. File2 has no 
> column names. Please do not include any. 
> File2 output format: Year Month Day_1 Day_2 ... Day_31 but no column names
> 
> Here is a simple reproducible example for both files/cases: 
> 
> 
> file1=list(df1,df1)df1=list(structure(list(X7011982.DONNACONAQC..station.joined..Homogenized.daily.maximum.temperature..Deg.Celcius...Updated.to.December.2014
>  
> =structure(c(20L,19L,21L,1L,2L,3L,4L,5L,6L,7L,8L,9L,10L,11L,12L,13L,14L,15L,16L,17L,18L),.Label
>  =c(" 1918  7 
> -.9M-.9M-.9M-.9M-.9M-.9M-.9M-.9M-.9M-.9M-.9M-.9M-.9M-.9M-.9M-.9M
>   23.6a  25.9a  25.8a  24.9a  24.9a  29.6a  27.4a  24.5a  28.5a  28.5a  30.1a 
>  25.3a  28.5a  19.6a  24.1a"," 1918  8   23.7a  18.6a  17.6a  19.0a  23.7a  
> 24.7a  18.6a  22.6a  20.1a  21.4a  22.6a  24.9a  24.1a  23.2a  22.0a  17.6a  
> 19.0a  19.0a  23.7a  24.1a  24.9a  27.9a  26.2a  22.6a  24.0a  25.4a  21.4a  
> 24.4a  19.0a  22.6a  23.7a"," 1918  9   22.0a  22.0a  24.0a  19.0a  14.4a  
> 11.2a  17.1a  18.1a  19.0a  12.0a  13.5a   9.6a  11.2a  10.7a  18.1a  18.1a  
> 16.3a  14.4a  14.3a  15.9a  10.1a   9.8a  11.3a  11.4a  13.6a  14.4a   9.3a   
> 9.6a   9.2a   8.4a-99!
 99!
> .9M"," 1918 109.3a   9.5a  11.3a  10.2a   9.9a-.9M   4.6a-.9M   
> 9.8a  13.6a  17.0a  15.2a  15.1a  15.9a   8.1a   9.3a   8.8a   6.0a   8.7a   
> 9.8a   9.8a  10.7a  11.3a   9.5a  10.7a-.9M  10.7a  16.9a  17.1a  10.7a  
> 12.7a"," 1918 118.8a-.9M   4.0a   3.4a   4.0a   6.6a   4.0a   7.3a   
> 8.1a   7.3a   2.5a   3.4a   7.7a   6.1a   2.2a   4.0a   4.6a   2.5a   2.2a   
> 1.6a   2.2a   3.0a  -3.4a   2.5a   1.6a  -3.4a   2.1a   0.0a   2.6a   
> 0.6a-.9M"," 1918 12  -10.1a  -8.3a  -6.3a  -5.5a  -5.1a  -7.2a-.9M  
> -3.4a  -2.2a  -5.5a  -6.0a  -3.4a   0.6a   3.0a   4.7a   0.6a  -5.0a  -6.4a  
> -5.9a  -2.2a   1.2a   4.0a   5.3a-.9M  -2.2a  -5.5a  -7.5a  -9.6a  -7.3a  
> -6.6a-.9M"," 1919  12.5a   0.0a  -7.3a  -6.7a  -6.6a  -9.2a  -5.9a  
> -0.7a  -2.9a  -13.2a  -8.0a  -17.1a  -7.4a  -4.0a  -5.5a   0.6a  -7.1a  -5.5a 
>  -2.2a  -7.6a  -7.0a  -3.4a  -2.2a  -6.7a  -8.0a  -2.9a  -1.5a  -5.9a  -5.5a  
> -5.8a  -3.4a"," 1919  2 -.9M   0.0a  -4.0a  -3.4a  -1.5a  -2.1a  -!
 3!
> .4a  -7.2a  -2.8a  -5.5a  -6.7a  -5.1a  -2.1a  -2.1a   1.2a  -2.1a  -5
> .9a  -2.8a  -4.5a  -4.5a  -3.4a   2.1a   0.0a   0.0a   1.2a  -2.1a  -8.3a  
> -6.6a-.9M-.9M-.9M"," 1919  3 -.9M   0.0a   1.6a   1.7a  -5.1a 
>  -6.7a  -5.1a  -3.4a  -2.0a   1.2a   3.4a   1.2a  -8.3a  -7.9a  -3.4a  -2.0a  
>  1.2a   3.4a   6.6a   1.2a   6.6a   1.2a   6.6a   6.6a   3.4a  10.7a   6.6a   
> 6.6a   0.6a   0.6a  -6.8a"," 1919  4   -5.9a  -3.4a   2.1a   3.4a   3.0a   
> 3.0a   8.1a   8.1a   6.0a   2.1a   6.6a   8.5a   6.0a   1.7a   4.7a   2.4a   
> 2.1a   8.5a   1.2a   1.7a   9.6a   8.6a  12.8a   9.5a  -2.8a   9.8a   4.7a  
> 10.7a   6.6a  11.2a-.9M"," 1919  5   16.4a   8.5a   9.4a   6.0a  10.7a   
> 9.8a   8.5a  13.6a  14.4a-.9M  16.4a  19.0a  23.2a  16.9a  17.0a  19.6a  
> 11.3a   9.4a  12.1a  17.2a  15.2a  17.0a  15.2a  17.5a  10.2a  22.6a  14.5a  
> 22.0a  24.9a  23.8a  19.0a"," 1919  6   17.7a  25.4a  31.2a  25.3a  26.8a  
> 22.0a  15.8a  19.0a  12.7a  19.6a  19.0a  24.5a  25.1a  27.4a  26.8a  19.0a  
> 20.8a  26.8a  27.9a  25.8a  20.1a  17.7a  19.0a  32.4a  30.7a  22.6!
 a !
>  19.0a  13.6a  17.5a  24.1a-.9M"," 1919  7   23.7a  24.4a  27.9a  29.6a  
> 23.7a  21.3a  23.7a  20.1a  23.7a  21.3a  17.0a  17.8a  23.7a  27.4a  18.2a  
> 23.2a  24.5a  26.2a  25.8a  27.9a  29.0a  25.3a  25.1a  23.9a  22.6a  23.9a  
> 20.8a  25.8a  20.1a  23.2a  23.7a"," 1919  8   20.8a  18.2a  20.1a  20.1a  
> 25.1a  20.8a  24.6a  18.5a  17.6a  

Re: [R] R plot-par(mfrow=c(x,y)) on multiple pages

2016-01-20 Thread Sarah Goslee
On Wed, Jan 20, 2016 at 4:56 PM, Mohsen Jafarikia  wrote:
> Thanks very much for the comment.
>
> I was also wondering why all the y-axis on all 12 plots are similar to
> the first plot. I have 12 plots and scale of the values for these
> plots are different. It seems R is using the x-axis for each
> individual plot correctly but y-axis is the same for all 12 graphs.

That seems highly unlikely: R should be using different axes for
independent plots.

Please provide a reproducible example, using fake data or built-in
data, or using dput()
with your own data.

The correct answer depends on what the format actually is; you need to
use dput() or some other unambiguous way of providing sample data.

Without a reproducible example that includes some sample data provided
using dput() (fake is fine), the code you used, and some clear idea of
what output you expect, it's impossible to figure out how to help you.
Here are some suggestions for creating a good reproducible example:
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example


> Regards,
> Mohsen
>
>
> On Wed, Jan 20, 2016 at 4:27 PM, Sarah Goslee  wrote:
>> Use a device like pdf() or postscript() that supports multiple pages.
>> Or start a new default device with dev.new() so you can see two
>> figures simultaneously.
>>
>> Sarah
>>
>> On Wed, Jan 20, 2016 at 3:37 PM, Mohsen Jafarikia  
>> wrote:
>>> Hello everyone:
>>>
>>> I have 12 plots that I am using par(mfrow=c(3,2)) to have 6 of them in
>>> a single page. R only prints the 6 first graph in a single page. Any
>>> comments how I can ask R to print all 12 graphs in two pages.
>>>
>>> Thanks very much,
>>> Mohsen
>>>

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


Re: [R] R plot-par(mfrow=c(x,y)) on multiple pages

2016-01-20 Thread Mohsen Jafarikia
Thanks very much for the comment.

I was also wondering why all the y-axis on all 12 plots are similar to
the first plot. I have 12 plots and scale of the values for these
plots are different. It seems R is using the x-axis for each
individual plot correctly but y-axis is the same for all 12 graphs.

Regards,
Mohsen


On Wed, Jan 20, 2016 at 4:27 PM, Sarah Goslee  wrote:
> Use a device like pdf() or postscript() that supports multiple pages.
> Or start a new default device with dev.new() so you can see two
> figures simultaneously.
>
> Sarah
>
> On Wed, Jan 20, 2016 at 3:37 PM, Mohsen Jafarikia  wrote:
>> Hello everyone:
>>
>> I have 12 plots that I am using par(mfrow=c(3,2)) to have 6 of them in
>> a single page. R only prints the 6 first graph in a single page. Any
>> comments how I can ask R to print all 12 graphs in two pages.
>>
>> Thanks very much,
>> Mohsen
>>

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


Re: [R] R editor for Mac

2016-01-20 Thread Richard M. Heiberger
Emacs with ESS is very simple to operate when you use the menu.
See Paul Johnson's document

[Emacs has no learning curve: Emacs and ESS]
http://pj.freefaculty.org/guides/Rcourse/emacs-ess/emacs-ess.pdf

Rich

On Wed, Jan 20, 2016 at 2:59 PM, Duncan Murdoch
 wrote:
> On 20/01/2016 2:22 PM, Franklin Bretschneider wrote:
>>
>> Dear Christofer Bogaso,
>>
>>
>> Re:
>>
>>
>> > Could you please suggest a good R editor for Mac OS X (10.7.5)
>>
>>
>>
>> Indeed, as Roy Mendelssohn wrote, the editor built into "R.app", the GUI
>> program which is part of the standard R for OS X, has a beautiful editor,
>> complete with syntax colouring and bracket balancing. And one can run only
>> one or a few lines from a script at wish.
>> I couldn't wish myself more.
>
>
> R.app looks nicer than RStudio (no tiling), but it is missing a lot of
> functionality.
>
>  - the debugger
>  - the integration with other tools provided by RStudio, like Shiny,
> RMarkdown, htmlwidgets, package building tools, etc.
>  - the integration with source code management.
>  - session management (i.e. it's easier to shut down and restart R, which
> you frequently need to do when developing and testing packages)
>  - syntax checking hints in the editor (not just for R, for some other
> languages too).
>
> I think Emacs + ESS matches (exceeds if you count non-R stuff) RStudio in
> functionality, but it is much harder to learn.
>
> Duncan Murdoch
>
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


[R] Where to get quantiles (1st parameter q) for pnorm? (Normal approximation to binomial distribution)

2016-01-20 Thread mviljamaa

I'm doing Normal approximation to binomial distribution.

My variables are generated by rbinom.

Here: 
http://msemac.redwoods.edu/~darnold/math15/spring2013/R/Activities/ApproxBinomWithNorm.html


it's claimed that normal approximation is done using the command pnorm.

Question:

Where to get quantiles (1st parameter q) for pnorm?

-Matti

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


Re: [R] config args for Rmpfr to link to mpfr and gmp?

2016-01-20 Thread Martin Maechler
Dear Seija,

> Seija Sirkiä 
> on Wed, 20 Jan 2016 10:01:05 +0200 writes:

> Hello,
> Sorry to bother with you with this, I'll be very brief: How do I 
communicate to the Rmpfr package that the (correct versions of) mpfr and gmp 
libraries are somewhere else than its installation assumes? Pointing me to 
documentation is fine, I haven't been able to find any beyond the README which 
tells me that sudo apt-getting the libraries should do. That is not an option 
in my case.

Sure.

The package has a configure script (auto generated from
configure.ac by GNU autoconf).

Did you see and study the result of

  ./Rmpfr/configure --help

?
It points you (among other) to arguments

  --libdir=DIRobject code libraries [EPREFIX/lib]
  --includedir=DIRC header files [PREFIX/include]

which I think (but did not check) should be sufficient.
I'd work for a solution by
1) manually find the correct way to call that configure script.
2) Once you found that, you should also be able to do this from R
   by correct setting of the arguments

  configure.args
  configure.vars
  INSTALL.opts

of the

   install.packages()

function.

As I am *not* an expert on the subject of  C compiler / library
/ include files (aka "headers") tweaking on all the many different platforms,
and even more importantly, as this question is of general
interest and so its answer is, too, I'm CC'ing to the R-help
mailing lsit and ask you to use 'reply to all' such that the
topic is kept and dealt with on R-help. 

I hope you'll enjoy working with the Rmpfr R package,
with best regards,

Martin Maechler
ETH Zurich

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


Re: [R] Where to get quantiles (1st parameter q) for pnorm?(Normalapproximation to binomial distribution)

2016-01-20 Thread Gerrit Eichner

Hi, Matti,

use

?pnorm

and read about qnorm.

 Hth  --  Gerrit


On Wed, 20 Jan 2016, mviljamaa wrote:


I'm doing Normal approximation to binomial distribution.

My variables are generated by rbinom.

Here: 
http://msemac.redwoods.edu/~darnold/math15/spring2013/R/Activities/ApproxBinomWithNorm.html


it's claimed that normal approximation is done using the command pnorm.

Question:

Where to get quantiles (1st parameter q) for pnorm?

-Matti

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


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


Re: [R] LSD value

2016-01-20 Thread Franklin Mairura via R-help
How can this be achieved in 2-way or 3 way experiments? 

On Monday, January 18, 2016 7:31 AM, Jianling Fan  
wrote:
 

 Thanks David,

That's exactly what I need! Thanks very much for your example.

Best regards,

Julian






On 18 January 2016 at 13:00, David L Carlson  wrote:
> Providing us with a reproducible example, makes it much easier to answer your 
> question. The object returned by LSD.test() is completely different from the 
> object described in the "Value" section of its manual page which makes things 
> confusing. If you look at the first example on the manual page:
>
>> library(agricolae)
>> data(sweetpotato)
>> model<-aov(yield~virus, data=sweetpotato)
>> out <- LSD.test(model,"virus", p.adj="bonferroni")
>> out
> $statistics
>    Mean      CV  MSerror    LSD
>  27.625 17.1666 22.48917 13.4704
>
> $parameters
>  Df ntr bonferroni alpha      test name.t
>    8  4  3.478879  0.05 bonferroni  virus
>
> $means
>      yield      std r      LCL      UCL  Min  Max
> cc 24.4 3.609709 3 18.086268 30.71373 21.7 28.5
> fc 12.86667 2.159475 3  6.552935 19.18040 10.6 14.9
> ff 36.3 7.333030 3 30.019601 42.64707 28.0 41.8
> oo 36.9 4.30 3 30.586268 43.21373 32.1 40.4
>
> $comparison
> NULL
>
> $groups
>  trt    means  M
> 1  oo 36.9  a
> 2  ff 36.3  a
> 3  cc 24.4 ab
> 4  fc 12.86667  b
>
> So you can get the LSD statistic with
>
>> out$statistics$LSD
> [1] 13.4704
>> out$statistics[4]
>      LSD
>  13.4704
>> out[[1]][4]
>      LSD
>  13.4704
>
> -
> David L Carlson
> Department of Anthropology
> Texas A University
> College Station, TX 77840-4352
>
>
> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Jianling Fan
> Sent: Monday, January 18, 2016 10:47 AM
> To: r-help
> Subject: [R] LSD value
>
> Hello, everyone,
>
> I am using LSD.test() from package "agricolae" to do my anova
> analysis. I know I can calculate LSD value by its equation
> t*sqrt(MSE*2/n), but I am wondering if there is a code or something
> that can give the LSD value more directly in R?
>
> Thanks!
>
> Julian
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


  
[[alternative HTML version deleted]]

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

Re: [R] Survival::coxph (clogit), survConcordance vs. summary(fit) concordance

2016-01-20 Thread Andrews, Chris
I only get the digest, sorry if this has already been answered.

When I run your code (after creating some data) I get a warning that "weights 
are ignored in clogit".  This is a result of miscalling the clogit function.  
The first 2 commas should be +s.

library(survival)
nn <- 1000
dat <- data.frame(resp = rbinom(nn, 1, 0.5), x1=rnorm(nn), x2=rnorm(nn), ID = 
rep(seq(nn/2), e=2), site = rep(seq(nn/10), e=10))
fit <- clogit(resp ~ x1 + x2, strata(ID), cluster(site), method ="efron", data 
= dat) # warning
fit <- clogit(resp ~ x1 + x2 + strata(ID) + cluster(site), method ="efron", 
data = dat) # no warning
summary(fit)

Chris

-Original Message-
From: Joe Ceradini [mailto:joecerad...@gmail.com] 
Sent: Tuesday, January 19, 2016 12:48 PM
To: r-help@r-project.org
Subject: [R] Survival::coxph (clogit), survConcordance vs. summary(fit) 
concordance

Hi,

I'm running conditional logistic regression with survival::clogit. I have
"1-1 case-control" data, i.e., there is 1 case and 1 control in each strata.

Model:
fit <- clogit(resp ~ x1 + x2, strata(ID), cluster(site), method ="efron",
data = dat)
Where resp is 1's and 0's, and x1 and x2 are both continuous.

Predictors are both significant. A snippet of summary(fit):
Concordance= 0.763  (se = 0.5 )
Rsquare= 0.304   (max possible= 0.5 )
Likelihood ratio test= 27.54  on 2 df,   p=1.047e-06
Wald test= 17.19  on 2 df,   p=0.0001853
Score (logrank) test = 17.43  on 2 df,   p=0.0001644,   Robust = 6.66
 p=0.03574

The concordance estimate seems good but the SE is HUGE.

I get a very different estimate from the survConcordance function, which I
know says computes concordance for a "single continuous covariate", but it
runs on my model with 2 continuous covariates

survConcordance(Surv(rep(1, 76L), resp) ~ predict(fit), dat)
n= 76
Concordance= 0.9106648 se= 0.09365047
concordant  discordant   tied.risk   tied.timestd(c-d)
 1315.   129. 0.   703.   270.4626

Are both of these concordance estimates valid but providing different
information?
Is one more appropriate for measuring "performance" (in the AUC sense) of
conditional logistic models?
Is it possible that the HUGE SE estimate represents a convergence problem
(no warnings were thrown when fit the model), or is this model just useless?

Thanks!
-- 
Cooperative Fish and Wildlife Research Unit
Zoology and Physiology Dept.
University of Wyoming
joecerad...@gmail.com / 914.707.8506
wyocoopunit.org

[[alternative HTML version deleted]]


**
Electronic Mail is not secure, may not be read every day, and should not be 
used for urgent or sensitive issues 
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.