Re: [R] Dimension of quantile function output

2016-01-22 Thread ruipbarradas
Hello,

Maybe something like the following.

temp2 <- cbind(temp[[3]][, 1], temp[[3]][, 2])
str(temp2)

Hope this helps,

Rui Barradas
 

Citando Jun Shen :

> Dear list,
>
> Say I have some quantile operation like this
>
> data.frame(ID=rep(1:10,each=10),CONC=runif(100)) -> test
>
> lapply(c('mean','sd','quantile'), function(x)
> aggregate(test['CONC'],by=test['ID'],FUN=x)) -> temp
>
> The output temp is a list of three elements. I would like to merge the
> three elements into one data frame. The first two elements (the mean and sd
> output) are easy to handle that I just need to update the column names. The
> problem is the third element. Although it looks like a data frame in
> dimension of 10 by 6 but really is just 10 by 2. How do I coerce the third
> element in 10 by 6? Thanks a lot.
>
> Jun
>  
>> head(temp[[3]])  ID     CONC.0%    CONC.25%    CONC.50%     
>> CONC.75%   CONC.100%
>
> 1  1 0.024352714 0.235039202 0.662819513 0.737295381 0.934520832
> 2  2 0.004732985 0.246812366 0.399628344 0.663579348 0.942850115
> 3  3 0.240309454 0.445094065 0.593619958 0.815292642 0.985080817
> 4  4 0.070251047 0.173052744 0.591731071 0.706560762 0.929560236
>
>         [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide  
> http://www.R-project.org/posting-guide.htmland provide commented,  
> minimal, self-contained, reproducible code.

 

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] aggregate and the $ operator

2016-01-22 Thread Ed Siefker
So that's how that works!  Thanks.

On Fri, Jan 22, 2016 at 1:32 PM, Joe Ceradini  wrote:
> Does this do what you want?
>
> aggregate(Nuclei ~ Slide, example, sum)
>
> On Fri, Jan 22, 2016 at 12:20 PM, Ed Siefker  wrote:
>>
>> Aggregate does the right thing with column names when passing it
>> numerical coordinates.
>> Given a dataframe like this:
>>
>>   Nuclei Positive Nuclei Slide
>> 1133  96A1
>> 2 96  70A1
>> 3 62  52A2
>> 4 60  50A2
>>
>> I can call 'aggregate' like this:
>>
>> > aggregate(example[1], by=example[3], sum)
>>   Slide Nuclei
>> 1A1229
>> 2A2122
>>
>> But that means I have to keep track of which column is which number.
>> If I try it the
>> easy way, it doesn't keep track of column names and it forces me to
>> coerce the 'by'
>> to a list.
>>
>> > aggregate(example$Nuclei, by=list(example$Slide), sum)
>>   Group.1   x
>> 1  A1 229
>> 2  A2 122
>>
>> Is there a better way to do this?  Thanks
>> -Ed
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>
>
>
>
> --
> Cooperative Fish and Wildlife Research Unit
> Zoology and Physiology Dept.
> University of Wyoming
> joecerad...@gmail.com / 914.707.8506
> wyocoopunit.org
>

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] tcltk table "validateCommand"

2016-01-22 Thread Dalthorp, Daniel
I'd like to allow users to edit data in tcltk tables and to use vcmd to
validate data entry, e.g., not allowing non-numbers to be entered in
numeric cells and not allowing '\n' to be entered in text cells.

The problem is that I can't figure out how to "see" their data entry before
it is entered, although it looks like %S can be somehow used in vcmd to get
this information.

Example: to disallow '\n' to be entered into a cell in an editable table:

require(tcltk2)
tt<-tktoplevel(); tfr<-tkframe(tt); tkgrid(tfr)
tableData<-tclArray()
tableData[[0,0]]<-"junk"

CellValidation<-function(){

## http://www.tcl.tk/community/hobbs/tcl/capp/tkTable/tkTable.html says:
## *%S* For *ValidateCommand*, it is the potential new value of the cell
being validated.
## which is exactly what I want, but I can't figure out how to do that.
## The following allows one bad character and then disallows further edits

  testval<-tclvalue(tcl(table1,"curvalue"))

  if (length(grep("\n",testval))>0)  return(tcl("expr", FALSE))  else
 return(tcl("expr", TRUE))
}

table1<<-tk2table(tfr,
  rows=1,cols=1,
  selectmode="extended",
  variable=tableData,
  validate=T,
  vcmd=CellValidation
)

tcl(table1,"tag","configure", "active", fg='black',bg=colors()[411])
tkgrid(table1)

How can I get the %S value rather than the tcl(table1,"curvalue")?

Much thanks for any help.

-Dan

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] aggregate and the $ operator

2016-01-22 Thread William Dunlap via R-help
Using column names where you used column numbers would work:

example <- data.frame(
check.names = FALSE,
Nuclei = c(133L, 96L, 62L, 60L),
`Positive Nuclei` = c(96L, 70L, 52L, 50L),
Slide = factor(c("A1", "A1", "A2", "A2"), levels = c("A1", "A2")))
aggregate(example["Nuclei"], by=example["Slide"], sum)
#  Slide Nuclei
#1A1229
#2A2122
aggregate(example[1], by=example[3], sum)
#  Slide Nuclei
#1A1229
#2A2122

Many people find that the functions in the dplyr or plyr packages
are worth the trouble to learn about.


Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Fri, Jan 22, 2016 at 11:20 AM, Ed Siefker  wrote:

> Aggregate does the right thing with column names when passing it
> numerical coordinates.
> Given a dataframe like this:
>
>   Nuclei Positive Nuclei Slide
> 1133  96A1
> 2 96  70A1
> 3 62  52A2
> 4 60  50A2
>
> I can call 'aggregate' like this:
>
> > aggregate(example[1], by=example[3], sum)
>   Slide Nuclei
> 1A1229
> 2A2122
>
> But that means I have to keep track of which column is which number.
> If I try it the
> easy way, it doesn't keep track of column names and it forces me to
> coerce the 'by'
> to a list.
>
> > aggregate(example$Nuclei, by=list(example$Slide), sum)
>   Group.1   x
> 1  A1 229
> 2  A2 122
>
> Is there a better way to do this?  Thanks
> -Ed
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Dimension of quantile function output

2016-01-22 Thread Jun Shen
Dear list,

Say I have some quantile operation like this

data.frame(ID=rep(1:10,each=10),CONC=runif(100)) -> test

lapply(c('mean','sd','quantile'), function(x)
aggregate(test['CONC'],by=test['ID'],FUN=x)) -> temp

The output temp is a list of three elements. I would like to merge the
three elements into one data frame. The first two elements (the mean and sd
output) are easy to handle that I just need to update the column names. The
problem is the third element. Although it looks like a data frame in
dimension of 10 by 6 but really is just 10 by 2. How do I coerce the third
element in 10 by 6? Thanks a lot.

Jun


> head(temp[[3]])  ID CONC.0%CONC.25%CONC.50%CONC.75%   
> CONC.100%
1  1 0.024352714 0.235039202 0.662819513 0.737295381 0.934520832
2  2 0.004732985 0.246812366 0.399628344 0.663579348 0.942850115
3  3 0.240309454 0.445094065 0.593619958 0.815292642 0.985080817
4  4 0.070251047 0.173052744 0.591731071 0.706560762 0.929560236

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] aggregate and the $ operator

2016-01-22 Thread Joe Ceradini
Does this do what you want?

aggregate(Nuclei ~ Slide, example, sum)

On Fri, Jan 22, 2016 at 12:20 PM, Ed Siefker  wrote:

> Aggregate does the right thing with column names when passing it
> numerical coordinates.
> Given a dataframe like this:
>
>   Nuclei Positive Nuclei Slide
> 1133  96A1
> 2 96  70A1
> 3 62  52A2
> 4 60  50A2
>
> I can call 'aggregate' like this:
>
> > aggregate(example[1], by=example[3], sum)
>   Slide Nuclei
> 1A1229
> 2A2122
>
> But that means I have to keep track of which column is which number.
> If I try it the
> easy way, it doesn't keep track of column names and it forces me to
> coerce the 'by'
> to a list.
>
> > aggregate(example$Nuclei, by=list(example$Slide), sum)
>   Group.1   x
> 1  A1 229
> 2  A2 122
>
> Is there a better way to do this?  Thanks
> -Ed
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Cooperative Fish and Wildlife Research Unit
Zoology and Physiology Dept.
University of Wyoming
joecerad...@gmail.com / 914.707.8506
wyocoopunit.org

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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 opening SHP file

