Re: [R] uniform number

2014-05-05 Thread Rolf Turner

On 05/05/14 17:05, Ragia Ibrahim wrote:


Dear group,
How to generate  uniform probability choosing p to be 2% and 5%, in separate 
trials for 100 times.


No idea WTF you are talking about.  Can you formulate a question that is 
comprehensible to the human mind?


cheers,

Rolf Turner

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

2014-05-05 Thread Kehl Dániel
Maybe you thought the binomial distribution?

see
?rbinom

best,
kd

Feladó: r-help-boun...@r-project.org [r-help-boun...@r-project.org] ; 
meghatalmaz#243;: Rolf Turner [r.tur...@auckland.ac.nz]
Küldve: 2014. május 5. 9:27
To: Ragia Ibrahim
Cc: r-help@r-project.org
Tárgy: Re: [R] uniform number

On 05/05/14 17:05, Ragia Ibrahim wrote:

 Dear group,
 How to generate  uniform probability choosing p to be 2% and 5%, in separate 
 trials for 100 times.

No idea WTF you are talking about.  Can you formulate a question that is
comprehensible to the human mind?

cheers,

Rolf Turner

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] DESeq vs DESeq2 different DEGs results

2014-05-05 Thread Catalina Aguilar Hurtado
Hi,

I want to compare DESeq vs DESeq2 and I am getting different number of DEGs
which I will expect to be normal. However, when I compare the 149 genes ID
that I get with DESeq with the 869 from DESeq2 there are only ~10 genes
that are in common which I don’t understand  (using FDR 0.05 for both). I
want to block the Subject effect for which I am including the reduced
formula of ~1.

Shouldn’t these two methods output similar results?  Because at the moment
I could interpret my results in different ways.

Thanks for your help,

Catalina


This the DESeq script that I am using:


DESeq

library(DESeq)

co=as.matrix(read.table(2014_04_01_6h_LP.csv,header=T, sep=,,
row.names=1))


Subject=c(1,2,3,4,5,1,2,4,5)

Treatment=c(rep(co,5),rep(c2,4))
a.con=cbind(Subject,Treatment)

cds=newCountDataSet(co,a.con)


cds - estimateSizeFactors( cds)

cds - estimateDispersions(cds,method=pooled-CR,
modelFormula=count~Subject+Treatment)


#filtering

rs = rowSums ( counts ( cds ))
theta = 0.2
use = (rs  quantile(rs, probs=theta))
table(use)
cdsFilt= cds[ use, ]



fit0 - fitNbinomGLMs (cdsFilt, count~1)

fit1 - fitNbinomGLMs (cdsFilt, count~Treatment)

pvals - nbinomGLMTest (fit1, fit0)


padj - p.adjust( pvals, method=BH )

padj - data.frame(padj)

row.names(padj)=row.names(cdsFilt)

padj_fil - subset (padj,padj 0.05 )

dim (padj_fil)

[1] 149   1


——————

library (DESeq2)

countdata=as.matrix(read.table(2014_04_01_6h_LP.csv,header=T, sep=,,
row.names=1))

coldata= read.table (targets.csv, header = T, sep=,,row.names=1)

coldata

Subject Treatment
F1   1co
F2   2co
F3   3co
F4   4co
F5   5co
H1   1c2
H2   2c2
H4   4c2
H5   5c2

dds - DESeqDataSetFromMatrix(
  countData = countdata,
  colData = coldata,
  design = ~ Subject + Treatment)
dds

dds$Treatment - relevel (dds$Treatment, co)


dds - estimateSizeFactors( dds)

dds - estimateDispersions(dds)


rs = rowSums ( counts ( dds ))
theta = 0.2
use = (rs  quantile(rs, probs=theta))
table(use)
ddsFilt= dds[ use, ]


dds - nbinomLRT(ddsFilt, full = design(dds), reduced = ~ 1)

resLRT - results(dds)

sum( resLRT$padj  0.05, na.rm=TRUE )

#[1] 869

[[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] uniform number

2014-05-05 Thread Suzen, Mehmet
WTF?

Is that a R package from you?



On 5 May 2014 09:27, Rolf Turner r.tur...@auckland.ac.nz wrote:
 On 05/05/14 17:05, Ragia Ibrahim wrote:


 Dear group,
 How to generate  uniform probability choosing p to be 2% and 5%, in
 separate trials for 100 times.


 No idea WTF you are talking about.  Can you formulate a question that is
 comprehensible to the human mind?

 cheers,

 Rolf Turner

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] function to compare lengths of objects?

2014-05-05 Thread Duncan Murdoch

On 05/05/2014, 1:02 AM, Spencer Graves wrote:

Is there a standard function to generate messages like longer
object length is not a multiple of shorter object length but providing
more information like the names of the objects?


No, not really.

At the C level objects don't really have names.  The same object may be 
linked to several different names, or none at all.  Most messages like 
the length warning are generated there, so they don't include name 
information.


At the R level you can use substitute() to find the expression that was 
used to supply a function argument, so you can do a little better.  For 
example, I would write a simpler version of your compareLengths function 
something like this:


