Re: [R] xyplot help

2013-02-20 Thread Peter Maclean
I am ploting gridded time series data. I would like the actual lat and lon 
value appear on the graph-if possible inside the graph as numbers. If there is 
also more elegant ways to plot the graphs I will appreciate more suggestions.
#
library(ggplot2)
library(lattice)
month - c(Jan, Feb, Mar, Apr, May, Jun, Jul, 
   Aug, Sep, Oct, Nov, Dec)  
month - factor(month, levels = month.abb)
data - as.data.frame(expand.grid(lon=seq(4,5, 1), lat=seq(-3,-2,1), 
  year=seq(2010, 2012,1), month=month))
n=nrow(data)
data$prec - rgamma(n, 2, 0.25)
data$year - factor(data$year)
data$lon  - factor(data$lon)
data$lat  - factor(data$lat)
ndata - data[order(data$lon, data$lat),]
fix(ndata)
max - max(ndata$prec, na.rm=TRUE)
min - min(ndata$prec, na.rm=TRUE)
 
#Plot the graph and save as pdf
pdf(H:/file.pdf)
 
xyplot(prec~month|year+lon+lat, data=ndata, 
   type = c(l, l,p), ylim=c(min, max),
   layout=c(1,4))
dev.off() 

 
##
#I want to remove the lat and lon rows and put the numbers inside the graph


Peter Maclean
Department of Economics
UDSM
[[alternative HTML version deleted]]

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


[R] Scatterplot, Color by Grade Category

2013-02-20 Thread David Arnold
Hi,

I have:

hours=c(5,6,6,7,7,8,8,9,7,8,8,8,9,9,10,10,9,10,10,11,11,11,12);
level=c(1.0,1.2,0.8,0.8,1.0,1.0,0.6,0.8,1.4,1.2,1.4,1.6,
1.2,1.4,1.0,1.4,1.6,1.6,1.8,1.4,1.6,1.8,1.6);
grade=c(rep(First,8),rep(Second,8),rep(Third,7))
length(hours)
length(level)
length(grade)
data=data.frame(hours=hours,level=level,grade=grade)
data
plot(data$hours,data$level)

Without using ggplot, just using core basic R, how can I:

1. Color each point according to the grade factor.

2. Select a different point type according to the grade factor.

Thanks.

D.





--
View this message in context: 
http://r.789695.n4.nabble.com/Scatterplot-Color-by-Grade-Category-tp4659135.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] type 3 aov for repeated measures

2013-02-20 Thread Anders Sand
Hi,

I know this question has been asked before but I have not seen an answer
pertaining to repeated measures anovas.

I got a simple data set with two factors: block (3 levels) and prime (2
levels). The dataset (expData) are stuctured so one column (block) states
which block a trial is in and one column (prime) states which prime was
used in the trial, another column (RT) states reation time for that trial
and finally a column (subject) states subject number (there are 10 trials
in each condition and 30 subjects so the dataset consists of 1800 obs of 4
variables).

I tried doing this repeated-measures ANOVA in SPSS which results in a
F-value of 25 for factor block and F-value 43 for factor prime.

I then try to reproduce this result in R. First I factor block and prime so
that R knows these are factors and not continous variables.

My anova command in R is aov(expData$RT ~ block * prime +
Error(expData$subject  /(block * prime))

This gives me a very different result, F-values for block is 2.9 and
F-value for prime is 5.7.

I think this difference is caused by the type of Sum of squares test used
in SPSS and R. So, I want to use type 3 test in R.

Is this correct and how do I apply this change in type? The aov function
does not take any type arguments.

Much appreciated.

[[alternative HTML version deleted]]

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


Re: [R] Scatterplot, Color by Grade Category

2013-02-20 Thread Jim Lemon

On 02/20/2013 07:44 PM, David Arnold wrote:

Hi,

I have:

hours=c(5,6,6,7,7,8,8,9,7,8,8,8,9,9,10,10,9,10,10,11,11,11,12);
level=c(1.0,1.2,0.8,0.8,1.0,1.0,0.6,0.8,1.4,1.2,1.4,1.6,
 1.2,1.4,1.0,1.4,1.6,1.6,1.8,1.4,1.6,1.8,1.6);
grade=c(rep(First,8),rep(Second,8),rep(Third,7))
length(hours)
length(level)
length(grade)
data=data.frame(hours=hours,level=level,grade=grade)
data
plot(data$hours,data$level)

Without using ggplot, just using core basic R, how can I:

1. Color each point according to the grade factor.

2. Select a different point type according to the grade factor.


Hi David,
As factors can be converted to numbers beginning with 1, you can do it 
easily:


plot(data$hours,data$level,pch=as.numeric(data$grade),
 col=as.numeric(data$grade))

Obviously if you want other than symbols 1, 2 and 3 in colors black, red 
and green, you can create vectors of symbol numbers and colors:


mysymbols-c(4,6,19)
mycolors-c(palevioletred4,mediumorchid3,lightgoldenrod2)

and then index into them:

plot(data$hours,data$level,pch=mysymbols[as.numeric(data$grade)],
 col=mycolors[as.numeric(data$grade)])

Jim

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


Re: [R] Cramer von Mises test for a discrete distribution

2013-02-20 Thread Santiago Guallar
Thanks Barry,
 
Following your list order
1) It pops up a window saying R for windows GUI front-end crashed. Below three 
options: look for on-line solutions; shut down the program; debug the program 
(I'm translating from Spanish)
2) The processor of my laptop is an Intel Core duo 1,60GHz with ram= 4 GB, 32 
bits. The R version I have installed is 2.15.2 (2012-10-26)
3) I read the posting-guide. Ok, it may be basic statistics. Question withdrawn
 
I made an additional mistake: I attached the wrong files. Please run the code 
with these, and you'll see the problem.
 
Santi
 
 

From: Barry Rowlingson b.rowling...@lancaster.ac.uk
To: Santiago Guallar sgual...@yahoo.com 
Cc: r-help@r-project.org r-help@r-project.org 
Sent: Tuesday, February 19, 2013 6:20 PM
Subject: Re: [R] Cramer von Mises test for a discrete distribution

On Tue, Feb 19, 2013 at 2:49 PM, Santiago Guallar sgual...@yahoo.com wrote:
 Hi,

 I'm trying to carry out Cramer von Mises tests between pairs of vectors 
 belonging to a discrete distribution (concretely frequencies from 0 to 200). 
 However, the program crashes in the attempt. The problem seems to be that 
 these vectors only have positive integer numbers (+ zero). When I add a 
 random very small positive decimal to the non-decimal part everything works 
 fine (files prm1  prpmr1). I attach two of these vectors so you can run the 
 following code. I've also thought to divide both vectors by a real constant 
 such as pi. Do you think these two approaches are acceptable?

 setwd()
 require(CvM2SL2Test)
 prm = scan('prm.txt')
 prpmr = scan('prpmr.txt')
 ct1 = cvmts.test(prm, prpmr) # here R crashes

For you maybe. For me, works fine, and:

 ct1

[1] 30.20509

 cvmts.pval( ct1, length(prm), length(prpmr) )

- this is taking a bit longer. I gave up and killed it. Maybe it
would have eventually crashed R, but you said the other function
call crashed R.

Your two mistakes are:

1. Saying R crashes without showing us any kind of crash report or
error message.
2. Not listing your system and package versions.

Ah, your three mistakes are...

3. Not reading http://www.r-project.org/posting-guide.html


Barry


198
193
200
173
179
200
198
199
185
171
118
44
154
200
200
199
200
200
200
200
200
200
200
200
200
200
200
200
200
200
200
200
200
200
200
163
200
200
200
200
198
197
200
200
193
189
170
173
23
200
200
200
150
200
131
25
0
0
0
169
200
200
200
200
200
200
197
200
184
166
172
185
200
200
184
200
200
200
200
200
200
197
200
200
200
200
140
200
200
200
197
198
200
200
200
200
200
200
200
200
200
200
150
177
198
200
200
200
200
181
200
200
200
200
136
200
200
200
200
200
183
185
186
123
186
63
64
200
200
200
200
174
200
200
200
200
200
200
200
200
200
200
200
200
193
197
117
115
94
92
200
200
200
200
200
193
179
198
138
35
0
0
141
174
168
127
3
17
0
0
0
0
59
0
134
186
184
190
18
5
0
0
0
101
200
200
200
192
200
180
0
188
98
123
118
147
179
184
198
194
197
199
171
198
199
163
200
199
198
175
200
191
142
141
196
191
200
200
200
192
193
200
200
200
200
200
194
200
200
200
200
200
200
200
200
200
200
200
200
200
200
200
200
200
200
200
200
196
200
196
200
200
21
9
85
11
4
25
76
200
195
74
77
7
176
183
173
150
41
186
200
200
196
4
0
2
4
0
0
40
200
200
200
200
200
200
200
139
72
200
200
200
200
192
200
200
200
200
200
161
200
200
186
200
200
191
191
183
111
7
0
200
171
20
200
200
200
200
194
187
191
181
94
0
200
195
199
200
200
193
191
200
200
199
200
199
200
200
192
165
186
177
200
200
192
3
0
0
200
168
200
200
195
199
200
200
200
200
200
200
200
200
200
200
197
200
200
200
200
200
200
200
165
199
162
145
123
168
200
200
200
200
200
93
1
95
0
0
0
171
18
0
0
0
188
200
26
200
200
67
184
160
53
0
0
0
0
0
200
200
166
119
95
63
0
0
0
1
106
41
200
200
200
200
200
198
200
200
200
200
200
93
176
195
128
142
19
63
200
200
152
0
0
1
188
188
198
189
174
196
200
70
0
0
0
0
40
2
200
168
19
0
0
0
0
0
0
0
0
0
0
0
165
190
135
199
200
12
0
0
126
200
200
200
200
200
200
200
197
200
175
0
179
0
129
193
184
161
176
177
0
0
0
0
176
163
186
140
183
171
178
200
200
200
200
200
200
200
200
200
200
200
200
200
200
200
200
200
194
139
31
197
106
161
68
0
0
0
0
0
200
200
193
167
200
200
200
199
200
200
196
200
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] type 3 aov for repeated measures

2013-02-20 Thread Rui Barradas

Hello,

Try function Anova() in package car.

#install.packages(car)
library(car)

?Anova  # see argument 'type'


Hope this helps,

Rui Barradas

Em 20-02-2013 09:08, Anders Sand escreveu:

Hi,

I know this question has been asked before but I have not seen an answer
pertaining to repeated measures anovas.

I got a simple data set with two factors: block (3 levels) and prime (2
levels). The dataset (expData) are stuctured so one column (block) states
which block a trial is in and one column (prime) states which prime was
used in the trial, another column (RT) states reation time for that trial
and finally a column (subject) states subject number (there are 10 trials
in each condition and 30 subjects so the dataset consists of 1800 obs of 4
variables).

I tried doing this repeated-measures ANOVA in SPSS which results in a
F-value of 25 for factor block and F-value 43 for factor prime.

I then try to reproduce this result in R. First I factor block and prime so
that R knows these are factors and not continous variables.

My anova command in R is aov(expData$RT ~ block * prime +
Error(expData$subject  /(block * prime))

This gives me a very different result, F-values for block is 2.9 and
F-value for prime is 5.7.

I think this difference is caused by the type of Sum of squares test used
in SPSS and R. So, I want to use type 3 test in R.

Is this correct and how do I apply this change in type? The aov function
does not take any type arguments.

Much appreciated.

[[alternative HTML version deleted]]

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



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


Re: [R] R script .bat file from Python

2013-02-20 Thread Miguel Manese
Hi Fabio,

I cannot reproduce it but this is probably some env var not set, or
some problem with the path to your R installation having whitespace in
it.

See ?.libPaths, if it is empty you might want to hard-code R_HOME somewhere.

Regards,

On Thu, Feb 14, 2013 at 10:58 PM, Fabio Veronesi f.veron...@gmail.com wrote:
 Hello,
 I would like to start running a script from Python with the Rscript command.
 I tested several ways of invoking R from Python and I finally I succeeded.

 The problem is that the script starts but R does not recognize the
 installed packages.
 I tried simplifying the matter and I created a script.bat with the classic
 commands: Rscript c:\test.R

 If I run it by double clicking on it it works perfectly. However, if I try
 to run it from Python, with a command such as os.system(script.bat), it
 says that it cannot recognize any of the packages that it needs to load.

 Has anyone had  a similar problem?

 Many thanks,
 Fabio

 [[alternative HTML version deleted]]

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

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


Re: [R] Problems with line types in plots saved as PDF files

2013-02-20 Thread Eik Vettorazzi
Hi Ian,
besides encouraging alternative pdf viewers, you just could thin out
your interpolation grid, such as
b = seq(-10, 10, 0.02) #instead of 0.0002
and everything goes fine even with AcroRead XI.

Cheers

Am 20.02.2013 01:09, schrieb Ian Renner:
 Hi,
 
 I am trying to save a plot as a PDF with different line types. In the example 
 below, R displays the plot correctly with 2 curves in solid lines, 2 curves 
 in dashed lines and 1 curve as a dotted line. However, when I save the image 
 as PDF (as attached), the dashed lines become solid. This also happens if I 
 use the pdf command directly (by removing the # symbols).
 
 Is there any way around this? Saving the image as a JPEG or PNG file works 
 fine but the image quality is not desirable.
 
 b.hat = 6
 a.1 = -12
 a.2 = 0
 a.3 = 200
 
 b = seq(-10, 10, 0.0002)
 l = a.1*(b - b.hat)^2 + a.2*(b - b.hat) + a.3
 
 lambda = 20
 
 p = -lambda*abs(b)
 
 pen.like = l + p
 
 y.min = 3*min(p)
 y.max = max(c(l, p, pen.like))
 
 #pdf(file = TestPlot.pdf, 6, 6)
 #{
 plot(b, l, type = l, ylim = c(y.min, y.max), lwd = 2, xlab = 
 expression(beta), ylab = , col = green, yaxt = n, xaxt = n)
 points(b, p, type = l, lty = dotted, lwd = 2, col = red)
 points(b, pen.like, type = l, lwd = 2, lty = dashed, col = green)
 
 axis(1, at = c(0))
 axis(2, at = c(0))
 
 lambda.hat = which.max(pen.like)
 lambda.glm = which(b == b.hat)
 
 points(b[lambda.glm], l[lambda.glm], pch = 16, cex = 1.5)
 points(b[lambda.hat], l[lambda.hat], pch = 17, cex = 1.5)
 
 b.hat = -3
 a.1 = -1.5
 a.2 = 0
 a.3 = 120
 
 l = a.1*(b - b.hat)^2 + a.2*(b - b.hat) + a.3
 
 pen.like = l + p
 
 points(b, l, type = l, lwd = 2, col = blue)
 points(b, pen.like, type = l, lwd = 2, lty = dashed, col = blue)
 
 lambda.hat = which.max(pen.like)
 lambda.glm = which(b == b.hat)
 
 points(b[lambda.glm], l[lambda.glm], pch = 16, cex = 1.5)
 points(b[lambda.hat], l[lambda.hat], pch = 17, cex = 1.5)
 
 abline(h = 0)
 abline(v = 0)
 
 #}
 
 #dev.off()
 
 
 Thanks,
 
 Ian
 
 
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 


-- 
Eik Vettorazzi

Department of Medical Biometry and Epidemiology
University Medical Center Hamburg-Eppendorf

Martinistr. 52
20246 Hamburg

T ++49/40/7410-58243
F ++49/40/7410-57790
--
Pflichtangaben gemäß Gesetz über elektronische Handelsregister und 
Genossenschaftsregister sowie das Unternehmensregister (EHUG):

Universitätsklinikum Hamburg-Eppendorf; Körperschaft des öffentlichen Rechts; 
Gerichtsstand: Hamburg

Vorstandsmitglieder: Prof. Dr. Martin Zeitz (Vorsitzender), Dr. Alexander 
Kirstein, Joachim Prölß, Prof. Dr. Dr. Uwe Koch-Gromus

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


Re: [R] xyplot help

2013-02-20 Thread Duncan Mackay

Hi Peter

As for more suggestions

library(latticeExtra)
useOuterStrips(
xyplot(prec~month|year*paste(lat,lon), data=ndata,
   as.table = T,
   type = c(l, l,p), ylim=c(min, max),
   layout=c(1,4)) )

have a look at
?strip.custom and ?strip.default as well as ?useOuterStrips for 
customizing the strips

and ?panel.text for within the panel.

HTH

Duncan

Duncan Mackay
Department of Agronomy and Soil Science
University of New England
Armidale NSW 2351
Email: home: mac...@northnet.com.au


At 18:13 20/02/2013, you wrote:

Content-Type: text/plain
Content-Disposition: inline
Content-length: 1370

I am ploting gridded time series data. I would like the actual lat 
and lon value appear on the graph-if possible inside the graph as 
numbers. If there is also more elegant ways to plot the graphs I 
will appreciate more suggestions.

#
library(ggplot2)
library(lattice)
month - c(Jan, Feb, Mar, Apr, May, Jun, Jul,
   Aug, Sep, Oct, Nov, Dec)
month - factor(month, levels = month.abb)
data - as.data.frame(expand.grid(lon=seq(4,5, 1), lat=seq(-3,-2,1),
  year=seq(2010, 2012,1), month=month))
n=nrow(data)
data$prec - rgamma(n, 2, 0.25)
data$year - factor(data$year)
data$lon  - factor(data$lon)
data$lat  - factor(data$lat)
ndata - data[order(data$lon, data$lat),]
fix(ndata)
max - max(ndata$prec, na.rm=TRUE)
min - min(ndata$prec, na.rm=TRUE)

#Plot the graph and save as pdf
pdf(H:/file.pdf)

xyplot(prec~month|year+lon+lat, data=ndata,
   type = c(l, l,p), ylim=c(min, max),
   layout=c(1,4))
dev.off()


##
#I want to remove the lat and lon rows and put the numbers inside the graph


Peter Maclean
Department of Economics
UDSM
[[alternative HTML version deleted]]


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


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


Re: [R] Cramer von Mises test for a discrete distribution

2013-02-20 Thread Barry Rowlingson
On Wed, Feb 20, 2013 at 10:03 AM, Santiago Guallar sgual...@yahoo.com wrote:
 Thanks Barry,

 Following your list order
 1) It pops up a window saying R for windows GUI front-end crashed. Below
 three options: look for on-line solutions; shut down the program; debug the
 program (I'm translating from Spanish)

 That's good - often people say crash when all they have seen is a
stop from R.

 2) The processor of my laptop is an Intel Core duo 1,60GHz with ram= 4 GB,
 32 bits. The R version I have installed is 2.15.2 (2012-10-26)

 Nicely up to date...

 3) I read the posting-guide. Ok, it may be basic statistics. Question
 withdrawn

 Oh don't do that! You're not asking how to do basic statistics, you
are trying to do it yourself and getting a crash. Fair question for
starters...

 I made an additional mistake: I attached the wrong files. Please run the
 code with these, and you'll see the problem.

 Will I, will I, will I

 ct1 = cvmts.test(prm, prpmr) # here R crashes

 *** caught segfault ***
address 0x5620e458, cause 'memory not mapped'

Traceback:
 1: .C(CvMTestStat, as.double(x), as.integer(length(x)),
as.double(y), as.integer(length(y)), testscore = double(1))
 2: cvmts.test(prm, prpmr)

Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace
Selection:

Yes! This looks like a bug in that package function, a bit of
investigation seems to blame it on when you have repeated values in
the vectors:

 cvmts.test(1:10,1:10)