2016-01-22 Thread David Winsemius

> On Jan 22, 2016, at 9:24 AM, Amoy Yang via R-help  
> wrote:
> 
> This is the results that addresses David's advice.
>> library(maptools)
>> library(maps)
>> state.map <- readShapeSpatial("maps/st24_d00.shp")
> Error in getinfo.shape(fn) : Error opening SHP file
>> # David question: What does list.files('maps') return? Is there a 
>> 'st24_d00.shp' value in there?
>> list.files('maps')
> character(0)
> I actually use the link below to learn how to load state/zip-data on USA map.

That link says:

"For example (assumes you have the maryland shapefiles in the map 
subdirectory):"

So it did not purport to tell you how to put shape files in that subdirectory. 
That statement assumed you understood basic OS path naming conventions in your 
unstated OS and how to move files around, which is not a topic for rhelp.

Try working through the examples in the documents that come with the 
`sp`-package.

-- 
David.
> 
> # 
> http://stackoverflow.com/questions/1441717/plotting-color-map-with-zip-codes-in-r-or-python
> Plotting color map with zip codes in R or Python
> |   |
> |   |  |   |   |   |   |   |
> | Plotting color map with zip codes in R or PythonI have some US demographic 
> and firmographic data. I would like to plot zipcode areas in a state or a 
> smaller region (e.g. city). Each area would be annotated by col... |
> |  |
> | View on stackoverflow.com | Preview by Yahoo |
> |  |
> |   |
> 
>On Friday, January 22, 2016 10:03 AM, Barry Rowlingson 
>  wrote:
> 
> 
> We can duplicate the error by giving a path to a non-existent
> shapefile, which is probably the original problem:
> 
>> require(maptools)
> Loading required package: maptools
> Loading required package: sp
> Checking rgeos availability: TRUE
>> foo=readShapeSpatial("fnord.shp")
> Error in getinfo.shape(fn) : Error opening SHP file
> 
> The error message there isn't totally explicit, and might cover a
> range of other possibilities such as a corrupted shapefile, or a
> missing .shx component of the shapefile or whatever.
> 
> BUT you probably shouldn't be using readShapeSpatial anyway, as it has
> a habit of not reading the coordinate system in the .prj file. I find
> it much easier to use `raster::shapefile` which *does* read the
> coordinate system *and* gives a more explicit error message for a
> missing shapefile:
> 
>> require(raster)
> Loading required package: raster
>> foo=shapefile("fnord.shp")
> Error in normalizePath(x, winslash = "/", mustWork = TRUE) :
>   path[1]="fnord.shp": No such file or directory
> 
> "No such file or directory"
> 
> Barry
> 
> 
> 
> On Fri, Jan 22, 2016 at 2:25 AM, boB Rudis  wrote:
>> Agreed with the others. After finding that shapefile and getting it to
>> work you are definitely not in the proper working directory.
>> 
>> On Thu, Jan 21, 2016 at 8:40 PM, David Winsemius  
>> wrote:
>>> 
 On Jan 21, 2016, at 4:39 PM, Amoy Yang via R-help  
 wrote:
 
 Any advice for the following errors?
 state.map <- readShapeSpatial("maps/st24_d00.shp")
 Error in getinfo.shape(fn) : Error opening SHP file
>>> 
>>> What does list.files('maps') return? Is there a 'st24_d00.shp' value in 
>>> there?
>>> 
>>> 
>>> --
>>> David.
>>> 
 
> 
> 
> 
>   [[alternative HTML version deleted]]
  ^^
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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 values from php or javascript

2016-01-22 Thread Jeff Newmiller
There are ways, but most likely you will not be satisfied with such a monster.  
Try the maptools package or the Analysis of Spatial Data Task View [1].

[1] https://cran.r-project.org/web/views/Spatial.html
-- 
Sent from my phone. Please excuse my brevity.

On January 22, 2016 1:18:45 AM PST, Alaios via R-help  
wrote:
>Dear all,I would like to execute some php or javascripts I found on the
>web.
>
>see at middle of this page towards bottom
>http://www.howtocreate.co.uk/php/gridref.php#samples
>
>Is there any way I can call the php function for example directly from
>R?
>I would like to thank you in advance for your replyRegardsAlex
>
>
>   [[alternative HTML version deleted]]
>
>__
>R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] aggregate and the $ operator

2016-01-22 Thread Ed Siefker
Aggregate does the right thing with column names when passing it
numerical coordinates.
Given a dataframe like this:

  Nuclei Positive Nuclei Slide
1133  96A1
2 96  70A1
3 62  52A2
4 60  50A2

I can call 'aggregate' like this:

> aggregate(example[1], by=example[3], sum)
  Slide Nuclei
1A1229
2A2122

But that means I have to keep track of which column is which number.
If I try it the
easy way, it doesn't keep track of column names and it forces me to
coerce the 'by'
to a list.

> aggregate(example$Nuclei, by=list(example$Slide), sum)
  Group.1   x
1  A1 229
2  A2 122

Is there a better way to do this?  Thanks
-Ed

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] aggregate and the $ operator

2016-01-22 Thread David Wolfskill
On Fri, Jan 22, 2016 at 01:20:59PM -0600, Ed Siefker wrote:
> Aggregate does the right thing with column names when passing it
> numerical coordinates.
> Given a dataframe like this:
> 
>   Nuclei Positive Nuclei Slide
> 1133  96A1
> 2 96  70A1
> 3 62  52A2
> 4 60  50A2
> 
> I can call 'aggregate' like this:
> 
> > aggregate(example[1], by=example[3], sum)
>   Slide Nuclei
> 1A1229
> 2A2122
> 
> But that means I have to keep track of which column is which number.
> If I try it the
> easy way, it doesn't keep track of column names and it forces me to
> coerce the 'by'
> to a list.
> 
> > aggregate(example$Nuclei, by=list(example$Slide), sum)
>   Group.1   x
> 1  A1 229
> 2  A2 122
> 
> Is there a better way to do this?  Thanks
> -Ed
> 

Something like:

> aggregate(Nuclei ~ Slide, example, sum)
  Slide Nuclei
1A1229
2A2122
> 

perhaps?

Peace,
david
-- 
David H. Wolfskill  r...@catwhisker.org
Those who would murder in the name of God or prophet are blasphemous cowards.

See http://www.catwhisker.org/~david/publickey.gpg for my public key.


signature.asc
Description: PGP signature
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Logical operator in R

2016-01-22 Thread li li
I see. Thanks!

2016-01-22 10:57 GMT-05:00 Rmh :