compareLengths - function(x, y, name.x = deparse(substitute(x)),
 name.y = deparse(substitute(y))) {
  if (length(x) == length(y))
return( c(equal, paste(objects, dQuote(name.x), and, 
dQuote(name.y), are the same length.))

  else ...

}

Then a function could call it like this:

f - function(a, b) {
  cmp1 - compareLengths(a, b)  # Message talks about  a and b
  cmp2 - compareLengths(a, b, deparse(substitute(a)),
 deparse(substitute(b))) # Message talks about names
 # in call to f
  ...
}

Duncan Murdoch




For example, a/b issues, Warning message:  In a/b : longer
object length is not a multiple of shorter object length if the length
of one is not a multiple of the other.  I want a utility to produce
messages that include the lengths of a and b and other information.


If you were to write such a function, what would you include in
it?  Arguments?  Values?  Options?


I started creating compareLengths.Rd with
\usage{compareLengths(x, y, name.x=NULL, name.y=NULL, Source='',
compFun=c('length', 'NROW'), action=c(comparable='',
incomparable='warning'), maxChar=20, ...)} and \value{A character vector
of length 2.  The first element is either 'equal', 'compatible' or
'incompatible'.  The second element is the message composed for the
desired action.


Thanks,
Spencer Graves

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

2014-05-05 Thread Suzen, Mehmet
That paper you cite is about Social networks. You may want to use
igraph or sna packages

On 5 May 2014 10:54, Ragia Ibrahim ragi...@hotmail.com wrote:
 thanks for replying

 in the following paper
 http://www.cs.cornell.edu/home/kleinber/kdd03-inf.pdf
 page 6 third paragraph


 the author writes:
 assigned a uniform probability of p to each edge of the graph, choosing p
 to be 1% and 10%
 in separate trials.


 how to use R function to get such probability ?
 Regards

 Date: Mon, 5 May 2014 10:12:49 +0200
 Subject: Re: [R] uniform number
 From: msu...@gmail.com
 To: r.tur...@auckland.ac.nz
 CC: ragi...@hotmail.com; r-help@r-project.org

 WTF?

 Is that a R package from you?



 On 5 May 2014 09:27, Rolf Turner r.tur...@auckland.ac.nz wrote:
  On 05/05/14 17:05, Ragia Ibrahim wrote:
 
 
  Dear group,
  How to generate uniform probability choosing p to be 2% and 5%, in
  separate trials for 100 times.
 
 
  No idea WTF you are talking about. Can you formulate a question that is
  comprehensible to the human mind?
 
  cheers,
 
  Rolf Turner
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/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] uniform number

2014-05-05 Thread Rolf Turner



Please keep responses on-list unless there are compelling reasons not to.

It is still not clear what you want to do.  You *might* want to assign
probabilities to the edges of a graph where these probabilities are 
uniformly (and independently) distributed on the interval [0.01, 0.10].


This could be done by

probs - runif(n,0.01,0.10)

where n is the number of edges.  See ?runif.

You *might* want to assign probabilities either 0.01 or 0.10 to each 
edge of the graph, each probability being chosen with probability 0.5 
(???).  This could be done by


probs - sample(c(0.01,0.10),n,TRUE).

You really need to learn something about R if you are going to use R.
Start with An Introduction to R available (under Manuals) from the R 
web site.


You also need to learn to express yourself clearly and unambiguously. 
Do not expect your readers to be telepathic.


cheers,

Rolf Turner

On 05/05/14 19:41, Ragia Ibrahim wrote:


thanks for replying
in the following paper
http://www.cs.cornell.edu/home/kleinber/kdd03-inf.pdf
page 6 third paragraph


the author writes:
assigned a uniform probability of p to each edge of the graph, choosing
p to be 1% and 10%
in separate trials.


how to use R function to get such probability ?
Regards


  Date: Mon, 5 May 2014 19:27:43 +1200
  From: r.tur...@auckland.ac.nz
  To: ragi...@hotmail.com
  CC: r-help@r-project.org
  Subject: Re: [R] uniform number
 
  On 05/05/14 17:05, Ragia Ibrahim wrote:
  
   Dear group,
   How to generate uniform probability choosing p to be 2% and 5%, in
separate trials for 100 times.
 
  No idea WTF you are talking about. Can you formulate a question that is
  comprehensible to the human mind?


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

2014-05-05 Thread Mia Bengtsson
Dear R and vegan package users,

I have been experiencing problems with the metaMDS function when working on a 
dataset (euk) consisting of 9 sites (RNA extracts of 9 biofilms samples) and 
340 species (microbial taxa based on rRNA sequences). The problem is that I 
get nMDS ordinations with overlapping points, so that it looks like 6 samples 
are identical, while the remaining 3 are well separated. The dataset is rather 
large, and quite complex so I do not think that this is a correct 
representation of dissimilarities. Every time this happens, I get the warning 
message:

In metaMDS(t(euk_red), distance = bray) :
  Stress is (nearly) zero - you may have insufficient data

Removing relatively rare species using: 

euk_red-euk[rowSums(euk)100,]

results in an nMDS ordination with scattered points that looks more reasonable. 
However, removing even more rare species (1000) results in a different, but 
similarly uncomplex ordination and the same warning message. Changing the 
distance metric to euclidean seems even more sensitive to this problem, 
yielding uncomplex ordinations with almost any rare species cutoff. 

The code I am using is:

euk_MDS-metaMDS(t(euk_red), distance=bray)
ordiplot(euk_MDS, display=sites)

I have tried the arguments engine=isoMDS, and changing maxit and trymax without 
noticeable effect. Generating the distance matrices separately in vegdist 
yields distance matrices that look normal to my eye. It seems like a similar 
problem to a recent thread in the R-help (Fabian Boetzl, Feb 2014), but my 
dataset has many species that are shared between all sites. I would be happy to 
provide the dataset if this may help in figuring out what the problem is. I am 
using R version 3.1.0 for MacOS, coupled to R-studio (version 0.98.510).

Thanks in advance and best regards!


Mia M. Bengtsson, University of Vienna





[[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] uniform number

2014-05-05 Thread Boris Steipe
... or this could mean to accept or reject an edge with p = 0.01 or 0.1 in 
which case you *might* use rbinom() as in

n - 100   # number of edges
p - 0.27  # desired probability
rbinom(n,1,p)
  [1] 0 1 0 0 0 1 0 0 0 0 0 0 0 1 1 0 0 1  ... etc.

B.

On 2014-05-05, at 5:19 AM, Rolf Turner wrote:

 
 
 Please keep responses on-list unless there are compelling reasons not to.
 
 It is still not clear what you want to do.  You *might* want to assign
 probabilities to the edges of a graph where these probabilities are uniformly 
 (and independently) distributed on the interval [0.01, 0.10].
 
 This could be done by
 
 probs - runif(n,0.01,0.10)
 
 where n is the number of edges.  See ?runif.
 
 You *might* want to assign probabilities either 0.01 or 0.10 to each edge of 
 the graph, each probability being chosen with probability 0.5 (???).  This 
 could be done by
 
 probs - sample(c(0.01,0.10),n,TRUE).
 
 You really need to learn something about R if you are going to use R.
 Start with An Introduction to R available (under Manuals) from the R web 
 site.
 
 You also need to learn to express yourself clearly and unambiguously. Do not 
 expect your readers to be telepathic.
 
 cheers,
 
 Rolf Turner
 
 On 05/05/14 19:41, Ragia Ibrahim wrote:
 
 thanks for replying
 in the following paper
 http://www.cs.cornell.edu/home/kleinber/kdd03-inf.pdf
 page 6 third paragraph
 
 
 the author writes:
 assigned a uniform probability of p to each edge of the graph, choosing
 p to be 1% and 10%
 in separate trials.
 
 
 how to use R function to get such probability ?
 Regards
 
 
  Date: Mon, 5 May 2014 19:27:43 +1200
  From: r.tur...@auckland.ac.nz
  To: ragi...@hotmail.com
  CC: r-help@r-project.org
  Subject: Re: [R] uniform number
 
  On 05/05/14 17:05, Ragia Ibrahim wrote:
  
   Dear group,
   How to generate uniform probability choosing p to be 2% and 5%, in
 separate trials for 100 times.
 
  No idea WTF you are talking about. Can you formulate a question that is
  comprehensible to the human mind?
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Plotting a Regression holding some exogeneous constant.

2014-05-05 Thread Katharina Mersmann
Dear R-community,

I am totally lost and need help.

For a Visualization  I need to plot two regressions in the same plot.  The
intention is to provide a visual basis for a synthesized theoretical
discussion.

 

1.)fixed.1-plm(CSmean~ FCRlong, data = data.plm, index =
c(countrynr,quartal),model = within)

2.)fixed.2-plm(FCRlong ~ GDP+ GDPpCapita+ budget+ percentDebt+
primSurplus

  +Inflation+lagBY, 

   data = data.plm, index = c(countrynr,quartal),model =
within

Usually I would do

plot(data.plm$ FCRlong,data.plm$BY,ylim = c(0,20))

abline(fixed.1)

abline(fixed.2)

 

For Regression Number one, “fixed.1”, it´s easy, because I have only two
Dimensions, but here I need to do a parallel shift by adding an average
Value, say 4, (to solve for  CSmean to BY)

So loosely speaking, I want to plot  fixed.1+4 ? What shall I do in this
case? 

 

Second, in Regression “fixed.2” I have a Hyperplane, but for a synthesized
general discussion the exogeneous variables, except lagBY, shall be set to
their average values

in the panel-dataset. With this restriction I am able to plot Regression 2
in the two-dimensional-plot as well. 

But I am not even sure how to reconstruct this by a code?

 

 

I unfortunately can´t give you an reproduceable example,

But any suggestions or hints or just a link to a similar problem would be
helpful

 

Thank you! 

Katie


[[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 Package making error

2014-05-05 Thread Ashis Deb
Hi  all  ,

I  have  a  GUI package  function   like  below ,


trader-function()
{

   install.packages(Rgtk2)
  install.packages(cluster)
  install.packages(gWidgets)
  install.packages(gWidgetsRGtk2)
  install.packages(scales)
  install.packages(RGtk2Extras)
  install.packages(FuzzyToolkitUoN)
  install.packages(splines)
  install.packages(plyr)
  install.packages(cairo)
  install.packages(cairoDevices)
  install.packages(e1071)
  install.packages(quantmod)
  install.packages(TTR)
  install.packages(xts)


library(RGtk2)
  library(RGtk2Extras)
  library(FuzzyToolkitUoN)
  library(splines)
  library(plyr)
  library(Cairo)
  library(cairoDevice)
  library(gWidgets2)
  library(gWidgetsRGtk2)
  library(e1071)
  library(quantmod)
  library(TTR)
  library(xts)




}







Ididn't   put  the   whole  code   here  ,

My  problem  is   I  had  converted  thisfunction   into  an
package ,   it works   good  ,but   every  time   it  has  to
install  all the packages,  is there  something  by which  only  once
it will install   the  packages   and  next  time  it is not needed .

Thanks

ASHIS

[[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 Package making error

2014-05-05 Thread Sarah Goslee
While I don't particularly like the idea of a package automatically
making changes to the system, you can use

installed.packages()

to see which of your needed packages are already available, and only
install the ones that are missing.

Better would be to put the whole list in Depends, and let R manage the loading.

http://stackoverflow.com/questions/8637993/better-explanation-of-when-to-use-imports-depends


Sarah

On Mon, May 5, 2014 at 9:46 AM, Ashis Deb ashisde...@gmail.com wrote:
 Hi  all  ,

 I  have  a  GUI package  function   like  below ,


 trader-function()
 {

install.packages(Rgtk2)
   install.packages(cluster)
   install.packages(gWidgets)
   install.packages(gWidgetsRGtk2)
   install.packages(scales)
   install.packages(RGtk2Extras)
   install.packages(FuzzyToolkitUoN)
   install.packages(splines)
   install.packages(plyr)
   install.packages(cairo)
   install.packages(cairoDevices)
   install.packages(e1071)
   install.packages(quantmod)
   install.packages(TTR)
   install.packages(xts)


 library(RGtk2)
   library(RGtk2Extras)
   library(FuzzyToolkitUoN)
   library(splines)
   library(plyr)
   library(Cairo)
   library(cairoDevice)
   library(gWidgets2)
   library(gWidgetsRGtk2)
   library(e1071)
   library(quantmod)
   library(TTR)
   library(xts)




 }







 Ididn't   put  the   whole  code   here  ,

 My  problem  is   I  had  converted  thisfunction   into  an
 package ,   it works   good  ,but   every  time   it  has  to
 install  all the packages,  is there  something  by which  only  once
 it will install   the  packages   and  next  time  it is not needed .

 Thanks

 ASHIS


---
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] auglag store parameters

2014-05-05 Thread MacQueen, Don
Just guessing, but something like


pars - numeric(nloops)
 
for (i in 1:nloops) {
  ## use auglag
  pars[i] -  {the $par part of the answer}
}


might be what you're looking for.

All of which has nothing to do with auglag in particular, just simple R
programming.

-Don

-- 
Don MacQueen

Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062





On 5/3/14 5:02 AM, Delger Enkhbayar d.enkhba...@lse.ac.uk wrote:

Hi,

I am minimizing a non-linear function subject to linear and nonlinear
equalities and inequalities. I managed to understand how to use auglag for
this case. Now, I'm using loops to get solutions for different
assumptions,
however, I'm facing a difficulty in storing just $par part of the answer
to
a vector form. Could someone point me to how to do this in auglag?

Thank you for all your great work!

   [[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] Tick marks at the 0:0 point in a plot ()

2014-05-05 Thread Ahmed Attia
Dear R usres,

Sorry to bother you with my basic question. I have a quick question about
tick mark in R. A reviewer wants the tick marks of the graph to start at
0:0 point. My current code below produces the tick mark a little far from
the corner;

plot(Simu2~Irrig, data=Ahmed,pch=17, col=1,subset=ET==40,tck=-0.01,
xlab = (Applied Irrigation (mm)),   ylab = expression(paste(Cumulative
ET  (mm)))
,cex.lab=1.2, cex.axis=0.8,cex=0.9,font.lab=1,xlim = c(0,1000),
xaxp=c(0,1000,10), yaxp=c(100,800,7),
ylim=c(100,800))

Any ideas.

Thank you

Ahmed M. Attia


Research Assistant
Dept. of SoilCrop Sciences
Texas AM University
ahmed.at...@ag.tamu.edu
Cell phone: 001-979-248-5215
FAX: 001-308-455-4024
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Parsing XML file to data frame

2014-05-05 Thread Timothy W. Cook
I didn't find an attached XML file. Maybe the list removes attachments?
You might try posting to StackOverflow.com if this is the case.




On Fri, May 2, 2014 at 2:17 PM, starcraz chan_will...@email.com wrote:

 Hi all - I am trying to parse out the attached XML file into a data frame.
 The file is extracted from Hadoop File Services (HFS). I am new in using
 the
 XML package so need some help in parsing out the data. Below is some code
 that I explore to get the attribute into a data frame. Any help is
 appreciated.

 library(XML)
 temp - xmlParseDoc(sample.xml)
 temp.root - xmlRoot(temp)
 xmlName(temp.root)
 xmlSize(temp.root) #21 child nodes
 temp.root[[2]] #headers
 temp.root[[2]][[2]] #extracts just the revision
 temp.2 - xmlToList(temp.root[[2]]) #extracts the info in temp.root[[2]]
 into a list
 temp.2
 temp.2.df - xmlToDataFrame(temp.root[[2]]) #data frame of the list
 temp.2.df
 xmlValue(temp.root[[2]]) #string the values of the node inside [[2]]

 temp.revision - xmlValue(temp.root[[2]][[Revision]])
 temp.revision

 test - xmlTreeParse(sample.xml)
 test




 --
 View this message in context:
 http://r.789695.n4.nabble.com/Parsing-XML-file-to-data-frame-tp4689883.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.




-- 


Timothy Cook
LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook
MLHIM http://www.mlhim.org

[[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] Tick marks at the 0:0 point in a plot ()

2014-05-05 Thread William Dunlap
I don't understand your question - you want a tick mark at 0,0 but you
explicitly ask for the y axis to start at 100 (and to go upwards from
there).   Do you mean you want the initial tick mark on an axis to be
at the lower left corner of the plot?  If so, see if adding xaxs=i,
yaxs=i to your plot command helps.  E.g., compare
  plot(0:10,0:10, xaxs=i, yaxs=i)
and
  plot(0:10,0:10)
Bill Dunlap
TIBCO Software
wdunlap tibco.com


On Mon, May 5, 2014 at 11:27 AM, Ahmed Attia ahmedati...@gmail.com wrote:
 Dear R usres,

 Sorry to bother you with my basic question. I have a quick question about
 tick mark in R. A reviewer wants the tick marks of the graph to start at
 0:0 point. My current code below produces the tick mark a little far from
 the corner;

 plot(Simu2~Irrig, data=Ahmed,pch=17, col=1,subset=ET==40,tck=-0.01,
 xlab = (Applied Irrigation (mm)),   ylab = expression(paste(Cumulative
 ET  (mm)))
 ,cex.lab=1.2, cex.axis=0.8,cex=0.9,font.lab=1,xlim = c(0,1000),
 xaxp=c(0,1000,10), yaxp=c(100,800,7),
 ylim=c(100,800))

 Any ideas.

 Thank you

 Ahmed M. Attia


 Research Assistant
 Dept. of SoilCrop Sciences
 Texas AM University
 ahmed.at...@ag.tamu.edu
 Cell phone: 001-979-248-5215
 FAX: 001-308-455-4024

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

2014-05-05 Thread Spencer Graves

  Is there a function someplace to compare lengths?


  For example, if longer object length is not a multiple of 
shorter object length, a/b issues a warning.  I'd like something with 
more flexibility in what is reported.



  Hadley Wickham's testthat and assertthat packages provide 
tools for testing and comparing objects, but I didn't see this.



  I'm starting to write compareLengths(x, y, name.x=NULL, 
name.y=NULL, Source='', compFun=c('length', 'NROW'), 
action=c(comparable='', incomparable='warning'), maxChar=20, ...). 
However, I'd prefer to use an existing function if I can find one that I 
feel is adequate.



  Thanks,
  Spencer

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

2014-05-05 Thread Duncan Murdoch

On 05/05/2014, 3:39 PM, Spencer Graves wrote:

Is there a function someplace to compare lengths?


For example, if longer object length is not a multiple of
shorter object length, a/b issues a warning.  I'd like something with
more flexibility in what is reported.


Hadley Wickham's testthat and assertthat packages provide
tools for testing and comparing objects, but I didn't see this.


I'm starting to write compareLengths(x, y, name.x=NULL,
name.y=NULL, Source='', compFun=c('length', 'NROW'),
action=c(comparable='', incomparable='warning'), maxChar=20, ...).
However, I'd prefer to use an existing function if I can find one that I
feel is adequate.



You posted this question (with a different subject line) yesterday. 
What is wrong with the response I sent then?


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.


[R] multiply of two expressions

2014-05-05 Thread Niloofar.Javanrouh


 hello,
i want to differentiate of L with respect to b
when:

L= k*ln (k/(k+mu)) + sum(y) * ln (1-(k/mu+k))   #(negative binomial ln 
likelihood)
and 
ln(mu/(mu+k)) = a+bx   #link function

how can i do it in R?
thank you.


_ 
Best Regards 

Niloofar.Javanrouh 
Ph.D Student of BioStatistics 

[[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] Lattice Histogram with Normal Curve - Y axis as percentages

2014-05-05 Thread jimdare
Hello,

This may seem like a simple problem, but it's frustrating me immensely.  I'm
trying to overlay a normal curve (dnorm) on top of a histogram using the
code below.  This works find when the type = density, but the person for
whom I'm making the plot wants the y axis in percent of total rather than
density.  When I change type to percent, I get the histogram scale I'm
after, but the dnorm plot is greatly reduced.  How could I scale the density
plot to the percent of total axis.  Alternatively, perhaps there is a way to
add density to a secondary y axis?

Thanks in advance for your help.

Jimdare


plot-histogram(~rdf[,j]|Year,nint=20, data=rdf,main = i,strip =
my.strip,xlab = j,  
   type = percent,layout=c(2,1),
   panel=function(x, ...) {
   panel.histogram(x, ...)

   panel.mathdensity(dmath=dnorm, col=black, 
  # Add na.rm = TRUE to mean() and sd()
args=list(mean=mean(x, na.rm = TRUE),
sd=sd(x, na.rm = TRUE)), ...)
}) 



--
View this message in context: 
http://r.789695.n4.nabble.com/Lattice-Histogram-with-Normal-Curve-Y-axis-as-percentages-tp469.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] Sciplot: Increasing the width of bargraph and decreasing the sapce b/n groups

2014-05-05 Thread Roopa Subbaiaih
Hello,

I am trying to plot bargraphs susing Sciplot. Is there a way to increase
the width of the bar graphs and decrease the space b/n the groups? I am
pasting the script as well as attaching the graph.

Bio6 - read.csv(Data/Plin1.csv,na.strings=,header=T)
attach(Bio6)
head(Bio6)
par(family=serif, font=11)
Bio6$Sps - factor(Bio6$Sps, levels = c(FFA1, FFA2,FFA3))
Bio6$Gp - factor(Bio6$Gp, levels = c(N-FFA1,
FU1,FA1,N-FFA2,FU2,FA2,N-FFA3,FU3,FA3))
bargraph.CI(Sps, O.D, group = Gp, data = Bio6,ylab = Relative expression
levels, cex.lab = 1.5, y.leg = 6,cex.leg = 0.82,cex=1.5, axisnames=TRUE,
col = c(red,blue,grey),space=c(0, 0.5), ylim=c(0,7),cex.names =
1.0,density = c(30,30,30), legend = TRUE, main=PLIN1)
detach(Bio6)

 O.D Gp  Sps
1  1.00 N-FFA1 FFA1
2  2.996432FU1 FFA1
3  3.223413FU1 FFA1
4  3.524465FU1 FFA1
5  1.311971FA1 FFA1
6  6.755860FA1 FFA1
7  1.566000FA1 FFA1
8  1.00 N-FFA2 FFA2
9  2.741612FU2 FFA2
10 2.800644FU2 FFA2
11 3.569509FU2 FFA2
12 4.141500FA2 FFA2
13 7.049476FA2 FFA2
14 4.694674FA2 FFA2
15 1.00 N-FFA3 FFA3
16 4.163601FU3 FFA3
17 3.903986FU3 FFA3
18 4.73FU3 FFA3
19 0.00FA3 FFA3
20 0.00FA3 FFA3
21 0.00FA3 FFA3

Any help would be appreciated.

Thanks in advance, Roopa
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Degrees of Freedom GAM/GAMM

2014-05-05 Thread Worthington, Thomas A
Dear All 

I've fitted a GAMM to relate water temperature to the day of the year (DOY) at 
three different sites. I used summary(MFinal$gam) and anova(MFinal$gam) to 
produce the output of my model. I'm confused on how to report the degrees of 
freedom for the smother and the factor. I currently have 

The final model suggested water temperature was significant related to DOY 
(6.46 estimated degrees of freedom, F = 224.2, p  0.001) and was significantly 
different between sites (F2 = 82.14, p 0.001)

But think there should be more to the degrees of freedom particularly for the 
sites factor.

If anyone could advise on the correct way to display the results I would 
greatly appreciate it . The output from the model is below

Best wishes

Tom 


 summary(MFinal$gam)

Family: gaussian 
Link function: identity 

Formula:
Temperature ~ s(DOY) + Site

Parametric coefficients:
Estimate Std. Error t value Pr(|t|)
(Intercept)  12.0366 0.2411   49.92   2e-16 ***
SiteG 4.2460 0.3979   10.67   2e-16 ***
SiteH 4.1439 0.4069   10.19   2e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Approximate significance of smooth terms:
 edf Ref.df F p-value
s(DOY) 6.457  6.457 224.2  2e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

R-sq.(adj) =  0.914  Scale est. = 0.098602  n = 137


 anova(MFinal$gam)

Family: gaussian 
Link function: identity 

Formula:
Temperature ~ s(DOY) + Site

Parametric Terms:
 df F p-value
Site  2 82.14  2e-16

Approximate significance of smooth terms:
 edf Ref.df F p-value
s(DOY) 6.457  6.457 224.2  2e-16 

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] list.files accessing subdirectory as relative path?

2014-05-05 Thread Adel
Dear list members,

I would like to access a subdirectory given where the work directory has
been set. So I have:

 getwd()
[1] C:/Users/Lord Adellus/Dropbox/I8child1/Data

 list.files() # give three folders
 [1] Least Developed Countries 
 [4] Low middle income grouping More advanced
developing countries and territories 

 list.files(path = ../Least Developed Countries) # I want to access now
 one of the subdirectories
character(0)

But as you can see R does not want to look into the specified subdirectory.
I have tried several combination and searched the list but without any great
success. 

Actually: 

list.files(path = ../...) #goes up one level in the folder structure so I
cannot see what the problem is.


Thanks in advance.
Adel




--
View this message in context: 
http://r.789695.n4.nabble.com/list-files-accessing-subdirectory-as-relative-path-tp4689997.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] function to compare lengths?

2014-05-05 Thread Spencer Graves

On 5/5/2014 1:19 PM, Duncan Murdoch wrote:

On 05/05/2014, 3:39 PM, Spencer Graves wrote:

Is there a function someplace to compare lengths?


For example, if longer object length is not a multiple of
shorter object length, a/b issues a warning.  I'd like something with
more flexibility in what is reported.


Hadley Wickham's testthat and assertthat packages provide
tools for testing and comparing objects, but I didn't see this.


I'm starting to write compareLengths(x, y, name.x=NULL,
name.y=NULL, Source='', compFun=c('length', 'NROW'),
action=c(comparable='', incomparable='warning'), maxChar=20, ...).
However, I'd prefer to use an existing function if I can find one that I
feel is adequate.



You posted this question (with a different subject line) yesterday. 
What is wrong with the response I sent then?



  Your earlier response was great, but I didn't see it until I 
received this reply.



  I apologize for sending essentially the same question twice. It 
was not my intent.  I missed Duncan's reply and couldn't find my 
original email in my sent folder.  I concluded erroneously that I may 
have deleted the draft rather than sending it.



  Thanks again,
  Spencer Graves



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] list.files accessing subdirectory as relative path?

2014-05-05 Thread MacQueen, Don
If 'foo' is a subdirectory of the current working directory, then
  list.files('foo')
lists the files in foo.

.. goes up one level
But you did not want to go up one level. You wanted to stay at the same
level.
(also, '...' has no meaning in pathnames)

Try either of
  list.files(path = ./Least Developed Countries)
  list.files(path = Least Developed Countries)

-- 
Don MacQueen

Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062





On 5/5/14 12:29 PM, Adel adel.da...@sociology.gu.se wrote:

Dear list members,

I would like to access a subdirectory given where the work directory has
been set. So I have:

 getwd()
[1] C:/Users/Lord Adellus/Dropbox/I8child1/Data

 list.files() # give three folders
 [1] Least Developed Countries
 [4] Low middle income grouping More advanced
developing countries and territories

 list.files(path = ../Least Developed Countries) # I want to access now
 one of the subdirectories
character(0)

But as you can see R does not want to look into the specified
subdirectory.
I have tried several combination and searched the list but without any
great
success. 

Actually: 

list.files(path = ../...) #goes up one level in the folder structure so
I
cannot see what the problem is.


Thanks in advance.
Adel




--
View this message in context:
http://r.789695.n4.nabble.com/list-files-accessing-subdirectory-as-relativ
e-path-tp4689997.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] Tick marks at the 0:0 point in a plot ()

