Re: [R] aov and Error function

2015-02-01 Thread Rolf Turner

On 01/02/15 02:17, John Sorkin wrote:

I am trying to understand the Error function and its use in ANOVA. In
particular I want to understand the difference between two models
that differ only with respect to the Error statement:


aovsubj - aov(value~group+time+Error(subject),data=dataRMANOVA)
and
aovsubjgroup - aov(value~group+time+Error(subject/group),data=dataRMANOVA)

You will note that in my data I have two subject identifiers,
subject and subject2. I am also trying to trying to understand how I
should identify subjects, within group (i.e. intervention vs.
control) or within time (0=baseline, 1=post)


Since no-one else seems to have answered you let me point out that your 
first formulation treats subject 1 in the int group as being the same

as subject 1 in the cont group, and similarly for subject 2 and so on.

The second formulation (subject nested within group) treats subject 1 in 
the int group as being *different* from subject 1 in the cont group.


If you were using subject2 instead of subject there would (I *think*) be 
no difference between the two formulations.


HTH

cheers,

Rolf Turner

--
Rolf Turner
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276
Home phone: +64-9-480-4619

__
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] Melt and Rbind/Rbindlist

2015-02-01 Thread Shouro Dasgupta
Hello Mr. Holtman,

Thank you very much for your reply and suggestion. This is what each Year's
data looks like;

tmp1 - structure(list(FIPS = c(1001L, 1003L, 1005L), X2026.01.01.1 =
 c(285.5533142,
   285.5533142, 286.2481079), X2026.01.01.2 = c(283.4977112, 283.4977112,
   285.0860291), X2026.01.01.3 = c(281.9733887, 281.9733887, 284.1548767
   ), X2026.01.01.4 = c(280.0234985, 280.0234985, 282.6075745),
   X2026.01.01.5 = c(278.7125854, 278.7125854, 281.2553711),
   X2026.01.01.6 = c(278.5204773, 278.5204773, 280.6148071)), .Names =
 c(FIPS,
   X2026.01.01.1, X2026.01.01.2, X2026.01.01.3, X2026.01.01.4,
   X2026.01.01.5, X2026.01.01.6), class = data.frame, row.names =
 c(NA,
   -3L))


The data is in 3-hour blocks for every day by US FIPS code from 2026-2045,
each year's data is in a difference csv. My goal is to to compute max, min,
and mean by week and month. I used the following code to assign week
numbers to the observations;

nweek - function(x, format=%Y-%m-%d, origin){
 if(missing(origin)){
 as.integer(format(strptime(x, format=format), %W))
 }else{
 x - as.Date(x, format=format)
 o - as.Date(origin, format=format)
 w - as.integer(format(strptime(x, format=format), %w))
 2 + as.integer(x - o - w) %/% 7
 }
 }


 Then the following;

for (i in filelist) {
 nweek(tmp2$date)
 }
 for (i in filelist) {
 nweek(dates, origin=2026-01-01)
 }
 for (i in filelist) {
 wkn-nweek(tmp2$date)
 }


Is this efficient? Thank you so much again. I really appreciate it.

Sincerely,

Shouro

