Re: [R] bootstrapping quantile regression

2012-10-31 Thread Kay Cichini
sry, I forgot to replace rlm() - but actually I tried both and the question
applies to both approaches..

Am 31.10.2012 00:19 schrieb Kay Cichini kay.cich...@gmail.com:

 HI everyone,

 I try to get some bootstrap CIs for coefficients obtained by quantile
regression. I have influencial values and thus switched to quantreg..
 The data is clustered and within clusters the variance of my DV = 0..

 Is this sensible for the below data? And what about the warnings?

 Thanks in advance for any guidance,
 Kay

  dput(d)
 structure(list(Porenfläche = c(4990L, 7002L, 7558L, 7352L, 7943L,
 7979L, 9333L, 8209L, 8393L, 6425L, 9364L, 8624L, 10651L, 8868L,
 9417L, 8874L, 10962L, 10743L, 11878L, 9867L, 7838L, 11876L, 12212L,
 8233L, 6360L, 4193L, 7416L, 5246L, 6509L, 4895L, 6775L, 7894L,
 5980L, 5318L, 7392L, 7894L, 3469L, 1468L, 3524L, 5267L, 5048L,
 1016L, 5605L, 8793L, 3475L, 1651L, 5514L, 9718L), P.Perimeter = c(2791.9,
 3892.6, 3930.66, 3869.32, 3948.54, 4010.15, 4345.75, 4344.75,
 3682.04, 3098.65, 4480.05, 3986.24, 4036.54, 3518.04, 3999.37,
 3629.07, 4608.66, 4787.62, 4864.22, 4479.41, 3428.74, 4353.14,
 4697.65, 3518.44, 1977.39, 1379.35, 1916.24, 1585.42, 1851.21,
 1239.66, 1728.14, 1461.06, 1426.76, 990.388, 1350.76, 1461.06,
 1376.7, 476.322, 1189.46, 1644.96, 941.543, 308.642, 1145.69,
 2280.49, 1174.11, 597.808, 1455.88, 1485.58), P.Form = c(0.0903296,
 0.148622, 0.183312, 0.117063, 0.122417, 0.167045, 0.189651, 0.164127,
 0.203654, 0.162394, 0.150944, 0.148141, 0.228595, 0.231623, 0.172567,
 0.153481, 0.204314, 0.262727, 0.200071, 0.14481, 0.113852, 0.291029,
 0.240077, 0.161865, 0.280887, 0.179455, 0.191802, 0.133083, 0.225214,
 0.341273, 0.311646, 0.276016, 0.197653, 0.326635, 0.154192, 0.276016,
 0.176969, 0.438712, 0.163586, 0.253832, 0.328641, 0.230081, 0.464125,
 0.420477, 0.200744, 0.262651, 0.182453, 0.200447), Durchlässigkeit =
c(6.3,
 6.3, 6.3, 6.3, 17.1, 17.1, 17.1, 17.1, 119, 119, 119, 119, 82.4,
 82.4, 82.4, 82.4, 58.6, 58.6, 58.6, 58.6, 142, 142, 142, 142,
 740, 740, 740, 740, 890, 890, 890, 890, 950, 950, 950, 950, 100,
 100, 100, 100, 1300, 1300, 1300, 1300, 580, 580, 580, 580), Gebiete =
structure(c(1L,
 1L, 1L, 1L, 2L, 2L, 2L, 2L, 6L, 6L, 6L, 6L, 4L, 4L, 4L, 4L, 3L,
 3L, 3L, 3L, 7L, 7L, 7L, 7L, 9L, 9L, 9L, 9L, 10L, 10L, 10L, 10L,
 11L, 11L, 11L, 11L, 5L, 5L, 5L, 5L, 12L, 12L, 12L, 12L, 8L, 8L,
 8L, 8L), .Label = c(6.3, 17.1, 58.6, 82.4, 100, 119,
 142, 580, 740, 890, 950, 1300), class = factor)), .Names =
c(Porenfläche,
 P.Perimeter, P.Form, Durchlässigkeit, Gebiete), row.names =
c(1,
 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
 47, 48), class = data.frame)

 ## do quantile regression and bootstrap the coefficients, allowing for
clustered data
 ## by putting Gebiet as strata argument (?),
 ## dv variation within clusters/Gebiet = 0!
 bs - function(formula, data, indices) {
   d - data[indices, ] # allows boot to select sample
   fit - rlm(formula, data = d)
   return(coef(fit))
 }

 results - boot(data = d, statistic = bs, strata = d$Gebiete,
 R = 199, formula = Durchlässigkeit ~ P.Perimeter + P.Form)

 # get 99% confidence intervals
 boot.ci(results, type=bca, index=1, conf = .99) # intercept
 boot.ci(results, type=bca, index=2, conf = .99) # P.Perimeter
 boot.ci(results, type=bca, index=3, conf = .99) # P.Form

 --

 Kay Cichini, MSc Biol

 Grubenweg 22, 6071 Aldrans

 E-Mail: kay.cich...@gmail.com
 --



[[alternative HTML version deleted]]

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


Re: [R] POSIXct date missing time component

2012-10-31 Thread chuck.01
I did  not read that close enough; thanks again. 