> FAQ 7.31
>
> in this case subtract the two numbers and see that
> they differ by about 1e-16
>
> Sent from my iPhone
>
> > On Jan 22, 2016, at 10:46, li li  wrote:
> >
> > Hi all,
> >  I encountered the following strange phenomenon.
> > For some reason, the obs_p[1] and res1$st_p[89] have
> > the same value but when I run "==", it returns FALSE.
> > Can anyone help give some explanation on this?
> >  Thanks very much!
> >Hanna
> >
> >> obs_p[1]
> > [1] 0.002201438
> >> res1$st_p[89]
> > [1] 0.002201438
> >> res1$st_p[89]==obs_p[1]
> > [1] FALSE
> >> res1$st_p[89] > [1] FALSE
> >> res1$st_p[89]>obs_p[1]
> > [1] TRUE
> >
> >[[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] tcltk tkwidget(..."table")

2016-01-22 Thread Dalthorp, Daniel
Thanks, Adrian...the discussions about  R bindings to Tcl and Tk look very
helpful!

-Dan

On Fri, Jan 22, 2016 at 2:49 AM, Adrian Waddell 
wrote:

> I have written some content about the R bindings to Tcl and Tk:
>
> http://waddella.github.io/loon/learn_R_tcltk.html
>
> And the pack geometry manager
>
> http://adrian.waddell.ch/EssentialSoftware/Rtcltk_geometry.pdf
>
> But if you have no experience with building graphical user interfaces then
> you might want to look into a book on Tk. "Effective TCL/TK programming" by
> Harrison and McLennan is a good one.
>
> Greetings,
>
> Adrian
> On Jan 21, 2016 10:36 PM, "Dalthorp, Daniel"  wrote:
>
>> >  Once you're up to speed on those issues...
>>
>> Any suggestions for getting up to speed on those issues?
>>
>>
>>
>> On Thu, Jan 21, 2016 at 11:46 AM, peter dalgaard 
>> wrote:
>>
>> >
>> > > On 21 Jan 2016, at 00:25 , Dalthorp, Daniel 
>> wrote:
>> > >
>> > > Thanks, Peter.
>> > >
>> > > I'm sure that's right, but it requires knowing: (1) that there's
>> > something called the "width subcommand", and (2) how to format the call
>> to
>> > that command/subcommand.
>> > >
>> >
>> > Yes, there's a fair amount of that going on with the tcltk interface.
>> You
>> > need to both grasp the rules for passing arguments to the underlying Tcl
>> > command, and know how to find and read the Tcl/Tk documentation. Once
>> > you're up to speed on those issues it's not all that hard to find stuff
>> in
>> > (for the present case), say,
>> > http://tktable.sourceforge.net/tktable/doc/tkTable.html
>> >
>> > The situation may be unfortunate, but the alternative is for "someone"
>> to
>> > sit down an convert all relevant Tcl/Tk documentation to R help files.
>> >
>> > -pd
>> >
>> >
>> > > I was able to do it eventually but only after a few hours of effort
>> > searching the web for help.
>> > >
>> > > E.g. with a table (called table1) with 3 columns and want to set
>> widths
>> > to 30, 5, and 5:
>> > >
>> > > colwidths<-c(30, 5, 5)
>> > >
>> > > for(i in 1:3) {
>> > >   tcl(table1, "width", i - 1, colwidths[i])
>> > > }
>> > >
>> > >
>> > >
>> > > On Wed, Jan 20, 2016 at 3:07 PM, peter dalgaard 
>> > wrote:
>> > >
>> > > > On 19 Jan 2016, at 20:48 , Dalthorp, Daniel 
>> > wrote:
>> > > >
>> > > > Does anyone know a simple way to create a tcltk table with columns
>> of
>> > > > varying widths?
>> > >
>> > > Create a table, then set the width of the columns with the width
>> > subcommand?
>> > >
>> > > -pd
>> > >
>> > >
>> > > pathName width ?col? ?value col value ...? If no col is specified,
>> > returns a list describing all cols for which a width has been set. If
>> col
>> > is specified with no value, it prints out the width of that col in
>> > characters (positive number) or pixels (negative number). If one or more
>> > col-value pairs are specified, then it sets each col to be that width in
>> > characters (positive number) or pixels (negative number). If value is
>> > default, then the col uses the default width, specified by -colwidth.
>> > >
>> > >
>> > >
>> > > >
>> > > > -Dan
>> > > >
>> > > >
>> > > >
>> > > > --
>> > > > Dan Dalthorp, PhD
>> > > > USGS Forest and Rangeland Ecosystem Science Center
>> > > > Forest Sciences Lab, Rm 189
>> > > > 3200 SW Jefferson Way
>> > > > Corvallis, OR 97331
>> > > > ph: 541-750-0953
>> > > > ddalth...@usgs.gov
>> > > >
>> > > >   [[alternative HTML version deleted]]
>> > > >
>> > > > __
>> > > > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> > > > https://stat.ethz.ch/mailman/listinfo/r-help
>> > > > PLEASE do read the posting guide
>> > http://www.R-project.org/posting-guide.html
>> > > > and provide commented, minimal, self-contained, reproducible code.
>> > >
>> > > --
>> > > Peter Dalgaard, Professor,
>> > > Center for Statistics, Copenhagen Business School
>> > > Solbjerg Plads 3, 2000 Frederiksberg, Denmark
>> > > Phone: (+45)38153501
>> > > Office: A 4.23
>> > > Email: pd@cbs.dk  Priv: pda...@gmail.com
>> > >
>> > >
>> > >
>> > >
>> > >
>> > >
>> > >
>> > >
>> > >
>> > >
>> > >
>> > >
>> > > --
>> > > Dan Dalthorp, PhD
>> > > USGS Forest and Rangeland Ecosystem Science Center
>> > > Forest Sciences Lab, Rm 189
>> > > 3200 SW Jefferson Way
>> > > Corvallis, OR 97331
>> > > ph: 541-750-0953
>> > > ddalth...@usgs.gov
>> > >
>> >
>> > --
>> > Peter Dalgaard, Professor,
>> > Center for Statistics, Copenhagen Business School
>> > Solbjerg Plads 3, 2000 Frederiksberg, Denmark
>> > Phone: (+45)38153501
>> > Office: A 4.23
>> > Email: pd@cbs.dk  Priv: pda...@gmail.com
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>>
>>
>> --
>> Dan Dalthorp, PhD
>> USGS Forest and Rangeland Ecosystem Science Center
>> Forest Sciences Lab, Rm 189
>> 3200 SW Jefferson Way
>> Corvallis, OR 97331
>> ph: 541-750-0953
>> ddalth...@usgs.gov
>>
>> 

Re: [R] tcltk tkwidget(..."table")

2016-01-22 Thread peter dalgaard
Good pointers, although R bindings document is not quite getting into the 
really messy bits. 

I think Daniel may be at a point where he needs to study the code snippets that 
he has got to work and figure out why and how they work. The help(TclInterface) 
page is the most definitive documentation for this, although it is admittedly 
rather dense (in both senses). E.g., it is hardly obvious that it is the 
distinction between string objects and lists of length one that decides whether 
Tcl displays stuff in braces (That particular point is something that I 
probably could patch up when/if I get a spare moment.)

-pd


> On 22 Jan 2016, at 11:49 , Adrian Waddell  wrote:
> 
> I have written some content about the R bindings to Tcl and Tk:
> 
> http://waddella.github.io/loon/learn_R_tcltk.html
> 
> And the pack geometry manager
> 
> http://adrian.waddell.ch/EssentialSoftware/Rtcltk_geometry.pdf
> 
> But if you have no experience with building graphical user interfaces then 
> you might want to look into a book on Tk. "Effective TCL/TK programming" by 
> Harrison and McLennan is a good one.
> 
> Greetings,
> 
> Adrian
> 
> On Jan 21, 2016 10:36 PM, "Dalthorp, Daniel"  wrote:
> >  Once you're up to speed on those issues...
> 
> Any suggestions for getting up to speed on those issues?
> 
> 
> 
> On Thu, Jan 21, 2016 at 11:46 AM, peter dalgaard  wrote:
> 
> >
> > > On 21 Jan 2016, at 00:25 , Dalthorp, Daniel  wrote:
> > >
> > > Thanks, Peter.
> > >
> > > I'm sure that's right, but it requires knowing: (1) that there's
> > something called the "width subcommand", and (2) how to format the call to
> > that command/subcommand.
> > >
> >
> > Yes, there's a fair amount of that going on with the tcltk interface. You
> > need to both grasp the rules for passing arguments to the underlying Tcl
> > command, and know how to find and read the Tcl/Tk documentation. Once
> > you're up to speed on those issues it's not all that hard to find stuff in
> > (for the present case), say,
> > http://tktable.sourceforge.net/tktable/doc/tkTable.html
> >
> > The situation may be unfortunate, but the alternative is for "someone" to
> > sit down an convert all relevant Tcl/Tk documentation to R help files.
> >
> > -pd
> >
> >
> > > I was able to do it eventually but only after a few hours of effort
> > searching the web for help.
> > >
> > > E.g. with a table (called table1) with 3 columns and want to set widths
> > to 30, 5, and 5:
> > >
> > > colwidths<-c(30, 5, 5)
> > >
> > > for(i in 1:3) {
> > >   tcl(table1, "width", i - 1, colwidths[i])
> > > }
> > >
> > >
> > >
> > > On Wed, Jan 20, 2016 at 3:07 PM, peter dalgaard 
> > wrote:
> > >
> > > > On 19 Jan 2016, at 20:48 , Dalthorp, Daniel 
> > wrote:
> > > >
> > > > Does anyone know a simple way to create a tcltk table with columns of
> > > > varying widths?
> > >
> > > Create a table, then set the width of the columns with the width
> > subcommand?
> > >
> > > -pd
> > >
> > >
> > > pathName width ?col? ?value col value ...? If no col is specified,
> > returns a list describing all cols for which a width has been set. If col
> > is specified with no value, it prints out the width of that col in
> > characters (positive number) or pixels (negative number). If one or more
> > col-value pairs are specified, then it sets each col to be that width in
> > characters (positive number) or pixels (negative number). If value is
> > default, then the col uses the default width, specified by -colwidth.
> > >
> > >
> > >
> > > >
> > > > -Dan
> > > >
> > > >
> > > >
> > > > --
> > > > Dan Dalthorp, PhD
> > > > USGS Forest and Rangeland Ecosystem Science Center
> > > > Forest Sciences Lab, Rm 189
> > > > 3200 SW Jefferson Way
> > > > Corvallis, OR 97331
> > > > ph: 541-750-0953
> > > > ddalth...@usgs.gov
> > > >
> > > >   [[alternative HTML version deleted]]
> > > >
> > > > __
> > > > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > > > https://stat.ethz.ch/mailman/listinfo/r-help
> > > > PLEASE do read the posting guide
> > http://www.R-project.org/posting-guide.html
> > > > and provide commented, minimal, self-contained, reproducible code.
> > >
> > > --
> > > Peter Dalgaard, Professor,
> > > Center for Statistics, Copenhagen Business School
> > > Solbjerg Plads 3, 2000 Frederiksberg, Denmark
> > > Phone: (+45)38153501
> > > Office: A 4.23
> > > Email: pd@cbs.dk  Priv: pda...@gmail.com
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > --
> > > Dan Dalthorp, PhD
> > > USGS Forest and Rangeland Ecosystem Science Center
> > > Forest Sciences Lab, Rm 189
> > > 3200 SW Jefferson Way
> > > Corvallis, OR 97331
> > > ph: 541-750-0953
> > > ddalth...@usgs.gov
> > >
> >
> > --
> > Peter Dalgaard, Professor,
> > Center for Statistics, Copenhagen Business School
> > Solbjerg Plads 3, 

[R] getting values from php or javascript

2016-01-22 Thread Alaios via R-help
Dear all,I would like to execute some php or javascripts I found on the web.

see at middle of this page towards bottom
http://www.howtocreate.co.uk/php/gridref.php#samples

Is there any way I can call the php function for example directly from R?
I would like to thank you in advance for your replyRegardsAlex


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] calculating functional complimentarity