2014-05-05 Thread Ahmed Attia
Dear William,

Worded beautifully. Yes, I wanted to get the tick marks at the left corner.
I had to just add xaxs=i and yaxs=i


Thanks

Ahmed


Ahmed M. Attia


Research Assistant
Dept. of SoilCrop Sciences
Texas AM University
ahmed.at...@ag.tamu.edu
Cell phone: 001-979-248-5215
FAX: 001-308-455-4024



On Mon, May 5, 2014 at 12:13 PM, William Dunlap wdun...@tibco.com wrote:

 I don't understand your question - you want a tick mark at 0,0 but you
 explicitly ask for the y axis to start at 100 (and to go upwards from
 there).   Do you mean you want the initial tick mark on an axis to be
 at the lower left corner of the plot?  If so, see if adding xaxs=i,
 yaxs=i to your plot command helps.  E.g., compare
   plot(0:10,0:10, xaxs=i, yaxs=i)
 and
   plot(0:10,0:10)
 Bill Dunlap
 TIBCO Software
 wdunlap tibco.com


 On Mon, May 5, 2014 at 11:27 AM, Ahmed Attia ahmedati...@gmail.com
 wrote:
  Dear R usres,
 
  Sorry to bother you with my basic question. I have a quick question about
  tick mark in R. A reviewer wants the tick marks of the graph to start at
  0:0 point. My current code below produces the tick mark a little far from
  the corner;
 
  plot(Simu2~Irrig, data=Ahmed,pch=17, col=1,subset=ET==40,tck=-0.01,
  xlab = (Applied Irrigation (mm)),   ylab = expression(paste(Cumulative
  ET  (mm)))
  ,cex.lab=1.2, cex.axis=0.8,cex=0.9,font.lab=1,xlim = c(0,1000),
  xaxp=c(0,1000,10), yaxp=c(100,800,7),
  ylim=c(100,800))
 
  Any ideas.
 
  Thank you
 
  Ahmed M. Attia
 
 
  Research Assistant
  Dept. of SoilCrop Sciences
  Texas AM University
  ahmed.at...@ag.tamu.edu
  Cell phone: 001-979-248-5215
  FAX: 001-308-455-4024
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/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] SQL vs R

