[R] How to repeat replication

2012-11-30 Thread Kamontip Srihaset


Dear all,

I generate data under IRT mdel. I conducted 1000 replications. When I run, some 
replication was not fit with my model. So, replications were fit model were 
less than 1000 replication. If I want its run until 1000 replicaions. How 
shouldI write functin. 

Thank you,
Kamontip



[[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 subtract the counter i in for loop?

2012-11-30 Thread Berend Hasselman

On 30-11-2012, at 07:18, C W wrote:

 thanks, Berend.  Both of your code works great.  Is there a function that can 
 do it?  
 
 Something like this:
 x - matrix(NA, nrow=15, ncol=2)
 for(i in 1:15){
x[i,] - sample(c(NA, 20, 77), 2, prob=c(0.2, 0.3, 0.4))
 }
 
  x
 
   [,1] [,2]
 
  [1,]   NA   77
 
  [2,]   77   NA
 
  [3,]   NA   77
 
  [4,]   77   20
 
  [5,]   77   20
 
  [6,]   77   20
 
  [7,]   20   NA
 
  [8,]   77   20
 
  [9,]   77   NA
 
 [10,]   77   NA
 
 [11,]   77   20
 
 [12,]   20   77
 
 [13,]   NA   77
 
 [14,]   77   20
 
 [15,]   77   20
 
 I want to have a column of 15 samples without NA's.  Is there an R function 
 like ifelse()?
 

It's not clear what you exactly want.
A matrix with 15 rows and some columns?
How do you want to remove the NA's in each column?
Then why don't you leave out the NA in the sample?

Berend

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


Re: [R] googleVis plot and knitr/sweave

2012-11-30 Thread Gergely Daróczi
Just a lame question: is there any chance to generate SVG maps with
googleVis and import that in LaTeX?

Best,
Gergely

On Fri, Nov 30, 2012 at 2:02 AM, Yihui Xie x...@yihui.name wrote:

 Then you can take a look at the ggmap (on CRAN) or snippets package
 (on Simon's RFroge: http://rforge.net/snippets/), which supports
 OpenStreet Map; googleVis is HTML/SVG based.

 Regards,
 Yihui
 --
 Yihui Xie xieyi...@gmail.com
 Phone: 515-294-2465 Web: http://yihui.name
 Department of Statistics, Iowa State University
 2215 Snedecor Hall, Ames, IA


 On Thu, Nov 29, 2012 at 5:00 PM, Filoche pmassico...@hotmail.com wrote:
  Hi and thank you for your answer.
 
  In fact, I don't really need the interactive part of googleVis map. So if
  there's a way to plot a static version of the map it would be perfect for
  me.
 
  Regards,
  Phil

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Little's Chi Square test for MCAR?

2012-11-30 Thread Jose Iparraguirre
If you mean Little's Chi Sq test in particular, go to the BaylorEdPsych package.
Regards,

José

José Iparraguirre
Chief Economist
Age UK

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Sileshi Melesse
Sent: 30 November 2012 05:57
To: 'r-h...@stat.math.ethz.ch'
Subject: [R] Little's Chi Square test for MCAR?

Is there any further development in R to identify the missing data Mechanism?
Would  you please help ?
=== Please find our Email Disclaimer here--: 
http://www.ukzn.ac.za/disclaimer ===

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

A Star for Christmas

Kick start the festive season by attending one of Age UK’s Carol Concerts, A 
Star for Christmas. Taking place at Manchester Cathedral on Saturday 1 December 
and London’s St Pancras Church (opposite Euston Station) on Thursday 6 
December, they will feature special musical performances, readings by your 
favourite celebrities and carols, followed by mince pies and wine.
Tickets are priced at £20 full price/ £10 concessions. For more information, 
please visit http://www.ageuk.org.uk/astarforchristmas  or contact the 
Fundraising Events Team on
020 303 31725.

Age UK  Improving later life
www.ageuk.org.uk

 

---
Age UK is a registered charity and company limited by guarantee, (registered 
charity number 1128267, registered company number 6825798). 
Registered office: Tavis House, 1-6 Tavistock Square, London WC1H 9NA.

For the purposes of promoting Age UK Insurance, Age UK is an Appointed 
Representative of Age UK Enterprises Limited, Age UK is an Introducer 
Appointed Representative of JLT Benefit Solutions Limited and Simplyhealth 
Access for the purposes of introducing potential annuity and health 
cash plans customers respectively.  Age UK Enterprises Limited, JLT Benefit 
Solutions Limited and Simplyhealth Access are all authorised and 
regulated by the Financial Services Authority. 
--

This email and any files transmitted with it are confidential and intended 
solely for the use of the individual or entity to whom they are 
addressed. If you receive a message in error, please advise the sender and 
delete immediately.

Except where this email is sent in the usual course of our business, any 
opinions expressed in this email are those of the author and do not 
necessarily reflect the opinions of Age UK or its subsidiaries and associated 
companies. Age UK monitors all e-mail transmissions passing 
through its network and may block or modify mails which are deemed to be 
unsuitable.

Age Concern England (charity number 261794) and Help the Aged (charity number 
272786) and their trading and other associated companies merged 
on 1st April 2009.  Together they have formed the Age UK Group, dedicated to 
improving the lives of people in later life.  The three national 
Age Concerns in Scotland, Northern Ireland and Wales have also merged with Help 
the Aged in these nations to form three registered charities: 
Age Scotland, Age NI, Age Cymru.










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

2012-11-30 Thread Alexandros Karatzoglou

kernlab package version 0.9-15 has been posted on CRAN,
it contains several improvements and fixes along with new features e.g. 
variance estimation for Gaussian Process  regression.


cheers
Alexandros

___
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] worldmap_region/country problem

2012-11-30 Thread Roger Bivand
 anna.fechner at de.pwc.com writes:

 
 Dear R community,
 
 I'm trying to graphically illustrate my data with a worlmap. 
 Unfortunately, my data is partly on country basis and partly on regional 
 basis (e.g. certain African countries are aggregated to one region). I am 
 using the package rwoldmap.
 
 The data on country basis can be mapped, but our defined regions cannot be 
 identified in R. Therefore, all the countries in these regions are not 
 plotted.
 Is there a way to define regions (for example 'Rest of East-Europe') and 
 to map a combination of these defined regions and individual countries in 
 one worldmap?
 
 Is it possible to not display borderlines between some countries but to 
 show the borders between others?

Yes, use gUnaryUnion() in rgeos, or the equivalent unionSpatialPolygons() in
maptools, which calls gUnaryUnion(). These create new, merged polygons, and
should then be associated with the data for the entities you are using. Be
careful not to use gpclib union functions as they are prohibited for commercial
purposes. Please follow up on the R-sig-geo list if need be.

Roger

 
 Thank you very much for your help!
 Anna Fechner
 
 PricewaterhouseCoopers Aktiengesellschaft Wirtschaftsprüfungsgesellschaft


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] CreateThread failure since R 2.15.2 (32-bit)

2012-11-30 Thread Martin Studer
Dear R users  developers,

I coming across the following issue since R 2.15.2 32-bit (running on
Windows XP 32.bit; some output left out for conciseness):

 setInternet2(TRUE)
 require(rJava)
 .jinit()
 getCRANmirrors()
 system(ls , intern = TRUE)
Error in system(ls, intern = TRUE) : CreateThread failed

My details are as follows:

 sessionInfo()
R version 2.15.2 (2012-10-26)
Platform: i386-w64-mingw32/i386 (32-bit)

locale:
[1] LC_COLLATE=German_Switzerland.1252
LC_CTYPE=German_Switzerland.1252
LC_MONETARY=German_Switzerland.1252
[4] LC_NUMERIC=CLC_TIME=German_Switzerland.1252

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

other attached packages:
[1] rJava_0.9-3


The failure appears since R 2.15.2, i.e. also with R 2.15.2patched and
with R-Devel. It does, however, not appear with e.g. R 2.15.1 or R
2.14.2. Also, I don't get the issue with R 2.15.2 64-bit (running on
Windows 7 Professional 64-bit).

Also note that the issue seems related to rJava in that running the
same without the rJava part (and therefore without initializing a JVM
instance) runs fine:

 setInternet2(TRUE)
 getCRANmirrors()
 system(ls , intern = TRUE)

Any ideas on what the issue might be?

Thanks  Best regards,
Martin

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

2012-11-30 Thread Andras Farkas
Dear All,
 
#I have the following code
 
Dose-1000
Tinf -0.5
INTERVAL -8
TIME8 -matrix(c((0*INTERVAL):(1*INTERVAL)))
TIME7 -matrix(c((0*INTERVAL):(2*INTERVAL)))
TIME6 -matrix(c((0*INTERVAL):(3*INTERVAL)))
TIME5 -matrix(c((0*INTERVAL):(4*INTERVAL)))
TIME4 -matrix(c((0*INTERVAL):(5*INTERVAL)))
TIME3 -matrix(c((0*INTERVAL):(6*INTERVAL)))
TIME2 -matrix(c((0*INTERVAL):(7*INTERVAL)))
TIME1 -matrix(c((0*INTERVAL):(8*INTERVAL)))
CDURINF1 -((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*TIME1))
CAFTINF1 
-((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*Tinf))*(exp(-0.088*(TIME1)))
CONC1 -ifelse(TIME1=Tinf,CDURINF1,CAFTINF1)
CDURINF2 -((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*TIME2))
CAFTINF2 
-((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*Tinf))*(exp(-0.088*(TIME2)))
CONC2 -ifelse(TIME2=Tinf,CDURINF2,CAFTINF2)
CDURINF3 -((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*TIME3))
CAFTINF3 
-((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*Tinf))*(exp(-0.088*(TIME3)))
CONC3 -ifelse(TIME3=Tinf,CDURINF3,CAFTINF3)
CDURINF4 -((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*TIME4))
CAFTINF4 
-((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*Tinf))*(exp(-0.088*(TIME4)))
CONC4 -ifelse(TIME4=Tinf,CDURINF4,CAFTINF4)
CDURINF5 -((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*TIME5))
CAFTINF5 
-((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*Tinf))*(exp(-0.088*(TIME5)))
CONC5 -ifelse(TIME5=Tinf,CDURINF5,CAFTINF5)
CDURINF6 -((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*TIME6))
CAFTINF6 
-((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*Tinf))*(exp(-0.088*(TIME6)))
CONC6 -ifelse(TIME6=Tinf,CDURINF6,CAFTINF6)
CDURINF7 -((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*TIME7))
CAFTINF7 
-((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*Tinf))*(exp(-0.088*(TIME7)))
CONC7 -ifelse(TIME7=Tinf,CDURINF7,CAFTINF7)
CDURINF8 -((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*TIME7))
CAFTINF8 
-((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*Tinf))*(exp(-0.088*(TIME8)))
CONC8 -ifelse(TIME8=Tinf,CDURINF8,CAFTINF8)
CONCF -matrix(c(CONC1+CONC2+CONC3+CONC4+CONC5+CONC6+CONC7+CONC8))
plot(CONCF,type=l)
 
I am trying to plot CONCF in a specific way. Let me try to explain: I would 
like to plot it so that the x axis goes from 0 to 8*INTERVAL (here the INTERVAL 
represents time in hours), and then each segments of the matrix  would  be 
added to the sum of the previous ones at a specific moment in time. Assuming a 
much shorter example this is what it should be like where according to the same 
equations above each value of CONCi was calculated at 1 h intervals:
INTERVAL =3
time points here where the values are calculated is 0:(3*INTERVAL) for CONC1, 
0:(2*INTERVAL) for CONC2, and 0:(1*INTERVAL) for CONC3, all calculated at 1 
hour intervals
 
and lets assume calculated values are:
 
CONC1 -c(0,1,2,3,4,5,6,7,8,9)
CONC2 -c( 11,12,13,14,15,16,17)
CONC3 -(21,22,23,24)
.
.
.
 
so I would like to get CONCF that would have the following values:
CONCF -c(0,1,2,3+11,4+12,5+13,6+14,7+15,8+16,9+17,  
6+14+21,7+15+22,8+16+23,9+17+23)
please note that CONC2 was started to be added to CONC1 at 1*INTERVAL value 
estimated for CONC1, ie CONC1 has the value of 3 at hour 3, and I need to add 
the value of CONC2 at hour zero to it, and so on...
hope I made it clear enough and thanks for the help,
 
