[R] plot discrete time series against time

2013-07-20 Thread shanxiao
Dear all, I try to plot some discrete time series data through time, of course I can achieve it by using the combination of some basic R functions, but it is not that convenient, does anyone know any R-inbuilt function to do it? Best. Shan Xiao Ph.D. student of Biostatistics, Departmen

Re: [R] Linear regression repeat for each column

2013-07-20 Thread arun
Hi, set.seed(28) dat1<- as.data.frame(matrix(sample(1:20,100,replace=TRUE),ncol=10)) set.seed(49) dat2<- as.data.frame(matrix(sample(40:80,100,replace=TRUE),ncol=10))  lapply(seq_len(ncol(dat1)),function(i) {lm(dat2[,i]~dat1[,i])}) A.K. - Original Message - From: iza.ch1 To: r-help@r-pr

Re: [R] BH correction with p.adjust

2013-07-20 Thread David Winsemius
On Jul 20, 2013, at 10:37 AM, Scott Robinson wrote: > Dear List, > > I have been trying to use p.adjust() to do BH multiple test correction and > have gotten some unexpected results. I thought that the equation for this was: > > pBH = p*n/i Looking at the code for `p.adjust`, you see that the

Re: [R] Extract specific rows from a data frame

2013-07-20 Thread arun
Hi, May be this helps: df1<- read.table(text="   t1 t2 t3 t4   len1 AA AA PP AP   len2 FALSE AA PP MM   len3 PP AA AA AP   len4 PP AM MP PP   len5 AA FALSE AP PP   len6 PP AA AA AA ",sep="",header=TRUE,stringsAsFactors=FALSE) df1[df1[,1]=="PP" & (rowSums(df1[,-1]!="PP")==(ncol(df1)-1)),] # t1

Re: [R] Linear regression repeat for each column

2013-07-20 Thread Jeff Newmiller
Sure. Read the Posting Guide, and provide a reproducible example with sample data. I suspect the basic idea will be to merge the data frames and then setup the model to refer to the desired columns. --- Jeff Newmiller

[R] Extract specific rows from a data frame

2013-07-20 Thread Chirag Gupta
Hi I have a data frame as below t1 t1 t3 t4 len1 AA AA PP AP len2 FALSE AA PP MM len3 PP AA AA AP len4 PP AM MP PP len5 AA FALSE AP PP len6 PP AA AA AA I am having trouble extracting only those rows which have "PP" in the first column but AA or FALSE or all any other value but not PP in

[R] BH correction with p.adjust

2013-07-20 Thread Scott Robinson
Dear List, I have been trying to use p.adjust() to do BH multiple test correction and have gotten some unexpected results. I thought that the equation for this was: pBH = p*n/i where p is the original p value, n is the number of tests and i is the rank of the p value. However when I try and re

[R] Linear regression repeat for each column

2013-07-20 Thread iza.ch1
Hi everyone I need to calculate abnormal returns for different events applying event study methodology. I must create a market model in order to perform the analysis. I apply regression analysis to get OLS estimators. I have a problem to create a linear regression which I could repeat for each

Re: [R] Different x-axis scales using c() in latticeExtra

2013-07-20 Thread Felix Andrews
latticeExtra's c() can not combine logarithmic with linear x scales, I'm afraid. I would recommend displaying each separate plot on one page using plot.trellis() or the gridExtra function that John Kane mentioned. Cheers Felix On 21 July 2013 02:50, David Winsemius wrote: > > On Jul 19, 2013,

Re: [R] Error from running R2WinBUGS in R