2014-05-05 Thread David Winsemius

On May 5, 2014, at 11:44 AM, Dr Eberhard Lisse wrote:

 I do not wish to prolong this metadiscussion but I remain confused
 by your advice:
 
 1) You don't understand what I asked (ie would have to parse two
 simple SQL statements)

Correct ... at least for me. I could have guessed at what that statement might 
have meant, but why should I need to guess? Why not use a shared 
naturallanguage rather than restricting your audience to the more limited group 
that understands both languages?

 2) The Original Post is understood enough, however, to point me to
 the Introduction to R (where I have not found something to help
 me)

That means my guess would have been wrong, since like Jeff Newmiller, I thought 
a simple call to `table` would have succeeded. (Section 5.10 although the 
desire for ordering suggested by my guess regarding 

 
 3) My name is not Pete.

I'm actually not sure who Pete was. It's a local expression of astonishment 
directed, not at you, but at Satish. That was a prelude to my effort explain to 
Satish why the other respondents to the list have not seen fit to be more 
expansive in their responses. I thought Satish's comment was gratuitous (and 
likewise unhelpful).

 
 If you don't want to help me, don't.

Several people are trying to help. You are remaining obdurate in failing to 
explain what is desired in natural language or posting an example in R code 
with desired output, as well as in failing to heed multiple other bits of 
advice in the Posting Guide. The accepted practice in responses is to include 
any context that might further the conversation. To my mind that would have 
required that you include the original request:

 How do I do something like this without using sqldf?
 
 a - sqldf(SELECT COUNT(*) FROM b WHERE c = 'd')
 
 or
 
 e - sqldf(SELECT f, COUNT(*) FROM b GROUP BY f ORDER BY f)

How does the earlier suggestion to look at the 'table' function fail to address 
the first alternative? ( It appears it might satisfy the second one as well.)

-- 
David.


  Nobody is forcing you to reply.
 
 el
 
 On 2014-05-04, 06:56 , David Winsemius wrote:
 
 On May 3, 2014, at 9:10 PM, Satish Anupindi Rao wrote:
 
 
  By making the effort to learn R??  very constructive and not
 condescending at all.  We, lesser beings, are indebted to you,
 sir.
 
 For Pete's sake.  The OP didn't even express his original request
 in natural language or offer a working example.  Those of us who
 are not regular SQL users would have needed to parse out the SQL
 code in order to figure out what was intended.  (My guess is that
 it would have been quite easy to solve if those were what were
 offered.)  But making the effort to divine the intent didn't seem
 justified by the level of courtesy offered by the questioner.
 
 

David Winsemius
Alameda, CA, USA

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


[R] Max characters from deparse(substitute(.))?

2014-05-05 Thread Spencer Graves
   Is there a standard or or a standard utility to limit the size of 
deparse(substitute(.))?


   Below please find an example of the problem plus one solution.  
If another solution already exists, I might prefer to use it.


   Thanks,
   Spencer


##
## Problem
##
deparse.x0 - function(x)deparse(substitute(x))
deparse.a - do.call(deparse.x0, list(letters))
nchar(deparse.a) # unacceptable

[1] 62 65  4


##
## Better
##
deparse.x - function(x, maxChar=20){
   name.x - deparse(substitute(x))
   nch.x - nchar(name.x)
   name2 - name.x[nch.x0]
   nch2 - nch.x[nch.x0]
   if((length(name2)1)){
 name2 - name2[1]
   }
   if(nch2[1]maxChar){
 name2 - paste0(substring(name2, 1, maxChar), '...')
   }
   name2
}

do.call(deparse.x, list(letters)) # better

[1] c(\a\, \b\, \c\, \d\...




[[alternative HTML version deleted]]

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


Re: [R] Sciplot: Increasing the width of bargraph and decreasing the sapce b/n groups

2014-05-05 Thread Jim Lemon

On 05/06/2014 05:02 AM, Roopa Subbaiaih wrote:

Hello,

I am trying to plot bargraphs susing Sciplot. Is there a way to increase
the width of the bar graphs and decrease the space b/n the groups? I am
pasting the script as well as attaching the graph.

Bio6- read.csv(Data/Plin1.csv,na.strings=,header=T)
attach(Bio6)
head(Bio6)
par(family=serif, font=11)
Bio6$Sps- factor(Bio6$Sps, levels = c(FFA1, FFA2,FFA3))
Bio6$Gp- factor(Bio6$Gp, levels = c(N-FFA1,
FU1,FA1,N-FFA2,FU2,FA2,N-FFA3,FU3,FA3))
bargraph.CI(Sps, O.D, group = Gp, data = Bio6,ylab = Relative expression
levels, cex.lab = 1.5, y.leg = 6,cex.leg = 0.82,cex=1.5, axisnames=TRUE,
col = c(red,blue,grey),space=c(0, 0.5), ylim=c(0,7),cex.names =
1.0,density = c(30,30,30), legend = TRUE, main=PLIN1)
detach(Bio6)

  O.D Gp  Sps
1  1.00 N-FFA1 FFA1
2  2.996432FU1 FFA1
3  3.223413FU1 FFA1
4  3.524465FU1 FFA1
5  1.311971FA1 FFA1
6  6.755860FA1 FFA1
7  1.566000FA1 FFA1
8  1.00 N-FFA2 FFA2
9  2.741612FU2 FFA2
10 2.800644FU2 FFA2
11 3.569509FU2 FFA2
12 4.141500FA2 FFA2
13 7.049476FA2 FFA2
14 4.694674FA2 FFA2
15 1.00 N-FFA3 FFA3
16 4.163601FU3 FFA3
17 3.903986FU3 FFA3
18 4.73FU3 FFA3
19 0.00FA3 FFA3
20 0.00FA3 FFA3
21 0.00FA3 FFA3


Hi Roopa,
bargraph.CI does something with the space argument that I can't quite 
work out. I can get a reasonable plot like this:


Bmeans-matrix(by(Bio6$O.D,Bio6$Gp],FUN=mean),ncol=3)
barpos-barplot(Bmeans,beside=TRUE,
 ylim=c(0,7),col=c(red,blue,grey),space=c(0.1,1),main=PLIN1)
legend(8.5,7.1,
 c(N-FFA1,FU1,FA1,N-FFA2,FU2,FA2,N-FFA3,FU3,FA3),
 fill=c(red,blue,grey),bty=n)
library(plotrix)
Bse-matrix(by(Bio6$O.D,Bio6$Gp,FUN=std.error),ncol=3)
dispersion(barpos,Bmeans,Bse,display.na=FALSE)

Jim

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


Re: [R] Max characters from deparse(substitute(.))?