On Sun, Feb 1, 2015 at 1:22 AM, jim holtman jholt...@gmail.com wrote:

 It would have been nice if you had at least supplied a subset (~10 lines)
 from a couple of files so we could see what the data looks like and test
 out any solution. Since you are using 'data.table', you should probably
 also use 'fread' for reading in the data.  Here is a possible approach of
 reading the data into a list and then creating a single, large data.table:

 ---
 myDTs - lapply(filelist, function(.file) {
   tmp1 - fread(.file, sep=,)
   tmp2 - melt(tmp1, id=FIPS)
   tmp2$year - as.numeric(substr(tmp2$variable,2,5))
   tmp2$month - as.numeric(substr(tmp2$variable,7,8))
   tmp2$day - as.numeric(substr(tmp2$variable,10,11))
   tmp2  # return value
 })

 bigDT - rbindlist(myDTs)  # rbind all the data.tables together

 # then you should be able to do:

 mean.temp - bigDT[, list(temp.mean=lapply(.SD, mean),
by=c(FIPS,year,month), .SDcols=c(temp)]




 Jim Holtman
 Data Munger Guru

 What is the problem that you are trying to solve?
 Tell me what you want to do, not how you want to do it.

 On Sat, Jan 31, 2015 at 5:57 PM, Shouro Dasgupta sho...@gmail.com wrote:

 I have climate data for 20 years for US counties (FIPS) in csv format,
 each
 file represents one year of data. I have extracted the data and reshaped
 the yearly data files using melt();

 for (i in filelist) {
tmp1 - as.data.table(read.csv(i,header=T, sep=,))
tmp2 - melt(tmp1, id=FIPS)
tmp2$year - as.numeric(substr(tmp2$variable,2,5))
tmp2$month - as.numeric(substr(tmp2$variable,7,8))
tmp2$day - as.numeric(substr(tmp2$variable,10,11))
  }


 Should I *rbind *in the loop here as I have the memory?
 So, the file (i) tmp2 looks like this:

 FIPS  temp year month  date
  1001 276.7936 2045 1 1/1/2045
  1003 276.7936 2045 1 1/1/2045
  1005 279.6452 2045 1 1/1/2045
  1007 276.7936 2045 1 1/1/2045
  1009 272.3748 2045 1 1/1/2045
  1011 279.6452 2045 1 1/1/2045


 My goal is calculate the mean by FIPS code by month/week, however, when I
 use the following code, I get a NULL value.

 mean.temp- for (i in filelist) {tmp2[, list(temp.mean=lapply(.SD, mean),
  by=c(FIPS,year,month), .SDcols=c(temp)]}


 This works fine for individual years but with *for (i in filelist)*. What
 am I doing wrong? Can include a rbind/bindlist in the loop to make a big
 data.frame? Any suggestions will be highly appreciated. Thank you.

 Sincerely,

 Shouro

 [[alternative HTML version deleted]]

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




[[alternative HTML version deleted]]

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


[R] Regression Overdispersion?

2015-02-01 Thread JvanDyne
I am trying to use Poisson regression to model count data with four
explanatory variables: ratio, ordinal, nominal and dichotomous – x1, x2, x3
and x4. After playing around with the input for a bit, I have formed – what
I believe is – a series of badly fitting models probably due to
overdispersion [1] - e.g. model=glm(y ~ x1 +
x2,family=poisson(link=log),data=data1) - and I was looking for some general
guidance/direction/help/approach to correcting this in R. 

[1] – I believe this as a. it’s, as I’m sure you’re aware, a possible reason
for poor model fits; b.the following:

tapply(data1$y,data$x2,function(x)c(mean=mean(x),variance=var(x)))

seems to suggest that, whilst variance does appear to be some function of
the mean, there is a consistently large difference between the two 





--
View this message in context: 
http://r.789695.n4.nabble.com/Regression-Overdispersion-tp4702611.html
Sent from the R help mailing list archive at Nabble.com.

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

[R] How to enable https for R 3.1.2 on windows 8.1

2015-02-01 Thread John Kalb
I run the code below successfully on Mac and Ubuntu successfully.
When I run on Windows, I get the results shown.  How do I get the code
to work on Windows? I've googled extensively with no success. Thanks
in advance.

require(twitteR)

Loading required package: twitteR
Loading required package: ROAuth
Loading required package: RCurl
Loading required package: bitops
Loading required package: rjson
 cred - OAuthFactory $ new( consumerKey = my.key, consumerSecret = my.secret, 
 requestURL =' https:// api.twitter.com/ oauth/ request_token', accessURL =' 
 https:// api.twitter.com/ oauth/ access_token', authURL =' https:// 
 api.twitter.com/ oauth/ authorize')
 cred$handshake(cainfo = C:/users/john/documents/twitter/cacert.pem)
Error in function (type, msg, asError = TRUE)  :
  Protocol  https not supported or disabled in libcurl

[[alternative HTML version deleted]]

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


Re: [R] How to enable https for R 3.1.2 on windows 8.1

2015-02-01 Thread Jeff Newmiller
Honestly? Did you try rcurl https windows (without the quotes)?
---
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 February 1, 2015 8:56:00 AM PST, John Kalb john.k...@gmail.com wrote:
I run the code below successfully on Mac and Ubuntu successfully.
When I run on Windows, I get the results shown.  How do I get the code
to work on Windows? I've googled extensively with no success. Thanks
in advance.

require(twitteR)

Loading required package: twitteR
Loading required package: ROAuth
Loading required package: RCurl
Loading required package: bitops
Loading required package: rjson
 cred - OAuthFactory $ new( consumerKey = my.key, consumerSecret =
my.secret, requestURL =' https:// api.twitter.com/ oauth/
request_token', accessURL =' https:// api.twitter.com/ oauth/
access_token', authURL =' https:// api.twitter.com/ oauth/ authorize')
 cred$handshake(cainfo = C:/users/john/documents/twitter/cacert.pem)
Error in function (type, msg, asError = TRUE)  :
  Protocol  https not supported or disabled in libcurl

   [[alternative HTML version deleted]]

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

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


Re: [R] Is there a way to map data from Binary format to Numerical numbers?

2015-02-01 Thread arun
Try

indx - which(!!mat, arr.ind=TRUE)
v1 -unname(sapply(split(indx[,2], indx[,1]),toString))

cat(paste(v1, collapse=\n), sep=\n)
1, 2, 3, 6, 7, 8, 9
1, 2, 3, 6, 8, 9
1, 3, 4, 6, 7, 8, 9
1, 8
1, 3, 6, 7, 8, 9
1, 3, 4, 6, 8, 9
1, 3, 5, 9


A.K.

   



Hi,
Is there a way to map data from Binary format to Numerical numbers?

example:
I have text files, where each record consists of several items (9 items)
1, means item appear
0, means item absent

1,1,1,0,0,1,1,1,1
1,1,1,0,0,1,0,1,1
1,0,1,1,0,1,1,1,1
1,0,0,0,0,0,0,1,0
1,0,1,0,0,1,1,1,1
1,0,1,1,0,1,0,1,1
1,0,1,0,1,0,0,0,1


I want transform my data to numerical numbers in ascending order, such that 
when items is absent, i didn't print it, but keep increase the counter. for 
example, the above binary format will be: ,
1,2,3,6,7,8,9
1,2,3,6,8,9
1,3,4,6,7,8,9
1,8,
1,3,6,7,8,9
1,3,4,5,7,8
1,3,5,9

__
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] Transform a list of multiple to a data.frame which I want

2015-02-01 Thread Yao He
Dear all:

I have a list like that,which is a standard str_locate_all() function 
(stringr package) output:
$K
   start end
$GSEGTCSCSSK
   start end
[1,] 6   6
[2,] 8   8
$GFSTTCPAHVDDLTPEQVLDGDVNELMDVVLHHVPEAK
   start end
[1,] 6   6
$LVECIGQELIFLLPNK
   start end
[1,] 4   4
$NFK
   start end
$HR
   start end
$AYASLFR
   start end

I want to transform this list like that:

ID   start.1  start.2 
K   NA  NA
GSEGTCSCSSK 6 8
GFSTTCPAHVDDLTPEQVLDGDVNELMDVVLHHVPEAK 6 NA
LVECIGQELIFLLPNK 4 NA
NFK NA NA
HR NA NA
AYASLFR NA NA

I have already tried to use t() , lapply() but I think it is hard to handle the 
NA value and different rows in every matrix 

Thanks in advance

__
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] Regression Overdispersion?

2015-02-01 Thread David Barron
There are two straightforward ways of modelling overdispersion:

1) Use glm as in your example but specify family=quasipoisson.
2) Use glm.nb in the MASS package, which fits a negative binomial model.