2013-07-20 Thread Uwe Ligges
Several problems: 1. You havbe an object called "matrix", that actually is a list of two data.frames. WinBUGS does not know about data,frames. You have to provide a matrix here, hence bugs(., data=list(Y=as.matrix(Y), Nf=5, ), ) 2. In your model file, you have gamma[1:2 ] T[1:2

Re: [R] how to download Journal Citation Reports with R

2013-07-20 Thread Ben Bolker
Wet Bell Diver gmail.com> writes: > > R-3.0.1, Rstudio, Win7 x64 > > Dear list, > > I would like to download all the webpages of the Journal Citations > Report (science edition), for a given year. I can do so manually, but > that it very time intensive, so I would like to use R for that. >

Re: [R] Windows 7 (Swedish): 'Rcmd INSTALL' fails

2013-07-20 Thread Uwe Ligges
On 21.07.2013 00:26, Göran Broström wrote: I am trying to build a Windows zip file of a private package by C:/Program/R/R-3.0.1/bin/x64/Rcmd INSTALL --build --library=. epigen_0.1.tar.gz Why --library=. ? Do you have appropriate poermissions to do that? In this case, you need to start every

[R] Windows 7 (Swedish): 'Rcmd INSTALL' fails

2013-07-20 Thread Göran Broström
I am trying to build a Windows zip file of a private package by C:/Program/R/R-3.0.1/bin/x64/Rcmd INSTALL --build --library=. epigen_0.1.tar.gz but I get errors like 1: package 'datasets' in options("defaultPackages") was not found and, finally, Error in normalsizePath(path.expand(path), wi

Re: [R] Identify Leverage Points

2013-07-20 Thread Greg Snow
The help page for plot.lm includes mention of ‘lm.influence’, ‘cooks.distance’, and 'hatvalues’ in the "See Also", section. Do any of those accomplish what you want? On Fri, Jul 19, 2013 at 4:14 PM, Noah Silverman wrote: > Hello, > > I'm working on some fairly standard regression models (linea

[R] how to download Journal Citation Reports with R

2013-07-20 Thread Wet Bell Diver
R-3.0.1, Rstudio, Win7 x64 Dear list, I would like to download all the webpages of the Journal Citations Report (science edition), for a given year. I can do so manually, but that it very time intensive, so I would like to use R for that. I have tried many things, including: download.file(url

Re: [R] How to search for a sequence(and its combination) inside a vector?

2013-07-20 Thread John Kane
My best guess it that you have something like 1 123123 in there somewhere try: which(cc[,1] == 6) and have a look at line 137 Essentially your data does not look exactly like what you think it does. John Kane Kingston ON Canada > -Original Message- > From: tmrs...@gmail.com > Sent:

Re: [R] How to search for a sequence(and its combination) inside a vector?

2013-07-20 Thread C W
Hi, John I am doing sparsity recovery from glmnet. Elements 1, 2, 3 of the repeating sequence are the nonzero elements. But it's not always recovered. How my original data frame looks like > df[1:15, ] i x 2 1 0.0869399788 3 2 -0.0994713934 4 3 0.0720312837 5 4 0.007539

Re: [R] How to search for a sequence(and its combination) inside a vector?

2013-07-20 Thread C W
Thanks, you guys are correct, I had different data. But why I get length 5 and 6, should only be 1 to 3. Full R code : vec <- c(1, 2, 3, 4, 5, 6, 7, 8, 13, 1, 2, 3, 5, 7, 8, 10, 12, 13, 14, 15, 1, 2, 3, 5, 6, 10, 12, 13, 1, 2, 3, 4, 5, 6, 7, 12, 13, 14, 15, 1, 2, 3, 6, 9, 10, 11, 13, 14, 1, 7, 10

Re: [R] Identify Leverage Points

2013-07-20 Thread Noah Silverman
I'll look at that today. Thank You, -- Noah Silverman, C.Phil UCLA Department of Statistics 8117 Math Sciences Building Los Angeles, CA 90095 On Jul 19, 2013, at 4:13 PM, Mark Leeds wrote: > see the hatvalues function in the car package. also, I highly recommend john's > CAR book. there's a

Re: [R] How to search for a sequence(and its combination) inside a vector?

2013-07-20 Thread John Kane
Beats me. I get: table(dd) val leng TRUE 13 3 12 What does dd look like. In my case I get this where the first column is the row number dd leng val 1 3 TRUE 3 3 TRUE 5 3 TRUE 7 3 TRUE 9 3 TRUE 111 TRUE 133 TRUE 153 TRUE 173 TRUE 193 TR

Re: [R] How to search for a sequence(and its combination) inside a vector?

2013-07-20 Thread Berend Hasselman
On 20-07-2013, at 19:11, C W wrote: > Thanks John. > > Why do I get length of 5 and 6? I thought I am only tallying up 1 to 3? >> table(dd) >val > leng TRUE > 15 > 24 > 3 81 > 51 > 64 I wouldn't know. Not same data? It's completely unclear, to me at least, what

Re: [R] How to search for a sequence(and its combination) inside a vector?

2013-07-20 Thread C W
Thanks John. Why do I get length of 5 and 6? I thought I am only tallying up 1 to 3? > table(dd) val leng TRUE 15 24 3 81 51 64 -M On Sat, Jul 20, 2013 at 12:52 PM, John Kane wrote: > Taking Berend's example a bit further, this seems to work > > If you use

Re: [R] read data from a URL with login required

2013-07-20 Thread Prof Brian Ripley
On 20/07/2013 16:43, Hui Du wrote: Hi All, How to read a URL requiring log in info in R? For example, I want to download some info from Linkedin pages, my username is abc, password is 123. How can I download my desired URL page in R? It really depends what 'login' means. For some sites this

Re: [R] How to search for a sequence(and its combination) inside a vector?

2013-07-20 Thread John Kane
Taking Berend's example a bit further, this seems to work If you use str(b) you will see it is a list b <- rle(a) cc <- data.frame(b[[1]], b[[2]]) names(cc) <- c("leng", 'val') dd <- subset(cc, val ==TRUE ) table(dd) John Kane Kingston ON Canada > -Original Message- > From: tmrs.

Re: [R] Different x-axis scales using c() in latticeExtra

2013-07-20 Thread David Winsemius
On Jul 19, 2013, at 8:18 PM, Jeff Stevens wrote: > Hi, > > I would like to combine multiple xyplots into a single, multipanel > display. Using R 3.0.1 in Ubuntu, I have used c() from latticeExtra > to combine three plots, but the x-axis for two plots are on a log > scale and the other is on a n

Re: [R] How to search for a sequence(and its combination) inside a vector?

2013-07-20 Thread C W
Hi Berend I am looking for a table, # of times one element (out of 1, 2, 3) showed up, two elements, and all three. I am trying, don't know if this works: > aa <- rle(a) > b <- aa$lengths[aa$values] > table(b) b 1 3 3 12 Mike On Sat, Jul 20, 2013 at 12:24 PM, Berend Hasselman wrote: > > O

Re: [R] Different x-axis scales using c() in latticeExtra

2013-07-20 Thread John Kane
No idea what I happening but does this give what you expect library(gridExtra) preds <- grid.arrange(pred1_plot,pred2_plot, pred3_plot, ncol=3) preds John Kane Kingston ON Canada > -Original Message- > From: stev0...@gmail.com > Sent: Fri, 19 Jul 2013 22:18:47 -0500 > To: r-help@r-pro

Re: [R] How to search for a sequence(and its combination) inside a vector?

2013-07-20 Thread Berend Hasselman
On 20-07-2013, at 18:05, C W wrote: > Hi R list, > > I have a sequence repeating 1:15 . Some numbers are deleted. I want > to find how many times 1, 2, 3 appeared. > Basically, I want to "grab" the beginning of the sequence and tally it up. > > R code: > >> vec <- c(1, 2, 3, 4, 5, 6, 7, 8,

[R] problem with minus signs when using postscript/pdf functions with ComputerModernItalic family

2013-07-20 Thread dbp
When I use the postscript with the ComputerModernItalic family, minus signs are not properly displayed, but are changed into capital gammas. The attached test-postscript.pdf file illustrates the problem, which I created starting with the following R code: > postscript("test-postscript.eps", f

[R] How to search for a sequence(and its combination) inside a vector?

2013-07-20 Thread C W
Hi R list, I have a sequence repeating 1:15 . Some numbers are deleted. I want to find how many times 1, 2, 3 appeared. Basically, I want to "grab" the beginning of the sequence and tally it up. R code: > vec <- c(1, 2, 3, 4, 5, 6, 7, 8, 13, 1, 2, 3, 5, 7, 8, 10, 12, 13, 14, 15, 1, 2, 3, 5, 6,

[R] read data from a URL with login required

2013-07-20 Thread Hui Du
Hi All, How to read a URL requiring log in info in R? For example, I want to download some info from Linkedin pages, my username is abc, password is 123. How can I download my desired URL page in R? Many thanks. HXD [[alternative HTML version deleted]] ___

Re: [R] S4 method signature - integer matrix

2013-07-20 Thread Simon Zehnder
Hi David, thanks for the reply! The prototype solution is I think not the appropriate solution, when the method adds the integer matrix next to the class object into the argument list. Also the .validObject method can only be applied to the object for which the method is called or I have to w

Re: [R] cut into groups of equal nr of elements...

2013-07-20 Thread Wet Bell Diver
Witold, Here's one way: Vec <- rnorm(30) Vec.cut <- cut(Vec, breaks=c(quantile(Vec, probs = seq(0, 1, by = 0.20))), labels=c("0-20","20-40","40-60","60-80","80-100"), include.lowest=TRUE) table(Vec.cut) or determine the breaks automatically: cut.size <- function(x, size) { cut.prob <

[R] RE : how to calculate the average values of each row in a matrix

2013-07-20 Thread Guibert TCHINDE
> vec = matrix(data=round(rnorm(15,1,2)),ncol=3) > vec [,1] [,2] [,3] [1,]11 -1 [2,]62 -1 [3,]002 [4,]0 -3 -2 [5,]112 > rowMeans(vec) [1] 0.333 2.333 0.667 -1.667 1.333 > apply(vec,1,mean) [1] 0.333 2.333 0.

Re: [R] Adding across columns ignoring NA

2013-07-20 Thread arun
HI,  sum(var1,var2,var3,var4,var5,na.rm=TRUE) #[1] 8 A.K. - Original Message - From: Jin Choi To: "r-help@r-project.org" Cc: Sent: Saturday, July 20, 2013 12:37 AM Subject: [R] Adding across columns ignoring NA I am having difficulty finding a solution to devising an R code to do th