2014-05-05 Thread William Dunlap
Have you looked at the width.cutoff and nlines arguments to deparse?
width.cutoff controls how long a line can be and it quits producing
output (saving time and space) after nlines of output are produced.
You want essentially the following
   f0 - function(x, maxChar=20) deparse(x, width.cutoff=maxChar, nlines=1)
or, to add the '...' to the end if something was cut off
  f1 - function(x, maxChar=20) {
  # deparse warns and uses 65 if maxChar20, so avoid that.
  retval - deparse(x, width.cutoff=max(20, maxChar+1), nlines=1)
  if (nchar(retval)  maxChar) {
  retval - paste0(substring(retval, 1, maxChar), ...)
  }
  retval
  }
Bill Dunlap
TIBCO Software
wdunlap tibco.com


On Mon, May 5, 2014 at 2:44 PM, Spencer Graves
spencer.gra...@structuremonitoring.com wrote:
Is there a standard or or a standard utility to limit the size of
 deparse(substitute(.))?


Below please find an example of the problem plus one solution.
 If another solution already exists, I might prefer to use it.


Thanks,
Spencer


 ##
 ## Problem
 ##
 deparse.x0 - function(x)deparse(substitute(x))
 deparse.a - do.call(deparse.x0, list(letters))
 nchar(deparse.a) # unacceptable

 [1] 62 65  4


 ##
 ## Better
 ##
 deparse.x - function(x, maxChar=20){
name.x - deparse(substitute(x))
nch.x - nchar(name.x)
name2 - name.x[nch.x0]
nch2 - nch.x[nch.x0]
if((length(name2)1)){
  name2 - name2[1]
}
if(nch2[1]maxChar){
  name2 - paste0(substring(name2, 1, maxChar), '...')
}
name2
 }

 do.call(deparse.x, list(letters)) # better

 [1] c(\a\, \b\, \c\, \d\...




 [[alternative HTML version deleted]]

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

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

2014-05-05 Thread Gabor Grothendieck
On Fri, May 2, 2014 at 5:23 PM, Dr Eberhard Lisse nos...@lisse.na wrote:
 Hi,

 How do I do something like this without using sqldf?

 a - sqldf(SELECT COUNT(*) FROM b WHERE c = 'd')

 or

 e - sqldf(SELECT f, COUNT(*) FROM b GROUP BY f ORDER BY f)


In the examples section at the bottom of ?sqldf are a number of SQL
statements and the corresponding R statements.

-- 
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] Max characters from deparse(substitute(.))?

2014-05-05 Thread Spencer Graves

On 5/5/2014 3:42 PM, William Dunlap wrote:

Have you looked at the width.cutoff and nlines arguments to deparse?
width.cutoff controls how long a line can be and it quits producing
output (saving time and space) after nlines of output are produced.
You want essentially the following
f0 - function(x, maxChar=20) deparse(x, width.cutoff=maxChar, nlines=1)
or, to add the '...' to the end if something was cut off
   f1 - function(x, maxChar=20) {
   # deparse warns and uses 65 if maxChar20, so avoid that.
   retval - deparse(x, width.cutoff=max(20, maxChar+1), nlines=1)
   if (nchar(retval)  maxChar) {
   retval - paste0(substring(retval, 1, maxChar), ...)
   }
   retval
   }


Hi, Bill:  Thanks very much.  I could have solved it myself if I had 
known which FMTR.  Thanks again.  Spencer



Bill Dunlap
TIBCO Software
wdunlap tibco.com


On Mon, May 5, 2014 at 2:44 PM, Spencer Graves
spencer.gra...@structuremonitoring.com wrote:

Is there a standard or or a standard utility to limit the size of
deparse(substitute(.))?


Below please find an example of the problem plus one solution.
If another solution already exists, I might prefer to use it.


Thanks,
Spencer


##
## Problem
##
deparse.x0 - function(x)deparse(substitute(x))
deparse.a - do.call(deparse.x0, list(letters))
nchar(deparse.a) # unacceptable

[1] 62 65  4


##
## Better
##
deparse.x - function(x, maxChar=20){
name.x - deparse(substitute(x))
nch.x - nchar(name.x)
name2 - name.x[nch.x0]
nch2 - nch.x[nch.x0]
if((length(name2)1)){
  name2 - name2[1]
}
if(nch2[1]maxChar){
  name2 - paste0(substring(name2, 1, maxChar), '...')
}
name2
}

do.call(deparse.x, list(letters)) # better

[1] c(\a\, \b\, \c\, \d\...




 [[alternative HTML version deleted]]

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


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

2014-05-05 Thread Gabor Grothendieck
On Mon, May 5, 2014 at 9:43 AM, Niloofar.Javanrouh
javanrou...@yahoo.com wrote:


  hello,
 i want to differentiate of L with respect to b
 when:

 L= k*ln (k/(k+mu)) + sum(y) * ln (1-(k/mu+k))   #(negative binomial ln 
 likelihood)
 and
 ln(mu/(mu+k)) = a+bx   #link function

 how can i do it in R?

Try this.  First we solve for 'mu' in terms of the other variables
using the link equation:

 library(Ryacas)
 k - Sym(k)
 mu - Sym(mu)
 y - Sym(y)
 L - Sym(L)
 a - Sym(a)
 b - Sym(b)
 x - Sym(x)
 sumy - Sym(sumy)
 Solve(log(mu/(mu+k)) == a+b*x, mu)
