Re: [R] ginv / LAPACK-SVD causes R to segfault on a large matrix.

2013-01-15 Thread Cyrus Shaoul
Thanks for trying it out, David. Unfortunately it isn't reproducible with a
machine with 64 Gb of RAM or more.

Yours,

Cyrus




On Mon, Jan 14, 2013 at 8:25 PM, David Winsemius dwinsem...@comcast.netwrote:


 On Jan 14, 2013, at 9:07 AM, Cyrus Shaoul wrote:

  No, Mehmet, I haven't tried that yet. I was hoping to find out if there
 was
  some other option. I have no experience using LAPACK directly. I have
  looked into RcppEigen and RcppArmadillo, but have not tested them yet.
 
  If there are no other options, I guess I will go down that path.

 I tried it on a 64 bit R with 32GB of RAM. It exhausted those resources
 and started paging out into virtual memory. No error, but I killed the
 process.

 --
 David.

 
  Thanks a lot,
 
  Cyrus
 
 
  On Mon, Jan 14, 2013 at 4:17 PM, Suzen, Mehmet msu...@gmail.com wrote:
 
  On 14 January 2013 15:08, Cyrus Shaoul cyrus.sha...@uni-tuebingen.de
  wrote:
  La.svd
 
  Dear Cyrus,
 
  Have you tried running La.svd ; LAPACK only version (without R) via
  C/C++ or Fortran code? After all it can be a
  LAPACK issue and R-team has no control on that.
 


 David Winsemius
 Alameda, CA, USA




-- 
Cyrus Shaoul, PhD
http://www.sfs.uni-tuebingen.de/~cshaoul/

[[alternative HTML version deleted]]

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


Re: [R] How to open grib file in R?

2013-01-15 Thread Barry Rowlingson
On Mon, Jan 14, 2013 at 6:26 PM, Jonsson amen.alya...@bordeaux.inra.fr wrote:
 I have just contacted the sources and I am told that he checked min/max
 lat/lon for the file and it was right. He is using Linux while I am using
 Windows, would that be problematic?

gdalinfo on a Linux box says it has the same problem:

$ gdalinfo Vol_025_H14_2010060700.grib
Warning: Inside GRIB2Inventory, Message # 5
ERROR: Ran out of file reading SECT0
There were 76 trailing bytes in the file.
Driver: GRIB/GRIdded Binary (.grb)
Files: Vol_025_H14_2010060700.grib
Size is 1440, 721
Coordinate System is:
GEOGCS[Coordinate System imported from GRIB file,
DATUM[unknown,
SPHEROID[Sphere,6367470,0]],
PRIMEM[Greenwich,0],
UNIT[degree,0.0174532925199433]]
Origin = (-0.125,90.125)
Pixel Size = (0.250,-0.250)
Corner Coordinates:
Upper Left  (  -0.125,  90.125) (  0d 7'30.00W, 90d 7'30.00N)
Lower Left  (  -0.125, -90.125) (  0d 7'30.00W, 90d 7'30.00S)
Upper Right ( 359.875,  90.125) (359d52'30.00E, 90d 7'30.00N)
Lower Right ( 359.875, -90.125) (359d52'30.00E, 90d 7'30.00S)
Center  ( 179.875,   0.000) (179d52'30.00E,  0d 0' 0.01N)

Now go ask your source why they are using 721 pixels from N to S...

I don't have anything else that can read grib files, so I can't say
any more, and as a binary file format its hard to tell if gdalinfo is
correct or not, but its usually pretty good.

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

2013-01-15 Thread Karan Anand
Hi,
I  have a graph where my y axis are scaled in the interval of 500 ,i
want to make them i the interval of 2,so pls can u help me out.


karan

[[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] function coverage

2013-01-15 Thread Keith Jewell

On 14/01/2013 22:25, Hadley Wickham wrote:

I think codetools could do this reasonably well with the walkCode function,
but I've never done it so I don't have sample code, and walkCode is mostly
an internal function.


There are a couple of approaches here:
http://stackoverflow.com/questions/14276728/

Hadley


I've used foodweb in mvbutils for that kind of thing.

HTH

KJ

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

2013-01-15 Thread Jim Lemon

On 01/15/2013 04:06 PM, Karan Anand wrote:

Hi,
 I  have a graph where my y axis are scaled in the interval of 500 ,i
want to make them i the interval of 2,so pls can u help me out.



Hi karan,
This appears to be a nonsensical request, as you seem to be asking for 
the number of tick marks on the Y axis to be multiplied by 250 times. R 
typically puts five or six tick marks on an axis by default, and 1250 to 
1500 tick marks would produce a solid line if you could manage to do it. 
Perhaps if you could give a bit more information about what you want to 
achieve we could be more helpful.


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] Need some help on Text manipulation.

2013-01-15 Thread Pascal Oettli

Hi,

If you only need aa to be replaced by a, bb by b and so on, try 
the following:


Dat$att - as.factor(substr(Dat$att,1,1))

HTH,
Pascal


Le 15/01/2013 18:48, Christofer Bogaso a écrit :

Dear all,

Let say I have following data-frame:

Dat - structure(list(dat = c(-0.387795842956327, -0.23270882099043,
-0.89528973290562, 0.95857175595512, 1.61680582493783, -1.17738110289352,
0.210601060411423, -0.827369747447338, -0.36896112964414, 0.440288648776096,
1.28018410608809, -0.897113649961341, 0.342216546981718, -1.17288066266219,
-1.57994101992621, -0.913655547602414, -2.54753726314408, -0.617703410989815,
-0.443272763891558, 0.359181170918489), att = structure(c(2L,
2L, 2L, 4L, 2L, 2L, 1L, 3L, 1L, 4L, 1L, 2L, 2L, 2L, 2L, 4L, 2L,
2L, 4L, 2L), .Label = c(aa, bb, cc, dd), class = factor)),
.Names = c(dat,
att), row.names = c(NA, -20L), class = data.frame); Dat


Now I want to replace the 2nd column with:

Replace - letters[1:20]

The rule is as follows:

Consider the 1st element of the 2nd colume: 'bb'. Now I need to see
which element of 'Replace' is contained in 'bb'? Obviously, this will
be 'b'. Therefore I need to replace bb with b. And so on for all
elements of 2nd column.

This is obviously an straightforward example. However I have some more
complex problem of replacing like that. I want to get the idea how to
achieve that programmatically.

Can somebody help me?

Thanks and regards,

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



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


[R] Removing an attached object

2013-01-15 Thread Pancho Mulongeni
Dear All,
I am a bit confused, I attached my data frame using 'attach(DATA)'
Then I removed it using 'rm(DATA)'
But for some reason it is still at position 2 at the search path
search()
 [1] .GlobalEnvDATA  package:foreign  
 [4] package:stats package:graphics  package:grDevices
 [7] package:datasets  package:rcom  package:rscproxy 
[10] package:utils package:methods   RExcelEnv
[13] Autoloads package:base 

Also when I enter the names of factors in this dataframe, such as 'AGE', I get 
a list of data values.
This is weird, why does it not disappear from the search path?
Thanks

Pancho Mulongeni
Research Assistant
PharmAccess Foundation
1 Fouché Street
Windhoek West
Windhoek
Namibia
 
Tel:   +264 61 419 000
Fax:  +264 61 419 001/2
Mob: +264 81 4456 286

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

2013-01-15 Thread Pascal Oettli

Hi,

Please read the following:

http://stackoverflow.com/questions/3536036/rmlist-ls-doesnt-completely-clear-the-workspace

HTH,
Pascal


Le 15/01/2013 19:55, Pancho Mulongeni a écrit :

Dear All,
I am a bit confused, I attached my data frame using 'attach(DATA)'
Then I removed it using 'rm(DATA)'
But for some reason it is still at position 2 at the search path
search()
  [1] .GlobalEnvDATA  package:foreign
  [4] package:stats package:graphics  package:grDevices
  [7] package:datasets  package:rcom  package:rscproxy
[10] package:utils package:methods   RExcelEnv
[13] Autoloads package:base

Also when I enter the names of factors in this dataframe, such as 'AGE', I get 
a list of data values.
This is weird, why does it not disappear from the search path?
Thanks

Pancho Mulongeni
Research Assistant
PharmAccess Foundation
1 Fouché Street
Windhoek West
Windhoek
Namibia

Tel:   +264 61 419 000
Fax:  +264 61 419 001/2
Mob: +264 81 4456 286

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

2013-01-15 Thread Pancho Mulongeni
Thanks, that makes it clear

-Original Message-
From: Pascal Oettli [mailto:kri...@ymail.com] 
Sent: Tuesday, January 15, 2013 1:07 PM
To: Pancho Mulongeni
Cc: R help
Subject: Re: [R] Removing an attached object

Hi,

Please read the following:

http://stackoverflow.com/questions/3536036/rmlist-ls-doesnt-completely-clear-the-workspace

HTH,
Pascal


Le 15/01/2013 19:55, Pancho Mulongeni a écrit :
 Dear All,
 I am a bit confused, I attached my data frame using 'attach(DATA)'
 Then I removed it using 'rm(DATA)'
 But for some reason it is still at position 2 at the search path
 search()
   [1] .GlobalEnvDATA  package:foreign
   [4] package:stats package:graphics  package:grDevices
   [7] package:datasets  package:rcom  package:rscproxy
 [10] package:utils package:methods   RExcelEnv
 [13] Autoloads package:base

 Also when I enter the names of factors in this dataframe, such as 'AGE', I 
 get a list of data values.
 This is weird, why does it not disappear from the search path?
 Thanks

 Pancho Mulongeni
 Research Assistant
 PharmAccess Foundation
 1 Fouché Street
 Windhoek West
 Windhoek
 Namibia

 Tel:   +264 61 419 000
 Fax:  +264 61 419 001/2
 Mob: +264 81 4456 286

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

2013-01-15 Thread Usha Gurunathan
Hi AK

Got an error message with

library(ggplot2)
ggplot(BP.stack1,aes(x=factor(HiBP),fill=Obese))+geom_bar(position=fill)Error
in rename(x, .base_to_ggplot, warn_missing = FALSE) :
  could not find function revalue
ggplot(BP.stack1,aes(x=factor(HiBP),fill=Overweight))+geom_bar(position=fill)Error
in rename(x, .base_to_ggplot, warn_missing = FALSE) :
  could not find function revalue
I got the dot plot, thanks for that.

I have attached some plots, not sure how to interpret, they had
unusual patterns.Is it because of missing data? I tried removing the
missing data too. They still appeared the same. Do I need to transform
the data?


Thanks in advance.





