Re: [R] order function

2013-02-02 Thread nalluri pratap
I agree with Duncan.
 
may be you need this
 
format(output[order(output[,3]),],scientific=T)
 
Pratap

--- On Sat, 2/2/13, Duncan Murdoch murdoch.dun...@gmail.com wrote:


From: Duncan Murdoch murdoch.dun...@gmail.com
Subject: Re: [R] order function
To: Kripa R kripa...@hotmail.com
Cc: r-help@r-project.org
Date: Saturday, 2 February, 2013, 4:19 AM


On 13-02-01 12:15 PM, Kripa R wrote:

 Hi I'm having a simple issue with the order function. When I use the 
 following code my data is not ordered correctly

 output[order(output[,3]),]

 Name    beta                         pval
 881      9.09303277751237     0.000100253350483199
 7402    6.40553461638365     0.00010228641631914
 4879   -8.88509881106217     0.000103251645995887

That's correctly ordered in the pval column.

 However when I export the data and sort it in excel I see the following:
 Name         beta                         pval       pval
 25037           -5.70737             2.48E-07
 34294           -19.6931             1.04E-05
 36002           -12.2478             1.63E-05

That is a different dataset, also correctly ordered in the third column. 
Excel seems to have added a 4th heading for some reason.


 Any suggestions on how I can get this sort to work properly on data in 
 scientifict format?

You need to explain what is wrong before we can fix it.

Duncan Murdoch


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