Andras
[[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] Confidence intervals for estimates of all independent variables in WLS regression

2012-11-30 Thread Rui Barradas

Hello,

You don't have to exchange 'object' by the name of your model, you call 
the function with the name of your model:


x - 1:20
y - x + rnorm(20)
fit - lm(y ~ x)

ci_lm(fit)
 beta  lowerupper
(Intercept) 0.6741130 -0.9834827 2.331709
x   0.9575906  0.8192171 1.095964

Hope this helps,

Rui Barradas
Em 30-11-2012 01:07, Torvon escreveu:

Rui,

Thank you very much. Are there other things I have to adjust except for
exchanging object by the name of my model?
Torvon

On 29 November 2012 08:17, Rui Barradas ruipbarra...@sapo.pt wrote:


ci_lm - function(object, level = 0.95){
  summfit - summary(object)
  beta - summfit$coefficients[, 1]
  se - summfit$coefficients[, 2]
  df - summfit$df[1]
  alpha - 1 - level
  lower - beta + qt(alpha/2, df = df)*se
  upper - beta + qt(1 - alpha/2, df = df)*se
  data.frame(beta, lower, upper)
}



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

2012-11-30 Thread Stefan Stagge
Hello R-Users, Hello R-help-team.

I found a nice way to create a xy-plot with a single log-axis (e.g. the 
y-axis). This is often needed to show biological data.

First attach the desired dataset you want to plot.
Now use the following commands:

 plot(x,y,log=y, yaxt=n, ylim=c(0.1,10), ... )
 y1-floor(log10(range(WT)))
 pow-seq(y1[1],y1[2]+1)
 ticksat -as.vector(sapply(pow, function(p) (1:10)*10^p))
 axis(2, 10^pow)
 axis(2, ticksat, labels=NA, tcl=-0.25, lwd=0, lwd.ticks=1)

I want to thank Aaron from http://stackoverflow.com/users/210673/aaron.

I just added the ylim option to create a nice 0.1 to 10 log-axis which is 
commonly used for biological datasets.

Good luck,
Stefan
-- 
Dipl. Biologe Stefan Stagge

Pengsjövägen 35
91133 Vännäs

mobilephone: +46 762 666401

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

2012-11-30 Thread Giles
Hi

I see a changed behaviour in xts indexed on class Date in the latest
versions, versus 2.

It seems to be related to changes to/from daylight savings time,
happens those weekends.

Is it not intended that class Date be used like this, or is this new
behaviour incorrect?

Giles


Example:

 a-as.Date(15423:15426)
 x-xts(seq_along(a),a)
 print(x)
   [,1]
2012-03-241
2012-03-252
2012-03-253
2012-03-264
 print(index(x))
[1] 2012-03-24 2012-03-25 2012-03-25 2012-03-26
 print(as.numeric(index(x)))
[1] 15423 15424 15424 15425

#for reference, zoo behaves as expected:
 z-zoo(seq_along(a),a)
 print(index(z))
[1] 2012-03-24 2012-03-25 2012-03-26 2012-03-27
 print(as.numeric(index(z)))
[1] 15423 15424 15425 15426


Package: xts
Type: Package
Title: eXtensible Time Series
Version: 0.8-8
Date: 2012-10-05

Windows 7 64-bit
R version 2.15.2 64-bit
all packages up-to-date

#--previously, R 2.13.2 and xts 0.8-2 , showing expected
behaviour -

 a-as.Date(15423:15426)
 x-xts(seq_along(a),a)
 print(x)
   [,1]
2012-03-241
2012-03-252
2012-03-263
2012-03-274
 print(index(x))
[1] 2012-03-24 2012-03-25 2012-03-26 2012-03-27
 print(as.numeric(index(x)))
[1] 15423 15424 15425 15426
 z-zoo(seq_along(a),a)
 print(index(z))
[1] 2012-03-24 2012-03-25 2012-03-26 2012-03-27
 print(as.numeric(index(z)))
[1] 15423 15424 15425 15426


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

2012-11-30 Thread Vasilchenko Aleksander
Hello
I have dataframe
101 2008-07 0.2898966
102 2008-08 0.3101667
103 2008-09 0.3730476
104 2008-10 0.2717037
105 2008-11 0.1344286
106 2008-12 0.1375000
107 2009-01 0.1781000
108 2009-02 0.2146667
109 2009-03 0.2808235
110 2009-04 0.4326250
111 2009-05 0.3420741
112 2009-06 0.2675238
113 2009-07 0.2478667
114 2009-08 0.3147000
115 2009-09 0.3437826
116 2009-10 0.2057391
117 2009-11 0.1824737
118 2009-12 0.1520714
119 2010-01 0.1485455
120 2010-02 0.176
121 2010-03 0.3072000
122 2010-04 0.3294445
123 2010-05 0.3278125
124 2010-06 0.2865000
125 2010-07 0.3170333
126 2010-08 0.2052143
127 2010-09 0.1837368
128 2010-10 0.1652778
129 2010-11 0.1292500
130 2010-12 0.1366250
131 2011-01 0.1909231
132 2011-02 0.1841177
133 2011-03 0.2897222
134 2011-04 0.3084211
135 2011-05 0.3349600
136 2011-06 0.3157917
137 2011-07 0.2755652
138 2011-08 0.2019355
139 2011-09 0.3325556
140 2011-10 0.1724348
141 2011-11 0.1935200
142 2011-12 0.1388000
143 2012-01 0.1484500
144 2012-02 0.204
145 2012-03   NaN
146 2012-04   NaN
147 2012-05   NaN
148 2012-06   NaN
149 2012-07   NaN
150 2012-08   NaN
151 2012-09   NaN
then I use function df.ts- ts(df[,2],start=c(2004,10),freq=12) and try to
use stl(log(df.ts),s.window=periodic) But I have an error related with
missed values.
How can omit missing values?
Regards Aleksander

[[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] TSCov function from RTAQ package

2012-11-30 Thread billycorg
Hi R Users!

I am having some difficulties in using the TSCov function from RTAQ package
that should calculate the two time scale realized volatility (Zhang et al,
2005).

Let's suppose I have tick by tick data, let's say aaa and bbb.

If I write in R:

/stock1=aaa$PRICE
stock2=bbb$PRICE

TSCov(list(stock1,stock2))/

The result is: /Error in var[i] : object of type 'closure' is not
subsettable/

Instead, if I write:

/TSCov(stock1,stock2)/

I obtain a single value and not a 2X2 matrix (one for each day).

I would only want to obtain a 2x2 matrix per day.

Where is my error? It would be sufficient an example of correct syntax! :)

Thank you, 
Vincent





--
View this message in context: 
http://r.789695.n4.nabble.com/TSCov-function-from-RTAQ-package-tp4651402.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] subgroup-based quantiles

2012-11-30 Thread R Kozarski
Dear R users, 
given the patient sample with their Gender and Age
GENDER Age
   [1,]  2  45
   [2,]  1  58
   [3,]  1  54
   [4,]  2  71
   [5,]  2  64
 ...
I would like to create an another column which groups the patients wrt
Gender specific Age quantiles, following methodology similar to:

Age_group - cut(Age, labels=c(1:10), breaks=quantile(Age,
seq(0,1,.1)),include.lowest = TRUE)

The function above allows me to group only wrt Age quantiles.

Best, Robert




--
View this message in context: 
http://r.789695.n4.nabble.com/subgroup-based-quantiles-tp4651415.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] Shipping densitty

2012-11-30 Thread suuz




--
View this message in context: 
http://r.789695.n4.nabble.com/Shipping-densitty-tp4651404.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] Oracle database connction from R in Linux

2012-11-30 Thread sasidhar M
Hi,

This is sasi.
I installed R 64 bit and oracle client 64 bit in fedora 17. After R is
working fine. Oracle database also working fine. but problem is, If i try
to connect oracle from R its not connecting.
So, pls guide me how to connect from R to oracle.


how, i tried:--

odbcinst.ini file code is

[ORACLE2]
Description = oracle driver
Driver = /ibexis/app/oracle/product/11.2.0/db_1/lib/libsqora.so.11.1
DontDLClose = 1
FileUsage = 1
UsageCount = 1


I tried in R ...
library(RODBC)
con - odbcConnect(data source name, uid=username, pwd=password)

after this line i got error,

 odbcConnect(india, uid=data_quality, pwd=data_quality)
[1] -1
Warning messages:
1: In odbcDriverConnect(DSN=india;UID=data_quality;PWD=data_quality) :
  [RODBC] ERROR: state 01000, code 0, message [unixODBC][Driver
Manager]Can't open lib
'/ibexis/app/oracle/product/11.2.0/db_1/lib/libsqora.so.11.1' : file not
found
2: In odbcDriverConnect(DSN=india;UID=data_quality;PWD=data_quality) :
  ODBC connection failed

Please help me .
Iam eagerly waiting for reply

Thanks  Regards
M.Sasidhar

[[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] Changing the base of geom_bar in ggplot

2012-11-30 Thread Werner
Hi,

this is likely very easy to do but I don't find the right terms to search
for the solution. 
I want to show in a bar chart how much different categories deviate from the
average percentage change. 
Thus, in the following example I would like to set the zero line or base or
whatever it is called to the average of the values (=0.82) and the bars
should show the deviation from that, i.e. have the positive length of the
deviation of the value from the average.
I can do that by subtracting the average from each value but I would like to
have the zero line as the average to make it more clear.
How do you change the 'base'-line?

x - data.frame(val=c(1.5, 3, -1.4, -1, 2), lab=letters[1:5])
ggplot(data=x, aes(x=lab, y=val)) + geom_bar(stat=identity) 

Many thanks for your help!

Best regards,
Werner



--
View this message in context: 
http://r.789695.n4.nabble.com/Changing-the-base-of-geom-bar-in-ggplot-tp4651407.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] Nightingale’s Rose chart-any suggestion?

2012-11-30 Thread Henry Smith
Hello, Everyone.

Does anyone know how to create a Nightingale’s Rose chart by using R?
Hopefully, the graph could be displayed like this:
http://mbostock.github.com/protovis/ex/crimea-rose.html
Thanks a lot.

Kind regards,
Henry

[[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] Generating sequences of dates

2012-11-30 Thread Vasilchenko Aleksander
Hello,

I have the starting date in UNIX_TIME LONG number (number of milliseconds
since 1970 jan 1st).

Is there a way to generete the sequence of dates with monthly interval in
POSIXct format like

2000-01-01
2000-02-01
2000-03-01

etc

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] missed values

2012-11-30 Thread arun
HI,
Use,
?na.omit()
na.omit(data)
A.K.




- Original Message -
From: Vasilchenko Aleksander vasilchenko@gmail.com
To: r-help@r-project.org
Cc: 
Sent: Friday, November 30, 2012 7:07 AM
Subject: [R] missed values

Hello
I have dataframe
101 2008-07 0.2898966
102 2008-08 0.3101667
103 2008-09 0.3730476
104 2008-10 0.2717037
105 2008-11 0.1344286
106 2008-12 0.1375000
107 2009-01 0.1781000
108 2009-02 0.2146667
109 2009-03 0.2808235
110 2009-04 0.4326250
111 2009-05 0.3420741
112 2009-06 0.2675238
113 2009-07 0.2478667
114 2009-08 0.3147000
115 2009-09 0.3437826
116 2009-10 0.2057391
117 2009-11 0.1824737
118 2009-12 0.1520714
119 2010-01 0.1485455
120 2010-02 0.176
121 2010-03 0.3072000
122 2010-04 0.3294445
123 2010-05 0.3278125
124 2010-06 0.2865000
125 2010-07 0.3170333
126 2010-08 0.2052143
127 2010-09 0.1837368
128 2010-10 0.1652778
129 2010-11 0.1292500
130 2010-12 0.1366250
131 2011-01 0.1909231
132 2011-02 0.1841177
133 2011-03 0.2897222
134 2011-04 0.3084211
135 2011-05 0.3349600
136 2011-06 0.3157917
137 2011-07 0.2755652
138 2011-08 0.2019355
139 2011-09 0.3325556
140 2011-10 0.1724348
141 2011-11 0.1935200
142 2011-12 0.1388000
143 2012-01 0.1484500
144 2012-02 0.204
145 2012-03       NaN
146 2012-04       NaN
147 2012-05       NaN
148 2012-06       NaN
149 2012-07       NaN
150 2012-08       NaN
151 2012-09       NaN
then I use function df.ts- ts(df[,2],start=c(2004,10),freq=12) and try to
use stl(log(df.ts),s.window=periodic) But I have an error related with
missed values.
How can omit missing values?
Regards Aleksander

    [[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] how to separate stuck row elements?

2012-11-30 Thread Jaime Otero Villar

Hi,

I was wondering if it's possible to separate elements in multiple rows  
that actually should appear in different columns. I have a file where  
in certain lines there are elements not separated, and they certainly  
should appear in different columns (an example of the file is  
attached). The point is that I do not want to manually add a space in  
the txt file, however, I did not manage to do it automatically in R...


Thanks in advance for any insight.

Jaime


-100 -100-3456-3456-3456-100 -100
23 -3456-3456-189 34 56 78
-100 34 56 21 44 65 78


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Nightingale’s Rose chart-any suggestion?

2012-11-30 Thread Rui Barradas
Hello,

Take a look at the graph in

http://gallery.r-enthusiasts.com/graph/Rose_diagram,97

Hope this helps,

Rui Barradas
Em 30-11-2012 12:24, Henry Smith escreveu:
 Hello, Everyone.

 Does anyone know how to create a Nightingale’s Rose chart by using R?
 Hopefully, the graph could be displayed like this:
 http://mbostock.github.com/protovis/ex/crimea-rose.html
 Thanks a lot.

 Kind regards,
 Henry

   [[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] Generating sequences of dates

2012-11-30 Thread Rui Barradas

Hello,

Try the following.


Y - 2000:2001
M - 1:12
D - 1
x - expand.grid(Y, M, D)

Dates - sort(as.Date(apply(x, 1, paste, collapse = -)))


Hope this helps,

Rui Barradas
Em 30-11-2012 12:26, Vasilchenko Aleksander escreveu:

Hello,

I have the starting date in UNIX_TIME LONG number (number of milliseconds
since 1970 jan 1st).

Is there a way to generete the sequence of dates with monthly interval in
POSIXct format like

2000-01-01
2000-02-01
2000-03-01

etc

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.


Re: [R] how to separate stuck row elements?

2012-11-30 Thread Rui Barradas
Hello,

Try the following.

x - scan(text=
-100 -100-3456-3456-3456-100 -100
23 -3456-3456-189 34 56 78
-100 34 56 21 44 65 78
, what = )


fun - function(x){
 f - function(.x){
 if(grepl(-[[:digit:]]+, .x)){
 g - gregexpr(-[[:digit:]]+, .x)
 .y - as.numeric(unlist(regmatches(.x, g)))
 }else{
 .y - as.numeric(.x)
 }
 .y
 }
 unlist(unname(sapply(x, f)))
}

fun(x)


Hope this helps,

Rui Barradas
Em 30-11-2012 12:55, Jaime Otero Villar escreveu:
 Hi,

 I was wondering if it's possible to separate elements in multiple rows 
 that actually should appear in different columns. I have a file where 
 in certain lines there are elements not separated, and they certainly 
 should appear in different columns (an example of the file is 
 attached). The point is that I do not want to manually add a space in 
 the txt file, however, I did not manage to do it automatically in R...

 Thanks in advance for any insight.

 Jaime





 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Deleting certain observations (and their imprint?)

2012-11-30 Thread PIKAL Petr
Hi

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
 project.org] On Behalf Of Stodola, Kirk
 Sent: Thursday, November 29, 2012 5:32 PM
 To: r-help@r-project.org
 Subject: [R] Deleting certain observations (and their imprint?)
 
 I'm manipulating a large dataset and need to eliminate some
 observations based on specific identifiers.  This isn't a problem in
 and of itself (using which.. or subset..) but an imprint of the deleted
 observations seem to remain, even though they have 0 observations.
 This is causing me problems later on.  I'll use the dataset warpbreaks
 to illustrate, I apologize if this isn't in the best format
 
 ##Summary of warpbreaks suggests three tension levels (H, M, L)
  summary(warpbreaks)
 
  breaks  wool   tension
  Min.   :10.00   A:27   L:18
  1st Qu.:18.25   B:27   M:18
  Median :26.00  H:18
  Mean   :28.15
  3rd Qu.:34.00
  Max.   :70.00
 
 ## Subset the dataset and keep only those observations with L
  wb.subset - warpbreaks[which(warpbreaks$tension==L),]

wb.subset - warpbreaks[which(warpbreaks$tension==L), , drop=TRUE]
or
warpbreaks$tension -  factor(warpbreaks$tension)
or
change tension from factor to character vector.

Regards
Petr



 
 
 ##Summary of the subsetted data shows: L=18, M=0, H=0, Why is M and H
 still included?
  summary(wb.subset)
 
  breaks  wool  tension
  Min.   :14.00   A:9   L:18
  1st Qu.:26.00   B:9   M: 0
  Median :29.50 H: 0
  Mean   :36.39
  3rd Qu.:49.25
  Max.   :70.00
 
 ##The subsetted dataset does not show M or H
  wb.subset
 
 Is there a way that M  H can be completely eliminated (i.e. they don't
 show up in summary)? The only way I found was to export the dataset and
 then reimport, which seems pretty cumbersome.  Thanks in advance for
 any help.  -Kirk
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] help on stacking matrices up

2012-11-30 Thread PIKAL Petr
Hi

try to make your example easier and reproducible.

I get

 CONCF -matrix(c(CONC1+CONC2+CONC3+CONC4+CONC5+CONC6+CONC7+CONC8))
Error in CONC1 + CONC2 : non-conformable arrays

so I cannot understand what shall the final plot look like.

Regards

Petr


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
 project.org] On Behalf Of Andras Farkas
 Sent: Friday, November 30, 2012 12:51 PM
 To: r-help@r-project.org
 Subject: [R] help on stacking matrices up
 
 Dear All,
 
 #I have the following code
 
 Dose-1000
 Tinf -0.5
 INTERVAL -8
 TIME8 -matrix(c((0*INTERVAL):(1*INTERVAL)))
 TIME7 -matrix(c((0*INTERVAL):(2*INTERVAL)))
 TIME6 -matrix(c((0*INTERVAL):(3*INTERVAL)))
 TIME5 -matrix(c((0*INTERVAL):(4*INTERVAL)))
 TIME4 -matrix(c((0*INTERVAL):(5*INTERVAL)))
 TIME3 -matrix(c((0*INTERVAL):(6*INTERVAL)))
 TIME2 -matrix(c((0*INTERVAL):(7*INTERVAL)))
 TIME1 -matrix(c((0*INTERVAL):(8*INTERVAL)))
 CDURINF1 -((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*TIME1))
 CAFTINF1 -((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*Tinf))*(exp(-
 0.088*(TIME1)))
 CONC1 -ifelse(TIME1=Tinf,CDURINF1,CAFTINF1)
 CDURINF2 -((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*TIME2))
 CAFTINF2 -((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*Tinf))*(exp(-
 0.088*(TIME2)))
 CONC2 -ifelse(TIME2=Tinf,CDURINF2,CAFTINF2)
 CDURINF3 -((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*TIME3))
 CAFTINF3 -((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*Tinf))*(exp(-
 0.088*(TIME3)))
 CONC3 -ifelse(TIME3=Tinf,CDURINF3,CAFTINF3)
 CDURINF4 -((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*TIME4))
 CAFTINF4 -((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*Tinf))*(exp(-
 0.088*(TIME4)))
 CONC4 -ifelse(TIME4=Tinf,CDURINF4,CAFTINF4)
 CDURINF5 -((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*TIME5))
 CAFTINF5 -((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*Tinf))*(exp(-
 0.088*(TIME5)))
 CONC5 -ifelse(TIME5=Tinf,CDURINF5,CAFTINF5)
 CDURINF6 -((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*TIME6))
 CAFTINF6 -((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*Tinf))*(exp(-
 0.088*(TIME6)))
 CONC6 -ifelse(TIME6=Tinf,CDURINF6,CAFTINF6)
 CDURINF7 -((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*TIME7))
 CAFTINF7 -((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*Tinf))*(exp(-
 0.088*(TIME7)))
 CONC7 -ifelse(TIME7=Tinf,CDURINF7,CAFTINF7)
 CDURINF8 -((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*TIME7))
 CAFTINF8 -((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*Tinf))*(exp(-
 0.088*(TIME8)))
 CONC8 -ifelse(TIME8=Tinf,CDURINF8,CAFTINF8)
 CONCF -matrix(c(CONC1+CONC2+CONC3+CONC4+CONC5+CONC6+CONC7+CONC8))
 plot(CONCF,type=l)
 
 I am trying to plot CONCF in a specific way. Let me try to explain: I
 would like to plot it so that the x axis goes from 0 to 8*INTERVAL
 (here the INTERVAL represents time in hours), and then each segments
 of the matrix  would  be added to the sum of the previous ones at a
 specific moment in time. Assuming a much shorter example this is what
 it should be like where according to the same equations above each
 value of CONCi was calculated at 1 h intervals:
 INTERVAL =3
 time points here where the values are calculated is 0:(3*INTERVAL) for
 CONC1, 0:(2*INTERVAL) for CONC2, and 0:(1*INTERVAL) for CONC3, all
 calculated at 1 hour intervals
 
 and lets assume calculated values are:
 
 CONC1 -c(0,1,2,3,4,5,6,7,8,9)
 CONC2 -c( 11,12,13,14,15,16,17)
 CONC3 -(21,22,23,24)
 .
 .
 .
 
 so I would like to get CONCF that would have the following values:
 CONCF -c(0,1,2,3+11,4+12,5+13,6+14,7+15,8+16,9+17,
 6+14+21,7+15+22,8+16+23,9+17+23) please note that CONC2 was started to
 be added to CONC1 at 1*INTERVAL value estimated for CONC1, ie CONC1 has
 the value of 3 at hour 3, and I need to add the value of CONC2 at hour
 zero to it, and so on...
 hope I made it clear enough and thanks for the help,
 
 Andras
   [[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 separate stuck row elements?

2012-11-30 Thread Berend Hasselman

On 30-11-2012, at 13:55, Jaime Otero Villar wrote:

 Hi,
 
 I was wondering if it's possible to separate elements in multiple rows that 
 actually should appear in different columns. I have a file where in certain 
 lines there are elements not separated, and they certainly should appear in 
 different columns (an example of the file is attached). The point is that I 
 do not want to manually add a space in the txt file, however, I did not 
 manage to do it automatically in R...
 

Taking into account your description simulate file.
Use readLines to read the file into a vector of lines.
Use gsub() to replace each - with a single space.
Finally use read.table to get a dataframe.


# use the example consisting of 3 lines
data.text - -100 -100-3456-3456-3456-100 -100
23 -3456-3456-189 34 56 78
-100 34 56 21 44 65 78

x.lines - readLines(textConnection(data.text))
x.lines

# replace - with single space 
 
x.1 - gsub(-, ,x.lines)
x.1

read.table(text=x.1, header=FALSE) 

Berend

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


Re: [R] bootstrapped cox regression (rms package)

2012-11-30 Thread Frank Harrell
Thanks Eric.  It would be good to show your entire script next time as stated
in the posting guidance.

Regarding matching with SPSS please describe the bootstrapping algorithm
used there.  In rms I do the unconditional bootstrap, i.e., I sample with
replacement from the rows of the raw data.  And also make sure that SPSS ran
a large number of bootstrap replications.

Frank


Eric Claus wrote
 Hi Frank,
 Below is the actual output from the anova(out) command.  I had copied in
 the p-values and from the previous output from anova(out) and the
 confidence intervals from print(quantile(out$boot.Coef[,i], c(.025,
 .975))) to illustrate that the confidence intervals were similar to SPSS
 while the p-values were not.
 
 Actual output from anova.rms(out):
 
  Wald Statistics  Response: Surv(months, recidivate) 
 
  Factor   Chi-Square d.f. P 
 fac1  0.27   10.6055
 fac2  0.20   10.6514
 fac3  0.01   10.9338
 fac4  0.05   10.8311
 fac5  1.06   10.3036
 fac6  0.33   10.5647
 fac7  0.81   10.3670
 fac8  0.30   10.5832
  TOTAL   1.48   80.9930
 
 Regarding your second question, it looks like SPSS is using the original
 estimate of Cox beta coefficients in the test (i.e. a new point estimate
 is not generated for the statistical test)
 
 Thanks again,
 Eric





-
Frank Harrell
Department of Biostatistics, Vanderbilt University
--
View this message in context: 
http://r.789695.n4.nabble.com/bootstrapped-cox-regression-rms-package-tp4651306p4651438.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] Changing the base of geom_bar in ggplot

2012-11-30 Thread Jeff Newmiller
I think your request is internally inconsistent: you want units of percent but 
you want to show the average(I assume you intend mean)?

You can subtract the mean from each value and then divide by the mean, then 
subtract 1, then multiply by 100. You inherently lose visibility to what the 
mean was, but that is the nature of percentages.
---
Jeff NewmillerThe .   .  Go Live...
DCN:jdnew...@dcn.davis.ca.usBasics: ##.#.   ##.#.  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.

Werner pensterfuz...@yahoo.de wrote:

Hi,

this is likely very easy to do but I don't find the right terms to
search
for the solution. 
I want to show in a bar chart how much different categories deviate
from the
average percentage change. 
Thus, in the following example I would like to set the zero line or
base or
whatever it is called to the average of the values (=0.82) and the bars
should show the deviation from that, i.e. have the positive length of
the
deviation of the value from the average.
I can do that by subtracting the average from each value but I would
like to
have the zero line as the average to make it more clear.
How do you change the 'base'-line?

x - data.frame(val=c(1.5, 3, -1.4, -1, 2), lab=letters[1:5])
ggplot(data=x, aes(x=lab, y=val)) + geom_bar(stat=identity) 

Many thanks for your help!

Best regards,
Werner



--
View this message in context:
http://r.789695.n4.nabble.com/Changing-the-base-of-geom-bar-in-ggplot-tp4651407.html
Sent from the R help mailing list archive at Nabble.com.

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

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


[R] subset data frame by variable with missing value

2012-11-30 Thread ramoss
Hello,

I have a variable in a data frame that contains NA values. I just want to
subset so that I get the obs where that variable is missing.
In SAS I would do:

data missing;
  set test;
  if myvalue=' ';
run;

How can I perform this simple task in R?

Thanks in advance for your help. 



--
View this message in context: 
http://r.789695.n4.nabble.com/subset-data-frame-by-variable-with-missing-value-tp4651439.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] subset data frame by variable with missing value

2012-11-30 Thread Marc Schwartz
On Nov 30, 2012, at 9:27 AM, ramoss ramine.mossad...@finra.org wrote:

 Hello,
 
 I have a variable in a data frame that contains NA values. I just want to
 subset so that I get the obs where that variable is missing.
 In SAS I would do:
 
 data missing;
  set test;
  if myvalue=' ';
 run;
 
 How can I perform this simple task in R?
 
 Thanks in advance for your help. 


The easiest is probably:

  NewDF - subset(DF, is.na(myvalue))

See ?is.na

Regards,

Marc Schwartz

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


[R] For loop

2012-11-30 Thread bibek sharma
Hello user,
I have large data containing  subject id, time and response where
subjects are measured repeatedly. However some time are duplicates. I
only want data with unique time points per id. I mean if time is
repeated, then take only one.
Here is a sample data.

id  timeres
1   2   0.64
1   3   0.78
1   3   6.5
1   3   4.5
1   4   4
1   5   3.4
2   10  5.7
2   11  5.8
2   11  9.3
2   11  3.4
2   12  3.4
2   13  6.7
3   3   5.6
3   3   3.4
3   4   2.3
3   5   5.6
3   12  9.8
3   10  7
3   24  6
3   16  4

for 1st subject I want this,

id  timeres
1   2   0.64
1   3   0.78
1   4   4
1   5   3.4
Any suggestions are much appreciated!
Thanks,
Bikek

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


Re: [R] help on stacking matrices up

2012-11-30 Thread PIKAL Petr
Hi Andras

Now it works but I suppose you shall simplify or explain it a bit more.

CONC7-c(rep(0,3),CONC7)
CONC8-c(rep(0,6),CONC8)
CONC6+CONC7+CONC8
  [,1]
[1,] 0.00
[2,] 2.330056
[3,] 2.133774
[4,] 1.954027
[5,] 4.119477
[6,] 3.772456
[7,] 3.454667
[8,] 5.493705
[9,] 5.030920
[10,] 4.607120

gives you desired result easier. So for summing CONC objects just add to 
beginning of each object so many zeroes as there are missing values. You can 
check dimension by

dim or nrow and use it to estimate how many zeroes you need to add.

Besides, you probably do not need matrices, vectors can do it too.

This
CONC6 -ifelse(TIME6=Tinf,CDURINF6,CAFTINF6)
in your case just change only the first value, but I presume in reality you can 
have Tinf such that it results in changing more values.

If this is not you are after, please be more specific.

Regards
Petr

From: Andras Farkas [mailto:motyoc...@yahoo.com]
Sent: Friday, November 30, 2012 3:52 PM
To: PIKAL Petr; r-help@r-project.org
Subject: Re: [R] help on stacking matrices up

Petr,

sorry, here is a better example that should work:

Dose-200
Tinf -0.5
INTERVAL -3
TIME8 -matrix(c((0*INTERVAL):(1*INTERVAL)))
TIME7 -matrix(c((0*INTERVAL):(2*INTERVAL)))
TIME6 -matrix(c((0*INTERVAL):(3*INTERVAL)))
CDURINF6 -((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*TIME6))
CAFTINF6 
-((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*Tinf))*(exp(-0.088*(TIME6)))
CONC6 -ifelse(TIME6=Tinf,CDURINF6,CAFTINF6)
CDURINF7 -((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*TIME7))
CAFTINF7 
-((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*Tinf))*(exp(-0.088*(TIME7)))
CONC7 -ifelse(TIME7=Tinf,CDURINF7,CAFTINF7)
CDURINF8 -((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*TIME8))
CAFTINF8 
-((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*Tinf))*(exp(-0.088*(TIME8)))
CONC8 -ifelse(TIME8=Tinf,CDURINF8,CAFTINF8)
CONCF 
-matrix(c(CONC6[1,],CONC6[2,],CONC6[3,],CONC6[4,]+CONC7[1,],CONC6[5,]+CONC7[2,],CONC6[6,]+CONC7[3,],CONC6[7,]+CONC7[4,]+CONC8[1,],CONC6[8,]+CONC7[5,]+CONC8[2,],CONC6[9,]+CONC7[6,]+CONC8[3,],CONC6[10,]+CONC7[7,]+CONC8[4,]))
plot(TIME6,CONCF,type=b)

the plot is what it should look like, keeping in mind that the INTERVAL will 
change, and that is the part i amtrying to figure out, ie: how can i make that 
dynamic. Is this better?

thanks,

Andras

From: PIKAL Petr petr.pi...@precheza.czmailto:petr.pi...@precheza.cz
To: Andras Farkas motyoc...@yahoo.commailto:motyoc...@yahoo.com; 
r-help@r-project.orgmailto:r-help@r-project.org 
r-help@r-project.orgmailto:r-help@r-project.org
Sent: Friday, November 30, 2012 8:51 AM
Subject: RE: [R] help on stacking matrices up

Hi

try to make your example easier and reproducible.

I get

 CONCF -matrix(c(CONC1+CONC2+CONC3+CONC4+CONC5+CONC6+CONC7+CONC8))
Error in CONC1 + CONC2 : non-conformable arrays

so I cannot understand what shall the final plot look like.

Regards

Petr


 -Original Message-
 From: r-help-boun...@r-project.orgmailto:r-help-boun...@r-project.org 
 [mailto:r-help-bounces@r-
 project.orgmailto:r-help-bounces@r-%0b%3e%20project.org] On Behalf Of 
 Andras Farkas
 Sent: Friday, November 30, 2012 12:51 PM
 To: r-help@r-project.orgmailto:r-help@r-project.org
 Subject: [R] help on stacking matrices up

 Dear All,

 #I have the following code

 Dose-1000
 Tinf -0.5
 INTERVAL -8
 TIME8 -matrix(c((0*INTERVAL):(1*INTERVAL)))
 TIME7 -matrix(c((0*INTERVAL):(2*INTERVAL)))
 TIME6 -matrix(c((0*INTERVAL):(3*INTERVAL)))
 TIME5 -matrix(c((0*INTERVAL):(4*INTERVAL)))
 TIME4 -matrix(c((0*INTERVAL):(5*INTERVAL)))
 TIME3 -matrix(c((0*INTERVAL):(6*INTERVAL)))
 TIME2 -matrix(c((0*INTERVAL):(7*INTERVAL)))
 TIME1 -matrix(c((0*INTERVAL):(8*INTERVAL)))
 CDURINF1 -((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*TIME1))
 CAFTINF1 -((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*Tinf))*(exp(-
 0.088*(TIME1)))
 CONC1 -ifelse(TIME1=Tinf,CDURINF1,CAFTINF1)
 CDURINF2 -((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*TIME2))
 CAFTINF2 -((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*Tinf))*(exp(-
 0.088*(TIME2)))
 CONC2 -ifelse(TIME2=Tinf,CDURINF2,CAFTINF2)
 CDURINF3 -((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*TIME3))
 CAFTINF3 -((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*Tinf))*(exp(-
 0.088*(TIME3)))
 CONC3 -ifelse(TIME3=Tinf,CDURINF3,CAFTINF3)
 CDURINF4 -((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*TIME4))
 CAFTINF4 -((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*Tinf))*(exp(-
 0.088*(TIME4)))
 CONC4 -ifelse(TIME4=Tinf,CDURINF4,CAFTINF4)
 CDURINF5 -((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*TIME5))
 CAFTINF5 -((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*Tinf))*(exp(-
 0.088*(TIME5)))
 CONC5 -ifelse(TIME5=Tinf,CDURINF5,CAFTINF5)
 CDURINF6 -((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*TIME6))
 CAFTINF6 -((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*Tinf))*(exp(-
 0.088*(TIME6)))
 CONC6 -ifelse(TIME6=Tinf,CDURINF6,CAFTINF6)
 CDURINF7 -((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*TIME7))
 CAFTINF7 -((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*Tinf))*(exp(-
 0.088*(TIME7)))
 CONC7 

Re: [R] subset data frame by variable with missing value

2012-11-30 Thread PIKAL Petr
Hi

see ?is.na

x -sample(c(1:3, NA), 20, replace=T) 

x
 [1]  2 NA  2  3  3  3  3  2  3 NA  3  2  1  2 NA  3  3  3  2  2
y-rnorm(20)
y[is.na(x)]
[1]  0.1600417  1.3264063 -0.6175832

Regards
Petr


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
 project.org] On Behalf Of ramoss
 Sent: Friday, November 30, 2012 4:27 PM
 To: r-help@r-project.org
 Subject: [R] subset data frame by variable with missing value
 
 Hello,
 
 I have a variable in a data frame that contains NA values. I just want
 to subset so that I get the obs where that variable is missing.
 In SAS I would do:
 
 data missing;
   set test;
   if myvalue=' ';
 run;
 
 How can I perform this simple task in R?
 
 Thanks in advance for your help.
 
 
 
 --
 View this message in context: http://r.789695.n4.nabble.com/subset-
 data-frame-by-variable-with-missing-value-tp4651439.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] subset data frame by variable with missing value

2012-11-30 Thread Milan Bouchet-Valat
Le vendredi 30 novembre 2012 à 07:27 -0800, ramoss a écrit :
 Hello,
 
 I have a variable in a data frame that contains NA values. I just want to
 subset so that I get the obs where that variable is missing.
 In SAS I would do:
 
 data missing;
   set test;
   if myvalue=' ';
 run;
 
 How can I perform this simple task in R?
missing - test[is.na(test$myvalue),]
or
missing - subset(test, is.na(myvalue))


Regards

 Thanks in advance for your help. 
 
 
 
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/subset-data-frame-by-variable-with-missing-value-tp4651439.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] Generating sequences of dates

