Re: [R] Masking oceans using polypath

2013-08-11 Thread Paul Murrell

Hi

The outline for France from that database is a little bit pesky because 
it consists of multiple segments that travel in different directions 
around the French border.  Here is some (possibly jetlagged) code that 
puts the segments all in the same direction and produces a nicer result ...


breaks <- which(is.na(outline$x))
starts <- c(1, breaks + 1)
ends <- c(breaks - 1, length(outline$x))
sections <- mapply(":", starts, ends)
xx <- lapply(sections, function(i) { outline$x[i] })
yy <- lapply(sections, function(i) { outline$y[i] })
for (i in 2:length(xx)) {
if (xx[[i - 1]][length(xx[[i - 1]])] != xx[[i]][1] ||
yy[[i - 1]][length(xx[[i - 1]])] != yy[[i]][1]) {
xx[[i]] <- rev(xx[[i]])
yy[[i]] <- rev(yy[[i]])
}
}
image(x=seq(from=xbox[1], to=xbox[2], length=10),
   y =seq(from=ybox[1], to=ybox[2], length=10),
   z = outer(1:10, 1:10, "+"),
   xlab = "lon", ylab = "lat", xlim=xbox, ylim=ybox)
polypath(c(unlist(xx), NA, c(rev(xbox), xbox)),
  c(unlist(yy), NA, rep(ybox, each=2)),
  col="light blue", rule="evenodd")

... Hope that works for you too.

Paul

On 08/06/13 04:02, Marc Girondot wrote:

I like very much the solution proposed by Paul Murrell to mask the ocean
(in fact, all that is not the country displayed) in a plot. It works
pretty well for Australia. However, when I try to apply the same code
for France, it fails. I search for the reason but I can't find. Here is
the code for Australia, after the same code for France with the display
problem.
Thanks a lot for any advice on the reason for the discrepancy.

Marc Girondot


### For Australia
library(mapdata)

outline <- map("worldHires", regions="Australia", exact=TRUE,
 plot=FALSE) # returns a list of x/y coords

xrange <- range(outline$x, na.rm=TRUE) # get bounding box
yrange <- range(outline$y, na.rm=TRUE)

xbox <- round(xrange + c(-2, 2))
ybox <- round(yrange + c(-2, 2))

image(x=seq(from=xbox[1], to=xbox[2], length=10),
y =seq(from=ybox[1], to=ybox[2], length=10),
z = outer(1:10, 1:10, "+"),
xlab = "lon", ylab = "lat", xlim=xbox, ylim=ybox)


# create the grid path in the current device

subset <- !is.na(outline$x)
polypath(c(outline$x[subset], NA, c(rev(xbox), xbox)),
   c(outline$y[subset], NA, rep(ybox, each=2)),
   col="light blue", rule="evenodd")

## Now here is the same code for France... not so beautiful.

### For France
library(mapdata)

outline <- map("worldHires", regions="France", exact=TRUE,
 plot=FALSE) # returns a list of x/y coords

xrange <- range(outline$x, na.rm=TRUE) # get bounding box
yrange <- range(outline$y, na.rm=TRUE)

xbox <- round(xrange + c(-2, 2))
ybox <- round(yrange + c(-2, 2))

image(x=seq(from=xbox[1], to=xbox[2], length=10),
y =seq(from=ybox[1], to=ybox[2], length=10),
z = outer(1:10, 1:10, "+"),
xlab = "lon", ylab = "lat", xlim=xbox, ylim=ybox)


# create the grid path in the current device

subset <- !is.na(outline$x)
polypath(c(outline$x[subset], NA, c(rev(xbox), xbox)),
   c(outline$y[subset], NA, rep(ybox, each=2)),
   col="light blue", rule="evenodd")




Le 16/07/13 23:42, Paul Murrell a écrit :

Hi

There are a couple of problems:

1.
Your 'outline' is much bigger than it needs to be.  For example, the
following produces just Australia ...

outline <- map("worldHires", regions="Australia", exact=TRUE,
plot=FALSE) # returns a list of x/y coords

2.
The outline you get still has NA values in it (the coastline of
Australia in this database is a series of distinct lines;  I don't
know why that is).  Fortunately, you can stitch Australia back
together again like this ...

subset <- !is.na(outline$x)
polypath(c(outline$x[subset], NA, c(xbox, rev(xbox))),
  c(outline$y[subset], NA, rep(ybox, each=2)),
  col="light blue", rule="evenodd")

With those two changes, I get a much better result.  You may want to
fiddle a bit more to add Tasmania and bits of PNG and Indonesia back
in the picture OR you could replace these problems with a different
approach and use a more sophisticated map outline via a "shapefile"
(see the 'sp' package and the 'maptools' package and possibly the
R-sig-geo mailing list).

Hope that helps.

Paul

On 07/16/13 23:17, Louise Wilson wrote:

library(mapdata)

image(x=110:155, y =-40:-10, z = outer(1:45, 1:30, "+"),

xlab = "lon", ylab = "lat")

outline <- map("worldHires", plot=FALSE) # returns a list of x/y coords

xrange <- range(outline$x, na.rm=TRUE) # get bounding box

yrange <- range(outline$y, na.rm=TRUE)

xbox <- xrange + c(-2, 2)

ybox <- yrange + c(-2, 2)

# create the grid path in the current device

polypath(c(outline$x, NA, c(xbox, rev(xbox))),

   c(outline$y, NA, rep(ybox, each=2)),

   col="light blue", rule="evenodd")







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

Re: [R] ifelse() applied on function

