Re: [R] Difficulty in caper: Error in phy$node.label[which(newNb > 0) - Ntip]

2013-03-07 Thread David Winsemius

On Mar 7, 2013, at 5:12 PM, Nicole Thompson wrote:

> Thank you, Peter, for your response.
> 
> I can see then that comparative.data() is performing some operation
> that calls an invalid subset of either my phylo or data file
> (mammaldata or mammaltree).
> 
> It would be helpful to understand what "newNb" is, as
> comparative.data() creates it while constructing the comparative
> dataset. I'm guessing Ntip is the taxa I've included in my mammaldata.
> Perhaps newNb is the number of nodes inside the mammaltree and the
> error occurs because the taxa and tree nodes don't match well?
> 
> If anyone has similar experience with comparative.data(), I would
> greatly appreciate your insight.

Questions about the code that are not explained by the commented source code 
(which may not be available unless you make specific efforts to retain 
comments)  are best posed to the package maintainer. If you are asking for 
advice from the mailing list, you should make the effort to construct a minimal 
example. I suspect that the examples in the help files do not throw the same 
error. 

-- 

David.

> 
> Thank you.
> Nicole
> 
> On Thu, Mar 7, 2013 at 12:35 PM, Peter Ehlers  wrote:
>> On 2013-03-06 07:49, Nicole Thompson wrote:
>>> 
>>> Hello,
>>> 
>>> I'm doing a comparative analysis of mammal brain and body size data.
>>> I'm following Charlie Nunn and Natalie Cooper's instructions for
>>> "Running PGLS in R using caper".
>>> 
>>> I run into the following error when I create my comparative dataset,
>>> combining my phylogenetic tree (mammaltree) and taxon measures
>>> (mammaldata):
>>> 
>>> "Error in phy$node.label[which(newNb > 0) - Ntip] : only 0's may be
>>> mixed with negative subscripts"
>>> 
>>> My full script is provided at the bottom.
>>> 
>>> I have looked at the caper manual by David Orme to understand how
>>> comparative.data() constructs the dataset, but still cannot interpret
>>> the error. Many thanks to anyone who could provide me with insight.
>>> 
>>> Nicole Thompson
>>> E3B Columbia University
>>> 
>>> 
>>> 
 library(caper)
>>> 
>>> 
>>> Loading required package: ape
>>> 
>>> Loading required package: MASS
>>> 
>>> Loading required package: mvtnorm
>>> 
 
>>> 
 mammaldata <-read.csv("R.Mammal_data.csv", header = TRUE)
>>> 
>>> 
 mammaltree <-read.nexus("BEphylotree.nex")
>>> 
>>> 
 mammal <- comparative.data(phy = mammaltree, data = mammaldata, names.col
 = Taxon, vcv = TRUE, na.omit = FALSE, warn.dropped = TRUE) #names.col?
>>> 
>>> 
>>> Error in phy$node.label[which(newNb > 0) - Ntip] : only 0's may be
>>> mixed with negative subscripts
>> 
>> 
>> Looks to me like 'which(newNb > 0) - Ntip' evaluates to a
>> vector that has both positive and negative elements.
>> Like this:
>> 
>>  x <- 1:5
>>  x[c(-2,-4)] ## ok
>>  x[c(-2, 0)] ## ok
>>  x[c(-2, 4)] ## generates your error
>> 
>> Peter Ehlers
>> 
>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> --
>>> Nicole A Thompson
>>> E3B Columbia University, NYCEP
>>> nat2...@columbia.edu
>>> 480.522.4212
>>> 
>> 
> 
> 
> 
> --
> Nicole A Thompson
> E3B Columbia University, NYCEP
> nat2...@columbia.edu
> 480.522.4212
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

David Winsemius
Alameda, CA, USA

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


Re: [R] Read Content from URL to XML format

2013-03-07 Thread R_Antony
Hi John ,

 

I tried this code

==

library(RCurl) 

library(XML) 

script <- getURL("www.r-bloggers.com")

 

and now getting an error like ,

“Error in function (type, msg, asError = TRUE)  : couldn't connect to host”

 

 

 

From: John Kane [via R] [mailto:ml-node+s789695n4660616...@n4.nabble.com] 
Sent: Thursday, March 07, 2013 8:53 PM
To: Akkara, Antony (GE Power & Water, Non-GE)
Subject: Re: Read Content from URL to XML format

 

Perhaps 
http://stackoverflow.com/questions/1395528/scraping-html-tables-into-r-data-frames-using-the-xml-package
 may be of help 

John Kane 
Kingston ON Canada 


> -Original Message- 
> From: [hidden email] 
> Sent: Wed, 6 Mar 2013 19:23:24 -0800 (PST) 
> To: [hidden email] 
> Subject: [R] Read Content from URL to XML format 
> 
> Hi, 
> 
> i want to know how to read a table values from a URL and get it as XML 
> content. 
> Could anyone please help me out ASAP ? 
> 
> Thanks, 
> Antony. 
> 
> 
> 
> -- 
> View this message in context: 
> http://r.789695.n4.nabble.com/Read-Content-from-URL-to-XML-format-tp4660561.html
> Sent from the R help mailing list archive at Nabble.com. 
> 
> __ 
> [hidden email] mailing list 
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code. 


 
TRY FREE IM TOOLPACK at http://www.imtoolpack.com/default.aspx?rc=if5
Capture screenshots, upload images, edit and send them to your friends 
through IMs, post on Twitter®, Facebook®, MySpace™, LinkedIn® – FAST! 

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





If you reply to this email, your message will be added to the discussion below:

http://r.789695.n4.nabble.com/Read-Table-Content-from-URL-to-XML-format-tp4660561p4660616.html
 

To unsubscribe from Read Table Content from URL to XML format, click here 

 .
NAML 

  





--
View this message in context: 
http://r.789695.n4.nabble.com/Read-Table-Content-from-URL-to-XML-format-tp4660561p4660687.html
Sent from the R help mailing list archive at Nabble.com.
[[alternative HTML version deleted]]

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


Re: [R] multiple plots and looping assistance requested (revised codes)

2013-03-07 Thread Irucka Embry
Hi Arun, thanks for the responses.

1) I added more data to the data set located at
http://stackoverflow.com/questions/11548368/making-multiple-plots-in-r-f
rom-one-textfile to more resemble the actual data set that I have. The
example data set is called tempdata. I have used the most recent code
suggestions for plotting on the example data set and I am receiving the
same error message as with the full data set. 

I figured that the plot function is stopping at Atlantacitydata and it
is not going further because Atlantacitydata is a blank plot.

How do I get plot to keep plotting after encountering a blank plot in a
multi plot series?

I have looked online and I have not found an answer yet.

# tempdata is the simpler data set that is similar to the real data set
> dput(tempdata)
structure(list(`:Bostoncitydata` = structure(list(Month = c(1L, 
2L, 3L, NA), Data1 = c(1.5, 12.3, 11.4, NA), Data2 = c(9.1342, 
12.31, 3.5, NA)), .Names = c("Month", "Data1", "Data2"), class =
"data.frame", row.names = c(NA, 
-4L)), `:Chicagocitydata` = structure(list(Month = c(1L, 2L, 
3L, 4L, 5L, NA), Data1 = c(1.52, 12.63, 20.34, 12.83, 3.34, NA
), Data2 = c(19.41342, 13.031, 0.80021, 12.63104, 19.20021, NA
)), .Names = c("Month", "Data1", "Data2"), class = "data.frame",
row.names = c(NA, 
-6L)), `:NewYorkcitydata` = structure(list(Month = c(1L, 2L, 
3L, 4L, 5L, 6L, 7L, NA), Data1 = c(NA, NA, NA, NA, NA, NA, NA, 
NA), Data2 = c(3.1342, 1.31, 13.5, 1.31, 2.40021, 0.25, 26.3, 
NA)), .Names = c("Month", "Data1", "Data2"), class = "data.frame",
row.names = c(NA, 
-8L)), `:Philadelphiacitydata` = structure(list(Month = c(1L, 
2L, 3L, 4L, 5L, 6L, NA), Data1 = c(1.65, 11.63, 5.0434, 13.73, 
3.0234, 34.209, NA), Data2 = c(2.61342, 16.331, 19.040021, 17.831, 
10.1010021, 3.80742, NA)), .Names = c("Month", "Data1", "Data2"
), class = "data.frame", row.names = c(NA, -7L)), `:Atlantacitydata` =
structure(list(
Month = c(1L, 2L, 3L, NA), Data1 = c(NA, NA, NA, NA), Data2 = c(NA, 
NA, NA, NA)), .Names = c("Month", "Data1", "Data2"), class =
"data.frame", row.names = c(NA, 
-4L)), `:Baltimorecitydata` = structure(list(Month = 1:2, Data1 =
c(11.325, 
32.433), Data2 = c(49.71342, 52.4031)), .Names = c("Month", "Data1", 
"Data2"), class = "data.frame", row.names = c(NA, -2L))), .Names =
c(":Bostoncitydata", 
":Chicagocitydata", ":NewYorkcitydata", ":Philadelphiacitydata", 
":Atlantacitydata", ":Baltimorecitydata"))