2016-01-22 Thread pushan chakraborty
hi group

How 'functional complimentarity' of a bipartite network can be calculated
using the package 'bipartite'
-- 
Pushan Chakraborty
CSIR - SRF

Center for Pollination Studies, University of Calcutta
35, Ballyguanje Circular Road, Kolkata - 700019
  &
Wildlife Institute of India
Chandrabani, Dehradun - 248001

webpage:

http://cpscu.in/?page_id=51

Skype: cpushan

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Lists heading in an array of lists in R

2016-01-22 Thread Dénes Tóth

Hi,

Provide a list of a list in the second assignment:

--
TunePar <- matrix(list(NULL), 2, 2)
TunePar[2,1] <- list(list(G = 2))
TunePar[2,1]
TunePar[2,1][[1]]$G
TunePar[[2]]$G
---

The point is that "[" returns the list element of the same level as the 
original object (TunePar in the present example). So in the assignment 
if you extracted one element on the LHS, it expects a one-element vector 
on the RHS, e.g., check this out:

---
# this throws an error
TunePar[1,2] <- list(H = 1:3, I = letters[1:2])

# this is fine
TunePar[1,2] <- list(list(H = 1:3, I = letters[1:2]))
TunePar[1,2]
TunePar[1,2][[1]]$I
---

HTH,
 Denes



On 01/22/2016 08:29 AM, TJUN KIAT TEO wrote:

TunePar<-matrix(list(Null),2,2)

TunePar[1,1]=list(G=2)


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


Re: [R] use gcheckbox in gWidgets to switch on/off gframe

2016-01-22 Thread Rolf Fankhauser

Hi Tonja

Maybe I wasn't clear in my last post. This is the code:

library(gWidgetstcltk)
library(gWidgets)
options(guiToolkit="tcltk")
Population <- c("A","B","C","D","E","F")
w = gwindow("")
g1 = ggroup(horizontal = F, cont=w)
g2 = ggroup(horizontal = T, cont=g1)
glabel("Population:", cont=g2)
Station = gcombobox(Population, editable=F, cont=g2, handler=NULL)
gseparator(horizontal=T, container=g1, expand=F)
gcheckbox("checked", checked=T, container=g1, handler=function(h,...) {
enabled ( frame1 ) <- svalue(h$obj)
})
frame1 <- gframe ( "A:" , cont = g1 , horizontal=FALSE )
lyt1 <- glayout ( cont = frame1)
widget_list <- list ( )
lyt1 [1,1] <- "A1:"
lyt1 [1,2,expand = TRUE] <- (widget_list$A1 <- gedit(" ", cont=lyt1, 
handler=NULL))

lyt1 [2,1] <- "A2:"
lyt1 [2,2,expand = TRUE] <- (widget_list$A2 <- gedit(" ", cont=lyt1, 
handler=NULL))

gcheckbox("checked", checked=T, container=g1, handler=function(h,...) {
enabled ( frame2 ) <-  svalue(h$obj)
})
frame2 <- gframe ( "B:" , cont = g1 , horizontal=FALSE )
lyt2 <- glayout ( cont = frame2)
widget_list <- list ( )
lyt2 [1,1] <- "B1:"
lyt2 [1,2, expand = TRUE] <- (widget_list$B1 <- gedit(" ", cont=lyt2, 
handler=NULL))


Regards, Rolf

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] tcltk tkwidget(..."table")

2016-01-22 Thread Adrian Waddell
I have written some content about the R bindings to Tcl and Tk:

http://waddella.github.io/loon/learn_R_tcltk.html

And the pack geometry manager

http://adrian.waddell.ch/EssentialSoftware/Rtcltk_geometry.pdf

But if you have no experience with building graphical user interfaces then
you might want to look into a book on Tk. "Effective TCL/TK programming" by
Harrison and McLennan is a good one.

Greetings,

Adrian
On Jan 21, 2016 10:36 PM, "Dalthorp, Daniel"  wrote:

> >  Once you're up to speed on those issues...
>
> Any suggestions for getting up to speed on those issues?
>
>
>
> On Thu, Jan 21, 2016 at 11:46 AM, peter dalgaard  wrote:
>
> >
> > > On 21 Jan 2016, at 00:25 , Dalthorp, Daniel 
> wrote:
> > >
> > > Thanks, Peter.
> > >
> > > I'm sure that's right, but it requires knowing: (1) that there's
> > something called the "width subcommand", and (2) how to format the call
> to
> > that command/subcommand.
> > >
> >
> > Yes, there's a fair amount of that going on with the tcltk interface. You
> > need to both grasp the rules for passing arguments to the underlying Tcl
> > command, and know how to find and read the Tcl/Tk documentation. Once
> > you're up to speed on those issues it's not all that hard to find stuff
> in
> > (for the present case), say,
> > http://tktable.sourceforge.net/tktable/doc/tkTable.html
> >
> > The situation may be unfortunate, but the alternative is for "someone" to
> > sit down an convert all relevant Tcl/Tk documentation to R help files.
> >
> > -pd
> >
> >
> > > I was able to do it eventually but only after a few hours of effort
> > searching the web for help.
> > >
> > > E.g. with a table (called table1) with 3 columns and want to set widths
> > to 30, 5, and 5:
> > >
> > > colwidths<-c(30, 5, 5)
> > >
> > > for(i in 1:3) {
> > >   tcl(table1, "width", i - 1, colwidths[i])
> > > }
> > >
> > >
> > >
> > > On Wed, Jan 20, 2016 at 3:07 PM, peter dalgaard 
> > wrote:
> > >
> > > > On 19 Jan 2016, at 20:48 , Dalthorp, Daniel 
> > wrote:
> > > >
> > > > Does anyone know a simple way to create a tcltk table with columns of
> > > > varying widths?
> > >
> > > Create a table, then set the width of the columns with the width
> > subcommand?
> > >
> > > -pd
> > >
> > >
> > > pathName width ?col? ?value col value ...? If no col is specified,
> > returns a list describing all cols for which a width has been set. If col
> > is specified with no value, it prints out the width of that col in
> > characters (positive number) or pixels (negative number). If one or more
> > col-value pairs are specified, then it sets each col to be that width in
> > characters (positive number) or pixels (negative number). If value is
> > default, then the col uses the default width, specified by -colwidth.
> > >
> > >
> > >
> > > >
> > > > -Dan
> > > >
> > > >
> > > >
> > > > --
> > > > Dan Dalthorp, PhD
> > > > USGS Forest and Rangeland Ecosystem Science Center
> > > > Forest Sciences Lab, Rm 189
> > > > 3200 SW Jefferson Way
> > > > Corvallis, OR 97331
> > > > ph: 541-750-0953
> > > > ddalth...@usgs.gov
> > > >
> > > >   [[alternative HTML version deleted]]
> > > >
> > > > __
> > > > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > > > https://stat.ethz.ch/mailman/listinfo/r-help
> > > > PLEASE do read the posting guide
> > http://www.R-project.org/posting-guide.html
> > > > and provide commented, minimal, self-contained, reproducible code.
> > >
> > > --
> > > Peter Dalgaard, Professor,
> > > Center for Statistics, Copenhagen Business School
> > > Solbjerg Plads 3, 2000 Frederiksberg, Denmark
> > > Phone: (+45)38153501
> > > Office: A 4.23
> > > Email: pd@cbs.dk  Priv: pda...@gmail.com
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > --
> > > Dan Dalthorp, PhD
> > > USGS Forest and Rangeland Ecosystem Science Center
> > > Forest Sciences Lab, Rm 189
> > > 3200 SW Jefferson Way
> > > Corvallis, OR 97331
> > > ph: 541-750-0953
> > > ddalth...@usgs.gov
> > >
> >
> > --
> > Peter Dalgaard, Professor,
> > Center for Statistics, Copenhagen Business School
> > Solbjerg Plads 3, 2000 Frederiksberg, Denmark
> > Phone: (+45)38153501
> > Office: A 4.23
> > Email: pd@cbs.dk  Priv: pda...@gmail.com
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
>
>
> --
> Dan Dalthorp, PhD
> USGS Forest and Rangeland Ecosystem Science Center
> Forest Sciences Lab, Rm 189
> 3200 SW Jefferson Way
> Corvallis, OR 97331
> ph: 541-750-0953
> ddalth...@usgs.gov
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/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 

