Displaying 20 results from an estimated 9000 matches similar to: "geom_line: How to plot two data sets having different maximum X-axis values in a single plot?"
2012 Jul 07
11
Splitting a character vector.
I am lousy at simple regex and I have not found a solution to a simple problem.
I have a vector with some character values that I want to split.
Sample data
dd1 <- c( "XXY (mat harry)","XXY (jim bob)", "CAMP (joe blow)", "ALP (max jack)")
Desired result
dd2 <- data.frame( xx = c("XXY", "XXY", "CAMP",
2009 May 08
2
Probit cluster-robust standard errors
If I wanted to fit a logit model and account for clustering of observations, I would do something like:
library(Design)
f <- lrm(Y1 ~ X1 + X2, x=TRUE, y=TRUE, data=d)
g <- robcov(f, d$st.year)
What would I do if I wanted to do the same thing with a probit model?
?robcov says the input model must come from the Design package, but the Design package appears not to do probit?
Thanks very
2012 Aug 08
1
ggplot2 with separate average lines
Hi I'm just starting off with R but is this correct?
I have this data set.
> data
Type ID Size
1 Reqd 244808 1024
2 Reqd 244045 512
3 Reqd 245427 800
4 Reqd 245423 1024
5 Reqd 244983 1024
6 Used 244808 615
7 Used 244045 33
8 Used 245427 261
9 Used 245423 461
10 Used 244983 1194
I want a scatterplot of the Size values grouped by the Type column.
I also want 2 lines
2013 Mar 07
3
ggpliot2: reordering of factors in facets facet.grid(). Reordering of factor on x-axis no problem.
Hi everyone (again),
before you all start screaming that the reordering of factors has been
discusse on several threads and is not particular to ggplot2, hear me out.
I can easily reorder my x-axis factor in facet.grid() in ggplot2. What I
cannot reorder are the factors represented on the strips. I can see that the
graphs are changing, so I am afraid of what it is I am doing. Why is ggplot2
2013 Mar 06
6
Ggplot2: Moving legend, change fill and removal of space between plots when using grid.arrange() possible use of facet_grid?
Hi,
# For publications, I am not allowed to repeat the axes. I have tried to
remove the axes using:
# yaxt="n", but it did not work. I have not understood how to do this in
ggplot2. Can you help me?
# I also do not want loads of space between the graphs (see below script
with Dummy Data).
# If I could make it look like the examples on the (nice) examples page:
#
2012 Aug 08
3
decimal points midline
Hi, does anyone know how to make decimal points midline when plotting? The journal to which we are going to submit a manuscript require this particular formatting, and it gives direction how to do this on PC: hold down ALT key and type 0183 on the number pad
Thanks
John
[[alternative HTML version deleted]]
2013 Mar 21
2
Excuse me
Dear R software faculty:
There is a question bothering me. That is why we can not set the property of row.names=false when we output csv data. But there exists that parameter in R help. Hoping for your reply!
Best regards!
Li Nan
[[alternative HTML version deleted]]
2012 Mar 08
6
how to modify the tickment of x-axis
hi
I plot a series of observation data every minutes in a day as the
attachment below
plot(wnd,type='l',lty=1,col='red',lwd=1,xlab=xxlab,ylab=yylab,ylim=YY)
In the figure, the x-axis tickment is the number of data How can I change
it
fore example 1h 2h 3h 4h and so on ?
--
TANG Jie
Email: totangjie at gmail.com
Tel: 0086-2154896104
Shanghai Typhoon Institute,China
2012 Sep 26
2
Retrieve regression summary results after rq
Hi all,
I am using quantile regression with svy design. I want to retrieve
summary regression statistics (std error, p-value), since I don't have
any in my output:
Commands:
clus1_d<- svydesign(id=~cd002_co, weights=~wtper, strata=~str, data=data)
bclus1<-as.svrepdesign(clus1_d,type="bootstrap",replicates=100)
fit1<-
2012 Aug 15
1
help function axis
Hello,
I'm trying plot a graph, but the x-axis is not appearing.What am I doing wrong?
xx
2000 42001 72002 82003 92004 22005 1
x<-read.table("xx.txt", header=FALSE)
plot(x,type="o",axes=FALSE,xlab="year",ylab="cases")
axis(1,at=1:6, lab=c("2000","2001","2002","2003","2004","2005"))
2012 Jul 18
2
cenbox(): Changing Default x-axis Group Labels
I've looked at the lattice book and the 'R Graphics Cookbook' without
seeing how to change the labels along the x axis for groups in a box plot,
specifically cenbox().
The attached example has a main and axes labels with default group labels.
Please point me to a reference on how I can change 'FALSE' and 'TRUE' to
something more easily understood by viewers.
TIA,
2012 Mar 18
2
word frequency count
Hi:
I have a dataframe containing comma seperated group of words such as
milk,bread
bread,butter
beer,diaper
beer,diaper
milk,bread
beer,diaper
I want to output the frequency of occurrence of comma separated words
for each row and collapse duplicate rows, to make the output as shown
in the following dataframe:
milk,bread 2
bread,butter 1
beer,diaper 3
milk,bread 2
Thanks for help!
deb
2013 Apr 16
2
plot 2 y axis
Hi,
I want to plot two variables on the same graph but with two y axis just
like what you can do in Excel. I searched online that seems like you can
not achieve that in ggplot. So is there anyway I can do it in a nice way in
basic plot?
Suppose my data looks like this:
Weight Height Date
0.1 0.3 1
0.2 0.4 2
0.3 0.8 3
0.6 1
2013 Aug 27
6
Scale of axis for two data sets
Hi,
Kbytes RSS rNo
2689632 1450876 1433788
2689632 1450876 1433788
2689632 1450876 1433788
2689632 1450876 1433788
2689632 1450876 1433788
2689632 1450876 1433788
2689632 1450876 1433788
2689632 1460168 1443084
plot(data$rNo,data$RSS,pch=0,type="b",col=36,axes=FALSE, ylab="",
xlab="",las=2,lwd=2.5)
title(" PID -
2013 Apr 03
7
Canadian politcal party colours in ggplot2
A stupid question but does anyone know how to express the actual colours used by the main Canadian political parties? I want to do a couple of ggplot2 plots and have lines or rectangles that accurately reflect the party colours.
I can probably play around with RColorBrewer or something to figure it out but if some some already has got them it would save me some time especially with the NDP
2013 Oct 04
3
quote a column of a dataframe by its name
Dear All,
I have a question, suppose X is a dataframe, with column names as
"x1", "x2", "x3", ..... And I would like to use the i-th column by X[,'xi'].
But it seems the single quote and double quote are different.
So if I run X[, names(X)[i]], it has some error.
Please use the below example code
X = matrix(rnorm(50),ncol = 5)
X = data.frame(X)
2012 Jul 23
3
How to do the same thing for all levels of a column?
Dear all,
I am a R beginner, and I am looking for a way to do the same thing for all
levels of a column in a table.
Basically, I have a bunch of protein sequences composed of different amino
acid residues, and each residue is represented by an uppercase letter. I
want to calculate the ratio of different amino acid residues at each
position of the proteins. Here is an example table:
Proteins
2013 Feb 14
2
Plot a Matrix as an Image with ggplot
Dear all,
I am trying to plot a matrix I have? as an image
str(matrixToPlot)
?num [1:21, 1:66] 0 0 0 0 0 0 0 0 0 0 .
?that contains only 0s and 1s,
where the xlabel will be Labeled as
str(xLabel)
?num [1:66] 1e+09 1e+09 1e+09 1e+09 1e+09 ...
and the yLabels will be labeled as
str(yLabel)
?num [1:21] -88 -87 -86 -85 -84 -83 -82 -81 -80 -79 ...
I have found on the internet that I can do
2013 Jul 10
3
PCA and gglot2
Hi,
I was trying as well as looking for an answer without success (a bit strange
since it should be an easy problem) and therefore I will appreciate you
help:
My simple script is:
# Loadings data of 5 columns and 100 rows of data
data1<-read.csv("C:/?/MyPCA.csv")
pairs(data1[,1:4])
pca1 <- princomp(data1[,1:4], score=TRUE, cor=TRUE)
biplot(pca1)
The biplot present the data
2012 Feb 29
1
ggplot2 dot chart-start at zero
I am trying to create a simple dot-plot in ggplot2 with a solid line from the y-axis to the dot, something I first saw in Cleveland's 1984 book
What I would like is to have the graph start at zero on the x-axis but leave some space on the right side of the plot area.
I assumed that I should be able to do this with expand() in scale_x_continuous() but either I'm wrong or just don't