[1] 0.025
 cvmts.test(rep(1,10),rep(1,10))
[1] 0.955
 cvmts.test(rep(1,10),rep(2,10))

 *** caught segfault ***
address 0x514daba8, cause 'memory not mapped'

Traceback:
 1: .C(CvMTestStat, as.double(x), as.integer(length(x)),
as.double(y), as.integer(length(y)), testscore = double(1))
 2: cvmts.test(rep(1, 10), rep(2, 10))

Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace

Functions shouldn't crash like this - so time for you to email the maintainer:

 packageDescription(CvM2SL2Test)$Maintainer
[1] Yuanhui Xiao yx...@gsu.edu

The function disappears into C code, but I suspect its dividing by
zero somewhere...

Barry

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


Re: [R] Problems with line types in plots saved as PDF files

2013-02-20 Thread Berend Hasselman

On 20-02-2013, at 12:58, Eik Vettorazzi e.vettora...@uke.de wrote:

 Hi Ian,
 besides encouraging alternative pdf viewers, you just could thin out
 your interpolation grid, such as
 b = seq(-10, 10, 0.02) #instead of 0.0002
 and everything goes fine even with AcroRead XI.
 

When I received the original mail this morning Mail.app on OS X 10.8.2 locked 
up completely when I tried to access the mail.
Both Preview and QuickLook became totally unresponsive.

With the above change  a(0.02 instead of 0.0002) all goes smoothly now.

Berend


 Cheers
 
 Am 20.02.2013 01:09, schrieb Ian Renner:
 Hi,
 
 I am trying to save a plot as a PDF with different line types. In the 
 example below, R displays the plot correctly with 2 curves in solid lines, 2 
 curves in dashed lines and 1 curve as a dotted line. However, when I save 
 the image as PDF (as attached), the dashed lines become solid. This also 
 happens if I use the pdf command directly (by removing the # symbols).
 
 Is there any way around this? Saving the image as a JPEG or PNG file works 
 fine but the image quality is not desirable.
 
 b.hat = 6
 a.1 = -12
 a.2 = 0
 a.3 = 200
 
 b = seq(-10, 10, 0.0002)
 l = a.1*(b - b.hat)^2 + a.2*(b - b.hat) + a.3
 
 lambda = 20
 
 p = -lambda*abs(b)
 
 pen.like = l + p
 
 y.min = 3*min(p)
 y.max = max(c(l, p, pen.like))
 
 #pdf(file = TestPlot.pdf, 6, 6)
 #{
 plot(b, l, type = l, ylim = c(y.min, y.max), lwd = 2, xlab = 
 expression(beta), ylab = , col = green, yaxt = n, xaxt = n)
 points(b, p, type = l, lty = dotted, lwd = 2, col = red)
 points(b, pen.like, type = l, lwd = 2, lty = dashed, col = green)
 
 axis(1, at = c(0))
 axis(2, at = c(0))
 
 lambda.hat = which.max(pen.like)
 lambda.glm = which(b == b.hat)
 
 points(b[lambda.glm], l[lambda.glm], pch = 16, cex = 1.5)
 points(b[lambda.hat], l[lambda.hat], pch = 17, cex = 1.5)
 
 b.hat = -3
 a.1 = -1.5
 a.2 = 0
 a.3 = 120
 
 l = a.1*(b - b.hat)^2 + a.2*(b - b.hat) + a.3
 
 pen.like = l + p
 
 points(b, l, type = l, lwd = 2, col = blue)
 points(b, pen.like, type = l, lwd = 2, lty = dashed, col = blue)
 
 lambda.hat = which.max(pen.like)
 lambda.glm = which(b == b.hat)
 
 points(b[lambda.glm], l[lambda.glm], pch = 16, cex = 1.5)
 points(b[lambda.hat], l[lambda.hat], pch = 17, cex = 1.5)
 
 abline(h = 0)
 abline(v = 0)
 
 #}
 
 #dev.off()
 
 
 Thanks,
 
 Ian
 
 
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 
 
 -- 
 Eik Vettorazzi
 
 Department of Medical Biometry and Epidemiology
 University Medical Center Hamburg-Eppendorf
 
 Martinistr. 52
 20246 Hamburg
 
 T ++49/40/7410-58243
 F ++49/40/7410-57790
 --
 Pflichtangaben gemäß Gesetz über elektronische Handelsregister und 
 Genossenschaftsregister sowie das Unternehmensregister (EHUG):
 
 Universitätsklinikum Hamburg-Eppendorf; Körperschaft des öffentlichen Rechts; 
 Gerichtsstand: Hamburg
 
 Vorstandsmitglieder: Prof. Dr. Martin Zeitz (Vorsitzender), Dr. Alexander 
 Kirstein, Joachim Prölß, Prof. Dr. Dr. Uwe Koch-Gromus
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] 'gmm' package: How to pass controls to a numerical solver used in the gmm() function?

2013-02-20 Thread Prof J C Nash (U30A)
This is a quite general issue that those of us who try to prepare 
optimization tools must deal with quite often. The minqa package 
internal methods were designed to be used with customized controls to 
the algorithm, but we had to package them with some more or less OK 
compromise settings. If you use that package directly, you can change 
the values, but not usually if it is wrapped inside something like gmm.


I'd welcome -- off list -- discussions with developers of packages like 
gmm to find a consistent approach to allow the controls to be set by 
those users needing to do so. A danger is that each wrapper package uses 
either its own approach or none at all. My suggestion is that such 
packages include a control() list as an argument with sensible defaults, 
and that this list contains an item (probably also a list) of controls 
to the optimizer(s). A bit ugly, but for most users, not used.


Best,

JN


On 13-02-20 06:00 AM, r-help-requ...@r-project.org wrote:

Message: 2
Date: Tue, 19 Feb 2013 19:01:35 -0800
From: David Winsemiusdwinsem...@comcast.net
To: Malikov, Emiremali...@binghamton.edu
Cc:r-help@r-project.org
Subject: Re: [R] 'gmm' package: How to pass controls to a numerical
solver  used in the gmm() function?
Message-ID:b54404ca-acc2-441b-8a1e-b0483695b...@comcast.net
Content-Type: text/plain; charset=us-ascii


On Feb 19, 2013, at 5:25 PM, Malikov, Emir wrote:


Hello --

The question I have is about the gmm() function from the 'gmm' package
(v. 1.4-5).

The manual accompanying the package says that the gmm() function is
programmed to use either of four numerical solvers -- optim, optimize,
constrOptim, or nlminb -- for the minimization of the GMM objective
function.

I wonder whether there is a way to pass controls to a solver used
while calling the gmm() function?

In particular, the problem that I have been having is that the gmm()
fails to converge withing the default number of iteration for the
'optim' solver that it uses. Ideally, I would wish to figure out a way
to be able to choose controls, including the number of iterations, for
the solver that I tell gmm() to use.

Currently, the way I call the function is as follows:

model.name - gmm(g=g.fn, x=data, gradv=g.gr, t0=c(start),
type=c(twostep), optfct=c(optim) )

I also would want the gmm() function to know that I want it to pass
the following control -- maxit=1500 -- to the optim solver.

The argument name in the manual is `itermax`. I cannot tell from lookng at the 
code whether that would get passed to 'optim'.


Unfortunately, the 'gmm' manual does not tell whether this is doable.

  There is also a ... argument which is stated in the help page to be passed to 
optim. Looking at ?optim one sees that controls generally need to be in a list named 
'control'. That this is the intent is supported by the sentence on page 11 of the gmm vignette:

We could try dierent starting values, increase the number of iterations in 
the control option of
optim or use nlminb which allows to put restrictions on the parameter space.

-- David Winsemius Alameda, CA, USA


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


Re: [R] Cramer von Mises test for a discrete distribution

2013-02-20 Thread Santiago Guallar
Great Barry!
Thanks for your time. I will e-mail the package maintainers.
 
Santi

From: Barry Rowlingson b.rowling...@lancaster.ac.uk
To: Santiago Guallar sgual...@yahoo.com 
Cc: r-help@r-project.org r-help@r-project.org 
Sent: Wednesday, February 20, 2013 1:36 PM
Subject: Re: [R] Cramer von Mises test for a discrete distribution

On Wed, Feb 20, 2013 at 10:03 AM, Santiago Guallar sgual...@yahoo.com wrote:
 Thanks Barry,

 Following your list order
 1) It pops up a window saying R for windows GUI front-end crashed. Below
 three options: look for on-line solutions; shut down the program; debug the
 program (I'm translating from Spanish)

That's good - often people say crash when all they have seen is a
stop from R.

 2) The processor of my laptop is an Intel Core duo 1,60GHz with ram= 4 GB,
 32 bits. The R version I have installed is 2.15.2 (2012-10-26)

Nicely up to date...

 3) I read the posting-guide. Ok, it may be basic statistics. Question
 withdrawn

Oh don't do that! You're not asking how to do basic statistics, you
are trying to do it yourself and getting a crash. Fair question for
starters...

 I made an additional mistake: I attached the wrong files. Please run the
 code with these, and you'll see the problem.

Will I, will I, will I

 ct1 = cvmts.test(prm, prpmr) # here R crashes

*** caught segfault ***
address 0x5620e458, cause 'memory not mapped'

Traceback:
1: .C(CvMTestStat, as.double(x), as.integer(length(x)),
as.double(y),    as.integer(length(y)), testscore = double(1))
2: cvmts.test(prm, prpmr)

Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace
Selection:

Yes! This looks like a bug in that package function, a bit of
investigation seems to blame it on when you have repeated values in
the vectors:

 cvmts.test(1:10,1:10)
[1] 0.025
 cvmts.test(rep(1,10),rep(1,10))
[1] 0.955
 cvmts.test(rep(1,10),rep(2,10))

*** caught segfault ***
address 0x514daba8, cause 'memory not mapped'

Traceback:
1: .C(CvMTestStat, as.double(x), as.integer(length(x)),
as.double(y),    as.integer(length(y)), testscore = double(1))
2: cvmts.test(rep(1, 10), rep(2, 10))

Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace

Functions shouldn't crash like this - so time for you to email the maintainer:

 packageDescription(CvM2SL2Test)$Maintainer
[1] Yuanhui Xiao yx...@gsu.edu

The function disappears into C code, but I suspect its dividing by
zero somewhere...

Barry



[[alternative HTML version deleted]]

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


Re: [R] generate variable y to produce excess zero in ZIP analysis

2013-02-20 Thread S Ellison
 Subject: [R] generate variable y to produce excess zero in 
 ZIP analysis

Maybe something like

rzip -  function(n, lambda, zip=0.0) {
#zip is the desired proportion of _excess_ zeros
   if(zip1.0 || zip 0) stop(zip must be in (0,1))
   n.zip - ceiling(zip*n)
   n.pois - n-n.zip
  sample( c( rpois(n.pois, lambda), rep(0,n.zip) ) )
}

#Example
rzip(50, 3.5, zip=0.5)

Having said that, I'd bet there's a package out there that already does it 
better...

 S Ellison

 
 
 
 Dear Mr/Mrs
 
 I am Lili Puspita Rahayu, student from magister third level 
 of Statistics in Bogor Agriculture University. 
 Mr/
 Mrs, now I'm analyzing the Zero inflated Poisson (ZIP), which 
 is a solution of the Poisson regression where the response 
 variable (Y) has zero excess. ZIP now I was doing did not use 
 real data, but using simulated data in R. Simulations by 
 generating data on variables x1, x2, x3 with each size n = 
 100, after which generate data on response variable (Y). 
 However, when I generate the variable y, after generating 
 variables x1, x2, x3, then the simulation result in the 
 variable y that does not have a zero excess. Sometimes just a 
 coincidence there are 23%, 25% the proportion of zero on the 
 variable Y. This is because I generate variables x1, x2, x3 
 with a distribution that has a small parameter values​​. I've 
 been consulting with my lecturer, and suggested to generate 
 variable Y that can control the proportion of zero on ​​ZIP 
 analysis. I've been trying to make the syntax, but has not 
 succeeded.I would like to ask for assistance to R to make the 
 syntax to generate simulated Y variables that can control the 
 proportion of zeros after generating variables x1, x2, x3 on 
 ZIP analysis.Thus, I can examine more deeply to determine how 
 much the proportion of zeros on response variable (Y) that 
 can be used in the Poisson regression analysis, parametric 
 ZIP and ZIP semiparametric.
 
 syntax that I made previously by generating variable y 
 without being controlled to produce zero excess in R :
 
  b0=1.5
  b1=-log(2)
  b2=log(3)
  b3=log(4)
  n=100
  x1-rnorm(n, mean=5, sd=2)
  x2-runif(n, min=1, max=2)
  x3-rnorm(n, mean=10, sd=15)
  
  y-seq(1,n)
  for(i in 1:n)
 + {
 + m-exp(b0+b1*x1[i]+b2*x2[i]+b3*x3[i])
 + yp-rpois(1,m)
 + y[i]-yp
 + }
 
 
 I am very
 grateful for the assistance of R.
 I am looking forward to hearing from you. Thank you very much.
 
 Sincerely yours
 Lili Puspita Rahayu 
   [[alternative HTML version deleted]]
 
 

***
This email and any attachments are confidential. Any use, copying or
disclosure other than by the intended recipient is unauthorised. If 
you have received this message in error, please notify the sender 
immediately via +44(0)20 8943 7000 or notify postmas...@lgcgroup.com 
and delete this message and any copies from your computer and network. 
LGC Limited. Registered in England 2991879. 
Registered office: Queens Road, Teddington, Middlesex, TW11 0LY, UK
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] lattice 3x3 plot: force common y-limits accross rows and align x-axes

2013-02-20 Thread Boris.Vasiliev
My appologies for reposting the final message in this thread.  The previous 
e-mail sent from a Yahoo mailbox got completely scrubbed ...
 
 - Forwarded Message -
From: Boris Vasiliev bvasil...@yahoo.com
To: Duncan Mackay mac...@northnet.com.au; gunter.ber...@gene.com 
gunter.ber...@gene.com; r-help-r-project.org r-help@r-project.org 
Sent: Tuesday, February 19, 2013 9:05:17 PM
Subject: Re: [R] lattice 3x3 plot: force common y-limits accross rows and align 
x-axes


Duncan and Bert,

Thank you very much for your help with my question.  It's very much appreciated.



I used your suggestions to get the plot I needed: 

* 3x3 lattice of dotplots, 

* x-limits are the same for all panels, 

* y-limits and y-ticks in each row are the same, 

* y-limits and y-ticks are different between rows,  

* within each row subjects are ordered by sum(count) in the row.  



My code is below just in case somebody in the r-help list finds it useful.


Regards,
Boris.


# raw data

df - data.frame(
subject=c('A','A','A',
  'BB','BB',
  'CCC','CCC','CCC',
  'DD','DD',
  'A','A','A',
  '','',
  'A','A',
  'B','B'),
risk=c('high','high','high',
   'high','high',
   'high','high','high',
   'med','med',
   'med','med','med',
   'med','med',
   'low','low',
   'low','low'),
treatment=c('none','optX','optZ',
'none','optZ',
'none','optX','optZ',
'none','optZ',
'none','optX','optZ',
'none','optZ',
'none','optX',
'none','optZ'),
count=c(5,10,2,
3,5,
8,1,2,
3,7,
10,2,5,
15,2,
7,7,

10,8))



# re-level factors
df$risk - factor(df$risk,levels=c('low','med','high'))
df$treatment - factor(df$treatment,levels=c('none','optX','optZ'))



# create unique subjects ordered by sum(count) and risk
df$sbj.byrisk - paste(df$risk,df$subject,sep=_)
df$sbj - reorder(reorder(df$sbj.byrisk,df$count,sum),as.numeric(df$risk))
df$sbj.ix - as.numeric(df$sbj)