On 1 February 2015 at 16:26, JvanDyne e283...@trbvm.com wrote:
 I am trying to use Poisson regression to model count data with four
 explanatory variables: ratio, ordinal, nominal and dichotomous – x1, x2, x3
 and x4. After playing around with the input for a bit, I have formed – what
 I believe is – a series of badly fitting models probably due to
 overdispersion [1] - e.g. model=glm(y ~ x1 +
 x2,family=poisson(link=log),data=data1) - and I was looking for some general
 guidance/direction/help/approach to correcting this in R.

 [1] – I believe this as a. it’s, as I’m sure you’re aware, a possible reason
 for poor model fits; b.the following:

 tapply(data1$y,data$x2,function(x)c(mean=mean(x),variance=var(x)))

 seems to suggest that, whilst variance does appear to be some function of
 the mean, there is a consistently large difference between the two





 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Regression-Overdispersion-tp4702611.html
 Sent from the R help mailing list archive at Nabble.com.

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

__
R-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] save program results and graphs to one file

2015-02-01 Thread Ragia Ibrahim

Dear group,

I have many plots and numeric results in my R program,  kindly how can I save 
them all sequently on one file.
thanks in advance
RAI
  
[[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] Regression Overdispersion?

2015-02-01 Thread Rune Haubo
A third, and often preferable, way is to add an observation-level random effect:

library(lme4)
data1$obs - factor(seq_len(nrow(data1)))
model - glmer(y ~ x1 + x2 + (1 | obs), family=poisson(link=log), data=data1)

See http://glmm.wikidot.com/faq and search for individual-level
random effects.

Cheers,
Rune

On 1 February 2015 at 19:55, David Barron dnbar...@gmail.com wrote:
 There are two straightforward ways of modelling overdispersion:

 1) Use glm as in your example but specify family=quasipoisson.
 2) Use glm.nb in the MASS package, which fits a negative binomial model.



 On 1 February 2015 at 16:26, JvanDyne e283...@trbvm.com wrote:
 I am trying to use Poisson regression to model count data with four
 explanatory variables: ratio, ordinal, nominal and dichotomous – x1, x2, x3
 and x4. After playing around with the input for a bit, I have formed – what
 I believe is – a series of badly fitting models probably due to
 overdispersion [1] - e.g. model=glm(y ~ x1 +
 x2,family=poisson(link=log),data=data1) - and I was looking for some general
 guidance/direction/help/approach to correcting this in R.

 [1] – I believe this as a. it’s, as I’m sure you’re aware, a possible reason
 for poor model fits; b.the following:

 tapply(data1$y,data$x2,function(x)c(mean=mean(x),variance=var(x)))

 seems to suggest that, whilst variance does appear to be some function of
 the mean, there is a consistently large difference between the two





 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Regression-Overdispersion-tp4702611.html
 Sent from the R help mailing list archive at Nabble.com.

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

 __
 R-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] save program results and graphs to one file