On Tue, Jan 15, 2013 at 8:54 AM, arun smartpink...@yahoo.com wrote:

 HI,

 BP_2b-read.csv(BP_2b.csv,sep=\t)
 BP_2bNM-na.omit(BP_2b)

 BP.stack3 -
 reshape(BP_2bNM,idvar=CODEA,timevar=time,sep=,varying=list(c(Obese14,Obese21),c(Overweight14,Overweight21),c(hibp14,hibp21)),v.names=c(Obese,Overweight,HiBP),times=factor(c(1,2)),direction=long)
 library(car)
 BP.stack3$Obese- recode(BP.stack3$Obese,1='Obese';0='Not Obese')
 BP.stack3$Overweight- recode(BP.stack3$Overweight,1='Overweight';0='Not
 Overweight')

 library(ggplot2)
 ggplot(BP.stack3,aes(x=factor(HiBP),fill=Obese))+geom_bar(position=fill)

 ggplot(BP.stack3,aes(x=factor(HiBP),fill=Overweight))+geom_bar(position=fill)

 You could try lmer() from lme4.
 library(lme4)
 fm1-lmer(HiBP~time+(1|CODEA), family=binomial,data=BP.stack3) #check
 codes, not sure
 print(dotplot(ranef(fm1,post=TRUE),
   scales = list(x = list(relation = free)))[[1]])
 qmt1- qqmath(ranef(fm1, postVar=TRUE))
 print(qmt1[[1]])

 A.K.





 
 From: Usha Gurunathan usha.nat...@gmail.com
 To: arun smartpink...@yahoo.com
 Cc: R help r-help@r-project.org
 Sent: Monday, January 14, 2013 6:32 AM
 Subject: Re: [R] random effects model


 Hi AK

 I have been trying to create some plots. All being categorical variables,
 I am not getting any luck with plots. The few ones that have worked are
 below:

 barchart(~table(HiBP)|Obese,data=BP.sub3) ## BP.sub3 is the stacked data
 without missing values

 barchart(~table(HiBP)|Overweight,data=BP.sub3)

 plot(jitter(hibp14,factor=2)~jitter(Obese14,factor=2),col=gray,cex=0.7,
 data=Copy.of.BP_2)  ## Copy.of.BP_2 is the original wide format

 ## not producing any good plots with mixed models as well.
 summary(lme.3 - lme(HiBP~time, data=BP.sub3,random=~1|CODEA,
 na.action=na.omit))
 anova(lme.3)
 head(ranef(lme.3))
 print(plot(ranef(lme.3))) ##

 Thanks for any help.





 On Mon, Jan 14, 2013 at 4:33 AM, arun smartpink...@yahoo.com wrote:


 
 
 HI,
 
 I think I mentioned to you before that when you reshape the
 columns excluding the response variable, response variable gets repeated
 (in this case hibp14 or hibp21) and creates the error
 
 
 I run your code, there are obvious problems in the code so I didn't reach
 up to BP.gee
 
 
 BP_2b-read.csv(BP_2b.csv,sep=\t)
 BP.stack3 -
 reshape(BP_2b,idvar=CODEA,timevar=time,sep=_,varying=list(c(Obese14,Obese21),c(Overweight14,Overweight21)),v.names=c(Obese,Overweight),times=factor(c(1,2)),direction=long)
 
 
 BP.stack3 -
 transform(BP.stack3,CODEA=factor(CODEA),Sex=factor(Sex,labels=c(Male,Female)),MaternalAge=factor(MaternalAge,labels=c(39years
 or less,40-49 years,50 years or
 older)),Education=factor(Education,labels=c(Primary/special,Started
 secondary,Completed grade10, Completed grade12,
 College,University)),Birthplace=factor(Birthplace,labels=c(Australia,Other
 English-speaking,Other)))
 
  BP.stack3$Sex -
 factor(BP.stack3$Sex,levels=levels(BP.stack3$Sex)[c(2,1)])
 
  BP.sub3a -  subset(BP.stack3,subset=!(is.na(Sex)| is.na(Education)|
 is.na(Birthplace)|is.na(Education)|is.na(hibp14)| is.na(hibp21)))
  nrow(BP.sub3a)
 #[1] 3364
  BP.sub5a - BP.sub3a[order(BP.sub3a$CODEA),] # your code was BP.sub5a -
 BP.sub3a[order(BP.sub5a$CODEA),]
 
 ^ was not defined before
 #Next line
 BPsub3$Categ[BPsub6$Overweight==1BPsub3$time==1BPsub3$Obese==0]-
 Overweight14  #It should be BP.sub3 and what is BPsub6, it was not
 defined previously.
 #Error in BPsub3$Categ[BPsub6$Overweight == 1  BPsub3$time == 1 
 BPsub3$Obese ==  :
   #object 'BPsub3' not found
 
 
 
 
 
 
 
 A.K.
 
 
 
 From: Usha Gurunathan usha.nat...@gmail.com
 To: arun smartpink...@yahoo.com
 
 Sent: Sunday, January 13, 2013 1:51 AM
 
 Subject: Re: [R] random effects model
 
 
 
 HI AK
 
 Thanks a lot  for explaining that.
 
 1. With the chi sq. ( in order to find out if the diffce is significant
 between groups) do I have create a separate excel file and make a
 dataframe.How do I go about it?
 
 I have resent a mail to Jun Yan at a difft email ad( first add.didn't
 work, mail not delivered).
 
 2. With my previous query ( reg. Obese/Overweight/ Normal at age 14 Vs
 change of blood pressure status at 21), even though I had compromised
 without the age-specific regression, but I am still keen to explore why the
 

Re: [R] Tukey HSD plot with lines indicating (non-)significance

2013-01-15 Thread Richard M. Heiberger
Karl,

Thank you for this interesting challenge.  It turns out to be reasonably
straightforward.
This code does it for the first example in ?MMC.

## This example is based on the example in ?HH:::MMC

library(HH)

## pairwise comparisons
data(catalystm)


## A. individual plots

## base graphics box plot
boxplot(concent ~ catalyst, data=catalystm,
xlab=catalyst, ylab=concentration, las=1)

## aov
catalystm1.aov - aov(concent ~ catalyst, data=catalystm)
summary(catalystm1.aov)

## MMC plot
old.omd - par(omd=c(0,.95,0,1))
catalystm.mmc - mmc(catalystm1.aov, linfct = mcp(catalyst = Tukey))
catalystm.mmc
plot(catalystm.mmc, ry=c(50,58), x.offset=1.8)

## tiebreaker plot
plotMatchMMC(catalystm.mmc$mca, xlabel.print=FALSE)



## B. coordinate scales of all three plots by adjusting par values and
##the frame sizes

def.par - par(no.readonly = TRUE) # save default, for resetting...
## allocate figure 1 the right 2/3 and top 2/3 of the plotting region
## allocate figure 2 the right 2/3 and bottom 1/3 of the plotting region
## allocate figure 3 the left 1/3 and top 2/3 of the plotting region
frame()
layout(matrix(c(3,1,
0,2), 2, 2, byrow = TRUE),
   widths=c(1,2), heights=c(2,1))
## show the regions that have been allocated to each plot
layout.show(3)

omd.old - par(omd=c(0,.95,0,1))
plot(catalystm.mmc, ry=c(50,59), x.offset=1.8)
usr.mmc - par()$usr

mar.old - par(mar=c(5,4,0,2)+.1)
plotMatchMMC(catalystm.mmc$mca, xlabel.print=FALSE)

par(mar.old)
boxplot(concent ~ catalyst, data=catalystm,
xlab=catalyst, ylab=concentration, las=1,
ylim=usr.mmc[3:4], yaxs=i)


## If you have a set of plots that don't fit comfortably into the
## space illustrated here, then you will need to increase the plotting
## device window from the default 7in x 7in because the cex is
## hardwired into the plot.mmc.multicomp function.



On Mon, Jan 14, 2013 at 6:37 PM, Richard M. Heiberger r...@temple.eduwrote:

 When the group means are close together, the labels will overlap.
 This overlap is actually informative, indicating that the groups are close.
 For this common case, we provide the tiebreaker function

 matchMMC

 which is also documented and illustrated on the ?MMC page.

 I have never tried to put the data on the same scale.  It should be easy.
 Let me try, and then post an example.

 Rich


 On Mon, Jan 14, 2013 at 3:53 PM, Karl Ove Hufthammer k...@huftis.orgwrote:

 må. den 14. 01. 2013 klokka 13.58 (-0500) skreiv Richard M. Heiberger:
  Please look at the MMC (Mean-mean Multiple Comparisons) plot in the HH
  package. It displays both the means and the differences.
 
  install.packages(HH) ## if you don't already have it.
  library(HH)
  ?MMC

 Thanks for the suggestion. That’s a very interesting and clever way of
 displaying both means and differences. It’s not what I was looking for,
 though, as it doesn’t display the actual data.

 For the record, here’s the syntax for using MMC on the dataset mentioned
 in my original posting:

 l.mmc=mmc(l, linfct = mcp(trt = Tukey))
 plot(l.mmc)

 (It looks best on data where the group means aren’t very close;
 otherwise the labels might overlap.)

 --
 Karl Ove Hufthammer

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Tukey HSD plot with lines indicating (non-)significance

2013-01-15 Thread Karl Ove Hufthammer

Den 2013-01-14 19:58 skreiv Richard M. Heiberger:
Please look at the MMC (Mean-mean Multiple Comparisons) plot in the 
HH package.

It displays both the means and the differences.

install.packages(HH) ## if you don't already have it.
library(HH)
?MMC


I have now coded a very quick-and-dirty solution for my line graph.
Example follows. I use the results of the 'cld' function in multcomp
to calculcate which groups are significantly different from each other.

Important note: The LetterMatrix object contains the needed
data, but the rows are not in the same order as the original levels,
and unfortunately the row names do *not* match the level names
(spaces seems to be stripped -- I don't know why). That's the reason
I remove the spaces in the example below.

Note: The levels should preferably be ordered by the group means,
but the function works (modulo any bugs) even if they're not.
Dotted lines are then used to indicate significant differences.

Important note: There are bound to be bugs. Do check the results
before using the resulting graph.


# Calculate non-significance lines for Tukey HSD
tukeyHSDLines=function(l, removeEndLines=TRUE, 
removeSingleGroups=FALSE) {


  # Calculate Tukey HSD values
  library(multcomp)
  l.glht=glht(l, linfct = mcp(trt = Tukey))

  # Calculcate a compact letter display (CLD)
  l.cld=cld(l.glht)
  lmat=l.cld$mcletters$LetterMatrix[levels(d$trt),]

  # Calculate the non-significance lines that should be
  # drawn, based on the CLD data
  calc.lines=function(x) {
r=rle(x)
lend=cumsum(r$lengths)# Line end index
lstart=c(1,lend[-length(lend)]+1) # Line start index
d2=data.frame(lstart=lstart-.4, lend=lend+.4, nodraw=!r$values)

if( removeEndLines ) {
  if(d2$nodraw[1]) d2=d2[-1,]   # Remove 'leading' 
dotted lines
  if(d2$nodraw[nrow(d2)]) d2=d2[-nrow(d2),] # Remove 'trailing' 
dotted lines

}
d2
  }

  linlist=apply(lmat, 2, calc.lines)
  lindat=do.call(rbind, linlist)
  lindat$y=rep(seq_along(linlist), times=sapply(linlist, nrow))

  if (removeSingleGroups) {
lindat=subset(lindat, !(y %in% which(tabulate(lindat$y)==1)))
lindat$y=as.numeric(factor(lindat$y))
  }
lindat
}


# Example:
library(DAAG)
d=rice # The dataset to use
levels(d$trt)=gsub( , , levels(d$trt)) # Remove spaces from level 
names
# d$trt=reorder(d$trt, -d$ShootDryMass)# Graph looks better with 
reordered factor

l=aov(ShootDryMass ~ trt, data=d)  # Fit a one-way ANOVA

lindat=tukeyHSDLines(l)
lindat$y=150-lindat$y*3

library(ggplot2)
ggplot(d, aes(x=trt, y=ShootDryMass)) + geom_boxplot(outlier.colour=NA) 
+

  geom_jitter(col=red, size=3, position=position_jitter(width=.1)) +
  geom_segment(aes(x=lstart, xend=lend, y=y, yend=y, linetype=nodraw), 
lindat)


--
Karl Ove Hufthammer

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Tukey HSD plot with lines indicating (non-)significance

2013-01-15 Thread Richard M. Heiberger
Karl,

I will look at your function later and comment on it.

RIght now, I am replying to your comment The levels should preferably be
ordered by the group means, 

One of the features of the tabular printout from the mmc function, and of
both
the MMC plot and the plotMatchMMC plot, is that the levels are ordered by
the group means.

Rich


On Tue, Jan 15, 2013 at 6:46 AM, Karl Ove Hufthammer k...@huftis.orgwrote:

 Den 2013-01-14 19:58 skreiv Richard M. Heiberger:

  Please look at the MMC (Mean-mean Multiple Comparisons) plot in the HH
 package.
 It displays both the means and the differences.

 install.packages(HH) ## if you don't already have it.
 library(HH)
 ?MMC


 I have now coded a very quick-and-dirty solution for my line graph.
 Example follows. I use the results of the 'cld' function in multcomp
 to calculcate which groups are significantly different from each other.

 Important note: The LetterMatrix object contains the needed
 data, but the rows are not in the same order as the original levels,
 and unfortunately the row names do *not* match the level names
 (spaces seems to be stripped -- I don't know why). That's the reason
 I remove the spaces in the example below.

 Note: The levels should preferably be ordered by the group means,
 but the function works (modulo any bugs) even if they're not.
 Dotted lines are then used to indicate significant differences.

 Important note: There are bound to be bugs. Do check the results
 before using the resulting graph.


 # Calculate non-significance lines for Tukey HSD
 tukeyHSDLines=function(l, removeEndLines=TRUE, removeSingleGroups=FALSE) {

   # Calculate Tukey HSD values

   library(multcomp)
   l.glht=glht(l, linfct = mcp(trt = Tukey))

   # Calculcate a compact letter display (CLD)
   l.cld=cld(l.glht)
   lmat=l.cld$mcletters$**LetterMatrix[levels(d$trt),]

   # Calculate the non-significance lines that should be
   # drawn, based on the CLD data
   calc.lines=function(x) {
 r=rle(x)
 lend=cumsum(r$lengths)# Line end index
 lstart=c(1,lend[-length(lend)]**+1) # Line start index
 d2=data.frame(lstart=lstart-.**4, lend=lend+.4, nodraw=!r$values)

 if( removeEndLines ) {
   if(d2$nodraw[1]) d2=d2[-1,]   # Remove 'leading' dotted
 lines
   if(d2$nodraw[nrow(d2)]) d2=d2[-nrow(d2),] # Remove 'trailing' dotted
 lines
 }
 d2
   }

   linlist=apply(lmat, 2, calc.lines)
   lindat=do.call(rbind, linlist)
   lindat$y=rep(seq_along(**linlist), times=sapply(linlist, nrow))

   if (removeSingleGroups) {
 lindat=subset(lindat, !(y %in% which(tabulate(lindat$y)==1)))
 lindat$y=as.numeric(factor(**lindat$y))
   }
 lindat
 }


 # Example:
 library(DAAG)
 d=rice # The dataset to use
 levels(d$trt)=gsub( , , levels(d$trt)) # Remove spaces from level names
 # d$trt=reorder(d$trt, -d$ShootDryMass)# Graph looks better with
 reordered factor
 l=aov(ShootDryMass ~ trt, data=d)  # Fit a one-way ANOVA

 lindat=tukeyHSDLines(l)
 lindat$y=150-lindat$y*3

 library(ggplot2)

 ggplot(d, aes(x=trt, y=ShootDryMass)) + geom_boxplot(outlier.colour=**NA)
 +
   geom_jitter(col=red, size=3, position=position_jitter(**width=.1)) +
   geom_segment(aes(x=lstart, xend=lend, y=y, yend=y, linetype=nodraw),
 lindat)


 --
 Karl Ove Hufthammer

 __**
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/**
 posting-guide.html 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.


[R] Need help: R for repetitive tasks

2013-01-15 Thread Simonas Kecorius
Dear R users,

First of all I would like to thank all of you who replayed to my previous
questions and problems. Thank you a lot for being great and helpful
community. I highly appreciate your suggestions and ideas even if I do not
respond after my question! But it means that your help was exactly what I
needed. Thank you again!

Now the following question I need help:

Suppose I do have a file.txt in the working directory. This file contains
the names of other files in the same directory:

First.txt
Second.txt
Third.txt
etc...

Files First.txt, Second.txt...are data files.

What I need R to do, is to read this file.txt line by line, open files
which names are listed ( First.txt, Second.txt...) and process it: lets say
make a FirstPlot.bmp, FirstSummary.txt  and save it to working directory,
then automatically open Second.txt, do the same, Third.txt etc. until the
end of the names in file.txt.

This would help me with the following task: I do measurements each day, and
I need to process my data: draw some plots, make some analysis.  When I
have 30 days of measurements each 1 second, there are huge amount of
numbers I am dealing with. If you could suggest some automation via R, it
would be perfect.

Thank you in advance.

Cheers.

-- 
Simonas Kecorius
**Lithuania

[[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] Rbbg for 2.15.2

2013-01-15 Thread John Laing
Tolga,

The Rbbg binary for 2.15 works for the .0, .1, and .2 minor versions. The
issue here is probably a change to the install.packages function that was
introduced in R 2.15.2. You can get around this by first calling

R options(install.packages.check.source = no)

and then following with the Rbbg installation.

Hope that helps,
John


On Mon, Jan 14, 2013 at 5:18 PM, Tolga Uzuner to...@coubros.com wrote:

 Dear R Users,

 Anyone know of a version of Rbbg compiled for R 2.15.2 . The current
 version does not appear to work with 2.15.2

  install.packages(Rbbg, repos = http://r.findata.org;)
 Installing package(s) into ‘C:/Users/t_uzu_000/Documents/**
 R/win-library/2.15’
 (as ‘lib’ is unspecified)
 Warning: unable to access index for repository http://r.findata.org/src/**
 contrib http://r.findata.org/src/contrib
 Warning message:
 package ‘Rbbg’ is not available (for R version 2.15.2)

 Thanks in advance,
 Tolga

 __**
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/**
 posting-guide.html 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] Need help: R for repetitive tasks

2013-01-15 Thread R. Michael Weylandt
list.files() to get all the files in the directory (use the pattern
argument to be more specific). Then loop over the file names, reading
in the data one at a time, do the desired processing, and then use the
file name to make the graphics file name as well.

Cheers, MW

On Tue, Jan 15, 2013 at 12:30 PM, Simonas Kecorius
simolas2...@gmail.com wrote:
 Dear R users,

 First of all I would like to thank all of you who replayed to my previous
 questions and problems. Thank you a lot for being great and helpful
 community. I highly appreciate your suggestions and ideas even if I do not
 respond after my question! But it means that your help was exactly what I
 needed. Thank you again!

 Now the following question I need help:

 Suppose I do have a file.txt in the working directory. This file contains
 the names of other files in the same directory:

 First.txt
 Second.txt
 Third.txt
 etc...

 Files First.txt, Second.txt...are data files.

 What I need R to do, is to read this file.txt line by line, open files
 which names are listed ( First.txt, Second.txt...) and process it: lets say
 make a FirstPlot.bmp, FirstSummary.txt  and save it to working directory,
 then automatically open Second.txt, do the same, Third.txt etc. until the
 end of the names in file.txt.

 This would help me with the following task: I do measurements each day, and
 I need to process my data: draw some plots, make some analysis.  When I
 have 30 days of measurements each 1 second, there are huge amount of
 numbers I am dealing with. If you could suggest some automation via R, it
 would be perfect.

 Thank you in advance.

 Cheers.

 --
 Simonas Kecorius
 **Lithuania

 [[alternative HTML version deleted]]

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

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


[R] paper - download - pubmed

2013-01-15 Thread Nooshin Omranian


Hi,

I actually need to download pdfs through R code.

The thing which I want to do is that, search for a paper in pubmed, 
which is possible by using GetPubMed function in the package NCBI2R’.


GetPubMed(searchterm, file = , download = TRUE , showurl = FALSE, 
xldiv = ;, hyper = HYPERLINK,
MaxRet = 3, sme = FALSE, smt = FALSE, quiet = TRUE, 
batchsize=500,descHead=FALSE)


With this function I can not download the pdfs for all hits, although if 
I go to the pubmed, I can download it.


So, the problem is not that, for each paper I have to download the pdfs 
(which are available if I go to the pubmed and search directly there) 
and the corresponding supplementary files.


Could anybody please help me how I can solve this?

Thanks,
Nooshin

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

2013-01-15 Thread Simon Kiss
HI all:
I have a customized source reader for the package tm (that Milan Bouchet-Vallat 
has been instrumental in producing). 
I can get it to produce a corpus of class:
VCorpus Corpus  list   

class(mycorp[1]) returns
VCorpus Corpus  list   

and class(mycorp[[1]] returns 
PlainTextDocument TextDocument  character   

But now that I've got a corpsu, none of the transformation functions work at 
all. They all return the following error (with the respective function name)
Error in UseMethod(stripWhitespace, x) : 
  no applicable method for 'stripWhitespace' applied to an object of class 
NULL

I haven't seen this error reported anywhere in the R-list archives.  Does 
anyone have any suggestions?
Yours, Simon Kiss

P.S. The results of sessionInfo() are
R version 2.15.0 (2012-03-30)
Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)

locale:
[1] en_CA.UTF-8/en_CA.UTF-8/en_CA.UTF-8/C/en_CA.UTF-8/en_CA.UTF-8

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

other attached packages:
[1] RWekajars_3.7.7-2 rJava_0.9-3   RWeka_0.4-13  
Snowball_0.0-8   
[5] tm.plugin.factiva_1.1 tm_0.5-8.1   

loaded via a namespace (and not attached):
[1] grid_2.15.0  slam_0.1-26  tools_2.15.0 XML_3.9-4   

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

2013-01-15 Thread Tolga Uzuner
Many thanks, I got this to work.

On 15/01/2013 12:57, John Laing wrote:
 Tolga,

 The Rbbg binary for 2.15 works for the .0, .1, and .2 minor versions. 
 The issue here is probably a change to the install.packages function 
 that was introduced in R 2.15.2. You can get around this by first calling

 R options(install.packages.check.source = no)

 and then following with the Rbbg installation.

 Hope that helps,
 John


 On Mon, Jan 14, 2013 at 5:18 PM, Tolga Uzuner to...@coubros.com 
 mailto:to...@coubros.com wrote:

 Dear R Users,

 Anyone know of a version of Rbbg compiled for R 2.15.2 . The
 current version does not appear to work with 2.15.2

  install.packages(Rbbg, repos = http://r.findata.org;)
 Installing package(s) into
 ‘C:/Users/t_uzu_000/Documents/R/win-library/2.15’
 (as ‘lib’ is unspecified)
 Warning: unable to access index for repository
 http://r.findata.org/src/contrib
 Warning message:
 package ‘Rbbg’ is not available (for R version 2.15.2)

 Thanks in advance,
 Tolga

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


[R] Code to fetch summary info from vector

2013-01-15 Thread Benjamin Gillespie
Hi all,

Thanks in advance for any help.

I have a vector b:

b=c(1,1,1,2,3,4,3,2,1,1,1,1,1,2,3,4,5,4,3.5,3,2,1,1,1)

Imagine b is river flow throughout time.

I would like some code that will generate the following information:

number of individual 'periods' where b1 (= 2 in this case)
period 1 length = 5, max = 4
period 2 length = 8, max = 5

I can't figure anything useful out.

Thanks,

Ben Gillespie
Research Postgraduate
 
School of Geography
University of Leeds
Leeds
LS2 9JT
 
http://www.geog.leeds.ac.uk/
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Code to fetch summary info from vector

2013-01-15 Thread Stephen Sefick
I don't know if I understand what you want.  What are the periods?  I 
suspect this is a time series.  What have you tried that didn't work?

kind regards,

Stephen

On 01/15/2013 10:16 AM, Benjamin Gillespie wrote:

Hi all,

Thanks in advance for any help.

I have a vector b:

b=c(1,1,1,2,3,4,3,2,1,1,1,1,1,2,3,4,5,4,3.5,3,2,1,1,1)

Imagine b is river flow throughout time.

I would like some code that will generate the following information:

number of individual 'periods' where b1 (= 2 in this case)
period 1 length = 5, max = 4
period 2 length = 8, max = 5

I can't figure anything useful out.

Thanks,

Ben Gillespie
Research Postgraduate

School of Geography
University of Leeds
Leeds
LS2 9JT

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


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

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

-K. Mullis

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

  -Robert Gentleman

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Code to fetch summary info from vector

2013-01-15 Thread Jose Iparraguirre
Hi Ben

I'm not sure whether I understood correctly, but is it something like this?

 sum(ifelse(b==2,1,0))
[1] 4
 sum(ifelse(b==3,1,0))
[1] 4
 sum(ifelse(b=2,1,0))
[1] 13
 sum(ifelse(b2,1,0))
[1] 9
Etc...

José

José Iparraguirre
Chief Economist
Age UK



-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Benjamin Gillespie
Sent: 15 January 2013 16:16
To: r-help@r-project.org
Subject: [R] Code to fetch summary info from vector

Hi all,

Thanks in advance for any help.

I have a vector b:

b=c(1,1,1,2,3,4,3,2,1,1,1,1,1,2,3,4,5,4,3.5,3,2,1,1,1)

Imagine b is river flow throughout time.

I would like some code that will generate the following information:

number of individual 'periods' where b1 (= 2 in this case)
period 1 length = 5, max = 4
period 2 length = 8, max = 5

I can't figure anything useful out.

Thanks,

Ben Gillespie
Research Postgraduate
 
School of Geography
University of Leeds
Leeds
LS2 9JT
 
http://www.geog.leeds.ac.uk/
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Wrap Up and Run 10k is back! 

Also, new for 2013 – 2km intergenerational walks at selected venues. So recruit 
a buddy, dust off the trainers and beat the winter blues by 
signing up now:

http://www.ageuk.org.uk/10k

 Milton Keynes | Oxford | Sheffield | Crystal Palace | Exeter | 
Harewood House, Leeds | 
 Tatton Park, Cheshire | Southampton | Coventry



Age UK Improving later life

http://www.ageuk.org.uk


 

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

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

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

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

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










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


Re: [R] Code to fetch summary info from vector

2013-01-15 Thread William Dunlap
I don't completely understand the  question, but if you are looking
for the lengths of the runs of values greater than 1 then rle() would
help:
   b - c(1,1,1,2,3,4,3,2,1,1,1,1,1,2,3,4,5,4,3.5,3,2,1,1,1)
   r - rle(b1)
   r
  Run Length Encoding
lengths: int [1:5] 3 5 5 8 3
values : logi [1:5] FALSE TRUE FALSE TRUE FALSE
   r$lengths[r$values]
  [1] 5 8
To get the maximum of each run of values greater than one, something
like the following may do (there are more elegant ways, but I don't want
to spend the time on it until I know what the question is):
   runNumber - cumsum( c(b[1]1, (b[-1]1)  (b[-length(b)]=1)) )
   runNumber[b=1] - NA
   tapply(b, runNumber, max)
  1 2 
  4 5

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
 Behalf
 Of Benjamin Gillespie
 Sent: Tuesday, January 15, 2013 8:16 AM
 To: r-help@r-project.org
 Subject: [R] Code to fetch summary info from vector
 
 Hi all,
 
 Thanks in advance for any help.
 
 I have a vector b:
 
 b=c(1,1,1,2,3,4,3,2,1,1,1,1,1,2,3,4,5,4,3.5,3,2,1,1,1)
 
 Imagine b is river flow throughout time.
 
 I would like some code that will generate the following information:
 
 number of individual 'periods' where b1 (= 2 in this case)
 period 1 length = 5, max = 4
 period 2 length = 8, max = 5
 
 I can't figure anything useful out.
 
 Thanks,
 
 Ben Gillespie
 Research Postgraduate
 
 School of Geography
 University of Leeds
 Leeds
 LS2 9JT
 
 http://www.geog.leeds.ac.uk/
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Code to fetch summary info from vector

2013-01-15 Thread Jessica Streicher
Maybe rle can help a little here

rle(b1)

Run Length Encoding
  lengths: int [1:5] 3 5 5 8 3
  values : logi [1:5] FALSE TRUE FALSE TRUE FALSE

 r-rle(b1)

r$lengths[r$values]
[1] 5 8

# started for the maximum but need to go home now, sorry. Will continue 
tomorrow if noone else finishes it.
groups - rep(1:length(r$lengths),r$lengths)

On 15.01.2013, at 17:16, Benjamin Gillespie wrote:

 Hi all,
 
 Thanks in advance for any help.
 
 I have a vector b:
 
 b=c(1,1,1,2,3,4,3,2,1,1,1,1,1,2,3,4,5,4,3.5,3,2,1,1,1)
 
 Imagine b is river flow throughout time.
 
 I would like some code that will generate the following information:
 
 number of individual 'periods' where b1 (= 2 in this case)
 period 1 length = 5, max = 4
 period 2 length = 8, max = 5
 
 I can't figure anything useful out.
 
 Thanks,
   
 Ben Gillespie
 Research Postgraduate
 
 School of Geography
 University of Leeds
 Leeds
 LS2 9JT
 
 http://www.geog.leeds.ac.uk/
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Hist with Dates

2013-01-15 Thread Dominic Roye
Hello R-Helpers,


I would like to generate the frequencies of dates (data.RData).

str(data)
 Date[1:43748], format: 2001-01-01 2001-01-01 2001-01-01 2001-01-01
...


test - hist(data,days,freq=T)
 test$counts
   [1] 27 17 12 15  6  4  5 13  5 13 15  9  7 10 11 21 10 10  9 11 15  7 10
14


but the count is wrong, because i have only 9 times 01/01/2001 etc.

 data[1:30]
 [1] 2001-01-01 2001-01-01 2001-01-01 2001-01-01 2001-01-01
 [6] 2001-01-01 2001-01-01 2001-01-01 2001-01-01

2001-01-02
[11] 2001-01-02 2001-01-02 2001-01-02 2001-01-02 2001-01-02
[16] 2001-01-02 2001-01-02 2001-01-02 2001-01-02 2001-01-02
[21] 2001-01-03 2001-01-03 2001-01-03 2001-01-03 2001-01-03
[26] 2001-01-03 2001-01-03 2001-01-03 2001-01-03 2001-01-03



Now, when i give R the breaks.

 br -
seq(as.Date(31.12.2000,format=%d.%m.%Y),as.Date(01.01.2012,format=%d.%m.%Y),by=1)
 test2- hist(data,br,freq=T)
 test2$counts[1:10]
 [1] 12 15 17 12 15  6  4  5 13  5


In this case, neither get the right counts but limiting i get the correct
counts:

 test3- hist(data[1:50],br[1:6],freq=T)
 test3$counts
[1]  9 11 13  9  8


I hope someone can help me with this problem.


Thank you very much!!

Best regards,

Dominic
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] temporal and spatial correlation structures in GAMM

2013-01-15 Thread Filipe Carvalho
Dear R_help
list members!
 
I’m
studding forest carnivores and I have data on resting site selection and use!
 
I’m trying
to model the probability that a forest carnivore might have in be located in a
tree hollow (1) (the main resting site selected) rather than elsewhere (0)
(other resting site types, dens, nests, etc.). 
The model
should be related with several variables such as for instance:
 
SHRUB_CV –
shrub cover;
D_RIPARIAN
– distance to riparian habitats
FOREST_PP –
forest habitat (tree availability) proportion in each sampling unit (1 km
buffer around each resting site)
D_RIP_KM –
distance to the nearest riparian habitat..
Day – day
of the year…
 
My data
consist of a daily resting site monitoring of 21 animals (during the time that
each radio-collar battery allowed) ranging from 40-380 days…The study was
conducted in the 2010-12 period…
So, in the
final I got a data base with more than 3300 observation events (an event is an
animal present in a resting site each day).
Several
resting sites were used more than once by the same individual, but some times
the same resting site were used by two or more animals (few times I had two
animals in the same day and in the same resting)…leading to, that for some
covariates, the values are the same across animals when they…
Also, in most
of the days I had more than one resting site event because during most of the
study I followed more than one animal at the same time…
Because I was not
interest if there is an animal effect on tree hollow probability use, I used
animal as random effect in the models. In addition, we assume that an
individual from the forest carnivore population will behave more or less the
same way concerning tree hollow use. This lead me to the mixed-effects
modelling techniques. 
Additionally,
because I get truly non-linear relationship between some of the covariates
(e.g. SHRUB_CV) with the response variable it leads me to the gamm option…
I start the
model building procedure by finding firstly the best fixed structure and after
the best random effect structure and finally the best model.
 
I my case
my first attempt final model was obtained by:
 
Model -
gamm4(TREE_01 ~ s(Day) + T_MAX + SHRUB_CV + D_AV5RS_KM + 
D_RIP_KM +
FOREST_PP, random = ~ (1 | fAnimal),
method =
REML, control = lmc, family = binomial, data = RSTEMP_01_X2)
summary(Model$gam)
 
Family:
binomial 
Link
function: logit 
Formula:
TREE_01 ~
s(Day) + T_MAX + SHRUB_CV + D_AV5RS_KM + D_RIP_KM + 
    FOREST_PP
Parametric
coefficients:
                               Estimate    
Std. Error     z value     Pr(|z|)    
(Intercept)              5.83792     0.91031    6.413    
1.43e-10 ***
T_MAX                -0.06309    0.02161   -2.919    
0.003509 ** 
SHRUB_CV         -7.72088    0.46859   -16.477    2e-16 ***
D_AV5RS_KM     1.94569     0.53025     3.669     0.000243 ***
D_RIP_KM           4.65035      0.60978      7.626     
2.42e-14 ***
FOREST_PP          2.09453     0.58465      3.583     
0.000340 ***
Signif.
codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05
‘.’ 0.1 ‘ ’ 1 
Approximate
significance of smooth terms:
                edf      Ref.df  Chi.sq  p-value   
s(Day)    5.332   5.332    18.57    0.00316 **
Signif.
codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05
‘.’ 0.1 ‘ ’ 1 
R-sq.(adj) =  0.541     glmer.ML score = 1117.3  Scale
est. = 1         n = 3358
 
I used the
‘gamm4’ package because it performs better than the ‘mgcv’ for binomial
response variables…
However,
now I have to check for temporal correlations structures since my monitoring
programs was in a daily basis it seems, at least, biologically that I would
have temporal correlation between days, i.e. the resting site that an animal
use in one day is correlated with the one used in the day after… 
I used the
formula ‘acf’ from the ‘nlme’ package, I got the temporal 
autocorrelation plot,
and I confirmed that I have correlation, especially in the first 5 days…
The
problems arrived after this, when I try to add some correlation structures in
the model I got the following error:
 
Error in
Initialize.corARMA(X[[2L]], ...) : 
covariate
must have unique values within groups for corARMA objects for
instance…
 
How can I
solve this problem, it is because I have the same value for some covariates
across the same animal and between animals?
If it is?
How can I manage that, because my data should allowed for this because it is 
normal
under this ecological data that a animal during their life time use several
times the same resting site and some times they are shared between males and
females and females and juveniles/sub-adults. 
Should I
have to create a grouping variable that can disentangle the parts…?
Should I

[R] How to get F values for a Generalized Linear Model?

2013-01-15 Thread Geraldine Werhahn
Dear All,
 
I have fitted generalized linear models with the glm() function from the 
package lme4. The statistical values it returns are the z-value and the 
p-value. Now I am searching for a way to get the F-values for my models  to use 
for reporting - as to my knowledge reporting z-values is not very useful and 
the F-values together with the p-values would be desired for the report. I 
tried the commands summary(model) , anova(model) noranova.glm(model), but 
couldnt get the F-values that way. 
 
Is the command stat.anova(table, test =  F, scale, df.scale, n) the right 
choice? If yes, for this I need the 'residual mean square' to use as scale. But 
how to extract the 'residual mean square' out of my glm in R?
 
I am very thankful for your comments and advice!
[[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] Histogram plot spacing

2013-01-15 Thread Julie Collet
Dear all,

I'd like to remove the space between the x-axis and the 0 of the y-axis in the 
hist function.
I saw the previous post 
https://stat.ethz.ch/pipermail/r-help/2012-September/324177.html suggesting 
adding the x-axis at position 0 (or the lowest value of y) after making the 
histogram. Unfortunately, it doesn't work in my case as I want to use it with a 
histogram with a ylim starting above 0, so that the x-axis ends up superposing 
the histogram bars. Any suggestion?

For info, I've been using:
hist(univariateCV$varcomp, ylim=c(10300,11100), xlim=c(-0.002,0.40), 
breaks=seq(0,1,0.004), axes=FALSE, main=, ylab=, xlab=,col='blue', 
xaxt=n)
axis(1, at=seq(0,0.40,0.05), labels=seq(0,0.40,0.05), pos=10300)
which gives the x axis superposed with the histogram bars.

Many thanks
Julie

[[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] Need some help on Text manipulation.

2013-01-15 Thread arun
HI,
In this case, all the elements in Dat$att are found in Replace.
 Dat1-within(Dat,{att-as.character(att)})
vec1-unlist(lapply(strsplit(Dat1$att,),unique))
vec1
 #[1] b b b d b b a c a d a b b b b d b b 
d
#[20] b

 Dat1[5:7,2]-c(uu,tt,vv)
vec1-unlist(lapply(strsplit(Dat1$att,),unique))

 Dat1$att-ifelse(vec1%in%Replace,vec1,Dat1$att)
Dat1$att
# [1] b  b  b  d  uu t  vv c  a  d  a  b  b  b  b 
#[16] d  b  b  d  b 
A.K.






- Original Message -
From: Christofer Bogaso bogaso.christo...@gmail.com
To: r-help r-help@r-project.org
Cc: 
Sent: Tuesday, January 15, 2013 4:48 AM
Subject: [R] Need some help on Text manipulation.

Dear all,

Let say I have following data-frame:

Dat - structure(list(dat = c(-0.387795842956327, -0.23270882099043,
-0.89528973290562, 0.95857175595512, 1.61680582493783, -1.17738110289352,
0.210601060411423, -0.827369747447338, -0.36896112964414, 0.440288648776096,
1.28018410608809, -0.897113649961341, 0.342216546981718, -1.17288066266219,
-1.57994101992621, -0.913655547602414, -2.54753726314408, -0.617703410989815,
-0.443272763891558, 0.359181170918489), att = structure(c(2L,
2L, 2L, 4L, 2L, 2L, 1L, 3L, 1L, 4L, 1L, 2L, 2L, 2L, 2L, 4L, 2L,
2L, 4L, 2L), .Label = c(aa, bb, cc, dd), class = factor)),
.Names = c(dat,
att), row.names = c(NA, -20L), class = data.frame); Dat


Now I want to replace the 2nd column with:

Replace - letters[1:20]

The rule is as follows:

Consider the 1st element of the 2nd colume: 'bb'. Now I need to see
which element of 'Replace' is contained in 'bb'? Obviously, this will
be 'b'. Therefore I need to replace bb with b. And so on for all
elements of 2nd column.

This is obviously an straightforward example. However I have some more
complex problem of replacing like that. I want to get the idea how to
achieve that programmatically.

Can somebody help me?

Thanks and regards,

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


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


Re: [R] random effects model

2013-01-15 Thread arun


Hi,
Check these links:
http://comments.gmane.org/gmane.comp.lang.r.ggplot2/6527
https://groups.google.com/forum/#!msg/ggplot2/nfVjxL0DXnY/5zf50zCeZuMJ
A.K.


From: Usha Gurunathan usha.nat...@gmail.com
To: arun smartpink...@yahoo.com 
Cc: R help r-help@r-project.org 
Sent: Tuesday, January 15, 2013 6:31 AM
Subject: Re: [R] random effects model


Hi AK

Got an error message with
library(ggplot2)  
ggplot(BP.stack1,aes(x=factor(HiBP),fill=Obese))+geom_bar(position=fill) 
Error in rename(x, .base_to_ggplot, warn_missing = FALSE) :  could not find 
function revalue  
ggplot(BP.stack1,aes(x=factor(HiBP),fill=Overweight))+geom_bar(position=fill) 
Error in rename(x, .base_to_ggplot, warn_missing = FALSE) :  could not find 
function revalue
I got the dot plot, thanks for that.

I have attached some plots, not sure how to interpret, they had unusual 
patterns.Is it because of missing data? I tried removing the missing data too. 
They still appeared the same. Do I need to transform the data?


Thanks in advance.





On Tue, Jan 15, 2013 at 8:54 AM, arun smartpink...@yahoo.com wrote:

HI,


BP_2b-read.csv(BP_2b.csv,sep=\t)
BP_2bNM-na.omit(BP_2b)

BP.stack3 - 
reshape(BP_2bNM,idvar=CODEA,timevar=time,sep=,varying=list(c(Obese14,Obese21),c(Overweight14,Overweight21),c(hibp14,hibp21)),v.names=c(Obese,Overweight,HiBP),times=factor(c(1,2)),direction=long)
library(car)
BP.stack3$Obese- recode(BP.stack3$Obese,1='Obese';0='Not Obese')
BP.stack3$Overweight- recode(BP.stack3$Overweight,1='Overweight';0='Not 
Overweight')

library(ggplot2)
ggplot(BP.stack3,aes(x=factor(HiBP),fill=Obese))+geom_bar(position=fill)
ggplot(BP.stack3,aes(x=factor(HiBP),fill=Overweight))+geom_bar(position=fill)

You could try lmer() from lme4. 
library(lme4)
fm1-lmer(HiBP~time+(1|CODEA), family=binomial,data=BP.stack3) #check codes, 
not sure
print(dotplot(ranef(fm1,post=TRUE),
  scales = list(x = list(relation = free)))[[1]])
qmt1- qqmath(ranef(fm1, postVar=TRUE))
print(qmt1[[1]])


A.K.






From: Usha Gurunathan usha.nat...@gmail.com
To: arun smartpink...@yahoo.com
Cc: R help r-help@r-project.org
Sent: Monday, January 14, 2013 6:32 AM

Subject: Re: [R] random effects model


Hi AK

I have been trying to create some plots. All being categorical variables, I am 
not getting any luck with plots. The few ones that have worked are below:

barchart(~table(HiBP)|Obese,data=BP.sub3) ## BP.sub3 is the stacked data 
without missing values

barchart(~table(HiBP)|Overweight,data=BP.sub3)

plot(jitter(hibp14,factor=2)~jitter(Obese14,factor=2),col=gray,cex=0.7, 
data=Copy.of.BP_2)  ## Copy.of.BP_2 is the original wide format

## not producing any good plots with mixed models as well.
summary(lme.3 - lme(HiBP~time, data=BP.sub3,random=~1|CODEA, 
na.action=na.omit))
anova(lme.3)
head(ranef(lme.3))
print(plot(ranef(lme.3))) ##

Thanks for any help.





On Mon, Jan 14, 2013 at 4:33 AM, arun smartpink...@yahoo.com wrote:




HI,

I think I mentioned to you before that when you reshape the
columns excluding the response variable, response variable gets repeated
(in this case hibp14 or hibp21) and creates the error


I run your code, there are obvious problems in the code so I didn't reach up 
to BP.gee


BP_2b-read.csv(BP_2b.csv,sep=\t)
BP.stack3 - 
reshape(BP_2b,idvar=CODEA,timevar=time,sep=_,varying=list(c(Obese14,Obese21),c(Overweight14,Overweight21)),v.names=c(Obese,Overweight),times=factor(c(1,2)),direction=long)


BP.stack3 - 
transform(BP.stack3,CODEA=factor(CODEA),Sex=factor(Sex,labels=c(Male,Female)),MaternalAge=factor(MaternalAge,labels=c(39years
 or less,40-49 years,50 years or 
older)),Education=factor(Education,labels=c(Primary/special,Started 
secondary,Completed grade10, Completed grade12, 
College,University)),Birthplace=factor(Birthplace,labels=c(Australia,Other
 English-speaking,Other)))

 BP.stack3$Sex - factor(BP.stack3$Sex,levels=levels(BP.stack3$Sex)[c(2,1)])

 BP.sub3a -  subset(BP.stack3,subset=!(is.na(Sex)| 
is.na(Education)|is.na(Birthplace)|is.na(Education)|is.na(hibp14)| 
is.na(hibp21)))  
 nrow(BP.sub3a)
#[1] 3364
 BP.sub5a - BP.sub3a[order(BP.sub3a$CODEA),] # your code was BP.sub5a - 
BP.sub3a[order(BP.sub5a$CODEA),] 
  
  
 ^ was not defined before
#Next line
BPsub3$Categ[BPsub6$Overweight==1BPsub3$time==1BPsub3$Obese==0]- 
Overweight14  #It should be BP.sub3 and what is BPsub6, it was not defined 
previously.
#Error in BPsub3$Categ[BPsub6$Overweight == 1  BPsub3$time == 1  
BPsub3$Obese ==  :
  #object 'BPsub3' not found







A.K.



From: Usha Gurunathan usha.nat...@gmail.com
To: arun smartpink...@yahoo.com

Sent: Sunday, January 13, 2013 1:51 AM

Subject: Re: [R] random effects model



HI AK

Thanks a lot  for explaining that.

1. With the chi sq. ( in 

Re: [R] GPIB-compatible instrument control with R

2013-01-15 Thread Greg Snow
I don't know of any tools within R to do something like this, but one
possibility is to use other software that will interface with your device
and can then talk with R, one possibility for an intermediate program is
here: http://www.windmill.co.uk/index.html.


On Fri, Jan 11, 2013 at 4:41 PM, Marko Tadjer marko.tad...@gmail.comwrote:

 Hello,

 Does an R package exist for communication with instruments using GPIB
 (IEEE 488) protocol?

 Something similar exists in python for control of instruments over
 GPIB, RS232, or USB buses (http://pyvisa.sourceforge.net/)

 Thanks,
 Marko

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




-- 
Gregory (Greg) L. Snow Ph.D.
538...@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] How to get F values for a Generalized Linear Model?

2013-01-15 Thread Bert Gunter
Geraldine:

On Tue, Jan 15, 2013 at 1:51 AM, Geraldine Werhahn geri...@yahoo.com wrote:
 Dear All,

 I have fitted generalized linear models with the glm() function from the 
 package lme4. The statistical values it returns are the z-value and the 
 p-value. Now I am searching for a way to get the F-values for my models  to 
 use for reporting - as to my knowledge

Your knowledge is insufficient. Your expectations are incorrect.
Either consult someone locally who has sufficient statistical
expertise or do some studying of GLM's. As this is a statistics not an
R question, you might also wish to try posting to a statistics list
instead, like stats.stackexchange.com.

Cheers,
Bert

reporting z-values is not very useful and the F-values together with
the p-values would be desired for the report. I tried the commands
summary(model) , anova(model) noranova.glm(model), but couldnt get the
F-values that way.

 Is the command stat.anova(table, test =  F, scale, df.scale, n) the right 
 choice? If yes, for this I need the 'residual mean square' to use as scale. 
 But how to extract the 'residual mean square' out of my glm in R?

 I am very thankful for your comments and advice!
 [[alternative HTML version deleted]]


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




-- 

Bert Gunter
Genentech Nonclinical Biostatistics

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

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


Re: [R] Hist with Dates

2013-01-15 Thread Christopher W Ryan
If all you want is frequencies, could you use table()?

dd - c(2001-01-02, 2001-01-02,  2001-01-02, 2001-01-02,
2001-01-02, 2001-01-02, 2001-01-02, 2001-01-02, 2001-01-02,
2001-01-03, 2001-01-03, 2001-01-03, 2001-01-03, 2001-01-03,
2001-01-03, 2001-01-03, 2001-01-03, 2001-01-04, 2001-01-04)
ddd - as.Date(dd)
str(ddd)
table(ddd)
as.numeric(table(ddd))

--Chris Ryan
SUNY Upstate Medical University
Binghamton, NY USA

On Tue, Jan 15, 2013 at 7:45 AM, Dominic Roye dominic.r...@gmail.com wrote:
 Hello R-Helpers,


 I would like to generate the frequencies of dates (data.RData).

 str(data)
  Date[1:43748], format: 2001-01-01 2001-01-01 2001-01-01 2001-01-01
 ...


 test - hist(data,days,freq=T)
 test$counts
[1] 27 17 12 15  6  4  5 13  5 13 15  9  7 10 11 21 10 10  9 11 15  7 10
 14


 but the count is wrong, because i have only 9 times 01/01/2001 etc.

 data[1:30]
  [1] 2001-01-01 2001-01-01 2001-01-01 2001-01-01 2001-01-01
  [6] 2001-01-01 2001-01-01 2001-01-01 2001-01-01

 2001-01-02
 [11] 2001-01-02 2001-01-02 2001-01-02 2001-01-02 2001-01-02
 [16] 2001-01-02 2001-01-02 2001-01-02 2001-01-02 2001-01-02
 [21] 2001-01-03 2001-01-03 2001-01-03 2001-01-03 2001-01-03
 [26] 2001-01-03 2001-01-03 2001-01-03 2001-01-03 2001-01-03



 Now, when i give R the breaks.

 br -
 seq(as.Date(31.12.2000,format=%d.%m.%Y),as.Date(01.01.2012,format=%d.%m.%Y),by=1)
 test2- hist(data,br,freq=T)
 test2$counts[1:10]
  [1] 12 15 17 12 15  6  4  5 13  5


 In this case, neither get the right counts but limiting i get the correct
 counts:

 test3- hist(data[1:50],br[1:6],freq=T)
 test3$counts
 [1]  9 11 13  9  8


 I hope someone can help me with this problem.


 Thank you very much!!

 Best regards,

 Dominic

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Code to fetch summary info from vector

2013-01-15 Thread Benjamin Gillespie
Thanks everyone,

I've used the code Will supplied - this worked well.

Thanks to all the others who contributed.

Ben Gillespie
Research Postgraduate

School of Geography
University of Leeds
Leeds
LS2 9JT

Tel: +44(0)113 34 33345
Mob: +44(0)770 868 7641
http://www.geog.leeds.ac.uk/

From: William Dunlap [wdun...@tibco.com]
Sent: 15 January 2013 16:51
To: Benjamin Gillespie; r-help@r-project.org
Subject: RE: Code to fetch summary info from vector

I don't completely understand the  question, but if you are looking
for the lengths of the runs of values greater than 1 then rle() would
help:
   b - c(1,1,1,2,3,4,3,2,1,1,1,1,1,2,3,4,5,4,3.5,3,2,1,1,1)
   r - rle(b1)
   r
  Run Length Encoding
lengths: int [1:5] 3 5 5 8 3
values : logi [1:5] FALSE TRUE FALSE TRUE FALSE
   r$lengths[r$values]
  [1] 5 8
To get the maximum of each run of values greater than one, something
like the following may do (there are more elegant ways, but I don't want
to spend the time on it until I know what the question is):
   runNumber - cumsum( c(b[1]1, (b[-1]1)  (b[-length(b)]=1)) )
   runNumber[b=1] - NA
   tapply(b, runNumber, max)
  1 2
  4 5

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
 Behalf
 Of Benjamin Gillespie
 Sent: Tuesday, January 15, 2013 8:16 AM
 To: r-help@r-project.org
 Subject: [R] Code to fetch summary info from vector

 Hi all,

 Thanks in advance for any help.

 I have a vector b:

 b=c(1,1,1,2,3,4,3,2,1,1,1,1,1,2,3,4,5,4,3.5,3,2,1,1,1)

 Imagine b is river flow throughout time.

 I would like some code that will generate the following information:

 number of individual 'periods' where b1 (= 2 in this case)
 period 1 length = 5, max = 4
 period 2 length = 8, max = 5

 I can't figure anything useful out.

 Thanks,

 Ben Gillespie
 Research Postgraduate

 School of Geography
 University of Leeds
 Leeds
 LS2 9JT

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

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


Re: [R] Histogram plot spacing

2013-01-15 Thread Uwe Ligges



On 15.01.2013 12:35, Julie Collet wrote:

Dear all,

I'd like to remove the space between the x-axis and the 0 of the y-axis in the 
hist function.
I saw the previous post 
https://stat.ethz.ch/pipermail/r-help/2012-September/324177.html suggesting 
adding the x-axis at position 0 (or the lowest value of y) after making the 
histogram. Unfortunately, it doesn't work in my case as I want to use it with a 
histogram with a ylim starting above 0, so that the x-axis ends up superposing 
the histogram bars. Any suggestion?

For info, I've been using:
hist(univariateCV$varcomp, ylim=c(10300,11100), xlim=c(-0.002,0.40), breaks=seq(0,1,0.004), axes=FALSE, 
main=, ylab=, xlab=,col='blue', xaxt=n)
axis(1, at=seq(0,0.40,0.05), labels=seq(0,0.40,0.05), pos=10300)
which gives the x axis superposed with the histogram bars.



par(yaxs=i)
hist(rnorm(100))

Uwe Ligges




Many thanks
Julie

[[alternative HTML version deleted]]

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



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


[R] Sparse dataframes?

2013-01-15 Thread andrewH
Dear Folks--
Is there a data frame analog to sparse matrices? I am working with a panel
data set that has a large number of variables that are redefined repeatedly
or exist for only a few years (out of 48).  In my current structure, where
variables are columns and rows are years, more than 90 percent of the cells
and more than 3/4 of the total size of my file are NAs.  

I am wondering if there is an alternate file specification currently
available that still allows numeric, character and factor data to be stored. 
Besides just using a database. 

A pointer in the right direction (or a solid no if that is the truth)
would be greatly appreciated.

Sincerely, andrewH



--
View this message in context: 
http://r.789695.n4.nabble.com/Sparse-dataframes-tp4655614.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] Hist with Dates

2013-01-15 Thread Jeff Newmiller
You should read the help for hist carefully:

?hist.Date

hist has very specific rules for applying breaks that are often different than 
tabulation (tapply or aggregate, with or without using the cut function first).
---
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.

Dominic Roye dominic.r...@gmail.com wrote:

Hello R-Helpers,


I would like to generate the frequencies of dates (data.RData).

str(data)
Date[1:43748], format: 2001-01-01 2001-01-01 2001-01-01
2001-01-01
...


test - hist(data,days,freq=T)
 test$counts
[1] 27 17 12 15  6  4  5 13  5 13 15  9  7 10 11 21 10 10  9 11 15  7
10
14


but the count is wrong, because i have only 9 times 01/01/2001 etc.

 data[1:30]
 [1] 2001-01-01 2001-01-01 2001-01-01 2001-01-01 2001-01-01
 [6] 2001-01-01 2001-01-01 2001-01-01 2001-01-01

2001-01-02
[11] 2001-01-02 2001-01-02 2001-01-02 2001-01-02 2001-01-02
[16] 2001-01-02 2001-01-02 2001-01-02 2001-01-02 2001-01-02
[21] 2001-01-03 2001-01-03 2001-01-03 2001-01-03 2001-01-03
[26] 2001-01-03 2001-01-03 2001-01-03 2001-01-03 2001-01-03



Now, when i give R the breaks.

 br -
seq(as.Date(31.12.2000,format=%d.%m.%Y),as.Date(01.01.2012,format=%d.%m.%Y),by=1)
 test2- hist(data,br,freq=T)
 test2$counts[1:10]
 [1] 12 15 17 12 15  6  4  5 13  5


In this case, neither get the right counts but limiting i get the
correct
counts:

 test3- hist(data[1:50],br[1:6],freq=T)
 test3$counts
[1]  9 11 13  9  8


I hope someone can help me with this problem.


Thank you very much!!

Best regards,

Dominic




__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Code to fetch summary info from vector

2013-01-15 Thread Rui Barradas

Hello,

Continuing Jessica's code, to get the maximum of each group just use

b - c(1,1,1,2,3,4,3,2,1,1,1,1,1,2,3,4,5,4,3.5,3,2,1,1,1)
r - rle(b  1)
groups - rep(1:length(r$lengths),r$lengths)

tapply(b, groups, FUN = max)

# To get just the groups where b  1,

mx - tapply(b, groups, FUN = max)
mx[mx  1]

# And you can combine both like in

cbind(length = r$lengths[r$values], max = mx[mx  1])


Hope this helps,

Rui Barradas
Em 15-01-2013 16:57, Jessica Streicher escreveu:

Maybe rle can help a little here

rle(b1)

Run Length Encoding
   lengths: int [1:5] 3 5 5 8 3
   values : logi [1:5] FALSE TRUE FALSE TRUE FALSE

  r-rle(b1)

r$lengths[r$values]
[1] 5 8

# started for the maximum but need to go home now, sorry. Will continue 
tomorrow if noone else finishes it.
groups - rep(1:length(r$lengths),r$lengths)

On 15.01.2013, at 17:16, Benjamin Gillespie wrote:


Hi all,

Thanks in advance for any help.

I have a vector b:

b=c(1,1,1,2,3,4,3,2,1,1,1,1,1,2,3,4,5,4,3.5,3,2,1,1,1)

Imagine b is river flow throughout time.

I would like some code that will generate the following information:

number of individual 'periods' where b1 (= 2 in this case)
period 1 length = 5, max = 4
period 2 length = 8, max = 5

I can't figure anything useful out.

Thanks,

Ben Gillespie
Research Postgraduate

School of Geography
University of Leeds
Leeds
LS2 9JT

http://www.geog.leeds.ac.uk/
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Code to fetch summary info from vector

2013-01-15 Thread David Winsemius


On Jan 15, 2013, at 8:16 AM, Benjamin Gillespie wrote:


Hi all,

Thanks in advance for any help.

I have a vector b:

b=c(1,1,1,2,3,4,3,2,1,1,1,1,1,2,3,4,5,4,3.5,3,2,1,1,1)

Imagine b is river flow throughout time.

I would like some code that will generate the following information:

number of individual 'periods' where b1 (= 2 in this case)
period 1 length = 5, max = 4
period 2 length = 8, max = 5

I can't figure anything useful out.


Look at:

rle(b1)
?rle

Should get you started.

--
David



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] Tukey HSD plot with lines indicating (non-)significance

2013-01-15 Thread Karl Ove Hufthammer
Thanks for the suggested code! It’s a very nice way of displaying most
aspects of the data and the HSD tests/CIs. The graphical display is
probably to big for inclusion in journal articles, but works well for
displaying the results when working with the data.


Regards,
Karl Ove Hufthammer


ty. den 15. 01. 2013 klokka 06.43 (-0500) skreiv Richard M. Heiberger:
 Karl, 
 
 Thank you for this interesting challenge.  It turns out to be
 reasonably straightforward. This code does it for the first example
 in ?MMC. 
 
 ## This example is based on the example in ?HH:::MMC 
 
 library(HH) 
 
 ## pairwise comparisons data(catalystm) 
 
 
 
 ## A. individual plots 
 
 ## base graphics box plot boxplot(concent ~ catalyst, data=catalystm,
 xlab=catalyst, ylab=concentration, las=1) 
 
 ## aov catalystm1.aov - aov(concent ~ catalyst, data=catalystm)
 summary(catalystm1.aov) 
 
 ## MMC plot old.omd - par(omd=c(0,.95,0,1)) catalystm.mmc -
 mmc(catalystm1.aov, linfct = mcp(catalyst = Tukey)) catalystm.mmc
 plot(catalystm.mmc, ry=c(50,58), x.offset=1.8) 
 
 ## tiebreaker plot plotMatchMMC(catalystm.mmc$mca,
 xlabel.print=FALSE) 
 
 
 
 
 
 ## B. coordinate scales of all three plots by adjusting par values and
 ##the frame sizes 
 
 def.par - par(no.readonly = TRUE) # save default, for resetting... ##
 allocate figure 1 the right 2/3 and top 2/3 of the plotting region ##
 allocate figure 2 the right 2/3 and bottom 1/3 of the plotting region
 ## allocate figure 3 the left 1/3 and top 2/3 of the plotting region
 frame() layout(matrix(c(3,1, 0,2), 2, 2, byrow =
 TRUE),widths=c(1,2), heights=c(2,1)) ## show the regions that
 have been allocated to each plot layout.show(3) 
 
 omd.old - par(omd=c(0,.95,0,1)) plot(catalystm.mmc, ry=c(50,59),
 x.offset=1.8) usr.mmc - par()$usr 
 
 mar.old - par(mar=c(5,4,0,2)+.1) plotMatchMMC(catalystm.mmc$mca,
 xlabel.print=FALSE) 
 
 par(mar.old) boxplot(concent ~ catalyst, data=catalystm,
 xlab=catalyst, ylab=concentration, las=1,
 ylim=usr.mmc[3:4], yaxs=i) 
 
 
 
 ## If you have a set of plots that don't fit comfortably into the ##
 space illustrated here, then you will need to increase the plotting ##
 device window from the default 7in x 7in because the cex is ##
 hardwired into the plot.mmc.multicomp function. 

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Using system() to dump HDF to text file?

2013-01-15 Thread Sarah Henderson
Hi all --

I am working on 64-bit Windows XP.  I'm not a very technical person when it
comes to the command line stuff, so please forgive me if this is a stupid
question.

I have a bunch of HDF files, and I want to dump a single PM25 data layer
from each file to .txt by invoking ncdump.exe from system().  Here's a
sample command string:

C:/ncdump -v PM25 C:/01aug2010.hdf  C:/01aug2010.txt

This works perfectly in Python, but does not actually generate the .txt
file in R when:

system(command)

It does show the output on the console, if flagged to do so, and I can
capture the output to an R object with intern = T.  I assume there is some
problem with the way I have specified how to get the output to the text
file (i.e. the ), but experimentation with other options has not gone
well.

Can anyone advise?

Thanks!

Sarah

[[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] Using system() to dump HDF to text file?

2013-01-15 Thread William Dunlap
Use shell() instead of system().  E.g., I have a bunch of Unix-like
executables in c:\cygwin\bin and I can use pipe and redirection
signs with them using shell():

 tf - tempfile()
 file.exists(tf)
[1] FALSE
 shell(paste(c:\\cygwin\\bin\\ls | c:\\cygwin\\bin\\head -5 , shQuote(tf, 
 cmd)))
 readLines(tf)
[1] R.dll   R.exe   RSetReg.exe Rblas.dll   Rcmd.exe   
 getwd()
[1] C:/Program Files/R/R-2.15.2/bin/x64
 dir()
 [1] open.exe  R.dll R.exe Rblas.dll Rcmd.exe 
 Rgraphapp.dll Rgui.exe  Riconv.dllRlapack.dll   
Rscript.exe   RSetReg.exe  
[12] Rterm.exe Rzlib.dll

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 Sarah Henderson
 Sent: Tuesday, January 15, 2013 10:28 AM
 To: R List
 Subject: [R] Using system() to dump HDF to text file?
 
 Hi all --
 
 I am working on 64-bit Windows XP.  I'm not a very technical person when it
 comes to the command line stuff, so please forgive me if this is a stupid
 question.
 
 I have a bunch of HDF files, and I want to dump a single PM25 data layer
 from each file to .txt by invoking ncdump.exe from system().  Here's a
 sample command string:
 
 C:/ncdump -v PM25 C:/01aug2010.hdf  C:/01aug2010.txt
 
 This works perfectly in Python, but does not actually generate the .txt
 file in R when:
 
 system(command)
 
 It does show the output on the console, if flagged to do so, and I can
 capture the output to an R object with intern = T.  I assume there is some
 problem with the way I have specified how to get the output to the text
 file (i.e. the ), but experimentation with other options has not gone
 well.
 
 Can anyone advise?
 
 Thanks!
 
 Sarah
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


[R] removing loops from code in making data.frame

2013-01-15 Thread Biau David
Dear all,

I am working on an author network and to do so I have to arrange a data.frame 
(tutu) crossing author names (rows) per publication number (column). The 
participation of the author to a study is indicated by a 1 and 0 otherwise.

I have a vector (xaulist) of all the names of authors and a data.frame (tata) 
with all the publications in row and the authors in columns. I have writen a 
loop to obtain my data.frame but it takes a long time when the number of 
studies increases. I was looking for a more efficient code.

Here is a minimal working example (my code is terrible i know...):

#-

au1 - c('deb', 'art', 'deb', 'seb', 'deb', 'deb', 'mar', 'mar', 'joy', 'deb')
au2 - c('art', 'deb', 'soy', 'deb', 'joy', 'ani', 'deb', 'deb', 'nem', 'mar')
au3 - c('mar', 'lio', 'mil', 'mar', 'ani', 'lul', 'nem', 'art', 'deb', 'tat')

tata - data.frame(au1, au2, au3)
xaulist2 - levels(factor(unlist(tata[,])))
xaulist - levels(as.factor(xaulist2))

tutu - matrix(NA, nrow=length(xaulist), ncol=dim(tata)[1]) # row are authors 
and col are papers
for (i in 1:length(xaulist))
{
  for (j in 1:dim(tata)[1])
  {
  ifelse('TRUE' %in% as.character(tata[j,]==xaulist[i]), tutu[i,j] - 1,  
tutu[i,j] - 0)
  }
}
tutu[is.na(tutu)] - 0

#-

I am looking at some more efficient way to build 'tutu'.

Thank you very much,

 
David

[[alternative HTML version deleted]]

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


Re: [R] Random Forest Error for Factor to Character column

2013-01-15 Thread Lopez, Dan
Andrew,

That did the trick.

Thank you.
Dan

From: Andrew Robinson [mailto:mensuration...@gmail.com]
Sent: Monday, January 14, 2013 6:06 PM
To: Lopez, Dan
Cc: R help (r-help@r-project.org)
Subject: Re: [R] Random Forest Error for Factor to Character column

After you subset the data, did you redeclare the factor? If not then R still 
thinks it has the potential for all those levels.

TRAINSET$JOBTITLE - factor(TRAINSET$JOBTITLE)

I hope this helps

Andrew

On Tuesday, January 15, 2013, Lopez, Dan wrote:
Hi,

Can someone please offer me some guidance?

I imported some data. One of the columns called JOBTITLE when imported was 
imported as a factor column with 416 levels.

I subset the data in such a way that only 4 levels have data in JOBTITLE and 
tried running randomForest but it complained about JOBTITLE having more than 
32 categories. I know that is the limit in randomForest but I guess I don't 
understand enough about factors because I thought by subsetting the data this 
no longer would be an issue. BTW I can run randomForest on this dataset if I 
exclude JOBTITLE.

So  I then converted that column to a character vector:
 TRAINSET$JOBTITLE-as.character(TRAINSET$JOBTITLE)

I ran Random Forest and got the below error. Why isn't this working? What do I 
need to do to get this working?

 library(randomForest)
 FOREST_model - randomForest(as.factor(TARGET)~., data=trainset, mtry=4, 
 ntree=1000,
+importance=TRUE, do.trace=100)

Error in randomForest.default(m, y, ...) :
  NA/NaN/Inf in foreign function call (arg 1)
In addition: Warning message:
In data.matrix(x) : NAs introduced by coercion

Your help will be greatly appreciated.

Dan

[[alternative HTML version deleted]]

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


--
Andrew Robinson
Director (A/g), ACERA
Department of Mathematics and StatisticsTel: +61-3-8344-6410
University of Melbourne, VIC 3010 Australia   (prefer email)
http://www.ms.unimelb.edu.au/~andrewprhttp://www.ms.unimelb.edu.au/%7Eandrewpr
  Fax: +61-3-8344-4599
http://www.acera.unimelb.edu.au/

FAwR: 
http://www.ms.unimelb.edu.au/~andrewpr/FAwR/http://www.ms.unimelb.edu.au/%7Eandrewpr/FAwR/
SPuR: http://www.ms.unimelb.edu.au/spuRs/

[[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] readHTMLTable (XML package)

2013-01-15 Thread Lopez, Dan
Hi,

I am using XML::readHTMLTable and getting the below error. Does anyone know 
why? Does this function not work with https? I didn't see anything in help 
about that.

 library(XML)
 wampage-readHTMLTable('https://hr-workforce-analytics.llnl.gov/wf_pi_pop.html',1)
Error in htmlParse(doc) :
  File https://hr-workforce-analytics.llnl.gov/wf_pi_pop.html does not exist

Dan


[[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] grouping elements of a data frame

2013-01-15 Thread Nuri Alpay Temiz
Hi everyone,

I have a question on selecting and grouping elements of a data frame. For 
example:

A.df- [ a c 0.9
 b  x 0.8
 b z 0.5
 c y 0.9
 c x 0.7
 c z 0.6]


I want to create a list of a data frame that gives me the unique values of 
column 1 of A.df so that i can create intersects. That is:

B[a]- [ c 0.9]

B[b]- [ x 0.8
 z 0.5]

B[c]- [ y 0.9
 x 0.7
 z 0.6]


B[c] n B[b] - c(x,z)


How can I accomplish this?

Thanks,
Al
 
 
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] e1071 SVM, cross-validation and overfitting

2013-01-15 Thread Robert Poor
I am accustomed to the LIBSVM package, which provides cross-validation
on training with the -v option

  % svm-train -v 5 ...

This does 5 fold cross validation while building the model and avoids
over-fitting.

But I don't see how to accomplish that in the e1071 package.  (I
learned that svm(... cross=5 ...) only _tests_ using cross-validation
-- it doesn't affect the training.)  Can someone clue me in how to do
something equivalent to LIBSVM's -v option?

Thanks!

- ff

P.S.: My test case follows.  If you run the code, the tuned output
shows clear signs of over-fitting.  I'd like to eliminate that.

require('e1071')
colors - c(2, 3, 4, 5, 6)
set.seed(23) # set random seed for repeatability

# log(x) + cos(x) + noise
f - function(x) log(x) + cos(x)
x - seq(0.1, 5, by = 0.05)
y - f(x) + rnorm(x, sd = 0.2)
plot(x, y, col=gray80)

legend(topleft,
   c(log(x) + cos(x), SVM, untuned, SVM, tuned),
   bty=n,
   col=colors,
   pch=20)

lines(x, f(x), col = colors[1]) # overlay noiseless data

# SVM, untuned
svmmodel1 - svm(x, y)
print(summary(svmmodel1))
y1 - predict(svmmodel1, x)
lines(x, y1, col = colors[2])

# SVM with tuning
tuning - tune.svm(x, y, gamma = 2^(-4:4), cost = 2^(-2:2))
svmmodel2 - tuning$best.model
print(summary(svmmodel2))
y2 - predict(svmmodel2, x)
lines(x, y2, col = colors[3])

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

2013-01-15 Thread Karl Ove Hufthammer
andrewH skreiv:

 Is there a data frame analog to sparse matrices? I am working with a panel
 data set that has a large number of variables that are redefined
 repeatedly or exist for only a few years (out of 48).  In my current
 structure, where variables are columns and rows are years, more than 90
 percent of the cells and more than 3/4 of the total size of my file are
 NAs.
 
 I am wondering if there is an alternate file specification currently
 available that still allows numeric, character and factor data to be
 stored. Besides just using a database.

How about storing the data in a ‘long’ format, like you get when you
apply melt() (with na.rm=TRUE) from the ‘reshape2’ package to your data 
frame? Parts of the data frame (the ID part) will be repeated on each row, 
which may make the data take up more space, but no rows are stored for NA 
cells, so for somewhat sparse data it will be a win. It also makes it very 
easy to reshape and analyse the data.

Here’s an introduction (to the older ‘reshape’ package, but ‘reshape2’ is 
very similar): http://www.jstatsoft.org/v21/i12

You might also be interested in this paper on ‘tidy’ data:
http://vita.had.co.nz/papers/tidy-data.pdf

-- 
Karl Ove Hufthammer
E-mail: k...@huftis.org
Jabber: huf...@jabber.no

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

2013-01-15 Thread Greg Snow
There is also the my.symbols and ms.polygon functions in the TeachingDemos
package that have syntax similar to the symbols function:


library(TeachingDemos)
x - runif(10)
y - rnorm(10)
my.symbols(x, y, ms.polygon, inches=0.3, n=400, add=FALSE, lty=3)





On Sat, Jan 12, 2013 at 7:42 PM, Ved P. Sharma vedsha...@gmail.com wrote:

 Thanks everyone for suggesting the alternative draw.circle.

 Ved

 On Sat, Jan 12, 2013 at 12:50 PM, Jose Iparraguirre
 jose.iparragui...@ageuk.org.uk wrote:
  Don't know, but you can use the function draw.circle in the plotrix
 package.
  Hope this helps,
  Jose
  
  From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On
 Behalf Of Ved P. Sharma [vedsha...@gmail.com]
  Sent: 12 January 2013 07:43
  To: r-help@r-project.org
  Subject: [R] Drawing a dotted circle.
 
  Hi,
 
  I am trying to draw a dotted circle by using symbols command:
 
  symbols(0, 0, circles = 1, inches = FALSE, fg = 'gray', lty=2)
 
  But it gives me a solid line. I was just wondering whether am I making a
  mistake?
 
  Ved
 
  [[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.
 
  Wrap Up and Run 10k is back!
 
  Also, new for 2013 – 2km intergenerational walks at selected venues. So
 recruit a buddy, dust off the trainers and beat the winter blues by
  signing up now:
 
  http://www.ageuk.org.uk/10k
 
   Milton Keynes | Oxford | Sheffield | Crystal Palace |
 Exeter | Harewood House, Leeds |
   Tatton Park, Cheshire | Southampton |
 Coventry
 
 
 
  Age UK Improving later life
 
  http://www.ageuk.org.uk
 
 
 
 
  ---
  Age UK is a registered charity and company limited by guarantee,
 (registered charity number 1128267, registered company number 6825798).
  Registered office: Tavis House, 1-6 Tavistock Square, London WC1H 9NA.
 
  For the purposes of promoting Age UK Insurance, Age UK is an Appointed
 Representative of Age UK Enterprises Limited, Age UK is an Introducer
  Appointed Representative of JLT Benefit Solutions Limited and
 Simplyhealth Access for the purposes of introducing potential annuity and
 health
  cash plans customers respectively.  Age UK Enterprises Limited, JLT
 Benefit Solutions Limited and Simplyhealth Access are all authorised and
  regulated by the Financial Services Authority.
  --
 
  This email and any files transmitted with it are confidential and
 intended solely for the use of the individual or entity to whom they are
  addressed. If you receive a message in error, please advise the sender
 and delete immediately.
 
  Except where this email is sent in the usual course of our business, any
 opinions expressed in this email are those of the author and do not
  necessarily reflect the opinions of Age UK or its subsidiaries and
 associated companies. Age UK monitors all e-mail transmissions passing
  through its network and may block or modify mails which are deemed to be
 unsuitable.
 
  Age Concern England (charity number 261794) and Help the Aged (charity
 number 272786) and their trading and other associated companies merged
  on 1st April 2009.  Together they have formed the Age UK Group,
 dedicated to improving the lives of people in later life.  The three
 national
  Age Concerns in Scotland, Northern Ireland and Wales have also merged
 with Help the Aged in these nations to form three registered charities:
  Age Scotland, Age NI, Age Cymru.
 
 
 
 
 
 
 
 
 
 

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




-- 
Gregory (Greg) L. Snow Ph.D.
538...@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] readHTMLTable (XML package)

2013-01-15 Thread Ista Zahn
Hi Dan,

A couple of things: first, I think that file really does not exist (at
least I can't open it in my web browser). Second, even if it did,
url() cannot download from https, according to the details section of
?url, which points you to RCurl. So, once you verify that you url
actually exists you can do something like

library(XML)
library(RCurl)
tabs - 
readHTMLTable(getURL(http://en.wikipedia.org/wiki/List_of_countries_by_population;))

Best,
Ista

On Tue, Jan 15, 2013 at 2:59 PM, Lopez, Dan lopez...@llnl.gov wrote:
 Hi,

 I am using XML::readHTMLTable and getting the below error. Does anyone know 
 why? Does this function not work with https? I didn't see anything in help 
 about that.

 library(XML)
 wampage-readHTMLTable('https://hr-workforce-analytics.llnl.gov/wf_pi_pop.html',1)
 Error in htmlParse(doc) :
   File https://hr-workforce-analytics.llnl.gov/wf_pi_pop.html does not exist

 Dan


 [[alternative HTML version deleted]]

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

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


[R] SQLDF column errors

2013-01-15 Thread Matthew Liebers
I am trying to exclude integer values from a small data frame 1, d1 that
have matching hits in data frame 2, d2 (Very big) which involves matching
those hits first.  I am trying to use sqldf on the df's in the following
fashion:

df1:
V1
12675
14753
16222
18765

df2: head(df2)
V1  V2
13647 rd1500
14753 rd1580
15987 rd1590
16222 rd2020.

df1_new-sqldf(select df1.V1, df2.V2 where rs10.V1 = d10.pos”) - Ideally I
would like to try to use delete or not equal to != though I can only
find that delete works with sqldf.
but it returns this error:
 Error in sqliteExecStatement(con, statement, bind.data) :
  RS-DBI driver: (error in statement: no such column: df1.V1)
I am also trying this:
df1_new-sqldf(select V1 from df1, V2 from df2 where df1.V1 = df2.V1)
which returns this error:
Error in sqliteExecStatement(con, statement, bind.data) :
  RS-DBI driver: (error in statement: near from: syntax error)

If anyone with sqldf knowledge could lend me a hand that would be great.
Thanks!

Matt

[[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] Regular expression

2013-01-15 Thread William Dunlap
 gsub([',], , 'asd'f)
Error: unexpected ']' in gsub([',]

What is the right way to include the 'double quote' in the search field?

The 'search field' is a string and to put a double quote into a double-quote
delimited string you need to escape it with a backslash so it is not
interpreted as the ending quote on the string.
gsub([',\], , 'asd'f)
  [1] asdf

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
 Behalf
 Of Christofer Bogaso
 Sent: Tuesday, January 15, 2013 1:39 PM
 To: r-help
 Subject: [R] Regular expression
 
 Hello again,
 
 I am having a problem on Regular expression. Let say I have following code:
 
  gsub([',], , 'asd'f)
 [1] asdf
 
 
 This is perfect. However I am having problem if I include  (i.e. the
 double quote) in the first argument as the pattern search:
 
  gsub([',], , 'asd'f)
 Error: unexpected ']' in gsub([',]
 
 
 What is the right way to include the 'double quote' in the search field?
 
 Thanks for your help.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] removing loops from code in making data.frame

2013-01-15 Thread arun
Hi,
May be this helps:
res-do.call(rbind,lapply(xaulist,function(x) 
as.integer(apply(tata,1,function(i) any(i==x)
res[]-sapply(res,as.numeric)
identical(res,tutu)
#[1] TRUE
A.K.





- Original Message -
From: Biau David djmb...@yahoo.fr
To: r help list r-help@r-project.org
Cc: 
Sent: Tuesday, January 15, 2013 2:41 PM
Subject: [R] removing loops from code in making data.frame

Dear all,

I am working on an author network and to do so I have to arrange a data.frame 
(tutu) crossing author names (rows) per publication number (column). The 
participation of the author to a study is indicated by a 1 and 0 otherwise.

I have a vector (xaulist) of all the names of authors and a data.frame (tata) 
with all the publications in row and the authors in columns. I have writen a 
loop to obtain my data.frame but it takes a long time when the number of 
studies increases. I was looking for a more efficient code.

Here is a minimal working example (my code is terrible i know...):

#-

au1 - c('deb', 'art', 'deb', 'seb', 'deb', 'deb', 'mar', 'mar', 'joy', 'deb')
au2 - c('art', 'deb', 'soy', 'deb', 'joy', 'ani', 'deb', 'deb', 'nem', 'mar')
au3 - c('mar', 'lio', 'mil', 'mar', 'ani', 'lul', 'nem', 'art', 'deb', 'tat')

tata - data.frame(au1, au2, au3)
xaulist2 - levels(factor(unlist(tata[,])))
xaulist - levels(as.factor(xaulist2))

tutu - matrix(NA, nrow=length(xaulist), ncol=dim(tata)[1]) # row are authors 
and col are papers
for (i in 1:length(xaulist))
{
  for (j in 1:dim(tata)[1])
  {
  ifelse('TRUE' %in% as.character(tata[j,]==xaulist[i]), tutu[i,j] - 1,  
tutu[i,j] - 0)
  }
}
tutu[is.na(tutu)] - 0

#-

I am looking at some more efficient way to build 'tutu'.

Thank you very much,

 
David

    [[alternative HTML version deleted]]


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


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


Re: [R] grouping elements of a data frame

2013-01-15 Thread David Winsemius

On Jan 15, 2013, at 9:10 AM, Nuri Alpay Temiz wrote:

 Hi everyone,
 
 I have a question on selecting and grouping elements of a data frame. For 
 example:
 
 A.df- [ a c 0.9
 b  x 0.8
 b z 0.5
 c y 0.9
 c x 0.7
 c z 0.6]

That is not R code. Matlab?, Python? 

 
 
 I want to create a list of a data frame that gives me the unique values of 
 column 1 of A.df so that i can create intersects. That is:
 
 B[a]- [ c 0.9]
 
 B[b]- [ x 0.8
 z 0.5]
 
 B[c]- [ y 0.9
 x 0.7
 z 0.6]
 
 
 B[c] n B[b] - c(x,z)
 

That's some sort of coded message? We are supposed to know what the n 
operation will do when assigned a vector?


Assuming your really do have a dataframe named B:

intersect(B$c, B$b)

Please code up examples in R in the future.

-- 

David Winsemius
Alameda, CA, USA

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


Re: [R] removing loops from code in making data.frame

2013-01-15 Thread arun
Hi,

You could also do this:
res1-do.call(rbind,lapply(xaulist,function(x) 
as.numeric(apply(t(mapply(`==`,tata,x)),2,any
identical(res1,tutu)
#[1] TRUE
A.K.





- Original Message -
From: Biau David djmb...@yahoo.fr
To: r help list r-help@r-project.org
Cc: 
Sent: Tuesday, January 15, 2013 2:41 PM
Subject: [R] removing loops from code in making data.frame

Dear all,

I am working on an author network and to do so I have to arrange a data.frame 
(tutu) crossing author names (rows) per publication number (column). The 
participation of the author to a study is indicated by a 1 and 0 otherwise.

I have a vector (xaulist) of all the names of authors and a data.frame (tata) 
with all the publications in row and the authors in columns. I have writen a 
loop to obtain my data.frame but it takes a long time when the number of 
studies increases. I was looking for a more efficient code.

Here is a minimal working example (my code is terrible i know...):

#-

au1 - c('deb', 'art', 'deb', 'seb', 'deb', 'deb', 'mar', 'mar', 'joy', 'deb')
au2 - c('art', 'deb', 'soy', 'deb', 'joy', 'ani', 'deb', 'deb', 'nem', 'mar')
au3 - c('mar', 'lio', 'mil', 'mar', 'ani', 'lul', 'nem', 'art', 'deb', 'tat')

tata - data.frame(au1, au2, au3)
xaulist2 - levels(factor(unlist(tata[,])))
xaulist - levels(as.factor(xaulist2))

tutu - matrix(NA, nrow=length(xaulist), ncol=dim(tata)[1]) # row are authors 
and col are papers
for (i in 1:length(xaulist))
{
  for (j in 1:dim(tata)[1])
  {
  ifelse('TRUE' %in% as.character(tata[j,]==xaulist[i]), tutu[i,j] - 1,  
tutu[i,j] - 0)
  }
}
tutu[is.na(tutu)] - 0

#-

I am looking at some more efficient way to build 'tutu'.

Thank you very much,

 
David

    [[alternative HTML version deleted]]


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


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


Re: [R] SQLDF column errors

2013-01-15 Thread Anthony Damico
i think this is what you want..  :)

http://stackoverflow.com/questions/4765936/using-joined-tables-to-exclude-certain-records

library(sqldf)

# use the mtcars example table
mtcars

# keep the first eight records in a second, separate data set
x - mtcars[ 1:8 , ]

# keep all the records from mtcars where the mpg value doesn't match a
record in the `x` data table
y - sqldf( select * from mtcars where not exists ( select * from x where
x.mpg == mtcars.mpg ) )


# the above example assumes your tables won't fit in RAM.
# if they do, this method is obviously much easier
y - mtcars[ !( mtcars$mpg %in% x$mpg ) , ]




On Tue, Jan 15, 2013 at 4:02 PM, Matthew Liebers mr...@cornell.edu wrote:

 I am trying to exclude integer values from a small data frame 1, d1 that
 have matching hits in data frame 2, d2 (Very big) which involves matching
 those hits first.  I am trying to use sqldf on the df's in the following
 fashion:

 df1:
 V1
 12675
 14753
 16222
 18765

 df2: head(df2)
 V1  V2
 13647 rd1500
 14753 rd1580
 15987 rd1590
 16222 rd2020.

 df1_new-sqldf(select df1.V1, df2.V2 where rs10.V1 = d10.pos”) - Ideally I
 would like to try to use delete or not equal to != though I can only
 find that delete works with sqldf.
 but it returns this error:
  Error in sqliteExecStatement(con, statement, bind.data) :
   RS-DBI driver: (error in statement: no such column: df1.V1)
 I am also trying this:
 df1_new-sqldf(select V1 from df1, V2 from df2 where df1.V1 = df2.V1)
 which returns this error:
 Error in sqliteExecStatement(con, statement, bind.data) :
   RS-DBI driver: (error in statement: near from: syntax error)

 If anyone with sqldf knowledge could lend me a hand that would be great.
 Thanks!

 Matt

 [[alternative HTML version deleted]]


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



[[alternative HTML version deleted]]

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


[R] configure/build R on Windows

2013-01-15 Thread Beto .
Hello,

Does anyone knows if there is a Documentation or any wiki that
could help me to configure and build R
 using cygwin with the Intel Compilers on Windows?

Thanks,
Humberto.

  
[[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] Regular expression

2013-01-15 Thread arun
HI,
vec1-'asd'f
 vec2-'asdf'
 gsub([\],,vec2)
#[1] asdf
 gsub(['],,vec1)
#[1] asdf
A.K.





- Original Message -
From: Christofer Bogaso bogaso.christo...@gmail.com
To: r-help r-help@r-project.org
Cc: 
Sent: Tuesday, January 15, 2013 4:38 PM
Subject: [R] Regular expression

Hello again,

I am having a problem on Regular expression. Let say I have following code:

 gsub([',], , 'asd'f)
[1] asdf


This is perfect. However I am having problem if I include  (i.e. the
double quote) in the first argument as the pattern search:

 gsub([',], , 'asd'f)
Error: unexpected ']' in gsub([',]


What is the right way to include the 'double quote' in the search field?

Thanks for your help.

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

2013-01-15 Thread Greg Snow
This is fairly straight forward, you can do something like:

myfiles - scan('files.txt', what=)
base - sub(\\.[^.]*$, , myfiles)

lapply( seq_along(myfiles), function(i) {
mydat - read.table( myfiles[i] )
sink( sprintf('%sSummary.txt', base[i]) )
summary(mydat)
sink()
bmp( sprintf(%sPlot.bmp, base[i]) )
with(mydat, plot(x,y))
dev.off()
} )

Of course modifying things to include what you want to use.  If you want
the summary information and plots together in a single output file (pdf
file, word document, html, etc.) then you should look at the knitr package
as a way to set up a template and possibly the pandoc program as a way to
convert the results to another format, then do the processing in a loop
like above.




On Tue, Jan 15, 2013 at 5:30 AM, Simonas Kecorius simolas2...@gmail.comwrote:

 Dear R users,

 First of all I would like to thank all of you who replayed to my previous
 questions and problems. Thank you a lot for being great and helpful
 community. I highly appreciate your suggestions and ideas even if I do not
 respond after my question! But it means that your help was exactly what I
 needed. Thank you again!

 Now the following question I need help:

 Suppose I do have a file.txt in the working directory. This file contains
 the names of other files in the same directory:

 First.txt
 Second.txt
 Third.txt
 etc...

 Files First.txt, Second.txt...are data files.

 What I need R to do, is to read this file.txt line by line, open files
 which names are listed ( First.txt, Second.txt...) and process it: lets say
 make a FirstPlot.bmp, FirstSummary.txt  and save it to working directory,
 then automatically open Second.txt, do the same, Third.txt etc. until the
 end of the names in file.txt.

 This would help me with the following task: I do measurements each day, and
 I need to process my data: draw some plots, make some analysis.  When I
 have 30 days of measurements each 1 second, there are huge amount of
 numbers I am dealing with. If you could suggest some automation via R, it
 would be perfect.

 Thank you in advance.

 Cheers.

 --
 Simonas Kecorius
 **Lithuania

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




-- 
Gregory (Greg) L. Snow Ph.D.
538...@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] readHTMLTable (XML package)

2013-01-15 Thread Lopez, Dan
Hi Ista,

It does exist. It’s a page in our company intranet.

It is https so it looks like I can't use RCurl either. I tried RCurl BTW and 
got the below error.

Do you have experience with pulling a table of an https site? If so how do I do 
that?

 
 tabs - 
 readHTMLTable(getURL(https://hr-workforce-analytics.llnl.gov/wf_pi_pop.html;))
Error in 
readHTMLTable(getURL(https://hr-workforce-analytics.llnl.gov/wf_pi_pop.html;)) 
: 
  error in evaluating the argument 'doc' in selecting a method for function 
'readHTMLTable': Error in function (type, msg, asError = TRUE)  : 
  SSL certificate problem, verify that the CA cert is OK. Details:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify 
failed


Thanks.
Dan

-Original Message-
From: Ista Zahn [mailto:istaz...@gmail.com] 
Sent: Tuesday, January 15, 2013 12:22 PM
To: Lopez, Dan
Cc: R help (r-help@r-project.org)
Subject: Re: [R] readHTMLTable (XML package)

Hi Dan,

A couple of things: first, I think that file really does not exist (at least I 
can't open it in my web browser). Second, even if it did,
url() cannot download from https, according to the details section of ?url, 
which points you to RCurl. So, once you verify that you url actually exists you 
can do something like

library(XML)
library(RCurl)
tabs - 
readHTMLTable(getURL(http://en.wikipedia.org/wiki/List_of_countries_by_population;))

Best,
Ista

On Tue, Jan 15, 2013 at 2:59 PM, Lopez, Dan lopez...@llnl.gov wrote:
 Hi,

 I am using XML::readHTMLTable and getting the below error. Does anyone know 
 why? Does this function not work with https? I didn't see anything in help 
 about that.

 library(XML)
 wampage-readHTMLTable('https://hr-workforce-analytics.llnl.gov/wf_pi
 _pop.html',1)
 Error in htmlParse(doc) :
   File https://hr-workforce-analytics.llnl.gov/wf_pi_pop.html does not 
 exist

 Dan


 [[alternative HTML version deleted]]

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


[R] Plot Header

2013-01-15 Thread Pete Brecknock
Any recommendations for how I can embed my title below in a single red
strip/box across the plot area in the outer margin? 

I would like to avoid the color appearing in any other area defined by the
oma.

# Example Plot
par(mfrow=c(2,2),mar=c(4,4,2,2), oma = c(1, 1, 3, 1))
plot(rnorm(100),1:100)
plot(rnorm(100),1:100)
plot(rnorm(100),1:100)
plot(rnorm(100),1:100)
# Title
title(MY TITLE, outer = TRUE, cex = 1.5, adj=0, col=blue, font=2)

Thanks for any pointers

Pete



--
View this message in context: 
http://r.789695.n4.nabble.com/Plot-Header-tp4655654.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] Can not load Rcmdr

2013-01-15 Thread Esformes, Carley M.
I am getting the error message:


 library(Rcmdr)

Loading required package: car

Loading required package: MASS

Loading required package: nnet

Error : .onAttach failed in attachNamespace() for 'Rcmdr', details:

  call: structure(.External(dotTclObjv, objv, PACKAGE = tcltk), class = 
tclObj)

  error: [tcl] invalid command name image.


Error: package/namespace load failed for 'Rcmdr'


If I try and load tcltk separately, it loads, but I get a warning.

 library(tcltk)

Loading Tcl/Tk interface ... done

Warning message:

In fun(libname, pkgname) :

  couldn't connect to display /tmp/launch-pCcdvk/:0

_X11TransSocketINETConnect() can't get address for /tmp/launch-pCcdvk/:6000: 
nodename nor servname provided, or not known


I want to run BiodiversityR.  Which runs, but ultimately I get an error.


 library(BiodiversityR)

Loading required package: vegan

Loading required package: permute

This is vegan 2.0-5

 BiodiversityRGUI()

Loading required package: Rcmdr

Error : .onAttach failed in attachNamespace() for 'Rcmdr', details:

  call: structure(.External(dotTclObjv, objv, PACKAGE = tcltk), class = 
tclObj)

  error: [tcl] invalid command name image.


Error in BiodiversityRGUI() : needs Rcmdr



[[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] grouping elements of a data frame

2013-01-15 Thread arun
Hi,
Try this:
The last part was not clear.
A.df-read.table(text=
        a c 0.9
    b  x 0.8
    b z 0.5
    c y 0.9
    c x 0.7
    c z 0.6
,sep=,header=FALSE,stringsAsFactors=FALSE)
 lst1-split(A.df[,-1],A.df$V1)
lst1
#$a
#  V2  V3
#1  c 0.9
#
#$b
#  V2  V3
#2  x 0.8
#3  z 0.5
#
#$c
#  V2  V3
#4  y 0.9
#5  x 0.7
#6  z 0.6


A.K.



- Original Message -
From: Nuri Alpay Temiz alpayte...@outlook.com
To: R-help@r-project.org
Cc: 
Sent: Tuesday, January 15, 2013 12:10 PM
Subject: [R] grouping elements of a data frame

Hi everyone,

I have a question on selecting and grouping elements of a data frame. For 
example:

A.df- [ a c 0.9
             b  x 0.8
             b z 0.5
             c y 0.9
             c x 0.7
             c z 0.6]


I want to create a list of a data frame that gives me the unique values of 
column 1 of A.df so that i can create intersects. That is:

B[a]- [ c 0.9]

B[b]- [ x 0.8
             z 0.5]

B[c]- [ y 0.9
             x 0.7
             z 0.6]


B[c] n B[b] - c(x,z)


How can I accomplish this?

Thanks,
Al
                    
            
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] readHTMLTable (XML package)

2013-01-15 Thread David Winsemius

On Jan 15, 2013, at 2:31 PM, Lopez, Dan wrote:

 Hi Ista,
 
 It does exist. It’s a page in our company intranet.
 
 It is https so it looks like I can't use RCurl either. I tried RCurl BTW and 
 got the below error.
 
 Do you have experience with pulling a table of an https site? If so how do I 
 do that?

Why not use a browser and save it locally?

-- 
David.
 
 
 tabs - 
 readHTMLTable(getURL(https://hr-workforce-analytics.llnl.gov/wf_pi_pop.html;))
 Error in 
 readHTMLTable(getURL(https://hr-workforce-analytics.llnl.gov/wf_pi_pop.html;))
  : 
  error in evaluating the argument 'doc' in selecting a method for function 
 'readHTMLTable': Error in function (type, msg, asError = TRUE)  : 
  SSL certificate problem, verify that the CA cert is OK. Details:
 error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify 
 failed
 
 
 Thanks.
 Dan
 
 -Original Message-
 From: Ista Zahn [mailto:istaz...@gmail.com] 
 Sent: Tuesday, January 15, 2013 12:22 PM
 To: Lopez, Dan
 Cc: R help (r-help@r-project.org)
 Subject: Re: [R] readHTMLTable (XML package)
 
 Hi Dan,
 
 A couple of things: first, I think that file really does not exist (at least 
 I can't open it in my web browser). Second, even if it did,
 url() cannot download from https, according to the details section of ?url, 
 which points you to RCurl. So, once you verify that you url actually exists 
 you can do something like
 
 library(XML)
 library(RCurl)
 tabs - 
 readHTMLTable(getURL(http://en.wikipedia.org/wiki/List_of_countries_by_population;))
 
 Best,
 Ista
 
 On Tue, Jan 15, 2013 at 2:59 PM, Lopez, Dan lopez...@llnl.gov wrote:
 Hi,
 
 I am using XML::readHTMLTable and getting the below error. Does anyone know 
 why? Does this function not work with https? I didn't see anything in help 
 about that.
 
 library(XML)
 wampage-readHTMLTable('https://hr-workforce-analytics.llnl.gov/wf_pi
 _pop.html',1)
 Error in htmlParse(doc) :
  File https://hr-workforce-analytics.llnl.gov/wf_pi_pop.html does not 
 exist
 
 Dan
 
 
[[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.

David Winsemius
Alameda, CA, USA

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


Re: [R] readHTMLTable (XML package)

2013-01-15 Thread Lopez, Dan
David,

Because there is some data on various webpages that I use periodically that 
this would be convenient for me to use.
Copying and pasting is messy . And obtaining direct database access for the 
data on some these pages is not possible for me (i.e. won't get approved...but 
I can use what is out there)

Dan


-Original Message-
From: David Winsemius [mailto:dwinsem...@comcast.net] 
Sent: Tuesday, January 15, 2013 3:00 PM
To: Lopez, Dan
Cc: Ista Zahn; R help (r-help@r-project.org)
Subject: Re: [R] readHTMLTable (XML package)


On Jan 15, 2013, at 2:31 PM, Lopez, Dan wrote:

 Hi Ista,
 
 It does exist. It's a page in our company intranet.
 
 It is https so it looks like I can't use RCurl either. I tried RCurl BTW and 
 got the below error.
 
 Do you have experience with pulling a table of an https site? If so how do I 
 do that?

Why not use a browser and save it locally?

--
David.
 
 
 tabs - 
 readHTMLTable(getURL(https://hr-workforce-analytics.llnl.gov/wf_pi_p
 op.html))
 Error in 
 readHTMLTable(getURL(https://hr-workforce-analytics.llnl.gov/wf_pi_pop.html;))
  : 
  error in evaluating the argument 'doc' in selecting a method for function 
 'readHTMLTable': Error in function (type, msg, asError = TRUE)  : 
  SSL certificate problem, verify that the CA cert is OK. Details:
 error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate 
 verify failed
 
 
 Thanks.
 Dan
 
 -Original Message-
 From: Ista Zahn [mailto:istaz...@gmail.com]
 Sent: Tuesday, January 15, 2013 12:22 PM
 To: Lopez, Dan
 Cc: R help (r-help@r-project.org)
 Subject: Re: [R] readHTMLTable (XML package)
 
 Hi Dan,
 
 A couple of things: first, I think that file really does not exist (at 
 least I can't open it in my web browser). Second, even if it did,
 url() cannot download from https, according to the details section of 
 ?url, which points you to RCurl. So, once you verify that you url 
 actually exists you can do something like
 
 library(XML)
 library(RCurl)
 tabs - 
 readHTMLTable(getURL(http://en.wikipedia.org/wiki/List_of_countries_b
 y_population))
 
 Best,
 Ista
 
 On Tue, Jan 15, 2013 at 2:59 PM, Lopez, Dan lopez...@llnl.gov wrote:
 Hi,
 
 I am using XML::readHTMLTable and getting the below error. Does anyone know 
 why? Does this function not work with https? I didn't see anything in help 
 about that.
 
 library(XML)
 wampage-readHTMLTable('https://hr-workforce-analytics.llnl.gov/wf_p
 i
 _pop.html',1)
 Error in htmlParse(doc) :
  File https://hr-workforce-analytics.llnl.gov/wf_pi_pop.html does not 
 exist
 
 Dan
 
 
[[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.

David Winsemius
Alameda, CA, USA

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


Re: [R] function coverage [solved?]

2013-01-15 Thread Ross Boylan
On Mon, 2013-01-14 at 13:08 -0800, Ross Boylan wrote:
 Is there an easy way to identify all the functions called as a result of
 invoking a function?  Getting the calling hierarchy too would be nice,
 but is definitely not essential.
 
 I'm trying to understand someone else's package, which is in a namespace
 and has some S3 functions.  I could probably live without tracing the S3
 functions.  All the functions I want to trace are in R.  The code passes
 functions around as arguments, so that the function being called is not
 always obvious from inspection of the source immediately around the
 call.
 
 I can imagine a solution that went something like this:
 1. identify all functions by searching the sources for  - function(
 (probably only at the left margin, to avoid attempting to trace
 functions defined inside of functions).
 2. Write a function that wraps another function to record the fact that
 it has been called.
 3. Somehow replace all functions with their wrapped equivalents.
 4. make the top level call.
 5. inspect the data constructed by the wrapper.
 
 The code is recursive and iterative; manual stepping does not seem
 feasible.  The package includes a lot of earlier versions of the code,
 and so I suspect that a lot of the code is not active.
 
 Thanks.
 Ross Boylan

Inspired particularly by Michael Weylandt's suggestion I developed the
following functions, with a typical usage indicated int he comments.
The file is cover.R.  I'm not sure if attachments are allowed, so here
it is inline
---
# cover.R  determine functions called
# GPL 3.0 license

# Typical use
# mylog - gzfile(try2.gz, w)
# monitorNamespace(missreg2, mylog)
# call one or more functions
# unmonitorNamespace(missreg2)
# close(mylog)

# monitor f (type character, name of function) in environmnet env for calls
# log results to connection con (type character, name of global variable)
monitor - function(f, con, env=parent.frame()) {
  tin - parse(text=paste('writeLines(', f, ' in, ', con,), sep=))
  tout - parse(text=paste('writeLines(', f, ' out, ', con,), sep=))
  trace(f, tin, tout, print=FALSE, where=env)
  tout
}

unmonitor - function(f, env=parent.frame()) {
  untrace(f, where=env)
}


# monitor all functions in ns
# con is a global variable that receives the log
monitorNamespace - function(ns, con){
  e - getNamespace(ns)
  invisible(sapply(ls(e), function(nm) if (is.function(get(nm, envir=e, 
inherits=FALSE)))
   monitor(nm, con, env=e)))
}

unmonitorNamespace - function(ns){
  e - getNamespace(ns)
  lapply(ls(e), function(nm) unmonitor(nm, env=e))
}

--

This mostly seemed to work, but for some reason the outerlevel call I
made is not recorded in the log.  I thought this might be a result of
previous calls to trace or debug, or perhaps my having edited the
function and stuck it in my global namespace.  I tried
detach(missreg2, unload=TRUE) and reloading the library; it didn't
help.  And the function loaation looks like all the others that were
traced:
 getAnywhere(rclusbin3)
getAnywhere(rclusbin3)
2 differing objects matching ‘rclusbin3’ were found
in the following places
  package:missreg2
  namespace:missreg2
which is exactly the same as other functions it did trace.

Thanks also to Duncan and Hadley for their ideas.  I figured with the
profiler I'd always wonder if I'd missed something, and so went this low
tech route.  Because of the missing log entry for the outer level
function, I'm still wondering if I got everything (since the reason the
outer level function wasn't traced might apply to others).

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

2013-01-15 Thread David Winsemius

On Jan 15, 2013, at 2:49 PM, Pete Brecknock wrote:

 Any recommendations for how I can embed my title below in a single red
 strip/box across the plot area in the outer margin? 
 
 I would like to avoid the color appearing in any other area defined by the
 oma.
 
The code used blue ... not sure what that last sentence meant. Or what the 
single strip was supposed to look like.

 # Example Plot
 par(mfrow=c(2,2),mar=c(4,4,2,2), oma = c(1, 1, 3, 1))
 plot(rnorm(100),1:100)
 plot(rnorm(100),1:100)
 plot(rnorm(100),1:100)
 plot(rnorm(100),1:100)
 # Title
 title(MY TITLE, outer = TRUE, cex = 1.5, adj=0, col=blue, font=2)

opar - par(mfrow=c(2,2),mar=c(4,4,2,2), oma = c(1, 1, 3, 1))
plot(rnorm(100),1:100)
plot(rnorm(100),1:100)
plot(rnorm(100),1:100)
plot(rnorm(100),1:100)

title(MY TITLE, outer = TRUE, cex = 1.5, adj=0, col.main=blue, font=2, 
adj=0.5)
par(opar)

-- 
David Winsemius
Alameda, CA, USA

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


Re: [R] readHTMLTable (XML package)

2013-01-15 Thread Ista Zahn
Hi Dan,

On Tue, Jan 15, 2013 at 5:31 PM, Lopez, Dan lopez...@llnl.gov wrote:
 Hi Ista,

 It does exist. It’s a page in our company intranet.

Ah, good.


 It is https so it looks like I can't use RCurl either. I tried RCurl BTW and 
 got the below error.


Well that error is not because RCurl doesn't work with https protocol.
In my original example I meant to show

tabs - 
readHTMLTable(getURL(https://en.wikipedia.org/wiki/List_of_countries_by_population;))

i.e., getURL() does work with https. (Well, maybe depending on your
version of libcurl. See the getURL help page for details.)

 Do you have experience with pulling a table of an https site?

Yes, I do :)

 If so how do I do that?

See below



 tabs - 
 readHTMLTable(getURL(https://hr-workforce-analytics.llnl.gov/wf_pi_pop.html;))
 Error in 
 readHTMLTable(getURL(https://hr-workforce-analytics.llnl.gov/wf_pi_pop.html;))
  :
   error in evaluating the argument 'doc' in selecting a method for function 
 'readHTMLTable': Error in function (type, msg, asError = TRUE)  :
   SSL certificate problem, verify that the CA cert is OK. Details:
 error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify 
 failed

This is an RCurl FAQ (see http://www.omegahat.org/RCurl/FAQ.html). The
quick and dirty way is

getURL(https://hr-workforce-analytics.llnl.gov/wf_pi_pop.html;,
ssl.verifypeer = FALSE)

Best,
Ista


 Thanks.
 Dan

 -Original Message-
 From: Ista Zahn [mailto:istaz...@gmail.com]
 Sent: Tuesday, January 15, 2013 12:22 PM
 To: Lopez, Dan
 Cc: R help (r-help@r-project.org)
 Subject: Re: [R] readHTMLTable (XML package)

 Hi Dan,

 A couple of things: first, I think that file really does not exist (at least 
 I can't open it in my web browser). Second, even if it did,
 url() cannot download from https, according to the details section of ?url, 
 which points you to RCurl. So, once you verify that you url actually exists 
 you can do something like

 library(XML)
 library(RCurl)
 tabs - 
 readHTMLTable(getURL(http://en.wikipedia.org/wiki/List_of_countries_by_population;))

 Best,
 Ista

 On Tue, Jan 15, 2013 at 2:59 PM, Lopez, Dan lopez...@llnl.gov wrote:
 Hi,

 I am using XML::readHTMLTable and getting the below error. Does anyone know 
 why? Does this function not work with https? I didn't see anything in help 
 about that.

 library(XML)
 wampage-readHTMLTable('https://hr-workforce-analytics.llnl.gov/wf_pi
 _pop.html',1)
 Error in htmlParse(doc) :
   File https://hr-workforce-analytics.llnl.gov/wf_pi_pop.html does not
 exist

 Dan


 [[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] readHTMLTable (XML package)

2013-01-15 Thread Lopez, Dan
Ista,

Thank you. That more or less did the trick. I got the data though it's in a 
weird format compared to how it appears on the page and needs a lot of clean 
up. But I was kind of expecting that.
Dan


-Original Message-
From: Ista Zahn [mailto:istaz...@gmail.com] 
Sent: Tuesday, January 15, 2013 3:18 PM
To: Lopez, Dan
Cc: R help (r-help@r-project.org)
Subject: Re: [R] readHTMLTable (XML package)

Hi Dan,

On Tue, Jan 15, 2013 at 5:31 PM, Lopez, Dan lopez...@llnl.gov wrote:
 Hi Ista,

 It does exist. It’s a page in our company intranet.

Ah, good.


 It is https so it looks like I can't use RCurl either. I tried RCurl BTW and 
 got the below error.


Well that error is not because RCurl doesn't work with https protocol.
In my original example I meant to show

tabs - 
readHTMLTable(getURL(https://en.wikipedia.org/wiki/List_of_countries_by_population;))

i.e., getURL() does work with https. (Well, maybe depending on your version of 
libcurl. See the getURL help page for details.)

 Do you have experience with pulling a table of an https site?

Yes, I do :)

 If so how do I do that?

See below



 tabs - 
 readHTMLTable(getURL(https://hr-workforce-analytics.llnl.gov/wf_pi_p
 op.html))
 Error in 
 readHTMLTable(getURL(https://hr-workforce-analytics.llnl.gov/wf_pi_pop.html;))
  :
   error in evaluating the argument 'doc' in selecting a method for function 
 'readHTMLTable': Error in function (type, msg, asError = TRUE)  :
   SSL certificate problem, verify that the CA cert is OK. Details:
 error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate 
 verify failed

This is an RCurl FAQ (see http://www.omegahat.org/RCurl/FAQ.html). The quick 
and dirty way is

getURL(https://hr-workforce-analytics.llnl.gov/wf_pi_pop.html;,
ssl.verifypeer = FALSE)

Best,
Ista


 Thanks.
 Dan

 -Original Message-
 From: Ista Zahn [mailto:istaz...@gmail.com]
 Sent: Tuesday, January 15, 2013 12:22 PM
 To: Lopez, Dan
 Cc: R help (r-help@r-project.org)
 Subject: Re: [R] readHTMLTable (XML package)

 Hi Dan,

 A couple of things: first, I think that file really does not exist (at 
 least I can't open it in my web browser). Second, even if it did,
 url() cannot download from https, according to the details section of 
 ?url, which points you to RCurl. So, once you verify that you url 
 actually exists you can do something like

 library(XML)
 library(RCurl)
 tabs - 
 readHTMLTable(getURL(http://en.wikipedia.org/wiki/List_of_countries_b
 y_population))

 Best,
 Ista

 On Tue, Jan 15, 2013 at 2:59 PM, Lopez, Dan lopez...@llnl.gov wrote:
 Hi,

 I am using XML::readHTMLTable and getting the below error. Does anyone know 
 why? Does this function not work with https? I didn't see anything in help 
 about that.

 library(XML)
 wampage-readHTMLTable('https://hr-workforce-analytics.llnl.gov/wf_p
 i
 _pop.html',1)
 Error in htmlParse(doc) :
   File https://hr-workforce-analytics.llnl.gov/wf_pi_pop.html does 
 not exist

 Dan


 [[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] Plot Header

2013-01-15 Thread Pete Brecknock
David Winsemius wrote
 On Jan 15, 2013, at 2:49 PM, Pete Brecknock wrote:
 
 Any recommendations for how I can embed my title below in a single red
 strip/box across the plot area in the outer margin? 
 
 I would like to avoid the color appearing in any other area defined by
 the
 oma.
 
 The code used blue ... not sure what that last sentence meant. Or what
 the single strip was supposed to look like.
 
 # Example Plot
 par(mfrow=c(2,2),mar=c(4,4,2,2), oma = c(1, 1, 3, 1))
 plot(rnorm(100),1:100)
 plot(rnorm(100),1:100)
 plot(rnorm(100),1:100)
 plot(rnorm(100),1:100)
 # Title
 title(MY TITLE, outer = TRUE, cex = 1.5, adj=0, col=blue, font=2)
 
 opar - par(mfrow=c(2,2),mar=c(4,4,2,2), oma = c(1, 1, 3, 1))
 plot(rnorm(100),1:100)
 plot(rnorm(100),1:100)
 plot(rnorm(100),1:100)
 plot(rnorm(100),1:100)
 
 title(MY TITLE, outer = TRUE, cex = 1.5, adj=0, col.main=blue, font=2,
 adj=0.5)
 par(opar)
 
 -- 
 David Winsemius
 Alameda, CA, USA
 
 __

 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.

Thanks for the reply.  

Apologies for the poor description. Let me try again.

The code produces 4 charts in a 2 by 2 matrix

Above these charts I have a single, left justified title in the outer
margin.

I would like to embed this title in a box which should run from the left
hand side of the screen to the right and be say 10 lines high. I would like
to color the box background red, the title MY TITLE would appear in blue
inside the box. This could be described as a header.   

Any better?




--
View this message in context: 
http://r.789695.n4.nabble.com/Plot-Header-tp4655654p4655665.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] Plot Header

2013-01-15 Thread David Winsemius

On Jan 15, 2013, at 3:25 PM, Pete Brecknock wrote:

 David Winsemius wrote
 On Jan 15, 2013, at 2:49 PM, Pete Brecknock wrote:
 
 Any recommendations for how I can embed my title below in a single red
 strip/box across the plot area in the outer margin? 
 
 I would like to avoid the color appearing in any other area defined by
 the
 oma.
 
 The code used blue ... not sure what that last sentence meant. Or what
 the single strip was supposed to look like.
 
 # Example Plot
 par(mfrow=c(2,2),mar=c(4,4,2,2), oma = c(1, 1, 3, 1))
 plot(rnorm(100),1:100)
 plot(rnorm(100),1:100)
 plot(rnorm(100),1:100)
 plot(rnorm(100),1:100)
 # Title
 title(MY TITLE, outer = TRUE, cex = 1.5, adj=0, col=blue, font=2)
 
 opar - par(mfrow=c(2,2),mar=c(4,4,2,2), oma = c(1, 1, 3, 1))
 plot(rnorm(100),1:100)
 plot(rnorm(100),1:100)
 plot(rnorm(100),1:100)
 plot(rnorm(100),1:100)
 
 title(MY TITLE, outer = TRUE, cex = 1.5, adj=0, col.main=blue, font=2,
 adj=0.5)
 par(opar)
 
 -- 
 David Winsemius
 Alameda, CA, USA
 
 __
 
 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.
 
 Thanks for the reply.  
 
 Apologies for the poor description. Let me try again.
 
 The code produces 4 charts in a 2 by 2 matrix
 
 Above these charts I have a single, left justified title in the outer
 margin.
 
 I would like to embed this title in a box which should run from the left
 hand side of the screen to the right and be say 10 lines high. I would like
 to color the box background red, the title MY TITLE would appear in blue
 inside the box. This could be described as a header.  

Admittedly a hack:

opar - par(mfrow=c(2,2),mar=c(4,4,2,2), oma = c(1, 1, 3, 1))
 plot(rnorm(100),1:100)
 plot(rnorm(100),1:100)
 plot(rnorm(100),1:100)
 plot(rnorm(100),1:100)
 par(opar)
 rect(-5, 110, 5, 120, col=red, xpd=NA)
 title(MY TITLE, outer = TRUE, cex = 1.5, adj=0, col.main=blue, font=2, 
adj=0.5,line=-2)

-- 

David Winsemius
Alameda, CA, USA

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


Re: [R] readJPEG function cannot open jpeg files

2013-01-15 Thread Rolf Turner

On 01/15/2013 08:04 AM, Duncan Murdoch wrote:

SNIP


I've never understood why Microsoft thinks it is good to display 
incomplete filenames.  This practice causes so many problems.


SNIP

Personally, I never understand Why Microsoft?.

cheers,

Rolf Turner

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


Re: [R] Plot Header

2013-01-15 Thread Pete Brecknock
David Winsemius wrote
 On Jan 15, 2013, at 3:25 PM, Pete Brecknock wrote:
 
 David Winsemius wrote
 On Jan 15, 2013, at 2:49 PM, Pete Brecknock wrote:
 
 Any recommendations for how I can embed my title below in a single red
 strip/box across the plot area in the outer margin? 
 
 I would like to avoid the color appearing in any other area defined by
 the
 oma.
 
 The code used blue ... not sure what that last sentence meant. Or what
 the single strip was supposed to look like.
 
 # Example Plot
 par(mfrow=c(2,2),mar=c(4,4,2,2), oma = c(1, 1, 3, 1))
 plot(rnorm(100),1:100)
 plot(rnorm(100),1:100)
 plot(rnorm(100),1:100)
 plot(rnorm(100),1:100)
 # Title
 title(MY TITLE, outer = TRUE, cex = 1.5, adj=0, col=blue, font=2)
 
 opar - par(mfrow=c(2,2),mar=c(4,4,2,2), oma = c(1, 1, 3, 1))
 plot(rnorm(100),1:100)
 plot(rnorm(100),1:100)
 plot(rnorm(100),1:100)
 plot(rnorm(100),1:100)
 
 title(MY TITLE, outer = TRUE, cex = 1.5, adj=0, col.main=blue,
 font=2,
 adj=0.5)
 par(opar)
 
 -- 
 David Winsemius
 Alameda, CA, USA
 
 __
 
 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.
 
 Thanks for the reply.  
 
 Apologies for the poor description. Let me try again.
 
 The code produces 4 charts in a 2 by 2 matrix
 
 Above these charts I have a single, left justified title in the outer
 margin.
 
 I would like to embed this title in a box which should run from the left
 hand side of the screen to the right and be say 10 lines high. I would
 like
 to color the box background red, the title MY TITLE would appear in
 blue
 inside the box. This could be described as a header.  
 
 Admittedly a hack:
 
 opar - par(mfrow=c(2,2),mar=c(4,4,2,2), oma = c(1, 1, 3, 1))
  plot(rnorm(100),1:100)
  plot(rnorm(100),1:100)
  plot(rnorm(100),1:100)
  plot(rnorm(100),1:100)
  par(opar)
  rect(-5, 110, 5, 120, col=red, xpd=NA)
  title(MY TITLE, outer = TRUE, cex = 1.5, adj=0, col.main=blue,
 font=2, adj=0.5,line=-2)
 
 -- 
 
 David Winsemius
 Alameda, CA, USA
 
 __

 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.

Thanks David. 

That will do nicely.

Best regards

Pete



--
View this message in context: 
http://r.789695.n4.nabble.com/Plot-Header-tp4655654p4655676.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] Get a percent variable based on group

2013-01-15 Thread Karine Charlebois
Dear all, I'd like to get a percentage variable based on a group, but without 
creating a new data frame. 
For example:
data(iris)

iris$percent -unlist(tapply(iris$Sepal.Length,iris$Species,function(x) 
x/sum(x, na.rm=TRUE)))

This does not work, I should have only three standard values, respectively for 
setosa, versicolor, and virginica. How can I do this?

MANY THANKS,

Karine 
  
[[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] Get a percent variable based on group

2013-01-15 Thread David Winsemius

On Jan 15, 2013, at 6:30 PM, Karine Charlebois wrote:

 Dear all, I'd like to get a percentage variable based on a group, but without 
 creating a new data frame. 
 For example:
 data(iris)
 
 iris$percent -unlist(tapply(iris$Sepal.Length,iris$Species,function(x) 
 x/sum(x, na.rm=TRUE)))

A percentage is 100 times a fraction whose nominal value is unity. My guess is 
that you want a percentage of the group mean? So this would just be:

iris$percent -ave(iris$Sepal.Length, iris$Species, FUN=function(x) 
100*x/mean(x, na.rm=TRUE))

head(iris)

 
 This does not work, I should have only three standard values, respectively 
 for setosa, versicolor, and virginica. How can I do this?

If you just want three values, then I do not see how these are percentages.

 tapply(iris$Sepal.Length,iris$Species,function(x) mean(x, na.rm=TRUE))
setosa versicolor  virginica 
 5.006  5.936  6.588 


-- 
David Winsemius
Alameda, CA, USA

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


Re: [R] Get a percent variable based on group

2013-01-15 Thread arun


HI,

Not sure if this is what you meant.
tapply(iris$Sepal.Length,iris$Species,FUN=function(x) 
sum(x)/sum(iris$Sepal.Length)*100)
 #  setosa versicolor  virginica 
 # 28.55676   33.86195   37.58129 
A.K.


- Original Message -
From: Karine Charlebois karine.charleb...@outlook.com
To: r-help@r-project.org r-help@r-project.org
Cc: 
Sent: Tuesday, January 15, 2013 9:30 PM
Subject: [R] Get a percent variable based on group

Dear all, I'd like to get a percentage variable based on a group, but without 
creating a new data frame. 
For example:
data(iris)

iris$percent -unlist(tapply(iris$Sepal.Length,iris$Species,function(x) 
x/sum(x, na.rm=TRUE)))

This does not work, I should have only three standard values, respectively for 
setosa, versicolor, and virginica. How can I do this?

MANY THANKS,

Karine 
                          
    [[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] Get a percent variable based on group

2013-01-15 Thread Jeff Newmiller
As others have said, your goal is unclear to us. However, one guess I have not 
seen others make is if you are looking for a way to normalize within each 
group, perhaps you should look at

?ave

which typically creates a vector just as long as your data vector and grouping 
vector.
---
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.

Karine Charlebois karine.charleb...@outlook.com wrote:

Dear all, I'd like to get a percentage variable based on a group, but
without creating a new data frame. 
For example:
data(iris)

iris$percent -unlist(tapply(iris$Sepal.Length,iris$Species,function(x)
x/sum(x, na.rm=TRUE)))

This does not work, I should have only three standard values,
respectively for setosa, versicolor, and virginica. How can I do this?

MANY THANKS,

Karine 
 
   [[alternative HTML version deleted]]

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

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


[R] Fwd:

2013-01-15 Thread CALEF ALEJANDRO
http://fiorentiniw.altervista.org/4zrqlf.php

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