[R] Generating 1-bit and 8-bit BMP files using R

2013-03-04 Thread Ingo Reinhold
Hi,

I'm trying to use the data which I generate within R to make images in .bmp 
format to be lateron printed by a printer.

My first thought was the RImageJ package, but this seems to be discontinued. 
What I am currently doing is generating a matrix of grey values, which needs to 
be parsed into the right image format. Is anyone aware of a package or rather 
"easy" way to generate these images using R?

Many thanks,

Ingo

[[alternative HTML version deleted]]

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


[R] R Compiler Options in the linux (ubuntu) Binaries? AVX?

2013-03-04 Thread ivo welch
curiosity question:  I was wondering whether the R binaries and BLAS
libraries for ubuntu linux are compiled using SSE4 and AVX support.
this probably can go a long way towards a unified memory bus GPGPU
substitute.


Ivo Welch (ivo.we...@gmail.com)
http://www.ivo-welch.info/

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

2013-03-04 Thread Irucka Embry
Hi Arun, thank you for your assistance. The code for part 1 worked
perfectly.

I am including here a list of all of the site names for part 2. Due to
the nature of the station ids it has been difficult for me to find a
good pattern to use with regular expressions.

Thank you all in advance for your assistance.

Irucka


(02143500, 02169000, 02169500, 02169570, 02172300, 02174250, 02175000,
02177000, 02192000, 02197065, 02198500, 02198920, 21GAEPD.01001001,
21GAEPD .01008001, 21GAEPD .01011001, 21GAEPD .01011801, 21GAEPD
.01013001, 21GAEPD .01014001, 21GAEPD .01014501, 21GAEPD .01015001,
21GAEPD .01018001, 21GAEPD .01021001, 21GAEPD .01025001,
21NC02WQ.A270, 21NC02WQ.A470, 21NC02WQ.C025,
21NC02WQ.C100, 21NC02WQ.C437, 21NC02WQ.C590,
21NC02WQ.C650, 21NC02WQ.C866, 21NC02WQ.C905,
21NC02WQ.C921, 21NC02WQ.C937, 21NC02WQ.C968,
21NC02WQ.C9819500, 21NC02WQ.I209, 21NC02WQ.I261,
21NC02WQ.I569, 21NC02WQ.I897, 21NC02WQ.I935,
21NC02WQ.Q022, 21NC02WQ.Q593, 21NC02WQ.Q597,
21NC02WQ.Q912, 21NC02WQ.Q916, 21NC02WQ.Q920, 21SC60WQ.B-005,
21SC60WQ.B-014, 21SC60WQ.B-028, 21SC60WQ.B-040, 21SC60WQ.B-041,
21SC60WQ.B-042, 21SC60WQ.B-044, 21SC60WQ.B-046, 21SC60WQ.B-047,
21SC60WQ.B-051, 21SC60WQ.B-053, 21SC60WQ.B-097, 21SC60WQ.B-126, 
21SC60WQ.B-163A, 21SC60WQ.B-221, 21SC60WQ.B-236, 21SC60WQ.B-331,
21SC60WQ.B-337, 21SC60WQ.C-001, 21SC60WQ.C-007, 21SC60WQ.C-017,
21SC60WQ.C-074, 21SC60WQ.CSB-001L, 21SC60WQ.CSB-001R, 21SC60WQ.CSTL-006,
21SC60WQ.CSTL-104, 21SC60WQ.CW-014, 21SC60WQ.CW-016, 21SC60WQ.CW-019,
21SC60WQ.CW-023, 21SC60WQ.CW-064, 21SC60WQ.CW-152, 21SC60WQ.CW-174,
21SC60WQ.CW-175, 21SC60WQ.CW-206, 21SC60WQ.CW-226, 21SC60WQ.CW-236,
21SC60WQ.E-007, 21SC60WQ.E-007A, 21SC60WQ.E-007B, 21SC60WQ.E-007C,
21SC60WQ.E-008, 21SC60WQ.E-008A, 21SC60WQ.E-012, 21SC60WQ.E-015,
21SC60WQ.E-099, 21SC60WQ.MD-110, 21SC60WQ.MD-111, 21SC60WQ.MD-119,
21SC60WQ.MD-124, 21SC60WQ.MD-145, 21SC60WQ.PD-012, 21SC60WQ.PD-015,
21SC60WQ.PD-021, 21SC60WQ.PD-028, 21SC60WQ.PD-041, 21SC60WQ.PD-042,
21SC60WQ.PD-044, 21SC60WQ.PD-045, 21SC60WQ.PD-060, 21SC60WQ.PD-076,
21SC60WQ.PD-170, 21SC60WQ.PD-189, 21SC60WQ.PD-281, 21SC60WQ.PD-330,
21SC60WQ.PD-337, 21SC60WQ.PD-350, 21SC60WQ.PD-355, 21SC60WQ.PD-359,
21SC60WQ.S-007, 21SC60WQ.S-013, 21SC60WQ.S-021, 21SC60WQ.S-047,
21SC60WQ.S-
050, 21SC60WQ.S-072, 21SC60WQ.S-102, 21SC60WQ.S-119, 21SC60WQ.S-123,
21SC60WQ.S-125, 21SC60WQ.S-150, 21SC60WQ.S-171, 21SC60WQ.S-186,
21SC60WQ.S-250, 21SC60WQ.S-295, 21SC60WQ.S-298, 21SC60WQ.S-305,
21SC60WQ.S-322, 21SC60WQ.SV-004, 21SC60WQ.SV-015, 21SC60WQ.SV-118,
21SC60WQ.SV-135, 21SC60WQ.SV-137, 21SC60WQ.SV-199, 21SC60WQ.SV-251,
21SC60WQ.SV-252, 21SC60WQ.SV-325, 21SC60WQ.SV-326, 21SC60WQ.SV-328,
21SC60WQ.SV-346, 21SC60WQ.SV-354, 21SCSANT.SC-001, 21SCSANT.SC-002)


<-Original Message-> 
>From: arun [smartpink...@yahoo.com]
>Sent: 3/4/2013 9:43:24 PM
>To: iruc...@mail2world.com
>Cc: r-help@r-project.org
>Subject: Re: [R] multiple plots and looping assistance requested
>
>Hi,
>
>May be you can try:
>res1<- gsub("\\_.*\\_.*\\_.*","",x)
> res2<-sub("(\\w)(\\w)(\\w)(\\w)(\\w)(\\w)(\\w)(\\w)(\\w)(\\w)(\\w)$",
"",
>x,perl=TRUE)
> identical(res1,res2)
>#[1] TRUE
>A.K.
>
>
>
>- Original Message -
>From: Irucka Embry 
>To: r-help@r-project.org
>Cc: 
>Sent: Monday, March 4, 2013 9:51 PM
>Subject: [R] multiple plots and looping assistance requested
>
>Hi all, I have a couple of questions.
>
>1) Is there a more effective way to remove the following pattern
>(patternrm) from the station_id_Timeseries (see below)
>
>patternrm <- c(_2000_4_OND, _2001_1_JFM, _2001_2_AMJ, _2001_3_JAS,
>_2001_4_OND, _2002_1_JFM, _2002_2_AMJ, _2002_3_JAS, _2002_4_OND,
>_2003_1_JFM, _2003_2_AMJ, _2003_3_JAS, _2003_4_OND, _2004_1_JFM,
>_2004_2_AMJ, _2004_3_JAS, _2000_4_OND) # This is the pattern to remove
>
>I am currently using this to remove the pattern: 
>sub("(\\w)(\\w)(\\w)(\\w)(\\w)(\\w)(\\w)(\\w)(\\w)(\\w)(\\w)$", "", x,
>perl=TRUE)
>
>
>2) I am attempting to make graphs of the station_id_Timeseries (x) in
>chronological order from 2000_4_OND to 2004_2_AMJ (there may be as as
>few as 2 or as many as 16) versus the load_00600_W (y1) and the
>load_00600_F (y2). There will be 2 plots for each x (x versus y1 & x
>versus y2). The data used here comes from a .csv file where there are
>about 100 sites and each site has it own unique station_id. In the end
>there should be a .pdf plot for each site.
>
>
>This is the full R code that I have written to process the data from
the
>.csv file in order to plot it:
>
>trytablecompare <- read.csv("calibset_fluxmasterandWRTDS_20130226.csv",
>sep = ",", stringsAsFactors = FALSE)
>x = trytablecompare[-c(1:2, 2193:2196), 1]
>sub("(\\w)(\\w)(\\w)(\\w)(\\w)(\\w)(\\w)(\\w)(\\w)(\\w)(\\w)$", "", x,
>perl=TRUE)
>
>columnsneed <- trytablecompare[-c(1:2, 2193:2196), c(1, 16, 18)]
>sites <- columnsneed[1]
>
>for(i in sites) {
>pdf(paste0("output for ", sites,".pdf"))
>xrange <- range("station_id_Timeseries:

Re: [R] how_to_create_a_package?

2013-03-04 Thread David Winsemius

On Mar 4, 2013, at 7:42 PM, Jyoti Sharma wrote:

> hello sir
> 
> myself Jyoti Sharma,  and i am working as preoject fellow in IGIB Delhi.
> I need your help to know how to create a package as well as how to
> post that package to the CRAN mirror, for public use. i have used
> package.skeleton() command but its not working properly.
> So, please suggest me the right way asap.

The asap part of that request will be most difficult. You have essentially 
composed a question which distilled to its essences reads: I'm having problems, 
please tell me what I have done wrong.


> i'll be very thankful to you.

You should read the material in the Posting Guide:

http://www.R-project.org/posting-guide.html

  and probably also the link at the bottom to the classic E. Raymond piece 
entitled something like "How to ask questions the smart way".

> 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] Learning the R way – A Wish

2013-03-04 Thread Mark Leeds
Hi Andrew: Not that I've gone through it all yet but the draft of hadley's
book  at https://github.com/hadley/devtools/wiki/Introduction has a lot if
not all of the commands you refer to and all of their gory details along
with many examples. No matter what you're budget, given that the book will
be finished in dec, 2013, I would print out the current draft ( it changes
frequently so your draft will become not current pretty quickly ) and make
a binding ( actually I had to make two bindings out of it ) and go through
it slowly. I was doing that for a while and it was quite enlightening until
I got sidetracked with other things.











On Mon, Mar 4, 2013 at 6:42 PM, andrewH  wrote:

> There is something that I wish I had that I think would help me a lot to
> be a
> better R programmer, that I think would probably help many others as well.
> I put the wish out there in the hopes that someone might think it was worth
> doing at some point.
>
> I wish I had the code of some substantial, widely used package – lm, say –
> heavily annotated and explained at roughly the level of R knowledge of
> someone who has completed an intro statistics course using R and picked up
> some R along the way.  The idea is that you would say what the various
> blocks of code are doing, why the authors chose to do it this way rather
> than some other way, point out coding techniques that save time or memory
> or
> prevent errors relative to alternatives, and generally, to explain what it
> does and point out and explain as many of the smarter features as possible.
> Ideally, this would include a description at least at the conceptual level
> if not at the code level of the major C functions that the package calls,
> so
> that you understand at least what is happening at that level, if not the
> nitty-gritty details of coding.
>
> I imagine this as a piece of annotated code, but maybe it could be a video
> of someone, or some couple of people, scrolling through the code and
> talking
> about it. Or maybe something more like a wiki page, with various people
> contributing explanations for different lines, sections, and practices.
>
> I am learning R on my own from books and the internet, and I think I would
> learn a lot from a chatty line-by-line description of some substantial
> block
> of code by someone who really knows what he or she is doing – perhaps with
> a
> little feedback from some people who are new about where they get lost in
> the description.
>
> There are a couple of particular things that I personally would hope to get
> out of this.  First, there are lots of instances of good coding practice
> that I think most people pick up from other programmers or by having
> individual bits of code explained to them that are pretty hard to get from
> books and help files.  I think this might be a good way to get at them.
>
> Second, there are a whole bunch of functions in R that I call
> meta-programming functions – don’t know if they have a more proper name.
> These are things that are intended primarily to act on R language objects
> or
> to control how R objects are evaluated. They include functions like call,
> match.call, parse and deparse, deparen, get, envir, substitute, eval, etc.
> Although I have read the individual documentation for many of these
> command,
> and even used most of them, I don’t think I have any fluency with them, or
> understand well how and when to code with them.  I think reading a
> good-sized hunk of code that uses these functions to do a lot of things
> that
> packages often need to do in the best-practice or standard R way, together
> with comments that describe and explain them would help a lot with that.
> (There is a good smaller-scale example of this in Friedrich Leisch’s
> tutorial on creating R packages).
>
> These are things I think I probably share with many others. I actually have
> an ulterior motive for suggesting lm in particular that is more peculiar to
> me, though not unique I am sure. I would like to understand how formulas
> work well enough to use them in my own functions. I do not think there is
> any way to get that from the help documentation. I have been working on a
> piece of code that I suspect is reinventing, but in an awkward and kludgey
> way, a piece of the functionality of formulas. So far as I have been able
> to
> gather, the only place they are really explained in detail is in chapters 2
> & 3 of the White Book, “Statistical Models in S”. Unfortunately, I do not
> have ready access to a major research library and I have way, way outspent
> my book budget. Someday I’ll probably buy a copy, but for the time being, I
> am stuck without it. So it would be great to have a piece of code that uses
> them explained in detail.
>
> Warmest regards to all,  andrewH
>
>
>
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/Learning-the-R-way-A-Wish-tp4660287.html
> Sent from the R help mailing list archive at Nabble.com.
>
> 

[R] how_to_create_a_package?

2013-03-04 Thread Jyoti Sharma
hello sir

myself Jyoti Sharma,  and i am working as preoject fellow in IGIB Delhi.
I need your help to know how to create a package as well as how to
post that package to the CRAN mirror, for public use. i have used
package.skeleton() command but its not working properly.
So, please suggest me the right way asap.
i'll be very thankful to you.


Jyoti Sharma
JRF @IGIB

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Learning the R way – A Wish

2013-03-04 Thread Andrew Koeser
The book that helped me break into R and more advanced texts was 
Crawley's "Statistics: An Introduction with R."  Very light read that 
assumes no prior knowledge with stats or R. I am using it to teach my 
fellow grad students R and all agree it was worth scrimping pennies to 
get. He also has a series of exercises (for free) that may be close to 
what you need.


http://www3.imperial.ac.uk/naturalsciences/research/statisticsusingr

Andrew

On 03/04/2013 05:42 PM, andrewH wrote:

There is something that I wish I had that I think would help me a lot to be a
better R programmer, that I think would probably help many others as well.
I put the wish out there in the hopes that someone might think it was worth
doing at some point.

I wish I had the code of some substantial, widely used package – lm, say –
heavily annotated and explained at roughly the level of R knowledge of
someone who has completed an intro statistics course using R and picked up
some R along the way.  The idea is that you would say what the various
blocks of code are doing, why the authors chose to do it this way rather
than some other way, point out coding techniques that save time or memory or
prevent errors relative to alternatives, and generally, to explain what it
does and point out and explain as many of the smarter features as possible.
Ideally, this would include a description at least at the conceptual level
if not at the code level of the major C functions that the package calls, so
that you understand at least what is happening at that level, if not the
nitty-gritty details of coding.

I imagine this as a piece of annotated code, but maybe it could be a video
of someone, or some couple of people, scrolling through the code and talking
about it. Or maybe something more like a wiki page, with various people
contributing explanations for different lines, sections, and practices.

I am learning R on my own from books and the internet, and I think I would
learn a lot from a chatty line-by-line description of some substantial block
of code by someone who really knows what he or she is doing – perhaps with a
little feedback from some people who are new about where they get lost in
the description.

There are a couple of particular things that I personally would hope to get
out of this.  First, there are lots of instances of good coding practice
that I think most people pick up from other programmers or by having
individual bits of code explained to them that are pretty hard to get from
books and help files.  I think this might be a good way to get at them.

Second, there are a whole bunch of functions in R that I call
meta-programming functions – don’t know if they have a more proper name.
These are things that are intended primarily to act on R language objects or
to control how R objects are evaluated. They include functions like call,
match.call, parse and deparse, deparen, get, envir, substitute, eval, etc.
Although I have read the individual documentation for many of these command,
and even used most of them, I don’t think I have any fluency with them, or
understand well how and when to code with them.  I think reading a
good-sized hunk of code that uses these functions to do a lot of things that
packages often need to do in the best-practice or standard R way, together
with comments that describe and explain them would help a lot with that.
(There is a good smaller-scale example of this in Friedrich Leisch’s
tutorial on creating R packages).

These are things I think I probably share with many others. I actually have
an ulterior motive for suggesting lm in particular that is more peculiar to
me, though not unique I am sure. I would like to understand how formulas
work well enough to use them in my own functions. I do not think there is
any way to get that from the help documentation. I have been working on a
piece of code that I suspect is reinventing, but in an awkward and kludgey
way, a piece of the functionality of formulas. So far as I have been able to
gather, the only place they are really explained in detail is in chapters 2
& 3 of the White Book, “Statistical Models in S”. Unfortunately, I do not
have ready access to a major research library and I have way, way outspent
my book budget. Someday I’ll probably buy a copy, but for the time being, I
am stuck without it. So it would be great to have a piece of code that uses
them explained in detail.

Warmest regards to all,  andrewH




--
View this message in context: 
http://r.789695.n4.nabble.com/Learning-the-R-way-A-Wish-tp4660287.html
Sent from the R help mailing list archive at Nabble.com.

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


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listin

Re: [R] multiple plots and looping assistance requested

2013-03-04 Thread arun
Hi,

May be you can try:
res1<- gsub("\\_.*\\_.*\\_.*","",x)
 res2<-sub("(\\w)(\\w)(\\w)(\\w)(\\w)(\\w)(\\w)(\\w)(\\w)(\\w)(\\w)$", "", 
x,perl=TRUE)
 identical(res1,res2)
#[1] TRUE
A.K.



- Original Message -
From: Irucka Embry 
To: r-help@r-project.org
Cc: 
Sent: Monday, March 4, 2013 9:51 PM
Subject: [R] multiple plots and looping assistance requested

Hi all, I have a couple of questions.

1) Is there a more effective way to remove the following pattern
(patternrm) from the station_id_Timeseries (see below)

patternrm <- c(_2000_4_OND, _2001_1_JFM, _2001_2_AMJ, _2001_3_JAS,
_2001_4_OND, _2002_1_JFM, _2002_2_AMJ, _2002_3_JAS, _2002_4_OND,
_2003_1_JFM, _2003_2_AMJ, _2003_3_JAS, _2003_4_OND, _2004_1_JFM,
_2004_2_AMJ, _2004_3_JAS, _2000_4_OND) # This is the pattern to remove

I am currently using this to remove the pattern: 
sub("(\\w)(\\w)(\\w)(\\w)(\\w)(\\w)(\\w)(\\w)(\\w)(\\w)(\\w)$", "", x,
perl=TRUE)


2) I am attempting to make graphs of the station_id_Timeseries (x) in
chronological order from 2000_4_OND to 2004_2_AMJ (there may be as as
few as 2 or as many as 16) versus the load_00600_W (y1) and the
load_00600_F (y2). There will be 2 plots for each x (x versus y1 & x
versus y2). The data used here comes from a .csv file where there are
about 100 sites and each site has it own unique station_id. In the end
there should be a .pdf plot for each site.


This is the full R code that I have written to process the data from the
.csv file in order to plot it:

trytablecompare <- read.csv("calibset_fluxmasterandWRTDS_20130226.csv",
sep = ",", stringsAsFactors = FALSE)
x = trytablecompare[-c(1:2, 2193:2196), 1]
sub("(\\w)(\\w)(\\w)(\\w)(\\w)(\\w)(\\w)(\\w)(\\w)(\\w)(\\w)$", "", x,
perl=TRUE)

columnsneed <- trytablecompare[-c(1:2, 2193:2196), c(1, 16, 18)]
sites <- columnsneed[1]

for(i in sites) {
pdf(paste0("output for ", sites,".pdf"))
xrange <- range("station_id_Timeseries:endofsubset$i")
yrange <- range("load_00600_W$endofsubset")
plot(x, y1, xlab="Year, Season", ylab="Total Flux (kg/season)")
lines(x, y1)
par(new=T)
xrange <- range("station_id_Timeseries:endofsubset$i")
yrange <- range("load_00600_F$endofsubset")
plot(x, y2, xlab="Year, Season", ylab="Total Flux (kg/season)")
lines(x, y2)
dev.off()
}