> tempdata =
read.funkyfile("/home/cptr/IE2/Documents/USGS-2012-Work/SPARROW-Summer-2
012-Work/EGRET/calibration/datamore.csv", "Header", header=TRUE,
sep="\t")
> tempdata1<-lapply(tempdata,function(x) x[complete.cases(x),])
> tempdata2<-lapply(tempdata1,function(temperNew)
lapply(names(temperNew)[-1],
function(i){x1<-cbind(temperNew[,1],temperNew[,i]); colnames(x1)<-
c("CYEAR_DECIMAL",i);x1}))
>
pdf("/home/cptr/IE2/Documents/USGS-2012-Work/SPARROW-Summer-2012-Work/EG
RET/calibration/Calibration_Results/Nitrogen/Graphics/seasonalFluxCompar
isonDataSet.pdf")
> par(mfrow=c(1,2))
> lapply(names(tempdata2),function(i) lapply(tempdata2[[i]],function(x)
{plot(x[,1],x[,2],main="Seasonal Flux
Sum",sub=paste(i,colnames(x)[2],sep="_"),xlab="Calendar Year
Timesteps",ylab="Total Flux (kg/season)");lines(x[,1],x[,2])}))
Error in plot.window(...) : need finite 'xlim' values
In addition: Warning messages:
1: In min(x) : no non-missing arguments to min; returning Inf
2: In max(x) : no non-missing arguments to max; returning -Inf
3: In min(x) : no non-missing arguments to min; returning Inf
4: In max(x) : no non-missing arguments to max; returning -Inf



2) I attempted the code that you sent in your recent response, but there
were errors in both cases. Please see below:

> temp1<-lapply(temp,function(x) x[complete.cases(x),]) #NA values are
removed
> temp1[[2]]<- temp1[[2]][1:2] #Some columns are removed
> temp1[[3]]<- temp1[[3]][c(1,3)] # Some columns removed
> temp3<-temp1[lapply(temp1,ncol)==3]
> temp3New<-lapply(temp3,function(x) lapply(names(x)[-1],
function(i){x1<-cbind(temp3[,1],temp3[,i]); colnames(x1)<-
c("CYEAR_DECIMAL",i);x1}))

Error in temp3[, 1] : incorrect number of dimensions


> temp2<-temp1[lapply(temp1,ncol)==2]
> temp2New<-lapply(temp2,function(x) lapply(names(x)[-1],
function(i){x1<-cbind(temp2[,1],temp2[,i]); colnames(x1)<-
c("CYEAR_DECIMAL",i);x1}))

Error in temp2[, 1] : incorrect number of dimensions


Thank you.

Irucka


<-Original Message-> 
>From: arun [smartpink...@yahoo.com]
>Sent: 3/7/2013 9:02:22 AM
>To: iruc...@mail2world.com
>Cc: r-help@r-project.org
>Subject: Re: [R] multiple plots and looping assistance requested
(revised codes)
>
>Hi Irucka,
>
>Regarding the first question.
>
>If you look at the ouput of temp1, it already strips off any NA that
was left in the columns. It is always to 
>give an example dataset that is similar to the real dataset.
>
>Here, I am guessing the situation is similar to this:
>temp1<-lapply(temp,function(x) x[complete.cases(x),]) #NA values are
removed
>temp1[[2]]<- temp1[[2]][

Re: [R] reduce the size of list

2013-03-07 Thread ishi soichi
thanks! It works.
I couldn't possibly figure out such trick...

soichi


2013/3/8 Jorge I Velez 

> If I understood correctly,
>
> lapply(x, "[", 1:3)
>
> will do what you want.
>
> HTH,
> Jorge.-
>
>
> On Fri, Mar 8, 2013 at 5:05 PM, ishi soichi <> wrote:
>
>> hi. I have a list like
>>
>> x <- list(1:10,11:20,21:30)
>>
>> It's a sort of a 3 x 10 matrix in list form.
>> I would like to reduce the dimension of this list.
>>
>> it would be something like
>>
>> list(1:3, 11:13, 21,23)
>>
>> I tried
>>
>> x[,1:3]
>>
>> does not work of course. Neither
>>
>> lapply(x, [1:3])
>>
>> works...
>>
>> Any suggestions?
>>
>> ishida
>>
>> [[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
>

[[alternative HTML version deleted]]

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


Re: [R] reduce the size of list

2013-03-07 Thread Jorge I Velez
If I understood correctly,

lapply(x, "[", 1:3)

will do what you want.

HTH,
Jorge.-


On Fri, Mar 8, 2013 at 5:05 PM, ishi soichi <> wrote:

> hi. I have a list like
>
> x <- list(1:10,11:20,21:30)
>
> It's a sort of a 3 x 10 matrix in list form.
> I would like to reduce the dimension of this list.
>
> it would be something like
>
> list(1:3, 11:13, 21,23)
>
> I tried
>
> x[,1:3]
>
> does not work of course. Neither
>
> lapply(x, [1:3])
>
> works...
>
> Any suggestions?
>
> ishida
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


[R] reduce the size of list

2013-03-07 Thread ishi soichi
hi. I have a list like

x <- list(1:10,11:20,21:30)

It's a sort of a 3 x 10 matrix in list form.
I would like to reduce the dimension of this list.

it would be something like

list(1:3, 11:13, 21,23)

I tried

x[,1:3]

does not work of course. Neither

lapply(x, [1:3])

works...

Any suggestions?

ishida

[[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] Understanding lm-based analysis of fractional factorial experiments

2013-03-07 Thread Peter Claussen

On Mar 7, 2013, at 4:47 AM, Kjetil Kjernsmo  wrote:

> On Wednesday 6. March 2013 16.33.34 Peter Claussen wrote:
>> But you don't have enough data points to estimate all of the possible
>> interactions; that's why you have NA in your original results.
> 
> Yes, but it seems to me that lm is doing the right thing, or at least the 
> expected thing, here, the NA's are simply telling me these are aliased, which 
> is correct and expected.
> 

I ran across the text you reference while looking up a couple other references 
yesterday; having read the appropriate section I can better understand your 
questions.

I would say in this case that what R is doing is expected, but not necessarily 
correct, for this problem. 

The authors go into some detail about aliasing treatments, and that there are 
different choices for aliasing. I didn't have my computer handy, but does R 
choose the same set of aliases as the authors?

Peter


>> You could
>> add the just the first order interactions manually, i.e.,  + B:C + B:D …
> 
> Yeah, I tried that, but then it returns to the "unexpected" result, i.e., I 
> get the same result as with the yavg ~ B * C * D * E * Q formula. Therefore, 
> I 
> think the problem doesn't lie with the formula, nor does it lie with any of 
> the code, it is just a matter of understanding defaults...
> 
> I have consulted local help (of course), but what they say is that "R has 
> some 
> odd defaults, you need to ask them or use something different". I don't want 
> to 
> use something different, I like R, I have contributed to R in the past and 
> will 
> do so again if only I can get my head around this... :-)
> 
> Kjetil
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Difficulty in caper: Error in phy$node.label[which(newNb > 0) - Ntip]

2013-03-07 Thread Nicole Thompson
Thank you, Peter, for your response.

I can see then that comparative.data() is performing some operation
that calls an invalid subset of either my phylo or data file
(mammaldata or mammaltree).

It would be helpful to understand what "newNb" is, as
comparative.data() creates it while constructing the comparative
dataset. I'm guessing Ntip is the taxa I've included in my mammaldata.
Perhaps newNb is the number of nodes inside the mammaltree and the
error occurs because the taxa and tree nodes don't match well?

If anyone has similar experience with comparative.data(), I would
greatly appreciate your insight.

Thank you.
Nicole

On Thu, Mar 7, 2013 at 12:35 PM, Peter Ehlers  wrote:
> On 2013-03-06 07:49, Nicole Thompson wrote:
>>
>> Hello,
>>
>> I'm doing a comparative analysis of mammal brain and body size data.
>> I'm following Charlie Nunn and Natalie Cooper's instructions for
>> "Running PGLS in R using caper".
>>
>> I run into the following error when I create my comparative dataset,
>> combining my phylogenetic tree (mammaltree) and taxon measures
>> (mammaldata):
>>
>> "Error in phy$node.label[which(newNb > 0) - Ntip] : only 0's may be
>> mixed with negative subscripts"
>>
>> My full script is provided at the bottom.
>>
>> I have looked at the caper manual by David Orme to understand how
>> comparative.data() constructs the dataset, but still cannot interpret
>> the error. Many thanks to anyone who could provide me with insight.
>>
>> Nicole Thompson
>> E3B Columbia University
>>
>>
>>
>>> library(caper)
>>
>>
>> Loading required package: ape
>>
>> Loading required package: MASS
>>
>> Loading required package: mvtnorm
>>
>>>
>>
>>> mammaldata <-read.csv("R.Mammal_data.csv", header = TRUE)
>>
>>
>>> mammaltree <-read.nexus("BEphylotree.nex")
>>
>>
>>> mammal <- comparative.data(phy = mammaltree, data = mammaldata, names.col
>>> = Taxon, vcv = TRUE, na.omit = FALSE, warn.dropped = TRUE) #names.col?
>>
>>
>> Error in phy$node.label[which(newNb > 0) - Ntip] : only 0's may be
>> mixed with negative subscripts
>
>
> Looks to me like 'which(newNb > 0) - Ntip' evaluates to a
> vector that has both positive and negative elements.
> Like this:
>
>   x <- 1:5
>   x[c(-2,-4)] ## ok
>   x[c(-2, 0)] ## ok
>   x[c(-2, 4)] ## generates your error
>
> Peter Ehlers
>
>
>>
>>
>>
>>
>>
>> --
>> Nicole A Thompson
>> E3B Columbia University, NYCEP
>> nat2...@columbia.edu
>> 480.522.4212
>>
>



--
Nicole A Thompson
E3B Columbia University, NYCEP
nat2...@columbia.edu
480.522.4212

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] install Netcdf library (linux)

2013-03-07 Thread Massimo Di Stefano
Hi All,

i'm on a debian linux 64bit,
i'm tying to install the netcdf intraface, i tried both ncdf and ncdf4

but  trying to build i received the error :

(i have necdf installed on my machine and it is able to fiund it .. no missed 
.h)

epy@epinux:~$ sudo R CMD INSTALL 
--configure-args="-with-netcdf_incdir=/usr/include 
-with-netcdf_libdir=/usr/lib" ncdf4_1.8.tar.gz 
* installing to library ‘/usr/local/lib/R/site-library’
* installing *source* package ‘ncdf4’ ...
checking for nc-config... yes
Using nc-config: nc-config
Output of nc-config --all:

This netCDF 4.2.1.1 has been built with the following features: 

  --cc-> gcc
  --cflags->  -I/usr/local/include -I/usr/local/include
  --libs  -> -L/usr/local/lib -lnetcdf

  --has-c++   -> no
  --cxx   -> 
  --has-c++4  -> no
  --cxx4  -> 

  --fc-> 
  --fflags-> 
  --flibs -> 
  --has-f90   -> no

  --has-dap   -> yes
  --has-nc2   -> yes
  --has-nc4   -> yes
  --has-hdf5  -> yes
  --has-hdf4  -> no
  --has-pnetcdf-> no
  --has-szlib -> 

  --prefix-> /usr/local
  --includedir-> /usr/local/include
  --version   -> netCDF 4.2.1.1

---
netcdf.m4: about to set rpath, here is source string: >-L/usr/local/lib 
-lnetcdf<
netcdf.m4: final rpath:   -Wl,-rpath,/usr/local/lib
Netcdf library version: netCDF 4.2.1.1
Netcdf library has version 4 interface present: yes
Netcdf library was compiled with C compiler: gcc
configure: creating ./config.status
config.status: creating R/load.R
config.status: creating src/Makevars
 
**  Results of ncdf4 package configure ***
 
netCDF v4 CPP flags = -I/usr/local/include -I/usr/local/include
netCDF v4 LD flags  =   -Wl,-rpath,/usr/local/lib -L/usr/local/lib -lnetcdf
netCDF v4 runtime path  =   -Wl,-rpath,/usr/local/lib
 
**

** libs
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -I/usr/local/include 
-I/usr/local/include -fpic  -O2 -pipe -g  -c ncdf.c -o ncdf.o
ncdf.c: In function ‘R_nc4_nctype_to_Rtypecode’:
ncdf.c:40:18: error: ‘NC_INT’ undeclared (first use in this function)
ncdf.c:40:18: note: each undeclared identifier is reported only once for each 
function it appears in
ncdf.c:49:18: error: ‘NC_UBYTE’ undeclared (first use in this function)
ncdf.c:51:18: error: ‘NC_USHORT’ undeclared (first use in this function)
ncdf.c:53:18: error: ‘NC_UINT’ undeclared (first use in this function)
ncdf.c:55:18: error: ‘NC_INT64’ undeclared (first use in this function)
ncdf.c:57:18: error: ‘NC_UINT64’ undeclared (first use in this function)
ncdf.c: In function ‘R_nc4_varsize’:
ncdf.c:69:28: error: ‘NC_MAX_DIMS’ undeclared (first use in this function)
ncdf.c:75:2: warning: implicit declaration of function ‘nc_inq_varndims’ 
[-Wimplicit-function-declaration]
ncdf.c:78:4: warning: implicit declaration of function ‘nc_strerror’ 
[-Wimplicit-function-declaration]
ncdf.c:84:2: warning: implicit declaration of function ‘nc_inq_vardimid’ 
[-Wimplicit-function-declaration]
ncdf.c:94:3: warning: implicit declaration of function ‘nc_inq_dimlen’ 
[-Wimplicit-function-declaration]
ncdf.c: In function ‘R_nc4_inq_varunlim’:
ncdf.c:112:2: warning: implicit declaration of function ‘nc_inq_unlimdim’ 
[-Wimplicit-function-declaration]
ncdf.c: In function ‘R_nc4_inq_var’:
ncdf.c:152:2: warning: implicit declaration of function ‘nc_inq_var’ 
[-Wimplicit-function-declaration]
ncdf.c: In function ‘R_nc4_inq_vartype’:
ncdf.c:168:2: warning: implicit declaration of function ‘nc_inq_vartype’ 
[-Wimplicit-function-declaration]
ncdf.c: In function ‘R_nc4_inq_varname’:
ncdf.c:181:2: warning: implicit declaration of function ‘nc_inq_varname’ 
[-Wimplicit-function-declaration]
ncdf.c: In function ‘R_nc4_get_vara_double’:
ncdf.c:214:2: warning: implicit declaration of function ‘nc_get_vara_double’ 
[-Wimplicit-function-declaration]
ncdf.c: In function ‘R_nc4_get_vara_int’:
ncdf.c:257:2: warning: implicit declaration of function ‘nc_get_vara_int’ 
[-Wimplicit-function-declaration]
ncdf.c: In function ‘R_nc4_get_vara_text’:
ncdf.c:313:2: warning: implicit declaration of function ‘nc_get_vara_text’ 
[-Wimplicit-function-declaration]
ncdf.c: In function ‘R_nc4_inq_dimid’:
ncdf.c:345:2: warning: implicit declaration of function ‘nc_inq_dimid’ 
[-Wimplicit-function-declaration]
ncdf.c: In function ‘R_nc4_inq_varid’:
ncdf.c:355:2: warning: implicit declaration of function ‘nc_inq_varid’ 
[-Wimplicit-function-declaration]
ncdf.c: In function ‘R_nc4_inq_dimids’:
ncdf.c:377:9: warning: implicit declaration of function ‘nc_inq_dimids’ 
[-Wimplicit-function-declaration]
ncdf.c: In function ‘R_nc4_inq_dim’:
ncdf.c:387:12: error: ‘NC_MAX_NAME’ undeclared (first use in this function)
ncdf.c:391:2: warning: implicit declaration of function ‘nc_inq_dim’ 
[-Wimplicit-function-declaration]
ncdf.c:408:2: warning: implicit declaration of function ‘nc_inq_unlimdims’ 
[-Wimplicit-function-declaration]
ncdf.c: In function ‘R_nc4_in

Re: [R] How to export data with defined decimal places

2013-03-07 Thread Marino David
*Hi Bert and all,*
*
*
*Thanks a lot for your response. Bert's method works very well.*
*
*
*
*


2013/3/8 Bert Gunter 

> Use format() or formatC() to convert your numeric data to character
> and then "call write.table on that."
>
> e.g.
>
> > z <-formatC(pi,digits=10,format="f")
> > z
> [1] "3.1415926536"
>
> If this still is not clear to you, I give up, as I do not know how to
> make it any clearer. Perhaps someone else can.
>
> -- Bert
>
>
> On Thu, Mar 7, 2013 at 4:24 PM, Marino David 
> wrote:
> > Hi Bert,
> >
> > I read both options and write.table help, but I still can't make it to
> save
> > the data into txt file with fixed precision.
> >
> > To let you know more clearly what I want, I still you use the previous
> > simple example to illustrate.
> >
> > I want to save pi into pi.txt file with 10 decimal places, that is
> > 3.1415926536. How to do it?
> >
> >
> >
> > Thanks
> >
> > Marin
> >
> >
> >
> > 2013/3/8 Marino David 
> >>
> >> Hi Bert,
> >>
> >> I want to save the data into .txt file for another software process.
> >>
> >> Thanks for suggestion.
> >>
> >> 2013/3/8 Bert Gunter 
> >>>
> >>> ?write.table
> >>>
> >>> which says, under details:
> >>>
> >>> "In almost all cases the conversion of numeric quantities is governed
> >>> by the option "scipen" (see options), but with the internal equivalent
> >>> of digits=15. For finer control, use format to make a character
> >>> matrix/data frame, and call write.table on that. "
> >>>
> >>> Not sure if this is what you want, as "export" is rather vague.
> >>>
> >>> -- Bert
> >>>
> >>> On Thu, Mar 7, 2013 at 12:52 PM, Marino David <
> davidmarino...@gmail.com>
> >>> wrote:
> >>> > Hi all mailing listers,
> >>> >
> >>> > I want to export data with specified precision into .txt file. How
> can
> >>> > I
> >>> > make it? See  below
> >>> >
> >>> > sprintf("%.10f",pi)
> >>> > [1] "3.1415926536"
> >>> >
> >>> > when carry out write.matrix(pi,"pi.txt"), 3.141592653589793115998 in
> >>> > pi.txt
> >>> > file not with 10 decimal places like using sprintf("%.10f",pi)
> >>> >
> >>> >
> >>> > Thanks
> >>> >
> >>> > Marino
> >>> >
> >>> > [[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
> >>
> >>
> >
>
>
>
> --
>
> 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
>

[[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] getting covariance ignoring NaN missing values

2013-03-07 Thread Sachinthaka Abeywardana
thanks, appreciate it


On Fri, Mar 8, 2013 at 2:49 PM, arun  wrote:

>
>
> Hi,
> If you look at ?cov(),
> there are options for 'use':
> set.seed(15)
> a=array(rnorm(9),dim=c(3,3))
>  a[3,2]<- NaN
>
>  cov(a,use="complete.obs")
> #   [,1][,2]   [,3]
> #[1,]  1.2360602 -0.32167789  0.8395953
> #[2,] -0.3216779  0.08371491 -0.2185001
> #[3,]  0.8395953 -0.21850006  0.5702960
>  cov(a,use="na.or.complete")
> #   [,1][,2]   [,3]
> #[1,]  1.2360602 -0.32167789  0.8395953
> #[2,] -0.3216779  0.08371491 -0.2185001
> #[3,]  0.8395953 -0.21850006  0.5702960
>  cov(a,use="pairwise.complete.obs")
> #   [,1][,2]   [,3]
> #[1,]  1.2570603 -0.32167789  0.7377472
> #[2,] -0.3216779  0.08371491 -0.2185001
> #[3,]  0.7377472 -0.21850006  0.4433438
> A.K.
>
>
>
>
> - Original Message -
> From: Sachinthaka Abeywardana 
> To: "r-help@r-project.org" 
> Cc:
> Sent: Thursday, March 7, 2013 10:36 PM
> Subject: [R] getting covariance ignoring NaN missing values
>
> Hi all,
>
> I have a matrix that has many NaN values. As soon as one of the columns has
> a missing (NaN) value the covariance estimation gets thrown off.
>
> Is there a robust way to do this?
>
> Thanks,
> Sachin
>
> a=array(rnorm(9),dim=c(3,3))> a[,1]   [,2]  [,3]
> [1,] -0.79418236  0.7813952  0.855881
> [2,] -1.65347906 -1.9462446 -0.376325
> [3,] -0.03144987  0.6756862 -1.879801> a[3,2]=NANError: object 'NAN'
> not found> a[3,2]=NaN> a[,1]   [,2]  [,3]
> [1,] -0.79418236  0.7813952  0.855881
> [2,] -1.65347906 -1.9462446 -0.376325
> [3,] -0.03144987NaN -1.879801> cov(a)   [,1] [,2]
>  [,3]
> [1,]  0.6585217   NA -0.5777408
> [2,] NA   NA NA
> [3,] -0.5777408   NA  1.8771214
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>

[[alternative HTML version deleted]]

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


Re: [R] getting covariance ignoring NaN missing values

2013-03-07 Thread arun


Hi,
If you look at ?cov(),
there are options for 'use':
set.seed(15)
a=array(rnorm(9),dim=c(3,3))
 a[3,2]<- NaN

 cov(a,use="complete.obs")
#   [,1]    [,2]   [,3]
#[1,]  1.2360602 -0.32167789  0.8395953
#[2,] -0.3216779  0.08371491 -0.2185001
#[3,]  0.8395953 -0.21850006  0.5702960
 cov(a,use="na.or.complete")
#   [,1]    [,2]   [,3]
#[1,]  1.2360602 -0.32167789  0.8395953
#[2,] -0.3216779  0.08371491 -0.2185001
#[3,]  0.8395953 -0.21850006  0.5702960
 cov(a,use="pairwise.complete.obs")
#   [,1]    [,2]   [,3]
#[1,]  1.2570603 -0.32167789  0.7377472
#[2,] -0.3216779  0.08371491 -0.2185001
#[3,]  0.7377472 -0.21850006  0.4433438
A.K.




- Original Message -
From: Sachinthaka Abeywardana 
To: "r-help@r-project.org" 
Cc: 
Sent: Thursday, March 7, 2013 10:36 PM
Subject: [R] getting covariance ignoring NaN missing values

Hi all,

I have a matrix that has many NaN values. As soon as one of the columns has
a missing (NaN) value the covariance estimation gets thrown off.

Is there a robust way to do this?

Thanks,
Sachin

a=array(rnorm(9),dim=c(3,3))> a            [,1]       [,2]      [,3]
[1,] -0.79418236  0.7813952  0.855881
[2,] -1.65347906 -1.9462446 -0.376325
[3,] -0.03144987  0.6756862 -1.879801> a[3,2]=NANError: object 'NAN'
not found> a[3,2]=NaN> a            [,1]       [,2]      [,3]
[1,] -0.79418236  0.7813952  0.855881
[2,] -1.65347906 -1.9462446 -0.376325
[3,] -0.03144987        NaN -1.879801> cov(a)           [,1] [,2]       [,3]
[1,]  0.6585217   NA -0.5777408
[2,]         NA   NA         NA
[3,] -0.5777408   NA  1.8771214

    [[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] getting covariance ignoring NaN missing values

2013-03-07 Thread Sachinthaka Abeywardana
Hi all,

I have a matrix that has many NaN values. As soon as one of the columns has
a missing (NaN) value the covariance estimation gets thrown off.

Is there a robust way to do this?

Thanks,
Sachin

a=array(rnorm(9),dim=c(3,3))> a[,1]   [,2]  [,3]
[1,] -0.79418236  0.7813952  0.855881
[2,] -1.65347906 -1.9462446 -0.376325
[3,] -0.03144987  0.6756862 -1.879801> a[3,2]=NANError: object 'NAN'
not found> a[3,2]=NaN> a[,1]   [,2]  [,3]
[1,] -0.79418236  0.7813952  0.855881
[2,] -1.65347906 -1.9462446 -0.376325
[3,] -0.03144987NaN -1.879801> cov(a)   [,1] [,2]   [,3]
[1,]  0.6585217   NA -0.5777408
[2,] NA   NA NA
[3,] -0.5777408   NA  1.8771214

[[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] Select rows from Data Frame with conditions

2013-03-07 Thread Sachinthaka Abeywardana
yep, that did the trick.

Thanks,
Sachin


On Fri, Mar 8, 2013 at 1:24 PM, Jeff Newmiller wrote:

> Something along the lines of
>
> top100 <- A[match(B,A[,1]),]
>
> Please provide R code with sample data and desired output. See
> http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example
> ---
> Jeff NewmillerThe .   .  Go Live...
> DCN:Basics: ##.#.   ##.#.  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.
>
> Sachinthaka Abeywardana  wrote:
>
> >Hi all,
> >
> >I have two dataframes. The first (A) contains all the stock prices for
> >today including today. So the first column is the stock Symbol and the
> >second column is the stock price. The second (B) is the symbol list in
> >the
> >top 100 stocks.
> >
> >I want to pick out from dataframe A only the rows containing the
> >symbols
> >from B. i.e. something like:
> >
> >prices <- A[A[,1]==B,2]
> >
> >is there any way to do this without using a for loop, I have to do this
> >365
> >times (i.e. for one year).
> >
> >Thanks,
> >Sachin
> >
> >   [[alternative HTML version deleted]]
> >
> >__
> >R-help@r-project.org mailing list
> >https://stat.ethz.ch/mailman/listinfo/r-help
> >PLEASE do read the posting guide
> >http://www.R-project.org/posting-guide.html
> >and provide commented, minimal, self-contained, reproducible code.
>
>

[[alternative HTML version deleted]]

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


Re: [R] Select rows from Data Frame with conditions

2013-03-07 Thread Rolf Turner

On 03/08/2013 02:22 PM, Sachinthaka Abeywardana wrote:

Hi all,

I have two dataframes. The first (A) contains all the stock prices for
today including today. So the first column is the stock Symbol and the
second column is the stock price. The second (B) is the symbol list in the
top 100 stocks.

I want to pick out from dataframe A only the rows containing the symbols
from B. i.e. something like:

 prices <- A[A[,1]==B,2]

is there any way to do this without using a for loop, I have to do this 365
times (i.e. for one year).


Is "B" a data frame, or a vector?

Any I think you want to do something like (untested):

prices <- A[A[,1] %in% B[,1],2]

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] Select rows from Data Frame with conditions

2013-03-07 Thread Jeff Newmiller
Something along the lines of

top100 <- A[match(B,A[,1]),]

Please provide R code with sample data and desired output. See 
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example
---
Jeff NewmillerThe .   .  Go Live...
DCN:Basics: ##.#.   ##.#.  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.

Sachinthaka Abeywardana  wrote:

>Hi all,
>
>I have two dataframes. The first (A) contains all the stock prices for
>today including today. So the first column is the stock Symbol and the
>second column is the stock price. The second (B) is the symbol list in
>the
>top 100 stocks.
>
>I want to pick out from dataframe A only the rows containing the
>symbols
>from B. i.e. something like:
>
>prices <- A[A[,1]==B,2]
>
>is there any way to do this without using a for loop, I have to do this
>365
>times (i.e. for one year).
>
>Thanks,
>Sachin
>
>   [[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 package ZIGP is not there anymore?

2013-03-07 Thread Jeff Newmiller
Presumably because no one is maintaining it. It is still in the archives, and 
it is licensed under GPL. You could contact the author or revive it yourself.

Please read the Posting Guide before posting again. Repeating yourself is not 
okay, nor is posting in HTML format.
---
Jeff NewmillerThe .   .  Go Live...
DCN:Basics: ##.#.   ##.#.  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.

lili puspita rahayu  wrote:

>Mr/Mrs
>
>I am Lili Puspita Rahayu, student from Bogor Agriculture University. 
>
>I wanna ask that why package ZIGP (Zero inflated Generalized Poisson)
>is not there anymore?
>is there any other packages that can analyze ZIGP?
>
>I am very
>grateful for the assistance of R.
>I am looking forward to hearing from you. Thank you very much.
>
>Sincerely yours
>Lili Puspita Rahayu 
>   [[alternative HTML version deleted]]
>
>__
>R-help@r-project.org mailing list
>https://stat.ethz.ch/mailman/listinfo/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] Select rows from Data Frame with conditions

2013-03-07 Thread Sachinthaka Abeywardana
Hi all,

I have two dataframes. The first (A) contains all the stock prices for
today including today. So the first column is the stock Symbol and the
second column is the stock price. The second (B) is the symbol list in the
top 100 stocks.

I want to pick out from dataframe A only the rows containing the symbols
from B. i.e. something like:

prices <- A[A[,1]==B,2]

is there any way to do this without using a for loop, I have to do this 365
times (i.e. for one year).

Thanks,
Sachin

[[alternative HTML version deleted]]

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


Re: [R] How to export data with defined decimal places

2013-03-07 Thread Bert Gunter
Use format() or formatC() to convert your numeric data to character
and then "call write.table on that."

e.g.

> z <-formatC(pi,digits=10,format="f")
> z
[1] "3.1415926536"

If this still is not clear to you, I give up, as I do not know how to
make it any clearer. Perhaps someone else can.

-- Bert


On Thu, Mar 7, 2013 at 4:24 PM, Marino David  wrote:
> Hi Bert,
>
> I read both options and write.table help, but I still can't make it to save
> the data into txt file with fixed precision.
>
> To let you know more clearly what I want, I still you use the previous
> simple example to illustrate.
>
> I want to save pi into pi.txt file with 10 decimal places, that is
> 3.1415926536. How to do it?
>
>
>
> Thanks
>
> Marin
>
>
>
> 2013/3/8 Marino David 
>>
>> Hi Bert,
>>
>> I want to save the data into .txt file for another software process.
>>
>> Thanks for suggestion.
>>
>> 2013/3/8 Bert Gunter 
>>>
>>> ?write.table
>>>
>>> which says, under details:
>>>
>>> "In almost all cases the conversion of numeric quantities is governed
>>> by the option "scipen" (see options), but with the internal equivalent
>>> of digits=15. For finer control, use format to make a character
>>> matrix/data frame, and call write.table on that. "
>>>
>>> Not sure if this is what you want, as "export" is rather vague.
>>>
>>> -- Bert
>>>
>>> On Thu, Mar 7, 2013 at 12:52 PM, Marino David 
>>> wrote:
>>> > Hi all mailing listers,
>>> >
>>> > I want to export data with specified precision into .txt file. How can
>>> > I
>>> > make it? See  below
>>> >
>>> > sprintf("%.10f",pi)
>>> > [1] "3.1415926536"
>>> >
>>> > when carry out write.matrix(pi,"pi.txt"), 3.141592653589793115998 in
>>> > pi.txt
>>> > file not with 10 decimal places like using sprintf("%.10f",pi)
>>> >
>>> >
>>> > Thanks
>>> >
>>> > Marino
>>> >
>>> > [[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
>>
>>
>



-- 

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] question on package plm

2013-03-07 Thread Wei-han Liu
 Hi R users:

 I am using the plm package for linear panel data analysis but encountered the 
following message when I try plm function to estimate an random model with 
individual effect.

 data.re.ind <- plm(X.RETURN. ~ IOB + IOBS,data=E,model="random",effect = 
"individual")
 Error in swar(object, data, effect) :  the estimated variance of the 
individual effect is negative

 I have tried the other estimation methods ("walhus", "amemiya", "nerlove") in 
addition to method "swar" but it does not help.

 I have googled for answer but I have not found the solution yet. Actually this 
problem encountered by some users but still remains unsolved, I am afraid. 
Would some people help in this regard?

 Best regards,

Wei-han Liu

[[alternative HTML version deleted]]

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


Re: [R] How to export data with defined decimal places

2013-03-07 Thread Jorge I Velez
Dear Marin,

May be not the cleanest way to do it, but the following seems to work:

write.table(as.character(round(pi, 10)), "pi.txt", row.names = FALSE,
col.names = FALSE, quote = FALSE)

Best,
Jorge.-


On Fri, Mar 8, 2013 at 11:24 AM, Marino David wrote:

> Hi Bert,
>
> I read both options and write.table help, but I still can't make it to save
> the data into txt file with fixed precision.
>
> To let you know more clearly what I want, I still you use the previous
> simple example to illustrate.
>
> I want to save pi into pi.txt file with 10 decimal places, that
> is 3.1415926536. How to do it?
>
>
>
> Thanks
>
> Marin
>
>
>
> 2013/3/8 Marino David 
>
> > Hi Bert,
> >
> > I want to save the data into .txt file for another software process.
> >
> > Thanks for suggestion.
> >
> >  2013/3/8 Bert Gunter 
> >
> >> ?write.table
> >>
> >> which says, under details:
> >>
> >> "In almost all cases the conversion of numeric quantities is governed
> >> by the option "scipen" (see options), but with the internal equivalent
> >> of digits=15. For finer control, use format to make a character
> >> matrix/data frame, and call write.table on that. "
> >>
> >> Not sure if this is what you want, as "export" is rather vague.
> >>
> >> -- Bert
> >>
> >> On Thu, Mar 7, 2013 at 12:52 PM, Marino David  >
> >> wrote:
> >> > Hi all mailing listers,
> >> >
> >> > I want to export data with specified precision into .txt file. How
> can I
> >> > make it? See  below
> >> >
> >> > sprintf("%.10f",pi)
> >> > [1] "3.1415926536"
> >> >
> >> > when carry out write.matrix(pi,"pi.txt"), 3.141592653589793115998 in
> >> pi.txt
> >> > file not with 10 decimal places like using sprintf("%.10f",pi)
> >> >
> >> >
> >> > Thanks
> >> >
> >> > Marino
> >> >
> >> > [[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<
> 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
> >>
> >
> >
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


Re: [R] install error - Netcdf library (linux)

2013-03-07 Thread David W. Pierce
> Hi All,
>
> i'm on a debian linux 64bit,
> i'm tying to install the netcdf intraface, i tried both ncdf and ncdf4

[error lines cut]

Hi Massimo,

things are getting confused because nc-config thinks that the netcdf
library is installed in one place, and you are telling R that it's
installed in a different place:

Your command line specifies /usr/lib and /usr/include:

> epy@epinux:~$ sudo R CMD INSTALL --configure-args="-with-
netcdf_incdir=/usr/include -with-netcdf_libdir=/usr/lib"

But nc-config thinks it's in /usr/local:

> --cflags->  -I/usr/local/include -I/usr/local/include
> --libs  -> -L/usr/local/lib -lnetcdf

Is there a reason you specified the paths on the command line? I
suggest *not* specifying the paths in the command line and seeing if
it works automatically using the information in nc-config. However, if
the information in nc-config is outright wrong (for instance, if the
libraries were moved manually after the library was installed), I
suggest removing your current installation of the netcdf library and
re-installing it cleanly from scratch so that it has a correct and
working nc-config.

Regards,

--Dave


On Thu, Mar 7, 2013 at 3:45 PM, epi  wrote:
> Hi All,
>
> i'm on a debian linux 64bit,
> i'm tying to install the netcdf intraface, i tried both ncdf and ncdf4
>
> but  trying to build i received the error :
>
> (i have necdf installed on my machine and it is able to fiund it .. no missed 
> .h)
>
> epy@epinux:~$ sudo R CMD INSTALL 
> --configure-args="-with-netcdf_incdir=/usr/include 
> -with-netcdf_libdir=/usr/lib" ncdf4_1.8.tar.gz
> * installing to library ‘/usr/local/lib/R/site-library’
> * installing *source* package ‘ncdf4’ ...
> checking for nc-config... yes
> Using nc-config: nc-config
> Output of nc-config --all:
>
> This netCDF 4.2.1.1 has been built with the following features:
>
>  --cc-> gcc
>  --cflags->  -I/usr/local/include -I/usr/local/include
>  --libs  -> -L/usr/local/lib -lnetcdf
>
>  --has-c++   -> no
>  --cxx   ->
>  --has-c++4  -> no
>  --cxx4  ->
>
>  --fc->
>  --fflags->
>  --flibs ->
>  --has-f90   -> no
>
>  --has-dap   -> yes
>  --has-nc2   -> yes
>  --has-nc4   -> yes
>  --has-hdf5  -> yes
>  --has-hdf4  -> no
>  --has-pnetcdf-> no
>  --has-szlib ->
>
>  --prefix-> /usr/local
>  --includedir-> /usr/local/include
>  --version   -> netCDF 4.2.1.1
>
> ---
> netcdf.m4: about to set rpath, here is source string: >-L/usr/local/lib 
> -lnetcdf<
> netcdf.m4: final rpath:   -Wl,-rpath,/usr/local/lib
> Netcdf library version: netCDF 4.2.1.1
> Netcdf library has version 4 interface present: yes
> Netcdf library was compiled with C compiler: gcc
> configure: creating ./config.status
> config.status: creating R/load.R
> config.status: creating src/Makevars
>
> **  Results of ncdf4 package configure ***
>
> netCDF v4 CPP flags = -I/usr/local/include -I/usr/local/include
> netCDF v4 LD flags  =   -Wl,-rpath,/usr/local/lib -L/usr/local/lib 
> -lnetcdf
> netCDF v4 runtime path  =   -Wl,-rpath,/usr/local/lib
>
> **
>
> ** libs
> gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -I/usr/local/include 
> -I/usr/local/include -fpic  -O2 -pipe -g  -c ncdf.c -o ncdf.o
> ncdf.c: In function ‘R_nc4_nctype_to_Rtypecode’:
> ncdf.c:40:18: error: ‘NC_INT’ undeclared (first use in this function)
> ncdf.c:40:18: note: each undeclared identifier is reported only once for each 
> function it appears in
> ncdf.c:49:18: error: ‘NC_UBYTE’ undeclared (first use in this function)
> ncdf.c:51:18: error: ‘NC_USHORT’ undeclared (first use in this function)
> ncdf.c:53:18: error: ‘NC_UINT’ undeclared (first use in this function)
> ncdf.c:55:18: error: ‘NC_INT64’ undeclared (first use in this function)
> ncdf.c:57:18: error: ‘NC_UINT64’ undeclared (first use in this function)
> ncdf.c: In function ‘R_nc4_varsize’:
> ncdf.c:69:28: error: ‘NC_MAX_DIMS’ undeclared (first use in this function)
> ncdf.c:75:2: warning: implicit declaration of function ‘nc_inq_varndims’ 
> [-Wimplicit-function-declaration]
> ncdf.c:78:4: warning: implicit declaration of function ‘nc_strerror’ 
> [-Wimplicit-function-declaration]
> ncdf.c:84:2: warning: implicit declaration of function ‘nc_inq_vardimid’ 
> [-Wimplicit-function-declaration]
> ncdf.c:94:3: warning: implicit declaration of function ‘nc_inq_dimlen’ 
> [-Wimplicit-function-declaration]
> ncdf.c: In function ‘R_nc4_inq_varunlim’:
> ncdf.c:112:2: warning: implicit declaration of function ‘nc_inq_unlimdim’ 
> [-Wimplicit-function-declaration]
> ncdf.c: In function ‘R_nc4_inq_var’:
> ncdf.c:152:2: warning: implicit declaration of function ‘nc_inq_var’ 
> [-Wimplicit-function-declaration]
> ncdf.c: In function ‘R_nc4_inq_vartype’:
> ncdf.c:168:2: warning: implicit declaration of function ‘nc_inq_vartype’ 
> [-Wimplicit-function-declaration]
> ncdf.c: In function ‘R_nc4_inq_varname’:
> ncdf.c:181:

Re: [R] How to export data with defined decimal places

2013-03-07 Thread Marino David
Hi Bert,

I read both options and write.table help, but I still can't make it to save
the data into txt file with fixed precision.

To let you know more clearly what I want, I still you use the previous
simple example to illustrate.

I want to save pi into pi.txt file with 10 decimal places, that
is 3.1415926536. How to do it?



Thanks

Marin



2013/3/8 Marino David 

> Hi Bert,
>
> I want to save the data into .txt file for another software process.
>
> Thanks for suggestion.
>
>  2013/3/8 Bert Gunter 
>
>> ?write.table
>>
>> which says, under details:
>>
>> "In almost all cases the conversion of numeric quantities is governed
>> by the option "scipen" (see options), but with the internal equivalent
>> of digits=15. For finer control, use format to make a character
>> matrix/data frame, and call write.table on that. "
>>
>> Not sure if this is what you want, as "export" is rather vague.
>>
>> -- Bert
>>
>> On Thu, Mar 7, 2013 at 12:52 PM, Marino David 
>> wrote:
>> > Hi all mailing listers,
>> >
>> > I want to export data with specified precision into .txt file. How can I
>> > make it? See  below
>> >
>> > sprintf("%.10f",pi)
>> > [1] "3.1415926536"
>> >
>> > when carry out write.matrix(pi,"pi.txt"), 3.141592653589793115998 in
>> pi.txt
>> > file not with 10 decimal places like using sprintf("%.10f",pi)
>> >
>> >
>> > Thanks
>> >
>> > Marino
>> >
>> > [[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
>>
>
>

[[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] why package ZIGP is not there anymore?

2013-03-07 Thread lili puspita rahayu
Mr/Mrs

I am Lili Puspita Rahayu, student from Bogor Agriculture University. 

I wanna ask that why package ZIGP (Zero inflated Generalized Poisson) is not 
there anymore?
is there any other packages that can analyze ZIGP?

I am very
grateful for the assistance of R.
I am looking forward to hearing from you. Thank you very much.

Sincerely yours
Lili Puspita Rahayu 
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] install error - Netcdf library (linux)

2013-03-07 Thread epi
Hi All,

i'm on a debian linux 64bit,
i'm tying to install the netcdf intraface, i tried both ncdf and ncdf4

but  trying to build i received the error :

(i have necdf installed on my machine and it is able to fiund it .. no missed 
.h)

epy@epinux:~$ sudo R CMD INSTALL 
--configure-args="-with-netcdf_incdir=/usr/include 
-with-netcdf_libdir=/usr/lib" ncdf4_1.8.tar.gz 
* installing to library ‘/usr/local/lib/R/site-library’
* installing *source* package ‘ncdf4’ ...
checking for nc-config... yes
Using nc-config: nc-config
Output of nc-config --all:

This netCDF 4.2.1.1 has been built with the following features: 

 --cc-> gcc
 --cflags->  -I/usr/local/include -I/usr/local/include
 --libs  -> -L/usr/local/lib -lnetcdf

 --has-c++   -> no
 --cxx   -> 
 --has-c++4  -> no
 --cxx4  -> 

 --fc-> 
 --fflags-> 
 --flibs -> 
 --has-f90   -> no

 --has-dap   -> yes
 --has-nc2   -> yes
 --has-nc4   -> yes
 --has-hdf5  -> yes
 --has-hdf4  -> no
 --has-pnetcdf-> no
 --has-szlib -> 

 --prefix-> /usr/local
 --includedir-> /usr/local/include
 --version   -> netCDF 4.2.1.1

---
netcdf.m4: about to set rpath, here is source string: >-L/usr/local/lib 
-lnetcdf<
netcdf.m4: final rpath:   -Wl,-rpath,/usr/local/lib
Netcdf library version: netCDF 4.2.1.1
Netcdf library has version 4 interface present: yes
Netcdf library was compiled with C compiler: gcc
configure: creating ./config.status
config.status: creating R/load.R
config.status: creating src/Makevars

**  Results of ncdf4 package configure ***

netCDF v4 CPP flags = -I/usr/local/include -I/usr/local/include
netCDF v4 LD flags  =   -Wl,-rpath,/usr/local/lib -L/usr/local/lib -lnetcdf
netCDF v4 runtime path  =   -Wl,-rpath,/usr/local/lib

**

** libs
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -I/usr/local/include 
-I/usr/local/include -fpic  -O2 -pipe -g  -c ncdf.c -o ncdf.o
ncdf.c: In function ‘R_nc4_nctype_to_Rtypecode’:
ncdf.c:40:18: error: ‘NC_INT’ undeclared (first use in this function)
ncdf.c:40:18: note: each undeclared identifier is reported only once for each 
function it appears in
ncdf.c:49:18: error: ‘NC_UBYTE’ undeclared (first use in this function)
ncdf.c:51:18: error: ‘NC_USHORT’ undeclared (first use in this function)
ncdf.c:53:18: error: ‘NC_UINT’ undeclared (first use in this function)
ncdf.c:55:18: error: ‘NC_INT64’ undeclared (first use in this function)
ncdf.c:57:18: error: ‘NC_UINT64’ undeclared (first use in this function)
ncdf.c: In function ‘R_nc4_varsize’:
ncdf.c:69:28: error: ‘NC_MAX_DIMS’ undeclared (first use in this function)
ncdf.c:75:2: warning: implicit declaration of function ‘nc_inq_varndims’ 
[-Wimplicit-function-declaration]
ncdf.c:78:4: warning: implicit declaration of function ‘nc_strerror’ 
[-Wimplicit-function-declaration]
ncdf.c:84:2: warning: implicit declaration of function ‘nc_inq_vardimid’ 
[-Wimplicit-function-declaration]
ncdf.c:94:3: warning: implicit declaration of function ‘nc_inq_dimlen’ 
[-Wimplicit-function-declaration]
ncdf.c: In function ‘R_nc4_inq_varunlim’:
ncdf.c:112:2: warning: implicit declaration of function ‘nc_inq_unlimdim’ 
[-Wimplicit-function-declaration]
ncdf.c: In function ‘R_nc4_inq_var’:
ncdf.c:152:2: warning: implicit declaration of function ‘nc_inq_var’ 
[-Wimplicit-function-declaration]
ncdf.c: In function ‘R_nc4_inq_vartype’:
ncdf.c:168:2: warning: implicit declaration of function ‘nc_inq_vartype’ 
[-Wimplicit-function-declaration]
ncdf.c: In function ‘R_nc4_inq_varname’:
ncdf.c:181:2: warning: implicit declaration of function ‘nc_inq_varname’ 
[-Wimplicit-function-declaration]
ncdf.c: In function ‘R_nc4_get_vara_double’:
ncdf.c:214:2: warning: implicit declaration of function ‘nc_get_vara_double’ 
[-Wimplicit-function-declaration]
ncdf.c: In function ‘R_nc4_get_vara_int’:
ncdf.c:257:2: warning: implicit declaration of function ‘nc_get_vara_int’ 
[-Wimplicit-function-declaration]
ncdf.c: In function ‘R_nc4_get_vara_text’:
ncdf.c:313:2: warning: implicit declaration of function ‘nc_get_vara_text’ 
[-Wimplicit-function-declaration]
ncdf.c: In function ‘R_nc4_inq_dimid’:
ncdf.c:345:2: warning: implicit declaration of function ‘nc_inq_dimid’ 
[-Wimplicit-function-declaration]
ncdf.c: In function ‘R_nc4_inq_varid’:
ncdf.c:355:2: warning: implicit declaration of function ‘nc_inq_varid’ 
[-Wimplicit-function-declaration]
ncdf.c: In function ‘R_nc4_inq_dimids’:
ncdf.c:377:9: warning: implicit declaration of function ‘nc_inq_dimids’ 
[-Wimplicit-function-declaration]
ncdf.c: In function ‘R_nc4_inq_dim’:
ncdf.c:387:12: error: ‘NC_MAX_NAME’ undeclared (first use in this function)
ncdf.c:391:2: warning: implicit declaration of function ‘nc_inq_dim’ 
[-Wimplicit-function-declaration]
ncdf.c:408:2: warning: implicit declaration of function ‘nc_inq_unlimdims’ 
[-Wimplicit-function-declaration]
ncdf.c: In function ‘R_nc4_inq’:
ncdf.c:451:2: warnin

Re: [R] How to export data with defined decimal places

2013-03-07 Thread Marino David
Hi Bert,

I want to save the data into .txt file for another software process.

Thanks for suggestion.

2013/3/8 Bert Gunter 

> ?write.table
>
> which says, under details:
>
> "In almost all cases the conversion of numeric quantities is governed
> by the option "scipen" (see options), but with the internal equivalent
> of digits=15. For finer control, use format to make a character
> matrix/data frame, and call write.table on that. "
>
> Not sure if this is what you want, as "export" is rather vague.
>
> -- Bert
>
> On Thu, Mar 7, 2013 at 12:52 PM, Marino David 
> wrote:
> > Hi all mailing listers,
> >
> > I want to export data with specified precision into .txt file. How can I
> > make it? See  below
> >
> > sprintf("%.10f",pi)
> > [1] "3.1415926536"
> >
> > when carry out write.matrix(pi,"pi.txt"), 3.141592653589793115998 in
> pi.txt
> > file not with 10 decimal places like using sprintf("%.10f",pi)
> >
> >
> > Thanks
> >
> > Marino
> >
> > [[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
>

[[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] xts time series object removing time and leaving just the date

2013-03-07 Thread arun
HI Douglas,
index(res)
#[1] "2012-09-10 23:59:00 EDT" "2012-09-11 23:59:00 EDT"
#[3] "2012-09-12 02:15:00 EDT"

 str(index(res))
 #POSIXct[1:3], format: "2012-09-10 23:59:00" "2012-09-11 23:59:00" ...

When you use this:

strsplit(index(res)," ")
#Error in strsplit(index(res), " ") : non-character argument


Convert it to character and split
 strsplit(as.character(index(res))," ")# split by space
#[[1]]
#[1] "2012-09-10" "23:59:00"  

#[[2]]
#[1] "2012-09-11" "23:59:00"  

#[[3]]
#[1] "2012-09-12" "02:15:00"  

Now it is a list with three list elements.  Each list element is a vector of 
length two.

lapply(strsplit(as.character(index(res))," "), function(x) x[1]) #select the 
first vector element
#[[1]]
#[1] "2012-09-10"

#[[2]]
#[1] "2012-09-11"

#[[3]]
#[1] "2012-09-12"


 unlist(lapply(strsplit(as.character(index(res))," "), function(x) x[1]))  
#which is still a 'character' class
#[1] "2012-09-10" "2012-09-11" "2012-09-12"


  index(res)<-unlist(lapply(strsplit(as.character(index(res))," "), function(x) 
x[1]))
#Error in `index<-.xts`(`*tmp*`, value = c("2012-09-10", "2012-09-11",  : 
 # unsupported ‘index’ index type of class ‘character’

Convert it to `date`
index(res)<- as.Date(unlist(lapply(strsplit(as.character(index(res))," "), 
function(x) x[1])))
res
#    [,1]
#2012-09-10  19.64393
#2012-09-11 -81.62702
#2012-09-12  11.98883





- Original Message -
From: Douglas Karabasz 
To: 'arun' 
Cc: 
Sent: Thursday, March 7, 2013 5:44 PM
Subject: RE: [R] xts time series object removing time and leaving just the date

Arun,

This is awesome, works perfect!  Now I'm trying to understand it.  I hate to
ask this but could you give a quick overview of 

index(res)<-as.Date(unlist(lapply(strsplit(as.character(index(res)),"
"),function(x) x[1])))  

If I'm ask too much I understand.  You got me over the hump and I'm sure I
will understand it at a later date.  

Thank you again,
Douglas

-Original Message-
From: arun [mailto:smartpink...@yahoo.com] 
Sent: Thursday, March 07, 2013 4:04 PM
To: Douglas Karabasz
Subject: Re: [R] xts time series object removing time and leaving just the
date

Hi Douglas,
No problem.
Arun




- Original Message -
From: Douglas Karabasz 
To: 'arun' 
Cc: 
Sent: Thursday, March 7, 2013 4:41 PM
Subject: RE: [R] xts time series object removing time and leaving just the
date

Arun,

Yes, this looks great!  Thanks for the help.  Also, thanks for creating a
xts object for me first.  I should have done it in the question looking
back.  However, I think I would have created incorrectly so I learned two
really helpful things here.

Thanks again,
Douglas

-Original Message-
From: arun [mailto:smartpink...@yahoo.com]
Sent: Thursday, March 07, 2013 1:09 PM
To: Douglas Karabasz
Cc: R help
Subject: Re: [R] xts time series object removing time and leaving just the
date

Hi,

Try this:
library(xts)

Date1<- seq(as.POSIXct("2012-09-10 02:15:00",format="%Y-%m-%d %H:%M:%S"),
as.POSIXct("2012-09-12 02:15:00",format="%Y-%m-%d %H:%M:%S"), by="min")
length(Date1)
#[1] 2881
set.seed(15)
value<- rnorm(2881)
xt1<-xts(value,order.by=Date1)

res<-apply.daily(xt1,sum)
res1<- res

 res
# [,1]
#2012-09-10 23:59:00  19.64393
#2012-09-11 23:59:00 -81.62702
#2012-09-12 02:15:00  11.98883
 index(res)<-as.Date(unlist(lapply(strsplit(as.character(index(res)),"
"),function(x) x[1])))
 res
#    [,1]
#2012-09-10  19.64393
#2012-09-11 -81.62702
#2012-09-12  11.98883

#or
index(res1)<-as.Date(gsub("\\s+.*","",index(res1)))
 res1
#    [,1]
#2012-09-10  19.64393
#2012-09-11 -81.62702
#2012-09-12  11.98883

A.K.



- Original Message -
From: Douglas Karabasz 
To: r-help@r-project.org
Cc: 
Sent: Thursday, March 7, 2013 1:42 PM
Subject: [R] xts time series object removing time and leaving just the date

I have and XTS time series object that has date and time.  I started with 1
minute data and used apply.daily(x, sum) to sum the data to one cumulative
value.  This function works just fine however it leaves a time for the last
summed value which looks like this 2006-07-19 14:58:00.  I need to just have
the date and to remove the time value of 14:58:00 just leaving the date
value of 2006-07-19  .  I want to keep the xts object otherwise intact.  Is
this possible?    

Thank you,
Douglas






    [[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] optim hangs without warnings or error

2013-03-07 Thread Ben Bolker
Katja Hebestreit  uni-muenster.de> writes:

> 
> Hello,
> 
> optim hangs for some reason when called within the betareg function
> (from the betareg package).
> 
> In this special case, the arguments which are passed to optim cause
> never ending calculations.
> 
> I uploaded the arguments passed to optim on:
> https://www.dropbox.com/s/ud507gbpt3gkbcp/optim_arguments.RData
> 
> I appreciate any help.
> Cheers,
> Katja
> 

 Hmm, it works fine for me (thank you for the very reproducible
example!)

L <- load("/tmp/optim_arguments.RData")
arglist <- setNames(lapply(L,get),L)
do.call(optim,arglist)

Results:

$par
 mean.(Intercept) mean.groupcontrol   mean.gendermaleprecision1   
precision2 
-2.522996e+00 -5.018542e-01  6.197797e-13  4.445938e+00 
2.871008e+01 

$value
[1] 274.5367

$counts
function gradient 
 552   87 

$convergence
[1] 0

$message
NULL

> sessionInfo()
R Under development (unstable) (2012-12-14 r61321)
Platform: i686-pc-linux-gnu (32-bit)

locale:
[snip]

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

loaded via a namespace (and not attached):
[1] betareg_3.0-2 flexmix_2.3-8 lmtest_0.9-30 modeltools_0.2-19
[5] multcomp_1.2-15   sandwich_2.2-9stats4_2.16.0 tools_2.16.0


> > sessionInfo()
> R version 2.15.3 (2013-03-01)
> Platform: x86_64-pc-linux-gnu (64-bit)
> 
> locale:
>  [1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C  
>  [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8
>  [5] LC_MONETARY=en_US.UTF-8LC_MESSAGES=en_US.UTF-8   
>  [7] LC_PAPER=C LC_NAME=C 
>  [9] LC_ADDRESS=C   LC_TELEPHONE=C
> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C   
> 
> attached base packages:
> [1] stats graphics  grDevices utils datasets  methods
> base 
> 
> loaded via a namespace (and not attached):
> [1] betareg_3.0-2 flexmix_2.3-8 lmtest_0.9-30
> modeltools_0.2-19
> [5] multcomp_1.2-15   sandwich_2.2-9stats4_2.15.3
> tools_2.15.3
> 
>

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


Re: [R] How to export data with defined decimal places

2013-03-07 Thread Bert Gunter
?write.table

which says, under details:

"In almost all cases the conversion of numeric quantities is governed
by the option "scipen" (see options), but with the internal equivalent
of digits=15. For finer control, use format to make a character
matrix/data frame, and call write.table on that. "

Not sure if this is what you want, as "export" is rather vague.

-- Bert

On Thu, Mar 7, 2013 at 12:52 PM, Marino David  wrote:
> Hi all mailing listers,
>
> I want to export data with specified precision into .txt file. How can I
> make it? See  below
>
> sprintf("%.10f",pi)
> [1] "3.1415926536"
>
> when carry out write.matrix(pi,"pi.txt"), 3.141592653589793115998 in pi.txt
> file not with 10 decimal places like using sprintf("%.10f",pi)
>
>
> Thanks
>
> Marino
>
> [[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.


[R] How to export data with defined decimal places

2013-03-07 Thread Marino David
Hi all mailing listers,

I want to export data with specified precision into .txt file. How can I
make it? See  below

sprintf("%.10f",pi)
[1] "3.1415926536"

when carry out write.matrix(pi,"pi.txt"), 3.141592653589793115998 in pi.txt
file not with 10 decimal places like using sprintf("%.10f",pi)


Thanks

Marino

[[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] iterative extracting data from a list without keys

2013-03-07 Thread Bert Gunter
Re-read
?"["
(always better to read the docs before archives...)

and note in particular:

"[[ can be applied recursively to lists, so that if the single index i
is a vector of length p, alist[[i]] is equivalent to
alist[[i1]]...[[ip]] providing all but the final indexing results in a
list."

I agree -- it's terse. But it's accurate and complete.

-- Bert

On Thu, Mar 7, 2013 at 12:14 PM, Jeff Hollenbeck  wrote:
> Dear R Users.
>
> This seems like a simple task, but I'm stuck.
>
> I have a list with 3 elements: (2 vectors and 1 matrix).  I wish to extract 
> each of these data elements using index subscripts and multiply them with a 
> vector multiplier.
>
> What I have:
>> betas
> [1] 0.01 0.01 0.01
>
>> LData[1]
> $int
>   [1] 1 1 1 1 1 1 1 1 1 1
> $date
>[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
>   [1,]  152  153  154  155  156  157  158  159  160  161
>   [2,]  163  164  165  166  167  168  162  163  164  165
> $land
>   [1] 0 0 0 0 1 0 1 1 0 0
>
> What I'm trying to do:
> I would like to have the elements in the vector, betas[1:3] multiplied by 
> corresponding data elements in LData[[1:3]].
> This is how I initially try to do it, but does not work:
>
>> probs <- betas[1:3] * LData[[1:3]]
> Error in LData[[1:3]] : recursive indexing failed at level 2
>
> Apparently, the above is not allowed.  But, if I try
>
>> probs <- betas[1:3] * LData[1:3]
> Error in betas[1:3] * LData[1:3] :
>   non-numeric argument to binary operator
>
> I can see that the list keys get in the way of the multiplication operation.
>
> There just has to be a way to do this.  I have searched archives and find 
> plenty of examples of extracting data elements individually, and even 
> extraction of multiple vector elements (unfortunately one of mine is an 
> matrix), but not my situation.  In particular, no examples attempting to 
> vectorize the math operation.  yapply and mapply don't seem to be what I 
> want, but what I've read of them confuses me.  Want to avoid for loops, 
> unless its the only way.
>
> All help is much appreciated!
>
> Thanks.
>
> ***
> Jeff P. Hollenbeck
> USGS Forest and Rangeland Ecosystem Science Center
> 3200 SW Jefferson Way
> Corvallis, OR 97331
> 541-750-0966
>
> [[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] Transpose a big data file and write to a new file

2013-03-07 Thread Claudia Beleites
Hi Yao He,

this doesn't sound like R to me. I'd go for perl (or awk).

See e.g. here:
http://stackoverflow.com/questions/1729824/transpose-a-file-in-bash

HTH

Claudia

Am Wed, 6 Mar 2013 22:37:14 +0800
schrieb Yao He :

> Dear all:
> 
> I have a big data file of 6 columns and 6 rows like that:
> 
> AA AC AA AA ...AT
> CC CC CT CT...TC
> ..
> .
> 
> I want to transpose it and the output is a new like that
> AA CC 
> AC CC
> AA CT.
> AA CT.
> 
> 
> AT TC.
> 
> The keypoint is  I can't read it into R by read.table() because the
> data is too large,so I try that:
> c<-file("silygenotype.txt","r")
> geno_t<-list()
> repeat{
>   line<-readLines(c,n=1)
>   if (length(line)==0)break  #end of file
>   line<-unlist(strsplit(line,"\t"))
> geno_t<-cbind(geno_t,line)
> }
>  write.table(geno_t,"xxx.txt")
> 
> It works but it is too slow ,how to optimize it???
> 
> Thank you
> 
> Yao He
> —
> Master candidate in 2rd year
> Department of Animal genetics & breeding
> Room 436,College of Animial Science&Technology,
> China Agriculture University,Beijing,100193
> E-mail: yao.h.1...@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.



-- 
Claudia Beleites
Spectroscopy/Imaging
Institute of Photonic Technology 
Albert-Einstein-Str. 9
07745 Jena
Germany

email: claudia.belei...@ipht-jena.de
phone: +49 3641 206-133
fax:   +49 2641 206-399

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] iterative extracting data from a list without keys

2013-03-07 Thread arun
Hi,
Try this:
betas<- c(0.01,0.01,0.01)
LData<- list(int=rep(1,10), date= 
matrix(c(152:161,163:168,162:165),nrow=2,ncol=10,byrow=TRUE), 
land=c(rep(0,4),1,0,1,1,0,0))

 betas2<- c(0.01,1,2)
mapply(`*`,LData,betas2)
#$int
# [1] 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01

#$date
# [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
#[1,]  152  153  154  155  156  157  158  159  160   161
#[2,]  163  164  165  166  167  168  162  163  164   165

#$land
# [1] 0 0 0 0 2 0 2 2 0 0


A.K.



- Original Message -
From: Jeff Hollenbeck 
To: r-help@r-project.org
Cc: 
Sent: Thursday, March 7, 2013 3:14 PM
Subject: [R] iterative extracting data from a list without keys

Dear R Users.

This seems like a simple task, but I'm stuck.

I have a list with 3 elements: (2 vectors and 1 matrix).  I wish to extract 
each of these data elements using index subscripts and multiply them with a 
vector multiplier.

What I have:
> betas
[1] 0.01 0.01 0.01

> LData[1]
$int
  [1] 1 1 1 1 1 1 1 1 1 1
$date
       [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] 
  [1,]  152  153  154  155  156  157  158  159  160  161  
  [2,]  163  164  165  166  167  168  162  163  164  165
$land
  [1] 0 0 0 0 1 0 1 1 0 0 

What I'm trying to do:
I would like to have the elements in the vector, betas[1:3] multiplied by 
corresponding data elements in LData[[1:3]].
This is how I initially try to do it, but does not work:

> probs <- betas[1:3] * LData[[1:3]]
Error in LData[[1:3]] : recursive indexing failed at level 2

Apparently, the above is not allowed.  But, if I try

> probs <- betas[1:3] * LData[1:3]
Error in betas[1:3] * LData[1:3] : 
  non-numeric argument to binary operator

I can see that the list keys get in the way of the multiplication operation.

There just has to be a way to do this.  I have searched archives and find 
plenty of examples of extracting data elements individually, and even 
extraction of multiple vector elements (unfortunately one of mine is an 
matrix), but not my situation.  In particular, no examples attempting to 
vectorize the math operation.  yapply and mapply don't seem to be what I want, 
but what I've read of them confuses me.  Want to avoid for loops, unless its 
the only way.

All help is much appreciated!

Thanks.

***
Jeff P. Hollenbeck
USGS Forest and Rangeland Ecosystem Science Center
3200 SW Jefferson Way
Corvallis, OR 97331
541-750-0966

    [[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] iterative extracting data from a list without keys

2013-03-07 Thread Jeff Hollenbeck
Dear R Users.

This seems like a simple task, but I'm stuck.

I have a list with 3 elements: (2 vectors and 1 matrix).  I wish to extract 
each of these data elements using index subscripts and multiply them with a 
vector multiplier.

What I have:
> betas
[1] 0.01 0.01 0.01

> LData[1]
$int
  [1] 1 1 1 1 1 1 1 1 1 1
$date
   [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] 
  [1,]  152  153  154  155  156  157  158  159  160  161   
  [2,]  163  164  165  166  167  168  162  163  164  165
$land
  [1] 0 0 0 0 1 0 1 1 0 0 

What I'm trying to do:
I would like to have the elements in the vector, betas[1:3] multiplied by 
corresponding data elements in LData[[1:3]].
This is how I initially try to do it, but does not work:

> probs <- betas[1:3] * LData[[1:3]]
Error in LData[[1:3]] : recursive indexing failed at level 2

Apparently, the above is not allowed.  But, if I try

> probs <- betas[1:3] * LData[1:3]
Error in betas[1:3] * LData[1:3] : 
  non-numeric argument to binary operator

I can see that the list keys get in the way of the multiplication operation.

There just has to be a way to do this.  I have searched archives and find 
plenty of examples of extracting data elements individually, and even 
extraction of multiple vector elements (unfortunately one of mine is an 
matrix), but not my situation.  In particular, no examples attempting to 
vectorize the math operation.  yapply and mapply don't seem to be what I want, 
but what I've read of them confuses me.  Want to avoid for loops, unless its 
the only way.

All help is much appreciated!

Thanks.

***
Jeff P. Hollenbeck
USGS Forest and Rangeland Ecosystem Science Center
3200 SW Jefferson Way
Corvallis, OR 97331
541-750-0966

[[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] optim hangs without warnings or error

2013-03-07 Thread Katja Hebestreit
Hello,

optim hangs for some reason when called within the betareg function
(from the betareg package).

In this special case, the arguments which are passed to optim cause
never ending calculations.

I uploaded the arguments passed to optim on:
https://www.dropbox.com/s/ud507gbpt3gkbcp/optim_arguments.RData


I appreciate any help.
Cheers,
Katja


> sessionInfo()
R version 2.15.3 (2013-03-01)
Platform: x86_64-pc-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C  
 [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8
 [5] LC_MONETARY=en_US.UTF-8LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=C LC_NAME=C 
 [9] LC_ADDRESS=C   LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C   

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

loaded via a namespace (and not attached):
[1] betareg_3.0-2 flexmix_2.3-8 lmtest_0.9-30
modeltools_0.2-19
[5] multcomp_1.2-15   sandwich_2.2-9stats4_2.15.3
tools_2.15.3

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] what is absolute size of mar

2013-03-07 Thread Duncan Murdoch

On 07/03/2013 2:07 PM, Not To Miss wrote:

Hi R users,

The margin parameter mar is measured in unit of lines, the size of which is
automatically adjusted during plotting. I am wondering how can get the size
of a line and how can I control the margin size by controlling the line
size? (I know I can use mai to control the absolute size of margin, but in
some situations that parameter does not exist. For example, heatmap() only
accept mar as a parameter to adjust the space for the axes labels.) I'd
appreciate any help.


You need to look at par().  I believe a line would be 
par("lheight")*par("cin")[2] inches.  You can use grconvertX or 
grconvertY to convert from inches to other units.


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] xts time series object removing time and leaving just the date

2013-03-07 Thread arun
Hi,

Try this:
library(xts)

Date1<- seq(as.POSIXct("2012-09-10 02:15:00",format="%Y-%m-%d %H:%M:%S"), 
as.POSIXct("2012-09-12 02:15:00",format="%Y-%m-%d %H:%M:%S"), by="min")
length(Date1)
#[1] 2881
set.seed(15)
value<- rnorm(2881)
xt1<-xts(value,order.by=Date1)

res<-apply.daily(xt1,sum)
res1<- res

 res
# [,1]
#2012-09-10 23:59:00  19.64393
#2012-09-11 23:59:00 -81.62702
#2012-09-12 02:15:00  11.98883
 index(res)<-as.Date(unlist(lapply(strsplit(as.character(index(res))," 
"),function(x) x[1])))
 res
#    [,1]
#2012-09-10  19.64393
#2012-09-11 -81.62702
#2012-09-12  11.98883

#or
index(res1)<-as.Date(gsub("\\s+.*","",index(res1)))
 res1
#    [,1]
#2012-09-10  19.64393
#2012-09-11 -81.62702
#2012-09-12  11.98883

A.K.



- Original Message -
From: Douglas Karabasz 
To: r-help@r-project.org
Cc: 
Sent: Thursday, March 7, 2013 1:42 PM
Subject: [R] xts time series object removing time and leaving just the date

I have and XTS time series object that has date and time.  I started with 1
minute data and used apply.daily(x, sum) to sum the data to one cumulative
value.  This function works just fine however it leaves a time for the last
summed value which looks like this 2006-07-19 14:58:00.  I need to just have
the date and to remove the time value of 14:58:00 just leaving the date
value of 2006-07-19  .  I want to keep the xts object otherwise intact.  Is
this possible?    

Thank you,
Douglas






    [[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] what is absolute size of mar

2013-03-07 Thread Not To Miss
Hi R users,

The margin parameter mar is measured in unit of lines, the size of which is
automatically adjusted during plotting. I am wondering how can get the size
of a line and how can I control the margin size by controlling the line
size? (I know I can use mai to control the absolute size of margin, but in
some situations that parameter does not exist. For example, heatmap() only
accept mar as a parameter to adjust the space for the axes labels.) I'd
appreciate any help.

Thanks,
Zech

[[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] ggpliot2: reordering of factors in facets facet.grid(). Reordering of factor on x-axis no problem.

2013-03-07 Thread John Kane

   Anna,
   You're right.  Something I am doing seems to be messing up RStudio every
   once in a while.  I rebooted it and the faceting is working just fine both
   with just the required packages loaded and with my normal set of packages.
   I had real trouble getting the legend.position command to work until I
   rebooted RStudio and now this.
   I have no idea of how to track  down what's happening but at least you've
   made me aware of it.
   Thanks

   John Kane
   Kingston ON Canada

   -Original Message-
   From: a...@ecology.su.se
   Sent: Thu, 07 Mar 2013 19:32:21 +0100
   To: jrkrid...@inbox.com, istaz...@gmail.com
   Subject: Re: [R] ggpliot2: reordering of factors in facets facet.grid().
   Reordering of factor on x-axis no problem.

   Dear John and Ista,

   Ista: Thank you so much for your help and for not shouting :-)
   Sometimes one goes blind having stared at a script for too long. I realize
   that the grouping is not needed at all - it is the remnant from another
   figure I made showing two factor 1 -levels per plot instead of just one
   level.

   John:   It   works   for   me.   You  mentioned  previously  that  the
   geometric.line(blabla dodge) didn't work because you had some other packages
   open. Maybe that is the case again? If you find out what it is, please
   share! It is good to know which packages disturb each other!

   Once again, thank you so much! Another day closer to disputation... :-S
   Anna


   Anna Zakrisson Braeunlich
   PhD student
   Department of Ecology Environment and Plant Sciences
   Stockholm University
   Svante Arrheniusv. 21A
   SE-106 91 Stockholm
   Sweden

   Lives in Berlin.
   For paper mail:
   Katzbachstr. 21
   D-10965, Berlin - Kreuzberg
   Germany/Deutschland
   E-mail: anna.zakris...@su.se
   Tel work: +49-(0)3091541281
   Mobile: +49-(0)15777374888
   LinkedIn: http://se.linkedin.com/pub/anna-zakrisson-braeunlich/33/5a2/51b
   ><º>`•. . • `•. .• `•. . ><º>`•. . • `•. .• `•. .><º>`•. . •
   `•. .• `•. .><º>

 -Original Message-
 From: John Kane 
 To: Ista Zahn , Anna Zakrisson 
 Cc: "r-help@r-project.org" 
 Date: Thu, 7 Mar 2013 09:35:01 -0800
 Subject: Re: [R] ggpliot2: reordering of factors in facets facet.grid().
 Reordering of factor on x-axis no problem.

   If I try  facet_wrap(~factor1, ncol = 2) I get no faceting at all. Strange.

   John Kane
   Kingston ON Canada
   > -Original Message-
   > From: istaz...@gmail.com
   > Sent: Thu, 7 Mar 2013 12:14:01 -0500
   > To: a...@ecology.su.se
   > Subject: Re: [R] ggpliot2: reordering of factors in facets facet.grid().
   > Reordering of factor on x-axis no problem.
   >
   > Hi Anna,
   >
   > On Thu, Mar 7, 2013 at 10:16 AM, Anna Zakrisson 
   > wrote:
   >>
   >> Hi everyone (again),
   >> before you all start screaming that the reordering of factors has been
   >> discusse on several threads and is not particular to ggplot2, hear me
   >> out.
   >
   > I'm sorry you have been traumatized like this! I promise not to yell.
   >
   >> I can easily reorder my x-axis factor in facet.grid() in ggplot2. What I
   >> cannot reorder are the factors represented on the strips. I can see that
   >> the
   >> graphs are changing, so I am afraid of what it is I am doing. Why is
   >> ggplot2
   >> not changin the strip labels if indeed the factor-order has been
   >> changed?
   >> or have I missed to add code defining the factor-labels in the strips. I
   >> have not found such code as it has been done automatically from my
   >> dataframe
   >> using facet.grid() previously. I am simply afraid of displaying the
   >> wrong
   >> things without noticing it.
   >
   > Your problem is simple. factor1 is a factor with the desired levels.
   > But you did not facet by factor1, you faceted by Grouping. You just
   > need to replace
   >
   >   facet_wrap(~Grouping, ncol = 2)
   >
   > with
   >
   >   facet_wrap(~factor1, ncol = 2)
   >
   > Best,
   > Ista
   >
   >> Here is my code and comments:
   >>
   >> I want to have my factor 1 in the order: "F", "E", "C", "D", "A", "B"
   >> instead of alphabetical. My normal methods do not work.
   >>
   >> with kind regards
   >> Anna Zakrisson
   >>
   >> # Some dummy data:
   >> mydata<- data.frame(factor1 = factor(rep(LETTERS[1:6], each = 80)),
   >> factor2 = factor(rep(c(1:5), each = 16)),
   >> factor3 = factor(rep(c(1:4), each = 4)),
   >> var1 = rnorm(120, mean = rep(c(0, 3, 5), each = 40),
   >>  sd = rep(c(1, 2, 3), each = 20)),
   >> var2 = rnorm(120, mean = rep(c(6, 7, 8), each = 40),
   >>  sd = rep(c(1, 2, 3), each = 20)))
   >>
   >> # Trying to change the order of my factor1 (same method works for
   >> factor3,
   >> # which is on th x-axis). Factor1 (A-F) is represented on the different
   >> facets
   >> # and the factor1 

[R] xts time series object removing time and leaving just the date

2013-03-07 Thread Douglas Karabasz
I have and XTS time series object that has date and time.  I started with 1
minute data and used apply.daily(x, sum) to sum the data to one cumulative
value.  This function works just fine however it leaves a time for the last
summed value which looks like this 2006-07-19 14:58:00.  I need to just have
the date and to remove the time value of 14:58:00 just leaving the date
value of 2006-07-19  .  I want to keep the xts object otherwise intact.  Is
this possible?
 
Thank you,
Douglas
 
 

 


[[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] ggpliot2: reordering of factors in facets facet.grid(). Reordering of factor on x-axis no problem.

2013-03-07 Thread Anna Zakrisson
Dear John and Ista,

Ista: Thank you so much for your help and for not shouting :-)
Sometimes one goes blind having stared at a script for too long. I realize 
that the grouping is not needed at all - it is the remnant from another 
figure I made showing two factor 1 -levels per plot instead of just one 
level.

John: It works for me. You mentioned previously that the 
geometric.line(blabla dodge) didn't work because you had some other packages 
open. Maybe that is the case again? If you find out what it is, please 
share! It is good to know which packages disturb each other!

Once again, thank you so much! Another day closer to disputation... :-S
Anna


Anna Zakrisson Braeunlich
PhD student

Department of Ecology Environment and Plant Sciences
Stockholm University
Svante Arrheniusv. 21A
SE-106 91 Stockholm
Sweden

Lives in Berlin.
For paper mail:
Katzbachstr. 21
D-10965, Berlin - Kreuzberg
Germany/Deutschland

E-mail: anna.zakris...@su.se
Tel work: +49-(0)3091541281
Mobile: +49-(0)15777374888
LinkedIn: http://se.linkedin.com/pub/anna-zakrisson-braeunlich/33/5a2/51b

><º>`•. . • `•. .• `•. . ><º>`•. . • `•. .• 
`•. .><º>`•. . • `•. .• `•. .><º>

-Original Message-
From: John Kane 
To: Ista Zahn , Anna Zakrisson 
Cc: "r-help@r-project.org" 
Date: Thu, 7 Mar 2013 09:35:01 -0800
Subject: Re: [R] ggpliot2: reordering of factors in facets facet.grid(). 
Reordering of factor on x-axis no problem.

If I try  facet_wrap(~factor1, ncol = 2) I get no faceting at all. Strange.
 

John Kane
Kingston ON Canada


> -Original Message-
> From: istaz...@gmail.com
> Sent: Thu, 7 Mar 2013 12:14:01 -0500
> To: a...@ecology.su.se
> Subject: Re: [R] ggpliot2: reordering of factors in facets facet.grid().
> Reordering of factor on x-axis no problem.
>
> Hi Anna,
>
> On Thu, Mar 7, 2013 at 10:16 AM, Anna Zakrisson 
> wrote:
>>
>> Hi everyone (again),
>> before you all start screaming that the reordering of factors has been
>> discusse on several threads and is not particular to ggplot2, hear me
>> out.
>
> I'm sorry you have been traumatized like this! I promise not to yell.
>
>> I can easily reorder my x-axis factor in facet.grid() in ggplot2. What I
>> cannot reorder are the factors represented on the strips. I can see that
>> the
>> graphs are changing, so I am afraid of what it is I am doing. Why is
>> ggplot2
>> not changin the strip labels if indeed the factor-order has been
>> changed?
>> or have I missed to add code defining the factor-labels in the strips. I
>> have not found such code as it has been done automatically from my
>> dataframe
>> using facet.grid() previously. I am simply afraid of displaying the
>> wrong
>> things without noticing it.
>
> Your problem is simple. factor1 is a factor with the desired levels.
> But you did not facet by factor1, you faceted by Grouping. You just
> need to replace
>
>   facet_wrap(~Grouping, ncol = 2)
>
> with
>
>   facet_wrap(~factor1, ncol = 2)
>
> Best,
> Ista
>
>> Here is my code and comments:
>>
>> I want to have my factor 1 in the order: "F", "E", "C", "D", "A", "B"
>> instead of alphabetical. My normal methods do not work.
>>
>> with kind regards
>> Anna Zakrisson
>>
>> # Some dummy data:
>> mydata<- data.frame(factor1 = factor(rep(LETTERS[1:6], each = 80)),
>> factor2 = factor(rep(c(1:5), each = 16)),
>> factor3 = factor(rep(c(1:4), each = 4)),
>> var1 = rnorm(120, mean = rep(c(0, 3, 5), each = 40),
>>  sd = rep(c(1, 2, 3), each = 20)),
>> var2 = rnorm(120, mean = rep(c(6, 7, 8), each = 40),
>>  sd = rep(c(1, 2, 3), each = 20)))
>>
>> # Trying to change the order of my factor1 (same method works for
>> factor3,
>> # which is on th x-axis). Factor1 (A-F) is represented on the different
>> facets
>> # and the factor1 labels can be read off the strips:
>> mydata$factor1 <- factor(mydata$factor1,
>>levels=c("F", "E", "C", "D", "A", "B"),
>>order=T)
>>
>> # summarizing the data with factor1 and factor3:
>> Summ  <-   ddply(mydata, .(factor3,factor1), summarize,
>>  mean = mean(var1, na.rm = FALSE),
>>  sdv = sd(var1, na.rm = FALSE),
>>  se = 1.96*(sd(var1, na.rm=FALSE)/sqrt(length(var1
>> Summ$Grouping <- c("F", "E", "C", "D", "A", "B")[Summ$factor1]
>>
>> # Trying to order factor 1 accordingly:
>> Summ$factor1 <- factor(Summ$factor1,
>>levels=c("F", "E", "C", "D", "A", "B"),
>>order=T)
>>
>>
>> # plotting:
>> ggplot(Summ, aes(factor3, mean, group = factor1,
>>  ymin = mean - sdv , ymax = mean + sdv)) +
>>   geom_point(position = position_dodge(width = 0.25), size = 3) +
>>   geom_line(position = position_dodge(width = 0.25)) +
>>   geom_errorbar(width = 0.3, position = position_dodge(width = 0.25),
>> size
>

Re: [R] rbind a list of matrices

2013-03-07 Thread Berend Hasselman

On 07-03-2013, at 17:52, Heath Blackmon  wrote:

> I have a large list of matrices and a vector that identifies the desired
> matrices that I would like to rbind.  However, I am stuck on how to get
> this to work.  I have written some code below to illustrate my problem:
> 
> # 3 simple matrices
> a<-matrix(1:9,3,3)
> b<-matrix(10:18,3,3)
> c<-matrix(19:27,3,3)
> 
> #this is the type of list of matrices I am dealing with
> matrix.list<-vector("list",3)
> matrix.list[[1]]<-a
> matrix.list[[2]]<-b
> matrix.list[[3]]<-c
> 
> #i have a vector that identifies the ones that i want
> desired.matrices <- c(1,3)
> 
> #i have tried lots of things next but all fail.  This one gets close but I
> seem to lose my dim attributes
> goal<-rbind(matrix.list[desired.matrices])
> 
> Any ideas would be wonderful.


do.call(rbind,matrix.list)

Berend

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


Re: [R] rbind a list of matrices

2013-03-07 Thread Bert Gunter
?do.call

## as in

do.call(rbind, list_of_matrices)

## Note that list_of_matrices must be a **list**.

-- Bert



On Thu, Mar 7, 2013 at 8:52 AM, Heath Blackmon  wrote:
> I have a large list of matrices and a vector that identifies the desired
> matrices that I would like to rbind.  However, I am stuck on how to get
> this to work.  I have written some code below to illustrate my problem:
>
> # 3 simple matrices
> a<-matrix(1:9,3,3)
> b<-matrix(10:18,3,3)
> c<-matrix(19:27,3,3)
>
> #this is the type of list of matrices I am dealing with
> matrix.list<-vector("list",3)
> matrix.list[[1]]<-a
> matrix.list[[2]]<-b
> matrix.list[[3]]<-c
>
> #i have a vector that identifies the ones that i want
> desired.matrices <- c(1,3)
>
> #i have tried lots of things next but all fail.  This one gets close but I
> seem to lose my dim attributes
> goal<-rbind(matrix.list[desired.matrices])
>
> Any ideas would be wonderful.
>
> Thanks
>
> Heath
>
> --
> *Heath Blackmon
> Graduate Teaching Assistant
> Dept of Biology - Box 19498
> Univ. of Texas, Arlington
> Arlington, TX 76019
> Office: ERB450
> Phone 682-444-0538
> *
>
> [[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] rbind a list of matrices

2013-03-07 Thread arun
Not sure if this what you wanted.

 do.call(rbind,(matrix.list[desired.matrices]))
# [,1] [,2] [,3]
#[1,]    1    4    7
#[2,]    2    5    8
#[3,]    3    6    9
#[4,]   19   22   25
#[5,]   20   23   26
#[6,]   21   24   27
A.K.




From: Heath Blackmon 
To: r-help@r-project.org 
Sent: Thursday, March 7, 2013 11:52 AM
Subject: [R] rbind a list of matrices

I have a large list of matrices and a vector that identifies the desired
matrices that I would like to rbind.  However, I am stuck on how to get
this to work.  I have written some code below to illustrate my problem:

# 3 simple matrices
a<-matrix(1:9,3,3)
b<-matrix(10:18,3,3)
c<-matrix(19:27,3,3)

#this is the type of list of matrices I am dealing with
matrix.list<-vector("list",3)
matrix.list[[1]]<-a
matrix.list[[2]]<-b
matrix.list[[3]]<-c

#i have a vector that identifies the ones that i want
desired.matrices <- c(1,3)

#i have tried lots of things next but all fail.  This one gets close but I
seem to lose my dim attributes
goal<-rbind(matrix.list[desired.matrices])

Any ideas would be wonderful.

Thanks

Heath

-- 
*Heath Blackmon
Graduate Teaching Assistant
Dept of Biology - Box 19498
Univ. of Texas, Arlington
Arlington, TX 76019
Office: ERB450
Phone 682-444-0538
*

    [[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] initial starting values with constOptim()

2013-03-07 Thread Konstantinos Georgalos
Hi all,

I am trying to estimate few parameters using the constained maximum
likelihood in R and more specifically the constOptim() from the stata
package in R. I am programming in Python and using R via the RPy2.

In my model, I am assuming that the data follow the Beta-distribution, so I
created a simulated dataset by using prespecified values for the parameters
and now I am trying to estimate these parameters in order to verify that my
estimation program works fine.

What I have observed is that my estimation is quite sensitive to the
initial parameters. For example I have 11 parameters to estimate (let's
call the parameters as pam1..pam11) and their true value is:

pam1=0.2 pam2=0.3 pam3=0.4 pam4=0.7 pam5=0.55 pam6=0.45 pam7=0.1 pam8=0.01
pam9=0.01 pam10=45 pam11=45

In the contrtOptim() I am setting the starting parameters as:

start_param=FloatVector((pam1,pam2,pam3,pam4,pam5,pam6,pam7,pam8,pam9,pam10,pam,11))

where I set the starting values. I have observed that when I am using
different sets of starting values the results change. For example when I am
using the set

start_param=FloatVector((0.2,0.3,0.4,0.6,0.7,0.8,0.3,0.011,0.011,15,15))

and I obtain the following estimates

$par

 [1]  0.20851065  0.30348571  0.43616932  0.73695654  0.58287221 0.45541506

 [7]  0.11191879  0.02233908  0.01988878 46.57249043 45.48544918

$value
[1] -215.9711

$convergence
[1] 0

but when I am using another set as for example:

start_param=FloatVector((0.2,0.3,0.4,0.75,0.55,0.45,0.3,0.05,0.05,59,59))

the results change and it seems that I am loosing convergence

$par
[1]  0.17218738  0.27165359  0.48458978  0.80295773  0.62618983  0.43254786
[7]  0.12426385  0.02991442  0.01853252 57.78269692 59.35376216

$value
[1] -146.9858

$convergence
[1] 1

My question is the following: I have seen that in STATA, there is an option
that searches for better starting values for the numerical optimization
algorithm. I tried to set multiple starting values by setting a matrix but
this did not work. Is there an option in constrOptim that will allow me to
do something like this?

Many thanks in advance.

For additional information, the specification I use for the constrOptim()
 is:

res=statsr.constrOptim(start_param,Rmaxlikelihood,grad='NULL',ui=ui,ci=ci,method="Nelder-Mead",control=list("maxit=3000,trace=F"))

[[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] Plotting time data for various countries in same graph

2013-03-07 Thread Tom Keller
ggplot returned a ggplot object with no layers as indicated by the error:
"Error: No layers in plot"
You need to add the layers to the object.
So in you example:
p1 <- ggplot(asd.df, aes(x=Time, y=Values, colour=Country))
then add the points (or something else)
p1 + geom_point()


Thomas (Tom) Keller, PhD email: kellert at ohsu.edu, ph: 
503.494.2442, office: RJH 5333
url: http://www.ohsu.edu/dnaseq/

On Mar 7, 2013, at 3:00 AM, 
mailto:r-help-requ...@r-project.org>> wrote:

From: Jim Lemon mailto:j...@bitwrit.com.au>>
Subject: Re: [R] Plotting time data for various countries in same graph
Date: March 6, 2013 3:25:55 AM PST
To: Anindya Sankar Dey mailto:anindy...@gmail.com>>
Cc: "r-help@r-project.org" 
mailto:r-help@r-project.org>>


On 03/06/2013 07:06 PM, Anindya Sankar Dey wrote:
Hi,

I've the following kind of data

Time  Country Values
2010Q1India   5
2010Q2India   7
2010Q3India   5
2010Q4India   9
2010Q1China 10
2010Q2China  6
2010Q3China  9
2010Q4 China 14


I needed to plot a graph with the x-axis being time,y-axis being he Values
and 2 line graph , one for India and one for counry.

I don't have great knowledge on graphics in R.

I was trying to use, ggplot(data,aes(x=Time,y=Values,colour=Country))

But this does not help.

Can anyone help me with this?

Hi Anindya,
This might be a start for you:

asd.df<-read.table(
 text="Time  Country Values
 2010Q1India   5
 2010Q2India   7
 2010Q3India   5
 2010Q4India   9
 2010Q1China 10
 2010Q2China  6
 2010Q3China  9
 2010Q4 China 14
 ",header=TRUE)
# Time is read as a factor, so it can be used directly in plotting
as.numeric(asd.df$Time)
[1] 1 2 3 4 1 2 3 4
plot(as.numeric(asd.df$Time)[asd.df$Country == "India"],
 asd.df$Values[asd.df$Country == "India"],
 type="l",col=4,lwd=2,xaxt="n",xlab="Financial Quarter",
 ylab="Value",ylim=c(0,14))
lines(as.numeric(asd.df$Time)[asd.df$Country == "China"],
 asd.df$Values[asd.df$Country == "China"],
 col=2,lwd=2)
axis(1,at=1:4,labels=paste("Q",1:4,sep=""))
legend(2,2,c("India","China"),lty=1,lwd=2,col=c(4,2))

Jim



[[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] rbind a list of matrices

2013-03-07 Thread Heath Blackmon
I have a large list of matrices and a vector that identifies the desired
matrices that I would like to rbind.  However, I am stuck on how to get
this to work.  I have written some code below to illustrate my problem:

# 3 simple matrices
a<-matrix(1:9,3,3)
b<-matrix(10:18,3,3)
c<-matrix(19:27,3,3)

#this is the type of list of matrices I am dealing with
matrix.list<-vector("list",3)
matrix.list[[1]]<-a
matrix.list[[2]]<-b
matrix.list[[3]]<-c

#i have a vector that identifies the ones that i want
desired.matrices <- c(1,3)

#i have tried lots of things next but all fail.  This one gets close but I
seem to lose my dim attributes
goal<-rbind(matrix.list[desired.matrices])

Any ideas would be wonderful.

Thanks

Heath

-- 
*Heath Blackmon
Graduate Teaching Assistant
Dept of Biology - Box 19498
Univ. of Texas, Arlington
Arlington, TX 76019
Office: ERB450
Phone 682-444-0538
*

[[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] Copying a dataframe

2013-03-07 Thread John Kane
With the orginal data.frame being df1

df2  <- data.frame(matrix(rep(NA, nrow(df1)*ncol(df1)), nrow = nrow(df1)))df2  
<- data.frame(matrix(rep(NA, nrow(df1)*ncol(df1)), nrow = nrow(df1)))


John Kane
Kingston ON Canada


> -Original Message-
> From: sahanasrinivasan...@gmail.com
> Sent: Thu, 7 Mar 2013 17:23:10 +
> To: r-help@r-project.org
> Subject: [R] Copying a dataframe
> 
> Hi, I am trying to create a data frame using the dimensions of another
> data
> frame that I have input. This is the code I am using:
> 
> tab is the data frame that is input.
> c.leng<-length(tab[,1]); r.leng<-length(tab[1,]);
> opdf<-data.frame(ncol=c.leng, nrow=r.leng);
> a<-1;
> while(a<=c.leng)
> {
> opdf[[1]][a]<-tab[[1]][a];
> a<-a+1;
> }
> 
> This is the error message I am getting:
> Error in `[[<-.data.frame`(`*tmp*`, 1, value = c(4626L, 1L)) :
> replacement has 2 rows, data has 1
> 
> I have tried printing out the dimensions of tab and mat separately to see
> if they are the same, but tab is 4626 rows, 21 columns (which is
> correct),
> while mat says 1row and 2columns.
> 
> Would be grateful if you could tell me where I am going wrong? Is there
> are
> better function to transfer/copy values?
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.


FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop!

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


Re: [R] Difficulty in caper: Error in phy$node.label[which(newNb > 0) - Ntip]

2013-03-07 Thread Peter Ehlers

On 2013-03-06 07:49, Nicole Thompson wrote:

Hello,

I'm doing a comparative analysis of mammal brain and body size data.
I'm following Charlie Nunn and Natalie Cooper's instructions for
"Running PGLS in R using caper".

I run into the following error when I create my comparative dataset,
combining my phylogenetic tree (mammaltree) and taxon measures
(mammaldata):

"Error in phy$node.label[which(newNb > 0) - Ntip] : only 0's may be
mixed with negative subscripts"

My full script is provided at the bottom.

I have looked at the caper manual by David Orme to understand how
comparative.data() constructs the dataset, but still cannot interpret
the error. Many thanks to anyone who could provide me with insight.

Nicole Thompson
E3B Columbia University




library(caper)


Loading required package: ape

Loading required package: MASS

Loading required package: mvtnorm






mammaldata <-read.csv("R.Mammal_data.csv", header = TRUE)



mammaltree <-read.nexus("BEphylotree.nex")



mammal <- comparative.data(phy = mammaltree, data = mammaldata, names.col = 
Taxon, vcv = TRUE, na.omit = FALSE, warn.dropped = TRUE) #names.col?


Error in phy$node.label[which(newNb > 0) - Ntip] : only 0's may be
mixed with negative subscripts


Looks to me like 'which(newNb > 0) - Ntip' evaluates to a
vector that has both positive and negative elements.
Like this:

  x <- 1:5
  x[c(-2,-4)] ## ok
  x[c(-2, 0)] ## ok
  x[c(-2, 4)] ## generates your error

Peter Ehlers







--
Nicole A Thompson
E3B Columbia University, NYCEP
nat2...@columbia.edu
480.522.4212



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] ggpliot2: reordering of factors in facets facet.grid(). Reordering of factor on x-axis no problem.

2013-03-07 Thread John Kane
If I try  facet_wrap(~factor1, ncol = 2) I get no faceting at all. Strange.
 

John Kane
Kingston ON Canada


> -Original Message-
> From: istaz...@gmail.com
> Sent: Thu, 7 Mar 2013 12:14:01 -0500
> To: a...@ecology.su.se
> Subject: Re: [R] ggpliot2: reordering of factors in facets facet.grid().
> Reordering of factor on x-axis no problem.
> 
> Hi Anna,
> 
> On Thu, Mar 7, 2013 at 10:16 AM, Anna Zakrisson 
> wrote:
>> 
>> Hi everyone (again),
>> before you all start screaming that the reordering of factors has been
>> discusse on several threads and is not particular to ggplot2, hear me
>> out.
> 
> I'm sorry you have been traumatized like this! I promise not to yell.
> 
>> I can easily reorder my x-axis factor in facet.grid() in ggplot2. What I
>> cannot reorder are the factors represented on the strips. I can see that
>> the
>> graphs are changing, so I am afraid of what it is I am doing. Why is
>> ggplot2
>> not changin the strip labels if indeed the factor-order has been
>> changed?
>> or have I missed to add code defining the factor-labels in the strips. I
>> have not found such code as it has been done automatically from my
>> dataframe
>> using facet.grid() previously. I am simply afraid of displaying the
>> wrong
>> things without noticing it.
> 
> Your problem is simple. factor1 is a factor with the desired levels.
> But you did not facet by factor1, you faceted by Grouping. You just
> need to replace
> 
>   facet_wrap(~Grouping, ncol = 2)
> 
> with
> 
>   facet_wrap(~factor1, ncol = 2)
> 
> Best,
> Ista
> 
>> Here is my code and comments:
>> 
>> I want to have my factor 1 in the order: "F", "E", "C", "D", "A", "B"
>> instead of alphabetical. My normal methods do not work.
>> 
>> with kind regards
>> Anna Zakrisson
>> 
>> # Some dummy data:
>> mydata<- data.frame(factor1 = factor(rep(LETTERS[1:6], each = 80)),
>> factor2 = factor(rep(c(1:5), each = 16)),
>> factor3 = factor(rep(c(1:4), each = 4)),
>> var1 = rnorm(120, mean = rep(c(0, 3, 5), each = 40),
>>  sd = rep(c(1, 2, 3), each = 20)),
>> var2 = rnorm(120, mean = rep(c(6, 7, 8), each = 40),
>>  sd = rep(c(1, 2, 3), each = 20)))
>> 
>> # Trying to change the order of my factor1 (same method works for
>> factor3,
>> # which is on th x-axis). Factor1 (A-F) is represented on the different
>> facets
>> # and the factor1 labels can be read off the strips:
>> mydata$factor1 <- factor(mydata$factor1,
>>levels=c("F", "E", "C", "D", "A", "B"),
>>order=T)
>> 
>> # summarizing the data with factor1 and factor3:
>> Summ  <-   ddply(mydata, .(factor3,factor1), summarize,
>>  mean = mean(var1, na.rm = FALSE),
>>  sdv = sd(var1, na.rm = FALSE),
>>  se = 1.96*(sd(var1, na.rm=FALSE)/sqrt(length(var1
>> Summ$Grouping <- c("F", "E", "C", "D", "A", "B")[Summ$factor1]
>> 
>> # Trying to order factor 1 accordingly:
>> Summ$factor1 <- factor(Summ$factor1,
>>levels=c("F", "E", "C", "D", "A", "B"),
>>order=T)
>> 
>> 
>> # plotting:
>> ggplot(Summ, aes(factor3, mean, group = factor1,
>>  ymin = mean - sdv , ymax = mean + sdv)) +
>>   geom_point(position = position_dodge(width = 0.25), size = 3) +
>>   geom_line(position = position_dodge(width = 0.25)) +
>>   geom_errorbar(width = 0.3, position = position_dodge(width = 0.25),
>> size
>> =
>> 0.3) +
>>   facet_wrap(~Grouping, ncol = 2) +
>>   theme(strip.background = element_blank()) +
>>   scale_shape(solid = FALSE)+
>>   theme_bw() +
>>   ylab(expression(paste("my measured stuff"))) +
>>   xlab("factor3") +
>>   theme(legend.position="none")+
>>   labs(shape = "factor1", group = "factor1", linetype = "factor1")
>> 
>> # What I find really scary is that when excluding the parts:
>> mydata$factor1 <- factor(mydata$factor1,
>>  levels=c("F", "E", "C", "D", "A", "B"),
>>  order=T)
>> Summ$factor1 <- factor(Summ$factor1,
>>levels=c("F", "E", "C", "D", "A", "B"),
>>order=T)
>> # I actually get a different plot than had I not reordered the factors.
>> # The labels are however still the same. How do I solve this?
>> 
>> 
>> 
>> ### But if I change the factor order for factor 3 (on the x-axis) it
>> works!
>> I get
>> # a different factor order!
>> Summ$factor1 <- factor(Summ$factor1,
>>levels=c("4", "2", "3", "1"),
>>order=T)
>> 
>> 
>> ggplot(Summ, aes(factor3, mean, group = factor1,
>>  ymin = mean - sdv , ymax = mean + sdv)) +
>>   geom_point(position = position_dodge(width = 0.25), size = 3) +
>>   geom_line(position = position_dodge(width = 0.25)) +
>>   geom_errorbar(width = 0.3, position = position_dodge(width = 0.25),
>> size
>> =
>> 0.3) +
>>   facet_w

Re: [R] Copying a dataframe

2013-03-07 Thread jim holtman
If you are just copying, why not:

opdf <- tab



On Thu, Mar 7, 2013 at 12:23 PM, Sahana Srinivasan <
sahanasrinivasan...@gmail.com> wrote:

> Hi, I am trying to create a data frame using the dimensions of another data
> frame that I have input. This is the code I am using:
>
> tab is the data frame that is input.
> c.leng<-length(tab[,1]); r.leng<-length(tab[1,]);
> opdf<-data.frame(ncol=c.leng, nrow=r.leng);
> a<-1;
> while(a<=c.leng)
> {
> opdf[[1]][a]<-tab[[1]][a];
> a<-a+1;
> }
>
> This is the error message I am getting:
> Error in `[[<-.data.frame`(`*tmp*`, 1, value = c(4626L, 1L)) :
> replacement has 2 rows, data has 1
>
> I have tried printing out the dimensions of tab and mat separately to see
> if they are the same, but tab is 4626 rows, 21 columns (which is correct),
> while mat says 1row and 2columns.
>
> Would be grateful if you could tell me where I am going wrong? Is there are
> better function to transfer/copy values?
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Jim Holtman
Data Munger Guru

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

[[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] Copying a dataframe

2013-03-07 Thread Sahana Srinivasan
Hi, I am trying to create a data frame using the dimensions of another data
frame that I have input. This is the code I am using:

tab is the data frame that is input.
c.leng<-length(tab[,1]); r.leng<-length(tab[1,]);
opdf<-data.frame(ncol=c.leng, nrow=r.leng);
a<-1;
while(a<=c.leng)
{
opdf[[1]][a]<-tab[[1]][a];
a<-a+1;
}

This is the error message I am getting:
Error in `[[<-.data.frame`(`*tmp*`, 1, value = c(4626L, 1L)) :
replacement has 2 rows, data has 1

I have tried printing out the dimensions of tab and mat separately to see
if they are the same, but tab is 4626 rows, 21 columns (which is correct),
while mat says 1row and 2columns.

Would be grateful if you could tell me where I am going wrong? Is there are
better function to transfer/copy values?

[[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] ggpliot2: reordering of factors in facets facet.grid(). Reordering of factor on x-axis no problem.

2013-03-07 Thread Ista Zahn
Hi Anna,

On Thu, Mar 7, 2013 at 10:16 AM, Anna Zakrisson  wrote:
>
> Hi everyone (again),
> before you all start screaming that the reordering of factors has been
> discusse on several threads and is not particular to ggplot2, hear me out.

I'm sorry you have been traumatized like this! I promise not to yell.

> I can easily reorder my x-axis factor in facet.grid() in ggplot2. What I
> cannot reorder are the factors represented on the strips. I can see that
> the
> graphs are changing, so I am afraid of what it is I am doing. Why is
> ggplot2
> not changin the strip labels if indeed the factor-order has been changed?
> or have I missed to add code defining the factor-labels in the strips. I
> have not found such code as it has been done automatically from my
> dataframe
> using facet.grid() previously. I am simply afraid of displaying the wrong
> things without noticing it.

Your problem is simple. factor1 is a factor with the desired levels.
But you did not facet by factor1, you faceted by Grouping. You just
need to replace

  facet_wrap(~Grouping, ncol = 2)

with

  facet_wrap(~factor1, ncol = 2)

Best,
Ista

> Here is my code and comments:
>
> I want to have my factor 1 in the order: "F", "E", "C", "D", "A", "B"
> instead of alphabetical. My normal methods do not work.
>
> with kind regards
> Anna Zakrisson
>
> # Some dummy data:
> mydata<- data.frame(factor1 = factor(rep(LETTERS[1:6], each = 80)),
> factor2 = factor(rep(c(1:5), each = 16)),
> factor3 = factor(rep(c(1:4), each = 4)),
> var1 = rnorm(120, mean = rep(c(0, 3, 5), each = 40),
>  sd = rep(c(1, 2, 3), each = 20)),
> var2 = rnorm(120, mean = rep(c(6, 7, 8), each = 40),
>  sd = rep(c(1, 2, 3), each = 20)))
>
> # Trying to change the order of my factor1 (same method works for factor3,
> # which is on th x-axis). Factor1 (A-F) is represented on the different
> facets
> # and the factor1 labels can be read off the strips:
> mydata$factor1 <- factor(mydata$factor1,
>levels=c("F", "E", "C", "D", "A", "B"),
>order=T)
>
> # summarizing the data with factor1 and factor3:
> Summ  <-   ddply(mydata, .(factor3,factor1), summarize,
>  mean = mean(var1, na.rm = FALSE),
>  sdv = sd(var1, na.rm = FALSE),
>  se = 1.96*(sd(var1, na.rm=FALSE)/sqrt(length(var1
> Summ$Grouping <- c("F", "E", "C", "D", "A", "B")[Summ$factor1]
>
> # Trying to order factor 1 accordingly:
> Summ$factor1 <- factor(Summ$factor1,
>levels=c("F", "E", "C", "D", "A", "B"),
>order=T)
>
>
> # plotting:
> ggplot(Summ, aes(factor3, mean, group = factor1,
>  ymin = mean - sdv , ymax = mean + sdv)) +
>   geom_point(position = position_dodge(width = 0.25), size = 3) +
>   geom_line(position = position_dodge(width = 0.25)) +
>   geom_errorbar(width = 0.3, position = position_dodge(width = 0.25), size
> =
> 0.3) +
>   facet_wrap(~Grouping, ncol = 2) +
>   theme(strip.background = element_blank()) +
>   scale_shape(solid = FALSE)+
>   theme_bw() +
>   ylab(expression(paste("my measured stuff"))) +
>   xlab("factor3") +
>   theme(legend.position="none")+
>   labs(shape = "factor1", group = "factor1", linetype = "factor1")
>
> # What I find really scary is that when excluding the parts:
> mydata$factor1 <- factor(mydata$factor1,
>  levels=c("F", "E", "C", "D", "A", "B"),
>  order=T)
> Summ$factor1 <- factor(Summ$factor1,
>levels=c("F", "E", "C", "D", "A", "B"),
>order=T)
> # I actually get a different plot than had I not reordered the factors.
> # The labels are however still the same. How do I solve this?
>
>
>
> ### But if I change the factor order for factor 3 (on the x-axis) it
> works!
> I get
> # a different factor order!
> Summ$factor1 <- factor(Summ$factor1,
>levels=c("4", "2", "3", "1"),
>order=T)
>
>
> ggplot(Summ, aes(factor3, mean, group = factor1,
>  ymin = mean - sdv , ymax = mean + sdv)) +
>   geom_point(position = position_dodge(width = 0.25), size = 3) +
>   geom_line(position = position_dodge(width = 0.25)) +
>   geom_errorbar(width = 0.3, position = position_dodge(width = 0.25), size
> =
> 0.3) +
>   facet_wrap(~Grouping, ncol = 2) +
>   theme(strip.background = element_blank()) +
>   scale_shape(solid = FALSE)+
>   theme_bw() +
>   ylab(expression(paste("my measured stuff"))) +
>   xlab("factor3") +
>   theme(legend.position="none")+
>   labs(shape = "factor1", group = "factor1", linetype = "factor1")
>
>
> Anna Zakrisson Braeunlich
> PhD student
>
> Department of Ecology Environment and Plant Sciences
> Stockholm University
> Svante Arrheniusv. 21A
> SE-106 91 Stockholm
> Sweden
>
> Lives in Berlin.
> For paper mail:
> Kat

[R] Estimating simultaneous equations in plm()

2013-03-07 Thread bateman001
Hello everybody,

I am relatively new to R and struggling with the following problem: I want
to estimate a system of equations in R using the plm() command.
Unfortunately the data have a panel structure which should be exploited
during the estimation process. Hence I decided for a fixed/random effects
setup. 
In the systemfit()-command one can actually define a system of equations and
estimate simultaneously while certain parameter restriction can be imposed.
But this only works for a pooling approach, i.e. ignoring the panel
structure. 

The code is the following:

first.eq <-  y ~ c + b1*x1 + b2*x2 + u   #First equation
second.eq <-  z ~ c + b1*x1 + b2*x2 + u #Second equation
third.eq <-  w ~ c + b1*x1 + b2*x2 + u#Third equation

As you can see, the explanatory variables are the same over all equations,
however, the endogenous variable is changing. What I want is to define a
system like: system.eq <- list(first.eq, second.eq, third.eq) and estimate
ist by: plm(system.eq, model = "within") 

Thank you very much for your help! 



--
View this message in context: 
http://r.789695.n4.nabble.com/Estimating-simultaneous-equations-in-plm-tp4660624.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] Colour branches/labels of dendrogram according to a grouping variable

2013-03-07 Thread Kevin Wright
Here is one example:
http://gallery.r-enthusiasts.com/graph/Colored_Dendrogram_79

Kevin



On Thu, Mar 7, 2013 at 8:22 AM, Johannes Radinger <
johannesradin...@gmail.com> wrote:

> Hi,
>
> is there a way to color the branches or text label of the branches of
> dendrograms e.g. from hclust() according to a grouping variable. Here
> I have something in mind like:
>
> http://www.sigmaaldrich.com/content/dam/sigma-aldrich/life-science/biowire/biowire-fall-2010/proteome-figure-1.Par.0001.Image.gif
> (ectodermal, endodermal, mesodermal).
>
> /johannes
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Kevin Wright

[[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] A==A false?

2013-03-07 Thread Marc Schwartz
On Mar 7, 2013, at 9:33 AM, "Creighton, Sean"  wrote:

>> 
>> as.numeric(ImpVol[1,5,57]) == 0.0001
> [1] FALSE
>> 
>> as.numeric(ImpVol[1,5,57])
> [1] 1e-04
>> 
>> 0.0001
> [1] 1e-04
>> 
> 
> 
> Any tips? 
> Thanks
> Sean


See R "Super FAQ" 7.31:

  
http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-doesn_0027t-R-think-these-numbers-are-equal_003f

Regards,

Marc Schwartz

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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-pkgs] new package: cec2013 (v0.1-4)

2013-03-07 Thread Mauricio Zambrano-Bigiarini
Dear R users,

I would like to draw your attention to 'cec2013', a new package
providing R wrappers for the 28 benchmark functions defined in the
Special Session and Competition on Real-Parameter Single Objective
Optimization at CEC-2013 (http://www.cec2013.org/).

The focus of this package is to provide an open-source and
multi-platform implementation of the CEC2013 benchmark functions, in
order to make easier for researchers to test the performance of new
optimization algorithms, or improvements to existing ones, in a
reproducible way.

The original C code was provided by Jane Jing Liang, while GNU/Linux
comments were made by Janez Brest.

This package was gently authorised for publication on CRAN by
Ponnuthurai Nagaratnam Suganthan. The official documentation is
available at:

http://www.ntu.edu.sg/home/EPNSugan/index_files/CEC2013/CEC2013.htm


cec2013 is already available on CRAN:

http://cran.r-project.org/web/packages/cec2013/


you can install it from the R console with:

 > install.packages("cec2013")


For any comment or contact for collaboration do not hesitate to
contact the authors (in English, Spanish or Italian):

Mauricio Zambrano-Bigiarini  
Yasser Gonzalez Fernandez 


Kind regards,

Mauricio Zambrano-Bigiarini, Ph.D

-- 
==
Water Resources Unit
Institute for Environment and Sustainability
Joint Research Centre, European Commission
webinfo: http://floods.jrc.ec.europa.eu/
==
DISCLAIMER:\ "The views expressed are purely those of th...{{dropped:7}}

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


Re: [R] A==A false?

2013-03-07 Thread ONKELINX, Thierry
FAQ 7.31

ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and 
Forest
team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
Kliniekstraat 25
1070 Anderlecht
Belgium
+ 32 2 525 02 51
+ 32 54 43 61 85
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more than 
asking him to perform a post-mortem examination: he may be able to say what the 
experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ Roger Brinner

The combination of some data and an aching desire for an answer does not ensure 
that a reasonable answer can be extracted from a given body of data.
~ John Tukey


-Oorspronkelijk bericht-
Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens 
Creighton, Sean
Verzonden: donderdag 7 maart 2013 16:33
Aan: 'r-help@r-project.org'
Onderwerp: [R] A==A false?

>
> as.numeric(ImpVol[1,5,57]) == 0.0001
[1] FALSE
>
> as.numeric(ImpVol[1,5,57])
[1] 1e-04
>
> 0.0001
[1] 1e-04
>


Any tips?
Thanks
Sean



R 2.15.3
windows 7

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
* * * * * * * * * * * * * D I S C L A I M E R * * * * * * * * * * * * *
Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en 
binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is 
door een geldig ondertekend document.
The views expressed in this message and any annex are purely those of the 
writer and may not be regarded as stating an official position of INBO, as long 
as the message is not confirmed by a duly signed document.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Nice analysis of time series data

2013-03-07 Thread Prof J C Nash (U30A)
In the recent SIAM Review, vol 54, No 3, pp 597-606, Robert Vanderbei 
does a nice analysis of daily temperature data. This uses publicly 
available data. A version of the paper is available at


http://arxiv.org/pdf/1209.0624

and there is a presentation at

http://www.princeton.edu/~rvdb/tex/talks/GERAD/LocalWarming.pdf

This would make a nice case for a vignette showing how to do such an 
analysis in R, possibly as a project for a senior undergraduate or 
perhaps even at the Master's level if some tools were developed, since 
Vanderbei presents a good argument for using Least Absolute Deviations 
regression (LAD). Generally LAD is overlooked by statisticians, maybe 
because the tools are unfamiliar.


I'm willing to kibbitz on a vignette if there's interest somewhere.

John Nash

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


[R] A==A false?

2013-03-07 Thread Creighton, Sean
> 
> as.numeric(ImpVol[1,5,57]) == 0.0001
[1] FALSE
> 
> as.numeric(ImpVol[1,5,57])
[1] 1e-04
> 
> 0.0001
[1] 1e-04
>


Any tips? 
Thanks
Sean



R 2.15.3 
windows 7

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

2013-03-07 Thread miguel.angel.rodriguez.muinos
Hi.

I have a problem running the code (under Windows 7, 32bits):
> require(XLConnect)
> require(gWidgets)
> options(guiToolkit="tcltk")
> require(gWidgetstcltk)
> gfile()

This problem occurs in R 2.15.2 & 2.15.3 versions but not in the 2.15.1.

The result of calling to the gfile() function should be a window that allows 
you to select a file. But that window does not appear.

If I run the same code from the environment RStudio it works perfectly, 
regardless of the version of R that uses.

Any ideas?

Thnks,
_
Miguel Angel Rodriguez Muinos
Dept. of Public Health
Xunta de Galicia
SPAIN
http://dxsp.sergas.es














Nota: A información contida nesta mensaxe e os seus posibles documentos 
adxuntos é privada e confidencial e está dirixida únicamente ó seu 
destinatario/a. Se vostede non é o/a destinatario/a orixinal desta mensaxe, por 
favor elimínea. A distribución ou copia desta mensaxe non está autorizada.

Nota: La información contenida en este mensaje y sus posibles documentos 
adjuntos es privada y confidencial y está dirigida únicamente a su 
destinatario/a. Si usted no es el/la destinatario/a original de este mensaje, 
por favor elimínelo. La distribución o copia de este mensaje no está autorizada.

See more languages: http://www.sergas.es/aviso_confidencialidad.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] Read Content from URL to XML format

2013-03-07 Thread John Kane
Perhaps 
http://stackoverflow.com/questions/1395528/scraping-html-tables-into-r-data-frames-using-the-xml-package
 may be of help

John Kane
Kingston ON Canada


> -Original Message-
> From: antony.akk...@ge.com
> Sent: Wed, 6 Mar 2013 19:23:24 -0800 (PST)
> To: r-help@r-project.org
> Subject: [R] Read Content from URL to XML format
> 
> Hi,
> 
> i want to know how to read a table values from a URL and get it as XML
> content.
> Could anyone please help me out ASAP ?
> 
> Thanks,
> Antony.
> 
> 
> 
> --
> View this message in context:
> http://r.789695.n4.nabble.com/Read-Content-from-URL-to-XML-format-tp4660561.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.


TRY FREE IM TOOLPACK at http://www.imtoolpack.com/default.aspx?rc=if5
Capture screenshots, upload images, edit and send them to your friends
through IMs, post on Twitter®, Facebook®, MySpace™, LinkedIn® – FAST!

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

2013-03-07 Thread arun
Hi,


directory<- "/home/arunksa111/dados" #renamed directory to dados
filelist<-function(directory,number,list1){
setwd(directory)
filelist1<-dir(directory)
direct<-dir(directory,pattern = paste("MSMS_",number,"PepInfo.txt",sep=""), 
full.names = FALSE, recursive = TRUE)
list1<-lapply(direct, function(x) read.table(x,header=TRUE, sep = 
"\t",stringsAsFactors=FALSE))
names(list1)<-filelist1
list2<- list(filelist1,list1)
return(list2)
}
foldernames1<-filelist(directory,23,list1)[[1]]
foldernames1
#[1] "a1" "a2" "c1" "c2" "c3" "t1" "t2"
lista<-filelist(directory,23,list1)[[2]] #lista output 

#If you look at the 
 lapply(lista,function(x) sapply(x,class)) #some spec were integer, and some 
were character
#do this
 listaNew<-lapply(lista,function(x) within(x,{spec<- as.character(spec)}))

FacGroup<- c("c1","c3","t2")
#Second function
#f<- function()

head(f(listaNew,FacGroup))
# Seq    Mod z c1 c3 t2
#1 aAATATAGPR 1-n_acPro/ 2  0  0  1
#2  aAAASSPVGVGQR 1-n_acPro/ 2  0  0  1
#3   aAGAAGGR 1-n_acPro/ 2  0  0  1
#4  aAAAGAAGGRGSGPGRR 1-n_acPro/ 2  1  0  0
#5    AAALQAK    2  0  1  1
#6 aAGAGPEMVR 1-n_acPro/ 2  0  0  2


A.K.




From: Vera Costa 
To: arun  
Sent: Thursday, March 7, 2013 7:12 AM
Subject: Re: new question


Hi.

Sorry again a question about this, but when I run this code I have this error:

Error in `[.data.table`(x1, , `:=`(spec, paste(spec, collapse = ",")),  : 
  Type of RHS ('character') must match LHS ('integer'). To check and coerce 
would impact performance too much for the fastest cases. Either change the type 
of the target column, or coerce the RHS of := yourself (e.g. by using 1L 
instead of 1)

Could you help me to with this? How can I eliminate this?

Thank you




2013/2/28 arun 

Hi,
>directory<- "/home/arunksa111/data.new"
>#first function
>filelist<-function(directory,number,list1){
>setwd(directory)
>filelist1<-dir(directory)
>
>direct<-dir(directory,pattern = paste("MSMS_",number,"PepInfo.txt",sep=""), 
>full.names = FALSE, recursive = TRUE)
>list1<-lapply(direct, function(x) read.table(x,header=TRUE, sep = 
>"\t",stringsAsFactors=FALSE))
>names(list1)<-filelist1
>list2<- list(filelist1,list1)
>return(list2)
>}
>foldernames1<-filelist(directory,23,list1)[[1]]
>foldernames1
>#[1] "a1" "c1" "c2" "c3" "t1" "t2"
>lista<-filelist(directory,23,list1)[[2]] #lista output
>
>FacGroup<- c("c1","c3","t2")
>
>#Second function
>f<-function(listRes,Toselect){
>res2<-split(listRes,gsub("[0-9]","",names(listRes)))
>res3<-lapply(seq_along(res2),function(i) lapply(res2[[i]],function(x) 
>x[x[["FDR"]]<0.01,c("Seq","Mod","z","spec")]))
>res4<-lapply(res3,function(x) x[names(x)[names(x)%in%Toselect]])
>res4New<- lapply(res4,function(x) lapply(names(x), function(i) 
>do.call(rbind,lapply(x[i],function(x) cbind(folder_name=i,x))) ))
>library(plyr)
>library(data.table)
>res5<-lapply(res4New,function(x) lapply(x,function(x1){ x1<- 
>data.table(x1);x1[,spec:=paste(spec,collapse=","),by=c("Seq","Mod","z")]}))
>res6<- lapply(res5,function(x) lapply(x,function(x1) 
>{x1$counts<-sapply(x1$spec, function(x2) length(gsub("\\s", "", 
>unlist(strsplit(x2, ",");x3<-as.data.frame(x1);names(x3)[6]<- 
>as.character(unique(x3$folder_name));x3[,-c(1,5)]}))
> 
>res7<-lapply(res6,function(x) Reduce(function(...) 
>merge(...,by=c("Seq","Mod","z"),all=TRUE),x))
> res8<-res7[lapply(res7,length)!=0]
> res9<- Reduce(function(...) merge(...,by=c("Seq","Mod","z"),all=TRUE),res8)
>res9[is.na(res9)] <- 0
>return(res9)
>}
>
>f(lista,FacGroup)
> head(f(lista,FacGroup))
> #    Seq    Mod z c1 c3 t2
>#1 aAATATAGPR 1-n_acPro/ 2  0  0  1
>#2  aAAASSPVGVGQR 1-n_acPro/ 2  0  0  1
>#3   aAGAAGGR 1-n_acPro/ 2  0  0  1
>#4  aAAAGAAGGRGSGPGRR 1-n_acPro/ 2  1  0  0
>#5    AAALQAK    2  0  1  1
>#6 aAGAGPEMVR 1-n_acPro/ 2  0  0  2
>
>resCounts<- f(lista,FacGroup)
>t.test.p.value <- function(...) {
>    obj<-try(t.test(...), silent=TRUE)
>    if (is(obj, "try-error")) return(NA) else return(obj$p.value)
> }
>
>#3rd function for p-value
>fpv<- function(Countdata){
>resNew<-do.call(cbind,lapply(split(names(Countdata)[4:ncol(Countdata)],gsub("[0-9]","",names(Countdata)[4:ncol(Countdata)])),
> function(i) {x<-if(ncol(Countdata[i])>1) rowSums(Countdata[i]) else 
>Countdata[i]; colnames(x)<-NULL;x}))
>indx<-combn(names(resNew),2)
>resPval<-do.call(cbind,lapply(seq_len(ncol(indx)),function(i) 
>{x<-as.data.frame(apply(resNew[,indx[,i]],1,t.test.p.value)); 
>colnames(x)<-paste("Pvalue",paste(indx[,i],collapse=""),sep="_");x}))
>resF<-cbind(resCounts,resPval)
>resF
>}
>
>fpv(resCounts)
>
>
>A.K.
>
>
>
>
>
>
>
>From: Vera Costa 
>To: arun 
>Sent: Thursday, February 28, 2013 11:30 AM
>Subject: new question
>
>
>
>Sorry about my question, but I need a new small thing...I need to split my 
>function to read 

Re: [R] Ggplot2: Moving legend, change fill and removal of space between plots when using grid.arrange() possible use of facet_grid?

2013-03-07 Thread Anna Zakrisson
GREAT! Thank you! Will try this! 
Anna

Anna Zakrisson Braeunlich
PhD student

Department of Ecology Environment and Plant Sciences
Stockholm University
Svante Arrheniusv. 21A
SE-106 91 Stockholm
Sweden

Lives in Berlin.
For paper mail:
Katzbachstr. 21
D-10965, Berlin - Kreuzberg
Germany/Deutschland

E-mail: anna.zakris...@su.se
Tel work: +49-(0)3091541281
Mobile: +49-(0)15777374888
LinkedIn: http://se.linkedin.com/pub/anna-zakrisson-braeunlich/33/5a2/51b

><º>`•. . • `•. .• `•. . ><º>`•. . • `•. .• 
`•. .><º>`•. . • `•. .• `•. .><º>

-Original Message-
From: John Kane 
To: Anna Zakrisson , ONKELINX Thierry 
, r-help@r-project.org
Date: Thu, 7 Mar 2013 07:06:00 -0800
Subject: Re: [R] Ggplot2: Moving legend, change fill and removal of space 
between plots when using grid.arrange() possible use of facet_grid?

Looking good.  I think the function in this post is what you want. It worked 
on your code for me.  
http://stackoverflow.com/questions/13297155/add-floating-axis-labels-in-facet-wrap-plot
 
.  

John Kane
Kingston ON Canada


> -Original Message-
> From: a...@ecology.su.se
> Sent: Thu, 07 Mar 2013 12:47:34 +0100
> To: thierry.onkel...@inbo.be, r-help@r-project.org
> Subject: Re: [R] Ggplot2: Moving legend, change fill and removal of space
> between plots when using grid.arrange() possible use of facet_grid?
>
> Hi,
> have managed to get rid of the facet labels (so do not spend your time
> explaining that to me). Tthere were some old code out there which did not
> work. My only remaining issue is how to add the axis labels to the plot
> without labels.
> Anna
>
> Summ  <-   ddply(mydata, .(factor3,factor1), summarize,
>  mean = mean(var1, na.rm = FALSE),
>  sdv = sd(var1, na.rm = FALSE),
>  se = 1.96*(sd(var1, na.rm=FALSE)/sqrt(length(var1
> Summ$Grouping <- c("AB", "AB", "CD", "CD", "EF", "EF")[Summ$factor1]
> Summ$factor1bis <- c("0", "1", "0", "1", "0", "1")[Summ$factor1]
>
> ggplot(Summ, aes(factor3, mean, group = factor1bis, shape = factor1bis,
> linetype = factor1bis, ymin = mean - sdv , ymax = mean + sdv)) +
>   geom_point(position = position_dodge(width = 0.25), size = 3) +
>   geom_line(position = position_dodge(width = 0.25)) +
>   geom_errorbar(width = 0.3, position = position_dodge(width = 0.25),
> size =
> 0.3) +
>   facet_wrap(~Grouping, ncol = 2) +
>   theme(strip.background = element_blank()) +
>   scale_shape(solid = FALSE)+
>   theme_bw() +
>   theme(strip.background = element_blank())+
>   theme(strip.text.x = element_blank(),
> strip.text.y = element_blank())+
>   ylab(expression(paste("my measured stuff"))) +
>   xlab("factor3") +
>   theme(legend.position="none")+
>   labs(shape = "factor1", group = "factor1", linetype = "factor1")
>
>
>
>
>
>
>
>
> Anna Zakrisson Braeunlich
> PhD student
>
> Department of Ecology Environment and Plant Sciences
> Stockholm University
> Svante Arrheniusv. 21A
> SE-106 91 Stockholm
> Sweden
>
> Lives in Berlin.
> For paper mail:
> Katzbachstr. 21
> D-10965, Berlin - Kreuzberg
> Germany/Deutschland
>
> E-mail: anna.zakris...@su.se
> Tel work: +49-(0)3091541281
> Mobile: +49-(0)15777374888
> LinkedIn: http://se.linkedin.com/pub/anna-zakrisson-braeunlich/33/5a2/51b
>
> >`b?". . b?" `b?". .b?" `b?". . >`b?". . b?" `b?". .b?"
> `b?". .>`b?". . b?" `b?". .b?" `b?". .>
>
> -Original Message-
> From: "ONKELINX, Thierry" 
> To: Anna Zakrisson , "r-help@r-project.org"
> 
> Date: Wed, 6 Mar 2013 13:36:00 +
> Subject: RE: [R] Ggplot2: Moving legend,   change fill and removal of
> space
> between   plots when using   grid.arrange() possible use of facet_grid?
>
> Dear Anna,
>
> Is this what you would like?
>
> Summ  <-   ddply(mydata, .(factor3,factor1), summarize,
>mean = mean(var1, na.rm = FALSE),
>sdv = sd(var1, na.rm = FALSE),
>se = 1.96*(sd(var1,
> na.rm=FALSE)/sqrt(length(var1
> Summ$Grouping <- c("AB", "AB", "CD", "CD", "EF", "EF")[Summ$factor1]
> Summ$factor1bis <- c("0", "1", "0", "1", "0", "1")[Summ$factor1]
>
> ggplot(Summ, aes(factor3, mean, group = factor1bis, shape = factor1bis,
> linetype = factor1bis, ymin = mean - sdv , ymax = mean + sdv)) +
> geom_point(position = position_dodge(width = 0.25), size = 3) +
> geom_line(position = position_dodge(width = 0.25)) +
> geom_errorbar(width = 0.3, position = position_dodge(width = 0.25), size
> =
> 0.3) +
> facet_wrap(~Grouping, ncol = 2) +
> theme_bw() +
> ylab(expression(paste("my measured stuff"))) +
> xlab("factor3") +
> labs(shape = "factor1", group = "factor1", linetype = "factor1")
>
> Best regards,
>
> ir. Thierry Onkelinx
> Instituut voor natuur- en bosonderzoek / Research Institute for Nature
> and
> Forest
> team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
> Kliniekstraat 25
> 1070 Anderlecht
> Belgium
> + 32 2 525 02 51
> + 32 54 

[R] ggpliot2: reordering of factors in facets facet.grid(). Reordering of factor on x-axis no problem.

2013-03-07 Thread Anna Zakrisson
Hi everyone (again),
before you all start screaming that the reordering of factors has been 
discusse on several threads and is not particular to ggplot2, hear me out.
I can easily reorder my x-axis factor in facet.grid() in ggplot2. What I 
cannot reorder are the factors represented on the strips. I can see that the 
graphs are changing, so I am afraid of what it is I am doing. Why is ggplot2 
not changin the strip labels if indeed the factor-order has been changed? 
or have I missed to add code defining the factor-labels in the strips. I 
have not found such code as it has been done automatically from my dataframe 
using facet.grid() previously. I am simply afraid of displaying the wrong 
things without noticing it.
Here is my code and comments:

I want to have my factor 1 in the order: "F", "E", "C", "D", "A", "B" 
instead of alphabetical. My normal methods do not work.

with kind regards
Anna Zakrisson

# Some dummy data:
mydata<- data.frame(factor1 = factor(rep(LETTERS[1:6], each = 80)),
factor2 = factor(rep(c(1:5), each = 16)),
factor3 = factor(rep(c(1:4), each = 4)),
var1 = rnorm(120, mean = rep(c(0, 3, 5), each = 40),
 sd = rep(c(1, 2, 3), each = 20)),
var2 = rnorm(120, mean = rep(c(6, 7, 8), each = 40),
 sd = rep(c(1, 2, 3), each = 20)))

# Trying to change the order of my factor1 (same method works for factor3,
# which is on th x-axis). Factor1 (A-F) is represented on the different 
facets
# and the factor1 labels can be read off the strips:
mydata$factor1 <- factor(mydata$factor1, 
   levels=c("F", "E", "C", "D", "A", "B"), 
   order=T)

# summarizing the data with factor1 and factor3:
Summ  <-   ddply(mydata, .(factor3,factor1), summarize,
 mean = mean(var1, na.rm = FALSE),
 sdv = sd(var1, na.rm = FALSE),
 se = 1.96*(sd(var1, na.rm=FALSE)/sqrt(length(var1
Summ$Grouping <- c("F", "E", "C", "D", "A", "B")[Summ$factor1]

# Trying to order factor 1 accordingly:
Summ$factor1 <- factor(Summ$factor1, 
   levels=c("F", "E", "C", "D", "A", "B"), 
   order=T)


# plotting:
ggplot(Summ, aes(factor3, mean, group = factor1,
 ymin = mean - sdv , ymax = mean + sdv)) +
  geom_point(position = position_dodge(width = 0.25), size = 3) +
  geom_line(position = position_dodge(width = 0.25)) +
  geom_errorbar(width = 0.3, position = position_dodge(width = 0.25), size = 
0.3) +
  facet_wrap(~Grouping, ncol = 2) +
  theme(strip.background = element_blank()) +
  scale_shape(solid = FALSE)+
  theme_bw() +
  ylab(expression(paste("my measured stuff"))) +
  xlab("factor3") +
  theme(legend.position="none")+
  labs(shape = "factor1", group = "factor1", linetype = "factor1")

# What I find really scary is that when excluding the parts:
mydata$factor1 <- factor(mydata$factor1, 
 levels=c("F", "E", "C", "D", "A", "B"), 
 order=T)
Summ$factor1 <- factor(Summ$factor1, 
   levels=c("F", "E", "C", "D", "A", "B"), 
   order=T)
# I actually get a different plot than had I not reordered the factors. 
# The labels are however still the same. How do I solve this?



### But if I change the factor order for factor 3 (on the x-axis) it works! 
I get
# a different factor order!
Summ$factor1 <- factor(Summ$factor1, 
   levels=c("4", "2", "3", "1"), 
   order=T)


ggplot(Summ, aes(factor3, mean, group = factor1,
 ymin = mean - sdv , ymax = mean + sdv)) +
  geom_point(position = position_dodge(width = 0.25), size = 3) +
  geom_line(position = position_dodge(width = 0.25)) +
  geom_errorbar(width = 0.3, position = position_dodge(width = 0.25), size = 
0.3) +
  facet_wrap(~Grouping, ncol = 2) +
  theme(strip.background = element_blank()) +
  scale_shape(solid = FALSE)+
  theme_bw() +
  ylab(expression(paste("my measured stuff"))) +
  xlab("factor3") +
  theme(legend.position="none")+
  labs(shape = "factor1", group = "factor1", linetype = "factor1")


Anna Zakrisson Braeunlich
PhD student

Department of Ecology Environment and Plant Sciences
Stockholm University
Svante Arrheniusv. 21A
SE-106 91 Stockholm
Sweden

Lives in Berlin.
For paper mail:
Katzbachstr. 21
D-10965, Berlin - Kreuzberg
Germany/Deutschland

E-mail: anna.zakris...@su.se
Tel work: +49-(0)3091541281
Mobile: +49-(0)15777374888
LinkedIn: http://se.linkedin.com/pub/anna-zakrisson-braeunlich/33/5a2/51b

><º>`•. . • `•. .• `•. . ><º>`•. . • `•. .• 
`•. .><º>`•. . • `•. .• `•. .><º>

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

Re: [R] Ggplot2: Moving legend, change fill and removal of space between plots when using grid.arrange() possible use of facet_grid?

2013-03-07 Thread John Kane
Looking good.  I think the function in this post is what you want. It worked on 
your code for me.  
http://stackoverflow.com/questions/13297155/add-floating-axis-labels-in-facet-wrap-plot
 .  

John Kane
Kingston ON Canada


> -Original Message-
> From: a...@ecology.su.se
> Sent: Thu, 07 Mar 2013 12:47:34 +0100
> To: thierry.onkel...@inbo.be, r-help@r-project.org
> Subject: Re: [R] Ggplot2: Moving legend, change fill and removal of space
> between plots when using grid.arrange() possible use of facet_grid?
> 
> Hi,
> have managed to get rid of the facet labels (so do not spend your time
> explaining that to me). Tthere were some old code out there which did not
> work. My only remaining issue is how to add the axis labels to the plot
> without labels.
> Anna
> 
> Summ  <-   ddply(mydata, .(factor3,factor1), summarize,
>  mean = mean(var1, na.rm = FALSE),
>  sdv = sd(var1, na.rm = FALSE),
>  se = 1.96*(sd(var1, na.rm=FALSE)/sqrt(length(var1
> Summ$Grouping <- c("AB", "AB", "CD", "CD", "EF", "EF")[Summ$factor1]
> Summ$factor1bis <- c("0", "1", "0", "1", "0", "1")[Summ$factor1]
> 
> ggplot(Summ, aes(factor3, mean, group = factor1bis, shape = factor1bis,
> linetype = factor1bis, ymin = mean - sdv , ymax = mean + sdv)) +
>   geom_point(position = position_dodge(width = 0.25), size = 3) +
>   geom_line(position = position_dodge(width = 0.25)) +
>   geom_errorbar(width = 0.3, position = position_dodge(width = 0.25),
> size =
> 0.3) +
>   facet_wrap(~Grouping, ncol = 2) +
>   theme(strip.background = element_blank()) +
>   scale_shape(solid = FALSE)+
>   theme_bw() +
>   theme(strip.background = element_blank())+
>   theme(strip.text.x = element_blank(),
> strip.text.y = element_blank())+
>   ylab(expression(paste("my measured stuff"))) +
>   xlab("factor3") +
>   theme(legend.position="none")+
>   labs(shape = "factor1", group = "factor1", linetype = "factor1")
> 
> 
> 
> 
> 
> 
> 
> 
> Anna Zakrisson Braeunlich
> PhD student
> 
> Department of Ecology Environment and Plant Sciences
> Stockholm University
> Svante Arrheniusv. 21A
> SE-106 91 Stockholm
> Sweden
> 
> Lives in Berlin.
> For paper mail:
> Katzbachstr. 21
> D-10965, Berlin - Kreuzberg
> Germany/Deutschland
> 
> E-mail: anna.zakris...@su.se
> Tel work: +49-(0)3091541281
> Mobile: +49-(0)15777374888
> LinkedIn: http://se.linkedin.com/pub/anna-zakrisson-braeunlich/33/5a2/51b
> 
> >`b?". . b?" `b?". .b?" `b?". . >`b?". . b?" `b?". .b?"
> `b?". .>`b?". . b?" `b?". .b?" `b?". .>
> 
> -Original Message-
> From: "ONKELINX, Thierry" 
> To: Anna Zakrisson , "r-help@r-project.org"
> 
> Date: Wed, 6 Mar 2013 13:36:00 +
> Subject: RE: [R] Ggplot2: Moving legend,   change fill and removal of
> space
> between   plots when using   grid.arrange() possible use of facet_grid?
> 
> Dear Anna,
> 
> Is this what you would like?
> 
> Summ  <-   ddply(mydata, .(factor3,factor1), summarize,
>mean = mean(var1, na.rm = FALSE),
>sdv = sd(var1, na.rm = FALSE),
>se = 1.96*(sd(var1,
> na.rm=FALSE)/sqrt(length(var1
> Summ$Grouping <- c("AB", "AB", "CD", "CD", "EF", "EF")[Summ$factor1]
> Summ$factor1bis <- c("0", "1", "0", "1", "0", "1")[Summ$factor1]
> 
> ggplot(Summ, aes(factor3, mean, group = factor1bis, shape = factor1bis,
> linetype = factor1bis, ymin = mean - sdv , ymax = mean + sdv)) +
> geom_point(position = position_dodge(width = 0.25), size = 3) +
> geom_line(position = position_dodge(width = 0.25)) +
> geom_errorbar(width = 0.3, position = position_dodge(width = 0.25), size
> =
> 0.3) +
> facet_wrap(~Grouping, ncol = 2) +
> theme_bw() +
> ylab(expression(paste("my measured stuff"))) +
> xlab("factor3") +
> labs(shape = "factor1", group = "factor1", linetype = "factor1")
> 
> Best regards,
> 
> ir. Thierry Onkelinx
> Instituut voor natuur- en bosonderzoek / Research Institute for Nature
> and
> Forest
> team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
> Kliniekstraat 25
> 1070 Anderlecht
> Belgium
> + 32 2 525 02 51
> + 32 54 43 61 85
> thierry.onkel...@inbo.be
> www.inbo.be
> 
> To call in the statistician after the experiment is done may be no more
> than
> asking him to perform a post-mortem examination: he may be able to say
> what
> the experiment died of.
> ~ Sir Ronald Aylmer Fisher
> 
> The plural of anecdote is not data.
> ~ Roger Brinner
> 
> The combination of some data and an aching desire for an answer does not
> ensure that a reasonable answer can be extracted from a given body of
> data.
> ~ John Tukey
> 
> -Oorspronkelijk bericht-
> Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
> Namens Anna Zakrisson
> Verzonden: woensdag 6 maart 2013 13:33
> Aan: r-help@r-project.org
> Onderwerp: [R] Ggplot2: Moving legend, change fill and removal of space
> between plots when using grid.arrange() possible use of facet_grid?
> 
> Hi

Re: [R] multiple plots and looping assistance requested (revised codes)

2013-03-07 Thread arun
Hi Irucka,

Regarding the first question.

If you look at the ouput of temp1, it already strips off any NA that was left 
in the columns.  It is always to give an example dataset that is similar to the 
real dataset.

Here, I am guessing the situation is similar to this:
temp1<-lapply(temp,function(x) x[complete.cases(x),]) #NA values are removed
temp1[[2]]<- temp1[[2]][1:2] #Some columns are removed
 temp1[[3]]<- temp1[[3]][c(1,3)] # Some columns removed
#Subsetting based on 3 columns and 2 columns
#3 columns

temp3<-temp1[lapply(temp1,ncol)==3]
temp3New<-lapply(temp3,function(x) lapply(names(x)[-1], 
function(i){x1<-cbind(temp3[,1],temp3[,i]); colnames(x1)<- 
c("CYEAR_DECIMAL",i);x1}))

pdf("Irucka3.pdf")
par(mfrow=c(1,2))
lapply(names(temp3New),function(i) lapply(temp3New[[i]],function(x) 
{plot(x[,1],x[,2],main="Fluxmaster versus EGRET/WRTDS \n Seasonal FLux 
Sum",sub=paste(i,colnames(x)[2],sep="_"),xlab="Calendar Year 
Timesteps",ylab="Total Flux (kg/season)");lines(x[,1],x[,2])}))
dev.off()
# 2 columns
temp2<-temp1[lapply(temp1,ncol)==2]
temp2New<-lapply(temp2,function(x) lapply(names(x)[-1], 
function(i){x1<-cbind(temp2[,1],temp2[,i]); colnames(x1)<- 
c("CYEAR_DECIMAL",i);x1}))

pdf("Irucka2.pdf")
par(mfrow=c(1,1))
lapply(names(temp2New),function(i) lapply(temp2New[[i]],function(x) 
{plot(x[,1],x[,2],main="Fluxmaster versus EGRET/WRTDS \n Seasonal FLux 
Sum",sub=paste(i,colnames(x)[2],sep="_"),xlab="Calendar Year 
Timesteps",ylab="Total Flux (kg/season)");lines(x[,1],x[,2])}))
dev.off()

A.K.









From: Irucka Embry 
To: smartpink...@yahoo.com 
Cc: r-help@r-project.org 
Sent: Thursday, March 7, 2013 1:50 AM
Subject: Re: [R] multiple plots and looping assistance requested (revised codes)


Hi Arun, that worked perfectly for the smaller data set, but it has failed to 
plot in the whole data set where I have missing columns (either 1 or 2 columns 
missing).

How can I ask any NAs not to be plotted? I have attempted to use 
na.omit(temper2[[i]]), but it did not work. See below:

pdf("SeasonalFluxComparisonDataSet.pdf")
par(mfrow=c(1,2))
lapply(names(temper2),function(i) lapply(na.omit(temper2[[i]]),function(x) 
{plot(x[,1],x[,2],main="Seasonal Flux 
Sum",sub=paste(i,colnames(x)[2],sep="_"),xlab="Calendar Year 
Timesteps",ylab="Total Flux (kg/season)");lines(x[,1],x[,2])}))
Error in plot.window(...) : need finite 'xlim' values
In addition: Warning messages:
1: In min(x) : no non-missing arguments to min; returning Inf
2: In max(x) : no non-missing arguments to max; returning -Inf
3: In min(x) : no non-missing arguments to min; returning Inf
4: In max(x) : no non-missing arguments to max; returning -Inf
> dev.off()

> options("na.action")
$na.action
[1] "na.omit"

Thank you for your quick responses.

Irucka


<-Original Message-> 
>From: arun [smartpink...@yahoo.com]
>Sent: 3/6/2013 11:38:37 PM
>To: iruc...@mail2world.com
>Cc: r-help@r-project.org
>Subject: Re: [R] multiple plots and looping assistance requested (revised 
>codes)
>
>HI,
>Try this:
> temp1<-lapply(temp,function(x) x[complete.cases(x),])
> temp2<-lapply(temp1,function(tempNew) lapply(names(tempNew)[-1], 
> function(i){x1<-
>cbind(tempNew[,1],tempNew[,i]); colnames(x1)<- c("CYEAR_DECIMAL",i);x1}))
>pdf("Irucka3.pdf")
> par(mfrow=c(1,2))
>lapply(names(temp2),function(i) lapply(temp2[[i]],function(x) 
>{plot(x[,1],x[,2],main="Fluxmaster versus 
>EGRET/WRTDS \n Seasonal FLux 
>Sum",sub=paste(i,colnames(x)[2],sep="_"),xlab="Calendar Year 
>Timesteps",ylab="Total Flux (kg/season)");lines(x[,1],x[,2])}))
>dev.off()
>A.K.
>
>
>
>
>
>
>
>From: Irucka Embry 
>To: smartpink...@yahoo.com 
>Cc: r-help@r-project.org 
>Sent: Wednesday, March 6, 2013 11:49 PM
>Subject: Re: [R] multiple plots and looping assistance requested (revised 
>codes)
>
>
>Hi Arun, thank you for your assistance.
>
>I have successfully ran your suggested revised code (with some minor changes). 
>Thank-you very much!
>
>Is there a way to print either "load_00600_W" or "load_00600_F" after "sub = 
>i" for each plot?
>
>For example, can the subtitle be "02143500 load_00600_W" which is included in 
>temp2?
>
>> dput(temp2)
>structure(list(`02143500` = structure(list(load_00600_W = 
>structure(c(2000.875, 
>2001.125, 2001.375, 2001.625, 2001.875, 2002.125, 2002.375, 2002.625, 
>2002.875, 2003.125, 2003.375, 2003.625, 2003.875, 2004.125, 2004.375, 
>2004.625, 227675.73764, 92777.682029, 84827.680295, 193298.65669, 
>170799.05034, 103666.8759, 107485.71333, 213765.87505, 472307.65662, 
>799500.4, 754868.43185, 454078.02653, 171521.7, 265827.90007, 
>120401.25989, 194000.26057), .Dim = c(16L, 2L), .Dimnames = list(
>NULL, c("CYEAR_DECIMAL", "x"))), load_00600_F = structure(c(2000.875, 
>2001.125, 2001.375, 2001.625, 2001.875, 2002.125, 2002..375, 2002.625, 
>2002.875, 2003.125, 2003.375, 2003.625, 2003.875, 2004.125, 2004.375, 
>2004.625, 4202.7437226, 16214.840538, 7371.9290209, 3114.1090754, 
>2464.1114951,

Re: [R] Issue when reading a table into R

2013-03-07 Thread David Reiner
Or if you just want to see what the table will look like when you read it
but not clutter your workspace by assigning it, you can do

View(head(read.table(filename),20))

-- David


-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Sarah Goslee
Sent: Wednesday, March 06, 2013 3:21 PM
To: Paul Bernal
Cc: r-help
Subject: Re: [R] Issue when reading a table into R

Since nobody else has mentioned it: if you are seeing that message
when you are reading data in, then you probably failed to assign the
data to an R object.

mydata <- read.table("somefile") # correct
read.table("somefile") # will simply print your data to the console, not save it

I'm not entirely sure what you meant by "retrieve" so maybe you
already knew this.

You can use e.g.
dim(mydata)
to find out whether it's the size you expect.

Sarah

On Wed, Mar 6, 2013 at 3:58 PM, Paul Bernal  wrote:
> Hello everyone,
>
> I was reading a table into R, and when trying to retrieve it the following
> message appeared:
>
>  [ reached getOption("max.print") -- omitted 469376 rows ]
>
> Does this mean that R left out 469376 rows? Or R is taking those 469376
> rows as well and the limitation is only for printing purposes?
>
> Thanks in advance for any help,
>
> Best regards,
>
> Paul

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


This e-mail and any materials attached hereto, including, without limitation, 
all content hereof and thereof (collectively, "XR Content") are confidential 
and proprietary to XR Trading, LLC ("XR") and/or its affiliates, and are 
protected by intellectual property laws.  Without the prior written consent of 
XR, the XR Content may not (i) be disclosed to any third party or (ii) be 
reproduced or otherwise used by anyone other than current employees of XR or 
its affiliates, on behalf of XR or its affiliates.

THE XR CONTENT IS PROVIDED AS IS, WITHOUT REPRESENTATIONS OR WARRANTIES OF ANY 
KIND.  TO THE MAXIMUM EXTENT PERMISSIBLE UNDER APPLICABLE LAW, XR HEREBY 
DISCLAIMS ANY AND ALL WARRANTIES, EXPRESS AND IMPLIED, RELATING TO THE XR 
CONTENT, AND NEITHER XR NOR ANY OF ITS AFFILIATES SHALL IN ANY EVENT BE LIABLE 
FOR ANY DAMAGES OF ANY NATURE WHATSOEVER, INCLUDING, BUT NOT LIMITED TO, 
DIRECT, INDIRECT, CONSEQUENTIAL, SPECIAL AND PUNITIVE DAMAGES, LOSS OF PROFITS 
AND TRADING LOSSES, RESULTING FROM ANY PERSON'S USE OR RELIANCE UPON, OR 
INABILITY TO USE, ANY XR CONTENT, EVEN IF XR IS ADVISED OF THE POSSIBILITY OF 
SUCH DAMAGES OR IF SUCH DAMAGES WERE FORESEEABLE.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Comparing Cox model with Competing Risk model

2013-03-07 Thread Tasnuva Tabassum
I have a competing risk data where a patient may die from either AIDS or
Cancer. I want to compare the cox model for each of the event of interest
with a competing risk model. In the competing risk model the cumulative
incidence function is used directly. I used the jackknife (pseudovalue) of
the cumulative incidence function for each cause (AIDS or Cancer) in a
generalized estimating equation. I used the following code:

>library(pseudo)
>cutoffs<-c(0.5,5.5,10.5,15.5)
>pseudo<-pseudoci(time,event,tmax=cutoffs)
>library(geepack)
>fit<-geese(pseudo~as.factor(Age)+as.factor(Sex),data=b,id=id, jack = TRUE,
scale.fix=TRUE,
mean.link = "logit", corstr="independence").



I want to know whether I am doing the right thing?

[[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] Understanding lm-based analysis of fractional factorial experiments

2013-03-07 Thread S Ellison
> So, there are at least two points of confusion here, one is 
> how coef() differs from effects() in the case of fractional 
> factorial experiments, and the other is the factor 1/4 
> between the coefficients used by Wu & Hamada and the values 
> returned by effects() as I would think from theory I've read 
> that it should be a factor 2.

Some observations to throw into the mix here.

First, the model.
 
> leaf.lm  <- lm(yavg ~ B * C * D * E * Q, data=leaf)

is indeed unnecessarily complicated. You can request all second order 
interactions (accepting that some will be NA) with 
> leaf.lm  <- lm(yavg ~ ( B + C + D + E + Q)^2, data=leaf)

or of course you can specify only the ones you know will be present:
> leaf.lm  <- lm(yavg ~ (B + C + D + E + Q + B:C + B:D + B:E + B:Q + C:Q + D:Q 
> + E:Q, data=leaf)

I cheated a bit: 
> leaf.avg <- leaf[, c(1:5, 9)]
>  leaf.lm.avg  <- lm(yavg ~ ( .)^2, data=leaf.avg)
#less typing, same model (with NAs for aliased interactions)

Now lets look at those effects.
First, look at the model.matrix for leaf.lm. 

>model.matrix(leaf.lm)
This shows you what your yavg is actually being regressed against - it's a 
matrix of dummy codings for your (character) levels "+" and "-". 
Notice the  values for B (under "B+") and the intercept. The first row (which 
has "-" for B in the leaf data set) has a zero coefficient; the second has a 1. 
So in this matrix, 1 corresponds to "+" and "-" corresponds to 0, which you can 
read as "not different from the intercept". This arises from teh way contrasts 
have been chosen; these arise from 'treatment contrasts', R's default for 
factors. Pretty much the same goes for all the other factors. This structure 
corresponds to measuring the 'alternate' level of every  factor - always "+" 
because the first level is "-" -  against the intercept. What the intercept 
represents is not immediately obvious if you;re used to the mean of the study 
as the intercept; it estimates the when all factors are in their 'zero' state. 
That's really useful if you want to test a series of alternate treatments 
against  a control. It's also R's default. But it's not what most industrial 
experiments based on 2-level fractional factorials want; the!
 y usually want differences between levels. That is why some folk would call 
R's defaults 'odd defaults'. 

To get something closer to the usual fractional factorial usage, you need to 
change those dummy codings from (0,1) for "-", "+" to something like +1, -1. 
You can change that using contrasts. To change the contrasts to something most 
industrial experimenters would expect, we use sum-to-zero contrasts. So we do 
this instead (using my leaf.avg data frame above):.

> options(contrasts=c("contr.sum", "contr.poly"))
> (leaf.lm.sum <- lm(yavg ~ (.)^2, data=leaf.avg))

Now we can see that the coefficient for B is indeed half the difference between 
levels, as you might have expected. And the intercept is now equal to the mean 
of the data, as you might expect from much of the industrial experiment design 
literature. 
So - why half, and why is it negative?

Look at the new model matrix:
> model.matrix(leaf.lm.sum)

This time, B is full of +1 and -1, instead of 0 and 1. So first, B+ and B- are 
both different (in equal and opposite directions) from the intercept. 
Second, the range allocated to B is (+1 - -1) = 2, so the change in yavg per 
_unit_ change in B  (the lm coefficient for B)- is half the difference between 
levels for B. 
Finally, look at the particular allocation of model matrix values for B. The 
first row has +1, the second row -1. That's because contr.sum has allocated +1 
to the first level of the factor B, which (if you look at levels(leaf$B) is "-" 
because factor() uses a default alphabetic order. (You could change that for 
all your factors if you wanted, for example with leaf$B <- factor(leaf$B, 
levels=c("+","-")) and you'd then have +1 for "+" and -1 for "-") . But in the 
mean time, lm has been told that "-" corresponds to an _increase_ in the dummy 
coding for B. Since the mean for B=="-" is lower than the intercept, you get a 
negative coefficient.

effects() is doing somethig quite different; the help page tells you what its 
doing mathematically. It has an indirect physical interpretation: for simple 
designs like this, effects() output for the coefficients comes out as the 
coefficient multiplied by sqrt(n), where n is the number of observations in the 
experiment. But it is not giving you the effect of a factor in the sense of an 
effect of change in factor level on mean response.

Hope some of that is useful to you.

S Ellison

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

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

[R] Colour branches/labels of dendrogram according to a grouping variable

2013-03-07 Thread Johannes Radinger
Hi,

is there a way to color the branches or text label of the branches of
dendrograms e.g. from hclust() according to a grouping variable. Here
I have something in mind like:
http://www.sigmaaldrich.com/content/dam/sigma-aldrich/life-science/biowire/biowire-fall-2010/proteome-figure-1.Par.0001.Image.gif
(ectodermal, endodermal, mesodermal).

/johannes

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

2013-03-07 Thread Charles Determan Jr
I refer to a multivariate model.  For example, I have two groups (control
and test) and multiple variables measured for each (V1, V2, V3... Vn).  I
wasn't sure if there was any way to conduct power analysis other than
conducting it as you would with a single variable and just account for
multiple testing.  I will look into the Clinical Trials Task view.  If
there any recommendations by others or generally approach to multivariate
power calculations I would love to hear them.

Thanks again Marc,

Charles

On Thu, Mar 7, 2013 at 6:28 AM, Marc Schwartz  wrote:

> On Mar 6, 2013, at 10:50 PM, Charles Determan Jr  wrote:
>
> > Generic question... I am familiar with generic power calculations in R,
> > however a lot of the data I primarily work with is multivariate.  Is
> there
> > any package/function that you would recommend to conduct such power
> > analysis?  Any recommendations would be appreciated.
> >
> > Thank you for your time,
> >
> > Charles
>
>
>
> Are you referring to a multivariate response or a multivariable model?
> Just trying to parse the terminology better.
>
> If the former, I don't believe that there is anything in R, but could be
> wrong. If correct, then you might want to look at simulation.
>
> If the latter, you might want to look at the Clinical Trials Task View:
>
>   http://cran.r-project.org/web/views/ClinicalTrials.html
>
> as there are various packages that might fit what you need, but again,
> simulation is always an option.
>
> Regards,
>
> Marc Schwartz
>
>


-- 
Charles Determan
Integrated Biosciences PhD Student
University of Minnesota

[[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] Understanding lm-based analysis of fractional factorial experiments

2013-03-07 Thread Kjetil Kjernsmo
On Wednesday 6. March 2013 14.50.23 Ben Bolker wrote:
>Just a quick thought (sorry for removing context): what happens if
> you use sum-to-zero contrasts throughout, i.e.
> options(contrasts=c("contr.sum", "contr.poly")) ... ?

Ah, I've got it now, this pointed me in the right direction. Thanks a lot!

For future reference, the default was "contr.treatment", which implies 
> contrasts(leaf$B)
  +
- 0
+ 1

using contr.sum, we get

> contrasts(leaf$B)
  [,1]
-1
+   -1

which is orthogonal, and also explains the switched sign.

Kjetil

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


Re: [R] How to conditionally remove dataframe rows?

2013-03-07 Thread Marc Schwartz
Just to add another option to what Arun has provided below. That approach is 
very generalizable to data frames with >2 columns, where you want to filter 
based upon a finding a maximum value (or other perhaps more complex criteria) 
within one or more grouping columns and return all of the columns in the 
original data frame.

In this special case of a two column data frame, you can use ?aggregate easily 
with a formula based approach that might be easier to read. aggregate() 
essentially encapsulates what Arun has done below.

Thus:

> DF
  Point_counts Psi_Sp
1A  0
2A  1
3B  1
4B  2
5B  0
6C  1
7D  1
8D  2


> aggregate(Psi_Sp ~ Point_counts, data = DF, max)
  Point_counts Psi_Sp
1A  1
2B  2
3C  1
4D  2


Regards,

Marc Schwartz


On Mar 6, 2013, at 8:42 PM, arun  wrote:

> Hi,
> 
> dfrm<- read.table(text="
> Point_counts  Psi_Sp
> 
> 1A  0
> 2A  1
> 3B  1
> 4B  2
> 5B  0
> 6C  1
> 7D  1
> 8D  2
> ",sep="",header=TRUE,stringsAsFactors=FALSE)
>  res<-do.call(rbind,lapply(split(dfrm,dfrm$Point_counts),function(x) 
> x[which.max(x$Psi_Sp),]))
>  row.names(res)<-1:nrow(res)
>  # Point_counts Psi_Sp
> #1A  1
> #2B  2
> #3C  1 #your input data doesn't have 0
> #4D  2
> A.K.
> 
> 
> 
> - Original Message -
> From: Francisco Carvalho Diniz 
> To: r-help@r-project.org
> Cc: 
> Sent: Wednesday, March 6, 2013 6:21 PM
> Subject: [R] Fwd: How to conditionally remove dataframe rows?
> 
> Hi,
> 
> I have a data frame with two columns. I need to remove duplicated rows in
> first column, but I need to do it conditionally to values of the second
> column.
> 
> Example:
> 
> Point_counts   Psi_Sp
> 
> 1A   0
> 2A   1
> 3B   1
> 4B   2
> 5B   0
> 6C   1
> 7D   1
> 8D   2
> 
> 
> I need to turn this data frame in one without duplicated rows at
> point-counts (one visit per point) but maintain the ones with maximum value
> at Psi_Sp, e.g. remove row 1 and maintain 2 or remove rows 3 and 5 and
> maintain 4. At the end I want a data frame like the one below:
> 
>  Point_counts   Psi_Sp
> 
> 1  A   1
> 2  B   2
> 3  C   0
> 4  D   2
> 
> How can I do it? I found several ways to edit data frames, but
> unfortunately I cound not use none of them.
> 
> I appreciate
> 
> Francisco

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Understanding lm-based analysis of fractional factorial experiments

2013-03-07 Thread Ista Zahn
On Thu, Mar 7, 2013 at 5:47 AM, Kjetil Kjernsmo  wrote:
> On Wednesday 6. March 2013 16.33.34 Peter Claussen wrote:
>> But you don't have enough data points to estimate all of the possible
>> interactions; that's why you have NA in your original results.
>
> Yes, but it seems to me that lm is doing the right thing, or at least the
> expected thing, here, the NA's are simply telling me these are aliased, which
> is correct and expected.

I agree lm is doing the correct thing, but I think you are not. It
simply does not make sense:

# your model tries to estimate means for all 32 of these groups
pm <- c("+", "-")
tmp <- expand.grid(B=pm, C=pm, D=pm, E=pm, Q=pm)
dim(tmp)

# but your data has only 16 of them!
interaction(tmp) %in% interaction(leaf[c("B", "C", "D", "E", "Q")])

# you model asks for estimates for these groups, but they do not exist
in your data
tmp[!interaction(tmp) %in% interaction(leaf[c("B", "C", "D", "E", "Q")]), ]


>
>> You could
>> add the just the first order interactions manually, i.e.,  + B:C + B:D …
>
> Yeah, I tried that, but then it returns to the "unexpected" result, i.e., I
> get the same result as with the yavg ~ B * C * D * E * Q formula. Therefore, I
> think the problem doesn't lie with the formula, nor does it lie with any of
> the code, it is just a matter of understanding defaults...
>
> I have consulted local help (of course), but what they say is that "R has some
> odd defaults, you need to ask them or use something different". I don't want 
> to
> use something different, I like R, I have contributed to R in the past and 
> will
> do so again if only I can get my head around this... :-)

Start again, and forget the book which most of us do not have. Explain
what you are trying to do. Base the explanation on the data and
example at hand, and explain what you consider to be the expected
result and why.

Best,
Ista

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

2013-03-07 Thread Marc Schwartz
On Mar 6, 2013, at 10:50 PM, Charles Determan Jr  wrote:

> Generic question... I am familiar with generic power calculations in R,
> however a lot of the data I primarily work with is multivariate.  Is there
> any package/function that you would recommend to conduct such power
> analysis?  Any recommendations would be appreciated.
> 
> Thank you for your time,
> 
> Charles



Are you referring to a multivariate response or a multivariable model? Just 
trying to parse the terminology better.

If the former, I don't believe that there is anything in R, but could be wrong. 
If correct, then you might want to look at simulation.

If the latter, you might want to look at the Clinical Trials Task View:

  http://cran.r-project.org/web/views/ClinicalTrials.html

as there are various packages that might fit what you need, but again, 
simulation is always an option.

Regards,

Marc Schwartz

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Help using system() command to execute Perl script through MSDOS

2013-03-07 Thread Marc Schwartz
On Mar 6, 2013, at 8:52 PM, pdbarry  wrote:

> I am working on creating a program for some simulations I need to do and I
> want to execute a Perl script that I wrote  using the system() command in R.
> I have spent a couple days trying to figure this out and it appears that my
> problem occurs when sending the perl script file path through R to MSDOS. I
> have tried using double backslashes, quotations, etc. Moving my files to the
> root directory with no folders with spaces seems to make the problem go
> away. 
> 
> So here is the code:
> system(paste("perl",FP.chmod,FP.baseline.in,FP.baseline.out))
> 
> where perl is the command to use the perl script
> FP.chmod is the extenstion to the perl file
>   "C:/Documents and Settings/Pato/Desktop/Mikes R package/chmod700.pl"
>created using FP.chmod<- file.path(wd,'chmod700.pl') #wd is the
> working directory
> FP.baseline.in is the input file extension
>"C:/Documents and Settings/Pato/Desktop/Mikes R
> package/Baseline2c.bse"
> FP.baseline.out is the output to make from the perl script.
> 
> If I look at it pasted together it looks like it would work: 
> "perl C:/Documents and Settings/Pato/Desktop/Mikes R package/chmod700.pl
> C:/Documents and Settings/Pato/Desktop/Mikes R package/Baseline2c.bse
> C:/Documents and Settings/Pato/Desktop/Mikes R package/Baseline2d.bse
> 
> If I change the location of the files so that they are directly under the
> root directory it runs without a hitch. I greatly appreciate any help that
> can be offered. 
> Pat



You might want to take a look to see how I do it in WriteXLS():

  https://github.com/marcschwartz/WriteXLS/blob/master/R/WriteXLS.R

Look at around line 167 in the R source.

The key thing to understand (as you hint at above) is that spaces in the 
arguments on the CLI are delimiters, separating what you have as a single 
argument into multiples.

Use ?shQuote to put single quotes around each argument that contains spaces, so 
that it is treated as a single argument:

> shQuote("This is a single argument")
[1] "'This is a single argument'"


Regards,

Marc Schwartz

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

2013-03-07 Thread Simon Zehnder
Dear Giovanni,

apologize for this late reply! I was testing and reading a lot of stuff. I 
tried your suggestions and the problem of singularity in the regressor cross 
product vanishes when using the Group Mean function 'pgm' instead of 'pvcm'. 
Nevertheless, I found the collinearity in the regressors and 'pvcm' ran 
further, until I got another error. This time a little different but still 
directed towards the same area:

'Error in solve.default(crossprod(X[[i]])[!coefna[i, ], !coefna[i, ]])) :
system is computationally singular: reciprocal condition number = 
1.86131e-17'

Following the description of R's function 'rcond', the reciprocal condition 
number measures how close a matrix is to be rank deficient. So in this case one 
regressor crossproduct seems to be sufficiently close to singularity, such that 
inversion becomes impossible. 

I attached you a simple subsample. If you let run the following commands on it:

require(plm)
data <- read.csv(path, sep = ",", header = TRUE)
pdata <- plm.data(data, index = c("gvkey", "fyear"))
debug(plm:::pvcm)
model.pvcm <- pvcm(LOGDXSGA~LOGDSALE + DECRLOGDSALE + DECRLOGDSALEWDAVG, data = 
pdata, model = "random")
.. go until
Browse[2]> 
debug: ml <- split(data cond)

Then type:
A <- as.matrix(ml$'25062'[, 2:4])
XX <- t(A) %*% A
qr(XX)$rank
[1] 2Aha, the rank is only 2! 
rcond(XX) 
[1] 9.339817e-16Alright, the matrix XX is pretty near to singularity, even 
it is not really singular!

Let us have a look at it:
A[, 2]/A[, 3]
.  A[, 2] is almost a multiple of A[, 3], if 
the latter is multiplied by -6.231979 or -6.231331 . at least it suffices 
to let the rank shrink to 2. 

The thing is, the same regression goes through in the Stata package. As I would 
say, I am an R fanatist, I would like to know, why it runs in Stata and not in 
R.and that one can let it run in R as well. Different number 
formats/precision? Maybe it suffices in such a case to enforce full rank of the 
crossproduct by enforcing positive definitess, for instance via the function 
'nearPD' in the R package 'Matrix':

Try 
library(Matrix)
qr(nearPD(XX)$mat)$rank
[1] 3 Yey!. :)

Tell me your opinion Giovanni! Give me a little help here please! 


Best 

Simon
 

P.S. Thank your for this fantastic package making panel data estimation 
possible in the R environment! 




On Feb 27, 2013, at 1:40 PM, Millo Giovanni  wrote:

> Hello.
> Another thing you may want to do depends on whether you are using
> model="within" (the default) or model="random".
> 
> In the first case, pvcm() estimates separate regressions, so you just
> need to loop lm() on individual indices to spot where it fails.
> 
> In the second case, what you may want to do is try a similar estimator:
> pmg(..., model="mg"), which is an unweighted version of Swamy's
> estimator in pvcm() and a simpler function to read and modify, possibly
> using the global assignment operator '<<-' as already suggested by
> William to output diagnostics.
> 
> Best,
> Giovanni
> 
>> -Original Message-
>> From: r-help-boun...@r-project.org
> [mailto:r-help-boun...@r-project.org] On Behalf
>> Of Simon Zehnder
>> Sent: Tuesday, February 26, 2013 2:53 AM
>> To: r-help@r-project.org help
>> Subject: [R] Count function calls
>> 
>> Dear R-users,
>> 
>> I have the following problem: I am running the function 'pvcm' from
> the 'plm' Panel Data
>> package. Inside this function 'solve' is called and gives for a
> certain individual data series
>> an exception because of singularity. I would like to know which
> individual data series
>> causes this error. I tried to debug it, but this is truly painful, as
> solve is called inside of
>> 'lapply' and there are over 5,000 individual data series in the panel.
>> 
>> Now, what I would like to do is to count the calls to 'solve' inside
> the function, so I can
>> see, where the function throws the exception. I tried to use 'trace'
> with a count variable,
>> but I have no clue how to define a global variable to be used by trace
> and updated at
>> every call.is there another approach?
>> 
>> 
>> Best
>> 
>> Simon
>> 
>> __
> 
>  
> Ai sensi del D.Lgs. 196/2003 si precisa che le informazioni contenute in 
> questo messaggio sono riservate ed a uso esclusivo del destinatario. Qualora 
> il messaggio in parola Le fosse pervenuto per errore, La invitiamo ad 
> eliminarlo senza copiarlo e a non inoltrarlo a terzi, dandocene gentilmente 
> comunicazione. Grazie.
> 
> Pursuant to Legislative Decree No. 196/2003, you are hereby informed that 
> this message contains confidential information intended only for the use of 
> the addressee. If you are not the addressee, and have received this message 
> by mistake, please delete it and immediately notify us. You may not copy or 
> disseminate this message to anyone. Thank you.

___

Re: [R] Ggplot2: Moving legend, change fill and removal of space between plots when using grid.arrange() possible use of facet_grid?

2013-03-07 Thread Anna Zakrisson
Hi,
have managed to get rid of the facet labels (so do not spend your time 
explaining that to me). Tthere were some old code out there which did not 
work. My only remaining issue is how to add the axis labels to the plot 
without labels.
Anna

Summ  <-   ddply(mydata, .(factor3,factor1), summarize,
 mean = mean(var1, na.rm = FALSE),
 sdv = sd(var1, na.rm = FALSE),
 se = 1.96*(sd(var1, na.rm=FALSE)/sqrt(length(var1
Summ$Grouping <- c("AB", "AB", "CD", "CD", "EF", "EF")[Summ$factor1]
Summ$factor1bis <- c("0", "1", "0", "1", "0", "1")[Summ$factor1]

ggplot(Summ, aes(factor3, mean, group = factor1bis, shape = factor1bis, 
linetype = factor1bis, ymin = mean - sdv , ymax = mean + sdv)) +
  geom_point(position = position_dodge(width = 0.25), size = 3) +
  geom_line(position = position_dodge(width = 0.25)) +
  geom_errorbar(width = 0.3, position = position_dodge(width = 0.25), size = 
0.3) +
  facet_wrap(~Grouping, ncol = 2) +
  theme(strip.background = element_blank()) +
  scale_shape(solid = FALSE)+
  theme_bw() +
  theme(strip.background = element_blank())+
  theme(strip.text.x = element_blank(),
strip.text.y = element_blank())+
  ylab(expression(paste("my measured stuff"))) +
  xlab("factor3") +
  theme(legend.position="none")+
  labs(shape = "factor1", group = "factor1", linetype = "factor1")








Anna Zakrisson Braeunlich
PhD student

Department of Ecology Environment and Plant Sciences
Stockholm University
Svante Arrheniusv. 21A
SE-106 91 Stockholm
Sweden

Lives in Berlin.
For paper mail:
Katzbachstr. 21
D-10965, Berlin - Kreuzberg
Germany/Deutschland

E-mail: anna.zakris...@su.se
Tel work: +49-(0)3091541281
Mobile: +49-(0)15777374888
LinkedIn: http://se.linkedin.com/pub/anna-zakrisson-braeunlich/33/5a2/51b

><º>`•. . • `•. .• `•. . ><º>`•. . • `•. .• 
`•. .><º>`•. . • `•. .• `•. .><º>

-Original Message-
From: "ONKELINX, Thierry" 
To: Anna Zakrisson , "r-help@r-project.org" 

Date: Wed, 6 Mar 2013 13:36:00 +
Subject: RE: [R] Ggplot2: Moving legend,   change fill and removal of space 
between   plots when using   grid.arrange() possible use of facet_grid?

Dear Anna,

Is this what you would like?

Summ  <-   ddply(mydata, .(factor3,factor1), summarize,
   mean = mean(var1, na.rm = FALSE),
   sdv = sd(var1, na.rm = FALSE),
   se = 1.96*(sd(var1, na.rm=FALSE)/sqrt(length(var1
Summ$Grouping <- c("AB", "AB", "CD", "CD", "EF", "EF")[Summ$factor1]
Summ$factor1bis <- c("0", "1", "0", "1", "0", "1")[Summ$factor1]

ggplot(Summ, aes(factor3, mean, group = factor1bis, shape = factor1bis, 
linetype = factor1bis, ymin = mean - sdv , ymax = mean + sdv)) +
geom_point(position = position_dodge(width = 0.25), size = 3) +
geom_line(position = position_dodge(width = 0.25)) +
geom_errorbar(width = 0.3, position = position_dodge(width = 0.25), size = 
0.3) +
facet_wrap(~Grouping, ncol = 2) +
theme_bw() +
ylab(expression(paste("my measured stuff"))) +
xlab("factor3") +
labs(shape = "factor1", group = "factor1", linetype = "factor1")

Best regards,

ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and 
Forest
team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
Kliniekstraat 25
1070 Anderlecht
Belgium
+ 32 2 525 02 51
+ 32 54 43 61 85
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more than 
asking him to perform a post-mortem examination: he may be able to say what 
the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ Roger Brinner

The combination of some data and an aching desire for an answer does not 
ensure that a reasonable answer can be extracted from a given body of data.
~ John Tukey

-Oorspronkelijk bericht-
Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] 
Namens Anna Zakrisson
Verzonden: woensdag 6 maart 2013 13:33
Aan: r-help@r-project.org
Onderwerp: [R] Ggplot2: Moving legend, change fill and removal of space 
between plots when using grid.arrange() possible use of facet_grid?

Hi,

# For publications, I am not allowed to repeat the axes. I have tried to
remove the axes using:
# yaxt="n", but it did not work. I have not understood how to do this in
ggplot2. Can you help me?
# I also do not want loads of space between the graphs (see below script
with Dummy Data).
# If I could make it look like the examples on the (nice) examples page:
# http://www.ling.upenn.edu/~joseff/rstudy/summer2010_ggplot2_intro.html
# using the facet_grid(), I would be very very happy.

# I also do not want the gemoetric points to be filled and the fill="white"
commande
# does not seem to work - why? and are there alternatives?

#Furthermore, I would like to add legends to inside the plot area instead of
on the side. Like when you use plotrix() and brkdn.plot:
legend("top

Re: [R] Error: no 'dimnames' attribute for array

2013-03-07 Thread eliza botto

Thankyou Micheal!!! That was so nice of you. It cleared everything.
Elisa

> From: michael.weyla...@gmail.com
> Date: Thu, 7 Mar 2013 11:31:59 +
> Subject: Re: [R] Error: no 'dimnames' attribute for array
> To: eliza_bo...@hotmail.com
> CC: r-help@r-project.org
> 
> On Thu, Mar 7, 2013 at 11:19 AM, eliza botto  wrote:
> > Thankyou very much M. Weylandt. i was actually more interested in knowing
> > about the error.
> 
> Let's talk you through it then:
> 
> As you said before you have
> 
> b1 <- c(1L, 2L, 6L, 7L, 12L, 16L, 17L, 20L, 21L, 23L, 25L, 34L, 46L,
> 48L, 58L, 64L, 65L, 68L, 82L, 97L, 98L, 101L, 113L, 115L)
> 
> in your session. And from there you create:
> 
> s<-noquote(paste (b1, collapse=","))
> 
> So let's take that apart: you take a set of integers (and integer
> vector) and collapse it using the paste() function. This returns a
> character string. You pass the resulting character string to noquote()
> which is a relatively obscure function. However, it's not a hard one:
> it basically attaches the "noquote" class to the object which allows
> it to act in almost entirely the same way, but to be printed without
> quotes. Note the difference in
> 
> print(paste(b1, collapse = ", "))
> 
> and
> 
> print(noquote(paste(b1, collapse = ", ")))
> 
> So anyways, now you've got s and you use it to subscript a matrix.
> Here R makes a decision that surprises you: it tries to interpret s as
> a character vector! (because it is one) So what does it mean when you
> subset by a character vector instead of a numeric index: well, to pull
> out the apropriate row or column by _name_ instead of by position. To
> do this requires knowing the names: so R looks for the relevant names,
> which are normally stored in a property called "dimnames" (dimension
> names).
> 
> Your matrix, however, doesn't seem to have any dimnames, so R throws
> an error saying (in effect) "you want me to get the rows by this name
> and I am totally willing to do so, but there's this tiny little issue:
> there aren't any names..."
> 
> Now this could have turned out differently: your matrix could have had
> some names, but none which matched s. Then you'd simply have
> successful subsetting with no result, not unlike computing b1[0]. A
> much more subtle error. So you should actually consider yourself lucky
> you got the error at this stage instead of having to hunt it down in a
> much more subtle form later.
> 
> So how did I know all of this? Aside from some general familiarity
> with R, I used the str() function which lets me take a look at what
> "sort" of thing things in R are. (Say that three times fast!) When I
> applied it to str(s) I found that s was a character vector of class
> noquote -- and that's what made it all clear that your numbers weren't
> really being interpreted as "numbers" because, well, they really
> weren't numbers from R's point of view.
> 
> Again, and just to make that last point clear: they weren't numbers
> because there's a fundamental difference between "3" and 3 in
> computers. One is the integral successor of 2, the other is a way that
> humans happen to denote it at certain points in history in certain
> computational contexts. Some languages like Perl let you play a bit
> fast and loose with this distinction, but I don't think anyone would
> argue that R needs to be more forgiving in its type system.
> 
> Cheers,
> MW
  
[[alternative HTML version deleted]]

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


Re: [R] Error: no 'dimnames' attribute for array

2013-03-07 Thread R. Michael Weylandt
On Thu, Mar 7, 2013 at 11:19 AM, eliza botto  wrote:
> Thankyou very much M. Weylandt. i was actually more interested in knowing
> about the error.

Let's talk you through it then:

As you said before you have

b1 <- c(1L, 2L, 6L, 7L, 12L, 16L, 17L, 20L, 21L, 23L, 25L, 34L, 46L,
48L, 58L, 64L, 65L, 68L, 82L, 97L, 98L, 101L, 113L, 115L)

in your session. And from there you create:

s<-noquote(paste (b1, collapse=","))

So let's take that apart: you take a set of integers (and integer
vector) and collapse it using the paste() function. This returns a
character string. You pass the resulting character string to noquote()
which is a relatively obscure function. However, it's not a hard one:
it basically attaches the "noquote" class to the object which allows
it to act in almost entirely the same way, but to be printed without
quotes. Note the difference in

print(paste(b1, collapse = ", "))

and

print(noquote(paste(b1, collapse = ", ")))

So anyways, now you've got s and you use it to subscript a matrix.
Here R makes a decision that surprises you: it tries to interpret s as
a character vector! (because it is one) So what does it mean when you
subset by a character vector instead of a numeric index: well, to pull
out the apropriate row or column by _name_ instead of by position. To
do this requires knowing the names: so R looks for the relevant names,
which are normally stored in a property called "dimnames" (dimension
names).

Your matrix, however, doesn't seem to have any dimnames, so R throws
an error saying (in effect) "you want me to get the rows by this name
and I am totally willing to do so, but there's this tiny little issue:
there aren't any names..."

Now this could have turned out differently: your matrix could have had
some names, but none which matched s. Then you'd simply have
successful subsetting with no result, not unlike computing b1[0]. A
much more subtle error. So you should actually consider yourself lucky
you got the error at this stage instead of having to hunt it down in a
much more subtle form later.

So how did I know all of this? Aside from some general familiarity
with R, I used the str() function which lets me take a look at what
"sort" of thing things in R are. (Say that three times fast!) When I
applied it to str(s) I found that s was a character vector of class
noquote -- and that's what made it all clear that your numbers weren't
really being interpreted as "numbers" because, well, they really
weren't numbers from R's point of view.

Again, and just to make that last point clear: they weren't numbers
because there's a fundamental difference between "3" and 3 in
computers. One is the integral successor of 2, the other is a way that
humans happen to denote it at certain points in history in certain
computational contexts. Some languages like Perl let you play a bit
fast and loose with this distinction, but I don't think anyone would
argue that R needs to be more forgiving in its type system.

Cheers,
MW

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


Re: [R] Error: no 'dimnames' attribute for array

2013-03-07 Thread eliza botto

Thankyou very much M. Weylandt. i was actually more interested in knowing about 
the error. I got the point.Thankyou
elisa 

> From: michael.weyla...@gmail.com
> Date: Thu, 7 Mar 2013 11:15:36 +
> Subject: Re: [R] Error: no 'dimnames' attribute for array
> To: eliza_bo...@hotmail.com
> CC: r-help@r-project.org
> 
> On Thu, Mar 7, 2013 at 11:02 AM, eliza botto  wrote:
> >
> > Dear XpeRts,
> > I prepared a no qoute Character string by the following command
> >
> > s<-noquote(paste (b1, collapse=","))
> >
> > where, b1 is the vector of 24 intergers.
> >
> >> dput(b1)
> >
> > c(1L, 2L, 6L, 7L, 12L, 16L, 17L, 20L, 21L, 23L, 25L, 34L, 46L, 48L, 58L, 
> > 64L, 65L, 68L, 82L, 97L, 98L, 101L, 113L, 115L)
> >
> >> dput(s)
> >
> > structure("1,2,6,7,12,16,17,20,21,23,25,34,46,48,58,64,65,68,82,97,98,101,113,115",
> >  class = "noquote")
> >
> > I want to use "s" in the following command
> >
> > matb1<-res[,c(s))]
> >
> > The objective is to call those columns of matrix "res", whose numbers have 
> > been defined in "s".
> > But when i plug "s" into "matb1" i get the following error
> >
> > Error: no 'dimnames' attribute for array
> >
> > How can i get rid of it??
> > thanks in advance
> 
> I may be way off-base here, but can't you just use res[, b1]?
> 
> As to the explanation as to why you get that error, let's just say
> it's because c(s) doesn't result in a numerical vector and leave it at
> that.
> 
> Cheers,
> MW
> 
> >
> > Eliza
> > [[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
  
[[alternative HTML version deleted]]

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


Re: [R] Error: no 'dimnames' attribute for array

2013-03-07 Thread R. Michael Weylandt
On Thu, Mar 7, 2013 at 11:02 AM, eliza botto  wrote:
>
> Dear XpeRts,
> I prepared a no qoute Character string by the following command
>
> s<-noquote(paste (b1, collapse=","))
>
> where, b1 is the vector of 24 intergers.
>
>> dput(b1)
>
> c(1L, 2L, 6L, 7L, 12L, 16L, 17L, 20L, 21L, 23L, 25L, 34L, 46L, 48L, 58L, 64L, 
> 65L, 68L, 82L, 97L, 98L, 101L, 113L, 115L)
>
>> dput(s)
>
> structure("1,2,6,7,12,16,17,20,21,23,25,34,46,48,58,64,65,68,82,97,98,101,113,115",
>  class = "noquote")
>
> I want to use "s" in the following command
>
> matb1<-res[,c(s))]
>
> The objective is to call those columns of matrix "res", whose numbers have 
> been defined in "s".
> But when i plug "s" into "matb1" i get the following error
>
> Error: no 'dimnames' attribute for array
>
> How can i get rid of it??
> thanks in advance

I may be way off-base here, but can't you just use res[, b1]?

As to the explanation as to why you get that error, let's just say
it's because c(s) doesn't result in a numerical vector and leave it at
that.

Cheers,
MW

>
> Eliza
> [[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] Error: no 'dimnames' attribute for array

2013-03-07 Thread eliza botto

Dear XpeRts,
I prepared a no qoute Character string by the following command

s<-noquote(paste (b1, collapse=","))

where, b1 is the vector of 24 intergers. 

> dput(b1)

c(1L, 2L, 6L, 7L, 12L, 16L, 17L, 20L, 21L, 23L, 25L, 34L, 46L, 48L, 58L, 64L, 
65L, 68L, 82L, 97L, 98L, 101L, 113L, 115L)

> dput(s)

structure("1,2,6,7,12,16,17,20,21,23,25,34,46,48,58,64,65,68,82,97,98,101,113,115",
 class = "noquote")

I want to use "s" in the following command 

matb1<-res[,c(s))]

The objective is to call those columns of matrix "res", whose numbers have been 
defined in "s".
But when i plug "s" into "matb1" i get the following error

Error: no 'dimnames' attribute for array

How can i get rid of it??
thanks in advance

Eliza 
[[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] Understanding lm-based analysis of fractional factorial experiments

2013-03-07 Thread Kjetil Kjernsmo
On Wednesday 6. March 2013 16.33.34 Peter Claussen wrote:
> But you don't have enough data points to estimate all of the possible
> interactions; that's why you have NA in your original results.

Yes, but it seems to me that lm is doing the right thing, or at least the 
expected thing, here, the NA's are simply telling me these are aliased, which 
is correct and expected.

> You could
> add the just the first order interactions manually, i.e.,  + B:C + B:D …

Yeah, I tried that, but then it returns to the "unexpected" result, i.e., I 
get the same result as with the yavg ~ B * C * D * E * Q formula. Therefore, I 
think the problem doesn't lie with the formula, nor does it lie with any of 
the code, it is just a matter of understanding defaults...

I have consulted local help (of course), but what they say is that "R has some 
odd defaults, you need to ask them or use something different". I don't want to 
use something different, I like R, I have contributed to R in the past and will 
do so again if only I can get my head around this... :-)

Kjetil

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

2013-03-07 Thread Knut Krueger

Am 06.03.2013 22:20, schrieb David L Carlson:

Actually, the http://www.sussex.ac.uk/its/pdfs/SPSS_Exact_Tests_20.pdf file 
indicates that for small samples and a one-way chi square test, SPSS uses a 
multinomial distribution to tabulate the distribution of chi square for a given 
N, K, and probability of membership in each group. In package stats, the 
dmultinom() function can be used to accomplish this. The last example on the 
help page shows the steps.

--
David L Carlson
Associate Professor of Anthropology
Texas A&M University
College Station, TX 77843-4352

Than you very much.

This was exactly (incuding the sppss pdf) for what I was looking for.

Maybe its helpful for others here are the IBM PDF files:
ftp://public.dhe.ibm.com/software/analytics/spss/documentation/statistics/20.0/en/client/Manuals/

Knut

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Help with a function and text

2013-03-07 Thread Eliano
Thanks for that. Eliano

2013/3/7 David Winsemius [via R] 

>
> On Mar 6, 2013, at 3:44 PM, Eliano wrote:
>
> > Thanks. Btw are you able to help with my issue? Thanks, Eliano
>
> I'm sorry,  I was too busy answering the question from 'Eliano' over
> on StackOverflow. I didn't have time to address this one.
>
> (Please do note that cross-posting questions to Rhelp is contrary to
> advice in the Posting Guide.)
>
> You might also do further searching in the Archives with the search terms:
> substitute text eval
>  and perhaps narrow it down further with contributors named:
> grothendeick, dunlap, ligges, venables
>
> >
> > Sent from my iPhone
> >
> > On 6 Mar 2013, at 23:41, "David Winsemius [via R]" <
> > [hidden email] >
> wrote:
> >
> >
> > On Mar 6, 2013, at 11:25 AM, Eliano Marques wrote:
> >
> >> Hi, can I understand why this message was rejected ?
> >> Thanks,
> >> Eliano
> >
> > First hit on a Markmail search:
> >
> >
> http://markmail.org/message/5xog3ayx4amprsdx?q=list:org%2Er-project%2Er-help+nabble+rejected
> >
> > --
> > David.
> >
> >>
> >> Sent from my iPhone
> >>
> >> On 6 Mar 2013, at 19:18, Eliano <[hidden
> email]>
>  > wrote:
> >>
> >>> Hi everyone,
> >>>
> >>> I am writing some code to generate a function. I am passing that code
> to
> > a
> >>> dataset which i'm importing in R, e.g.
> >>> Test=read.table('C:/test.txt', header=F, sep='\t', na.strings='NA',
> > dec='.',
> >>> strip.white=TRUE)
> >>> Test
> >>>
> >>> V1
> >>> (if(nclusters>0){OptmizationInputs[3,3]*beta[1]}else{0})+"
> >>> (if(nclusters>1){OptmizationInputs[3,3]*beta[1]}else{0})+"
> >>> V1 has inside a code for a function.
> >>>
> >>> I'm having problems with 2 things:
> >>>
> >>> 1 - I need to take out from V1 all " that appears in the text, i tried
> a
> >>> replace but did not work.
> >>> Test=replace(Test,' " ', ' ')  , did not work.
> >>>
> >>> 2 - Writing a function like this :
> >>>
> >>> nlog=function(par)
> >>>  {
> >>>  beta=par[1:n]
> >>>  Measure=Test[1]  # would this read the text?
> >>>  return(Measure)
> >>>  }
> >>>
> >>> So i need to use that code inside the function as above.
> >>> Any suggestion on how you would do this?
> >>>
> >>> Kind Regards,
> >>> Eliano
> >>>
> >>>
> >>>
> >>> --
> >>> View this message in context:
> >
> http://r.789695.n4.nabble.com/Help-with-a-function-and-text-tp4660523.html
> >>> Sent from the R help mailing list archive at Nabble.com.
> >>>
> >>
> >> __
> >> [hidden email]  mailing
> > list
> >> https://stat.ethz.ch/mailman/listinfo/r-help
> >> PLEASE do read the posting guide
> > http://www.R-project.org/posting-guide.html
> >> and provide commented, minimal, self-contained, reproducible code.
> >
> > David Winsemius
> > Alameda, CA, USA
> >
> > __
> > [hidden email]  mailing
> > list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
> >
> > --
> > If you reply to this email, your message will be added to the discussion
> > below:
> >
> http://r.789695.n4.nabble.com/Help-with-a-function-and-text-tp4660523p4660547.html
> > To unsubscribe from Help with a function and text, click
> > here<
>
> > .
> > NAML<
> http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>
> >
> >
> >
> >
> > --
> > View this message in context:
> http://r.789695.n4.nabble.com/Help-with-a-function-and-text-tp4660523p4660548.html
>
> > Sent from the R help mailing list archive at Nabble.com.
> > [[alternative HTML version deleted]]
> >
> > __
> > [hidden email] 
> > mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>
> David Winsemius
> Alameda, CA, USA
>
> __
> [hidden email] mailing 
> list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>
> --

Re: [R] Ggplot2: Moving legend, change fill and removal of space between plots when using grid.arrange() possible use of facet_grid?

2013-03-07 Thread Anna Zakrisson
I have tried to remove the strips completely using either.
theme(strip.background = element_blank()) 
or
theme(strip.text.x = element_blank(),
strip.text.y = element_blank())

with no success. 

I also have the problem that A, B, C, D, E and F are stations at sea. 
Therefore, I would need a lagend on each of the plots to show for example in 
the first plot: which is A and which is B.

I have found loads of information in how to build a lagend, but not how to 
build different legends for all three plots.
I have added the script you sent me with a few changes for visualization of 
the problem.

once again, thank you for your time. 
Anna


Summ  <-   ddply(mydata, .(factor3,factor1), summarize,
 mean = mean(var1, na.rm = FALSE),
 sdv = sd(var1, na.rm = FALSE),
 se = 1.96*(sd(var1, na.rm=FALSE)/sqrt(length(var1
Summ$Grouping <- c("AB", "AB", "CD", "CD", "EF", "EF")[Summ$factor1]
Summ$factor1bis <- c("0", "1", "0", "1", "0", "1")[Summ$factor1]

ggplot(Summ, aes(factor3, mean, group = factor1bis, shape = factor1bis, 
linetype = factor1bis, ymin = mean - sdv , ymax = mean + sdv)) +
  geom_point(position = position_dodge(width = 0.25), size = 3) +
  geom_line(position = position_dodge(width = 0.25)) +
  geom_errorbar(width = 0.3, position = position_dodge(width = 0.25), size = 
0.3) +
  facet_wrap(~Grouping, ncol = 2) +
  theme(strip.background = element_blank()) +
  scale_shape(solid = FALSE)+
  theme_bw() +
  ylab(expression(paste("my measured stuff"))) +
  xlab("factor3") +
  theme(legend.position="none")+
  labs(shape = "factor1", group = "factor1", linetype = "factor1")


Anna Zakrisson Braeunlich
PhD student

Department of Ecology Environment and Plant Sciences
Stockholm University
Svante Arrheniusv. 21A
SE-106 91 Stockholm
Sweden

Lives in Berlin.
For paper mail:
Katzbachstr. 21
D-10965, Berlin - Kreuzberg
Germany/Deutschland

E-mail: anna.zakris...@su.se
Tel work: +49-(0)3091541281
Mobile: +49-(0)15777374888
LinkedIn: http://se.linkedin.com/pub/anna-zakrisson-braeunlich/33/5a2/51b

><º>`•. . • `•. .• `•. . ><º>`•. . • `•. .• 
`•. .><º>`•. . • `•. .• `•. .><º>

-Original Message-
From: "ONKELINX, Thierry" 
To: Anna Zakrisson , "r-help@r-project.org" 

Date: Wed, 6 Mar 2013 13:36:00 +
Subject: RE: [R] Ggplot2: Moving legend,   change fill and removal of space 
between   plots when using   grid.arrange() possible use of facet_grid?

Dear Anna,

Is this what you would like?

Summ  <-   ddply(mydata, .(factor3,factor1), summarize,
   mean = mean(var1, na.rm = FALSE),
   sdv = sd(var1, na.rm = FALSE),
   se = 1.96*(sd(var1, na.rm=FALSE)/sqrt(length(var1
Summ$Grouping <- c("AB", "AB", "CD", "CD", "EF", "EF")[Summ$factor1]
Summ$factor1bis <- c("0", "1", "0", "1", "0", "1")[Summ$factor1]

ggplot(Summ, aes(factor3, mean, group = factor1bis, shape = factor1bis, 
linetype = factor1bis, ymin = mean - sdv , ymax = mean + sdv)) +
geom_point(position = position_dodge(width = 0.25), size = 3) +
geom_line(position = position_dodge(width = 0.25)) +
geom_errorbar(width = 0.3, position = position_dodge(width = 0.25), size = 
0.3) +
facet_wrap(~Grouping, ncol = 2) +
theme_bw() +
ylab(expression(paste("my measured stuff"))) +
xlab("factor3") +
labs(shape = "factor1", group = "factor1", linetype = "factor1")

Best regards,

ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and 
Forest
team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
Kliniekstraat 25
1070 Anderlecht
Belgium
+ 32 2 525 02 51
+ 32 54 43 61 85
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more than 
asking him to perform a post-mortem examination: he may be able to say what 
the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ Roger Brinner

The combination of some data and an aching desire for an answer does not 
ensure that a reasonable answer can be extracted from a given body of data.
~ John Tukey

-Oorspronkelijk bericht-
Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] 
Namens Anna Zakrisson
Verzonden: woensdag 6 maart 2013 13:33
Aan: r-help@r-project.org
Onderwerp: [R] Ggplot2: Moving legend, change fill and removal of space 
between plots when using grid.arrange() possible use of facet_grid?

Hi,

# For publications, I am not allowed to repeat the axes. I have tried to
remove the axes using:
# yaxt="n", but it did not work. I have not understood how to do this in
ggplot2. Can you help me?
# I also do not want loads of space between the graphs (see below script
with Dummy Data).
# If I could make it look like the examples on the (nice) examples page:
# http://www.ling.upenn.edu/~joseff/rstudy/summer2010_ggplot2_intro.html
# using the facet_grid(), I would be very very happy.

# I also do not want th

Re: [R] create vector from indices interpolated values

2013-03-07 Thread PIKAL Petr
Hi

maybe

index <- which(is.na(dataset1$V2))
y <- dataset2$V1[index]
plot(y~x)

Regards
Petr


> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> project.org] On Behalf Of e-letter
> Sent: Thursday, March 07, 2013 8:28 AM
> To: r-help@r-project.org
> Subject: [R] create vector from indices interpolated values
> 
> Readers,
> 
> Is it possible to create a plot command based upon the indices of
> missing values in a data set?
> 
> dataset1<-read.table(text='
> 10 2
> 20 NA
> 30 5
> 40 7
> 50 NA
> 60 NA
> 70 2
> 80 6
> 90 NA
> 100 9
> ')
> 
> dataset2<-read.table(text='
> 0.2
> 0.4
> 0.1
> 0.9
> 0.2
> 0.3
> 1.1
> 0.7
> 0.9
> 0.6
> 0.4
> ')
> 
> The 'approx' function is used to obtain the interpolated values for
> 'NA' in dataset1.
> 
> dataset1interpolatedvalues<-
> approx(dataset1,y=NULL,xout=dataset1$V1[is.na(dataset1$V2)])
> 
> dataset1interpolatedvalues
> $x
> [1] 20 50 60 90
> 
> $y
> [1] 3.50 5.33 3.67 7.50
> 
> x<-dataset1interpolatedvalues$y
> 
> How to create a vector 'y' by selecting the values in 'dataset2' using
> the indices equivalent to interpolated values in 'dataset1' (i.e.
> indices 2, 5, 6, 9 in dataset1)? The result of creating 'y' should be
> 
> y
> 0.4
> 0.2
> 0.3
> 0.9
> 
> Then the desired plot would be
> 
> plot(y~x)
> 
> Thanks.
> 
> --
> r2151
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Automatically fix big jumps in one variable due to anomalies

2013-03-07 Thread PIKAL Petr
Hi

Not sure if it solves all possible misbehavior with sensor but
changing all jumps start to NA or 0, summing diferences and adding them to 
start can help you to polish your data

> x
 [1]   NA   NA  246  251  250  255 5987 5991 5994 5999
xd<-diff(x)
xd[xd>10]<-NA
xd[is.na(xd)]<-0
> cumsum(xd)
[1]  0  0  5  4  9  9 13 16 21
> 246+cumsum(xd)
[1] 246 246 251 250 255 255 259 262 267

Regards
Petr

> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> project.org] On Behalf Of Cesar Terrer
> Sent: Tuesday, March 05, 2013 12:13 AM
> To: r-help@r-project.org
> Subject: [R] Automatically fix big jumps in one variable due to
> anomalies
> 
> Hi,
> I am attaching a plot where you can see there are a few "jumps" (plots
> 1, 4,
> 5 and 6), due to incidents with the measuring sensors (basically
> someone touching the sensor). I need to revert those changes to have a
> plot without unreal measurements, so make those fragments go back to
> its original pattern before the jump.
> 
> I have used the function cpt.mean {changepoints} so I can identify the
> jumps and the mean of each segment. Now I don't know how to
> automatically revert the jumps, probably subtracting one higher
> fragment mean by the mean of the previous one. Does it make sense?
> 
> Example of data set
> 
> TIMESTAMP  variable   diameter
> 38  2012-06-21 13:45:00 r4_3   NA
> 86  2012-06-21 14:00:00 r4_3   NA
> 134 2012-06-21 14:15:00 r4_3   246
> 182 2012-06-21 14:30:00 r4_3   251
> 230 2012-06-21 14:45:00 r4_3   250
> 278 2012-06-21 15:00:00 r4_3   255
> 326 2012-06-21 15:15:00 r4_3   5987
> 374 2012-06-21 15:30:00 r4_3   5991
> 422 2012-06-21 15:45:00 r4_3   5994
> 470 2012-06-21 16:00:00 r4_3   5999
> 
> As an example, this is the current diameter data:
> NA-NA-246-251-250-255-5987-5991-5994-599
> 
> I would need this series without the big jump, avoiding the jump and
> following the increase/decrease pattern, for example:
> NA-NA-246-251-250-255-255-259-262-267
> 
> Any other idea is welcome.
> 
> 

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