[[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] Question on plotCI function

2013-02-02 Thread Jim Lemon

On 02/02/2013 02:21 AM, li li wrote:

Thanks so much for the reply, Ista. I used plotrix library.

Here is my example:

xx- seq(0.05, 0.95, by=0.05)
lower- c(-2.896865, -2.728416, -2.642574, -2.587724, -2.548672, -2.518994,
-2.495409, -2.476031, -2.459662, -2.445513, -2.433014, -2.421739, -2.411344,
-2.401536, -2.392040, -2.382571, -2.372786, -2.362198, -2.349891)
upper- c(2.311539, 2.372006, 2.423280, 2.469220, 2.511851, 2.552421,
  2.591797, 2.630657, 2.669579, 2.709135, 2.749928, 2.792670, 2.838268,
  2.887976, 2.943683, 3.008502, 3.088240, 3.195954, 3.373528)

library(plotrix)
plotCI(xx,ui=upper,li=lower,err=y,pch=NA, xlab=, ylab=, ylim=c(-5,
5),  slty=solid,scol=blue, lwd=2)


My question is how can I change the xllim to be c(0,1) which corresponds to
the xx values.

Hanna
2013/2/1 Ista Zahnistaz...@gmail.com


There are many plotCI functions in many different packages... which
one are you referring to? Also please construct a reproducible example
illustrating your problem.

Best,
Ista

On Thu, Jan 31, 2013 at 11:58 PM, li lihannah@gmail.com  wrote:

Hi all,
In my plotCI function, the argument x is chosen to be seq(0.05, 0.95,
by=0.05).
However, when I make the plot, the plot has the x coordinate goes  1:19.
Does anyone know how to make the x coordinate to be (0,0.5, 0.1, ...,
0.95).


Hi Hanna,
You are getting what you request in the example. xx is interpreted as 
the y values and the x values default to the number of y values 
(1:19). Perhaps what you want is something like this:


x-seq(0.05,0.95,by=0.05)
xx-seq(0.05,0.95,by=0.05)
lower-c(-2.896865,-2.728416,-2.642574,-2.587724,-2.548672,-2.518994,
 -2.495409,-2.476031,-2.459662,-2.445513,-2.433014,-2.421739,-2.411344,
 -2.401536, -2.392040, -2.382571, -2.372786, -2.362198, -2.349891)
upper-c(2.311539,2.372006,2.423280,2.469220,2.511851,2.552421,
 2.591797, 2.630657, 2.669579, 2.709135, 2.749928, 2.792670, 2.838268,
 2.887976, 2.943683, 3.008502, 3.088240, 3.195954, 3.373528)
library(plotrix)
plotCI(x,xx,ui=upper,li=lower,err=y,pch=NA,xlab=,ylab=,
 slty=solid,scol=blue,lwd=2)

Jim

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


[R] Mixed Models: Contribution of random variable to final estimate

2013-02-02 Thread Luis Reino
Dear all,

We want to test if the invasiveStatus is predicted by the amount (quant) of 
animals arriving to a country of a certain species (taxonid). We are using lmer 
to perform the model.

The model is:
lmer(invasiveStatus~I(log(quant+1))+I(log(inDegree+1))+(1|taxonid)+(1|country), 
family=binomial,data=td),

where invasiveStatus is a binary variable, quant and inDegree are integer 
variables, and taxonid and country are factor variables.

The fixef output is
  (Intercept)I(log(quant + 1)) I(log(inDegree + 1))
  -15.63382880.31980742.1566502

and the ranef output is, sorted from higher to lower, andshowing only the first 
10 lines,

$taxonid
T16 9.51
T2588.36
T3888.24
T9617.98
T76 7.48
T4707.46
T1087.17
T84 7.15
T2926.91
T1896.65
...
$country
US  3.23
JP  2.45
ES  2.35
IT  2.14
BM  1.63
IL  1.41
SI  1.39
LB  1.06
FR  1.05
VE  0.996
...

Our problem is that the coefficients to the final estimate of invasiveStatus 
are higher for the random variables than the fixed ones. We think this is a 
result of the confound effect between quant, and country and taxonid. In other 
words, the higher the number of animals of a given species(taxonid) arriving to 
given country, the higher the probability of other species to arrive to the 
same country.
Are we formulating the model correctly? Is there a way to avoid that the 
contribution of the random variables is the most contributing part to the final 
estimate?

Thanks,

Luis Reino


[[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] Armadillo error in R extension

2013-02-02 Thread Simon Zehnder
Dear Michael,

during the last days of programming I came across RcppArmadillo (Rcpp) and for 
my kind of work this is indeed pretty interesting. So, I will take a closer 
look today what it is about and how it works. 

As a C++ programmer though, I am still interested why compilation of my package 
fails at this point of code. I hope I get a little more insight on the 
Rcpp-devel list suggested by Dirk! 

Thanks for your comment!

Simon


On Feb 2, 2013, at 12:14 AM, Michael Weylandt michael.weyla...@gmail.com 
wrote:

 Look up the terribly wonderful RcppArmadillo package. 
 
 MW
 
 On Feb 1, 2013, at 8:38 PM, Simon Zehnder szehn...@uni-bonn.de wrote:
 
 Is there anyway with some experience in using armadillo in R C++ extensions?
 
 My problem is the following:
 
 I programmed a function in a header looking like
 
 #include armadillo
 
 inline arma::vec foo(input) {
 
   ... do something
 
   return an arma::vec object 
 }
 
 compiling this via R CMD INSTALL packagename (PKG_CXXFLAGS = 
 -I/folder/of/armadillo and armadillo_bits in my package)
 
 I get the following error 
 
 error: expected initializer before 'foo' 
 
 The exact line and word is where inline arma::vec ends.
 
 Does anyone know what this error could be? 
 
 
 Best
 
 Simon
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Mixed Models: Contribution of random variable to final estimate

2013-02-02 Thread Ben Bolker
Luis Reino luisreino at isa.utl.pt writes:

 
 Dear all,
 
 We want to test if the invasiveStatus is predicted by the amount
 (quant) of animals arriving to a country of a certain species
 (taxonid). We are using lmer to perform the model.

  In general lmer questions belong on r-sig-mixed-mod...@r-project.org,
but I think this
 
 The model is:
 lmer(invasiveStatus~I(log(quant+1))+I(log(inDegree+1))+
  (1|taxonid)+(1|country),
 family=binomial,data=td)

  You don't need I() around those terms -- you only need it to
protect expressions such as x^2 that would be interpreted differently
in the formula context.

 where invasiveStatus is a binary variable, quant and inDegree are
 integer variables, and taxonid and country are factor variables.

 The fixef output is
   (Intercept)I(log(quant + 1)) I(log(inDegree + 1))
   -15.63382880.31980742.1566502
 
 and the ranef output is, sorted from higher to lower, andshowing
  only the first 10 lines,
 
 $taxonid
 T16   9.51
 T258  8.36
 [snip]

 $country
 US3.23
 JP2.45
 ES2.35

[snip]

 Our problem is that the coefficients to the final estimate of
 invasiveStatus are higher for the random variables than the fixed
 ones. We think this is a result of the confound effect between
 quant, and country and taxonid. In other words, the higher the
 number of animals of a given species(taxonid) arriving to given
 country, the higher the probability of other species to arrive to
 the same country.  Are we formulating the model correctly? Is there
 a way to avoid that the contribution of the random variables is the
 most contributing part to the final estimate?  Thanks, Luis Reino

  This might be an issue of parameter scaling.
The idea is that your coefficients measure the effect of
the parameters *per unit*.  Thus the random effects are
measured in log-odds units, while the effects of quant and inDegree
are measured in units of log-odds change **per log-unit change in
the variable**, i.e. multiplying by e is expected to  make 1 log-odds
change in the outcome.  You might try scaling your variables
(see e.g. Schielzeth 2010 Methods in Ecology  Evolution).
(Of course, you can make the fixed effects look as big as you
want by scaling the predictor appropriately ...)

  It worries me a little that your intercept is so small --
suggests that the average fraction invasive when quant=0
and inDegree=0 is 3 x 10^{-7} ...

  Follow-ups to r-sig-mixed-models

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] use name (not values!) of a dataframe inside a funktion

2013-02-02 Thread William Dunlap
Another R-ish way of modifying an object with a function is to use
'replacement functions' (there must be other names, I'm not sure
what the standard is) that let you use syntax like
 someProperty(myData, ...) - newProperty
To do this define a function called `someProperty-` whose last argument
is named 'value' and which returns a modified version of its first argument.
When R sees the above syntax it does the equivalent of
   myData - `someProperty-`(myData, ..., value=newProperty)

E.g., 
 `useLog2Scale-` - function(dataframe, value) {
   if (value) dataframe[] - lapply(dataframe, log2)
   else dataframe[] - lapply(dataframe, function(x)2^x)
   dataframe
}
 d - data.frame(x=1:5, y=1/(1:5))
 useLog2Scale(d) - TRUE
 d
 x y
1 0.00  0.00
2 1.00 -1.00
3 1.584963 -1.584963
4 2.00 -2.00
5 2.321928 -2.321928
 useLog2Scale(d) - FALSE
 d
  x y
1 1 1.000
2 2 0.500
3 3 0.333
4 4 0.250
5 5 0.200

(Usually such a function is used to set a property in the data, such as a 
logScale
flag, that is used or queried later.)


Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
 Behalf
 Of Greg Snow
 Sent: Friday, February 01, 2013 8:54 AM
 To: Winfried Moser
 Cc: r-help
 Subject: Re: [R] use name (not values!) of a dataframe inside a funktion
 
 It is strongly discouraged in R to have functions that change data values
 in the global workspace (or any location other than their local
 environment).
 
 The usual procedure in R is to have your function return a modified version
 of the object and the user then decides what to do with it.  They can
 assign it back to the same original object so that there is still only one
 copy and it has changed (but the user made that decision, not the
 programmer), or they can save it to a different name and not lose the
 original.
 
 If you really want to change the original copy (and there are sometimes
 when the exception to the rule makes sense) then you can either use
 environments (which don't copy on modify) or use macros instead of
 functions.  Given your examples I would look at the macro approach first.
  There is a 'defmacro' function in the 'gtools' package and the reference
 on the help page for 'defmacro' leads to the original R news (now R
 Journal) article describing the use of macros in R (definitely read this if
 you are considering this approach).
 
 
 On Thu, Jan 31, 2013 at 7:34 AM, Winfried Moser 
 winfried.mo...@gmail.comwrote:
 
  Dear Listers,
 
  can anyone help me, please.
 
  Since several days i try to figure out, how to assign values, vectors,
  functions etc to variables with dynamically generated names inside of
  functions.
  Sometimes I succeed, but the success is rather arbitrary, it seems. up to
  now i don't fully understand, why things like get, assign, - etc do
  sometimes work, and sometimes not.
 
  here's one of my daily examples, i am stuck with: Example 1 does work, but
  example 2 doesn't?
  How kann i tell R, that i want it to expand the string dfb to dfb[,2]
  inside the function.
  In the end i want the function to change the second variable of the
  dataframe dfb permanently to factor (not just inside the function).
 
  Thanks in advance!
 
  Winfried
 
 
  Example 1:
  dfa - data.frame(a=c(1:4),b=c(1:4))
  dfa[,2] - factor(dfa[,2])
  is.factor(dfa[,2])
  TRUE
 
  Example 2:
  dfb - data.frame(a=c(1:4),b=c(1:4))
  f.fact - function(x) {x[,2] - factor(x[,2])}
  f.fact(dfb)
  is.factor(dfb[,2])
  FALSE
 
 
  PS: I tried a whole lot of other things like, ...
  I really don't know where to keep on searching.
 
 
  dfb - data.frame(a=c(1,2,3,4),b=c(1,2,3,4))
  f.fact - function(x) {get(x)[,2] - factor(get(x)[,2])}
  f.fact(dfb)
  is.factor(dfb[,2])
   Object 'x' nicht gefunden
 
  dfb - data.frame(a=c(1,2,3,4),b=c(1,2,3,4))
  f.fact - function(x) {get(x[,2]) - factor(x[,2])}
  f.fact(dfb)
  is.factor(dfb[,2])
   Object 'x' nicht gefunden
 
  dfb - data.frame(a=c(1,2,3,4),b=c(1,2,3,4))
  f.fact - function(x) {get(x)[,2] - factor(x[,2])}
  f.fact(dfb)
  is.factor(dfb[,2])
   Object 'x' nicht gefunden
 
  dfb - data.frame(a=c(1,2,3,4),b=c(1,2,3,4))
  f.fact - function(x) {assign(x[,2], factor(x[,2]))}
  f.fact(dfb)
  is.factor(dfb[,2])
   Ungültiges erstes Argument
 
  dfb - data.frame(a=c(1,2,3,4),b=c(1,2,3,4))
  f.fact - function(x) {quote(x)[,2], factor(x[,2])}
  f.fact(dfb)
  is.factor(dfb[,2])
   Unerwartetes ','
 
  dfb - data.frame(a=c(1,2,3,4),b=c(1,2,3,4))
  f.fact - function(x) {
  name - paste0(quote(x),[,2])
   assign(name, factor(x[,2]))}
  f.fact(dfb)
  is.factor(dfb[,2])
   FALSE
 
  dfb - data.frame(a=c(1,2,3,4),b=c(1,2,3,4))
  f.fact - function(x) {
  name - paste0(get(x),[,2])
  assign(name, factor(x[,2]))}
  f.fact(dfb)
  is.factor(dfb[,2])
   Falsche Anzahl von Dimensionen
 
  dfb - data.frame(a=c(1,2,3,4),b=c(1,2,3,4))
  f.fact - 

Re: [R] Loading a list into the environment

2013-02-02 Thread Jonathan Greenberg
Thanks all!  list2env was exactly what I was looking for.  As an FYI (and
please correct me if I'm wrong), if you want to load a list into the
current environment, use:

myvariables - list(a=1:10,b=20)
loadenv - list2env(myvariables ,envir=environment())
a
b

--j


On Fri, Feb 1, 2013 at 5:49 PM, Rui Barradas ruipbarra...@sapo.pt wrote:

 Hello,

 Something like this?

 myfun - function(x, envir = .GlobalEnv){
 nm - names(x)
 for(i in seq_along(nm))
 assign(nm[i], x[[i]], envir)
 }

 myvariables - list(a=1:10,b=20)

 myfun(myvariables)
 a
 b


 Hope this helps,

 Rui Barradas

 Em 01-02-2013 22:24, Jonathan Greenberg escreveu:

  R-helpers:

 Say I have a list:

 myvariables - list(a=1:10,b=20)

 Is there a way to load the list components into the environment as
 variables based on the component names?  i.e. by applying this theoretical
 function to myvariables I would have the variables a and b loaded into the
 environment without having to explicitly define them.

 --j




-- 
Jonathan A. Greenberg, PhD
Assistant Professor
Global Environmental Analysis and Remote Sensing (GEARS) Laboratory
Department of Geography and Geographic Information Science
University of Illinois at Urbana-Champaign
607 South Mathews Avenue, MC 150
Urbana, IL 61801
Phone: 217-300-1924
http://www.geog.illinois.edu/~jgrn/
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007

[[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] vectorisation

2013-02-02 Thread Brett Robinson
Hi
I'm trying to set up a simulation problem without resorting to (m)any loops. I 
want to set entries in a data frame of zeros ('starts' in the code below) to 1 
at certain points and the points have been randomly generated and stored in a 
separate data.frame ('sl'), which has the same number of columns.

An example of the procedure is as follows:
ml - data.frame(matrix(sample(1:50,80, replace=TRUE),20,4))
mm - apply(ml, 2, cumsum)
starts- data.frame(matrix(0,600,4))

I can achieve the result I want with a loop:
for (i in 1:4){
lstarts[,i][mm[,i]] -1
}

But as I want to use a large number of columns I would like to do away with the 
loop

Can anyone suggest how this might be done?

Thanks in advance

Brett Robinson

__
This email has been scanned by the Symantec Email Security.cloud service.
For more information please visit http://www.symanteccloud.com
__
[[alternative HTML version deleted]]

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


[R] Reading .rdata files

2013-02-02 Thread Andrew DeCarlo
Hello,

I am a developer working on extracting information from .rdata files using
java. I have been looking through the documentation a lot trying to figure
out how to read these files, but am a bit stuck at the moment.

I have generated two .RDATA files from StatTransfer and have noticed that
they both begin in similar ways.

*File 1*

RDA2
A
2
131585
66560
1026
1
4105
10
.Traceback
254
1026
1
4105
*8  - these are the only difference*
SPSSTest -FileName
787

*
*
*File 2*

RDA2
A
2
131585
66560
1026
1
4105
10
.Traceback
254
1026
1
4105
*9 **- these are the only difference*
statatest -FileName
787

Because of the remarkable similarity between these two beginning segments I
assume that this is some sort of header. After examining the R Internals
Manual (Section 1.8) I was able to discover that the first line describes
the file RDA2 means its an ascii data file opposed to XDR or word order
binary and the 2 indicates that it is version 2 of R. After this first line
there are supposed to be 3 integers that also describe the version.

However this is pretty much where section 1.8 ends and even though I
searched through the rest of the document (and a lot of Google) I couldn't
find anything about what the rest of the bytes/numbers indicate. I may just
be missing something (I have seen a lot of people reference the Internals
Manual) but is there any documentation on the different data files (RDA,
RDX, RDB) and how they are organized.

Any info would be greatly appreciated. Thanks a bunch!

-Andrew

[[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] Choice of text for intermediate level R programming course

2013-02-02 Thread Harris Butler
I recommend The Art of R Programming: A Tour of Statistical Software
Design, by Norman Matloff, No Starch Press.  It is only 40 bucks so
your students will appreciate that.  As far as content goes, it covers
just about everything, you can view a sample chapter, detailed ToC,
and index at the website: http://nostarch.com/artofr.htm.  The only
drawback to using it as a textbook is that it doesn't contain any
excercises, so you would have to create your own.  I think that the no
exercises drawback is an acceptable price to pay considering the
quality of the book.

Here's some anecdotal evidence for you:  I used R for my M.S. thesis
and at first I spent my time searching on the internet for how to do
things in R.  When I found this book, I took some time off from my
thesis work and chugged through the book full time- I think it would
take a full semester in a 3 hour course.  After getting through the
book I found that I wasn't worrying about R anymore and I could
concentrate on the intellectual part of my work.  I won't say that
content of my thesis was that great but the code worked and I managed
to finish on time.

--

Cheers,

Harris Butler


On Fri, Feb 1, 2013 at 5:43 PM, William Grove grove...@umn.edu wrote:

 The Subject line mostly says it.  I'm designing it as a semester-long, 3
 hours per week, course
 that takes in students who got the basics of R in stats classes, but don't
 really know how to
 program in it.  Translation:  if their own examples don't look enough like
 examples from
 previous work, they're stumped.

 Does anybody have a text for an intermediate R course (but not too
 highbrow, no total guide
 to object oriented programming, and class s3 vs. s4 objects), they would
 recommend.  I
 read 24 books some ielementary some advance not many intermediate, and I
 have two I
 like but for quite difference reasons.  I won't name them so as not to
 prejudice anybody.

 It needs to be English language and I greatly prefer a good index like
 \LaTeX\ produces
 by the makeindex() prograrm.

 Regards,
 William Grove

 --
 William M. Grove, Ph.D.
 Psychology Department
 University of Minnesota

 My public encryption key.is:

 -BEGIN PGP PUBLIC KEY BLOCK-
 Version: GnuPG v1.2.2 (MingW32)
 mQGiBE+tS9ERBACCTYW1uclqHbUvBvP92rUN8zOlMWe2zr3NfRp6ELNyYa60H5PK
 +Xx/vbHGWF0MXhGLLVFMiRNBRomJ4S30Ify4exTg6vWpPrVsmDvyKLmYilWSOuw1
 0yoimDdr4DphGQSKqVD/O/tLUhO1wyEKJI89qtJmFG4usnn7f/Bvt4cRZwCgq76W
 LRhGATk0E2GYl0n+2UeFU+8D/ipLpFYNJEkz3y492/9orimBsxsAdnXmK5bpOBG5
 pQaoFuvvPMtkUYhVNYUqMyjJniM3F6mnv7OX52sHHcYn89ScO9S+WtWAYsekwTTE
 xb1wvwB9u7PoGDC46tihXhTl533oUcMFGMwlVKvFZ4zpWYo5W3i0DmOAtjcMPzl2
 4wcfA/0fgbUe2JIkPTf6MFMQTFwpNhCGeDvTfbcC5YCCcAXWcnUT/GKFsvRT0Wje
 i/A4PMopJkfLRreM1GSZ6JY0cOL3U071M6YhVmldrL4X74OUAjfdo8mYosxe/qTe
 Ji0s6jg/oiXgY/hHLZzDE+AtQ6LRi0/1tpms2Qw9/7pXs8HHErQ0V2lsbGlhbSBN
 LiBHcm92ZSAoR1BHIFB1YmxpYyBLZXkpIDxncm92ZTAwMUB1bW4uZWR1PohbBBMR
 AgAbBQJPrUvRBgsJCAcDAgMVAgMDFgIBAh4BAheAAAoJEG2MPb65SVkFnNcAnRCi
 URO4Oy9dk5Kb6j/1yN1iElTJAKCnlwfwOt0J8jf2nJ78sNkiZNjM6bkCDQRPrUvT
 EAgAg52fj9/7k6BuJgmY+ynKm4rwWaRW6VjrnS5VI+luTmEkQi/w9Vz6dOmCJWlz
 VLsm7mEW0tvB9VwZbkrttoWnJOmqzRWNJxlRlj78jRq6yN16JZNhbPGDSbjL/+JV
 LzlhMetUpuTYPziuatSr7C2RxYYRd5pabgd3G/XowqSBtyD3jrViJ8CqcZlMQGfJ
 BRoiyBDlVEOO+aJ/KGLinfbhyz06tR50BpXFFlxBN1m+DInRLF6zRkjZUO+OyFO6
 Acy0SM4htfetEI0H0+X1w/Cw8e2Ew48Wwsve+USRr+OLXqwkgBP/jTNRko6cUI5m
 LiXjkSXYdR0JonTzgUSh66TDBwADBQf/TR/xC5P5Vs6X5OPu3iHsKRp/dGVpL33D
 KBH2Ofw3ps48kQ65la/uMW+fZDvwZJukTIJL4dq5OGjxnwznj3hkZJZWLknRFDx+
 ByoumskJXPENphqlnpDV+W2stNwoSY3f5gO9xTQSGeoqqLB6+Xwe4CDZo/wOuhMA
 nCXQeIJxiH3GsCnxkZY9e3rw9HdcE/6NbvKGZ/OOLMdorASG9eSuyQZDgKN7jXZ3
 2GPbppaRjzUWuRGau1RBv9V0QMY5C0Z1c51njCHuR0cgcItad69IcgaujlC2kouu
 C/MW/VOA5rfGhvBBI7nr26MjhxwHUYWQw6i/KgzYwJ+X43cEBCoITIhGBBgRAgAG
 BQJPrUvTAAoJEG2MPb65SVkFDLoAn36dv6dBZyIrTD+lF3y1lXO/R1OHAJ0Sn0bi
 0TdH/wwxUEFeq5eCMfoZTg==
 =91Ch
 -END PGP PUBLIC KEY BLOCK-

 [[alternative HTML version deleted]]

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

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


[R] VAR simulation help

2013-02-02 Thread londonphd
http://r.789695.n4.nabble.com/file/n4657370/untitled.jpg 

Hi Everyone,

I am a new comer to R circle. I am trying to simulate a VAR estimation. The
problem is given above in the image. Assume that the errors are iid and
normally distributed.  Here the number of observations x1=x2=64. 

I've written the code below. Not sure if it is correct.

pi=matrix(c(0.9,0.1,-0.1,0.7),nrow=2,ncol=2)

# errors
error1=rnorm(64,mean=0,sd=1)
error2=rnorm(64,mean=0,sd=1)

#variables x1 and x2
x1=sample(64) 
x2=sample(64) 

#VAR simulation#

obs = 64
set.seed(123)
E=matrix(c(error1,error2),nrow=2,ncol=64)
pi=matrix(c(0.9,0.1,-0.1,0.7),nrow=2,ncol=2)
X=matrix(c(x1,x2),nrow=2,ncol=64)
for (i in 2:obs) {
  X[,i] = pi%*%X[,i-1]+E[,i]
}

I would appreciate if you could comment whether I've correctly simulated it
or not.
Thank you,
lphd



--
View this message in context: 
http://r.789695.n4.nabble.com/VAR-simulation-help-tp4657370.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] Change default order of colors line types

2013-02-02 Thread Harris Butler
You can change colors by manually creating your own palette.  You can
start with the Set1 color palette from RColorBrewer, then move the
values.  You then use this new palette in your plot:

library(RColorBrewer)

numGroups -5 #here is where you define the size of your color palette
customPalette - brewer.pal(numGroups, Set1) #create your color palette
customPalette - append(customPalette, customPalette[1], after=4)
#insert the first color into the correct place on the list
customPalette - customPalette[2:len(customPalette)] #drop the first color

To use this in your plot, instead of using
scale_color_brewer(palette=Set1), you would use
scale_color_manual(values=customPalette).

Linetype will need to be handled a slightly different way.  Remove
linetype=method from your initial qplot command, and then add a manual
linetype scale that would look something like this:

+ scale_linetype_manual(breaks=c(m1, m2, m3, m4, m5),
values=c(2,3,4,1,5))

where m1, m2, etc are the method names that you are grouping
everything by.  You should keep your geom_line() command the same.
Note that the values in scale_linetype_manual() are rearranged to put
1 in the 4th position.  I'm sure there is a more elegant way to do it,
but this way should work as long as you aren't creating lots of plots
with changing method names.


--
Cheers,

Harris Butler


On Fri, Feb 1, 2013 at 1:41 PM, Soyeon Kim soyeon.sophia@gmail.com wrote:
 Dear R users,

 I'd like to change the default order of colors  line types.
 Especially I am using ggplot2 and using color Set1.
 In Set1, the default color order is red, blue, green, violet,.. ect.
 However, I want to put red in fourth (not first).
 Likewise, I want to change the order of default linetype. I want to
 put solid line in fourth.
 How can I do thses?

 R code to draw the graph is
 qplot(variable, power, data = m.powers, colour = method,
 linetype=method,  ylab = Power) + geom_line(aes(group = method),
 ylim = c(0,1)) +
   scale_colour_brewer(palette=Set1)

 Thank you,

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] create and save a simulated dataset

2013-02-02 Thread Giovanna Ottaviani
Hello,
I am trying to learn how to create a simulated dataset of a forest stand:
I must simulate 10 stands, for each of the stands I have been creating a random 
number of trees. For each tree I should create a random diameter.
The problem I have is that I cannot use a matrix because the length of the 
three items is different. I was trying with list but I have no clue on how to 
make a dataset out of them... tried merge
Anyone has some clever suggestion?
THANK you !!
Giovanna


Giovanna Ottaviani Aalmo
Stipendiat/Ph.D. Student
---
Norsk institutt for skog og landskap
Pb 115, NO-1431 Ås
T (+47) 64 94 9094
M(+47) 980 30 422
F(+47) 64 94  90 80
---
www.skogoglandskap.nohttp://www.skogoglandskap.no/
---


[[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] Reading .rdata files

2013-02-02 Thread Duncan Murdoch

On 13-02-02 2:23 PM, Andrew DeCarlo wrote:

Hello,

I am a developer working on extracting information from .rdata files using
java. I have been looking through the documentation a lot trying to figure
out how to read these files, but am a bit stuck at the moment.

I have generated two .RDATA files from StatTransfer and have noticed that
they both begin in similar ways.

*File 1*

RDA2
A
2
131585
66560
1026
1
4105
10
.Traceback
254
1026
1
4105
*8  - these are the only difference*
SPSSTest -FileName
787

*
*
*File 2*

RDA2
A
2
131585
66560
1026
1
4105
10
.Traceback
254
1026
1
4105
*9 **- these are the only difference*
statatest -FileName
787

Because of the remarkable similarity between these two beginning segments I
assume that this is some sort of header. After examining the R Internals
Manual (Section 1.8) I was able to discover that the first line describes
the file RDA2 means its an ascii data file opposed to XDR or word order
binary and the 2 indicates that it is version 2 of R. After this first line
there are supposed to be 3 integers that also describe the version.

However this is pretty much where section 1.8 ends and even though I
searched through the rest of the document (and a lot of Google) I couldn't
find anything about what the rest of the bytes/numbers indicate. I may just
be missing something (I have seen a lot of people reference the Internals
Manual) but is there any documentation on the different data files (RDA,
RDX, RDB) and how they are organized.

Any info would be greatly appreciated. Thanks a bunch!


You could try the source code:  the files are written by the code in

https://svn.r-project.org/R/trunk/src/main/serialize.c

The comments in there describe it, and the code does what it does.

Duncan Murdoch

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


Re: [R] Why replacement has length zero? And How can I fix it?

2013-02-02 Thread soon yi
Hi 

for the loop section runif needs curved brackets

Try

IAP -NA
for (i in 1:Sample.Size){ 
if (DataSet$SES[i]0)   { 
IAP[i] -  ifelse(runif(1)0.75, 1, 0) # High SES, higher 
chance to be in
Treatment # 
} 
else  { 
IAP[i] - ifelse(runif(1)=0.25, 1, 0) # Low SES, lower chance 
to be in
Treatment # 
 } 
} # End loop # 
IAP




IAP 
zjiaqi19880219 wrote
 Hi, all,
 
 I am working on a project to run a simulation. I am now working on the
 main body of the simulation body, I generate the data and all work well
 before I identify a variable IAP, there is always an error message as
 replacement has length zero, and I do not know how to fix it. Can anyone
 help?
 
 Here is the code:
 
 library (mvtnorm)
 
 options(digits=2)
 
 # Set variable name #
 namelist1 - c(Age, Gender, SES, ISS, IQTe, PreTe)
 
 # Generate Data #
 Sample.Size - 10 # Variable Sample Size #
 CorMat - matrix(c(1.0 ,0.0 ,0.0 , 0.5, 0.2, 0.5,
   0.0, 1.0 ,0.0, 0.0, 0.0, 0.0,
   0.0 ,0.0 ,1.0, 0.5, 0.4, 0.5,
   0.5, 0.0, 0.5, 1.0, 0.4, 0.7,
   0.2, 0.0, 0.4, 0.4, 1.0, 0.9,
   0.5, 0.0, 0.5, 0.7, 0.9, 1.0),ncol=6) # 
 Correlation Matrix #
 
 DataSet - rmvnorm(Sample.Size, mean=c(0,0,0,0,0,0), sigma=CorMat) # Draw
 Sample.Size covariate set all mean 0 #
 DataSet - as.data.frame(DataSet)
 names(DataSet) - namelist1
 DataSet
 
 # For Treatment IAP #
 IAP - matrix(0, nrow=Sample.Size)
 for (i in 1:Sample.Size){
   IAP[i] - if (DataSet$SES0)
   {
   ifelse(runif[1]0.75, 1, 0) # High SES, higher chance to be in 
 Treatment
 #
   }
   IAP[i] - if (DataSet$SES=0)
   {
   ifelse(runif[1]=0.25, 1, 0) # Low SES, lower chance to be in 
 Treatment
 #
   }
 } # End loop #
 IAP
 
 Error in IAP[i] - if (DataSet$SES  0) { : replacement has length zero
 In addition: Warning message:
 In if (DataSet$SES  0) { :
   the condition has length  1 and only the first element will be used
 
 Thanks!





--
View this message in context: 
http://r.789695.n4.nabble.com/Why-replacement-has-length-zero-And-How-can-I-fix-it-tp4657373p4657380.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 and save a simulated dataset

2013-02-02 Thread Bert Gunter
Is this a homework problem? (We don't do homework here).

What is missing from your query is any specification of what you mean
by random, which, by itself, is meaningless. It also might be the
case that the trees within each stand are correlated in some way --
perhaps they should to be more similar in diameter within a stand than
between.  So I think your first task is to think more carefully about
**what** you want to do and how to specify it precisely and completely
before worrying about  **how** to do it..


Cheers,
Bert

On Sat, Feb 2, 2013 at 12:10 PM, Giovanna Ottaviani
g...@skogoglandskap.no wrote:
 Hello,
 I am trying to learn how to create a simulated dataset of a forest stand:
 I must simulate 10 stands, for each of the stands I have been creating a 
 random number of trees. For each tree I should create a random diameter.
 The problem I have is that I cannot use a matrix because the length of the 
 three items is different. I was trying with list but I have no clue on how to 
 make a dataset out of them... tried merge
 Anyone has some clever suggestion?
 THANK you !!
 Giovanna


 Giovanna Ottaviani Aalmo
 Stipendiat/Ph.D. Student
 ---
 Norsk institutt for skog og landskap
 Pb 115, NO-1431 Ås
 T (+47) 64 94 9094
 M(+47) 980 30 422
 F(+47) 64 94 90 80
 ---
 www.skogoglandskap.nohttp://www.skogoglandskap.no/
 ---


 [[alternative HTML version deleted]]


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




-- 

Bert Gunter
Genentech Nonclinical Biostatistics

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

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


Re: [R] create and save a simulated dataset

2013-02-02 Thread Rui Barradas

Hello,

Once you formulate the problem properly, it's not hard to solve it in R.

Bert's questions should be answered before continuing. I'll make two 
assumptions, not present in your post.
All diameters are assumed independent and to follow the same uniform 
distribution. (iid scenario; the two assumptions you have to decide about.)


With these in mind, you can get some inspiration from the following 
code. It produces 10 vectors of a random numbers of trees of random 
diameters.



min.diam - 1  # trees' diameters
max.diam - 2  #
max.trees - 10  # trees per stand
lapply(1:10, function(i) runif(sample(max.trees, 1), min.diam, max.diam))


Hope this helps,

Rui Barradas

Em 02-02-2013 20:10, Giovanna Ottaviani escreveu:

Hello,
I am trying to learn how to create a simulated dataset of a forest stand:
I must simulate 10 stands, for each of the stands I have been creating a random 
number of trees. For each tree I should create a random diameter.
The problem I have is that I cannot use a matrix because the length of the three items is 
different. I was trying with list but I have no clue on how to make a dataset out of 
them... tried merge
Anyone has some clever suggestion?
THANK you !!
Giovanna


Giovanna Ottaviani Aalmo
Stipendiat/Ph.D. Student
---
Norsk institutt for skog og landskap
Pb 115, NO-1431 Ås
T (+47) 64 94 9094
M(+47) 980 30 422
F(+47) 64 94  90 80
---
www.skogoglandskap.nohttp://www.skogoglandskap.no/
---


[[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] Why replacement has length zero? And How can I fix it?

2013-02-02 Thread Dennis Murphy
Hi:

No offense, but this is code is inefficient on several levels.
Firstly, a loop is unnecessary (see below); secondly,  ifelse() is a
vectorized function and you're attempting to apply it to each row of
DataSet. Try this instead, given

 dput(DataSet)
structure(list(Age = c(-0.552450789929175, -2.06988485889524,
-1.1290497440272, -0.268777167923272, -0.012748181465016, 0.554761979685086,
0.179401201802416, 0.0973216900180107, -0.914782595075178, -1.53708818506571
), Gender = c(-0.0705367578252014, 0.969426004829301, 0.0556317051882303,
1.33716753655214, -0.638382962845772, 0.480939398350137, -0.755053441639217,
1.25393329162734, 1.45933385954704, 0.672871276697159), SES =
c(-1.88102131807556,
0.529181612783923, 0.271835979074789, -0.656415898217512, -0.517622943602359,
0.639094817790355, -1.08205962796926, -0.193116856300625, 0.707374091321319,
1.98180909069287), ISS = c(-1.74208565286036, -1.235721877648,
0.459828219284939, -0.87781916182417, -0.429262433047679, 0.379335629940134,
0.949088546564315, 0.689758637278236, -1.14832161185134, 1.40363651773545
), IQTe = c(-0.266523341317252, -0.32477349599139, -0.75723700635683,
0.74556355929622, -0.238794158234391, 0.0906173696194765, 0.331200954821995,
-0.373009866084321, 0.417237160703897, 0.755603172535694), PreTe =
c(-0.743400287678305,
-1.1501727014007, -0.668278397501659, -0.0766957410591086, -0.232360222985187,
0.320050787942651, 0.474114337341715, -0.0181639478062117, -0.0905594374421625,
0.517614989060291)), .Names = c(Age, Gender, SES, ISS,
IQTe, PreTe), row.names = c(NA, -10L), class = data.frame)

u - runif(10)
 u
 [1] 0.72 0.57 0.71 0.64 0.38 0.53 0.14 0.14 0.82 0.12

# Remember two things:
#  (i) ifelse() is a vectorized function;
#  (ii) logical statements return either TRUE (1) or FALSE (0).
#  As a result,

# less efficient:
IAP0 - ifelse(DataSet$SES  0, ifelse(u  0.75, 1, 0),
 ifelse(u = 0.25, 1, 0))
# more efficient:
IAP1 - ifelse(DataSet$SES  0, u  0.75, u = 0.25) * 1
IAP1
 [1] 0 0 0 0 0 0 1 1 1 0
 identical(IAP0, IAP1)
[1] TRUE

# Verification:
cbind(DataSet$SES, u, IAP1)

This result conforms to what one would expect with u as the realized
uniform random vector. Moreover, the code is transparent: if SES  0,
then apply the test u  0.75, else apply the test u = 0.25). The
post-multiplication by 1 ensures that the result is numeric rather
than logical.

Dennis


On Sat, Feb 2, 2013 at 12:57 PM, soon yi soon...@ymail.com wrote:
 Hi

 for the loop section runif needs curved brackets

 Try

 IAP -NA
 for (i in 1:Sample.Size){
 if (DataSet$SES[i]0)   {
 IAP[i] -  ifelse(runif(1)0.75, 1, 0) # High SES, higher 
 chance to be in
 Treatment #
 }
 else  {
 IAP[i] - ifelse(runif(1)=0.25, 1, 0) # Low SES, lower 
 chance to be in
 Treatment #
  }
 } # End loop #
 IAP




 IAP
 zjiaqi19880219 wrote
 Hi, all,

 I am working on a project to run a simulation. I am now working on the
 main body of the simulation body, I generate the data and all work well
 before I identify a variable IAP, there is always an error message as
 replacement has length zero, and I do not know how to fix it. Can anyone
 help?

 Here is the code:

 library (mvtnorm)

 options(digits=2)

 # Set variable name #
 namelist1 - c(Age, Gender, SES, ISS, IQTe, PreTe)

 # Generate Data #
 Sample.Size - 10 # Variable Sample Size #
 CorMat - matrix(c(1.0 ,0.0 ,0.0 , 0.5, 0.2, 0.5,
   0.0, 1.0 ,0.0, 0.0, 0.0, 0.0,
   0.0 ,0.0 ,1.0, 0.5, 0.4, 0.5,
   0.5, 0.0, 0.5, 1.0, 0.4, 0.7,
   0.2, 0.0, 0.4, 0.4, 1.0, 0.9,
   0.5, 0.0, 0.5, 0.7, 0.9, 1.0),ncol=6) 
 # Correlation Matrix #

 DataSet - rmvnorm(Sample.Size, mean=c(0,0,0,0,0,0), sigma=CorMat) # Draw
 Sample.Size covariate set all mean 0 #
 DataSet - as.data.frame(DataSet)
 names(DataSet) - namelist1
 DataSet

 # For Treatment IAP #
 IAP - matrix(0, nrow=Sample.Size)
 for (i in 1:Sample.Size){
   IAP[i] - if (DataSet$SES0)
   {
   ifelse(runif[1]0.75, 1, 0) # High SES, higher chance to be in 
 Treatment
 #
   }
   IAP[i] - if (DataSet$SES=0)
   {
   ifelse(runif[1]=0.25, 1, 0) # Low SES, lower chance to be in 
 Treatment
 #
   }
 } # End loop #
 IAP

 Error in IAP[i] - if (DataSet$SES  0) { : replacement has length zero
 In addition: Warning message:
 In if (DataSet$SES  0) { :
   the condition has length  1 and only the first element will be used

 Thanks!





 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Why-replacement-has-length-zero-And-How-can-I-fix-it-tp4657373p4657380.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 

Re: [R] vectorisation

2013-02-02 Thread arun
Hi,

Not sure this helps:

ml - data.frame(matrix(sample(1:50,80, replace=TRUE),20,4))
mm - apply(ml, 2, cumsum)
starts- data.frame(matrix(0,600,4))
starts1- data.frame(matrix(0,600,4))
for (i in 1:4){
starts1[,i][mm[,i]] -1
}

starts2-as.data.frame(do.call(cbind,lapply(1:4,function(i) 
{starts[,i][mm[,i]]-1;starts[,i]})))
colnames(starts2)- colnames(starts1)
identical(starts1,starts2)
#[1] TRUE

#loop should be fast compared to lapply
ml - data.frame(matrix(sample(1:1e4,1e3, replace=TRUE),100,4))
mm - apply(ml, 2, cumsum)
starts- data.frame(matrix(0,1e6,4))
starts1- data.frame(matrix(0,1e6,4))
system.time({for (i in 1:4){
starts1[,i][mm[,i]] -1
}})
 #user  system elapsed 
  # 0.63    0.30    0.92 
system.time(starts2-as.data.frame(do.call(cbind,lapply(1:4,function(i) 
{starts[,i][mm[,i]]-1;starts[,i]}

# user  system elapsed 
 #  0.74    0.26    1.03 

colnames(starts2)- colnames(starts1)
identical(starts1,starts2)
#[1] TRUE
A.K.



- Original Message -
From: Brett Robinson brett.robin...@7dials.com
To: r-help@r-project.org r-help@r-project.org
Cc: 
Sent: Saturday, February 2, 2013 11:38 AM
Subject: [R] vectorisation

Hi
I'm trying to set up a simulation problem without resorting to (m)any loops. I 
want to set entries in a data frame of zeros ('starts' in the code below) to 1 
at certain points and the points have been randomly generated and stored in a 
separate data.frame ('sl'), which has the same number of columns.

An example of the procedure is as follows:
ml - data.frame(matrix(sample(1:50,80, replace=TRUE),20,4))
mm - apply(ml, 2, cumsum)
starts- data.frame(matrix(0,600,4))

I can achieve the result I want with a loop:
for (i in 1:4){
lstarts[,i][mm[,i]] -1
}

But as I want to use a large number of columns I would like to do away with the 
loop

Can anyone suggest how this might be done?

Thanks in advance

Brett Robinson

__
This email has been scanned by the Symantec Email Security.cloud service.
For more information please visit http://www.symanteccloud.com
__
    [[alternative HTML version deleted]]

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


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] vectorisation

2013-02-02 Thread Rui Barradas

Hello,

Try the following.

set.seed(4315)
ml - data.frame(matrix(sample(1:50,80, replace=TRUE),20,4))
mm - apply(ml, 2, cumsum)
s2 - starts - data.frame(matrix(0,600,4))

for (i in 1:4){
starts[,i][mm[,i]] - 1
}

s2[] - lapply(seq_len(ncol(mm)), function(i) {s2[,i][mm[,i]] - 1; s2[,i]})

identical(s2, starts) # TRUE


Note that lapply is a loop in disguise.

Hope this helps,

Rui Barradas

Em 02-02-2013 16:38, Brett Robinson escreveu:

Hi
I'm trying to set up a simulation problem without resorting to (m)any loops. I 
want to set entries in a data frame of zeros ('starts' in the code below) to 1 
at certain points and the points have been randomly generated and stored in a 
separate data.frame ('sl'), which has the same number of columns.

An example of the procedure is as follows:
ml - data.frame(matrix(sample(1:50,80, replace=TRUE),20,4))
mm - apply(ml, 2, cumsum)
starts- data.frame(matrix(0,600,4))

I can achieve the result I want with a loop:
for (i in 1:4){
lstarts[,i][mm[,i]] -1
}

But as I want to use a large number of columns I would like to do away with the 
loop

Can anyone suggest how this might be done?

Thanks in advance

Brett Robinson

__
This email has been scanned by the Symantec Email Security.cloud service.
For more information please visit http://www.symanteccloud.com
__
[[alternative HTML version deleted]]

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



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Filter according to the latest data

2013-02-02 Thread Gabor Grothendieck
On Fri, Feb 1, 2013 at 8:05 AM, nalluri pratap pratap_s...@yahoo.co.in wrote:
 library(sqldf)


 sqldf(select *
 from k1
 group by No
 having max(Date))


HAVING is only used to select groups and only works by chance in this
example but if the data were to change then it would likely not work.

Try this instead.  It makes use of an sqlite-specific feature that
guarantees that when MAX is used in a GROUP BY that the other columns
will be from the same row:

 sqldf(select ID, No, Change, max(Date) Date from k1 group by No)
  ID  NoChange   Date
1  D 111 final 2013-01-12
2  C 123 bug fixed 2013-01-17


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


[R] Fortan to R

2013-02-02 Thread eliza botto

Dear UseRs,
How can i connect my FTN95 fortran compiler with R in window 7?Thanks in 
Advance,
Elisa 
[[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] Nested loop and output help

2013-02-02 Thread staysafe23
Dear R help moderator,

My name is Thomas and I am new here. I am wondering if my post violated
some of the rules of posting here. If so can you please let me know what I
have done so that I can repost? I reread the posting guidelines and don't
see anything that I violate. I have been reading a great deal online but
just can figure out how to run the loop correctly.

Thank you kindly,

Tom
On Feb 1, 2013 2:12 PM, staysafe23 staysaf...@gmail.com wrote:

 Thank you very much Petr,

 I believe I have fixed my inquiry to not use floating points in my cycle
 as you pointed out and to use the list structure to keep my results. I am
 still at a loss as to how to run the multiple loops. I have tried quite a
 few different strategies but my failure seems to illustrate that my
 understanding of how the loops will run is nonexistent.

 I would like to simultaneously let the following 4 things vary:

 z1 - rnorm(ss,mean=400, sd=70) and z2 - rnorm(ss,mean=450, sd=90) by ss
 - seq(5,9,by=1) which yields 5 6 7 8 9

 r - cc by cc - seq(-0.5,0.5, by=0.25) which yields -0.50 -0.25 0.00 0.25
 0.50

 dev1 - oo1 by oo1 - seq(-10,10, by=5) which yields -10 -5 0 5 10

 dev2 - oo2 by oo2 - seq(0,20, by=5) which yields 0 5 10 15 20

 I tried to run the loops that would vary each of these above conditions
 with the looped code attached below and failed very badly.

 Thank you Petr and all,

 Best,

 Thomas

 ###SINGLE RUN
 CODE

 lll - vector(mode = list, length = 10)

 names(lll) - c(mat1, mat2, mat3, mat4, cut1, cut2, out3a,
 out3b, out4a, out4b)

 z1 - rnorm(20,mean=400, sd=70)

 z2 - rnorm(20,mean=450, sd=90)

 cor - runif(1,min=0.4, max=0.6)

 X - z1

 Y = cor*z1+(1-cor)*z2

 lll[[mat1]] - cbind(X,Y)

 dev1 - sample(-40:40, 1, replace=T)

 lll[[cut1]] - mean(X) + dev1

 dev2 - sample(12:54, 1, replace=T)

 lll[[cut2]] - mean(X) + dev1 + dev2

 X2 - X-lll[[cut1]]

 Y2 - Y-lll[[cut2]]

 c3 - cor(X2,Y2)

 lll[[mat2]] -cbind(X2,Y2)

 a11 - ifelse( X  lll[[cut1]]  Y  lll[[cut2]], 1, 0)

 a12 - ifelse( X  lll[[cut1]]  Y = lll[[cut2]], 1, 0)

 a21 - ifelse( X = lll[[cut1]]  Y  lll[[cut2]], 1, 0)

 a22 - ifelse( X = lll[[cut1]]  Y = lll[[cut2]], 1, 0)

 lll[[mat3]] -matrix(c(sum(a11),sum(a21), sum(a12),sum(a22)), nrow = 2)

 lll[[mat4]] -matrix(c(sum(a11),sum(a22), sum(a12),sum(a21)), nrow = 2)

 lll[[out3a]] - mcnemar.test(lll[[mat3]], correct=FALSE)

 lll[[out3b]] - mcnemar.test(lll[[mat3]], correct=TRUE)

 lll[[out4a]] - chisq.test(lll[[mat4]], correct = FALSE)

 lll[[out4b]] - chisq.test(lll[[mat4]], correct = TRUE)

 print(lll)

 capture.output(print(lll), file = C:/Chi_Square_fix/temp.txt, append =
 TRUE)

 ##LOOPED
 CODE#

 lll - vector(mode = list, length = 10)

 names(lll) - c(mat1, mat2, mat3, mat4, cut1, cut2, out3a,
 out3b, out4a, out4b)

 ss - seq(5,9,by=1)

 cc - seq(-0.5,0.5, by=0.25)

 oo1 - seq(-10,10, by=5)

 oo2 - seq(0,20, by=5)

 for(i in ss) {

 for (j in cc) {

 for (k in oo1) {

 for (l in oo2) {

 z1 - rnorm(ss,mean=400, sd=70)

 z2 - rnorm(ss,mean=450, sd=90)

 r - cc

 X - z1

 Y = r*z1+(1-r)*z2

 lll[[mat1]] - cbind(X,Y)

 dev1 - oo1

 lll[[cut1]] - mean(X) + dev1

 dev2 - oo2

 lll[[cut2]] - mean(X) + dev1 + dev2

 X2 - X-lll[[cut1]]

 Y2 - Y-lll[[cut2]]

 c3 - cor(X2,Y2)

 lll[[mat2]] -cbind(X2,Y2)

 a11 - ifelse( X  lll[[cut1]]  Y  lll[[cut2]], 1, 0)

 a12 - ifelse( X  lll[[cut1]]  Y = lll[[cut2]], 1, 0)

 a21 - ifelse( X = lll[[cut1]]  Y  lll[[cut2]], 1, 0)

 a22 - ifelse( X = lll[[cut1]]  Y = lll[[cut2]], 1, 0)

 lll[[mat3]] -matrix(c(sum(a11),sum(a21), sum(a12),sum(a22)), nrow = 2)

 lll[[mat4]] -matrix(c(sum(a11),sum(a22), sum(a12),sum(a21)), nrow = 2)

 lll[[out3a]] - mcnemar.test(lll[[mat3]], correct=FALSE)

 lll[[out3b]] - mcnemar.test(lll[[mat3]], correct=TRUE)

 lll[[out4a]] - chisq.test(lll[[mat4]], correct = FALSE)

 lll[[out4b]] - chisq.test(lll[[mat4]], correct = TRUE)

 print(lll)

 capture.output(print(lll), file = C:/Chi_Square_fix/temp.txt, append =
 TRUE)

 }

 }

 }

 }
 On Feb 1, 2013 2:01 AM, PIKAL Petr petr.pi...@precheza.cz wrote:

 Hi

 see inline

  -Original Message-
  From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
  project.org] On Behalf Of staysafe23
  Sent: Friday, February 01, 2013 1:01 AM
  To: r-help@r-project.org
  Subject: [R] Nested loop and output help
 
  Hello Everyone,
 
  My name is Thomas and I have been using R for one week. I recently
  found your site and have been able to search the archives of posts.
  This has given me some great information that has allowed me to craft
  an initial design to an inquiry I would like to make into the breakdown
  of McNemar's test. I have read an intro to R manual and the posting
  guides and hope I am not violating them with this post. If so I will
  re-ask my question in the proper format.
 
  I have succeeded in writing a loop to vary one condition of my inquiry
 

[R] Split xts data set into weeks

2013-02-02 Thread Seimizu Joukan
Hi

I am trying to use split() to split a xts data set into weeks, but the
result seems not right.
original data is as following:

 head(xec)
 Open   HighLow  Close mean
2011-02-28 112.34 113.34 111.96 112.87 112.6275
2011-03-01 112.89 113.71 112.75 112.80 113.0375
2011-03-02 112.75 113.56 112.50 113.54 113.0875
2011-03-03 113.50 115.08 113.10 115.05 114.1825
2011-03-04 115.16 115.97 114.85 115.06 115.2600
2011-03-07 115.21 115.26 114.55 114.85 114.9675
...

and I did the split() as following

 head(split(x=xec,f=weeks))
[[1]]
 Open   HighLow  Close mean
2011-02-28 112.34 113.34 111.96 112.87 112.6275

[[2]]
 Open   HighLow  Close mean
2011-03-01 112.89 113.71 112.75 112.80 113.0375
2011-03-02 112.75 113.56 112.50 113.54 113.0875
2011-03-03 113.50 115.08 113.10 115.05 114.1825
2011-03-04 115.16 115.97 114.85 115.06 115.2600
2011-03-07 115.21 115.26 114.55 114.85 114.9675
...

the 2011-02-28 is the Monday but not being grouped with the other
days in that week,
which makes the second groups begin from Tuesday (2011-03-01).

I want it to be as following

[[1]]
 Open   HighLow  Close mean
2011-02-28 112.34 113.34 111.96 112.87 112.6275
2011-03-01 112.89 113.71 112.75 112.80 113.0375
2011-03-02 112.75 113.56 112.50 113.54 113.0875
2011-03-03 113.50 115.08 113.10 115.05 114.1825
2011-03-04 115.16 115.97 114.85 115.06 115.2600

[[2]]
 Open   HighLow  Close mean
2011-03-07 115.21 115.26 114.55 114.85 114.9675
...

Could anyone please give some advice?
Thanks in advance.

Seimizu Joukan

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Question: write an R script with help information available to the user

2013-02-02 Thread Chee Chen
Dear All,

I would like to ask a question on how to incorporate into an R script help 
information for the user. I vaguely recall that I saw some instructions on an R 
manual, but am not able to figure them out. Hereunder is the basic setting:

1.  I finished writing an R script, my_script.r, that is a function (the 
function is named my_func) for a statistical procedure. This means that the 
user only needs to: source(directory_of_script\my_script.r), then run, 
my_func(arg1, arg2, ..), to execute the procedure.

2. I would like to add some lines into my_script.r, so that a user can get 
information on this file and function by using ?my_func

Any help or suggestion is appreciated.
Best regards,
Chee
[[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] Question: write an R script with help information available to the user

2013-02-02 Thread Jeff Newmiller
The normal expectations of an R user is that useful functions you want to share 
are in packages, which include help files. There is no way to both avoid the 
package development process and offer help to the user within R. Read the 
Writing R Extensions document for the most up-to-date information about this 
process. RStudio has some nice enhancements for making this process a little 
quicker, but not so much that you can escape reading the documentation I just 
mentioned. I happen to like using roxygen2 for building help files, but this 
just means reading even more documentation.

If you are determined to use the source function instead of building a package, 
then you cannot take advantage of the users' familiarity with the help system. 
However, you could just put your instructions in comments in your R file and 
hope they will look there.
---
Jeff NewmillerThe .   .  Go Live...
DCN:jdnew...@dcn.davis.ca.usBasics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
--- 
Sent from my phone. Please excuse my brevity.

Chee Chen chen...@purdue.edu wrote:

Dear All,

I would like to ask a question on how to incorporate into an R script
help information for the user. I vaguely recall that I saw some
instructions on an R manual, but am not able to figure them out.
Hereunder is the basic setting:

1.  I finished writing an R script, my_script.r, that is a function
(the function is named my_func) for a statistical procedure. This
means that the user only needs to:
source(directory_of_script\my_script.r), then run, my_func(arg1,
arg2, ..), to execute the procedure.

2. I would like to add some lines into my_script.r, so that a user
can get information on this file and function by using ?my_func

Any help or suggestion is appreciated.
Best regards,
Chee
   [[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] Question: write an R script with help information available to the user

2013-02-02 Thread Gabor Grothendieck
On Sat, Feb 2, 2013 at 6:31 PM, Chee Chen chen...@purdue.edu wrote:
 Dear All,

 I would like to ask a question on how to incorporate into an R script help 
 information for the user. I vaguely recall that I saw some instructions on an 
 R manual, but am not able to figure them out. Hereunder is the basic setting:

 1.  I finished writing an R script, my_script.r, that is a function (the 
 function is named my_func) for a statistical procedure. This means that the 
 user only needs to: source(directory_of_script\my_script.r), then run, 
 my_func(arg1, arg2, ..), to execute the procedure.

 2. I would like to add some lines into my_script.r, so that a user can get 
 information on this file and function by using ?my_func



You may wish to create a package from your script; however, if you
would prefer not then a workaround would be to redefine the ? function
in your script to provide some help.  For example if you had this line
in your script:

`?` - function(...) if (match.call()[[2]] == mytopic)
cat(whatever\n) else help(...)

then this would work:

 ?mytopic
whatever
 ?dim

where the last line launches normal help.  If you wish to display a
file rather than cat strings to the console then use: file.show


--
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] Split xts data set into weeks

2013-02-02 Thread Jeff Newmiller
Your example of the problem is not reproducible [1]. This behavior could arise 
due to small discrepancies in the index values, or from specifying frequency 
instead of f as the second argument, our perhaps you have found a bug that 
only your data triggers. Any verification of what your problem is will require 
a reproducible example.

[1] 
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example
---
Jeff NewmillerThe .   .  Go Live...
DCN:jdnew...@dcn.davis.ca.usBasics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
--- 
Sent from my phone. Please excuse my brevity.

Seimizu Joukan saim...@gmail.com wrote:

Hi

I am trying to use split() to split a xts data set into weeks, but the
result seems not right.
original data is as following:

 head(xec)
 Open   HighLow  Close mean
2011-02-28 112.34 113.34 111.96 112.87 112.6275
2011-03-01 112.89 113.71 112.75 112.80 113.0375
2011-03-02 112.75 113.56 112.50 113.54 113.0875
2011-03-03 113.50 115.08 113.10 115.05 114.1825
2011-03-04 115.16 115.97 114.85 115.06 115.2600
2011-03-07 115.21 115.26 114.55 114.85 114.9675
...

and I did the split() as following

 head(split(x=xec,f=weeks))
[[1]]
 Open   HighLow  Close mean
2011-02-28 112.34 113.34 111.96 112.87 112.6275

[[2]]
 Open   HighLow  Close mean
2011-03-01 112.89 113.71 112.75 112.80 113.0375
2011-03-02 112.75 113.56 112.50 113.54 113.0875
2011-03-03 113.50 115.08 113.10 115.05 114.1825
2011-03-04 115.16 115.97 114.85 115.06 115.2600
2011-03-07 115.21 115.26 114.55 114.85 114.9675
...

the 2011-02-28 is the Monday but not being grouped with the other
days in that week,
which makes the second groups begin from Tuesday (2011-03-01).

I want it to be as following

[[1]]
 Open   HighLow  Close mean
2011-02-28 112.34 113.34 111.96 112.87 112.6275
2011-03-01 112.89 113.71 112.75 112.80 113.0375
2011-03-02 112.75 113.56 112.50 113.54 113.0875
2011-03-03 113.50 115.08 113.10 115.05 114.1825
2011-03-04 115.16 115.97 114.85 115.06 115.2600

[[2]]
 Open   HighLow  Close mean
2011-03-07 115.21 115.26 114.55 114.85 114.9675
...

Could anyone please give some advice?
Thanks in advance.

Seimizu Joukan

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Question: write an R script with help information available to the user

2013-02-02 Thread Bert Gunter
A  related approach which, if memory serves, was originally in S eons
ago, is to define a doc attribute of any function (or object, for
that matter)  that you wish to document that contains text for
documentation and a doc() function of the form:

doc - function(obj) cat(attr(obj,doc))

used as:

 f- function(x) NULL
 attr(f,doc) - Some text\n\n
 doc(f)
 doc(f)
Some text

This is pretty primitive, but I suppose you could instead have the
attribute point to something like an HTML file and the doc() function
open it in a web browser, which is basically what R's built-in package
document system does anyway. Except you wouldn't have to build a
package and don't have to learn or follow R's procedures. Which means
you don't get  R's standardization and organization and no one but a
private bunch of users will be able to use your function. But maybe
that's sufficient for your needs.

-- Bert

On Sat, Feb 2, 2013 at 10:01 PM, Gabor Grothendieck
ggrothendi...@gmail.com wrote:
 On Sat, Feb 2, 2013 at 6:31 PM, Chee Chen chen...@purdue.edu wrote:
 Dear All,

 I would like to ask a question on how to incorporate into an R script help 
 information for the user. I vaguely recall that I saw some instructions on 
 an R manual, but am not able to figure them out. Hereunder is the basic 
 setting:

 1.  I finished writing an R script, my_script.r, that is a function (the 
 function is named my_func) for a statistical procedure. This means that 
 the user only needs to: source(directory_of_script\my_script.r), then run, 
 my_func(arg1, arg2, ..), to execute the procedure.

 2. I would like to add some lines into my_script.r, so that a user can get 
 information on this file and function by using ?my_func



 You may wish to create a package from your script; however, if you
 would prefer not then a workaround would be to redefine the ? function
 in your script to provide some help.  For example if you had this line
 in your script:

 `?` - function(...) if (match.call()[[2]] == mytopic)
 cat(whatever\n) else help(...)

 then this would work:

 ?mytopic
 whatever
 ?dim

 where the last line launches normal help.  If you wish to display a
 file rather than cat strings to the console then use: file.show


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



-- 

Bert Gunter
Genentech Nonclinical Biostatistics

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

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


[R] problem in installing reshape2 (urgent)

2013-02-02 Thread Partha Saha
Dear R users,

In order to install reshape2 package, I gave the following command:

install.packages(reshape2,dep=TRUE)

However, it is not getting installed.

The message that I am getting is:

Warning: dependencies ‘plyr’, ‘stringr’, ‘testthat’ are not available
trying URL '
http://ftp.ctex.org/mirrors/CRAN/src/contrib/reshape2_1.2.2.tar.gz'
Content type 'application/x-gzip' length 27220 bytes (26 Kb)
opened URL
==
downloaded 26 Kb

* installing *source* package ‘reshape2’ ...
** R
** data
**  moving datasets to lazyload DB
** inst
** preparing package for lazy loading
Error in loadNamespace(i, c(lib.loc, .libPaths())) :
  there is no package called 'plyr'
ERROR: lazy loading failed for package ‘reshape2’
* removing ‘/home/dell/R/i486-pc-linux-gnu-library/2.10/reshape2’


Please suggest.

[[alternative HTML version deleted]]

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


Re: [R] problem in installing reshape2 (urgent)

2013-02-02 Thread Jeff Newmiller
Suggestion: follow instructions appropriate for your OS (see CRAN) to install 
the current version of R. (2.15.2)
---
Jeff NewmillerThe .   .  Go Live...
DCN:jdnew...@dcn.davis.ca.usBasics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
--- 
Sent from my phone. Please excuse my brevity.

Partha Saha kuttus...@gmail.com wrote:

Dear R users,

In order to install reshape2 package, I gave the following command:

install.packages(reshape2,dep=TRUE)

However, it is not getting installed.

The message that I am getting is:

Warning: dependencies �plyr�, �stringr�, �testthat� are not available
trying URL '
http://ftp.ctex.org/mirrors/CRAN/src/contrib/reshape2_1.2.2.tar.gz'
Content type 'application/x-gzip' length 27220 bytes (26 Kb)
opened URL
==
downloaded 26 Kb

* installing *source* package �reshape2� ...
** R
** data
**  moving datasets to lazyload DB
** inst
** preparing package for lazy loading
Error in loadNamespace(i, c(lib.loc, .libPaths())) :
  there is no package called 'plyr'
ERROR: lazy loading failed for package �reshape2�
* removing �/home/dell/R/i486-pc-linux-gnu-library/2.10/reshape2�


Please suggest.

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