Re: [R] Error opening SHP file

2016-01-22 Thread Amoy Yang via R-help
Let me just make this case simple and quick to address what I need.
Giving a data-file that includes tow columns: zip5 and population. How do I put 
pop (colored with different segments) by zips (with boundary) on the USA map 
with R?
Amoy 

On Friday, January 22, 2016 12:45 PM, David Winsemius 
 wrote:
 

 
> On Jan 22, 2016, at 9:24 AM, Amoy Yang via R-help  
> wrote:
> 
> This is the results that addresses David's advice.
>> library(maptools)
>> library(maps)
>> state.map <- readShapeSpatial("maps/st24_d00.shp")
> Error in getinfo.shape(fn) : Error opening SHP file
>> # David question: What does list.files('maps') return? Is there a 
>> 'st24_d00.shp' value in there?
>> list.files('maps')
> character(0)
> I actually use the link below to learn how to load state/zip-data on USA map.

That link says:

"For example (assumes you have the maryland shapefiles in the map 
subdirectory):"

So it did not purport to tell you how to put shape files in that subdirectory. 
That statement assumed you understood basic OS path naming conventions in your 
unstated OS and how to move files around, which is not a topic for rhelp.

Try working through the examples in the documents that come with the 
`sp`-package.

-- 
David.
> 
> # 
> http://stackoverflow.com/questions/1441717/plotting-color-map-with-zip-codes-in-r-or-python
> Plotting color map with zip codes in R or Python
> |  |
> |  |  |  |  |  |  |  |
> | Plotting color map with zip codes in R or PythonI have some US demographic 
> and firmographic data. I would like to plot zipcode areas in a state or a 
> smaller region (e.g. city). Each area would be annotated by col... |
> |  |
> | View on stackoverflow.com | Preview by Yahoo |
> |  |
> |  |
> 
>    On Friday, January 22, 2016 10:03 AM, Barry Rowlingson 
> wrote:
> 
> 
> We can duplicate the error by giving a path to a non-existent
> shapefile, which is probably the original problem:
> 
>> require(maptools)
> Loading required package: maptools
> Loading required package: sp
> Checking rgeos availability: TRUE
>> foo=readShapeSpatial("fnord.shp")
> Error in getinfo.shape(fn) : Error opening SHP file
> 
> The error message there isn't totally explicit, and might cover a
> range of other possibilities such as a corrupted shapefile, or a
> missing .shx component of the shapefile or whatever.
> 
> BUT you probably shouldn't be using readShapeSpatial anyway, as it has
> a habit of not reading the coordinate system in the .prj file. I find
> it much easier to use `raster::shapefile` which *does* read the
> coordinate system *and* gives a more explicit error message for a
> missing shapefile:
> 
>> require(raster)
> Loading required package: raster
>> foo=shapefile("fnord.shp")
> Error in normalizePath(x, winslash = "/", mustWork = TRUE) :
>  path[1]="fnord.shp": No such file or directory
> 
> "No such file or directory"
> 
> Barry
> 
> 
> 
> On Fri, Jan 22, 2016 at 2:25 AM, boB Rudis  wrote:
>> Agreed with the others. After finding that shapefile and getting it to
>> work you are definitely not in the proper working directory.
>> 
>> On Thu, Jan 21, 2016 at 8:40 PM, David Winsemius  
>> wrote:
>>> 
 On Jan 21, 2016, at 4:39 PM, Amoy Yang via R-help  
 wrote:
 
 Any advice for the following errors?
 state.map <- readShapeSpatial("maps/st24_d00.shp")
 Error in getinfo.shape(fn) : Error opening SHP file
>>> 
>>> What does list.files('maps') return? Is there a 'st24_d00.shp' value in 
>>> there?
>>> 
>>> 
>>> --
>>> David.
>>> 
 
> 
> 
> 
>     [[alternative HTML version deleted]]
      ^^
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/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


  
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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 opening SHP file

2016-01-22 Thread boB Rudis
Look at the choroplethr package.

On Fri, Jan 22, 2016 at 5:31 PM, Amoy Yang  wrote:
> Let me just make this case simple and quick to address what I need.
>
> Giving a data-file that includes tow columns: zip5 and population. How do I
> put pop (colored with different segments) by zips (with boundary) on the USA
> map with R?
>
> Amoy
>
>
> On Friday, January 22, 2016 12:45 PM, David Winsemius
>  wrote:
>
>
>
>> On Jan 22, 2016, at 9:24 AM, Amoy Yang via R-help 
>> wrote:
>>
>> This is the results that addresses David's advice.
>>> library(maptools)
>>> library(maps)
>>> state.map <- readShapeSpatial("maps/st24_d00.shp")
>> Error in getinfo.shape(fn) : Error opening SHP file
>>> # David question: What does list.files('maps') return? Is there a
>>> 'st24_d00.shp' value in there?
>>> list.files('maps')
>> character(0)
>> I actually use the link below to learn how to load state/zip-data on USA
>> map.
>
> That link says:
>
> "For example (assumes you have the maryland shapefiles in the map
> subdirectory):"
>
> So it did not purport to tell you how to put shape files in that
> subdirectory. That statement assumed you understood basic OS path naming
> conventions in your unstated OS and how to move files around, which is not a
> topic for rhelp.
>
> Try working through the examples in the documents that come with the
> `sp`-package.
>
>
> --
> David.
>>
>> #
>> http://stackoverflow.com/questions/1441717/plotting-color-map-with-zip-codes-in-r-or-python
>> Plotting color map with zip codes in R or Python
>> |  |
>> |  |  |  |  |  |  |  |
>> | Plotting color map with zip codes in R or PythonI have some US
>> demographic and firmographic data. I would like to plot zipcode areas in a
>> state or a smaller region (e.g. city). Each area would be annotated by
>> col... |
>> |  |
>> | View on stackoverflow.com | Preview by Yahoo |
>> |  |
>> |  |
>>
>>On Friday, January 22, 2016 10:03 AM, Barry Rowlingson
>>  wrote:
>>
>>
>> We can duplicate the error by giving a path to a non-existent
>> shapefile, which is probably the original problem:
>>
>>> require(maptools)
>> Loading required package: maptools
>> Loading required package: sp
>> Checking rgeos availability: TRUE
>>> foo=readShapeSpatial("fnord.shp")
>> Error in getinfo.shape(fn) : Error opening SHP file
>>
>> The error message there isn't totally explicit, and might cover a
>> range of other possibilities such as a corrupted shapefile, or a
>> missing .shx component of the shapefile or whatever.
>>
>> BUT you probably shouldn't be using readShapeSpatial anyway, as it has
>> a habit of not reading the coordinate system in the .prj file. I find
>> it much easier to use `raster::shapefile` which *does* read the
>> coordinate system *and* gives a more explicit error message for a
>> missing shapefile:
>>
>>> require(raster)
>> Loading required package: raster
>>> foo=shapefile("fnord.shp")
>> Error in normalizePath(x, winslash = "/", mustWork = TRUE) :
>>  path[1]="fnord.shp": No such file or directory
>>
>> "No such file or directory"
>>
>> Barry
>>
>>
>>
>> On Fri, Jan 22, 2016 at 2:25 AM, boB Rudis  wrote:
>>> Agreed with the others. After finding that shapefile and getting it to
>>> work you are definitely not in the proper working directory.
>>>
>>> On Thu, Jan 21, 2016 at 8:40 PM, David Winsemius 
>>> wrote:

> On Jan 21, 2016, at 4:39 PM, Amoy Yang via R-help
>  wrote:
>
> Any advice for the following errors?
> state.map <- readShapeSpatial("maps/st24_d00.shp")
> Error in getinfo.shape(fn) : Error opening SHP file

 What does list.files('maps') return? Is there a 'st24_d00.shp' value in
 there?


 --
 David.

>
>>
>>
>>
>> [[alternative HTML version deleted]]
>   ^^
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Lists heading in an array of lists in R

2016-01-22 Thread Duncan Murdoch

On 22/01/2016 2:29 AM, TJUN KIAT TEO wrote:

I am trying to populate an array of lists in R . Here is my code

TunePar<-matrix(list(Null),2,2)

TunePar[1,1]=list(G=2)

But when I type TunePar[1,1,], all I get is 2. The G has disappeared. why?

If I do this

Test=list(G=2)

Test

$G
[1] 2



Matrices generally don't keep the names of elements assigned to them. 
What you did is similar to


x <- matrix(0, 2,2)
x[1,1] <- c(G=2)
x

which loses the name.

Working with lists is different, because you need to distinguish between 
subsets and elements.  So you'd get what you want by assigning your list 
to the element using


TunePar[[1,1]] <- list(G=2)

At this point, TunePar[1,1] is a list containing list(G=2): it prints as

[[1]]
[[1]]$G
[1] 1


To get the result you want, you also need to access the element instead 
of the subset:  TunePar[[1,1]] will print


$G
[1] 1

Duncan Murdoch

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Sorting a Data Frame

2016-01-22 Thread Robert Sherry

In R, I run the following commands:
df = data.frame( x=runif(10), y=runif(10) )
df2 = df[order(x),]

The first, as I would expect, creates a data frame with two columns and 
10 rows. I expect the second to sort the data based upon
the columns x and produce a new data frame, df2, with the same size as 
df. However, the data frame is produces is much larger.
I do not understand what is going on. I am hoping somebody can help me. 
I am also wondering if I should have a comma after
order(x) in the second statement. I do not see a purpose for it but it 
was in an example on the web.


Thanks
Bob

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Constrained Poisson model / Bayesian Poisson model

2016-01-22 Thread mara . pfleiderer

Hi all,

I am dealing with a problem about my linear Poisson regression model  
(link function=identity).


I am using the glm()-function which results in negative coefficients,  
but a negative influence of the regressors wouldn't make sense.


(i) Is there a possibility to set constraints on the regression  
parameters in glm() such that all coefficients are positive? Or is  
there another function in R for which this is possible?


(ii) Is there a Bayesian version of the glm()-function where I can  
specify the prior distribution for my regression parameters? (e.g. a  
Dirichlet prior s.t. the parameters are positive)


All this with respect to the linear Poisson model...

Thanks in advance!
Best,
Mara

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Shift all values above certain value by 1

2016-01-22 Thread Dimitri Liakhovitski
I think I got it:

set.seed(123)
x <- data.frame(a = 1:10, b = 2:11, c = 3:12, other = rnorm(10))
x
temp <- as.matrix(x[1:3])
temp[temp %in% 7] <- 4
temp[temp > 7] <- temp[temp > 7]-1
x[1:3] <- temp
x

It works only with matrices, right? Can't do x[x>7] when x is a data frame?
Thanks!

On Fri, Jan 22, 2016 at 11:34 AM, Dimitri Liakhovitski
 wrote:
> Hello!
>
> # I have a data frame x:
> x <- data.frame(a = 1:10, b = 2:11, c = 3:12, other = rnorm(10))
>
> # First, I need to change every value 7 in columns a:c to 4
> # Then, I need to decrease by 1 all values in columns a:c that are >7
>
> What would be the fastest way of doing it?
> Thank you!
>
> --
> Dimitri Liakhovitski



-- 
Dimitri Liakhovitski

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Updating a Time Series After Forecast()

2016-01-22 Thread Paul Gilbert

Lorenzo

Berend's suggestion may be the simplest if you have univariate ts style 
series. If you are writing code and you want it to work with 
multivariate series and other time representations then you might want 
to consider the splice() function in package tframe.

  library(tfplot)
  ts3 <- splice(ts2, pred2$mean)

(and tframePlus if you need zoo and other support.)

Regards,
Paul

On 01/16/2016 06:00 AM, r-help-requ...@r-project.org wrote:

Date: Fri, 15 Jan 2016 13:02:58 +0100
From: Berend Hasselman
To: Lorenzo Isella
Cc:"r-help@r-project.org"  
Subject: Re: [R] Updating a Time Series After Forecast()
Message-ID:
Content-Type: text/plain; charset=us-ascii



>On 14 Jan 2016, at 22:36, Lorenzo Isella  wrote:
>
>Dear All,
>Perhaps I am drowning in a cup of water, since I am positive that the
>answer will be a one-liner.
>Consider the following short script
>
>
>
>library(forecast)
>
>ts2<-structure(c(339130, 356462, 363234, 378179, 367864, 378337, 392157,
>402153, 376361, 392204, 403483, 414034, 391967, 406067, 419464,
>434913, 410102, 424795, 437073, 448827, 415569, 430561, 444719,
>455764, 419892, 444190, 454648, 466312, 439922, 448963, 465153,
>475621, 445502, 457198, 473573, 485764, 463895, 470274, 484390,
>490678, 478003, 483570, 499141, 509216, 481395, 492345, 511184,
>513420, 483757, 490884, 514966, 515457, 497614, 510139, 523467,
>526406, 499784, 519033, 532009, 531260, 521539, 532590, 553118,
>557725, 548321, 556832, 578087, 578120, 566116, 580571, 587993,
>569985, 534326, 539641, 564824, 568445, 558614, 570192, 594584,
>598305, 593769, 598278, 620147, 615884, 611033, 609304, 630458,
>624325, 614356, 627192, 649324, 645988, 642965, 645125, 669471,
>665529, 664248, 669670, 694719), na.action = structure(1:64, class =
>"omit"), .Tsp = c(1991,
>2015.5, 4), class = "ts")
>
>fit2 <- auto.arima(ts2, approximation=FALSE,trace=FALSE)
>
>pred2 <- forecast(fit2, h=2)
>
>###
>
>So, I have an original quarterly time series ts2 and a forecast for 2
>quarters pred2.
>
>I would like to combine ts2 and pred2 (just the prediction) into a new
>time series (in other words, just stretch a bit ts2).
>How can I do that?

A possible way is this

ts3 <- ts(c(ts2,pred2$mean),start=start(ts2),frequency=frequency(ts2))

Most  likely there are more ways of getting what you want.

Berend


>Many thanks
>
>Lorenzo
>


__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Logical operator in R

2016-01-22 Thread Rick Bilonick

On 01/22/2016 10:46 AM, li li wrote:

Hi all,
   I encountered the following strange phenomenon.
For some reason, the obs_p[1] and res1$st_p[89] have
the same value but when I run "==", it returns FALSE.
Can anyone help give some explanation on this?
   Thanks very much!
 Hanna


obs_p[1]

[1] 0.002201438

res1$st_p[89]

[1] 0.002201438