2015-02-01 Thread Bert Gunter
But in addition to what Jeff noted, see ?save and ?save.image

(noting that that the resulting .Rdata file can only be read by R).

Cheers,
Bert

Bert Gunter
Genentech Nonclinical Biostatistics
(650) 467-7374

Data is not information. Information is not knowledge. And knowledge
is certainly not wisdom.
Clifford Stoll




On Sun, Feb 1, 2015 at 12:26 PM, Jeff Newmiller
jdnew...@dcn.davis.ca.us wrote:
 In general this depends what you plan to do with those results. I suspect you 
 are looking for something like knitr with rmarkdown (.Rmd files to create 
 HTML or Word) or LaTeX (.Rnw files to create PDF).
 ---
 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 February 1, 2015 12:05:47 PM PST, Ragia Ibrahim ragi...@hotmail.com 
 wrote:

Dear group,

I have many plots and numeric results in my R program,  kindly how can
I save them all sequently on one file.
thanks in advance
RAI

   [[alternative HTML version deleted]]

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

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

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


Re: [R] save program results and graphs to one file

2015-02-01 Thread Henrik Bengtsson
If you're happy with outputting to a multi-page PDF, then you can just
set the default graphics device to pdf(), i.e.

 options(device=pdf)

and the start plotting:

 plot(1:10, col=0)
 plot(10:1, col=1)
 plot((1:10)^2, col=2)
 plot((10:1)^2, col=3)

