Re: [R] How to make a nomogam and Calibration plot

2011-08-03 Thread sytangping
Dear Harrell,

Many thanks for your quick response!
However, after try and try, I still have difficulty to solve my questions.
I post my questions again. I hope someone can help me run the data and draw
the nomogram and calibration plot for me. I know that is not good but indeed
I have no way to go. The problems almost drove me mad!

Best regards!

Ping Tang

Dear R users,

I am a new R user and something stops me when I try to write a academic
article. I want to make a nomogram to predict the risk of prostate cancer
(PCa) using several factors which have been selected from the Logistic
regression run under the SPSS. Always, a calibration plot is needed to
validate the prediction accuracy of the nomogram.
However, I tried many times and read a lot of posts with respect to this
topic but I still couldn't figure out how to draw the nomogram and the
calibration plot. Attached file is the dataset for the research. It will be
very grateful if someone can save his/her time to help for my questions.

Warmest regards!

Logistic Regression

Classification Tablea,b
ObservedPredicted
Pca-YN  Percentage Correct
0   1   
Step 0  Pca-YN  0   295 0   100.0
1   218 0   .0
Overall Percentage  57.5


Variables in the Equation
B   S.E.Walddf  Sig.Exp(B)  95.0% C.I.for 
EXP(B)
Lower   Upper
Step 1a Age .031.0154.491   1   .0341.032   1.002   1.062
DRE 1.173   .26619.492  1   .0003.233   1.920   5.443
LogPV   -2.857  .50931.532  1   .000.057.021.156
LogPSA  2.316   .24688.416  1   .00010.132  6.253   16.419
Constant-1.024  1.273   .6481   .421.359


The equation:

Probability = 

 e-1.024+0.31age+1.173DRE+-2.857LogPV+2.316LogPSA
1+e-1.024+0.31age+1.173DRE+-2.857LogPV+2.316LogPSA

My questions are,

1.How to draw a nomogram (similar to the below figure 1) to predict the
probability of cancer using R?

2. How to make the Calibration plot (similar to the below figure 2) which
used to validate the prediction accuracy of the nomogram using R? And how to
calculate the concordance index (C-index) ?


http://r.789695.n4.nabble.com/file/n3714477/untitled.jpg 
http://r.789695.n4.nabble.com/file/n3714477/%E9%99%84%E4%BB%B62.jpg 
http://r.789695.n4.nabble.com/file/n3714477/Dataset.xls Dataset.xls 

--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-make-a-nomogam-and-Calibration-plot-tp3710068p3714477.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] cdplot error

2011-08-03 Thread wildernessness
Fairly new at this.  
Trying to create a conditional density plot.

cdplot(status~harvd.l,data=phy)
Error in cdplot.formula(status~harvd.l,data=phy):
dependent variable should be a factor

What does this error mean?  Status is a binary response of infestation (0/1)
and harvd.l is the log of timber harvest density per catchment.

Thanks.

--
View this message in context: 
http://r.789695.n4.nabble.com/cdplot-error-tp3714454p3714454.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] AICcmodavg functions and 'mer' class models

2011-08-03 Thread RonnyG
What is teh reason some functions in the AICcmodavg package do not work with
'mer' class models?
One such example would be the 'importance' function.

Thanks
Ronny

--
View this message in context: 
http://r.789695.n4.nabble.com/AICcmodavg-functions-and-mer-class-models-tp3714534p3714534.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] create a list under constraints

2011-08-03 Thread Dennis Murphy
Hi:

Here's one way; using the mdply() function in the plyr package:

k - c(1,2,3,4,5)
i - c(0,1,3,2,1)

# Takes two scalars k and i as input, outputs a data frame
ff - function(k, i) data.frame(k = rep(k, i+1), i = seq(0, i, by = 1))

library('plyr')
mdply(data.frame(k, i), ff)   # returns a data frame

# -
Another way to do this is to use the mapply() function
This one returns a matrix.
# -

gg - function(k, i) cbind(k = rep(k, i+1), i = seq(0, i, by = 1))
do.call(rbind, mapply(gg, k, i))

HTH,
Dennis

On Tue, Aug 2, 2011 at 6:40 PM, Kathie kathryn.lord2...@gmail.com wrote:
 Hi, R users,

 Here is an example.

 k - c(1,2,3,4,5)
 i - c(0,1,3,2,1)

 if k=1, then i=0
 if k=2, then i=0, 1
 if k=3, then i=0, 1, 2, 3
 if k=4, then i=0, 1, 2
 if k=5, then i=0, 1

 so i'd like to create a list like below.

 list
   k i
 1  1 0
 2  2 0
 3  2 1
 4  3 0
 5  3 1
 6  3 2
 7  3 3
 8  4 0
 9  4 1
 10 4 2
 11 5 0
 12 5 1

 I tried expand.grid, but I can't.

 Any suggestion will be greatly appreciated.

 Regards,

 Kathryn Lord

 --
 View this message in context: 
 http://r.789695.n4.nabble.com/create-a-list-under-constraints-tp3714191p3714191.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] Error while trying to install a package

2011-08-03 Thread Patrick Connolly
On Mon, 01-Aug-2011 at 02:55PM -0400, Sushil Amirisetty wrote:

| 
| Hi Everyone, 
| 
| When i try to install a package using 
| 
|  install.packages(agricolae) 
| --- Please select a CRAN mirror for use in this session --- 
| | 
| 
| 

| The cursor keeps blinking i dont get a popup menu to choose a CRAN
| mirror? Is it due to my proxy server settings? I tried to echo
| $http_proxy , it doesnt carry any proxy , its blank. Please help
| me.

Look back in the archives.  There was a discussion in the last month
or so on how you make those settings.  I don't remember the details
because they were to do with Windows (which I'm guessing is what
you're using).



| Thanks, 
| Sushil.
|  [[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.

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

__
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] convert a splus randomforest object to R

2011-08-03 Thread Duncan Mackay

Hi Jimmy

Years ago I think that Splus introduced an argument when dumping of 
old.style = T  or something similar to dump it into a form that could 
be read into R.

This may only be for data.frames etc not things like random forest objects

Regards

Duncan


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


At 10:10 03/08/2011, you wrote:

Hi,

I have a randomforest object cost.rf that was created in splus 8.0,
now I need to use this trained RF model in R. So in Splus, I dump the RF
file as below

data.dump(cost.rf, file=cost.rf.txt, oldStyle=T)

then in R, restore the dumped file,

library(foreign)

data.restore(cost.rf.txt)

it works fine and able to restore the cost.rf object. But when I try
to pass a new data through this randomforest object using predict()
function, it gives me error message.

in R:

library(randomForest)
set.seed(2211)

pred - predict(cost.rf, InputData[ , ])

Error in object$forest$cutoff : $ operator is invalid for atomic vectors


Looks like after restoring the dump file, the object is not compatible
in R. Have anyone successfully converted a splus randomforest object to
R? what will be the appropriate method to do this?

Thanks in advance.

Jimmy

==
This communication contains information that is confidential, and 
solely for the use of the intended recipient. It may contain 
information that is privileged and exempt from disclosure under 
applicable law. If you are not the intended recipient of this 
communication, please be advised that any disclosure, copying, 
distribution or use of this communication is strictly prohibited. 
Please also immediately notify SCAN Health Plan at 1-800-247-5091, 
x5263 and return the communication to the originating address.

Thank You.
==

[[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] cdplot error

2011-08-03 Thread Allan Engelhardt (CYBAEA)

On 03/08/11 05:52, wildernessness wrote:

Fairly new at this.
Trying to create a conditional density plot.


cdplot(status~harvd.l,data=phy)

Error in cdplot.formula(status~harvd.l,data=phy):
dependent variable should be a factor

What does this error mean?  Status is a binary response of infestation (0/1)


Probably status is a numerical variable rather than a factor**.  Try 
print(is.factor(phy$status)) and if that is FALSE then


phy$status - factor(phy$status, labels=c(N, Y))
cdplot(status~harvd.l,data=phy)

Hope this helps a little.

Allan


and harvd.l is the log of timber harvest density per catchment.

Thanks.

--
View this message in context: 
http://r.789695.n4.nabble.com/cdplot-error-tp3714454p3714454.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.


[R] Finding dependancies?

2011-08-03 Thread Rainer M Krug
Hi

although the background is that it happened on an hpc cluster, this question
does *not* concern hpc computing with R.

I was using R on a cluster and had to install several packages in my home
directory. Now the head node was migrated to new hardware (new install as
well) and many dependencies for my in $HOME installed packages, which were
present on the old head, are missing on the new head. Now I could simply try
to run my script, wait for the error message, mail the administrator to
install the package, try again, ... . But this is a tedious process - and I
can not go to him directly, as I am sitting opn a different continent.

So my question: is there an easy way (like ldd for programs), to identify
the dependencies which are not met, and how could I use that on the
packages?

Thanks,

Rainer

-- 
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology,
UCT), Dipl. Phys. (Germany)

Centre of Excellence for Invasion Biology
Stellenbosch University
South Africa

Tel :   +33 - (0)9 53 10 27 44
Cell:   +33 - (0)6 85 62 59 98
Fax (F):   +33 - (0)9 58 10 27 44

Fax (D):+49 - (0)3 21 21 25 22 44

email:  rai...@krugs.de

Skype:  RMkrug

[[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] lattice: index plot

2011-08-03 Thread Thaler, Thorn, LAUSANNE, Applied Mathematics
 Does
 
   xyplot(y ~ seq_along(y), xlab = Index)
 
 do what you want?


Not exactly, because it does not work once multipanel conditioning comes
into play:

xyplot(y~seq_along(y)|factor(rep(1:2, each=5)), xlab = Index)

The points in the right panel are plotted from 6:10 while the points in
the left panel are plotted from 1:5. Of course I could do something like


xyplot(y~rep(1:5, 2) |factor(rep(1:2, each=5)), xlab = Index)

in this toy example, but as pointed out this becomes very cumbersome if
the grouping variable does not follow a pattern.

BTW: my toy example did not work with multipanel conditioning either,
but one can work around that too using the subscripts argument in the
panel function (I skipped that exercise for the sake of brevity, but I
must admit that it obscured somehow my real intention, sorry for that).

However, the more I think of it the more I believe that I have to
provide the x's explicitly nevertheless and my solution would be:

set.seed(123)
y - rnorm(20)
grp - index - sample(3, 20, TRUE)
index[unlist(lapply(levels(as.factor(grp)), function(n)
which(as.factor(grp)==n)))] - unlist(tapply(grp, grp, seq_along)) 
xyplot(y ~ index | factor(grp), xlab = Index)

This should work, but it seems to be a rather elaborate solution,
especially since an index plot is nothing too fancy.

So maybe I'm not seeing the wood for trees, but does anybody know an
easier way?

Thanks.

KR,

-Thorn

__
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] cdplot error

2011-08-03 Thread Peter Ehlers

On 2011-08-02 21:52, wildernessness wrote:

Fairly new at this.
Trying to create a conditional density plot.


cdplot(status~harvd.l,data=phy)

Error in cdplot.formula(status~harvd.l,data=phy):
dependent variable should be a factor

What does this error mean?  Status is a binary response of infestation (0/1)
and harvd.l is the log of timber harvest density per catchment.


Your question suggests that have not looked at help(cdplot)
which clearly says just what the error message says and/or
you aren't aware that 'factor' has a specific meaning in R
in which case a look at chapter 4 of 'An Introduction to R'
likely would be profitable.

Peter Ehlers



Thanks.

--
View this message in context: 
http://r.789695.n4.nabble.com/cdplot-error-tp3714454p3714454.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.


[R] Running R in a sandbox

2011-08-03 Thread Antonio Rodriges
Hello,

The idea is to grant access of remote users to R running on Linux.
Users must have ability to run their
R scripts but avoid corrupting the operating system.

How one can restrict/limit access of remote users to certain R
functions? For example, dealing with IO (file system), graphical
tools, etc.

Thank you.

-- 
Kind regards,
Antonio Rodriges

__
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] fixInNamespace

2011-08-03 Thread ms3437
Dear all,

I would like to ask how one can access certain methods via fixInNamespace. 
Is there some option / way for selecting a certain methods for a defined 
signature. 

Thank you for your answer and efforts in advance!

Best,

Michael

--

__
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] conditional data replace (recode, change or whatsoever)

2011-08-03 Thread zcatav
Hello,
I have a big data.frame, a piece of it as follows.

a   b   c   d
1   58009   2010-11-02  0   NA
2   114761  NA  1   2008-11-05
3   184440  NA  1   2009-12-08
4   189372  NA  0   NA
5   105286  NA  0   NA
6   186717  NA  0   NA
7   189106  NA  0   NA
8   127306  NA  0   NA
9   157342  2011-04-25  0   NA

I want to replace b[NA] values with 20011-07-28 where c==0. I use rstudio
and i'm a novice.


--
View this message in context: 
http://r.789695.n4.nabble.com/conditional-data-replace-recode-change-or-whatsoever-tp3714715p3714715.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] Odp: conditional data replace (recode, change or whatsoever)

2011-08-03 Thread Petr PIKAL
Hi
 
 Hello,
 I have a big data.frame, a piece of it as follows.
 
 a   b  c   d
 1   58009   2010-11-02   0   NA
 2   114761   NA  1   2008-11-05
 3   184440   NA  1   2009-12-08
 4   189372   NA  0   NA
 5   105286   NA  0   NA
 6   186717   NA  0   NA
 7   189106   NA  0   NA
 8   127306   NA  0   NA
 9   157342   2011-04-25   0   NA
 
 I want to replace b[NA] values with 20011-07-28 where c==0. I use 
rstudio
 and i'm a novice.

I believe there are better solutions but I would use two steps

select rows where c==0 (see also FAQ 7.31)
sel-which(big.data.frame$c==0)

change NA values in b column based on sel
big.data.frame$b[sel][is.na(big.data.frame$b[sel])]-20011-07-28

Beware of data types AFAIK R can not accept 20011-07-28 as a date.

Regards
Petr

 
 
 --
 View this message in context: http://r.789695.n4.nabble.com/conditional-
 data-replace-recode-change-or-whatsoever-tp3714715p3714715.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] conditional data replace (recode, change or whatsoever)

2011-08-03 Thread Romain DOUMENC
Please do your homework before asking the list:
An introduction to R, chapter 7

Am 03.08.2011 10:05, schrieb zcatav:
 Hello,
 I have a big data.frame, a piece of it as follows.
 
   a   b   c   d
 1 58009   2010-11-02  0   NA
 2 114761  NA  1   2008-11-05
 3 184440  NA  1   2009-12-08
 4 189372  NA  0   NA
 5 105286  NA  0   NA
 6 186717  NA  0   NA
 7 189106  NA  0   NA
 8 127306  NA  0   NA
 9 157342  2011-04-25  0   NA
 
 I want to replace b[NA] values with 20011-07-28 where c==0. I use rstudio
 and i'm a novice.
 
 
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/conditional-data-replace-recode-change-or-whatsoever-tp3714715p3714715.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] R-help Digest, Vol 102, Issue 3

2011-08-03 Thread fraenzi . korner
Wir sind bis am 20. August in den Ferien und werden keine e-mails beantworten. 
Bei dringenden Fällen melden Sie sich bei Stefanie von Felten 
steffi.vonfel...@oikostat.ch

We are on vacation until 20. August. In urgent cases, please contact Stefanie 
von Felten steffi.vonfel...@oikostat.ch

__
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] syntax with do.call and `[`

2011-08-03 Thread Jannis
Dear List,



i would like to mimic the behaviour or the following indexing with a do.call 
construct to be able to supply the arguments to `[` as a list:


test   = matrix[1:4,2]

result = test[2,]


My try, however, did not work:

result = do.call(`[`,list(test,2,NULL))
result = do.call(`[`,list(test,2,))
result = do.call(`[`,list(test,2,''))


How can I use the do.call in that way with leaving the second indexing vector 
blanc?


Cheers
Jannis

__
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] Need to compute density as done by panel.histogram

2011-08-03 Thread Peter Ehlers

On 2011-08-02 11:51, Sébastien Bihorel wrote:

Hi,

This might be a simple problem but I don't know how to calculate a random
variable density the way panel.histogram does it before it creates the
actual density rectangles. The documentation says that it uses the density
function but the actual code suggests that the hist.constructor function
(which does not seem to be easily accessible).


The documentation in ?histogram is misleading. I think that the intent
is that density() is used in panel.densityplot but panel.histogram uses
hist(), as is clear in ?panel.histogram.

So you'll find the code for the density rectangles in hist.default
where 'counts' is computed and followed with

 dens - counts/(n * diff(breaks))

You might find the code for truehist() in the MASS package easy to
follow.

To see how hist.constructor calls hist():

 lattice:::hist.constructor

Peter Ehlers



Any suggestion for computing the density values of foo$x in the following
example will be welcome.


require(lattice)
set.seed(12345)

foo1-
data.frame(x=rnorm(100,0,0.1),grp=1,by=rep(1:2,each=50),by2=rep(1:2,times=50))
foo2-
data.frame(x=rnorm(100,2,1),grp=2,by=rep(1:2,each=50),by2=rep(1:2,times=50))
foo- rbind(foo1,foo2)

xplot- histogram(~x,data=foo, type='density')