res1$st_p[89]==obs_p[1]

[1] FALSE

res1$st_p[89]obs_p[1]

[1] TRUE

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
I believe the decimal representation is only approximate. The real 
internal values in binary are different. If you want to have comparisons 
like this result in being considered equal, I think there is a way to 
use a fuzzy comparison but I don't remember the details.


Rick

--
Richard A. Bilonick, PhD
Assistant Professor
Dept. of Ophthalmology, School of Medicine
Dept. of Biostatistics, Graduate School of Public Health
Dept. of Orthodontics, School of Dental Medicine
University of Pittsburgh
Principal Investigator for the Pittsburgh Aerosol Research
 and Inhalation Epidemiology Study (PARIES)
412 647 5756

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] pgmm error message, Error in terms.default(formula) : no terms component nor attribute

2016-01-22 Thread Xin Shi
Dear

I try to use pgmm to estimate dynamic model for panel data. I got the message 
below. It is appreciate that you could help on this. 
data<-read.csv("G:/MMU/Research/Urbanlisation/paneldata.csv",sep=",", 
header=TRUE) library(plm) library(Formula) urban<-pdata.frame(data, 
index=c("id","year_begin")) y<-urban[,7] x1<-urban[,8] x2<-urban[,9] 
x3<-urban[,10] x4<-urban[,11] 
z1<-pgmm(formula=y~lag(y,0:1)+x2+x3+x4,data=urban, effect = "twoways", model = 
"twosteps") Error in terms.default(formula) : no terms component nor attribute

Xin
---
Dr.Xin Shi
Reader in Applied Statistics
Director of DBA Programme
Room 609
Department of Marketing, Operations and Digital Business
Business School
All Saints Campus
Manchester Metropolitan University
Oxford Road
Manchester
M15 6BH
United Kingdom
E-mail: x@mmu.ac.uk
Telephone: +44 (0)161 247 3841
Fax: +44(0)161 247 6305
Office Hours: Wed 1-3pm.
http://www.business.mmu.ac.uk/staff/staffdetails.php?uref=423
http://www.mmu.ac.uk/dba

"Before acting on this email or opening any attachments you should read the 
Manchester Metropolitan University email disclaimer available on its website 
http://www.mmu.ac.uk/emaildisclaimer "

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Logical operator in R

2016-01-22 Thread Bert Gunter
FAQ 7.31

-- Bert


Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Fri, Jan 22, 2016 at 7:46 AM, li li  wrote:
> Hi all,
>   I encountered the following strange phenomenon.
> For some reason, the obs_p[1] and res1$st_p[89] have
> the same value but when I run "==", it returns FALSE.
> Can anyone help give some explanation on this?
>   Thanks very much!
> Hanna
>
>> obs_p[1]
> [1] 0.002201438
>> res1$st_p[89]
> [1] 0.002201438
>> res1$st_p[89]==obs_p[1]
> [1] FALSE
>> res1$st_p[89] [1] FALSE
>> res1$st_p[89]>obs_p[1]
> [1] TRUE
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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 opening SHP file

2016-01-22 Thread Barry Rowlingson
We can duplicate the error by giving a path to a non-existent
shapefile, which is probably the original problem:

 > require(maptools)
Loading required package: maptools
Loading required package: sp
Checking rgeos availability: TRUE
 > foo=readShapeSpatial("fnord.shp")
Error in getinfo.shape(fn) : Error opening SHP file

The error message there isn't totally explicit, and might cover a
range of other possibilities such as a corrupted shapefile, or a
missing .shx component of the shapefile or whatever.

BUT you probably shouldn't be using readShapeSpatial anyway, as it has
a habit of not reading the coordinate system in the .prj file. I find
it much easier to use `raster::shapefile` which *does* read the
coordinate system *and* gives a more explicit error message for a
missing shapefile:

 > require(raster)
Loading required package: raster
 > foo=shapefile("fnord.shp")
Error in normalizePath(x, winslash = "/", mustWork = TRUE) :
  path[1]="fnord.shp": No such file or directory

"No such file or directory"

Barry



On Fri, Jan 22, 2016 at 2:25 AM, boB Rudis  wrote:
> Agreed with the others. After finding that shapefile and getting it to
> work you are definitely not in the proper working directory.
>
> On Thu, Jan 21, 2016 at 8:40 PM, David Winsemius  
> wrote:
>>
>>> On Jan 21, 2016, at 4:39 PM, Amoy Yang via R-help  
>>> wrote:
>>>
>>> Any advice for the following errors?
>>> state.map <- readShapeSpatial("maps/st24_d00.shp")
>>> Error in getinfo.shape(fn) : Error opening SHP file
>>
>> What does list.files('maps') return? Is there a 'st24_d00.shp' value in 
>> there?
>>
>>
>> --
>> David.
>>
>>>
>>>   [[alternative HTML version deleted]]
>>>
>>> __
>>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>>> https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Logical operator in R

2016-01-22 Thread li li
Hi all,
  I encountered the following strange phenomenon.
For some reason, the obs_p[1] and res1$st_p[89] have
the same value but when I run "==", it returns FALSE.
Can anyone help give some explanation on this?
  Thanks very much!
Hanna

> obs_p[1]
[1] 0.002201438
> res1$st_p[89]
[1] 0.002201438
> res1$st_p[89]==obs_p[1]
[1] FALSE
> res1$st_p[89] res1$st_p[89]>obs_p[1]
[1] TRUE

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Logical operator in R

2016-01-22 Thread Fábio Magalhães
Hi,

This can get you started:
https://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-doesn_0027t-R-think-these-numbers-are-equal_003f


--Fabio

On Fri, Jan 22, 2016 at 1:46 PM, li li  wrote:

> Hi all,
>   I encountered the following strange phenomenon.
> For some reason, the obs_p[1] and res1$st_p[89] have
> the same value but when I run "==", it returns FALSE.
> Can anyone help give some explanation on this?
>   Thanks very much!
> Hanna
>
> > obs_p[1]
> [1] 0.002201438
> > res1$st_p[89]
> [1] 0.002201438
> > res1$st_p[89]==obs_p[1]
> [1] FALSE
> > res1$st_p[89] [1] FALSE
> > res1$st_p[89]>obs_p[1]
> [1] TRUE
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Logical operator in R

2016-01-22 Thread Rmh
FAQ 7.31

in this case subtract the two numbers and see that
they differ by about 1e-16

Sent from my iPhone