arun kirshna wrote
 Hi,
 
 ?as.POSIXct()
 format: character string giving a date-time format as used by
   ‘strptime’.
 
 ?strptime()
 format: A character string.  The default for the ‘format’ methods is
   ‘%Y-%m-%d %H:%M:%S’ if any component has a time component
   which is not midnight, and ‘%Y-%m-%d’ otherwise.  If
   ‘options(digits.secs)’ is set, up to the specified number
   of digits will be printed for seconds.
 
 So, may be it is better to add a sec and later subtract it.
 
  dates.mine2-dates.mine+1
 dates.mine2[3]
 #[1] 2009-05-22 00:00:01 GMT
  dates.mine3-dates.mine2-1
  dates.mine3[3]
 #[1] 2009-05-22 GMT
 A.K.
 
 
 
 
 
 
 - Original Message -
 From: chuck.01 lt;

 CharlieTheBrown77@

 gt;
 To: 

 r-help@

 Cc: 
 Sent: Tuesday, October 30, 2012 5:21 PM
 Subject: Re: [R] POSIXct  date missing time component
 
 Um, OK. 
 My dates have times, they are 00:00:00 (i.e. midnight)
 I'll just add a fraction of a second my dates and go with it.
 
 Thanks for the reply. 
 
 
 
 
 arun kirshna wrote
 HI,
 Please check this link
 (http://rss.acs.unt.edu/Rdoc/library/base/html/as.POSIXlt.html). 
 Dates without times are treated as being at midnight UTC. 
 
 May be you can try this (if it doesn't create additional problems):
  dates.mine2-dates.mine+1
 dates.mine2
 #[1] 2009-05-21 23:30:01 GMT 2009-05-21 23:45:01 GMT
 #[3] 2009-05-22 00:00:01 GMT 2009-05-22 00:15:01 GMT
  dates.mine2[3]
 #[1] 2009-05-22 00:00:01 GMT
 str(dates.mine2)
  #POSIXct[1:4], format: 2009-05-21 23:30:01 2009-05-21 23:45:01 ...
 A.K.
 
 
 
 
 
 --
 View this message in context:
 http://r.789695.n4.nabble.com/POSIXct-date-missing-time-component-tp4647932p4647939.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __

 R-help@

  mailing list
 https://stat.ethz.ch/mailman/listinfo/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@

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





--
View this message in context: 
http://r.789695.n4.nabble.com/POSIXct-date-missing-time-component-tp4647932p4647963.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] R crashing after successfully running compiled code

2012-10-31 Thread Adam Clark
I'm running R 2.15.1x64, though the same problem persists for 2.13.0x32 and
2.13.0x64.

I am trying to run compiled C code using the .C convention. The
code compiles without problems, dynamically loads within the R
workspace with no problems, and even runs and gives correct results with
no problems.

However, R will randomly crash within a few minutes of successfully using
the compiled function.

For example, if I run my compiled function using:
dyn.load(mycfun.dll)
answer-.C(mycfun, parameters...), I get a completely sensible
result that gets stored to answer.
However, if I try to do too many things to answer, the R exits
without warning.
I've tried dyn.unload in hopes that R would become stable afterwards, but
in this case using the function crashes R without fail.

Usually, I can either plot, or view, or save answer to a file - but never
take more than a single action before R exits. This does not appear to
depend on how long R has been open. Initially, I thought it was a bug in
the inline function, but I'm finding the same problem now that I'm using
the dynamically loaded file directly. I'm used to R being insanely stable,
and am somewhat mystified by this whole problem.

My next move is to learn the .Call convention, as I suspect that
my problem is related to my C function using memory that R doesn't
know is used. But - before I invest a while lot more time on this, I'd
like to know whether anybody things this is likely to solve the problem.
If not, I may just want to run my code entirely in C, and forget the
R problem.

-- 
Adam Clark
University of Minnesota, EEB
100 Ecology Building
1987 Upper Buford Circle
St. Paul, MN 55108
(857)-544-6782

[[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] IBrokers readBin is of argument NULL

2012-10-31 Thread loyolite270
hi

I ran the below code, its throwing some error.

 contract - twsEquity(FAS)
 reqMktData(tws, contract)
Error in if (curMsg == .twsIncomingMSG$TICK_PRICE) { : 
  argument is of length zero

So i ran this following code to check the location of the problem

 socketSelect(list(con), write=FALSE, timeout=15)
[1] TRUE
 readBin(con,character(),1) # which is the curMsg
character(0)

The above readBin command is always giving the same result as above. I think
its not able to read any msg from TWS API or TWS API is not sending any msg
(may be i should change settings). Can some one please help with this
problem ?

Thanks
Prabakar




--
View this message in context: 
http://r.789695.n4.nabble.com/IBrokers-readBin-is-of-argument-NULL-tp4647968.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] R crashing after successfully running compiled code

2012-10-31 Thread R. Michael Weylandt michael.weyla...@gmail.com


On Oct 31, 2012, at 3:13 AM, Adam Clark atcl...@umn.edu wrote:

 I'm running R 2.15.1x64, though the same problem persists for 2.13.0x32 and
 2.13.0x64.
 
 I am trying to run compiled C code using the .C convention. The
 code compiles without problems, dynamically loads within the R
 workspace with no problems, and even runs and gives correct results with
 no problems.
 
 However, R will randomly crash within a few minutes of successfully using
 the compiled function.
 
 For example, if I run my compiled function using:
 dyn.load(mycfun.dll)
 answer-.C(mycfun, parameters...), I get a completely sensible
 result that gets stored to answer.
 However, if I try to do too many things to answer, the R exits
 without warning.
 I've tried dyn.unload in hopes that R would become stable afterwards, but
 in this case using the function crashes R without fail.
 
 Usually, I can either plot, or view, or save answer to a file - but never
 take more than a single action before R exits. This does not appear to
 depend on how long R has been open. Initially, I thought it was a bug in
 the inline function, but I'm finding the same problem now that I'm using
 the dynamically loaded file directly. I'm used to R being insanely stable,
 and am somewhat mystified by this whole problem.
 
 My next move is to learn the .Call convention, as I suspect that
 my problem is related to my C function using memory that R doesn't
 know is used. But - before I invest a while lot more time on this, I'd
 like to know whether anybody things this is likely to solve the problem.
 If not, I may just want to run my code entirely in C, and forget the
 R problem.

Hi Adam,

Can you make a minimal reproducible example of your C sources available? I'm 
relatively certain that the problem is in the memory management therein, but I 
obviously can't say more without seeing the code. 

Michael

 
 -- 
 Adam Clark
 University of Minnesota, EEB
 100 Ecology Building
 1987 Upper Buford Circle
 St. Paul, MN 55108
 (857)-544-6782
 
[[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] POSIXct date missing time component

2012-10-31 Thread Jeff Newmiller
Rather than altering your data, it is better to use the same date time format 
at all times, and specify it explicitly when converting to or from character.
---
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.

chuck.01 charliethebrow...@gmail.com wrote:

I did  not read that close enough; thanks again. 




arun kirshna wrote
 Hi,
 
 ?as.POSIXct()
 format: character string giving a date-time format as used by
   ‘strptime’.
 
 ?strptime()
 format: A character string.  The default for the ‘format’ methods is
   ‘%Y-%m-%d %H:%M:%S’ if any component has a time component
   which is not midnight, and ‘%Y-%m-%d’ otherwise.  If
   ‘options(digits.secs)’ is set, up to the specified number
   of digits will be printed for seconds.
 
 So, may be it is better to add a sec and later subtract it.
 
  dates.mine2-dates.mine+1
 dates.mine2[3]
 #[1] 2009-05-22 00:00:01 GMT
  dates.mine3-dates.mine2-1
  dates.mine3[3]
 #[1] 2009-05-22 GMT
 A.K.
 
 
 
 
 
 
 - Original Message -
 From: chuck.01 lt;

 CharlieTheBrown77@

 gt;
 To: 

 r-help@

 Cc: 
 Sent: Tuesday, October 30, 2012 5:21 PM
 Subject: Re: [R] POSIXct  date missing time component
 
 Um, OK. 
 My dates have times, they are 00:00:00 (i.e. midnight)
 I'll just add a fraction of a second my dates and go with it.
 
 Thanks for the reply. 
 
 
 
 
 arun kirshna wrote
 HI,
 Please check this link
 (http://rss.acs.unt.edu/Rdoc/library/base/html/as.POSIXlt.html). 
 Dates without times are treated as being at midnight UTC. 
 
 May be you can try this (if it doesn't create additional problems):
  dates.mine2-dates.mine+1
 dates.mine2
 #[1] 2009-05-21 23:30:01 GMT 2009-05-21 23:45:01 GMT
 #[3] 2009-05-22 00:00:01 GMT 2009-05-22 00:15:01 GMT
  dates.mine2[3]
 #[1] 2009-05-22 00:00:01 GMT
 str(dates.mine2)
  #POSIXct[1:4], format: 2009-05-21 23:30:01 2009-05-21 23:45:01
...
 A.K.
 
 
 
 
 
 --
 View this message in context:

http://r.789695.n4.nabble.com/POSIXct-date-missing-time-component-tp4647932p4647939.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __

 R-help@

  mailing list
 https://stat.ethz.ch/mailman/listinfo/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@

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





--
View this message in context:
http://r.789695.n4.nabble.com/POSIXct-date-missing-time-component-tp4647932p4647963.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] standard error for quantile

2012-10-31 Thread Jim Lemon

On 10/31/2012 12:46 AM, PIKAL Petr wrote:

Dear all

I have a question about quantiles standard error, partly practical
partly theoretical. I know that

x-rlnorm(10, log(200), log(2))
quantile(x, c(.10,.5,.99))

computes quantiles but I would like to know if there is any function to
find standard error (or any dispersion measure) of these estimated
values.

And here is a theoretical one. I feel that when I compute median from
given set of values it will have lower standard error then 0.1 quantile
computed from the same set of values.

Is it true? If yes can you point me to some reasoning?


Hi Petr,
Using a resampling method, it depends upon the distribution of the 
values. If you have a love-hate distribution (bimodal and heavily 
weighted toward extreme values), the median standard error can be 
larger. Try this:


x-sample(-5:5,1000,TRUE,
 prob=c(0.2,0.1,0.05,0.04,0.03,0.02,0.03,0.04,0.05,0.1,0.2))
x-ifelse(x0,x+runif(1000),x-runif(1000))
hist(x)
mcse.q(x, 0.1)
$est
[1] -3.481419

$se
[1] 0.06887319

mcse.q(x, 0.5)
$est
[1] 1.088475

$se
[1] 0.3440115

 mcse.q(x, 0.1)
$est
[1] -3.481419

$se
[1] 0.06887319

Jim

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


[R] aggregate.formula: formula from string

2012-10-31 Thread Thaler,Thorn,LAUSANNE,Applied Mathematics
Dear all,

I want to use aggregate.formula to conveniently summarize a data.frame. I have 
quiet some variables in the data.frame and thus I don't want to write all these 
names by hand, but instead create them on the fly. This approach has the 
advantage that if there will be even more columns in the data.frame I don't 
have to change the code.

I've hence tried to construct a formula object and to pass that to aggregate:

d - expand.grid(a = factor(1:3), b = factor(LETTERS[1:2]))
d - rbind(d,d,d)
d$y - rnorm(18)
d$z - rnorm(18)
mF - as.formula(paste(cbind(, paste(names(d)[-(1:2)], collapse = ,), ) ~ 
a + b, sep = ))

But if I try to pass that formula to aggregate

aggregate(mF, d, mean)

I get the following error:

Error in m[[2L]][[2L]] : object of type 'symbol' is not subsettable

But if I pass the formula directly:

aggregate(cbind(y, z) ~ a + b, d, mean)

Everything is working as expected.

So I was wondering what went wrong? I know I could use a formula like . ~ a + b 
instead and this would work fine, but I'm just interested in why the outlined 
approach does not work as expected, and where my mistake lies? (that means in 
particular I am not asking for a solution of how to get the thing done - there 
are plenty of alternatives - but instead to understand why this very approach 
does not work)

Thanks for your help!

Kind Regards,

Thorn Thaler
Mathematician

Applied Mathematics 
Nestec Ltd,
Nestlé Research Center
PO Box 44 
CH-1000 Lausanne 26
Phone: +41 21 785 8220
Fax: +41 21 785 9486

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

2012-10-31 Thread PIKAL Petr
Thanks Jim.

After reinstall of new R version all mentioned packages work. I tested various 
functions which revealed that on my lognorm data there is no big difference in 
error of median or 10% quantile. I also found some function for quantile se 
computing in Hmisc package.

Petr


 -Original Message-
 From: Jim Lemon [mailto:j...@bitwrit.com.au]
 Sent: Wednesday, October 31, 2012 9:56 AM
 To: PIKAL Petr
 Cc: r-help@r-project.org
 Subject: Re: [R] standard error for quantile
 
 On 10/31/2012 12:46 AM, PIKAL Petr wrote:
  Dear all
 
  I have a question about quantiles standard error, partly practical
  partly theoretical. I know that
 
  x-rlnorm(10, log(200), log(2))
  quantile(x, c(.10,.5,.99))
 
  computes quantiles but I would like to know if there is any function
  to find standard error (or any dispersion measure) of these estimated
  values.
 
  And here is a theoretical one. I feel that when I compute median from
  given set of values it will have lower standard error then 0.1
  quantile computed from the same set of values.
 
  Is it true? If yes can you point me to some reasoning?
 
 Hi Petr,
 Using a resampling method, it depends upon the distribution of the
 values. If you have a love-hate distribution (bimodal and heavily
 weighted toward extreme values), the median standard error can be
 larger. Try this:
 
 x-sample(-5:5,1000,TRUE,
   prob=c(0.2,0.1,0.05,0.04,0.03,0.02,0.03,0.04,0.05,0.1,0.2))
 x-ifelse(x0,x+runif(1000),x-runif(1000))
 hist(x)
 mcse.q(x, 0.1)
 $est
 [1] -3.481419
 
 $se
 [1] 0.06887319
 
 mcse.q(x, 0.5)
 $est
 [1] 1.088475
 
 $se
 [1] 0.3440115
 
   mcse.q(x, 0.1)
 $est
 [1] -3.481419
 
 $se
 [1] 0.06887319
 
 Jim

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

2012-10-31 Thread PIKAL Petr
Hi Bert


 -Original Message-
 From: Bert Gunter [mailto:gunter.ber...@gene.com]
 Sent: Tuesday, October 30, 2012 3:37 PM
 To: PIKAL Petr
 Cc: r-help@r-project.org
 Subject: Re: [R] standard error for quantile
 
  Petr:
 
 1. Not an R question.

Partly. I asked also for pointing me to some R functions which can compute such 
standard error, which is by my humble opinion valid R question.

 
 2. You want the distribution of order statistics. Search on that. It's
 basically binomial/beta.

Hm. I looked at some web info, which is quite good for trained statistician but 
at the edge of my understanding as chemist (and sometimes beyound:-).

Thanks anyway.
Regards
Petr

 
 -- Bert
 
 On Tue, Oct 30, 2012 at 6:46 AM, PIKAL Petr petr.pi...@precheza.cz
 wrote:
  Dear all
 
  I have a question about quantiles standard error, partly practical
  partly theoretical. I know that
 
  x-rlnorm(10, log(200), log(2))
  quantile(x, c(.10,.5,.99))
 
  computes quantiles but I would like to know if there is any function
  to find standard error (or any dispersion measure) of these estimated
  values.
 
  And here is a theoretical one. I feel that when I compute median from
  given set of values it will have lower standard error then 0.1
  quantile computed from the same set of values.
 
  Is it true? If yes can you point me to some reasoning?
 
  Thanks for all answers.
  Regards
  Petr
 
  PS.
  I found mcmcse package which shall compute the standard error but
  which I could not make to work probably because I do not have recent
  R-devel version installed
 
  Error in eval(expr, envir, enclos) :
could not find function .getNamespace
  Error : unable to load R code in package 'mcmcse'
  Error: package/namespace load failed for 'mcmcse'
 
  Maybe I will also something find in quantreg package, but I did not
  went through it yet.
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 
 
 --
 
 Bert Gunter
 Genentech Nonclinical Biostatistics
 
 Internal Contact Info:
 Phone: 467-7374
 Website:
 http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-
 biostatistics/pdb-ncb-home.htm
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Hausman test error solve

2012-10-31 Thread Millo Giovanni
Liebe Gloria,

the error says it all: you have a singular covariance matrix (the
vcov(q) term in the Hausman test); this is not invertible and therefore
the test fails.

As for the reasons, this might be either a bug or perhaps an
ill-conditioned problem: it is impossible for me to tell without a
reproducible example. I can only suggest an alternative strategy (which
you must tailor to your example).

Another (computationally more robust) way to perform a Hausman test is
through an auxiliary regression (see Wooldridge, Econometric analysis
of cross-section and panel data, 10.7.3)

 Hausman test by auxiliary regression 
library(plm)

## standard Munnell example
data(Produc)
fm-log(gsp)~log(pcap)+log(pc)+log(emp)+unemp

re-plm(fm, data=Produc, model=random)
fe-plm(fm, data=Produc, model=within)

## extract transformed data
y.re-pmodel.response(re)
X.re-model.matrix(re)
X.fe-model.matrix(fe)

## check coefficients
coef(re)
lm(y.re~X.re-1)

coef(fe)
lm(pmodel.response(fe)~X.fe-1)

## make aux dataset
auxdata-data.frame(cbind(y.re,X.re,X.fe))
colnames(auxdata)-c(y, paste(x, 1:9, sep=))

## auxiliary model
auxmod-lm(y~x1+x2+x3+x4+x5+x6+x7+x8+x9-1, auxdata)

## regression-based Hausman test is exclusion test for 6-9
library(lmtest)
waldtest(auxmod, 6:9)

I will eventually add a production version of this to 'plm' as
phtest2().
Best wishes nach Koeln
Giovanni

Giovanni Millo, PhD
Research Dept.,
Assicurazioni Generali SpA
Via Machiavelli 4,
34132 Trieste (Italy)
tel. +39 040 671184
fax  +39 040 671160

 original message --
Date: Mon, 29 Oct 2012 13:14:09 -0700 (PDT)
From: gloria gbus...@smail.uni-koeln.de
To: r-help@r-project.org
Subject: [R] Hausman test  error solve
Message-ID: 1351541649650-4647793.p...@n4.nabble.com
Content-Type: text/plain; charset=UTF-8

Hello,
I am trying to conduct a Hausman test to choose between FE estimators
and RE
estimators. 

When I try to run:

library(plm)

fixed - plm(ROS ~ DiffClosenessC +ZZiele + AggSK + nRedundantStrecken +
Degree + KantenGew + BetweennessC + SitzKappazitaet, 
data=Panel,index=c(id,time),model=within)   

summary(fixed)

fixef(fixed)

random -plm(ROS ~ DiffClosenessC +ZZiele + AggSK + nRedundantStrecken +
Degree + KantenGew + BetweennessC + SitzKappazitaet, 
data=Panel,index=c(id,time), model=random)   

summary(random)

phtest(fixed, random)

I get an error from phtest(fixed, random)

Fehler in solve.default(dvcov) : 
  System ist f?r den Rechner singul?r: reziproke Konditionszahl = ...

Error in solve.default(dvcov) :
  system is computationally singular: reciprocal condition number =...

Can someone Help me with this problem or give me a hint where to look?

Thanks

gloria


--
View this message in context:
http://r.789695.n4.nabble.com/Hausman-test-error-solve-tp4647793.html
Sent from the R help mailing list archive at Nabble.com.
-end original message -

 
Ai sensi del D.Lgs. 196/2003 si precisa che le informazi...{{dropped:12}}

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

2012-10-31 Thread Jose Iparraguirre
Have a look at this: 
http://stats.stackexchange.com/questions/15486/plotting-a-boxplot-against-multiple-factors-in-r-with-ggplot2

Hope it helps.

José


-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of dysonsphere
Sent: 30 October 2012 18:22
To: r-help@r-project.org
Subject: [R] boxplots of various levels

noob here
trying to make boxplots of some data
i would like to separate the boxplots according to conditons of various
levels
for example:

i have 
group:1 and 2, each group performed tests consisting of
condition A,B,C,D
side: left and right
time: 1 to 10

I would like separate boxplots of the results (x) of the tests (numeric) for
each group under each condition on each side over time.

so far i have set it up like this:
boxplot(test$x~test$time)
this gives me the plot for all vaues of x in each time bin.  basicaly i
would need a command that tells R to include only the data that agrees with
the group, condition, and side I set.
something like 
boxplot(test$x~test$time) where test$group=1,test$condition=A,test$side=left

can this be done?




--
View this message in context: 
http://r.789695.n4.nabble.com/boxplots-of-various-levels-tp4647917.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.

Age UK and YouthNet are official charities for the Virgin London Marathon 2013

We need you to Run for it. Join the team and help raise vital funds to bring 
generations together to combat loneliness and isolation.

Go to http://www.runforit.org.uk for more information or contact Helen Parson 
at helen.pars...@ageuk.org.uk or on 020 303 31369.

Age UK and YouthNet. A lifeline, online.

www.runforit.org.uk



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 confide...{{dropped:28}}

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

2012-10-31 Thread PIKAL Petr
Hi Ted

 -Original Message-
 From: ted@deb [mailto:ted@deb] On Behalf Of Ted Harding
 Sent: Tuesday, October 30, 2012 6:41 PM
 To: r-help@r-project.org

snip

 
 The general asymptotic result for the pth quantile (0p1) X.p of a
 sample of size n is that it is asymptotically Normally distributed with
 mean the pth quantile Q.p of the parent distribution and
 
   var(X.p) = p*(1-p)/(n*f(Q.p)^2)
 
 where f(x) is the probability density function of the parent
 distribution.

So if I understand correctly p*(1-p) is biggest when p=0.5 and decreases with 
smaller or bigger p. The var(X.p) then depends on ratio to parent distribution 
at this p probability. For lognorm distribution and 200 values the resulting 
var is

 (0.5*(1-.5))/(200*qlnorm(.5, log(200), log(2))^2)
[1] 3.125e-08
 (0.1*(1-.1))/(200*qlnorm(.1, log(200), log(2))^2)
[1] 6.648497e-08

so 0.1 var is slightly bigger than 0.5 var. For different distributions this 
can be reversed as Jim pointed out.

Did I manage to understand?

Thank you very much.
Regards
Petr 


 
 This is not necessarily very helpful for small sample sizes (depending
 on the parent distribution).
 
 However, it is possible to obtain a general result giving an exact
 confidence interval for Q.p given the entire ordered sample, though
 there is only a restricted set of confidence levels to which it
 applies.
 
 If you'd like more detail about the above, I could write up derivations
 and make the write-up available.
 
 Hoping this helps,
 Ted.
 
 -
 E-Mail: (Ted Harding) ted.hard...@wlandres.net
 Date: 30-Oct-2012  Time: 17:40:55
 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.


Re: [R] standard error for quantile

2012-10-31 Thread PIKAL Petr
Hi Roger

Thanks for your answer. I tried it with partial success. I got values for tau 
but I did not manage to evaluate errors or variances of these values.

from help page this shall compute median 

rq(rnorm(50) ~ 1, ci=FALSE)

and I assumed some kind of confidence interval is computed when ci=TRUE, but no 
avail.

In the mean time I have got several other answers which helped me to understand 
the topic.

Thanks again.

Regards
Petr

 -Original Message-
 From: Roger Koenker [mailto:rkoen...@illinois.edu]
 Sent: Tuesday, October 30, 2012 3:42 PM
 To: PIKAL Petr
 Cc: r-help@r-project.org help
 Subject: Re: [R] standard error for quantile
 
 Petr,
 
 You can  do:
 
 require(quantreg)
 summary(rq(x ~ 1, tau = c(.10,.50,.99))
 
 
 url:www.econ.uiuc.edu/~rogerRoger Koenker
 emailrkoen...@uiuc.eduDepartment of Economics
 vox: 217-333-4558University of Illinois
 fax:   217-244-6678Urbana, IL 61801
 
 On Oct 30, 2012, at 9:37 AM, Bert Gunter wrote:
 
  Petr:
 
  1. Not an R question.
 
  2. You want the distribution of order statistics. Search on that.
 It's
  basically binomial/beta.
 
  -- Bert
 
  On Tue, Oct 30, 2012 at 6:46 AM, PIKAL Petr petr.pi...@precheza.cz
 wrote:
  Dear all
 
  I have a question about quantiles standard error, partly practical
  partly theoretical. I know that
 
  x-rlnorm(10, log(200), log(2))
  quantile(x, c(.10,.5,.99))
 
  computes quantiles but I would like to know if there is any function
  to find standard error (or any dispersion measure) of these
 estimated
  values.
 
  And here is a theoretical one. I feel that when I compute median
 from
  given set of values it will have lower standard error then 0.1
  quantile computed from the same set of values.
 
  Is it true? If yes can you point me to some reasoning?
 
  Thanks for all answers.
  Regards
  Petr
 
  PS.
  I found mcmcse package which shall compute the standard error but
  which I could not make to work probably because I do not have recent
  R-devel version installed
 
  Error in eval(expr, envir, enclos) :
   could not find function .getNamespace
  Error : unable to load R code in package 'mcmcse'
  Error: package/namespace load failed for 'mcmcse'
 
  Maybe I will also something find in quantreg package, but I did not
  went through it yet.
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 
 
  --
 
  Bert Gunter
  Genentech Nonclinical Biostatistics
 
  Internal Contact Info:
  Phone: 467-7374
  Website:
  http://pharmadevelopment.roche.com/index/pdb/pdb-functional-
 groups/pdb
  -biostatistics/pdb-ncb-home.htm
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.

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

2012-10-31 Thread vincent guyader
@sarah,

it's true , but I need a boolean vector.


@berend

good idea


@David,

yes %in% work fine but I need   = and =

@bill

yes, it could be a solution, but i prefer  a simple operator.. so i will
build one.


thank you all


2012/10/30 Sarah Goslee sarah.gos...@gmail.com

 Here's one option:
   vec-c(3,4,5,NA,1,NA,9,NA,1)
  subset(vec, vec  2)
 [1] 3 4 5 9
  subset(vec, vec == 1)
 [1] 1 1

 Sarah

 On Tue, Oct 30, 2012 at 5:08 PM, vincent guyader
 vincent.guya...@gmail.com wrote:
  Hi everyone,
 
   i'm looking for a NA-friendly operator
 
  I explain :
 
  vec-c(3,4,5,NA,1,NA,9,NA,1)
 
  vec[vec == 1]  # NA  1 NA NA  1
 
  I dont want the NA's :
  vec[vec == 1  ! is.na(vec)]# 1  1
  is the same as
  vec[vec %in% 1] # 1  1
 
  %in% is NA-friendly :)
 
  But if i want 2 without the NA's :
 
  vec[vec2] #3  4  5 NA NA  9 NA
 
  if i dont want the NA i have to do :
 
  vec[vec2  !is.na(vec)] #3  4  5  9
 
  is there an opérator to directly do that?
 
  any idea?
 
  thx a lot.
 


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


[[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] invalid labels; length 2 should be 1 or 0

2012-10-31 Thread rachel.cole
I had the same problem, but found this note in the MICE package documentation
(at http://cran.r-project.org/web/packages/mice/mice.pdf):
Added June 25, 2012: The currently implemented algorithm does not handle
predictors that are
specified as fixed effects (type=1). When using mice.impute.2l.norm(), the
current advice is to
specify all predictors as random effects (type=2).
Warning: The assumption of heterogeneous variances requires that in every
class at least one observation has a response in y.



--
View this message in context: 
http://r.789695.n4.nabble.com/invalid-labels-length-2-should-be-1-or-0-tp4643712p4647974.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] RCurl - curlPerform - Time out?!?

2012-10-31 Thread Florian Umlauf (CRIE)
Hi,


I am working with the RCurl package and I am using the curlPerform 
function for an soap-query.
The problem is that the code is usually working well, but sometimes the 
connection gets lost.

So I wrote a while-loop to repeat the query if anything might happened 
so that the same query runs again, but if the query-faults it takes a 
very long time for the repetition.

My question is if there is any possibility to force a time out for the 
curlPerform function or something like that?


Thanks!



 run = 1
 i=0
 while(run==1)
 {
 i=i+1
 try(
  run - curlPerform(url = 
http://search.webofknowledge.com/esti/wokmws/ws/WokSearchLite.cgi;,
httpheader=c(Accept-Encoding=gzip,deflate,Content-Type=text/xml;charset=UTF-8,'SOAPAction'='',
Cookie=paste('SID=',s_session,'',sep=),Content-Length=paste(nchar(s_body)),Host=search.webofknowledge.com,Connection=Keep-Alive,User-Agent=Apache-HttpClient/4.1.1
 
(java 1.5)),
postfields=s_body,
writefunction = h$update
,verbose = TRUE)
  ,TRUE)


 print(i)
  }




[[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] NA-friendly operator

2012-10-31 Thread R. Michael Weylandt
On Wed, Oct 31, 2012 at 10:54 AM, vincent guyader
vincent.guya...@gmail.com wrote:


 yes, it could be a solution, but i prefer  a simple operator.. so i will
 build one.

See this thread for both advice and pitfalls:

https://stat.ethz.ch/pipermail/r-help/2012-June/316240.html

Michael Weylandt

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


Re: [R] R crashing after successfully running compiled code

2012-10-31 Thread Duncan Murdoch

On 12-10-30 11:13 PM, Adam Clark wrote:

I'm running R 2.15.1x64, though the same problem persists for 2.13.0x32 and
2.13.0x64.

I am trying to run compiled C code using the .C convention. The
code compiles without problems, dynamically loads within the R
workspace with no problems, and even runs and gives correct results with
no problems.

However, R will randomly crash within a few minutes of successfully using
the compiled function.

For example, if I run my compiled function using:
dyn.load(mycfun.dll)
answer-.C(mycfun, parameters...), I get a completely sensible
result that gets stored to answer.
However, if I try to do too many things to answer, the R exits
without warning.
I've tried dyn.unload in hopes that R would become stable afterwards, but
in this case using the function crashes R without fail.

Usually, I can either plot, or view, or save answer to a file - but never
take more than a single action before R exits. This does not appear to
depend on how long R has been open. Initially, I thought it was a bug in
the inline function, but I'm finding the same problem now that I'm using
the dynamically loaded file directly. I'm used to R being insanely stable,
and am somewhat mystified by this whole problem.

My next move is to learn the .Call convention, as I suspect that
my problem is related to my C function using memory that R doesn't
know is used. But - before I invest a while lot more time on this, I'd
like to know whether anybody things this is likely to solve the problem.
If not, I may just want to run my code entirely in C, and forget the
R problem.


I think your C code has a bug in it.  The bug might go away when you 
rewrite the function to work within the .Call convention, but it is 
probably easier to find the bug and fix it with the current code.


Things to look for:

Are you fully allocating all arrays in R before passing them to C?  The 
C code receives a pointer and will happily write to it, whether that 
makes sense or not.


Are you careful with your limits on vectors?  In R, a vector is indexed 
from 1 to n, but the same vector in C is indexed from 0 to n-1.  If the 
C code writes to entry n, that will eventually cause problems.


Are you allocating memory in your C code?  There are several ways to do 
that, depending on how you want it managed.  If you do it one way and 
expect it to be managed in a different way, you'll get problems.


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] R crashing after successfully running compiled code

2012-10-31 Thread Prof Brian Ripley

On Wed, 31 Oct 2012, Duncan Murdoch wrote:


On 12-10-30 11:13 PM, Adam Clark wrote:

I'm running R 2.15.1x64, though the same problem persists for 2.13.0x32 and
2.13.0x64.

I am trying to run compiled C code using the .C convention. The
code compiles without problems, dynamically loads within the R
workspace with no problems, and even runs and gives correct results with
no problems.

However, R will randomly crash within a few minutes of successfully using
the compiled function.

For example, if I run my compiled function using:
dyn.load(mycfun.dll)
answer-.C(mycfun, parameters...), I get a completely sensible
result that gets stored to answer.
However, if I try to do too many things to answer, the R exits
without warning.
I've tried dyn.unload in hopes that R would become stable afterwards, but
in this case using the function crashes R without fail.

Usually, I can either plot, or view, or save answer to a file - but never
take more than a single action before R exits. This does not appear to
depend on how long R has been open. Initially, I thought it was a bug in
the inline function, but I'm finding the same problem now that I'm using
the dynamically loaded file directly. I'm used to R being insanely stable,
and am somewhat mystified by this whole problem.

My next move is to learn the .Call convention, as I suspect that
my problem is related to my C function using memory that R doesn't
know is used. But - before I invest a while lot more time on this, I'd
like to know whether anybody things this is likely to solve the problem.
If not, I may just want to run my code entirely in C, and forget the
R problem.


I think your C code has a bug in it.  The bug might go away when you rewrite 
the function to work within the .Call convention, but it is probably easier 
to find the bug and fix it with the current code.


Things to look for:

Are you fully allocating all arrays in R before passing them to C?  The C 
code receives a pointer and will happily write to it, whether that makes 
sense or not.


Are you careful with your limits on vectors?  In R, a vector is indexed from 
1 to n, but the same vector in C is indexed from 0 to n-1.  If the C code 
writes to entry n, that will eventually cause problems.


Using R-devel and the following new feature

• There is a new option, options(CBoundsCheck=), which controls how
  .C() and .Fortran() pass arguments to compiled code.  If true
  (which can be enabled by setting the environment variable
  R_C_BOUNDS_CHECK to yes), raw, integer, double and complex
  arguments are always copied, and checked for writing off either
  end of the array on return from the compiled code (when a second
  copy is made).  This also checks individual elements of character
  vectors passed to .C().

  This is not intended for routine use, but can be very helpful in
  finding segfaults in package code.

makes checking these two points a lot easier.

Are you allocating memory in your C code?  There are several ways to do that, 
depending on how you want it managed.  If you do it one way and expect it to 
be managed in a different way, you'll get problems.


If you can run your code under valgrind (see 'Writing R Extensions') 
you will usually get pointed to the exact cause.  But that's for 
Linux, and with some care MacOS X.


--
Brian D. Ripley,  rip...@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] boxplots of various levels

2012-10-31 Thread John Kane
I am not sure I understand exactly what you want but does this do anything like 
what you want?

library(ggplot2)
mydata  -  data.frame(result = rnorm(100), group = rep(c(1, 2), each = 
50), 
   side = sample(c(L, R), 100, replace = TRUE) , dtime 
= rep(1:10, each=10))

p  -  ggplot(mydata , aes( group, result, fill = side ))+ geom_boxplot() +
facet_wrap(~dtime)
p 

John Kane
Kingston ON Canada


 -Original Message-
 From: dysonspher...@gmail.com
 Sent: Tue, 30 Oct 2012 11:21:49 -0700 (PDT)
 To: r-help@r-project.org
 Subject: [R] boxplots of various levels
 
 noob here
 trying to make boxplots of some data
 i would like to separate the boxplots according to conditons of various
 levels
 for example:
 
 i have
 group:1 and 2, each group performed tests consisting of
 condition A,B,C,D
 side: left and right
 time: 1 to 10
 
 I would like separate boxplots of the results (x) of the tests (numeric)
 for
 each group under each condition on each side over time.
 
 so far i have set it up like this:
 boxplot(test$x~test$time)
 this gives me the plot for all vaues of x in each time bin.  basicaly i
 would need a command that tells R to include only the data that agrees
 with
 the group, condition, and side I set.
 something like
 boxplot(test$x~test$time) where
 test$group=1,test$condition=A,test$side=left
 
 can this be done?
 
 
 
 
 --
 View this message in context:
 http://r.789695.n4.nabble.com/boxplots-of-various-levels-tp4647917.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.


Send any screenshot to your friends in seconds...
Works in all emails, instant messengers, blogs, forums and social networks.
TRY IM TOOLPACK at http://www.imtoolpack.com/default.aspx?rc=if2 for FREE

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


Re: [R] aggregate.formula: formula from string

2012-10-31 Thread arun
Hi,
Try this:
res- aggregate(eval(mF),d,mean)

res

#  a b  NA  NA
#1 1 A -1.48354978 -0.37141485
#2 2 A -0.08862713  0.35359250
#3 3 A  1.17519518 -0.47595290
#4 1 B  0.10214686 -0.70005131
#5 2 B  0.41185154  0.03707291
#6 3 B  0.20507062 -0.67946389


res1-aggregate(cbind(y, z) ~ a + b, d, mean)
colnames(res)[3:4]-colnames(res1)[3:4]
 identical(res,res1)
#[1] TRUE
A.K.




- Original Message -
From: Thaler,Thorn,LAUSANNE,Applied Mathematics thorn.tha...@rdls.nestle.com
To: r-help@r-project.org r-help@r-project.org
Cc: 
Sent: Wednesday, October 31, 2012 5:46 AM
Subject: [R] aggregate.formula: formula from string

Dear all,

I want to use aggregate.formula to conveniently summarize a data.frame. I have 
quiet some variables in the data.frame and thus I don't want to write all these 
names by hand, but instead create them on the fly. This approach has the 
advantage that if there will be even more columns in the data.frame I don't 
have to change the code.

I've hence tried to construct a formula object and to pass that to aggregate:

d - expand.grid(a = factor(1:3), b = factor(LETTERS[1:2]))
d - rbind(d,d,d)
d$y - rnorm(18)
d$z - rnorm(18)
mF - as.formula(paste(cbind(, paste(names(d)[-(1:2)], collapse = ,), ) ~ 
a + b, sep = ))

But if I try to pass that formula to aggregate

aggregate(mF, d, mean)

I get the following error:

Error in m[[2L]][[2L]] : object of type 'symbol' is not subsettable

But if I pass the formula directly:

aggregate(cbind(y, z) ~ a + b, d, mean)

Everything is working as expected.

So I was wondering what went wrong? I know I could use a formula like . ~ a + b 
instead and this would work fine, but I'm just interested in why the outlined 
approach does not work as expected, and where my mistake lies? (that means in 
particular I am not asking for a solution of how to get the thing done - there 
are plenty of alternatives - but instead to understand why this very approach 
does not work)

Thanks for your help!

Kind Regards,

Thorn Thaler
Mathematician

Applied Mathematics 
Nestec Ltd,
Nestlé Research Center
PO Box 44 
CH-1000 Lausanne 26
Phone: +41 21 785 8220
Fax: +41 21 785 9486

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

2012-10-31 Thread John Kane
 
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example

John Kane
Kingston ON Canada


 -Original Message-
 From: cat...@bas.ac.uk
 Sent: Tue, 30 Oct 2012 10:27:29 -0700 (PDT)
 To: r-help@r-project.org
 Subject: [R] box() doesnt work
 
 Hi,
 
 when plotting a graphic i find that the surrounding box disappears if I
 adjust the margins with par(mar=..). Ive tried reassigning it with box()
 but
 it doesnt seem to make any difference. Does anyone know a way to overcome
 this?
 
 Thanks in advance
 
 
 
 --
 View this message in context:
 http://r.789695.n4.nabble.com/box-doesnt-work-tp4647909.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.


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] aggregate.formula: formula from string

2012-10-31 Thread Thaler,Thorn,LAUSANNE,Applied Mathematics
Dear Arun,

Thanks for your suggestion, that does the trick. Just because I'm curious, 
where does the problem come from? I figured that wrapping the formula object in 
brackets would work as well:

aggregate((mF), d, mean)

So I guess it has something to do with the scope of mF, or what is the root 
cause?

Thanks for your help!


KR,

-Thorn

 -Original Message-
 From: arun [mailto:smartpink...@yahoo.com]
 Sent: Mittwoch, 31. Oktober 2012 13:15
 To: Thaler,Thorn,LAUSANNE,Applied Mathematics
 Cc: R help
 Subject: Re: [R] aggregate.formula: formula from string
 
 Hi,
 Try this:
 res- aggregate(eval(mF),d,mean)
 
 res
 
 #  a b  NA  NA
 #1 1 A -1.48354978 -0.37141485
 #2 2 A -0.08862713  0.35359250
 #3 3 A  1.17519518 -0.47595290
 #4 1 B  0.10214686 -0.70005131
 #5 2 B  0.41185154  0.03707291
 #6 3 B  0.20507062 -0.67946389
 
 
 res1-aggregate(cbind(y, z) ~ a + b, d, mean)
 colnames(res)[3:4]-colnames(res1)[3:4]
  identical(res,res1)
 #[1] TRUE
 A.K.
 
 
 
 
 - Original Message -
 From: Thaler,Thorn,LAUSANNE,Applied Mathematics
 thorn.tha...@rdls.nestle.com
 To: r-help@r-project.org r-help@r-project.org
 Cc:
 Sent: Wednesday, October 31, 2012 5:46 AM
 Subject: [R] aggregate.formula: formula from string
 
 Dear all,
 
 I want to use aggregate.formula to conveniently summarize a data.frame. I have
 quiet some variables in the data.frame and thus I don't want to write all
 these names by hand, but instead create them on the fly. This approach has the
 advantage that if there will be even more columns in the data.frame I don't
 have to change the code.
 
 I've hence tried to construct a formula object and to pass that to aggregate:
 
 d - expand.grid(a = factor(1:3), b = factor(LETTERS[1:2]))
 d - rbind(d,d,d)
 d$y - rnorm(18)
 d$z - rnorm(18)
 mF - as.formula(paste(cbind(, paste(names(d)[-(1:2)], collapse = ,), ) ~
 a + b, sep = ))
 
 But if I try to pass that formula to aggregate
 
 aggregate(mF, d, mean)
 
 I get the following error:
 
 Error in m[[2L]][[2L]] : object of type 'symbol' is not subsettable
 
 But if I pass the formula directly:
 
 aggregate(cbind(y, z) ~ a + b, d, mean)
 
 Everything is working as expected.
 
 So I was wondering what went wrong? I know I could use a formula like . ~ a +
 b instead and this would work fine, but I'm just interested in why the
 outlined approach does not work as expected, and where my mistake lies? (that
 means in particular I am not asking for a solution of how to get the thing
 done - there are plenty of alternatives - but instead to understand why this
 very approach does not work)
 
 Thanks for your help!
 
 Kind Regards,
 
 Thorn Thaler
 Mathematician
 
 Applied Mathematics
 Nestec Ltd,
 Nestlé Research Center
 PO Box 44
 CH-1000 Lausanne 26
 Phone: +41 21 785 8220
 Fax: +41 21 785 9486
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] aggregate.formula: formula from string

2012-10-31 Thread arun
Hi Thorn,

May be it is a bug in aggregate.formula().  Not sure about it.

The solutions that I gave and yours were returning the colnames as NA.  

I guess this should be much better in terms of getting the result in one step.

 do.call(aggregate,list(mF,d,mean))
#  a b   y   z
#1 1 A -1.48354978 -0.37141485
#2 2 A -0.08862713  0.35359250
#3 3 A  1.17519518 -0.47595290
#4 1 B  0.10214686 -0.70005131
#5 2 B  0.41185154  0.03707291
#6 3 B  0.20507062 -0.67946389
A.K.




- Original Message -
From: Thaler,Thorn,LAUSANNE,Applied Mathematics thorn.tha...@rdls.nestle.com
To: arun smartpink...@yahoo.com
Cc: R help r-help@r-project.org
Sent: Wednesday, October 31, 2012 8:30 AM
Subject: RE: [R] aggregate.formula: formula from string

Dear Arun,

Thanks for your suggestion, that does the trick. Just because I'm curious, 
where does the problem come from? I figured that wrapping the formula object in 
brackets would work as well:

aggregate((mF), d, mean)

So I guess it has something to do with the scope of mF, or what is the root 
cause?

Thanks for your help!


KR,

-Thorn

 -Original Message-
 From: arun [mailto:smartpink...@yahoo.com]
 Sent: Mittwoch, 31. Oktober 2012 13:15
 To: Thaler,Thorn,LAUSANNE,Applied Mathematics
 Cc: R help
 Subject: Re: [R] aggregate.formula: formula from string
 
 Hi,
 Try this:
 res- aggregate(eval(mF),d,mean)
 
 res
 
 #  a b  NA  NA
 #1 1 A -1.48354978 -0.37141485
 #2 2 A -0.08862713  0.35359250
 #3 3 A  1.17519518 -0.47595290
 #4 1 B  0.10214686 -0.70005131
 #5 2 B  0.41185154  0.03707291
 #6 3 B  0.20507062 -0.67946389
 
 
 res1-aggregate(cbind(y, z) ~ a + b, d, mean)
 colnames(res)[3:4]-colnames(res1)[3:4]
  identical(res,res1)
 #[1] TRUE
 A.K.
 
 
 
 
 - Original Message -
 From: Thaler,Thorn,LAUSANNE,Applied Mathematics
 thorn.tha...@rdls.nestle.com
 To: r-help@r-project.org r-help@r-project.org
 Cc:
 Sent: Wednesday, October 31, 2012 5:46 AM
 Subject: [R] aggregate.formula: formula from string
 
 Dear all,
 
 I want to use aggregate.formula to conveniently summarize a data.frame. I have
 quiet some variables in the data.frame and thus I don't want to write all
 these names by hand, but instead create them on the fly. This approach has the
 advantage that if there will be even more columns in the data.frame I don't
 have to change the code.
 
 I've hence tried to construct a formula object and to pass that to aggregate:
 
 d - expand.grid(a = factor(1:3), b = factor(LETTERS[1:2]))
 d - rbind(d,d,d)
 d$y - rnorm(18)
 d$z - rnorm(18)
 mF - as.formula(paste(cbind(, paste(names(d)[-(1:2)], collapse = ,), ) ~
 a + b, sep = ))
 
 But if I try to pass that formula to aggregate
 
 aggregate(mF, d, mean)
 
 I get the following error:
 
 Error in m[[2L]][[2L]] : object of type 'symbol' is not subsettable
 
 But if I pass the formula directly:
 
 aggregate(cbind(y, z) ~ a + b, d, mean)
 
 Everything is working as expected.
 
 So I was wondering what went wrong? I know I could use a formula like . ~ a +
 b instead and this would work fine, but I'm just interested in why the
 outlined approach does not work as expected, and where my mistake lies? (that
 means in particular I am not asking for a solution of how to get the thing
 done - there are plenty of alternatives - but instead to understand why this
 very approach does not work)
 
 Thanks for your help!
 
 Kind Regards,
 
 Thorn Thaler
 Mathematician
 
 Applied Mathematics
 Nestec Ltd,
 Nestlé Research Center
 PO Box 44
 CH-1000 Lausanne 26
 Phone: +41 21 785 8220
 Fax: +41 21 785 9486
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] bootstrapping quantile regression

2012-10-31 Thread Roger Koenker
There is no automatic clustering option for QR bootstrapping.
You will have to roll your own.


url:www.econ.uiuc.edu/~rogerRoger Koenker
emailrkoen...@uiuc.eduDepartment of Economics
vox: 217-333-4558University of Illinois
fax:   217-244-6678Urbana, IL 61801

On Oct 31, 2012, at 1:38 AM, Kay Cichini wrote:

 sry, I forgot to replace rlm() - but actually I tried both and the question
 applies to both approaches..
 
 Am 31.10.2012 00:19 schrieb Kay Cichini kay.cich...@gmail.com:
 
 HI everyone,
 
 I try to get some bootstrap CIs for coefficients obtained by quantile
 regression. I have influencial values and thus switched to quantreg..
 The data is clustered and within clusters the variance of my DV = 0..
 
 Is this sensible for the below data? And what about the warnings?
 
 Thanks in advance for any guidance,
 Kay
 
 dput(d)
 structure(list(Porenfläche = c(4990L, 7002L, 7558L, 7352L, 7943L,
 7979L, 9333L, 8209L, 8393L, 6425L, 9364L, 8624L, 10651L, 8868L,
 9417L, 8874L, 10962L, 10743L, 11878L, 9867L, 7838L, 11876L, 12212L,
 8233L, 6360L, 4193L, 7416L, 5246L, 6509L, 4895L, 6775L, 7894L,
 5980L, 5318L, 7392L, 7894L, 3469L, 1468L, 3524L, 5267L, 5048L,
 1016L, 5605L, 8793L, 3475L, 1651L, 5514L, 9718L), P.Perimeter = c(2791.9,
 3892.6, 3930.66, 3869.32, 3948.54, 4010.15, 4345.75, 4344.75,
 3682.04, 3098.65, 4480.05, 3986.24, 4036.54, 3518.04, 3999.37,
 3629.07, 4608.66, 4787.62, 4864.22, 4479.41, 3428.74, 4353.14,
 4697.65, 3518.44, 1977.39, 1379.35, 1916.24, 1585.42, 1851.21,
 1239.66, 1728.14, 1461.06, 1426.76, 990.388, 1350.76, 1461.06,
 1376.7, 476.322, 1189.46, 1644.96, 941.543, 308.642, 1145.69,
 2280.49, 1174.11, 597.808, 1455.88, 1485.58), P.Form = c(0.0903296,
 0.148622, 0.183312, 0.117063, 0.122417, 0.167045, 0.189651, 0.164127,
 0.203654, 0.162394, 0.150944, 0.148141, 0.228595, 0.231623, 0.172567,
 0.153481, 0.204314, 0.262727, 0.200071, 0.14481, 0.113852, 0.291029,
 0.240077, 0.161865, 0.280887, 0.179455, 0.191802, 0.133083, 0.225214,
 0.341273, 0.311646, 0.276016, 0.197653, 0.326635, 0.154192, 0.276016,
 0.176969, 0.438712, 0.163586, 0.253832, 0.328641, 0.230081, 0.464125,
 0.420477, 0.200744, 0.262651, 0.182453, 0.200447), Durchlässigkeit =
 c(6.3,
 6.3, 6.3, 6.3, 17.1, 17.1, 17.1, 17.1, 119, 119, 119, 119, 82.4,
 82.4, 82.4, 82.4, 58.6, 58.6, 58.6, 58.6, 142, 142, 142, 142,
 740, 740, 740, 740, 890, 890, 890, 890, 950, 950, 950, 950, 100,
 100, 100, 100, 1300, 1300, 1300, 1300, 580, 580, 580, 580), Gebiete =
 structure(c(1L,
 1L, 1L, 1L, 2L, 2L, 2L, 2L, 6L, 6L, 6L, 6L, 4L, 4L, 4L, 4L, 3L,
 3L, 3L, 3L, 7L, 7L, 7L, 7L, 9L, 9L, 9L, 9L, 10L, 10L, 10L, 10L,
 11L, 11L, 11L, 11L, 5L, 5L, 5L, 5L, 12L, 12L, 12L, 12L, 8L, 8L,
 8L, 8L), .Label = c(6.3, 17.1, 58.6, 82.4, 100, 119,
 142, 580, 740, 890, 950, 1300), class = factor)), .Names =
 c(Porenfläche,
 P.Perimeter, P.Form, Durchlässigkeit, Gebiete), row.names =
 c(1,
 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
 47, 48), class = data.frame)
 
 ## do quantile regression and bootstrap the coefficients, allowing for
 clustered data
 ## by putting Gebiet as strata argument (?),
 ## dv variation within clusters/Gebiet = 0!
 bs - function(formula, data, indices) {
  d - data[indices, ] # allows boot to select sample
  fit - rlm(formula, data = d)
  return(coef(fit))
 }
 
 results - boot(data = d, statistic = bs, strata = d$Gebiete,
R = 199, formula = Durchlässigkeit ~ P.Perimeter + P.Form)
 
 # get 99% confidence intervals
 boot.ci(results, type=bca, index=1, conf = .99) # intercept
 boot.ci(results, type=bca, index=2, conf = .99) # P.Perimeter
 boot.ci(results, type=bca, index=3, conf = .99) # P.Form
 
 --
 
 Kay Cichini, MSc Biol
 
 Grubenweg 22, 6071 Aldrans
 
 E-Mail: kay.cich...@gmail.com
 --
 
 
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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

2012-10-31 Thread Roger Koenker
The rank test inversion option that you are trying to use won't
work with only one coefficient, and therefore with univariate
quantiles,  if you use summary(rq(rnorm(50) ~ 1, tau = .9), cov = TRUE)
you will have better luck.

url:www.econ.uiuc.edu/~rogerRoger Koenker
emailrkoen...@uiuc.eduDepartment of Economics
vox: 217-333-4558University of Illinois
fax:   217-244-6678Urbana, IL 61801

On Oct 30, 2012, at 9:42 AM, Koenker, Roger W wrote:

 Petr,
 
 You can  do:
 
 require(quantreg)
 summary(rq(x ~ 1, tau = c(.10,.50,.99))
 
 
 url:www.econ.uiuc.edu/~rogerRoger Koenker
 emailrkoen...@uiuc.eduDepartment of Economics
 vox: 217-333-4558University of Illinois
 fax:   217-244-6678Urbana, IL 61801
 
 On Oct 30, 2012, at 9:37 AM, Bert Gunter wrote:
 
 Petr:
 
 1. Not an R question.
 
 2. You want the distribution of order statistics. Search on that. It's
 basically binomial/beta.
 
 -- Bert
 
 On Tue, Oct 30, 2012 at 6:46 AM, PIKAL Petr petr.pi...@precheza.cz wrote:
 Dear all
 
 I have a question about quantiles standard error, partly practical
 partly theoretical. I know that
 
 x-rlnorm(10, log(200), log(2))
 quantile(x, c(.10,.5,.99))
 
 computes quantiles but I would like to know if there is any function to
 find standard error (or any dispersion measure) of these estimated
 values.
 
 And here is a theoretical one. I feel that when I compute median from
 given set of values it will have lower standard error then 0.1 quantile
 computed from the same set of values.
 
 Is it true? If yes can you point me to some reasoning?
 
 Thanks for all answers.
 Regards
 Petr
 
 PS.
 I found mcmcse package which shall compute the standard error but which
 I could not make to work probably because I do not have recent R-devel
 version installed
 
 Error in eval(expr, envir, enclos) :
 could not find function .getNamespace
 Error : unable to load R code in package 'mcmcse'
 Error: package/namespace load failed for 'mcmcse'
 
 Maybe I will also something find in quantreg package, but I did not
 went through it yet.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 
 
 -- 
 
 Bert Gunter
 Genentech Nonclinical Biostatistics
 
 Internal Contact Info:
 Phone: 467-7374
 Website:
 http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] issues with krige function

2012-10-31 Thread Adrienne Wootten
My apologies to all, the package is gstat that I am using not geoR.
thanks!
A

On Tue, Oct 30, 2012 at 1:35 PM, Adrienne Wootten amwoo...@ncsu.edu wrote:
 Greetings all,

 Ran into a strange problem with the krige function from geoR.  The
 problem that I am having is that while the krige function seems to
 work well, the resulting predicted values are all NAs.  Given the size
 of the datasets I am working with can't attach it, but I can provide
 snippets of the datasets.

 casedata
station year month day  obs mpebias type  lat   lon
 140  319147 2011 8  28 0.00 0.0  0. COOP 35.48667 
 -82.96833
 141  319354 2011 8  28 0.02 0.001305799 -0.01869420 COOP 34.25722 
 -78.68722
 142  319357 2011 8  28 0.00 0.045194085  0.04519409 COOP 34.40944 
 -78.79139
 143  319440 2011 8  28 6.92 5.530313974 -1.38968603 COOP 35.85278 
 -77.03056
 144  319461 2011 8  28 0.98 0.949224103 -0.03077590 COOP 34.14250 
 -77.87861
 145  319467 2011 8  28 0.30 1.492852601  1.19285260 COOP 34.32083 
 -77.92056
 146  319476 2011 8  28 2.95 3.284362345  0.33436235 COOP 35.69389 
 -77.94556
 147  319555 2011 8  28 0.00 0.0  0. COOP 36.13083 
 -81.22750
 148  319667 2011 8  28 0.00 0.014472943  0.01447294 COOP 35.85583 
 -80.36083
 149  319675 2011 8  28 0.00 0.0  0. COOP 36.13056 
 -80.54806

 v.fit = vgm(phi=1.2914,model=Mat,range=14.1611,nugget=0.23,kappa=83.1047)
 krige.pred.out = 
 krige(formula=bias~1,locations=~lon+lat,data=casedata,newdata=gridmeta,model=v.fit)
 [using ordinary kriging]

 krige.pred.out
lon  lat var1.pred var1.var
 1  -86.28771 33.91335   NaN  NaN
 2  -86.27388 33.94722   NaN  NaN
 3  -86.26003 33.98111   NaN  NaN
 4  -86.24615 34.01500   NaN  NaN
 5  -86.23225 34.04890   NaN  NaN
 6  -86.21835 34.08280   NaN  NaN
 7  -86.20441 34.11672   NaN  NaN
 8  -86.19045 34.15064   NaN  NaN
 9  -86.17648 34.18457   NaN  NaN
 10 -86.16249 34.21851   NaN  NaN

  summary(krige.pred.out)
   lon  lat var1.predvar1.var
  Min.   :-86.29   Min.   :30.51   Min.   : NA Min.   : NA
  1st Qu.:-82.38   1st Qu.:33.73   1st Qu.: NA 1st Qu.: NA
  Median :-79.88   Median :35.22   Median : NA Median : NA
  Mean   :-79.91   Mean   :35.26   Mean   :NaN Mean   :NaN
  3rd Qu.:-77.48   3rd Qu.:36.76   3rd Qu.: NA 3rd Qu.: NA
  Max.   :-73.16   Max.   :40.16   Max.   : NA Max.   : NA
NA's   :44408   NA's   :44408


 Any ideas are greatly appreciated, I'm not getting any warnings or
 errors from krige, so this is perplexing to me.

 --
 Adrienne Wootten
 Graduate Research Assistant
 State Climate Office of North Carolina
 Department of Marine, Earth and Atmospheric Sciences
 North Carolina State University



-- 
Adrienne Wootten
Graduate Research Assistant
State Climate Office of North Carolina
Department of Marine, Earth and Atmospheric Sciences
North Carolina State University

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

2012-10-31 Thread Frank Harrell
A piece of this is solved by the rms package's Rq and bootcov functions. 
-Frank

Roger Koenker-3 wrote
 There is no automatic clustering option for QR bootstrapping.
 You will have to roll your own.
 
 
 url:www.econ.uiuc.edu/~rogerRoger Koenker
 email

 rkoenker@

 Department of Economics
 vox: 217-333-4558University of Illinois
 fax:   217-244-6678Urbana, IL 61801
 
 On Oct 31, 2012, at 1:38 AM, Kay Cichini wrote:
 
 sry, I forgot to replace rlm() - but actually I tried both and the
 question
 applies to both approaches..
 
 Am 31.10.2012 00:19 schrieb Kay Cichini lt;

 kay.cichini@

 gt;:
 
 HI everyone,
 
 I try to get some bootstrap CIs for coefficients obtained by quantile
 regression. I have influencial values and thus switched to quantreg..
 The data is clustered and within clusters the variance of my DV = 0..
 
 Is this sensible for the below data? And what about the warnings?
 
 Thanks in advance for any guidance,
 Kay
 
 dput(d)
 structure(list(Porenfläche = c(4990L, 7002L, 7558L, 7352L, 7943L,
 7979L, 9333L, 8209L, 8393L, 6425L, 9364L, 8624L, 10651L, 8868L,
 9417L, 8874L, 10962L, 10743L, 11878L, 9867L, 7838L, 11876L, 12212L,
 8233L, 6360L, 4193L, 7416L, 5246L, 6509L, 4895L, 6775L, 7894L,
 5980L, 5318L, 7392L, 7894L, 3469L, 1468L, 3524L, 5267L, 5048L,
 1016L, 5605L, 8793L, 3475L, 1651L, 5514L, 9718L), P.Perimeter =
 c(2791.9,
 3892.6, 3930.66, 3869.32, 3948.54, 4010.15, 4345.75, 4344.75,
 3682.04, 3098.65, 4480.05, 3986.24, 4036.54, 3518.04, 3999.37,
 3629.07, 4608.66, 4787.62, 4864.22, 4479.41, 3428.74, 4353.14,
 4697.65, 3518.44, 1977.39, 1379.35, 1916.24, 1585.42, 1851.21,
 1239.66, 1728.14, 1461.06, 1426.76, 990.388, 1350.76, 1461.06,
 1376.7, 476.322, 1189.46, 1644.96, 941.543, 308.642, 1145.69,
 2280.49, 1174.11, 597.808, 1455.88, 1485.58), P.Form = c(0.0903296,
 0.148622, 0.183312, 0.117063, 0.122417, 0.167045, 0.189651, 0.164127,
 0.203654, 0.162394, 0.150944, 0.148141, 0.228595, 0.231623, 0.172567,
 0.153481, 0.204314, 0.262727, 0.200071, 0.14481, 0.113852, 0.291029,
 0.240077, 0.161865, 0.280887, 0.179455, 0.191802, 0.133083, 0.225214,
 0.341273, 0.311646, 0.276016, 0.197653, 0.326635, 0.154192, 0.276016,
 0.176969, 0.438712, 0.163586, 0.253832, 0.328641, 0.230081, 0.464125,
 0.420477, 0.200744, 0.262651, 0.182453, 0.200447), Durchlässigkeit =
 c(6.3,
 6.3, 6.3, 6.3, 17.1, 17.1, 17.1, 17.1, 119, 119, 119, 119, 82.4,
 82.4, 82.4, 82.4, 58.6, 58.6, 58.6, 58.6, 142, 142, 142, 142,
 740, 740, 740, 740, 890, 890, 890, 890, 950, 950, 950, 950, 100,
 100, 100, 100, 1300, 1300, 1300, 1300, 580, 580, 580, 580), Gebiete =
 structure(c(1L,
 1L, 1L, 1L, 2L, 2L, 2L, 2L, 6L, 6L, 6L, 6L, 4L, 4L, 4L, 4L, 3L,
 3L, 3L, 3L, 7L, 7L, 7L, 7L, 9L, 9L, 9L, 9L, 10L, 10L, 10L, 10L,
 11L, 11L, 11L, 11L, 5L, 5L, 5L, 5L, 12L, 12L, 12L, 12L, 8L, 8L,
 8L, 8L), .Label = c(6.3, 17.1, 58.6, 82.4, 100, 119,
 142, 580, 740, 890, 950, 1300), class = factor)), .Names =
 c(Porenfläche,
 P.Perimeter, P.Form, Durchlässigkeit, Gebiete), row.names =
 c(1,
 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
 47, 48), class = data.frame)
 
 ## do quantile regression and bootstrap the coefficients, allowing for
 clustered data
 ## by putting Gebiet as strata argument (?),
 ## dv variation within clusters/Gebiet = 0!
 bs - function(formula, data, indices) {
  d - data[indices, ] # allows boot to select sample
  fit - rlm(formula, data = d)
  return(coef(fit))
 }
 
 results - boot(data = d, statistic = bs, strata = d$Gebiete,
R = 199, formula = Durchlässigkeit ~ P.Perimeter +
 P.Form)
 
 # get 99% confidence intervals
 boot.ci(results, type=bca, index=1, conf = .99) # intercept
 boot.ci(results, type=bca, index=2, conf = .99) # P.Perimeter
 boot.ci(results, type=bca, index=3, conf = .99) # P.Form
 
 --
 
 Kay Cichini, MSc Biol
 
 Grubenweg 22, 6071 Aldrans
 
 E-Mail: 

 kay.cichini@

 --
 
 
 
  [[alternative HTML version deleted]]
 
 __
 

 R-help@

  mailing list
 https://stat.ethz.ch/mailman/listinfo/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@

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





-
Frank Harrell
Department of Biostatistics, Vanderbilt University
--
View this message in context: 
http://r.789695.n4.nabble.com/bootstrapping-quantile-regression-tp4647948p4648001.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list

[R] Mixed modelling course with R in Portugal

2012-10-31 Thread Highland Statistics Ltd


We would like to announce the following statistics course:

Introduction to linear mixed effects modelling course with R.
11 - 15 February 2013. Lisbon, Portugal.


For details, see: http://www.highstat.com/statscourse.htm
Course flyer: http://www.highstat.com/Courses/Flyer2013FebSIM_Lisbon.pdf


Kind regards,

Alain Zuur

--

Dr. Alain F. Zuur
First author of:

1. Analysing Ecological Data (2007).
Zuur, AF, Ieno, EN and Smith, GM. Springer. 680 p.
URL: www.springer.com/0-387-45967-7


2. Mixed effects models and extensions in ecology with R. (2009).
Zuur, AF, Ieno, EN, Walker, N, Saveliev, AA, and Smith, GM. Springer.
http://www.springer.com/life+sci/ecology/book/978-0-387-87457-9


3. A Beginner's Guide to R (2009).
Zuur, AF, Ieno, EN, Meesters, EHWG. Springer
http://www.springer.com/statistics/computational/book/978-0-387-93836-3


4. Zero Inflated Models and Generalized Linear Mixed Models with R. (2012) 
Zuur, Saveliev, Ieno.
http://www.highstat.com/book4.htm

Other books: http://www.highstat.com/books.htm


Statistical consultancy, courses, data analysis and software
Highland Statistics Ltd.
6 Laverock road
UK - AB41 6FN Newburgh
Tel: 0044 1358 788177
Email: highs...@highstat.com
URL: www.highstat.com
URL: www.brodgar.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] issues with krige function

2012-10-31 Thread ONKELINX, Thierry
Dear Adrienne,

What is the output of summary(casestudy) and summary(gridmeta)?

What happens if you set nmax to 10?
krige(formula=bias~1,locations=~lon+lat,data=casedata,newdata=gridmeta 
,model=v.fit, nmax = 10)

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

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

The plural of anecdote is not data.
~ Roger Brinner

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


-Oorspronkelijk bericht-
Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens 
Adrienne Wootten
Verzonden: dinsdag 30 oktober 2012 18:36
Aan: r-help@r-project.org
Onderwerp: [R] issues with krige function

Greetings all,

Ran into a strange problem with the krige function from geoR.  The problem that 
I am having is that while the krige function seems to work well, the resulting 
predicted values are all NAs.  Given the size of the datasets I am working with 
can't attach it, but I can provide snippets of the datasets.

 casedata
   station year month day  obs mpebias type  lat   lon
140  319147 2011 8  28 0.00 0.0  0. COOP 35.48667 -82.96833
141  319354 2011 8  28 0.02 0.001305799 -0.01869420 COOP 34.25722 -78.68722
142  319357 2011 8  28 0.00 0.045194085  0.04519409 COOP 34.40944 -78.79139
143  319440 2011 8  28 6.92 5.530313974 -1.38968603 COOP 35.85278 -77.03056
144  319461 2011 8  28 0.98 0.949224103 -0.03077590 COOP 34.14250 -77.87861
145  319467 2011 8  28 0.30 1.492852601  1.19285260 COOP 34.32083 -77.92056
146  319476 2011 8  28 2.95 3.284362345  0.33436235 COOP 35.69389 -77.94556
147  319555 2011 8  28 0.00 0.0  0. COOP 36.13083 -81.22750
148  319667 2011 8  28 0.00 0.014472943  0.01447294 COOP 35.85583 -80.36083
149  319675 2011 8  28 0.00 0.0  0. COOP 36.13056 -80.54806

 v.fit =
 vgm(phi=1.2914,model=Mat,range=14.1611,nugget=0.23,kappa=83.1047)
 krige.pred.out =
 krige(formula=bias~1,locations=~lon+lat,data=casedata,newdata=gridmeta
 ,model=v.fit)
[using ordinary kriging]

 krige.pred.out
   lon  lat var1.pred var1.var
1  -86.28771 33.91335   NaN  NaN
2  -86.27388 33.94722   NaN  NaN
3  -86.26003 33.98111   NaN  NaN
4  -86.24615 34.01500   NaN  NaN
5  -86.23225 34.04890   NaN  NaN
6  -86.21835 34.08280   NaN  NaN
7  -86.20441 34.11672   NaN  NaN
8  -86.19045 34.15064   NaN  NaN
9  -86.17648 34.18457   NaN  NaN
10 -86.16249 34.21851   NaN  NaN

  summary(krige.pred.out)
  lon  lat var1.predvar1.var
 Min.   :-86.29   Min.   :30.51   Min.   : NA Min.   : NA
 1st Qu.:-82.38   1st Qu.:33.73   1st Qu.: NA 1st Qu.: NA
 Median :-79.88   Median :35.22   Median : NA Median : NA
 Mean   :-79.91   Mean   :35.26   Mean   :NaN Mean   :NaN
 3rd Qu.:-77.48   3rd Qu.:36.76   3rd Qu.: NA 3rd Qu.: NA
 Max.   :-73.16   Max.   :40.16   Max.   : NA Max.   : NA
   NA's   :44408   NA's   :44408


Any ideas are greatly appreciated, I'm not getting any warnings or errors from 
krige, so this is perplexing to me.

--
Adrienne Wootten
Graduate Research Assistant
State Climate Office of North Carolina
Department of Marine, Earth and Atmospheric Sciences North Carolina State 
University

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

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


Re: [R] R crashing after successfully running compiled code

2012-10-31 Thread Adam Clark
Thanks for the advice.

I'll go ahead and dig through my C code. It's helpful to know that my C
code can cause R to crash AFTER successfully implementing the code.

I have made sure to account for C's vector indexing, and I think I'm
allocating my C memory, and passing information back and forth between C
and R, as I should. I'm including my input/output stuff below.

I tried including options(CBoundsCheck=TRUE) in the script both before and
after loading the C function, which doesn't seem to do much. To get it to
work, do I actually need to go into the R configuration file and edit the
default?

It would be exceedingly helpful if anybody could give me tips on where I'm
misusing pointers in the example below. That said, I certainly don't expect
the R community to debug my C code for me. If I come up with a solution,
I'll email it out over the list.

In R, I run the script:
dyn.load(mycfun.dll)
set.seed(1031)
A-1:100
B-runif(100)
myfunC-function(A, B, M, N) {
result-as.double(rep(0, (length(A)- N -(M+1
plengtht-as.integer(length(A))
Aest-as.numeric(rep(0, (length(A)- N -(M+1
distances-as.numeric(rep(0, length(A)))
neighbors-as.integer(rep(0, (M+1)))
u-as.numeric(rep(0, (M+1)))
w-as.numeric(rep(0, (M+1)))
return(.C(mycfun, as.double(A), as.double(B), as.integer(M),
as.integer(N),
result=as.double(result), as.integer(plengtht), as.double(Aest),
as.double(distances),
as.integer(neighbors), as.double(u), as.double(w))$result)
}

fun_result-myfunC(A,B,3,1)


This corresponds to the C code (input output only):
#include R.h
#include Rmath.h
void mycfun(double *A, double *B, int *pM, int *pN, double *result, int
*plengtht,
double *Aest, double *distances, int *neighbors, double *u, double *w) {
int t, i, j, n, from, to, nneigh;
double distsv, sumu, sumaest, corout;
int M = *pM;
int N = *pN;
int lengtht= *plengtht;
n=0;

# running various loops over variables #

result[n]=corout;
n=n+1;
}


# END #

I also have two sub-functions that manipulate neighbors and distances -
I can send the i/o for those as well, but they seem much more
straightforward, since I don't need to pass all my arguments as pointers. I
pass the pointers to internal variables at the beginning because I couldn't
index any C arrays using *pM or *pN.


Many thanks,
Adam



On Wed, Oct 31, 2012 at 7:12 AM, Prof Brian Ripley rip...@stats.ox.ac.ukwrote:

 On Wed, 31 Oct 2012, Duncan Murdoch wrote:

  On 12-10-30 11:13 PM, Adam Clark wrote:

 I'm running R 2.15.1x64, though the same problem persists for 2.13.0x32
 and
 2.13.0x64.

 I am trying to run compiled C code using the .C convention. The
 code compiles without problems, dynamically loads within the R
 workspace with no problems, and even runs and gives correct results with
 no problems.

 However, R will randomly crash within a few minutes of successfully using
 the compiled function.

 For example, if I run my compiled function using:
 dyn.load(mycfun.dll)
 answer-.C(mycfun, parameters...), I get a completely sensible
 result that gets stored to answer.
 However, if I try to do too many things to answer, the R exits
 without warning.
 I've tried dyn.unload in hopes that R would become stable afterwards, but
 in this case using the function crashes R without fail.

 Usually, I can either plot, or view, or save answer to a file - but
 never
 take more than a single action before R exits. This does not appear to
 depend on how long R has been open. Initially, I thought it was a bug in
 the inline function, but I'm finding the same problem now that I'm
 using
 the dynamically loaded file directly. I'm used to R being insanely
 stable,
 and am somewhat mystified by this whole problem.

 My next move is to learn the .Call convention, as I suspect that
 my problem is related to my C function using memory that R doesn't
 know is used. But - before I invest a while lot more time on this, I'd
 like to know whether anybody things this is likely to solve the problem.
 If not, I may just want to run my code entirely in C, and forget the
 R problem.


 I think your C code has a bug in it.  The bug might go away when you
 rewrite the function to work within the .Call convention, but it is
 probably easier to find the bug and fix it with the current code.

 Things to look for:

 Are you fully allocating all arrays in R before passing them to C?  The C
 code receives a pointer and will happily write to it, whether that makes
 sense or not.

 Are you careful with your limits on vectors?  In R, a vector is indexed
 from 1 to n, but the same vector in C is indexed from 0 to n-1.  If the C
 code writes to entry n, that will eventually cause problems.


 Using R-devel and the following new feature

 • There is a new option, options(CBoundsCheck=), which controls how
   .C() and .Fortran() pass arguments to compiled code.  If true
   (which can be enabled by setting the environment variable
   R_C_BOUNDS_CHECK to yes), raw, integer, double and complex
   arguments are 

[R] Snallball, rJava, and R 2.15.1

2012-10-31 Thread Triss.Ashton
I just bought a new machine and installed the latest release of R 2.15.1 two
days ago.  Loaded libraries yesterday (all reported successful loads). 
While running scripts, rJava and Snowball would not load.  Here is Snowball
successful install:


 utils:::menuInstallPkgs()
trying URL
'http://cran.cs.wwu.edu/bin/windows/contrib/2.15/Snowball_0.0-8.zip'
Content type 'application/zip' length 386840 bytes (377 Kb)
opened URL
downloaded 377 Kb

package ‘Snowball’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
C:\Users\Triss\AppData\Local\Temp\RtmpKsz7Qg\downloaded_packages
 


Here is rJava' successful install:

 utils:::menuInstallPkgs()
trying URL 'http://cran.cs.wwu.edu/bin/windows/contrib/2.15/rJava_0.9-3.zip'
Content type 'application/zip' length 746108 bytes (728 Kb)
opened URL
downloaded 728 Kb

package ‘rJava’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
C:\Users\Triss\AppData\Local\Temp\RtmpKsz7Qg\downloaded_packages
 

The directories for rJava and Snowball are viewable in the Libraries
directory.   Tried to run my scripts but rJava and Snowball failed to load
giving the following error when the libraries try to load:

 library(rJava)
Error : .onLoad failed in loadNamespace() for 'rJava', details:
  call: fun(libname, pkgname)
  error: JAVA_HOME cannot be determined from the Registry
Error: package/namespace load failed for ‘rJava’
 library(Snowball)
Error : .onLoad failed in loadNamespace() for 'Snowball', details:
  call: NULL
  error: .onLoad failed in loadNamespace() for 'rJava', details:
  call: fun(libname, pkgname)
  error: JAVA_HOME cannot be determined from the Registry
In addition: Warning message:
package ‘Snowball’ was built under R version 2.15.2 
Error: package/namespace load failed for ‘Snowball’
 

I then found a different copy of rJava on R-Force last night.  Installed it
and it seemed to fix the rJava problem.  However, Snowball continues to be a
problem:

  Error : .onLoad failed in loadNamespace() for 'Snowball', details:
  call: get(Info[i, 1], envir = env)
  error: internal error -3 in R_decompress1
In addition: Warning messages:
1: package ‘lsa’ was built under R version 2.15.2 
2: package ‘Snowball’ was built under R version 2.15.2 
Error: package ‘Snowball’ could not be loaded
 
 

To illustrate this problem, I reinstalled the rJava package from Cran this
morning.  After writing this up, went back to R-force to reinstall a working
copy of rJava, but it seems they have now pulled the rJava library so I am
now stuck with two broken libraries.  Thought the problem might be with R
2.15.1.  Installed 2.15.0 but same results.  One other point: at one time
last night there was a window popping up with a warning message - something
to do with Rf_copyListMatrix.  That window is not coming up this morning. 
Let me know if there is anything else you need to figure this out.

Thanks,

Triss



--
View this message in context: 
http://r.789695.n4.nabble.com/Snallball-rJava-and-R-2-15-1-tp4648007.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] Cannot rescale a constant/zero column error.

2012-10-31 Thread fillay89
I am trying to run the R Script below, I have actually simplified it to just
this part that is causing issues.  When I run this script I continue to get
an error that says cannot rescale a constant/zero column to a unit
variance.  I cannot figure out what is going on here.  I have stripped down
my data file so it is more manageable so I can try to figure this out.

The data.txt file that is being read looks like this:


I have made this file very basic on purpose to see if I could get this to
work, but it is not working.  Of course once I get this to actually work I
will expand the data file to match the data I am actually using.  



If I change the attribute in the prcomp function to scale=FALSE of course I
can run my script.  But if it is scaling...which is causing the issues, it
errors.

Any help would be GREATLY appreciated.



--
View this message in context: 
http://r.789695.n4.nabble.com/Cannot-rescale-a-constant-zero-column-error-tp4647996.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] Lavaan model

2012-10-31 Thread sylvain.giroud
Dear R-users,
Does somebody know what does the Estimate reported by the Lavaan model
tell us?
I assume this tells the relative strength of the dyadic relations. 
Thank you for your help!
Regards,
Sylvain



--
View this message in context: 
http://r.789695.n4.nabble.com/Lavaan-model-tp4648004.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] Mean Help

2012-10-31 Thread Hard Core
I have a dataframe.
Let's suppose that i have two columns. The first one contains height, the
second one contains eye color that can be Green, Blue or Brown.
I want to calculate the aritmetic mean of the height only for those people
who have Blue eyes. How can I do it?
Thank you for your availability.




--
View this message in context: 
http://r.789695.n4.nabble.com/Mean-Help-tp4648000.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] From summary function to formula

2012-10-31 Thread LordSword
Hi there!

I need to generate a final general linear model from a set of coefficients
of the variables within the summary function.
When I have the summary-function, HOW do I create a final model (response
variable = bla bla bla)?

LordSword



--
View this message in context: 
http://r.789695.n4.nabble.com/From-summary-function-to-formula-tp4648008.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] Forward and backward algorithm in R?

2012-10-31 Thread quantum
How can I wrtie and calculate alpha and beta in the forward backward
algorithm in R ? 



--
View this message in context: 
http://r.789695.n4.nabble.com/Forward-and-backward-algorithm-in-R-tp4648012.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] gamlss mu.start vector ?

2012-10-31 Thread Abiologist
Dear All,

I'd like to set up a loop whereby successive parameter values are used as
start values in gamlss (yes I know this isn't usually necessary ! -
unfortunately for my truncated data it is), to return the estimated
parameters etc. giving the lowest AIC value. 

I notice that mu.start can take a vector of values - but I can't find any
information as to what the function actually does with a vector of eg.
mu.start values - does it cycle through the values and then give the result
with the lowest AIC value ??
If it doesn't I'd appreciate any coding which has already been implemented
(presumably using for loops) to achieve the above.

Many thanks.




--
View this message in context: 
http://r.789695.n4.nabble.com/gamlss-mu-start-vector-tp4648010.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] Snallball, rJava, and R 2.15.1

2012-10-31 Thread Pascal Oettli

Hello,

It is said
 In addition: Warning messages:
 1: package ‘lsa’ was built under R version 2.15.2
 2: package ‘Snowball’ was built under R version 2.15.2

Install R 2.15.2 first.

Regards,
Pascal


Le 31/10/12 23:29, Triss.Ashton a écrit :

I just bought a new machine and installed the latest release of R 2.15.1 two
days ago.  Loaded libraries yesterday (all reported successful loads).
While running scripts, rJava and Snowball would not load.  Here is Snowball
successful install:



utils:::menuInstallPkgs()

trying URL
'http://cran.cs.wwu.edu/bin/windows/contrib/2.15/Snowball_0.0-8.zip'
Content type 'application/zip' length 386840 bytes (377 Kb)
opened URL
downloaded 377 Kb

package ‘Snowball’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
 C:\Users\Triss\AppData\Local\Temp\RtmpKsz7Qg\downloaded_packages





Here is rJava' successful install:


utils:::menuInstallPkgs()

trying URL 'http://cran.cs.wwu.edu/bin/windows/contrib/2.15/rJava_0.9-3.zip'
Content type 'application/zip' length 746108 bytes (728 Kb)
opened URL
downloaded 728 Kb

package ‘rJava’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
 C:\Users\Triss\AppData\Local\Temp\RtmpKsz7Qg\downloaded_packages




The directories for rJava and Snowball are viewable in the Libraries
directory.   Tried to run my scripts but rJava and Snowball failed to load
giving the following error when the libraries try to load:


library(rJava)

Error : .onLoad failed in loadNamespace() for 'rJava', details:
   call: fun(libname, pkgname)
   error: JAVA_HOME cannot be determined from the Registry
Error: package/namespace load failed for ‘rJava’

library(Snowball)

Error : .onLoad failed in loadNamespace() for 'Snowball', details:
   call: NULL
   error: .onLoad failed in loadNamespace() for 'rJava', details:
   call: fun(libname, pkgname)
   error: JAVA_HOME cannot be determined from the Registry
In addition: Warning message:
package ‘Snowball’ was built under R version 2.15.2
Error: package/namespace load failed for ‘Snowball’




I then found a different copy of rJava on R-Force last night.  Installed it
and it seemed to fix the rJava problem.  However, Snowball continues to be a
problem:

   Error : .onLoad failed in loadNamespace() for 'Snowball', details:
   call: get(Info[i, 1], envir = env)
   error: internal error -3 in R_decompress1
In addition: Warning messages:
1: package ‘lsa’ was built under R version 2.15.2
2: package ‘Snowball’ was built under R version 2.15.2
Error: package ‘Snowball’ could not be loaded





To illustrate this problem, I reinstalled the rJava package from Cran this
morning.  After writing this up, went back to R-force to reinstall a working
copy of rJava, but it seems they have now pulled the rJava library so I am
now stuck with two broken libraries.  Thought the problem might be with R
2.15.1.  Installed 2.15.0 but same results.  One other point: at one time
last night there was a window popping up with a warning message - something
to do with Rf_copyListMatrix.  That window is not coming up this morning.
Let me know if there is anything else you need to figure this out.

Thanks,

Triss



--
View this message in context: 
http://r.789695.n4.nabble.com/Snallball-rJava-and-R-2-15-1-tp4648007.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] Forward and backward algorithm in R?

2012-10-31 Thread R. Michael Weylandt
On Wed, Oct 31, 2012 at 2:50 PM, quantum quan...@live.dk wrote:
 How can I wrtie and calculate alpha and beta in the forward backward
 algorithm in R ?

You might need to be more specific Here's a smattering of links
you should probably look into as well:

http://r-manuals.flakery.org/R-intro.html

http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example

www.catb.org/esr/faqs/smart-questions.html
http://mattgemmell.com/2008/12/08/what-have-you-tried/



Finally, I note you're posting from Nabble. Please include context in
your reply -- I don't believe Nabble does this automatically, so
you'll need to manually include it. Most of the regular respondents on
this list don't use Nabble -- it is a _mailing list_ after all -- so
we don't get the forum view you do, only emails of the individual
posts. Combine that with the high volume of posts, and it's quite
difficult to trace a discussion if we all don't make sure to include
context.

Michael

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

2012-10-31 Thread R. Michael Weylandt
Many forms, but I'll recommend this one this time around:

aggregate(height ~ eyes, DATA, mean)

See ?aggregate for an explanation of what aggregate() does and
?formula for an explanation of the tilde syntax.

Note that this assumes your column names are height and eyes.
Adjust as needed.

Michael

On Wed, Oct 31, 2012 at 1:18 PM, Hard Core gi...@hotmail.it wrote:
 I have a dataframe.
 Let's suppose that i have two columns. The first one contains height, the
 second one contains eye color that can be Green, Blue or Brown.
 I want to calculate the aritmetic mean of the height only for those people
 who have Blue eyes. How can I do it?
 Thank you for your availability.




 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Mean-Help-tp4648000.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] Snallball, rJava, and R 2.15.1

2012-10-31 Thread Prof Brian Ripley

You forgot to install a JRE (Java runtime).

And please use R 2.15.2, which is current, if you are installing from 
scratch.  Some packages built with 2.15.2 (e.g. Matrix) do not work with 
2.15.[01].


rJava is on CRAN/rforge.net, not 'R-force' (sic).

 PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html


which includes updating your R before posting.

On 31/10/2012 14:29, Triss.Ashton wrote:

I just bought a new machine and installed the latest release of R 2.15.1 two
days ago.  Loaded libraries yesterday (all reported successful loads).
While running scripts, rJava and Snowball would not load.  Here is Snowball
successful install:



utils:::menuInstallPkgs()

trying URL
'http://cran.cs.wwu.edu/bin/windows/contrib/2.15/Snowball_0.0-8.zip'
Content type 'application/zip' length 386840 bytes (377 Kb)
opened URL
downloaded 377 Kb

package ‘Snowball’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
 C:\Users\Triss\AppData\Local\Temp\RtmpKsz7Qg\downloaded_packages





Here is rJava' successful install:


utils:::menuInstallPkgs()

trying URL 'http://cran.cs.wwu.edu/bin/windows/contrib/2.15/rJava_0.9-3.zip'
Content type 'application/zip' length 746108 bytes (728 Kb)
opened URL
downloaded 728 Kb

package ‘rJava’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
 C:\Users\Triss\AppData\Local\Temp\RtmpKsz7Qg\downloaded_packages




The directories for rJava and Snowball are viewable in the Libraries
directory.   Tried to run my scripts but rJava and Snowball failed to load
giving the following error when the libraries try to load:


library(rJava)

Error : .onLoad failed in loadNamespace() for 'rJava', details:
   call: fun(libname, pkgname)
   error: JAVA_HOME cannot be determined from the Registry
Error: package/namespace load failed for ‘rJava’

library(Snowball)

Error : .onLoad failed in loadNamespace() for 'Snowball', details:
   call: NULL
   error: .onLoad failed in loadNamespace() for 'rJava', details:
   call: fun(libname, pkgname)
   error: JAVA_HOME cannot be determined from the Registry
In addition: Warning message:
package ‘Snowball’ was built under R version 2.15.2
Error: package/namespace load failed for ‘Snowball’




I then found a different copy of rJava on R-Force last night.  Installed it
and it seemed to fix the rJava problem.  However, Snowball continues to be a
problem:

   Error : .onLoad failed in loadNamespace() for 'Snowball', details:
   call: get(Info[i, 1], envir = env)
   error: internal error -3 in R_decompress1
In addition: Warning messages:
1: package ‘lsa’ was built under R version 2.15.2
2: package ‘Snowball’ was built under R version 2.15.2
Error: package ‘Snowball’ could not be loaded





To illustrate this problem, I reinstalled the rJava package from Cran this
morning.  After writing this up, went back to R-force to reinstall a working
copy of rJava, but it seems they have now pulled the rJava library so I am
now stuck with two broken libraries.  Thought the problem might be with R
2.15.1.  Installed 2.15.0 but same results.  One other point: at one time
last night there was a window popping up with a warning message - something
to do with Rf_copyListMatrix.  That window is not coming up this morning.
Let me know if there is anything else you need to figure this out.

Thanks,

Triss



--
View this message in context: 
http://r.789695.n4.nabble.com/Snallball-rJava-and-R-2-15-1-tp4648007.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.




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

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


Re: [R] HELP!! how to remove 10% of data randomly in R

2012-10-31 Thread Nordlund, Dan (DSHS/RDA)
 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
 project.org] On Behalf Of Eugenie
 Sent: Wednesday, October 31, 2012 5:42 AM
 To: r-help@r-project.org
 Subject: Re: [R] HELP!! how to remove 10% of data randomly in R
 
   tDate tTimeO3   No2 Temp Sun Wspeed Wdirect Hum Indicator
 119980101  2400 0.065 0.036 31.4 7659.9 351  NA 1
 219980102  2400 0.053 0.025 31.8 6247.7 351  NA 1
 319980103  2400 0.027 0.033 31.5 8528.8 331  NA 2
 419980104  2400 0.034 0.023 30.7 6797.0 338  NA 2
 519980105  2400 0.019 0.016 28.1 3769.6 354  NA 1
 619980106  2400 0.021 0.018 29.9 6039.3 356  NA 1
 719980107  2400 0.026 0.047 31.2 857   10.7 336  NA 1
 819980108  2400 0.024 0.014 31.1 6357.8 330  NA 1
 919980109  2400 0.058 0.033 32.5 742   10.7 334  NA 1
 10   19980110  2400 0.026 0.032 33.9 923   10.6 347  NA 2
 11   19980111  2400 0.064 0.034 32.5 7516.3 355  NA 2
 12   19980112  2400 0.066 0.034 33.3 6978.5 319  NA 1
 13   19980113  2400 0.026 0.030 33.4 992   12.5 341  NA 1
 14   19980114  2400 0.101 0.028 33.8 7058.7 349  NA 1
 15   19980115  2400 0.069 0.030 33.3 718   11.4 348  NA 1
 16   19980116  2400 0.054 0.026 33.4 639   10.9 354  NA 1
 17   19980117  2400 0.090 0.039 33.1 653   13.2 342  NA 2
 18   19980118  2400 0.048 0.017 33.2 825   10.8 323  NA 2
 19   19980119  2400 0.038 0.027 33.7 984   10.3 353  NA 1
 20   19980120  2400 0.026 0.032 34.2 994   15.0 357  NA 1
 21   19980121  2400 0.065 0.044 33.8 999   17.5 343  NA 1
 22   19980122  2400 0.046 0.024 33.5 931   10.1 332  NA 1
 23   19980123  2400 0.050 0.041 33.9 881   11.3 353  NA 1
 24   19980124  2400 0.036 0.027 33.8 8779.1 328  NA 2
 25   19980125  2400 0.043 0.021 33.2 777   10.5 340  NA 2
 26   19980126  2400 0.029 0.016 33.1 999   14.1 341  NA 1
 27   19980127  2400 0.033 0.030 33.9 943   12.9 344  NA 1
 28   19980128  2400 0.040 0.022 33.7 805   12.6 354  NA 1
 29   19980129  2400 0.029 0.015 30.2 5127.4 356  NA 1
 30   19980130  2400 0.027 0.013 31.7 656   13.9 349  NA 1
 
 
 
 if given data like this,how to remove the data in
 O3,NO2,sun,temp,wspeed
 randomly??(missing values in these rows  columns)
 
 

If your data frame is called dat, then something like this may do what you 
want, but since you haven't given an example of what you want the output to 
look like I am only guessing.

dat[sample(1:30,5),3:8] - NA


hope this is helpful,

Dan

Daniel J. Nordlund
Olympia, WA 98504-5204


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

2012-10-31 Thread Jessica Streicher
please provide a bit of the dataframe in the future using the dput() function

 x-data.frame(height=1:10, 
 color=sample(c(blue,green,brown),10,replace=T))
 x
   height color
1   1  blue
2   2 green
3   3  blue
4   4 brown
5   5  blue
6   6 brown
7   7 green
8   8 brown
9   9 green
10 10 brown

 blue.eyes - x[x$color==blue, ]
 blue.eyes
  height color
1  1  blue
3  3  blue
5  5  blue

should create a new dataframe with only those that have blue eyes, then

 mean(blue.eyes$height)
[1] 3

should provide you with the mean of those.

On 31.10.2012, at 14:18, Hard Core wrote:

 I have a dataframe.
 Let's suppose that i have two columns. The first one contains height, the
 second one contains eye color that can be Green, Blue or Brown.
 I want to calculate the aritmetic mean of the height only for those people
 who have Blue eyes. How can I do it?
 Thank you for your availability.
 
 
 
 
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Mean-Help-tp4648000.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] R crashing after successfully running compiled code

2012-10-31 Thread Adam Clark
Aha - got it.

My problem was that I had a pointer (*Aest) that had less memory allocated
to it than I ended up storing in it (e.g. I had *Aest = 1:100, but stored
into it values at positions 5:105). With that fixed, all works flawlessly.

Thanks a lot for the help. What I hadn't realized was that .C allowed you
to exceed memory allocations - I'd have assumed that it would just crash
while I was running the function as soon as it ran out of space. Instead, I
guess it must have been writing beyond the space allocated for *Aest, and
not running into any trouble until R tried to store something else in the
same spot later (e.g. while plotting a figure).

It was immensely helpful to hear from you all that the function could still
have a bug, even if it ran successfully. As I understand it, the way
.Call passes variables, this sort of a mistake would not be possible. Is
this true? I'm tempted to learn the new syntax, but I also like how .C
allows me to keep things looking more or less like normal C code.

Adam

PS - As you mention, Prof. Ripley, I am insane for trying to do this
without a good debugger. Also, as you point out, valgrind doesn't run on
Cygwin. If you know of any useful PC debuggers, I'd be most grateful - but
if all else fails for debugging, I can just run Ubuntu in an Oracle
VirtualBox.

On Wed, Oct 31, 2012 at 9:38 AM, Adam Clark atcl...@umn.edu wrote:

 Thanks for the advice.

 I'll go ahead and dig through my C code. It's helpful to know that my C
 code can cause R to crash AFTER successfully implementing the code.

 I have made sure to account for C's vector indexing, and I think I'm
 allocating my C memory, and passing information back and forth between C
 and R, as I should. I'm including my input/output stuff below.

 I tried including options(CBoundsCheck=TRUE) in the script both before
 and after loading the C function, which doesn't seem to do much. To get it
 to work, do I actually need to go into the R configuration file and edit
 the default?

 It would be exceedingly helpful if anybody could give me tips on where I'm
 misusing pointers in the example below. That said, I certainly don't expect
 the R community to debug my C code for me. If I come up with a solution,
 I'll email it out over the list.

 In R, I run the script:
 dyn.load(mycfun.dll)
 set.seed(1031)
 A-1:100
 B-runif(100)
 myfunC-function(A, B, M, N) {
 result-as.double(rep(0, (length(A)- N -(M+1
  plengtht-as.integer(length(A))
 Aest-as.numeric(rep(0, (length(A)- N -(M+1
  distances-as.numeric(rep(0, length(A)))
 neighbors-as.integer(rep(0, (M+1)))
  u-as.numeric(rep(0, (M+1)))
 w-as.numeric(rep(0, (M+1)))
  return(.C(mycfun, as.double(A), as.double(B), as.integer(M),
 as.integer(N),
 result=as.double(result), as.integer(plengtht), as.double(Aest),
 as.double(distances),
  as.integer(neighbors), as.double(u), as.double(w))$result)
 }

 fun_result-myfunC(A,B,3,1)


 This corresponds to the C code (input output only):
 #include R.h
 #include Rmath.h
 void mycfun(double *A, double *B, int *pM, int *pN, double *result, int
 *plengtht,
 double *Aest, double *distances, int *neighbors, double *u, double *w) {
 int t, i, j, n, from, to, nneigh;
 double distsv, sumu, sumaest, corout;
 int M = *pM;
 int N = *pN;
 int lengtht= *plengtht;
 n=0;

 # running various loops over variables #

 result[n]=corout;
 n=n+1;
 }


 # END #

 I also have two sub-functions that manipulate neighbors and distances
 - I can send the i/o for those as well, but they seem much more
 straightforward, since I don't need to pass all my arguments as pointers. I
 pass the pointers to internal variables at the beginning because I couldn't
 index any C arrays using *pM or *pN.


 Many thanks,
 Adam



 On Wed, Oct 31, 2012 at 7:12 AM, Prof Brian Ripley 
 rip...@stats.ox.ac.ukwrote:

 On Wed, 31 Oct 2012, Duncan Murdoch wrote:

  On 12-10-30 11:13 PM, Adam Clark wrote:

 I'm running R 2.15.1x64, though the same problem persists for 2.13.0x32
 and
 2.13.0x64.

 I am trying to run compiled C code using the .C convention. The
 code compiles without problems, dynamically loads within the R
 workspace with no problems, and even runs and gives correct results with
 no problems.

 However, R will randomly crash within a few minutes of successfully
 using
 the compiled function.

 For example, if I run my compiled function using:
 dyn.load(mycfun.dll)
 answer-.C(mycfun, parameters...), I get a completely sensible
 result that gets stored to answer.
 However, if I try to do too many things to answer, the R exits
 without warning.
 I've tried dyn.unload in hopes that R would become stable afterwards,
 but
 in this case using the function crashes R without fail.

 Usually, I can either plot, or view, or save answer to a file - but
 never
 take more than a single action before R exits. This does not appear to
 depend on how long R has been open. Initially, I thought it was a bug in
 the inline function, but I'm finding the same problem now 

Re: [R] issues with krige function

2012-10-31 Thread Adrienne Wootten
Thierry, To answer your first question

summary(casedata)
   station   year  monthday  obs
   mpe
 Length:236 Min.   :2011   Min.   :8   Min.   :28   Min.
:0.   Min.   :0.0
 Class :character   1st Qu.:2011   1st Qu.:8   1st Qu.:28   1st
Qu.:0.   1st Qu.:0.0
 Mode  :character   Median :2011   Median :8   Median :28   Median
:0.   Median :0.0
Mean   :2011   Mean   :8   Mean   :28   Mean
:0.6119   Mean   :0.60163
3rd Qu.:2011   3rd Qu.:8   3rd Qu.:28   3rd
Qu.:0.0225   3rd Qu.:0.03953
Max.   :2011   Max.   :8   Max.   :28   Max.
:9.3600   Max.   :9.05766
  bias  typelat lon
 city
 Min.   :-4.75583   Length:236 Min.   :33.53   Min.   :-84.84
 Length:236
 1st Qu.: 0.0   Class :character   1st Qu.:34.37   1st Qu.:-82.71
 Class :character
 Median : 0.0   Mode  :character   Median :35.06   Median :-81.18
 Mode  :character
 Mean   :-0.01028  Mean   :35.18   Mean   :-81.00
 3rd Qu.: 0.03rd Qu.:35.99   3rd Qu.:-79.37
 Max.   : 2.82117  Max.   :36.98   Max.   :-76.33
statepreciptime
 Length:236 Length:236
 Class :character   Class :character
 Mode  :character   Mode  :character

  summary(gridmeta)
  lon  latxcell ycell
 row  col
 Min.   :-86.29   Min.   :30.51   Min.   :1895112   Min.   :-6545105
Min.   :  1.00   Min.   :  1.0
 1st Qu.:-82.38   1st Qu.:33.73   1st Qu.:2184464   1st Qu.:-6330770
1st Qu.: 61.75   1st Qu.: 46.0
 Median :-79.88   Median :35.22   Median :2473816   Median :-6114053
Median :122.50   Median : 91.5
 Mean   :-79.91   Mean   :35.26   Mean   :2473816   Mean   :-6114053
Mean   :122.50   Mean   : 91.5
 3rd Qu.:-77.48   3rd Qu.:36.76   3rd Qu.:2763169   3rd Qu.:-5897337
3rd Qu.:183.25   3rd Qu.:137.0
 Max.   :-73.16   Max.   :40.16   Max.   :3052521   Max.   :-5683002
Max.   :244.00   Max.   :182.0


To answer your second question, I'm not quite sure why, but apparently
constraining nmax like that was exactly what it needed, because now it
is producing values.
v.fit = vgm(psill=1.2914,model=Mat,range=14.1611,nugget=0.23,kappa=83.1047)
krige.pred.out =
krige(formula=bias~1,locations=~lon+lat,data=casedata,newdata=gridmeta,model=v.fit)
summary(krige.pred.out)

  lon  lat var1.pred var1.var
 Min.   :-86.29   Min.   :30.51   Min.   :-1.083   Min.   :0.253
 1st Qu.:-82.38   1st Qu.:33.73   1st Qu.:-0.044   1st Qu.:0.253
 Median :-79.88   Median :35.22   Median : 0.000   Median :0.253
 Mean   :-79.91   Mean   :35.26   Mean   :-0.051   Mean   :0.253
 3rd Qu.:-77.48   3rd Qu.:36.76   3rd Qu.: 0.000   3rd Qu.:0.253
 Max.   :-73.16   Max.   :40.16   Max.   : 1.252   Max.   :0.254
   NA's   :14925NA's   :31483

Thanks for the help.

Adrienne


On Wed, Oct 31, 2012 at 10:28 AM, ONKELINX, Thierry
thierry.onkel...@inbo.be wrote:
 Dear Adrienne,

 What is the output of summary(casestudy) and summary(gridmeta)?

 What happens if you set nmax to 10?
 krige(formula=bias~1,locations=~lon+lat,data=casedata,newdata=gridmeta 
 ,model=v.fit, nmax = 10)

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

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

 The plural of anecdote is not data.
 ~ Roger Brinner

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


 -Oorspronkelijk bericht-
 Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] 
 Namens Adrienne Wootten
 Verzonden: dinsdag 30 oktober 2012 18:36
 Aan: r-help@r-project.org
 Onderwerp: [R] issues with krige function

 Greetings all,

 Ran into a strange problem with the krige function from geoR.  The problem 
 that I am having is that while the krige function seems to work well, the 
 resulting predicted values are all NAs.  Given the size of the datasets I am 
 working with can't attach it, but I can provide snippets of the datasets.

 casedata
station year month day  obs mpebias type  lat   lon
 140  319147 2011 8  28 0.00 0.0  0. COOP 35.48667 
 -82.96833
 141  319354 2011 8  28 0.02 0.001305799 -0.01869420 COOP 34.25722 
 -78.68722
 142  319357 2011 8  28 0.00 0.045194085  0.04519409 COOP 34.40944 
 -78.79139
 143  319440 2011 8  28 6.92 5.530313974 -1.38968603 COOP 35.85278 
 

Re: [R] HELP!! how to remove 10% of data randomly in R

2012-10-31 Thread David Winsemius

On Oct 31, 2012, at 5:42 AM, Eugenie wrote:

  tDate tTimeO3   No2 Temp Sun Wspeed Wdirect Hum Indicator
 119980101  2400 0.065 0.036 31.4 7659.9 351  NA 1
 219980102  2400 0.053 0.025 31.8 6247.7 351  NA 1
 319980103  2400 0.027 0.033 31.5 8528.8 331  NA 2
 419980104  2400 0.034 0.023 30.7 6797.0 338  NA 2
 519980105  2400 0.019 0.016 28.1 3769.6 354  NA 1
 619980106  2400 0.021 0.018 29.9 6039.3 356  NA 1
 719980107  2400 0.026 0.047 31.2 857   10.7 336  NA 1
 819980108  2400 0.024 0.014 31.1 6357.8 330  NA 1
 919980109  2400 0.058 0.033 32.5 742   10.7 334  NA 1
 10   19980110  2400 0.026 0.032 33.9 923   10.6 347  NA 2
 11   19980111  2400 0.064 0.034 32.5 7516.3 355  NA 2
 12   19980112  2400 0.066 0.034 33.3 6978.5 319  NA 1
 13   19980113  2400 0.026 0.030 33.4 992   12.5 341  NA 1
 14   19980114  2400 0.101 0.028 33.8 7058.7 349  NA 1
 15   19980115  2400 0.069 0.030 33.3 718   11.4 348  NA 1
 16   19980116  2400 0.054 0.026 33.4 639   10.9 354  NA 1
 17   19980117  2400 0.090 0.039 33.1 653   13.2 342  NA 2
 18   19980118  2400 0.048 0.017 33.2 825   10.8 323  NA 2
 19   19980119  2400 0.038 0.027 33.7 984   10.3 353  NA 1
 20   19980120  2400 0.026 0.032 34.2 994   15.0 357  NA 1
 21   19980121  2400 0.065 0.044 33.8 999   17.5 343  NA 1
 22   19980122  2400 0.046 0.024 33.5 931   10.1 332  NA 1
 23   19980123  2400 0.050 0.041 33.9 881   11.3 353  NA 1
 24   19980124  2400 0.036 0.027 33.8 8779.1 328  NA 2
 25   19980125  2400 0.043 0.021 33.2 777   10.5 340  NA 2
 26   19980126  2400 0.029 0.016 33.1 999   14.1 341  NA 1
 27   19980127  2400 0.033 0.030 33.9 943   12.9 344  NA 1
 28   19980128  2400 0.040 0.022 33.7 805   12.6 354  NA 1
 29   19980129  2400 0.029 0.015 30.2 5127.4 356  NA 1
 30   19980130  2400 0.027 0.013 31.7 656   13.9 349  NA 1
 
 
 
 if given data like this,how to remove the data in O3,NO2,sun,temp,wspeed
 randomly??(missing values in these rows  columns)

Not clear whether those entries are to be NA or that you wanted a reduced size 
dataframe. Perhaps:


is.na(dfrm[ sample(1:NROW(dfrm) , c('O3','NO2','sun','temp','wspeed')]) - TRUE

Note that the spellings of your column names and specified targets are not the 
same, and so there is a further problem with you problem specification.

-- 

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] Cannot rescale a constant/zero column error.

2012-10-31 Thread David Winsemius

On Oct 31, 2012, at 5:47 AM, fillay89 wrote:

 I am trying to run the R Script below,

There is no script (or data description)  appearing in this posting to the 
Rhelp Mailing List. Nabble is not Rhelp, despite Nabble's effort to get you to 
think it is an archive. Please review the Posting Guide that I know you were 
offered when you posted from Nabble.

Yes, we could view this in Nabble, but most of us choose not to do so. This is 
a technical mailing list, not a website or chat-room.
-- 
David.


 I have actually simplified it to just
 this part that is causing issues.  When I run this script I continue to get
 an error that says cannot rescale a constant/zero column to a unit
 variance.  I cannot figure out what is going on here.  I have stripped down
 my data file so it is more manageable so I can try to figure this out.
 
 The data.txt file that is being read looks like this:
 
 
 I have made this file very basic on purpose to see if I could get this to
 work, but it is not working.  Of course once I get this to actually work I
 will expand the data file to match the data I am actually using.  
 
 
 
 If I change the attribute in the prcomp function to scale=FALSE of course I
 can run my script.  But if it is scaling...which is causing the issues, it
 errors.
 
 Any help would be GREATLY appreciated.
 
 
 
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Cannot-rescale-a-constant-zero-column-error-tp4647996.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.

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] R crashing after successfully running compiled code

2012-10-31 Thread William Dunlap
As long as you use C (or C++ or Fortran ...), using memory that
you don't own is possible.  This is one reason people use languages
like R.

(If you program microprocessors or write operating system code
then C's willingness to let you read or write any at address is essential.)

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 Adam Clark
 Sent: Wednesday, October 31, 2012 8:47 AM
 To: Adam Clark
 Cc: r-help@r-project.org; Prof Brian Ripley
 Subject: Re: [R] R crashing after successfully running compiled code
 
 Aha - got it.
 
 My problem was that I had a pointer (*Aest) that had less memory allocated
 to it than I ended up storing in it (e.g. I had *Aest = 1:100, but stored
 into it values at positions 5:105). With that fixed, all works flawlessly.
 
 Thanks a lot for the help. What I hadn't realized was that .C allowed you
 to exceed memory allocations - I'd have assumed that it would just crash
 while I was running the function as soon as it ran out of space. Instead, I
 guess it must have been writing beyond the space allocated for *Aest, and
 not running into any trouble until R tried to store something else in the
 same spot later (e.g. while plotting a figure).
 
 It was immensely helpful to hear from you all that the function could still
 have a bug, even if it ran successfully. As I understand it, the way
 .Call passes variables, this sort of a mistake would not be possible. Is
 this true? I'm tempted to learn the new syntax, but I also like how .C
 allows me to keep things looking more or less like normal C code.
 
 Adam
 
 PS - As you mention, Prof. Ripley, I am insane for trying to do this
 without a good debugger. Also, as you point out, valgrind doesn't run on
 Cygwin. If you know of any useful PC debuggers, I'd be most grateful - but
 if all else fails for debugging, I can just run Ubuntu in an Oracle
 VirtualBox.
 
 On Wed, Oct 31, 2012 at 9:38 AM, Adam Clark atcl...@umn.edu wrote:
 
  Thanks for the advice.
 
  I'll go ahead and dig through my C code. It's helpful to know that my C
  code can cause R to crash AFTER successfully implementing the code.
 
  I have made sure to account for C's vector indexing, and I think I'm
  allocating my C memory, and passing information back and forth between C
  and R, as I should. I'm including my input/output stuff below.
 
  I tried including options(CBoundsCheck=TRUE) in the script both before
  and after loading the C function, which doesn't seem to do much. To get it
  to work, do I actually need to go into the R configuration file and edit
  the default?
 
  It would be exceedingly helpful if anybody could give me tips on where I'm
  misusing pointers in the example below. That said, I certainly don't expect
  the R community to debug my C code for me. If I come up with a solution,
  I'll email it out over the list.
 
  In R, I run the script:
  dyn.load(mycfun.dll)
  set.seed(1031)
  A-1:100
  B-runif(100)
  myfunC-function(A, B, M, N) {
  result-as.double(rep(0, (length(A)- N -(M+1
   plengtht-as.integer(length(A))
  Aest-as.numeric(rep(0, (length(A)- N -(M+1
   distances-as.numeric(rep(0, length(A)))
  neighbors-as.integer(rep(0, (M+1)))
   u-as.numeric(rep(0, (M+1)))
  w-as.numeric(rep(0, (M+1)))
   return(.C(mycfun, as.double(A), as.double(B), as.integer(M),
  as.integer(N),
  result=as.double(result), as.integer(plengtht), as.double(Aest),
  as.double(distances),
   as.integer(neighbors), as.double(u), as.double(w))$result)
  }
 
  fun_result-myfunC(A,B,3,1)
 
 
  This corresponds to the C code (input output only):
  #include R.h
  #include Rmath.h
  void mycfun(double *A, double *B, int *pM, int *pN, double *result, int
  *plengtht,
  double *Aest, double *distances, int *neighbors, double *u, double *w) {
  int t, i, j, n, from, to, nneigh;
  double distsv, sumu, sumaest, corout;
  int M = *pM;
  int N = *pN;
  int lengtht= *plengtht;
  n=0;
 
  # running various loops over variables #
 
  result[n]=corout;
  n=n+1;
  }
 
 
  # END #
 
  I also have two sub-functions that manipulate neighbors and distances
  - I can send the i/o for those as well, but they seem much more
  straightforward, since I don't need to pass all my arguments as pointers. I
  pass the pointers to internal variables at the beginning because I couldn't
  index any C arrays using *pM or *pN.
 
 
  Many thanks,
  Adam
 
 
 
  On Wed, Oct 31, 2012 at 7:12 AM, Prof Brian Ripley 
  rip...@stats.ox.ac.ukwrote:
 
  On Wed, 31 Oct 2012, Duncan Murdoch wrote:
 
   On 12-10-30 11:13 PM, Adam Clark wrote:
 
  I'm running R 2.15.1x64, though the same problem persists for 2.13.0x32
  and
  2.13.0x64.
 
  I am trying to run compiled C code using the .C convention. The
  code compiles without problems, dynamically loads within the R
  workspace with no problems, and even runs and gives correct results with
  no problems.
 
  

Re: [R] Snallball, rJava, and R 2.15.1

2012-10-31 Thread Ashton, Triss
No difference.



R version 2.15.2 (2012-10-26) -- Trick or Treat
Copyright (C) 2012 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: x86_64-w64-mingw32/x64 (64-bit)
 chooseCRANmirror()
 utils:::menuInstallPkgs()
trying URL 'http://cran.stat.ucla.edu/bin/windows/contrib/2.15/rJava_0.9-3.zip'
Content type 'application/zip' length 746108 bytes (728 Kb)
opened URL
downloaded 728 Kb
package ‘rJava’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\Triss\AppData\Local\Temp\RtmpEJUIPF\downloaded_packages
 local({pkg - select.list(sort(.packages(all.available = TRUE)),graphics=TRUE)
+ if(nchar(pkg)) library(pkg, character.only=TRUE)})
Error : .onLoad failed in loadNamespace() for 'rJava', details:
  call: fun(libname, pkgname)
  error: JAVA_HOME cannot be determined from the Registry
Error: package/namespace load failed for ‘rJava’
 utils:::menuInstallPkgs()
also installing the dependencies ‘RWekajars’, ‘RWeka’
trying URL 
'http://cran.stat.ucla.edu/bin/windows/contrib/2.15/RWekajars_3.7.7-1.zip'
Content type 'application/zip' length 5521316 bytes (5.3 Mb)
opened URL
downloaded 5.3 Mb
trying URL 'http://cran.stat.ucla.edu/bin/windows/contrib/2.15/RWeka_0.4-12.zip'
Content type 'application/zip' length 527842 bytes (515 Kb)
opened URL
downloaded 515 Kb
trying URL 
'http://cran.stat.ucla.edu/bin/windows/contrib/2.15/Snowball_0.0-8.zip'
Content type 'application/zip' length 386840 bytes (377 Kb)
opened URL
downloaded 377 Kb
package ‘RWekajars’ successfully unpacked and MD5 sums checked
package ‘RWeka’ successfully unpacked and MD5 sums checked
package ‘Snowball’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\Triss\AppData\Local\Temp\RtmpEJUIPF\downloaded_packages
 local({pkg - select.list(sort(.packages(all.available = TRUE)),graphics=TRUE)
+ if(nchar(pkg)) library(pkg, character.only=TRUE)})
Error : .onLoad failed in loadNamespace() for 'Snowball', details:
  call: NULL
  error: .onLoad failed in loadNamespace() for 'rJava', details:
  call: fun(libname, pkgname)
  error: JAVA_HOME cannot be determined from the Registry
Error: package/namespace load failed for ‘Snowball’



From: Pascal Oettli [kri...@ymail.com]
Sent: Wednesday, October 31, 2012 10:15 AM
To: Ashton, Triss
Cc: r-help@r-project.org
Subject: Re: [R] Snallball, rJava, and R 2.15.1

Hello,

It is said
  In addition: Warning messages:
  1: package ‘lsa’ was built under R version 2.15.2
  2: package ‘Snowball’ was built under R version 2.15.2

Install R 2.15.2 first.

Regards,
Pascal


Le 31/10/12 23:29, Triss.Ashton a écrit :
 I just bought a new machine and installed the latest release of R 2.15.1 two
 days ago.  Loaded libraries yesterday (all reported successful loads).
 While running scripts, rJava and Snowball would not load.  Here is Snowball
 successful install:


 utils:::menuInstallPkgs()
 trying URL
 'http://cran.cs.wwu.edu/bin/windows/contrib/2.15/Snowball_0.0-8.zip'
 Content type 'application/zip' length 386840 bytes (377 Kb)
 opened URL
 downloaded 377 Kb

 package ‘Snowball’ successfully unpacked and MD5 sums checked

 The downloaded binary packages are in
  C:\Users\Triss\AppData\Local\Temp\RtmpKsz7Qg\downloaded_packages



 Here is rJava' successful install:

 utils:::menuInstallPkgs()
 trying URL 'http://cran.cs.wwu.edu/bin/windows/contrib/2.15/rJava_0.9-3.zip'
 Content type 'application/zip' length 746108 bytes (728 Kb)
 opened URL
 downloaded 728 Kb

 package ‘rJava’ successfully unpacked and MD5 sums checked

 The downloaded binary packages are in
  C:\Users\Triss\AppData\Local\Temp\RtmpKsz7Qg\downloaded_packages


 The directories for rJava and Snowball are viewable in the Libraries
 directory.   Tried to run my scripts but rJava and Snowball failed to load
 giving the following error when the libraries try to load:

 library(rJava)
 Error : .onLoad failed in loadNamespace() for 'rJava', details:
call: fun(libname, pkgname)
error: JAVA_HOME cannot be determined from the Registry
 Error: package/namespace load failed for ‘rJava’
 library(Snowball)
 Error : .onLoad failed in loadNamespace() for 'Snowball', details:
call: NULL
error: .onLoad failed in loadNamespace() for 'rJava', details:
call: fun(libname, pkgname)
error: JAVA_HOME cannot be determined from the Registry
 In addition: Warning message:
 package ‘Snowball’ was built under R version 2.15.2
 Error: package/namespace load failed for ‘Snowball’


 I then found a different copy of rJava on R-Force last night.  Installed it
 and it seemed to fix the rJava problem.  However, Snowball continues to be a
 problem:

Error : .onLoad failed in loadNamespace() for 'Snowball', details:
call: get(Info[i, 1], envir = env)
error: internal error -3 in R_decompress1
 In addition: Warning messages:
 1: package ‘lsa’ was built under R version 2.15.2
 2: package ‘Snowball’ was built 

Re: [R] From summary function to formula

2012-10-31 Thread Bert Gunter
?predict.xxx

where xxx is either lm or glm, as I don't know what you mean by
general linear model. I also don't know what you mean by summary
function but have assumed it's fitted model.

You need to read ?lm (or ?glm) carefully, and also follow some of the
links therein.

-- Bert

On Wed, Oct 31, 2012 at 7:32 AM, LordSword kini...@student.sdu.dk wrote:
 Hi there!

 I need to generate a final general linear model from a set of coefficients
 of the variables within the summary function.
 When I have the summary-function, HOW do I create a final model (response
 variable = bla bla bla)?

 LordSword



 --
 View this message in context: 
 http://r.789695.n4.nabble.com/From-summary-function-to-formula-tp4648008.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.



-- 

Bert Gunter
Genentech Nonclinical Biostatistics

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

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


Re: [R] Forward and backward algorithm in R?

2012-10-31 Thread Ingmar Visser
R-site search with 'forward backward' returns references to packages for
fitting hidden Markov models.
hth, Ingmar

https://www.google.com/search?q=forward+backwarddomains=r-project.orgsitesearch=r-project.orgbtnG=Google+Search


On Wed, Oct 31, 2012 at 3:50 PM, quantum quan...@live.dk wrote:

 How can I wrtie and calculate alpha and beta in the forward backward
 algorithm in R ?



 --
 View this message in context:
 http://r.789695.n4.nabble.com/Forward-and-backward-algorithm-in-R-tp4648012.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.


[[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] R crashing after successfully running compiled code

2012-10-31 Thread David Winsemius
 Adam Clark atcl...@umn.edu wrote:

 I'll go ahead and dig through my C code. 

 My problem was that I had a pointer (*Aest) that had less memory allocated
 to it than I ended up storing in it ...

On Oct 31, 2012, at 9:04 AM, William Dunlap wrote:

 As long as you use C (or C++ or Fortran ...), using memory that you don't own 
 is possible.  This is one reason people use languages like R.

This seems suitable for the fortunes collection. Any seconds to this nomination?

-- 

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] Cannot rescale a constant/zero column error.

2012-10-31 Thread Jason Fill
Sorry about that, this is my first time posting.  Below is the complete post.


I am trying to run the R Script below, I have actually simplified it to just 
this part that is causing issues.  When I run this script I continue to get an 
error that says cannot rescale a constant/zero column to a unit variance.  I 
cannot figure out what is going on here.  I have stripped down my data file so 
it is more manageable so I can try to figure this out. 

The data.txt file that is being read looks like this: 
UserID,Q1,Q2
2342,3,2

I have made this file very basic on purpose to see if I could get this to work, 
but it is not working.  Of course once I get this to actually work I will 
expand the data file to match the data I am actually using.   

library(stats)
mydata  -  read.table(data.txt, header=TRUE, sep = ,)
newdata -na.omit(mydata)
pcdata - newdata[c(-1)]
pcmatrix - data.frame(pcdata)

# Add the difference so the totals in the scale = 100
pcmatrix[,1] - pcmatrix[,1] + 96
pcmatrix[,2] - pcmatrix[,2] + 96

x.pca - prcomp(pcmatrix, retx=TRUE, center=TRUE, scale=TRUE, cor=TRUE)
weight - cbind(round(abs(x.pca$rotation[,1]),3))

write.table(weight,file=weights.txt)

If I change the attribute in the prcomp function to scale=FALSE of course I can 
run my script.  But if it is scaling...which is causing the issues, it errors. 

Any help would be GREATLY appreciated.


On Oct 31, 2012, at 10:54 AM, David Winsemius wrote:

 
 On Oct 31, 2012, at 5:47 AM, fillay89 wrote:
 
 I am trying to run the R Script below,
 
 There is no script (or data description)  appearing in this posting to the 
 Rhelp Mailing List. Nabble is not Rhelp, despite Nabble's effort to get you 
 to think it is an archive. Please review the Posting Guide that I know you 
 were offered when you posted from Nabble.
 
 Yes, we could view this in Nabble, but most of us choose not to do so. This 
 is a technical mailing list, not a website or chat-room.
 -- 
 David.
 
 
 I have actually simplified it to just
 this part that is causing issues.  When I run this script I continue to get
 an error that says cannot rescale a constant/zero column to a unit
 variance.  I cannot figure out what is going on here.  I have stripped down
 my data file so it is more manageable so I can try to figure this out.
 
 The data.txt file that is being read looks like this:
 
 
 I have made this file very basic on purpose to see if I could get this to
 work, but it is not working.  Of course once I get this to actually work I
 will expand the data file to match the data I am actually using.  
 
 
 
 If I change the attribute in the prcomp function to scale=FALSE of course I
 can run my script.  But if it is scaling...which is causing the issues, it
 errors.
 
 Any help would be GREATLY appreciated.
 
 
 
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Cannot-rescale-a-constant-zero-column-error-tp4647996.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.
 
 David Winsemius, MD
 Alameda, CA, USA
 


[[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] Filling a covariance matrix

2012-10-31 Thread emorway
Hi Joshua,

The code you put together is very helpful.  I have run into a small issue,
however, and I am surprised you weren't getting similar error message when
you tried running the nested for loops?  As an example, I've pared down the
for loop a bit to highlight the error message I'm getting (note also that I
had to modify xs[[i]]$Q to xs[[i]]$*x*Q):

for(i in seq_along(xs)) {
  for(j in seq_along(xs)) {
xcov[paste0(Q,i),paste0(Q,j)] - xcov[paste0(Q,j),paste0(Q,i)]
- cov(xs[[i]]$xQ, xs[[j]]$xQ, use=complete.obs)
  }
}

#Error in cov(xs[[i]]$xQ, xs[[j]]$xQ, use = complete.obs) : 
#  incompatible dimensions

#Some investigation...
i
# 1
j
# 95

length(xs[[i]]$xQ)
# 96
length(xs[[j]]$xQ)
# 92

xs[[j]]$xQ[1:10]
#xQ
#2004-04-04 00:00:00 674
#2004-04-04 00:15:00 669
#2004-04-04 00:30:00 664
#2004-04-04 00:45:00 664
#2004-04-04 01:00:00 669
#2004-04-04 01:15:00 659
#2004-04-04 01:30:00 674
#2004-04-04 01:45:00 669
#2004-04-04 03:00:00 664
#2004-04-04 03:15:00 674

xs[[i]]$xQ[1:10]
# xQ
#2004-01-01 00:00:00 0.43
#2004-01-01 00:15:00 0.43
#2004-01-01 00:30:00 0.43
#2004-01-01 00:45:00 0.43
#2004-01-01 01:00:00 0.57
#2004-01-01 01:15:00 0.57
#2004-01-01 01:30:00 0.57
#2004-01-01 01:45:00 0.43
#2004-01-01 02:00:00 0.43
#2004-01-01 02:15:00 0.57

I suppose the reason use=complete.obs, use=pair, or
use=pairwise.complete.obs won't work is because the date stamp is
different despite the fact there are similar time stamps during the
respective days.  Thus, I'm wondering if there is a way to direct the cov
function to make the calculation using only the time stamp (and not the date
stamp) to determine pairs?

Thanks, Eric



--
View this message in context: 
http://r.789695.n4.nabble.com/Filling-a-covariance-matrix-tp4647170p4648015.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] Mean Help

2012-10-31 Thread Hard Core
Thank you ... can you explain what you've done?



--
View this message in context: 
http://r.789695.n4.nabble.com/Mean-Help-tp4648000p4648013.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] Mean Help

2012-10-31 Thread Hard Core
Thank you but with that formula i don't understand how R can select only the
one with blue eyes



--
View this message in context: 
http://r.789695.n4.nabble.com/Mean-Help-tp4648000p4648030.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] bootstrapping quantile regression

2012-10-31 Thread David Freedman
A possiblie solution might be to use the survey package.  You could specify
that the data is clustered using the svydesign function, and then speciy the
replicate weights using the as.svrepdesign function.  And then, it would be
possible to use the withReplicates function to bootstrap the clusters

A copy of Thomas Lumley's book - Complex Surveys - would probably help with
this

Hope this helps



--
View this message in context: 
http://r.789695.n4.nabble.com/bootstrapping-quantile-regression-tp4647948p4648032.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] Mean Help

2012-10-31 Thread R. Michael Weylandt
On Wed, Oct 31, 2012 at 4:31 PM, Hard Core gi...@hotmail.it wrote:
 Thank you but with that formula i don't understand how R can select only the
 one with blue eyes


Assuming you're referring to my proposal of

aggregate(height ~ eyes, DATA, mean)

It's not blue eyes only: that will summarize height for each eye color
by taking the mean. Then just select blue eyes and you're good to go.

Finally, I note you're posting from Nabble. Please include context in
your reply -- I don't believe Nabble does this automatically, so
you'll need to manually include it. Most of the regular respondents on
this list don't use Nabble -- it is a _mailing list_ after all -- so
we don't get the forum view you do, only emails of the individual
posts. Combine that with the high volume of posts, and it's quite
difficult to trace a discussion if we all don't make sure to include
context. I'm only following up because I have a hunch this involves my
earlier reply, but it's really not clear.

Cheers,
Michael

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] grep txt file names from html

2012-10-31 Thread chuck.01
Sorry, I know I should read a little 1st about this, but I am actually just
helping somebody really quick and need help too. 

I want to grep all of the names of the .txt files mentioned on this html web
page:

http://www.epa.gov/emap/remap/html/three/data/index.html

Thanks ahead of time.



--
View this message in context: 
http://r.789695.n4.nabble.com/grep-txt-file-names-from-html-tp4648037.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] Aggregate Table Data into Cell Frequencies

2012-10-31 Thread Edward Patzelt
R-help -

I have this set of aggregated tables (sample data below via dput()).  And I
would like to have delayValue as the column variables with the temp
(temp1, temp2, temp3) values as the row variables.  However I would like to
have the temp variables *aggregated into single rows* so that I have the
frequency (Freq | counts) of each time each delayValue occurs in the
cells.

I've tried this command without luck, it seems to be dropping a bunch of
values.

tmp - reshape(sampleData, direction = wide,timevar = delayValue,
new.row.names = unique(sampleData$id) )



structure(list(delayValue = c(0, NA, 7, 8, 9, 10, NA,
NA, 4, 5, 6, 7, 8, NA, NA, 4, 5, NA, 6, 7,
8, 9, 10, 11, 12, NA, NA, 5, 6, 7, 8, 9,
NA, 4, 5, 6, 7, 8, 9, 10, NA, 9, 10, NA, NA,
NA, 4, 5, 6, NA, 5, 6, 7, NA, 7, 8, 9, 10,
11, NA, NA, 6, NA, 6, NA, 6, NA, 6, NA, 6, NA, 6,
NA, 6, NA, 6, NA, 6, NA, 6, NA, 6, NA, 6, NA, 6,
NA, 6, NA, 6, NA, 6, NA, 6, NA, 6, NA, 6, NA, NA,
6, NA, 4, 7, NA, 4, NA, 2, 3, 4, NA, 5, NA, 5,
6, NA, 6, NA, 6, NA, 6, NA, 2, 3, NA, 5, NA, 3,
4, NA, 4, 5, NA, 4, NA, 3, NA, NA, 2, 3, 4, 5,
6, 7, 8, 9, NA, 9, NA, NA, 2, NA, 3, 4, 5,
6, NA, 4, 5, 6, NA, 5, NA, 2, 3, NA, 4, 5,
6, NA, 3, NA, NA, 2, NA, 2, NA, 6, NA, 2, NA, 4,
NA, 2, 3, NA, 2, NA, 2, 3, 4, NA, 4, 5, NA, 2,
NA, 3, 4, NA, NA, 18, 19, 20, 21, 22, 23, 24,
25, 26, NA, NA, NA, NA, NA, 4, NA, NA, NA, NA, 5, 6,
NA, NA, 7, 8, 9, 10, NA, 11, 12, 13, 14, NA,
10, NA, 11, 12, 13, 14, 15, 16, NA, 10, 11,
12, NA, 13, 14, 15, 16, 17, NA, 2, NA, 2, 3,
4, NA, 2, NA, 3, NA, 2, 3, 4, 5, 6, 5, 6,
7, NA, 6, 8, NA, 7, 8, NA, 6, 7, 8, 9, NA,
NA, 6, 7, NA, NA, 5, 6, NA, 4, 5, 6, 7, NA, 6,
NA, 7, 8, NA, 6, 7, 8, NA, 5, NA, 2, 3, 4,
5, NA, 7, 7, NA, 7, NA, 7, NA, 7, NA, 7, NA, 7,
NA, 7, 8, NA, 7, 8, NA, 5, 6, NA, 4, NA, 7, NA,
4, NA, 7, NA, 7, 8, NA, 8, NA, 7, 8, NA, 7, NA,
7, NA, 7, NA, NA, 16, 17, 18, NA, 19, 20, 21,
NA, 21, 22, 23, 24, 25, 25, 26, 27, 28, NA,
NA, NA, NA, NA, NA, NA, 4, 6, NA, NA, 4, 5, 6, 7,
NA, 7, 8, 9, NA, 10, 11, 12, NA, 12, 13, 14,
NA, 13, 14, NA, 12, 13, 14, NA, 15, 16, NA, NA,
2, 3, NA, 2, 3, NA, 4, 5, 6, NA, 5, 6, 7,
8, 9, 10, 11, 12, NA, 9, 10, 11, NA, 12, 13,
NA, 9, 10, 11, NA, 12, 13, NA, 13, 14, 15, 16,
17, NA, 6, 7, NA, NA, 6, 7, 8, NA, 9, 10, 11,
NA, NA, 5, 7, NA, 5, NA, NA, 2, 3, 4, 5, NA, NA,
8, 9, NA, 8, 9, NA, NA, NA, NA, NA, NA, NA, NA, NA, 6,
NA, NA, 6, 7, 8, NA, 8, 9, NA, 9, NA, 9, 10,
NA, 9, 10, NA, 9, 10, NA, 9, 10, NA, 7, 2, 3,
NA, 2, NA, 2, 3, NA, 2, 3, 4, NA, 2, 3, NA, 2,
3, NA, 3, NA, 2, NA, 3, 4, NA, 3, 4, NA, 5, NA,
2, 3, 4, NA, 3, 5, NA, 3, 4, NA, 2, 3, 4,
NA, 2, 3, NA, 2, 3, 4, NA, 2, NA, 3, 4, NA, NA,
18, 19, 20, 21, NA, 21, 22, 23, 24, NA, 23,
25, NA, 23, 24, 25, 26, NA, NA, 22, 23, 24, NA,
NA, NA, NA, NA, 6, 7, NA, NA, 7, 8, 9, 10, NA, 11,
12, 13, NA, 14, 15, NA, 13, 14, 15, NA, 14, 15,
16, NA, 15, 16, 17, 18, NA, 16, 17, NA, 7, 20,
21, 22, 23, NA, 22, 23, 24, NA, 25, 26, 27,
NA, 27, 28, 29, 30, NA, 31, NA, NA, NA, NA, NA, NA,
7, 8, NA, NA, 8, NA, 8, 9, NA, 10, 11, 12, 13,
NA, 13, 14, 15, NA, 15, 16, 17, NA, 15, 16, NA,
17, 18, 19, NA, NA, 12, 13, 14, NA, 13, NA, 9,
10, 11, NA, 12, 13, 14, 15, NA, NA, 9, 10, NA,
NA, NA, NA, NA, 6, NA, NA, 4, 5, 6, NA, 3, 4, 5,
NA, 6, 7, 8, NA, 9, NA, 3, 4, 5, NA, 6, 7,
8, 9, 10, 11, 12, 13, NA, 7, 13, NA, 11, 12,
NA, 13, 14, 15, 16, 17, 14, NA, 13, 15, NA, 14,
15, 16, NA, NA, NA, NA, NA, 6, 7, NA, NA, 7, NA, 7,
NA, 8, NA, 8, 9, 10, NA, 10, 11, 12, 13, NA,
13, 14, 15, 16, NA, 14, NA, NA, 2, NA, 2, NA, 2,
NA, 2, 3, NA, 2, 3, NA, 2, NA, 2, NA, 2, 3, NA,
2, 3, NA, 4, 5, NA, 5, 6, NA, 4, 5, NA, 4,
NA, 2, NA, 2, NA, 2, 3, NA, 2, 3, NA, 3, NA, 2,
NA, NA, 4, 5, 6, NA, 6, 7, 8, NA, 8, NA, 8, NA,
3, NA, 2, NA, 2, NA, 2, NA, 2, NA, 2, 3, NA, 6,
NA, 2, NA, 3, 4, 5, 6, 7, NA, 4, 5, NA, NA, NA,
2, 3, NA, 4, NA, 3, 4, NA, 7, 2, 3, 4, 5,
6, 4, 5, NA, 2, 3, NA, 3, 4, NA, 5, 6, 7,
NA, 8, 9, 10, NA, 11, NA, 10, 12, NA, 9, 10,
NA, 10, 11, NA, 6, 7, NA, 8, 9, 10, NA, 4, 5,
6, NA, 6, NA, 3, 4, 5, NA, 2, 3, NA, 3, 4,
NA, 2, 3, NA, 3, 4, NA), Freq = c(0, 1, 1, 1, 1, 1, 1,
6, 1, 1, 1, 1, 1, 5, 5, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 3, 5, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 2, 1, 1, 4, 5, 5, 1, 1, 1,
2, 1, 1, 1, 3, 1, 1, 1, 1, 1, 5, 1, 3, 2, 3, 3, 2, 3, 3, 2, 2,
3, 3, 2, 2, 3, 3, 2, 2, 3, 3, 3, 3, 2, 3, 3, 3, 3, 2, 3, 3, 2,
2, 3, 3, 3, 3, 2, 2, 3, 1, 1, 4, 1, 1, 4, 1, 4, 1, 1, 2, 1, 3,
2, 1, 2, 2, 2, 3, 3, 2, 1, 4, 1, 1, 4, 2, 3, 2, 1, 3, 2, 1, 3,
2, 3, 2, 3, 5, 1, 1, 1, 1, 1, 1, 1, 2, 2, 3, 2, 1, 2, 3, 1, 1,
1, 1, 2, 1, 1, 1, 2, 1, 4, 1, 1, 3, 1, 1, 1, 2, 1, 4, 5, 3, 2,
3, 3, 3, 2, 2, 4, 1, 5, 1, 1, 3, 2, 3, 2, 1, 1, 1, 1, 1, 4, 1,
4, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 5, 5, 5, 5, 1, 4,
5, 5, 6, 2, 1, 2, 6, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 1, 1,
1, 1, 1, 1, 5, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 4, 1, 2, 1, 2,
1, 4, 1, 4, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 3, 1, 1, 3, 1, 1,
1, 1, 1, 6, 2, 1, 2, 6, 1, 1, 4, 1, 1, 1, 1, 1, 2, 3, 1, 1, 3,
1, 1, 1, 3, 1, 4, 1, 1, 1, 1, 1, 1, 2, 3, 3, 3, 3, 2, 2, 3, 3,
2, 2, 3, 1, 2, 2, 1, 1, 3, 1, 

Re: [R] grep txt file names from html

2012-10-31 Thread Sarah Goslee
they're all of the form

http.*txt

but the best way to grep them (by which I assume you mean extract the
file names from the page source) depends on what you plan to do with them,
and what sort of output you expect.

It isn't even clear whether you plan to do this in R.

Sarah


On Wed, Oct 31, 2012 at 12:56 PM, chuck.01 charliethebrow...@gmail.comwrote:

 Sorry, I know I should read a little 1st about this, but I am actually just
 helping somebody really quick and need help too.

 I want to grep all of the names of the .txt files mentioned on this html
 web
 page:

 http://www.epa.gov/emap/remap/html/three/data/index.html

 Thanks ahead of time.


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

[[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] pseudo R-squared for model generated with spgm (splm)

2012-10-31 Thread Marion Jacquot
I am working with the splm package. I use the spgm function: general 
estimation of a panel data model. Based on this approach, I know it is 
possible to compute a R2, eg the ratio of variation explained by a given 
model.

My model is :
bivmod-spgm(logIKA~NBLITRE0+NBLITRE1,data=mydatap,listw=comsKnn.nbW,spatial.error=TRUE)
 


I know that we can calculate the R^2 as the variance of the fitted 
values from the reduced form of the model (Yfitted) over the variance of 
y (here logIKA).
Since I am using the option lag = FALSE; the fitted value for an error 
model are Yfitted = X\beta.

If I well understood :

*1) We can get X* (NT * k matrix of observations on the non-stochastic 
regressors. with N: spatial units , T: time unit et k : number of 
non-stochastic regressors) with

**

bivmod$model[,c(2,3)]  # in the matrix of the data used (bivmod$model), 
the first column corresponds to the response variable and the subsequent 
one to regressors).

NBLITRE0 NBLITRE1

ADAM-LES-PASSAVANT-2004 0 0

ADAM-LES-PASSAVANT-2005 0 0

ADAM-LES-PASSAVANT-2006 0 0

ADAM-LES-PASSAVANT-2007 0 0

ADAM-LES-PASSAVANT-2008 0 0

ADAM-LES-VERCEL-2004 0 0


*2) Beta* corresponds to coefficients associated to each regressor : we 
can get them with

**

bivmod$coefficients

NBLITRE0 NBLITRE1

-0.001131662 -0.001083650


But I do not know what means the  \  in the formula. I suppose it is 
different from / which means divide by .

Any hint appreciated.

Regards,

Marion

-- 
Marion Jacquot
Laboratoire de Chrono-environnement
UMR UFC/CNRS 6249 USC INRA
Université de Franche-Comté
Place Leclerc
F-25030 Besançon cedex
FRANCE
Tel. : +33 (0)381 665 829
Fax : +33 (0)381 665 797
http://chrono-environnement.univ-fcomte.fr/



[[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] grep txt file names from html

2012-10-31 Thread David Winsemius

On Oct 31, 2012, at 9:56 AM, chuck.01 wrote:

 Sorry, I know I should read a little 1st about this, but I am actually just
 helping somebody really quick and need help too. 
 
 I want to grep all of the names of the .txt files mentioned on this html web
 page:
 
 http://www.epa.gov/emap/remap/html/three/data/index.html


This shows code that will identify lines in that source page containing URLs 
that end in '.txt'

 lines - 
 readLines(con=url(http://www.epa.gov/emap/remap/html/three/data/index.html;) 
 )
Warning message:
In readLines(con = 
url(http://www.epa.gov/emap/remap/html/three/data/index.html;)) :
  incomplete final line found on 
'http://www.epa.gov/emap/remap/html/three/data/index.html'
# You can generally ignore that warning.

 length(grep('\\http://([./A-Za-z]){1+}\\.txt', lines) )
[1] 11

Should be fairly straightforward to remove the preceding and trailing material.

 sub('(^.*\\)(http://([./A-Za-z]){1+}\\.txt)(.*$)', \\2, lines[ 
 grep('\\http://([./A-Za-z]){1+}\\.txt', lines) ] )
 [1] 
http://www.epa.gov/emap/html/data/surfwatr/data/mastreams/9396/benthic/benmet.txt;
  
 [2] 
http://www.epa.gov/emap/html/data/surfwatr/data/mastreams/9396/benthic/bencnt.txt;
  
 [3] 
http://www.epa.gov/emap/html/data/surfwatr/data/mastreams/9396/location/watchr.txt;
 
 [4] 
http://www.epa.gov/emap/html/data/surfwatr/data/mastreams/9396/location/habbest.txt;
 [5] 
http://www.epa.gov/emap/html/data/surfwatr/data/mastreams/9396/design/sdesign.txt;
  
 [6] 
http://www.epa.gov/emap/html/data/surfwatr/data/mastreams/9396/wchem/chmval.txt;

 [7] 
http://www.epa.gov/emap/html/data/surfwatr/data/mastreams/9396/fish/fshmet.txt;
 
 [8] 
http://www.epa.gov/emap/html/data/surfwatr/data/mastreams/9396/fish/fshcnt.txt;
 
 [9] 
http://www.epa.gov/emap/html/data/surfwatr/data/mastreams/9396/fish/fshnam.txt;
 
[10] 
http://www.epa.gov/emap/html/data/surfwatr/data/mastreams/9396/tissue/ftmet.txt;

[11] 
http://www.epa.gov/emap/html/data/surfwatr/data/mastreams/9396/tissue/ftorg.txt;


 

 Thanks ahead of time.
 
 
 
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/grep-txt-file-names-from-html-tp4648037.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.

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] Aggregate Table Data into Cell Frequencies

2012-10-31 Thread Marc Schwartz

On Oct 31, 2012, at 11:38 AM, Edward Patzelt patze...@umn.edu wrote:

 R-help -
 
 I have this set of aggregated tables (sample data below via dput()).  And I
 would like to have delayValue as the column variables with the temp
 (temp1, temp2, temp3) values as the row variables.  However I would like to
 have the temp variables *aggregated into single rows* so that I have the
 frequency (Freq | counts) of each time each delayValue occurs in the
 cells.
 
 I've tried this command without luck, it seems to be dropping a bunch of
 values.
 
 tmp - reshape(sampleData, direction = wide,timevar = delayValue,
 new.row.names = unique(sampleData$id) )
 
 
 
 structure(list(delayValue = c(0, NA, 7, 8, 9, 10, NA,
 NA, 4, 5, 6, 7, 8, NA, NA, 4, 5, NA, 6, 7,
 8, 9, 10, 11, 12, NA, NA, 5, 6, 7, 8, 9,
 NA, 4, 5, 6, 7, 8, 9, 10, NA, 9, 10, NA, NA,
 NA, 4, 5, 6, NA, 5, 6, 7, NA, 7, 8, 9, 10,
 11, NA, NA, 6, NA, 6, NA, 6, NA, 6, NA, 6, NA, 6,
 NA, 6, NA, 6, NA, 6, NA, 6, NA, 6, NA, 6, NA, 6,
 NA, 6, NA, 6, NA, 6, NA, 6, NA, 6, NA, 6, NA, NA,
 6, NA, 4, 7, NA, 4, NA, 2, 3, 4, NA, 5, NA, 5,
 6, NA, 6, NA, 6, NA, 6, NA, 2, 3, NA, 5, NA, 3,
 4, NA, 4, 5, NA, 4, NA, 3, NA, NA, 2, 3, 4, 5,
 6, 7, 8, 9, NA, 9, NA, NA, 2, NA, 3, 4, 5,
 6, NA, 4, 5, 6, NA, 5, NA, 2, 3, NA, 4, 5,
 6, NA, 3, NA, NA, 2, NA, 2, NA, 6, NA, 2, NA, 4,
 NA, 2, 3, NA, 2, NA, 2, 3, 4, NA, 4, 5, NA, 2,
 NA, 3, 4, NA, NA, 18, 19, 20, 21, 22, 23, 24,
 25, 26, NA, NA, NA, NA, NA, 4, NA, NA, NA, NA, 5, 6,
 NA, NA, 7, 8, 9, 10, NA, 11, 12, 13, 14, NA,
 10, NA, 11, 12, 13, 14, 15, 16, NA, 10, 11,
 12, NA, 13, 14, 15, 16, 17, NA, 2, NA, 2, 3,
 4, NA, 2, NA, 3, NA, 2, 3, 4, 5, 6, 5, 6,
 7, NA, 6, 8, NA, 7, 8, NA, 6, 7, 8, 9, NA,
 NA, 6, 7, NA, NA, 5, 6, NA, 4, 5, 6, 7, NA, 6,
 NA, 7, 8, NA, 6, 7, 8, NA, 5, NA, 2, 3, 4,
 5, NA, 7, 7, NA, 7, NA, 7, NA, 7, NA, 7, NA, 7,
 NA, 7, 8, NA, 7, 8, NA, 5, 6, NA, 4, NA, 7, NA,
 4, NA, 7, NA, 7, 8, NA, 8, NA, 7, 8, NA, 7, NA,
 7, NA, 7, NA, NA, 16, 17, 18, NA, 19, 20, 21,
 NA, 21, 22, 23, 24, 25, 25, 26, 27, 28, NA,
 NA, NA, NA, NA, NA, NA, 4, 6, NA, NA, 4, 5, 6, 7,
 NA, 7, 8, 9, NA, 10, 11, 12, NA, 12, 13, 14,
 NA, 13, 14, NA, 12, 13, 14, NA, 15, 16, NA, NA,
 2, 3, NA, 2, 3, NA, 4, 5, 6, NA, 5, 6, 7,
 8, 9, 10, 11, 12, NA, 9, 10, 11, NA, 12, 13,
 NA, 9, 10, 11, NA, 12, 13, NA, 13, 14, 15, 16,
 17, NA, 6, 7, NA, NA, 6, 7, 8, NA, 9, 10, 11,
 NA, NA, 5, 7, NA, 5, NA, NA, 2, 3, 4, 5, NA, NA,
 8, 9, NA, 8, 9, NA, NA, NA, NA, NA, NA, NA, NA, NA, 6,
 NA, NA, 6, 7, 8, NA, 8, 9, NA, 9, NA, 9, 10,
 NA, 9, 10, NA, 9, 10, NA, 9, 10, NA, 7, 2, 3,
 NA, 2, NA, 2, 3, NA, 2, 3, 4, NA, 2, 3, NA, 2,
 3, NA, 3, NA, 2, NA, 3, 4, NA, 3, 4, NA, 5, NA,
 2, 3, 4, NA, 3, 5, NA, 3, 4, NA, 2, 3, 4,
 NA, 2, 3, NA, 2, 3, 4, NA, 2, NA, 3, 4, NA, NA,
 18, 19, 20, 21, NA, 21, 22, 23, 24, NA, 23,
 25, NA, 23, 24, 25, 26, NA, NA, 22, 23, 24, NA,
 NA, NA, NA, NA, 6, 7, NA, NA, 7, 8, 9, 10, NA, 11,
 12, 13, NA, 14, 15, NA, 13, 14, 15, NA, 14, 15,
 16, NA, 15, 16, 17, 18, NA, 16, 17, NA, 7, 20,
 21, 22, 23, NA, 22, 23, 24, NA, 25, 26, 27,
 NA, 27, 28, 29, 30, NA, 31, NA, NA, NA, NA, NA, NA,
 7, 8, NA, NA, 8, NA, 8, 9, NA, 10, 11, 12, 13,
 NA, 13, 14, 15, NA, 15, 16, 17, NA, 15, 16, NA,
 17, 18, 19, NA, NA, 12, 13, 14, NA, 13, NA, 9,
 10, 11, NA, 12, 13, 14, 15, NA, NA, 9, 10, NA,
 NA, NA, NA, NA, 6, NA, NA, 4, 5, 6, NA, 3, 4, 5,
 NA, 6, 7, 8, NA, 9, NA, 3, 4, 5, NA, 6, 7,
 8, 9, 10, 11, 12, 13, NA, 7, 13, NA, 11, 12,
 NA, 13, 14, 15, 16, 17, 14, NA, 13, 15, NA, 14,
 15, 16, NA, NA, NA, NA, NA, 6, 7, NA, NA, 7, NA, 7,
 NA, 8, NA, 8, 9, 10, NA, 10, 11, 12, 13, NA,
 13, 14, 15, 16, NA, 14, NA, NA, 2, NA, 2, NA, 2,
 NA, 2, 3, NA, 2, 3, NA, 2, NA, 2, NA, 2, 3, NA,
 2, 3, NA, 4, 5, NA, 5, 6, NA, 4, 5, NA, 4,
 NA, 2, NA, 2, NA, 2, 3, NA, 2, 3, NA, 3, NA, 2,
 NA, NA, 4, 5, 6, NA, 6, 7, 8, NA, 8, NA, 8, NA,
 3, NA, 2, NA, 2, NA, 2, NA, 2, NA, 2, 3, NA, 6,
 NA, 2, NA, 3, 4, 5, 6, 7, NA, 4, 5, NA, NA, NA,
 2, 3, NA, 4, NA, 3, 4, NA, 7, 2, 3, 4, 5,
 6, 4, 5, NA, 2, 3, NA, 3, 4, NA, 5, 6, 7,
 NA, 8, 9, 10, NA, 11, NA, 10, 12, NA, 9, 10,
 NA, 10, 11, NA, 6, 7, NA, 8, 9, 10, NA, 4, 5,
 6, NA, 6, NA, 3, 4, 5, NA, 2, 3, NA, 3, 4,
 NA, 2, 3, NA, 3, 4, NA), Freq = c(0, 1, 1, 1, 1, 1, 1,
 6, 1, 1, 1, 1, 1, 5, 5, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 3, 5, 1,
 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 2, 1, 1, 4, 5, 5, 1, 1, 1,
 2, 1, 1, 1, 3, 1, 1, 1, 1, 1, 5, 1, 3, 2, 3, 3, 2, 3, 3, 2, 2,
 3, 3, 2, 2, 3, 3, 2, 2, 3, 3, 3, 3, 2, 3, 3, 3, 3, 2, 3, 3, 2,
 2, 3, 3, 3, 3, 2, 2, 3, 1, 1, 4, 1, 1, 4, 1, 4, 1, 1, 2, 1, 3,
 2, 1, 2, 2, 2, 3, 3, 2, 1, 4, 1, 1, 4, 2, 3, 2, 1, 3, 2, 1, 3,
 2, 3, 2, 3, 5, 1, 1, 1, 1, 1, 1, 1, 2, 2, 3, 2, 1, 2, 3, 1, 1,
 1, 1, 2, 1, 1, 1, 2, 1, 4, 1, 1, 3, 1, 1, 1, 2, 1, 4, 5, 3, 2,
 3, 3, 3, 2, 2, 4, 1, 5, 1, 1, 3, 2, 3, 2, 1, 1, 1, 1, 1, 4, 1,
 4, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 5, 5, 5, 5, 1, 4,
 5, 5, 6, 2, 1, 2, 6, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 1, 1,
 1, 1, 1, 1, 5, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 4, 1, 2, 1, 2,
 1, 4, 1, 4, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 

Re: [R] FW: replace repeated id in a pedigree list

2012-10-31 Thread Terry Therneau

 I use kinship package of R and it doesn't create a kinship matrix with 
repeated id.

The kinship package is out of date, use the kinship2 and coxme packages (it was split into 
two parts).  Then the problem you describe no longer exists -- the kinship function no 
longer requires each subject id to be unique across all pedigrees.


pedlist - with(mydata, pedgiree(id, fa_id, mo_id, sex, famid=famid))
kmat - kinship(pedlist)
fit - coxme(Surv(time, status) ~ x1 + x2 +... + (1| famid/id), varlist=kmat)

The pedlist object contains all the families, plot(pedlist[4]) would pull out and plot the 
4th family.

The column labels of kmat will be of the form famid/id


To solve your original problem (though you don't need to) create a single 
unified id.
uid - paste(famid, id, sep='/')
idlist - unique(uid)

newid - match(uid, idlist)
newmom - match(paste(famid, mo_id, sep='/'), idlist)
newdad - match(paste(famid, fa_id, sep='/'), idlist)


Terry Therneau
author of kinship and coxme, but not :-) the maintainer of kinship2

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


Re: [R] Aggregate Table Data into Cell Frequencies

2012-10-31 Thread Rui Barradas
Hello,

I'm not sure if this is what you want.


aggregate(delayValue ~ id + Freq, data = sampleData, length)


Hope this helps,

Rui Barradas
Em 31-10-2012 16:38, Edward Patzelt escreveu:
 R-help -

 I have this set of aggregated tables (sample data below via dput()).  And I
 would like to have delayValue as the column variables with the temp
 (temp1, temp2, temp3) values as the row variables.  However I would like to
 have the temp variables *aggregated into single rows* so that I have the
 frequency (Freq | counts) of each time each delayValue occurs in the
 cells.

 I've tried this command without luck, it seems to be dropping a bunch of
 values.

 tmp - reshape(sampleData, direction = wide,timevar = delayValue,
 new.row.names = unique(sampleData$id) )



 structure(list(delayValue = c(0, NA, 7, 8, 9, 10, NA,
 NA, 4, 5, 6, 7, 8, NA, NA, 4, 5, NA, 6, 7,
 8, 9, 10, 11, 12, NA, NA, 5, 6, 7, 8, 9,
 NA, 4, 5, 6, 7, 8, 9, 10, NA, 9, 10, NA, NA,
 NA, 4, 5, 6, NA, 5, 6, 7, NA, 7, 8, 9, 10,
 11, NA, NA, 6, NA, 6, NA, 6, NA, 6, NA, 6, NA, 6,
 NA, 6, NA, 6, NA, 6, NA, 6, NA, 6, NA, 6, NA, 6,
 NA, 6, NA, 6, NA, 6, NA, 6, NA, 6, NA, 6, NA, NA,
 6, NA, 4, 7, NA, 4, NA, 2, 3, 4, NA, 5, NA, 5,
 6, NA, 6, NA, 6, NA, 6, NA, 2, 3, NA, 5, NA, 3,
 4, NA, 4, 5, NA, 4, NA, 3, NA, NA, 2, 3, 4, 5,
 6, 7, 8, 9, NA, 9, NA, NA, 2, NA, 3, 4, 5,
 6, NA, 4, 5, 6, NA, 5, NA, 2, 3, NA, 4, 5,
 6, NA, 3, NA, NA, 2, NA, 2, NA, 6, NA, 2, NA, 4,
 NA, 2, 3, NA, 2, NA, 2, 3, 4, NA, 4, 5, NA, 2,
 NA, 3, 4, NA, NA, 18, 19, 20, 21, 22, 23, 24,
 25, 26, NA, NA, NA, NA, NA, 4, NA, NA, NA, NA, 5, 6,
 NA, NA, 7, 8, 9, 10, NA, 11, 12, 13, 14, NA,
 10, NA, 11, 12, 13, 14, 15, 16, NA, 10, 11,
 12, NA, 13, 14, 15, 16, 17, NA, 2, NA, 2, 3,
 4, NA, 2, NA, 3, NA, 2, 3, 4, 5, 6, 5, 6,
 7, NA, 6, 8, NA, 7, 8, NA, 6, 7, 8, 9, NA,
 NA, 6, 7, NA, NA, 5, 6, NA, 4, 5, 6, 7, NA, 6,
 NA, 7, 8, NA, 6, 7, 8, NA, 5, NA, 2, 3, 4,
 5, NA, 7, 7, NA, 7, NA, 7, NA, 7, NA, 7, NA, 7,
 NA, 7, 8, NA, 7, 8, NA, 5, 6, NA, 4, NA, 7, NA,
 4, NA, 7, NA, 7, 8, NA, 8, NA, 7, 8, NA, 7, NA,
 7, NA, 7, NA, NA, 16, 17, 18, NA, 19, 20, 21,
 NA, 21, 22, 23, 24, 25, 25, 26, 27, 28, NA,
 NA, NA, NA, NA, NA, NA, 4, 6, NA, NA, 4, 5, 6, 7,
 NA, 7, 8, 9, NA, 10, 11, 12, NA, 12, 13, 14,
 NA, 13, 14, NA, 12, 13, 14, NA, 15, 16, NA, NA,
 2, 3, NA, 2, 3, NA, 4, 5, 6, NA, 5, 6, 7,
 8, 9, 10, 11, 12, NA, 9, 10, 11, NA, 12, 13,
 NA, 9, 10, 11, NA, 12, 13, NA, 13, 14, 15, 16,
 17, NA, 6, 7, NA, NA, 6, 7, 8, NA, 9, 10, 11,
 NA, NA, 5, 7, NA, 5, NA, NA, 2, 3, 4, 5, NA, NA,
 8, 9, NA, 8, 9, NA, NA, NA, NA, NA, NA, NA, NA, NA, 6,
 NA, NA, 6, 7, 8, NA, 8, 9, NA, 9, NA, 9, 10,
 NA, 9, 10, NA, 9, 10, NA, 9, 10, NA, 7, 2, 3,
 NA, 2, NA, 2, 3, NA, 2, 3, 4, NA, 2, 3, NA, 2,
 3, NA, 3, NA, 2, NA, 3, 4, NA, 3, 4, NA, 5, NA,
 2, 3, 4, NA, 3, 5, NA, 3, 4, NA, 2, 3, 4,
 NA, 2, 3, NA, 2, 3, 4, NA, 2, NA, 3, 4, NA, NA,
 18, 19, 20, 21, NA, 21, 22, 23, 24, NA, 23,
 25, NA, 23, 24, 25, 26, NA, NA, 22, 23, 24, NA,
 NA, NA, NA, NA, 6, 7, NA, NA, 7, 8, 9, 10, NA, 11,
 12, 13, NA, 14, 15, NA, 13, 14, 15, NA, 14, 15,
 16, NA, 15, 16, 17, 18, NA, 16, 17, NA, 7, 20,
 21, 22, 23, NA, 22, 23, 24, NA, 25, 26, 27,
 NA, 27, 28, 29, 30, NA, 31, NA, NA, NA, NA, NA, NA,
 7, 8, NA, NA, 8, NA, 8, 9, NA, 10, 11, 12, 13,
 NA, 13, 14, 15, NA, 15, 16, 17, NA, 15, 16, NA,
 17, 18, 19, NA, NA, 12, 13, 14, NA, 13, NA, 9,
 10, 11, NA, 12, 13, 14, 15, NA, NA, 9, 10, NA,
 NA, NA, NA, NA, 6, NA, NA, 4, 5, 6, NA, 3, 4, 5,
 NA, 6, 7, 8, NA, 9, NA, 3, 4, 5, NA, 6, 7,
 8, 9, 10, 11, 12, 13, NA, 7, 13, NA, 11, 12,
 NA, 13, 14, 15, 16, 17, 14, NA, 13, 15, NA, 14,
 15, 16, NA, NA, NA, NA, NA, 6, 7, NA, NA, 7, NA, 7,
 NA, 8, NA, 8, 9, 10, NA, 10, 11, 12, 13, NA,
 13, 14, 15, 16, NA, 14, NA, NA, 2, NA, 2, NA, 2,
 NA, 2, 3, NA, 2, 3, NA, 2, NA, 2, NA, 2, 3, NA,
 2, 3, NA, 4, 5, NA, 5, 6, NA, 4, 5, NA, 4,
 NA, 2, NA, 2, NA, 2, 3, NA, 2, 3, NA, 3, NA, 2,
 NA, NA, 4, 5, 6, NA, 6, 7, 8, NA, 8, NA, 8, NA,
 3, NA, 2, NA, 2, NA, 2, NA, 2, NA, 2, 3, NA, 6,
 NA, 2, NA, 3, 4, 5, 6, 7, NA, 4, 5, NA, NA, NA,
 2, 3, NA, 4, NA, 3, 4, NA, 7, 2, 3, 4, 5,
 6, 4, 5, NA, 2, 3, NA, 3, 4, NA, 5, 6, 7,
 NA, 8, 9, 10, NA, 11, NA, 10, 12, NA, 9, 10,
 NA, 10, 11, NA, 6, 7, NA, 8, 9, 10, NA, 4, 5,
 6, NA, 6, NA, 3, 4, 5, NA, 2, 3, NA, 3, 4,
 NA, 2, 3, NA, 3, 4, NA), Freq = c(0, 1, 1, 1, 1, 1, 1,
 6, 1, 1, 1, 1, 1, 5, 5, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 3, 5, 1,
 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 2, 1, 1, 4, 5, 5, 1, 1, 1,
 2, 1, 1, 1, 3, 1, 1, 1, 1, 1, 5, 1, 3, 2, 3, 3, 2, 3, 3, 2, 2,
 3, 3, 2, 2, 3, 3, 2, 2, 3, 3, 3, 3, 2, 3, 3, 3, 3, 2, 3, 3, 2,
 2, 3, 3, 3, 3, 2, 2, 3, 1, 1, 4, 1, 1, 4, 1, 4, 1, 1, 2, 1, 3,
 2, 1, 2, 2, 2, 3, 3, 2, 1, 4, 1, 1, 4, 2, 3, 2, 1, 3, 2, 1, 3,
 2, 3, 2, 3, 5, 1, 1, 1, 1, 1, 1, 1, 2, 2, 3, 2, 1, 2, 3, 1, 1,
 1, 1, 2, 1, 1, 1, 2, 1, 4, 1, 1, 3, 1, 1, 1, 2, 1, 4, 5, 3, 2,
 3, 3, 3, 2, 2, 4, 1, 5, 1, 1, 3, 2, 3, 2, 1, 1, 1, 1, 1, 4, 1,
 4, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 5, 5, 5, 5, 1, 4,
 5, 5, 6, 2, 1, 2, 6, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 1, 

Re: [R] Mean Help

2012-10-31 Thread Hard Core
Dear Michael ... You're a genius thak you very much 
really thank you !!! It worked!!!



--
View this message in context: 
http://r.789695.n4.nabble.com/Mean-Help-tp4648000p4648038.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] Mean Help

2012-10-31 Thread arun
Sure.

set.seed(1)
 dat1-data.frame(Height=sample(150:180,12,replace=TRUE),EyeColor=rep(c(Green,Blue,Brown),each=4))
dat1[,2]==Blue
# [1] FALSE FALSE FALSE FALSE  TRUE  TRUE  TRUE  TRUE FALSE FALSE FALSE FALSE # 
Returns a logical vector which checks whether each row of 2nd column of dat1 is 
Blue or not.
dat1[,1][dat1[,2]==Blue] #gives me values of 1st column where the index 
(logical vector) is TRUE.
#[1] 156 177 179 170

If I use,
dat1[dat1[,2]==Blue,] #returns the subset of data with all the columns of dat1
 # Height EyeColor
#5    156 Blue
#6    177 Blue
#7    179 Blue
#8    170 Blue

#Finally,
mean(dat1[,1][dat1[,2]==Blue]) gives the mean of those values I mentioned 
above.
#[1] 170.5





 






- Original Message -
From: Hard Core gi...@hotmail.it
To: r-help@r-project.org
Cc: 
Sent: Wednesday, October 31, 2012 11:19 AM
Subject: Re: [R] Mean Help

Thank you ... can you explain what you've done?



--
View this message in context: 
http://r.789695.n4.nabble.com/Mean-Help-tp4648000p4648013.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] extracting information from txt file

2012-10-31 Thread chuck.01
Hello,

Here is a link to some data:
http://www.epa.gov/emap/html/data/surfwatr/data/mastreams/9396/wchem/chmval.txt

I am trying to read this in, and want to use: 
chmval -
read.table(http://www.epa.gov/emap/html/data/surfwatr/data/mastreams/9396/wchem/chmval.txt;,
sep=,, skip= 84, header=T)

the # 84, for 84 lines skipped needs to be derived from the 5th line of the
txt file  
# Header Records:  85 

so, I need that # (-1) for input into the read.table statement above

I've tried grep but that didn't work: 
 (for this I downloaded the txt file and manually removed that hash mark!)

grep(Header Records:, read.table(chmval.txt, header=T))
Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, 
: 
  line 1 did not have 5 elements

Any ideas?
Can I just extract the 5th line?




--
View this message in context: 
http://r.789695.n4.nabble.com/extracting-information-from-txt-file-tp4648033.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] grep txt file names from html

2012-10-31 Thread chuck.01
Sorry Sarah. 
I want to store them as a vector for use later.  

so, similar to this:

links -
c(http://www.epa.gov/emap/html/data/surfwatr/data/mastreams/9396/benthic/benmet.txt;,
http://www.epa.gov/emap/html/data/surfwatr/data/mastreams/9396/location/watchr.txt;,
http://www.epa.gov/emap/html/data/surfwatr/data/mastreams/9396/wchem/chmval.txt;)




Sarah Goslee wrote
 they're all of the form
 
 http.*txt
 
 but the best way to grep them (by which I assume you mean extract the
 file names from the page source) depends on what you plan to do with them,
 and what sort of output you expect.
 
 It isn't even clear whether you plan to do this in R.
 
 Sarah
 
 
 On Wed, Oct 31, 2012 at 12:56 PM, chuck.01 lt;

 CharlieTheBrown77@

 gt;wrote:
 
 Sorry, I know I should read a little 1st about this, but I am actually
 just
 helping somebody really quick and need help too.

 I want to grep all of the names of the .txt files mentioned on this html
 web
 page:

 http://www.epa.gov/emap/remap/html/three/data/index.html

 Thanks ahead of time.


 -- 
 Sarah Goslee
 http://www.functionaldiversity.org
 
   [[alternative HTML version deleted]]
 
 __

 R-help@

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





--
View this message in context: 
http://r.789695.n4.nabble.com/grep-txt-file-names-from-html-tp4648037p4648043.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] Snallball, rJava, and R 2.15.1

2012-10-31 Thread Ashton, Triss
Found the problem on this.  This is a new computer and does not have Java 
installed.  Loaded JDK and everything is working.  Thanks.  

-Original Message-
From: Pascal Oettli [mailto:kri...@ymail.com] 
Sent: Wednesday, October 31, 2012 10:15 AM
To: Ashton, Triss
Cc: r-help@r-project.org
Subject: Re: [R] Snallball, rJava, and R 2.15.1

Hello,

It is said
  In addition: Warning messages:
  1: package ‘lsa’ was built under R version 2.15.2   2: package ‘Snowball’ 
  was built under R version 2.15.2

Install R 2.15.2 first.

Regards,
Pascal


Le 31/10/12 23:29, Triss.Ashton a écrit :
 I just bought a new machine and installed the latest release of R 
 2.15.1 two days ago.  Loaded libraries yesterday (all reported successful 
 loads).
 While running scripts, rJava and Snowball would not load.  Here is 
 Snowball successful install:


 utils:::menuInstallPkgs()
 trying URL
 'http://cran.cs.wwu.edu/bin/windows/contrib/2.15/Snowball_0.0-8.zip'
 Content type 'application/zip' length 386840 bytes (377 Kb) opened URL 
 downloaded 377 Kb

 package ‘Snowball’ successfully unpacked and MD5 sums checked

 The downloaded binary packages are in
  
 C:\Users\Triss\AppData\Local\Temp\RtmpKsz7Qg\downloaded_packages



 Here is rJava' successful install:

 utils:::menuInstallPkgs()
 trying URL 'http://cran.cs.wwu.edu/bin/windows/contrib/2.15/rJava_0.9-3.zip'
 Content type 'application/zip' length 746108 bytes (728 Kb) opened URL 
 downloaded 728 Kb

 package ‘rJava’ successfully unpacked and MD5 sums checked

 The downloaded binary packages are in
  
 C:\Users\Triss\AppData\Local\Temp\RtmpKsz7Qg\downloaded_packages


 The directories for rJava and Snowball are viewable in the Libraries
 directory.   Tried to run my scripts but rJava and Snowball failed to load
 giving the following error when the libraries try to load:

 library(rJava)
 Error : .onLoad failed in loadNamespace() for 'rJava', details:
call: fun(libname, pkgname)
error: JAVA_HOME cannot be determined from the Registry
 Error: package/namespace load failed for ‘rJava’
 library(Snowball)
 Error : .onLoad failed in loadNamespace() for 'Snowball', details:
call: NULL
error: .onLoad failed in loadNamespace() for 'rJava', details:
call: fun(libname, pkgname)
error: JAVA_HOME cannot be determined from the Registry In 
 addition: Warning message:
 package ‘Snowball’ was built under R version 2.15.2
 Error: package/namespace load failed for ‘Snowball’


 I then found a different copy of rJava on R-Force last night.  
 Installed it and it seemed to fix the rJava problem.  However, 
 Snowball continues to be a
 problem:

Error : .onLoad failed in loadNamespace() for 'Snowball', details:
call: get(Info[i, 1], envir = env)
error: internal error -3 in R_decompress1 In addition: Warning 
 messages:
 1: package ‘lsa’ was built under R version 2.15.2
 2: package ‘Snowball’ was built under R version 2.15.2
 Error: package ‘Snowball’ could not be loaded



 To illustrate this problem, I reinstalled the rJava package from Cran 
 this morning.  After writing this up, went back to R-force to 
 reinstall a working copy of rJava, but it seems they have now pulled 
 the rJava library so I am now stuck with two broken libraries.  
 Thought the problem might be with R 2.15.1.  Installed 2.15.0 but same 
 results.  One other point: at one time last night there was a window 
 popping up with a warning message - something to do with Rf_copyListMatrix. 
  That window is not coming up this morning.
 Let me know if there is anything else you need to figure this out.

 Thanks,

 Triss



 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Snallball-rJava-and-R-2-15-1-tp4648007.h
 tml 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] extracting information from txt file

2012-10-31 Thread Rui Barradas

Hello,

Use readLines instead.

?readLines  # see argument 'n'
readLines(http://www.epa.gov/emap/html/data/surfwatr/data/mastreams/9396/wchem/chmval.txt;, 
n = 5)[5]



Hope this helps,

Rui Barradas
Em 31-10-2012 16:46, chuck.01 escreveu:

Hello,

Here is a link to some data:
http://www.epa.gov/emap/html/data/surfwatr/data/mastreams/9396/wchem/chmval.txt

I am trying to read this in, and want to use:
chmval -
read.table(http://www.epa.gov/emap/html/data/surfwatr/data/mastreams/9396/wchem/chmval.txt;,
sep=,, skip= 84, header=T)

the # 84, for 84 lines skipped needs to be derived from the 5th line of the
txt file
# Header Records:  85

so, I need that # (-1) for input into the read.table statement above

I've tried grep but that didn't work:
  (for this I downloaded the txt file and manually removed that hash mark!)

grep(Header Records:, read.table(chmval.txt, header=T))
Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings,
:
   line 1 did not have 5 elements

Any ideas?
Can I just extract the 5th line?




--
View this message in context: 
http://r.789695.n4.nabble.com/extracting-information-from-txt-file-tp4648033.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] standard error for quantile

2012-10-31 Thread Ted Harding
[see in-line below]

On 31-Oct-2012 10:26:14 PIKAL Petr wrote:
 Hi Ted
 
 -Original Message-
 From: ted@deb [mailto:ted@deb] On Behalf Of Ted Harding
 Sent: Tuesday, October 30, 2012 6:41 PM
 To: r-help@r-project.org
 
 snip
 
 
 The general asymptotic result for the pth quantile (0p1) X.p of a
 sample of size n is that it is asymptotically Normally distributed with
 mean the pth quantile Q.p of the parent distribution and
 
   var(X.p) = p*(1-p)/(n*f(Q.p)^2)
 
 where f(x) is the probability density function of the parent
 distribution.
 
 So if I understand correctly p*(1-p) is biggest when p=0.5 and decreases with
 smaller or bigger p. The var(X.p) then depends on ratio to parent
 distribution at this p probability. For lognorm distribution and 200 values
 the resulting var is
 
 (0.5*(1-.5))/(200*qlnorm(.5, log(200), log(2))^2)
 [1] 3.125e-08
 (0.1*(1-.1))/(200*qlnorm(.1, log(200), log(2))^2)
 [1] 6.648497e-08
 
 so 0.1 var is slightly bigger than 0.5 var. For different distributions this
 can be reversed as Jim pointed out.
 
 Did I manage to understand?
 
 Thank you very much.
 Regards
 Petr 

Yes, it looks as though you understand! As a further illustration,
here is some R code applied to examples where the parent distrbution
is uniform or Normal. For each case, the reraults are stated as
first: simulated; second: by the formula. It can be seen that for
n=200 the formula and the simulations are close.
Ted.

###
## Test of formula for var(quantile)
varQ - function(p,n,f.p) {
  p*(1-p)/(n*(f.p^2))
}

## Test 1: Uniform (0,1), n = 200
n - 200
## Pick one of (a), (b), (c):
## (a)# p - 0.50 ; q - 100 ; f.p - 1
## (b)# p - 0.25 ; q -  50 ; f.p - 1
## (c)# p - 0.10 ; q -  25 ; f.p - 1
Nsim - 1000
Qs   - numeric(Nsim)
for( i in (1:Nsim) ){
  Qs[i] - sort(runif(n))[q]
}
var(Qs)
varQ(p,n,f.p)
## (a) 0.001239982
## 0.00125
## (b) 0.0008877879
## 0.0009375
## (c) 0.0005619348
## 0.00045

## Test 2: N(0,1), n = 200
n - 200
## Pick one of (a), (b), (c):
## (a)# p - 0.50 ; q - 100 ; f.p - dnorm(qnorm(0.50))
## (b)# p - 0.25 ; q -  50 ; f.p - dnorm(qnorm(0.25))
## (c)# p - 0.10 ; q -  20 ; f.p - dnorm(qnorm(0.10))
Nsim - 1000
Qs   - numeric(Nsim)
for( i in (1:Nsim) ){
  Qs[i] - sort(rnorm(n))[q]
}
var(Qs)
varQ(p,n,f.p)
## (a) 0.007633568
## 0.007853982
## (b) 0.009370099
## 0.009283837
## (c) 0.01420517
## 0.01461055
###

 This is not necessarily very helpful for small sample sizes (depending
 on the parent distribution).
 
 However, it is possible to obtain a general result giving an exact
 confidence interval for Q.p given the entire ordered sample, though
 there is only a restricted set of confidence levels to which it
 applies.
 
 If you'd like more detail about the above, I could write up derivations
 and make the write-up available.
 
 Hoping this helps,
 Ted.
 
 -
 E-Mail: (Ted Harding) ted.hard...@wlandres.net
 Date: 30-Oct-2012  Time: 17:40:55
 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.

-
E-Mail: (Ted Harding) ted.hard...@wlandres.net
Date: 31-Oct-2012  Time: 18:10:16
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.


Re: [R] extracting information from txt file

2012-10-31 Thread jim holtman
This worked fine for me:

 x - 
 read.csv(http://www.epa.gov/emap/html/data/surfwatr/data/mastreams/9396/wchem/chmval.txt;,
  skip=84, as.is = TRUE)
 str(x)
'data.frame':   711 obs. of  75 variables:
 $ ALDI: chr  . . . . ...
 $ ALDS: chr  . S S S ...
 $ ALDSF   : chr  ...
 $ ALKCALC : chr  106.05 210.7 73.51 432.63 ...
 $ ALOR: chr  . S S S ...
 $ ALORF   : chr  ...
 $ ALTD: chr  54 36 47 12 ...
 $ ALTDF   : chr  ...
 $ ANC : chr  115 207.2 82.2 435.2 ...


On Wed, Oct 31, 2012 at 12:46 PM, chuck.01 charliethebrow...@gmail.com wrote:
 Hello,

 Here is a link to some data:
 http://www.epa.gov/emap/html/data/surfwatr/data/mastreams/9396/wchem/chmval.txt

 I am trying to read this in, and want to use:
 chmval -
 read.table(http://www.epa.gov/emap/html/data/surfwatr/data/mastreams/9396/wchem/chmval.txt;,
 sep=,, skip= 84, header=T)

 the # 84, for 84 lines skipped needs to be derived from the 5th line of the
 txt file
 # Header Records:  85

 so, I need that # (-1) for input into the read.table statement above

 I've tried grep but that didn't work:
  (for this I downloaded the txt file and manually removed that hash mark!)

 grep(Header Records:, read.table(chmval.txt, header=T))
 Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings,
 :
   line 1 did not have 5 elements

 Any ideas?
 Can I just extract the 5th line?




 --
 View this message in context: 
 http://r.789695.n4.nabble.com/extracting-information-from-txt-file-tp4648033.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.



-- 
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] extracting information from txt file

2012-10-31 Thread jim holtman
Using na.string works better:

 x - 
 read.csv(http://www.epa.gov/emap/html/data/surfwatr/data/mastreams/9396/wchem/chmval.txt;,
  skip=84, as.is = TRUE, na.string = '.')
 str(x)
'data.frame':   711 obs. of  75 variables:
 $ ALDI: int  NA NA NA NA NA NA NA NA NA NA ...
 $ ALDS: chr  NA S S S ...
 $ ALDSF   : chr  ...
 $ ALKCALC : num  106 210.7 73.5 432.6 38.7 ...
 $ ALOR: chr  NA S S S ...
 $ ALORF   : chr  ...
 $ ALTD: int  54 36 47 12 19 10 12 5 8 6 ...
 $ ALTDF   : chr  ...
 $ ANC : num  115 207.2 82.2 435.2 37.4 ...
 $ ANCF: chr  ...
 $ ANDEF   : num  82.5 52.3 31.8 21.9 12.2 ...
 $ ANSUM   : num  771 728 328 892 251 ...
 $ CA  : num  303 529 182 392 124 ...


On Wed, Oct 31, 2012 at 12:46 PM, chuck.01 charliethebrow...@gmail.com wrote:
 Hello,

 Here is a link to some data:
 http://www.epa.gov/emap/html/data/surfwatr/data/mastreams/9396/wchem/chmval.txt

 I am trying to read this in, and want to use:
 chmval -
 read.table(http://www.epa.gov/emap/html/data/surfwatr/data/mastreams/9396/wchem/chmval.txt;,
 sep=,, skip= 84, header=T)

 the # 84, for 84 lines skipped needs to be derived from the 5th line of the
 txt file
 # Header Records:  85

 so, I need that # (-1) for input into the read.table statement above

 I've tried grep but that didn't work:
  (for this I downloaded the txt file and manually removed that hash mark!)

 grep(Header Records:, read.table(chmval.txt, header=T))
 Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings,
 :
   line 1 did not have 5 elements

 Any ideas?
 Can I just extract the 5th line?




 --
 View this message in context: 
 http://r.789695.n4.nabble.com/extracting-information-from-txt-file-tp4648033.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.



-- 
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] extracting information from txt file

2012-10-31 Thread David Winsemius

On Oct 31, 2012, at 9:46 AM, chuck.01 wrote:

 Hello,
 
 Here is a link to some data:
 http://www.epa.gov/emap/html/data/surfwatr/data/mastreams/9396/wchem/chmval.txt
 
 I am trying to read this in, and want to use: 
 chmval -
 read.table(http://www.epa.gov/emap/html/data/surfwatr/data/mastreams/9396/wchem/chmval.txt;,
 sep=,, skip= 84, header=T)
 
 the # 84, for 84 lines skipped needs to be derived from the 5th line of the
 txt file  
 # Header Records:  85 
 
 so, I need that # (-1) for input into the read.table statement above

That # (-1) is fairly cryptic to my reading, but it appears you are seeing 
the behavior of the 3 character in terminating input for comments. Changing 
the comment character in the call to read.table will allow input from that line.

?read.table

You will need to read only the first 5 or 6 lines first, then execute a 
separate read.table while skipping input from those lines as well as the 
variable list that forms a secondary header.

 headfrm - read.table( file=url( 
 http://www.epa.gov/emap/html/data/surfwatr/data/mastreams/9396/wchem/chmval.txt;),
  nrows=6, sep=:, comment.char=)
 headfrm
V1   V2
1  Dataset   EMAP Stream Chemistry Data
2File Name   chmval
3 Date Created 02/22/99
4  # Variables   75
5 # Header Records   85
6   # Data Records  711



 
 I've tried grep but that didn't work: 
 (for this I downloaded the txt file and manually removed that hash mark!)
 
 grep(Header Records:, read.table(chmval.txt, header=T))
 Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, 
 : 
  line 1 did not have 5 elements
 
 Any ideas?
 Can I just extract the 5th line?
 
 
 
 
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/extracting-information-from-txt-file-tp4648033.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.

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] extracting information from txt file

2012-10-31 Thread David Winsemius

On Oct 31, 2012, at 11:11 AM, David Winsemius wrote:

 
 On Oct 31, 2012, at 9:46 AM, chuck.01 wrote:
 
 Hello,
 
 Here is a link to some data:
 http://www.epa.gov/emap/html/data/surfwatr/data/mastreams/9396/wchem/chmval.txt
 
 I am trying to read this in, and want to use: 
 chmval -
 read.table(http://www.epa.gov/emap/html/data/surfwatr/data/mastreams/9396/wchem/chmval.txt;,
 sep=,, skip= 84, header=T)
 
 the # 84, for 84 lines skipped needs to be derived from the 5th line of the
 txt file  
 # Header Records:  85 
 
 so, I need that # (-1) for input into the read.table statement above
 
 That # (-1) is fairly cryptic to my reading, but it appears you are seeing 
 the
 behavior of the 3 character in terminating input for comments.

That would be the shifted-3.


 Changing the comment character in the call to read.table will allow input 
 from that line.
 
 ?read.table
 
 You will need to read only the first 5 or 6 lines first, then execute a 
 separate read.table while skipping input from those lines as well as the 
 variable list that forms a secondary header.
 
 headfrm - read.table( file=url( 
 http://www.epa.gov/emap/html/data/surfwatr/data/mastreams/9396/wchem/chmval.txt;),
  nrows=6, sep=:, comment.char=)
 headfrm
V1   V2
 1  Dataset   EMAP Stream Chemistry Data
 2File Name   chmval
 3 Date Created 02/22/99
 4  # Variables   75
 5 # Header Records   85
 6   # Data Records  711
 
 
 
 
 I've tried grep but that didn't work: 
 (for this I downloaded the txt file and manually removed that hash mark!)
 
 grep(Header Records:, read.table(chmval.txt, header=T))
 Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, 
 : 
 line 1 did not have 5 elements
 
 Any ideas?
 Can I just extract the 5th line?
 
 
 
 
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/extracting-information-from-txt-file-tp4648033.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.
 
 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.

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] boxplots of various levels

2012-10-31 Thread dysonsphere
ok this is close, thanks for your effort

i will be more specific about my data set now, maybe that will help.

there are 2 cats, labeled rs29 and rs30
there are a number of experimental results, i will make a graph set for
each one. for example we can look at the results of BRCLNET.
the tasks are devided into right middle and left
the tasks are performed over time 1 to 10.

i was a boxplot per cat per side (1 left 1 middle 1 right) over the time (1
to 10)

at this point I have adjusted the code you sent me to this:
mydata  -  data.frame(BRCLNET, cat, side, group)

mydata then gives me a list of 4 columns: BRCLNET, cat, side, time
that is perfect

then:
ggplot(mydata , aes( group, BRCLNET, fill = cat ))+ geom_boxplot() +
+ facet_wrap(~side)

this gives me a figure divided into 3 columns: LEFT MIDDLE RIGHT
with 2 boxes in each (RS29 and RS30). the yaxis is labeled BRCLNET and the
xaxis is labeled time. but there is not a separate box for each time point.
there are only 2 boxes per plot.

i would like to have six separate plots:
1. LEFT RS29 BRCLNET over time (10 boxes)
2. MIDDLE RS29 BRCLNET overtime (10 boxes)
.
6. RIGHT RS30 BRCLNET over time

thanks for your help


On Wed, Oct 31, 2012 at 8:16 AM, John Kane [via R] 
ml-node+s789695n4647989...@n4.nabble.com wrote:

 I am not sure I understand exactly what you want but does this do anything
 like what you want?

 library(ggplot2)
 mydata  -  data.frame(result = rnorm(100), group = rep(c(1, 2), each
 = 50),
side = sample(c(L, R), 100, replace = TRUE) ,
 dtime = rep(1:10, each=10))

 p  -  ggplot(mydata , aes( group, result, fill = side ))+ geom_boxplot()
 +
 facet_wrap(~dtime)
 p

 John Kane
 Kingston ON Canada


  -Original Message-
  From: [hidden email]http://user/SendEmail.jtp?type=nodenode=4647989i=0
  Sent: Tue, 30 Oct 2012 11:21:49 -0700 (PDT)
  To: [hidden email]http://user/SendEmail.jtp?type=nodenode=4647989i=1
  Subject: [R] boxplots of various levels
 
  noob here
  trying to make boxplots of some data
  i would like to separate the boxplots according to conditons of various
  levels
  for example:
 
  i have
  group:1 and 2, each group performed tests consisting of
  condition A,B,C,D
  side: left and right
  time: 1 to 10
 
  I would like separate boxplots of the results (x) of the tests (numeric)
  for
  each group under each condition on each side over time.
 
  so far i have set it up like this:
  boxplot(test$x~test$time)
  this gives me the plot for all vaues of x in each time bin.  basicaly i
  would need a command that tells R to include only the data that agrees
  with
  the group, condition, and side I set.
  something like
  boxplot(test$x~test$time) where
  test$group=1,test$condition=A,test$side=left
 
  can this be done?
 
 
 
 
  --
  View this message in context:
  http://r.789695.n4.nabble.com/boxplots-of-various-levels-tp4647917.html
  Sent from the R help mailing list archive at Nabble.com.
 
  __
  [hidden email] 
  http://user/SendEmail.jtp?type=nodenode=4647989i=2mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.

 
 Send any screenshot to your friends in seconds...
 Works in all emails, instant messengers, blogs, forums and social
 networks.
 TRY IM TOOLPACK at http://www.imtoolpack.com/default.aspx?rc=if2 for FREE

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


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

 http://r.789695.n4.nabble.com/boxplots-of-various-levels-tp4647917p4647989.html
  To unsubscribe from boxplots of various levels, click 
 herehttp://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_codenode=4647917code=ZHlzb25zcGhlcmUyM0BnbWFpbC5jb218NDY0NzkxN3wtMTkzNDk0ODEyOA==
 .
 NAMLhttp://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewerid=instant_html%21nabble%3Aemail.namlbase=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespacebreadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml




-- 
Kenneth Stephen Dyson
Chercheur postdoctoral
Groupe de recherche sur le système nerveux central (GRSNC)

Université de Montréal
Département de physiologie
2960, chemin de la tour, bureau 4130
Montréal (Québec) Canada H3T 1J4

Tel: (514) 343-6111 ext 

[R] Problem Installing Packages

2012-10-31 Thread Hard Core
I run R as administrator but when i try to install packages i get this
message:

 install.packages()
Warning in install.packages :
  apertura non riuscita: stato HTTP '403 Forbidden'
Warning in install.packages :
  apertura non riuscita: stato HTTP '403 Forbidden'
Warning in install.packages :
  unable to access index for repository
http://cran.mirror.garr.it/mirrors/CRAN/bin/windows/contrib/2.15
Error in install.packages : no packages were specified

How can i solve this issue?



--
View this message in context: 
http://r.789695.n4.nabble.com/Problem-Installing-Packages-tp4648051.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] party tree coordinates

2012-10-31 Thread aelmore
I'm hoping that folks out there with expertise in working with the party
package can help me out here.  My team is trying to convert party tree
output into a text file format that can be read by our image processing
software.  We are running into difficulties because the way the two
different programs identify their nodes is different.

R numbers it's nodes 1, 2, 3, 4, 5, 6 etc. down the yes answers in the
tree until a terminal node is reached, at which point it backs up to the
parent of that terminal node, gives its no child the next number
available, follows any additional yes children down from there until it hits
a terminal node, and repeats necessary.

Our image processing system uses a coordinate system that labels each node
according to its location in the tree (e.g. row 4, column 43).  For
instance, the first split in the tree is at location (1,1), the two daughter
nodes are (2,1) and (2,2), and their daughters are (3,1), (3,2), (3,3),
(3,4), etc. etc. on down the tree.  It assigns these location coordinates
referencing all possible node locations.  In other words, if node (2,1) in
the above scenario happened to be a terminal node, the daughters of node 2,2
would still be labeled (3,3) and (3,4), even though nodes (3,1) and (3,2)
would not actually exist. They are still, from a labeling/ID perspective,
retained, as it were, as phantom place holders.

Given that the plot function in the party package is able to produce output
that shows these column and row relationships in graphical format, it seems
to me that there ought to be a way to extract this positional information
from the package, but I haven't found a way to do it yet.

The plot.tree info in the manual says it creates an (invisible) list with
components x and y giving the coordinates of the tree nodes, and I'm
wondering if it's talking about tree coordinates, as used by our image
processor, or if it's refering to the x and y position on the printed plot.
Either way, I don't know how to access those x/y numbers. 

At any rate, I'm pretty stumped.  It seems to me that since the positional
relationships are produced in the plots, there ought to be a way to get at
them, programmatically.

Any suggestions out there?





--
View this message in context: 
http://r.789695.n4.nabble.com/party-tree-coordinates-tp4648047.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] predict glm() with offset

2012-10-31 Thread Lucas Chaparro
Dear R friends.
I have a question about running a glm( family= 'binomial', *offset=T*), (I
know offset is a vector of values)
My doubt is about predicting the values on a new data. Does the predict()
function considers the offset? o should I especified something?

Here is the model I´m using:

*model-stepAIC(glm(f_ocur~altitud+UTM_X+UTM_Y+j_sin+j_cos+temp_res+pp,
offset=(log(1/offset)) data=data,
family='binomial', ), direction='both')*

Now, I want to get the estimated values, how should I do it considering
that I´m stablishing an offset value in the model?

If anyone can help me, i´d really appreciate it.

Thank you.

Lucas.

[[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] Stock Watson DOLS in R

2012-10-31 Thread Stephen Howe
Hi everyone,

Longtime reader first time questioner. A colleague was showing me the
EViews statistical package and demonstrating some of its regression
capabilities--like DOLS--and commenting how easy it was to do certain kinds
of regression. Being more of an R type, I went to try and replicate his
regression results in R and to my surprise couldn't find a way--or anyone
discussing how--to perform a dynamic ordinary least squares regression in
R. Are there any packages or guidelines on how to do this?

I've started messing with d() and L() in dynlm to see if I can recreate the
leads/lags portions of the DOLS equation, but I'm having little success at
the moment. I'm incredibly confused how to do this at the moment so any
pointers would be appreciated!

Sincerely,

Stephen

[[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] extracting information from txt file

2012-10-31 Thread Taimur Sajid
This worked for the example you provided. Assumes the header count is the only 
numeric value on the 5th line.

epa_extract - function(address){
doc - readLines(address, n = 5)[5]

head_count - as.numeric(gsub(\\D, , doc))

read.table(address, sep = ,, header = TRUE, skip = head_count)
}

foo - 
epa_extract(http://www.epa.gov/emap/html/data/surfwatr/data/mastreams/9396/wchem/chmval.txt;)


Taimur Sajid
Research  Development Analyst
Primatics Financial

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of chuck.01
Sent: Wednesday, October 31, 2012 12:47 PM
To: r-help@r-project.org
Subject: [R] extracting information from txt file

Hello,

Here is a link to some data:
http://www.epa.gov/emap/html/data/surfwatr/data/mastreams/9396/wchem/chmval.txt

I am trying to read this in, and want to use: 
chmval -
read.table(http://www.epa.gov/emap/html/data/surfwatr/data/mastreams/9396/wchem/chmval.txt;,
sep=,, skip= 84, header=T)

the # 84, for 84 lines skipped needs to be derived from the 5th line of the txt 
file # Header Records:  85 

so, I need that # (-1) for input into the read.table statement above

I've tried grep but that didn't work: 
 (for this I downloaded the txt file and manually removed that hash mark!)

grep(Header Records:, read.table(chmval.txt, header=T)) Error in scan(file, 
what, nmax, sep, dec, quote, skip, nlines, na.strings,
: 
  line 1 did not have 5 elements

Any ideas?
Can I just extract the 5th line?




--
View this message in context: 
http://r.789695.n4.nabble.com/extracting-information-from-txt-file-tp4648033.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] HELP!! how to remove 10% of data randomly in R

2012-10-31 Thread arun
HI,

May be this helps.


dat1-read.table(text=
  TDate TTime    O3  No2 Temp Sun Wspeed Wdirect Hum Indicator
1    19980101  2400 0.065 0.036 31.4 765    9.9    351  NA    1
2    19980102  2400 0.053 0.025 31.8 624    7.7    351  NA    1
3    19980103  2400 0.027 0.033 31.5 852    8.8    331  NA    2
4    19980104  2400 0.034 0.023 30.7 679    7.0    338  NA    2
5    19980105  2400 0.019 0.016 28.1 376    9.6    354  NA    1
6    19980106  2400 0.021 0.018 29.9 603    9.3    356  NA    1
7    19980107  2400 0.026 0.047 31.2 857  10.7    336  NA    1
8    19980108  2400 0.024 0.014 31.1 635    7.8    330  NA    1
9    19980109  2400 0.058 0.033 32.5 742  10.7    334  NA    1
10  19980110  2400 0.026 0.032 33.9 923  10.6    347  NA    2
11  19980111  2400 0.064 0.034 32.5 751    6.3    355  NA    2
12  19980112  2400 0.066 0.034 33.3 697    8.5    319  NA    1
13  19980113  2400 0.026 0.030 33.4 992  12.5    341  NA    1
14  19980114  2400 0.101 0.028 33.8 705    8.7    349  NA    1
15  19980115  2400 0.069 0.030 33.3 718  11.4    348  NA    1
16  19980116  2400 0.054 0.026 33.4 639  10.9    354  NA    1
17  19980117  2400 0.090 0.039 33.1 653  13.2    342  NA    2
18  19980118  2400 0.048 0.017 33.2 825  10.8    323  NA    2
19  19980119  2400 0.038 0.027 33.7 984  10.3    353  NA    1
20  19980120  2400 0.026 0.032 34.2 994  15.0    357  NA    1
21  19980121  2400 0.065 0.044 33.8 999  17.5    343  NA    1
22  19980122  2400 0.046 0.024 33.5 931  10.1    332  NA    1
23  19980123  2400 0.050 0.041 33.9 881  11.3    353  NA    1
24  19980124  2400 0.036 0.027 33.8 877    9.1    328  NA    2
25  19980125  2400 0.043 0.021 33.2 777  10.5    340  NA    2
26  19980126  2400 0.029 0.016 33.1 999  14.1    341  NA    1
27  19980127  2400 0.033 0.030 33.9 943  12.9    344  NA    1
28  19980128  2400 0.040 0.022 33.7 805  12.6    354  NA    1
29  19980129  2400 0.029 0.015 30.2 512    7.4    356  NA    1
30  19980130  2400 0.027 0.013 31.7 656  13.9    349  NA    1
,sep=,header=TRUE,stringsAsFactors=FALSE)

#creating NA for 10% of data in the specified columns (deviant of David's 
method).  
is.na(dat1[sample(1:nrow(dat1),0.1*nrow(dat1)),3:7])-TRUE
tail(dat1)
#  TDate TTime    O3   No2 Temp Sun Wspeed Wdirect Hum Indicator
#25 19980125  2400    NA    NA   NA  NA NA 340  NA 2
#26 19980126  2400 0.029 0.016 33.1 999   14.1 341  NA 1
#27 19980127  2400 0.033 0.030 33.9 943   12.9 344  NA 1
#28 19980128  2400 0.040 0.022 33.7 805   12.6 354  NA 1
#29 19980129  2400 0.029 0.015 30.2 512    7.4 356  NA 1
#30 19980130  2400 0.027 0.013 31.7 656   13.9 349  NA 1

#If you need to create NA for individual columns randomly
res-do.call(cbind,lapply(lapply(dat1[,3:7],function(x) 
data.frame(x)),function(x) x[sample(1:nrow(x),0.1*nrow(x)),]))
dat1[,3][dat1[,3]%in%res[,1]]-NA
 dat1[,4][dat1[,4]%in%res[,2]]-NA
 dat1[,5][dat1[,5]%in%res[,3]]-NA
 dat1[,6][dat1[,6]%in%res[,4]]-NA
dat1[,7][dat1[,7]%in%res[,5]]-NA
 head(dat1)
# TDate TTime    O3   No2 Temp Sun Wspeed Wdirect Hum Indicator
#1 19980101  2400 0.065 0.036 31.4 765    9.9 351  NA 1
#2 19980102  2400 0.053 0.025 31.8 624    7.7 351  NA 1
#3 19980103  2400 0.027 0.033 31.5 852    8.8 331  NA 2
#4 19980104  2400    NA    NA 30.7 679    7.0 338  NA 2
#5 19980105  2400 0.019 0.016 28.1 376    9.6 354  NA 1
#6 19980106  2400 0.021 0.018 29.9 603 NA 356  NA 1

A.K.

- Original Message -
From: Eugenie leemean...@hotmail.com
To: r-help@r-project.org
Cc: 
Sent: Wednesday, October 31, 2012 8:42 AM
Subject: Re: [R] HELP!! how to remove 10% of data randomly in R

  tDate tTime    O3   No2 Temp Sun Wspeed Wdirect Hum Indicator
1    19980101  2400 0.065 0.036 31.4 765    9.9     351  NA         1
2    19980102  2400 0.053 0.025 31.8 624    7.7     351  NA         1
3    19980103  2400 0.027 0.033 31.5 852    8.8     331  NA         2
4    19980104  2400 0.034 0.023 30.7 679    7.0     338  NA         2
5    19980105  2400 0.019 0.016 28.1 376    9.6     354  NA         1
6    19980106  2400 0.021 0.018 29.9 603    9.3     356  NA         1
7    19980107  2400 0.026 0.047 31.2 857   10.7     336  NA         1
8    19980108  2400 0.024 0.014 31.1 635    7.8     330  NA         1
9    19980109  2400 0.058 0.033 32.5 742   10.7     334  NA         1
10   19980110  2400 0.026 0.032 33.9 923   10.6     347  NA         2
11   19980111  2400 0.064 0.034 32.5 751    6.3     355  NA         2
12   19980112  2400 0.066 0.034 33.3 697    8.5     319  NA         1
13   19980113  2400 0.026 0.030 33.4 992   12.5     341  NA         1
14   19980114  2400 0.101 0.028 33.8 705    8.7     349  NA         1
15   19980115  2400 0.069 0.030 33.3 718   11.4     348  NA         1
16   19980116  2400 0.054 0.026 33.4 639   10.9 

Re: [R] boxplots of various levels

2012-10-31 Thread Rui Barradas
Hello,

Like this?


library(ggplot2)
set.seed(3101)
mydata - data.frame(
 BRCLNET = rnorm(1000),
 group = rep(c(1, 2), each = 500),
   side = sample(c(Left, Middle, Right), 1000, replace = TRUE) ,
 dtime = rep(1:10, 100))



p  -  ggplot(mydata , aes(factor(dtime), BRCLNET, fill = side)) +
 geom_boxplot() +
 facet_grid(group~side)
p


Note that it's factor(dtime) and facet_grid(), not facet_wrap()

Hope this helps,

Rui Barradas
Em 31-10-2012 17:33, dysonsphere escreveu:
 ok this is close, thanks for your effort

 i will be more specific about my data set now, maybe that will help.

 there are 2 cats, labeled rs29 and rs30
 there are a number of experimental results, i will make a graph set for
 each one. for example we can look at the results of BRCLNET.
 the tasks are devided into right middle and left
 the tasks are performed over time 1 to 10.

 i was a boxplot per cat per side (1 left 1 middle 1 right) over the time (1
 to 10)

 at this point I have adjusted the code you sent me to this:
 mydata  -  data.frame(BRCLNET, cat, side, group)

 mydata then gives me a list of 4 columns: BRCLNET, cat, side, time
 that is perfect

 then:
 ggplot(mydata , aes( group, BRCLNET, fill = cat ))+ geom_boxplot() +
 + facet_wrap(~side)

 this gives me a figure divided into 3 columns: LEFT MIDDLE RIGHT
 with 2 boxes in each (RS29 and RS30). the yaxis is labeled BRCLNET and the
 xaxis is labeled time. but there is not a separate box for each time point.
 there are only 2 boxes per plot.

 i would like to have six separate plots:
 1. LEFT RS29 BRCLNET over time (10 boxes)
 2. MIDDLE RS29 BRCLNET overtime (10 boxes)
 .
 6. RIGHT RS30 BRCLNET over time

 thanks for your help


 On Wed, Oct 31, 2012 at 8:16 AM, John Kane [via R] 
 ml-node+s789695n4647989...@n4.nabble.com wrote:

 I am not sure I understand exactly what you want but does this do anything
 like what you want?

 library(ggplot2)
 mydata  -  data.frame(result = rnorm(100), group = rep(c(1, 2), each
 = 50),
 side = sample(c(L, R), 100, replace = TRUE) ,
 dtime = rep(1:10, each=10))

 p  -  ggplot(mydata , aes( group, result, fill = side ))+ geom_boxplot()
 +
  facet_wrap(~dtime)
 p

 John Kane
 Kingston ON Canada


 -Original Message-
 From: [hidden email]http://user/SendEmail.jtp?type=nodenode=4647989i=0
 Sent: Tue, 30 Oct 2012 11:21:49 -0700 (PDT)
 To: [hidden email]http://user/SendEmail.jtp?type=nodenode=4647989i=1
 Subject: [R] boxplots of various levels

 noob here
 trying to make boxplots of some data
 i would like to separate the boxplots according to conditons of various
 levels
 for example:

 i have
 group:1 and 2, each group performed tests consisting of
 condition A,B,C,D
 side: left and right
 time: 1 to 10

 I would like separate boxplots of the results (x) of the tests (numeric)
 for
 each group under each condition on each side over time.

 so far i have set it up like this:
 boxplot(test$x~test$time)
 this gives me the plot for all vaues of x in each time bin.  basicaly i
 would need a command that tells R to include only the data that agrees
 with
 the group, condition, and side I set.
 something like
 boxplot(test$x~test$time) where
 test$group=1,test$condition=A,test$side=left

 can this be done?




 --
 View this message in context:
 http://r.789695.n4.nabble.com/boxplots-of-various-levels-tp4647917.html
 Sent from the R help mailing list archive at Nabble.com.

 __
 [hidden email] 
 http://user/SendEmail.jtp?type=nodenode=4647989i=2mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 Send any screenshot to your friends in seconds...
 Works in all emails, instant messengers, blogs, forums and social
 networks.
 TRY IM TOOLPACK at http://www.imtoolpack.com/default.aspx?rc=if2 for FREE

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


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

 http://r.789695.n4.nabble.com/boxplots-of-various-levels-tp4647917p4647989.html
   To unsubscribe from boxplots of various levels, click 
 herehttp://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_codenode=4647917code=ZHlzb25zcGhlcmUyM0BnbWFpbC5jb218NDY0NzkxN3wtMTkzNDk0ODEyOA==
 .
 

Re: [R] Problem Installing Packages

2012-10-31 Thread David Winsemius

On Oct 31, 2012, at 10:46 AM, Hard Core wrote:

 I run R as administrator but when i try to install packages i get this
 message:
 
 install.packages()
 Warning in install.packages :
  apertura non riuscita: stato HTTP '403 Forbidden'
 Warning in install.packages :
  apertura non riuscita: stato HTTP '403 Forbidden'
 Warning in install.packages :
  unable to access index for repository
 http://cran.mirror.garr.it/mirrors/CRAN/bin/windows/contrib/2.15
 Error in install.packages : no packages were specified
 
 How can i solve this issue?

What were you expecting to happen when you ran install.packages() with no 
arguments?

--
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] Lavaan model

2012-10-31 Thread yrosseel

On 10/31/2012 02:47 PM, sylvain.giroud wrote:

Dear R-users,
Does somebody know what does the Estimate reported by the Lavaan model
tell us?
I assume this tells the relative strength of the dyadic relations.


The 'Estimate' column contains the estimated model parameters. There are 
many different kinds of model parameters. Under the heading 'Latent 
variables', you may have factor loadings. Under the heading 
'Regressions' you may have regression coefficients. Other parameters are 
(residual) variances and (residual) covariances.


Yves Rosseel.
http://lavaan.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.


[R] expand.grip for permutations

2012-10-31 Thread trekvana
if i were to have a block size of 4 people and i want to assign a treatment
combination to the entire block, there would be 16 different treatment
combinations (, TTTP, TTPP, PTTP, etc.)

i am trying to get all 16 permutations and i am able to use this code below.

drugs=c('P','T');
comb=expand.grid(drugs,drugs,drugs,drugs)

for a block size of 3 the code would be comb=expand.grid(drugs,drugs,drugs)
and for a block size of 2 it would be comb=expand.grid(drugs,drugs).

my question is whether there is a way to automatically create the comb
variable. i tried using expand.grid(rep(drugs, block.size) but that didn't
work.

any help on how i can proceed? thanks



--
View this message in context: 
http://r.789695.n4.nabble.com/expand-grip-for-permutations-tp4648067.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] Webinar signup: Gradient Boosting and Classification Trees: A Winning Combination. November 9, 10-11 a.m., PST

2012-10-31 Thread Lisa Solomon
Webinar signup: 
Tree Ensembles and Classification Trees: A Winning Combination
November 9, 10-11 a.m., PST.

Webinar Registration: 
http://2.salford-systems.com/gradientboosting/ 

Understand major shortcomings of using only decision trees and how tree 
ensembles can help overcome these challenges and improve your model building. 
Combine all of the advantages of using classification and regression trees with 
the power-house interpretability of stochastic gradient boosting.
 __
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Strange compiling behaviour

2012-10-31 Thread Worik R
Compiling this little function gets me some strange behaviour

.initDataDir - function(){
  if(file.exists(LOCATION)) {
if(as.logical(file.info(LOCATION)[isdir]))return
stop(LOCATION,  exists but is not a directory)
  }
  Z - dir.create(LOCATION)
  if(!Z){
stop(geterrmessage())
##stop(Juggel)
  }
  return(Z)
}





 .initDataDir - function(){
+   if(file.exists(LOCATION)) {
+ if(as.logical(file.info(LOCATION)[isdir]))return
+ stop(LOCATION,  exists but is not a directory)
+   }
+   Z - dir.create(LOCATION)
+   if(!Z){
+ stop(geterrmessage())
+ ##stop(Juggel)
+   }
+   return(Z)
+ }
 LOCATION
[1] /xxx
 Q - .initDataDir()
Error in .initDataDir() :
  Error in .initDataDir() : Error in .initDataDir() :
  Error in .initDataDir() : Error in .initDataDir() : Juggel
In addition: Warning message:
In dir.create(LOCATION) :
  cannot create dir '/xxx', reason 'Permission denied'




I commented out the stop(Juggel) line

I made a mistake when I first created the function

stop(geterrormessage())

Which failed of course.


Here are some more attempts

 .initDataDir - function(){
+   if(file.exists(LOCATION)) {
+ if(as.logical(file.info(LOCATION)[isdir]))return
+ stop(LOCATION,  exists but is not a directory)
+   }
+   Z - dir.create(LOCATION)
+   if(!Z){
+ stop(geterrmessage())
+ stop(Juggel)
+   }
+   return(Z)
+ }
 LOCATION
[1] /xxx
 Q - .initDataDir()
Error in .initDataDir() : Error in .initDataDir() : Juggel
In addition: Warning message:
In dir.create(LOCATION) :
  cannot create dir '/xxx', reason 'Permission denied'
 .initDataDir - function(){
+   if(file.exists(LOCATION)) {
+ if(as.logical(file.info(LOCATION)[isdir]))return
+ stop(LOCATION,  exists but is not a directory)
+   }
+   Z - dir.create(LOCATION)
+   if(!Z){
+ stop(geterrormessage())
+ stop(Juggel)
+   }
+   return(Z)
+ }
 LOCATION
[1] /xxx
 Q - .initDataDir()
Error in stop(geterrormessage()) :
  could not find function geterrormessage
In addition: Warning message:
In dir.create(LOCATION) :
  cannot create dir '/xxx', reason 'Permission denied'



I tried killing the R session and restarting and then got this

 .initDataDir - function(){
+   if(file.exists(LOCATION)) {
+ if(as.logical(file.info(LOCATION)[isdir]))return
+ stop(LOCATION,  exists but is not a directory)
+   }
+   Z - dir.create(LOCATION)
+   if(!Z){
+ stop(geterrmessage())
+ ##stop(Juggel)
+   }
+   return(Z)
+ }
 LOCATION - /
 Q - .initDataDir()
Error in .initDataDir() : Error in stop(geterrormessage()) :
  could not find function geterrormessage
In addition: Warning message:
In dir.create(LOCATION) :
  cannot create dir '/', reason 'Permission denied'


This is very strange, but not a show stopper.




.version
   _
platform   x86_64-pc-linux-gnu
arch   x86_64
os linux-gnu
system x86_64, linux-gnu
status
major  2
minor  14.1
year   2011
month  12
day22
svn rev57956
language   R
version.string R version 2.14.1 (2011-12-22)


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] Problem Installing Packages

2012-10-31 Thread R. Michael Weylandt
On Wed, Oct 31, 2012 at 8:25 PM, David Winsemius dwinsem...@comcast.net wrote:

 On Oct 31, 2012, at 10:46 AM, Hard Core wrote:

 I run R as administrator but when i try to install packages i get this
 message:

 install.packages()
 Warning in install.packages :
  apertura non riuscita: stato HTTP '403 Forbidden'
 Warning in install.packages :
  apertura non riuscita: stato HTTP '403 Forbidden'
 Warning in install.packages :
  unable to access index for repository
 http://cran.mirror.garr.it/mirrors/CRAN/bin/windows/contrib/2.15
 Error in install.packages : no packages were specified

 How can i solve this issue?

 What were you expecting to happen when you ran install.packages() with no 
 arguments?


Fo me it brings up an interactive menu, so I don't think that's the problem.

Have you tried a different mirror? Italy/Milano seems down but
Italy/Padua works for me.

Use the chooseCRANmirror() function.

Cheers,
Michael

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

2012-10-31 Thread William Dunlap
Instead of  
   rep(drugs, block.size)
use
   rep(list(drugs), block.size)
as the argument to expand.grid.

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 trekvana
 Sent: Wednesday, October 31, 2012 1:18 PM
 To: r-help@r-project.org
 Subject: [R] expand.grip for permutations
 
 if i were to have a block size of 4 people and i want to assign a treatment
 combination to the entire block, there would be 16 different treatment
 combinations (, TTTP, TTPP, PTTP, etc.)
 
 i am trying to get all 16 permutations and i am able to use this code below.
 
 drugs=c('P','T');
 comb=expand.grid(drugs,drugs,drugs,drugs)
 
 for a block size of 3 the code would be comb=expand.grid(drugs,drugs,drugs)
 and for a block size of 2 it would be comb=expand.grid(drugs,drugs).
 
 my question is whether there is a way to automatically create the comb
 variable. i tried using expand.grid(rep(drugs, block.size) but that didn't
 work.
 
 any help on how i can proceed? thanks
 
 
 
 --
 View this message in context: http://r.789695.n4.nabble.com/expand-grip-for-
 permutations-tp4648067.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] Cannot rescale a constant/zero column error.

2012-10-31 Thread Kevin Wright
Sounds like one of your data columns is constant.  The variance of a
constant is 0, and scaling would then divide by 0, which is impossible.

Kevin Wright


On Wed, Oct 31, 2012 at 7:47 AM, fillay89 jasonf...@gmail.com wrote:

 I am trying to run the R Script below, I have actually simplified it to
 just
 this part that is causing issues.  When I run this script I continue to get
 an error that says cannot rescale a constant/zero column to a unit
 variance.  I cannot figure out what is going on here.  I have stripped
 down
 my data file so it is more manageable so I can try to figure this out.

 The data.txt file that is being read looks like this:


 I have made this file very basic on purpose to see if I could get this to
 work, but it is not working.  Of course once I get this to actually work I
 will expand the data file to match the data I am actually using.



 If I change the attribute in the prcomp function to scale=FALSE of course I
 can run my script.  But if it is scaling...which is causing the issues, it
 errors.

 Any help would be GREATLY appreciated.



 --
 View this message in context:
 http://r.789695.n4.nabble.com/Cannot-rescale-a-constant-zero-column-error-tp4647996.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.




-- 
Kevin Wright

[[alternative HTML version deleted]]

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


Re: [R] party tree coordinates

2012-10-31 Thread Achim Zeileis

On Wed, 31 Oct 2012, aelmore wrote:


I'm hoping that folks out there with expertise in working with the party
package can help me out here.  My team is trying to convert party tree
output into a text file format that can be read by our image processing
software.  We are running into difficulties because the way the two
different programs identify their nodes is different.

R numbers it's nodes 1, 2, 3, 4, 5, 6 etc. down the yes answers in the 
tree until a terminal node is reached, at which point it backs up to the 
parent of that terminal node, gives its no child the next number 
available, follows any additional yes children down from there until it 
hits a terminal node, and repeats necessary.


And that's essentially also how the visualization works. A suitably sized 
grid is set up first and then grid viewports are recursively created and 
traversed.


Our image processing system uses a coordinate system that labels each 
node according to its location in the tree (e.g. row 4, column 43). 
For instance, the first split in the tree is at location (1,1), the two 
daughter nodes are (2,1) and (2,2), and their daughters are (3,1), 
(3,2), (3,3), (3,4), etc. etc. on down the tree.  It assigns these 
location coordinates referencing all possible node locations.  In other 
words, if node (2,1) in the above scenario happened to be a terminal 
node, the daughters of node 2,2 would still be labeled (3,3) and (3,4), 
even though nodes (3,1) and (3,2) would not actually exist. They are 
still, from a labeling/ID perspective, retained, as it were, as phantom 
place holders.


Given that the plot function in the party package is able to produce 
output that shows these column and row relationships in graphical 
format, it seems to me that there ought to be a way to extract this 
positional information from the package, but I haven't found a way to do 
it yet.


I think we haven't got anything in the package that delivers this out of 
the box. (Also note that the tree is often sparser than all binary splits 
that could occur.)


The plot.tree info in the manual says it creates an (invisible) list 
with components x and y giving the coordinates of the tree nodes, and 
I'm wondering if it's talking about tree coordinates, as used by our 
image processor, or if it's refering to the x and y position on the 
printed plot. Either way, I don't know how to access those x/y numbers.


That's not from the party package anyways. plot.tree is from the tree 
package whose code bases are not related.


At any rate, I'm pretty stumped.  It seems to me that since the 
positional relationships are produced in the plots, there ought to be a 
way to get at them, programmatically.


Any suggestions out there?


I would suggest that you take a loot at the partykit package. It 
contains a reimplementation of ctree() based on acleaner design of the 
recursive tree structure. It also offers more functions for user 
interaction. It comes with a vignette that is still somewhat rough but 
should give you a good idea how things work.


hth,
Z

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Σχετ: Σχετ: Swap rows and columns in a matrix

2012-10-31 Thread Rolf Turner

Okay; I think I get it.  One (rather kludgy) way of accomplishing your goal
is as follows:  Let the two matrices which you want to check for being
isomorphic be A and B.  Do:

rA - apply(A,1,paste,collapse= )
rB - apply(B,1,paste,collapse= )
cA - apply(A,2,paste,collapse= )
cB - apply(B,2,paste,collapse= )
iso - all(sort(rA) == sort(rB)) | all(sort(cA) == sort(cB))

Then iso will be TRUE if A and B are isomorphic and FALSE otherwise.

As you can see, this works by converting the rows and columns of your
matrices to character strings.  This should be OK --- I think that the base
method duplicated.data.frame() works along similar lines --- but it does
seem kludgy to me.

Perhaps someone else will come up with a sexier idea.

 cheers,

 Rolf

On 31/10/12 19:57, Haris Rhrlp wrote:

 i want to check for isomorphish between matrices i will give you an 
 example to see what i want.

 1 -1 -1 1  1  1
 1  1  11 -1 -1
 -1 -1 1  -1 -1 1
 -1 1 -1 -1 1 -1
 this 2 matrices are isomorphic beacause if i swap the first 2 rows the 
 matrices will be intetical
 next example

 1 -1 -1 -1  1  -1
 1  1  1   1  1   1
 -1 -1 1   -1 -1  1
 -1 1 -1  1 -1 -1

 this 2 matrices are isomorphic beacuse if i swap the first 2 columns 
 the matrices will be intetical

 i want to write an algorithm to check all the swaps of the rows and 
 all the swaps of the columns

 and then if the matrices are indetical then will be isomorphic

 *Áðï:* Rolf Turner rolf.tur...@xtra.co.nz
 *Ðñïò:* Haris Rhrlp haris_r_h...@yahoo.com
 *Êïéí.:* R-help@r-project.org R-help@r-project.org
 *ÓôÜëèçêå:* 10:53 ì.ì. Ôñßôç, 30 Ïêôùâñßïõ 2012
 *Èåìá:* Re: Ó÷åô: [R] Swap rows and columns in a matrix


 Unless there is a good reason not to, you should keep discussions
 on-list.

 On 31/10/12 08:29, Haris Rhrlp wrote:
 thank you for your answer but i dont want the transpose of matrix. I 
 want to swap rows seperatly and columns the same

 Then I am afraid that your question is all Greek to me. :-)

 You will have to explain --- with a simple example or two --- exactly what
 it is that you want to accomplish.

 cheers,

 Rolf Turner

 
 *Áðï:* Rolf Turner rolf.tur...@xtra.co.nz 
 mailto:rolf.tur...@xtra.co.nz
 *Ðñïò:* Haris Rhrlp haris_r_h...@yahoo.com 
 mailto:haris_r_h...@yahoo.com
 *Êïéí.:* R-help@r-project.org mailto:R-help@r-project.org 
 R-help@r-project.org mailto:R-help@r-project.org
 *ÓôÜëèçêå:* 9:17 ì.ì. Ôñßôç, 30 Ïêôùâñßïõ 2012
 *Èåìá:* Re: [R] Swap rows and columns in a matrix

 On 31/10/12 07:59, Haris Rhrlp wrote:
  Dear R users,
 
  I want a help to write an algorithm for swapping rows and columns 
 in a matrix
 
  thanks in advance

 ?t

 (???)




[[alternative HTML version deleted]]

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


Re: [R] expand.grip for permutations

2012-10-31 Thread trekvana
thank you both! that worked!



--
View this message in context: 
http://r.789695.n4.nabble.com/expand-grip-for-permutations-tp4648067p4648076.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] gauss fit with outlier removal

2012-10-31 Thread Dieter Best
I have distribution that are gaussian to a good approximation. I fit a
gaussian to these distributons. Once in a while there is an outlier. Could
someone suggest a robust method (R package already?) that removes those
outliers and redoes the gaussian fit to get a better fit? 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] Clustering groups according to multiple variables

2012-10-31 Thread Matthew Ouellette
Dear R help,


I am trying to cluster my data according to group in a data frame such as
the following:

df=data.frame(group=rep(c(a,b,c,d),10),(replicate(100,rnorm(40


I'm not sure how to tell hclust() that I want to cluster according to the
group variable.  For example:

dfclust=hclust(dist(df),ave)

plot(dfclust)

Clusters according to each individual row.  What I'm looking for is an
unrooted tree that will show similarity/dissimilarity among groups
according to the data set as a whole.

I appreciate the help,


MO

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


  1   2   >