PS: the present question relates to a workaround for another problem
previously submitted to the list (
https://stat.ethz.ch/pipermail/r-help/attachments/20110727/5f0a8853/attachment.pl).

[[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] conditional data replace (recode, change or whatsoever)

2011-08-03 Thread R. Michael Weylandt michael.weyla...@gmail.com
As others have noted, this is discussed in many free R tutorials, but if you 
want to do it in one line I think this should do it:

X[is.NA(X[,b])(X[,c]==0),b]-2011-07-28 #where X is the name of the 
data frame. 

It's a somewhat convoluted line of code but if you read it inside out the logic 
is clear:

Find those rows where column b is NA and c is 1 by searching all rows of the 
relevant column (the X[,something] syntax): select those rows and the b column. 
Put the desired date in those slots. let me know of I can further clarify this. 
I changed the date assuming a typo on your end. 

Welcome and good luck getting started with R,

Michael Weylandt


On Aug 3, 2011, at 4:05 AM, zcatav zca...@gmail.com wrote:

 Hello,
 I have a big data.frame, a piece of it as follows.
 
   abcd
 1580092010-11-020NA
 2114761NA12008-11-05
 3184440NA12009-12-08
 4189372NA0NA
 5105286NA0NA
 6186717NA0NA
 7189106NA0NA
 8127306NA0NA
 91573422011-04-250NA
 
 I want to replace b[NA] values with 20011-07-28 where c==0. I use rstudio
 and i'm a novice.
 
 
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/conditional-data-replace-recode-change-or-whatsoever-tp3714715p3714715.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] Odp: conditional data replace (recode, change or whatsoever)

2011-08-03 Thread zcatav

Petr Pikal wrote:
 
 Hi
 I believe there are better solutions but I would use two steps
 
 select rows where c==0 (see also FAQ 7.31)
 sel-which(big.data.frame$c==0)
 
 change NA values in b column based on sel
 big.data.frame$b[sel][is.na(big.data.frame$b[sel])]-20011-07-28
 
 Beware of data types AFAIK R can not accept 20011-07-28 as a date.
 
 Regards
 Petr
 
 

Thanks, it runs like a charm.
Replaced date format just a typo.

--
View this message in context: 
http://r.789695.n4.nabble.com/conditional-data-replace-recode-change-or-whatsoever-tp3714715p3715080.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] conditional data replace (recode, change or whatsoever)

2011-08-03 Thread zcatav
Your suggestion works perfect as i pointed previous message. Now have another
question about data editing. I try this code:
X[X[,c]==1,b]-X[,d]
and results with error: `[-.data.frame`(`*tmp*`, X[, c] == 1, b, value
= c(NA,  : 
  replacement has 9 rows, data has 2

Logically i selected 2 rows with X[,c]==1. Than i want to replace in that
rows its own data from d to b with X[,b]-X[,d]. What is wrong?

--
View this message in context: 
http://r.789695.n4.nabble.com/conditional-data-replace-recode-change-or-whatsoever-tp3714715p3715218.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] Coefficient names when using lm() with contrasts

2011-08-03 Thread Peter Morgan
Dear R Users,

Am using lm() with contrasts as below. If I skip the contrasts() 
statement, I get the coefficient names to be 
 names(results$coef)
[1] (Intercept) VarAcat VarArat VarB 

which are much more meaningful than ones based on integers.

Can anyone tell me how to get R to keep the coefficient names based on the 
factor levels whilst using contrasts rather than labelling them with 
integers?

Many thanks in advance,

Pete

Cardiff, UK

 dt=read.table(testreg.txt,sep=,,header=T)
 dt
   ID VarA VarB VarC
1   1  cat2   23
2   2  dog3   56
3   3  rat5   35
4   4  cat2   43
5   5  cat7   51
6   6  dog3   31
7   7  dog4   65
8   8  rat1   18
9   9  rat6   49
10 10  dog3   28
 dt$VarA=relevel(dt$VarA,ref=dog)
 treat3=matrix(-1/3,ncol=2,nrow=3); for (i in 1:2) {treat3[i+1,i]=2/3}
 contrasts(dt$VarA)=treat3
 levels(dt$VarA)
[1] dog cat rat
 results=lm(formula=VarC~VarA+VarB, data=dt)
 names(results$coef)
[1] (Intercept) VarA1   VarA2   VarB 
[[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] conditional data replace (recode, change or whatsoever)

2011-08-03 Thread R. Michael Weylandt michael.weyla...@gmail.com
As R notes, the problem is that you are trying to fit 9 rows into two:
specifically, note that on the left hand side you select only those rows
such that X[,c]==1 (which is 2 for your data) while on the right hand you
select all 9rows of column d so they simply don't fit. If you change the
code to

X[X[,c]==1,b]-X[X[,c]==1,d]

it will move the column d rows corresponding to the ones you've selected
on the LHS. Hopefully that makes sense.

Michael Weylandt

On Wed, Aug 3, 2011 at 8:09 AM, zcatav zca...@gmail.com wrote:

 Your suggestion works perfect as i pointed previous message. Now have
 another
 question about data editing. I try this code:
 X[X[,c]==1,b]-X[,d]
 and results with error: `[-.data.frame`(`*tmp*`, X[, c] == 1, b, value
 = c(NA,  :
  replacement has 9 rows, data has 2

 Logically i selected 2 rows with X[,c]==1. Than i want to replace in that
 rows its own data from d to b with X[,b]-X[,d]. What is wrong?

 --
 View this message in context:
 http://r.789695.n4.nabble.com/conditional-data-replace-recode-change-or-whatsoever-tp3714715p3715218.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.


[[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] conditional data replace (recode, change or whatsoever)

2011-08-03 Thread Gabor Grothendieck
On Wed, Aug 3, 2011 at 8:09 AM, zcatav zca...@gmail.com wrote:
 Your suggestion works perfect as i pointed previous message. Now have another
 question about data editing. I try this code:
 X[X[,c]==1,b]-X[,d]
 and results with error: `[-.data.frame`(`*tmp*`, X[, c] == 1, b, value
 = c(NA,  :
  replacement has 9 rows, data has 2

 Logically i selected 2 rows with X[,c]==1. Than i want to replace in that
 rows its own data from d to b with X[,b]-X[,d]. What is wrong?


Also check out transform and ifelse, e.g.

transform(X, b = ifelse(is.na(b)  c == 0, 2011-07-28, b))

transform(X, b = ifelse(c == 1, d, c))


-- 
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] syntax with do.call and `[`

2011-08-03 Thread Jean V Adams
Good question, Jannis.

I couldn't figure out how to specify the j argument in the [ function as 
empty or missing either.

One work around is to specify ALL the columns as the j argument:

test - matrix(1:4, 2)  # I think this is what you meant in your 
original post, not matrix[1:4, 2]
result1 - test[2, ]
result2 - do.call([, list(test, 2, seq(dim(test)[2])))

test
result1
result2

Jean


`·.,,  (((º   `·.,,  (((º   `·.,,  (((º

Jean V. Adams
Statistician
U.S. Geological Survey
Great Lakes Science Center
223 East Steinfest Road
Antigo, WI 54409  USA



From:
Jannis bt_jan...@yahoo.de
To:
r-help@r-project.org
Date:
08/03/2011 05:35 AM
Subject:
[R] syntax with do.call and `[`
Sent by:
r-help-boun...@r-project.org



Dear List,



i would like to mimic the behaviour or the following indexing with a 
do.call construct to be able to supply the arguments to `[` as a list:


test   = matrix[1:4,2]

result = test[2,]


My try, however, did not work:

result = do.call(`[`,list(test,2,NULL))
result = do.call(`[`,list(test,2,))
result = do.call(`[`,list(test,2,''))


How can I use the do.call in that way with leaving the second indexing 
vector blanc?


Cheers
Jannis

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



[[alternative HTML version deleted]]

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


Re: [R] How to make a nomogam and Calibration plot

2011-08-03 Thread Frank Harrell
The nomogram you included was produced by the Design package, the precursor
to the rms package.  You will have to take the time to intensively read the
rms package documentation.  Note that how you developed the model (e.g.,
allowing for non-linearity in log PSA, not using stepwise regression which
invalidates the results, making sure all clinically relevant predictors are
in the model, ...) is the most important step.  The process you are going
through generally requires an M.S. in biostatistics.
Frank

sytangping wrote:
 
 Dear Harrell,
 
 Many thanks for your quick response!
 However, after try and try, I still have difficulty to solve my questions.
 I post my questions again. I hope someone can help me run the data and
 draw the nomogram and calibration plot for me. I know that is not good but
 indeed I have no way to go. The problems almost drove me mad!
 
 Best regards!
 
 Ping Tang
 
 Dear R users,
 
 I am a new R user and something stops me when I try to write a academic
 article. I want to make a nomogram to predict the risk of prostate cancer
 (PCa) using several factors which have been selected from the Logistic
 regression run under the SPSS. Always, a calibration plot is needed to
 validate the prediction accuracy of the nomogram.
 However, I tried many times and read a lot of posts with respect to this
 topic but I still couldn't figure out how to draw the nomogram and the
 calibration plot. Attached file is the dataset for the research. It will
 be very grateful if someone can save his/her time to help for my
 questions.
 
 Warmest regards!
 
 Logistic Regression
 
 Classification Tablea,b
   ObservedPredicted
   Pca-YN  Percentage Correct
   0   1   
 Step 0Pca-YN  0   295 0   100.0
   1   218 0   .0
   Overall Percentage  57.5
 
 
 Variables in the Equation
   B   S.E.Walddf  Sig.Exp(B)  95.0% C.I.for 
 EXP(B)
   Lower   Upper
 Step 1a   Age .031.0154.491   1   .0341.032   1.002   
 1.062
   DRE 1.173   .26619.492  1   .0003.233   1.920   5.443
   LogPV   -2.857  .50931.532  1   .000.057.021.156
   LogPSA  2.316   .24688.416  1   .00010.132  6.253   16.419
   Constant-1.024  1.273   .6481   .421.359
   
 
 The equation:
 
 Probability = 
 
  e-1.024+0.31age+1.173DRE+-2.857LogPV+2.316LogPSA
 1+e-1.024+0.31age+1.173DRE+-2.857LogPV+2.316LogPSA
 
 My questions are,
 
 1.How to draw a nomogram (similar to the below figure 1) to predict the
 probability of cancer using R?
 
 2. How to make the Calibration plot (similar to the below figure 2) which
 used to validate the prediction accuracy of the nomogram using R? And how
 to calculate the concordance index (C-index) ?
 
 
  http://r.789695.n4.nabble.com/file/n3714477/untitled.jpg 
 http://r.789695.n4.nabble.com/file/n3714477/%E9%99%84%E4%BB%B62.jpg 
 http://r.789695.n4.nabble.com/file/n3714477/Dataset.xls Dataset.xls 
 


-
Frank Harrell
Department of Biostatistics, Vanderbilt University
--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-make-a-nomogam-and-Calibration-plot-tp3710068p3715336.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] Running R in a sandbox

2011-08-03 Thread Dieter Menne

Antonio Rodriges wrote:
 
 
 The idea is to grant access of remote users to R running on Linux. Users
 must have ability to run their
 R scripts but avoid corrupting the operating system.
 
 

Check RStudio.org

Dieter


--
View this message in context: 
http://r.789695.n4.nabble.com/Running-R-in-a-sandbox-tp3714716p3715351.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] xlsx error

2011-08-03 Thread Dieter Menne

Andrew Winterman wrote:
 
 
 I'm trying to use the xlsx package to read a series of excel spreadsheets
 into R, but my code is failing at the first step.
 
 I setwd into my the directory with the spreadsheets, and, as a test ask
 for
 the first one:
 
read.xlsx(file = Argentina Final.xls, sheetIndex = 1)
 I promptly get an error message:
 Error in .jcall(row[[ir]], Lorg/apache/poi/xssf/usermodel/XSSFCell;,  :
 
 

Check if your Java installation is ok. Try to access an rJava function
directly for a test

Dieter


--
View this message in context: 
http://r.789695.n4.nabble.com/xlsx-error-tp3714057p3715367.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] 3D Bar Graphs in ggplot2?

2011-08-03 Thread wwreith
So I take it 3D pie charts are out? 

P.S. It is not about hiding anything. It is about consulting and being told
by your client to make 3D pie charts and change this font or that color to
make the graphs more apealing. Given that I am the one trying to open the
door to using R where I work it would be much easier if I could simply use a
2D graph.

--
View this message in context: 
http://r.789695.n4.nabble.com/3D-Bar-Graphs-in-ggplot2-tp3713305p3715382.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] conditional data replace (recode, change or whatsoever)

2011-08-03 Thread David Winsemius


On Aug 3, 2011, at 8:09 AM, zcatav wrote:

Your suggestion works perfect as i pointed previous message. Now  
have another

question about data editing. I try this code:
X[X[,c]==1,b]-X[,d]
and results with error: `[-.data.frame`(`*tmp*`, X[, c] == 1,  
b, value

= c(NA,  :
 replacement has 9 rows, data has 2

Logically i selected 2 rows with X[,c]==1. Than i want to replace  
in that
rows its own data from d to b with X[,b]-X[,d]. What is  
wrong?


You need to apply the same logical test/selection on the rows of the  
RHS as you are doing on the LHS.

Possibly:

X[ X[,c]==1, b] - X[ X[,c]==1, d]

(No data, not tested code.)
--

David Winsemius, MD
West Hartford, CT

__
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] Running R in a sandbox

2011-08-03 Thread Barry Rowlingson
On Wed, Aug 3, 2011 at 9:04 AM, Antonio Rodriges antonio@gmail.com wrote:
 Hello,

 The idea is to grant access of remote users to R running on Linux.
 Users must have ability to run their
 R scripts but avoid corrupting the operating system.

 Ordinary users can't corrupt the operating system on Linux[1]. The
worst they can do is run CPU- and memory-intensive tasks that can slow
things down for everyone and conceivably bring the system to a halt,
but there are ways of limiting CPU and memory usage per user session.

 What don't you want them to do?

Barry

[1] Security holes excepted. But those will be present in any sandbox solution.

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


Re: [R] Error Installing or Updating Packages (Maybe because of a proxy)

2011-08-03 Thread mohammad...@gmail.com
Hello David,
I encountered the same problem of yours.
What did you do to resolve it?
Thanks for your reply
Mohammad

--
View this message in context: 
http://r.789695.n4.nabble.com/Error-Installing-or-Updating-Packages-Maybe-because-of-a-proxy-tp3462312p3715332.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] slow computation of functions over large datasets

2011-08-03 Thread Caroline Faisst
Hello there,


I’m computing the total value of an order from the price of the order items
using a “for” loop and the “ifelse” function. I do this on a large dataframe
(close to 1m lines). The computation of this function is painfully slow: in
1min only about 90 rows are calculated.


The computation time taken for a given number of rows increases with the
size of the dataset, see the example with my function below:


# small dataset: function performs well

exampledata-data.frame(orderID=c(1,1,1,2,2,3,3,3,4),itemPrice=c(10,17,9,12,25,10,1,9,7))

exampledata[1,orderAmount]-exampledata[1,itemPrice]

system.time(for (i in 2:length(exampledata[,1]))
{exampledata[i,orderAmount]-ifelse(exampledata[i,orderID]==exampledata[i-1,orderID],exampledata[i-1,orderAmount]+exampledata[i,itemPrice],exampledata[i,itemPrice])})


# large dataset: the very same computational task takes much longer

exampledata2-data.frame(orderID=c(1,1,1,2,2,3,3,3,4,5:200),itemPrice=c(10,17,9,12,25,10,1,9,7,25:220))

exampledata2[1,orderAmount]-exampledata2[1,itemPrice]

system.time(for (i in 2:9)
{exampledata2[i,orderAmount]-ifelse(exampledata2[i,orderID]==exampledata2[i-1,orderID],exampledata2[i-1,orderAmount]+exampledata2[i,itemPrice],exampledata2[i,itemPrice])})



Does someone know a way to increase the speed?


Thank you very much!

Caroline

[[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] equivalent of var.test(x,y) for skew and kurtosis

2011-08-03 Thread Timothy Bates
Dear R-users,
I am comparing differences in variance, skew, and kurtosis between two groups.

For variance the comparison is easy: just 
 var.test(group1, group2)

I am using  agostino.test() for skew, and anscombe.test() for kurtosis. 
However, I can't  find an equivalent of the F.test or Mood.test for comparing 
kurtosis or skewness between two samples.

Would the test just be a 1 df test on the difference in Z or F scores returned 
by the agostino or anscombe? How are the differences distributed: chi2?

Any guidance greatly appreciated.

google and wikipedia return hits for measuring the third and fourth 
standardized moments, but none I can see for comparing differences on these 
parameters.

best, tim

__
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] slow computation of functions over large datasets

2011-08-03 Thread ONKELINX, Thierry
Dear Caroline,

Here is a faster and more elegant solution.

 n - 1
 exampledata - data.frame(orderID = sample(floor(n / 5), n, replace = TRUE), 
 itemPrice = rpois(n, 10))
 library(plyr)
 system.time({
+   ddply(exampledata, .(orderID), function(x){
+   data.frame(itemPrice = x$itemPrice, orderAmount = 
cumsum(x$itemPrice))
+   })
+ })
   user  system elapsed 
   1.670.001.69 
 exampledata[1,orderAmount]-exampledata[1,itemPrice]
 system.time(for (i in 2:length(exampledata[,1]))
+ 
{exampledata[i,orderAmount]-ifelse(exampledata[i,orderID]==exampledata[i-1,orderID],exampledata[i-1,orderAmount]+exampledata[i,itemPrice],exampledata[i,itemPrice])})
   user  system elapsed 
  11.940.02   11.97

Best regards,

Thierry
 -Oorspronkelijk bericht-
 Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 Namens Caroline Faisst
 Verzonden: woensdag 3 augustus 2011 15:26
 Aan: r-help@r-project.org
 Onderwerp: [R] slow computation of functions over large datasets
 
 Hello there,
 
 
 I'm computing the total value of an order from the price of the order items 
 using
 a for loop and the ifelse function. I do this on a large dataframe (close 
 to
 1m lines). The computation of this function is painfully slow: in 1min only 
 about
 90 rows are calculated.
 
 
 The computation time taken for a given number of rows increases with the size
 of the dataset, see the example with my function below:
 
 
 # small dataset: function performs well
 
 exampledata-
 data.frame(orderID=c(1,1,1,2,2,3,3,3,4),itemPrice=c(10,17,9,12,25,10,1,9,7))
 
 exampledata[1,orderAmount]-exampledata[1,itemPrice]
 
 system.time(for (i in 2:length(exampledata[,1]))
 {exampledata[i,orderAmount]-
 ifelse(exampledata[i,orderID]==exampledata[i-1,orderID],exampledata[i-
 1,orderAmount]+exampledata[i,itemPrice],exampledata[i,itemPrice])})
 
 
 # large dataset: the very same computational task takes much longer
 
 exampledata2-
 data.frame(orderID=c(1,1,1,2,2,3,3,3,4,5:200),itemPrice=c(10,17,9,12,25,1
 0,1,9,7,25:220))
 
 exampledata2[1,orderAmount]-exampledata2[1,itemPrice]
 
 system.time(for (i in 2:9)
 {exampledata2[i,orderAmount]-
 ifelse(exampledata2[i,orderID]==exampledata2[i-
 1,orderID],exampledata2[i-
 1,orderAmount]+exampledata2[i,itemPrice],exampledata2[i,itemPrice])})
 
 
 
 Does someone know a way to increase the speed?
 
 
 Thank you very much!
 
 Caroline
 
   [[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] Combining multiple dependent variables for machine learning

2011-08-03 Thread Vishal Thapar
Hi,

I apologize for posting this here, I am also trying to post this on machine
learning emailing lists.

I have a set (18K) of sequences (22 nt long) and I have their counts at 4
different stages. The difference in counts from one stage to the next
represents how well the sequence performed in the transition. The total
counts remain about the same in each stage. So if a 1 sequence loses some
counts in 1 stage, another sequence gains those counts in that stage. I am
trying to build a predictor that combines these 4 stages. I have already
tried to build an SVM using just the counts in the final stage but its not
that great (0.3 correlation with test set). The problem I am facing now is
how to combine these 4 stages into 1 dependent variable or something like
that. The 4 stages are the dependent variables and the sequence is my
independent variable. The aim is to use the count information in each stage
to select how well the sequence performs across all 4 stages.

I appreciate any suggestions for this problem.

Sincerely,

Vishal

[[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] Need to compute density as done by panel.histogram

2011-08-03 Thread Sébastien Bihorel
Thank you very much Peter,

I'm going to dig deeper into the code of the functions you've listed.


On Wed, Aug 3, 2011 at 6:57 AM, Peter Ehlers ehl...@ucalgary.ca wrote:

 On 2011-08-02 11:51, Sébastien Bihorel wrote:

 Hi,

 This might be a simple problem but I don't know how to calculate a random
 variable density the way panel.histogram does it before it creates the
 actual density rectangles. The documentation says that it uses the density
 function but the actual code suggests that the hist.constructor function
 (which does not seem to be easily accessible).


 The documentation in ?histogram is misleading. I think that the intent
 is that density() is used in panel.densityplot but panel.histogram uses
 hist(), as is clear in ?panel.histogram.

 So you'll find the code for the density rectangles in hist.default
 where 'counts' is computed and followed with

  dens - counts/(n * diff(breaks))

 You might find the code for truehist() in the MASS package easy to
 follow.

 To see how hist.constructor calls hist():

  lattice:::hist.constructor

 Peter Ehlers


 Any suggestion for computing the density values of foo$x in the following
 example will be welcome.


 require(lattice)
 set.seed(12345)

 foo1-
 data.frame(x=rnorm(100,0,0.1),**grp=1,by=rep(1:2,each=50),by2=**
 rep(1:2,times=50))
 foo2-
 data.frame(x=rnorm(100,2,1),**grp=2,by=rep(1:2,each=50),by2=**
 rep(1:2,times=50))
 foo- rbind(foo1,foo2)

 xplot- histogram(~x,data=foo, type='density')


 PS: the present question relates to a workaround for another problem
 previously submitted to the list (
 https://stat.ethz.ch/**pipermail/r-help/attachments/**
 20110727/5f0a8853/attachment.**plhttps://stat.ethz.ch/pipermail/r-help/attachments/20110727/5f0a8853/attachment.pl
 ).

[[alternative HTML version deleted]]

 __**
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/**
 posting-guide.html 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] Combining multiple dependent variables for machine learning

2011-08-03 Thread Sarah Goslee
Hi,

On Wed, Aug 3, 2011 at 10:06 AM, Vishal Thapar vishaltha...@gmail.com wrote:
 Hi,

 I apologize for posting this here, I am also trying to post this on machine
 learning emailing lists.

 I have a set (18K) of sequences (22 nt long) and I have their counts at 4
 different stages. The difference in counts from one stage to the next
 represents how well the sequence performed in the transition. The total
 counts remain about the same in each stage. So if a 1 sequence loses some
 counts in 1 stage, another sequence gains those counts in that stage. I am
 trying to build a predictor that combines these 4 stages. I have already
 tried to build an SVM using just the counts in the final stage but its not
 that great (0.3 correlation with test set). The problem I am facing now is
 how to combine these 4 stages into 1 dependent variable or something like
 that. The 4 stages are the dependent variables and the sequence is my
 independent variable. The aim is to use the count information in each stage
 to select how well the sequence performs across all 4 stages.

 I appreciate any suggestions for this problem.

Suggestions? Yes. Read the posting guide and follow it. It isn't clear that
this is even an R question, since you don't tell us anything about the
packages or functions you are using, or about your data. There aren't
any actual questions in your message, and your problem statement
is exceedingly vague.

You might find more help on the Bioconductor list, if in fact you are using
R for your problem.

Sarah

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

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


Re: [R] lattice: index plot

2011-08-03 Thread Peter Ehlers

On 2011-08-03 00:24, Thaler,Thorn,LAUSANNE,Applied Mathematics wrote:

Does

   xyplot(y ~ seq_along(y), xlab = Index)

do what you want?



Not exactly, because it does not work once multipanel conditioning comes
into play:

xyplot(y~seq_along(y)|factor(rep(1:2, each=5)), xlab = Index)

The points in the right panel are plotted from 6:10 while the points in
the left panel are plotted from 1:5. Of course I could do something like


xyplot(y~rep(1:5, 2) |factor(rep(1:2, each=5)), xlab = Index)

in this toy example, but as pointed out this becomes very cumbersome if
the grouping variable does not follow a pattern.

BTW: my toy example did not work with multipanel conditioning either,
but one can work around that too using the subscripts argument in the
panel function (I skipped that exercise for the sake of brevity, but I
must admit that it obscured somehow my real intention, sorry for that).

However, the more I think of it the more I believe that I have to
provide the x's explicitly nevertheless and my solution would be:

set.seed(123)
y- rnorm(20)
grp- index- sample(3, 20, TRUE)
index[unlist(lapply(levels(as.factor(grp)), function(n)
which(as.factor(grp)==n)))]- unlist(tapply(grp, grp, seq_along))
xyplot(y ~ index | factor(grp), xlab = Index)

This should work, but it seems to be a rather elaborate solution,
especially since an index plot is nothing too fancy.

So maybe I'm not seeing the wood for trees, but does anybody know an
easier way?


Here's a way to use 'subscripts' in the xyplot.
The main problem is to determine the xlims to use.

 dat - data.frame(y, grp)

 ## xlims
 xL - function(groups){
   tbl - table(groups)
   xlim - c(0, max(tbl) + 1)
   xlim
 }

 xyplot(y ~ seq_along(y) | factor(grp), data = dat,
   xlim = xL(dat$grp),
   panel = function(y, subscripts){
 x - seq_along(subscripts)
 panel.xyplot(x, y)
   }
 )


Peter Ehlers



Thanks.

KR,

-Thorn





__
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] confint() in stats4 package

2011-08-03 Thread Jinsong Zhao

Hi there,

I had a problem when I hoped to get confidence intervals for the 
parameters I got using mle() of stats4 package. This problem would not 
appear if ``fixed'' option was not used. The following mini-example will 
demo the problem:


x - c(100, 56, 32, 18, 10, 1)
r - c(18, 17, 10, 6, 4, 3)
n - c(18, 22, 17, 21, 23, 20)

loglik.1 - function(alpha, beta, c) {
  x - log10(x)
  P - c + (1-c) * pnorm(alpha + beta * x)
  control - which(x == -Inf)
  if (length(control) != 0) P[control] - c
  P - pmax(pmin(P,1),0)
  -(sum(r * log(P)) + sum((n - r)* log(1-P)))
}

loglik.2 - function(alpha, beta) {
  x - log10(x)
  P - pnorm(alpha + beta * x)
  P - pmax(pmin(P,1),0)
  -(sum(r * log(P)) + sum((n - r)* log(1-P)))
}

library(stats4)

fit.1 - mle(loglik.1, start = list(alpha = 0, beta = 0, c = 0), method 
= BFGS, fixed = list(c=0))


fit.2 - mle(loglik.2, start = list(alpha = 0, beta = 0), method = 
BFGS, fixed = list())


 confint(fit.1)
Profiling...
Error in approx(sp$y, sp$x, xout = cutoff) :
  need at least two non-NA values to interpolate
In addition: Warning message:
In approx(sp$y, sp$x, xout = cutoff) : collapsing to unique 'x' values
 confint(fit.2)
Profiling...
   2.5 %97.5 %
alpha -2.5187909 -1.144600
beta   0.9052395  1.876322

The version I test the above code is 2.11.1 and 2.13.1.

I hope to know what's the matter? and how to avoid the error, and get 
the correct confidence intervals for the parameters? Any suggestions 
will be really appreciated.


P.S.: I noticed that there was a file named mle.R.rej in the source 
directory of stats4. A broken patch? Thanks!


Regards,
Jinsong

__
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] syntax with do.call and `[`

2011-08-03 Thread peter dalgaard

On Aug 3, 2011, at 12:30 , Jannis wrote:

 Dear List,
 
 
 
 i would like to mimic the behaviour or the following indexing with a do.call 
 construct to be able to supply the arguments to `[` as a list:
 
 
 test   = matrix[1:4,2]
 
 result = test[2,]
 
 
 My try, however, did not work:
 
 result = do.call(`[`,list(test,2,NULL))
 result = do.call(`[`,list(test,2,))
 result = do.call(`[`,list(test,2,''))
 
 
 How can I use the do.call in that way with leaving the second indexing vector 
 blanc?
 

alist() actually allows this, although probably more by coincidence than by 
design.

Watch:

 do.call(`[`, alist(test, 2, ))
[1] 2 4

If you want to turn this into a programming idiom, be aware that there are 
subtle differences because alist() does not evaluate its arguments. E.g., the 
two plots below are not quite the same.

 x - 1:10
 y - rnorm(10)
 do.call(plot, list(x, y))
 do.call(plot, alist(x, y))


-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd@cbs.dk  Priv: pda...@gmail.com
Døden skal tape! --- Nordahl Grieg

__
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] slow computation of functions over large datasets

2011-08-03 Thread David Winsemius


On Aug 3, 2011, at 9:25 AM, Caroline Faisst wrote:


Hello there,


I’m computing the total value of an order from the price of the  
order items

using a “for” loop and the “ifelse” function.


Ouch. Schools really should stop teaching SAS and BASIC as a first  
language.



I do this on a large dataframe
(close to 1m lines). The computation of this function is painfully  
slow: in

1min only about 90 rows are calculated.


The computation time taken for a given number of rows increases with  
the

size of the dataset, see the example with my function below:


# small dataset: function performs well

exampledata- 
data 
.frame 
(orderID=c(1,1,1,2,2,3,3,3,4),itemPrice=c(10,17,9,12,25,10,1,9,7))


exampledata[1,orderAmount]-exampledata[1,itemPrice]

system.time(for (i in 2:length(exampledata[,1]))
{exampledata[i,orderAmount]- 
ifelse 
(exampledata 
[i 
,orderID 
]==exampledata[i-1,orderID],exampledata[i-1,orderAmount] 
+exampledata[i,itemPrice],exampledata[i,itemPrice])})


Try instead using 'ave' to calculate a cumulative 'sum' within  
orderID:


exampledata$orderAmt - with(exampledata,  ave(itemPrice, orderID,  
FUN=cumsum) )


I assure you this will be more reproducible,  faster, and  
understandable.



# large dataset:


medium dataset really. Barely nudges the RAM dial on my machine.


the very same computational task takes much longer

exampledata2- 
data 
.frame 
(orderID 
= 
c 
(1,1,1,2,2,3,3,3,4,5 
:200),itemPrice=c(10,17,9,12,25,10,1,9,7,25:220))


exampledata2[1,orderAmount]-exampledata2[1,itemPrice]

system.time(for (i in 2:9)
{exampledata2[i,orderAmount]- 
ifelse 
(exampledata2 
[i 
,orderID 
]==exampledata2[i-1,orderID],exampledata2[i-1,orderAmount] 
+exampledata2[i,itemPrice],exampledata2[i,itemPrice])})



 system.time( exampledata2$orderAmt - with(exampledata2,   
ave(itemPrice, orderID, FUN=cumsum) ) )

   user  system elapsed
 35.106   0.811  35.822

On a three year-old machine. Not as fast as I expected, but not long  
enough to require refilling the coffee cup either.


--
David.


Does someone know a way to increase the speed?



--

David Winsemius, MD
West Hartford, CT

__
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] syntax with do.call and `[`

2011-08-03 Thread Prof Brian Ripley

On Wed, 3 Aug 2011, peter dalgaard wrote:



On Aug 3, 2011, at 12:30 , Jannis wrote:


Dear List,



i would like to mimic the behaviour or the following indexing with a do.call 
construct to be able to supply the arguments to `[` as a list:


test   = matrix[1:4,2]

result = test[2,]


My try, however, did not work:

result = do.call(`[`,list(test,2,NULL))
result = do.call(`[`,list(test,2,))
result = do.call(`[`,list(test,2,''))


How can I use the do.call in that way with leaving the second indexing vector 
blanc?



alist() actually allows this, although probably more by coincidence than by 
design.

Watch:


do.call(`[`, alist(test, 2, ))

[1] 2 4

If you want to turn this into a programming idiom, be aware that there are 
subtle differences because alist() does not evaluate its arguments. E.g., the 
two plots below are not quite the same.


x - 1:10
y - rnorm(10)
do.call(plot, list(x, y))
do.call(plot, alist(x, y))


I decided to forbear suggesting that, not least as someone who writes

test   = matrix[1:4,2]

appears to know very little R and test even less.

But for indexing the answer could be something like

do.call(`[`, list(test, 2, TRUE))

as in almost all cases (including here) an empty index is equivalent 
to TRUE (which is recycled to the required length).



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


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

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


[R] step

2011-08-03 Thread Diana Schwegler
Hello I am using the step function in order to do backward selection for a
linear model of more than 200 variables but it doesn't work correctly.
I think, there is a problem, if the matrix has same or more columns than
rows. 
And if the matrix has too much columns the step-function doesn't work
because the function will work with all columns together and I think, this
is
the problem.
Is there a solution or a bug fixing of this problem?

Thanks a lot

--
View this message in context: 
http://r.789695.n4.nabble.com/step-tp3715681p3715681.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] conditional data replace (recode, change or whatsoever)

2011-08-03 Thread zcatav

Gabor Grothendieck wrote:
 
 On Wed, Aug 3, 2011 at 8:09 AM, zcatav lt;zca...@gmail.comgt; wrote:
 Your suggestion works perfect as i pointed previous message. Now have
 another
 question about data editing. I try this code:
 X[X[,c]==1,b]-X[,d]
 and results with error: `[-.data.frame`(`*tmp*`, X[, c] == 1, b,
 value
 = c(NA,  :
  replacement has 9 rows, data has 2

 Logically i selected 2 rows with X[,c]==1. Than i want to replace in
 that
 rows its own data from d to b with X[,b]-X[,d]. What is wrong?

 
 Also check out transform and ifelse, e.g.
 
 transform(X, b = ifelse(is.na(b)  c == 0, 2011-07-28, b))
 
 transform(X, b = ifelse(c == 1, d, c))
 
 

 transform(X, b = ifelse(is.na(b)  c == 0, 2011-07-28, b))

This code results as follows. Data at [1,b] and [9,b] not managed as Date.
   a  b  c  d
1  58009  14915 0   NA
2 114761   NA 1 2008-11-05
3 184440   NA 1 2009-12-08
4 189372 2011-07-28 0   NA
5 105286 2011-07-28 0   NA
6 186717 2011-07-28 0   NA
7 189106 2011-07-28 0   NA
8 127306 2011-07-28 0   NA
9 157342  15089 0   NA


And the second code

 transform(X, b = ifelse(c == 1, d, c))

results as follows. Data at [,b] are completly lost.

   a b c  d
1  58009 1 0   NA
2 114761 14188 1 2008-11-05
3 184440 14586 1 2009-12-08
4 189372 1 0   NA
5 105286 1 0   NA
6 186717 1 0   NA
7 189106 1 0   NA
8 127306 1 0   NA
9 157342 1 0   NA

I think this solution not proper for me.

--
View this message in context: 
http://r.789695.n4.nabble.com/conditional-data-replace-recode-change-or-whatsoever-tp3714715p3715525.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] conditional data replace (recode, change or whatsoever)

2011-08-03 Thread zcatav

David Winsemius wrote:
 
 On Aug 3, 2011, at 8:09 AM, zcatav wrote:
 
 You need to apply the same logical test/selection on the rows of the  
 RHS as you are doing on the LHS.
 Possibly:
 
 X[ X[,c]==1, b] - X[ X[,c]==1, d]
 
 

This solution was suggested by R. Michael Weylandt and it works great.


--
View this message in context: 
http://r.789695.n4.nabble.com/conditional-data-replace-recode-change-or-whatsoever-tp3714715p3715544.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] Memory limit in Aggregate()

2011-08-03 Thread Guillaume
Hi Peter,
Thanks for these information.
I used a column concatenating the listBy data to do this aggregation : (I
don't know if it's the best solution, but it seems to work).

aggregateMultiBy - function(x, by, FUN){
tableBy = data.frame(by)
tableBy$byKey = 
for(colBy in names(by))
tableBy$byKey = paste(tableBy$byKey, 
as.character(tableBy[,colBy]),)

tableOut - aggregate(  x = x
,   by = list(byKey = tableBy$byKey)
,   FUN = FUN)
tableOut - merge(  x = tableOut
,   y = tableBy
,   by = byKey)

tableOut$byKey - NULL
return(tableOut)
}

Thanks again,
Guillaume

--
View this message in context: 
http://r.789695.n4.nabble.com/Memory-limit-in-Aggregate-tp3711819p3715633.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] lme4 help pls!

2011-08-03 Thread xy
Hi,
I have some difficulties to work with the function lmer from lme4. My
responses are binary form  and i want to use forward selection to my 12
covariates but i dont know how can I choose them based on deviance. Can
someone pls give me a example so i can apply. For example my covariates are
gestation,smoking ...and my response baby

b1=lmer(baby~ (1|id), data, binomial)

Thanks.

--
View this message in context: 
http://r.789695.n4.nabble.com/lme4-help-pls-tp3715628p3715628.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] Rattle loading String to Vector file from WEKA

2011-08-03 Thread NightWolf
Hi all,

I have been using WEKA to do some text classification work and I want to try
out R. 

The problem is I cannot load the String to Vector ARFF files created by
WEKA's string parser into Rattle . 
Looking at the logs I get something like:

/Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, 
:
   scan() expected 'a real', got '2281}'/


*My ARFF data file looks a bit like this:*

/@relation 'reviewData'

@attribute polarity {0,2}
.
@attribute $$ numeric
@attribute we numeric
@attribute wer numeric
@attribute win numeric
@attribute work numeric

@data
{0 2,63 1,71 1,100 1,112 1,140 1,186 1,228 1}
{14 1,40 1,48 1,52 1,61 1,146 1}
{2 1,41 1,43 1,57 1,71 1,79 1,106 1,108 1,133 1,146 1,149 1,158 1,201 1}
{0 2,6 1,25 1,29 1,42 1,49 1,69 1,82 1,108 1,116 1,138 1,140 1,155 1}
/

Any ideas how I can convert this into an R readable format?

Cheers!

--
View this message in context: 
http://r.789695.n4.nabble.com/R-Rattle-loading-String-to-Vector-file-from-WEKA-tp3715641p3715641.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] How to map current Europe?

2011-08-03 Thread tn85
Hello All,

I was trying to generate a map of Europe with the following codes:
europe-map(database=world, fill=FALSE,
plot=TRUE,xlim=c(-25,70),ylim=c(35,71)) 

However, the world database is too old to have right European country
names. Could anyone help? 

Thanks,
Tianchan

--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-map-current-Europe-tp3715709p3715709.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] Combining multiple dependent variables for machine learning -- fortunes candidate?

2011-08-03 Thread Bert Gunter
I thought Sarah's reply was great and, alas, should probably be
templated for this list.
Not sure it fits as a fortunes package entry, but I thought it at
least worthy of consideration.

Cheers,
Bert

 ...
 I appreciate any suggestions for this problem.

Sarah Goslee replied:

 Suggestions? Yes. Read the posting guide and follow it. It isn't clear that
 this is even an R question, since you don't tell us anything about the
 packages or functions you are using, or about your data. There aren't
 any actual questions in your message, and your problem statement
 is exceedingly vague.



 Sarah

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


-- 
Men by nature long to get on to the ultimate truths, and will often
be impatient with elementary studies or fight shy of them. If it were
possible to reach the ultimate truths without the elementary studies
usually prefixed to them, these would not be preparatory studies but
superfluous diversions.

-- Maimonides (1135-1204)

Bert Gunter
Genentech Nonclinical Biostatistics

__
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] Running R in a sandbox

2011-08-03 Thread Gavin Simpson
On Wed, 2011-08-03 at 11:04 +0300, Antonio Rodriges wrote:
 Hello,
 
 The idea is to grant access of remote users to R running on Linux.
 Users must have ability to run their
 R scripts but avoid corrupting the operating system.
 
 How one can restrict/limit access of remote users to certain R
 functions? For example, dealing with IO (file system), graphical
 tools, etc.

We've been here before, IIRC. But I'm too lazy to check the archives -
that's your job ;-)

Try a search on http://finzi.psych.upenn.edu/search.html for relevant
terms and make sure you turn on the email lists and off the
functions/vignettes.

 Thank you.

G

-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,  [f] +44 (0)20 7679 0565
 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London  [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT. [w] http://www.freshwaters.org.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.


[R] How to calculate the number of time a given string can be displayed in the width of a grid viewport

2011-08-03 Thread Sébastien Bihorel
Dear R users,

I am trying to determine how many characters can be displayed within the
width of an open grid viewport. Unfortunately, the arithmetic operation that
seems obvious in this case is be permitted with unit objects (see example
below). Although it isa brut force way to get this number (using a while
loop where the string would be modified by appending the original string to
itseft until its width is bigger than the width of the viewport), this
solution seems a bit overworked. Any suggestion would be welcome.

Sebastien

require(grid)
dev.off()
dev.new()
nstr - ''
str - 'O'

nInWidth - floor(unit(1,'npc')/unit(1,'strwidth',str))  # Does not work

nInWidth - 0

convertWidth(unit(1,'strwidth',nstr),'npc')

while
(unclass(convertWidth(unit(1,'strwidth',paste(nstr,str,sep='')),'npc'))[1] -
1 =.Machine$double.eps){
  nInWidth - nInWidth +1
  nstr - paste(nstr,str,sep='')
}

nInWidth

grid.text(paste(rep(str,nInWidth),collapse=''),
  x = unit(0.5, npc), y = unit(0.5, npc),
  draw = TRUE)

[[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] slow computation of functions over large datasets

2011-08-03 Thread David Winsemius


On Aug 3, 2011, at 9:59 AM, ONKELINX, Thierry wrote:


Dear Caroline,

Here is a faster and more elegant solution.


n - 1
exampledata - data.frame(orderID = sample(floor(n / 5), n, replace  
= TRUE), itemPrice = rpois(n, 10))

library(plyr)
system.time({

+   ddply(exampledata, .(orderID), function(x){
+ 		data.frame(itemPrice = x$itemPrice, orderAmount = cumsum(x 
$itemPrice))

+   })
+ })
  user  system elapsed
  1.670.001.69

exampledata[1,orderAmount]-exampledata[1,itemPrice]
system.time(for (i in 2:length(exampledata[,1]))
+ {exampledata[i,orderAmount]- 
ifelse 
(exampledata 
[i 
,orderID 
]==exampledata[i-1,orderID],exampledata[i-1,orderAmount] 
+exampledata[i,itemPrice],exampledata[i,itemPrice])})

  user  system elapsed
 11.940.02   11.97


I tried running this method on the large dataset (2MM row) the OP  
offered, and needed to eventually interrupt it so I could get my  
console back:


 system.time({
+   ddply(exampledata2, .(orderID), function(x){
+  		data.frame(itemPrice = x$itemPrice, orderAmount = cumsum(x 
$itemPrice))

+   })
+  })

Timing stopped at: 808.473 1013.749 1816.125

The same task with ave() took 35 seconds.

--
david.



Best regards,

Thierry

-Oorspronkelijk bericht-
Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org 
]

Namens Caroline Faisst
Verzonden: woensdag 3 augustus 2011 15:26
Aan: r-help@r-project.org
Onderwerp: [R] slow computation of functions over large datasets

Hello there,


I'm computing the total value of an order from the price of the  
order items using
a for loop and the ifelse function. I do this on a large  
dataframe (close to
1m lines). The computation of this function is painfully slow: in  
1min only about

90 rows are calculated.


The computation time taken for a given number of rows increases  
with the size

of the dataset, see the example with my function below:


# small dataset: function performs well

exampledata-
data 
.frame 
(orderID=c(1,1,1,2,2,3,3,3,4),itemPrice=c(10,17,9,12,25,10,1,9,7))


exampledata[1,orderAmount]-exampledata[1,itemPrice]

system.time(for (i in 2:length(exampledata[,1]))
{exampledata[i,orderAmount]-
ifelse 
(exampledata[i,orderID]==exampledata[i-1,orderID],exampledata[i-
1,orderAmount] 
+exampledata[i,itemPrice],exampledata[i,itemPrice])})


# large dataset: the very same computational task takes much longer

exampledata2-
data 
.frame 
(orderID=c(1,1,1,2,2,3,3,3,4,5:200),itemPrice=c(10,17,9,12,25,1

0,1,9,7,25:220))

exampledata2[1,orderAmount]-exampledata2[1,itemPrice]

system.time(for (i in 2:9)
{exampledata2[i,orderAmount]-
ifelse(exampledata2[i,orderID]==exampledata2[i-
1,orderID],exampledata2[i-
1,orderAmount] 
+exampledata2[i,itemPrice],exampledata2[i,itemPrice])})


Does someone know a way to increase the speed?


Thank you very much!

Caroline


David Winsemius, MD
West Hartford, CT

__
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] conditional data replace (recode, change or whatsoever)

2011-08-03 Thread Justin
zcatav zcatav at gmail.com writes:

 
 Your suggestion works perfect as i pointed previous message. Now have another
 question about data editing. I try this code:
 X[X[,c]==1,b]-X[,d]
 and results with error: `[-.data.frame`(`*tmp*`, X[, c] == 1, b, value
 = c(NA,  : 
   replacement has 9 rows, data has 2
 

is this equivalent and/or preferred to:

X$b[X$c==1]-X$d[X$c==1] ??

I assume this goes back to the various indexing methods for a dataframe, an
object vector that is a column of a data frame vs. an object data frame that
happens to be one column of a larger data frame.

on a very large data set is one preferable for speed?  one for memory use?

I tend to index using $ operators often and if I should quit let me know!!


Thanks,

Justin

 Logically i selected 2 rows with X[,c]==1. Than i want to replace in that
 rows its own data from d to b with X[,b]-X[,d]. What is wrong?
 
 --
 View this message in context:
http://r.789695.n4.nabble.com/conditional-data-replace-recode-change-or-whatsoever-tp3714715p3715218.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] 3D Bar Graphs in ggplot2?

2011-08-03 Thread Brian Diggs

On 8/3/2011 6:07 AM, wwreith wrote:

So I take it 3D pie charts are out?


At least with ggplot, yes.  2D pie charts are somewhat tricky with 
ggplot, even.  They can be gone with stacked, normalized bar charts 
projected into polar coordinates, if I recall properly.


Not limited to ggplot, there is pie() in the graphics package, and 
pie3D() in the plotrix package.


I couldn't find anything that would do bar plots with a 3D effect; the 
closest was the scatterplot3d package, but that is more a way to do a 
two dimensional array of bars, rather than a 3D effect.



P.S. It is not about hiding anything. It is about consulting and being told
by your client to make 3D pie charts and change this font or that color to
make the graphs more apealing. Given that I am the one trying to open the
door to using R where I work it would be much easier if I could simply use a
2D graph.


External requirements can make us make choices we otherwise might not 
have.  If the client is amenable to education, you could slowly try to 
persuade (say, using side-by-side examples), but some are not.  Good luck.



--
View this message in context: 
http://r.789695.n4.nabble.com/3D-Bar-Graphs-in-ggplot2-tp3713305p3715382.html
Sent from the R help mailing list archive at Nabble.com.




--
Brian S. Diggs, PhD
Senior Research Associate, Department of Surgery
Oregon Health  Science University

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


[R] How to calculate the number of times a given string can be displayed in the width of a grid viewport

2011-08-03 Thread Sébastien Bihorel
There was too many spelling mistakes in my original post so I have
decided to re-submit it. So here is it

Dear R users,

I am trying to determine how many characters can be displayed within
the width of an open grid viewport. Unfortunately, the arithmetic
operation that seems obvious in this case is not permitted with unit
objects (see example below). Although there is a brute force way to
get this number (using a while loop where the string would be modified
by appending the original string to itseft until its width is larger
than the width of the viewport), this solution seems a bit overworked.
Any suggestion would be welcome.

Sebastien

require(grid)
dev.off()
dev.new()
nstr - ''
str - 'O'

nInWidth - floor(unit(1,'npc')/unit(1,'strwidth',str))  # Does not work

nInWidth - 0

convertWidth(unit(1,'strwidth',nstr),'npc')

while
(unclass(convertWidth(unit(1,'strwidth',paste(nstr,str,sep='')),'npc'))[1]
- 1 =.Machine$double.eps){
  nInWidth - nInWidth +1
  nstr - paste(nstr,str,sep='')
}

nInWidth

grid.text(paste(rep(str,nInWidth),collapse=''),
  x = unit(0.5, npc), y = unit(0.5, npc),
  draw = TRUE)

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


Re: [R] Error Installing or Updating Packages (Maybe because of a proxy)

2011-08-03 Thread Uwe Ligges

1. you wrote to the mailing list rather than to the original poster.
2. you forgot to cite the original post, hence  we do not know what you 
are referring to.


PLease do read the posting guide to this list!

Uwe Ligges


On 03.08.2011 14:53, mohammad...@gmail.com wrote:

Hello David,
I encountered the same problem of yours.
What did you do to resolve it?
Thanks for your reply
Mohammad

--
View this message in context: 
http://r.789695.n4.nabble.com/Error-Installing-or-Updating-Packages-Maybe-because-of-a-proxy-tp3462312p3715332.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] Extract p value from coxme object

2011-08-03 Thread Terry Therneau
 You can look at the code
coxme:::print.coxme

There you will see that the global test is a chisquare
   chi1 - 2*diff(x$loglik[1:2]) 
with x$df[1] degrees of freedom.

 The fixed effects coefficients are found in x$coefficients$fixed, and
the variances are diag(x$var)[-(1:nfrail)].  (The variances for the
random coefficients are first, and then those for the fixed effects).
If there are 5 fixed coefficients, their variance/covariance matrix is
the lower right 5x5 corner of x$var.

Terry Therneau

__
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] slow computation of functions over large datasets

2011-08-03 Thread jim holtman
This takes about 2 secs for 1M rows:

 n - 100
 exampledata - data.frame(orderID = sample(floor(n / 5), n, replace = TRUE), 
 itemPrice = rpois(n, 10))
 require(data.table)
 # convert to data.table
 ed.dt - data.table(exampledata)
 system.time(result - ed.dt[
+ , list(total = sum(itemPrice))
+ , by = orderID
+ ]
+)
   user  system elapsed
   1.300.051.34

 str(result)
Classes ‘data.table’ and 'data.frame':  198708 obs. of  2 variables:
 $ orderID: int  1 2 3 4 5 6 8 9 10 11 ...
 $ total  : num  49 37 72 92 50 76 34 22 65 39 ...
 head(result)
 orderID total
[1,]   149
[2,]   237
[3,]   372
[4,]   492
[5,]   550
[6,]   676



On Wed, Aug 3, 2011 at 9:25 AM, Caroline Faisst
caroline.fai...@gmail.com wrote:
 Hello there,


 I’m computing the total value of an order from the price of the order items
 using a “for” loop and the “ifelse” function. I do this on a large dataframe
 (close to 1m lines). The computation of this function is painfully slow: in
 1min only about 90 rows are calculated.


 The computation time taken for a given number of rows increases with the
 size of the dataset, see the example with my function below:


 # small dataset: function performs well

 exampledata-data.frame(orderID=c(1,1,1,2,2,3,3,3,4),itemPrice=c(10,17,9,12,25,10,1,9,7))

 exampledata[1,orderAmount]-exampledata[1,itemPrice]

 system.time(for (i in 2:length(exampledata[,1]))
 {exampledata[i,orderAmount]-ifelse(exampledata[i,orderID]==exampledata[i-1,orderID],exampledata[i-1,orderAmount]+exampledata[i,itemPrice],exampledata[i,itemPrice])})


 # large dataset: the very same computational task takes much longer

 exampledata2-data.frame(orderID=c(1,1,1,2,2,3,3,3,4,5:200),itemPrice=c(10,17,9,12,25,10,1,9,7,25:220))

 exampledata2[1,orderAmount]-exampledata2[1,itemPrice]

 system.time(for (i in 2:9)
 {exampledata2[i,orderAmount]-ifelse(exampledata2[i,orderID]==exampledata2[i-1,orderID],exampledata2[i-1,orderAmount]+exampledata2[i,itemPrice],exampledata2[i,itemPrice])})



 Does someone know a way to increase the speed?


 Thank you very much!

 Caroline

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





-- 
Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?

__
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] strsplit and forward slash '/'

2011-08-03 Thread Federico Calboli
Hi All,

is there a way of using strsplit with a forward slash '/' as the splitting 
point?

For data such as:

1  T/TC/C  16/33
2  T/TC/C  33/36
3  T/TC/C  16/34
4  T/TC/C  16/31
5  C/CC/C  28/29
6  T/TC/C  16/34

strsplit(my.data[1,1], /) # and any variation thereof 
Error in strsplit(apoe[1, 1], /) : non-character argument

Any advice will be gratefully received.

Best wishes,

Federico


--
Federico C. F. Calboli
Department of Epidemiology and Biostatistics
Imperial College, St. Mary's Campus
Norfolk Place, London W2 1PG

Tel +44 (0)20 75941602   Fax +44 (0)20 75943193

f.calboli [.a.t] imperial.ac.uk
f.calboli [.a.t] 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.


[R] gstat error

2011-08-03 Thread gbrenes
Hello.

I am running the examples provided in the gstat help menus.  When I try to
run the following in predict.gstat:

data(meuse)
coordinates(meuse)= ~x+y
v-variogram(log(zinc)~1, meuse)

I get the following error message:

Error in vector(double, length) : invalid 'length' argument


What's the problem?


Gilbert

__
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] strsplit and forward slash '/'

2011-08-03 Thread Duncan Murdoch

On 03/08/2011 12:37 PM, Federico Calboli wrote:

Hi All,

is there a way of using strsplit with a forward slash '/' as the splitting 
point?

For data such as:

1  T/TC/C  16/33
2  T/TC/C  33/36
3  T/TC/C  16/34
4  T/TC/C  16/31
5  C/CC/C  28/29
6  T/TC/C  16/34

strsplit(my.data[1,1], /) # and any variation thereof
Error in strsplit(apoe[1, 1], /) : non-character argument


It looks as though your my.data[1,1] value is a factor, not a character 
value.


strsplit(as.character(my.data[1,1]), /)

would work, or you could avoid getting factors in the first place, using the 
stringsAsFactors argument when you create the dataframe.

Duncan Murdoch



Any advice will be gratefully received.

Best wishes,

Federico


--
Federico C. F. Calboli
Department of Epidemiology and Biostatistics
Imperial College, St. Mary's Campus
Norfolk Place, London W2 1PG

Tel +44 (0)20 75941602   Fax +44 (0)20 75943193

f.calboli [.a.t] imperial.ac.uk
f.calboli [.a.t] 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.


__
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] strsplit and forward slash '/'

2011-08-03 Thread Sarah Goslee
Hi Federico,

A forward slash isn't a special character:

 strsplit(T/T, /)
[[1]]
[1] T T

so there's some other problem.

Are you sure that your first column contains strings and not factors?
What does str(my.data) tell you?

Does
strsplit(as.character(my.data[1,1]), /)
work?

If you used read.table() to get your data in, you might want the
as.is=TRUE or the stringsAsFactors=FALSE argument.

Sarah

On Wed, Aug 3, 2011 at 12:37 PM, Federico Calboli
f.calb...@imperial.ac.uk wrote:
 Hi All,

 is there a way of using strsplit with a forward slash '/' as the splitting 
 point?

 For data such as:

 1      T/T    C/C  16/33
 2      T/T    C/C  33/36
 3      T/T    C/C  16/34
 4      T/T    C/C  16/31
 5      C/C    C/C  28/29
 6      T/T    C/C  16/34

 strsplit(my.data[1,1], /) # and any variation thereof
 Error in strsplit(apoe[1, 1], /) : non-character argument

 Any advice will be gratefully received.

 Best wishes,

 Federico




-- 
Sarah Goslee
http://www.sarahgoslee.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] strsplit and forward slash '/'

2011-08-03 Thread Federico Calboli
On 3 Aug 2011, at 17:41, Duncan Murdoch wrote:

 
 It looks as though your my.data[1,1] value is a factor, not a character value.
 
 strsplit(as.character(my.data[1,1]), /)

Thanks Duncan, this solved it.

Best 

Federico


 
 would work, or you could avoid getting factors in the first place, using the 
 stringsAsFactors argument when you create the dataframe.
 
 Duncan Murdoch
 
 
 Any advice will be gratefully received.
 
 Best wishes,
 
 Federico
 
 
 --
 Federico C. F. Calboli
 Department of Epidemiology and Biostatistics
 Imperial College, St. Mary's Campus
 Norfolk Place, London W2 1PG
 
 Tel +44 (0)20 75941602   Fax +44 (0)20 75943193
 
 f.calboli [.a.t] imperial.ac.uk
 f.calboli [.a.t] 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.
 

--
Federico C. F. Calboli
Department of Epidemiology and Biostatistics
Imperial College, St. Mary's Campus
Norfolk Place, London W2 1PG

Tel +44 (0)20 75941602   Fax +44 (0)20 75943193

f.calboli [.a.t] imperial.ac.uk
f.calboli [.a.t] 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] strsplit and forward slash '/'

2011-08-03 Thread Federico Calboli

On 3 Aug 2011, at 17:46, Sarah Goslee wrote:

 Hi Federico,
 
 A forward slash isn't a special character:
 
 strsplit(T/T, /)
 [[1]]
 [1] T T
 
 so there's some other problem.
 
 Are you sure that your first column contains strings and not factors?
 What does str(my.data) tell you?
 
 Does
 strsplit(as.character(my.data[1,1]), /)
 work?

yes!

Thanks

Federico


 
 If you used read.table() to get your data in, you might want the
 as.is=TRUE or the stringsAsFactors=FALSE argument.
 
 Sarah
 
 On Wed, Aug 3, 2011 at 12:37 PM, Federico Calboli
 f.calb...@imperial.ac.uk wrote:
 Hi All,
 
 is there a way of using strsplit with a forward slash '/' as the splitting 
 point?
 
 For data such as:
 
 1  T/TC/C  16/33
 2  T/TC/C  33/36
 3  T/TC/C  16/34
 4  T/TC/C  16/31
 5  C/CC/C  28/29
 6  T/TC/C  16/34
 
 strsplit(my.data[1,1], /) # and any variation thereof
 Error in strsplit(apoe[1, 1], /) : non-character argument
 
 Any advice will be gratefully received.
 
 Best wishes,
 
 Federico
 
 
 
 
 -- 
 Sarah Goslee
 http://www.sarahgoslee.com

--
Federico C. F. Calboli
Department of Epidemiology and Biostatistics
Imperial College, St. Mary's Campus
Norfolk Place, London W2 1PG

Tel +44 (0)20 75941602   Fax +44 (0)20 75943193

f.calboli [.a.t] imperial.ac.uk
f.calboli [.a.t] 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 CMD check problem

2011-08-03 Thread Duncan Murdoch

On 03/08/2011 12:47 PM, Baidya Nath Mandal wrote:

Dear Murdoch,

After setting CYGWIN=nodosfilewarning, i re-ran the R CMD check and got
following message:

* installing *source* package 'mypackage' ...
** libs
ERROR: compilation failed for package 'mypackage'
* removing 'C:/Rpackages/mypackage.Rcheck/mypackage'

The log file contained following.
* using log directory 'C:/Rpackages/mypackage.Rcheck'
* using R version 2.13.0 (2011-04-13)
* using platform: i386-pc-mingw32 (32-bit)
* using session charset: ISO8859-1
* checking for file 'mypackage/DESCRIPTION' ... OK
* this is package 'mypackage' version '1.1'
* checking package name space information ... OK
* checking package dependencies ... OK
* checking if this is a source package ... OK
* checking for executable files ... OK
* checking whether package 'mypackage' can be installed ... ERROR
Installation failed.
See 'C:/Rpackages/mypackage.Rcheck/00install.out' for details.

The src directory contains nothing since all my codes are in R and are in
the R directory. I have checked that the code works fine in R console. My
DESCRIPTION file is like this:
Package: mypackage
Version: 1.1
Date: 2011-07-14
Title: abcd
Author: B N Mandalmandal.s...@gmail.com
Maintainer: B N Mandalmandal.s...@gmail.com
Depends: R(= 2.13.0)
Description: xyz
License: GPL (=2)

and NAMESPACE file contains
export(fun1)

I have checked Rd files are fine.

Can you suggest what may be wrong now?


You should delete your src directory if you don't need it.

Duncan Murdoch

regards,
BN Mandal

On Tue, Aug 2, 2011 at 4:17 PM, Duncan Murdochmurdoch.dun...@gmail.comwrote:

  On 11-08-02 5:26 AM, Baidya Nath Mandal wrote:

  Dear friends,

  I am building an R package called *mypackage*. I followed every possible
  steps (to my understanding) for the same. I got following problem while
  doing *R CMD check mypackage*.

  * installing *source* package 'mypackage' ...
  ** libs
  cygwin warning:
MS-DOS style path detected: C:/PROGRA~1/R/R-213~1.0/etc/**i386/Makeconf
Preferred POSIX equivalent is:
  /cygdrive/c/PROGRA~1/R/R-213~**1.0/etc/i386/Makeconf
CYGWIN environment variable option nodosfilewarning turns off this
  warning.
Consult the user's guide for more details about POSIX paths:
  
http://cygwin.com/cygwin-ug-**net/using.html#using-pathnameshttp://cygwin.com/cygwin-ug-net/using.html#using-pathnames


  I believe that warning is ignorable, but you can turn it off using

  set CYGWIN=nodosfilewarning

  It probably didn't cause the error below.


   ERROR: compilation failed for package 'mypackage'


  I don't know what did cause that error, but it's likely something in your
  src directory of the package.  What do you have there?

  Duncan Murdoch

   * removing 'C:/Rpackages/mypackage.**Rcheck/mypackage'.

  What I understood from above is that it is something with PATH variable. I
  had set the following PATH variable:
  C:\Rtools\bin;C:\Rtools\MinGW\**bin;C:\Program
  Files\R\R-2.13.0\bin;C:\**Program Files\MiKTeX
  2.9\miktex\bin;%SystemRoot%\**system32;%SystemRoot%;%**
  SystemRoot%\System32\Wbem;%**SYSTEMROOT%\System32\**
  WindowsPowerShell\v1.0\;C:\**Program
  Files\HTML Help Workshop


  Can anybody suggest what possibly could have gone wrong?

  Thanks,
  BN Mandal

 [[alternative HTML version deleted]]

  __**
  R-help@r-project.org mailing list
  
https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide http://www.R-project.org/**
  posting-guide.htmlhttp://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] slow computation of functions over large datasets

2011-08-03 Thread David Winsemius


On Aug 3, 2011, at 12:20 PM, jim holtman wrote:


This takes about 2 secs for 1M rows:


n - 100
exampledata - data.frame(orderID = sample(floor(n / 5), n, replace  
= TRUE), itemPrice = rpois(n, 10))

require(data.table)
# convert to data.table
ed.dt - data.table(exampledata)
system.time(result - ed.dt[

+ , list(total = sum(itemPrice))
+ , by = orderID
+ ]
+)
  user  system elapsed
  1.300.051.34


Interesting. Impressive. And I noted that the OP wanted what cumsum  
would provide and for some reason creating that longer result is even  
faster on my machine than the shorter result using sum.


--
David.


str(result)

Classes ‘data.table’ and 'data.frame':  198708 obs. of  2 variables:
$ orderID: int  1 2 3 4 5 6 8 9 10 11 ...
$ total  : num  49 37 72 92 50 76 34 22 65 39 ...

head(result)

orderID total
[1,]   149
[2,]   237
[3,]   372
[4,]   492
[5,]   550
[6,]   676





On Wed, Aug 3, 2011 at 9:25 AM, Caroline Faisst
caroline.fai...@gmail.com wrote:

Hello there,


I’m computing the total value of an order from the price of the  
order items
using a “for” loop and the “ifelse” function. I do this on a large  
dataframe
(close to 1m lines). The computation of this function is painfully  
slow: in

1min only about 90 rows are calculated.


The computation time taken for a given number of rows increases  
with the

size of the dataset, see the example with my function below:


# small dataset: function performs well

exampledata- 
data 
.frame 
(orderID=c(1,1,1,2,2,3,3,3,4),itemPrice=c(10,17,9,12,25,10,1,9,7))


exampledata[1,orderAmount]-exampledata[1,itemPrice]

system.time(for (i in 2:length(exampledata[,1]))
{exampledata[i,orderAmount]- 
ifelse 
(exampledata 
[i 
,orderID 
]==exampledata[i-1,orderID],exampledata[i-1,orderAmount] 
+exampledata[i,itemPrice],exampledata[i,itemPrice])})



# large dataset: the very same computational task takes much longer

exampledata2- 
data 
.frame 
(orderID 
= 
c 
(1,1,1,2,2,3,3,3,4,5 
:200),itemPrice=c(10,17,9,12,25,10,1,9,7,25:220))


exampledata2[1,orderAmount]-exampledata2[1,itemPrice]

system.time(for (i in 2:9)
{exampledata2[i,orderAmount]- 
ifelse 
(exampledata2 
[i 
,orderID 
]==exampledata2[i-1,orderID],exampledata2[i-1,orderAmount] 
+exampledata2[i,itemPrice],exampledata2[i,itemPrice])})




Does someone know a way to increase the speed?


Thank you very much!

Caroline

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






--
Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?

__
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, MD
West Hartford, CT

__
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] gstat error

2011-08-03 Thread Peter Ehlers

On 2011-08-03 09:40, gbre...@ssc.wisc.edu wrote:

Hello.

I am running the examples provided in the gstat help menus.  When I try to
run the following in predict.gstat:

data(meuse)
coordinates(meuse)= ~x+y
v-variogram(log(zinc)~1, meuse)

I get the following error message:

Error in vector(double, length) : invalid 'length' argument


What's the problem?


You should at the very least provide your sessionInfo().

Peter Ehlers




Gilbert

__
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] Coefficient names when using lm() with contrasts

2011-08-03 Thread Greg Snow
If you add column names to your contrast matrix (treat3) then those names will 
be used in the coefficient names.

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
 project.org] On Behalf Of Peter Morgan
 Sent: Wednesday, August 03, 2011 6:12 AM
 To: r-help@r-project.org
 Subject: [R] Coefficient names when using lm() with contrasts
 
 Dear R Users,
 
 Am using lm() with contrasts as below. If I skip the contrasts()
 statement, I get the coefficient names to be
  names(results$coef)
 [1] (Intercept) VarAcat VarArat VarB
 
 which are much more meaningful than ones based on integers.
 
 Can anyone tell me how to get R to keep the coefficient names based on
 the
 factor levels whilst using contrasts rather than labelling them with
 integers?
 
 Many thanks in advance,
 
 Pete
 
 Cardiff, UK
 
  dt=read.table(testreg.txt,sep=,,header=T)
  dt
ID VarA VarB VarC
 1   1  cat2   23
 2   2  dog3   56
 3   3  rat5   35
 4   4  cat2   43
 5   5  cat7   51
 6   6  dog3   31
 7   7  dog4   65
 8   8  rat1   18
 9   9  rat6   49
 10 10  dog3   28
  dt$VarA=relevel(dt$VarA,ref=dog)
  treat3=matrix(-1/3,ncol=2,nrow=3); for (i in 1:2) {treat3[i+1,i]=2/3}
  contrasts(dt$VarA)=treat3
  levels(dt$VarA)
 [1] dog cat rat
  results=lm(formula=VarC~VarA+VarB, data=dt)
  names(results$coef)
 [1] (Intercept) VarA1   VarA2   VarB
   [[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] slow computation of functions over large datasets

2011-08-03 Thread David Winsemius


On Aug 3, 2011, at 2:01 PM, Ken wrote:


Hello,
 Perhaps transpose the table attach(as.data.frame(t(data))) and use  
ColSums() function with order id as header.

-Ken Hutchison


 Got any code? The OP offered a reproducible example, after all.

--
David.


On Aug 3, 2554 BE, at 1:12 PM, David Winsemius  
dwinsem...@comcast.net wrote:




On Aug 3, 2011, at 12:20 PM, jim holtman wrote:


This takes about 2 secs for 1M rows:


n - 100
exampledata - data.frame(orderID = sample(floor(n / 5), n,  
replace = TRUE), itemPrice = rpois(n, 10))

require(data.table)
# convert to data.table
ed.dt - data.table(exampledata)
system.time(result - ed.dt[

+ , list(total = sum(itemPrice))
+ , by = orderID
+ ]
+)
user  system elapsed
1.300.051.34


Interesting. Impressive. And I noted that the OP wanted what cumsum  
would provide and for some reason creating that longer result is  
even faster on my machine than the shorter result using sum.


--
David.


str(result)

Classes ‘data.table’ and 'data.frame':  198708 obs. of  2 variables:
$ orderID: int  1 2 3 4 5 6 8 9 10 11 ...
$ total  : num  49 37 72 92 50 76 34 22 65 39 ...

head(result)

  orderID total
[1,]   149
[2,]   237
[3,]   372
[4,]   492
[5,]   550
[6,]   676





On Wed, Aug 3, 2011 at 9:25 AM, Caroline Faisst
caroline.fai...@gmail.com wrote:

Hello there,


I’m computing the total value of an order from the price of the  
order items
using a “for” loop and the “ifelse” function. I do this on a  
large dataframe
(close to 1m lines). The computation of this function is  
painfully slow: in

1min only about 90 rows are calculated.


The computation time taken for a given number of rows increases  
with the

size of the dataset, see the example with my function below:


# small dataset: function performs well

exampledata- 
data 
.frame 
(orderID=c(1,1,1,2,2,3,3,3,4),itemPrice=c(10,17,9,12,25,10,1,9,7))


exampledata[1,orderAmount]-exampledata[1,itemPrice]

system.time(for (i in 2:length(exampledata[,1]))
{exampledata[i,orderAmount]- 
ifelse 
(exampledata 
[i 
,orderID 
]==exampledata[i-1,orderID],exampledata[i-1,orderAmount] 
+exampledata[i,itemPrice],exampledata[i,itemPrice])})



# large dataset: the very same computational task takes much longer

exampledata2- 
data 
.frame 
(orderID 
= 
c 
(1,1,1,2,2,3,3,3,4,5 
:200),itemPrice=c(10,17,9,12,25,10,1,9,7,25:220))


exampledata2[1,orderAmount]-exampledata2[1,itemPrice]

system.time(for (i in 2:9)
{exampledata2[i,orderAmount]- 
ifelse 
(exampledata2 
[i 
,orderID 
]==exampledata2[i-1,orderID],exampledata2[i-1,orderAmount] 
+exampledata2[i,itemPrice],exampledata2[i,itemPrice])})




Does someone know a way to increase the speed?


Thank you very much!

Caroline

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






--
Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?

__
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, MD
West Hartford, CT

__
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, MD
West Hartford, CT

__
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] gstat error

2011-08-03 Thread gbrenes
Here is my sessionInfo()

 sessionInfo()
R version 2.12.2 (2011-02-25)
Platform: i386-pc-mingw32/i386 (32-bit)

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United
States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

attached base packages:
[1] splines   grid  stats graphics  grDevices utils datasets 
methods
[9] base

other attached packages:
 [1] spsurvey_2.1-2  lmtest_0.9-27   zoo_1.6-5
 [4] car_2.0-9   survival_2.36-5 nnet_7.3-1
 [7] spgwr_0.6-10spatialCovariance_0.6-4 spatial_7.3-2
[10] spatgraphs_2.44 sgeostat_1.0-23 rworldmap_0.1211
[13] fields_6.3  spam_0.23-0 RPyGeo_0.9-2
[16] RSAGA_0.91-1shapefiles_0.6  RgoogleMaps_1.1.9.7
[19] raster_1.8-22   RArcInfo_0.4-10 RColorBrewer_1.0-2
[22] PBSmodelling_2.61.210   PBSmapping_2.61.9   mapproj_1.1-8.3
[25] mapdata_2.1-4   intamap_1.3-8   evd_2.2-4
[28] mvtnorm_0.9-96  automap_1.0-9   rgdal_0.6-33
[31] gmaps_0.2   maps_2.1-6  glmmBUGS_1.9
[34] spdep_0.5-32coda_0.14-2 deldir_0.0-13
[37] maptools_0.8-7  foreign_0.8-42  Matrix_0.999375-46
[40] lattice_0.19-17 boot_1.2-43 abind_1.3-0
[43] MASS_7.3-11 geosphere_1.2-19geonames_0.8
[46] rjson_0.2.3 ctv_0.7-2   GEOmap_1.5-13
[49] akima_0.5-4 RPMG_2.0-5  splancs_2.01-27
[52] geomapdata_1.0-4geoRglm_0.8-33  geoR_1.6-34
[55] gstat_0.9-81sp_0.9-81   nlme_3.1-98

loaded via a namespace (and not attached):
[1] tcltk_2.12.2 tools_2.12.2



 On 2011-08-03 09:40, gbre...@ssc.wisc.edu wrote:
 Hello.

 I am running the examples provided in the gstat help menus.  When I try
 to
 run the following in predict.gstat:

 data(meuse)
 coordinates(meuse)= ~x+y
 v-variogram(log(zinc)~1, meuse)

 I get the following error message:

 Error in vector(double, length) : invalid 'length' argument


 What's the problem?

 You should at the very least provide your sessionInfo().

 Peter Ehlers



 Gilbert

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


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


[R] Convert matrix to numeric

2011-08-03 Thread Jeffrey Joh

I have a matrix that looks like this:


structure(c(0.0376673981759913, 0.111066500741386, 1, 1103, 
18, OPEN, DEPR, 0.0404073656092023, 0.115186044704599, 
1, 719, 18, OPEN, DEPR, 0.0665342096693433, 0.197570061769498, 
1, 1103, 18, OPEN, DEPR, 0.119287147905722, 0.356427096010845, 
1, 1103, 18, OPEN, DEPR), .Dim = c(7L, 4L), .Dimnames = list(
c(Sn, SlnC, housenum, date, hour, flue, pressurization
), c(10019.BLO, 1002.BLO, 10020.BLO, 10021.BLO)))

 

How do I convert rows 1-5 to numeric?  I tried mode() - numeric but that 
doesn't change anything.

 

I also tried converting this to a table then converting to numeric, but I got: 
(list) object cannot be coerced to type 'double'

 

Jeff  
__
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] limits on liniar model

2011-08-03 Thread ראובן אברמוביץ

   Can I put limits on the lm() command? I only know that you can choose a
   liniar model with or without an intercept, but can I put other limits on
   the coefficients (for example- the intercept must be bigger than 1) ?

 _

   Walla! Mail - [1]Get your free unlimited mail today

References

   1. http://www.walla.co.il/
__
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] Case-by-case tolerance needed for successful integrate()

2011-08-03 Thread Delphine Pessoa
Hello,

We are trying to use R to simulate a model based on parameters 'a' and 'b'.
This involves the following integration:

model-function(s,x,a,b)(exp(-s*x*10^-5.5)*(s^(a-1)*(1-s)^(b-1)))
g- function(x,a,b){
 out-c()
 for (i in 1:length(x)){
   out[i]-1- (integrate(model,0,1,x[i],a,b)$value / beta(a,b))
 }
 out
 }
x- 10^seq(0,10,by=0.01)
y- g(x,a=0.8,b=0.5)

This gives the error

Error in integrate(model, 0, 1, x[i], a, b) :   the integral is
probably divergent


Changing the relative or absolute tolerance solves this issue, but a certain
tolerance only works with a certain set of 'a' and 'b'.
For example, and abs.tol=10^-9 will make it work with a=0.8 and b=0.5 but
fail with a=0.3 and b=0.9.
We need this code to work for any reasonable value of 'a' and 'b' - as
seen by the shape of the distribution Beta(a,b).

We have tried using a different number of subdivisions without any luck.
The same integration in MATLAB works without any problem (using quad).

Anyone has an idea of why these problems occur and how to avoid them?

Many thanks.

[[alternative HTML version deleted]]

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


Re: [R] R CMD check problem

2011-08-03 Thread Baidya Nath Mandal
Dear Murdoch,

After setting CYGWIN=nodosfilewarning, i re-ran the R CMD check and got
following message:

* installing *source* package 'mypackage' ...
** libs
ERROR: compilation failed for package 'mypackage'
* removing 'C:/Rpackages/mypackage.Rcheck/mypackage'

The log file contained following.
* using log directory 'C:/Rpackages/mypackage.Rcheck'
* using R version 2.13.0 (2011-04-13)
* using platform: i386-pc-mingw32 (32-bit)
* using session charset: ISO8859-1
* checking for file 'mypackage/DESCRIPTION' ... OK
* this is package 'mypackage' version '1.1'
* checking package name space information ... OK
* checking package dependencies ... OK
* checking if this is a source package ... OK
* checking for executable files ... OK
* checking whether package 'mypackage' can be installed ... ERROR
Installation failed.
See 'C:/Rpackages/mypackage.Rcheck/00install.out' for details.

The src directory contains nothing since all my codes are in R and are in
the R directory. I have checked that the code works fine in R console. My
DESCRIPTION file is like this:
Package: mypackage
Version: 1.1
Date: 2011-07-14
Title: abcd
Author: B N Mandal mandal.s...@gmail.com
Maintainer: B N Mandal mandal.s...@gmail.com
Depends: R(= 2.13.0)
Description: xyz
License: GPL (=2)

and NAMESPACE file contains
export(fun1)

I have checked Rd files are fine.

Can you suggest what may be wrong now?

regards,
BN Mandal

On Tue, Aug 2, 2011 at 4:17 PM, Duncan Murdoch murdoch.dun...@gmail.comwrote:

 On 11-08-02 5:26 AM, Baidya Nath Mandal wrote:

 Dear friends,

 I am building an R package called *mypackage*. I followed every possible
 steps (to my understanding) for the same. I got following problem while
 doing *R CMD check mypackage*.

 * installing *source* package 'mypackage' ...
 ** libs
 cygwin warning:
   MS-DOS style path detected: C:/PROGRA~1/R/R-213~1.0/etc/**i386/Makeconf
   Preferred POSIX equivalent is:
 /cygdrive/c/PROGRA~1/R/R-213~**1.0/etc/i386/Makeconf
   CYGWIN environment variable option nodosfilewarning turns off this
 warning.
   Consult the user's guide for more details about POSIX paths:
 
 http://cygwin.com/cygwin-ug-**net/using.html#using-pathnameshttp://cygwin.com/cygwin-ug-net/using.html#using-pathnames


 I believe that warning is ignorable, but you can turn it off using

 set CYGWIN=nodosfilewarning

 It probably didn't cause the error below.


  ERROR: compilation failed for package 'mypackage'


 I don't know what did cause that error, but it's likely something in your
 src directory of the package.  What do you have there?

 Duncan Murdoch

  * removing 'C:/Rpackages/mypackage.**Rcheck/mypackage'.

 What I understood from above is that it is something with PATH variable. I
 had set the following PATH variable:
 C:\Rtools\bin;C:\Rtools\MinGW\**bin;C:\Program
 Files\R\R-2.13.0\bin;C:\**Program Files\MiKTeX
 2.9\miktex\bin;%SystemRoot%\**system32;%SystemRoot%;%**
 SystemRoot%\System32\Wbem;%**SYSTEMROOT%\System32\**
 WindowsPowerShell\v1.0\;C:\**Program
 Files\HTML Help Workshop


 Can anybody suggest what possibly could have gone wrong?

 Thanks,
 BN Mandal

[[alternative HTML version deleted]]

 __**
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/**
 posting-guide.html 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] r-help

2011-08-03 Thread KnifeBoot
  Hey,
Is there any function plotting several implicit functions (F(x,y)=0) on 
the same fig. Is there anyone who has an example code of how to do this?
The contour3d function in the misc3d package only work with the  functions 
with three dimensions.
Thanks a lot.
Many thanks for your help.
KnifeBoot
[[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] R CMD check problem

2011-08-03 Thread Baidya Nath Mandal
Many many thanks, working now.

Best,
BN Mandal

On Wed, Aug 3, 2011 at 10:34 PM, Duncan Murdoch murdoch.dun...@gmail.comwrote:

 On 03/08/2011 12:47 PM, Baidya Nath Mandal wrote:

 Dear Murdoch,

 After setting CYGWIN=nodosfilewarning, i re-ran the R CMD check and got
 following message:

 * installing *source* package 'mypackage' ...
 ** libs
 ERROR: compilation failed for package 'mypackage'
 * removing 'C:/Rpackages/mypackage.**Rcheck/mypackage'

 The log file contained following.
 * using log directory 'C:/Rpackages/mypackage.**Rcheck'
 * using R version 2.13.0 (2011-04-13)
 * using platform: i386-pc-mingw32 (32-bit)
 * using session charset: ISO8859-1
 * checking for file 'mypackage/DESCRIPTION' ... OK
 * this is package 'mypackage' version '1.1'
 * checking package name space information ... OK
 * checking package dependencies ... OK
 * checking if this is a source package ... OK
 * checking for executable files ... OK
 * checking whether package 'mypackage' can be installed ... ERROR
 Installation failed.
 See 'C:/Rpackages/mypackage.**Rcheck/00install.out' for details.

 The src directory contains nothing since all my codes are in R and are in
 the R directory. I have checked that the code works fine in R console. My
 DESCRIPTION file is like this:
 Package: mypackage
 Version: 1.1
 Date: 2011-07-14
 Title: abcd
 Author: B N Mandalmandal.s...@gmail.com
 Maintainer: B N Mandalmandal.s...@gmail.com
 Depends: R(= 2.13.0)
 Description: xyz
 License: GPL (=2)

 and NAMESPACE file contains
 export(fun1)

 I have checked Rd files are fine.

 Can you suggest what may be wrong now?


 You should delete your src directory if you don't need it.

 Duncan Murdoch

 regards,
 BN Mandal

 On Tue, Aug 2, 2011 at 4:17 PM, Duncan 
 Murdochmurdoch.duncan@gmail.**commurdoch.dun...@gmail.com
 wrote:

   On 11-08-02 5:26 AM, Baidya Nath Mandal wrote:
 
   Dear friends,
 
   I am building an R package called *mypackage*. I followed every
 possible
   steps (to my understanding) for the same. I got following problem
 while
   doing *R CMD check mypackage*.
 
   * installing *source* package 'mypackage' ...
   ** libs
   cygwin warning:
 MS-DOS style path detected: C:/PROGRA~1/R/R-213~1.0/etc/
 i386/Makeconf
 Preferred POSIX equivalent is:
   /cygdrive/c/PROGRA~1/R/R-213~1.0/etc/i386/Makeconf
 CYGWIN environment variable option nodosfilewarning turns off this
   warning.
 Consult the user's guide for more details about POSIX paths:
   
  http://cygwin.com/cygwin-ug-net/using.html#using-pathnameshttp://cygwin.com/cygwin-ug-**net/using.html#using-pathnames
 **http://cygwin.com/cygwin-ug-**net/using.html#using-pathnameshttp://cygwin.com/cygwin-ug-net/using.html#using-pathnames
 **

 
 
   I believe that warning is ignorable, but you can turn it off using
 
   set CYGWIN=nodosfilewarning
 
   It probably didn't cause the error below.
 
 
ERROR: compilation failed for package 'mypackage'
 
 
   I don't know what did cause that error, but it's likely something in
 your
   src directory of the package.  What do you have there?
 
   Duncan Murdoch
 
* removing 'C:/Rpackages/mypackage.Rcheck/mypackage'.
 
   What I understood from above is that it is something with PATH
 variable. I
   had set the following PATH variable:
   C:\Rtools\bin;C:\Rtools\MinGW\bin;C:\Program
   Files\R\R-2.13.0\bin;C:\Program Files\MiKTeX
   2.9\miktex\bin;%SystemRoot%\system32;%SystemRoot%;%**
   SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\**
   WindowsPowerShell\v1.0\;C:\Program
   Files\HTML Help Workshop
 
 
   Can anybody suggest what possibly could have gone wrong?
 
   Thanks,
   BN Mandal
 
  [[alternative HTML version deleted]]
 
   __
   R-help@r-project.org mailing list
   
  https://stat.ethz.ch/mailman/listinfo/r-helphttps://stat.ethz.ch/mailman/**listinfo/r-help
 https://stat.**ethz.ch/mailman/listinfo/r-**helphttps://stat.ethz.ch/mailman/listinfo/r-help
 

   PLEASE do read the posting guide http://www.R-project.org/**
   
  posting-guide.htmlhttp://www.**R-project.org/posting-guide.**htmlhttp://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] R-help Digest, Vol 102, Issue 3

2011-08-03 Thread Uwe Ligges

Since we got this the x-th time now:

Dear Fränzi Korner,

please please please never ever add auto-replies to your account that 
also reply to mailing list messages! Thousands of readers of R-help get 
your auto reply everey day now!


Best,
Uwe Ligges




On 03.08.2011 12:11, fraenzi.kor...@oikostat.ch wrote:

Wir sind bis am 20. August in den Ferien und werden keine e-mails beantworten. 
Bei dringenden Fällen melden Sie sich bei Stefanie von Felten 
steffi.vonfel...@oikostat.ch

We are on vacation until 20. August. In urgent cases, please contact Stefanie 
von Felten steffi.vonfel...@oikostat.ch

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


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


[R] How to fit model in function using passed-in formula, then predict from another function

2011-08-03 Thread Jason Roberts
Hello R experts,

 

I am trying to fit an lme model within a function, using a formula that I
passed into the function, and then predict that model from a different
function. Could you please advise me on how to do this? The following code
illustrates the essence of what I'm trying to do. The actual scenario is
more complicated but this toy example illustrates the crux of the problem.

 

 library(nlme)

 

 Fit - function(f)

+ {

+ model - lme(f, BodyWeight, random = ~ Time)   # BodyWeight is from
nlme package

+ return(model)

+ }

 m1 - Fit(weight ~ Time * Diet)

 

 Predict - function(m)

+ {

+ print(predict(m, m$data))

+ }

 Predict(m1)

Error in eval(expr, envir, enclos) : object 'f' not found

 

 traceback()

7: eval(expr, envir, enclos)

6: eval(mCall$fixed)

5: eval(eval(mCall$fixed)[-2])

4: predict.lme(m, m$data)

3: predict(m, m$data)

2: print(predict(m, m$data))

1: Predict(m1)

 

I have tried various things using parse(), eval(), force(), and so on and
could not figure it out. I suspect this all comes down to a basic ignorance
on my part regarding R's lazy evaluation mechanism, promises, and
environments. I've encountered similar problems elsewhere when passing other
things into functions. It seems like some packages, such as nlme here, have
this restriction and other packages do not. I would appreciate anything you
can do to enlighten me about how this is supposed to work.

 

Thanks very much,

 

Jason

 


[[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] gstat error

2011-08-03 Thread David Winsemius
I see a 'variogram' function in both spatial and gstat when I use ?? 
variogram on my machine that probably does not have even all of those  
packages installed. Are you sure they are the same (I looked  they  
are not)  or failing that that the one you expect is being chosen? And  
are you even sure that there is not a third or a fourth 'variogram' in  
one of those other packages?


--
David.


On Aug 3, 2011, at 2:45 PM, gbre...@ssc.wisc.edu wrote:


Here is my sessionInfo()


sessionInfo()

R version 2.12.2 (2011-02-25)
Platform: i386-pc-mingw32/i386 (32-bit)

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United
States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

attached base packages:
[1] splines   grid  stats graphics  grDevices utils  
datasets

methods
[9] base

other attached packages:
[1] spsurvey_2.1-2  lmtest_0.9-27   zoo_1.6-5
[4] car_2.0-9   survival_2.36-5 nnet_7.3-1
[7] spgwr_0.6-10spatialCovariance_0.6-4 spatial_7.3-2
[10] spatgraphs_2.44 sgeostat_1.0-23 rworldmap_0.1211
[13] fields_6.3  spam_0.23-0 RPyGeo_0.9-2
[16] RSAGA_0.91-1shapefiles_0.6   
RgoogleMaps_1.1.9.7
[19] raster_1.8-22   RArcInfo_0.4-10  
RColorBrewer_1.0-2

[22] PBSmodelling_2.61.210   PBSmapping_2.61.9   mapproj_1.1-8.3
[25] mapdata_2.1-4   intamap_1.3-8   evd_2.2-4
[28] mvtnorm_0.9-96  automap_1.0-9   rgdal_0.6-33
[31] gmaps_0.2   maps_2.1-6  glmmBUGS_1.9
[34] spdep_0.5-32coda_0.14-2 deldir_0.0-13
[37] maptools_0.8-7  foreign_0.8-42   
Matrix_0.999375-46

[40] lattice_0.19-17 boot_1.2-43 abind_1.3-0
[43] MASS_7.3-11 geosphere_1.2-19geonames_0.8
[46] rjson_0.2.3 ctv_0.7-2   GEOmap_1.5-13
[49] akima_0.5-4 RPMG_2.0-5  splancs_2.01-27
[52] geomapdata_1.0-4geoRglm_0.8-33  geoR_1.6-34
[55] gstat_0.9-81sp_0.9-81   nlme_3.1-98

loaded via a namespace (and not attached):
[1] tcltk_2.12.2 tools_2.12.2






On 2011-08-03 09:40, gbre...@ssc.wisc.edu wrote:

Hello.

I am running the examples provided in the gstat help menus.  When  
I try

to
run the following in predict.gstat:

data(meuse)
coordinates(meuse)= ~x+y
v-variogram(log(zinc)~1, meuse)

I get the following error message:

Error in vector(double, length) : invalid 'length' argument


What's the problem?


You should at the very least provide your sessionInfo().

Peter Ehlers




Gilbert

__
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, MD
West Hartford, CT

__
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 Needed in attempting to install 64-bit R!

2011-08-03 Thread Nynese Tinsley
Hello R Help,

I am attempting to install/build a 64-bit version of R to hopefully resolve 
some memory.limit problems for a user who is running a simulation.  The 
'configure' runs fine and the compilation (make) runs fine until the very last 
part (see below). I have libiconv in /usr/local/lib (no sure why I am getting 
the referencing error).  The config.site file is attached.  ANY HELP YOU  CAN 
GIVE WOULD BE GREATLY APPRECIATED! :)

./configure --without-readline DYLIB_LDFLAGS=-xarch=v9 MAIN_LDFLAGS=-xarch=v9

Then I run /usr/ccs/bin/make


cc -xc99=all -xarch=v9  -xopenmp -L/usr/local/bin -o R.bin Rmain.o libR.a 
-L../../lib -lRblas -R/usr/local/opt/SUNWspro/lib/v9:/opt/SUNWspro/lib/v9 
-L/usr/local/opt/SUNWspro/lib/v9 -L/usr/local/opt/SUNWspro/prod/lib/v9 
-L/usr/ccs/lib/sparcv9 -L/lib/sparcv9 -L/usr/lib/sparcv9 -lfui -lfai -lfai2 
-lfsumai -lfprodai -lfminlai -lfmaxlai -lfminvai -lfmaxvai -lfsu -lsunmath 
-lmtsk -lm -lnsl -lsocket -ldl -lm -licuuc -licui18n
cc: Warning: Specify a supported level of optimization when using -xopenmp, 
-xopenmp will not set an optimization level in a future release. Optimization 
level changed to 3 to support -xopenmp
Undefined   first referenced
symbol in file
libiconv_close  libR.a(sysutils.o)
libiconv_open   libR.a(sysutils.o)
libiconvlibR.a(sysutils.o)
ld: fatal: Symbol referencing errors. No output written to R.bin
*** Error code 1
make: Fatal error: Command failed for target `R.bin'
Current working directory /usr/local/pkg/R-2.13.1/src/main
*** Error code 1
The following command caused the error:
/usr/ccs/bin/make install-bin-local
make: Fatal error: Command failed for target `R'
Current working directory /usr/local/pkg/R-2.13.1/src/main
*** Error code 1
The following command caused the error:
for d in scripts include extra appl nmath unix main modules library; do \
  (cd ${d}  /usr/ccs/bin/make R) || exit 1; \
done
make: Fatal error: Command failed for target `R'
Current working directory /usr/local/pkg/R-2.13.1/src
*** Error code 1
The following command caused the error:
for d in m4 tools doc etc share src tests  po; do \
  (cd ${d}  /usr/ccs/bin/make R) || exit 1; \
done
make: Fatal error: Command failed for target `R'

Thanks,
  Nynese

Nynese Tinsley, BSEE, MSCIS
UNIX Systems Analyst
Harvard School of Public Health
Center for Biostatistics in AIDS Research
651 Huntington Ave, FXB 614
Boston, MA 02115
617-432-3244 office#
617-432-2843 fax#

__
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] Model selection

2011-08-03 Thread xy
 Dear List, 
I have some difficulties to work with the function lmer from lme4. My
responses are binary form  and i want to use forward selection to my 12
covariates but i dont know how can I choose them based on deviance. Can
someone pls give me a example so i can apply. For example my covariates are
gestation,smoking ...and my response baby 

b1=lmer(baby~ (1|id), data, binomial) 

i will appreciate any help.thankss

--
View this message in context: 
http://r.789695.n4.nabble.com/Model-selection-tp3716109p3716109.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] slow computation of functions over large datasets

2011-08-03 Thread Ken
Sorry about the lack of code, but using Davids example, would:
tapply(itemPrice, INDEX=orderID, FUN=sum)
work?
  -Ken Hutchison

On Aug 3, 2554 BE, at 2:09 PM, David Winsemius dwinsem...@comcast.net wrote:

 
 On Aug 3, 2011, at 2:01 PM, Ken wrote:
 
 Hello,
 Perhaps transpose the table attach(as.data.frame(t(data))) and use ColSums() 
 function with order id as header.
-Ken Hutchison
 
 Got any code? The OP offered a reproducible example, after all.
 
 -- 
 David.
 
 On Aug 3, 2554 BE, at 1:12 PM, David Winsemius dwinsem...@comcast.net 
 wrote:
 
 
 On Aug 3, 2011, at 12:20 PM, jim holtman wrote:
 
 This takes about 2 secs for 1M rows:
 
 n - 100
 exampledata - data.frame(orderID = sample(floor(n / 5), n, replace = 
 TRUE), itemPrice = rpois(n, 10))
 require(data.table)
 # convert to data.table
 ed.dt - data.table(exampledata)
 system.time(result - ed.dt[
 + , list(total = sum(itemPrice))
 + , by = orderID
 + ]
 +)
 user  system elapsed
 1.300.051.34
 
 Interesting. Impressive. And I noted that the OP wanted what cumsum would 
 provide and for some reason creating that longer result is even faster on 
 my machine than the shorter result using sum.
 
 -- 
 David.
 
 str(result)
 Classes ‘data.table’ and 'data.frame':  198708 obs. of  2 variables:
 $ orderID: int  1 2 3 4 5 6 8 9 10 11 ...
 $ total  : num  49 37 72 92 50 76 34 22 65 39 ...
 head(result)
  orderID total
 [1,]   149
 [2,]   237
 [3,]   372
 [4,]   492
 [5,]   550
 [6,]   676
 
 
 
 On Wed, Aug 3, 2011 at 9:25 AM, Caroline Faisst
 caroline.fai...@gmail.com wrote:
 Hello there,
 
 
 I’m computing the total value of an order from the price of the order 
 items
 using a “for” loop and the “ifelse” function. I do this on a large 
 dataframe
 (close to 1m lines). The computation of this function is painfully slow: 
 in
 1min only about 90 rows are calculated.
 
 
 The computation time taken for a given number of rows increases with the
 size of the dataset, see the example with my function below:
 
 
 # small dataset: function performs well
 
 exampledata-data.frame(orderID=c(1,1,1,2,2,3,3,3,4),itemPrice=c(10,17,9,12,25,10,1,9,7))
 
 exampledata[1,orderAmount]-exampledata[1,itemPrice]
 
 system.time(for (i in 2:length(exampledata[,1]))
 {exampledata[i,orderAmount]-ifelse(exampledata[i,orderID]==exampledata[i-1,orderID],exampledata[i-1,orderAmount]+exampledata[i,itemPrice],exampledata[i,itemPrice])})
 
 
 # large dataset: the very same computational task takes much longer
 
 exampledata2-data.frame(orderID=c(1,1,1,2,2,3,3,3,4,5:200),itemPrice=c(10,17,9,12,25,10,1,9,7,25:220))
 
 exampledata2[1,orderAmount]-exampledata2[1,itemPrice]
 
 system.time(for (i in 2:9)
 {exampledata2[i,orderAmount]-ifelse(exampledata2[i,orderID]==exampledata2[i-1,orderID],exampledata2[i-1,orderAmount]+exampledata2[i,itemPrice],exampledata2[i,itemPrice])})
 
 
 
 Does someone know a way to increase the speed?
 
 
 Thank you very much!
 
 Caroline
 
 [[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.
 
 
 
 
 
 -- 
 Jim Holtman
 Data Munger Guru
 
 What is the problem that you are trying to solve?
 
 __
 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, MD
 West Hartford, CT
 
 __
 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, MD
 West Hartford, CT
 

__
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.app installer probs on Snow Leopard

2011-08-03 Thread Walter Ludwick
Have tried to install R.app several times (6, in fact: versions 2.12, 13  14, 
both 32 and 64 bit versions), using packages freshly downloaded from the 
official project page, and failed every time, given exception reports such as 
the following (appended below, the 2 reports arising out of my 1st  6th 
attempts). 

Machine  software version specifics are all contained therein. 

What am i missing, i wonder? Any clues would be most appreciated -thanx!   /w



8(snip)---8

Process: R [15997]
Path:/Applications/R.app/Contents/MacOS/R
Identifier:  org.R-project.R
Version: ??? (???)
Code Type:   X86-64 (Native)
Parent Process:  launchd [179]

Date/Time:   2011-08-03 16:13:36.857 +0100
OS Version:  Mac OS X 10.6.8 (10K540)
Report Version:  6

Interval Since Last Report:  23665 sec
Crashes Since Last Report:   5
Per-App Crashes Since Last Report:   3
Anonymous UUID:  A3B4FAD8-70A5-420F-A0E1-E02624B493A5

Exception Type:  EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0002, 0x
Crashed Thread:  0

Dyld Error Message:
 Library not loaded: 
/Library/Frameworks/R.framework/Versions/2.14/Resources/lib/libR.dylib
 Referenced from: /Applications/R.app/Contents/MacOS/R
 Reason: image not found

Binary Images:
   0x7fff5fc0 - 0x7fff5fc3bdef  dyld 132.1 (???) 
69130DA3-7CB3-54C8-ABC5-423DECDD2AF7 /usr/lib/dyld

Model: MacBookPro5,5, BootROM MBP55.00AC.B03, 2 processors, Intel Core 2 Duo, 
2.53 GHz, 4 GB, SMC 1.47f2
Graphics: NVIDIA GeForce 9400M, NVIDIA GeForce 9400M, PCI, 256 MB
Memory Module: global_name
AirPort: spairport_wireless_card_type_airport_extreme (0x14E4, 0x8D), Broadcom 
BCM43xx 1.0 (5.10.131.42.4)
Bluetooth: Version 2.4.5f3, 2 service, 19 devices, 1 incoming serial ports
Network Service: AirPort, AirPort, en1
Serial ATA Device: ST9250315ASG, 232.89 GB
Serial ATA Device: HL-DT-ST DVDRW  GS23N
USB Device: Internal Memory Card Reader, 0x05ac  (Apple Inc.), 0x8403, 
0x2650 / 2
USB Device: Built-in iSight, 0x05ac  (Apple Inc.), 0x8507, 0x2440 / 2
USB Device: BRCM2046 Hub, 0x0a5c  (Broadcom Corp.), 0x4500, 0x0610 / 2
USB Device: Bluetooth USB Host Controller, 0x05ac  (Apple Inc.), 0x8213, 
0x0611 / 4
USB Device: Apple Internal Keyboard / Trackpad, 0x05ac  (Apple Inc.), 0x0237, 
0x0460 / 3
USB Device: IR Receiver, 0x05ac  (Apple Inc.), 0x8242, 0x0450 / 2

8(snip)---8

Process: R [16330]
Path:/Applications/R.app/Contents/MacOS/R
Identifier:  org.R-project.R
Version: ??? (???)
Code Type:   X86 (Native)
Parent Process:  launchd [179]

Date/Time:   2011-08-03 17:18:06.587 +0100
OS Version:  Mac OS X 10.6.8 (10K540)
Report Version:  6

Interval Since Last Report:  27534 sec
Crashes Since Last Report:   9
Per-App Crashes Since Last Report:   7
Anonymous UUID:  A3B4FAD8-70A5-420F-A0E1-E02624B493A5

Exception Type:  EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0002, 0x
Crashed Thread:  0

Dyld Error Message:
  Library not loaded: 
/Library/Frameworks/R.framework/Versions/2.12/Resources/lib/libR.dylib
  Referenced from: /Applications/R.app/Contents/MacOS/R
  Reason: image not found

Binary Images:
0x8fe0 - 0x8fe4162b  dyld 132.1 (???) 
1C06ECD9-A2D7-BB10-AF50-0F2B598A7DEC /usr/lib/dyld

Model: MacBookPro5,5, BootROM MBP55.00AC.B03, 2 processors, Intel Core 2 Duo, 
2.53 GHz, 4 GB, SMC 1.47f2
Graphics: NVIDIA GeForce 9400M, NVIDIA GeForce 9400M, PCI, 256 MB
Memory Module: global_name
AirPort: spairport_wireless_card_type_airport_extreme (0x14E4, 0x8D), Broadcom 
BCM43xx 1.0 (5.10.131.42.4)
Bluetooth: Version 2.4.5f3, 2 service, 19 devices, 1 incoming serial ports
Network Service: AirPort, AirPort, en1
Serial ATA Device: ST9250315ASG, 232.89 GB
Serial ATA Device: HL-DT-ST DVDRW  GS23N
USB Device: Internal Memory Card Reader, 0x05ac  (Apple Inc.), 0x8403, 
0x2650 / 2
USB Device: Built-in iSight, 0x05ac  (Apple Inc.), 0x8507, 0x2440 / 2
USB Device: BRCM2046 Hub, 0x0a5c  (Broadcom Corp.), 0x4500, 0x0610 / 2
USB Device: Bluetooth USB Host Controller, 0x05ac  (Apple Inc.), 0x8213, 
0x0611 / 4
USB Device: Apple Internal Keyboard / Trackpad, 0x05ac  (Apple Inc.), 0x0237, 
0x0460 / 3
USB Device: IR Receiver, 0x05ac  (Apple Inc.), 0x8242, 0x0450 / 2

8(snip)---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] Convert matrix to numeric

2011-08-03 Thread Duncan Murdoch

On 03/08/2011 3:04 PM, Jeffrey Joh wrote:

I have a matrix that looks like this:


structure(c(0.0376673981759913, 0.111066500741386, 1, 1103,
18, OPEN, DEPR, 0.0404073656092023, 0.115186044704599,
1, 719, 18, OPEN, DEPR, 0.0665342096693433, 0.197570061769498,
1, 1103, 18, OPEN, DEPR, 0.119287147905722, 0.356427096010845,
1, 1103, 18, OPEN, DEPR), .Dim = c(7L, 4L), .Dimnames = list(
 c(Sn, SlnC, housenum, date, hour, flue, pressurization
 ), c(10019.BLO, 1002.BLO, 10020.BLO, 10021.BLO)))



How do I convert rows 1-5 to numeric?  I tried mode()- numeric but that 
doesn't change anything.


Every entry in a matrix has the same type, so you can't change just 
those rows other than by extracting them into a separate matrix and 
changing that.


Duncan Murdoch




I also tried converting this to a table then converting to numeric, but I got: 
(list) object cannot be coerced to type 'double'



Jeff
__
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] slow computation of functions over large datasets

2011-08-03 Thread Ken
Hello, 
  Perhaps transpose the table attach(as.data.frame(t(data))) and use ColSums() 
function with order id as header.
 -Ken Hutchison

On Aug 3, 2554 BE, at 1:12 PM, David Winsemius dwinsem...@comcast.net wrote:

 
 On Aug 3, 2011, at 12:20 PM, jim holtman wrote:
 
 This takes about 2 secs for 1M rows:
 
 n - 100
 exampledata - data.frame(orderID = sample(floor(n / 5), n, replace = 
 TRUE), itemPrice = rpois(n, 10))
 require(data.table)
 # convert to data.table
 ed.dt - data.table(exampledata)
 system.time(result - ed.dt[
 + , list(total = sum(itemPrice))
 + , by = orderID
 + ]
 +)
  user  system elapsed
  1.300.051.34
 
 Interesting. Impressive. And I noted that the OP wanted what cumsum would 
 provide and for some reason creating that longer result is even faster on my 
 machine than the shorter result using sum.
 
 -- 
 David.
 
 str(result)
 Classes ‘data.table’ and 'data.frame':  198708 obs. of  2 variables:
 $ orderID: int  1 2 3 4 5 6 8 9 10 11 ...
 $ total  : num  49 37 72 92 50 76 34 22 65 39 ...
 head(result)
orderID total
 [1,]   149
 [2,]   237
 [3,]   372
 [4,]   492
 [5,]   550
 [6,]   676
 
 
 
 On Wed, Aug 3, 2011 at 9:25 AM, Caroline Faisst
 caroline.fai...@gmail.com wrote:
 Hello there,
 
 
 I’m computing the total value of an order from the price of the order items
 using a “for” loop and the “ifelse” function. I do this on a large dataframe
 (close to 1m lines). The computation of this function is painfully slow: in
 1min only about 90 rows are calculated.
 
 
 The computation time taken for a given number of rows increases with the
 size of the dataset, see the example with my function below:
 
 
 # small dataset: function performs well
 
 exampledata-data.frame(orderID=c(1,1,1,2,2,3,3,3,4),itemPrice=c(10,17,9,12,25,10,1,9,7))
 
 exampledata[1,orderAmount]-exampledata[1,itemPrice]
 
 system.time(for (i in 2:length(exampledata[,1]))
 {exampledata[i,orderAmount]-ifelse(exampledata[i,orderID]==exampledata[i-1,orderID],exampledata[i-1,orderAmount]+exampledata[i,itemPrice],exampledata[i,itemPrice])})
 
 
 # large dataset: the very same computational task takes much longer
 
 exampledata2-data.frame(orderID=c(1,1,1,2,2,3,3,3,4,5:200),itemPrice=c(10,17,9,12,25,10,1,9,7,25:220))
 
 exampledata2[1,orderAmount]-exampledata2[1,itemPrice]
 
 system.time(for (i in 2:9)
 {exampledata2[i,orderAmount]-ifelse(exampledata2[i,orderID]==exampledata2[i-1,orderID],exampledata2[i-1,orderAmount]+exampledata2[i,itemPrice],exampledata2[i,itemPrice])})
 
 
 
 Does someone know a way to increase the speed?
 
 
 Thank you very much!
 
 Caroline
 
   [[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.
 
 
 
 
 
 -- 
 Jim Holtman
 Data Munger Guru
 
 What is the problem that you are trying to solve?
 
 __
 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, MD
 West Hartford, CT
 
 __
 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] Convert matrix to numeric

2011-08-03 Thread Ken
How about
Matrix[1:5,]=as.numeric(Matrix[1:5,])
-Ken Hutchison

On Aug 3, 2554 BE, at 3:04 PM, Jeffrey Joh johjeff...@hotmail.com wrote:

 
 I have a matrix that looks like this:
 
 
 structure(c(0.0376673981759913, 0.111066500741386, 1, 1103, 
 18, OPEN, DEPR, 0.0404073656092023, 0.115186044704599, 
 1, 719, 18, OPEN, DEPR, 0.0665342096693433, 0.197570061769498, 
 1, 1103, 18, OPEN, DEPR, 0.119287147905722, 0.356427096010845, 
 1, 1103, 18, OPEN, DEPR), .Dim = c(7L, 4L), .Dimnames = list(
c(Sn, SlnC, housenum, date, hour, flue, pressurization
), c(10019.BLO, 1002.BLO, 10020.BLO, 10021.BLO)))
 
 
 
 How do I convert rows 1-5 to numeric?  I tried mode() - numeric but that 
 doesn't change anything.
 
 
 
 I also tried converting this to a table then converting to numeric, but I 
 got: (list) object cannot be coerced to type 'double'
 
 
 
 Jeff 
 __
 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] implicit functions (was r-help)

2011-08-03 Thread Duncan Murdoch

On 03/08/2011 11:21 AM, KnifeBoot wrote:

   Hey,
 Is there any function plotting several implicit functions (F(x,y)=0) on 
the same fig. Is there anyone who has an example code of how to do this?
 The contour3d function in the misc3d package only work with the  functions 
with three dimensions.
 Thanks a lot.


contour() will do it.  Use add=TRUE to add extra functions.

Duncan Murdoch

P.S. Please use a more informative subject line!

__
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] limits on liniar model

2011-08-03 Thread Bert Gunter
Please use R's search capabilities before posting.

RSiteSearch(Linear Model with Constraints)

appears to give you what you're looking for. Incidentally, with
constraints, the model is no longer linear, I believe.

-- Bert

2011/8/3 ראובן אברמוביץ gantk...@walla.com:

   Can I put limits on the lm() command? I only know that you can choose a
   liniar model with or without an intercept, but can I put other limits on
   the coefficients (for example- the intercept must be bigger than 1) ?

     _

   Walla! Mail - [1]Get your free unlimited mail today

 References

   1. http://www.walla.co.il/

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





-- 
Men by nature long to get on to the ultimate truths, and will often
be impatient with elementary studies or fight shy of them. If it were
possible to reach the ultimate truths without the elementary studies
usually prefixed to them, these would not be preparatory studies but
superfluous diversions.

-- Maimonides (1135-1204)

Bert Gunter
Genentech Nonclinical Biostatistics

__
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] Convert matrix to numeric

2011-08-03 Thread Sarah Goslee
Hi Jeffrey,

On Wed, Aug 3, 2011 at 3:04 PM, Jeffrey Joh johjeff...@hotmail.com wrote:

 I have a matrix that looks like this:


 structure(c(0.0376673981759913, 0.111066500741386, 1, 1103,
 18, OPEN, DEPR, 0.0404073656092023, 0.115186044704599,
 1, 719, 18, OPEN, DEPR, 0.0665342096693433, 0.197570061769498,
 1, 1103, 18, OPEN, DEPR, 0.119287147905722, 0.356427096010845,
 1, 1103, 18, OPEN, DEPR), .Dim = c(7L, 4L), .Dimnames = list(
    c(Sn, SlnC, housenum, date, hour, flue, pressurization
    ), c(10019.BLO, 1002.BLO, 10020.BLO, 10021.BLO)))

Thank you for providing a small working example.

 How do I convert rows 1-5 to numeric?  I tried mode() - numeric but that 
 doesn't change anything.

Two things are going on here. First, a matrix can only contain one kind of data.
For this example, since there are strings the whole thing has to be character.
A data frame is intended to hold different kinds of data, but each column has
to be a single type. So if you want those values to be numeric instead of
character, you'll need to transpose your matrix and convert it to a data frame.

tempdata - structure(c(0.0376673981759913, 0.111066500741386, 1, 1103,
18, OPEN, DEPR, 0.0404073656092023, 0.115186044704599,
1, 719, 18, OPEN, DEPR, 0.0665342096693433, 0.197570061769498,
1, 1103, 18, OPEN, DEPR, 0.119287147905722, 0.356427096010845,
1, 1103, 18, OPEN, DEPR), .Dim = c(7L, 4L), .Dimnames = list(
   c(Sn, SlnC, housenum, date, hour, flue, pressurization
   ), c(10019.BLO, 1002.BLO, 10020.BLO, 10021.BLO)))

tempdata - data.frame(t(tempdata), stringsAsFactors=FALSE)

Once you have the right kind of object, you can convert the five columns
of interest to numeric. This needs to be done a column at a time, I think:
tempdata[, 1:5] - apply(tempdata[,1:5], 2, as.numeric)

Sarah

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

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


Re: [R] Convert matrix to numeric

2011-08-03 Thread Nordlund, Dan (DSHS/RDA)
 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
 project.org] On Behalf Of Ken
 Sent: Wednesday, August 03, 2011 12:13 PM
 To: Jeffrey Joh
 Cc: r-help@r-project.org
 Subject: Re: [R] Convert matrix to numeric
 
 How about
 Matrix[1:5,]=as.numeric(Matrix[1:5,])
 -Ken Hutchison
 
 On Aug 3, 2554 BE, at 3:04 PM, Jeffrey Joh johjeff...@hotmail.com
 wrote:
 
 
  I have a matrix that looks like this:
 
 
  structure(c(0.0376673981759913, 0.111066500741386, 1, 1103,
  18, OPEN, DEPR, 0.0404073656092023, 0.115186044704599,
  1, 719, 18, OPEN, DEPR, 0.0665342096693433,
 0.197570061769498,
  1, 1103, 18, OPEN, DEPR, 0.119287147905722,
 0.356427096010845,
  1, 1103, 18, OPEN, DEPR), .Dim = c(7L, 4L), .Dimnames =
 list(
 c(Sn, SlnC, housenum, date, hour, flue,
 pressurization
 ), c(10019.BLO, 1002.BLO, 10020.BLO, 10021.BLO)))
 
 
 
  How do I convert rows 1-5 to numeric?  I tried mode() - numeric
 but that doesn't change anything.
 

Ken,

You can't store the numeric values back in the matrix, because rows 6 and 7 
contain character values.  Everything will just be converted back to character. 
 You need to create a new matrix for the numeric values.

Hope this is helpful,

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.


Re: [R] slow computation of functions over large datasets

2011-08-03 Thread David Winsemius


On Aug 3, 2011, at 3:05 PM, Ken wrote:


Sorry about the lack of code, but using Davids example, would:
tapply(itemPrice, INDEX=orderID, FUN=sum)
work?


Doesn't do the cumulative sums or the assignment into column of the  
same data.frame. That's why I used ave, because it keeps the sequence  
correct.


--
David.

 -Ken Hutchison

On Aug 3, 2554 BE, at 2:09 PM, David Winsemius  
dwinsem...@comcast.net wrote:




On Aug 3, 2011, at 2:01 PM, Ken wrote:


Hello,
Perhaps transpose the table attach(as.data.frame(t(data))) and use  
ColSums() function with order id as header.

  -Ken Hutchison


Got any code? The OP offered a reproducible example, after all.

--
David.


On Aug 3, 2554 BE, at 1:12 PM, David Winsemius dwinsem...@comcast.net 
 wrote:




On Aug 3, 2011, at 12:20 PM, jim holtman wrote:


This takes about 2 secs for 1M rows:


n - 100
exampledata - data.frame(orderID = sample(floor(n / 5), n,  
replace = TRUE), itemPrice = rpois(n, 10))

require(data.table)
# convert to data.table
ed.dt - data.table(exampledata)
system.time(result - ed.dt[

+ , list(total = sum(itemPrice))
+ , by = orderID
+ ]
+)
user  system elapsed
1.300.051.34


Interesting. Impressive. And I noted that the OP wanted what  
cumsum would provide and for some reason creating that longer  
result is even faster on my machine than the shorter result using  
sum.


--
David.


str(result)
Classes ‘data.table’ and 'data.frame':  198708 obs. of  2  
variables:

$ orderID: int  1 2 3 4 5 6 8 9 10 11 ...
$ total  : num  49 37 72 92 50 76 34 22 65 39 ...

head(result)

orderID total
[1,]   149
[2,]   237
[3,]   372
[4,]   492
[5,]   550
[6,]   676





On Wed, Aug 3, 2011 at 9:25 AM, Caroline Faisst
caroline.fai...@gmail.com wrote:

Hello there,


I’m computing the total value of an order from the price of the  
order items
using a “for” loop and the “ifelse” function. I do this on a  
large dataframe
(close to 1m lines). The computation of this function is  
painfully slow: in

1min only about 90 rows are calculated.


The computation time taken for a given number of rows increases  
with the

size of the dataset, see the example with my function below:


# small dataset: function performs well

exampledata- 
data 
.frame 
(orderID 
=c(1,1,1,2,2,3,3,3,4),itemPrice=c(10,17,9,12,25,10,1,9,7))


exampledata[1,orderAmount]-exampledata[1,itemPrice]

system.time(for (i in 2:length(exampledata[,1]))
{exampledata[i,orderAmount]- 
ifelse 
(exampledata 
[i 
,orderID 
]==exampledata[i-1,orderID],exampledata[i-1,orderAmount] 
+exampledata[i,itemPrice],exampledata[i,itemPrice])})



# large dataset: the very same computational task takes much  
longer


exampledata2- 
data 
.frame 
(orderID 
= 
c 
(1,1,1,2,2,3,3,3,4,5 
:200),itemPrice=c(10,17,9,12,25,10,1,9,7,25:220))


exampledata2[1,orderAmount]-exampledata2[1,itemPrice]

system.time(for (i in 2:9)
{exampledata2[i,orderAmount]- 
ifelse 
(exampledata2 
[i 
,orderID 
]==exampledata2[i-1,orderID],exampledata2[i-1,orderAmount] 
+exampledata2[i,itemPrice],exampledata2[i,itemPrice])})




Does someone know a way to increase the speed?


Thank you very much!

Caroline

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







--
Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?

__
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, MD
West Hartford, CT

__
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, MD
West Hartford, CT



David Winsemius, MD
West Hartford, CT

__
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] the significance of BEKK estimation

2011-08-03 Thread zoe_zhang
Here is one more question,
How could I input an asymmetry in volatility specication in the BEKK
function?
As far as I know, the BEKK estimation function is 

mvBEKK.est(eps, order = c(1,1), params = NULL, fixed = NULL, method =
BFGS, verbose = F)

I totally have no idea to exert an asymmetry into.

Many thanks!

Sincere,
Zoe


--
View this message in context: 
http://r.789695.n4.nabble.com/the-significance-of-BEKK-estimation-tp3716586p3716597.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] the significance of BEKK estimation

2011-08-03 Thread zoe_zhang
Dear ALL,

I use BEKK package to estimate Bivariate GARCH model. But when the results
come out, there's no t-stat or p-value of the estimated coeffients. Does
anyone know how to get the significance?

Followings are the codes I input,

P1=data.frame(x,y)
y1=mvBEKK.est(P1)
mvBEKK.diag(y1)

Anyhelp would be appreciated!

Sincere,
Zoe

--
View this message in context: 
http://r.789695.n4.nabble.com/the-significance-of-BEKK-estimation-tp3716586p3716586.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] gstat error

2011-08-03 Thread Dennis Murphy
To add to David's comments (nice catch, BTW), I found three
variogram() functions as a result of ??variogram. The one that gets
used is from the package that is highest in the search path (notice
that gstat is 55th (!!)) - that would be the one from the spatial
package. [The other is in the SpatialExtremes package, which is not
loaded, so the one in spatial is masking the one in gstat.]

To use the variogram() function in gstat, call gstat::variogram (...).

Dennis



On Wed, Aug 3, 2011 at 12:04 PM, David Winsemius dwinsem...@comcast.net wrote:
 I see a 'variogram' function in both spatial and gstat when I use
 ??variogram on my machine that probably does not have even all of those
 packages installed. Are you sure they are the same (I looked  they are
 not)  or failing that that the one you expect is being chosen? And are you
 even sure that there is not a third or a fourth 'variogram' in one of those
 other packages?

 --
 David.


 On Aug 3, 2011, at 2:45 PM, gbre...@ssc.wisc.edu wrote:

 Here is my sessionInfo()

 sessionInfo()

 R version 2.12.2 (2011-02-25)
 Platform: i386-pc-mingw32/i386 (32-bit)

 locale:
 [1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United
 States.1252
 [3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
 [5] LC_TIME=English_United States.1252

 attached base packages:
 [1] splines   grid      stats     graphics  grDevices utils     datasets
 methods
 [9] base

 other attached packages:
 [1] spsurvey_2.1-2          lmtest_0.9-27           zoo_1.6-5
 [4] car_2.0-9               survival_2.36-5         nnet_7.3-1
 [7] spgwr_0.6-10            spatialCovariance_0.6-4 spatial_7.3-2
 [10] spatgraphs_2.44         sgeostat_1.0-23         rworldmap_0.1211
 [13] fields_6.3              spam_0.23-0             RPyGeo_0.9-2
 [16] RSAGA_0.91-1            shapefiles_0.6          RgoogleMaps_1.1.9.7
 [19] raster_1.8-22           RArcInfo_0.4-10         RColorBrewer_1.0-2
 [22] PBSmodelling_2.61.210   PBSmapping_2.61.9       mapproj_1.1-8.3
 [25] mapdata_2.1-4           intamap_1.3-8           evd_2.2-4
 [28] mvtnorm_0.9-96          automap_1.0-9           rgdal_0.6-33
 [31] gmaps_0.2               maps_2.1-6              glmmBUGS_1.9
 [34] spdep_0.5-32            coda_0.14-2             deldir_0.0-13
 [37] maptools_0.8-7          foreign_0.8-42          Matrix_0.999375-46
 [40] lattice_0.19-17         boot_1.2-43             abind_1.3-0
 [43] MASS_7.3-11             geosphere_1.2-19        geonames_0.8
 [46] rjson_0.2.3             ctv_0.7-2               GEOmap_1.5-13
 [49] akima_0.5-4             RPMG_2.0-5              splancs_2.01-27
 [52] geomapdata_1.0-4        geoRglm_0.8-33          geoR_1.6-34
 [55] gstat_0.9-81            sp_0.9-81               nlme_3.1-98

 loaded via a namespace (and not attached):
 [1] tcltk_2.12.2 tools_2.12.2



 On 2011-08-03 09:40, gbre...@ssc.wisc.edu wrote:

 Hello.

 I am running the examples provided in the gstat help menus.  When I try
 to
 run the following in predict.gstat:

 data(meuse)
 coordinates(meuse)= ~x+y
 v-variogram(log(zinc)~1, meuse)

 I get the following error message:

 Error in vector(double, length) : invalid 'length' argument


 What's the problem?

 You should at the very least provide your sessionInfo().

 Peter Ehlers



 Gilbert

 __
 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, MD
 West Hartford, CT

 __
 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] Convert matrix to numeric

2011-08-03 Thread David Winsemius

Here's what you _should_  do

1) transpose
2a) as.data.frame
3a) fix the stupid default stringsAsFactor behavior
4a) convert the first 5 columns to numeric

dfrm - as.data.frame( t( structure(.) ) )
dfrm[, 1:5] -lapply(dfrm[, 1:5], as.character)
dfrm[, 1:5] -lapply(dfrm[, 1:5], as.numeric)

Or:
1) transpose
2b) as.data.frame with stringsAsFactors= FALSE
3b) convert to numeric




On Aug 3, 2011, at 3:04 PM, Jeffrey Joh wrote:



I have a matrix that looks like this:


structure(c(0.0376673981759913, 0.111066500741386, 1, 1103,
18, OPEN, DEPR, 0.0404073656092023, 0.115186044704599,
1, 719, 18, OPEN, DEPR, 0.0665342096693433,  
0.197570061769498,
1, 1103, 18, OPEN, DEPR, 0.119287147905722,  
0.356427096010845,
1, 1103, 18, OPEN, DEPR), .Dim = c(7L, 4L), .Dimnames =  
list(
   c(Sn, SlnC, housenum, date, hour, flue,  
pressurization

   ), c(10019.BLO, 1002.BLO, 10020.BLO, 10021.BLO)))



How do I convert rows 1-5 to numeric?  I tried mode() - numeric  
but that doesn't change anything.




I also tried converting this to a table then converting to numeric,  
but I got: (list) object cannot be coerced to type 'double'




Jeff
__
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, MD
West Hartford, CT

__
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] limits on liniar model

2011-08-03 Thread John Sorkin
It is hard to prove a negative, but to the best of my knowledge lm will not do 
what you want. This does not mean there is not a function that will perform 
your analyses; the sort of thing you want to do is often accomplished using 
non-linear methods.
John 

 ראובן אברמוביץgantk...@walla.com 8/3/2011 12:00:04 PM 

   Can I put limits on the lm() command? I only know that you can choose a
   liniar model with or without an intercept, but can I put other limits on
   the coefficients (for example- the intercept must be bigger than 1) ?

 _

   Walla! Mail - [1]Get your free unlimited mail today

References

   1. http://www.walla.co.il/

Confidentiality Statement:
This email message, including any attachments, is for th...{{dropped:6}}

__
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.app installer probs on Snow Leopard

2011-08-03 Thread peter dalgaard

On Aug 3, 2011, at 18:35 , Walter Ludwick wrote:

 Have tried to install R.app several times (6, in fact: versions 2.12, 13  
 14, both 32 and 64 bit versions), using packages freshly downloaded from the 
 official project page, and failed every time, given exception reports such as 
 the following (appended below, the 2 reports arising out of my 1st  6th 
 attempts). 
 
 Machine  software version specifics are all contained therein. 
 
 What am i missing, i wonder? Any clues would be most appreciated -thanx!   /w

What did you do to install? For a plain install, just get

http://cran.r-project.org/bin/macosx/R-2.13.1.pkg

open it and follow the instructions.


If you tried to install the 

http://cran.r-project.org/bin/macosx/Mac-GUI-1.41.tar.gz

then I suspect that you missed the point, that R.app is something you install 
_on_ _top_ _of_ an installation of R itself.

 
 
 
 8(snip)---8
 
 Process: R [15997]
 Path:/Applications/R.app/Contents/MacOS/R
 Identifier:  org.R-project.R
 Version: ??? (???)
 Code Type:   X86-64 (Native)
 Parent Process:  launchd [179]
 
 Date/Time:   2011-08-03 16:13:36.857 +0100
 OS Version:  Mac OS X 10.6.8 (10K540)
 Report Version:  6
 
 Interval Since Last Report:  23665 sec
 Crashes Since Last Report:   5
 Per-App Crashes Since Last Report:   3
 Anonymous UUID:  A3B4FAD8-70A5-420F-A0E1-E02624B493A5
 
 Exception Type:  EXC_BREAKPOINT (SIGTRAP)
 Exception Codes: 0x0002, 0x
 Crashed Thread:  0
 
 Dyld Error Message:
 Library not loaded: 
 /Library/Frameworks/R.framework/Versions/2.14/Resources/lib/libR.dylib
 Referenced from: /Applications/R.app/Contents/MacOS/R
 Reason: image not found
 
 Binary Images:
   0x7fff5fc0 - 0x7fff5fc3bdef  dyld 132.1 (???) 
 69130DA3-7CB3-54C8-ABC5-423DECDD2AF7 /usr/lib/dyld
 
 Model: MacBookPro5,5, BootROM MBP55.00AC.B03, 2 processors, Intel Core 2 Duo, 
 2.53 GHz, 4 GB, SMC 1.47f2
 Graphics: NVIDIA GeForce 9400M, NVIDIA GeForce 9400M, PCI, 256 MB
 Memory Module: global_name
 AirPort: spairport_wireless_card_type_airport_extreme (0x14E4, 0x8D), 
 Broadcom BCM43xx 1.0 (5.10.131.42.4)
 Bluetooth: Version 2.4.5f3, 2 service, 19 devices, 1 incoming serial ports
 Network Service: AirPort, AirPort, en1
 Serial ATA Device: ST9250315ASG, 232.89 GB
 Serial ATA Device: HL-DT-ST DVDRW  GS23N
 USB Device: Internal Memory Card Reader, 0x05ac  (Apple Inc.), 0x8403, 
 0x2650 / 2
 USB Device: Built-in iSight, 0x05ac  (Apple Inc.), 0x8507, 0x2440 / 2
 USB Device: BRCM2046 Hub, 0x0a5c  (Broadcom Corp.), 0x4500, 0x0610 / 2
 USB Device: Bluetooth USB Host Controller, 0x05ac  (Apple Inc.), 0x8213, 
 0x0611 / 4
 USB Device: Apple Internal Keyboard / Trackpad, 0x05ac  (Apple Inc.), 0x0237, 
 0x0460 / 3
 USB Device: IR Receiver, 0x05ac  (Apple Inc.), 0x8242, 0x0450 / 2
 
 8(snip)---8
 
 Process: R [16330]
 Path:/Applications/R.app/Contents/MacOS/R
 Identifier:  org.R-project.R
 Version: ??? (???)
 Code Type:   X86 (Native)
 Parent Process:  launchd [179]
 
 Date/Time:   2011-08-03 17:18:06.587 +0100
 OS Version:  Mac OS X 10.6.8 (10K540)
 Report Version:  6
 
 Interval Since Last Report:  27534 sec
 Crashes Since Last Report:   9
 Per-App Crashes Since Last Report:   7
 Anonymous UUID:  A3B4FAD8-70A5-420F-A0E1-E02624B493A5
 
 Exception Type:  EXC_BREAKPOINT (SIGTRAP)
 Exception Codes: 0x0002, 0x
 Crashed Thread:  0
 
 Dyld Error Message:
  Library not loaded: 
 /Library/Frameworks/R.framework/Versions/2.12/Resources/lib/libR.dylib
  Referenced from: /Applications/R.app/Contents/MacOS/R
  Reason: image not found
 
 Binary Images:
 0x8fe0 - 0x8fe4162b  dyld 132.1 (???) 
 1C06ECD9-A2D7-BB10-AF50-0F2B598A7DEC /usr/lib/dyld
 
 Model: MacBookPro5,5, BootROM MBP55.00AC.B03, 2 processors, Intel Core 2 Duo, 
 2.53 GHz, 4 GB, SMC 1.47f2
 Graphics: NVIDIA GeForce 9400M, NVIDIA GeForce 9400M, PCI, 256 MB
 Memory Module: global_name
 AirPort: spairport_wireless_card_type_airport_extreme (0x14E4, 0x8D), 
 Broadcom BCM43xx 1.0 (5.10.131.42.4)
 Bluetooth: Version 2.4.5f3, 2 service, 19 devices, 1 incoming serial ports
 Network Service: AirPort, AirPort, en1
 Serial ATA Device: ST9250315ASG, 232.89 GB
 Serial ATA Device: HL-DT-ST DVDRW  GS23N
 USB Device: Internal Memory Card Reader, 0x05ac  (Apple Inc.), 0x8403, 
 0x2650 / 2
 USB Device: Built-in iSight, 0x05ac  (Apple Inc.), 0x8507, 0x2440 / 2
 USB Device: BRCM2046 Hub, 0x0a5c  (Broadcom Corp.), 0x4500, 0x0610 / 2
 USB Device: Bluetooth USB Host Controller, 0x05ac  (Apple Inc.), 0x8213, 
 0x0611 / 4
 USB Device: Apple Internal Keyboard / Trackpad, 0x05ac  (Apple Inc.), 0x0237, 
 0x0460 / 3
 USB Device: IR Receiver, 0x05ac  (Apple Inc.), 0x8242, 0x0450 / 2
 
 8(snip)---8
 
 __
 

Re: [R] R.app installer probs on Snow Leopard

2011-08-03 Thread David Winsemius


Did you install R first? R.app is just a GUI around the actual R code  
that could run without any assistance in a terminal session. Generally  
one installs both R and R.app from the super-bundle. Since you  
provided no details of which .pkg files were chosen we are left  
guessing.


(And this is really supposed to be posted to the MAC-SIG list, anyway.)

--
David.
On Aug 3, 2011, at 12:35 PM, Walter Ludwick wrote:

Have tried to install R.app several times (6, in fact: versions  
2.12, 13  14, both 32 and 64 bit versions), using packages


Names? Links?


freshly downloaded from the official project page,


And that means what? The ATT page?  or the CRAN page?

and failed every time, given exception reports such as the following  
(appended below, the 2 reports arising out of my 1st  6th attempts).


Machine  software version specifics are all contained therein.

What am i missing, i wonder?


We don't know because so many details are still,  missing.


Any clues would be most appreciated -thanx!   /w



(Running R 2.13.1 on OSX 10.5.8)
--

David Winsemius, MD
West Hartford, CT

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


  1   2   >