I have attempted to create reproducible code below, but I know that it
is not complete. 
For example:
x = c(02143500_2000_4_OND, 02143500_2001_1_JFM, 02143500_2001_2_AMJ,
02143500_2001_3_JAS, 02143500_2001_4_OND, 02143500_2002_1_JFM,
02143500_2002_2_AMJ, 02143500_2002_3_JAS, 02143500_2002_4_OND,
02143500_2003_1_JFM, 02143500_2003_2_AMJ, 02143500_2003_3_JAS,
02143500_2003_4_OND, 02143500_2004_1_JFM, 02143500_2004_2_AMJ,
02143500_2004_3_JAS, 21W43.5000_2000_4_OND, 21W43.5000_2001_1_JFM,
21W43.5000_2001_2_AMJ, 21W43.5000_2001_3_JAS, 21W43.5000_2001_4_OND,
21W43.5000_2002_1_JFM, 21W43.5000_2002_2_AMJ, 21W43.5000_2002_3_JAS,
21W43.5000_2002_4_OND, 21W43.5000_2003_1_JFM, 21W43.5000_2003_2_AMJ,
21W43.5000_2003_3_JAS, 21W43.5000_2003_4_OND, 21W43.5000_2004_1_JFM,
21W43.5000_2004_2_AMJ, 21W43.5000_2004_3_JAS) # station_id_Timeseries

y1 = c(rnorm(16), rnorm(16)) # load_00600_W
y2 = c(rnorm(16), rnorm(16)) # load_00600_F


for(i in x) {
pdf(paste0("output for ", sites,".pdf"))
xrange <- range("x1$i") # This would be the first set of sites for the
specified seasons
yrange <- range("y1") 
plot(x, y1, xlab="Year, Season", ylab="Total Flux (kg/season)")
lines(x, y1)
par(new=T)
xrange <- range(""x1$i"") # This would be the first set of sites for the
specified seasons
yrange <- range("y2")
plot(x, y2, xlab="Year, Season", ylab="Total Flux (kg/season)")
lines(x, y2))
dev.off()
}







Thank-you.

Irucka Embry



This is a small sampling of the data that I'm extracting to plot from
the .csv file:
station_id_Timeseries (as the x axis)
02143500_2000_4_OND
02143500_2001_1_JFM
02143500_2001_2_AMJ
02143500_2001_3_JAS
02143500_2001_4_OND
02143500_2002_1_JFM
02143500_2002_2_AMJ
02143500_2002_3_JAS
02143500_2002_4_OND
02143500_2003_1_JFM
02143500_2003_2_AMJ
02143500_2003_3_JAS
02143500_2003_4_OND
02143500_2004_1_JFM
02143500_2004_2_AMJ
02143500_2004_3_JAS
02169000_2000_4_OND
02169000_2001_1_JFM
02169000_2001_2_AMJ
02169000_2001_3_JAS
02169000_2001_4_OND
02169000_2002_1_JFM
02169000_2002_2_AMJ
02169000_2002_3_JAS
02169000_2002_4_OND
02169000_2003_1_JFM
02169000_2003_2_AMJ
02169000_2003_3_JAS
02169000_2003_4_OND
02169000_2004_1_JFM
02169000_2004_2_AMJ
02169000_2004_3_JAS
21GAEPD .01021001_2003_3_JAS
21GAEPD .01025001_2000_4_OND
21GAEPD .01025001_2001_1_JFM
21GAEPD .01025001_2001_2_AMJ
21GAEPD .01025001_2001_3_JAS
21GAEPD .01025001_2001_4_OND
21GAEPD .01025001_2002_1_JFM
21GAEPD .01025001_2002_2_AMJ
21GAEPD .01025001_2002_3_JAS
21GAEPD .01025001_2002_4_OND
21GAEPD .01025001_2003_1_JFM
21GAEPD .01025001_2003_2_AMJ
21GAEPD .01025001_2003_3_JAS
21NC02WQ.A270_2000_4_OND
21NC02WQ.A270_2001_1_JFM
21NC02WQ.A270_2001_2_AMJ
21NC02WQ.A270_2001_3_JAS
21NC02WQ.A270_2001_4_OND
21NC02WQ.A270_2002_1_JFM
21NC02WQ.A

Re: [R] Automatically fix big jumps in one variable due to anomalies

2013-03-04 Thread Duncan Mackay

Hi Cesar

Not sure what you actually want to accomplish

?rle  may give you some ideas eg (I have added some to return to the 
good section)


x = c(246,251,250,255,5987,5991,5994,599,255,259,262,267)

xdiff = diff(x)
xdiff
 [1] 5-1 5  5732 4 3 -5395  -344 4 3 5
rle(xdiff)
Run Length Encoding
  lengths: int [1:11] 1 1 1 1 1 1 1 1 1 1 ...
  values : num [1:11] 5 -1 5 5732 4 3 -5395 -344 4 3 ...
which(abs(rle(xdiff)[[2]] ) > 50)
[1] 4 7 8
rle(xdiff)[[2]][abs(rle(xdiff)[[2]] ) > 50]

It is then a matter of removing the required sequences or applying a 
function to them or substituting values ?zoo::na.approx from memory


HTH

Duncan

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



At 09:13 5/03/2013, you wrote:

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.


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] multiple plots and looping assistance requested

2013-03-04 Thread Irucka Embry
Hi all, I have a couple of questions.

1) Is there a more effective way to remove the following pattern
(patternrm) from the station_id_Timeseries (see below)

patternrm <- c(_2000_4_OND, _2001_1_JFM, _2001_2_AMJ, _2001_3_JAS,
_2001_4_OND, _2002_1_JFM, _2002_2_AMJ, _2002_3_JAS, _2002_4_OND,
_2003_1_JFM, _2003_2_AMJ, _2003_3_JAS, _2003_4_OND, _2004_1_JFM,
_2004_2_AMJ, _2004_3_JAS, _2000_4_OND) # This is the pattern to remove

I am currently using this to remove the pattern: 
sub("(\\w)(\\w)(\\w)(\\w)(\\w)(\\w)(\\w)(\\w)(\\w)(\\w)(\\w)$", "", x,
perl=TRUE)


2) I am attempting to make graphs of the station_id_Timeseries (x) in
chronological order from 2000_4_OND to 2004_2_AMJ (there may be as as
few as 2 or as many as 16) versus the load_00600_W (y1) and the
load_00600_F (y2). There will be 2 plots for each x (x versus y1 & x
versus y2). The data used here comes from a .csv file where there are
about 100 sites and each site has it own unique station_id. In the end
there should be a .pdf plot for each site.


This is the full R code that I have written to process the data from the
.csv file in order to plot it:

trytablecompare <- read.csv("calibset_fluxmasterandWRTDS_20130226.csv",
sep = ",", stringsAsFactors = FALSE)
x = trytablecompare[-c(1:2, 2193:2196), 1]
sub("(\\w)(\\w)(\\w)(\\w)(\\w)(\\w)(\\w)(\\w)(\\w)(\\w)(\\w)$", "", x,
perl=TRUE)

columnsneed <- trytablecompare[-c(1:2, 2193:2196), c(1, 16, 18)]
sites <- columnsneed[1]

for(i in sites) {
pdf(paste0("output for ", sites,".pdf"))
xrange <- range("station_id_Timeseries:endofsubset$i")
yrange <- range("load_00600_W$endofsubset")
plot(x, y1, xlab="Year, Season", ylab="Total Flux (kg/season)")
lines(x, y1)
par(new=T)
xrange <- range("station_id_Timeseries:endofsubset$i")
yrange <- range("load_00600_F$endofsubset")
plot(x, y2, xlab="Year, Season", ylab="Total Flux (kg/season)")
lines(x, y2)
dev.off()
}


I have attempted to create reproducible code below, but I know that it
is not complete. 
For example:
x = c(02143500_2000_4_OND, 02143500_2001_1_JFM, 02143500_2001_2_AMJ,
02143500_2001_3_JAS, 02143500_2001_4_OND, 02143500_2002_1_JFM,
02143500_2002_2_AMJ, 02143500_2002_3_JAS, 02143500_2002_4_OND,
02143500_2003_1_JFM, 02143500_2003_2_AMJ, 02143500_2003_3_JAS,
02143500_2003_4_OND, 02143500_2004_1_JFM, 02143500_2004_2_AMJ,
02143500_2004_3_JAS, 21W43.5000_2000_4_OND, 21W43.5000_2001_1_JFM,
21W43.5000_2001_2_AMJ, 21W43.5000_2001_3_JAS, 21W43.5000_2001_4_OND,
21W43.5000_2002_1_JFM, 21W43.5000_2002_2_AMJ, 21W43.5000_2002_3_JAS,
21W43.5000_2002_4_OND, 21W43.5000_2003_1_JFM, 21W43.5000_2003_2_AMJ,
21W43.5000_2003_3_JAS, 21W43.5000_2003_4_OND, 21W43.5000_2004_1_JFM,
21W43.5000_2004_2_AMJ, 21W43.5000_2004_3_JAS) # station_id_Timeseries

y1 = c(rnorm(16), rnorm(16)) # load_00600_W
y2 = c(rnorm(16), rnorm(16)) # load_00600_F


for(i in x) {
pdf(paste0("output for ", sites,".pdf"))
xrange <- range("x1$i") # This would be the first set of sites for the
specified seasons
yrange <- range("y1") 
plot(x, y1, xlab="Year, Season", ylab="Total Flux (kg/season)")
lines(x, y1)
par(new=T)
xrange <- range(""x1$i"") # This would be the first set of sites for the
specified seasons
yrange <- range("y2")
plot(x, y2, xlab="Year, Season", ylab="Total Flux (kg/season)")
lines(x, y2))
dev.off()
}







Thank-you.

Irucka Embry



This is a small sampling of the data that I'm extracting to plot from
the .csv file:
station_id_Timeseries (as the x axis)
02143500_2000_4_OND
02143500_2001_1_JFM
02143500_2001_2_AMJ
02143500_2001_3_JAS
02143500_2001_4_OND
02143500_2002_1_JFM
02143500_2002_2_AMJ
02143500_2002_3_JAS
02143500_2002_4_OND
02143500_2003_1_JFM
02143500_2003_2_AMJ
02143500_2003_3_JAS
02143500_2003_4_OND
02143500_2004_1_JFM
02143500_2004_2_AMJ
02143500_2004_3_JAS
02169000_2000_4_OND
02169000_2001_1_JFM
02169000_2001_2_AMJ
02169000_2001_3_JAS
02169000_2001_4_OND
02169000_2002_1_JFM
02169000_2002_2_AMJ
02169000_2002_3_JAS
02169000_2002_4_OND
02169000_2003_1_JFM
02169000_2003_2_AMJ
02169000_2003_3_JAS
02169000_2003_4_OND
02169000_2004_1_JFM
02169000_2004_2_AMJ
02169000_2004_3_JAS
21GAEPD .01021001_2003_3_JAS
21GAEPD .01025001_2000_4_OND
21GAEPD .01025001_2001_1_JFM
21GAEPD .01025001_2001_2_AMJ
21GAEPD .01025001_2001_3_JAS
21GAEPD .01025001_2001_4_OND
21GAEPD .01025001_2002_1_JFM
21GAEPD .01025001_2002_2_AMJ
21GAEPD .01025001_2002_3_JAS
21GAEPD .01025001_2002_4_OND
21GAEPD .01025001_2003_1_JFM
21GAEPD .01025001_2003_2_AMJ
21GAEPD .01025001_2003_3_JAS
21NC02WQ.A270_2000_4_OND
21NC02WQ.A270_2001_1_JFM
21NC02WQ.A270_2001_2_AMJ
21NC02WQ.A270_2001_3_JAS
21NC02WQ.A270_2001_4_OND
21NC02WQ.A270_2002_1_JFM
21NC02WQ.A270_2002_2_AMJ
21NC02WQ.A270_2002_3_JAS
21NC02WQ.A270_2002_4_OND
21NC02WQ.A270_2003_1_JFM
21NC02WQ.A270_2003_2_AMJ
21NC02WQ.A270_2003_3_JAS
21NC02WQ.A270_2003_4_OND
21NC02WQ.A270_2004_1_JFM
21NC02WQ.A270_2004_2_AMJ
21NC02WQ.A270_2004_3_JAS
21NC02WQ.A470_2000_4_OND
21NC02WQ.A470_2001_1_JFM
21NC02WQ.A470_2001_2_AMJ

Re: [R] Results from clogit out of range?

2013-03-04 Thread Lisa S
Thanks for the illustrative example. In my project actually my supervisor
wanted to estimate the probabilities using a "conditional MLE" approach,
which happens to be the case that *uses clogit() while trying to achieve
aim b in your words*.

I learned that clogit() is based on the sufficient statistic which is
usually the sum over all positive responses in each stratum. However since
we are supposed to not knowing the responses when trying to predict a new
sample, it can be impossible to do this "out-of-sample" prediction right?

Now what I suggested is to use clogit() to estimate beta (ppl say this beta
is better than betas from unconditional MLE, why??) and derive the linear
predictor for any new sample by multiplying new predictors with this beta,
then

1) if there is only one obs each strata, use the traditional unconditional
formula

phat = exp(xbeta)/(1+exp(xbeta))

to get the so-called predicted probability;

2) if there is a lot of obs each strata, use

phat = exp(xbeta)/sum(exp(xbeta))

to get the so-called predicted probabilities.

My case has only 1 obs per stratum so I used method 1. Though I am not sure
if it is reasonable. Would like to hear opinions from all of you guy. ;P

On Mon, Mar 4, 2013 at 10:04 PM, Terry Therneau  wrote:

> I'm late to this discussion, but let me try to put it in another context.
>   Assume that I wanted to know whether kids who live west of their school
> or east of their shool are more likely to be early (some hypothesis about
> walking slower if the sun is in their eyes).  So I create a 0/1 variable
> east/west and get samples of 10 student arrival times at each of 100
> different schools.  Fit the model
>
>lm(arrive ~ factor(school) + east.west)
>
> where "arrive" is in some common scale like "minutes since midnight".
>  Since different schools could have different starting times for their
> first class we need an intercept per school.
>
>   Two questions:
>  1. Incremental effect: the coefficient of east/west measures the
> incredmental effect across all schools.  With n of 1000 it is likely
> estimated with high precision.
>  2. Absolute: predict the average arrival time (on the clock) for
> students.
>
> Conditional logistic is very like this.  We have a large number of strata
> ("schools") with a small number of observations in each (often only 2 per
> strata).  One can ask incremental questions about variables common to all
> strata, but absolute prediction is pretty worthless.  a. You can only do it
> for schools (strata) that have already been seen and b. there are so few
> subjects in each of them that the estimates are very noisy.
>   The default prediction from clogit is focused on questions of type 1.
>  The documentation doesn't even bother to mention predictions of type 2,
> which would be probabilities of events.  I can think of a way to extract
> such output from the routine (being the author gives some insight), but why
> would I want to?
>
> Terry Therneau
>
>

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

2013-03-04 Thread arun
Hi,

If you meant to get the array index from `res1`, then this will do it.  But, if 
it is from 'dat3`, it will  be huge as each index is unique.
indx<-which(apply(res1,1,function(x) x!=0) ,arr.ind=TRUE)
 Names2<-do.call(rbind,lapply(1:3,function(i) {x<-indx[indx[,2]==i,]; 
paste(apply(x,1,function(y) 
paste("(",paste(y,collapse=","),")",sep="")),collapse=",")} ))
 res2<- data.frame(Frequency=apply(res1,1,function(x) sum(1*(x!=0))), 
stations=Names2,stringsAsFactors=FALSE)

A.K.








From: eliza botto 
To: "smartpink...@yahoo.com"  
Sent: Monday, March 4, 2013 5:50 PM
Subject: RE: histogram



Dear Arun,
Just a small inquiry i have.
you can see that in the results, there are some stations which are repeating 
themselves like station number 16 which is included in all three ranges. its 
because for station 16 there are over 100 values. So to get rid of 
it what if instead of stations, i want  to locate the 
coordinates of each station in the final table. like for coordinate 
(17row,16col), it should be in range 0-25 and (18row,17col) should be included 
in range 25-50.

so my final table should look like

 Range                          stations                                        
 Frequency
0-25                           (1,4),(2,3),(8,9)                                
     3
25-50                         (4,10),(11,100)                                   
   2
50-75                         (55,56),(57,60)                                   
  2       

is it possible?
thanks alot...

elisa