expression(list(mu == k * exp(a + b * x)/(1 - exp(a + b * x


Now in 'k*log(k/(k+mu)) + sumy * log(1-(k/mu+k))' substitute 'k *
exp(a + b * x)/(1 - exp(a + b * x)))' for 'mu' using 'Subst' and take
the derivative with respect to 'a' using 'deriv':

 s - Subst(k*log(k/(k+mu)) + sumy * log(1-(k/mu+k)), mu,
+   k * exp(a + b * x)/(1 - exp(a + b * x)))
 deriv(s, a)
expression(sumy * (k * ((1 - exp(a + b * x)) * (k * exp(a + b *
x)) + k * exp(a + b * x)^2))/((1 - exp(a + b * x))^2 * (k *
exp(a + b * x)/(1 - exp(a + b * x)))^2 * (1 - (k * (1 - exp(a +
b * x))/(k * exp(a + b * x)) + k))) - k * ((k + k * exp(a +
b * x)/(1 - exp(a + b * x))) * (k * ((1 - exp(a + b * x)) *
(k * exp(a + b * x)) + k * exp(a + b * x)^2)))/((1 - exp(a +
b * x))^2 * ((k + k * exp(a + b * x)/(1 - exp(a + b * x)))^2 *
k)))

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

2014-05-05 Thread David Winsemius

On May 5, 2014, at 6:05 PM, Gabor Grothendieck wrote:

 On Mon, May 5, 2014 at 9:43 AM, Niloofar.Javanrouh
 javanrou...@yahoo.com wrote:
 
 
 hello,
 i want to differentiate of L with respect to b
 when:
 
 L= k*ln (k/(k+mu)) + sum(y) * ln (1-(k/mu+k))   #(negative binomial ln 
 likelihood)
 and
 ln(mu/(mu+k)) = a+bx   #link function
 
 how can i do it in R?
 
 Try this.  First we solve for 'mu' in terms of the other variables
 using the link equation:
 
 library(Ryacas)
 k - Sym(k)
 mu - Sym(mu)
 y - Sym(y)
 L - Sym(L)
 a - Sym(a)
 b - Sym(b)
 x - Sym(x)
 sumy - Sym(sumy)
 Solve(log(mu/(mu+k)) == a+b*x, mu)
 expression(list(mu == k * exp(a + b * x)/(1 - exp(a + b * x
 
 
 Now in 'k*log(k/(k+mu)) + sumy * log(1-(k/mu+k))' substitute 'k *
 exp(a + b * x)/(1 - exp(a + b * x)))' for 'mu' using 'Subst' and take
 the derivative with respect to 'a' using 'deriv':
 
 s - Subst(k*log(k/(k+mu)) + sumy * log(1-(k/mu+k)), mu,
 +   k * exp(a + b * x)/(1 - exp(a + b * x)))
 deriv(s, a)
 expression(sumy * (k * ((1 - exp(a + b * x)) * (k * exp(a + b *
x)) + k * exp(a + b * x)^2))/((1 - exp(a + b * x))^2 * (k *
exp(a + b * x)/(1 - exp(a + b * x)))^2 * (1 - (k * (1 - exp(a +
b * x))/(k * exp(a + b * x)) + k))) - k * ((k + k * exp(a +
b * x)/(1 - exp(a + b * x))) * (k * ((1 - exp(a + b * x)) *
(k * exp(a + b * x)) + k * exp(a + b * x)^2)))/((1 - exp(a +
b * x))^2 * ((k + k * exp(a + b * x)/(1 - exp(a + b * x)))^2 *
k)))
 

But can we maybe get the Taylor series approximation to first or second order?

-- 

David Winsemius
Alameda, CA, USA

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


Re: [R] multiply of two expressions

2014-05-05 Thread Gabor Grothendieck
On Mon, May 5, 2014 at 10:16 PM, David Winsemius dwinsem...@comcast.net wrote:

 On May 5, 2014, at 6:05 PM, Gabor Grothendieck wrote:

 On Mon, May 5, 2014 at 9:43 AM, Niloofar.Javanrouh
 javanrou...@yahoo.com wrote:


 hello,
 i want to differentiate of L with respect to b
 when:

 L= k*ln (k/(k+mu)) + sum(y) * ln (1-(k/mu+k))   #(negative binomial ln 
 likelihood)
 and
 ln(mu/(mu+k)) = a+bx   #link function

 how can i do it in R?

 Try this.  First we solve for 'mu' in terms of the other variables
 using the link equation:

 library(Ryacas)
 k - Sym(k)
 mu - Sym(mu)
 y - Sym(y)
 L - Sym(L)
 a - Sym(a)
 b - Sym(b)
 x - Sym(x)
 sumy - Sym(sumy)
 Solve(log(mu/(mu+k)) == a+b*x, mu)
 expression(list(mu == k * exp(a + b * x)/(1 - exp(a + b * x


 Now in 'k*log(k/(k+mu)) + sumy * log(1-(k/mu+k))' substitute 'k *
 exp(a + b * x)/(1 - exp(a + b * x)))' for 'mu' using 'Subst' and take
 the derivative with respect to 'a' using 'deriv':

 s - Subst(k*log(k/(k+mu)) + sumy * log(1-(k/mu+k)), mu,
 +   k * exp(a + b * x)/(1 - exp(a + b * x)))
 deriv(s, a)
 expression(sumy * (k * ((1 - exp(a + b * x)) * (k * exp(a + b *
x)) + k * exp(a + b * x)^2))/((1 - exp(a + b * x))^2 * (k *
exp(a + b * x)/(1 - exp(a + b * x)))^2 * (1 - (k * (1 - exp(a +
b * x))/(k * exp(a + b * x)) + k))) - k * ((k + k * exp(a +
b * x)/(1 - exp(a + b * x))) * (k * ((1 - exp(a + b * x)) *
(k * exp(a + b * x)) + k * exp(a + b * x)^2)))/((1 - exp(a +
b * x))^2 * ((k + k * exp(a + b * x)/(1 - exp(a + b * x)))^2 *
k)))


 But can we maybe get the Taylor series approximation to first or second order?




 Taylor(d, a, 0, 2)
expression(sumy * (k * ((1 - exp(b * x)) * (k * exp(b * x)) +
k * exp(b * x)^2))/((1 - exp(b * x))^2 * (k * exp(b * x)/(1 -
exp(b * x)))^2 * (1 - (k * (1 - exp(b * x))/(k * exp(b *
x)) + k))) - k * ((k + k * exp(b * x)/(1 - exp(b * x))) *
(k * ((1 - exp(b * x)) * (k * exp(b * x)) + k * exp(b * x)^2)))/((1 -
exp(b * x))^2 * ((k + k * exp(b * x)/(1 - exp(b * x)))^2 *
k)) + (((1 - exp(b * x))^2 * (k * exp(b * x)/(1 - exp(b *
x)))^2 * (1 - (k * (1 - exp(b * x))/(k * exp(b * x)) + k)) *
(sumy * (k * ((1 - exp(b * x)) * (k * exp(b * x)) - k * exp(b *
x)^2 + k * (2 * exp(b * x)^2 - sumy * (k * ((1 -
exp(b * x)) * (k * exp(b * x)) + k * exp(b * x)^2)) * ((1 -
exp(b * x))^2 * (k * exp(b * x)/(1 - exp(b * x)))^2 * (k *
((1 - exp(b * x)) * (k * exp(b * x)) + k * exp(b * x)^2))/((1 -
exp(b * x))^2 * (k * exp(b * x)/(1 - exp(b * x)))^2) + ((1 -
exp(b * x))^2 * (k * exp(b * x) * (2 * ((1 - exp(b * x)) *
(k * exp(b * x)) + k * exp(b * x)^2)))/(1 - exp(b * x))^3 +
-2 * exp(b * x) * (1 - exp(b * x)) * (k * exp(b * x)/(1 -
exp(b * x)))^2) * (1 - (k * (1 - exp(b * x))/(k * exp(b *
x)) + k/((1 - exp(b * x))^2 * (k * exp(b * x)/(1 - exp(b *
x)))^2 * (1 - (k * (1 - exp(b * x))/(k * exp(b * x)) + k)))^2 -
((1 - exp(b * x))^2 * ((k + k * exp(b * x)/(1 - exp(b * x)))^2 *
k) * (k * ((k + k * exp(b * x)/(1 - exp(b * x))) * (k *
((1 - exp(b * x)) * (k * exp(b * x)) - k * exp(b * x)^2 +
k * (2 * exp(b * x)^2))) + k * ((1 - exp(b * x)) *
(k * exp(b * x)) + k * exp(b * x)^2)^2/(1 - exp(b * x))^2)) -
k * ((k + k * exp(b * x)/(1 - exp(b * x))) * (k * ((1 -
exp(b * x)) * (k * exp(b * x)) + k * exp(b * x)^2))) *
((1 - exp(b * x))^2 * (k * ((k + k * exp(b * x)/(1 -
exp(b * x))) * (2 * ((1 - exp(b * x)) * (k *
exp(b * x)) + k * exp(b * x)^2/(1 - exp(b *
x))^2 + -2 * exp(b * x) * (1 - exp(b * x)) *
((k + k * exp(b * x)/(1 - exp(b * x)))^2 * k)))/((1 -
exp(b * x))^2 * ((k + k * exp(b * x)/(1 - exp(b * x)))^2 *
k))^2) * a + a^2 * 1 - exp(b * x))^2 * (k * exp(b *
x)/(1 - exp(b * x)))^2 * (1 - (k * (1 - exp(b * x))/(k *
exp(b * x)) + k)))^2 * ((1 - exp(b * x))^2 * (k * exp(b *
x)/(1 - exp(b * x)))^2 * (1 - (k * (1 - exp(b * x))/(k *
exp(b * x)) + k)) * (sumy * (k * ((1 - exp(b * x)) * (k *
exp(b * x)) - k * exp(b * x)^2 - k * (2 * exp(b * x)^2) +
k * (4 * exp(b * x)^2 + ((1 - exp(b * x))^2 * (k * exp(b *
x)/(1 - exp(b * x)))^2 * (k * ((1 - exp(b * x)) * (k * exp(b *
x)) + k * exp(b * x)^2))/((1 - exp(b * x))^2 * (k * exp(b *
x)/(1 - exp(b * x)))^2) + ((1 - exp(b * x))^2 * (k * exp(b *
x) * (2 * ((1 - exp(b * x)) * (k * exp(b * x)) + k * exp(b *
x)^2)))/(1 - exp(b * x))^3 + -2 * exp(b * x) * (1 - exp(b *
x)) * (k * exp(b * x)/(1 - exp(b * x)))^2) * (1 - (k * (1 -
exp(b * x))/(k * exp(b * x)) + k))) * (sumy * (k * ((1 -
exp(b * x)) * (k * exp(b * x)) - k * exp(b * x)^2 + k * (2 *
exp(b * x)^2 - (sumy * (k * ((1 - exp(b * x)) * (k *
exp(b * x)) + k * exp(b * x)^2)) * (((1 - exp(b * x))^2 *
(k * exp(b * x)/(1 - exp(b * x)))^2 * ((1 - exp(b * x))^2 *
(k * exp(b * x)/(1 - exp(b * x)))^2 * (k * ((1 - exp(b *
x)) * 

Re: [R] Problem with products in R ?

2014-05-05 Thread Richard M. Heiberger
Gabor,

Can you confirm that the bc function is supposed to be current.
The bc package works with my Mac, but not with Windows.
I keep getting the message

Error in system(cmd, input = input, intern = TRUE) : -l

The FAQ on your https://code.google.com/p/r-bc/ page didn't get me past that
problem.  I tried both the download bc.zip from the page and also the cygwin bc.

A secondary issue is that placing your bc.exe into c:/Program
Files/R/R-3.1.0/library/bc/bcdir/bc.exe
gives the message
 one - bc(1)
Error in system(cmd, input = input, intern = TRUE) :
  'C:/Program' not found

Working around that is possible with
 bc.cmd - C:/Progra~1/R/R-3.1.0/library/bc/bcdir/bc.exe -l
 one - bc(1, cmd=bc.cmd)
but the next line gives the same problem
 one
Error in system(cmd, input = input, intern = TRUE) :
  'C:/Program' not found

Thanks
Rich


On Sun, May 4, 2014 at 1:10 PM, Gabor Grothendieck
ggrothendi...@gmail.com wrote:
 Checking this with the bc R package (https://code.google.com/p/r-bc/),
 the Ryacas package (CRAN), the gmp package (CRAN) and the Windows 8.1
 calculator all four give the same result:

 library(bc)
 bc(168988580159 * 36662978)
 [1] 6195624596620653502

 library(Ryacas)
 yacas(168988580159 * 36662978, retclass = character)
 6195624596620653502

 library(gmp)
 as.bigz(168988580159) * as.bigz(36662978)
 Big Integer ('bigz') :
 [1] 6195624596620653502


 On Sun, May 4, 2014 at 12:50 PM, Ted Harding ted.hard...@wlandres.net wrote:
 On 04-May-2014 14:13:27 Jorge I Velez wrote:
 Try

 options(digits = 22)
 168988580159 * 36662978
# [1] 6195624596620653568

 HTH,
 Jorge.-

 Err, not quite ... !
 I hitch my horses to my plough (with help from R):

 options(digits=22)
 168988580159*8 = 1351908641272 (copy down)
 168988580159*7 = 1182920061113  (   )
 168988580159*9 = 1520897221431  (   )
 168988580159*2 =  337977160318  (   )
 168988580159*6 = 1013931480954  (   )^3
 168988580159*3 =  506965740477  (   )

  1351908641272
 11829200611130
152089722143100
337977160318000
  1013931480954
 10139314809540
101393148095400
506965740477000
 ==
6195624596620653502
 [after adding up mentally]

 compared with Jorge's:
6195624596620653568

 (02 vs 68 in the final two digits).

 Alternatively, if using a unixoid system with 'bc' present,
 one can try interfacing R with 'bc'. 'bc' is an calculating
 engine which works to arbitrary precision.

 There certainly used to be a utility in which R can evoke 'bc',
 into which one can enter a 'bc' command and get the result
 returned as a string, but I can't seem to find it on CRAN now.
 In any case, the raw UNIX command line for this calculation
 with 'bc' (with result) is:

 $ bc -l
 [...]
 168988580159 * 36662978
 6195624596620653502
 quit

 which agrees with my horse-drawn working.

 Best wishes to all,
 Ted.

 On Sun, May 4, 2014 at 10:44 PM, ARTENTOR Diego Tentor 
 diegotento...@gmail.com wrote:

 Trying algorithm for products with large numbers i encountered a difference
 between result of 168988580159 * 36662978 in my algorithm and r product.
 The Microsoft calculator confirm my number.

 Thanks.
 --
 *Gráfica ARTENTOR  *

 de Diego L. Tentor
 Echagüe 558
 Tel.:0343 4310119
 Paraná - Entre Ríos

 -
 E-Mail: (Ted Harding) ted.hard...@wlandres.net
 Date: 04-May-2014  Time: 17:50:54
 This message was sent by XFMail

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



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


Re: [R] Problem with products in R ?

2014-05-05 Thread Gabor Grothendieck
1. Firstly your library should be in user space.  Don't use the one in
C:\Program Files\... .  That is the case not only for bc but for other
packages too.  Reinstall R and the first time you install a package it
should ask you to allow it to create a user library.  Be sure you
allow that.

2. As indicated in the FAQ which bc you use  matters.  I am using the
one on the Downloads tab, i.e. here:

https://code.google.com/p/r-bc/downloads/list

If you are using a different bc then try this one.

3. Also ensure bc on your path.  From within R: Sys.which(bc) should
find it if its on your path.

4. I usually just source the bc.R file and that seems to work for me.
I just added a NAMESPACE file to the svn repo so that the package will
build and install on more recent versions of R.

This works for me on R 3.1 patched under Windows 8.1:

 source(http://r-bc.googlecode.com/svn/trunk/R/bc.R;)
  one - bc(1)
 one
[1] 1

and with the version of the repo that I just updated a few minutes ago
and building and installing bc in a separate session this works too:
 library(bc)
 bc(1)
[1] 1


On Mon, May 5, 2014 at 11:09 PM, Richard M. Heiberger r...@temple.edu wrote:
 Gabor,

 Can you confirm that the bc function is supposed to be current.
 The bc package works with my Mac, but not with Windows.
 I keep getting the message

 Error in system(cmd, input = input, intern = TRUE) : -l

 The FAQ on your https://code.google.com/p/r-bc/ page didn't get me past that
 problem.  I tried both the download bc.zip from the page and also the cygwin 
 bc.

 A secondary issue is that placing your bc.exe into c:/Program
 Files/R/R-3.1.0/library/bc/bcdir/bc.exe
 gives the message
 one - bc(1)
 Error in system(cmd, input = input, intern = TRUE) :
   'C:/Program' not found

 Working around that is possible with
 bc.cmd - C:/Progra~1/R/R-3.1.0/library/bc/bcdir/bc.exe -l
 one - bc(1, cmd=bc.cmd)
 but the next line gives the same problem
 one
 Error in system(cmd, input = input, intern = TRUE) :
   'C:/Program' not found

 Thanks
 Rich


 On Sun, May 4, 2014 at 1:10 PM, Gabor Grothendieck
 ggrothendi...@gmail.com wrote:
 Checking this with the bc R package (https://code.google.com/p/r-bc/),
 the Ryacas package (CRAN), the gmp package (CRAN) and the Windows 8.1
 calculator all four give the same result:

 library(bc)
 bc(168988580159 * 36662978)
 [1] 6195624596620653502

 library(Ryacas)
 yacas(168988580159 * 36662978, retclass = character)
 6195624596620653502

 library(gmp)
 as.bigz(168988580159) * as.bigz(36662978)
 Big Integer ('bigz') :
 [1] 6195624596620653502


 On Sun, May 4, 2014 at 12:50 PM, Ted Harding ted.hard...@wlandres.net 
 wrote:
 On 04-May-2014 14:13:27 Jorge I Velez wrote:
 Try

 options(digits = 22)
 168988580159 * 36662978
# [1] 6195624596620653568

 HTH,
 Jorge.-

 Err, not quite ... !
 I hitch my horses to my plough (with help from R):

 options(digits=22)
 168988580159*8 = 1351908641272 (copy down)
 168988580159*7 = 1182920061113  (   )
 168988580159*9 = 1520897221431  (   )
 168988580159*2 =  337977160318  (   )
 168988580159*6 = 1013931480954  (   )^3
 168988580159*3 =  506965740477  (   )

  1351908641272
 11829200611130
152089722143100
337977160318000
  1013931480954
 10139314809540
101393148095400
506965740477000
 ==
6195624596620653502
 [after adding up mentally]

 compared with Jorge's:
6195624596620653568

 (02 vs 68 in the final two digits).

 Alternatively, if using a unixoid system with 'bc' present,
 one can try interfacing R with 'bc'. 'bc' is an calculating
 engine which works to arbitrary precision.

 There certainly used to be a utility in which R can evoke 'bc',
 into which one can enter a 'bc' command and get the result
 returned as a string, but I can't seem to find it on CRAN now.
 In any case, the raw UNIX command line for this calculation
 with 'bc' (with result) is:

 $ bc -l
 [...]
 168988580159 * 36662978
 6195624596620653502
 quit

 which agrees with my horse-drawn working.

 Best wishes to all,
 Ted.

 On Sun, May 4, 2014 at 10:44 PM, ARTENTOR Diego Tentor 
 diegotento...@gmail.com wrote:

 Trying algorithm for products with large numbers i encountered a 
 difference
 between result of 168988580159 * 36662978 in my algorithm and r product.
 The Microsoft calculator confirm my number.

 Thanks.
 --
 *Gráfica ARTENTOR  *

 de Diego L. Tentor
 Echagüe 558
 Tel.:0343 4310119
 Paraná - Entre Ríos

 -
 E-Mail: (Ted Harding) ted.hard...@wlandres.net
 Date: 04-May-2014  Time: 17:50:54
 This message was sent by XFMail

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



 --
 Statistics  Software Consulting
 GKX Group, GKX 

Re: [R] list.files accessing subdirectory as relative path?

2014-05-05 Thread Frede Aakmann Tøgersen
Hi

.. is the parent directory whereas . is the current directory, so you 
probably want

list.files(path = ./Least Developed Countries)

instead of

list.files(path = ../Least Developed Countries)

Yours sincerely / Med venlig hilsen


Frede Aakmann Tøgersen
Specialist, M.Sc., Ph.D.
Plant Performance  Modeling

Technology  Service Solutions
T +45 9730 5135
M +45 2547 6050
fr...@vestas.com
http://www.vestas.com

Company reg. name: Vestas Wind Systems A/S
This e-mail is subject to our e-mail disclaimer statement.
Please refer to www.vestas.com/legal/notice
If you have received this e-mail in error please contact the sender. 


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of Adel
 Sent: 5. maj 2014 21:30
 To: r-help@r-project.org
 Subject: [R] list.files accessing subdirectory as relative path?
 
 Dear list members,
 
 I would like to access a subdirectory given where the work directory has
 been set. So I have:
 
  getwd()
 [1] C:/Users/Lord Adellus/Dropbox/I8child1/Data
 
  list.files() # give three folders
  [1] Least Developed Countries
  [4] Low middle income grouping More advanced
 developing countries and territories
 
  list.files(path = ../Least Developed Countries) # I want to access now
  one of the subdirectories
 character(0)
 
 But as you can see R does not want to look into the specified subdirectory.
 I have tried several combination and searched the list but without any great
 success.
 
 Actually:
 
 list.files(path = ../...) #goes up one level in the folder structure so I
 cannot see what the problem is.
 
 
 Thanks in advance.
 Adel
 
 
 
 
 --
 View this message in context: http://r.789695.n4.nabble.com/list-files-
 accessing-subdirectory-as-relative-path-tp4689997.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] Making a package works on any R version

2014-05-05 Thread Ashis Deb
Hi all   I  had made a package  in  R-3.0.3  , and its running  well   ,
my  issue is  it  is  not running in  other versions   or  R   like
R-3.0.2/3.0.1  it is  showing error  like  ---


Error: This is R 3.0.2, package ‘xxx’ needs = 3.0.3



Does anybody  have  the solution  on  how  to  make this  package  run  on
any  versions  .

i  know its   not  a  big problem  ,  please forgive my  ignorance   if it
sounds  silly .


Thanks ,

ASHIS

[[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 Histogram with Normal Curve - Y axis as percentages

2014-05-05 Thread Duncan Mackay
Hi Jim

Without going to the histogram function to study it in detail it appears 
when there is  density used  in the histogram function the data has to be in
the original scale to to send to the panel function.

As you example is not reproducible use the singer data to get the ylimits
for the histogram and density plot separately

For density
d -
histogram( ~ height | voice.part, data = singer,
  xlab = Height (inches), type = density,
  panel = function(x, ...) {
 # panel.histogram(x, ...)
  panel.abline(v= 70)
  panel.mathdensity(dmath = dnorm, col = black,
args = list(mean=mean(x),sd=sd(x)))
  } )

d$y.limits ...

and the same for the histogram with type = percent

if you divide the last by the former there is a difference of 192 (ie
scaling factor)

Using the full dataset as it is quicker to demonstrate

histogram( ~ height, data = singer,
  type = percent, border = transparent, col.line = grey60,
  xlab = Height (inches),
  ylab = Density Histogram\n with Normal Fit )

trellis.focus(panel, 1, 1, clip.off=F, highlight = FALSE)
llines(density(singer$height)$x, density(singer$height)$y*192)
trellis.unfocus()

This will give you the idea that it is possible. y axes labels etc are all
funny now

By using a user defined panel function  plotting the histogram and the
density output plotted as panel.lines after scaling within the function you
should be able to get a plot
It may be easier to start off with an xyplot to send the data to the panel
function as you will need 2 types of data as original and that for the
histogram.
Whether you need to use panel.groups is another mater

HTH

Duncan

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


-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of jimdare
Sent: Tuesday, 6 May 2014 06:23
To: r-help@r-project.org
Subject: [R] Lattice Histogram with Normal Curve - Y axis as percentages

Hello,

This may seem like a simple problem, but it's frustrating me immensely.  I'm
trying to overlay a normal curve (dnorm) on top of a histogram using the
code below.  This works find when the type = density, but the person for
whom I'm making the plot wants the y axis in percent of total rather than
density.  When I change type to percent, I get the histogram scale I'm
after, but the dnorm plot is greatly reduced.  How could I scale the density
plot to the percent of total axis.  Alternatively, perhaps there is a way to
add density to a secondary y axis?

Thanks in advance for your help.

Jimdare


plot-histogram(~rdf[,j]|Year,nint=20, data=rdf,main = i,strip =
my.strip,xlab = j,  
   type = percent,layout=c(2,1),
   panel=function(x, ...) {
   panel.histogram(x, ...)

   panel.mathdensity(dmath=dnorm, col=black, 
  # Add na.rm = TRUE to mean() and sd()
args=list(mean=mean(x, na.rm = TRUE),
sd=sd(x, na.rm = TRUE)), ...)
}) 



--
View this message in context:
http://r.789695.n4.nabble.com/Lattice-Histogram-with-Normal-Curve-Y-axis-as-
percentages-tp469.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-es] Mapa de quantiles con spplot

2014-05-05 Thread Olivier Nuñez
No resulta fácil contestarte con la información que proporcionas.
Sobre la base de las variables que definiste, intuyó que lo siguiente debería
funcionar:

zm$clases - class
spplot(zm, clases , col.regions=plotclr)

Un saludo. Olivier

 Hola,

 Intento representar en un mapa participaciones porcentuales de los sectores
 económicos y no logro hacerlo con spplot.

 He intentado con spplot(zm, c(“part88”, “part93”), cuts=4, 
 col.regions=brewer.pal(4,
 “Set3”))

 Lo pude hacer utilizando el base graphics de R, definiendo:

 plotvar88 - zm$part88
 nclr - 8
 plotclr - brewer.pal(nclr, PuOr)
 plotclr - plotclr[nclr:1]
 class - classIntervals(plotvar88, nclr, style=quantile)
 colcode - findColours(class, plotclr)
 plot(zm)
 plot(zm, col=colcode, add=T)
 legend(3377189,2249615, legend=names(attr(colcode, table)), 
 fill=attr(colcode,
 palette), cex=0.6, bty=n”)

 Después intenté meter algunos de esos argumentos utilizando spplot

 spplot(zm, c(“part88”, “part93”), col.regions=plotclr, cuts=nclr)

 y tampoco funcionó.

 Tengo algunas nociones de cómo hacerlo en spplot, pero no sé cómo, pues 
 desconozco
 la forma en utilizar los argumentos por ejemplo usando “cuts”, “at”. He 
 revisado la
 ayuda que provee el paquete y sigo sin poder concretarlo.

 Agradecería un poco de orientación.

 Saludos cordiales.

 Rolando Valdez

 ___
 R-help-es mailing list
 R-help-es@r-project.org
 https://stat.ethz.ch/mailman/listinfo/r-help-es



--



Olivier G. Nuñez
Email: onu...@unex.es
http://kolmogorov.unex.es/~onunez
Tel : +34 663 03 69 09
Departamento de Matemáticas
Universidad de Extremadura

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


Re: [R-es] Mapa de quantiles con spplot

2014-05-05 Thread Rolando Valdez
No me sale ningún error, simplemente el resultado no es el esperado.

Les comparto la carpeta con la capa y los datos que estoy usando.

https://www.dropbox.com/s/umy0evt3qm1wr4d/dissolve.zip

Esto es lo que estoy haciendo:

library(rgdal)
library(maptools)
library(sp)
library(classInt)
library(RColorBrewer)
zm - readOGR(“.”, “zmdis”)
data - read.csv(“part_pot.csv”, header=T, sep=“,”, dec=“.”)
zm@data=data.frame(data)
plotvar88 - zm$part88
nclr - 8
plotclr - brewer.pal(nclr, “Blues”)
class - classIntervals(plotvar88, nclr, style=“quantile”)
colcode - findColours(class, plotclr)
plot(zm)
plot(zm, col=colcode, add=T)
legend(3777189,2249615, legend=names(attar(colcode, “table”)), 
fill=attr(colcode, “palette”), cex=0.6, bty=“n”)

Entonces obtengo el mapa como lo quiero (Me falta la división política, pero 
para este ejemplo la omití):

https://www.dropbox.com/s/w3ps61o4jr1ciy5/part88.tiff

Cuando lo hago con spplot:

spplot(zm, part88, col.regions=plotclr, cuts=nclr, key.space=bottom”)

Me regresa lo siguiente:

https://www.dropbox.com/s/2cgiua5ra2tx4a0/part88_spplot.tiff

Entonces lo que quiero es usar el spplot para pintar dos variables c(“part88”, 
“part93”), que el mismo ‘legend’ aplique para ambas.




El 05/05/2014, a las 05:44, Oscar Perpiñan oscar.perpi...@upm.es escribió:

 Hola Rolando,
 
 Por el código que muestras debiera funcionar, pero falta información
 para poder responderte.
 Cuando dices que no funcionó, ¿que significa? ¿Obtienes un error? ¿El
 resultado no es el esperado?
 Por favor, envía los datos que estás utilizando, al menos una muestra,
 o algo que sirva para poder reproducir tu código.
 
 Saludos.
 
 Oscar.
 -
 Oscar Perpiñán Lamigueiro
 Dpto. Ingeniería Eléctrica (ETSIDI-UPM)
 Grupo de Sistemas Fotovoltaicos (IES-UPM)
 URL: http://oscarperpinan.github.io
 Twitter: @oscarperpinan
 
 
 El día 3 de mayo de 2014, 21:39, Rolando Valdez rvald...@gmail.com escribió:
 Hola,
 
 Intento representar en un mapa participaciones porcentuales de los sectores 
 económicos y no logro hacerlo con spplot.
 
 He intentado con spplot(zm, c(“part88”, “part93”), cuts=4, 
 col.regions=brewer.pal(4, “Set3”))
 
 Lo pude hacer utilizando el base graphics de R, definiendo:
 
 plotvar88 - zm$part88
 nclr - 8
 plotclr - brewer.pal(nclr, PuOr)
 plotclr - plotclr[nclr:1]
 class - classIntervals(plotvar88, nclr, style=quantile)
 colcode - findColours(class, plotclr)
 plot(zm)
 plot(zm, col=colcode, add=T)
 legend(3377189,2249615, legend=names(attr(colcode, table)), 
 fill=attr(colcode, palette), cex=0.6, bty=n”)
 
 Después intenté meter algunos de esos argumentos utilizando spplot
 
 spplot(zm, c(“part88”, “part93”), col.regions=plotclr, cuts=nclr)
 
 y tampoco funcionó.
 
 Tengo algunas nociones de cómo hacerlo en spplot, pero no sé cómo, pues 
 desconozco la forma en utilizar los argumentos por ejemplo usando “cuts”, 
 “at”. He revisado la ayuda que provee el paquete y sigo sin poder 
 concretarlo.
 
 Agradecería un poco de orientación.
 
 Saludos cordiales.
 
 Rolando Valdez
 
 ___
 R-help-es mailing list
 R-help-es@r-project.org
 https://stat.ethz.ch/mailman/listinfo/r-help-es

Rolando Valdez

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


Re: [R-es] Mapa de quantiles con spplot

2014-05-05 Thread Rolando Valdez
Hola, no me funciona:

Te contesto lo mismo que le contesté a otro compañero de la lista, espero ser 
más claro.

Les comparto la carpeta con la capa y los datos que estoy usando.

https://www.dropbox.com/s/umy0evt3qm1wr4d/dissolve.zip

Esto es lo que estoy haciendo:

library(rgdal)
library(maptools)
library(sp)
library(classInt)
library(RColorBrewer)
zm - readOGR(“.”, “zmdis”)
data - read.csv(“part_pot.csv”, header=T, sep=“,”, dec=“.”)
zm@data=data.frame(data)
plotvar88 - zm$part88
nclr - 8
plotclr - brewer.pal(nclr, “Blues”)
class - classIntervals(plotvar88, nclr, style=“quantile”)
colcode - findColours(class, plotclr)
plot(zm)
plot(zm, col=colcode, add=T)
legend(3777189,2249615, legend=names(attar(colcode, “table”)), 
fill=attr(colcode, “palette”), cex=0.6, bty=“n”)

Entonces obtengo el mapa como lo quiero (Me falta la división política, pero 
para este ejemplo la omití):

https://www.dropbox.com/s/w3ps61o4jr1ciy5/part88.tiff

Cuando lo hago con spplot:

spplot(zm, part88, col.regions=plotclr, cuts=nclr, key.space=bottom”)

Me regresa lo siguiente:

https://www.dropbox.com/s/2cgiua5ra2tx4a0/part88_spplot.tiff

Entonces lo que quiero es usar el spplot para pintar dos variables c(“part88”, 
“part93”), que el mismo ‘legend’ aplique para ambas.

Saludos cordiales
El 05/05/2014, a las 10:39, Olivier Nuñez onu...@unex.es escribió:

 No resulta fácil contestarte con la información que proporcionas.
 Sobre la base de las variables que definiste, intuyó que lo siguiente debería
 funcionar:
 
 zm$clases - class
 spplot(zm, clases , col.regions=plotclr)
 
 Un saludo. Olivier
 
 Hola,
 
 Intento representar en un mapa participaciones porcentuales de los sectores
 económicos y no logro hacerlo con spplot.
 
 He intentado con spplot(zm, c(“part88”, “part93”), cuts=4, 
 col.regions=brewer.pal(4,
 “Set3”))
 
 Lo pude hacer utilizando el base graphics de R, definiendo:
 
 plotvar88 - zm$part88
 nclr - 8
 plotclr - brewer.pal(nclr, PuOr)
 plotclr - plotclr[nclr:1]
 class - classIntervals(plotvar88, nclr, style=quantile)
 colcode - findColours(class, plotclr)
 plot(zm)
 plot(zm, col=colcode, add=T)
 legend(3377189,2249615, legend=names(attr(colcode, table)), 
 fill=attr(colcode,
 palette), cex=0.6, bty=n”)
 
 Después intenté meter algunos de esos argumentos utilizando spplot
 
 spplot(zm, c(“part88”, “part93”), col.regions=plotclr, cuts=nclr)
 
 y tampoco funcionó.
 
 Tengo algunas nociones de cómo hacerlo en spplot, pero no sé cómo, pues 
 desconozco
 la forma en utilizar los argumentos por ejemplo usando “cuts”, “at”. He 
 revisado la
 ayuda que provee el paquete y sigo sin poder concretarlo.
 
 Agradecería un poco de orientación.
 
 Saludos cordiales.
 
 Rolando Valdez
 
 ___
 R-help-es mailing list
 R-help-es@r-project.org
 https://stat.ethz.ch/mailman/listinfo/r-help-es
 
 
 
 --
 
 
 
 Olivier G. Nuñez
 Email: onu...@unex.es
 http://kolmogorov.unex.es/~onunez
 Tel : +34 663 03 69 09
 Departamento de Matemáticas
 Universidad de Extremadura
 
 
 
 
 
 

Rolando Valdez

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


Re: [R-es] Realizar pruebas unitarias al codigo de R

2014-05-05 Thread Marcuzzi, Javier Ruben
Estimada Daliana Ramos

Yo preste un libro que tenía sobre esos temas y que nunca me 
devolvieron. No recuerdo el nombre o tengo la posibilidad de buscar un 
ejemplo para enviarle.

Pero yo buscaría por estos lados: 
http://www.stats.uwo.ca/faculty/murdoch/software/debuggingR/

Javier Marcuzzi

El 05/05/2014 03:44 p.m., Daliana Ramos Garcia escribió:
 hola a todos, nuevamente tengo una duda y me gustaría compartirla con 
 ustedes para ver si pueden ayudarme.
 Estoy haciendo un proyecto en R, usando la metodología XP que como saben en 
 la fase de pruebas hay que hacer pruebas unitaria al código, pero no se como 
 realizarlas en R.
 Si alguien sabe como se pueden hacer le agradecería su ayuda.



 ___
 R-help-es mailing list
 R-help-es@r-project.org
 https://stat.ethz.ch/mailman/listinfo/r-help-es


[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es