2012-11-30 Thread Jagat.K.Sheth
?seq.Date

 seq(as.Date(2000-01-01), len=5, by=1 mon)
[1] 2000-01-01 2000-02-01 2000-03-01 2000-04-01 2000-05-01

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
 project.org] On Behalf Of Vasilchenko Aleksander
 Sent: Friday, November 30, 2012 6:27 AM
 To: r-help@r-project.org
 Subject: [R] Generating sequences of dates
 
 Hello,
 
 I have the starting date in UNIX_TIME LONG number (number of
 milliseconds
 since 1970 jan 1st).
 
 Is there a way to generete the sequence of dates with monthly interval
 in
 POSIXct format like
 
 2000-01-01
 2000-02-01
 2000-03-01
 
 etc
 
 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.


Re: [R] For loop

2012-11-30 Thread Jessica Streicher
Hello Bikek,

please use dput() next time to provide the data, its easier to use that.

also: looking at the data provided, how would you want to decide which value of 
the non-unique times to retain? Just take the first one? They aren't all the 
same.

On 30.11.2012, at 16:59, bibek sharma wrote:

 Hello user,
 I have large data containing  subject id, time and response where
 subjects are measured repeatedly. However some time are duplicates. I
 only want data with unique time points per id. I mean if time is
 repeated, then take only one.
 Here is a sample data.
 
 idtimeres
 1 2   0.64
 1 3   0.78
 1 3   6.5
 1 3   4.5
 1 4   4
 1 5   3.4
 2 10  5.7
 2 11  5.8
 2 11  9.3
 2 11  3.4
 2 12  3.4
 2 13  6.7
 3 3   5.6
 3 3   3.4
 3 4   2.3
 3 5   5.6
 3 12  9.8
 3 10  7
 3 24  6
 3 16  4
 
 for 1st subject I want this,
 
 idtimeres
 1 2   0.64
 1 3   0.78
 1 4   4
 1 5   3.4
 Any suggestions are much appreciated!
 Thanks,
 Bikek
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] how to separate stuck row elements?

2012-11-30 Thread arun
Hi,
Try this:
Lines--100 -100-3456-3456-3456-100 -100
23 -3456-3456-189 34 56 78
-100 34 56 21 44 65 78

res-unlist(strsplit(gsub(\\-, -,Lines),\n))
res1-do.call(rbind,lapply(lapply(split(res,seq_along(res)),function(x) 
unlist(strsplit(x, ))),function(x) as.numeric(x[x!=])))
 res1
##  [,1]  [,2]  [,3]  [,4]  [,5] [,6] [,7]
#1 -100  -100 -3456 -3456 -3456 -100 -100
#2   23 -3456 -3456  -189    34   56   78
#3 -100    34    56    21    44   65   78

 res2-data.frame(res1)
A.K.



- Original Message -
From: Jaime Otero Villar j.o.vil...@bio.uio.no
To: r-help@r-project.org
Cc: 
Sent: Friday, November 30, 2012 7:55 AM
Subject: [R] how to separate stuck row elements?

Hi,

I was wondering if it's possible to separate elements in multiple rows that 
actually should appear in different columns. I have a file where in certain 
lines there are elements not separated, and they certainly should appear in 
different columns (an example of the file is attached). The point is that I do 
not want to manually add a space in the txt file, however, I did not manage to 
do it automatically in R...

Thanks in advance for any insight.

Jaime





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

2012-11-30 Thread arun
Hi,
Try this:
dat1-read.table(text=
id    time res
1    2    0.64
1    3    0.78
1    3    6.5
1    3    4.5
1    4    4
1    5    3.4
2    10    5.7
2    11    5.8
2    11    9.3
2    11    3.4
2    12    3.4
2    13    6.7
3    3    5.6
3    3    3.4
3    4    2.3
3    5    5.6
3    12    9.8
3    10    7
3    24    6
3    16    4
,sep=,header=TRUE,stringsAsFactors=TRUE)
res-dat1[!duplicated(dat1[,1:2]),]
 res
#   id time  res
#1   1    2 0.64
#2   1    3 0.78
#5   1    4 4.00
#6   1    5 3.40
#7   2   10 5.70
#8   2   11 5.80
#11  2   12 3.40
#12  2   13 6.70
#13  3    3 5.60
#15  3    4 2.30
#16  3    5 5.60
#17  3   12 9.80
#18  3   10 7.00
#19  3   24 6.00
#20  3   16 4.00
row.names(res)-1:nrow(res)

A.K.



- Original Message -
From: bibek sharma mbhpat...@gmail.com
To: R-help@r-project.org
Cc: 
Sent: Friday, November 30, 2012 10:59 AM
Subject: [R] For loop

Hello user,
I have large data containing  subject id, time and response where
subjects are measured repeatedly. However some time are duplicates. I
only want data with unique time points per id. I mean if time is
repeated, then take only one.
Here is a sample data.

id    time     res
1    2    0.64
1    3    0.78
1    3    6.5
1    3    4.5
1    4    4
1    5    3.4
2    10    5.7
2    11    5.8
2    11    9.3
2    11    3.4
2    12    3.4
2    13    6.7
3    3    5.6
3    3    3.4
3    4    2.3
3    5    5.6
3    12    9.8
3    10    7
3    24    6
3    16    4

for 1st subject I want this,

id    time     res
1    2    0.64
1    3    0.78
1    4    4
1    5    3.4
Any suggestions are much appreciated!
Thanks,
Bikek

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

2012-11-30 Thread PIKAL Petr
Hi

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
 project.org] On Behalf Of bibek sharma
 Sent: Friday, November 30, 2012 5:00 PM
 To: R-help@r-project.org
 Subject: [R] For loop
 
 Hello user,
 I have large data containing  subject id, time and response where
 subjects are measured repeatedly. However some time are duplicates. I
 only want data with unique time points per id. I mean if time is
 repeated, then take only one.

Which one? The first one?

aggregate(test$res, list(time=test$time, id=test$id), function(x) x[1])

Regards
Petr


 Here is a sample data.
 
 idtimeres
 1 2   0.64
 1 3   0.78
 1 3   6.5
 1 3   4.5
 1 4   4
 1 5   3.4
 2 10  5.7
 2 11  5.8
 2 11  9.3
 2 11  3.4
 2 12  3.4
 2 13  6.7
 3 3   5.6
 3 3   3.4
 3 4   2.3
 3 5   5.6
 3 12  9.8
 3 10  7
 3 24  6
 3 16  4
 
 for 1st subject I want this,
 
 idtimeres
 1 2   0.64
 1 3   0.78
 1 4   4
 1 5   3.4
 Any suggestions are much appreciated!
 Thanks,
 Bikek
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] subset data frame by variable with missing value

2012-11-30 Thread ramoss
I found the answer;

Its mymissing - subset(mydata,is.na(myvar))



--
View this message in context: 
http://r.789695.n4.nabble.com/subset-data-frame-by-variable-with-missing-value-tp4651439p4651440.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] Standard errors for predictions of zero-inflated models

2012-11-30 Thread Lee, Laura
Dear all,