# for each row (i.e. risk), find limits, ticks, labels, and
# maximum number of points per panel
df.byrisk - split(df,df['risk'])
ylim - lapply(df.byrisk,function(idf) return(range(idf$sbj.ix)))
ytck - lapply(df.byrisk,function(idf) return(sort(unique(idf$sbj.ix
ylbl - lapply(df.byrisk,function(idf) {
  ytck - sort(unique(idf$sbj.ix))
  jdnx - pmatch(ytck,idf$sbj.ix)
  ylbl - sub(.*_,,idf$sbj[jdnx])
  return(ylbl)
})
yhei - unlist(lapply(ytck,length))

# set up lists for limits, ticks, labels, panel heights
ylims - rep(ylim,c(3,3,3))
ytcks - rep(list(NULL,NULL,NULL),c(3,3,3))
ytcks[seq(1,7,by=3)] - ytck
ylbls - rep(list(NULL,NULL,NULL),c(3,3,3))
ylbls[seq(1,7,by=3)] - ylbl

# set up plot layout
laywid - list(axis.panel=c(1,0.1,0.1))
layhei - list(panel=yhei/sum(yhei))

# plot
oltc - dotplot(sbj~count|treatment+risk,data=df,
type=c(p,h),origin=0,
scales=list(x=list(limits=c(-1,16),
   alternating=FALSE),
y=list(relation=free,
   alternating=FALSE,
   limits=ylims,
   at=ytcks,
   labels=ylbls)),
par.settings=list(layout.widths=laywid,
  layout.heights=layhei),
between=list(y=0.2))
useOuterStrips(oltc)




From: Duncan Mackay mac...@northnet.com.au
To: Boris Vasiliev bvasil...@yahoo.com; r-help-r-project.org 
r-help@r-project.org 
Sent: Monday, February 18, 2013 10:29:23 PM
Subject: Re: [R] lattice 3x3 plot: force common y-limits accross rows and align 
x-axes


Hi Boris

Just a different take on it, quick glimpse of it

library(lattice)
library(latticeExtra)

z= unique(df$subject)
df$nsub - sapply(df$subject, pmatch, z)

useOuterStrips(xyplot(count ~ nsub|treatment*risk, df, type = h, lwd = 2, 
scales = list(x = list(at = 1:6, labels = z

The order can be changed by changing the order in z by making subject a factor 
in the correct order

see

http://finzi.psych.upenn.edu/R/Rhelp02/archive/43626.html

on how to change the yaxis limits. An example of mine (cut and paste)  for an 
8x3 panel xyplot (it could be streamlined - i needed to change things as I went 
along to get everything in)

  par.settings =  layout.heights = list(panel = 
c(1,1,0.6,0.6,0.6,0.6,1,0.5)/sum(c(1,1,0.6,0.6,1,0.6,1,0.5)) )
  ),
  scales  = list(x = list(alternating 

[R] ggplot2 customizing a plot

2013-02-20 Thread Alaios
Dear all,
I want some help improve my ggplot as following:
Make the plottable area with grid, so is easy one to see where each box refers 
to x and y values.
Add a color bar but with fixed values, that I want to specify.
How   I can do those two?

Before is some code what I have tried so far.

Regards
Alex 


DataToPlot-matrix(data=seq(1:9),nrow=3,dimnames=list(seq(1,3),seq(4,6)))   
    


require(reshape)
require(ggplot2)
require(raster)


 
 tdm - melt(DataToPlot)  



p- ggplot(tdm, aes(x = Var2, y = Var1, fill = factor(value))) +
    labs(x = MHz, y = Threshold, fill = Duty Cycle) +
    geom_raster() +
    scale_fill_discrete()

[[alternative HTML version deleted]]

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


Re: [R] odfWeave: Trouble Getting the Package to Work

2013-02-20 Thread Paul Miller
Hi Max,
 
It works! Updating the odfWeave and xml software did the trick. Thanks very 
much for your help.
 
Paul


[[alternative HTML version deleted]]

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


[R] Bayesian mixing model

2013-02-20 Thread Richard Cooper (ENV)
Fellow R users,

I'm using the BCE {BCE} function to run a Bayesian sediment mixing model. The 
aim is to find the optimum % contribution from each of the 4 source areas that 
can yield the target geochemistry.

I have geochemistry for 4 source areas called Rat:

Rat-read.table(text=CaO   MgO  Na2OAl2O3
Topsoils  2.511250 0.7445500 0.7085500 14.10375
ChannelBanks 55.021500 0.8665000 0.3045000 10.19800
FieldDrains  17.958221 0.9415394 0.2979383 14.68013
RoadRunoff9.177297 1.9034304 0.4618634 22.22206, header=TRUE)

...and geochemistry for 1 target sediment called Dat:

Dat-read.table(text= CaO   MgO  Na2O  Al2O3
Targethf 15.741 1.346 0.368 19.872, header=TRUE)

I have absolute stdev on the sources called adssdRat:

abssdRat-read.table(text=   CaO   MgO   Na2OAl2O3
Topsoils 1.8552515 0.1135672 0.06212094 1.491125
ChannelBanks 9.8400162 0.1401057 0.08599080 2.708710
FieldDrains  2.3896499 0.1961217 0.02545431 4.300644
RoadRunoff   0.7780579 0.1749869 0.02848264 1.116747, header =TRUE)

...and absolute stdev on the target called adssdDat:

abssdDat-read.table(text=CaO   MgO  Na2O Al2O3
1 0.877 0.531 0.264 2.439, header=TRUE)


Whilst the model results are OK, there is one problem. The model fails to take 
into consideration covariance between the geochemistry in each source area 
(Rat) and therefore the uncertainty in the output is likely to be overestimated 
(e.g. Mg and Na are strongly positively correlated in each of the 4 source 
areas)

My understanding is that this can be corrected for by changing the userProb 
argument such that the multivariate normal distribution is called for 'Rat' 
instead of the default gamma distribution. However I am having trouble in 
writing a new userProb argument, so I'd be very grateful to anyone who could 
help me out with this. Failing that, does anybody know of another package for 
Bayesian optimisation that could account for covariance in the source area 
geochemistry?

For anyone that can help, you may need the logprobability function that BCE 
calls as the default when userProb is set to NULL:
##
logProbabilityBCE1 -
  function (RAT, X, init.list)
  {
with(init.list, {
  if (!is.null(userProb))
logp - log(userProb(RAT, X))
  else {
y - X %*% RAT
if (!is.null(positive)) {
  dA.p - dgamma(RAT[ind.pos], krat[ind.pos], lrat[ind.pos],
 log = TRUE)
  kdat - y^2/sddat^2
  ldat - y/sddat^2
  kdat[Dat == 0] - 1
  ldat[Dat == 0  !is.na(Dat)] - 1/y[Dat == 0 
!is.na(Dat)]
  dB.p - dgamma(Dat[, positive], kdat[, positive],
 ldat[, positive], log = TRUE)
}
else {
  dA.p - 0
  dB.p - 0
}
if (any(wholeranged)) {
  dA.r - dnorm(RAT[ind.r], Rat[ind.r], sdrat[ind.r],
log = TRUE)
  dB.r - dnorm(y[, wholeranged], Dat[, wholeranged],
sddat[, wholeranged], log = TRUE)
}
else {
  dA.r - 0
  dB.r - 0
}
dA.p[dA.p  -1e+08] - -1e+08
dA.p[dA.p  +1e+08] - +1e+08
dA.r[dA.r  -1e+08] - -1e+08
dA.r[dA.r  +1e+08] - +1e+08
drat - sum(dA.p, dA.r, na.rm = TRUE)
if (unif)
  drat - 0
if (any(RAT  minRat | RAT  maxRat, na.rm = TRUE))
  drat - -Inf
dB.p[dB.p  -1e+08] - -1e+08
dB.p[dB.p  +1e+08] - +1e+08
dB.r[dB.r  -1e+08] - -1e+08
dB.r[dB.r  +1e+08] - +1e+08
ddat - sum(dB.p, dB.r, na.rm = TRUE)/nst
logp - drat + ddat
  }
  return(logp)
})}

##

Regards

[[alternative HTML version deleted]]

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


Re: [R] ggplot2 customizing a plot

2013-02-20 Thread Ista Zahn
Hi,

On Wed, Feb 20, 2013 at 9:33 AM, Alaios ala...@yahoo.com wrote:
 Dear all,
 I want some help improve my ggplot as following:
 Make the plottable area with grid, so is easy one to see where each box 
 refers to x and y values.

I don't think you can easily move the grid to the front, but you can
make the tiles transparent so the grid can be seen through them by
setting the alpha  1.

 Add a color bar but with fixed values, that I want to specify.

use scale_fill_manual

 How   I can do those two?

p- ggplot(tdm, aes(x = Var2, y = Var1, fill = factor(value))) +
  labs(x = MHz, y = Threshold, fill = Duty Cycle) +
  geom_raster(alpha=.5) +
  scale_fill_manual(values=c(red, blue, green, purple,
orange, pink, tan, violet, yellow))


Best,
Ista



 Before is some code what I have tried so far.

 Regards
 Alex


 DataToPlot-matrix(data=seq(1:9),nrow=3,dimnames=list(seq(1,3),seq(4,6)))


 require(reshape)
 require(ggplot2)
 require(raster)

  tdm - melt(DataToPlot)



 p- ggplot(tdm, aes(x = Var2, y = Var1, fill = factor(value))) +
 labs(x = MHz, y = Threshold, fill = Duty Cycle) +
 geom_raster() +
 scale_fill_discrete()

 [[alternative HTML version deleted]]


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


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


Re: [R] calculating seconds

2013-02-20 Thread S Ellison
 I'm looking at some data which has the time in seconds since 
 1992/10/8,
 15:15:42.5
 
 Are there any functions currently available to translate 
 this or should I just do my own?

strptime() goes from date formats to seconds.

For going the other way, see ?DateTimeClasses  for a lot of information on 
dates and times, and (probably) ?as.POSIXct for changing something in seconds 
(as the Examples say, 'a large integer') into a date-time class which you 
should be able to convert to other things more easily.

S Ellison

***
This email and any attachments are confidential. Any use...{{dropped:8}}

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


[R] a priori power analysis for glm, family = poisson

2013-02-20 Thread Chad Widmer
Dear R/statistics wizards,



This may be more of a statistics question than an R one, but I’m hoping
that someone has the time to help.  I’ve already consulted a few local
statisticians and I’ve not yet received a clear answer.  Before I start an
experiment I want to conduct an a priori power analysis test for a
Generalized Linear Model, family = poisson.  The response variables will be
counts.  I want to look at the effects of 5 temperatures and 3 salinities,
and their interaction in 15 different combinations (5 temperatures each
testing 3 different salinity levels).   I am hoping to learn the power I
would achieve if I used a sample size of 18 in each of the combinations,
for a total sample size N = 270.



Does such a power analysis exist?  Can I just use a power analysis for a
linear model since the glm is an extension of that (which seems to make
sense), or maybe even one from a 2 way anova? Can someone show me the path
of righteousness in R, or point me in the right direction please?



Thank you very much for your valuable time.

Chad

[[alternative HTML version deleted]]

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


[R] Error in setwd(outDir) : cannot change working directory

2013-02-20 Thread Joanna Papakonstantinou
I installed R on my Windows laptop in C:\Program Files\R\R-2.15.2

and am able to open RGUI  (640bit), see packages and run commands. However,
when I test the installation and run the basic tests and all the tests on
the standard and recommended packages i.e.:

  library(tools)

  testInstalledBasic(both)

  testInstalledPackages(base, errorsAreFatal = FALSE)

  testInstalledPackages(recommended, errorsAreFatal = FALSE)



I am getting errors such as:

  testInstalledPackages(base,errorsAreFatal=FALSE)

 Error in setwd(outDir) : cannot change working directory



my working driectory is:

getwd()

[1] C:/Users/jpapa/Documents
 In which I see R folder as well as the .rData from my last session.

what does the wd have to do with the output directory? Do  I need to create
an output directory? DO I need to setwd(outDir)?

do i need to change the wd (for example to the Pogram Files directory where
R is installed or to another directory I need to create? if so, how do I do
this?





i also noticed that i have packages in

\library ‘C:/Users/jpapa/Documents/R/win-library/2.15’

and in library ‘C:/Program Files/R/R-2.15.2/library’.

Do all packages need to be in one place? If so, should they be in my
Documents or in Program Files?



Thank you for your help.



**


*Joanna Papakonstantinou, Ph.D.*

[[alternative HTML version deleted]]

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


[R] R and microsoft

2013-02-20 Thread teija stormi
Hi,

I hava some questions about R and other softas.
Which applications (softas) I can use with R? Can I connect R with
Microsoft? Can I connect R with SPSS and how I can do it?

I am grateful, if you can help me.

-Teija
teijasto...@gmail.com

[[alternative HTML version deleted]]

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


[R] Generating QFs from same sample

2013-02-20 Thread M. Rauf Ahmad
Dear All


I am kind of stuck up with a code a part of which seems to be causing a
problem, or at least I think so. May be the community can help me. It’s
simple but I suppose I am missing something.


I generate a data matrix X, say of order n*p, where n represents
independent row-vectors and p correlated col vectors. Let the row
representation be X = (X’_1, . . ., X’_n)’. I generate the differences of
these vectors as D_{ab} = X_a – X_b, with different indices a and b, and
similarly D_{cd} = X_c – X_d, and make a quadratic form D’_{ab}D_{cd} =
A_{abcd}, say. Please note that, here a is unequal b, c is unequal d, a is
unequal c, b is unequal d.


By slightly shuffling the same set of vectors, I generate two other similar
quadratic forms, say A_{acbd} and A_{adcb}, where the indices are again as
unequal as stated above.



In the R-code (a part of ) below, I compute these three forms using pata,
patb, patc, respectively, using kronecker products. But from the final
result of this code I get the feeling there is a difference between what I
want the code to do and what it actually does.


 en - matrix(1, n, 1)

 jn - matrix(1, n, n)

 dev  - jn - diag(n)

 pata - dev%x%dev

 patb - jn%x%jn - diag(n)%x%diag(n)

 patc - jn%x%diag(n) - diag(n)%x%jn



Any help will be sincerely appreciated!



Best regards

MR Ahmad

[[alternative HTML version deleted]]

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


Re: [R] NLS results different from Excel

2013-02-20 Thread Bruce McCullough
The idea that the Excel solver has a good reputation for being fast and 
accurate does not withstand an examination  of the Excel solver's 
ability to solve the StRD nls test problems.  Solver's ability is 
abysmal.  13 of 27 answers have zero accurate digits, and three more 
have fewer than two accurate digits -- and this is after tuning the 
solver to get a good answer.  For details see

B. D. McCullough and Berry Wilson
On the Accuracy of Statistical Procedures in Microsoft Excel 2000 and 
Excel XP,
/Computational Statistics and Data Analysis/ *40*(4), 713-721, 2002

The situation is the same for Excel 2003 and Excel 2007.  The alleged 
improvements for Excel 2010 have had not much practical effect.  Excel 
solver does have the virture that it will always produce an answer, 
albeit one with zero accurate digits.

To see an extended example of precisely how solver fails:

B. D. McCullough
Some Details of Nonlinear Estimation, Chapter Eight in
/Numerical Methods in Statistical Computing for the Social Sciences, /
Micah Altman, Jeff Gill and Michael P. McDonald, editors
New York: Wiley, 2004

I am unaware of R being applied to the StRD, but I did apply S+ to the 
StRD and, with analytic derivatives, it performed flawlessly.


On 02/19/2013 08:38 PM, r-help-requ...@r-project.org wrote:
 May I be allowed to say that the general comments on MS Excel may be alright,
 in this special case they are not.  The Excel Solver -- which is made by an
 external company, not MS -- has a good reputation for being fast and accurate.
 And it indeed solves least-squares and nonlinear problems better than some of
 the solvers available in R.
 There is a professional version of this solver, not available from Microsoft,
 that could be called excellent. We, and this includes me, should not be too
 arrogant towards the outside, non-R world, the 'barbarians' as the ancient
 Greeks called it.

 Hans Werner


-- 
B. D. McCullough, Professor
Department of Decision Sciences
LeBow College of Business

So what's getting ubiquitous and cheap? Data. And what is
complementary to data? Analysis. So my recommendation is to
take lots of courses about how to manipulate and analyze
data: databases, machine learning, econometrics, statistics,
visualization, and so on. Google Chief Economist, Hal Varian,
New York Times, 25 February 2008


[[alternative HTML version deleted]]

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


Re: [R] data format

2013-02-20 Thread arun
Hi elisa,
Try this:


mat1-matrix(signif(c(1.200407,1.861941,1.560613,2.129241,2.047772,1.784105,1.777159,1.988596,2.163199,2.446993,3.593623,5.706672),digits=3),ncol=1)
 list1- list(mat1,mat1,mat1)

list2-lapply(list1,function(x) 
data.frame(date1=format(seq.Date(as.Date(1911.01.01,format=%Y.%m.%d),by=month,length.out=12),format=%Y.%m.%d),value=x,stringsAsFactors=FALSE))
list3- lapply(list2,function(x){ substr(x[,1],6,6)- 
ifelse(substr(x[,1],6,6)==0, ,substr(x[,1],6,6));substr(x[,1],9,9)- 
ifelse(substr(x[,1],9,9)==0, ,substr(x[,1],9,9));x})
list4- lapply(list3,function(x) 
{x[,2]-sprintf(%.2f,x[,2]);data.frame(col1=c(EXACT DATA,FROM 1911 1 1 TO 
1911 12 1,do.call(paste,x)),stringsAsFactors=FALSE)}) 


 list4[[1]]
# col1
#1  EXACT DATA
#2  FROM 1911 1 1 TO 1911 12 1
#3 1911. 1. 1 1.20
#4 1911. 2. 1 1.86
#5 1911. 3. 1 1.56
#6 1911. 4. 1 2.13
#7 1911. 5. 1 2.05
#8 1911. 6. 1 1.78
#9 1911. 7. 1 1.78
#10    1911. 8. 1 1.99
#11    1911. 9. 1 2.16
#12    1911.10. 1 2.45
#13    1911.11. 1 3.59
#14    1911.12. 1 5.71

A.K.



From: eliza botto eliza_bo...@hotmail.com
To: smartpink...@yahoo.com smartpink...@yahoo.com 
Sent: Wednesday, February 20, 2013 8:25 AM
Subject: RE: data format




Dear Arun,
i have a slight inquiry, and i hope you wont mind
if i have a list of 124 like the following


[[1]]
          [,1]
 [1,] 1.200407
 [2,] 1.861941
 [3,] 1.560613
 [4,] 2.129241
 [5,] 2.047772
 [6,] 1.784105
 [7,] 1.777159
 [8,] 1.988596
 [9,] 2.163199
[10,] 2.446993
[11,] 3.593623
[12,] 5.706672

and i want them all in the following manner

[[1]]
EXACT DATA
FROM 1911 1 1 TO 1911 12 1
1911. 1. 1    1.20
1911. 2. 1    1.86
1911. 3. 1    1.56
1911. 4. 1    2.12
1911. 5. 1    2.04
1911. 6. 1    1.78
1911. 7. 1    1.77
1911. 8. 1    1.98
1911. 9. 1    2.16
1911.10. 1    2.44
1911.11. 1    3.59
1911.12. 1    5.70

date pattern should be same as before and
the following two line should be inserted on the top of every list
EXACT DATA
FROM 1911 1 1 TO 1911 12 1

thankyou so very much in advance. i hope you wont my frequent questions

elisa


 Date: Tue, 19 Feb 2013 08:18:25 -0800
 From: smartpink...@yahoo.com
 Subject: Re: data format
 To: eliza_bo...@hotmail.com
 
 
 
 Hi Elisa,
 No problem.
 Arun
 
 
 
 
 
 From: eliza botto eliza_bo...@hotmail.com
 To: smartpink...@yahoo.com smartpink...@yahoo.com 
 Sent: Tuesday, February 19, 2013 11:10 AM
 Subject: RE: data format
 
 
 
 Thanks arun. it worked!!
 i am so glad
 
 elisa
 
 
  Date: Tue, 19 Feb 2013 07:22:20 -0800
  From: smartpink...@yahoo.com
  Subject: Re: data format
  To: eliza_bo...@hotmail.com
  CC: r-help@r-project.org
  
  Hi,
  Try this:
  el- read.csv(el.csv,header=TRUE,sep=\t,stringsAsFactors=FALSE)
   elsplit- split(el,el$st)
   
  datetrial-data.frame(date1=seq.Date(as.Date(1930.1.1,format=%Y.%m.%d),as.Date(2010.12.31,format=%Y.%m.%d),by=day))
  elsplit1- lapply(elsplit,function(x) 
  data.frame(date1=as.Date(paste(x[,2],x[,3],x[,4],sep=-),format=%Y-%m-%d),discharge=x[,5]))
   elsplit2-lapply(elsplit1,function(x) x[order(x[,1]),])
  library(plyr)
  elsplit3-lapply(elsplit2,function(x) 
  join(datetrial,x,by=date1,type=full))
   elsplit4-lapply(elsplit3,function(x) {x[,2][is.na(x[,2])]- 
  -.000;x})
  elsplit5-lapply(elsplit4,function(x) {x[,1]-format(x[,1],%Y.%m.%d);x})
  elsplit6-lapply(elsplit5,function(x){substr(x[,1],6,6)-ifelse(substr(x[,1],6,6)==0,
   ,substr(x[,1],6,6));substr(x[,1],9,9)- ifelse(substr(x[,1],9,9)==0, 
  ,substr(x[,1],9,9));x})
   elsplit6[[1]][1:4,]
  #   date1 discharge
  #1 1930. 1. 1 -.000
  #2 1930. 1. 2 -.000
  #3 1930. 1. 3 -.000
  #4 1930. 1. 4 -.000
  
   length(elsplit6)
  #[1] 124
   tail(elsplit6[[124]],25)
  #   date1 discharge
  #29561 2010.12. 7 -.000
  #29562 2010.12. 8 -.000
  #29563 2010.12. 9 -.000
  #29564 2010.12.10 -.000
  #29565 2010.12.11 -.000
  #29566 2010.12.12 -.000
  #29567 2010.12.13 -.000
  #29568 2010.12.14 -.000
  #29569 2010.12.15 -.000
  #29570 2010.12.16 -.000
  #29571 2010.12.17 -.000
  #29572 2010.12.18 -.000
  #29573 2010.12.19 -.000
  #29574 2010.12.20 -.000
  #29575 2010.12.21 -.000
  #29576 2010.12.22 -.000
  #29577 2010.12.23 -.000
  #29578 2010.12.24 -.000
  #29579 2010.12.25 -.000
  #29580 2010.12.26 -.000
  #29581 2010.12.27 -.000
  #29582 2010.12.28 -.000
  #29583 2010.12.29 -.000
  #29584 2010.12.30 -.000
  #29585 2010.12.31 -.000
  
   str(head(elsplit6,3))
  #List of 3
  # $ AGOMO:'data.frame':    29585 obs. of  2 variables:
   # ..$ date1    : chr [1:29585] 1930. 1. 1 1930. 1. 2 1930. 1. 3 
  1930. 1. 4 ...
    #..$ discharge: chr [1:29585] -.000 -.000 -.000 
  -.000 ...
   #$ AGONO:'data.frame':    29585 obs. of  2 

Re: [R] 2 setGeneric's, same name, different method signatures

2013-02-20 Thread Romain Fenouil
Dear members,
please excuse me for eventual mistake in posting my first message on this
list.

I am actually glad to read these very interesting questions and answers
because I have been facing a related situation for the last 2 days. I am
writing a R package that is using some of the interesting functions offered
by Dr. Morgan's 'ShortRead' library.

I have a C++/Java background and only used R as a scripting language until
now. 
I am now writing my first class with R and everything seems fine until I
tried to define a function (accessor) named 'chromosome' for it.
Indeed this function name is already used in ShortRead library as an
accessor to the corresponding slot.

My others accessors are usually defined like this :

# Getter
setGeneric(name=pairedEnds,   def=function(object, ...)
{standardGeneric(pairedEnds)});
setMethod(  f=pairedEnds,
signature=myClass, 
definition=function(object, ...) {return(slot(object, 
pairedEnds))});

# Setter
setGeneric(name=pairedEnds-, def=function(object, value)
{standardGeneric(pairedEnds-)});
setReplaceMethod(   f=pairedEnds,
signature=AlignedData, 
definition=function(object, value) {object@pairedEnds-value;
validObject(object); return(object);});

However, I realized that when I tried to do the same with the 'chromosome'
function, calling setGeneric overrides the previous 'definition' (the
'ShortRead' one) and if I understand correctly, masked it. The consequence
is that I cannot use chromosome anymore on a 'ShortRead' object
('alignedRead').

I think I understood that we can only call setGeneric once per function
name. By the way, if I ommit my setGeneric and only use the setMethod in my
package, it seems to work correctly, probably basing it on the setGeneric
call from the ShortRead library.

My questions are :

1. Is my last statement correct ?

2. How to define a function with the same name as one previously existing in
another package ? How to avoid conflicts in case we load these two packages
at the same time ?

3. In order to avoid several calls to setGeneric, I have been thinking about
a conditional use of setGeneric 'if(!is.generic(myFunc)) setGeneric(myFunc)'
but it seems tricky and I have never seen such use, I guess this would be
problematic...

4. Is this phenomenon happening because I'm doing this in the global
environment (Testing) ? Would it be transparent when in the package
Namespace ?


This method dispatching is very disappointing to me... I believe that these
questions come from my general misunderstanding of how R OOP is designed and
I would be glad to find a reference document for S4.

Thank you very much for your help.

Romain Fenouil.



--
View this message in context: 
http://r.789695.n4.nabble.com/2-setGeneric-s-same-name-different-method-signatures-tp4658570p4659139.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] Heatmap missing in Heatmap.2 output

2013-02-20 Thread M.K. Choy

Hi,

I have a matrix 11x7761245 and I am trying to do clustering, dendrogram and 
heatmap. The analysis was completed but only the dendrogram was written in 
the jpeg file. The heatmap was missing. May I know if anyone know this 
problem?


My script: hc = hclust.vector(x, method=ward) dend = as.dendrogram(hc) 
jpeg(Plot2.jpg) 
heatmap.2(y,Colv=dend,Rowv=FALSE,dendrogram=column,trace=none,col=rev(heat.colors(30))) 
dev.off()


Many thanks,

Munkit

--
Mun-Kit Choy, PhD
Division of Cardiovascular Medicine, Department of Medicine,
Box 110, Level 6, Addenbrooke's Centre for Clinical Investigation (ACCI), 
Addenbrooke's Hospital, Hills Road, Cambridge CB2 0QQ, United Kingdom.

Tel: +44 1223 746298
Fax: +44 1223 331505

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


Re: [R] Error in setwd(outDir) : cannot change working directory

2013-02-20 Thread Gabor Grothendieck
On Wed, Feb 20, 2013 at 11:54 AM, Joanna Papakonstantinou
joanna.p...@gmail.com wrote:
 I installed R on my Windows laptop in C:\Program Files\R\R-2.15.2

 and am able to open RGUI  (640bit), see packages and run commands. However,
 when I test the installation and run the basic tests and all the tests on
 the standard and recommended packages i.e.:

   library(tools)

   testInstalledBasic(both)

   testInstalledPackages(base, errorsAreFatal = FALSE)

   testInstalledPackages(recommended, errorsAreFatal = FALSE)



 I am getting errors such as:

   testInstalledPackages(base,errorsAreFatal=FALSE)

  Error in setwd(outDir) : cannot change working directory



 my working driectory is:

getwd()

 [1] C:/Users/jpapa/Documents
  In which I see R folder as well as the .rData from my last session.

 what does the wd have to do with the output directory? Do  I need to create
 an output directory? DO I need to setwd(outDir)?

 do i need to change the wd (for example to the Pogram Files directory where
 R is installed or to another directory I need to create? if so, how do I do
 this?





 i also noticed that i have packages in

 \library ‘C:/Users/jpapa/Documents/R/win-library/2.15’

 and in library ‘C:/Program Files/R/R-2.15.2/library’.

 Do all packages need to be in one place? If so, should they be in my
 Documents or in Program Files?

Its likely trying to write in the C:\Program Files tree but lacks
permission. Run R with Administrator permissions or re-install R
elsewhere, e.g. C:\R

-- 
Statistics  Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

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


Re: [R] R and microsoft

2013-02-20 Thread Richard M. Heiberger
Please look at RExcel by Erich Neuwirth, rcom.univie.ac.at

RExcel and the underlying technology RCOM server by Thomas Baier seamlessly
integrate R into Excel and other Microsoft software on Windows.

Please see the book R through Excel by Professor Neuwirth and me.
We designed the book as a computational supplement to Statistics courses.
http://www.springer.com/978-1-4419-0051-7

On Wed, Feb 20, 2013 at 9:59 AM, teija stormi teijasto...@gmail.com wrote:

 Hi,

 I hava some questions about R and other softas.
 Which applications (softas) I can use with R? Can I connect R with
 Microsoft? Can I connect R with SPSS and how I can do it?

 I am grateful, if you can help me.

 -Teija
 teijasto...@gmail.com

 [[alternative HTML version deleted]]

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


[[alternative HTML version deleted]]

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


Re: [R] NLS results different from Excel -- Tricky fortunes nomination

2013-02-20 Thread Bert Gunter
Folks:

I thought the following excerpt from Bruce McCullough's post would be
a good candidate for the R fortunes package -- except that it's about
Excel, not R!  So I nominate it... but leave it to others to say
whether it's really qualified to be nominated.


The idea that the Excel solver has a good reputation for being fast
and accurate does not withstand an examination  of the Excel solver's
ability to solve the StRD nls test problems. ...
Excel solver does have the virtue that it will always produce an
answer, albeit one with zero accurate digits.
---

I also leave it to others to modify what is excerpted if appropriate.

Cheers,
Bert



On Wed, Feb 20, 2013 at 7:58 AM, Bruce McCullough
bdmccullo...@drexel.edu wrote:
 The idea that the Excel solver has a good reputation for being fast and
 accurate does not withstand an examination  of the Excel solver's
 ability to solve the StRD nls test problems.  Solver's ability is
 abysmal.  13 of 27 answers have zero accurate digits, and three more
 have fewer than two accurate digits -- and this is after tuning the
 solver to get a good answer.  For details see

 B. D. McCullough and Berry Wilson
 On the Accuracy of Statistical Procedures in Microsoft Excel 2000 and
 Excel XP,
 /Computational Statistics and Data Analysis/ *40*(4), 713-721, 2002

 The situation is the same for Excel 2003 and Excel 2007.  The alleged
 improvements for Excel 2010 have had not much practical effect.  Excel
 solver does have the virture that it will always produce an answer,
 albeit one with zero accurate digits.

 To see an extended example of precisely how solver fails:

 B. D. McCullough
 Some Details of Nonlinear Estimation, Chapter Eight in
 /Numerical Methods in Statistical Computing for the Social Sciences, /
 Micah Altman, Jeff Gill and Michael P. McDonald, editors
 New York: Wiley, 2004

 I am unaware of R being applied to the StRD, but I did apply S+ to the
 StRD and, with analytic derivatives, it performed flawlessly.


 On 02/19/2013 08:38 PM, r-help-requ...@r-project.org wrote:
 May I be allowed to say that the general comments on MS Excel may be alright,
 in this special case they are not.  The Excel Solver -- which is made by an
 external company, not MS -- has a good reputation for being fast and 
 accurate.
 And it indeed solves least-squares and nonlinear problems better than some of
 the solvers available in R.
 There is a professional version of this solver, not available from Microsoft,
 that could be called excellent. We, and this includes me, should not be too
 arrogant towards the outside, non-R world, the 'barbarians' as the ancient
 Greeks called it.

 Hans Werner


 --
 B. D. McCullough, Professor
 Department of Decision Sciences
 LeBow College of Business

 So what's getting ubiquitous and cheap? Data. And what is
 complementary to data? Analysis. So my recommendation is to
 take lots of courses about how to manipulate and analyze
 data: databases, machine learning, econometrics, statistics,
 visualization, and so on. Google Chief Economist, Hal Varian,
 New York Times, 25 February 2008


 [[alternative HTML version deleted]]

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



-- 

Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm

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


Re: [R] Error in setwd(outDir) : cannot change working directory

2013-02-20 Thread Gabor Grothendieck
On Wed, Feb 20, 2013 at 12:33 PM, Gabor Grothendieck
ggrothendi...@gmail.com wrote:
 On Wed, Feb 20, 2013 at 11:54 AM, Joanna Papakonstantinou
 joanna.p...@gmail.com wrote:
 I installed R on my Windows laptop in C:\Program Files\R\R-2.15.2

 and am able to open RGUI  (640bit), see packages and run commands. However,
 when I test the installation and run the basic tests and all the tests on
 the standard and recommended packages i.e.:

   library(tools)

   testInstalledBasic(both)

   testInstalledPackages(base, errorsAreFatal = FALSE)

   testInstalledPackages(recommended, errorsAreFatal = FALSE)



 I am getting errors such as:

   testInstalledPackages(base,errorsAreFatal=FALSE)

  Error in setwd(outDir) : cannot change working directory



 my working driectory is:

getwd()

 [1] C:/Users/jpapa/Documents
  In which I see R folder as well as the .rData from my last session.

 what does the wd have to do with the output directory? Do  I need to create
 an output directory? DO I need to setwd(outDir)?

 do i need to change the wd (for example to the Pogram Files directory where
 R is installed or to another directory I need to create? if so, how do I do
 this?





 i also noticed that i have packages in

 \library ‘C:/Users/jpapa/Documents/R/win-library/2.15’

 and in library ‘C:/Program Files/R/R-2.15.2/library’.

 Do all packages need to be in one place? If so, should they be in my
 Documents or in Program Files?

 Its likely trying to write in the C:\Program Files tree but lacks
 permission. Run R with Administrator permissions or re-install R
 elsewhere, e.g. C:\R

Also regarding your questions your setup is the standard desirable
setup (with a separate user library) and R in the \Program Files tree
so there seems nothing wrong with your library setup or how R itself
has been set up on your system.



-- 
Statistics  Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

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


Re: [R] Problems with line types in plots saved as PDF files

2013-02-20 Thread David Winsemius

On Feb 20, 2013, at 4:36 AM, Berend Hasselman wrote:

 
 On 20-02-2013, at 12:58, Eik Vettorazzi e.vettora...@uke.de wrote:
 
 Hi Ian,
 besides encouraging alternative pdf viewers, you just could thin out
 your interpolation grid, such as
 b = seq(-10, 10, 0.02) #instead of 0.0002
 and everything goes fine even with AcroRead XI.
 
 
 When I received the original mail this morning Mail.app on OS X 10.8.2 locked 
 up completely when I tried to access the mail.
 Both Preview and QuickLook became totally unresponsive.
 
 With the above change  a(0.02 instead of 0.0002) all goes smoothly now.

It is true that Preview.app took an inordinately long time to display on my 
system (MacOS 10.6.8, Preview 5.0.3, Mail 4.6), but going out to refill my 
coffee cup did let it succeed. I didn't try with QuickLook.


-- 
David.
 Berend
 
 
 Cheers
 
 Am 20.02.2013 01:09, schrieb Ian Renner:
 Hi,
 
 I am trying to save a plot as a PDF with different line types. In the 
 example below, R displays the plot correctly with 2 curves in solid lines, 
 2 curves in dashed lines and 1 curve as a dotted line. However, when I save 
 the image as PDF (as attached), the dashed lines become solid. This also 
 happens if I use the pdf command directly (by removing the # symbols).
 
 Is there any way around this? Saving the image as a JPEG or PNG file works 
 fine but the image quality is not desirable.
 
 b.hat = 6
 a.1 = -12
 a.2 = 0
 a.3 = 200
 
 b = seq(-10, 10, 0.0002)
 l = a.1*(b - b.hat)^2 + a.2*(b - b.hat) + a.3
 
 lambda = 20
 
 p = -lambda*abs(b)
 
 pen.like = l + p
 
 y.min = 3*min(p)
 y.max = max(c(l, p, pen.like))
 
 #pdf(file = TestPlot.pdf, 6, 6)
 #{
 plot(b, l, type = l, ylim = c(y.min, y.max), lwd = 2, xlab = 
 expression(beta), ylab = , col = green, yaxt = n, xaxt = n)
 points(b, p, type = l, lty = dotted, lwd = 2, col = red)
 points(b, pen.like, type = l, lwd = 2, lty = dashed, col = green)
 
 axis(1, at = c(0))
 axis(2, at = c(0))
 
 lambda.hat = which.max(pen.like)
 lambda.glm = which(b == b.hat)
 
 points(b[lambda.glm], l[lambda.glm], pch = 16, cex = 1.5)
 points(b[lambda.hat], l[lambda.hat], pch = 17, cex = 1.5)
 
 b.hat = -3
 a.1 = -1.5
 a.2 = 0
 a.3 = 120
 
 l = a.1*(b - b.hat)^2 + a.2*(b - b.hat) + a.3
 
 pen.like = l + p
 
 points(b, l, type = l, lwd = 2, col = blue)
 points(b, pen.like, type = l, lwd = 2, lty = dashed, col = blue)
 
 lambda.hat = which.max(pen.like)
 lambda.glm = which(b == b.hat)
 
 points(b[lambda.glm], l[lambda.glm], pch = 16, cex = 1.5)
 points(b[lambda.hat], l[lambda.hat], pch = 17, cex = 1.5)
 
 abline(h = 0)
 abline(v = 0)
 
 #}
 
 #dev.off()
 
 
 Thanks,
 
 Ian
 
 
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 
 
 -- 
 Eik Vettorazzi
 
 Department of Medical Biometry and Epidemiology
 University Medical Center Hamburg-Eppendorf
 
 Martinistr. 52
 20246 Hamburg
 
 T ++49/40/7410-58243
 F ++49/40/7410-57790
 --
 Pflichtangaben gemäß Gesetz über elektronische Handelsregister und 
 Genossenschaftsregister sowie das Unternehmensregister (EHUG):
 
 Universitätsklinikum Hamburg-Eppendorf; Körperschaft des öffentlichen 
 Rechts; Gerichtsstand: Hamburg
 
 Vorstandsmitglieder: Prof. Dr. Martin Zeitz (Vorsitzender), Dr. Alexander 
 Kirstein, Joachim Prölß, Prof. Dr. Dr. Uwe Koch-Gromus
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

David Winsemius
Alameda, CA, USA

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


Re: [R] Error in setwd(outDir) : cannot change working directory

2013-02-20 Thread Gabor Grothendieck
On Wed, Feb 20, 2013 at 1:01 PM, Joanna Papakonstantinou
joanna.p...@gmail.com wrote:
 I am running as administrator.

 Again, the first 2 tests worked but the 3rd is still giving me an error:
 testInstalledBasic(basic)
 running strict specific tests
   running code in ‘eval-etc.R’
   comparing ‘eval-etc.Rout’ to ‘eval-etc.Rout.save’ ...[1] 1
 testInstalledBasic(both)
 running strict specific tests
   running code in ‘eval-etc.R’
   comparing ‘eval-etc.Rout’ to ‘eval-etc.Rout.save’ ...[1] 1

 testInstalledPackages(base,errorsAreFatal=FALSE)
 Error in setwd(outDir) : cannot change working directory


I also got errors.  There may be something wrong with the tests themselves.


-- 
Statistics  Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

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


Re: [R] R and microsoft

2013-02-20 Thread S Ellison
 

 -Original Message-
 I hava some questions about R and other softas.
 Which applications (softas) I can use with R? Can I connect R 
 with Microsoft? Can I connect R with SPSS and how I can do it?

Information on transferring data to and from other systems can be found under 
Importing from other statistical systems  in the R data import/export manual 
in your R help system. 

***
This email and any attachments are confidential. Any use...{{dropped:8}}

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


Re: [R] Error in setwd(outDir) : cannot change working directory

2013-02-20 Thread S Ellison
 

 I am getting errors such as:
  testInstalledPackages(base,errorsAreFatal=FALSE)
 
  Error in setwd(outDir) : cannot change working directory

Er, the first parameter in  testInstalledPackages() is the output directory 
name, not the package name supplied in scope. You probably don;t have a 
writeable directory called base

Try
 testInstalledPackages(scope=base,errorsAreFatal=FALSE)

S Ellison

***
This email and any attachments are confidential. Any use...{{dropped:8}}

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


[R] Sending Email from R

2013-02-20 Thread Lopez, Dan
Hi R experts,

I know how to send simple plain text message in body and how to send with 
attachments. This is thanks to stackoverflow reference below.

But I don't know how to send dput() output in the body of the email (or 
attachment) using sendmailR. I more interested in figuring out how to include 
it as part of the body of the email.

Does anybody have experience on how to do this?

#http://stackoverflow.com/questions/2885660/how-to-send-email-with-attachment-from-r-in-windows
#?sendmailR::sendmail

library(sendmailR)

#set working directory
setwd(C:/workingdirectorypath)

#send plain email

from - y...@account.com
to - recipi...@account.com
subject - Email Subject
body - Email body.
mailControl=list(smtpServer=serverinfo)

sendmail(from=from,to=to,subject=subject,msg=body,control=mailControl)


Dan
Lawrence Livermore National Laboratory


[[alternative HTML version deleted]]

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


Re: [R] Sending Email from R

2013-02-20 Thread David Winsemius

On Feb 20, 2013, at 10:24 AM, Lopez, Dan wrote:

 Hi R experts,
 
 I know how to send simple plain text message in body and how to send with 
 attachments. This is thanks to stackoverflow reference below.
 
 But I don't know how to send dput() output in the body of the email (or 
 attachment) using sendmailR. I more interested in figuring out how to include 
 it as part of the body of the email.
 
 Does anybody have experience on how to do this?
 
 #http://stackoverflow.com/questions/2885660/how-to-send-email-with-attachment-from-r-in-windows
 #?sendmailR::sendmail
 
 library(sendmailR)
 
 #set working directory
 setwd(C:/workingdirectorypath)
 
 #send plain email
 
 from - y...@account.com
 to - recipi...@account.com
 subject - Email Subject
 body - Email body.
 mailControl=list(smtpServer=serverinfo)
 
 sendmail(from=from,to=to,subject=subject,msg=body,control=mailControl)

Does this mean you get success with the simple example you posted? There are a 
set of mime_part.* functions listed in the index for that package.

-- 

David Winsemius
Alameda, CA, USA

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


[R] To convert a quarterly data to a monthly data.

2013-02-20 Thread Yuan, Rebecca
Hello,

I have a data set has

2001Q1 100
2001Q2 101
2001Q3 120
2001Q4 103
...


And would like to convert it to a monthly data. i.e.

200101  XXX
200102  XXX
200103  XXX
200104  XXX
200105  XXX
200106  XXX
200107  XXX
200108  XXX
200109  XXX
200110  XXX
200111  XXX
200112  XXX

I googled for convert quarterly data to monthly data R but most search 
results shows how to convert monthly data to quarterly data, not the way I need.

Is there any library or function in R can do that?

Thanks very much!

Cheers,

Rebecca

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

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


Re: [R] Error in setwd(outDir) : cannot change working directory

2013-02-20 Thread Joanna Papakonstantinou
I am running as administrator.

Again, the first 2 tests worked but the 3rd is still giving me an error:
 testInstalledBasic(basic)
running strict specific tests
  running code in ‘eval-etc.R’
  comparing ‘eval-etc.Rout’ to ‘eval-etc.Rout.save’ ...[1] 1
 testInstalledBasic(both)
running strict specific tests
  running code in ‘eval-etc.R’
  comparing ‘eval-etc.Rout’ to ‘eval-etc.Rout.save’ ...[1] 1
 testInstalledPackages(base,errorsAreFatal=FALSE)
Error in setwd(outDir) : cannot change working directory


So since this my installation was standard, do you just recommend I
unistall and resintsall somewhere else?

Thank you for your help.


On Wed, Feb 20, 2013 at 11:33 AM, Gabor Grothendieck 
ggrothendi...@gmail.com wrote:

 On Wed, Feb 20, 2013 at 11:54 AM, Joanna Papakonstantinou
 joanna.p...@gmail.com wrote:
  I installed R on my Windows laptop in C:\Program Files\R\R-2.15.2
 
  and am able to open RGUI  (640bit), see packages and run commands.
 However,
  when I test the installation and run the basic tests and all the tests on
  the standard and recommended packages i.e.:
 
library(tools)
 
testInstalledBasic(both)
 
testInstalledPackages(base, errorsAreFatal = FALSE)
 
testInstalledPackages(recommended, errorsAreFatal = FALSE)
 
 
 
  I am getting errors such as:
 
testInstalledPackages(base,errorsAreFatal=FALSE)
 
   Error in setwd(outDir) : cannot change working directory
 
 
 
  my working driectory is:
 
 getwd()
 
  [1] C:/Users/jpapa/Documents
   In which I see R folder as well as the .rData from my last session.
 
  what does the wd have to do with the output directory? Do  I need to
 create
  an output directory? DO I need to setwd(outDir)?
 
  do i need to change the wd (for example to the Pogram Files directory
 where
  R is installed or to another directory I need to create? if so, how do I
 do
  this?
 
 
 
 
 
  i also noticed that i have packages in
 
  \library ‘C:/Users/jpapa/Documents/R/win-library/2.15’
 
  and in library ‘C:/Program Files/R/R-2.15.2/library’.
 
  Do all packages need to be in one place? If so, should they be in my
  Documents or in Program Files?

 Its likely trying to write in the C:\Program Files tree but lacks
 permission. Run R with Administrator permissions or re-install R
 elsewhere, e.g. C:\R

 --
 Statistics  Software Consulting
 GKX Group, GKX Associates Inc.
 tel: 1-877-GKX-GROUP
 email: ggrothendieck at gmail.com




-- 
**


*Joanna Papakonstantinou, Ph.D.*

[[alternative HTML version deleted]]

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


[R] duplicate 'row.names' are not allowed

2013-02-20 Thread Joanna Papakonstantinou
I am getting an error when trying to import tab delimited .txt file saved
from Excel.
I have read what is posted on the forums but still am confused.

I saved my Excel file (DataTestforR.xlsx) as a tab delimited txt file
(DataTestR.txt) on my Desktop.
In the RGUI, I tried to import the txt file and got an error

 myfile-C:\\Users\\jpapa\\Desktop\\DataTestR.txt
 mydf-read.delim(myfile, header=TRUE,sep= , dec=.)
Error in read.table(file = file, header = header, sep = sep, quote =
quote,  :
  duplicate 'row.names' are not allowed

The first row of my file has column names and the first column of my file
has unique identifing names (not duplicated):
Cu Sa Na Ci Se NM NPI IPI Seg
0090.00 15.48 1 SOM S L TX 0 0.2 0.2 7-Very
10997.00 64.62 123 B C NJ 0 0.01 0.04 7-Very

Please tell me what I am doing wrong.

Thank you.
**


*Joanna Papakonstantinou, Ph.D.*

[[alternative HTML version deleted]]

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


Re: [R] Error in setwd(outDir) : cannot change working directory

2013-02-20 Thread Gabor Grothendieck
On Wed, Feb 20, 2013 at 1:08 PM, Gabor Grothendieck
ggrothendi...@gmail.com wrote:
 On Wed, Feb 20, 2013 at 1:01 PM, Joanna Papakonstantinou
 joanna.p...@gmail.com wrote:
 I am running as administrator.

 Again, the first 2 tests worked but the 3rd is still giving me an error:
 testInstalledBasic(basic)
 running strict specific tests
   running code in ‘eval-etc.R’
   comparing ‘eval-etc.Rout’ to ‘eval-etc.Rout.save’ ...[1] 1
 testInstalledBasic(both)
 running strict specific tests
   running code in ‘eval-etc.R’
   comparing ‘eval-etc.Rout’ to ‘eval-etc.Rout.save’ ...[1] 1

 testInstalledPackages(base,errorsAreFatal=FALSE)
 Error in setwd(outDir) : cannot change working directory


 I also got errors.  There may be something wrong with the tests themselves.

Just a clarification.  The errors I was referring to was the fact that
both you and I got a result of 1 for the first too. That indicates
that the test and target differed.


-- 
Statistics  Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

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


Re: [R] Error in setwd(outDir) : cannot change working directory

2013-02-20 Thread Joanna Papakonstantinou
I ran
testInstalledPackages(scope=base,errorsAreFatal=FALSE)
and it completed (and spit out a graph).

Does this mean I am ok to contunie using this installation of R?
Should I create an output directory somewhere either in Program Files where
R is installed or in my working directory?
Thank you for your time and help.

On Wed, Feb 20, 2013 at 12:20 PM, S Ellison s.elli...@lgcgroup.com wrote:



  I am getting errors such as:
   testInstalledPackages(base,errorsAreFatal=FALSE)
 
   Error in setwd(outDir) : cannot change working directory

 Er, the first parameter in  testInstalledPackages() is the output
 directory name, not the package name supplied in scope. You probably don;t
 have a writeable directory called base

 Try
  testInstalledPackages(scope=base,errorsAreFatal=FALSE)

 S Ellison

 ***
 This email and any attachments are confidential. Any u...{{dropped:20}}

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


Re: [R] a priori power analysis for glm, family = poisson

2013-02-20 Thread Joerg Luedicke
Probably the best way of doing this is via simulation. Have a look at
chapter 5 of:

Bolker, B. 2008. Ecological models and data in R. Princeton Univ. Press,
Princeton, NJ.

for an introduction and a bunch of examples.

Joerg


On Wed, Feb 20, 2013 at 5:49 AM, Chad Widmer cw...@st-andrews.ac.uk wrote:
 Dear R/statistics wizards,



 This may be more of a statistics question than an R one, but I’m hoping
 that someone has the time to help.  I’ve already consulted a few local
 statisticians and I’ve not yet received a clear answer.  Before I start an
 experiment I want to conduct an a priori power analysis test for a
 Generalized Linear Model, family = poisson.  The response variables will be
 counts.  I want to look at the effects of 5 temperatures and 3 salinities,
 and their interaction in 15 different combinations (5 temperatures each
 testing 3 different salinity levels).   I am hoping to learn the power I
 would achieve if I used a sample size of 18 in each of the combinations,
 for a total sample size N = 270.



 Does such a power analysis exist?  Can I just use a power analysis for a
 linear model since the glm is an extension of that (which seems to make
 sense), or maybe even one from a 2 way anova? Can someone show me the path
 of righteousness in R, or point me in the right direction please?



 Thank you very much for your valuable time.

 Chad

 [[alternative HTML version deleted]]


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


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


Re: [R] Error in setwd(outDir) : cannot change working directory

2013-02-20 Thread Gabor Grothendieck
On Wed, Feb 20, 2013 at 2:01 PM, Joanna Papakonstantinou
joanna.p...@gmail.com wrote:
 I ran
testInstalledPackages(scope=base,errorsAreFatal=FALSE)
 and it completed (and spit out a graph).

 Does this mean I am ok to contunie using this installation of R?
 Should I create an output directory somewhere either in Program Files where
 R is installed or in my working directory?
 Thank you for your time and help.


Those tests don't seem to be working and I think you should ignore
them.  You should not have to create an output directory.  Installing
R is just a matter of clicking on OK repeatedly to the installer.
Everything else is optional, e.g. placing R on your Windows path,
installing Rtools to build packages (although increasingly even that
seems unnecessary for some packages and if you download binaries you
don't have to build packages in the first place), creating a
customized startup via .Rprofile or related files.

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


Re: [R] duplicate 'row.names' are not allowed

2013-02-20 Thread David Winsemius

On Feb 20, 2013, at 10:14 AM, Joanna Papakonstantinou wrote:

 I am getting an error when trying to import tab delimited .txt file saved
 from Excel.
 I have read what is posted on the forums but still am confused.
 
 I saved my Excel file (DataTestforR.xlsx) as a tab delimited txt file
 (DataTestR.txt) on my Desktop.
 In the RGUI, I tried to import the txt file and got an error
 
 myfile-C:\\Users\\jpapa\\Desktop\\DataTestR.txt
 mydf-read.delim(myfile, header=TRUE,sep= , dec=.)
 Error in read.table(file = file, header = header, sep = sep, quote =
 quote,  :
  duplicate 'row.names' are not allowed
 
 The first row of my file has column names and the first column of my file
 has unique identifing names (not duplicated):
 Cu Sa Na Ci Se NM NPI IPI Seg
 0090.00 15.48 1 SOM S L TX 0 0.2 0.2 7-Very

I count 11 data columns and nine column names.

-- 
Alameda, CA, USA

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


Re: [R] NLS results different from Excel -- Tricky fortunes nomination

2013-02-20 Thread Rolf Turner


I think that this nomination is a Good Idea!

cheers,

Rolf

On 02/21/2013 06:50 AM, Bert Gunter wrote:

Folks:

I thought the following excerpt from Bruce McCullough's post would be
a good candidate for the R fortunes package -- except that it's about
Excel, not R!  So I nominate it... but leave it to others to say
whether it's really qualified to be nominated.


The idea that the Excel solver has a good reputation for being fast
and accurate does not withstand an examination  of the Excel solver's
ability to solve the StRD nls test problems. ...
Excel solver does have the virtue that it will always produce an
answer, albeit one with zero accurate digits.
---

I also leave it to others to modify what is excerpted if appropriate.


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


Re: [R] NLS results different from Excel

2013-02-20 Thread Marc Schwartz
Just as an FYI, there is the NISTnls package on CRAN by Doug Bates:

  http://cran.r-project.org/web/packages/NISTnls/index.html

There have also been threads over the years touching on some of the issues in 
replicating the NIST results, for example:

  http://tolstoy.newcastle.edu.au/R/devel/06/07/6331.html

Regards,

Marc Schwartz

On Feb 20, 2013, at 9:58 AM, Bruce McCullough bdmccullo...@drexel.edu wrote:

 The idea that the Excel solver has a good reputation for being fast and 
 accurate does not withstand an examination  of the Excel solver's 
 ability to solve the StRD nls test problems.  Solver's ability is 
 abysmal.  13 of 27 answers have zero accurate digits, and three more 
 have fewer than two accurate digits -- and this is after tuning the 
 solver to get a good answer.  For details see
 
 B. D. McCullough and Berry Wilson
 On the Accuracy of Statistical Procedures in Microsoft Excel 2000 and 
 Excel XP,
 /Computational Statistics and Data Analysis/ *40*(4), 713-721, 2002
 
 The situation is the same for Excel 2003 and Excel 2007.  The alleged 
 improvements for Excel 2010 have had not much practical effect.  Excel 
 solver does have the virture that it will always produce an answer, 
 albeit one with zero accurate digits.
 
 To see an extended example of precisely how solver fails:
 
 B. D. McCullough
 Some Details of Nonlinear Estimation, Chapter Eight in
 /Numerical Methods in Statistical Computing for the Social Sciences, /
 Micah Altman, Jeff Gill and Michael P. McDonald, editors
 New York: Wiley, 2004
 
 I am unaware of R being applied to the StRD, but I did apply S+ to the 
 StRD and, with analytic derivatives, it performed flawlessly.
 
 
 On 02/19/2013 08:38 PM, r-help-requ...@r-project.org wrote:
 May I be allowed to say that the general comments on MS Excel may be alright,
 in this special case they are not.  The Excel Solver -- which is made by an
 external company, not MS -- has a good reputation for being fast and 
 accurate.
 And it indeed solves least-squares and nonlinear problems better than some of
 the solvers available in R.
 There is a professional version of this solver, not available from Microsoft,
 that could be called excellent. We, and this includes me, should not be too
 arrogant towards the outside, non-R world, the 'barbarians' as the ancient
 Greeks called it.
 
 Hans Werner
 
 
 -- 
 B. D. McCullough, Professor
 Department of Decision Sciences
 LeBow College of Business

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


Re: [R] To convert a quarterly data to a monthly data.

2013-02-20 Thread Rolf Turner



This question doesn't make a lot of sense to me.  What do
you expect/want your XXX values to be?  If you only know
that the value for the first quarter was 100, you cannot infer
the individual values for January, February and March.  All
you know is that these values sum to 100.

cheers,

Rolf Turner

On 02/21/2013 08:15 AM, Yuan, Rebecca wrote:

Hello,

I have a data set has

2001Q1 100
2001Q2 101
2001Q3 120
2001Q4 103
...


And would like to convert it to a monthly data. i.e.

200101  XXX
200102  XXX
200103  XXX
200104  XXX
200105  XXX
200106  XXX
200107  XXX
200108  XXX
200109  XXX
200110  XXX
200111  XXX
200112  XXX

I googled for convert quarterly data to monthly data R but most search 
results shows how to convert monthly data to quarterly data, not the way I need.

Is there any library or function in R can do that?

Thanks very much!



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


Re: [R] To convert a quarterly data to a monthly data.

2013-02-20 Thread Yuan, Rebecca
Hello Rolf,

Thanks for your kind reply!

I figured out there is a function splint in fields that can do the cubic spine 
interpolation which would enable me to get the monthly series from the 
quarterly series.

Problem solved.

Here is the code I use the do the task:

out - cbind(out, splint(qtrly$rDate, qtrly[,names(qtrly)[i]] ,subset(mthly, 
rDate = max(qtrly$rDate))$rDate ))

where qtrly is the quarterly data and mthly is the monthly data.

Cheers,

Rebecca

-Original Message-
From: Rolf Turner [mailto:rolf.tur...@xtra.co.nz] 
Sent: Wednesday, February 20, 2013 3:14 PM
To: Yuan, Rebecca
Cc: R help
Subject: Re: [R] To convert a quarterly data to a monthly data.



This question doesn't make a lot of sense to me.  What do you expect/want your 
XXX values to be?  If you only know that the value for the first quarter was 
100, you cannot infer the individual values for January, February and March.  
All you know is that these values sum to 100.

 cheers,

 Rolf Turner

On 02/21/2013 08:15 AM, Yuan, Rebecca wrote:
 Hello,

 I have a data set has

 2001Q1 100
 2001Q2 101
 2001Q3 120
 2001Q4 103
 ...


 And would like to convert it to a monthly data. i.e.

 200101  XXX
 200102  XXX
 200103  XXX
 200104  XXX
 200105  XXX
 200106  XXX
 200107  XXX
 200108  XXX
 200109  XXX
 200110  XXX
 200111  XXX
 200112  XXX

 I googled for convert quarterly data to monthly data R but most search 
 results shows how to convert monthly data to quarterly data, not the way I 
 need.

 Is there any library or function in R can do that?

 Thanks very much!




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

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


Re: [R] To convert a quarterly data to a monthly data.

2013-02-20 Thread Berend Hasselman

On 20-02-2013, at 21:13, Rolf Turner rolf.tur...@xtra.co.nz wrote:

 
 
 This question doesn't make a lot of sense to me.  What do
 you expect/want your XXX values to be?

Well the OP wants some sort of interpolation.

  If you only know
 that the value for the first quarter was 100, you cannot infer
 the individual values for January, February and March.  All
 you know is that these values sum to 100.

And if you a value for the second quarter you can interpolate.

The quarterly data could be stock data such as a money stock.
In that case the new values wouldn't sum to e.g. 100.
The quarterly data would be located at the start or end of a quarter.

The OP didn't specify if the data were stocks or flows.
The spline method the OP used is a perfectly reasonable route to take.

If you have a model for the low frequency data there  is  a very new package 
for temporal disagggregation: tempdisagg.
CRAN Task View: Time Series Analysis provide more timeseries stuff.
I think that package zoo could also help but I haven't been able to construct 
an example.

For the OP: are your quarterly data stocks of flows?
If they are flows you probably want the interpolated monthly values to sum to 
the quarterly value.
If they are stocks you should specify if your quarterly values are 
end-of-quarter or start-of-quarter.

Berend

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


Re: [R] To convert a quarterly data to a monthly data.

2013-02-20 Thread Berend Hasselman

On 20-02-2013, at 21:21, Yuan, Rebecca rebecca.y...@bankofamerica.com wrote:

 Hello Rolf,
 
 Thanks for your kind reply!
 
 I figured out there is a function splint in fields that can do the cubic 
 spine interpolation which would enable me to get the monthly series from the 
 quarterly series.
 
 Problem solved.
 
 Here is the code I use the do the task:
 
 out - cbind(out, splint(qtrly$rDate, qtrly[,names(qtrly)[i]] ,subset(mthly, 
 rDate = max(qtrly$rDate))$rDate ))
 
 where qtrly is the quarterly data and mthly is the monthly data.


Here is an example using package zoo:

library(zoo)
yq - zooreg(c(100,101,120,103), start=2000, frequency=4)

# complicated method
zm - zooreg(rep(NA,12),start=2000,freq=12)
merge(yq,zm)
na.spline(merge(yq, zm)[, 1])

# Easy direct method taken from help pages of zoo

na.spline(yq, xout=as.yearmon(start(yq)+(0:11)/12)) 

or 

na.approx(yq, xout=as.yearmon(start(yq)+(0:11)/12))  


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


Re: [R] 2 setGeneric's, same name, different method signatures

2013-02-20 Thread Martin Morgan

On 02/20/2013 02:19 AM, Romain Fenouil wrote:

Dear members,
please excuse me for eventual mistake in posting my first message on this
list.

I am actually glad to read these very interesting questions and answers
because I have been facing a related situation for the last 2 days. I am
writing a R package that is using some of the interesting functions offered
by Dr. Morgan's 'ShortRead' library.

I have a C++/Java background and only used R as a scripting language until
now.
I am now writing my first class with R and everything seems fine until I
tried to define a function (accessor) named 'chromosome' for it.
Indeed this function name is already used in ShortRead library as an
accessor to the corresponding slot.

My others accessors are usually defined like this :

# Getter
setGeneric(name=pairedEnds, def=function(object, ...)
{standardGeneric(pairedEnds)});
setMethod(  f=pairedEnds,
signature=myClass,
definition=function(object, ...) {return(slot(object, 
pairedEnds))});

# Setter
setGeneric(name=pairedEnds-,def=function(object, value)
{standardGeneric(pairedEnds-)});
setReplaceMethod(   f=pairedEnds,
signature=AlignedData,
definition=function(object, value) {object@pairedEnds-value;
validObject(object); return(object);});

However, I realized that when I tried to do the same with the 'chromosome'
function, calling setGeneric overrides the previous 'definition' (the
'ShortRead' one) and if I understand correctly, masked it. The consequence
is that I cannot use chromosome anymore on a 'ShortRead' object
('alignedRead').


actually, the original generic and its methods are still available with

  ShortRead::chromosome



I think I understood that we can only call setGeneric once per function
name. By the way, if I ommit my setGeneric and only use the setMethod in my
package, it seems to work correctly, probably basing it on the setGeneric
call from the ShortRead library.

My questions are :

1. Is my last statement correct ?


maybe; you should have in your DESCRIPTION file

  Imports: ShortRead

and in your NAMESPACE file

  importFrom(ShortRead, chromosome)


2. How to define a function with the same name as one previously existing in
another package ? How to avoid conflicts in case we load these two packages
at the same time ?


inside your package, you're free to do what you like. If you don't want to 
re-use the ShortRead::chromosome generic, then don't importFrom(ShortRead, 
chromosome)




3. In order to avoid several calls to setGeneric, I have been thinking about
a conditional use of setGeneric 'if(!is.generic(myFunc)) setGeneric(myFunc)'
but it seems tricky and I have never seen such use, I guess this would be
problematic...


this used to be an idiom when there was no NAMESPACE, but inside your package 
you know what generics are defined (you've imported them explicitly) so no need 
to test whether they exist or not.




4. Is this phenomenon happening because I'm doing this in the global
environment (Testing) ? Would it be transparent when in the package
Namespace ?



Yes to some extent there are fewer conflicts -- inside your package -- when 
using a NAMESPACE.



This method dispatching is very disappointing to me... I believe that these
questions come from my general misunderstanding of how R OOP is designed and
I would be glad to find a reference document for S4.


I would guess that what you want to do is reuse the ShortRead generic, not 
create a new one, and add your method to it


DESCRIPTION:
  Imports: ShortRead

NAMESPACE:

  importFrom(ShortRead, chromosome)
  exportMethods(chromosome)

R/somewhere.R

  setMethod(chromosome, MyClass, function(object, ...) {
  ## implementation
  })

Hope that helps, and good luck with your package.

Martin




Thank you very much for your help.

Romain Fenouil.



--
View this message in context: 
http://r.789695.n4.nabble.com/2-setGeneric-s-same-name-different-method-signatures-tp4658570p4659139.html
Sent from the R help mailing list archive at Nabble.com.

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




--
Computational Biology / Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N.
PO Box 19024 Seattle, WA 98109

Location: Arnold Building M1 B861
Phone: (206) 667-2793

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


Re: [R] Sending Email from R

2013-02-20 Thread David Winsemius

On Feb 20, 2013, at 10:44 AM, David Winsemius wrote:

 
 On Feb 20, 2013, at 10:24 AM, Lopez, Dan wrote:
 
 Hi R experts,
 
 I know how to send simple plain text message in body and how to send with 
 attachments. This is thanks to stackoverflow reference below.
 
 But I don't know how to send dput() output in the body of the email (or 
 attachment) using sendmailR. I more interested in figuring out how to 
 include it as part of the body of the email.
 
 Does anybody have experience on how to do this?
 
 #http://stackoverflow.com/questions/2885660/how-to-send-email-with-attachment-from-r-in-windows
 #?sendmailR::sendmail
 
 library(sendmailR)
 
 #set working directory
 setwd(C:/workingdirectorypath)
 
 #send plain email
 
 from - y...@account.com
 to - recipi...@account.com
 subject - Email Subject
 body - Email body.
 mailControl=list(smtpServer=serverinfo)
 
 sendmail(from=from,to=to,subject=subject,msg=body,control=mailControl)
 
 Does this mean you get success with the simple example you posted?

This might be critical. There was a 2010 posting from Barry Rowlingson saying 
that 'sendmail' in sendmailR was unable to provide smtp-authorization. I got an 
error message regarding authorization when I added my password.

http://markmail.org/search/?q=list%3Aorg.r-project.r-help+sendmail+authentication#query:list%3Aorg.r-project.r-help%20sendmail%20authentication+page:1+mid:pwfqwwwumgwtcqx7+state:results

That thread also included Ben Bolker's offer of code in package:Rmail at:

http://www.math.mcmaster.ca/~bolker/R/src/contrib/

I was able to get Lin Himmelmann's  mail::sendmail function to send a message 
to myself. Looking at the code it appears Lin has set up a PHP server and is 
parsing an http: request. It also doesn't look like it is intended to be 
general solution since there is a message saying the numbers of messages are 
limited.

-- 

David Winsemius
Alameda, CA, USA

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


[R] Problem with levelplot() in a loop

2013-02-20 Thread Nikhil Joshi
Dear R users,
I am trying to print heatmaps in a loop (with a pause).  Idea is to
visualize changing correlations over time and for testing I wrote this
simple (reproducible) code below.
My problem is that levelplot() does not produce any output when I run the
code (though heatmap does).  Ideally I would like to use levelplot() as it
produces a neat index on the side indicating the color and the correlation
value that it corresponds to while heatmap does not.  Any pointers as to
how I can make levelplot() produce output in the loop or get heatmap to
procude a nice index like levelplot() does?
ps- To see the output with heatmap in a loop, just uncomment the heatmap()
line and comment out the levelplot() line

col.l - colorRampPalette(c('blue', 'green', 'yellow', 'red'))(30)
for (i in 1:10)
{
  randmat - cbind(rnorm(100),rnorm(100),rnorm(100),rnorm(100),rnorm(100))
  colnames(randmat) - c('A','B','C','D','E')
  cormat - cor(randmat)
  levelplot(cormat,xlab=NULL,ylab=NULL,main='Correlation Heat
Map',col.regions=col.l)
#  heatmap(cormat,col=col.l,Rowv=NA, Colv=NA,main=paste(Plot:,i,sep=''))
  Sys.sleep(1)
}

Thanks much in advance!

[[alternative HTML version deleted]]

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


Re: [R] Problem with levelplot() in a loop

2013-02-20 Thread John Kane
I think you need a print command in there

John Kane
Kingston ON Canada


 -Original Message-
 From: nikhiljo...@gmail.com
 Sent: Wed, 20 Feb 2013 16:38:56 -0500
 To: r-help@r-project.org
 Subject: [R] Problem with levelplot() in a loop
 
 Dear R users,
 I am trying to print heatmaps in a loop (with a pause).  Idea is to
 visualize changing correlations over time and for testing I wrote this
 simple (reproducible) code below.
 My problem is that levelplot() does not produce any output when I run the
 code (though heatmap does).  Ideally I would like to use levelplot() as
 it
 produces a neat index on the side indicating the color and the
 correlation
 value that it corresponds to while heatmap does not.  Any pointers as to
 how I can make levelplot() produce output in the loop or get heatmap to
 procude a nice index like levelplot() does?
 ps- To see the output with heatmap in a loop, just uncomment the
 heatmap()
 line and comment out the levelplot() line
 
 col.l - colorRampPalette(c('blue', 'green', 'yellow', 'red'))(30)
 for (i in 1:10)
 {
   randmat -
 cbind(rnorm(100),rnorm(100),rnorm(100),rnorm(100),rnorm(100))
   colnames(randmat) - c('A','B','C','D','E')
   cormat - cor(randmat)
   levelplot(cormat,xlab=NULL,ylab=NULL,main='Correlation Heat
 Map',col.regions=col.l)
 #  heatmap(cormat,col=col.l,Rowv=NA,
 Colv=NA,main=paste(Plot:,i,sep=''))
   Sys.sleep(1)
 }
 
 Thanks much in advance!
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks  orcas on your 
desktop!

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


Re: [R] Sending Email from R

2013-02-20 Thread Lopez, Dan
David

Thanks for the other resources. But I think those don't solve my problem.

FYI I used sendmailR:sendmail without password.

This is more or less how I ended up doing it. I can send a simple plain email 
or a simple plain email with an attachment or few attachments. Not sure if it 
makes a difference but in this test I am sending to myself from within the 
company

I am just trying to figure out how to email the contents from dput(). Whenever 
I try it prints it to the screen and the contents don't appear in the email at 
all: body or attachment. If I try it as an attachment (that's the mime_part()) 
the attachment is blank.

## Not run: 
from - lopez...@llnl.gov
to - lopez...@llnl.gov
subject - This email from R
body - list(It works!, mime_part(iris))  
mailControl=list(smtpServer=thing.thing.gov)

sendmail(from=from,to=to,subject=subject,msg=body,control=mailControl)
## End(Not run)

Thanks.
Dan


-Original Message-
From: David Winsemius [mailto:dwinsem...@comcast.net] 
Sent: Wednesday, February 20, 2013 11:59 AM
To: David Winsemius
Cc: Lopez, Dan; R help (r-help@r-project.org)
Subject: Re: [R] Sending Email from R


On Feb 20, 2013, at 10:44 AM, David Winsemius wrote:

 
 On Feb 20, 2013, at 10:24 AM, Lopez, Dan wrote:
 
 Hi R experts,
 
 I know how to send simple plain text message in body and how to send with 
 attachments. This is thanks to stackoverflow reference below.
 
 But I don't know how to send dput() output in the body of the email (or 
 attachment) using sendmailR. I more interested in figuring out how to 
 include it as part of the body of the email.
 
 Does anybody have experience on how to do this?
 
http://stackoverflow.com/questions/2885660/how-to-send-email-with-attachment-from-r-in-windows

 #?sendmailR::sendmail
 
 library(sendmailR)
 
 #set working directory
 setwd(C:/workingdirectorypath)
 
 #send plain email
 
 from - y...@account.com
 to - recipi...@account.com
 subject - Email Subject
 body - Email body.
 mailControl=list(smtpServer=serverinfo)
 
 sendmail(from=from,to=to,subject=subject,msg=body,control=mailControl)
 
 Does this mean you get success with the simple example you posted?

This might be critical. There was a 2010 posting from Barry Rowlingson saying 
that 'sendmail' in sendmailR was unable to provide smtp-authorization. I got an 
error message regarding authorization when I added my password.

http://markmail.org/search/?q=list%3Aorg.r-project.r-help+sendmail+authentication#query:list%3Aorg.r-project.r-help%20sendmail%20authentication+page:1+mid:pwfqwwwumgwtcqx7+state:results

That thread also included Ben Bolker's offer of code in package:Rmail at:

http://www.math.mcmaster.ca/~bolker/R/src/contrib/ 


I was able to get Lin Himmelmann's  mail::sendmail function to send a message 
to myself. Looking at the code it appears Lin has set up a PHP server and is 
parsing an http: request. It also doesn't look like it is intended to be 
general solution since there is a message saying the numbers of messages are 
limited.

-- 

David Winsemius
Alameda, CA, USA

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


Re: [R] Why R simulation gives same random results?

2013-02-20 Thread Nordlund, Dan (DSHS/RDA)
 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
 project.org] On Behalf Of C W
 Sent: Tuesday, February 19, 2013 5:32 PM
 To: r-help
 Subject: [R] Why R simulation gives same random results?
 
 Hi, list
 I am doing 100,000 iterations of Bayesian simulations.
 
 What I did is I split it into 4 different R sessions, each one runs
 25,000
 iteration.  But two of the sessions gave the simulation result.
 
 I did not use any set.seed().  What is going on here?
 
 Thanks,
 Mike
 

I may have missed it, but I haven't seen a response to this question yet.  If 
no one has responded, it is probably because you haven't provided the code you 
used to run the simulation, or a reproducible example which demonstrates the 
problem.  You say you didn't use set.seed(), but you didn't show what you did 
do, so there is insufficient information for anyone to be able to comment what 
went wrong.

Dan 

Daniel J. Nordlund
Washington State Department of Social and Health Services
Planning, Performance, and Accountability
Research and Data Analysis Division
Olympia, WA 98504-5204

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


[R] Tracking time-varying objects with the DLM package (dynamic linear models in R)

2013-02-20 Thread Samantha Azzarello
Hello all,

I am working with the dlm package, specifcially doing a dlm multivariate Y
linear regression using
dlmModReg and dlmFilter and dlmSmooth...

I have altereted the inputs into dlmModReg to make them time-varying using
JFF, JW etc.

How do I track the results of the time varying system matrices?
For example what I am really interested in is JW - my system variance matrix
for each time period - I cannot get R to give
me the array of this matrix

Any help would be really appreciated!
Thanks



--
View this message in context: 
http://r.789695.n4.nabble.com/Tracking-time-varying-objects-with-the-DLM-package-dynamic-linear-models-in-R-tp4659211.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Why R simulation gives same random results?

2013-02-20 Thread Greg Snow
To know for sure we need to know how you are running these different R
sessions, but here are some possibilities:

The help page for set.seed says that if no seed exists then the seed is
set based on the current time (and since 2.14.0 the process ID).  So one
possibility is that 2 of the sessions are started close enough together
that they get the same seed.  Or the difference in time and process ID
cancel each other out.

Another possibility (also mentioned in the help page) is that if the seed
was saved in a previous session then it will be restored in the new
session, if all the sessions are reading in the same stored session (or
just the 2 that are the same) then they would start from the same seed.


On Tue, Feb 19, 2013 at 6:31 PM, C W tmrs...@gmail.com wrote:

 Hi, list
 I am doing 100,000 iterations of Bayesian simulations.

 What I did is I split it into 4 different R sessions, each one runs 25,000
 iteration.  But two of the sessions gave the simulation result.

 I did not use any set.seed().  What is going on here?

 Thanks,
 Mike

 [[alternative HTML version deleted]]

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




-- 
Gregory (Greg) L. Snow Ph.D.
538...@gmail.com

[[alternative HTML version deleted]]

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


Re: [R] Why R simulation gives same random results?

2013-02-20 Thread C W
Thanks, Greg.  I think you are right.  I did simulation one right after the
other, less than 2 seconds.

But still, it was shocking to see identical samples, which I had to throw
away.

As a rule of thumb, should I do simulation in one R console, rather than
splitting the work into 2 consoles.  I just thought it would take less time
for me, but it seems risky.

Thanks,
Mike


On Wed, Feb 20, 2013 at 6:13 PM, Greg Snow 538...@gmail.com wrote:

 To know for sure we need to know how you are running these different R
 sessions, but here are some possibilities:

 The help page for set.seed says that if no seed exists then the seed is
 set based on the current time (and since 2.14.0 the process ID).  So one
 possibility is that 2 of the sessions are started close enough together
 that they get the same seed.  Or the difference in time and process ID
 cancel each other out.

 Another possibility (also mentioned in the help page) is that if the seed
 was saved in a previous session then it will be restored in the new
 session, if all the sessions are reading in the same stored session (or
 just the 2 that are the same) then they would start from the same seed.


 On Tue, Feb 19, 2013 at 6:31 PM, C W tmrs...@gmail.com wrote:

 Hi, list
 I am doing 100,000 iterations of Bayesian simulations.

 What I did is I split it into 4 different R sessions, each one runs 25,000
 iteration.  But two of the sessions gave the simulation result.

 I did not use any set.seed().  What is going on here?

 Thanks,
 Mike

 [[alternative HTML version deleted]]


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




 --
 Gregory (Greg) L. Snow Ph.D.
 538...@gmail.com


[[alternative HTML version deleted]]

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


[R] Plotting Discriminants from qda

2013-02-20 Thread Melanie Zoelck
Dear R Help Members,

I am aware how to plot the LD1 vs LD2 from a lda in R, using the code:

plot(baseline.systat.hat$x, 
col=baseline.systat.hat$class,pch=as.numeric(baseline.systat.hat$class))

However, I need to use the quadratic discriminant function, qda due to data 
properties. Is there a way to obtain the same sort of plot for from a qda 
object (and the output of predict qda). I have not been able to find this and 
am a bit stumped. I cannot seem to find any information on plotting this.

Thank you,

Melanie

Melanie Zölck (Zoelck)
PhD Candidate
Galway-Mayo Institute of Technology
Marine and Freshwater Research Centre
Commercial Fisheries Research Group
Department of Life Science
Dublin Road
Galway
Republic of Ireland
Mobile: +353 (0) 85 7246196
Skype: melaniezoelck
E-mail: mzoe...@gmx.com or mzoe...@hotmaill.com


[[alternative HTML version deleted]]

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


Re: [R] duplicate 'row.names' are not allowed

2013-02-20 Thread Joanna Papakonstantinou
Some of the names in the columns actually have spaces in them (e.g., S L TX
is in one column). So there are really 9.
I was able to save the file as a csv file and read.table succesfully.

On Wed, Feb 20, 2013 at 2:03 PM, David Winsemius dwinsem...@comcast.netwrote:


 On Feb 20, 2013, at 10:14 AM, Joanna Papakonstantinou wrote:

  I am getting an error when trying to import tab delimited .txt file saved
  from Excel.
  I have read what is posted on the forums but still am confused.
 
  I saved my Excel file (DataTestforR.xlsx) as a tab delimited txt file
  (DataTestR.txt) on my Desktop.
  In the RGUI, I tried to import the txt file and got an error
 
  myfile-C:\\Users\\jpapa\\Desktop\\DataTestR.txt
  mydf-read.delim(myfile, header=TRUE,sep= , dec=.)
  Error in read.table(file = file, header = header, sep = sep, quote =
  quote,  :
   duplicate 'row.names' are not allowed
 
  The first row of my file has column names and the first column of my file
  has unique identifing names (not duplicated):
  Cu Sa Na Ci Se NM NPI IPI Seg
  0090.00 15.48 1 SOM S L TX 0 0.2 0.2 7-Very

 I count 11 data columns and nine column names.

 --
 Alameda, CA, USA




-- 
**


*Joanna Papakonstantinou, Ph.D.*

[[alternative HTML version deleted]]

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


Re: [R] subsetting with greater than and less than indexing

2013-02-20 Thread iembry
Hi Arun, thank-you for your assistance.

I'm sorry that I did not provide a reproducible example. I will provide
a reproducible example the next time.

Using the next to last line of your code I was able to get what I needed
without using the for loop. 

Thanks again.

Irucka


-Original Message- 
From: arun kirshna [via R] [ml-node+s789695n4659154...@n4.nabble.com]
Sent: 2/20/2013 8:49:22 AM
To: iruc...@mail2world.com
Subject: Re: subsetting with greater than and less than indexing

Hi, 
It is better to provide a reproducible example. So, not sure about the
problem 

Using another example: 
mat1-matrix(signif(c(1.200407,1.861941,1.560613,2.129241,2.047772,1.78
4105,1.777159,1.988596,2.163199,2.446993,3.593623,5.706672),digits=3),nc
ol=1)

 list1- list(mat1,mat1,mat1) 
list2-lapply(list1,function(x)
data.frame(date1=format(seq.Date(as.Date(1911.01.01,format=%Y.%m.%d
),by=month,length.out=12),format=%Y.%m.%d),value=x,stringsAsFactors=
FALSE))

 res-lapply(seq_along(list2),function(i) subset(list2[[i]],value1.99
value2.45)) 
res[[1]] 
# date1 value 
#4 1911.04.01 2.13 
#5 1911.05.01 2.05 
#9 1911.09.01 2.16 
A.K. 




If you reply to this email, your message will be added to the
discussion below:
http://r.789695.n4.nabble.com/subsetting-with-greater-than-and-less-tha
n-indexing-tp4659142p4659154.html

To unsubscribe from subsetting with greater than and less than
indexing, click here.
NAML 


span id=m2wTlpfont face=Arial, Helvetica, sans-serif size=2 
style=font-size:13.5px___BRGet
 the Free email that has everyone talking at a href=http://www.mail2world.com 
target=newhttp://www.mail2world.com/abr  font color=#99Unlimited 
Email Storage #150; POP3 #150; Calendar #150; SMS #150; Translator #150; 
Much More!/font/font/span



--
View this message in context: 
http://r.789695.n4.nabble.com/subsetting-with-greater-than-and-less-than-indexing-tp4659142p4659204.html
Sent from the R help mailing list archive at Nabble.com.
[[alternative HTML version deleted]]

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


[R] Fitting a gaussian distribution to a plot

2013-02-20 Thread Samantha Warnes
I have a peak I would like to fit with a gaussian distribution, and am having 
difficulties. First of all I am having difficulties getting R to except my 
function input, and additionally I am having trouble plotting the non linear 
model on my scatterplot of data (the peak). Here is my log:

 small - 
 c(507680,507670,508832,510184,511272,513380,515828,519160,525046,534046,547982,567124,590208,614506,637876,656846,669054,672976,668800,656070,637136,614342,590970,570752,554480,542882,535630,531276,528682,527682,527020,526834,526802,526860)
 plot(small)
 mean(small)
[1] 563996.7
 sd(small)
[1] 55996.21

 x -c(0:35)
 x -as.numeric(x)
 f - ((1/(55996.21)*sqrt(2*pi)))*exp^(-((x-563996.7)^2)/(2*(55996.21^2)))



Error in exp^(-((x - 563996.7)^2)/(2 * (55996.21^2))) : 
 non-numeric argument to binary operator



From this point, to fit a non-linear model so I type nlm(f,507680)? I have 
tried reading up on this and looking for additional information on the 
internet but I am truly stuck. Thank you in advance!
Samantha

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


Re: [R] Sending Email from R

2013-02-20 Thread David Winsemius

On Feb 20, 2013, at 2:21 PM, Lopez, Dan wrote:

 David
 
 Thanks for the other resources. But I think those don't solve my problem.
 
 FYI I used sendmailR:sendmail without password.
 
 This is more or less how I ended up doing it. I can send a simple plain email 
 or a simple plain email with an attachment or few attachments. Not sure if it 
 makes a difference but in this test I am sending to myself from within the 
 company
 
 I am just trying to figure out how to email the contents from dput(). 
 Whenever I try it prints it to the screen and the contents don't appear in 
 the email at all: body or attachment. If I try it as an attachment (that's 
 the mime_part()) the attachment is blank.
 
 ## Not run: 
 from - lopez...@llnl.gov
 to - lopez...@llnl.gov
 subject - This email from R
 body - list(It works!, mime_part(iris))  

Shouldn't that be :

 body - list(It works!, mime_part(iris) )   # ???



 mailControl=list(smtpServer=thing.thing.gov)
 
 sendmail(from=from,to=to,subject=subject,msg=body,control=mailControl)
 ## End(Not run)
 
 Thanks.
 Dan
 
 
 -Original Message-
 From: David Winsemius [mailto:dwinsem...@comcast.net] 
 Sent: Wednesday, February 20, 2013 11:59 AM
 To: David Winsemius
 Cc: Lopez, Dan; R help (r-help@r-project.org)
 Subject: Re: [R] Sending Email from R
 
 
 On Feb 20, 2013, at 10:44 AM, David Winsemius wrote:
 
 
 On Feb 20, 2013, at 10:24 AM, Lopez, Dan wrote:
 
 Hi R experts,
 
 I know how to send simple plain text message in body and how to send with 
 attachments. This is thanks to stackoverflow reference below.
 
 But I don't know how to send dput() output in the body of the email (or 
 attachment) using sendmailR. I more interested in figuring out how to 
 include it as part of the body of the email.
 
 Does anybody have experience on how to do this?
 
 http://stackoverflow.com/questions/2885660/how-to-send-email-with-attachment-from-r-in-windows
 
 #?sendmailR::sendmail
 
 library(sendmailR)
 
 #set working directory
 setwd(C:/workingdirectorypath)
 
 #send plain email
 
 from - y...@account.com
 to - recipi...@account.com
 subject - Email Subject
 body - Email body.
 mailControl=list(smtpServer=serverinfo)
 
 sendmail(from=from,to=to,subject=subject,msg=body,control=mailControl)
 
 Does this mean you get success with the simple example you posted?
 
 This might be critical. There was a 2010 posting from Barry Rowlingson saying 
 that 'sendmail' in sendmailR was unable to provide smtp-authorization. I got 
 an error message regarding authorization when I added my password.
 
 http://markmail.org/search/?q=list%3Aorg.r-project.r-help+sendmail+authentication#query:list%3Aorg.r-project.r-help%20sendmail%20authentication+page:1+mid:pwfqwwwumgwtcqx7+state:results
 
 That thread also included Ben Bolker's offer of code in package:Rmail at:
 
 http://www.math.mcmaster.ca/~bolker/R/src/contrib/ 
 
 
 I was able to get Lin Himmelmann's  mail::sendmail function to send a message 
 to myself. Looking at the code it appears Lin has set up a PHP server and is 
 parsing an http: request. It also doesn't look like it is intended to be 
 general solution since there is a message saying the numbers of messages are 
 limited.
 
 -- 
 
 David Winsemius
 Alameda, CA, USA
 

David Winsemius
Alameda, CA, USA

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


Re: [R] Sending Email from R

2013-02-20 Thread Lopez, Dan
David,

Yes, sorry, I sent the version of this were I was playing with trying to get 
two sets of text in the body. You are right: 
body - list(It works!, mime_part(iris) )   

But that doesn't address my original problem with trying to get dput() into 
email from R. I mean I can copy and paste as I usually do but just thought 
there is an easy way to do it through sendmail.

Thanks.
Dan


-Original Message-
From: David Winsemius [mailto:dwinsem...@comcast.net] 
Sent: Wednesday, February 20, 2013 4:06 PM
To: Lopez, Dan
Cc: R help (r-help@r-project.org)
Subject: Re: [R] Sending Email from R


On Feb 20, 2013, at 2:21 PM, Lopez, Dan wrote:

 David
 
 Thanks for the other resources. But I think those don't solve my problem.
 
 FYI I used sendmailR:sendmail without password.
 
 This is more or less how I ended up doing it. I can send a simple plain email 
 or a simple plain email with an attachment or few attachments. Not sure if it 
 makes a difference but in this test I am sending to myself from within the 
 company
 
 I am just trying to figure out how to email the contents from dput(). 
 Whenever I try it prints it to the screen and the contents don't appear in 
 the email at all: body or attachment. If I try it as an attachment (that's 
 the mime_part()) the attachment is blank.
 
 ## Not run: 
 from - lopez...@llnl.gov
 to - lopez...@llnl.gov
 subject - This email from R
 body - list(It works!, mime_part(iris))  

Shouldn't that be :

 body - list(It works!, mime_part(iris) )   # ???



 mailControl=list(smtpServer=thing.thing.gov)
 
 sendmail(from=from,to=to,subject=subject,msg=body,control=mailControl)
 ## End(Not run)
 
 Thanks.
 Dan
 
 
 -Original Message-
 From: David Winsemius [mailto:dwinsem...@comcast.net] 
 Sent: Wednesday, February 20, 2013 11:59 AM
 To: David Winsemius
 Cc: Lopez, Dan; R help (r-help@r-project.org)
 Subject: Re: [R] Sending Email from R
 
 
 On Feb 20, 2013, at 10:44 AM, David Winsemius wrote:
 
 
 On Feb 20, 2013, at 10:24 AM, Lopez, Dan wrote:
 
 Hi R experts,
 
 I know how to send simple plain text message in body and how to send with 
 attachments. This is thanks to stackoverflow reference below.
 
 But I don't know how to send dput() output in the body of the email (or 
 attachment) using sendmailR. I more interested in figuring out how to 
 include it as part of the body of the email.
 
 Does anybody have experience on how to do this?
 
 http://stackoverflow.com/questions/2885660/how-to-send-email-with-attachment-from-r-in-windows
 
 #?sendmailR::sendmail
 
 library(sendmailR)
 
 #set working directory
 setwd(C:/workingdirectorypath)
 
 #send plain email
 
 from - y...@account.com
 to - recipi...@account.com
 subject - Email Subject
 body - Email body.
 mailControl=list(smtpServer=serverinfo)
 
 sendmail(from=from,to=to,subject=subject,msg=body,control=mailControl)
 
 Does this mean you get success with the simple example you posted?
 
 This might be critical. There was a 2010 posting from Barry Rowlingson saying 
 that 'sendmail' in sendmailR was unable to provide smtp-authorization. I got 
 an error message regarding authorization when I added my password.
 
 http://markmail.org/search/?q=list%3Aorg.r-project.r-help+sendmail+authentication#query:list%3Aorg.r-project.r-help%20sendmail%20authentication+page:1+mid:pwfqwwwumgwtcqx7+state:results
 
 That thread also included Ben Bolker's offer of code in package:Rmail at:
 
 http://www.math.mcmaster.ca/~bolker/R/src/contrib/ 
 
 
 I was able to get Lin Himmelmann's  mail::sendmail function to send a message 
 to myself. Looking at the code it appears Lin has set up a PHP server and is 
 parsing an http: request. It also doesn't look like it is intended to be 
 general solution since there is a message saying the numbers of messages are 
 limited.
 
 -- 
 
 David Winsemius
 Alameda, CA, USA
 

David Winsemius
Alameda, CA, USA

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


[R] Having trouble converting a dataframe of character vectors to factors

2013-02-20 Thread Lopez, Dan
R Experts,

I have a dataframe made up of character vectors--these are results from survey 
questions. I need to convert them to factors.

I tried the following which did not work:
scs2-sapply(scs2,as.factor)
also this didn't work:
scs2-sapply(scs2,function(x) as.factor(x))

After doing either of above I end up with
str(scs2)

chr [1:10, 1:10] very important very important very important very 
important ...

 - attr(*, dimnames)=List of 2

  ..$ : NULL

  ..$ : chr [1:10] Q1_1 Q1_2 Q1_3 Q1_4 ...

class(scs2)
matrix

But when I do it one at a time it works:
scs2$Q1_1-as.factor(scs2$Q1_1)
scs2$Q1_2- as.factor(scs2$Q1_2)

What am I doing wrong?  How do I accomplish this with sapply or similar 
function?

Data for reproducibility:


scs2-structure(list(Q1_1 = c(very important, very important, very 
important,

very important, very important, very important, very important,

somewhat important, important, very important), Q1_2 = c(important,

somewhat important, very important, important, important,

very important, somewhat important, somewhat important,

very important, very important), Q1_3 = c(very important,

important, very important, very important, important,

very important, very important, somewhat important, not important,

important), Q1_4 = c(very important, important, very important,

very important, important, important, important, very important,

somewhat important, important), Q1_5 = c(very important,

not important, important, very important, not important,

important, somewhat important, important, somewhat important,

not important), Q1_6 = c(very important, not important,

important, very important, somewhat important, very important,

very important, very important, important, important),

Q1_7 = c(very important, somewhat important, important,

somewhat important, important, important, very important,

very important, somewhat important, not important),

Q2 = c(Somewhat, Very Much, Somewhat, Very Much,

Very Much, Very Much, Very Much, Very Much, Very Much,

Very Much), Q3 = c(yes, yes, yes, yes, yes, yes,

yes, yes, yes, yes), Q4 = c(None, None, None,

None, Confirmed Field of Study, Confirmed Field of Study,

Confirmed Field of Study, None, None, None)), .Names = c(Q1_1,

Q1_2, Q1_3, Q1_4, Q1_5, Q1_6, Q1_7, Q2, Q3, Q4

), row.names = c(78L, 46L, 80L, 196L, 188L, 197L, 39L, 195L,

172L, 110L), class = data.frame)


[[alternative HTML version deleted]]

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


Re: [R] Sending Email from R

2013-02-20 Thread William Dunlap
Try replacing
   dput(x)
with
   capture.output(dput(x))

dput(x) prints a parsable representation of x but returns x.  capture.output(y) 
returns
what print(y) would have printed.

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
 Behalf
 Of Lopez, Dan
 Sent: Wednesday, February 20, 2013 4:09 PM
 To: David Winsemius
 Cc: R help (r-help@r-project.org)
 Subject: Re: [R] Sending Email from R
 
 David,
 
 Yes, sorry, I sent the version of this were I was playing with trying to get 
 two sets of text
 in the body. You are right:
 body - list(It works!, mime_part(iris) )
 
 But that doesn't address my original problem with trying to get dput() into 
 email from R. I
 mean I can copy and paste as I usually do but just thought there is an easy 
 way to do it
 through sendmail.
 
 Thanks.
 Dan
 
 
 -Original Message-
 From: David Winsemius [mailto:dwinsem...@comcast.net]
 Sent: Wednesday, February 20, 2013 4:06 PM
 To: Lopez, Dan
 Cc: R help (r-help@r-project.org)
 Subject: Re: [R] Sending Email from R
 
 
 On Feb 20, 2013, at 2:21 PM, Lopez, Dan wrote:
 
  David
 
  Thanks for the other resources. But I think those don't solve my problem.
 
  FYI I used sendmailR:sendmail without password.
 
  This is more or less how I ended up doing it. I can send a simple plain 
  email or a simple
 plain email with an attachment or few attachments. Not sure if it makes a 
 difference but
 in this test I am sending to myself from within the company
 
  I am just trying to figure out how to email the contents from dput(). 
  Whenever I try it
 prints it to the screen and the contents don't appear in the email at all: 
 body or
 attachment. If I try it as an attachment (that's the mime_part()) the 
 attachment is blank.
 
  ## Not run:
  from - lopez...@llnl.gov
  to - lopez...@llnl.gov
  subject - This email from R
  body - list(It works!, mime_part(iris))
 
 Shouldn't that be :
 
  body - list(It works!, mime_part(iris) )   # ???
 
 
 
  mailControl=list(smtpServer=thing.thing.gov)
 
  sendmail(from=from,to=to,subject=subject,msg=body,control=mailControl)
  ## End(Not run)
 
  Thanks.
  Dan
 
 
  -Original Message-
  From: David Winsemius [mailto:dwinsem...@comcast.net]
  Sent: Wednesday, February 20, 2013 11:59 AM
  To: David Winsemius
  Cc: Lopez, Dan; R help (r-help@r-project.org)
  Subject: Re: [R] Sending Email from R
 
 
  On Feb 20, 2013, at 10:44 AM, David Winsemius wrote:
 
 
  On Feb 20, 2013, at 10:24 AM, Lopez, Dan wrote:
 
  Hi R experts,
 
  I know how to send simple plain text message in body and how to send with
 attachments. This is thanks to stackoverflow reference below.
 
  But I don't know how to send dput() output in the body of the email (or 
  attachment)
 using sendmailR. I more interested in figuring out how to include it as part 
 of the body of
 the email.
 
  Does anybody have experience on how to do this?
 
  http://stackoverflow.com/questions/2885660/how-to-send-email-with-attachment-
 from-r-in-windows
 
  #?sendmailR::sendmail
 
  library(sendmailR)
 
  #set working directory
  setwd(C:/workingdirectorypath)
 
  #send plain email
 
  from - y...@account.com
  to - recipi...@account.com
  subject - Email Subject
  body - Email body.
  mailControl=list(smtpServer=serverinfo)
 
  sendmail(from=from,to=to,subject=subject,msg=body,control=mailControl)
 
  Does this mean you get success with the simple example you posted?
 
  This might be critical. There was a 2010 posting from Barry Rowlingson 
  saying that
 'sendmail' in sendmailR was unable to provide smtp-authorization. I got an 
 error
 message regarding authorization when I added my password.
 
  http://markmail.org/search/?q=list%3Aorg.r-project.r-
 help+sendmail+authentication#query:list%3Aorg.r-project.r-
 help%20sendmail%20authentication+page:1+mid:pwfqwwwumgwtcqx7+state:results
 
  That thread also included Ben Bolker's offer of code in package:Rmail at:
 
  http://www.math.mcmaster.ca/~bolker/R/src/contrib/
 
 
  I was able to get Lin Himmelmann's  mail::sendmail function to send a 
  message to
 myself. Looking at the code it appears Lin has set up a PHP server and is 
 parsing an http:
 request. It also doesn't look like it is intended to be general solution 
 since there is a
 message saying the numbers of messages are limited.
 
  --
 
  David Winsemius
  Alameda, CA, USA
 
 
 David Winsemius
 Alameda, CA, USA
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide 

Re: [R] Having trouble converting a dataframe of character vectors to factors

2013-02-20 Thread Bert Gunter
Pleaser re-read ?sapply and pay particular attention to the simplify argument.

The following should help explain the issues:

 z - data.frame(a=letters[1:3],b=letters[4:6],stringsAsFactors=FALSE)
 sapply(z,class)
  a   b
character character
 z1 - sapply(z,as.factor)
 sapply(z1,class)
  a   b   c   d   e   f
character character character character character character
 z2 - sapply(z,factor, simplify = FALSE)
 sapply(z2,class)
   ab
factor factor
 z3 - lapply(z,factor)
 sapply(z3,class)
   ab
factor factor
 z3
$a
[1] a b c
Levels: a b c

$b
[1] d e f
Levels: d e f

## Note that both z2 and z3 are lists, and would have to be converted
back to data frames.

-- Bert

On Wed, Feb 20, 2013 at 4:09 PM, Lopez, Dan lopez...@llnl.gov wrote:
 R Experts,

 I have a dataframe made up of character vectors--these are results from 
 survey questions. I need to convert them to factors.

 I tried the following which did not work:
 scs2-sapply(scs2,as.factor)
 also this didn't work:
 scs2-sapply(scs2,function(x) as.factor(x))

 After doing either of above I end up with
str(scs2)

 chr [1:10, 1:10] very important very important very important very 
 important ...

  - attr(*, dimnames)=List of 2

   ..$ : NULL

   ..$ : chr [1:10] Q1_1 Q1_2 Q1_3 Q1_4 ...

class(scs2)
 matrix

 But when I do it one at a time it works:
 scs2$Q1_1-as.factor(scs2$Q1_1)
 scs2$Q1_2- as.factor(scs2$Q1_2)

 What am I doing wrong?  How do I accomplish this with sapply or similar 
 function?

 Data for reproducibility:


 scs2-structure(list(Q1_1 = c(very important, very important, very 
 important,

 very important, very important, very important, very important,

 somewhat important, important, very important), Q1_2 = c(important,

 somewhat important, very important, important, important,

 very important, somewhat important, somewhat important,

 very important, very important), Q1_3 = c(very important,

 important, very important, very important, important,

 very important, very important, somewhat important, not important,

 important), Q1_4 = c(very important, important, very important,

 very important, important, important, important, very important,

 somewhat important, important), Q1_5 = c(very important,

 not important, important, very important, not important,

 important, somewhat important, important, somewhat important,

 not important), Q1_6 = c(very important, not important,

 important, very important, somewhat important, very important,

 very important, very important, important, important),

 Q1_7 = c(very important, somewhat important, important,

 somewhat important, important, important, very important,

 very important, somewhat important, not important),

 Q2 = c(Somewhat, Very Much, Somewhat, Very Much,

 Very Much, Very Much, Very Much, Very Much, Very Much,

 Very Much), Q3 = c(yes, yes, yes, yes, yes, yes,

 yes, yes, yes, yes), Q4 = c(None, None, None,

 None, Confirmed Field of Study, Confirmed Field of Study,

 Confirmed Field of Study, None, None, None)), .Names = c(Q1_1,

 Q1_2, Q1_3, Q1_4, Q1_5, Q1_6, Q1_7, Q2, Q3, Q4

 ), row.names = c(78L, 46L, 80L, 196L, 188L, 197L, 39L, 195L,

 172L, 110L), class = data.frame)


 [[alternative HTML version deleted]]

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



-- 

Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm

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


Re: [R] Sending Email from R

2013-02-20 Thread Lopez, Dan
Hi Bill,

That's awesome!!! That did the trick!

Thank you so much.

BTW I think spotfire is an awesome visulization and analytics tool. Too bad we 
can't afford it in my dept.

Dan


-Original Message-
From: William Dunlap [mailto:wdun...@tibco.com] 
Sent: Wednesday, February 20, 2013 4:18 PM
To: Lopez, Dan; David Winsemius
Cc: R help (r-help@r-project.org)
Subject: RE: [R] Sending Email from R

Try replacing
   dput(x)
with
   capture.output(dput(x))

dput(x) prints a parsable representation of x but returns x.  capture.output(y) 
returns what print(y) would have printed.

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com


 -Original Message-
 From: r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.org] On Behalf Of Lopez, Dan
 Sent: Wednesday, February 20, 2013 4:09 PM
 To: David Winsemius
 Cc: R help (r-help@r-project.org)
 Subject: Re: [R] Sending Email from R
 
 David,
 
 Yes, sorry, I sent the version of this were I was playing with trying 
 to get two sets of text in the body. You are right:
 body - list(It works!, mime_part(iris) )
 
 But that doesn't address my original problem with trying to get dput() 
 into email from R. I mean I can copy and paste as I usually do but 
 just thought there is an easy way to do it through sendmail.
 
 Thanks.
 Dan
 
 
 -Original Message-
 From: David Winsemius [mailto:dwinsem...@comcast.net]
 Sent: Wednesday, February 20, 2013 4:06 PM
 To: Lopez, Dan
 Cc: R help (r-help@r-project.org)
 Subject: Re: [R] Sending Email from R
 
 
 On Feb 20, 2013, at 2:21 PM, Lopez, Dan wrote:
 
  David
 
  Thanks for the other resources. But I think those don't solve my problem.
 
  FYI I used sendmailR:sendmail without password.
 
  This is more or less how I ended up doing it. I can send a simple 
  plain email or a simple
 plain email with an attachment or few attachments. Not sure if it 
 makes a difference but in this test I am sending to myself from within 
 the company
 
  I am just trying to figure out how to email the contents from 
  dput(). Whenever I try it
 prints it to the screen and the contents don't appear in the email at 
 all: body or attachment. If I try it as an attachment (that's the 
 mime_part()) the attachment is blank.
 
  ## Not run:
  from - lopez...@llnl.gov
  to - lopez...@llnl.gov
  subject - This email from R
  body - list(It works!, mime_part(iris))
 
 Shouldn't that be :
 
  body - list(It works!, mime_part(iris) )   # ???
 
 
 
  mailControl=list(smtpServer=thing.thing.gov)
 
  sendmail(from=from,to=to,subject=subject,msg=body,control=mailContro
  l)
  ## End(Not run)
 
  Thanks.
  Dan
 
 
  -Original Message-
  From: David Winsemius [mailto:dwinsem...@comcast.net]
  Sent: Wednesday, February 20, 2013 11:59 AM
  To: David Winsemius
  Cc: Lopez, Dan; R help (r-help@r-project.org)
  Subject: Re: [R] Sending Email from R
 
 
  On Feb 20, 2013, at 10:44 AM, David Winsemius wrote:
 
 
  On Feb 20, 2013, at 10:24 AM, Lopez, Dan wrote:
 
  Hi R experts,
 
  I know how to send simple plain text message in body and how to 
  send with
 attachments. This is thanks to stackoverflow reference below.
 
  But I don't know how to send dput() output in the body of the 
  email (or attachment)
 using sendmailR. I more interested in figuring out how to include it 
 as part of the body of the email.
 
  Does anybody have experience on how to do this?
 
  http://stackoverflow.com/questions/2885660/how-to-send-email-with-at
  tachment-
 from-r-in-windows
 
  #?sendmailR::sendmail
 
  library(sendmailR)
 
  #set working directory
  setwd(C:/workingdirectorypath)
 
  #send plain email
 
  from - y...@account.com
  to - recipi...@account.com
  subject - Email Subject
  body - Email body.
  mailControl=list(smtpServer=serverinfo)
 
  sendmail(from=from,to=to,subject=subject,msg=body,control=mailCont
  rol)
 
  Does this mean you get success with the simple example you posted?
 
  This might be critical. There was a 2010 posting from Barry 
  Rowlingson saying that
 'sendmail' in sendmailR was unable to provide smtp-authorization. I 
 got an error message regarding authorization when I added my password.
 
  http://markmail.org/search/?q=list%3Aorg.r-project.r-
 help+sendmail+authentication#query:list%3Aorg.r-project.r-
 help%20sendmail%20authentication+page:1+mid:pwfqwwwumgwtcqx7+state:res
 ults
 
  That thread also included Ben Bolker's offer of code in package:Rmail at:
 
  http://www.math.mcmaster.ca/~bolker/R/src/contrib/
 
 
  I was able to get Lin Himmelmann's  mail::sendmail function to send 
  a message to
 myself. Looking at the code it appears Lin has set up a PHP server and is 
 parsing an http:
 request. It also doesn't look like it is intended to be general 
 solution since there is a message saying the numbers of messages are limited.
 
  --
 
  David Winsemius
  Alameda, CA, USA
 
 
 David Winsemius
 Alameda, CA, USA
 
 __
 R-help@r-project.org mailing list

Re: [R] Plotting Discriminants from qda

2013-02-20 Thread David Winsemius

On Feb 20, 2013, at 2:42 PM, Melanie Zoelck wrote:

 Dear R Help Members,
 
 I am aware how to plot the LD1 vs LD2 from a lda in R, using the code:
 
 plot(baseline.systat.hat$x, 
 col=baseline.systat.hat$class,pch=as.numeric(baseline.systat.hat$class))
 
 However, I need to use the quadratic discriminant function, qda due to data 
 properties. Is there a way to obtain the same sort of plot for from a qda 
 object (and the output of predict qda). I have not been able to find this and 
 am a bit stumped. I cannot seem to find any information on plotting this.
 

Code for plotting qda results appears on p340 of MASSe4. However the comment 
that Function predplot is given in the scripts is not something I was able 
turn into anything useful after looking in hte index, searching the MASS 
website. Searching with Google for 'ripley MASS predplot' I find an R help 
posting by Gavin Simpson in 2003 that pointed to the file ch11.R in the MASS 
library, but I find that in the meantime it has moved to ch12.R in the 
scripts directory of ../library/MASS/

-- 

David Winsemius
Alameda, CA, USA

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


Re: [R] Error in setwd(outDir) : cannot change working directory

2013-02-20 Thread S Ellison


 Should I create an output directory somewhere either in Program Files where
 R is installed or in my working directory?
If I wanted to create a writeable test directory I'd put it in my own 
workspace, not the program files space.
But why do you think you need to create an output directory?


***
This email and any attachments are confidential. Any use, copying or
disclosure other than by the intended recipient is unauthorised. If 
you have received this message in error, please notify the sender 
immediately via +44(0)20 8943 7000 or notify postmas...@lgcgroup.com 
and delete this message and any copies from your computer and network. 
LGC Limited. Registered in England 2991879. 
Registered office: Queens Road, Teddington, Middlesex, TW11 0LY, UK

[[alternative HTML version deleted]]

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


Re: [R] Tracking time-varying objects with the DLM package (dynamic linear models in R)

2013-02-20 Thread Giovanni Petris

Hi Samantha,

I had not anticipated such kind of requests, so getting what (I believe) you 
want is not totally trivial. However, what 'dlmFilter' does, when dealing with 
a time-varying DLM, is to build, at each time, the appropriate matrix W from 
'JW' and 'X'. So, I suggest that you look at how dlmFilter works and start from 
there.

Best,
Giovanni
 

From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] on behalf of 
Samantha Azzarello [samantha.azzare...@cmegroup.com]
Sent: Wednesday, February 20, 2013 5:02 PM
To: r-help@r-project.org
Subject: [R] Tracking time-varying objects with the DLM package (dynamic linear 
models in R)

Hello all,

I am working with the dlm package, specifcially doing a dlm multivariate Y
linear regression using
dlmModReg and dlmFilter and dlmSmooth...

I have altereted the inputs into dlmModReg to make them time-varying using
JFF, JW etc.

How do I track the results of the time varying system matrices?
For example what I am really interested in is JW - my system variance matrix
for each time period - I cannot get R to give
me the array of this matrix

Any help would be really appreciated!
Thanks



--
View this message in context: 
http://r.789695.n4.nabble.com/Tracking-time-varying-objects-with-the-DLM-package-dynamic-linear-models-in-R-tp4659211.html
Sent from the R help mailing list archive at Nabble.com.

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

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


Re: [R] Fitting a gaussian distribution to a plot

2013-02-20 Thread arun
Hi,

Do you need exp^?  Should it be exp(-((...?

x1-as.numeric(x)
 sd1-sd(small)
mean1- mean(small)
((1/sd1)*sqrt(2*pi))*exp(-((x1-mean1)^2)/(2*(sd1^2)))
# [1] 4.189541e-27 4.190295e-27 4.191049e-27 4.191803e-27 4.192557e-27
 #[6] 4.193311e-27 4.194065e-27 4.194820e-27 4.195574e-27 4.196329e-27
#[11] 4.197084e-27 4.197839e-27 4.198594e-27 4.199349e-27 4.200105e-27
#[16] 4.200860e-27 4.201616e-27 4.202372e-27 4.203128e-27 4.203884e-27
#[21] 4.204640e-27 4.205396e-27 4.206153e-27 4.206909e-27 4.207666e-27
#[26] 4.208423e-27 4.209180e-27 4.209937e-27 4.210694e-27 4.211452e-27
#[31] 4.212209e-27 4.212967e-27 4.213725e-27 4.214483e-27 4.215241e-27
#[36] 4.215999e-27
A.K.



- Original Message -
From: Samantha Warnes war...@wisc.edu
To: r-help@r-project.org
Cc: 
Sent: Wednesday, February 20, 2013 6:33 PM
Subject: [R] Fitting a gaussian distribution to a plot

I have a peak I would like to fit with a gaussian distribution, and am having 
difficulties. First of all I am having difficulties getting R to except my 
function input, and additionally I am having trouble plotting the non linear 
model on my scatterplot of data (the peak). Here is my log:

 small - 
 c(507680,507670,508832,510184,511272,513380,515828,519160,525046,534046,547982,567124,590208,614506,637876,656846,669054,672976,668800,656070,637136,614342,590970,570752,554480,542882,535630,531276,528682,527682,527020,526834,526802,526860)
 plot(small)
 mean(small)
[1] 563996.7
 sd(small)
[1] 55996.21

 x -c(0:35)
 x -as.numeric(x)
 f - ((1/(55996.21)*sqrt(2*pi)))*exp^(-((x-563996.7)^2)/(2*(55996.21^2)))



Error in exp^(-((x - 563996.7)^2)/(2 * (55996.21^2))) : 
non-numeric argument to binary operator



From this point, to fit a non-linear model so I type nlm(f,507680)? I have 
tried reading up on this and looking for additional information on the 
internet but I am truly stuck. Thank you in advance!
Samantha

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


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


Re: [R] duplicate 'row.names' are not allowed

2013-02-20 Thread Jim Lemon

On 02/21/2013 07:10 AM, Joanna Papakonstantinou wrote:

Some of the names in the columns actually have spaces in them (e.g., S L TX
is in one column). So there are really 9.
I was able to save the file as a csv file and read.table succesfully.


Hi Joanna,
As you specified space ( ) as the field delimiter in your initial 
post, fields with spaces would be read as multiple fields, forcing the 
first column to be read as row names. I suspect that you changed the 
delimiter or that read.csv treats this differently from read.delim. I 
recall having to specify something about row names with read.delim once.


Jim

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


[R] About multivariate GARCH: DVEC and BEKK

2013-02-20 Thread jpm miao
Dear All,

   I attempted to fit a DVEC and a BEKK multivariate GARCH model, but am
wondering which package to use.

  1. I tried to use rmgarch package in R, but I couldn't find the
subroutines for DVEC and BEKK.

  2. I tried to find rmgarch package of R, which is not located on the
official R site. This is the latest version I can find, where the programs
were uploaded 2 years ago.

https://github.com/vst/mgarch/downloads

Are there later versions? Is there a manual on the functions?

   Thanks,

Miao

[[alternative HTML version deleted]]

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


Re: [R] Having trouble converting a dataframe of character vectors to factors

2013-02-20 Thread Mark Lamias
How about this?

scs2-data.frame(lapply(scs2, factor))





 From: Lopez, Dan lopez...@llnl.gov
To: R help (r-help@r-project.org) r-help@r-project.org 
Sent: Wednesday, February 20, 2013 7:09 PM
Subject: [R] Having trouble converting a dataframe of character vectors to 
factors

R Experts,

I have a dataframe made up of character vectors--these are results from survey 
questions. I need to convert them to factors.

I tried the following which did not work:
scs2-sapply(scs2,as.factor)
also this didn't work:
scs2-sapply(scs2,function(x) as.factor(x))

After doing either of above I end up with
str(scs2)

chr [1:10, 1:10] very important very important very important very 
important ...

- attr(*, dimnames)=List of 2

  ..$ : NULL

  ..$ : chr [1:10] Q1_1 Q1_2 Q1_3 Q1_4 ...

class(scs2)
matrix

But when I do it one at a time it works:
scs2$Q1_1-as.factor(scs2$Q1_1)
scs2$Q1_2- as.factor(scs2$Q1_2)

What am I doing wrong?  How do I accomplish this with sapply or similar 
function?

Data for reproducibility:


scs2-structure(list(Q1_1 = c(very important, very important, very 
important,

very important, very important, very important, very important,

somewhat important, important, very important), Q1_2 = c(important,

somewhat important, very important, important, important,

very important, somewhat important, somewhat important,

very important, very important), Q1_3 = c(very important,

important, very important, very important, important,

very important, very important, somewhat important, not important,

important), Q1_4 = c(very important, important, very important,

very important, important, important, important, very important,

somewhat important, important), Q1_5 = c(very important,

not important, important, very important, not important,

important, somewhat important, important, somewhat important,

not important), Q1_6 = c(very important, not important,

important, very important, somewhat important, very important,

very important, very important, important, important),

    Q1_7 = c(very important, somewhat important, important,

    somewhat important, important, important, very important,

    very important, somewhat important, not important),

    Q2 = c(Somewhat, Very Much, Somewhat, Very Much,

    Very Much, Very Much, Very Much, Very Much, Very Much,

    Very Much), Q3 = c(yes, yes, yes, yes, yes, yes,

    yes, yes, yes, yes), Q4 = c(None, None, None,

    None, Confirmed Field of Study, Confirmed Field of Study,

    Confirmed Field of Study, None, None, None)), .Names = c(Q1_1,

Q1_2, Q1_3, Q1_4, Q1_5, Q1_6, Q1_7, Q2, Q3, Q4

), row.names = c(78L, 46L, 80L, 196L, 188L, 197L, 39L, 195L,

172L, 110L), class = data.frame)


    [[alternative HTML version deleted]]

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

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


[R] error with bbox for k12hat (splancs) bivarite k-function

2013-02-20 Thread awooditc
Hello,

I am trying to conduct a bi-variate ripley's k using the k12hat function in
the splancs package (found here
http://rss.acs.unt.edu/Rdoc/library/splancs/html/k12hat.html). Although, I
receive an error when getting to the bboxx part of the code:

poly - list(x=c(fire4$X, nar4$X), y=c(fire4$Y, nar4$Y))
plot(seq(5,80,5), sqrt(k12hat(fire4), as.points(nar4),
bboxx(bbox(as.points(okpoly))), seq(5,80,5))/pi) - seq(5,80,5),
xlab=distance, 

Error: unexpected ',' in bboxx(bbox(as.points(poly))),

What am I doing wrong?  Any help would be greatly appreciated. 

Thanks!
- Elise



--
View this message in context: 
http://r.789695.n4.nabble.com/error-with-bbox-for-k12hat-splancs-bivarite-k-function-tp4659233.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Why R simulation gives same random results?

2013-02-20 Thread Prof Brian Ripley

On 20/02/2013 23:13, Greg Snow wrote:

To know for sure we need to know how you are running these different R
sessions, but here are some possibilities:

The help page for set.seed says that if no seed exists then the seed is
set based on the current time (and since 2.14.0 the process ID).  So one
possibility is that 2 of the sessions are started close enough together
that they get the same seed.  Or the difference in time and process ID
cancel each other out.


That is exceedingly unlikely.  We are not told the platform, but AFAIK 
on all common R platforms and current versions of R:


- the time is measured to at least msec accuracy.
- times which might cancel out pid differences are many hours apart.

A while ago it was possible on some platforms to get the same seed by 
starting two R processes on the same clock tick (within 1/60 or 1/100 s 
of each other).  But now you are talking about generating a pretty 
random unsigned integer with 32 bits to set the seed, so the probability 
of coincidence is very small.



Another possibility (also mentioned in the help page) is that if the seed
was saved in a previous session then it will be restored in the new
session, if all the sessions are reading in the same stored session (or
just the 2 that are the same) then they would start from the same seed.


Much more likely.


On Tue, Feb 19, 2013 at 6:31 PM, C W tmrs...@gmail.com wrote:


Hi, list
I am doing 100,000 iterations of Bayesian simulations.



What I did is I split it into 4 different R sessions, each one runs 25,000
iteration.  But two of the sessions gave the simulation result.


This falls within the class of parallel simulations.  You would do 
better to set carefully selected seeds: see the vignette for package 
'parallel'.



I did not use any set.seed().  What is going on here?

Thanks,
Mike




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

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


Re: [R] error with bbox for k12hat (splancs) bivarite k-function

2013-02-20 Thread Jim Lemon

On 02/21/2013 04:53 PM, awooditc wrote:

Hello,

I am trying to conduct a bi-variate ripley's k using the k12hat function in
the splancs package (found here
http://rss.acs.unt.edu/Rdoc/library/splancs/html/k12hat.html). Although, I
receive an error when getting to the bboxx part of the code:

poly- list(x=c(fire4$X, nar4$X), y=c(fire4$Y, nar4$Y))
plot(seq(5,80,5), sqrt(k12hat(fire4), as.points(nar4),
bboxx(bbox(as.points(okpoly))), seq(5,80,5))/pi) - seq(5,80,5),
xlab=distance,

Error: unexpected ',' in bboxx(bbox(as.points(poly))),

What am I doing wrong?  Any help would be greatly appreciated.


Hi Elise,
I think it's the extra right parenthesis after okpoly.

Jim

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