2013-08-11 Thread William Dunlap
> ifelse(ChooseFn, lapply, sfLapply)(MyList, function(x) {
> ...
> return())

Use 'if', not 'ifelse', and wrap it in parentheses to get the precendence right
  (if (ChooseFn) lapply else sfLapply)(MyList, function(x){...})

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 Ron Michael
> Sent: Sunday, August 11, 2013 1:18 PM
> To: r-help@r-project.org
> Subject: [R] ifelse() applied on function
> 
> Hi,
> 
> How can I apply ifelse function to chose appropriate function?
> 
> My goal is user will chose lapply() function if "ChooseFn = T" otherwise to 
> chose
> sfLapply() from snowfall package.
> 
> I am basically trying to avoid repeatation to write all internal steps, if 
> user choses lapply
> or sfLapply. For example, I am wondering if there is any posibility to write 
> something like:
> 
> ifelse(ChooseFn, lapply, sfLapply)(MyList, function(x) {
> 
> ...
> ..
> return())
> 
> Really appreciate if someone helps me out.
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Some improvements in gam package

2013-08-11 Thread Trevor Hastie
I have posted a new version of the gam package:  gam_1.09
to CRAN. Thus update improved the step.gam function considerably,
and gives it a parallel option.

I am posting this update announcement along with the original package 
announcement below,
which may be of interest to those new to the list

Trevor Hastie

Begin forwarded message:

> From: "Trevor Hastie" 
> Subject: gam --- a new contributed package
> Date: August 6, 2004 10:35:36 AM PDT
> To: 
> 
> I have contributed a "gam" library to CRAN,
> which implements "Generalized Additive Models".
> 
> This implementation follows closely the description in 
> the GAM chapter 7 of the "white" book "Statistical Models in S"
> (Chambers & Hastie (eds), 1992, Wadsworth), as well as the philosophy
> in "Generalized Additive Models" (Hastie & Tibshirani 1990, Chapman and
> Hall). Hence it behaves pretty much like the Splus version of GAM.
> 
> Note: this gam library and functions therein are different from the
> gam function in package mgcv, and both libraries should not be used
> simultaneously.
> 
> The gam library allows both local regression (loess) and smoothing
> spline smoothers, and uses backfitting and local scoring to fit gams.
> It also allows users to supply their own smoothing methods which can
> then be included in gam fits.
> 
> The gam function in mgcv uses only smoothing spline smoothers, with a
> focus on automatic parameter selection via gcv. 
> 
> Some of the features of the gam library:
> 
> * full compatibility with the R functions glm and lm - a fitted gam
>  inherits from class "glm" and "lm"
> 
> * print, summary, anova, predict and plot methods are provided, as
>  well as the usual extractor methods like coefficients, residuals etc
> 
> * the method step.gam provides a flexible and customizable approach to
>  model selection. 
> 
> Some differences with the Splus version of gam:
> 
> * predictions with new data are improved, without need for the
>  "safe.predict.gam" function. This was partly facilitated by
>  the improved prediction strategy used in R for GLMs and LMs
> 
> * Currently the only backfitting algorithm is all.wam. In the earlier
>  versions of gam, dedicated fortran routines fit models that had only
>  smoothing spline terms (s.wam) or all local regression terms
>  (lo.wam), which in fact made calls back to Splus to update the
>  working response and weights. These were designed for efficiency. It
>  seems now with much faster computers this efficiency is no longer
>  needed, and all.wam is modular and "visible"
> 
 
 

  Trevor Hastie   has...@stanford.edu  
  Professor, Department of Statistics, Stanford University
  Phone: (650) 725-2231 Fax: (650) 725-8977  
  URL: http://www.stanford.edu/~hastie  
   address: room 104, Department of Statistics, Sequoia Hall
   390 Serra Mall, Stanford University, CA 94305-4065  
 
--




[[alternative HTML version deleted]]

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


[R] SEM polychoric

2013-08-11 Thread Pablo Menese Camargo
I have this

mcfa<-
"impulsivity=~imp1r+imp2+imp3+imp4
physical=~phys1+phys2+phys3+phys4
risky=~risk1+risk2+risk3+risk4
selfish=~self1+self2+self3+self4
simple=~simp1+simp2+simp3+simp4r
temper=~temp1+temp2+temp3+temp4
control=~impulsivity+physical+risky+selfish+simple+temper"

where: the model is a second order CFA
the variables are dichotomic (0-1)
and I would like to use polychoric

when I have the same items but polytomous i use

fitcfa <- cfa(mcfa, data = data_analisis)
summary(fitcfa, standardized = TRUE, fit.measure=TRUE)
standardizedSolution(fitcfa, type = "std.all")

anyone know what y should do to apply polychoric?

[[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] Off-topic? Linux laptop for R

2013-08-11 Thread Mitchell Maltenfort
Perhaps it is bad form to respond to my own post but all the responses have
been useful and I did not want to play favorites 

I am coming back to Linux after several MacBook years.  Unfortunately the
Linux for Laptops page is not as well updated as it once was.  On the other
hand, pre-installed Linux laptops are looking quite good.  System 76 may be
hearing from me shortly...
On Aug 11, 2013 2:03 PM, "Mitchell Maltenfort"  wrote:

> Can anyone recommend a laptop that performs well running R under Linux?
> Thanks.
>

[[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] Off-topic? Linux laptop for R

2013-08-11 Thread memilanuk
Another +1 here for the ThinkPad series... they seem to run Linux 
distros about as well as most, and are pretty robustly built.  I picked 
up a Lenovo ThinkPad T530 last fall with Windows 7 Pro on it, and have 
it currently set up to dual-boot into openSUSE 12.3.  Ubuntu 13.04 
probably ran the smoothest on it, with a bit of tweaking (add PPAs for 
tlp and bumblebee to better manage battery life and the nVidia 
graphics), and Mint 15 was close.  On distros like CentOS or Debian with 
older kernels the battery life was atrocious.  The base machine itself - 
4GB RAM upgraded to 16, 500GB HD moved over to the UltraBay in lieu of 
the DVD-R drive, 256GB SSD for the main drive, i5 processor... yeah, it 
runs R acceptably ;)


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Off-topic? Linux laptop for R

2013-08-11 Thread stephen sefick
I have a gatway running scientific linux 6.4.  It runs R quite well.  I had
an old mac power pc running a special flavor of debian that ran R well
relative to the hardware constraints.

FWIW, get all intel hardware; Then the rest is up to you.  Good Luck!

Stephen


On Sun, Aug 11, 2013 at 4:40 PM, Steve Lianoglou
wrote:

> Hi,
>
> I have no real input here from personal experience, but the author of
> the coderspiel blog has these two "recent" posts about his experience
> with Ubuntu on (what seem to be) two very nice machines:
>
> The latest is a Vaio Pro of some sort. Ubuntu is a bit difficult to
> install, but doable:
>
> http://code.technically.us/post/55425026899/vaio-pro-for-programming
>
> An earlier post talks about the ThinkPad Carbon X1:
>
> http://code.technically.us/post/50837506478/senistive-touchpads-and-ubuntu
>
> Which apparently supports ubuntu quite easily (out of the box, I think).
>
> >From quickly skimming, it seems like his only gripe with the X1 is
> that it has a large monitor.
>
> I can't really imagine why any of these laptops would have a problem
> running R. I agree with what (I think) Rolf is saying in that your
> biggest issue will be to find a laptop that runs your favorite flavor
> of Linux well. Once you satisfy that constraint, I'm relatively sure
> that the chances of running R "well" is quite high. Whether or not the
> machine can run R well doesn't say much about how easily linux will be
> installed (and fully functional).
>
> HTH,
> -steve
>
>
> On Sun, Aug 11, 2013 at 1:19 PM, Rolf Turner 
> wrote:
> >
> >
> > I think that Hasan Diwan's assertion is a bit of an over-simplification.
>  I
> > have a Toshiba Satellite
> > L850 that has no problems of any sort running R.  However it *does* have
> > problems with WiFi.
> > The WiFi drivers for my laptop won't work under (any?) Linux system.
> > Apparently (I don't completely
> > grok the concepts here) this is because the drivers are proprietary and
> so
> > Linux developers can't
> > get at the code.
> >
> > My previous laptop (an elderly IBM ThinkPad) had no problems with WiFi,
> at
> > least not after I
> > upgraded to the then most recent versions of Fedora and later Ubuntu.
> >
> > I have managed to work around the WiFi problem by using a USB WiFi
> device.
> > Be careful,
> > but.  The first one I got, an ASUS USB-N10, was advertised to have "Linux
> > support" but
> > after much travail (and after having got a great deal of expert advice) I
> > decided it was
> > no go.  I am currently using an EnGenius EUB9801 which seems to work
> > smoothly.  I have
> > also ordered a "Penguin Wireless G USB Adapter for GNU / Linux" from
> > ThinkPenguin.com,
> > but it hasn't arrived yet.  (Being shipped from the USA to New Zealand.)
> > The ThinkPenguin
> > people seem to have their heads screwed on right, and answered my inquiry
> > promptly,
> > thoroughly and comprehensibly.
> >
> > I hope this is of some relevance to someone!
> >
> > cheers,
> >
> > Rolf Turner
> >
> >
> >
> > On 12/08/13 06:47, Hasan Diwan wrote:
> >>
> >> Any laptop that performs well with Linux will perform acceptably with R
> >> and
> >> vice versa. -- H
> >>
> >>
> >> On 11 August 2013 11:03, Mitchell Maltenfort  wrote:
> >>
> >>> Can anyone recommend a laptop that performs well running R under Linux?
> >>> Thanks.
> >
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>
>
>
> --
> Steve Lianoglou
> Computational Biologist
> Bioinformatics and Computational Biology
> Genentech
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Stephen Sefick
**
Auburn University
Biological Sciences
331 Funchess Hall
Auburn, Alabama
36849
**
sas0...@auburn.edu
http://www.auburn.edu/~sas0025
**

Let's not spend our time and resources thinking about things that are so
little or so large that all they really do for us is puff us up and make us
feel like gods.  We are mammals, and have not exhausted the annoying little
problems of being mammals.

-K. Mullis

"A big computer, a complex algorithm and a long time does not equal
science."

  -Robert Gentleman

[[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/p

Re: [R] Off-topic? Linux laptop for R

2013-08-11 Thread Steve Lianoglou
Hi,

I have no real input here from personal experience, but the author of
the coderspiel blog has these two "recent" posts about his experience
with Ubuntu on (what seem to be) two very nice machines:

The latest is a Vaio Pro of some sort. Ubuntu is a bit difficult to
install, but doable:

http://code.technically.us/post/55425026899/vaio-pro-for-programming

An earlier post talks about the ThinkPad Carbon X1:

http://code.technically.us/post/50837506478/senistive-touchpads-and-ubuntu

Which apparently supports ubuntu quite easily (out of the box, I think).

>From quickly skimming, it seems like his only gripe with the X1 is
that it has a large monitor.

I can't really imagine why any of these laptops would have a problem
running R. I agree with what (I think) Rolf is saying in that your
biggest issue will be to find a laptop that runs your favorite flavor
of Linux well. Once you satisfy that constraint, I'm relatively sure
that the chances of running R "well" is quite high. Whether or not the
machine can run R well doesn't say much about how easily linux will be
installed (and fully functional).

HTH,
-steve


On Sun, Aug 11, 2013 at 1:19 PM, Rolf Turner  wrote:
>
>
> I think that Hasan Diwan's assertion is a bit of an over-simplification.  I
> have a Toshiba Satellite
> L850 that has no problems of any sort running R.  However it *does* have
> problems with WiFi.
> The WiFi drivers for my laptop won't work under (any?) Linux system.
> Apparently (I don't completely
> grok the concepts here) this is because the drivers are proprietary and so
> Linux developers can't
> get at the code.
>
> My previous laptop (an elderly IBM ThinkPad) had no problems with WiFi, at
> least not after I
> upgraded to the then most recent versions of Fedora and later Ubuntu.
>
> I have managed to work around the WiFi problem by using a USB WiFi device.
> Be careful,
> but.  The first one I got, an ASUS USB-N10, was advertised to have "Linux
> support" but
> after much travail (and after having got a great deal of expert advice) I
> decided it was
> no go.  I am currently using an EnGenius EUB9801 which seems to work
> smoothly.  I have
> also ordered a "Penguin Wireless G USB Adapter for GNU / Linux" from
> ThinkPenguin.com,
> but it hasn't arrived yet.  (Being shipped from the USA to New Zealand.)
> The ThinkPenguin
> people seem to have their heads screwed on right, and answered my inquiry
> promptly,
> thoroughly and comprehensibly.
>
> I hope this is of some relevance to someone!
>
> cheers,
>
> Rolf Turner
>
>
>
> On 12/08/13 06:47, Hasan Diwan wrote:
>>
>> Any laptop that performs well with Linux will perform acceptably with R
>> and
>> vice versa. -- H
>>
>>
>> On 11 August 2013 11:03, Mitchell Maltenfort  wrote:
>>
>>> Can anyone recommend a laptop that performs well running R under Linux?
>>> Thanks.
>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



-- 
Steve Lianoglou
Computational Biologist
Bioinformatics and Computational Biology
Genentech

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Off-topic? Linux laptop for R

2013-08-11 Thread Rolf Turner



I think that Hasan Diwan's assertion is a bit of an 
over-simplification.  I have a Toshiba Satellite
L850 that has no problems of any sort running R.  However it *does* have 
problems with WiFi.
The WiFi drivers for my laptop won't work under (any?) Linux system.  
Apparently (I don't completely
grok the concepts here) this is because the drivers are proprietary and 
so Linux developers can't

get at the code.

My previous laptop (an elderly IBM ThinkPad) had no problems with WiFi, 
at least not after I

upgraded to the then most recent versions of Fedora and later Ubuntu.

I have managed to work around the WiFi problem by using a USB WiFi 
device.  Be careful,
but.  The first one I got, an ASUS USB-N10, was advertised to have 
"Linux support" but
after much travail (and after having got a great deal of expert advice) 
I decided it was
no go.  I am currently using an EnGenius EUB9801 which seems to work 
smoothly.  I have
also ordered a "Penguin Wireless G USB Adapter for GNU / Linux" from 
ThinkPenguin.com,
but it hasn't arrived yet.  (Being shipped from the USA to New 
Zealand.)  The ThinkPenguin
people seem to have their heads screwed on right, and answered my 
inquiry promptly,

thoroughly and comprehensibly.

I hope this is of some relevance to someone!

cheers,

Rolf Turner


On 12/08/13 06:47, Hasan Diwan wrote:

Any laptop that performs well with Linux will perform acceptably with R and
vice versa. -- H


On 11 August 2013 11:03, Mitchell Maltenfort  wrote:


Can anyone recommend a laptop that performs well running R under Linux?
Thanks.


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


[R] Plotting multivariate time-series with ggplot2

2013-08-11 Thread A Duranel
Hello all.
Let's say I have a multivariate time-series, obtained from 2 loggers
returning a numeric value and a factor giving additional information about
this numeric value, for instance its accuracy:

data<-data.frame(date=rep(seq(from=as.Date("2012-01-01"), by=1,
length.out=100), 2), logger=c(rep("logger1",100), rep("logger2", 100)),
value=rnorm(200), accuracy=rep(c(rep("poor", 25), rep("good", 50),
rep("poor", 25)),2))

I would like to plot this time-series using ggplot2, with one facet per
logger, and using colour to show the accuracy class:

ggplot(data, aes(date, value,
colour=accuracy))+geom_line()+facet_wrap(~logger)

 

The problem is that ggplot2 actually plots 2 discontinuous time-series in
each facet (one for each accuracy class), which results in straight lines
across the plot, and line breaks between different accuracy classes. Of
course I could create 4 time-series with the same index, padding them with
NAs to get rid of the straight lines, but this would not get rid of the line
breaks, and, since the actual data have many more possible logger x accuracy
combinations, I was wondering if there was an easier and quicker way?
Many thanks
Arnaud



--
View this message in context: 
http://r.789695.n4.nabble.com/Plotting-multivariate-time-series-with-ggplot2-tp4673535.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] RWeb Server

2013-08-11 Thread Gergely Daróczi
Hi Ed,

our rapporter.net service might be useful for you that lets users create
brew-flavored report templates (text with R chunks) to be run on datasets.
So this is a cloud solution to be used directly via the frontend, or called
dynamically from any webpage via API:
http://blog.rapporter.net/2013/01/lets-rapplicate.html

I would be more than happy to hear your feedback.

Best,
Gergely


On 11 August 2013 21:43, Wiebe, Ed@CDCR  wrote:

> Hello,
>
> I am looking for tutorials on setting up R on a Windows 2008 server for
> the purpose of making calls from web pages (e.g. SharePoint) or report
> engines (e.g. SSRS) to embed inline dynamically rendered R content. I found
> the link to RWeb (http://www.math.montana.edu/Rweb/) which I was hoping
> would get me started in the right direction, but apparently the links are
> broken and the contact is no longer available. Other than that I have not
> been able to find related support.
>
> Is there any help you can offer to get me going?
>
> Thank you!
>
> Ed
>
>
>
>
> Ed Wiebe, Manager
> Enterprise Architecture, Enterprise Information Services
> California Department of Corrections and Rehabilitation
> 1900 Birkmont Drive
> Rancho Cordova, CA 95742
> 1-916-358-1866 Desk
> 1-916-358-2019 Fax
> ed.wi...@cdcr.ca.gov
>
> "The key to successfully doing something is in successfully understanding
> what you're doing."
> - Thomas Erl
>
> [[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] Advice on use of R for Generalised Linear Modelling

2013-08-11 Thread Steve Lianoglou
Hi,

On Sun, Aug 11, 2013 at 4:47 AM, Alan Sausse  wrote:
> Hi,
>
> Not an expert R user, something of a novice - please be gentle with me!
>
> I have a particular interest in generalised linear models (GLMs) and I'm
> experienced in fitting them using other bits of software.
>
> R can fit GLMs of course, using the glm() command.  I have some large
> multivariate data sets I'd like to fit GLMs to, ideally using R.  Two
> concerns though:
>
> Firstly, I'm told that R isn't especially fast at fitting GLMs, especially
> if the data files are too large to fit into RAM.  Can anyone advise if
> there are alternatives to glm() around which might cope better.  For
> example, I've heard that RevolutionR is available, and claims to fit GLMs
> faster in these cases.  Might it be possible, alternatively, to write some
> very quick code using C (for example) and to get R to invoke this instead?
>  Has anyone tried to do this?

Likely not -- you'll need to have RevolutionR around for that, and if
you've have RevoR, then just use RevoR -- not sure what the point
would be call RevoR-specific functionality from R.

Perhaps the biglm package can help you from R, though, as it provides
a bigglm function that can do GLMs with out-of-memory data -- no idea
how well/fast it works, though.

You should also consider that your data may not require that, though
-- glmnet, for instance, works incredibly fast on large data. If your
data can actually be loaded (perhaps via a sparse matrix), then you
can try that.

HTH,
-steve

-- 
Steve Lianoglou
Computational Biologist
Bioinformatics and Computational Biology
Genentech

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

2013-08-11 Thread Steve Lianoglou
Hi,

On Sun, Aug 11, 2013 at 1:18 PM, Ron Michael  wrote:
> Hi,
>
> How can I apply ifelse function to chose appropriate function?
>
> My goal is user will chose lapply() function if "ChooseFn = T" otherwise to 
> chose sfLapply() from snowfall package.
>
> I am basically trying to avoid repeatation to write all internal steps, if 
> user choses lapply or sfLapply. For example, I am wondering if there is any 
> posibility to write something like:
>
> ifelse(ChooseFn, lapply, sfLapply)(MyList, function(x) {
>
> ...
> ..
> return())
>
> Really appreciate if someone helps me out.

How about something like:

loop <- if (ChooseFn) lapply else sfLapply

result <- loop(MyList, function(x) {
  ## ...
})

Should work as long as `sfLapply` has same function signature as lapply.

HTH,

-steve

-- 
Steve Lianoglou
Computational Biologist
Bioinformatics and Computational Biology
Genentech

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

2013-08-11 Thread Bert Gunter
Take a look at  http://www.rstudio.com/shiny/  to see if this is useful.

Cheers,
Bert


On Sun, Aug 11, 2013 at 12:43 PM, Wiebe, Ed@CDCR  wrote:
> Hello,
>
> I am looking for tutorials on setting up R on a Windows 2008 server for the 
> purpose of making calls from web pages (e.g. SharePoint) or report engines 
> (e.g. SSRS) to embed inline dynamically rendered R content. I found the link 
> to RWeb (http://www.math.montana.edu/Rweb/) which I was hoping would get me 
> started in the right direction, but apparently the links are broken and the 
> contact is no longer available. Other than that I have not been able to find 
> related support.
>
> Is there any help you can offer to get me going?
>
> Thank you!
>
> Ed
>
>
>
>
> Ed Wiebe, Manager
> Enterprise Architecture, Enterprise Information Services
> California Department of Corrections and Rehabilitation
> 1900 Birkmont Drive
> Rancho Cordova, CA 95742
> 1-916-358-1866 Desk
> 1-916-358-2019 Fax
> ed.wi...@cdcr.ca.gov
>
> "The key to successfully doing something is in successfully understanding 
> what you're doing."
> - Thomas Erl
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



-- 

Bert Gunter
Genentech Nonclinical Biostatistics

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

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


[R] ifelse() applied on function

2013-08-11 Thread Ron Michael
Hi,
 
How can I apply ifelse function to chose appropriate function?
 
My goal is user will chose lapply() function if "ChooseFn = T" otherwise to 
chose sfLapply() from snowfall package.
 
I am basically trying to avoid repeatation to write all internal steps, if user 
choses lapply or sfLapply. For example, I am wondering if there is any 
posibility to write something like:
 
ifelse(ChooseFn, lapply, sfLapply)(MyList, function(x) {
 
...
..
return())
 
Really appreciate if someone helps me out.

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

2013-08-11 Thread Wiebe, Ed@CDCR
Hello,

I am looking for tutorials on setting up R on a Windows 2008 server for the 
purpose of making calls from web pages (e.g. SharePoint) or report engines 
(e.g. SSRS) to embed inline dynamically rendered R content. I found the link to 
RWeb (http://www.math.montana.edu/Rweb/) which I was hoping would get me 
started in the right direction, but apparently the links are broken and the 
contact is no longer available. Other than that I have not been able to find 
related support.

Is there any help you can offer to get me going?

Thank you!

Ed




Ed Wiebe, Manager
Enterprise Architecture, Enterprise Information Services
California Department of Corrections and Rehabilitation
1900 Birkmont Drive
Rancho Cordova, CA 95742
1-916-358-1866 Desk
1-916-358-2019 Fax
ed.wi...@cdcr.ca.gov

"The key to successfully doing something is in successfully understanding what 
you're doing."
- Thomas Erl

[[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] Working with string

2013-08-11 Thread arun
HI Christofer,
Don't know what is wrong in your side.
I copy and pasted the same code and got the same answer as I emailed you.


CH <- c("MRTZIt", "MRTZIT", "PPBZJG", "ppbzJG")
 CH1<-sort(CH,decreasing=TRUE) 
CH1
#[1] "ppbzJG" "PPBZJG" "MRTZIt" "MRTZIT"
chnew<-CH1 
chnew[duplicated(toupper(CH1))]<- CH1[duplicated(toupper(CH1),fromLast=TRUE)] 
 chnew
#[1] "ppbzJG" "ppbzJG" "MRTZIt" "MRTZIt"
 sort(chnew) 
#[1] "MRTZIt" "MRTZIt" "ppbzJG" "ppbzJG"
A.K.






From: Christofer Bogaso 
To: arun  
Cc: R help ; Bert Gunter  
Sent: Sunday, August 11, 2013 2:19 PM
Subject: Re: [R] Working with string



Hello Arun,

Thank you for your prompt reply.

However if I use your new code, I am not getting the answer which you provided:

> CH <- c("MRTZIt", "MRTZIT", "PPBZJG", "ppbzJG")
> CH
[1] "MRTZIt" "MRTZIT" "PPBZJG" "ppbzJG"
> CH1<-sort(CH,decreasing=TRUE) 
> chnew<-CH1 
> chnew[duplicated(toupper(CH1))]<- CH1[duplicated(toupper(CH1),fromLast=TRUE)] 
> sort(chnew) 
[1] "MRTZIT" "MRTZIT" "PPBZJG" "PPBZJG"


Probably that I am missing something. Can you please help me out?

Thanks and regards,



On Sun, Aug 11, 2013 at 11:51 PM, arun  wrote:


>
>Hi Christofer,
>
>I didn't test this extensively.  Looks like this works for the example you 
>showed.
>
>
> CH1<-sort(CH,decreasing=TRUE)
>chnew<-CH1
>chnew[duplicated(toupper(CH1))]<- CH1[duplicated(toupper(CH1),fromLast=TRUE)]
>sort(chnew)
>#[1] "MRTZIt" "MRTZIt" "ppbzJG" "ppbzJG"
>A.K.
>
>
>
>
>
>From: Christofer Bogaso 
>To: Bert Gunter 
>Cc: arun ; R help 
>Sent: Sunday, August 11, 2013 1:54 PM
>Subject: Re: [R] Working with string
>
>
>
>
>Thanks Bert and Arun for your help.
>
>As Bert already pointed out, Arun's code is working well, however except this:
>
>> CH <- c("MRTZIt", "MRTZIT", "PPBZJG", "ppbzJG")
>> chnew<-CH
>> chnew[duplicated(toupper(CH))]<-CH[duplicated(toupper(CH),fromLast=TRUE)]
>> CH
>[1] "MRTZIt" "MRTZIT" "PPBZJG" "ppbzJG"
>> chnew
>[1] "MRTZIt" "MRTZIt" "PPBZJG" "PPBZJG"
>
>
>However Bert's code is also working very well, except following scenario:
>
>> CH <- c("MRTZIt", "MRTZIT", "PPBZJG", "PPBZJG")
>> caps <- CH %in%  toupper(CH) 
>> noncaps <- CH[!caps] 
>> chnew <- CH
>> chnew[caps] <- noncaps[match(CH[caps], toupper(noncaps))] 
>> CH
>[1] "MRTZIt" "MRTZIT" "PPBZJG" "PPBZJG"
>> chnew
>[1] "MRTZIt" "MRTZIt" NA       NA      
>
>
>In my case, both can be well possibilities.
>
>Any better pointer?
>
>Thanks and regards,
>
>
>
>
>
>On Sun, Aug 11, 2013 at 9:42 PM, Bert Gunter  wrote:
>
>Well, maybe: it assumes that the uppercase string version always
>>occurs after the nonuppercase version. That's why I rejected it.
>>
>>However, it points out something important: details matter. The more
>>one knows about the nature of the problem, the better the solution one
>>can tailor -- a remark for which the response should be, "well duhhh!"
>> But posters frequently seem to disregard this.
>>
>>-- Bert
>>
>>
>>On Sun, Aug 11, 2013 at 8:43 AM, arun  wrote:
>>>
>>>
>>> Hi,
>>>
>>> May be this helps:
>>> chnew<-CH
>>>  chnew[duplicated(toupper(CH))]<-CH[duplicated(toupper(CH),fromLast=TRUE)]
>>>  chnew
>>> #[1] "aBd"    "sTb"    "aBd"    "dFDasd" "asd"    "dFDasd"
>>> A.K.
>>>
>>>
>>> - Original Message -
>>> From: Christofer Bogaso 
>>> To: r-help 
>>> Cc:
>>> Sent: Sunday, August 11, 2013 8:39 AM
>>> Subject: [R] Working with string
>>>
>>> Hello again,
>>>
>>> Let say I have a lengthy character vector like:
>>>
>>> CH <- c("aBd", "sTb", "ABD", "dFDasd", "asd", "DFDASD")
>>>
>>> Now I want to create a vector like:
>>>
>>> CH_New <- c("aBd", "sTb", "aBd", "dFDasd", "asd", "dFDasd")  ## the 3rd and
>>> 6th element replaced
>>>
>>> Basically, the goal is:
>>>
>>> If an element has all upper case then it will find another element with all
>>> lower case or mix of upper/lower case. Then the all-upper-case element will
>>> be replaced by that mix. If there is multiple match then chose the first
>>> one.
>>>
>>>
>>> Can somebody give me any pointer how can I achieve that?
>>>
>>> Thanks and regards,
>>>
>>>     [[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.
>>
>>
>>
>>
>>--
>>
>>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
>>
>

___

Re: [R] Working with string

2013-08-11 Thread Bert Gunter
Christopher:

Yes, I warned you about both cases: In your second example there is no
match since there is no nonupper case version of the all upper case
entries. As you did not specify what should be done in that case, I
leave it to you to figure out the necessary modifications of my code.

Possible Hint: ?is.na

-- Bert

On Sun, Aug 11, 2013 at 10:54 AM, Christofer Bogaso
 wrote:
> Thanks Bert and Arun for your help.
>
> As Bert already pointed out, Arun's code is working well, however except
> this:
>
>> CH <- c("MRTZIt", "MRTZIT", "PPBZJG", "ppbzJG")
>> chnew<-CH
>> chnew[duplicated(toupper(CH))]<-CH[duplicated(toupper(CH),fromLast=TRUE)]
>> CH
> [1] "MRTZIt" "MRTZIT" "PPBZJG" "ppbzJG"
>> chnew
> [1] "MRTZIt" "MRTZIt" "PPBZJG" "PPBZJG"
>
>
> However Bert's code is also working very well, except following scenario:
>
>> CH <- c("MRTZIt", "MRTZIT", "PPBZJG", "PPBZJG")
>> caps <- CH %in%  toupper(CH)
>> noncaps <- CH[!caps]
>> chnew <- CH
>> chnew[caps] <- noncaps[match(CH[caps], toupper(noncaps))]
>> CH
> [1] "MRTZIt" "MRTZIT" "PPBZJG" "PPBZJG"
>> chnew
> [1] "MRTZIt" "MRTZIt" NA   NA
>
>
> In my case, both can be well possibilities.
>
> Any better pointer?
>
> Thanks and regards,
>
>
>
>
> On Sun, Aug 11, 2013 at 9:42 PM, Bert Gunter  wrote:
>>
>> Well, maybe: it assumes that the uppercase string version always
>> occurs after the nonuppercase version. That's why I rejected it.
>>
>> However, it points out something important: details matter. The more
>> one knows about the nature of the problem, the better the solution one
>> can tailor -- a remark for which the response should be, "well duhhh!"
>>  But posters frequently seem to disregard this.
>>
>> -- Bert
>>
>> On Sun, Aug 11, 2013 at 8:43 AM, arun  wrote:
>> >
>> >
>> > Hi,
>> >
>> > May be this helps:
>> > chnew<-CH
>> >
>> > chnew[duplicated(toupper(CH))]<-CH[duplicated(toupper(CH),fromLast=TRUE)]
>> >  chnew
>> > #[1] "aBd""sTb""aBd""dFDasd" "asd""dFDasd"
>> > A.K.
>> >
>> >
>> > - Original Message -
>> > From: Christofer Bogaso 
>> > To: r-help 
>> > Cc:
>> > Sent: Sunday, August 11, 2013 8:39 AM
>> > Subject: [R] Working with string
>> >
>> > Hello again,
>> >
>> > Let say I have a lengthy character vector like:
>> >
>> > CH <- c("aBd", "sTb", "ABD", "dFDasd", "asd", "DFDASD")
>> >
>> > Now I want to create a vector like:
>> >
>> > CH_New <- c("aBd", "sTb", "aBd", "dFDasd", "asd", "dFDasd")  ## the 3rd
>> > and
>> > 6th element replaced
>> >
>> > Basically, the goal is:
>> >
>> > If an element has all upper case then it will find another element with
>> > all
>> > lower case or mix of upper/lower case. Then the all-upper-case element
>> > will
>> > be replaced by that mix. If there is multiple match then chose the first
>> > one.
>> >
>> >
>> > Can somebody give me any pointer how can I achieve that?
>> >
>> > Thanks and regards,
>> >
>> > [[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.
>>
>>
>>
>> --
>>
>> Bert Gunter
>> Genentech Nonclinical Biostatistics
>>
>> Internal Contact Info:
>> Phone: 467-7374
>> Website:
>>
>> http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm
>
>



-- 

Bert Gunter
Genentech Nonclinical Biostatistics

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

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


Re: [R] Off-topic? Linux laptop for R

2013-08-11 Thread Hasan Diwan
Any laptop that performs well with Linux will perform acceptably with R and
vice versa. -- H


On 11 August 2013 11:03, Mitchell Maltenfort  wrote:

> Can anyone recommend a laptop that performs well running R under Linux?
> Thanks.
>
> [[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.
>



-- 
Sent from my mobile device
Envoyé de mon portable

[[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] Working with string

2013-08-11 Thread Christofer Bogaso
Hello Arun,

Thank you for your prompt reply.

However if I use your new code, I am not getting the answer which you
provided:

> CH <- c("MRTZIt", "MRTZIT", "PPBZJG", "ppbzJG")
> CH
[1] "MRTZIt" "MRTZIT" "PPBZJG" "ppbzJG"
> CH1<-sort(CH,decreasing=TRUE)
> chnew<-CH1
> chnew[duplicated(toupper(CH1))]<-
CH1[duplicated(toupper(CH1),fromLast=TRUE)]
> sort(chnew)
[1] "MRTZIT" "MRTZIT" "PPBZJG" "PPBZJG"


Probably that I am missing something. Can you please help me out?

Thanks and regards,


On Sun, Aug 11, 2013 at 11:51 PM, arun  wrote:

>
>
> Hi Christofer,
>
> I didn't test this extensively.  Looks like this works for the example you
> showed.
>
>
>  CH1<-sort(CH,decreasing=TRUE)
> chnew<-CH1
> chnew[duplicated(toupper(CH1))]<-
> CH1[duplicated(toupper(CH1),fromLast=TRUE)]
> sort(chnew)
> #[1] "MRTZIt" "MRTZIt" "ppbzJG" "ppbzJG"
> A.K.
>
>
>
> 
> From: Christofer Bogaso 
> To: Bert Gunter 
> Cc: arun ; R help 
> Sent: Sunday, August 11, 2013 1:54 PM
> Subject: Re: [R] Working with string
>
>
>
> Thanks Bert and Arun for your help.
>
> As Bert already pointed out, Arun's code is working well, however except
> this:
>
> > CH <- c("MRTZIt", "MRTZIT", "PPBZJG", "ppbzJG")
> > chnew<-CH
> > chnew[duplicated(toupper(CH))]<-CH[duplicated(toupper(CH),fromLast=TRUE)]
> > CH
> [1] "MRTZIt" "MRTZIT" "PPBZJG" "ppbzJG"
> > chnew
> [1] "MRTZIt" "MRTZIt" "PPBZJG" "PPBZJG"
>
>
> However Bert's code is also working very well, except following scenario:
>
> > CH <- c("MRTZIt", "MRTZIT", "PPBZJG", "PPBZJG")
> > caps <- CH %in%  toupper(CH)
> > noncaps <- CH[!caps]
> > chnew <- CH
> > chnew[caps] <- noncaps[match(CH[caps], toupper(noncaps))]
> > CH
> [1] "MRTZIt" "MRTZIT" "PPBZJG" "PPBZJG"
> > chnew
> [1] "MRTZIt" "MRTZIt" NA   NA
>
>
> In my case, both can be well possibilities.
>
> Any better pointer?
>
> Thanks and regards,
>
>
>
>
>
> On Sun, Aug 11, 2013 at 9:42 PM, Bert Gunter 
> wrote:
>
> Well, maybe: it assumes that the uppercase string version always
> >occurs after the nonuppercase version. That's why I rejected it.
> >
> >However, it points out something important: details matter. The more
> >one knows about the nature of the problem, the better the solution one
> >can tailor -- a remark for which the response should be, "well duhhh!"
> > But posters frequently seem to disregard this.
> >
> >-- Bert
> >
> >
> >On Sun, Aug 11, 2013 at 8:43 AM, arun  wrote:
> >>
> >>
> >> Hi,
> >>
> >> May be this helps:
> >> chnew<-CH
> >>
>  chnew[duplicated(toupper(CH))]<-CH[duplicated(toupper(CH),fromLast=TRUE)]
> >>  chnew
> >> #[1] "aBd""sTb""aBd""dFDasd" "asd""dFDasd"
> >> A.K.
> >>
> >>
> >> - Original Message -
> >> From: Christofer Bogaso 
> >> To: r-help 
> >> Cc:
> >> Sent: Sunday, August 11, 2013 8:39 AM
> >> Subject: [R] Working with string
> >>
> >> Hello again,
> >>
> >> Let say I have a lengthy character vector like:
> >>
> >> CH <- c("aBd", "sTb", "ABD", "dFDasd", "asd", "DFDASD")
> >>
> >> Now I want to create a vector like:
> >>
> >> CH_New <- c("aBd", "sTb", "aBd", "dFDasd", "asd", "dFDasd")  ## the 3rd
> and
> >> 6th element replaced
> >>
> >> Basically, the goal is:
> >>
> >> If an element has all upper case then it will find another element with
> all
> >> lower case or mix of upper/lower case. Then the all-upper-case element
> will
> >> be replaced by that mix. If there is multiple match then chose the first
> >> one.
> >>
> >>
> >> Can somebody give me any pointer how can I achieve that?
> >>
> >> Thanks and regards,
> >>
> >> [[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.
> >
> >
> >
> >
> >--
> >
> >Bert Gunter
> >Genentech Nonclinical Biostatistics
> >
> >Internal Contact Info:
> >Phone: 467-7374
> >Website:
> >
> http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm
> >
>

[[alternative HTML version deleted]]

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


Re: [R] Adding negative values with mean of positive values

2013-08-11 Thread arun
Hi,
You may try this:
vec1<-unique(data1[,1])
res<-do.call(rbind,lapply(seq_along(vec1),function(i) 
{x1<-data1[data1[,1]%in%vec1[-i],]; x2<-mean(x1$value[x1$value>0]); x3<- 
data1[data1[,1]%in% vec1[i],]; x3$value[x3$value<0]<-x3$value[x3$value<0]+x2; 
x3}))
res1<-res[match(row.names(dat1),row.names(res)),]


A.K.




My example dataset is below. 
data1<-structure(list(Group = c("c", "c", "b", "e", "b", "b", "e", "b", 
"b", "c", "b", "c", "d", "e", "a", "c", "e", "e", "b", "c", "e", 
"a", "b", "c", "a", "d", "c", "a", "c", "d"), value = c(1.65766756554083, 
-1.00159810943707, 0.828016940090355, -0.0942360302636258, 0.110184789532348, 
0.501357929769482, -0.843610465892682, 0.112544248337201, 0.83530947271874, 
1.54896291279315, -0.668032450079063, -0.328748306664628, -0.15429551998755, 
1.58892084606551, -0.45892429914377, -2.15596722591948, 0.89857005135, 
-0.287228845053069, -1.54706640415041, -0.780803473387221, 1.54955826561218, 
-0.506014575029359, -1.66808530086564, -0.845467401060001, 1.92688611565505, 
0.46643424929481, 0.293821259924534, 0.151536430922866, -1.62429048404794, 
0.444694790051071)), .Names = c("Group", "value"), row.names = c(NA, 
-30L), class = "data.frame") 

Here, i need to change the negative values by adding with the 
mean of the positive values.  The condition is that the mean of the 
positive values should exclude the positive values on the group on which
 this is carried out.  For example, the 'a' group negative values should
 be added with the mean from the positive values from groups 
'c","d',"e","b".  Similarly for other groups. 
Thanks.

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

2013-08-11 Thread arun


Hi Christofer,

I didn't test this extensively.  Looks like this works for the example you 
showed.


 CH1<-sort(CH,decreasing=TRUE)
chnew<-CH1
chnew[duplicated(toupper(CH1))]<- CH1[duplicated(toupper(CH1),fromLast=TRUE)]
sort(chnew)
#[1] "MRTZIt" "MRTZIt" "ppbzJG" "ppbzJG"
A.K.




From: Christofer Bogaso 
To: Bert Gunter  
Cc: arun ; R help  
Sent: Sunday, August 11, 2013 1:54 PM
Subject: Re: [R] Working with string



Thanks Bert and Arun for your help.

As Bert already pointed out, Arun's code is working well, however except this:

> CH <- c("MRTZIt", "MRTZIT", "PPBZJG", "ppbzJG")
> chnew<-CH
> chnew[duplicated(toupper(CH))]<-CH[duplicated(toupper(CH),fromLast=TRUE)]
> CH
[1] "MRTZIt" "MRTZIT" "PPBZJG" "ppbzJG"
> chnew
[1] "MRTZIt" "MRTZIt" "PPBZJG" "PPBZJG"


However Bert's code is also working very well, except following scenario:

> CH <- c("MRTZIt", "MRTZIT", "PPBZJG", "PPBZJG")
> caps <- CH %in%  toupper(CH) 
> noncaps <- CH[!caps] 
> chnew <- CH
> chnew[caps] <- noncaps[match(CH[caps], toupper(noncaps))] 
> CH
[1] "MRTZIt" "MRTZIT" "PPBZJG" "PPBZJG"
> chnew
[1] "MRTZIt" "MRTZIt" NA       NA      


In my case, both can be well possibilities.

Any better pointer?

Thanks and regards,





On Sun, Aug 11, 2013 at 9:42 PM, Bert Gunter  wrote:

Well, maybe: it assumes that the uppercase string version always
>occurs after the nonuppercase version. That's why I rejected it.
>
>However, it points out something important: details matter. The more
>one knows about the nature of the problem, the better the solution one
>can tailor -- a remark for which the response should be, "well duhhh!"
> But posters frequently seem to disregard this.
>
>-- Bert
>
>
>On Sun, Aug 11, 2013 at 8:43 AM, arun  wrote:
>>
>>
>> Hi,
>>
>> May be this helps:
>> chnew<-CH
>>  chnew[duplicated(toupper(CH))]<-CH[duplicated(toupper(CH),fromLast=TRUE)]
>>  chnew
>> #[1] "aBd"    "sTb"    "aBd"    "dFDasd" "asd"    "dFDasd"
>> A.K.
>>
>>
>> - Original Message -
>> From: Christofer Bogaso 
>> To: r-help 
>> Cc:
>> Sent: Sunday, August 11, 2013 8:39 AM
>> Subject: [R] Working with string
>>
>> Hello again,
>>
>> Let say I have a lengthy character vector like:
>>
>> CH <- c("aBd", "sTb", "ABD", "dFDasd", "asd", "DFDASD")
>>
>> Now I want to create a vector like:
>>
>> CH_New <- c("aBd", "sTb", "aBd", "dFDasd", "asd", "dFDasd")  ## the 3rd and
>> 6th element replaced
>>
>> Basically, the goal is:
>>
>> If an element has all upper case then it will find another element with all
>> lower case or mix of upper/lower case. Then the all-upper-case element will
>> be replaced by that mix. If there is multiple match then chose the first
>> one.
>>
>>
>> Can somebody give me any pointer how can I achieve that?
>>
>> Thanks and regards,
>>
>>     [[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.
>
>
>
>
>--
>
>Bert Gunter
>Genentech Nonclinical Biostatistics
>
>Internal Contact Info:
>Phone: 467-7374
>Website:
>http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm
>

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


[R] Off-topic? Linux laptop for R

2013-08-11 Thread Mitchell Maltenfort
Can anyone recommend a laptop that performs well running R under Linux?
Thanks.

[[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] Working with string

2013-08-11 Thread Christofer Bogaso
Thanks Bert and Arun for your help.

As Bert already pointed out, Arun's code is working well, however except
this:

> CH <- c("MRTZIt", "MRTZIT", "PPBZJG", "ppbzJG")
> chnew<-CH
> chnew[duplicated(toupper(CH))]<-CH[duplicated(toupper(CH),fromLast=TRUE)]
> CH
[1] "MRTZIt" "MRTZIT" "PPBZJG" "ppbzJG"
> chnew
[1] "MRTZIt" "MRTZIt" "PPBZJG" "PPBZJG"


However Bert's code is also working very well, except following scenario:

> CH <- c("MRTZIt", "MRTZIT", "PPBZJG", "PPBZJG")
> caps <- CH %in%  toupper(CH)
> noncaps <- CH[!caps]
> chnew <- CH
> chnew[caps] <- noncaps[match(CH[caps], toupper(noncaps))]
> CH
[1] "MRTZIt" "MRTZIT" "PPBZJG" "PPBZJG"
> chnew
[1] "MRTZIt" "MRTZIt" NA   NA


In my case, both can be well possibilities.

Any better pointer?

Thanks and regards,




On Sun, Aug 11, 2013 at 9:42 PM, Bert Gunter  wrote:

> Well, maybe: it assumes that the uppercase string version always
> occurs after the nonuppercase version. That's why I rejected it.
>
> However, it points out something important: details matter. The more
> one knows about the nature of the problem, the better the solution one
> can tailor -- a remark for which the response should be, "well duhhh!"
>  But posters frequently seem to disregard this.
>
> -- Bert
>
> On Sun, Aug 11, 2013 at 8:43 AM, arun  wrote:
> >
> >
> > Hi,
> >
> > May be this helps:
> > chnew<-CH
> >
>  chnew[duplicated(toupper(CH))]<-CH[duplicated(toupper(CH),fromLast=TRUE)]
> >  chnew
> > #[1] "aBd""sTb""aBd""dFDasd" "asd""dFDasd"
> > A.K.
> >
> >
> > - Original Message -
> > From: Christofer Bogaso 
> > To: r-help 
> > Cc:
> > Sent: Sunday, August 11, 2013 8:39 AM
> > Subject: [R] Working with string
> >
> > Hello again,
> >
> > Let say I have a lengthy character vector like:
> >
> > CH <- c("aBd", "sTb", "ABD", "dFDasd", "asd", "DFDASD")
> >
> > Now I want to create a vector like:
> >
> > CH_New <- c("aBd", "sTb", "aBd", "dFDasd", "asd", "dFDasd")  ## the 3rd
> and
> > 6th element replaced
> >
> > Basically, the goal is:
> >
> > If an element has all upper case then it will find another element with
> all
> > lower case or mix of upper/lower case. Then the all-upper-case element
> will
> > be replaced by that mix. If there is multiple match then chose the first
> > one.
> >
> >
> > Can somebody give me any pointer how can I achieve that?
> >
> > Thanks and regards,
> >
> > [[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.
>
>
>
> --
>
> Bert Gunter
> Genentech Nonclinical Biostatistics
>
> Internal Contact Info:
> Phone: 467-7374
> Website:
>
> http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm
>

[[alternative HTML version deleted]]

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


Re: [R] Advice on use of R for Generalised Linear Modelling

2013-08-11 Thread Bert Gunter
1. For RevolutionR capabilities, contact them (mailing lists, website, etc.)

2. CRAN has a whole section on GUI's. You should consult it:
 http://www.sciviews.org/_rgui/

3. Your GUI query would be more appropriate on the R-sig-gui list.

Cheers,
Bert

On Sun, Aug 11, 2013 at 4:47 AM, Alan Sausse  wrote:
> Hi,
>
> Not an expert R user, something of a novice - please be gentle with me!
>
> I have a particular interest in generalised linear models (GLMs) and I'm
> experienced in fitting them using other bits of software.
>
> R can fit GLMs of course, using the glm() command.  I have some large
> multivariate data sets I'd like to fit GLMs to, ideally using R.  Two
> concerns though:
>
> Firstly, I'm told that R isn't especially fast at fitting GLMs, especially
> if the data files are too large to fit into RAM.  Can anyone advise if
> there are alternatives to glm() around which might cope better.  For
> example, I've heard that RevolutionR is available, and claims to fit GLMs
> faster in these cases.  Might it be possible, alternatively, to write some
> very quick code using C (for example) and to get R to invoke this instead?
>  Has anyone tried to do this?
>
> Secondly, I might like to create some kind of GUI so that I can have a nice
> interface for viewing data, specifying models, showing graphical model
> outputs, etc.  Is there a preferred way to do this?  The only GUI builder I
> know of is Shiny - http://www.rstudio.com/shiny/ - is this a good way to
> go?  What alternatives might I consider?
>
> My IT/coding skills are limited.  I'm hoping at some point to find an R
> expert to collaborate with, but in the mean time, a few pointers would be
> appreciated.
>
> Thanks!
>
> [[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] Advice on use of R for Generalised Linear Modelling

2013-08-11 Thread John Sorkin
Alan,
I can't answer your first question, but as far as the second question goes, 
have you examined RStudio?
http://www.rstudio.com/ 
Rstudio is a free, nice, IDE (I think this stands for integrated development 
environment that facilitates working in R. I provides very very basic sytax 
help (i.e. makes sure parenthesis are balanced), but more importantly allows 
for viewing plots generated by code more easily. 
John

 
John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) >>> Alan 
Sausse  8/11/2013 7:47 AM >>>
Hi,

Not an expert R user, something of a novice - please be gentle with me!

I have a particular interest in generalised linear models (GLMs) and I'm
experienced in fitting them using other bits of software.

R can fit GLMs of course, using the glm() command.  I have some large
multivariate data sets I'd like to fit GLMs to, ideally using R.  Two
concerns though:

Firstly, I'm told that R isn't especially fast at fitting GLMs, especially
if the data files are too large to fit into RAM.  Can anyone advise if
there are alternatives to glm() around which might cope better.  For
example, I've heard that RevolutionR is available, and claims to fit GLMs
faster in these cases.  Might it be possible, alternatively, to write some
very quick code using C (for example) and to get R to invoke this instead?
Has anyone tried to do this?

Secondly, I might like to create some kind of GUI so that I can have a nice
interface for viewing data, specifying models, showing graphical model
outputs, etc.  Is there a preferred way to do this?  The only GUI builder I
know of is Shiny - http://www.rstudio.com/shiny/ - is this a good way to
go?  What alternatives might I consider?

My IT/coding skills are limited.  I'm hoping at some point to find an R
expert to collaborate with, but in the mean time, a few pointers would be
appreciated.

Thanks!

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


Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information.  
Any unauthorized use, disclosure or distribution is prohibited.  If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Advice on use of R for Generalised Linear Modelling

2013-08-11 Thread Alan Sausse
Hi,

Not an expert R user, something of a novice - please be gentle with me!

I have a particular interest in generalised linear models (GLMs) and I'm
experienced in fitting them using other bits of software.

R can fit GLMs of course, using the glm() command.  I have some large
multivariate data sets I'd like to fit GLMs to, ideally using R.  Two
concerns though:

Firstly, I'm told that R isn't especially fast at fitting GLMs, especially
if the data files are too large to fit into RAM.  Can anyone advise if
there are alternatives to glm() around which might cope better.  For
example, I've heard that RevolutionR is available, and claims to fit GLMs
faster in these cases.  Might it be possible, alternatively, to write some
very quick code using C (for example) and to get R to invoke this instead?
 Has anyone tried to do this?

Secondly, I might like to create some kind of GUI so that I can have a nice
interface for viewing data, specifying models, showing graphical model
outputs, etc.  Is there a preferred way to do this?  The only GUI builder I
know of is Shiny - http://www.rstudio.com/shiny/ - is this a good way to
go?  What alternatives might I consider?

My IT/coding skills are limited.  I'm hoping at some point to find an R
expert to collaborate with, but in the mean time, a few pointers would be
appreciated.

Thanks!

[[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-pkgs] pls 2.4-3 released

2013-08-11 Thread Bjørn-Helge Mevik
Version 2.4-3 of the pls package has been released.  Windows and OSX
binaries should appear shortly.

The pls package implements Partial Least Squares Regression, Principal
Component Regression and Canonical Powered PLS Regression.

The major changes are:

- Can now perform cross-validation in parallel, using the facilities of
  the 'parallel' package.  See ?pls.options and the examples in ?mvr for
  details.  (Note: in order to use MPI, packages 'snow' and 'Rmpi' must
  be installed, because 'parallel' rely on them for MPI parallelisation.)

Other user-visible changes:

- In order to comply with current CRAN submission policies,
  pls.options() no longer stores the modified option list in the global 
  environment.  This has the effect that the options will have to be set
  every time R is started, even if the work space was saved an loaded.

-- 
Regards,
Bjørn-Helge Mevik

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


Re: [R] Working with string

2013-08-11 Thread Bert Gunter
Well, maybe: it assumes that the uppercase string version always
occurs after the nonuppercase version. That's why I rejected it.

However, it points out something important: details matter. The more
one knows about the nature of the problem, the better the solution one
can tailor -- a remark for which the response should be, "well duhhh!"
 But posters frequently seem to disregard this.

-- Bert

On Sun, Aug 11, 2013 at 8:43 AM, arun  wrote:
>
>
> Hi,
>
> May be this helps:
> chnew<-CH
>  chnew[duplicated(toupper(CH))]<-CH[duplicated(toupper(CH),fromLast=TRUE)]
>  chnew
> #[1] "aBd""sTb""aBd""dFDasd" "asd""dFDasd"
> A.K.
>
>
> - Original Message -
> From: Christofer Bogaso 
> To: r-help 
> Cc:
> Sent: Sunday, August 11, 2013 8:39 AM
> Subject: [R] Working with string
>
> Hello again,
>
> Let say I have a lengthy character vector like:
>
> CH <- c("aBd", "sTb", "ABD", "dFDasd", "asd", "DFDASD")
>
> Now I want to create a vector like:
>
> CH_New <- c("aBd", "sTb", "aBd", "dFDasd", "asd", "dFDasd")  ## the 3rd and
> 6th element replaced
>
> Basically, the goal is:
>
> If an element has all upper case then it will find another element with all
> lower case or mix of upper/lower case. Then the all-upper-case element will
> be replaced by that mix. If there is multiple match then chose the first
> one.
>
>
> Can somebody give me any pointer how can I achieve that?
>
> Thanks and regards,
>
> [[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.



-- 

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] Working with string

2013-08-11 Thread arun


Hi,

May be this helps:
chnew<-CH
 chnew[duplicated(toupper(CH))]<-CH[duplicated(toupper(CH),fromLast=TRUE)]
 chnew
#[1] "aBd"    "sTb"    "aBd"    "dFDasd" "asd"    "dFDasd"
A.K.


- Original Message -
From: Christofer Bogaso 
To: r-help 
Cc: 
Sent: Sunday, August 11, 2013 8:39 AM
Subject: [R] Working with string

Hello again,

Let say I have a lengthy character vector like:

CH <- c("aBd", "sTb", "ABD", "dFDasd", "asd", "DFDASD")

Now I want to create a vector like:

CH_New <- c("aBd", "sTb", "aBd", "dFDasd", "asd", "dFDasd")  ## the 3rd and
6th element replaced

Basically, the goal is:

If an element has all upper case then it will find another element with all
lower case or mix of upper/lower case. Then the all-upper-case element will
be replaced by that mix. If there is multiple match then chose the first
one.


Can somebody give me any pointer how can I achieve that?

Thanks and regards,

    [[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] Working with string

2013-08-11 Thread Bert Gunter
Oh, sorry. One type. Here's the correct version

On Sun, Aug 11, 2013 at 7:54 AM, Bert Gunter  wrote:
> Christofer:
>
> You may have to fortify the following a bit to allow for the
> possibility that some of your caps strings don't match. But other than
> that, I think this will do:
>
>> CH <- c("aBd", "sTb", "ABD", "dFDasd", "asd", "DFDASD")
>> caps <- CH %in%  toupper(CH)
>> noncaps <- CH[!caps]
>> chnew <- CH
>> chnew[caps] <- noncaps[match(CH[caps], toupper(noncaps))]
>> CH
> [1] "aBd""sTb""ABD""dFDasd" "asd"
> [6] "DFDASD"
>> chnew
> [1] "aBd""sTb""aBd""dFDasd" "asd"
> [6] "dFDasd"
>
> Cheers,
> Bert
>
> On Sun, Aug 11, 2013 at 5:39 AM, Christofer Bogaso
>  wrote:
>> Hello again,
>>
>> Let say I have a lengthy character vector like:
>>
>> CH <- c("aBd", "sTb", "ABD", "dFDasd", "asd", "DFDASD")
>>
>> Now I want to create a vector like:
>>
>> CH_New <- c("aBd", "sTb", "aBd", "dFDasd", "asd", "dFDasd")  ## the 3rd and
>> 6th element replaced
>>
>> Basically, the goal is:
>>
>> If an element has all upper case then it will find another element with all
>> lower case or mix of upper/lower case. Then the all-upper-case element will
>> be replaced by that mix. If there is multiple match then chose the first
>> one.
>>
>>
>> Can somebody give me any pointer how can I achieve that?
>>
>> Thanks and regards,
>>
>> [[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>
>
>
> --
>
> Bert Gunter
> Genentech Nonclinical Biostatistics
>
> Internal Contact Info:
> Phone: 467-7374
> Website:
> http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm



-- 

Bert Gunter
Genentech Nonclinical Biostatistics

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

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


Re: [R] Working with string

2013-08-11 Thread Bert Gunter
Christofer:

You may have to fortify the following a bit to allow for the
possibility that some of your caps strings don't match. But other than
that, I think this will do:

> CH <- c("aBd", "sTb", "ABD", "dFDasd", "asd", "DFDASD")
> caps <- CH %in% z
> noncaps <- CH[!caps]
> chnew <- CH
> chnew[caps] <- noncaps[match(CH[caps], toupper(noncaps))]
> CH
[1] "aBd""sTb""ABD""dFDasd" "asd"
[6] "DFDASD"
> chnew
[1] "aBd""sTb""aBd""dFDasd" "asd"
[6] "dFDasd"

Cheers,
Bert

On Sun, Aug 11, 2013 at 5:39 AM, Christofer Bogaso
 wrote:
> Hello again,
>
> Let say I have a lengthy character vector like:
>
> CH <- c("aBd", "sTb", "ABD", "dFDasd", "asd", "DFDASD")
>
> Now I want to create a vector like:
>
> CH_New <- c("aBd", "sTb", "aBd", "dFDasd", "asd", "dFDasd")  ## the 3rd and
> 6th element replaced
>
> Basically, the goal is:
>
> If an element has all upper case then it will find another element with all
> lower case or mix of upper/lower case. Then the all-upper-case element will
> be replaced by that mix. If there is multiple match then chose the first
> one.
>
>
> Can somebody give me any pointer how can I achieve that?
>
> Thanks and regards,
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



-- 

Bert Gunter
Genentech Nonclinical Biostatistics

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

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


[R] Working with string

2013-08-11 Thread Christofer Bogaso
Hello again,

Let say I have a lengthy character vector like:

CH <- c("aBd", "sTb", "ABD", "dFDasd", "asd", "DFDASD")

Now I want to create a vector like:

CH_New <- c("aBd", "sTb", "aBd", "dFDasd", "asd", "dFDasd")  ## the 3rd and
6th element replaced

Basically, the goal is:

If an element has all upper case then it will find another element with all
lower case or mix of upper/lower case. Then the all-upper-case element will
be replaced by that mix. If there is multiple match then chose the first
one.


Can somebody give me any pointer how can I achieve that?

Thanks and regards,

[[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] coxph diagnostics

2013-08-11 Thread Göran Broström



On 08/11/2013 06:14 AM, Soumitro Dey wrote:

Hello all,

This may be a naive question but since I'm new to R/survival models, I
cannot figure it out the problem myself.

I have a coxph model for my data and I am trying to test if the
proportional hazards assumption holds. Using cox.zph on the model I get a
global score:

GLOBAL  NA 4.20e+02 0.00e+00

Does this mean that the proportional hazard assumption does not hold?


Yes, or, the fit is very bad (see Bert's response).


When I plot the  Schoenfeld residuals, generally the plots are across
the horizontal line which makes me think that the proportional hazards
assumption still holds. Could someone please clarify on this?


Did you try

> plot(cox.zph(fit))

Read the help pages for cox.zph and plot.cox.zph. The raw Schoenfeld 
residuals plots are generally of limited value.


With factor covariate(s) you could also perform a graphical inspection 
by plotting the estimated cumulative hazards, stratifying on these factors.


A somewhat unrelated question: I have come across several papers which
just calculate the coxph model without the diagnostics for
proportional hazards assumption and interpret the results of the
regression directly. Should that be acceptable?


No.


Are there other ways
to show the goodness of the model?


Yes, see above.

Göran

 Thanks!


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