I am using the zeroinfl() function from the pscl package to develop a 
zero-inflated Poisson GLM. I would like to calculate the standard errors of 
predicted values. I've tried code posted in a previous discussion on this topic 
(https://stat.ethz.ch/pipermail/r-help/2008-December/182806.html), and I don't 
understand the results. Before I apply this code, I get the predicted value for 
the data 'newdat' using the following:

- predict(bestfit,type=response,newdata=newdat)
109
198.5146

The predicted value is approximately 199. When I apply the previously mentioned 
code (predict.zeroinfl), I can now calculate the standard error:

- predict(bestfit,type=response,se=TRUE,newdata=newdat)
MC iterate 1 of 1000
MC iterate 2 of 1000
...
MC iterate 1000 of 1000

[[1]]
   109
0.00016793

[[2]]
[[2]]$lower
[1] 9.151924e-05

[[2]]$upper
[1] 0.0002945504

[[2]]$se
[1] 5.296472e-05

However, the predicted value is now 1.7x10^-4. The standard error value makes 
sense for this predicted value, but I'm not sure why the predicted value has 
changed. I would appreciate any assistance.


Cheers,

Laura

[[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] googleVis plot and knitr/sweave

2012-11-30 Thread Michael Friendly

On 11/29/2012 2:53 PM, Filoche wrote:

Dear R users.

I'm currently making a report with knitr (RStudio) where I would like to
plot a googleVis map. However, the map generated is an HTML file which I
don't know how to integrate it in my report.

So my question is how to include a map generated with googleVis in a PDF
created with knitr/sweave.


Since others have told you that you can't do this directly, one 
recommended kludge is to use a static graph in the report, e.g.,

a screen capture from the HTML page, perhaps with a link to
the 'live' version if you are putting this online.

You can still show the googleVis code if you want using ... eval=FALSE

--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.  Chair, Quantitative Methods
York University  Voice: 416 736-2100 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

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

2012-11-30 Thread Jessica Streicher
You could use the duplicated function maybe:

 mtest
 id time value
[1,]  13 1
[2,]  13 2
[3,]  12 3
[4,]  11 4
[5,]  21 5
[6,]  23 6
[7,]  23 7
[8,]  23 8

duplicated(mtest[,1:2])
[1] FALSE  TRUE FALSE FALSE FALSE FALSE  TRUE  TRUE

mtest[!duplicated(mtest[,1:2]),]
 id time value
[1,]  13 1
[2,]  12 3
[3,]  11 4
[4,]  21 5
[5,]  23 6

On 30.11.2012, at 17:15, Jessica Streicher wrote:

 Hello Bikek,
 
 please use dput() next time to provide the data, its easier to use that.
 
 also: looking at the data provided, how would you want to decide which value 
 of the non-unique times to retain? Just take the first one? They aren't all 
 the same.
 
 On 30.11.2012, at 16:59, bibek sharma wrote:
 
 Hello user,
 I have large data containing  subject id, time and response where
 subjects are measured repeatedly. However some time are duplicates. I
 only want data with unique time points per id. I mean if time is
 repeated, then take only one.
 Here is a sample data.
 
 id   timeres
 12   0.64
 13   0.78
 13   6.5
 13   4.5
 14   4
 15   3.4
 210  5.7
 211  5.8
 211  9.3
 211  3.4
 212  3.4
 213  6.7
 33   5.6
 33   3.4
 34   2.3
 35   5.6
 312  9.8
 310  7
 324  6
 316  4
 
 for 1st subject I want this,
 
 id   timeres
 12   0.64
 13   0.78
 14   4
 15   3.4
 Any suggestions are much appreciated!
 Thanks,
 Bikek
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 separate stuck row elements?

2012-11-30 Thread arun
Hi,
You could also try this:
Lines--100 -100-3456-3456-3456-100 -100
23 -3456-3456-189 34 56 78
-100 34 56 21 44 65 78
Lines1-readLines(textConnection(Lines))
 res1-unlist(strsplit(gsub([-], -,Lines2), ))
 matrix(as.numeric(res1[res1!=]),nrow=length(Lines1),byrow=TRUE)
    [,1]  [,2]  [,3]  [,4]  [,5] [,6] [,7]
#[1,] -100  -100 -3456 -3456 -3456 -100 -100
#[2,]   23 -3456 -3456  -189    34   56   78
#[3,] -100    34    56    21    44   65   78


A.K.

- Original Message -
From: Jaime Otero Villar j.o.vil...@bio.uio.no
To: r-help@r-project.org
Cc: 
Sent: Friday, November 30, 2012 7:55 AM
Subject: [R] how to separate stuck row elements?

Hi,

I was wondering if it's possible to separate elements in multiple rows that 
actually should appear in different columns. I have a file where in certain 
lines there are elements not separated, and they certainly should appear in 
different columns (an example of the file is attached). The point is that I do 
not want to manually add a space in the txt file, however, I did not manage to 
do it automatically in R...

Thanks in advance for any insight.

Jaime





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

2012-11-30 Thread PIKAL Petr
Hi

ifelse shall work just fine.

x-1:10
a-rnorm(10)
b-rnorm(10)+100
tinf-5
ifelse(xtinf, a,b)
[1]  -0.32157732  -0.11065857   0.07127818   0.35928359 100.06200507
[6]  98.77752570 100.92743376  99.73918386  99.79837539 101.32640626

It is only your value of Tinf which is 0.5 compared to TIME which is 0:10 and 
therefore your logical construction selects only values lower than Tinf

see
TIME6=Tinf
result

If you encounter strange result of complicated code skin it to bones and 
separate to pieces line by line and even to line parts if possible. This will 
give you insight how your code really works.

Just like disassembling old clock (those which have cogwheels) to see and 
understand how it works.

Regards
Petr

From: Andras Farkas [mailto:motyoc...@yahoo.com]
Sent: Friday, November 30, 2012 5:37 PM
To: PIKAL Petr; r-help@r-project.org
Subject: Re: [R] help on stacking matrices up

Petr,

thanks for the solution, putting the zeros in there makes it work just how I 
want it. Also, thanks for picking up on the error in my code below... I did not 
notice that it only changes the 1st value, and yes, your assumption is right: 
there is a chance where more values should be changed based on Tinf... I have 
tryed to work with if ... else..., but that does not give me correct answer 
either, to my suprise... Would you be willing to provide some insigths on how I 
could go about solving that?

thanks,

Andras

From: PIKAL Petr petr.pi...@precheza.czmailto:petr.pi...@precheza.cz
To: Andras Farkas motyoc...@yahoo.commailto:motyoc...@yahoo.com; 
r-help@r-project.orgmailto:r-help@r-project.org 
r-help@r-project.orgmailto:r-help@r-project.org
Sent: Friday, November 30, 2012 10:58 AM
Subject: RE: [R] help on stacking matrices up

Hi Andras

Now it works but I suppose you shall simplify or explain it a bit more.

CONC7-c(rep(0,3),CONC7)
CONC8-c(rep(0,6),CONC8)
CONC6+CONC7+CONC8
  [,1]
[1,] 0.00
[2,] 2.330056
[3,] 2.133774
[4,] 1.954027
[5,] 4.119477
[6,] 3.772456
[7,] 3.454667
[8,] 5.493705
[9,] 5.030920
[10,] 4.607120

gives you desired result easier. So for summing CONC objects just add to 
beginning of each object so many zeroes as there are missing values. You can 
check dimension by

dim or nrow and use it to estimate how many zeroes you need to add.

Besides, you probably do not need matrices, vectors can do it too.

This
CONC6 -ifelse(TIME6=Tinf,CDURINF6,CAFTINF6)
in your case just change only the first value, but I presume in reality you can 
have Tinf such that it results in changing more values.

If this is not you are after, please be more specific.

Regards
Petr

From: Andras Farkas [mailto:motyoc...@yahoo.com]
Sent: Friday, November 30, 2012 3:52 PM
To: PIKAL Petr; r-help@r-project.orgmailto:r-help@r-project.org
Subject: Re: [R] help on stacking matrices up

Petr,

sorry, here is a better example that should work:

Dose-200
Tinf -0.5
INTERVAL -3
TIME8 -matrix(c((0*INTERVAL):(1*INTERVAL)))
TIME7 -matrix(c((0*INTERVAL):(2*INTERVAL)))
TIME6 -matrix(c((0*INTERVAL):(3*INTERVAL)))
CDURINF6 -((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*TIME6))
CAFTINF6 
-((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*Tinf))*(exp(-0.088*(TIME6)))
CONC6 -ifelse(TIME6=Tinf,CDURINF6,CAFTINF6)
CDURINF7 -((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*TIME7))
CAFTINF7 
-((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*Tinf))*(exp(-0.088*(TIME7)))
CONC7 -ifelse(TIME7=Tinf,CDURINF7,CAFTINF7)
CDURINF8 -((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*TIME8))
CAFTINF8 
-((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*Tinf))*(exp(-0.088*(TIME8)))
CONC8 -ifelse(TIME8=Tinf,CDURINF8,CAFTINF8)
CONCF 
-matrix(c(CONC6[1,],CONC6[2,],CONC6[3,],CONC6[4,]+CONC7[1,],CONC6[5,]+CONC7[2,],CONC6[6,]+CONC7[3,],CONC6[7,]+CONC7[4,]+CONC8[1,],CONC6[8,]+CONC7[5,]+CONC8[2,],CONC6[9,]+CONC7[6,]+CONC8[3,],CONC6[10,]+CONC7[7,]+CONC8[4,]))
plot(TIME6,CONCF,type=b)

the plot is what it should look like, keeping in mind that the INTERVAL will 
change, and that is the part i amtrying to figure out, ie: how can i make that 
dynamic. Is this better?

thanks,

Andras

From: PIKAL Petr petr.pi...@precheza.czmailto:petr.pi...@precheza.cz
To: Andras Farkas motyoc...@yahoo.commailto:motyoc...@yahoo.com; 
r-help@r-project.orgmailto:r-help@r-project.org 
r-help@r-project.orgmailto:r-help@r-project.org
Sent: Friday, November 30, 2012 8:51 AM
Subject: RE: [R] help on stacking matrices up

Hi

try to make your example easier and reproducible.

I get

 CONCF -matrix(c(CONC1+CONC2+CONC3+CONC4+CONC5+CONC6+CONC7+CONC8))
Error in CONC1 + CONC2 : non-conformable arrays

so I cannot understand what shall the final plot look like.

Regards

Petr


 -Original Message-
 From: r-help-boun...@r-project.orgmailto:r-help-boun...@r-project.org 
 [mailto:r-help-bounces@r-
 project.orgmailto:r-help-bounces@r-%0b%3e%20project.org] On Behalf Of 
 Andras Farkas
 Sent: Friday, November 30, 2012 12:51 PM
 To: r-help@r-project.orgmailto:r-help@r-project.org
 Subject: [R] help on stacking matrices up


Re: [R] missed values

2012-11-30 Thread arun
Hi,
May be this helps:
dat1-read.table(text=
---data---
,header=TRUE,stringsAsFactors=FALSE)

library(zoo)
 dat1$date-as.yearmon(dat1$date,format=%Y-%m)
lm1-lm(value~date,dat1)
dat2-data.frame(date=dat1[,1])
 dat1$fit-predict(lm1,newdata=dat2)
 dat1-within(dat1,{newvalue-ifelse(is.na(value)==T,fit,value)})
dat1new-dat1[,c(1:2,4)]
dat1new[80:86,]
#   date value  newvalue
#80 Oct 2006 0.1577647 0.1577647
#81 Nov 2006   NaN 0.2782320
#82 Dec 2006   NaN 0.2773986
#83 Jan 2007   NaN 0.2765651
#84 Feb 2007   NaN 0.2757317
#85 Mar 2007 0.2956429 0.2956429
#86 Apr 2007 0.3767500 0.3767500
A.K.




- Original Message -
From: Vasilchenko Aleksander vasilchenko@gmail.com
To: arun smartpink...@yahoo.com
Cc: 
Sent: Friday, November 30, 2012 8:22 AM
Subject: Re: [R] missed values

   date     value
1   2000-03 0.3425263
2   2000-04 0.461
3   2000-05 0.459
4   2000-06 0.3952500
5   2000-07 0.3497931
6   2000-08 0.458
7   2000-09 0.3281667
8   2000-10 0.3025263
9   2000-11 0.1706000
10  2000-12 0.1474118
11  2001-01 0.124
12  2001-02 0.2417333
13  2001-03 0.2615882
14  2001-04 0.3127778
15  2001-05 0.4201250
16  2001-06 0.3875000
17  2001-07 0.4382400
18  2001-08 0.4810345
19  2001-09 0.2790476
20  2001-10 0.2814483
21  2001-11 0.1588125
22  2001-12 0.1346429
23  2002-01 0.2103750
24  2002-02 0.2967000
25  2002-03 0.4348334
26  2002-04 0.475
27  2002-05 0.3669000
28  2002-06 0.4609600
29  2002-07 0.4170909
30  2002-08 0.4220435
31  2002-09 0.3641053
32  2002-10 0.1797308
33  2002-11 0.2112500
34  2002-12 0.1486250
35  2003-01 0.1800667
36  2003-02 0.2997857
37  2003-03 0.3697500
38  2003-04 0.495
39  2003-05 0.5344348
40  2003-06 0.5187334
41  2003-07 0.413
42  2003-08 0.5350715
43  2003-09 0.2706316
44  2003-10 0.2185333
45  2003-11 0.2260625
46  2003-12 0.1523750
47  2004-01 0.183
48  2004-02 0.2055455
49  2004-03 0.3884118
50  2004-04 0.367
51  2004-05 0.3104211
52  2004-06 0.3226818
53  2004-07 0.3570741
54  2004-08 0.3387097
55  2004-09 0.3168750
56  2004-10 0.2618000
57  2004-11 0.1487500
58  2004-12 0.138
59  2005-01 0.1768125
60  2005-02 0.2206000
61  2005-03 0.3592353
62  2005-04 0.3589500
63  2005-05 0.3481250
64  2005-06 0.3983077
65  2005-07 0.3612857
66  2005-08 0.3426539
67  2005-09 0.3435000
68  2005-10 0.2008636
69  2005-11 0.1967333
70  2005-12 0.111
71  2006-01 0.2308125
72  2006-02 0.1883125
73  2006-03 0.3261000
74  2006-04 0.2914118
75  2006-05 0.3331852
76  2006-06 0.4564348
77  2006-07 0.3920968
78  2006-08 0.3059259
79  2006-09 0.2567917
80  2006-10 0.1577647
81  2006-11       NaN
82  2006-12       NaN
83  2007-01       NaN
84  2007-02       NaN
85  2007-03 0.2956429
86  2007-04 0.3767500
87  2007-05 0.3727391
88  2007-06 0.4370800
89  2007-07 0.3504194
90  2007-08 0.3266400
91  2007-09 0.2328400
92  2007-10 0.209
93  2007-11 0.1631667
94  2007-12 0.1302143
95  2008-01 0.1131539
96  2008-02 0.1982727
97  2008-03 0.2568000
98  2008-04 0.2892000
99  2008-05 0.3523158
100 2008-06 0.358
101 2008-07 0.2898966
102 2008-08 0.3101667
103 2008-09 0.3730476
104 2008-10 0.2717037
105 2008-11 0.1344286
106 2008-12 0.1375000
107 2009-01 0.1781000
108 2009-02 0.2146667
109 2009-03 0.2808235
110 2009-04 0.4326250
111 2009-05 0.3420741
112 2009-06 0.2675238
113 2009-07 0.2478667
114 2009-08 0.3147000
115 2009-09 0.3437826
116 2009-10 0.2057391
117 2009-11 0.1824737
118 2009-12 0.1520714
119 2010-01 0.1485455
120 2010-02 0.176
121 2010-03 0.3072000
122 2010-04 0.3294445
123 2010-05 0.3278125
124 2010-06 0.2865000
125 2010-07 0.3170333
126 2010-08 0.2052143
127 2010-09 0.1837368
128 2010-10 0.1652778
129 2010-11 0.1292500
130 2010-12 0.1366250
131 2011-01 0.1909231
132 2011-02 0.1841177
133 2011-03 0.2897222
134 2011-04 0.3084211
135 2011-05 0.3349600
136 2011-06 0.3157917
137 2011-07 0.2755652
138 2011-08 0.2019355
139 2011-09 0.3325556
140 2011-10 0.1724348
141 2011-11 0.1935200
142 2011-12 0.1388000
143 2012-01 0.1484500
144 2012-02 0.204

I want to obtain these values by linear interpolation between 80
2006-10 0.1577647 and  85  2007-03 0.2956429
81  2006-11       NaN
82  2006-12       NaN
83  2007-01       NaN
84  2007-02       NaN

This time series has only one such block, but there can be several
such blocks in general

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] Reading .gsheet within R

2012-11-30 Thread Luca Meyer
Hello R-experts,

I would like to know if there is a solution to read files with extension 
.gsheet directly into R - see http://www.fileinfo.com/extension/gsheet for more 
info on this file format.

Thank you,
Luca

Mr. Luca Meyer
www.lucameyer.com
R 2.15.1
Mac OS X 10.8.2







[[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] repeating matrices in a list

2012-11-30 Thread Anser Chen
Suppose I have the following  square, non-negative matrices

 g=matrix(c(0,2,4,0.25,0,0,0,0.6,0),3,3,byrow=T);



I want to create a list where this matrix is repeated multiple times. if I
do this brute force (manually), using

 env - list(g,g,g)

works fine. Yields

[[1]]
 [,1] [,2] [,3]
[1,] 0.00  2.04
[2,] 0.25  0.00
[3,] 0.00  0.60

[[2]]
 [,1] [,2] [,3]
[1,] 0.00  2.04
[2,] 0.25  0.00
[3,] 0.00  0.60

[[3]]
 [,1] [,2] [,3]
[1,] 0.00  2.04
[2,] 0.25  0.00
[3,] 0.00  0.60



But - for a variety of purposes, I need to 'automate' building said list. I
tried using rep


  env - list(rep(g,each=3))

but this yields

[1] 0.00 0.00 0.00 0.25 0.25 0.25 0.00 0.00 0.00 2.00 2.00 2.00 0.00 0.00
0.00
[16] 0.60 0.60 0.60 4.00 4.00 4.00 0.00 0.00 0.00 0.00 0.00 0.00

Any suggestions/pointers to the obvious?

Thanks in advance...

[[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] repeating matrices in a list

2012-11-30 Thread Sarah Goslee
You are so close:

rep(list(g), 3)
[[1]]
 [,1] [,2] [,3]
[1,] 0.00  2.04
[2,] 0.25  0.00
[3,] 0.00  0.60

[[2]]
 [,1] [,2] [,3]
[1,] 0.00  2.04
[2,] 0.25  0.00
[3,] 0.00  0.60

[[3]]
 [,1] [,2] [,3]
[1,] 0.00  2.04
[2,] 0.25  0.00
[3,] 0.00  0.60


Sarah

On Fri, Nov 30, 2012 at 12:50 PM, Anser Chen anser.c...@gmail.com wrote:
 Suppose I have the following  square, non-negative matrices

 g=matrix(c(0,2,4,0.25,0,0,0,0.6,0),3,3,byrow=T);



 I want to create a list where this matrix is repeated multiple times. if I
 do this brute force (manually), using

 env - list(g,g,g)

 works fine. Yields

 [[1]]
  [,1] [,2] [,3]
 [1,] 0.00  2.04
 [2,] 0.25  0.00
 [3,] 0.00  0.60

 [[2]]
  [,1] [,2] [,3]
 [1,] 0.00  2.04
 [2,] 0.25  0.00
 [3,] 0.00  0.60

 [[3]]
  [,1] [,2] [,3]
 [1,] 0.00  2.04
 [2,] 0.25  0.00
 [3,] 0.00  0.60



 But - for a variety of purposes, I need to 'automate' building said list. I
 tried using rep


  env - list(rep(g,each=3))

 but this yields

 [1] 0.00 0.00 0.00 0.25 0.25 0.25 0.00 0.00 0.00 2.00 2.00 2.00 0.00 0.00
 0.00
 [16] 0.60 0.60 0.60 4.00 4.00 4.00 0.00 0.00 0.00 0.00 0.00 0.00

 Any suggestions/pointers to the obvious?

 Thanks in advance...


--
Sarah Goslee
http://www.functionaldiversity.org

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


Re: [R] repeating matrices in a list

2012-11-30 Thread arun
Hi,
Try this:
lapply(1:3,function(x) g)

A.K.





- Original Message -
From: Anser Chen anser.c...@gmail.com
To: r-help@r-project.org
Cc: 
Sent: Friday, November 30, 2012 12:50 PM
Subject: [R] repeating matrices in a list

Suppose I have the following  square, non-negative matrices

 g=matrix(c(0,2,4,0.25,0,0,0,0.6,0),3,3,byrow=T);



I want to create a list where this matrix is repeated multiple times. if I
do this brute force (manually), using

 env - list(g,g,g)

works fine. Yields

[[1]]
     [,1] [,2] [,3]
[1,] 0.00  2.0    4
[2,] 0.25  0.0    0
[3,] 0.00  0.6    0

[[2]]
     [,1] [,2] [,3]
[1,] 0.00  2.0    4
[2,] 0.25  0.0    0
[3,] 0.00  0.6    0

[[3]]
     [,1] [,2] [,3]
[1,] 0.00  2.0    4
[2,] 0.25  0.0    0
[3,] 0.00  0.6    0



But - for a variety of purposes, I need to 'automate' building said list. I
tried using rep


  env - list(rep(g,each=3))

but this yields

[1] 0.00 0.00 0.00 0.25 0.25 0.25 0.00 0.00 0.00 2.00 2.00 2.00 0.00 0.00
0.00
[16] 0.60 0.60 0.60 4.00 4.00 4.00 0.00 0.00 0.00 0.00 0.00 0.00

Any suggestions/pointers to the obvious?

Thanks in advance...

    [[alternative HTML version deleted]]

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


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


[R] what is the cost in cv.glm?

2012-11-30 Thread mael
Hi,

I have a question regarding the cv.glm function in the package boot. What is
exactly the cost? Is it the threshold value for an estimated value to be
classified as either 0 or 1? I have troubles understanding the explanation
in R. Lets say I want all estimations 0.65 to be classified as 1s and 0.35
as 0s, how do I write that? And if the cost is something else, how do I set
the threshold value?

Thanks in advance!
Anna



--
View this message in context: 
http://r.789695.n4.nabble.com/what-is-the-cost-in-cv-glm-tp4651435.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] help on stacking matrices up

2012-11-30 Thread Andras Farkas
Petr,
 
sorry, here is a better example that should work:
 Dose-200
Tinf -0.5
INTERVAL -3
TIME8 -matrix(c((0*INTERVAL):(1*INTERVAL)))
TIME7 -matrix(c((0*INTERVAL):(2*INTERVAL)))
TIME6 -matrix(c((0*INTERVAL):(3*INTERVAL)))
CDURINF6 -((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*TIME6))
CAFTINF6 
-((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*Tinf))*(exp(-0.088*(TIME6)))
CONC6 -ifelse(TIME6=Tinf,CDURINF6,CAFTINF6)
CDURINF7 -((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*TIME7))
CAFTINF7 
-((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*Tinf))*(exp(-0.088*(TIME7)))
CONC7 -ifelse(TIME7=Tinf,CDURINF7,CAFTINF7)
CDURINF8 -((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*TIME8))
CAFTINF8 
-((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*Tinf))*(exp(-0.088*(TIME8)))
CONC8 -ifelse(TIME8=Tinf,CDURINF8,CAFTINF8)
CONCF 
-matrix(c(CONC6[1,],CONC6[2,],CONC6[3,],CONC6[4,]+CONC7[1,],CONC6[5,]+CONC7[2,],CONC6[6,]+CONC7[3,],CONC6[7,]+CONC7[4,]+CONC8[1,],CONC6[8,]+CONC7[5,]+CONC8[2,],CONC6[9,]+CONC7[6,]+CONC8[3,],CONC6[10,]+CONC7[7,]+CONC8[4,]))
plot(TIME6,CONCF,type=b)
 
the plot is what it should look like, keeping in mind that the INTERVAL will 
change, and that is the part i amtrying to figure out, ie: how can i make that 
dynamic. Is this better?
 
thanks,
 
Andras



From: PIKAL Petr petr.pi...@precheza.cz

roject.org 
Sent: Friday, November 30, 2012 8:51 AM
Subject: RE: [R] help on stacking matrices up

Hi

try to make your example easier and reproducible.

I get

 CONCF -matrix(c(CONC1+CONC2+CONC3+CONC4+CONC5+CONC6+CONC7+CONC8))
Error in CONC1 + CONC2 : non-conformable arrays

so I cannot understand what shall the final plot look like.

Regards

Petr


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
 project.org] On Behalf Of Andras Farkas
 Sent: Friday, November 30, 2012 12:51 PM
 To: r-help@r-project.org
 Subject: [R] help on stacking matrices up
 
 Dear All,
 
 #I have the following code
 
 Dose-1000
 Tinf -0.5
 INTERVAL -8
 TIME8 -matrix(c((0*INTERVAL):(1*INTERVAL)))
 TIME7 -matrix(c((0*INTERVAL):(2*INTERVAL)))
 TIME6 -matrix(c((0*INTERVAL):(3*INTERVAL)))
 TIME5 -matrix(c((0*INTERVAL):(4*INTERVAL)))
 TIME4 -matrix(c((0*INTERVAL):(5*INTERVAL)))
 TIME3 -matrix(c((0*INTERVAL):(6*INTERVAL)))
 TIME2 -matrix(c((0*INTERVAL):(7*INTERVAL)))
 TIME1 -matrix(c((0*INTERVAL):(8*INTERVAL)))
 CDURINF1 -((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*TIME1))
 CAFTINF1 -((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*Tinf))*(exp(-
 0.088*(TIME1)))
 CONC1 -ifelse(TIME1=Tinf,CDURINF1,CAFTINF1)
 CDURINF2 -((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*TIME2))
 CAFTINF2 -((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*Tinf))*(exp(-
 0.088*(TIME2)))
 CONC2 -ifelse(TIME2=Tinf,CDURINF2,CAFTINF2)
 CDURINF3 -((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*TIME3))
 CAFTINF3 -((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*Tinf))*(exp(-
 0.088*(TIME3)))
 CONC3 -ifelse(TIME3=Tinf,CDURINF3,CAFTINF3)
 CDURINF4 -((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*TIME4))
 CAFTINF4 -((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*Tinf))*(exp(-
 0.088*(TIME4)))
 CONC4 -ifelse(TIME4=Tinf,CDURINF4,CAFTINF4)
 CDURINF5 -((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*TIME5))
 CAFTINF5 -((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*Tinf))*(exp(-
 0.088*(TIME5)))
 CONC5 -ifelse(TIME5=Tinf,CDURINF5,CAFTINF5)
 CDURINF6 -((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*TIME6))
 CAFTINF6 -((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*Tinf))*(exp(-
 0.088*(TIME6)))
 CONC6 -ifelse(TIME6=Tinf,CDURINF6,CAFTINF6)
 CDURINF7 -((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*TIME7))
 CAFTINF7 -((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*Tinf))*(exp(-
 0.088*(TIME7)))
 CONC7 -ifelse(TIME7=Tinf,CDURINF7,CAFTINF7)
 CDURINF8 -((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*TIME7))
 CAFTINF8 -((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*Tinf))*(exp(-
 0.088*(TIME8)))
 CONC8 -ifelse(TIME8=Tinf,CDURINF8,CAFTINF8)
 CONCF -matrix(c(CONC1+CONC2+CONC3+CONC4+CONC5+CONC6+CONC7+CONC8))
 plot(CONCF,type=l)
 
 I am trying to plot CONCF in a specific way. Let me try to explain: I
 would like to plot it so that the x axis goes from 0 to 8*INTERVAL
 (here the INTERVAL represents time in hours), and then each segments
 of the matrix  would  be added to the sum of the previous ones at a
 specific moment in time. Assuming a much shorter example this is what
 it should be like where according to the same equations above each
 value of CONCi was calculated at 1 h intervals:
 INTERVAL =3
 time points here where the values are calculated is 0:(3*INTERVAL) for
 CONC1, 0:(2*INTERVAL) for CONC2, and 0:(1*INTERVAL) for CONC3, all
 calculated at 1 hour intervals
 
 and lets assume calculated values are:
 
 CONC1 -c(0,1,2,3,4,5,6,7,8,9)
 CONC2 -c( 11,12,13,14,15,16,17)
 CONC3 -(21,22,23,24)
 .
 .
 .
 
 so I would like to get CONCF that would have the following values:
 CONCF -c(0,1,2,3+11,4+12,5+13,6+14,7+15,8+16,9+17,
 6+14+21,7+15+22,8+16+23,9+17+23) please note that CONC2 was 

[R] can't integrate in loop

2012-11-30 Thread faeriewhisper
Hi guys!
I have to compute something and i don't know what i'm doing wrong. my code
is a bit complex, but imagine that is something like this:

a = c(1 2 3 4)
ia = length(a)

x = seq(1,100,length=0.1)
ib = length(x) 

for(j in 1:ia) {
   H = function(x) {sen(x) + a[j]} 
  for(i in 1:ib) {   
int = function(x) { integrate(H, lower = 0, upper = x[i])} 
int1[i] = int(1)
}
end
   int1 = unlist(int1)
   ss[j] = sum(int1)
}
end

if i try this code without the for loop it's ok, but when i put the cycle
on, i get all sort of errors...
Thank you for your help :)










--
View this message in context: 
http://r.789695.n4.nabble.com/can-t-integrate-in-loop-tp4651416.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] loop function and integrate?

2012-11-30 Thread faeriewhisper
Hi guys! 
I have to compute something and i don't know what i'm doing wrong. my code
is a bit complex, but imagine that is something like this: 

a = c(1,2,3,4) 
ia = length(a) 

x = seq(1,100,length=0.1) 
ib = length(x) 

int1 = numeric(ib) 
b = numeric(ib) 

for(j in 1:ia) { 
   H = function(x) {sin(x + a[j])} 
  for(i in 1:ib) {  
int =  integrate(H, lower = 0, upper = x[i]) 
int1[i] = int[1] 
b[i] = 1 + a[i] 
} 
end 
   int1 = unlist(int1) 
   int2 = int1*b 
   ss[j] = sum(int2) 
} 
end 

if i try this code without the for loop it's ok, but when i put the for on,
i get all sort of errors... 
Thank you for your help :) 



