I'm wondering how I can manipulate the size of strip text in facetted plots. My question
is similar to a question on plot titles, but I'm specifically concerned with
manipulating not the plot title but the text that appears in facet titles (strip_h).
As an example, consider the mpg dataset.
library(ggplot2)
qplot(hwy, cty, dat...
I'm trying to produce a single variable which is a concatenation of two chars e.g to go from "p30s4" "p28s4" to "p30s4 p28s4". I've tried cat and paste as shown below. Both return empty variables. What am I doing wrong?
> blah = c("p30s4","p28s4")
> blah
[1] "p30s4" "p28s4"
> foo = cat(blah)
p30s4 p28s4
> foo
NULL
> foo = paste(c...
Hello,
I am looking for something like the 'msm' package, but for discrete Markov chains. For example, if I had a transition matrix defined as such
Pi <- matrix(c(1/3,1/3,1/3,
0,2/3,1/6,
2/3,0,1/2))
for states A,B,C. How can I simulate a Markov chain according to that transition matrix?
Thanks,
...
The x-axis is time broken up into time intervals. There is an interval column in the data frame that specifies the time for each row. The column is a factor, where each interval is a different factor level.
Plotting a histogram or line using geom_histogram and geom_freqpoly works great, but I'd like to have a line, like that provided ...
Hello,
My apologies if this is more of a statistics question than an R question. I am trying to estimate the following model in R.
y_t = mu0 (1 - S_t) + mu1 S_t + e_t e_t ~ N(0, sigma_t^2)
sigma_t^2 = sigma_0^2 (1 - S_t) + sigma_1^2 S_t
where mu_t = mu0 if S_t = 0, mu_t = mu1 if S_t = 1, and S_t is a Markov process, either 0 or 1, ...
Say I make a scatterplot with thousands of points:
ggplot(head(data, n=2000), aes(length, coverage))+
geom_point(alpha = 0.5, color = 'navyblue') + coord_trans(x='log', y='log')
I want to add the labels of "the 20 or so most extreme points" (in the upper right and bottom right corners). They are easy to identify visually. But ...
Can someone explain why levels() shows three factor levels, while you can see that the vector has only two?
> str(walk.df)
'data.frame': 10 obs. of 4 variables:
$ walker : Factor w/ 3 levels "1","2","3": 1 1 1 1 1 2 2 2 2 2
> walk.df$walker
[1] 1 1 1 1 1 2 2 2 2 2
Levels: 1 2 3
I would like to extract a vector of levels, and I t...
Is it possible to use the R package 'RGL' in x64 Windows?
RGL Website
...
I'd like to export plotting symbols form R as a png graphic. But I haven't found a perfect way yet.
Using
png("symbol.png",width=20, height=20, bg="transparent")
par(mar=c(0,0,0,0))
plot.new()
symbols(1, 1, circles=0.3, bg=2, inches=FALSE, lwd=2, bty="n")
dev.off()
creates a little border around the symbol (I'd like it to be transpa...
hi there
I have a big dataframe with columns such as:
ID, time, OS, IP
Each row of that dataframe corresponds to one entry. Within that dataframe for some IDs serveral entries (rows) exist.
I would like to get rid of those multiple rows (obviously the other attributes will differ for the same ID). Or put different: I only want one single...
R: What are the pros and cons of using Lattice versus ggplot2?
...
I am working with a large list of points (each point has three dimensions x,y,z).
I am pretty new with R, so I would like to know what is the best way to represent that kind of information. As far as I know, an array allows me to represent any multidimensional data, so currently I am using:
> points<-array( c(1,2,0,1,3,0,2,4,0,2,5,0,2...
Hi all,
I have 40 subjects, of two groups, over 15 weeks, with some measured variable (Y).
I wish to have a plot where: x = time, y = T, lines are by subjects and colours by groups.
I found it can be done like this:
TIME <- paste("week",5:20)
ID <- 1:40
GROUP <- sample(c("a","b"),length(ID), replace = T)
group.id <- data.frame(GROUP,...
I've been using ggplot2 for a while now, and I can't find a way to get formula from ggplot object. Though I can get basic info with summary(<ggplot_object>), in order to get complete formula, usually I was combing up and down through .Rhistory file. And this becomes frustrating when you experiment with new graphs, especially when code ge...
I recently posted this question on the r-help mailing list but got no answers, so I thought I would post it here as well and see if there were any suggestions.
I am trying to calculate the cumulative standard deviation of a matrix. I want a function that accepts a matrix and returns a matrix of the same size where output cell (i,j) is s...
I'm trying to replace elements of a data.frame containing "#N/A" with "NULL", and I'm running into problems:
foo <- data.frame("day"= c(1, 3, 5, 7), "od" = c(0.1, "#N/A", 0.4, 0.8))
indices_of_NAs <- which(foo == "#N/A")
replace(foo, indices_of_NAs, "NULL")
Error in [<-.data.frame(*tmp*, list, value = "NULL") :
new columns woul...
I am playing with the "stars" ({graphics}) function to create a segment of flowers.
I wish to plot a flower of segments, for example in way the following command will produce:
stars1(mtcars[, 1:7],
draw.segments = T,
main = "Motor Trend Cars : stars(*, full = F)", full = T, col.radius = 1:8)
But, I want the segments to not ...
I'm trying to compare two numbers in R as a part of a if-statement condition:
(a-b) >= 0.5
In this particular instance, a = 0.58 and b = 0.08... and yet (a-b) >= 0.5 is false. I'm aware of the dangers of using == for exact number comparisons, and this seems related:
(a - b) == 0.5) is false, while
all.equal((a - b), 0.5) is true.
...
I'm struggling with how to best structure categorical data that's messy, and comes from a dataset I'll need to clean.
The Coding Scheme
I'm analyzing data from a university science course exam. We're looking at patterns in
student responses, and we developed a coding scheme to represent the kinds of things
students are doing in their ...
I have 4 reasonably complex r scripts that are used to manipulate csv and xml files. These were created by another department where they work exclusively in r.
My understanding is that while r is very fast when dealing with data, it's not really optimised for file manipulation. Can I expect to get significant speed increases by conv...