and at the end make sure to close the device:

 dev.off()

(The PDF device was automatically opened with the first plot call -
all other figures are appended to this one.)


This is what happens implicitly when you run a script in a
non-interactive session, e.g.

Rscript -f myscript.R

That is, in that case you don't have to set the 'device' options (it's
done for you by default) and you don't have to close it at the end,
because that is also done for you by default.

/Henrik



On Sun, Feb 1, 2015 at 2:53 PM, Bert Gunter gunter.ber...@gene.com wrote:
 But in addition to what Jeff noted, see ?save and ?save.image

 (noting that that the resulting .Rdata file can only be read by R).

 Cheers,
 Bert

 Bert Gunter
 Genentech Nonclinical Biostatistics
 (650) 467-7374

 Data is not information. Information is not knowledge. And knowledge
 is certainly not wisdom.
 Clifford Stoll




 On Sun, Feb 1, 2015 at 12:26 PM, Jeff Newmiller
 jdnew...@dcn.davis.ca.us wrote:
 In general this depends what you plan to do with those results. I suspect 
 you are looking for something like knitr with rmarkdown (.Rmd files to 
 create HTML or Word) or LaTeX (.Rnw files to create PDF).
 ---
 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 February 1, 2015 12:05:47 PM PST, Ragia Ibrahim ragi...@hotmail.com 
 wrote:

Dear group,

I have many plots and numeric results in my R program,  kindly how can
I save them all sequently on one file.
thanks in advance
RAI

   [[alternative HTML version deleted]]

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

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

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

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


Re: [R] save program results and graphs to one file

2015-02-01 Thread Jeff Newmiller
In general this depends what you plan to do with those results. I suspect you 
are looking for something like knitr with rmarkdown (.Rmd files to create HTML 
or Word) or LaTeX (.Rnw files to create PDF). 
---
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 February 1, 2015 12:05:47 PM PST, Ragia Ibrahim ragi...@hotmail.com wrote:

Dear group,

I have many plots and numeric results in my R program,  kindly how can
I save them all sequently on one file.
thanks in advance
RAI
 
   [[alternative HTML version deleted]]

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

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


Re: [R] Regression Overdispersion?

2015-02-01 Thread David Winsemius

On Feb 1, 2015, at 8:26 AM, JvanDyne wrote:

 I am trying to use Poisson regression to model count data with four
 explanatory variables: ratio, ordinal, nominal and dichotomous – x1, x2, x3
 and x4. After playing around with the input for a bit, I have formed – what
 I believe is – a series of badly fitting models probably due to
 overdispersion [1] - e.g. model=glm(y ~ x1 +
 x2,family=poisson(link=log),data=data1) - and I was looking for some general
 guidance/direction/help/approach to correcting this in R. 
 
 [1] – I believe this as a. it’s, as I’m sure you’re aware, a possible reason
 for poor model fits; b.the following:
 
 tapply(data1$y,data$x2,function(x)c(mean=mean(x),variance=var(x)))
 
 seems to suggest that, whilst variance does appear to be some function of
 the mean, there is a consistently large difference between the two 
 

This is possibly an interesting question, but at the moment it is both 
off-topic on R and probably deserving of a book chapter as an answer. There are 
simply no specifics. One place where it would be on-topic and if tightened up 
with a specific example might prompt interesting and useful answers from a 
knowledgeable audience would be http://CrossValidated.com .


 
 Sent from the R help mailing list archive at Nabble.com.

The Nabble archive of R-help is neither an archive of any sort since they 
arbitraily delte postings and not is most certainly not the Rhelp archive.

Maybe if I unquote this four line message, then Nabble users will see it, 
although usually it get s trimmed:

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.

-- 

David Winsemius
Alameda, CA, USA

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


[R] the less-than-minus gotcha

2015-02-01 Thread Mike Miller

I've got to remember to use more spaces.  Here's the basic problem:

These are the same:

v 1
v1

But these are extremely different:

v -1
v-1

This mistake can get you even inside of a function call like this:


v - -2:2
which( v1 )