--
View this message in context: 
http://r.789695.n4.nabble.com/loop-function-and-integrate-tp4651436.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 regarding calendar heatmap

2012-11-30 Thread sharan kumar
Hi,

I would like to create calendarheat map with Hours of day on Y axis and
Date on X axis.

Is there any function to do so? Can someone help me with reference.


Thanks
Sharan

[[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] subset data frame by variable with missing value

2012-11-30 Thread arun
Hi,
YOu could also use:
set.seed(5)
dat1-data.frame(col1=sample(c(1:4,NA),10,replace=TRUE),col2=runif(10,0,1))
 dat1[!complete.cases(dat1),]
#  col1  col2
#3   NA 0.3184040
#8   NA 0.8878698
#9   NA 0.5549226
A.K.



- Original Message -
From: ramoss ramine.mossad...@finra.org
To: r-help@r-project.org
Cc: 
Sent: Friday, November 30, 2012 10:27 AM
Subject: [R] subset data frame by variable with missing value

Hello,

I have a variable in a data frame that contains NA values. I just want to
subset so that I get the obs where that variable is missing.
In SAS I would do:

data missing;
  set test;
  if myvalue=' ';
run;

How can I perform this simple task in R?

Thanks in advance for your help. 



--
View this message in context: 
http://r.789695.n4.nabble.com/subset-data-frame-by-variable-with-missing-value-tp4651439.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] Nightingale’s Rose chart-any suggestion?

2012-11-30 Thread Henry Smith
Hi, thanks a lot.
The package from your link seems could plot only one type of variable.
  If I have following three variables:If I have following three
variables:
  a b c
1 3 7 8
2 5 4 1
3 5 1 7
4 3 1 5
5 1 7 3
6 7 1 1
7 1 1 1
8 3 3 2
Do you have any idea how to plot it by using variable color and radii in
one rose chart like here?
http://gallery.r-enthusiasts.com/graph/Rose_diagram,97

On Fri, Nov 30, 2012 at 1:55 PM, Rui Barradas ruipbarra...@sapo.pt wrote:

  Hello,

 Take a look at the graph in

 http://gallery.r-enthusiasts.com/graph/Rose_diagram,97

 Hope this helps,

 Rui Barradas
 Em 30-11-2012 12:24, Henry Smith escreveu:

 Hello, Everyone.

 Does anyone know how to create a Nightingale’s Rose chart by using R?
 Hopefully, the graph could be displayed like 
 this:http://mbostock.github.com/protovis/ex/crimea-rose.html

 Thanks a lot.

 Kind regards,
 Henry

   [[alternative HTML version deleted]]




 __r-h...@r-project.org mailing 
 listhttps://stat.ethz.ch/mailman/listinfo/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] help on stacking matrices up

2012-11-30 Thread Andras Farkas
Petr,
 
thanks for the solution, putting the zeros in there makes it work just how I 
want it. Also, thanks for picking up on the error in my code below... I did not 
notice that it only changes the 1st value, and yes, your assumption is right: 
there is a chance where more values should be changed based on Tinf... I have 
tryed to work with if ... else..., but that does not give me correct answer 
either, to my suprise... Would you be willing to provide some insigths on how I 
could go about solving that?
 
thanks,
 
Andras 



From: PIKAL Petr petr.pi...@precheza.cz

roject.org 
Sent: Friday, November 30, 2012 10:58 AM
Subject: RE: [R] help on stacking matrices up


Hi Andras
 
Now it works but I suppose you shall simplify or explain it a bit more. 
 
CONC7-c(rep(0,3),CONC7)
CONC8-c(rep(0,6),CONC8)
CONC6+CONC7+CONC8
  [,1]
[1,] 0.00
[2,] 2.330056
[3,] 2.133774
[4,] 1.954027
[5,] 4.119477
[6,] 3.772456
[7,] 3.454667
[8,] 5.493705
[9,] 5.030920
[10,] 4.607120
 
gives you desired result easier. So for summing CONC objects just add to 
beginning of each object so many zeroes as there are missing values. You can 
check dimension by
 
dim or nrow and use it to estimate how many zeroes you need to add.
 
Besides, you probably do not need matrices, vectors can do it too.
 
This
CONC6 -ifelse(TIME6=Tinf,CDURINF6,CAFTINF6)
in your case just change only the first value, but I presume in reality you can 
have Tinf such that it results in changing more values.
 
If this is not you are after, please be more specific.
 
Regards
Petr
 

Sent: Friday, November 30, 2012 3:52 PM
To: PIKAL Petr; r-help@r-project.org
Subject: Re: [R] help on stacking matrices up
 
Petr,
 
sorry, here is a better example that should work:
 
Dose-200
Tinf -0.5
INTERVAL -3
TIME8 -matrix(c((0*INTERVAL):(1*INTERVAL)))
TIME7 -matrix(c((0*INTERVAL):(2*INTERVAL)))
TIME6 -matrix(c((0*INTERVAL):(3*INTERVAL)))
CDURINF6 -((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*TIME6))
CAFTINF6 
-((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*Tinf))*(exp(-0.088*(TIME6)))
CONC6 -ifelse(TIME6=Tinf,CDURINF6,CAFTINF6)
CDURINF7 -((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*TIME7))
CAFTINF7 
-((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*Tinf))*(exp(-0.088*(TIME7)))
CONC7 -ifelse(TIME7=Tinf,CDURINF7,CAFTINF7)
CDURINF8 -((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*TIME8))
CAFTINF8 
-((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*Tinf))*(exp(-0.088*(TIME8)))
CONC8 -ifelse(TIME8=Tinf,CDURINF8,CAFTINF8)
CONCF 
-matrix(c(CONC6[1,],CONC6[2,],CONC6[3,],CONC6[4,]+CONC7[1,],CONC6[5,]+CONC7[2,],CONC6[6,]+CONC7[3,],CONC6[7,]+CONC7[4,]+CONC8[1,],CONC6[8,]+CONC7[5,]+CONC8[2,],CONC6[9,]+CONC7[6,]+CONC8[3,],CONC6[10,]+CONC7[7,]+CONC8[4,]))
plot(TIME6,CONCF,type=b)
 
the plot is what it should look like, keeping in mind that the INTERVAL will 
change, and that is the part i amtrying to figure out, ie: how can i make that 
dynamic. Is this better?
 
thanks,
 
Andras
 
From:PIKAL Petr petr.pi...@precheza.cz

roject.org 
Sent: Friday, November 30, 2012 8:51 AM
Subject: RE: [R] help on stacking matrices up

Hi

try to make your example easier and reproducible.

I get

 CONCF -matrix(c(CONC1+CONC2+CONC3+CONC4+CONC5+CONC6+CONC7+CONC8))
Error in CONC1 + CONC2 : non-conformable arrays

so I cannot understand what shall the final plot look like.

Regards

Petr


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
 project.org] On Behalf Of Andras Farkas
 Sent: Friday, November 30, 2012 12:51 PM
 To: r-help@r-project.org
 Subject: [R] help on stacking matrices up
 
 Dear All,
 
 #I have the following code
 
 Dose-1000
 Tinf -0.5
 INTERVAL -8
 TIME8 -matrix(c((0*INTERVAL):(1*INTERVAL)))
 TIME7 -matrix(c((0*INTERVAL):(2*INTERVAL)))
 TIME6 -matrix(c((0*INTERVAL):(3*INTERVAL)))
 TIME5 -matrix(c((0*INTERVAL):(4*INTERVAL)))
 TIME4 -matrix(c((0*INTERVAL):(5*INTERVAL)))
 TIME3 -matrix(c((0*INTERVAL):(6*INTERVAL)))
 TIME2 -matrix(c((0*INTERVAL):(7*INTERVAL)))
 TIME1 -matrix(c((0*INTERVAL):(8*INTERVAL)))
 CDURINF1 -((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*TIME1))
 CAFTINF1 -((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*Tinf))*(exp(-
 0.088*(TIME1)))
 CONC1 -ifelse(TIME1=Tinf,CDURINF1,CAFTINF1)
 CDURINF2 -((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*TIME2))
 CAFTINF2 -((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*Tinf))*(exp(-
 0.088*(TIME2)))
 CONC2 -ifelse(TIME2=Tinf,CDURINF2,CAFTINF2)
 CDURINF3 -((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*TIME3))
 CAFTINF3 -((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*Tinf))*(exp(-
 0.088*(TIME3)))
 CONC3 -ifelse(TIME3=Tinf,CDURINF3,CAFTINF3)
 CDURINF4 -((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*TIME4))
 CAFTINF4 -((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*Tinf))*(exp(-
 0.088*(TIME4)))
 CONC4 -ifelse(TIME4=Tinf,CDURINF4,CAFTINF4)
 CDURINF5 -((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*TIME5))
 CAFTINF5 -((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*Tinf))*(exp(-
 0.088*(TIME5)))
 CONC5 

[R] flip heatmap (pheatmap)

2012-11-30 Thread DebKV

When plotting a heatmap with heatmap.2 the shortest euclidean distance
cluster is plotted in the top left corner of the heatmap
  http://r.789695.n4.nabble.com/file/n4651430/heatmap.2.jpeg 

when plotting the same data with pheatmap the very same cluster is in the
bottom right corner
http://r.789695.n4.nabble.com/file/n4651430/pheatmap.jpeg 

