similar to: text matching and substitution

Displaying 20 results from an estimated 20000 matches similar to: "text matching and substitution"

2010 Apr 18
4
confused with yearmon, xts and maybe zoo
R-listers, I am using xts with a yearmon index, but am getting some inconsistent results with the date index when i drop observations (for example by using na.omit). The issue is illustrated in the example below. If I start with a monthly zooreg series starting in 2009, yearmon converts this to "Dec-2008". Not such a worry for my example, but strange. Having converted to xts, i drop
2008 Nov 04
2
ggplot & annotating charts
Dear "R-listers" I've been trying to figure out how to annotate charts in ggplot (ie add text to line charts, highlighted boxes etc). By and large, I can get close to what i want with base graphics, but would ideally like to use ggplot whenever possible (additionally, i would like to add text labels automatically to the chart). The code is below I suspect I need to use geom_rect,
2009 Aug 18
1
Plyr and memory allocation issue
Dear R users I am trying to create some new variables for a 4401 x 30 dataframe using ddply and transform. The "id" variable i am using is a factor with 1330 levles eg bb <- function(df) {transform(df, years = study.year - min(study.year) + 1, periods = length(study.year) )} test <- ddply(x,.(id),bb) I havent copied the data to avoid clogging the
2009 Jan 17
1
Downloading Excel file & reading a range
I am trying to figure out a way to download an Excel file and then read a range into R - so that i can have a reasonably automated process. I have been trying to use the RODBC package, but with little success. I suspect that this isnt the right route Here is some code. My aim is to read in the data starting in H69:H283 in sheet 2.
2010 Aug 17
3
predict.lm, matrix in formula and newdata
Dear all, I am stumped at what should be a painfully easy task: predicting from an lm object. A toy example would be this: XX <- matrix(runif(8),ncol=2) yy <- runif(4) model <- lm(yy~XX) XX.pred <- data.frame(matrix(runif(6),ncol=2)) colnames(XX.pred) <- c("XX1","XX2") predict(model,newdata=XX.pred) I would have expected the last line to give me the
2009 May 28
4
Read & name multiple excel sheets using RODBC
I'd like to be able to read multiple sheets from an excel workbook and use the sheet name to name the resulting dataframe using RODBC. at the moment i've figured out how to do it the long way (see below) but feel sure that there is a speedier & possibly automatic way to do it in R. i've tried to run a loop using sqlTables but it seemed to break the connection. unless i've
2008 Aug 08
8
RPro
I recently came across a flyer from REvolution Computing, and I wanted to ask if this is R going private? Tony. [[alternative HTML version deleted]]
2010 Jun 08
2
scatterplot function - double check: dashed lines
Hello everyone, This is just a quick double check. It concerns the 'scatterplot function' in R. I have 6 curves and I wish to represent each of them by a different kind of line (their colour must be black). The curves are derived from the cuminc function...the coordinates of which are in 'xx'. Upon reading the documentation in R, it looks like I can use the 'on/off'
2008 Jun 13
4
Sweave: looping over mixed R/LaTeX code
Dear guRus, I would like to loop over a medium amount of Sweave code, including both R and LaTeX chunks. Is there any way to do so? As an illustration, can I create a .tex file like this using a loop within a .Rnw file, where the "1,2,3" comes from some iteration variable in R? ################################################ \documentclass{article} \usepackage{Sweave} \begin{document}
2008 Dec 30
3
Componentwise means of a list of matrices?
Dear useRs, I have a list, each entry of which is a matrix of constant dimensions. Is there a good way (i.e., not using a for loop) to apply a mean to each matrix entry *across list entries*? Example: foo <- list(rbind(c(1,2,3),c(4,5,6)),rbind(c(7,8,9),c(10,11,12))) some.sort.of.apply(foo,FUN=mean) I'm looking for a componentwise mean across the two entries of foo, i.e., the
2009 Apr 04
2
axis colours
Hi, Is there a way to use par to change the colours of the axes lines (not the labels)? I've done this: par(bg = "black") plot(x, y, col = "yellow", pch = 16) but I have to use axes = F within the plot command, and then use axis (1, col = "yellow") axis (2, col = "yellow") and so on for axes 3 & 4. This does not help since the new axes are not
2008 Dec 28
1
Logistic regression with rcs() and inequality constraints?
Dear guRus, I am doing a logistic regression using restricted cubic splines via rcs(). However, the fitted probabilities should be nondecreasing with increasing predictor. Example: predictor <- seq(1,20) y <- c(rep(0,9),rep(1,10),0) model <- glm(y~rcs(predictor,n.knots=3),family="binomial") print(1/(1+exp(-predict(model)))) The last expression should be a nondecreasing
2010 Nov 02
1
Colour filling in panel.bwplot from lattice
Inspired by colouring the dots of box-whisker plots I am trying to also fill the boxes (rectangles) with different colours. This seems not to work as I expected. Looking at the help page of panel.bwplot it says: 'fill - color to fill the boxplot'. Obviously it is only intended to fill all boxes with only one colour? Nevertheless the following example shows, that 'fill' from
2011 Aug 25
1
question on silhouette colours
I'm fairly new to the silhouette functionality in the cluster package, so apologize if I'm asking something naive. If I run the 'agnes(ruspini)' example from the silhouette section of the cluster package vignette, and assign colours to clusters, two clusters have what appear to be incorrect colours in the silhouette plot. library(cluster) data(ruspini) ar<- agnes(ruspini)
2010 Nov 20
1
Setting a Red->Yellow->Green Color Transition in Image(...) with yellow corresponding with the Mean Value...
In the following example I would like to have the color transition from Red->yellow->green in the image(...) function, and if possible have the yellow be set to correspond with the mean value (for the below 75). ? I was able to figure something like out when using filled.contour(...), e.g. filled.contour(ak.fan, levels = c(70, 73, 76,?80, 90), color = terrain.colors) (I still
2010 Jan 13
3
Operating on each row of data frame
Hi All I have a data frame in which there are 4 columns . Column 1 : name Column 2-4 : values I would like to calculate mean/Standard error of values in column 2-4 and store them in column 5,6 respectively. I have done the following but doesn't seem to work mean_N_SE <-function(x) { name <- x[1] vals <- c(x[2:4]) temp_mean <- mean(vals) SE <- sqrt(var(x)/length(x)) }
2005 Mar 30
5
2d plotting and colours
Hi! I am new to R just 3 days in it and i apologize if my questions seem very trivial and consumed your valuable time. I am coding in perl and i stumbled upon R regarding plotting good statistical graphs. I tried the kmean clustering for a large matrix ,say > 150 * 150 . I tried the example code given in the tutorial to perform 2d plot # i ranges from 2 to 10 cl <- kmeans(x, i, 20)
2009 Jul 15
2
Substituting a user-defined function for a standard function in graphics
Dear R-help readers, I'm trying to substitute my own version of plot.default, in order to capture low-level graphics input for further manipulation. I seem to be having difficulties getting the versions of functions that I intend to use called at the right places. Specifically, I have an object produced by survfit from the survival package, and I want to save the values that
2008 Jul 14
2
Backslash in sub pattern?
Dear guRus, I am trying to replace "~" by "$\sim$" for TeX. However, I can't get the backslash to work. I would like to turn "DV~IV" into "DV$\sim$IV". sub("~","$\sim$","DV~IV") => "DV$sim$IV" sub("~","$\\sim$","DV~IV") => "DV$sim$IV"
2007 Aug 16
7
combining P values using Fisher's method
Hi All, Can somebody tell me how to use R to combine p values using Fisher's method? thanks. Jiong The email message (and any attachments) is for the sole use of the intended recipient(s) and may contain confidential information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and