> On Jan 22, 2016, at 10:46, li li  wrote:
> 
> Hi all,
>  I encountered the following strange phenomenon.
> For some reason, the obs_p[1] and res1$st_p[89] have
> the same value but when I run "==", it returns FALSE.
> Can anyone help give some explanation on this?
>  Thanks very much!
>Hanna
> 
>> obs_p[1]
> [1] 0.002201438
>> res1$st_p[89]
> [1] 0.002201438
>> res1$st_p[89]==obs_p[1]
> [1] FALSE
>> res1$st_p[89] [1] FALSE
>> res1$st_p[89]>obs_p[1]
> [1] TRUE
> 
>[[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Shift all values above certain value by 1

2016-01-22 Thread Dimitri Liakhovitski
Hello!

# I have a data frame x:
x <- data.frame(a = 1:10, b = 2:11, c = 3:12, other = rnorm(10))

# First, I need to change every value 7 in columns a:c to 4
# Then, I need to decrease by 1 all values in columns a:c that are >7

What would be the fastest way of doing it?
Thank you!

-- 
Dimitri Liakhovitski

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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 opening SHP file

2016-01-22 Thread Amoy Yang via R-help
This is the results that addresses David's advice.
> library(maptools)
> library(maps)
> state.map <- readShapeSpatial("maps/st24_d00.shp")
Error in getinfo.shape(fn) : Error opening SHP file
> # David question: What does list.files('maps') return? Is there a 
> 'st24_d00.shp' value in there?
> list.files('maps')
character(0)
I actually use the link below to learn how to load state/zip-data on USA map.

# 
http://stackoverflow.com/questions/1441717/plotting-color-map-with-zip-codes-in-r-or-python
Plotting color map with zip codes in R or Python
|   |
|   |  |   |   |   |   |   |
| Plotting color map with zip codes in R or PythonI have some US demographic 
and firmographic data. I would like to plot zipcode areas in a state or a 
smaller region (e.g. city). Each area would be annotated by col... |
|  |
| View on stackoverflow.com | Preview by Yahoo |
|  |
|   |




 

On Friday, January 22, 2016 10:03 AM, Barry Rowlingson 
 wrote:
 

 We can duplicate the error by giving a path to a non-existent
shapefile, which is probably the original problem:

 > require(maptools)
Loading required package: maptools
Loading required package: sp
Checking rgeos availability: TRUE
 > foo=readShapeSpatial("fnord.shp")
Error in getinfo.shape(fn) : Error opening SHP file

The error message there isn't totally explicit, and might cover a
range of other possibilities such as a corrupted shapefile, or a
missing .shx component of the shapefile or whatever.

BUT you probably shouldn't be using readShapeSpatial anyway, as it has
a habit of not reading the coordinate system in the .prj file. I find
it much easier to use `raster::shapefile` which *does* read the
coordinate system *and* gives a more explicit error message for a
missing shapefile:

 > require(raster)
Loading required package: raster
 > foo=shapefile("fnord.shp")
Error in normalizePath(x, winslash = "/", mustWork = TRUE) :
  path[1]="fnord.shp": No such file or directory

"No such file or directory"

Barry



On Fri, Jan 22, 2016 at 2:25 AM, boB Rudis  wrote:
> Agreed with the others. After finding that shapefile and getting it to
> work you are definitely not in the proper working directory.
>
> On Thu, Jan 21, 2016 at 8:40 PM, David Winsemius  
> wrote:
>>
>>> On Jan 21, 2016, at 4:39 PM, Amoy Yang via R-help  
>>> wrote:
>>>
>>> Any advice for the following errors?
>>> state.map <- readShapeSpatial("maps/st24_d00.shp")
>>> Error in getinfo.shape(fn) : Error opening SHP file
>>
>> What does list.files('maps') return? Is there a 'st24_d00.shp' value in 
>> there?
>>
>>
>> --
>> David.
>>
>>>
>>>      [[alternative HTML version deleted]]
>>>
>>> __
>>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>>> https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] unexpected behaviour of an extended time series (using packages spuRs and xts)

2016-01-22 Thread Joshua Ulrich
Try using the latest xts on GitHub:
https://github.com/joshuaulrich/xts

On Thu, Jan 14, 2016 at 9:05 AM, Olivier ETERRADOSSI
 wrote:
> Hi list,
>
>
>
> I thought I knew how to use extended time series (package xts), but I was
> wrong  J  …
>
>
>
> While preparing a toy example for something else, using data provided in
> R, I run into an unexpected problem and can’t figure by myself what is
> happening below, can anyone of you tell ? I searched the archives but
> didn’t locate any answer. Probably it’s trivial, so please forgive  :
>
>
>
> I’m using :
>
> R version 3.2.3 (2015-12-10) -- "Wooden Christmas-Tree" / Platform:
> x86_64-w64-mingw32/x64 (64-bit)
>
> Packages are updated weekly, sometimes daily.
>
>
>
> I take some data from package spuRs :
>
>> library(spuRs)
>
>> data(kew)
>
>
>
> I turn the dataframe into time series (by combining each kew[,2:13] one
> after each other into a vector, and turning the vector into time series).
>
>
>
> One is ts :
>
>
>
>>
> kew.ts<-ts(data=stock,start=kew$year[1],end=kew$year[length(kew$year)],fre
> quency=12)
>
>
>
> And the other is xts, it looks fine at first :
>
>
>
>> kew.xts<-as.xts(kew.ts)
>
>> periodicity(kew.xts)
>
> Monthly periodicity from janv. 1697 to janv. 1999  # OK
>
>> hist(kew.xts) # OK
>
>> summary(kew.xts)
>
>  Index kew.xts
>
>  Min.   :1697   Min.   :  0.00
>
>  1st Qu.:1772   1st Qu.: 29.70
>
>  Median :1848   Median : 47.00
>
>  Mean   :1848   Mean   : 51.14
>
>  3rd Qu.:1924   3rd Qu.: 67.60
>
>  Max.   :1999   Max.   :189.00  # OK
>
>
>
>> gdata::is.what(kew.xts)
>
> [1] "is.array""is.atomic"   "is.double"
> "is.index.unique"
>
> [5] "is.matrix"   "is.numeric"  "is.object"   "is.regular"
>
>
>  [9] "is.time.unique"  "is.unsorted" "is.xts"  "is.zoo"
> # seems OK
>
>
>
>
>
> # But now, first try :
>
>> plot(kew.xts)
>
> Error in if (on == "years") { :
>
>   valeur manquante là où TRUE / FALSE est requis # french for «
> missing value where TRUE/FALSE is required »
>
>
>
> # h, let’s try something else :
>
>> plot(kew.xts['1697-01/1979/']) # OK
>
>
>
>> plot(kew.xts['1697-01/1980/'])
>
> Error in if (on == "years") { :
>
>   valeur manquante là où TRUE / FALSE est requis
>
>
>
>> plot(kew.xts['1697-01/1979-12/']) # OK
>
>
>
>> plot(kew.xts['1697-01/1980-01/'])
>
> Error in if (on == "years") { :
>
>   valeur manquante là où TRUE / FALSE est requis
>
>
>
> # but…!  :
>
>
>
>> plot(kew.xts['1979-01/1980/']) # OK !
>
>
>
> And so are :
>
>> plot (kew.xts['1978/1980/'])
>
>> plot(kew.xts['1977/1982/'])
>
>> plot(kew.xts['1977-01/1982-12'])  # and so on…
>
>
>
> I’m puzzled ! I have probably missed a trivial point… Can someone tell ?
>
>
>
> Thanks a lot list, regards, Olivier
>
>
>
> --
>
> Olivier ETERRADOSSI
>
> Maître-Assistant, HDR
>
> Ecole des Mines d’Alès (C2MA, site de Pau)
>
> Ingénierie de l'aspect visuel et tactile des matériaux
>
> Pôle « Recherche sur les Interactions des Matériaux avec leur
> Environnement » (RIME)
>
> Hélioparc, 2 av. P. Angot, F-64053 PAU CEDEX 9
>
> Tel : 05 59 30 90 35 (direct) - 05 59 30  54 25 (std)
>
> Fax : 05 59 30 63 68
>
>   http://www.mines-ales.fr
>
>   http://www.mines-telecom.fr
>
>
>
>
>
>
>
>
> [[alternative HTML version deleted]]
>
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



-- 
Joshua Ulrich  |  about.me/joshuaulrich
FOSS Trading  |  www.fosstrading.com
R/Finance 2016 | www.rinfinance.com

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Constrained Poisson model / Bayesian Poisson model

2016-01-22 Thread David Winsemius

> On Jan 22, 2016, at 7:01 AM, mara.pfleide...@uni-ulm.de wrote:
> 
> Hi all,
> 
> I am dealing with a problem about my linear Poisson regression model (link 
> function=identity).
> 
> I am using the glm()-function which results in negative coefficients, but a 
> negative influence of the regressors wouldn't make sense.

Negative coefficients merely indicate a lower relative rate. You need to be 
more specific about the exactly data and model output before you can raise our 
concern to a level where further comment can be made.


> 
> (i) Is there a possibility to set constraints on the regression parameters in 
> glm() such that all coefficients are positive? Or is there another function 
> in R for which this is possible?
> 
> (ii) Is there a Bayesian version of the glm()-function where I can specify 
> the prior distribution for my regression parameters? (e.g. a Dirichlet prior 
> s.t. the parameters are positive)
> 
> All this with respect to the linear Poisson model...

As I implied above, the word "linear" means something different than "additive" 
when the link is log().

--

David Winsemius
Alameda, CA, USA

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Sorting a Data Frame

2016-01-22 Thread Uwe Ligges



On 23.01.2016 01:21, Robert Sherry wrote:

In R, I run the following commands:
 df = data.frame( x=runif(10), y=runif(10) )
 df2 = df[order(x),]



You use another x from your workspace, you actually want to


 df2 = df[order(df[,"x"]),]

Best,
Uwe Ligges




The first, as I would expect, creates a data frame with two columns and
10 rows. I expect the second to sort the data based upon
the columns x and produce a new data frame, df2, with the same size as
df. However, the data frame is produces is much larger.
I do not understand what is going on. I am hoping somebody can help me.
I am also wondering if I should have a comma after
order(x) in the second statement. I do not see a purpose for it but it
was in an example on the web.

Thanks
Bob

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