I am just wondering what I would need to change in my pheatmap code to have
the same orientation as with heamap.2 (eg the ?

Any comments much appreciated.

Thanks,

DKV






--
View this message in context: 
http://r.789695.n4.nabble.com/flip-heatmap-pheatmap-tp4651430.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] segfault debugging

2012-11-30 Thread Donatella Quagli
Hello everybody,

I have written a script with two inline cfunctions. The script crashes from 
time to time with:
   *** caught segfault ***
  address 0x10, cause 'memory not mapped'

The crashs happen within R code after the cfunctions were executed. 
Nevertheless I think
that the pointers in my cfunctions are not used correctly.

I tried to find some examples for debugging tools. I found something like R -d 
gdb. But I
could not find an example how to use it with #!/usr/bin/Rscript. And I cannot 
source the script
within a running R session because I must run it with some args.

Can anybody tell me as a non nerd step by step what I can do to locate the 
problem? Can
you recommend tools? If so how are they used with Rscript?

Many many thanks in advance
Donatella

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Nightingale’s Rose chart-any suggestion?

2012-11-30 Thread Henry Smith
Dear Dennis,

Many thanks!
Yes, ggplot2 could be used to illustrate a simple rose chart (category +
one type variable)
If I have a data frame like this:
DF - data.frame(month = factor(month.abb, levels = month.abb),
   freq1 = rpois(12, 80),freq2=rpois(12,
80),freq3=rpois(12, 80))

Do you have any idea how to plot the other 2 variables freq2 and freq3 by R?
Nightingale’s Rose chart actually represent 3 variables here:
blue is disease, red is wounds, and black is uncategorized.
I checked plotrix; however, it seems it could not fulfill my purpose too.
Actually, what I am looking for is how to render a heatmap (not a bar
chart) in a polar coordinate system.
Thanks again.

Best,
Henry



On Fri, Nov 30, 2012 at 2:37 PM, Dennis Murphy djmu...@gmail.com wrote:

 A simple version of what can be done in ggplot2 is illustrated in the
 following toy example:

 DF - data.frame(month = factor(month.abb, levels = month.abb),
freq = rpois(12, 80))
 ggplot(DF, aes(x = month, y = freq)) +
  theme_bw() +
  geom_bar(stat = identity, fill = pink2) +
  coord_polar()

 Another option might be to use the plotrix package and to look into
 the radial.plot function, but I don't know offhand if it will produce
 rose diagrams without some effort. In ggplot2, a rose diagram is a bar
 chart rendered in a polar coordinate system, consistent with
 Wilkinson's grammar of graphics (whence the gg in ggplot2).

 Dennis

 On Fri, Nov 30, 2012 at 4:24 AM, Henry Smith henry.helsi...@gmail.com
 wrote:
  Hello, Everyone.
 
  Does anyone know how to create a Nightingale’s Rose chart by using R?
  Hopefully, the graph could be displayed like this:
  http://mbostock.github.com/protovis/ex/crimea-rose.html
  Thanks a lot.
 
  Kind regards,
  Henry
 
  [[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] googleVis plot and knitr/sweave

2012-11-30 Thread Filoche
Thank you Michael.

I'll try that. Maybe I can find a solution to convert the HTML file into a
let's say SVG file.

Regards,
Phil



--
View this message in context: 
http://r.789695.n4.nabble.com/googleVis-plot-and-knitr-sweave-tp4651341p4651463.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] googleVis plot and knitr/sweave

2012-11-30 Thread Filoche
Thank everyone for the answers.

I looked into ggmap but could not find how to plot a map that would like
this:

http://www.google.ca/trends/explore#q=flu

I looked into get_map but it can only be of this type:

maptype = c(terrain, satellite, roadmap, hybrid, toner,
watercolor)

Any suggestions would be appreciated.

Regards,
Phil





--
View this message in context: 
http://r.789695.n4.nabble.com/googleVis-plot-and-knitr-sweave-tp4651341p4651434.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] loop function and integrate?

2012-11-30 Thread faeriewhisper
Now i've managed to do this:

funcs - list()
funcs[]

# loop through to define functions
for(i in 1:ib-1){

# Make function name
funcName - paste( 'func', i, sep = '' )

# make function
func = paste('function(x){sin(x + a[', i,'])))}',sep = '')

funcs[[funcName]] = eval(parse(text=func))
  

}
end

but still cant apply the integrate in a loop for all the different
functions. :/
help me out guys pretty please :)



--
View this message in context: 
http://r.789695.n4.nabble.com/loop-function-and-integrate-tp4651436p4651455.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] qbinom

2012-11-30 Thread jaybell
a=c(0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9)
b=c(0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1)
cor(a,b)= -1

a'=qbinom(a, 1, 0.5)
b'=qbinom(b, 1, 0.5)
why cor(a',b') becomes -0.5 ?



--
View this message in context: 
http://r.789695.n4.nabble.com/qbinom-tp4651460.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] subgroup-based quantiles

2012-11-30 Thread Rui Barradas

Hello,

If you want Age quantiles by gender, you have to split the data by 
gender, apply the same code then recombine the result.



fun - function(x){
Age_group - cut(x[, Age], labels=c(1:10),
breaks=quantile(x[, Age], seq(0,1,.1)),
include.lowest = TRUE)
cbind(x, Age_group)
}

result - do.call(rbind, lapply(split(dat, dat[, GENDER]), fun))
rownames(result) - seq_len(nrow(result))
result


Hope this helps,

Rui Barradas
Em 30-11-2012 12:18, R Kozarski escreveu:

Dear R users,
given the patient sample with their Gender and Age
 GENDER Age
[1,]  2  45
[2,]  1  58
[3,]  1  54
[4,]  2  71
[5,]  2  64
  ...
I would like to create an another column which groups the patients wrt
Gender specific Age quantiles, following methodology similar to:

Age_group - cut(Age, labels=c(1:10), breaks=quantile(Age,
seq(0,1,.1)),include.lowest = TRUE)

The function above allows me to group only wrt Age quantiles.

Best, Robert




--
View this message in context: 
http://r.789695.n4.nabble.com/subgroup-based-quantiles-tp4651415.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] repeating matrices in a list

2012-11-30 Thread arun
HI,
You could also use:
res1-sapply(1:3,function(x) g,simplify=FALSE)
#or 

res2-replicate(3,g,simplify=FALSE)
 identical(res1,res2)
#[1] TRUE
A.K.


- Original Message -
From: Anser Chen anser.c...@gmail.com
To: r-help@r-project.org
Cc: 
Sent: Friday, November 30, 2012 12:50 PM
Subject: [R] repeating matrices in a list

Suppose I have the following  square, non-negative matrices

 g=matrix(c(0,2,4,0.25,0,0,0,0.6,0),3,3,byrow=T);



I want to create a list where this matrix is repeated multiple times. if I
do this brute force (manually), using

 env - list(g,g,g)

works fine. Yields

[[1]]
     [,1] [,2] [,3]
[1,] 0.00  2.0    4
[2,] 0.25  0.0    0
[3,] 0.00  0.6    0

[[2]]
     [,1] [,2] [,3]
[1,] 0.00  2.0    4
[2,] 0.25  0.0    0
[3,] 0.00  0.6    0

[[3]]
     [,1] [,2] [,3]
[1,] 0.00  2.0    4
[2,] 0.25  0.0    0
[3,] 0.00  0.6    0



But - for a variety of purposes, I need to 'automate' building said list. I
tried using rep


  env - list(rep(g,each=3))

but this yields

[1] 0.00 0.00 0.00 0.25 0.25 0.25 0.00 0.00 0.00 2.00 2.00 2.00 0.00 0.00
0.00
[16] 0.60 0.60 0.60 4.00 4.00 4.00 0.00 0.00 0.00 0.00 0.00 0.00

Any suggestions/pointers to the obvious?

Thanks in advance...

    [[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] loop function and integrate?

2012-11-30 Thread Rui Barradas

Hello,

Your code doesn't run without initializing 'ss' to something. And I've 
made some changes, but I don't understand what you are trying to do. See 
comments inline.



a = c(1,2,3,4)
ia = length(a)

x = seq(1, 100, by=0.1)   # It was 'length = 0.1' (!)
ib = length(x)

ss - numeric(ia)  # New, 'ss' must exist.
int1 = numeric(ib)
b = numeric(ib)

for(j in 1:ia) {
H = function(x) {sin(x + a[j])}
for(i in 1:ib) {
int =  integrate(H, lower = 0, upper = x[i])
int1[i] = int[1]
b[i] = 1 + a[j]   # It was 'a[i]', didn't make any sense.
}
int1 = unlist(int1)
int2 = int1*b
ss[j] = sum(int2)
}
ss


And for loops (or any other type of loops) do _not_ end with 'end'.

Hope this helps,

Rui Barradas

Em 30-11-2012 15:08, faeriewhisper escreveu:

Hi guys!
I have to compute something and i don't know what i'm doing wrong. my code
is a bit complex, but imagine that is something like this:

a = c(1,2,3,4)
ia = length(a)

x = seq(1,100,length=0.1)
ib = length(x)

int1 = numeric(ib)
b = numeric(ib)

for(j in 1:ia) {
H = function(x) {sin(x + a[j])}
   for(i in 1:ib) { 
 int =  integrate(H, lower = 0, upper = x[i])
 int1[i] = int[1]
 b[i] = 1 + a[i]
 }
 end
int1 = unlist(int1)
int2 = int1*b
ss[j] = sum(int2)
}
end

if i try this code without the for loop it's ok, but when i put the for on,
i get all sort of errors...
Thank you for your help :)



--
View this message in context: 
http://r.789695.n4.nabble.com/loop-function-and-integrate-tp4651436.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] loop function and integrate?

2012-11-30 Thread Berend Hasselman

On 30-11-2012, at 16:08, faeriewhisper wrote:

 Hi guys! 
 I have to compute something and i don't know what i'm doing wrong. my code
 is a bit complex, but imagine that is something like this: 
 
 a = c(1,2,3,4) 
 ia = length(a) 
 
 x = seq(1,100,length=0.1) 
 ib = length(x) 
 
 int1 = numeric(ib) 
 b = numeric(ib) 
 
 for(j in 1:ia) { 
   H = function(x) {sin(x + a[j])} 
  for(i in 1:ib) { 
int =  integrate(H, lower = 0, upper = x[i]) 
int1[i] = int[1] 
b[i] = 1 + a[i] 
} 
end 
   int1 = unlist(int1) 
   int2 = int1*b 
   ss[j] = sum(int2) 
 } 
 end 
 

What are you doing?
What's the end doing in your code in two places.
end is a function to extract and encode the last observation of a time series 
object. See ?end
It makes absolutely no sense to put them in your code.
Remove them immediately.

You haven't declared ss to be a vector.
So before the start of the j loop insert ss - numeric(ia)

And simplify your code:

ss - numeric(ia)

for(j in 1:ia) { 
  H = function(x) {sin(x + a[j])} 
 for(i in 1:ib) {   
   int =  integrate(H, lower = 0, upper = x[i])  
   int1[i] = int$value
   b[i] = 1 + a[i] 
   }
  ss[j] = sum(int1*b)
} 
ss

And more simplification is possible by eliminating b, which I leave to you.

Berend

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


Re: [R] can't integrate in loop

2012-11-30 Thread Jessica Streicher
Thats not a very precise question. I'll try anyway..

- if you use c, you need to separate the values by commas
- i think you mean seq(1,100,0.1), otherwise x only has one value
- function sen is not defined
- If you call int(1), upper will be 1, not x[i]
- why are you making a function and calling it instead of just : int1[i] - 
integrate(H, lower = 0, upper = x[i]) ?
- looking at ?integral, you may rather want integral(..)$value

On 30.11.2012, at 13:32, faeriewhisper wrote:

 Hi guys!
 I have to compute something and i don't know what i'm doing wrong. my code
 is a bit complex, but imagine that is something like this:
 
 a = c(1 2 3 4)
 ia = length(a)
 
 x = seq(1,100,length=0.1)
 ib = length(x) 
 
 for(j in 1:ia) {
   H = function(x) {sen(x) + a[j]} 
  for(i in 1:ib) {  
   int = function(x) { integrate(H, lower = 0, upper = x[i])} 
   int1[i] = int(1)
   }
   end
   int1 = unlist(int1)
   ss[j] = sum(int1)
 }
 end
 
 if i try this code without the for loop it's ok, but when i put the cycle
 on, i get all sort of errors...
 Thank you for your help :)
 
 
 
 
 
 
 
 
 
 
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/can-t-integrate-in-loop-tp4651416.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] loop function and integrate?

2012-11-30 Thread Berend Hasselman

On 30-11-2012, at 19:34, Berend Hasselman wrote:

 
 On 30-11-2012, at 16:08, faeriewhisper wrote:
 
 Hi guys! 
 I have to compute something and i don't know what i'm doing wrong. my code
 is a bit complex, but imagine that is something like this: 
 
 a = c(1,2,3,4) 
 ia = length(a) 
 
 x = seq(1,100,length=0.1) 
 ib = length(x) 
 
 int1 = numeric(ib) 
 b = numeric(ib) 
 
 for(j in 1:ia) { 
  H = function(x) {sin(x + a[j])} 
 for(i in 1:ib) { 
   int =  integrate(H, lower = 0, upper = x[i]) 
   int1[i] = int[1] 
   b[i] = 1 + a[i] 
   } 
   end 
  int1 = unlist(int1) 
  int2 = int1*b 
  ss[j] = sum(int2) 
 } 
 end 
 
 
 What are you doing?
 What's the end doing in your code in two places.
 end is a function to extract and encode the last observation of a time series 
 object. See ?end
 It makes absolutely no sense to put them in your code.
 Remove them immediately.
 
 You haven't declared ss to be a vector.
 So before the start of the j loop insert ss - numeric(ia)
 
 And simplify your code:
 
 ss - numeric(ia)
 
 for(j in 1:ia) { 
  H = function(x) {sin(x + a[j])} 
 for(i in 1:ib) {  
   int =  integrate(H, lower = 0, upper = x[i])  
   int1[i] = int$value
   b[i] = 1 + a[i] 
   }
  ss[j] = sum(int1*b)
 } 
 ss
 
 And more simplification is possible by eliminating b, which I leave to you.

There is no need to define the function H in the j loop.
You could do this:

H = function(x,A) {sin(x + A)}

for(j in 1:ia) {
 aj - a[j]
 for(i in 1:ib) {
   int =  integrate(H, lower = 0, upper = x[i], A=aj)
   int1[i] = (1 + a[i])* int$value
   }
  ss[j] = sum(int1)
}

And if Rui is right  a[i] can be replaced by aj.

Berend

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


Re: [R] segfault debugging

2012-11-30 Thread Duncan Murdoch

On 30/11/2012 12:02 PM, Donatella Quagli wrote:

Hello everybody,

I have written a script with two inline cfunctions. The script crashes from 
time to time with:
*** caught segfault ***
   address 0x10, cause 'memory not mapped'

The crashs happen within R code after the cfunctions were executed. 
Nevertheless I think
that the pointers in my cfunctions are not used correctly.

I tried to find some examples for debugging tools. I found something like R -d 
gdb. But I
could not find an example how to use it with #!/usr/bin/Rscript. And I cannot 
source the script
within a running R session because I must run it with some args.

Can anybody tell me as a non nerd step by step what I can do to locate the 
problem? Can
you recommend tools? If so how are they used with Rscript?


This isn't easy, but what I would do is add something to your script to 
get it to pause (or to wait for some file to be created, or some other 
signal), then figure out the process number, and tell gdb to connect to 
it after it has already started.


The ps command will list all the running processes, for some definition 
of all.  Then


gdb --pid=PID

will connect to the process with id PID.  I believe it will interrupt 
the process at that point, but you can restart it, send the signal to it 
to get out of its loop), and hopefully see the segfault in action.


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] qbinom

2012-11-30 Thread Peter Langfelder
On Fri, Nov 30, 2012 at 9:47 AM, jaybell stephe...@yahoo.com.tw wrote:
 a=c(0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9)
 b=c(0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1)
 cor(a,b)= -1

 a'=qbinom(a, 1, 0.5)
 b'=qbinom(b, 1, 0.5)
 why cor(a',b') becomes -0.5 ?

On my computer the correlation is -0.8. It is not 1 because you did a
non-linear transformation of a and b. Plot a vs. b, then plot a' vs b'
and you will see why the correlation is not -1: a vs b is  a straight
line, a' vs b' is not a straight line.

Peter

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


Re: [R] xts indexed with Date class

2012-11-30 Thread arun
Hi,
You could try this:
Sys.setenv(TZ=GMT)
a-as.Date(15423:15426)
x-xts(seq_along(a),a)
 print(index(x))
#[1] 2012-03-24 2012-03-25 2012-03-26 2012-03-27
 print(as.numeric(index(x)))
#[1] 15423 15424 15425 15426
A.K.



- Original Message -
From: Giles giles.heyw...@cantab.net
To: r-help@r-project.org
Cc: 
Sent: Friday, November 30, 2012 4:32 AM
Subject: [R] xts indexed with Date class

Hi

I see a changed behaviour in xts indexed on class Date in the latest
versions, versus 2.

It seems to be related to changes to/from daylight savings time,
happens those weekends.

Is it not intended that class Date be used like this, or is this new
behaviour incorrect?

Giles


Example:

 a-as.Date(15423:15426)
 x-xts(seq_along(a),a)
 print(x)
           [,1]
2012-03-24    1
2012-03-25    2
2012-03-25    3
2012-03-26    4
 print(index(x))
[1] 2012-03-24 2012-03-25 2012-03-25 2012-03-26
 print(as.numeric(index(x)))
[1] 15423 15424 15424 15425

#for reference, zoo behaves as expected:
 z-zoo(seq_along(a),a)
 print(index(z))
[1] 2012-03-24 2012-03-25 2012-03-26 2012-03-27
 print(as.numeric(index(z)))
[1] 15423 15424 15425 15426


Package: xts
Type: Package
Title: eXtensible Time Series
Version: 0.8-8
Date: 2012-10-05

Windows 7 64-bit
R version 2.15.2 64-bit
all packages up-to-date

#--previously, R 2.13.2 and xts 0.8-2 , showing expected
behaviour -

 a-as.Date(15423:15426)
 x-xts(seq_along(a),a)
 print(x)
           [,1]
2012-03-24    1
2012-03-25    2
2012-03-26    3
2012-03-27    4
 print(index(x))
[1] 2012-03-24 2012-03-25 2012-03-26 2012-03-27
 print(as.numeric(index(x)))
[1] 15423 15424 15425 15426
 z-zoo(seq_along(a),a)
 print(index(z))
[1] 2012-03-24 2012-03-25 2012-03-26 2012-03-27
 print(as.numeric(index(z)))
[1] 15423 15424 15425 15426


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

2012-11-30 Thread Rui Barradas

Hello,

Arun's code is much better.

Rui Barradas
Em 30-11-2012 18:50, arun escreveu:

Hi,
You could also try ?ave()
dat$Age_group-ave(dat$Age,dat$GENDER,FUN=function(x){cut(x,labels=1:10,breaks=quantile(x,seq(0,1,.1)),include.lowest=TRUE)})
  dat
#  GENDER Age Age_group
#1  2  45 1
#2  1  5810
#3  1  54 1
#4  2  7110
#5  2  64 5
A.K.



- Original Message -
From: Rui Barradas ruipbarra...@sapo.pt
To: R Kozarski r.kozar...@gmail.com
Cc: r-help@r-project.org
Sent: Friday, November 30, 2012 1:07 PM
Subject: Re: [R] subgroup-based quantiles

Hello,

If you want Age quantiles by gender, you have to split the data by
gender, apply the same code then recombine the result.


fun - function(x){
  Age_group - cut(x[, Age], labels=c(1:10),
  breaks=quantile(x[, Age], seq(0,1,.1)),
  include.lowest = TRUE)
  cbind(x, Age_group)
}

result - do.call(rbind, lapply(split(dat, dat[, GENDER]), fun))
rownames(result) - seq_len(nrow(result))
result


Hope this helps,