[1] 1 2 3

which( v-1 )  # oops, I meant v -1 not v-1 a HUGE mistake!

Error in which(v - 1) : argument to 'which' is not logical

v

[1] 1

It throws an error but not because I just destroyed my data.  R has no way 
of knowing that I didn't intend to overwrite the vector.


This was how it got me:

which( frame$var4 )   # no problem

which( frame$var-4 )  # huge problem: frame$var is destroyed

Too late now:  The data in frame$var were all overwritten with 4s.  So the 
data are lost and might not be recoverable.


Maybe the tactic that will save me in the future is to remember to always 
use plenty of spaces:


which( frame$var  4 )

which( frame$var  -4 )

That also makes the code easier to read.  In a script, I probably would 
have done that, but in an interactive session I can be lazy.


It seems that there are a lot of R gotcha pages on the web but quite a 
few of the examples show R behaving exactly like I would want and expect 
(e.g., of course NA + 5 returns NA)...


https://github.com/mikelove/r-gotchas/blob/master/README.md
http://stackoverflow.com/questions/1535021/whats-the-biggest-r-gotcha-youve-run-across
http://www.burns-stat.com/pages/Tutor/R_inferno.pdf
http://biostat.mc.vanderbilt.edu/wiki/Main/LinuxWorkshopRProgramingTipsAndGotchas
http://tim-smith.us/arrgh/

I didn't happen to see my example on any list, but I didn't read them 
thoroughly, so it's probably there.


Mike

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


Re: [R] the less-than-minus gotcha

2015-02-01 Thread Kevin E. Thorpe

Using = has it's problems too.

For example,

print(fit - lm(...))

Assigns the result of the lm call to fit and prints the results. This is 
quite a useful trick actually.


print(fit = lm(...))

Throws an error.

Moral of story, computers do what you tell them, not what you meant.

Kevin

On 02/01/2015 08:26 PM, Steve Taylor wrote:

All the more reason to use = instead of -


-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Ben Bolker
Sent: Monday, 2 February 2015 2:07p
To: r-h...@stat.math.ethz.ch
Subject: Re: [R] the less-than-minus gotcha

Mike Miller mbmiller+l at gmail.com writes:



I've got to remember to use more spaces.  Here's the basic problem:

These are the same:

v 1
v1

But these are extremely different:

v -1
v-1



This is indeed documented, in passing, in one of the pages you listed:

http://tim-smith.us/arrgh/syntax.html

Whitespace is meaningless, unless it isn't. Some parsing ambiguities
are resolved by considering whitespace around operators. See and
despair: x-y (assignment) is parsed differently than x  -y (comparison)!




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

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


Re: [R] the less-than-minus gotcha

2015-02-01 Thread Ben Bolker
Mike Miller mbmiller+l at gmail.com writes:

 
 I've got to remember to use more spaces.  Here's the basic problem:
 
 These are the same:
 
 v 1
 v1
 
 But these are extremely different:
 
 v -1
 v-1
 

This is indeed documented, in passing, in one of the pages you listed:

http://tim-smith.us/arrgh/syntax.html

Whitespace is meaningless, unless it isn't. Some parsing ambiguities 
are resolved by considering whitespace around operators. See and
despair: x-y (assignment) is parsed differently than x  -y (comparison)!

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


Re: [R] the less-than-minus gotcha

2015-02-01 Thread Steve Taylor
All the more reason to use = instead of -


-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Ben Bolker
Sent: Monday, 2 February 2015 2:07p
To: r-h...@stat.math.ethz.ch
Subject: Re: [R] the less-than-minus gotcha

Mike Miller mbmiller+l at gmail.com writes:

 
 I've got to remember to use more spaces.  Here's the basic problem:
 
 These are the same:
 
 v 1
 v1
 
 But these are extremely different:
 
 v -1
 v-1
 

This is indeed documented, in passing, in one of the pages you listed:

http://tim-smith.us/arrgh/syntax.html

Whitespace is meaningless, unless it isn't. Some parsing ambiguities 
are resolved by considering whitespace around operators. See and
despair: x-y (assignment) is parsed differently than x  -y (comparison)!