> Date: Mon, 4 Mar 2013 12:38:22 -0800
> From: smartpink...@yahoo.com
> Subject: Re: histogram
> To: eliza_bo...@hotmail.com
> 
> Sometimes, you make mistake when you are quick.  I forgot names(which(..)). 
> THe corrected version is sent.
> Thanks.
> Arun
> 
> 
> 
> 
> 
> 
> 
> From: eliza botto 
> To: "smartpink...@yahoo.com"  
> Sent: Monday, March 4, 2013 3:31 PM
> Subject: RE: histogram
> 
> 
> 
> My GOD, you are so quick. 
> Thankyou so very much indeed...
> stay blessed.
> 
> elisa
> 
> 
> > Date: Mon, 4 Mar 2013 12:26:44 -0800
> > From: smartpink...@yahoo.com
> > Subject: Re: histogram
> > To: eliza_bo...@hotmail.com
> > CC: r-help@r-project.org
> > 
> > Hi,
> > 
> > dat1<- read.csv("rightest.csv",sep=",",header=TRUE,check.names=FALSE)
> >  dat2<- as.dist(dat1[,-1],upper=F,diag=F)
> > vec1<- as.vector(dat2)
> > label1=c("0-25","25-50","50-75")
> > Name1<-unlist(lapply(0:123,function(i) rep(i+1,i)))
> > dat3<-data.frame(Name1,vec1)
> > res<-t(aggregate(.~Name1,data=dat3,function(x) 
> > table(cut(x,breaks=seq(0,75,25),labels=label1
> > colnames(res)<- res[1,]
> > res1<- res[-1,]
> > row.names(res1)<-gsub("vec1.","",row.names(res1))
> > res1
> > Names2<-apply(res1,1,function(x) paste(which(x!=0),collapse=","))
> > res2<- data.frame(Frequency=apply(res1,1,function(x) sum(1*(x!=0))), 
> > stations=Names2,stringsAsFactors=FALSE)
> > 
> > res2
> > #  Frequency
> > #0-25    121
> > #25-50   122
> > #50-75    76
> > 
> > 
> > 
> > 
> >    
> > #stations
> > #0-25    
> > #1,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123
> > #25-50 
> > #2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123
> > #50-75  
> >    
> > #10,16,22,25,27,30,31,33,34,35,36,37,38,39,40,41,47,48,50,53,56,58,59,61,64,65,68,69,70,73,75,76,77,78,79,80,81,82,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,121,123
> > 
> > A.K.
> > 
> > 
> > From: eliza botto 
> > To: "smartpink...@yahoo.com"  
> > Sent: Monday, March 4, 2013 3:21 PM
> > Subject: RE: histogram
> > 
> > 
> > 
> > Dear Arun,
> > 
> > 
> > Thanks for replying
> > Although codes well defined my problem but the table in the end s

Re: [R] Learning the R way – A Wish

2013-03-04 Thread David Winsemius

On Mar 4, 2013, at 3:42 PM, andrewH wrote:

> There is something that I wish I had that I think would help me a lot to be a
> better R programmer, that I think would probably help many others as well.  
> I put the wish out there in the hopes that someone might think it was worth
> doing at some point.
> 
> I wish I had the code of some substantial, widely used package – lm, say –
> heavily annotated and explained at roughly the level of R knowledge of
> someone who has completed an intro statistics course using R and picked up
> some R along the way.  The idea is that you would say what the various
> blocks of code are doing, why the authors chose to do it this way rather
> than some other way, point out coding techniques that save time or memory or
> prevent errors relative to alternatives, and generally, to explain what it
> does and point out and explain as many of the smarter features as possible. 
> Ideally, this would include a description at least at the conceptual level
> if not at the code level of the major C functions that the package calls, so
> that you understand at least what is happening at that level, if not the
> nitty-gritty details of coding.
> 
> I imagine this as a piece of annotated code, but maybe it could be a video
> of someone, or some couple of people, scrolling through the code and talking
> about it. Or maybe something more like a wiki page, with various people
> contributing explanations for different lines, sections, and practices.
> 
> I am learning R on my own from books and the internet, and I think I would
> learn a lot from a chatty line-by-line description of some substantial block
> of code by someone who really knows what he or she is doing – perhaps with a
> little feedback from some people who are new about where they get lost in
> the description.
> 
> There are a couple of particular things that I personally would hope to get
> out of this.  First, there are lots of instances of good coding practice
> that I think most people pick up from other programmers or by having
> individual bits of code explained to them that are pretty hard to get from
> books and help files.  I think this might be a good way to get at them.
> 
> Second, there are a whole bunch of functions in R that I call
> meta-programming functions – don’t know if they have a more proper name.
> These are things that are intended primarily to act on R language objects or
> to control how R objects are evaluated. They include functions like call,
> match.call, parse and deparse, deparen, get, envir, substitute, eval, etc.
> Although I have read the individual documentation for many of these command,
> and even used most of them, I don’t think I have any fluency with them, or
> understand well how and when to code with them.  I think reading a
> good-sized hunk of code that uses these functions to do a lot of things that
> packages often need to do in the best-practice or standard R way, together
> with comments that describe and explain them would help a lot with that.
> (There is a good smaller-scale example of this in Friedrich Leisch’s
> tutorial on creating R packages).
> 
> These are things I think I probably share with many others. I actually have
> an ulterior motive for suggesting lm in particular that is more peculiar to
> me, though not unique I am sure. I would like to understand how formulas
> work well enough to use them in my own functions. I do not think there is
> any way to get that from the help documentation. I have been working on a
> piece of code that I suspect is reinventing, but in an awkward and kludgey
> way, a piece of the functionality of formulas. So far as I have been able to
> gather, the only place they are really explained in detail is in chapters 2
> & 3 of the White Book, “Statistical Models in S”. Unfortunately, I do not
> have ready access to a major research library and I have way, way outspent
> my book budget. Someday I’ll probably buy a copy, but for the time being, I
> am stuck without it. So it would be great to have a piece of code that uses
> them explained in detail.

Not sure that you have a valid idea of the cost of that particular 
investment... at bookfinder.com

Bookseller  Notes   Price
1.  
United States   Softcover, ISBN 0412053012
Publisher: Chapman & Hall/CRC, 1991
Section: Computer Languages: The Attic  
$21.94

Chapter 2 was useful for some of the the purposes you propose, but chapter 3 
did not.

However, I would suggest that you might instead purchase "S Programming" by 
Venables and Ripley. And ... it was even cheaper at Bookfinder. Reviewing the 
indices shows of both texts shows a far greater treatment of the functions you 
list above.  I found the later, more up-to-date text "Software for Data 
Analysis" to be less helpful in understanding the R/S "internals" than the "S 
Programming" text. It was surprisingly sparse with its coding examples. You 
could sometimes go for pages without seeing any code. Extended discussions of 
how

[R] Automatically fix big jumps in one variable due to anomalies

2013-03-04 Thread Cesar Terrer
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.


[R] Learning the R way – A Wish

2013-03-04 Thread andrewH
There is something that I wish I had that I think would help me a lot to be a
better R programmer, that I think would probably help many others as well.  
I put the wish out there in the hopes that someone might think it was worth
doing at some point.

I wish I had the code of some substantial, widely used package – lm, say –
heavily annotated and explained at roughly the level of R knowledge of
someone who has completed an intro statistics course using R and picked up
some R along the way.  The idea is that you would say what the various
blocks of code are doing, why the authors chose to do it this way rather
than some other way, point out coding techniques that save time or memory or
prevent errors relative to alternatives, and generally, to explain what it
does and point out and explain as many of the smarter features as possible. 
Ideally, this would include a description at least at the conceptual level
if not at the code level of the major C functions that the package calls, so
that you understand at least what is happening at that level, if not the
nitty-gritty details of coding.

I imagine this as a piece of annotated code, but maybe it could be a video
of someone, or some couple of people, scrolling through the code and talking
about it. Or maybe something more like a wiki page, with various people
contributing explanations for different lines, sections, and practices.

I am learning R on my own from books and the internet, and I think I would
learn a lot from a chatty line-by-line description of some substantial block
of code by someone who really knows what he or she is doing – perhaps with a
little feedback from some people who are new about where they get lost in
the description.

There are a couple of particular things that I personally would hope to get
out of this.  First, there are lots of instances of good coding practice
that I think most people pick up from other programmers or by having
individual bits of code explained to them that are pretty hard to get from
books and help files.  I think this might be a good way to get at them.

Second, there are a whole bunch of functions in R that I call
meta-programming functions – don’t know if they have a more proper name.
These are things that are intended primarily to act on R language objects or
to control how R objects are evaluated. They include functions like call,
match.call, parse and deparse, deparen, get, envir, substitute, eval, etc.
Although I have read the individual documentation for many of these command,
and even used most of them, I don’t think I have any fluency with them, or
understand well how and when to code with them.  I think reading a
good-sized hunk of code that uses these functions to do a lot of things that
packages often need to do in the best-practice or standard R way, together
with comments that describe and explain them would help a lot with that.
(There is a good smaller-scale example of this in Friedrich Leisch’s
tutorial on creating R packages).

These are things I think I probably share with many others. I actually have
an ulterior motive for suggesting lm in particular that is more peculiar to
me, though not unique I am sure. I would like to understand how formulas
work well enough to use them in my own functions. I do not think there is
any way to get that from the help documentation. I have been working on a
piece of code that I suspect is reinventing, but in an awkward and kludgey
way, a piece of the functionality of formulas. So far as I have been able to
gather, the only place they are really explained in detail is in chapters 2
& 3 of the White Book, “Statistical Models in S”. Unfortunately, I do not
have ready access to a major research library and I have way, way outspent
my book budget. Someday I’ll probably buy a copy, but for the time being, I
am stuck without it. So it would be great to have a piece of code that uses
them explained in detail.

Warmest regards to all,  andrewH




--
View this message in context: 
http://r.789695.n4.nabble.com/Learning-the-R-way-A-Wish-tp4660287.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] Syntax for error messages

2013-03-04 Thread David Winsemius

On Mar 4, 2013, at 3:09 PM, Fisher Dennis wrote:

> R 2.15
> OS X and Windows
> 
> Colleagues,
> 
> I am running a lengthy R script (> 20K lines of code) within a GUI build in 
> RealBasic.  There are rare instances in which an error is triggered in R.  I 
> am trying to trap these based on their syntax.  I have identified three 
> general formats for error messages:
>   Error in
>   Error: object
>   Error: could
> Each is these is followed by some informative text.  However, these stems are 
> sufficient to identify these particular errors.
> 
> Are there other stems that I have missed?

After a bit of searching the See also links from try  You might want to 
look at the "1.9.2 R messages" section in Writing R Extensions. It describes 
the method of extraction of error and warning messages from a package.

-- 
David Winsemius
Alameda, CA, USA

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


[R] Syntax for error messages

2013-03-04 Thread Fisher Dennis
R 2.15
OS X and Windows

Colleagues,

I am running a lengthy R script (> 20K lines of code) within a GUI build in 
RealBasic.  There are rare instances in which an error is triggered in R.  I am 
trying to trap these based on their syntax.  I have identified three general 
formats for error messages:
Error in
Error: object
Error: could
Each is these is followed by some informative text.  However, these stems are 
sufficient to identify these particular errors.

Are there other stems that I have missed?

Dennis

Dennis Fisher MD
P < (The "P Less Than" Company)
Phone: 1-866-PLessThan (1-866-753-7784)
Fax: 1-866-PLessThan (1-866-753-7784)
www.PLessThan.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] What package can I use to help me categorize comment responses?

2013-03-04 Thread Rolf Turner

On 03/05/2013 09:28 AM, Lopez, Dan wrote:

Hi,

We have comment questions from a survey that we need to categorize. What 
package and functions can I use in R to help do this?


There was a fairly recent posting about a package called "qdap" that might
be relevant.  See:

http://cran.r-project.org/web/packages/qdap/index.html

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] SAS and R complement each other

2013-03-04 Thread Peter Ehlers

On 2013-03-04 12:30, David Winsemius wrote:


On Mar 4, 2013, at 12:18 PM, Peter Ehlers wrote:


On 2013-03-04 12:04, Ista Zahn wrote:

On Mon, Mar 4, 2013 at 2:57 PM, Rolf Turner  wrote:


I never saw the "original note" nor its resubmission.  Nor could I find it
in the R-help archives.

Is it just me?


No, same here.


Think Nabble!!!
(where there are often waits for approval)


"Think Nabble" is correct, however, that wait will take infinite time on some 
posts. There is now an automatic censoring process for Nabble posts that resemble the 
signatures of prior spambot attacks on Rhelp. It was known that some innocent posts would 
be affected, including, unfortunately, some of the posts from our most valued members if 
they happen to be posting from Nabble at the time.  This eventuality was noted when those 
filters were installed. In this case Frank saw it on Nabble and gave a perfectly valid 
reply that was not censored.

The moderation queue was getting 20 or thirty postings that on cursory review 
were valid, but which turned out on investigation to be duplicates of prior 
Nabble-mediated posts and the only new content was bogus advertising. The  
moderators were not volunteering to do investigation of all such posts.



I probably should have said: "Think the _curse_ of Nabble!"

Hey, that might make a great movie title: "The Curse of Nabble".
Starring, of course, Peter Lorre, Christopher Lee and Boris Karloff,
each of whom has at least one 'r' in his name.

Peter Ehlers

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] package ‘contingency.tables’ is not available (for R version 2.15.2)

2013-03-04 Thread Joanna Papakonstantinou
Thank you.
I actually ended up using:

> CrossTable(mdt)

   Cell Contents
|-|
|   N |
| Chi-square contribution |
|   N / Row Total |
|   N / Col Total |
| N / Table Total |
|-|


Total Observations in Table:  8


 |
 |  Blue | Green |   Red | Row Total |
-|---|---|---|---|
   A | 1 | 0 | 1 | 2 |
 | 0.083 | 0.500 | 0.083 |   |
 | 0.500 | 0.000 | 0.500 | 0.250 |
 | 0.333 | 0.000 | 0.333 |   |
 | 0.125 | 0.000 | 0.125 |   |
-|---|---|---|---|
   G | 1 | 0 | 1 | 2 |
 | 0.083 | 0.500 | 0.083 |   |
 | 0.500 | 0.000 | 0.500 | 0.250 |
 | 0.333 | 0.000 | 0.333 |   |
 | 0.125 | 0.000 | 0.125 |   |
-|---|---|---|---|
   H | 1 | 0 | 1 | 2 |
 | 0.083 | 0.500 | 0.083 |   |
 | 0.500 | 0.000 | 0.500 | 0.250 |
 | 0.333 | 0.000 | 0.333 |   |
 | 0.125 | 0.000 | 0.125 |   |
-|---|---|---|---|
   W | 0 | 2 | 0 | 2 |
 | 0.750 | 4.500 | 0.750 |   |
 | 0.000 | 1.000 | 0.000 | 0.250 |
 | 0.000 | 1.000 | 0.000 |   |
 | 0.000 | 0.250 | 0.000 |   |
-|---|---|---|---|
Column Total | 3 | 2 | 3 | 8 |
 | 0.375 | 0.250 | 0.375 |   |
-|---|---|---|---|


and

> expected.counts <- (apply(mdt,1,sum) %o% apply(mdt,2,sum))/sum(mdt)

> print(expected.counts)

  Blue Green  Red

A 0.75   0.5 0.75

G 0.75   0.5 0.75

H 0.75   0.5 0.75

W 0.75   0.5 0.75
to get the info I needed.


Regards,
Joanna

On Mon, Mar 4, 2013 at 2:15 PM, Milan Bouchet-Valat wrote:

> Le lundi 04 mars 2013 à 12:37 -0600, Joanna Papakonstantinou a écrit :
> > I am trying to create contingency tables (to evaluate prior to performing
> > Pearson's Chi-Squared test for independence). I would like to see column
> > and row totals as well as expected and observed values and cell counts.
> > I tried to use the package "contingency. tables" but get the following
> > warning:
> >  package contingency.tables is not available (for R versions 2.15.2)
> > Is there something comparable or was this replaced with something else
> for
> > later versions of R.
> > Any help would be appreciated so that I may create a contigencey table
> like
> > this.
> I'm not aware of the existence of such a package, but base R provides
> most of what you need, and other packages offer even more. See e.g.
> http://www.statmethods.net/stats/frequencies.html
>
>
> Regards
>



-- 
**


*Joanna Papakonstantinou, Ph.D.*

[[alternative HTML version deleted]]

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


Re: [R] histogram

2013-03-04 Thread arun
Hi,

dat1<- read.csv("rightest.csv",sep=",",header=TRUE,check.names=FALSE)
 dat2<- as.dist(dat1[,-1],upper=F,diag=F)
vec1<- as.vector(dat2)
label1=c("0-25","25-50","50-75")
Name1<-unlist(lapply(0:123,function(i) rep(i+1,i)))
dat3<-data.frame(Name1,vec1)
res<-t(aggregate(.~Name1,data=dat3,function(x) 
table(cut(x,breaks=seq(0,75,25),labels=label1
colnames(res)<- res[1,]
res1<- res[-1,]
row.names(res1)<-gsub("vec1.","",row.names(res1))
res1
Names2<-apply(res1,1,function(x) paste(which(x!=0),collapse=","))
res2<- data.frame(Frequency=apply(res1,1,function(x) sum(1*(x!=0))), 
stations=Names2,stringsAsFactors=FALSE)

res2
#  Frequency
#0-25    121
#25-50   122
#50-75    76




   #stations
#0-25    
#1,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123
#25-50 
#2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123
#50-75  
   
#10,16,22,25,27,30,31,33,34,35,36,37,38,39,40,41,47,48,50,53,56,58,59,61,64,65,68,69,70,73,75,76,77,78,79,80,81,82,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,121,123

A.K.


From: eliza botto 
To: "smartpink...@yahoo.com"  
Sent: Monday, March 4, 2013 3:21 PM
Subject: RE: histogram



Dear Arun,


Thanks for replying
Although codes well defined my problem but the table in the end should look 
like the following

its just an imaginary table.
Range                          stations                                         
Frequency
0-25                           1,2,3,8,9                                        
   5
25-50                      4,10,11,100                                      
   4
50-75                          55,56,57                                         
   3
Where the "station" column shows the stations where distance of station is 
between the corresponding range like 1,2,3,8,9 have the distance between 
0-25

i hope you wont mind

elisa




> Date: Mon, 4 Mar 2013 11:56:43 -0800
> From: smartpink...@yahoo.com
> Subject: Re: histogram
> To: eliza_bo...@hotmail.com
> CC: r-help@r-project.org
> 
> Hi Elisa,
> 
> I am not sure about the output you wanted.
> dat1<- read.csv("rightest.csv",sep=",",header=TRUE,check.names=FALSE)
>  dat2<- as.dist(dat1[,-1],upper=F,diag=F)
> vec1<- as.vector(dat2)
> label1=c("0-25","25-50","50-75")
> Count1<- as.data.frame(table(cut(vec1,breaks=seq(0,75,25),labels=label1))) 
> #Overall count
>  Count1
> #   Var1 Freq
> #1  0-25 5465
> #2 25-50 1992
> #3 50-75  169
> 
> 
> Name1<-unlist(lapply(0:123,function(i) rep(i+1,i)))
>  length(Name1)
> #[1] 7626
> dat3<-data.frame(Name1,vec1)
> res<-t(aggregate(.~Name1,data=dat3,function(x) 
> table(cut(x,breaks=seq(0,75,25),labels=label1
> colnames(res)<- res[1,]
>  res1<- res[-1,]
> row.names(res1)<-gsub("vec1.","",row.names(res1))
> res1
> #  2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 
> 28
> #0-25  1 0 2 0 2 3 2 1  1  1  3  1  1  3  2  3  6  3  5  2  4  8 13 21 21 23 
> 20
> #25-50 0 2 1 4 3 3 5 7  8  8  8 11 12 11 13 12 11 15 14 18 17 12 10  3  2  3  
> 6
> #50-75 0 0 0 0 0 0 0 0  0  1  0  0  0  0  0  1  0  0  0  0  0  2  0  0  2  0  
> 1
> -
> 
> A.K.
> 
> 
> 
> 
> 
> 
> From: eliza botto 
> To: "smartpink...@yahoo.com"  
> Sent: Monday, March 4, 2013 11:36 AM
> Subject: histogram
> 
> 
> 
> Dear Arun,
> 
> i have a distance matrix as attached in excel file with this email. You can 
> read the data via R and 
> after reading the data i want you to extract the lower part of distance 
> matrix by 
> as.dist(x, upper=F, diag=F). You will see that there 
> are 124 stations in my study. After that, i want to divide the data into 
> three intervals 0-

Re: [R] What package can I use to help me categorize comment responses?

2013-03-04 Thread MacQueen, Don
Daniel,

Looking at CRAN, the following might be useful:

  memiscTools for Management of Survey Data, Graphics, Programming,
Statistics, and Simulation
  questionr Functions to make surveys processing easier
  surveyanalysis of complex survey samples
  surveydataTools to manipulate survey data



and possibly
  questionr Functions to make surveys processing easier
  samplingbook  Survey Sampling Procedures

I recently saw an r-help message that mentioned the psych package in
regard to surveys.

If you're looking specifically at free-form comments, where the respondent
can say anything they want, there is I think at least one package designed
for analysis of text and/or searching text for key words and the like.

-Don

-- 
Don MacQueen

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





On 3/4/13 12:28 PM, "Lopez, Dan"  wrote:

Hi,

We have comment questions from a survey that we need to categorize. What
package and functions can I use in R to help do this?

Daniel Lopez
Lawrence Livermore Labs
SHRM


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

2013-03-04 Thread arun
Hi,
Sorry, I forgot names(which()
Names2<-apply(res1,1,function(x) paste(names(which(x!=0)),collapse=","))

res2<- data.frame(Frequency=apply(res1,1,function(x) sum(1*(x!=0))), 
stations=Names2,stringsAsFactors=FALSE)
 res2
 #     Frequency
#0-25    121
#25-50   122
#50-75    76




 #stations
#0-25    
#2,4,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124
#25-50 
#3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124
#50-75  
    
#11,17,23,26,28,31,32,34,35,36,37,38,39,40,41,42,48,49,51,54,57,59,60,62,65,66,69,70,71,74,76,77,78,79,80,81,82,83,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,122,124


A.K.



- Original Message -
From: arun 
To: eliza botto 
Cc: R help 
Sent: Monday, March 4, 2013 3:26 PM
Subject: Re: histogram

Hi,

dat1<- read.csv("rightest.csv",sep=",",header=TRUE,check.names=FALSE)
 dat2<- as.dist(dat1[,-1],upper=F,diag=F)
vec1<- as.vector(dat2)
label1=c("0-25","25-50","50-75")
Name1<-unlist(lapply(0:123,function(i) rep(i+1,i)))
dat3<-data.frame(Name1,vec1)
res<-t(aggregate(.~Name1,data=dat3,function(x) 
table(cut(x,breaks=seq(0,75,25),labels=label1
colnames(res)<- res[1,]
res1<- res[-1,]
row.names(res1)<-gsub("vec1.","",row.names(res1))
res1
Names2<-apply(res1,1,function(x) paste(which(x!=0),collapse=","))
res2<- data.frame(Frequency=apply(res1,1,function(x) sum(1*(x!=0))), 
stations=Names2,stringsAsFactors=FALSE)

res2
#  Frequency
#0-25    121
#25-50   122
#50-75    76




   #stations
#0-25    
#1,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123
#25-50 
#2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123
#50-75  
   
#10,16,22,25,27,30,31,33,34,35,36,37,38,39,40,41,47,48,50,53,56,58,59,61,64,65,68,69,70,73,75,76,77,78,79,80,81,82,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,121,123

A.K.


From: eliza botto 
To: "smartpink...@yahoo.com"  
Sent: Monday, March 4, 2013 3:21 PM
Subject: RE: histogram



Dear Arun,


Thanks for replying
Although codes well defined my problem but the table in the end should look 
like the following

its just an imaginary table.
Range                          stations                                         
Frequency
0-25                           1,2,3,8,9                                        
   5
25-50                      4,10,11,100                                      
   4
50-75                          55,56,57                                         
   3
Where the "station" column shows the stations where dist

Re: [R] SAS and R complement each other

2013-03-04 Thread David Winsemius

On Mar 4, 2013, at 12:18 PM, Peter Ehlers wrote:

> On 2013-03-04 12:04, Ista Zahn wrote:
>> On Mon, Mar 4, 2013 at 2:57 PM, Rolf Turner  wrote:
>>> 
>>> I never saw the "original note" nor its resubmission.  Nor could I find it
>>> in the R-help archives.
>>> 
>>> Is it just me?
>> 
>> No, same here.
> 
> Think Nabble!!!
> (where there are often waits for approval)

"Think Nabble" is correct, however, that wait will take infinite time on some 
posts. There is now an automatic censoring process for Nabble posts that 
resemble the signatures of prior spambot attacks on Rhelp. It was known that 
some innocent posts would be affected, including, unfortunately, some of the 
posts from our most valued members if they happen to be posting from Nabble at 
the time.  This eventuality was noted when those filters were installed. In 
this case Frank saw it on Nabble and gave a perfectly valid reply that was not 
censored.

The moderation queue was getting 20 or thirty postings that on cursory review 
were valid, but which turned out on investigation to be duplicates of prior 
Nabble-mediated posts and the only new content was bogus advertising. The  
moderators were not volunteering to do investigation of all such posts. 

-- 
David Winsemius
Alameda, CA, USA

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


[R] What package can I use to help me categorize comment responses?

2013-03-04 Thread Lopez, Dan
Hi,

We have comment questions from a survey that we need to categorize. What 
package and functions can I use in R to help do this?

Daniel Lopez
Lawrence Livermore Labs
SHRM


[[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] interactive visualizations - anyone use SVGAnnotation?

2013-03-04 Thread Paul Murrell

Hi

An alternative is the 'gridSVG' package
http://www.stat.auckland.ac.nz/~paul/gridSVG/gridsvg.pdf

Paul

On 02/03/13 06:12, Joseph Clark wrote:


Hi all:I found some great demonstrations of interactive presentation graphics generated in R with the SVGAnnotation package, here:http://www.omegahat.org/SVGAnnotation/http://www.omegahat.org/SVGAnnotation/SVGAnnotationPaper/SVGAnnotationPaper.htmlI tried to install the package available at that website (it's not on CRAN) and am getting some pretty uninformative errors (see below).  My best guess is that the package worked under an earlier version of R but is broken now.  Do any of you use this package for interactive presentation graphics?  Or, what are some good alternative libraries?  I've played around a bit with 'iplots' and RStudio's 'manipulate' library, but those are really geared for exploratory analysis.  I'm looking for something geared toward presentation, for example, on a web page.  A good "hello,world" I want to accomplish would be a time series with 2 or more line graphs that the viewer can choose between with radio buttons or checkboxes.Thanks in advance! The error 

I get when trying to install SVGAnnotation from the file: > 
install.packages("SVGAnnotation_0.93-1.tar.gz",repos=NULL)

Warning in install.packages :
   package ‘SVGAnnotation_0.93-1.tar.gz’ is not available (for R version 2.15.1)
Installing package(s) into ‘C:/Program Files/R/R-2.15.1/library’
(as ‘lib’ is unspecified)
Warning in install.packages :
   error 1 in extracting from zip file
Warning in install.packages :
   cannot open compressed file 'SVGAnnotation_0.93-1.tar.gz/DESCRIPTION', 
probable reason 'No such file or directory'
Error in install.packages : cannot open the connection


// joseph w. clark , phd , visiting research associate
\\ university of nebraska at omaha - college of IS&T

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



--
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
p...@stat.auckland.ac.nz
http://www.stat.auckland.ac.nz/~paul/

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

2013-03-04 Thread Peter Ehlers

On 2013-03-04 12:04, Ista Zahn wrote:

On Mon, Mar 4, 2013 at 2:57 PM, Rolf Turner  wrote:


I never saw the "original note" nor its resubmission.  Nor could I find it
in the R-help archives.

Is it just me?


No, same here.


Think Nabble!!!
(where there are often waits for approval)

Peter Ehlers

[...snip...]

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

2013-03-04 Thread Milan Bouchet-Valat
Le mardi 05 mars 2013 à 08:57 +1300, Rolf Turner a écrit :
> I never saw the "original note" nor its resubmission.  Nor could I find it
> in the R-help archives.
> 
> Is it just me?
> 
> Not that it really matters a damn --- I don't use SAS either --- I'm just
> curious, and find the situation mysterious.
A link to Nabble was at the end of Frank's reply:
http://r.789695.n4.nabble.com/SAS-and-R-complement-each-other-tp4660157p4660190.html

Probably not worth a read, though (especially because the message only
talks about... SAS, not R).


Regards

> On 03/04/2013 04:32 PM, Frank Harrell wrote:
> > I'm not sure why you posted the original note.  I quit using SAS in 1991 and
> > haven't needed it yet.
> > Frank
> >
> > RogerJDeAngelis wrote
> >> Sorry about the double post. But I keep getting 'post' rejections, so I
> >> resubmitted about an hour later.
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Upgrading to R version 2.15.3 under Fedora.

2013-03-04 Thread Rolf Turner


Thanks Marc.  All very clear, cogent and useful.  Sorry for not
sending my original post to r-sig-fedora; I *knew* about that,
but had (in my dotage?) forgotten.

cheers,

Rolf

On 03/05/2013 09:01 AM, Marc Schwartz wrote:

On Mar 4, 2013, at 1:48 PM, Rolf Turner  wrote:


 From time to time since the release of R 2.15.3 was announced
I have tried to upgrade from 2.15.2 by doing

sudo yum install R

I keep getting


Package R-2.15.2-1.fc17.x86_64 already installed and latest version
Nothing to do

Has the upgrade really not propagated to the Fedora repositories yet?

Or is it the case that I am doing something wrong or that there is some
other action or adjustment required?

I am running Fedora 17.1.

Thanks for any hints.

cheers,

Rolf Turner


Rolf,

According to Koji, which is the Fedora build system:

   http://koji.fedoraproject.org/koji/packageinfo?packageID=1230

2.15.3 is not yet available. So 2.15.2 is the most recent version available 
from the Fedora stable repos.

You would also want to typically use:

   sudo yum update R

You could contact Tom Callaway to see what the timeline for 2.15.3 might be. He 
is cc'd here for convenience.

Also, you can track the general package building and testing status for R here:

   https://admin.fedoraproject.org/updates/R

BTW Rolf, Fedora (and RH/RH derivative) related queries should go to 
r-sig-fedora:

   https://stat.ethz.ch/mailman/listinfo/r-sig-fedora

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] package ‘contingency.tables’ is not available (for R version 2.15.2)

2013-03-04 Thread Milan Bouchet-Valat
Le lundi 04 mars 2013 à 12:37 -0600, Joanna Papakonstantinou a écrit :
> I am trying to create contingency tables (to evaluate prior to performing
> Pearson's Chi-Squared test for independence). I would like to see column
> and row totals as well as expected and observed values and cell counts.
> I tried to use the package "contingency. tables" but get the following
> warning:
>  package contingency.tables is not available (for R versions 2.15.2)
> Is there something comparable or was this replaced with something else for
> later versions of R.
> Any help would be appreciated so that I may create a contigencey table like
> this.
I'm not aware of the existence of such a package, but base R provides
most of what you need, and other packages offer even more. See e.g.
http://www.statmethods.net/stats/frequencies.html


Regards

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

2013-03-04 Thread David Winsemius

On Mar 4, 2013, at 11:31 AM, William Dunlap wrote:

> Use ave().  The following tries to save a little time and simplify things
> by only processing the duplicated entries.
> 
>> Vec
>   [1] "B" "B" "C" "E" "B" "E" "E" "D" "D" "A"
>> f <- function(v) {
>  + d <- duplicated(v)
>  + v[d] <- ave(v[d], v[d], FUN=function(vdi)paste0(vdi, seq_along(vdi)))
>  + v
>  + }
>> f(Vec)
>   [1] "B"  "B1" "C"  "E"  "B2" "E1" "E2" "D"  "D1" "A"

And notice that this is the functionality provided by 'make.names' called by 
the read.* functions:

> make.names(Vec, unique=TRUE)
 [1] "B"   "B.1" "C"   "E"   "B.2" "E.1" "E.2" "D"   "D.1" "A"  
> ?make.names


-- 
David.

> Bill Dunlap
> Spotfire, TIBCO Software
> wdunlap tibco.com
> 
> 
>> -Original Message-
>> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
>> Behalf
>> Of Christofer Bogaso
>> Sent: Monday, March 04, 2013 11:14 AM
>> To: r-help
>> Subject: [R] A problem with text manipulation
>> 
>> Hello again,
>> 
>> Let say I have following vector:
>> 
>> set.seed(1)
>> Vec <- sample(LETTERS[1:5], 10, replace = TRUE)
>> Vec
>> 
>> Now with each repeated letter, I like to add suffix programatically.
>> Therefore I want to get following vector:
>> 
>> c("B", "B1", "C", "E", "B2", "E1", "E2", "D", "D1", "A")
>> 
>> Can somebody tell me how to achieve that?
>> 
>> Thanks and regards,
>> 
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

David Winsemius
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] A problem with text manipulation

2013-03-04 Thread arun
Hi,
You could use:


res<-unsplit(lapply(split(Vec,Vec),function(x) if(length(x)>1) 
c(head(x,1),paste0(head(x,-1),seq_along(head(x,-1 else x),Vec)
 res
# [1] "B"  "B1" "C"  "E"  "B2" "E1" "E2" "D"  "D1" "A" 
A.K.



- Original Message -
From: Christofer Bogaso 
To: r-help 
Cc: 
Sent: Monday, March 4, 2013 2:13 PM
Subject: [R] A problem with text manipulation

Hello again,

Let say I have following vector:

set.seed(1)
Vec <- sample(LETTERS[1:5], 10, replace = TRUE)
Vec

Now with each repeated letter, I like to add suffix programatically.
Therefore I want to get following vector:

c("B", "B1", "C", "E", "B2", "E1", "E2", "D", "D1", "A")

Can somebody tell me how to achieve that?

Thanks and regards,

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

2013-03-04 Thread Ista Zahn
On Mon, Mar 4, 2013 at 2:57 PM, Rolf Turner  wrote:
>
> I never saw the "original note" nor its resubmission.  Nor could I find it
> in the R-help archives.
>
> Is it just me?

No, same here.

>
> Not that it really matters a damn --- I don't use SAS either --- I'm just
> curious, and find the situation mysterious.
>
> cheers,
>
> Rolf
>
>
> On 03/04/2013 04:32 PM, Frank Harrell wrote:
>>
>> I'm not sure why you posted the original note.  I quit using SAS in 1991
>> and
>> haven't needed it yet.
>> Frank
>>
>> RogerJDeAngelis wrote
>>>
>>> Sorry about the double post. But I keep getting 'post' rejections, so I
>>> resubmitted about an hour later.
>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Upgrading to R version 2.15.3 under Fedora.

2013-03-04 Thread Marc Schwartz
On Mar 4, 2013, at 1:48 PM, Rolf Turner  wrote:

> 
> From time to time since the release of R 2.15.3 was announced
> I have tried to upgrade from 2.15.2 by doing
> 
>sudo yum install R
> 
> I keep getting
> 
>> Package R-2.15.2-1.fc17.x86_64 already installed and latest version
>> Nothing to do
> 
> Has the upgrade really not propagated to the Fedora repositories yet?
> 
> Or is it the case that I am doing something wrong or that there is some
> other action or adjustment required?
> 
> I am running Fedora 17.1.
> 
> Thanks for any hints.
> 
>cheers,
> 
>Rolf Turner


Rolf,

According to Koji, which is the Fedora build system:

  http://koji.fedoraproject.org/koji/packageinfo?packageID=1230

2.15.3 is not yet available. So 2.15.2 is the most recent version available 
from the Fedora stable repos.

You would also want to typically use:

  sudo yum update R

You could contact Tom Callaway to see what the timeline for 2.15.3 might be. He 
is cc'd here for convenience.

Also, you can track the general package building and testing status for R here:

  https://admin.fedoraproject.org/updates/R

BTW Rolf, Fedora (and RH/RH derivative) related queries should go to 
r-sig-fedora:

  https://stat.ethz.ch/mailman/listinfo/r-sig-fedora

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] SAS and R complement each other

2013-03-04 Thread Rolf Turner


I never saw the "original note" nor its resubmission.  Nor could I find it
in the R-help archives.

Is it just me?

Not that it really matters a damn --- I don't use SAS either --- I'm just
curious, and find the situation mysterious.

cheers,

Rolf

On 03/04/2013 04:32 PM, Frank Harrell wrote:

I'm not sure why you posted the original note.  I quit using SAS in 1991 and
haven't needed it yet.
Frank

RogerJDeAngelis wrote

Sorry about the double post. But I keep getting 'post' rejections, so I
resubmitted about an hour later.


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

2013-03-04 Thread arun
Hi Elisa,

I am not sure about the output you wanted.
dat1<- read.csv("rightest.csv",sep=",",header=TRUE,check.names=FALSE)
 dat2<- as.dist(dat1[,-1],upper=F,diag=F)
vec1<- as.vector(dat2)
label1=c("0-25","25-50","50-75")
Count1<- as.data.frame(table(cut(vec1,breaks=seq(0,75,25),labels=label1))) 
#Overall count
 Count1
#   Var1 Freq
#1  0-25 5465
#2 25-50 1992
#3 50-75  169


Name1<-unlist(lapply(0:123,function(i) rep(i+1,i)))
 length(Name1)
#[1] 7626
dat3<-data.frame(Name1,vec1)
res<-t(aggregate(.~Name1,data=dat3,function(x) 
table(cut(x,breaks=seq(0,75,25),labels=label1
colnames(res)<- res[1,]
 res1<- res[-1,]
row.names(res1)<-gsub("vec1.","",row.names(res1))
res1
#  2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
#0-25  1 0 2 0 2 3 2 1  1  1  3  1  1  3  2  3  6  3  5  2  4  8 13 21 21 23 20
#25-50 0 2 1 4 3 3 5 7  8  8  8 11 12 11 13 12 11 15 14 18 17 12 10  3  2  3  6
#50-75 0 0 0 0 0 0 0 0  0  1  0  0  0  0  0  1  0  0  0  0  0  2  0  0  2  0  1
-

A.K.






Fr

istogram



Dear Arun,

i have a distance matrix as attached in excel file with this email. You can 
read the data via R and 
after reading the data i want you to extract the lower part of distance matrix 
by 
as.dist(x, upper=F, diag=F). You will see that there 
are 124 stations in my study. After that, i want to divide the data into three 
intervals 0-25, 25-75, 
75-100. Then i want to count the number of stations falling in each interval, 
which will be called 
"Frequency". After that i want to draw the following table
Range     stations  
   Frequency
0-25   names of station 
     Number of stations
25-50  
50-75
Finally, i want to draw histogram. i know i asked same kind of question before, 
but those commands are not working on distance matrix.

thankyou very very much in advance
elisa

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Upgrading to R version 2.15.3 under Fedora.

2013-03-04 Thread Rolf Turner


From time to time since the release of R 2.15.3 was announced
I have tried to upgrade from 2.15.2 by doing

sudo yum install R

I keep getting


Package R-2.15.2-1.fc17.x86_64 already installed and latest version
Nothing to do


Has the upgrade really not propagated to the Fedora repositories yet?

Or is it the case that I am doing something wrong or that there is some
other action or adjustment required?

I am running Fedora 17.1.

Thanks for any hints.

cheers,

Rolf Turner

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


[R] package ‘contingency.tables’ is not available (for R version 2.15.2)

2013-03-04 Thread Joanna Papakonstantinou
I am trying to create contingency tables (to evaluate prior to performing
Pearson's Chi-Squared test for independence). I would like to see column
and row totals as well as expected and observed values and cell counts.
I tried to use the package "contingency. tables" but get the following
warning:
 package ‘contingency.tables’ is not available (for R versions 2.15.2)
Is there something comparable or was this replaced with something else for
later versions of R.
Any help would be appreciated so that I may create a contigencey table like
this.

Thank you.

**


*Joanna *

[[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] Raster images and saving with original pixel dimensions in tiff, jpeg, or png perferablly.

2013-03-04 Thread Paul Murrell

Hi

It sounds like you just want to control the size of the external raster 
image that you are creating.  For example ...


library(grid)

im <- matrix(0:1, ncol=3, nrow=3)

# grid.newpage()
grid.raster(im, interpolate=FALSE)

png("ident.png", 3, 3)
grid.raster(im, interpolate=FALSE)
dev.off()

Does that help?

Paul

On 03/03/13 11:03, Hans Thompson wrote:

Hello R-Help,

I want to be able to read in a raster image, plot it with grid.raster
or rasterImage and save the image with one pixel per a pixel element
from my array. Saved preferably in a common image format.

The real goal of my question is to eventually read in images with text
on them, manipulate them with my controlled functions, save them
without changing the image dimensions, and perform OCR outside R.

I have read The R Journal article on raster images
(http://journal.r-project.org/archive/2011-1/RJournal_2011-1_Murrell.pdf)
and have experimented with some of the par() variables with no
success.  There are some arguments in gird.raster that elude me
currently on how to use them.  These include, vjust, hjust,
default.units, gp and vp.  Perhaps these are what I need to use but I
am getting nowhere without more documentation.

Here is the basic code I've used to experiment with making this work.
The end result I'm hoping for would be an image exactly like the one
I've read in (Rlogo.jpg for this small example).  I turned off
dev.copy lines because I'm not sure on the guidelines for file writing
functions.

Thanks,
Hans Thompson

Forgive me If I made any mistakes following posting guidelines.

START#
library(jpeg)
library(grid)

img <- readJPEG(system.file("img", "Rlogo.jpg", package="jpeg"))
grid.raster(img, interpolate =F)
#turnon next line for output. Don't want to accidentally write any
unwanted files.
#dev.copy(tiff, "outputimage.tiff")
dev.off()

#or using package = "graphics" but not perfered.

library(graphics)

plot( c(0, dim(img)[2]), c(0, dim(img)[1]), type = "n", xlab = "", ylab = "")
rasterImage(img, 0, 0, dim(img)[2], dim(img)[1])
#dev.copy(tiff, "outputfile2.tiff")
dev.off()

##STOP##

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



--
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
p...@stat.auckland.ac.nz
http://www.stat.auckland.ac.nz/~paul/

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

2013-03-04 Thread Bert Gunter
Christofer:

This reminds me of those IQ puzzles I took so many years ago as a kid:
Given the numbers 7, 22, 43, 5, 26,...what are the next 3 numbers
in this series? I don't recall having a clue, and when I got older and
more mathematical, generally came to the conclusion that it could
logically be anything I wanted it to.

Anyway... that's my reaction to your post: I haven't a clue what rule
you used to construct the desired output from the input. But then
others may.  So of course I would not be able to tell you **how** to
write an R procedure that does it. But then others may. If not, I
would suggest that you reveal your secret.

Cheers,
Bert

On Mon, Mar 4, 2013 at 11:13 AM, Christofer Bogaso
 wrote:
> Hello again,
>
> Let say I have following vector:
>
> set.seed(1)
> Vec <- sample(LETTERS[1:5], 10, replace = TRUE)
> Vec
>
> Now with each repeated letter, I like to add suffix programatically.
> Therefore I want to get following vector:
>
> c("B", "B1", "C", "E", "B2", "E1", "E2", "D", "D1", "A")
>
> Can somebody tell me how to achieve that?
>
> Thanks and regards,
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] A problem with text manipulation

2013-03-04 Thread William Dunlap
Use ave().  The following tries to save a little time and simplify things
by only processing the duplicated entries.

  > Vec
   [1] "B" "B" "C" "E" "B" "E" "E" "D" "D" "A"
  > f <- function(v) {
  + d <- duplicated(v)
  + v[d] <- ave(v[d], v[d], FUN=function(vdi)paste0(vdi, seq_along(vdi)))
  + v
  + }
  > f(Vec)
   [1] "B"  "B1" "C"  "E"  "B2" "E1" "E2" "D"  "D1" "A"

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com


> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
> Behalf
> Of Christofer Bogaso
> Sent: Monday, March 04, 2013 11:14 AM
> To: r-help
> Subject: [R] A problem with text manipulation
> 
> Hello again,
> 
> Let say I have following vector:
> 
> set.seed(1)
> Vec <- sample(LETTERS[1:5], 10, replace = TRUE)
> Vec
> 
> Now with each repeated letter, I like to add suffix programatically.
> Therefore I want to get following vector:
> 
> c("B", "B1", "C", "E", "B2", "E1", "E2", "D", "D1", "A")
> 
> Can somebody tell me how to achieve that?
> 
> Thanks and regards,
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Excel User interface for R

2013-03-04 Thread David Winsemius

On Mar 4, 2013, at 5:39 AM, Tammy Ma wrote:

> 
> HI, 
> 
> Assume I have the data frame generated from R as the following:
> 
> Product Price market_share
>  A 10010%
>  B 1109%
> C  12020%
> D  90  61%
> 
> What I want to do is to have this kind of excel user interface by changing 
> price of certain products, to get the impact of market share generated from R:
> if I change A price from 100 to 90, and change B price from 110 to 100, based 
> on the calculation in R, I want to get the result from excel, for example,
> 
> 
> Product Price market_share
>  A 9020%
>  B 100   12%
> C  120   10%
> D  90 58%
> 
> 
> I want to have the excel interface which make me be able to change the value 
> in excel cell, then based on the calculation in R, then exported market share 
> impact in excel.
> 
> DO you have recommendation for such user interface or sth which make me 
> achieve this task?

When this request has appeared before, the advice given was to look at RExcel. 
That is only an option in the Windows environment.

-- 

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] Version Upgrade and Packages

2013-03-04 Thread David Winsemius

On Mar 4, 2013, at 8:28 AM, Rich Shepard wrote:

> On Mon, 4 Mar 2013, MacQueen, Don wrote:
> 
>> Immediately after you see one of those messages, do, e.g.,
>> 
>> find('cor')
> 
>> It should tell you that you have more than one object named 'cor' in your
>> search path, and where they all are. Then you can decide if it's what you
>> want (probably not, but can't say from here).
> 
> Don,
> 
>  find doesn't because these are apparently not individual files. So I run
> egrep -R 'cor' * or egrep -R 'as.Date' * within /usr/lib/R/library and see
> many instances of where these strings are used. Many are in help files.
> Others are used in different libraries; for example:

Don assumed you were in an R session. The `find` function in R takes a 
character argument. You did not produce the entire message because you should 
have seen immediately above that message the name of  a package being loaded 
(in this case most likely as part of the startup process)

?Startup

In my ,Rprofile I load both package:sos and package:utils and I see this at 
startupo:
---
Attaching package: ‘utils’

The following object(s) are masked from ‘package:sos’:

?


So the sos function '?' is masked by the utils function named '?'

> 
> gdata/unitTests/runit.getDateTimeParts.R:cDate <- as.Date(tDate)
> 
> plyr/tests/test-rbind.r:d = as.Date(c("2008-01-01", "2009-01-01",
> "2010-01-01")))
> 
> spacetime/demo/gvis.R:rural_PM10$time == as.Date("2003-12-31"))
> 
> timeDate/unitTests/runit.SpecialDates.R:dts <- as.Date(ch.dts)
> 
> zoo/NAMESPACE:   "as.Date",
> 
>  I'm not seeing code for as.Date, as.Date.numeric, or cor in multiple
> libraries.

Please read Uwe Ligges' excellent article regarding finding R code:

http://cran.r-project.org/doc/Rnews/Rnews_2006-4.pdf

-- 

David Winsemius
Alameda, CA, USA

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


[R] A problem with text manipulation

2013-03-04 Thread Christofer Bogaso
Hello again,

Let say I have following vector:

set.seed(1)
Vec <- sample(LETTERS[1:5], 10, replace = TRUE)
Vec

Now with each repeated letter, I like to add suffix programatically.
Therefore I want to get following vector:

c("B", "B1", "C", "E", "B2", "E1", "E2", "D", "D1", "A")

Can somebody tell me how to achieve that?

Thanks and regards,

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

2013-03-04 Thread Bert Gunter
1. You are right with your statements.

2. You should address all further discussion to the r-sig-mixed-models
list, not here.

-- Bert

On Mon, Mar 4, 2013 at 9:06 AM, Filipe Carvalho
 wrote:
> Hi List,
>
> I’ m analysing the selectivity of
> resting site use by forest carnivores through mixed modelling techniques and I
> wonder which will be the best r package to deal with several aspects 
> simultaneously:
> -  binomial
> variable response;
> -  possible
> spatial and/or temporal correlation;
> I have tried nlme (lme function) and
> lme4 (lmer function) packages, however I realize that the results were 
> different
> concerning regression coefficients estimates and p-values!
>
> In nlme package, despite I can add
> easily a variance structure and/or temporal and spatial correlations 
> structures,
> the choice of the “family = binomial” is not allowed. On the other hand, with 
> lme4
> I can choose the binomial familty, but no structures can be added!
>
>
> Am I wrong with these statements?
> Zuur et al. 2009 always used lme4 (Mass or glmmML) with binomial data but 
> never
> nlme!
> Can anyone help me? There is other options
> in R ?
>
>
> Thanks a lot!
> Best regards!
>
> Filipe Carvalho
>
> Filipe Carvalho, MSc, PhD student.
> Unidade de Biologia da Conservação (UBC) e
> Centro de Investigação em Biodiversidade e
> Recursos Genéticos (CIBIO),
> Universidade de Évora,
> Casa Cordovil, 2º Andar, Rua Dr.
> Joaquim Henrique da Fonseca,
> 7000-890 Évora, (PORTUGAL)
> Telefone: + 351266759350
>
>
> Filipe Carvalho, MSc, PhD student.
> Conservation Biology Unit (UBC) and
> Research Center in Biodiversity and
> Genetic Resources (CIBIO),
> University of Évora,
> Casa Cordovil, 2º Andar, Rua Dr.
> Joaquim Henrique da Fonseca,
> 7000-890 Évora, (PORTUGAL)
> Phone: + 351266759350
>
> [[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] R function for estimating historical-VaR

2013-03-04 Thread Blaser Nello
Does it just not work or does it not do the right thing? The reason it doesn't 
work is that you are writing 'T = length(returns) x_foc = vector(length=n) N = 
T-(n+1)' on one line instead of using three lines. However, your description of 
what you want to do also doesn't seem to correspond to the function. Please 
clarify what exactly you want the function to do. You could also write the 
current function as follows. 

VaR_foc <- function(returns, value=1000, p=.01, n=300) {
N <- length(returns)-n-1
op <- N*p
unlist(lapply(1:n, function(i) {-sort(returns[i:(N+i)])[op]*value}))
}

Nello Blaser


-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of ? ???
Sent: Montag, 4. März 2013 14:07
To: R-help@r-project.org
Subject: [R] R function for estimating historical-VaR



Hi everyone!! I am new in R and I want to create a simple R function for 
estimating historical-VaR.  In y_IBM returns, there are 2300 observations. For 
evaluation I take the next 2000 observations, then I abandon the latest 300 
observations. Firstly, I use the window which has the fix length and contains 
the observations from 1 to 2000 to estimate the VaR. At first I  take 2000 obs. 
and reorder these series in ascending order, from smallest return to largest 
return. Each ordered return is assigned an index value (1, 2, ...). At the 99% 
confidence level, the daily VaR under historical simulation method equals the 
return corresponding to the index number calculated as follows:
(1-0.99)*2000 (the number of our window) =20. The return corresponding to index 
20 is the daily historical simulation VaR.
I repeat the first step except the window changes the observations from 2 to 
2001. Such a process provides 300 one-step ahead VaR.
My function is:



VaR_foc <- function (returns, value = 1000, p = 0.01, n=251) { T = 
length(returns) x_foc = vector(length=n) N = T-(n+1)
m=sort(returns[1:N])
op = as.integer(N*p) # p % smallest
for (i in 2:n) {
g= returns[i:(N+i)]
ys = sort(g) # sort returns
x_foc[[1]] = -m[op]*value # VaR number
x_foc[i] = -ys[op]*value
}
return(x_foc)
}
VaR_foc (returns=y_IBM)

But the fucntion doesn't work,  can smbd help me wh

[[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] robustbase adjbox segfault - memory not mapped

2013-03-04 Thread Baan

Thank you Martin. Look forward to the fix.

Regards
Baan


On Monday 04 March 2013 10:19 PM, Martin Maechler wrote:

"B" == Baan  
 on Mon, 4 Mar 2013 15:02:02 +0530 writes:

 B> Hi, I encountered a segfault, memory not mapped error
 B> when using adjbox in robustbase. In trying to recreate
 B> the issue I found that the error occurs only for large
 B> sample size. Here is the code.

 >> require(robustbase)
 B> Loading required package: robustbase
 >> x <- rnorm(10)
 >> y <- rep(1, 10)
 >> adjbox(x ~ y) ## gives a plot
 >> x <- rnorm(1)
 >> y <- rep(1, 1)
 >> adjbox(x ~ y) ## gives a plot
 >> x <- rnorm(10)
 >> y <- rep(1, 10)
 >> adjbox(x ~ y)

 B> *** caught segfault ***
 B> address 0xfffcc47af530, cause 'memory not mapped'


 B> Traceback:
 B> 1: .C(mc_C, x, n, eps = eps, iter = c.iter, medc = double(1))
 B> 2: mcComp(x, doReflect, eps1 = eps1, eps2 = eps2, maxit = maxit,
 B> trace.lev = trace.lev)
 B> 3: mc.default(x, ..., na.rm = TRUE)
 B> 4: mc(x, ..., na.rm = TRUE)
 B> 5: adjboxStats(unclass(groups[[i]]), coef = range, doReflect = 
doReflect)
 B> 6: adjbox.default(split(mf[[response]], mf[-response]), ...)
 B> 7: adjbox(split(mf[[response]], mf[-response]), ...)
 B> 8: adjbox.formula(x ~ y)
 B> 9: adjbox(x ~ y)

Indeed, I (as maintainer of robustbase) can reproduce the
segfault *even* though you did not specify the random seed...

So this should be fixed ... hopefully within a week or so,
but I am not promising anything, given my busy schedule!

Martin Maechler,
ETH Zurich

[]

 B> My setup details:

 B> R --version
 B> R version 2.15.2 (2012-10-26) -- "Trick or Treat"

 B> Package:robustbase
 B> Version:0.9-5
 B> Date:   2012-03-01
 B> Packaged:   2013-03-01 16:34:03 UTC; maechler
 B> NeedsCompilation:   yes
 B> Repository: CRAN
 B> Date/Publication:   2013-03-01 18:31:33
 B> Built:  R 2.15.2; x86_64-pc-linux-gnu; 2013-03-04 05:54:20
 B> UTC; unix


 B> Platform: x86_64-pc-linux-gnu (64-bit)
 B> uname -a
 B> Linux R 2.6.32-5-amd64 #1 SMP Mon Feb 25 00:26:11 UTC 2013 x86_64 
GNU/Linux
 B> Debian squeeze

 B> Could someone pls help.

 B> Regards
 B> Baan


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

2013-03-04 Thread Filipe Carvalho
Hi List, 
 
I’ m analysing the selectivity of
resting site use by forest carnivores through mixed modelling techniques and I
wonder which will be the best r package to deal with several aspects 
simultaneously:
-          binomial
variable response;
-          possible
spatial and/or temporal correlation;
I have tried nlme (lme function) and
lme4 (lmer function) packages, however I realize that the results were different
concerning regression coefficients estimates and p-values!

In nlme package, despite I can add
easily a variance structure and/or temporal and spatial correlations structures,
the choice of the “family = binomial” is not allowed. On the other hand, 
with lme4
I can choose the binomial familty, but no structures can be added!

 
Am I wrong with these statements?
Zuur et al. 2009 always used lme4 (Mass or glmmML) with binomial data but never
nlme! 
Can anyone help me? There is other options
in R ?

 
Thanks a lot!
Best regards!
 
Filipe Carvalho
 
Filipe Carvalho, MSc, PhD student.
Unidade de Biologia da Conservação (UBC) e
Centro de Investigação em Biodiversidade e 
Recursos Genéticos (CIBIO),
Universidade de Évora,
Casa Cordovil, 2º Andar, Rua Dr. 
Joaquim Henrique da Fonseca, 
7000-890 Évora, (PORTUGAL)
Telefone: + 351266759350


Filipe Carvalho, MSc, PhD student.
Conservation Biology Unit (UBC) and
Research Center in Biodiversity and 
Genetic Resources (CIBIO),
University of Évora,
Casa Cordovil, 2º Andar, Rua Dr. 
Joaquim Henrique da Fonseca, 
7000-890 Évora, (PORTUGAL)
Phone: + 351266759350

[[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] Mysterious issues with reading text files from R in ArcGIS and Excel

2013-03-04 Thread Jeff Newmiller
Your description of diagnosis uses non-R software (off topic here). Please 
either describe the difference in the files (you may need a hex editor or the 
hexbin package to detect the differences) or supply the files that behave 
differently (this may require some alternate route than this mailing list if 
there are odd characters at fault).

For what it is worth, TXT is not a clearly-defined format, so this could be 
more effectively addressed by using a more specific format for data exchange.
---
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.

Kerry  wrote:

>I realize my command code is not writing a CSV file, I already pointed
>out that CSV file seems to work OK but not in the TXT format.
>�Regardless of that, there should be no problems in ArcGIS in reading
>the date column - in ArcGIS it will simply recognize it as a text field
>by default. �As I said in my initial posting, when I use other programs
>to create a text file (say textpad,wordpad, notepad or excel) and bring
>the txt file into ArcGIS, there is no dropping of the information - it
>doesn't turn the column into NA's. �It only does this when I try to add
>text files that were generated from using the write.table or write.csv.
>
>Any thoughts at to explain why I get 2 new columns of data in either
>the CSV format or the TXT format?
>�
>~K
>
>
>
>
>
>
>On 04/03/2013 10:52 AM, Kerry wrote:
>> Here's the first 5 lines of my dataset:
>> 
>> structure(list(id = structure(c(1L, 1L, 1L, 1L, 1L), .Label =
>c("F07001",
>> "F07002", "F07003", "F07004", "F07005", "F07006", "F07008", "F07009",
>> "F07010", "F07011", "F07014", "F07015", "F07017", "F07018", "F07019",
>> "F07020", "F07021", "F07022", "F07023", "F07024", "F10001", "F10002",
>> "F10004", "F10008", "F10009", "F10010", "F10012", "F10013", "F10014",
>> "F98015", "M07007", "M07012", "M07013", "M07016", "M10007", "M10011",
>> "M10015"), class = "factor"), x = c(1482445L, 1481274L, 1481279L,
>> 1481271L, 1480849L), y = c(6621768L, 6619628L, 6619630L, 6619700L,
>> 6620321L), date = structure(c(1173085253, 1173092441, 1173099672,
>> 1173106839, 1173114055), class = c("POSIXct", "POSIXt"), tzone = ""),
>>� �  R1dmed = c(2498.29727014221, 657.102921923195, 660.356911071581,
>>� �  620.139702002702, 378.186792471657), R1dmean =
>c(2498.29727014221,
>>� �  657.102921923195, 660.356911071581, 620.139702002702,
>378.186792471657
>>� �  ), R1error = c(FALSE, FALSE, FALSE, FALSE, FALSE), R2error =
>c(FALSE,
>>� �  FALSE, FALSE, FALSE, FALSE)), .Names = c("id", "x", "y",
>> "date", "R1dmed", "R1dmean", "R1error", "R2error"), row.names = c(NA,
>> 5L), class = "data.frame")
>> 
>> and here's the code I wrote for this file:
>> 
>> write.table(test, "D:/MooseEncounters/locations/Individual/test.txt")
>
>That's not a CSV file, it is being written with a blank as separator.� 
>Since it also has blanks in the formatted POSIXct column, you're very
>likely to run into problems reading it.
>
>Use write.csv(test, "test.csv") and you'll have fewer problems.� If you
>want tab-delimited columns instead, you'll need to specify that in the
>write.table call.
>
>Duncan Murdoch
>   [[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] Mysterious issues with reading text files from R in ArcGIS and Excel

2013-03-04 Thread Duncan Murdoch

On 04/03/2013 11:15 AM, Kerry wrote:
I realize my command code is not writing a CSV file, I already pointed 
out that CSV file seems to work OK but not in the TXT format.


Sorry.  In that case, I think you really do have to go to R-sig-Geo to 
find someone who knows about ArcGIS.


Duncan Murdoch

 Regardless of that, there should be no problems in ArcGIS in reading 
the date column - in ArcGIS it will simply recognize it as a text 
field by default.  As I said in my initial posting, when I use other 
programs to create a text file (say textpad,wordpad, notepad or excel) 
and bring the txt file into ArcGIS, there is no dropping of the 
information - it doesn't turn the column into NA's.  It only does this 
when I try to add text files that were generated from using the 
write.table or write.csv.


Any thoughts at to explain why I get 2 new columns of data in either 
the CSV format or the TXT format?

~K




On 04/03/2013 10:52 AM, Kerry wrote:
> Here's the first 5 lines of my dataset:
>
> structure(list(id = structure(c(1L, 1L, 1L, 1L, 1L), .Label = 
c("F07001",

> "F07002", "F07003", "F07004", "F07005", "F07006", "F07008", "F07009",
> "F07010", "F07011", "F07014", "F07015", "F07017", "F07018", "F07019",
> "F07020", "F07021", "F07022", "F07023", "F07024", "F10001", "F10002",
> "F10004", "F10008", "F10009", "F10010", "F10012", "F10013", "F10014",
> "F98015", "M07007", "M07012", "M07013", "M07016", "M10007", "M10011",
> "M10015"), class = "factor"), x = c(1482445L, 1481274L, 1481279L,
> 1481271L, 1480849L), y = c(6621768L, 6619628L, 6619630L, 6619700L,
> 6620321L), date = structure(c(1173085253, 1173092441, 1173099672,
> 1173106839, 1173114055), class = c("POSIXct", "POSIXt"), tzone = ""),
>R1dmed = c(2498.29727014221, 657.102921923195, 660.356911071581,
>620.139702002702, 378.186792471657), R1dmean = c(2498.29727014221,
>657.102921923195, 660.356911071581, 620.139702002702, 
378.186792471657

>), R1error = c(FALSE, FALSE, FALSE, FALSE, FALSE), R2error = c(FALSE,
>FALSE, FALSE, FALSE, FALSE)), .Names = c("id", "x", "y",
> "date", "R1dmed", "R1dmean", "R1error", "R2error"), row.names = c(NA,
> 5L), class = "data.frame")
>
> and here's the code I wrote for this file:
>
> write.table(test, "D:/MooseEncounters/locations/Individual/test.txt")

That's not a CSV file, it is being written with a blank as separator.  
Since it also has blanks in the formatted POSIXct column, you're very 
likely to run into problems reading it.


Use write.csv(test, "test.csv") and you'll have fewer problems.  If 
you want tab-delimited columns instead, you'll need to specify that in 
the write.table call.


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] issue creating a subset

2013-03-04 Thread Pablo Menese
Thanks a lot!!!


On Mon, Mar 4, 2013 at 12:46 PM, MacQueen, Don  wrote:

> What Jim said separately is correct, and I would suggest following his
> advice.
> But there are some points worth looking at in your method.
>
> See this example:
>
> > item1 <- item2 <- item3 <- item4 <- 1:4
> >
> > matrix1<-cbind(item1, item2, item3, item4)
> >
> > z <- c(TRUE,TRUE,FALSE,TRUE)
> >
> > matrix2 <- cbind(item1[z], item2[z], item3[z], item4[z])
> >
> > matrix3 <- cbind(item1=item1[z], item2=item2[z],
> +  item3=item3[z], item4=item4[z])
> >
> > print(matrix1)
>  item1 item2 item3 item4
> [1,] 1 1 1 1
> [2,] 2 2 2 2
> [3,] 3 3 3 3
> [4,] 4 4 4 4
> >
> > print(matrix2)
>  [,1] [,2] [,3] [,4]
> [1,]1111
> [2,]2222
> [3,]4444
> >
> > print(matrix3)
>  item1 item2 item3 item4
> [1,] 1 1 1 1
> [2,] 2 2 2 2
> [3,] 4 4 4 4
>
> Points to consider:
>
> Since your "z" is a vector of logical values, you don't need
>item1[z==T]
> instead, use
>item1[z]
>
> Your column names on matrix2 do not look correct, given how you created
> matrix2.
>
> Not that you can specify column names when you create the matrix using
> cbind, as in my matrix3 example.
>
> -Don
>
>
> --
> Don MacQueen
>
> Lawrence Livermore National Laboratory
> 7000 East Ave., L-627
> Livermore, CA 94550
> 925-423-1062
>
>
>
>
>
> On 2/28/13 5:53 PM, "Pablo Menese"  wrote:
>
> I'm performing item response theory with eRm packages
> I am excluding the persons that doesn't fit in the infit/outfit persons.
> for that I created a condition. then I have to create a new subset or
> matrix but with the condition.
>
> So:
>
> ORIGINAL
>
> matrix<-cbind(item1, item2, item3, item4)
>
> IF I PERFORM A head(matrix)
>
> item1 item2 item3 item4
>   3 2   3   1
>   3 1   2   4
>
> THEN I CREATE THE LOGIC CONDITION
>
> z<-thing==T
>
> THEN I TRY TO CREATE THE NEW MATRIX BUT WITH THE CONDITION
>
> matrix2<-cbind(item1[z==T], item2[z==T], item3[z==T], item4[z==T])
>
> THE ISSUE IS THAT IF I PERFORM A head(matrix2)
>
>  I1I2   I3  I4
>   3 2   3   1
>   3 1   2   4
>
> The names of the columns change at all.
>
> CAN ANYONE HELP ME TO KEEP THE SAME NAMES?
>
> [[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] Version Upgrade and Packages

2013-03-04 Thread Rich Shepard

On Mon, 4 Mar 2013, MacQueen, Don wrote:


Immediately after you see one of those messages, do, e.g.,

 find('cor')



It should tell you that you have more than one object named 'cor' in your
search path, and where they all are. Then you can decide if it's what you
want (probably not, but can't say from here).


Don,

  find doesn't because these are apparently not individual files. So I run
egrep -R 'cor' * or egrep -R 'as.Date' * within /usr/lib/R/library and see
many instances of where these strings are used. Many are in help files.
Others are used in different libraries; for example:

gdata/unitTests/runit.getDateTimeParts.R:cDate <- as.Date(tDate)

plyr/tests/test-rbind.r:d = as.Date(c("2008-01-01", "2009-01-01",
"2010-01-01")))

spacetime/demo/gvis.R:  rural_PM10$time == as.Date("2003-12-31"))

timeDate/unitTests/runit.SpecialDates.R:dts <- as.Date(ch.dts)

zoo/NAMESPACE:   "as.Date",

  I'm not seeing code for as.Date, as.Date.numeric, or cor in multiple
libraries.

Thanks,

Rich

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] robustbase adjbox segfault - memory not mapped

2013-03-04 Thread Martin Maechler
> "B" == Baan  
> on Mon, 4 Mar 2013 15:02:02 +0530 writes:

B> Hi, I encountered a segfault, memory not mapped error
B> when using adjbox in robustbase. In trying to recreate
B> the issue I found that the error occurs only for large
B> sample size. Here is the code.

>> require(robustbase)
B> Loading required package: robustbase
>> x <- rnorm(10)
>> y <- rep(1, 10)
>> adjbox(x ~ y) ## gives a plot
>> x <- rnorm(1)
>> y <- rep(1, 1)
>> adjbox(x ~ y) ## gives a plot
>> x <- rnorm(10)
>> y <- rep(1, 10)
>> adjbox(x ~ y)

B> *** caught segfault ***
B> address 0xfffcc47af530, cause 'memory not mapped'


B> Traceback:
B> 1: .C(mc_C, x, n, eps = eps, iter = c.iter, medc = double(1))
B> 2: mcComp(x, doReflect, eps1 = eps1, eps2 = eps2, maxit = maxit, 
B> trace.lev = trace.lev)
B> 3: mc.default(x, ..., na.rm = TRUE)
B> 4: mc(x, ..., na.rm = TRUE)
B> 5: adjboxStats(unclass(groups[[i]]), coef = range, doReflect = doReflect)
B> 6: adjbox.default(split(mf[[response]], mf[-response]), ...)
B> 7: adjbox(split(mf[[response]], mf[-response]), ...)
B> 8: adjbox.formula(x ~ y)
B> 9: adjbox(x ~ y)

Indeed, I (as maintainer of robustbase) can reproduce the
segfault *even* though you did not specify the random seed... 

So this should be fixed ... hopefully within a week or so,
but I am not promising anything, given my busy schedule!

Martin Maechler,
ETH Zurich

[]

B> My setup details:

B> R --version
B> R version 2.15.2 (2012-10-26) -- "Trick or Treat"

B> Package:robustbase
B> Version:0.9-5
B> Date:   2012-03-01
B> Packaged:   2013-03-01 16:34:03 UTC; maechler
B> NeedsCompilation:   yes
B> Repository: CRAN
B> Date/Publication:   2013-03-01 18:31:33
B> Built:  R 2.15.2; x86_64-pc-linux-gnu; 2013-03-04 05:54:20
B> UTC; unix


B> Platform: x86_64-pc-linux-gnu (64-bit)
B> uname -a
B> Linux R 2.6.32-5-amd64 #1 SMP Mon Feb 25 00:26:11 UTC 2013 x86_64 
GNU/Linux
B> Debian squeeze

B> Could someone pls help.

B> Regards
B> Baan

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

2013-03-04 Thread Eik Vettorazzi
There’s more than one way to skin a cat, here is another

mm<-model.matrix(~personId+law+0,testdata)
merge(testdata,aggregate(mm[,-1],list(personId=mm[,"personId"]),max))

cheers

Am 04.03.2013 16:44, schrieb David Studer:
> Hello everyone!
> 
> Does anyone of you know how I could solve the following problem.
> I guess, it is not a very difficult question, but I simply lack of the
> right idea:
> 
> I have a dataset containing data of convictions. This dataset contains 4
> columns:
> - personId: individual number that identifies the offender
> - law: law which has been violated
> - article: article which has been violated
> 
> # Testdata:
> personId<-c(1,1,2,2,2,2,2,3,4,4)
> law<-c("SVG", "SVG", "StGB", "StGB", "SVG", "AuG", "StGB", "SVG", "StGB",
> "AuG")
> article<-c(10, 10, 123, 122, 10, 40, 126, 10, 111, 40)
> testdata<-data.frame(personId, law, article)
> 
> Now I'd like to create three additional dummy-coded columns for each law
> (SVG, StGB, AuG).
> For each offender (all offenders have the same personId) it should be
> checked, whether there are
> any violations against the three laws. If there are any violations against
> SVG (for example), then
> in all rows of this offender the column SVG should have the value 1
> (otherwise 0).
> 
> For example offender 2 has once violated against law "SVG" therefore his
> four entries should have
> the value 1 at the column "SVG".
> 
> I hope you can understand my problem. I'd really appreciate any hints and
> solutions!
> 
> Thank you!
> David
> 
>   [[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.
> 


-- 
Eik Vettorazzi

Department of Medical Biometry and Epidemiology
University Medical Center Hamburg-Eppendorf

Martinistr. 52
20246 Hamburg

T ++49/40/7410-58243
F ++49/40/7410-57790
--
Pflichtangaben gemäß Gesetz über elektronische Handelsregister und 
Genossenschaftsregister sowie das Unternehmensregister (EHUG):

Universitätsklinikum Hamburg-Eppendorf; Körperschaft des öffentlichen Rechts; 
Gerichtsstand: Hamburg

Vorstandsmitglieder: Prof. Dr. Martin Zeitz (Vorsitzender), Dr. Alexander 
Kirstein, Joachim Prölß, Prof. Dr. Dr. Uwe Koch-Gromus

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

2013-03-04 Thread ONKELINX, Thierry
Have a look at cast() from the reshape package.

library(reshape)
cast(personId ~ law, data = testdata, value = "article", fun = length)
cast(personId ~ law, data = testdata, value = "article", fun = function(x){1 * 
(length(x) > 0)})


Van: r-help-boun...@r-project.org [r-help-boun...@r-project.org] namens David 
Studer [stude...@gmail.com]
Verzonden: maandag 4 maart 2013 16:44
Aan: r-help@r-project.org
Onderwerp: [R] urgent: question concerning data manipulation

Hello everyone!

Does anyone of you know how I could solve the following problem.
I guess, it is not a very difficult question, but I simply lack of the
right idea:

I have a dataset containing data of convictions. This dataset contains 4
columns:
- personId: individual number that identifies the offender
- law: law which has been violated
- article: article which has been violated

# Testdata:
personId<-c(1,1,2,2,2,2,2,3,4,4)
law<-c("SVG", "SVG", "StGB", "StGB", "SVG", "AuG", "StGB", "SVG", "StGB",
"AuG")
article<-c(10, 10, 123, 122, 10, 40, 126, 10, 111, 40)
testdata<-data.frame(personId, law, article)

Now I'd like to create three additional dummy-coded columns for each law
(SVG, StGB, AuG).
For each offender (all offenders have the same personId) it should be
checked, whether there are
any violations against the three laws. If there are any violations against
SVG (for example), then
in all rows of this offender the column SVG should have the value 1
(otherwise 0).

For example offender 2 has once violated against law "SVG" therefore his
four entries should have
the value 1 at the column "SVG".

I hope you can understand my problem. I'd really appreciate any hints and
solutions!

Thank you!
David

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


Re: [R] Mysterious issues with reading text files from R in ArcGIS and Excel

2013-03-04 Thread Kerry
I realize my command code is not writing a CSV file, I already pointed out that 
CSV file seems to work OK but not in the TXT format.  Regardless of that, there 
should be no problems in ArcGIS in reading the date column - in ArcGIS it will 
simply recognize it as a text field by default.  As I said in my initial 
posting, when I use other programs to create a text file (say textpad,wordpad, 
notepad or excel) and bring the txt file into ArcGIS, there is no dropping of 
the information - it doesn't turn the column into NA's.  It only does this when 
I try to add text files that were generated from using the write.table or 
write.csv.

Any thoughts at to explain why I get 2 new columns of data in either the CSV 
format or the TXT format?
 
~K






On 04/03/2013 10:52 AM, Kerry wrote:
> Here's the first 5 lines of my dataset:
> 
> structure(list(id = structure(c(1L, 1L, 1L, 1L, 1L), .Label = c("F07001",
> "F07002", "F07003", "F07004", "F07005", "F07006", "F07008", "F07009",
> "F07010", "F07011", "F07014", "F07015", "F07017", "F07018", "F07019",
> "F07020", "F07021", "F07022", "F07023", "F07024", "F10001", "F10002",
> "F10004", "F10008", "F10009", "F10010", "F10012", "F10013", "F10014",
> "F98015", "M07007", "M07012", "M07013", "M07016", "M10007", "M10011",
> "M10015"), class = "factor"), x = c(1482445L, 1481274L, 1481279L,
> 1481271L, 1480849L), y = c(6621768L, 6619628L, 6619630L, 6619700L,
> 6620321L), date = structure(c(1173085253, 1173092441, 1173099672,
> 1173106839, 1173114055), class = c("POSIXct", "POSIXt"), tzone = ""),
>     R1dmed = c(2498.29727014221, 657.102921923195, 660.356911071581,
>     620.139702002702, 378.186792471657), R1dmean = c(2498.29727014221,
>     657.102921923195, 660.356911071581, 620.139702002702, 378.186792471657
>     ), R1error = c(FALSE, FALSE, FALSE, FALSE, FALSE), R2error = c(FALSE,
>     FALSE, FALSE, FALSE, FALSE)), .Names = c("id", "x", "y",
> "date", "R1dmed", "R1dmean", "R1error", "R2error"), row.names = c(NA,
> 5L), class = "data.frame")
> 
> and here's the code I wrote for this file:
> 
> write.table(test, "D:/MooseEncounters/locations/Individual/test.txt")

That's not a CSV file, it is being written with a blank as separator.   Since 
it also has blanks in the formatted POSIXct column, you're very likely to run 
into problems reading it.

Use write.csv(test, "test.csv") and you'll have fewer problems.  If you want 
tab-delimited columns instead, you'll need to specify that in the write.table 
call.

Duncan Murdoch
[[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] urgent: question concerning data manipulation

2013-03-04 Thread MacQueen, Don
Here is one way. There will be many ways to do it; I offer this one
because it is very general.

-Don


tmp <- split(testdata, testdata$personId)

myfun <- function(df) {
  dfo <- df
  if (any(df$law=='SVG')) dfo$svg <- 1 else dfo$svg <- 0
  dfo
}

tmpo <- lapply(tmp,myfun)

testout <- do.call('rbind', tmpo)

> print(testout)
 personId  law article svg
1.1 1  SVG  10   1
1.2 1  SVG  10   1
2.3 2 StGB 123   1
2.4 2 StGB 122   1
2.5 2  SVG  10   1
2.6 2  AuG  40   1
2.7 2 StGB 126   1
3   3  SVG  10   1
4.9 4 StGB 111   0
4.104  AuG  40   0






-- 
Don MacQueen

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





On 3/4/13 7:44 AM, "David Studer"  wrote:

Hello everyone!

Does anyone of you know how I could solve the following problem.
I guess, it is not a very difficult question, but I simply lack of the
right idea:

I have a dataset containing data of convictions. This dataset contains 4
columns:
- personId: individual number that identifies the offender
- law: law which has been violated
- article: article which has been violated

# Testdata:
personId<-c(1,1,2,2,2,2,2,3,4,4)
law<-c("SVG", "SVG", "StGB", "StGB", "SVG", "AuG", "StGB", "SVG", "StGB",
"AuG")
article<-c(10, 10, 123, 122, 10, 40, 126, 10, 111, 40)
testdata<-data.frame(personId, law, article)

Now I'd like to create three additional dummy-coded columns for each law
(SVG, StGB, AuG).
For each offender (all offenders have the same personId) it should be
checked, whether there are
any violations against the three laws. If there are any violations against
SVG (for example), then
in all rows of this offender the column SVG should have the value 1
(otherwise 0).

For example offender 2 has once violated against law "SVG" therefore his
four entries should have
the value 1 at the column "SVG".

I hope you can understand my problem. I'd really appreciate any hints and
solutions!

Thank you!
David

[[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] Mysterious issues with reading text files from R in ArcGIS and Excel

2013-03-04 Thread Duncan Murdoch

On 04/03/2013 10:52 AM, Kerry wrote:

Here's the first 5 lines of my dataset:

structure(list(id = structure(c(1L, 1L, 1L, 1L, 1L), .Label = c("F07001",
"F07002", "F07003", "F07004", "F07005", "F07006", "F07008", "F07009",
"F07010", "F07011", "F07014", "F07015", "F07017", "F07018", "F07019",
"F07020", "F07021", "F07022", "F07023", "F07024", "F10001", "F10002",
"F10004", "F10008", "F10009", "F10010", "F10012", "F10013", "F10014",
"F98015", "M07007", "M07012", "M07013", "M07016", "M10007", "M10011",
"M10015"), class = "factor"), x = c(1482445L, 1481274L, 1481279L,
1481271L, 1480849L), y = c(6621768L, 6619628L, 6619630L, 6619700L,
6620321L), date = structure(c(1173085253, 1173092441, 1173099672,
1173106839, 1173114055), class = c("POSIXct", "POSIXt"), tzone = ""),
R1dmed = c(2498.29727014221, 657.102921923195, 660.356911071581,
620.139702002702, 378.186792471657), R1dmean = c(2498.29727014221,
657.102921923195, 660.356911071581, 620.139702002702, 378.186792471657
), R1error = c(FALSE, FALSE, FALSE, FALSE, FALSE), R2error = c(FALSE,
FALSE, FALSE, FALSE, FALSE)), .Names = c("id", "x", "y",
"date", "R1dmed", "R1dmean", "R1error", "R2error"), row.names = c(NA,
5L), class = "data.frame")

and here's the code I wrote for this file:

write.table(test, "D:/MooseEncounters/locations/Individual/test.txt")


That's not a CSV file, it is being written with a blank as separator.   
Since it also has blanks in the formatted POSIXct column, you're very 
likely to run into problems reading it.


Use write.csv(test, "test.csv") and you'll have fewer problems.  If you 
want tab-delimited columns instead, you'll need to specify that in the 
write.table call.


Duncan Murdoch


~K




*From:* Duncan Murdoch 
*To:* Kerry 
*Cc:* "r-help@r-project.org" 
*Sent:* Monday, March 4, 2013 4:48 PM
*Subject:* Re: [R] Mysterious issues with reading text files from R in 
ArcGIS and Excel


On 04/03/2013 10:09 AM, Kerry wrote:
> It seems within the last ~3 months Ive been having issues with 
writing text or csv files from a R data frame. The problem is 
multifold and it is hard to filter  out what is going on and where the 
problem is.  So, Im hoping someone else has come across this and may 
provide insight.


I think you need to provide a simple example for us to try, either by
putting a small example of one of your files online for us to download,
or (better) by giving us self-contained code to duplicate the problem.

You might also get better help (especially about ArcGIS) on the
R-sig-Geo mailing list: .

Duncan Murdoch

>
>
>
> My current settings for R:
> R version 2.15.2 (2012-10-26)
> Platform: x86_64-w64-mingw32/x64 (64-bit)
> locale:
>
> [1] LC_COLLATE=Swedish_Sweden.1252 LC_CTYPE=Swedish_Sweden.1252 
LC_MONETARY=Swedish_Sweden.1252 LC_NUMERIC=C

> [5] LC_TIME=Swedish_Sweden.1252
>
> attached base packages:
> [1] tcltkstatsgraphics  grDevices utils datasets  methods  base
>
> other attached packages:
> [1] adehabitat_1.8.11 shapefiles_0.6foreign_0.8-51   
tkrplot_0.0-23ade4_1.5-1

>
> loaded via a namespace (and not attached):
> [1] tools_2.15.2
>
> I am using Microsoft Excel 2010 and ArcGIS 10.1sp1 for Desktop
>
> Basically, no matter what data frame I am working on, when I export 
it to a text file to be use in Excel or ArcGIS problems arise.  Im not 
sure if it is R or these other programs, maybe forums for ArcGIS might 
be more appropriate, but this problem only occurs when I use tables 
that have been produced from an R session.

>
> When I try to open a text file in Excel, either I get an error 
message stating
> The file you are trying to open is in a different format than 
specified by the file extension.  Verify that the file is not 
corrupted and is from a trusted source.

> Followed by
> Excel has detected that 'file.txt' is a SYLK file, but cannot load 
it.  Either the file has errors or is not a SYLK file format.  Click 
OK to open the file in a different format

> Then the file opens
>
>
> Otherwise, the file opens "fine" the first time through - and 
"looks" ok. I can't figure out what Im doing different between the two 
commands of write.table as they are always written the same:
> write.csv(file, file = "D:/mylocations/fileofinterest.csv") or 
write.table(file, file = "D:/mylocations/fileofinterest.txt")
> Sometimes I will try to add sep = "," or sep = ";" but these don't 
make a difference (which I didn't figure they would).

>
> The other program I use is ArcGIS and bringing in a txt file from R 
is really messing things up as 2 new columns of information are 
typically added and date/time data is usually lost with txt files, but 
not with csv files.

>
> For instance - a text file that looks like this in Excel:
>  id  x  ydateR1dmed R1dmean R1error 
R2error
> 1 F07001 1482445 6621768 2007-03-05 10:00:53 2498.2973 2498.2973  

Re: [R] Mysterious issues with reading text files from R in ArcGIS and Excel

2013-03-04 Thread Kerry
Here's the first 5 lines of my dataset:

structure(list(id = structure(c(1L, 1L, 1L, 1L, 1L), .Label = c("F07001", 
"F07002", "F07003", "F07004", "F07005", "F07006", "F07008", "F07009", 
"F07010", "F07011", "F07014", "F07015", "F07017", "F07018", "F07019", 
"F07020", "F07021", "F07022", "F07023", "F07024", "F10001", "F10002", 
"F10004", "F10008", "F10009", "F10010", "F10012", "F10013", "F10014", 
"F98015", "M07007", "M07012", "M07013", "M07016", "M10007", "M10011", 
"M10015"), class = "factor"), x = c(1482445L, 1481274L, 1481279L, 
1481271L, 1480849L), y = c(6621768L, 6619628L, 6619630L, 6619700L, 
6620321L), date = structure(c(1173085253, 1173092441, 1173099672, 
1173106839, 1173114055), class = c("POSIXct", "POSIXt"), tzone = ""), 
    R1dmed = c(2498.29727014221, 657.102921923195, 660.356911071581, 
    620.139702002702, 378.186792471657), R1dmean = c(2498.29727014221, 
    657.102921923195, 660.356911071581, 620.139702002702, 378.186792471657
    ), R1error = c(FALSE, FALSE, FALSE, FALSE, FALSE), R2error = c(FALSE, 
    FALSE, FALSE, FALSE, FALSE)), .Names = c("id", "x", "y", 
"date", "R1dmed", "R1dmean", "R1error", "R2error"), row.names = c(NA, 
5L), class = "data.frame")

and here's the code I wrote for this file:

write.table(test, "D:/MooseEncounters/locations/Individual/test.txt")

 
~K






 From: Duncan Murdoch 

Cc: "r-help@r-project.org"  
Sent: Monday, March 4, 2013 4:48 PM
Subject: Re: [R] Mysterious issues with reading text files from R in ArcGIS and 
Excel

On 04/03/2013 10:09 AM, Kerry wrote:
> It seems within the last ~3 months Ive been having issues with writing text 
> or csv files from a R data frame.  The problem is multifold and it is hard to 
> filter  out what is going on and where the problem is.  So, Im hoping someone 
> else has come across this and may provide insight.

I think you need to provide a simple example for us to try, either by 
putting a small example of one of your files online for us to download, 
or (better) by giving us self-contained code to duplicate the problem.

You might also get better help (especially about ArcGIS) on the 
R-sig-Geo mailing list: .

Duncan Murdoch

>
>
>
> My current settings for R:
> R version 2.15.2 (2012-10-26)
> Platform: x86_64-w64-mingw32/x64 (64-bit)
> locale:
>
> [1] LC_COLLATE=Swedish_Sweden.1252  LC_CTYPE=Swedish_Sweden.1252    
> LC_MONETARY=Swedish_Sweden.1252 LC_NUMERIC=C
> [5] LC_TIME=Swedish_Sweden.1252
>
> attached base packages:
> [1] tcltk     stats     graphics  grDevices utils     datasets  methods   base
>
> other attached packages:
> [1] adehabitat_1.8.11 shapefiles_0.6    foreign_0.8-51    tkrplot_0.0-23    
> ade4_1.5-1
>
> loaded via a namespace (and not attached):
> [1] tools_2.15.2
>
> I am using Microsoft Excel 2010 and ArcGIS 10.1sp1 for Desktop
>
> Basically, no matter what data frame I am working on, when I export it to a 
> text file to be use in Excel or ArcGIS problems arise.  Im not sure if it is 
> R or these other programs, maybe forums for ArcGIS might be more appropriate, 
> but this problem only occurs when I use tables that have been produced from 
> an R session.
>
> When I try to open a text file in Excel, either I get an error message stating
> The file you are trying to open is in a different format than specified by 
> the file extension.  Verify that the file is not corrupted and is from a 
> trusted source.
> Followed by
> Excel has detected that 'file.txt' is a SYLK file, but cannot load it.  
> Either the file has errors or is not a SYLK file format.  Click OK to open 
> the file in a different format
> Then the file opens
>
>
> Otherwise, the file opens "fine" the first time through - and "looks" ok. I 
> can't figure out what Im doing different between the two commands of 
> write.table as they are always written the same:
> write.csv(file, file = "D:/mylocations/fileofinterest.csv") or 
> write.table(file, file = "D:/mylocations/fileofinterest.txt")
> Sometimes I will try to add sep = "," or sep = ";" but these don't make a 
> difference (which I didn't figure they would).
>
> The other program I use is ArcGIS and bringing in a txt file from R is really 
> messing things up as 2 new columns of information are typically added and 
> date/time data is usually lost with txt files, but not with csv files.
>
> For instance - a text file that looks like this in Excel:
>      id       x       y                date    R1dmed    R1dmean R1error 
>R2error
> 1 F07001 1482445 6621768 2007-03-05 10:00:53 2498.2973 2498.2973   FALSE   
> FALSE
> 2 F07001 1481274 6619628 2007-03-05 12:00:41  657.1029  657.1029    FALSE   
> FALSE
> 3 F07001 1481279 6619630 2007-03-05 14:01:12  660.3569  660.3569    FALSE   
> FALSE
> 4 F07001 1481271 6619700 2007-03-05 16:00:39  620.1397  620.1397    FALSE   
> FALSE
>
>   in ArcGIS now looks like this:
>
> Field1idid_Xid_YxydateR1dmedR1dmean R1errorR2errorOBJECTID *
> 1F07001118.081811

Re: [R] Version Upgrade and Packages

2013-03-04 Thread MacQueen, Don
Hi Rich,

Immediately after you see one of those messages, do, e.g.,

  find('cor')

It should tell you that you have more than one object named 'cor' in your
search path, and where they all are. Then you can decide if it's what you
want (probably not, but can't say from here).

-Don

-- 
Don MacQueen

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





On 3/4/13 7:38 AM, "Rich Shepard"  wrote:

   I just upgraded from 2.15.2 to 2.15.3 on our Slackware systems and see
the
following when testing that the new version properly loads:

"The following object(s) are masked from 'package:stats':
 cor

"The following object(s) are masked from 'package:base':
 as.Date, as.Date.numeric"

   What, exactly, does this mean?

   Also, I assume that if I see no errors about loading packages that means
they do not need to be upgraded to work with this low level upgrade.

Rich

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Mysterious issues with reading text files from R in ArcGIS and Excel

2013-03-04 Thread Duncan Murdoch

On 04/03/2013 10:09 AM, Kerry wrote:

It seems within the last ~3 months Ive been having issues with writing text or 
csv files from a R data frame.  The problem is multifold and it is hard to 
filter  out what is going on and where the problem is.  So, Im hoping someone 
else has come across this and may provide insight.


I think you need to provide a simple example for us to try, either by 
putting a small example of one of your files online for us to download, 
or (better) by giving us self-contained code to duplicate the problem.


You might also get better help (especially about ArcGIS) on the 
R-sig-Geo mailing list: .


Duncan Murdoch





My current settings for R:
R version 2.15.2 (2012-10-26)
Platform: x86_64-w64-mingw32/x64 (64-bit)
locale:

[1] LC_COLLATE=Swedish_Sweden.1252  LC_CTYPE=Swedish_Sweden.1252
LC_MONETARY=Swedish_Sweden.1252 LC_NUMERIC=C
[5] LC_TIME=Swedish_Sweden.1252

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

other attached packages:
[1] adehabitat_1.8.11 shapefiles_0.6foreign_0.8-51tkrplot_0.0-23
ade4_1.5-1

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

I am using Microsoft Excel 2010 and ArcGIS 10.1sp1 for Desktop

Basically, no matter what data frame I am working on, when I export it to a 
text file to be use in Excel or ArcGIS problems arise.  Im not sure if it is R 
or these other programs, maybe forums for ArcGIS might be more appropriate, but 
this problem only occurs when I use tables that have been produced from an R 
session.

When I try to open a text file in Excel, either I get an error message stating
The file you are trying to open is in a different format than specified by the 
file extension.  Verify that the file is not corrupted and is from a trusted 
source.
Followed by
Excel has detected that 'file.txt' is a SYLK file, but cannot load it.  Either 
the file has errors or is not a SYLK file format.  Click OK to open the file in 
a different format
Then the file opens


Otherwise, the file opens "fine" the first time through - and "looks" ok. I 
can't figure out what Im doing different between the two commands of write.table as they are always 
written the same:
write.csv(file, file = "D:/mylocations/fileofinterest.csv") or write.table(file, file = 
"D:/mylocations/fileofinterest.txt")
Sometimes I will try to add sep = "," or sep = ";" but these don't make a 
difference (which I didn't figure they would).

The other program I use is ArcGIS and bringing in a txt file from R is really 
messing things up as 2 new columns of information are typically added and 
date/time data is usually lost with txt files, but not with csv files.

For instance - a text file that looks like this in Excel:
 id   x   ydateR1dmedR1dmean R1error R2error
1 F07001 1482445 6621768 2007-03-05 10:00:53 2498.2973 2498.2973   FALSE   FALSE
2 F07001 1481274 6619628 2007-03-05 12:00:41  657.1029  657.1029FALSE   
FALSE
3 F07001 1481279 6619630 2007-03-05 14:01:12  660.3569  660.3569FALSE   
FALSE
4 F07001 1481271 6619700 2007-03-05 16:00:39  620.1397  620.1397FALSE   
FALSE

  in ArcGIS now looks like this:

Field1idid_Xid_YxydateR1dmedR1dmean R1errorR2errorOBJECTID *
1F07001118.0818119.485541e+01514824456621768NA2498.297272498.29727FALSEFALSE1
2F07001118.0818119.485541e+01514812746619628NA657.102922657.102922FALSEFALSE2
3F07001118.0818119.485541e+01514812796619630NA660.356911660.356911FALSEFALSE3
4F07001118.0818119.485541e+01514812716619700NA620.139702620.139702FALSEFALSE4
5F07001118.0818119.485541e+01514808496620321NA378.186792378.186792FALSEFALSE5

Where did id_X and id_Y come from?? What are they??
What happened to the Date column???  Why does the date column show up when I 
use write.csv but not write.table?

Thank you for your help.

~K
[[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] issue creating a subset

2013-03-04 Thread MacQueen, Don
What Jim said separately is correct, and I would suggest following his
advice.
But there are some points worth looking at in your method.

See this example:

> item1 <- item2 <- item3 <- item4 <- 1:4
> 
> matrix1<-cbind(item1, item2, item3, item4)
> 
> z <- c(TRUE,TRUE,FALSE,TRUE)
> 
> matrix2 <- cbind(item1[z], item2[z], item3[z], item4[z])
> 
> matrix3 <- cbind(item1=item1[z], item2=item2[z],
+  item3=item3[z], item4=item4[z])
> 
> print(matrix1)
 item1 item2 item3 item4
[1,] 1 1 1 1
[2,] 2 2 2 2
[3,] 3 3 3 3
[4,] 4 4 4 4
> 
> print(matrix2)
 [,1] [,2] [,3] [,4]
[1,]1111
[2,]2222
[3,]4444
> 
> print(matrix3)
 item1 item2 item3 item4
[1,] 1 1 1 1
[2,] 2 2 2 2
[3,] 4 4 4 4

Points to consider:

Since your "z" is a vector of logical values, you don't need
   item1[z==T]
instead, use
   item1[z]
  
Your column names on matrix2 do not look correct, given how you created
matrix2.

Not that you can specify column names when you create the matrix using
cbind, as in my matrix3 example.

-Don 


-- 
Don MacQueen

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





On 2/28/13 5:53 PM, "Pablo Menese"  wrote:

I'm performing item response theory with eRm packages
I am excluding the persons that doesn't fit in the infit/outfit persons.
for that I created a condition. then I have to create a new subset or
matrix but with the condition.

So:

ORIGINAL

matrix<-cbind(item1, item2, item3, item4)

IF I PERFORM A head(matrix)

item1 item2 item3 item4
  3 2   3   1
  3 1   2   4

THEN I CREATE THE LOGIC CONDITION

z<-thing==T

THEN I TRY TO CREATE THE NEW MATRIX BUT WITH THE CONDITION

matrix2<-cbind(item1[z==T], item2[z==T], item3[z==T], item4[z==T])

THE ISSUE IS THAT IF I PERFORM A head(matrix2)

 I1I2   I3  I4
  3 2   3   1
  3 1   2   4

The names of the columns change at all.

CAN ANYONE HELP ME TO KEEP THE SAME NAMES?

[[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] urgent: question concerning data manipulation

2013-03-04 Thread David Studer
Hello everyone!

Does anyone of you know how I could solve the following problem.
I guess, it is not a very difficult question, but I simply lack of the
right idea:

I have a dataset containing data of convictions. This dataset contains 4
columns:
- personId: individual number that identifies the offender
- law: law which has been violated
- article: article which has been violated

# Testdata:
personId<-c(1,1,2,2,2,2,2,3,4,4)
law<-c("SVG", "SVG", "StGB", "StGB", "SVG", "AuG", "StGB", "SVG", "StGB",
"AuG")
article<-c(10, 10, 123, 122, 10, 40, 126, 10, 111, 40)
testdata<-data.frame(personId, law, article)

Now I'd like to create three additional dummy-coded columns for each law
(SVG, StGB, AuG).
For each offender (all offenders have the same personId) it should be
checked, whether there are
any violations against the three laws. If there are any violations against
SVG (for example), then
in all rows of this offender the column SVG should have the value 1
(otherwise 0).

For example offender 2 has once violated against law "SVG" therefore his
four entries should have
the value 1 at the column "SVG".

I hope you can understand my problem. I'd really appreciate any hints and
solutions!

Thank you!
David

[[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] Version Upgrade and Packages

2013-03-04 Thread Rich Shepard

  I just upgraded from 2.15.2 to 2.15.3 on our Slackware systems and see the
following when testing that the new version properly loads:

"The following object(s) are masked from 'package:stats':
cor

"The following object(s) are masked from 'package:base':
as.Date, as.Date.numeric"

  What, exactly, does this mean?

  Also, I assume that if I see no errors about loading packages that means
they do not need to be upgraded to work with this low level upgrade.

Rich

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Mysterious issues with reading text files from R in ArcGIS and Excel

2013-03-04 Thread Kerry
It seems within the last ~3 months Ive been having issues with writing text or 
csv files from a R data frame.  The problem is multifold and it is hard to 
filter  out what is going on and where the problem is.  So, Im hoping someone 
else has come across this and may provide insight.  



My current settings for R:
R version 2.15.2 (2012-10-26)
Platform: x86_64-w64-mingw32/x64 (64-bit)
locale:

[1] LC_COLLATE=Swedish_Sweden.1252  LC_CTYPE=Swedish_Sweden.1252    
LC_MONETARY=Swedish_Sweden.1252 LC_NUMERIC=C                   
[5] LC_TIME=Swedish_Sweden.1252    

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

other attached packages:
[1] adehabitat_1.8.11 shapefiles_0.6    foreign_0.8-51    tkrplot_0.0-23    
ade4_1.5-1       

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

I am using Microsoft Excel 2010 and ArcGIS 10.1sp1 for Desktop

Basically, no matter what data frame I am working on, when I export it to a 
text file to be use in Excel or ArcGIS problems arise.  Im not sure if it is R 
or these other programs, maybe forums for ArcGIS might be more appropriate, but 
this problem only occurs when I use tables that have been produced from an R 
session. 

When I try to open a text file in Excel, either I get an error message stating 
The file you are trying to open is in a different format than specified by the 
file extension.  Verify that the file is not corrupted and is from a trusted 
source.
Followed by
Excel has detected that 'file.txt' is a SYLK file, but cannot load it.  Either 
the file has errors or is not a SYLK file format.  Click OK to open the file in 
a different format
Then the file opens


Otherwise, the file opens "fine" the first time through - and "looks" ok. I 
can't figure out what Im doing different between the two commands of 
write.table as they are always written the same:
write.csv(file, file = "D:/mylocations/fileofinterest.csv") or 
write.table(file, file = "D:/mylocations/fileofinterest.txt")
Sometimes I will try to add sep = "," or sep = ";" but these don't make a 
difference (which I didn't figure they would).

The other program I use is ArcGIS and bringing in a txt file from R is really 
messing things up as 2 new columns of information are typically added and 
date/time data is usually lost with txt files, but not with csv files.

For instance - a text file that looks like this in Excel:
    id       x       y                date    R1dmed    R1dmean R1error R2error
1 F07001 1482445 6621768 2007-03-05 10:00:53 2498.2973 2498.2973   FALSE   FALSE
2 F07001 1481274 6619628 2007-03-05 12:00:41  657.1029  657.1029    FALSE   
FALSE
3 F07001 1481279 6619630 2007-03-05 14:01:12  660.3569  660.3569    FALSE   
FALSE
4 F07001 1481271 6619700 2007-03-05 16:00:39  620.1397  620.1397    FALSE   
FALSE

 in ArcGIS now looks like this:

Field1idid_Xid_YxydateR1dmedR1dmean R1errorR2errorOBJECTID *
1F07001118.0818119.485541e+01514824456621768NA2498.297272498.29727FALSEFALSE1
2F07001118.0818119.485541e+01514812746619628NA657.102922657.102922FALSEFALSE2
3F07001118.0818119.485541e+01514812796619630NA660.356911660.356911FALSEFALSE3 
4F07001118.0818119.485541e+01514812716619700NA620.139702620.139702FALSEFALSE4
5F07001118.0818119.485541e+01514808496620321NA378.186792378.186792FALSEFALSE5

Where did id_X and id_Y come from?? What are they?? 
What happened to the Date column???  Why does the date column show up when I 
use write.csv but not write.table?

Thank you for your help.

~K
[[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 loop several binary files from two directories?

2013-03-04 Thread arun
HI,

Check these links:
http://r.789695.n4.nabble.com/Re-new-question-td4659908.html
http://r.789695.n4.nabble.com/Re-reading-data-td4658705.html#a4659751

It shows reading files (not binary files) from multiple subdirectories and 
doing some calculations.
You may need to change it according to your needs ('read.table' to 'readBin' 
etc.)
 A.K.




- Original Message -
From: Jonsson 
To: r-help@r-project.org
Cc: 
Sent: Monday, March 4, 2013 6:08 AM
Subject: [R] How to loop several binary files from two directories?

I have two binary files(rasters) with the same dimensions. The first file is
called `over`  and the second is `corr`. I want to replace values in `over`
by `NA` whenever `corr` is greater than 0.5.


to read the two files we can use:

        conne <- file("C:corr.bin","rb")
        over <- readBin(conne, numeric(), size=4,  n=1440*720, signed=TRUE)
        frf <- file("C:cor206.bin","rb")
        corr <- readBin(frf, numeric(), size=4,  n=1440*720, signed=TRUE)
        
to replace values in `over` by `NA` whenever `corr` is greater than 0.5:
                              
                         over[corr > 0.4] = NA
to write the results:

      to.write = file(paste("C:flag.bin", sep=""), "wb")
      writeBin(as.double(over), to.write, size = 4)
      close(to.write)
              
            
Now I want to do the same but with 24 files(12 files in each directory) i.e.
to loop thru several files :
so file1 from the first directory with file1 from the second directory and
so on

To read the files from both directories

    firstdirctory   <- list.files("C:final-2010", "*.bin", full.names =
TRUE)
    seconddirctory   <- list.files("C:jop-2012", "*.bin", full.names = TRUE)



--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-loop-several-binary-files-from-two-directories-tp4660205.html
Sent from the R help mailing list archive at Nabble.com.

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


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


Re: [R] Problems with xlsx and rjava

2013-03-04 Thread Siddharth Khera
I was also facing the same problem.
It may be possible that in your computer “Java” may not be installed, try
installing Java. My problem was solved after installing it.
http://www.java.com/en/download/manual.jsp

Thanks.
Sent from Windows Mail

[[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] Metafor "SMCR" Pre-Post Effect sizes

2013-03-04 Thread Markus Kösters
Dear Wolfgang,

Thank you for your clarification - and your excellent package !

Best wishes,

Markus

-Ursprüngliche Nachricht-
Von: Viechtbauer Wolfgang (STAT)
[mailto:wolfgang.viechtba...@maastrichtuniversity.nl] 
Gesendet: Montag, 4. März 2013 10:45
An: Markus Kösters; R-help@r-project.org
Betreff: RE: [R] Metafor "SMCR" Pre-Post Effect sizes

Absolutely correct. The documentation wasn't clear on that. Changed for the
next version of the package. And the escalc() function now no longer checks
for sd2i, since it is not needed anyway (for "SMCR"). For now, you will just
have to set sd2i to something (e.g., 0).

Thanks for bringing this to my attention!

Best,
Wolfgang

--   
Wolfgang Viechtbauer, Ph.D., Statistician   
Department of Psychiatry and Psychology   
School for Mental Health and Neuroscience   
Faculty of Health, Medicine, and Life Sciences   
Maastricht University, P.O. Box 616 (VIJV1)   
6200 MD Maastricht, The Netherlands   
+31 (43) 388-4170 | http://www.wvbauer.com   


> -Original Message-
> From: r-help-boun...@r-project.org 
> [mailto:r-help-boun...@r-project.org]
> On Behalf Of Markus Kösters
> Sent: Saturday, March 02, 2013 23:31
> To: R-help@r-project.org
> Subject: [R] Metafor "SMCR" Pre-Post Effect sizes
> 
> Dear all,
> 
> I am very grateful that Wolfgang Viechtbauer implemented the 
> standardised mean change for dependent groups. I was playing around a 
> bit today, and I am not sure if I understand the "SMCR" procedure 
> correctly. The documentation states that sd1i and sd2i are needed, but 
> it seems to me that SMCR is ignoring sd2i (so Variances are not 
> pooled). Instead, it uses sd1i (pre-test sd), as suggested by Becker 
> 1988. Is that correct?
> 
> Thank you all very much for your time and help,
> 
> Markus
> 
>   [[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] using reserved words in R, and reuse variable names in different functions

2013-03-04 Thread MacQueen, Don
Yes, it can cause problems. And speaking for myself, I'd say it's not
worth the risk, because it's easy enough to find alternative variable
names that are close enough to the notation of your formulas that
remembering should be no problem. For example, "tt", "cc", and "mmatrix"
might do it.

-Don

-- 
Don MacQueen

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





On 3/1/13 1:56 PM, "C W"  wrote:

Hi list,
I am writing several functions and running out variable names.  I am using
words such as "t", "c", "matrix" to keep the notation same as formulas I am
using.

For example I have,

unnormalized <- function(t, x, y){
val <- rnorm(t, mean=x, var=y)
return(val)
}

metropolis <- function(t, c, x, y){
den1 <- unnormalized(t, mean=x, sd=y)
den2 <- unnormalized(c, mean=x, sd=y)
if(den1 < den2)
   return(a)
else
   return(b)
}

for(i in 1: 100){
matrix <- c()
matrix[i] <- metroplis(1, 2, 3, 4)
}
Here, I reused letter "t" and "c", and the word "matrix".  Could this cause
any potential problems?

Thanks in advance,
Mike

[[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] R broken after upgrade to 2.15.3 (Ubuntu 12.10, 64bit)

2013-03-04 Thread Dirk Eddelbuettel

On 4 March 2013 at 10:01, Ista Zahn wrote:
| Please see http://stackoverflow.com/q/15090817, where it was reported
| that sudo chmod 644 /etc/R/Renviron fixed this issue. If that doesn't

That issue affected only pre-releases of 2.15.3. The 2.15.3 release does not
have that issue. It also should not affect upgrades.

| work for you, consider posting to
| https://stat.ethz.ch/mailman/listinfo/r-sig-debian

That is clearly the best place.

I must updated close to a dozen machines to this 2.15.3 build, and all work
fine.  We need something more to work with, and r-sig-debian is the best venue.

Dirk

-- 
Dirk Eddelbuettel | e...@debian.org | http://dirk.eddelbuettel.com

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


Re: [R] R broken after upgrade to 2.15.3 (Ubuntu 12.10, 64bit)

2013-03-04 Thread Ista Zahn
Hi,

Please see http://stackoverflow.com/q/15090817, where it was reported
that sudo chmod 644 /etc/R/Renviron fixed this issue. If that doesn't
work for you, consider posting to
https://stat.ethz.ch/mailman/listinfo/r-sig-debian

Best,
Ista

On Mon, Mar 4, 2013 at 9:56 AM, Ulrich Bodenhofer
 wrote:
> Hi,
>
> I am using R on Ubuntu 12.10 (64bit). This morning, Ubuntu's software
> updater automatically installed updates to R's base system (version 2.15.3;
> via the CRAN PPA). Now R does not work anymore. Here is what I get when I
> simply enter "R" on the shell prompt:
>
> bodenhof FUKUOKA~>R
> cannot find system Renviron
> Error : .onLoad failed in loadNamespace() for 'utils', details:
> call: options(op.utils[toset])
> error: invalid value for 'editor'
>
> R version 2.15.3 (2013-03-01) -- "Security Blanket"
> Copyright (C) 2013 The R Foundation for Statistical Computing
> ISBN 3-900051-07-0
> Platform: x86_64-pc-linux-gnu (64-bit)
>
> R is free software and comes with ABSOLUTELY NO WARRANTY.
> You are welcome to redistribute it under certain conditions.
> Type 'license()' or 'licence()' for distribution details.
>
> Natural language support but running in an English locale
>
> R is a collaborative project with many contributors.
> Type 'contributors()' for more information and
> 'citation()' on how to cite R or R packages in publications.
>
> Type 'demo()' for some demos, 'help()' for on-line help, or
> 'help.start()' for an HTML browser interface to help.
> Type 'q()' to quit R.
>
> Error : .onLoad failed in loadNamespace() for 'utils', details:
> call: options(op.utils[toset])
> error: invalid value for 'editor'
> In addition: Warning message:
> package "methods" in options("defaultPackages") was not found
> Error : .onLoad failed in loadNamespace() for 'utils', details:
> call: options(op.utils[toset])
> error: invalid value for 'editor'
> In addition: Warning message:
> package ‘utils’ in options("defaultPackages") was not found
> Error : .onLoad failed in loadNamespace() for 'utils', details:
> call: options(op.utils[toset])
> error: invalid value for 'editor'
> In addition: Warning message:
> package ‘stats’ in options("defaultPackages") was not found
> During startup - Warning message:
> package ‘methods’ in options("defaultPackages") was not found
>>
>
> Basic operations work, but the help system is defunct and no add-on packages
> can be loaded. It seems that the utils package is missing or cannot be
> loaded (for a reason that is specified, but which I do not understand).
> There seems to be a fundamental problem. Any ideas what is wrong?
>
> Thanks in advance,
> Ulrich
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] R broken after upgrade to 2.15.3 (Ubuntu 12.10, 64bit)

2013-03-04 Thread Ulrich Bodenhofer

Hi,

I am using R on Ubuntu 12.10 (64bit). This morning, Ubuntu's software 
updater automatically installed updates to R's base system (version 
2.15.3; via the CRAN PPA). Now R does not work anymore. Here is what I 
get when I simply enter "R" on the shell prompt:


bodenhof FUKUOKA~>R
cannot find system Renviron
Error : .onLoad failed in loadNamespace() for 'utils', details:
call: options(op.utils[toset])
error: invalid value for 'editor'

R version 2.15.3 (2013-03-01) -- "Security Blanket"
Copyright (C) 2013 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

Error : .onLoad failed in loadNamespace() for 'utils', details:
call: options(op.utils[toset])
error: invalid value for 'editor'
In addition: Warning message:
package "methods" in options("defaultPackages") was not found
Error : .onLoad failed in loadNamespace() for 'utils', details:
call: options(op.utils[toset])
error: invalid value for 'editor'
In addition: Warning message:
package ‘utils’ in options("defaultPackages") was not found
Error : .onLoad failed in loadNamespace() for 'utils', details:
call: options(op.utils[toset])
error: invalid value for 'editor'
In addition: Warning message:
package ‘stats’ in options("defaultPackages") was not found
During startup - Warning message:
package ‘methods’ in options("defaultPackages") was not found
>

Basic operations work, but the help system is defunct and no add-on 
packages can be loaded. It seems that the utils package is missing or 
cannot be loaded (for a reason that is specified, but which I do not 
understand). There seems to be a fundamental problem. Any ideas what is 
wrong?


Thanks in advance,
Ulrich

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Results from clogit out of range?

2013-03-04 Thread Terry Therneau

I'm late to this discussion, but let me try to put it in another context.
  Assume that I wanted to know whether kids who live west of their school or east of 
their shool are more likely to be early (some hypothesis about walking slower if the sun 
is in their eyes).  So I create a 0/1 variable east/west and get samples of 10 student 
arrival times at each of 100 different schools.  Fit the model


   lm(arrive ~ factor(school) + east.west)

where "arrive" is in some common scale like "minutes since midnight".  Since different 
schools could have different starting times for their first class we need an intercept per 
school.


  Two questions:
 1. Incremental effect: the coefficient of east/west measures the incredmental effect 
across all schools.  With n of 1000 it is likely estimated with high precision.

 2. Absolute: predict the average arrival time (on the clock) for students.

Conditional logistic is very like this.  We have a large number of strata ("schools") with 
a small number of observations in each (often only 2 per strata).  One can ask incremental 
questions about variables common to all strata, but absolute prediction is pretty 
worthless.  a. You can only do it for schools (strata) that have already been seen and b. 
there are so few subjects in each of them that the estimates are very noisy.
  The default prediction from clogit is focused on questions of type 1.  The 
documentation doesn't even bother to mention predictions of type 2, which would be 
probabilities of events.  I can think of a way to extract such output from the routine 
(being the author gives some insight), but why would I want to?


Terry Therneau

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


[R] R function for estimating historical-VaR

2013-03-04 Thread Аскар Нысанов


Hi everyone!! I am new in R and I want to create a simple R function for 
estimating historical-VaR.  In y_IBM returns, there are 2300 observations. For 
evaluation I take the next 2000 observations,
then I abandon the latest 300 observations. Firstly, I use the window which has 
the fix
length and contains the observations from 1 to 2000 to estimate the VaR. At 
first I  take 2000 obs. and reorder these series in ascending order, from 
smallest return to largest return. Each ordered return is assigned an index 
value (1, 2, ...). At the 99% confidence level, the daily VaR under historical 
simulation method equals the return corresponding to the index number 
calculated as follows:
(1-0.99)*2000 (the number of our window) =20. The return corresponding to index 
20 is the daily historical simulation VaR.
I repeat the first step except the window changes the observations from 2 to 
2001. Such a process provides 300 one-step ahead VaR.
My function is:



VaR_foc <- function (returns, value = 1000, p = 0.01, n=251) { 
T = length(returns)
x_foc = vector(length=n)
N = T-(n+1)
m=sort(returns[1:N])
op = as.integer(N*p) # p % smallest
for (i in 2:n) {
g= returns[i:(N+i)] 
ys = sort(g) # sort returns
x_foc[[1]] = -m[op]*value # VaR number
x_foc[i] = -ys[op]*value 
}
return(x_foc)
}
VaR_foc (returns=y_IBM)

But the fucntion doesn't work,  can smbd help me wh

[[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] robustbase adjbox segfault - memory not mapped

2013-03-04 Thread Baan

Hi,

I encountered a segfault, memory not mapped error when  using adjbox in 
robustbase. In trying to recreate the issue I found that the error 
occurs only for large sample size. Here is the code.


> require(robustbase)
Loading required package: robustbase
> x <- rnorm(10)
> y <- rep(1, 10)
> adjbox(x ~ y) ## gives a plot
> x <- rnorm(1)
> y <- rep(1, 1)
> adjbox(x ~ y) ## gives a plot
> x <- rnorm(10)
> y <- rep(1, 10)
> adjbox(x ~ y)

 *** caught segfault ***
address 0xfffcc47af530, cause 'memory not mapped'

Traceback:
 1: .C(mc_C, x, n, eps = eps, iter = c.iter, medc = double(1))
 2: mcComp(x, doReflect, eps1 = eps1, eps2 = eps2, maxit = maxit, 
trace.lev = trace.lev)

 3: mc.default(x, ..., na.rm = TRUE)
 4: mc(x, ..., na.rm = TRUE)
 5: adjboxStats(unclass(groups[[i]]), coef = range, doReflect = doReflect)
 6: adjbox.default(split(mf[[response]], mf[-response]), ...)
 7: adjbox(split(mf[[response]], mf[-response]), ...)
 8: adjbox.formula(x ~ y)
 9: adjbox(x ~ y)

*** glibc detected *** /usr/lib64/R/bin/exec/R: free(): corrupted 
unsorted chunks: 0x02510030 ***

=== Backtrace: =
/lib64/libc.so.6(+0x71e16)[0x7fbaf93a6e16]
/lib64/libc.so.6(cfree+0x6c)[0x7fbaf93abb8c]
/usr/lib64/R/lib/libR.so(+0x135481)[0x7fbaf9bf5481]
/usr/lib64/R/lib/libR.so(+0xa5e19)[0x7fbaf9b65e19]
/usr/lib64/R/lib/libR.so(R_GetTraceback+0xb5)[0x7fbaf9b9cdf5]
/usr/lib64/R/lib/libR.so(+0x130f83)[0x7fbaf9bf0f83]
/lib64/libpthread.so.0(+0xeff0)[0x7fbaf96a5ff0]
/usr/local/lib/R/site-library/robustbase/libs/robustbase.so(mc_C_d+0x1263)[0x7fbaf50d73a3]
/usr/local/lib/R/site-library/robustbase/libs/robustbase.so(mc_C+0xb)[0x7fbaf50d75bb]
/usr/lib64/R/lib/libR.so(+0xba136)[0x7fbaf9b7a136]
/usr/lib64/R/lib/libR.so(Rf_eval+0x75b)[0x7fbaf9bb1eab]
/usr/lib64/R/lib/libR.so(+0xf97b0)[0x7fbaf9bb97b0]
/usr/lib64/R/lib/libR.so(+0x1df282)[0x7fbaf9c9f282]
/usr/lib64/R/lib/libR.so(Rf_eval+0x57b)[0x7fbaf9bb1ccb]
/usr/lib64/R/lib/libR.so(+0xf94f0)[0x7fbaf9bb94f0]
/usr/lib64/R/lib/libR.so(Rf_eval+0x57b)[0x7fbaf9bb1ccb]
/usr/lib64/R/lib/libR.so(+0xf3160)[0x7fbaf9bb3160]
/usr/lib64/R/lib/libR.so(Rf_eval+0x57b)[0x7fbaf9bb1ccb]
/usr/lib64/R/lib/libR.so(Rf_applyClosure+0x36b)[0x7fbaf9bb3a4b]
/usr/lib64/R/lib/libR.so(Rf_eval+0x458)[0x7fbaf9bb1ba8]
/usr/lib64/R/lib/libR.so(+0xf94f0)[0x7fbaf9bb94f0]
/usr/lib64/R/lib/libR.so(Rf_eval+0x57b)[0x7fbaf9bb1ccb]
/usr/lib64/R/lib/libR.so(+0xf3160)[0x7fbaf9bb3160]
/usr/lib64/R/lib/libR.so(Rf_eval+0x57b)[0x7fbaf9bb1ccb]
/usr/lib64/R/lib/libR.so(Rf_applyClosure+0x36b)[0x7fbaf9bb3a4b]
/usr/lib64/R/lib/libR.so(Rf_usemethod+0x820)[0x7fbaf9c09930]
/usr/lib64/R/lib/libR.so(+0x149bf8)[0x7fbaf9c09bf8]
/usr/lib64/R/lib/libR.so(Rf_eval+0x57b)[0x7fbaf9bb1ccb]
/usr/lib64/R/lib/libR.so(Rf_applyClosure+0x36b)[0x7fbaf9bb3a4b]
/usr/lib64/R/lib/libR.so(Rf_eval+0x458)[0x7fbaf9bb1ba8]
/usr/lib64/R/lib/libR.so(+0xf94f0)[0x7fbaf9bb94f0]
/usr/lib64/R/lib/libR.so(Rf_eval+0x57b)[0x7fbaf9bb1ccb]
/usr/lib64/R/lib/libR.so(+0xf3160)[0x7fbaf9bb3160]
/usr/lib64/R/lib/libR.so(Rf_eval+0x57b)[0x7fbaf9bb1ccb]


My setup details:

R --version
R version 2.15.2 (2012-10-26) -- "Trick or Treat"

Package:robustbase
Version:0.9-5
Date:   2012-03-01
Packaged:   2013-03-01 16:34:03 UTC; maechler
NeedsCompilation:   yes
Repository: CRAN
Date/Publication:   2013-03-01 18:31:33
Built:  R 2.15.2; x86_64-pc-linux-gnu; 2013-03-04 05:54:20
UTC; unix


Platform: x86_64-pc-linux-gnu (64-bit)
uname -a
Linux R 2.6.32-5-amd64 #1 SMP Mon Feb 25 00:26:11 UTC 2013 x86_64 GNU/Linux
Debian squeeze

Could someone pls help.

Regards
Baan

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 treat dominant alternatives & infeasible/unrealistic alternatives in the choice set

2013-03-04 Thread Jonson Javier
Please help!

I made an oa design using the DoE package of R.Then, I created the 18 blocks 
containing 4 choice sets and converted these into questionnaire form using 
rotation method of the CE support package.However,some of the alternatives in 
the choice sets are infeasible/unrealistic and dominant (but no attribute 
attribute overlapping)

Is there a way to deal with these using R?(such that the statistical properties 
of the design are minimallly modified). If can't be done using R, can you 
please help me on the best way to deal with these problems?

Thank you very much for your help.


Jonson M. Javier
[[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] survfit plot question

2013-03-04 Thread Steve Einbender
Hello,
I create a plot from a coxph object called fit.ads4:
plot(survfit(fit.ads4))

plot is located at:
https://www.dropbox.com/s/9jswrzid7mp1u62/survfit%20plot.png

I also create the following survfit statistics:

> print(survfit(fit.ads4),print.rmean=T)
Call: survfit(formula = fit.ads4)

   records  n.maxn.start events *rmean *se(rmean)
median0.95LCL0.95UCL
 203.0  100.0  100.0  103.0  486.7   24.4
 387.0  340.0  467.0
* restricted mean with upper limit =  819


Questions:
1.  What is the cross mark in the plot ?
2.  How does the cross mark in the plot relate to either the "rmean" or the
"median" from survfit ?
3.  What is the meaning of the "restricted mean" ?  The "upper limit" noted
in the output is the "end of the observation period" (i.e., it is always
the Stop value in the Censored observation)

Thanks for taking the time to review

Steve

[[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] Excel User interface for R

2013-03-04 Thread Tammy Ma

HI, 

Assume I have the data frame generated from R as the following:

Product Price market_share
  A 10010%
  B 1109%
 C  12020%
 D  90  61%

What I want to do is to have this kind of excel user interface by changing 
price of certain products, to get the impact of market share generated from R:
if I change A price from 100 to 90, and change B price from 110 to 100, based 
on the calculation in R, I want to get the result from excel, for example,


Product Price market_share
  A 9020%
  B 100   12%
 C  120   10%
 D  90 58%


I want to have the excel interface which make me be able to change the value in 
excel cell, then based on the calculation in R, then exported market share 
impact in excel.

DO you have recommendation for such user interface or sth which make me achieve 
this task?

Thanks.

Kind regards,
Lingyi



  
[[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] installing biOps on MacOSX fails

2013-03-04 Thread Prof Brian Ripley
See the recent discussion on R-sig-mac (the place to ask questions about 
OS X).


On 04/03/2013 11:00, ishi soichi wrote:

version.string R version 2.15.2 (2012-10-26)

I am trying to install biOps on MacOS X 10.8.2

First, I have tiff, fftw-3, jpeg

and set paths like

cd /usr/include
sudo ln -s /usr/local/include/fftw3.h
for x in /usr/local/include/j*.h; do sudo ln -s $x; done
for x in /usr/local/include/tiff*.h; do sudo ln -s $x; done
cd /usr/lib
for x in /usr/local/lib/libfftw3.*; do sudo ln -s $x; done
for x in /usr/local/lib/libjpeg.*; do sudo ln -s $x; done
for x in /usr/local/lib/libtiff.*; do sudo ln -s $x; done

then run,

install.packages("biOps", repos="http://cran.md.tsukuba.ac.jp/";, type="source")


but it gives errors like the following.
Can you tell me why ?  it looks like R cannot find the libraries..


R does nothing: it is the linker which cannot find the libraries. See 
the discussion on R-sig-mac 




** R
** data
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
Error in dyn.load(file, DLLpath = DLLpath, ...) :
   unable to load shared object
'/Library/Frameworks/R.framework/Versions/2.15/Resources/library/biOps/libs/i386/biOps.so':

dlopen(/Library/Frameworks/R.framework/Versions/2.15/Resources/library/biOps/libs/i386/biOps.so,
6): Symbol not found: _TIFFClose
   Referenced from:
/Library/Frameworks/R.framework/Versions/2.15/Resources/library/biOps/libs/i386/biOps.so
   Expected in: flat namespace
  in
/Library/Frameworks/R.framework/Versions/2.15/Resources/library/biOps/libs/i386/biOps.so
Error: loading failed
Execution halted
ERROR: loading failed
* removing
'/Library/Frameworks/R.framework/Versions/2.15/Resources/library/biOps'

The downloaded source packages are in
'/private/var/folders/hk/1clspzcd49d173p3pvpk1f3wgn/T/RtmpFpgBgP/downloaded_packages'
Warning message:
In install.packages("biOps", repos = "http://cran.md.tsukuba.ac.jp/";,  :
   installation of package 'biOps' had non-zero exit status

library(biOps)

Error in library(biOps) : there is no package called 'biOps'




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




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

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


[R] How to loop several binary files from two directories?

2013-03-04 Thread Jonsson
I have two binary files(rasters) with the same dimensions. The first file is
called `over`  and the second is `corr`. I want to replace values in `over`
by `NA` whenever `corr` is greater than 0.5.


to read the two files we can use:

conne <- file("C:corr.bin","rb")
over <- readBin(conne, numeric(), size=4,  n=1440*720, signed=TRUE)
frf <- file("C:cor206.bin","rb")
corr <- readBin(frf, numeric(), size=4,  n=1440*720, signed=TRUE)

to replace values in `over` by `NA` whenever `corr` is greater than 0.5:
   
 over[corr > 0.4] = NA
to write the results:

  to.write = file(paste("C:flag.bin", sep=""), "wb")
  writeBin(as.double(over), to.write, size = 4)
  close(to.write)
  

Now I want to do the same but with 24 files(12 files in each directory) i.e.
to loop thru several files :
so file1 from the first directory with file1 from the second directory and
so on

To read the files from both directories

firstdirctory   <- list.files("C:final-2010", "*.bin", full.names =
TRUE)
seconddirctory   <- list.files("C:jop-2012", "*.bin", full.names = TRUE)



--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-loop-several-binary-files-from-two-directories-tp4660205.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] installing biOps on MacOSX fails

2013-03-04 Thread ishi soichi
version.string R version 2.15.2 (2012-10-26)

I am trying to install biOps on MacOS X 10.8.2

First, I have tiff, fftw-3, jpeg

and set paths like

cd /usr/include
sudo ln -s /usr/local/include/fftw3.h
for x in /usr/local/include/j*.h; do sudo ln -s $x; done
for x in /usr/local/include/tiff*.h; do sudo ln -s $x; done
cd /usr/lib
for x in /usr/local/lib/libfftw3.*; do sudo ln -s $x; done
for x in /usr/local/lib/libjpeg.*; do sudo ln -s $x; done
for x in /usr/local/lib/libtiff.*; do sudo ln -s $x; done

then run,

install.packages("biOps", repos="http://cran.md.tsukuba.ac.jp/";, type="source")


but it gives errors like the following.
Can you tell me why ?  it looks like R cannot find the libraries..


** R
** data
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
Error in dyn.load(file, DLLpath = DLLpath, ...) :
  unable to load shared object
'/Library/Frameworks/R.framework/Versions/2.15/Resources/library/biOps/libs/i386/biOps.so':

dlopen(/Library/Frameworks/R.framework/Versions/2.15/Resources/library/biOps/libs/i386/biOps.so,
6): Symbol not found: _TIFFClose
  Referenced from:
/Library/Frameworks/R.framework/Versions/2.15/Resources/library/biOps/libs/i386/biOps.so
  Expected in: flat namespace
 in
/Library/Frameworks/R.framework/Versions/2.15/Resources/library/biOps/libs/i386/biOps.so
Error: loading failed
Execution halted
ERROR: loading failed
* removing
'/Library/Frameworks/R.framework/Versions/2.15/Resources/library/biOps'

The downloaded source packages are in
'/private/var/folders/hk/1clspzcd49d173p3pvpk1f3wgn/T/RtmpFpgBgP/downloaded_packages'
Warning message:
In install.packages("biOps", repos = "http://cran.md.tsukuba.ac.jp/";,  :
  installation of package 'biOps' had non-zero exit status
> library(biOps)
Error in library(biOps) : there is no package called 'biOps'
>

[[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] Metafor "SMCR" Pre-Post Effect sizes

2013-03-04 Thread Viechtbauer Wolfgang (STAT)
Absolutely correct. The documentation wasn't clear on that. Changed for the 
next version of the package. And the escalc() function now no longer checks for 
sd2i, since it is not needed anyway (for "SMCR"). For now, you will just have 
to set sd2i to something (e.g., 0).

Thanks for bringing this to my attention!

Best,
Wolfgang

--   
Wolfgang Viechtbauer, Ph.D., Statistician   
Department of Psychiatry and Psychology   
School for Mental Health and Neuroscience   
Faculty of Health, Medicine, and Life Sciences   
Maastricht University, P.O. Box 616 (VIJV1)   
6200 MD Maastricht, The Netherlands   
+31 (43) 388-4170 | http://www.wvbauer.com   


> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
> On Behalf Of Markus Kösters
> Sent: Saturday, March 02, 2013 23:31
> To: R-help@r-project.org
> Subject: [R] Metafor "SMCR" Pre-Post Effect sizes
> 
> Dear all,
> 
> I am very grateful that Wolfgang Viechtbauer implemented the standardised
> mean change for dependent
> groups. I was playing around a bit today, and I am not sure if I
> understand the "SMCR" procedure correctly. The documentation states that
> sd1i and sd2i are needed, but it seems to me that SMCR is ignoring sd2i
> (so Variances are not pooled). Instead, it uses sd1i (pre-test sd), as
> suggested by Becker 1988. Is that correct?
> 
> Thank you all very much for your time and help,
> 
> Markus
> 
>   [[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] [R-pkgs] frailtypack: new options !

2013-03-04 Thread Virginie RONDEAU
A new version of the package FRAILTYPACK is now available on CRAN.

-- possibility to fit now a Shared and a Joint Frailty model with a log-normal 
distribution for the random effects. 

-- possibility to deal with interval-censored data (for a shared frailty model)

-- possibility to fit a joint frailty model for clustered data

For more details see the corresponding NEWS files in the pkgs.
We are looking forward to getting your  bug reports or simple feedback, 

Best reagrds, 
Virginie and coauthors (CC).
___
R-packages mailing list
r-packa...@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-packages

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