Rui Barradas
Em 30-11-2012 12:18, R Kozarski escreveu:

Dear R users,
given the patient sample with their Gender and Age
   GENDER Age
  [1,]  2  45
  [2,]  1  58
  [3,]  1  54
  [4,]  2  71
  [5,]  2  64
...
I would like to create an another column which groups the patients wrt
Gender specific Age quantiles, following methodology similar to:

Age_group - cut(Age, labels=c(1:10), breaks=quantile(Age,
seq(0,1,.1)),include.lowest = TRUE)

The function above allows me to group only wrt Age quantiles.

Best, Robert




--
View this message in context: 
http://r.789695.n4.nabble.com/subgroup-based-quantiles-tp4651415.html
Sent from the R help mailing list archive at Nabble.com.

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

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



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Nightingale’s Rose chart-any suggestion?

2012-11-30 Thread John Kane
I think this does it. 

  require(reshape2)
  
  df1  -  melt(DF, id=month)
  
  ggplot(df1, aes(x = month, y = value, fill = variable)) +
theme_bw() +
geom_bar(stat = identity) +
coord_polar()

John Kane
Kingston ON Canada


 -Original Message-
 From: henry.helsi...@gmail.com
 Sent: Fri, 30 Nov 2012 14:56:51 +0100
 To: djmu...@gmail.com, r-help@r-project.org
 Subject: Re: [R] Nightingale’s Rose chart-any suggestion?
 
 Dear Dennis,
 
 Many thanks!
 Yes, ggplot2 could be used to illustrate a simple rose chart (category +
 one type variable)
 If I have a data frame like this:
 DF - data.frame(month = factor(month.abb, levels = month.abb),
freq1 = rpois(12, 80),freq2=rpois(12,
 80),freq3=rpois(12, 80))
 
 Do you have any idea how to plot the other 2 variables freq2 and freq3 by
 R?
 Nightingale?s Rose chart actually represent 3 variables here:
 blue is disease, red is wounds, and black is uncategorized.
 I checked plotrix; however, it seems it could not fulfill my purpose too.
 Actually, what I am looking for is how to render a heatmap (not a bar
 chart) in a polar coordinate system.
 Thanks again.
 
 Best,
 Henry
 
 
 
 On Fri, Nov 30, 2012 at 2:37 PM, Dennis Murphy djmu...@gmail.com wrote:
 
 A simple version of what can be done in ggplot2 is illustrated in the
 following toy example:
 
 DF - data.frame(month = factor(month.abb, levels = month.abb),
freq = rpois(12, 80))
 ggplot(DF, aes(x = month, y = freq)) +
  theme_bw() +
  geom_bar(stat = identity, fill = pink2) +
  coord_polar()
 
 Another option might be to use the plotrix package and to look into
 the radial.plot function, but I don't know offhand if it will produce
 rose diagrams without some effort. In ggplot2, a rose diagram is a bar
 chart rendered in a polar coordinate system, consistent with
 Wilkinson's grammar of graphics (whence the gg in ggplot2).
 
 Dennis
 
 On Fri, Nov 30, 2012 at 4:24 AM, Henry Smith henry.helsi...@gmail.com
 wrote:
 Hello, Everyone.
 
 Does anyone know how to create a Nightingale?s Rose chart by using R?
 Hopefully, the graph could be displayed like this:
 http://mbostock.github.com/protovis/ex/crimea-rose.html
 Thanks a lot.
 
 Kind regards,
 Henry
 
 [[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.


FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks  orcas on your 
desktop!

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


Re: [R] subgroup-based quantiles

2012-11-30 Thread arun
Hi,
You could also try ?ave()
dat$Age_group-ave(dat$Age,dat$GENDER,FUN=function(x){cut(x,labels=1:10,breaks=quantile(x,seq(0,1,.1)),include.lowest=TRUE)})
 dat
#  GENDER Age Age_group
#1  2  45 1
#2  1  58    10
#3  1  54 1
#4  2  71    10
#5  2  64 5
A.K.



- Original Message -
From: Rui Barradas ruipbarra...@sapo.pt
To: R Kozarski r.kozar...@gmail.com
Cc: r-help@r-project.org
Sent: Friday, November 30, 2012 1:07 PM
Subject: Re: [R] subgroup-based quantiles

Hello,

If you want Age quantiles by gender, you have to split the data by 
gender, apply the same code then recombine the result.


fun - function(x){
     Age_group - cut(x[, Age], labels=c(1:10),
         breaks=quantile(x[, Age], seq(0,1,.1)),
         include.lowest = TRUE)
     cbind(x, Age_group)
}

result - do.call(rbind, lapply(split(dat, dat[, GENDER]), fun))
rownames(result) - seq_len(nrow(result))
result


Hope this helps,

Rui Barradas
Em 30-11-2012 12:18, R Kozarski escreveu:
 Dear R users,
 given the patient sample with their Gender and Age
          GENDER Age
     [1,]      2  45
     [2,]      1  58
     [3,]      1  54
     [4,]      2  71
     [5,]      2  64
   ...
 I would like to create an another column which groups the patients wrt
 Gender specific Age quantiles, following methodology similar to:

 Age_group - cut(Age, labels=c(1:10), breaks=quantile(Age,
 seq(0,1,.1)),include.lowest = TRUE)

 The function above allows me to group only wrt Age quantiles.

 Best, Robert




 --
 View this message in context: 
 http://r.789695.n4.nabble.com/subgroup-based-quantiles-tp4651415.html
 Sent from the R help mailing list archive at Nabble.com.

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

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


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] bootstrapped cox regression (rms package)

2012-11-30 Thread Eric Claus
Hi Frank,
My apologies for not posting the entire script - I have repasted it below.

library(rms)
library(foreign)
temp=read.spss('coxdata.sav', to.data.frame=T)

formula=Surv(months, recidivate) ~ fac1 + fac2 + fac3 + fac4 + fac5 + fac6 +
fac7 + fac8 
fit=cph(formula, data=temp, x=T, y=T) 
val.out=validate(fit, method=boot, B=, bw=F, type=residual,
sls=0.05, aics=0,force=NULL, estimates=TRUE, pr=FALSE) 
out=bootcov(fit, B=, pr=F, coef.reps=T, loglik=F) 
anova(out) 

 Factor   Chi-Square d.f. P 
fac1  0.27   10.6055 
fac2  0.20   10.6514 
fac3  0.01   10.9338 
fac4  0.05   10.8311 
fac5  1.06   10.3036 
fac6  0.33   10.5647 
fac7  0.81   10.3670 
fac8  0.30   10.5832 
 TOTAL   1.48   80.9930 

for (i in 1:8) {
print(quantile(out$boot.Coef[,i], c(.025, .975)))
}

2.5% 97.5% 
-9.236751 20.772061 
 2.5% 97.5% 
-8.841030  3.094755 
 2.5% 97.5% 
-1.834436  2.161983 
  2.5%  97.5% 
-0.1800666  0.0871867 
  2.5%  97.5% 
-3.2129636  0.4783566 
   2.5%   97.5% 
-0.04157389  0.07130994 
  2.5%  97.5% 
-0.6415962  0.1001843 
   2.5%   97.5% 
-0.01529467  0.21055259 

Again, the SPSS output I am trying to match is here:
variable low CI high CI p-value 
fac1 -8.474 20.020 .456 
fac2 -8.206 3.093 .524 
fac3 -1.829 2.087 .900 
fac4 -.173 .083 .749 
fac5 -2.945 .450 .143 
fac6 -.035 .070 .306 
fac7 -.626 .092 .189 
fac8 -.017 .203 .247 

In looking through the SPSS syntax, my colleague is using SIMPLE resampling,
which is doing sampling with replacement from the original data set.  
bootstrap replications are being used, the same as what I have used in the
bootcov command.  The piece of the SPSS output that is not clear is the
generation of p-values from the distribution of parameter estimates; spss
appears to be testing the parameter estimate from the original cox
regression, but the method of testing that parameter is not clear.  

Eric





--
View this message in context: 
http://r.789695.n4.nabble.com/bootstrapped-cox-regression-rms-package-tp4651306p4651474.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] loop function and integrate?

2012-11-30 Thread faeriewhisper
hello guys!
thank u for the help, but u didnt understood what i need.
1st, it is a[i] cuz i want to sum 1 + x[i], for all i's not j.
but i've solved it! :)
like i said, my code is more complex, but, if you need to integrate several
functions in a loop, thats what you  should do:

w2 = seq(-1,-1/3,length=100)
ib = length(w2)

bin = w2[2] - w2[1]

w3 - numeric(ib-1)

for (h in 1:ib-1)

w3[h] = (w2[h] + w2[h+1])/2 
end

probt - numeric(ib)
di2 - numeric(ia)
a2 - numeric(ia)

ic = ib-1

arealog - numeric(ic) 
log_probt - numeric(ic)

funcs - list()
funcs[]

# loop through to define functions
for(i in 1:ic){

funcName - paste( 'func', i, sep = '' )

func = paste('function(z){c/(Ho*sqrt(dens*(1+z)^3 +
(1-dens)*(1+z)^(3*(1+w3[', i,']}',sep = '')

funcs[[funcName]] = eval(parse(text=func))
 
}
end

for(j in 1:ic){

for(i in 1:ia){

d2 = integrate(funcs[[j]], lower = 0, upper = z[i])
di2[i] = d2[1]
a2[i] = 1 + z[i]

}
end
di2 = unlist(di2)
dist2 = di2*a2
mag2 = 5*log(dist2) + 25
prob2 = (1/disp*sqrt(2*pi))*exp( - ((mag2 - probv)^2)/2*disp^2)
log_prob2 = log(prob2)
log_proba2 = sum(log_prob2)
log_probt[j] = log_proba2
arealog[j] = bin*(log_proba2)   
}
end

log_probt2 = sum(arealog)/(w2[ib] - w2[1])
  


 



--
View this message in context: 
http://r.789695.n4.nabble.com/loop-function-and-integrate-tp4651436p4651489.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] Choleski decomposition

2012-11-30 Thread jaybell
m - matrix(nrow=5, ncol=5)
m - ifelse(row(m)==col(m), 1, 0.2)
c - chol(m)# Choleski decomposition
u - matrix(rnorm(2000*5), ncol=5)
uc - u %*% c
cr - pnorm(uc)
cr - qbinom(cr,1,0.5)
cor(cr) 
I expected that the cor(cr) to be 0.2 as i set in m, but the result is
around 0.1.
Why is that? Thanks



--
View this message in context: 
http://r.789695.n4.nabble.com/Choleski-decomposition-tp4651475.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] Choleski decomposition

2012-11-30 Thread David Winsemius

On Nov 30, 2012, at 10:34 AM, jaybell wrote:

   m - matrix(nrow=5, ncol=5)
   m - ifelse(row(m)==col(m), 1, 0.2)
   c - chol(m)# Choleski decomposition
   u - matrix(rnorm(2000*5), ncol=5)
   uc - u %*% c
   cr - pnorm(uc)
   cr - qbinom(cr,1,0.5)
   cor(cr) 
 I expected that the cor(cr) to be 0.2 as i set in m, but the result is
 around 0.1.
 Why is that? Thanks

Cross-posting to rhelp and Stackoverflow is deprecated (at least on Rhelp). If 
you didn't get effective advice after a reasonable interval (measured in days) 
it would make sense to look elsewhere. But this is essentially a statistics 
questions rather than a coding question and you were advised on SO to post the 
question on a website that is designed for statistics questions. Rhelp is not 
that site.

-- 

David Winsemius, MD
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] bootstrapped cox regression (rms package)

2012-11-30 Thread Frank Harrell
It will be crucial to know the details of the test statistic and P-value
calculations from SPSS.  It's also running anova on both the bootcov and the
original fits to see if SPSS is ignoring the bootstrap when computing the
covariance matrix.
Frank

Eric Claus wrote
 Hi Frank,
 My apologies for not posting the entire script - I have repasted it below.
 
 library(rms)
 library(foreign)
 temp=read.spss('coxdata.sav', to.data.frame=T)
 
 formula=Surv(months, recidivate) ~ fac1 + fac2 + fac3 + fac4 + fac5 + fac6
 + fac7 + fac8 
 fit=cph(formula, data=temp, x=T, y=T) 
 val.out=validate(fit, method=boot, B=, bw=F, type=residual,
 sls=0.05, aics=0,force=NULL, estimates=TRUE, pr=FALSE) 
 out=bootcov(fit, B=, pr=F, coef.reps=T, loglik=F) 
 anova(out) 
 
  Factor   Chi-Square d.f. P 
 fac1  0.27   10.6055 
 fac2  0.20   10.6514 
 fac3  0.01   10.9338 
 fac4  0.05   10.8311 
 fac5  1.06   10.3036 
 fac6  0.33   10.5647 
 fac7  0.81   10.3670 
 fac8  0.30   10.5832 
  TOTAL   1.48   80.9930 
 
 for (i in 1:8) {
 print(quantile(out$boot.Coef[,i], c(.025, .975)))
 }
 
 2.5% 97.5% 
 -9.236751 20.772061 
  2.5% 97.5% 
 -8.841030  3.094755 
  2.5% 97.5% 
 -1.834436  2.161983 
   2.5%  97.5% 
 -0.1800666  0.0871867 
   2.5%  97.5% 
 -3.2129636  0.4783566 
2.5%   97.5% 
 -0.04157389  0.07130994 
   2.5%  97.5% 
 -0.6415962  0.1001843 
2.5%   97.5% 
 -0.01529467  0.21055259 
 
 Again, the SPSS output I am trying to match is here:
 variable low CI high CI p-value 
 fac1 -8.474 20.020 .456 
 fac2 -8.206 3.093 .524 
 fac3 -1.829 2.087 .900 
 fac4 -.173 .083 .749 
 fac5 -2.945 .450 .143 
 fac6 -.035 .070 .306 
 fac7 -.626 .092 .189 
 fac8 -.017 .203 .247 
 
 In looking through the SPSS syntax, my colleague is using SIMPLE
 resampling, which is doing sampling with replacement from the original
 data set.   bootstrap replications are being used, the same as what I
 have used in the bootcov command.  The piece of the SPSS output that is
 not clear is the generation of p-values from the distribution of parameter
 estimates; spss appears to be testing the parameter estimate from the
 original cox regression, but the method of testing that parameter is not
 clear.  
 
 Eric





-
Frank Harrell
Department of Biostatistics, Vanderbilt University
--
View this message in context: 
http://r.789695.n4.nabble.com/bootstrapped-cox-regression-rms-package-tp4651306p4651493.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] Line numbers with errors and warnings?

2012-11-30 Thread Worik R
Is it possible to get a line number with an error report?

I have a long script and an error:

Error in `[.xts`(x, xsubset) : subscript out of bounds


It would be very helpful, and save a lot of time, if there was some
indication in the error message which line the error was.

I can find it using binary search but that is a painful process.

cheers
Worik

[[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] Line numbers with errors and warnings?

2012-11-30 Thread jim holtman
One thing that I do when I have a long script is to put progress
report messages.  These have some comments so I can chart the progress
and also print out the current CPU and memory usage so I can also
isolate where potential problems might be.  This will help narrow down
the section of code where the error occurred.  Are you also running
with

options(error=utils::recover)

so that when the error occurs, you get the stack and current
environment so that debugging is easier?

On Fri, Nov 30, 2012 at 4:22 PM, Worik R wor...@gmail.com wrote:
 Is it possible to get a line number with an error report?

 I have a long script and an error:

 Error in `[.xts`(x, xsubset) : subscript out of bounds


 It would be very helpful, and save a lot of time, if there was some
 indication in the error message which line the error was.

 I can find it using binary search but that is a painful process.

 cheers
 Worik

 [[alternative HTML version deleted]]

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



-- 
Jim Holtman
Data Munger Guru

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

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Line numbers with errors and warnings?

2012-11-30 Thread David Winsemius

On Nov 30, 2012, at 1:22 PM, Worik R wrote:

 Is it possible to get a line number with an error report?
 
 I have a long script and an error:
 
 Error in `[.xts`(x, xsubset) : subscript out of bounds
 
 
 It would be very helpful, and save a lot of time, if there was some
 indication in the error message which line the error was.
 
 I can find it using binary search but that is a painful process.

Generally if one is in an interactive mode, one is advised to use the error 
recovery process provided by:

 options(error=recover)

You should then be dropped into the browser in the environment of the error. 
Execute ls() to see what variables are accessible in the local environment. So 
you also need to consult:

?browser


-- 

David Winsemius, MD
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] (no subject)

2012-11-30 Thread bibek sharma
Hello R usuer,

The code given below superimposes a pie diagram on another plot
containing some points. However, I would like to center the pie
diagram on the xy location on the plot, but not on the center. is
there any way to re-center pic diagram.
Any suggestion or better alternative are highly appreciated.
Thank you in advance for your help.

Regards,
Bibke

library(visualFields)
library(car)
a-saplocmap$p24d2
ordinate-data.frame(a$xod,a$yod)
plot( a$xod,a$yod, xlim=c(-30,30),
ylim=c(-30,30),xlab=,ylab=,type=p, data=ordinate)
abline(v=0,h=0)
par(new=TRUE)

# Define cars vector with 8 values
cars - c(1,1,1,1,1,1,1,1)

# Define colors in each sector

color1 - 
c(grey80,grey80,grey80,grey80,gray80,grey30,grey20,gray10
) ## gray10=0.0001, gray200.001, gray300.01, gray40=0.05, gray
80=0.05
# Putting sector levels
car_labels - c(1,2,3,4,5,6,7,8)
car_labels - paste(car_labels,sep=)

# Create a pie chart with defined heading and custom colors
# and labels

pie(cars, main=Sectors, col=color1, labels= ,
radius=0.05,border=NA, cex=0.8)

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


Re: [R] Reading .gsheet within R

2012-11-30 Thread Rui Barradas

Hello,

Package sos does a good job at finding things available for R.

library(sos)
findFn('gsheet')
found 0 matches
x has zero rows;  nothing to display.
Warning message:
In findFn(gsheet) : HIT not found in HTML;  processing one page only.


So I guess there's nothing yet.

Hope this helps,

Rui Barradas
Em 30-11-2012 17:43, Luca Meyer escreveu:

Hello R-experts,

I would like to know if there is a solution to read files with extension 
.gsheet directly into R - see http://www.fileinfo.com/extension/gsheet for more 
info on this file format.

Thank you,
Luca

Mr. Luca Meyer
www.lucameyer.com
R 2.15.1
Mac OS X 10.8.2







[[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] (no subject)

2012-11-30 Thread William Dunlap
Try subplot() from the TeachingDemos package.  E.g.,

   plot(c(1,2,3), c(1,3,2), xlim=c(0,5), ylim=c(0,10))
   subplot(pie(1:5), x=4, y=6)
   abline(h=6, v=4)
   subplot(pie(1:5), x=1, y=8, size=c(0.5, 0.5))

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 bibek sharma
 Sent: Friday, November 30, 2012 2:07 PM
 To: R help
 Subject: [R] (no subject)
 
 Hello R usuer,
 
 The code given below superimposes a pie diagram on another plot
 containing some points. However, I would like to center the pie
 diagram on the xy location on the plot, but not on the center. is
 there any way to re-center pic diagram.
 Any suggestion or better alternative are highly appreciated.
 Thank you in advance for your help.
 
 Regards,
 Bibke
 
 library(visualFields)
 library(car)
 a-saplocmap$p24d2
 ordinate-data.frame(a$xod,a$yod)
 plot( a$xod,a$yod, xlim=c(-30,30),
 ylim=c(-30,30),xlab=,ylab=,type=p, data=ordinate)
 abline(v=0,h=0)
 par(new=TRUE)
 
 # Define cars vector with 8 values
 cars - c(1,1,1,1,1,1,1,1)
 
 # Define colors in each sector
 
 color1 - 
 c(grey80,grey80,grey80,grey80,gray80,grey30,grey20,gray10
 ) ## gray10=0.0001, gray200.001, gray300.01, gray40=0.05, gray
 80=0.05
 # Putting sector levels
 car_labels - c(1,2,3,4,5,6,7,8)
 car_labels - paste(car_labels,sep=)
 
 # Create a pie chart with defined heading and custom colors
 # and labels
 
 pie(cars, main=Sectors, col=color1, labels= ,
 radius=0.05,border=NA, cex=0.8)
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide 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] Reading .gsheet within R

2012-11-30 Thread Marc Schwartz
Hi,

I don't know if the information is still current, but there were some 
discussions a while back pertaining to reading Google Docs documents in R. 
There is a blog post here from David Smith that might be helpful:

  
http://blog.revolutionanalytics.com/2009/09/how-to-use-a-google-spreadsheet-as-data-in-r.html

I would be sure to read the comments as well.

Regards,

Marc Schwartz

On Nov 30, 2012, at 4:12 PM, Rui Barradas ruipbarra...@sapo.pt wrote:

 Hello,
 
 Package sos does a good job at finding things available for R.
 
 library(sos)
 findFn('gsheet')
 found 0 matches
 x has zero rows;  nothing to display.
 Warning message:
 In findFn(gsheet) : HIT not found in HTML;  processing one page only.
 
 
 So I guess there's nothing yet.
 
 Hope this helps,
 
 Rui Barradas
 Em 30-11-2012 17:43, Luca Meyer escreveu:
 Hello R-experts,
 
 I would like to know if there is a solution to read files with extension 
 .gsheet directly into R - see http://www.fileinfo.com/extension/gsheet for 
 more info on this file format.
 
 Thank you,
 Luca
 
 Mr. Luca Meyer
 www.lucameyer.com
 R 2.15.1
 Mac OS X 10.8.2

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Workarounds to Rd file name conflict when extending a S4 method of some other package

2012-11-30 Thread Janko Thyson

Dear list,

// IN SHORT //
What are possible workarounds to consolidate documentation for S4 
methods that are scattered across different packages (generic and some 
custom methods in one package, additional custom methods in another 
package) in a *single* Rd help file while using package 'roxygen2' to 
generate the actual Rd files?


// ADDITIONAL INFORMATION //
First of, here are the three facts that cause my problem:

1) I'd like the software, i.e. the packages, that I write to be as 
extendable as possible

2) I pretty much ended up using S4 functionality in everything I do
3) I'm a big fan of in-file documentation and package 'roxygen2' does 
a wonderful job in helping me out keeping my Rd help files synced