__
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] Boundaries and deldir

2015-02-01 Thread p_connolly

Just what is meant by dummy points as referred to by the help for the
deldir() function?  I understood they indicated the boundary beyond
which triangulation would cease.

I thought I would need the x/y elements (as described in the help file
at the end of the description of the use of the dpl argument) to
describe ad hoc dummy points as way to define a polygon or two as a
boundary.  However, it gives this error:

Error in xd[-drop] : only 0's may be mixed with negative subscripts

Something internal is doing the negative subscripting.
I tried ndx/ndy instead of x/y but it evidently refers only to a
rectangle so not what I need.

Am I barking up the wrong tree altogether?  Is the boundary defined
somewhere else entirely?  I need to get that clear before I am able to 
provide

useful example code.

TIA
Patrick

__
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] Repeat elements of character vector

2015-02-01 Thread PIKAL Petr
Hi

Just a warning. Do you intend it for naming some objects. If yes do not do it, 
use list instead. If not, just discard my comment.

Cheers
Petr

 -Original Message-
 From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Knut
 Hansen
 Sent: Friday, January 30, 2015 2:34 PM
 To: r-help@r-project.org
 Subject: [R] Repeat elements of character vector

 I have a vector of several character elements:
 v1 - c(a, b, c)

 I want each of these elements to be repeated n times and the number of
 the repetition added as part of the element text, hence rep() will not
 work. For
 n=3 the result would be:
 v2 - c(a_1, a_2, a_3, b_1, b_2, b_3, c_1, c_2, c_3)

 Knut Hansen
 knut.han...@uit.no

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


Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a jsou určeny 
pouze jeho adresátům.
Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě neprodleně 
jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho kopie vymažte ze 
svého systému.
Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento email 
jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat.
Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou modifikacemi či 
zpožděním přenosu e-mailu.

V případě, že je tento e-mail součástí obchodního jednání:
- vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření smlouvy, a 
to z jakéhokoliv důvodu i bez uvedení důvodu.
- a obsahuje-li nabídku, je adresát oprávněn nabídku bezodkladně přijmout; 
Odesílatel tohoto e-mailu (nabídky) vylučuje přijetí nabídky ze strany příjemce 
s dodatkem či odchylkou.
- trvá odesílatel na tom, že příslušná smlouva je uzavřena teprve výslovným 
dosažením shody na všech jejích náležitostech.
- odesílatel tohoto emailu informuje, že není oprávněn uzavírat za společnost 
žádné smlouvy s výjimkou případů, kdy k tomu byl písemně zmocněn nebo písemně 
pověřen a takové pověření nebo plná moc byly adresátovi tohoto emailu případně 
osobě, kterou adresát zastupuje, předloženy nebo jejich existence je adresátovi 
či osobě jím zastoupené známá.

This e-mail and any documents attached to it may be confidential and are 
intended only for its intended recipients.
If you received this e-mail by mistake, please immediately inform its sender. 
Delete the contents of this e-mail with all attachments and its copies from 
your system.
If you are not the intended recipient of this e-mail, you are not authorized to 
use, disseminate, copy or disclose this e-mail in any manner.
The sender of this e-mail shall not be liable for any possible damage caused by 
modifications of the e-mail or by delay with transfer of the email.

In case that this e-mail forms part of business dealings:
- the sender reserves the right to end negotiations about entering into a 
contract in any time, for any reason, and without stating any reasoning.
- if the e-mail contains an offer, the recipient is entitled to immediately 
accept such offer; The sender of this e-mail (offer) excludes any acceptance of 
the offer on the part of the recipient containing any amendment or variation.
- the sender insists on that the respective contract is concluded only upon an 
express mutual agreement on all its aspects.
- the sender of this e-mail informs that he/she is not authorized to enter into 
any contracts on behalf of the company except for cases in which he/she is 
expressly authorized to do so in writing, and such authorization or power of 
attorney is submitted to the recipient or the person represented by the 
recipient, or the existence of such authorization is known to the recipient of 
the person represented by the recipient.
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.