That being said, it is a quite common scenario that some package (say 
'pkga') contains the *generic* method/function 'foo()' as well as *some* 
custom methods (for different data types of the available signature 
arguments).


Now, let's suppose that someone using 'pkga' and building a new package 
(say 'pkgb') would like to build upon the generic method 'pkga::foo()' 
and provide some more custom methods for it. When he sticks to the 
suggested workflow (especially with respect to the way the roxygen2 code 
is written), then R CMD check will rightly(!) complain that an Rd file 
with the respective name (generated by 'roxygenize()') already exists 
(because it is already part of 'pkga').


My question is hence twofold:
1) What would be possible workarounds that allow me to a) keep using 
'roxygen2' and link documentation of pkga::foo() with that of 
pkgb::foo() (as they do belong together conecptionally)
2) Is there a need to address this problem on a higher level in the 
future? My feeling is that more people are starting to use S4 which, 
IMHO, is a good thing as it allows to systematically build upon code of 
other programmers. But then I guess we would need some sort of an 
inter-package check and/or help-file consolidation to present the user 
a single source of documentation for some S4 method.


I tried to illustrate the problem with actual code in this post at 
Stackoverflow: 
http://stackoverflow.com/questions/13137912/rd-file-name-conflict-when-s4-generic-and-methods-are-not-in-the-same-package


Best regards,
Janko

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

2012-11-30 Thread jaybell
sorry, I repost the question again  

a=c(0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9) 
b=c(0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1) 
cor(a,b)= -1 

pa=qbinom(a, 1, 0.5) 
pb=qbinom(b, 1, 0.5) 
cor(pa,pb)=-0.8

but when  
pa=qbinom(a,10,0.5)
pb=qbinom(b,10,0.5)

cor(pa,pb) becomes -1 again



--
View this message in context: 
http://r.789695.n4.nabble.com/qbinom-tp4651460p4651496.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] protentially serious R error

2012-11-30 Thread liuxf
Hi guy,
I have recently encountered a problem while  I was just trying to generate
some random numbers with the function rnorm, the problem is shown below:
case 1
 rnorm(20*0.2)
[1] -1.2765922 -0.5732654 -1.2246126 -0.4734006
case 2###
* rnorm(20*(1-0.8))
[1] -0.62036668  0.04211587 -0.91092165*
#case 3
 a-0.2
 rnorm(20*a)
[1]  0.1580288 -0.6545846  1.7672873  0.7167075
#case 4#
* b-1-0.8
 rnorm(20*b)
[1] 0.9101742 0.3841854 1.6821761*

I was expecting the 4 cases should do the same job--generate 4 random
numbers. But in case 2 and 4 I only get 3. Has anyone else seen this problem
before? Thanks. (I have tried with other functions i.e rchisq,rexp ...)
###
One of my colleague also have a problem that we think it might be related
with the problem I addressed above:

 test1 - runif(10,0,1)
 test1
 [1] 0.3868379 0.1587814 0.8140483 0.7796691 0.5357628 0.2431110 0.1782747
0.3906829 0.5262615 0.7440143
 test2 - NULL
 for(i in seq(0.01,1,length=100)){
+   test2[i*100] - sum(test1i) 
+ }
 test2
  [1]  0  0  0  0  0  0 *NA*  0  0  0  0  0  0  0  0  1  1  2  2  2  2  2  2
2  3  3  3  3  3  3  3  3  3  3  3  3  3  3  4  5  5  5  5  5
 [45]  5  5  5  5  5  5  5  5  6  7  7  7  7  7  7  7  7  7  7  7  7  7  7
7  7  7  7  7  7  7  8  8  8  9  9  9  9 10 10 10 10 10 10 10
 [89] 10 10 10 10 10 10 10 10 10 10 10 10

Every time he re-runs the code there always always a NA(highlighted). Does
any one know why?  Your help is greatly appreciated.   


Xiaofeng





--
View this message in context: 
http://r.789695.n4.nabble.com/protentially-serious-R-error-tp4651495.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] quantreg installation and conflicts with R 2.15.2

2012-11-30 Thread Brian S Cade
I recently lost the partitions on my hard drive (second time in 6 months) 
so I had to have our IT folks image all my files over to a new drive.  I 
completely reinstalled R (now 2.15.2) and all my libraries to my computer 
(Dell Latitude running Windows 7).  A few of my previous workspaces 
(created with R 2.14.1) can't be restored, reporting an error similar to 
the one I get when I try to load quantreg package which requires 
SparseM (see below).   So, not only will quantreg not load but some of 
my workspaces can't be restored when being loaded (see below).  Not sure 
about what this is about.   I asked Roger Koenker, the package maintainer, 
but he is on travel and won't have chance to seriously investigate this 
for awhile.  So I thought I would put it out to the R community and see if 
anyone has any suggestions about why this conflict might be occurring.

 library(quantreg)
Loading required package: SparseM
Error : object ?kronecker? is not exported by 'namespace:methods'
Error: package ?SparseM? could not be loaded

or 

Error: object ?kronecker? is not exported by 'namespace:methods'
During startup - Warning message:
unable to restore saved data in C:\CADESTUFF\DATA\BarryNoon\.RData 


Brian

Brian S. Cade, PhD

U. S. Geological Survey
Fort Collins Science Center
2150 Centre Ave., Bldg. C
Fort Collins, CO  80526-8818

email:  brian_c...@usgs.gov
tel:  970 226-9326
[[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 add widgets of gWidgets to widgets of rgtk2 ???

2012-11-30 Thread jverzaniNWBKZ
For this it would be best to insert an intermediate group container, as its
add method allows you to add the RGtk2 widgets. Something like:

library(gWidgets)
options(guiToolkit=RGtk2)
library(RGtk2)

w - gwindow()
lyt - glayout(cont=w)
lyt[1,1] - (g - ggroup(cont=lyt))

widget - gtkButton(click me)
add(g, widget)


Otherwise you can get the underlying GtkTable widget with:
getToolkitWidget(lyt)



--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-add-widgets-of-gWidgets-to-widgets-of-rgtk2-tp4651396p4651491.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] subgroup-based quantiles

2012-11-30 Thread R Kozarski
Dear Arun and Rui,  thank you for replying, your commands are very helpful.
Before you replied, Ive solved the issue with the following approach (for
quartiles):

myFun - function(x, GENDER)
{
x.male - cut(x, labels=c(1:4), breaks=quantile(split(x,GENDER) $ '1',
seq(0,1,.25), na.rm=TRUE),include.lowest = TRUE)
x.female - cut(x, labels=c(1:4), breaks=quantile(split(x,GENDER) $ '2',
seq(0,1,.25), na.rm=TRUE),include.lowest = TRUE)
ifelse(GENDER==1, x.male, x.female)
}


Robert




--
View this message in context: 
http://r.789695.n4.nabble.com/subgroup-based-quantiles-tp4651415p4651494.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] Fw: quantreg installation and conflicts with R 2.15.2

2012-11-30 Thread Brian S Cade
Just noticed that I get a similar error about object 'kronecker' in 
Matrix package when trying to load lme4.   So this is a more pervasive 
problem. 

Brian

Brian S. Cade, PhD

U. S. Geological Survey
Fort Collins Science Center
2150 Centre Ave., Bldg. C
Fort Collins, CO  80526-8818

email:  brian_c...@usgs.gov
tel:  970 226-9326
- Forwarded by Brian S Cade/BRD/USGS/DOI on 11/30/2012 02:07 PM -

From:
Brian S Cade/BRD/USGS/DOI
To:
R-help@r-project.org
Date:
11/30/2012 01:16 PM
Subject:
quantreg installation and conflicts with R 2.15.2


I recently lost the partitions on my hard drive (second time in 6 months) 
so I had to have our IT folks image all my files over to a new drive.  I 
completely reinstalled R (now 2.15.2) and all my libraries to my computer 
(Dell Latitude running Windows 7).  A few of my previous workspaces 
(created with R 2.14.1) can't be restored, reporting an error similar to 
the one I get when I try to load quantreg package which requires 
SparseM (see below).   So, not only will quantreg not load but some of 
my workspaces can't be restored when being loaded (see below).  Not sure 
about what this is about.   I asked Roger Koenker, the package maintainer, 
but he is on travel and won't have chance to seriously investigate this 
for awhile.  So I thought I would put it out to the R community and see if 
anyone has any suggestions about why this conflict might be occurring.

 library(quantreg)
Loading required package: SparseM
Error : object ?kronecker? is not exported by 'namespace:methods'
Error: package ?SparseM? could not be loaded

or 

Error: object ?kronecker? is not exported by 'namespace:methods'
During startup - Warning message:
unable to restore saved data in C:\CADESTUFF\DATA\BarryNoon\.RData 


Brian

Brian S. Cade, PhD

U. S. Geological Survey
Fort Collins Science Center
2150 Centre Ave., Bldg. C
Fort Collins, CO  80526-8818

email:  brian_c...@usgs.gov
tel:  970 226-9326

[[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] Training, Validation and Test Sets and LDA with MASS package

2012-11-30 Thread Roberto
Hi all,
please, can someone give me an example of LDA with MASS package with
training, validation and test sets?

I never used it, so I need and example to avoid to make errors.

Thank you very much.

Best,
Roberto



--
View this message in context: 
http://r.789695.n4.nabble.com/Training-Validation-and-Test-Sets-and-LDA-with-MASS-package-tp4651497.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] protentially serious R error

2012-11-30 Thread Sarah Goslee
Potentially serious? Only to you: this looks like R FAQ 7.31 striking again.

Here's a hint:


identical(20*(1-0.8), 4)

and another

rnorm(round(20*(1-0.8)))

Sarah

On Fri, Nov 30, 2012 at 4:05 PM, liuxf li...@math.mcmaster.ca wrote:
 Hi guy,
 I have recently encountered a problem while  I was just trying to generate
 some random numbers with the function rnorm, the problem is shown below:
 case 1
 rnorm(20*0.2)
 [1] -1.2765922 -0.5732654 -1.2246126 -0.4734006
 case 2###
 * rnorm(20*(1-0.8))
 [1] -0.62036668  0.04211587 -0.91092165*
 #case 3
 a-0.2
 rnorm(20*a)
 [1]  0.1580288 -0.6545846  1.7672873  0.7167075
 #case 4#
 * b-1-0.8
 rnorm(20*b)
 [1] 0.9101742 0.3841854 1.6821761*

 I was expecting the 4 cases should do the same job--generate 4 random
 numbers. But in case 2 and 4 I only get 3. Has anyone else seen this problem
 before? Thanks. (I have tried with other functions i.e rchisq,rexp ...)
 ###
 One of my colleague also have a problem that we think it might be related
 with the problem I addressed above:

 test1 - runif(10,0,1)
 test1
  [1] 0.3868379 0.1587814 0.8140483 0.7796691 0.5357628 0.2431110 0.1782747
 0.3906829 0.5262615 0.7440143
 test2 - NULL
 for(i in seq(0.01,1,length=100)){
 +   test2[i*100] - sum(test1i)
 + }
 test2
   [1]  0  0  0  0  0  0 *NA*  0  0  0  0  0  0  0  0  1  1  2  2  2  2  2  2
 2  3  3  3  3  3  3  3  3  3  3  3  3  3  3  4  5  5  5  5  5
  [45]  5  5  5  5  5  5  5  5  6  7  7  7  7  7  7  7  7  7  7  7  7  7  7
 7  7  7  7  7  7  7  8  8  8  9  9  9  9 10 10 10 10 10 10 10
  [89] 10 10 10 10 10 10 10 10 10 10 10 10

 Every time he re-runs the code there always always a NA(highlighted). Does
 any one know why?  Your help is greatly appreciated.


 Xiaofeng




--
Sarah Goslee
http://www.functionaldiversity.org

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


Re: [R] protentially serious R error

2012-11-30 Thread Ted Harding
[See in-line below]

On 30-Nov-2012 21:05:23 liuxf wrote:
 Hi guy,
 I have recently encountered a problem while  I was just trying to generate
 some random numbers with the function rnorm, the problem is shown below:
case 1
 rnorm(20*0.2)
 [1] -1.2765922 -0.5732654 -1.2246126 -0.4734006
case 2###
 * rnorm(20*(1-0.8))
 [1] -0.62036668  0.04211587 -0.91092165*

The key to this case can be seen in:

  20*0.2 - 4
  # [1] 0

  20*(1-0.8)-4
  # [1] -8.881784e-16

  0.2 - (1-0.8)
  # [1] 5.551115e-17

So you have fallen victim to the fact that, in general, floating-point
arithmetic is not exact (and this is not a feature only of R, but
of other packages that use standard floating-point CPU arithmetic.

#case 3
 a-0.2
 rnorm(20*a)
 [1]  0.1580288 -0.6545846  1.7672873  0.7167075
#case 4#
 * b-1-0.8
 rnorm(20*b)
 [1] 0.9101742 0.3841854 1.6821761*
 
 I was expecting the 4 cases should do the same job--generate 4 random
 numbers. But in case 2 and 4 I only get 3. Has anyone else seen this problem
 before? Thanks. (I have tried with other functions i.e rchisq,rexp ...)
###
 One of my colleague also have a problem that we think it might be related
 with the problem I addressed above:
 
 test1 - runif(10,0,1)
 test1
  [1] 0.3868379 0.1587814 0.8140483 0.7796691 0.5357628 0.2431110 0.1782747
 0.3906829 0.5262615 0.7440143
 test2 - NULL
 for(i in seq(0.01,1,length=100)){
 +   test2[i*100] - sum(test1i) 
 + }
 test2
   [1]  0  0  0  0  0  0 *NA*  0  0  0  0  0  0  0  0  1  1  2  2  2  2  2  2
 2  3  3  3  3  3  3  3  3  3  3  3  3  3  3  4  5  5  5  5  5
  [45]  5  5  5  5  5  5  5  5  6  7  7  7  7  7  7  7  7  7  7  7  7  7  7
 7  7  7  7  7  7  7  8  8  8  9  9  9  9 10 10 10 10 10 10 10
  [89] 10 10 10 10 10 10 10 10 10 10 10 10
 
 Every time he re-runs the code there always always a NA(highlighted). Does
 any one know why?  Your help is greatly appreciated.   
 
 Xiaofeng

This is effectovely the same issue:

  test1 - runif(10,0,1)
  test1
  # [1] 0.3868379 0.1587814 0.8140483 0.7796691 0.5357628 0.2431110
  # 0.1782747 0.3906829 0.5262615 0.7440143
  test2 - NULL
  for(i in seq(0.01,1,length=100)){
test2[i*100] - sum(test1i) 
  }
  test2
  #   [1]  0  0  0  0  0  0 *NA*   0  0  0  0  0  0  0  0  1  1  2  2
  #  2  2  2  2  2  3  3  3  3  3  3  3  3  3  3  3  3  3  3  4  5  5
  #  5  5  5  5  5  5  5  5  5  5  5  6  7  7  7  7  7  7  7  7  7  7
  #  7  7  7  7  7  7  7  7  7  7  7  8  8  8  9  9  9  9 10 10 10 10
  # 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10

  S - seq(0.01,1,length=100))
  100*S[7] - 7
  # [1] -8.881784e-16

  which(100*S  (1:100))
  # [1] 7

Why not simply use expressions which evaluate to exact integers?
There is no obvious reason in the examples given to do otherwise.

But, if you must adopt your approach, then consider:

  round(100*S)

  100*S - (1:100)
  #  [1]  0.00e+00  0.00e+00  0.00e+00  0.00e+00
  #  [5]  0.00e+00  8.881784e-16 -8.881784e-16  0.00e+00
  #  [9]  0.00e+00  0.00e+00  0.00e+00  0.00e+00
  # [13]  0.00e+00  1.776357e-15  1.776357e-15  0.00e+00
  # [17]  0.00e+00  3.552714e-15  0.00e+00  0.00e+00
  # [etc  ]

  round(100*S) - (1:100)
  #  [1] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
  # [26] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
  # [51] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
  # [76] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Hoping this helps,
Ted.

-
E-Mail: (Ted Harding) ted.hard...@wlandres.net
Date: 30-Nov-2012  Time: 23:26:41
This message was sent by XFMail

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


  1   2   >