Is there an easy way to convert character strings with comma-separated
numbers and ranges to a numeric vector?
x- 2,5-7,10,12-15
[1] 2 5 6 7 10 12 13 14 15
Thanks,
Chris
--
Chris Stubben
Los Alamos National Lab
Bioscience Division
MS M888
Los Alamos, NM 87545
113 3.77 1.513 16.90 1 152
#OR?
xpathSApply(doc, //record[@id='Lotus Europa'])
getNodeSet(doc, //record[@id='Lotus Europa'])
# And to list all Ids...
xpathSApply(doc, //record, xmlGetAttr, id)
[1] Mazda RX4 Mazda RX4 Wag Datsun 710 .
--
Chris Stubben
Los
pcaA Rv0470cMycolic acid
synthase (cyclopropane synthase)
4 Mycolic acid synthesis pcaA Rv0470cMycolic acid
synthase (cyclopropane synthase)
--
Chris Stubben
Los Alamos National Lab
Bioscience Division
MS M888
Los Alamos, NM 87545
I want to merge dat1 and dat2 based on ID in order
Have you tried merge(dat1, dat2) ?
If ID is the common column (and no others), then that should be all you
need to join (see ?merge). And then order if needed.
Chris
--
Chris Stubben
Los Alamos National Lab
Bioscience Division
MS M888
=TRUE))
Chris
--
Chris Stubben
Los Alamos National Lab
Bioscience Division
MS M888
Los Alamos, NM 87545
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R
in raw
datasets
are pretty important, especially if observations are split into different files and
you are trying to join them later. How do you know for ID 0001 and obs 1 that height
is 3.2 and not 2.6, especially if order in the two files are not exactly the same.
Chris
--
Chris Stubben
.
t1 - readHTMLTable(
http://www.ncbi.nlm.nih.gov/pmc/articles/PMC3544749/table/T1;, which=1)
Thanks,
Chris
t1-readHTMLTable(
http://www.ncbi.nlm.nih.gov/pmc/articles/PMC3544749/table/T1;, which=1)
--
Chris Stubben
Los Alamos National Lab
Bioscience Division
MS M888
Los Alamos, NM
Sorry if I was not clear. I wanted to remove the superscripts using xpath
queries if possible. For example this will get p nodes with superscripts,
but how do I remove the superscripts if there are many matching nodes and
different superscripts?
xpathSApply(doc, //p[sup], xmlValue)
[1] Cata
8 642 1
33016 8874.441
9 71 1 7 939 1
12808 6911.880
10 71 2 6 1035 1
23233 6911.880
Chris Stubben
Daniel Nordlund-4
To keep the table dimensions the same, try changing the columns to factors...
boxes$y97-factor(boxes$y97, 1:4)
boxes$y98-factor(boxes$y98, 1:4)
boxes$y99-factor(boxes$y99, 1:4)
...
table(boxes$y98, boxes$y97)
1 2 3 4
1 1 0 1 0
2 0 0 0 0
3 0 0 0 0
4 1 0 0 1
table(boxes$y99,
Just increase the margins on the left side and add the rownames
x - cor(matrix(rnorm(600), 60, 100))
rownames(x)-paste(row, 1:100)
op-par(mar=c(1,5,1,1), xpd=TRUE)
image(t(x[nrow(x):1,]), axes=FALSE)
text(-0.01, seq(0,1,length=nrow(x) ), rownames(x), pos = 2, offset = 0,
cex = .7)
Another
degree counter clockwise rotation
image(t(x[nrow(x):1,]), axes=FALSE)
## add 100 column names
y-paste(column, 1:100)
text( seq(0,1,length=100) , 1.01, y, pos = 2, srt = 270, offset=0, cex=.7)
Chris Stubben
Lara Poplarski wrote:
I have a large (1600*1600) matrix generated with symnum, that I
Gene names often have single quotes like
5'-methylthioadenosine phosphorylase
ATP synthase B' chain
ppGpp 3'-pyrophosphohydrolase
so maybe try adding quote= to the read table options.
Chris Stubben
--
View this message in context:
http://r.789695.n4.nabble.com/R-eat-my-data
Thanks for any help,
Chris Stubben
--
View this message in context:
http://n4.nabble.com/Using-substitute-in-a-print-method-tp1606635p1606635.html
Sent from the R help mailing list archive at Nabble.com.
__
R-help@r-project.org mailing list
https
Shawn Morrison-2 wrote:
# The paper reports a 95% CI of 0.79 - 1.10
# My reproduced result for the CIs is much larger, especially on the
upper end. Why would this be?
# The authors report using the 'delta' method (Caswell, 2001) to
calculate the CI in which the
Shawn,
I probably
Mark W. Miller wrote:
I have a list of scientific names in a data set. I would like to split
the names into genus, species and subspecies. Not all names include a
subspecies. Could someone show me how to do this?
strsplit should work for your example...
data.frame(
,]0 0. 0. 0. 96.92715 0.00.0
108.6551
[6,]0 0. 0. 0. 0.0 69.875270.0
0.
[7,]0 0. 0. 0. 0.0 0.0 65.86229
0.
Chris Stubben
--
View this message in context:
http
)
y1-y[z,]
n2[i,] -prop.table( table(y1[,2], y1[,1]), 2) %*% n
}
# the CIs are much wider here
apply(n2, 2, quantile, c(0.025,0.975))
[,1] [,2] [,3]
2.5% 55.89959 132.6868 361.2091
97.5% 85.11097 169.3798 399.7032
Chris Stubben
--
View this message in context:
http
(longch) # not truncated
Thanks,
Chris Stubben
--
View this message in context:
http://www.nabble.com/Long-character-not-truncated-by-str%28%29-after-adding-comment-tp24611767p24611767.html
Sent from the R help mailing list archive at Nabble.com.
__
R
, then maybe combine the code above into
a function and then apply it to your list using lapply.
Chris Stubben
--
View this message in context:
http://www.nabble.com/sampling-quadrats-of-increasing-size-in-a-list-of-matrices-tp24270434p24276950.html
Sent from the R help mailing list archive
dimensions)
mat - matrix(unlist(x), n * p, length(x))
mm - matrix(rowMeans(mat, ...), n, p)
dimnames(mm) - dimnames(x[[1]])
mm
}
Chris Stubben
--
View this message in context:
http://www.nabble.com/how-to-calculate-means-of-matrix-elements-tp23607694p23609472.html
Sent from the R help
21 29
AT 2 6 10 14
TA 3 7 11 15
Chris Stubben
jholtman wrote:
Try this:
key - rownames(a)
key[key == AT] - TA
do.call(rbind, by(a, key, colSums))
V2 V3 V4 V5
AA 1 5 9 13
TA 5 13 21 29
TT 4 8 12 16
On Mon, May 11, 2009 at 4:53 PM, Crosby, Jacy R
jacy.r.cro
-- Chc -- -- --
6 42 42 35 14 W 100 35 100 -- Chc -- -- --
# plot
plot(z[Temp])
Chris Stubben
--
View this message in context:
http://www.nabble.com/Download-daily-weather-data-tp22233373p22252517.html
Sent from the R help mailing list archive
, if the user has
permission to save to that directory, and probably some other complications
I'm missing. Any suggestions?
Thanks,
Chris Stubben
--
View this message in context:
http://www.nabble.com/how-to-save-an-updated-dataset-tp17782584p17782584.html
Sent from the R help mailing list archive
Greg,
If you have a MySQL table with an auto_increment field, you could just
insert a NULL value into that column and the database will increment the key
(it may not work in SQL STRICT mode, I'm not sure). I don't think there's
any way to specify which columns you want to load data into using
Michelle,
I would probably run a loop as well and save all matrices to a single list
(see hudsonia and calathea on working with lists of matrices).
First, run the example(test.census) to get the stage-fate data frame trans
and then run this code to save the matrices into a list all.
-Halcyon- wrote:
My question is : How do I arbitrarily assign the animals being FALSE
***according to the uniformal chance generation*** to the array
Dead.Animals, there being TRUE?
Maybe I'm missing something, but aren't dead animals just the ones that
aren't alive? Why do you even
privalan wrote:
However, I cannot figure out the way to compute the asymptotic stochastic
population growth rate using “popbio”. I would like to perform a
stochastic model in which my demographic rates are sampled from beta
distribution with known mean and SD. For example, rather than 0.50
Also try the odiag function in the demogR package
odiag( 1:5, -1)
[,1] [,2] [,3] [,4] [,5] [,6]
[1,]000000
[2,]100000
[3,]020000
[4,]003000
[5,]000400
[6,]000
You could use a combination of rle, cumsum and append.
x - c(1,1,1,2,2,3,3,3,3,3,4)
y-rle(x)$lengths
y
[1] 3 2 5 1
z-cumsum(y)[y1]
z
[1] 3 5 10
for(i in rev(z)) x - append(x, c(0,0,0), after = i)
x
[1] 1 1 1 0 0 0 2 2 0 0 0 3 3 3 3 3 0 0 0 4
Chris
Serguei Kaniovski-3 wrote:
Sorry, I wasn't sure what you meant. This way will return more than one
answer, right?
N-c(1,2,1,3)
R-c(1.75,3.5,1.75,1.3125)
## get all 126 combinations of five 0's and four 1's for matrix
cbn-as.matrix(expand.grid( rep( list(0:1), 9)))
cbn- cbn[rowSums(cbn)==4,]
ans-list()
ctr-0
## loop
that I
missed in the documentation/help.
Chris
--
---
Chris Stubben
Los Alamos National Lab
BioScience Division
MS M888
Los Alamos, NM 87545
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read
Maybe something like this?
N-c(1,2,1,3)
## create empty matrix
x-diag(0,3)
## fill off diagonal
x[row(x)==col(x)+1]-N[1:2]
# fill 3rd column
x[1:2,3]-N[3:4]
Or create a function and return both x and y
mat3-function(N)
{
x-diag(0,3)
# fill each element separately
x[2,1]-N[1]
x[3,2]-N[2]
Sorry, I didn't think carefully about your question on my first reply, so
please ignore it.
Chapter 9 in Morris and Doak (2002) cover vital rate elasticities and
sensitivities (see Box 9.1 for Matlab code
http://www.sinauer.com/PVA/vitalsens.m). Simon, thanks for posting your
code, I will
I would like to calculate elasticities and sensitivities of each parameters
involved in the following transition matrix:
A - matrix(c(
sigma*s0*f1, sigma*s0*f2,
s, v
), nrow=2, byrow=TRUE,dimnames=list(stage,stage))
The command eigen.analysis avaliable in
On 10/12/07, Ben Bolker bolker at ufl.edu wrote:
Trying to find a quick/slick/easily interpretable way to
collapse a data set.
Another alternative for SQL fans is the sqldf package. I used the MySQL driver
here since SQLite does not support standard deviation.
sqldf(select BROOD,
Adam Wilson-4 wrote:
I am running R 2.5.1, RMySQL 0.6 , and DBI 0.2-3 on Windows XP
Like others, I am having trouble with NA/Null value conversions between R
and a MySQL database via DBI, but I could not find my exact problem in the
archives. Most of the time NA values in R get
Transition matrices are Markov transition matrices among different
life stages of organisms -- in the simplest case (Leslie matrices,
Ben,
Thanks for your clear explanation and plot examples. I like the dotplots alot
and added a few modifications below. Since I often compare rows and
]
A-matrix(c(
0.21, 0.21,0.03,
0.55, 0.58, 0.09,
1.30, 1.35, 0.22), nrow=3, byrow=TRUE, dimnames=list(stages,stages) )
## I can get a surface plot, but that's about it.
persp3d(A, col=red, alpha=0.7,
xlab=fate, ylab=stage, zlab=Sensitivity, box=FALSE)
Thanks,
Chris Stubben
hadley wickham h.wickham at gmail.com writes:
Why do you want a 3d barchart? They are generally a bad way to
present information as tall bars can obscure short bars, and it is
hard to accurately read off the height of a bar. While adding
rotation can reduce some of these problems, why not
Duncan Murdoch murdoch at stats.uwo.ca writes:
That demo gives you the basics of the code, so it shouldn't be too hard
to put your own together: just strip out the counting part.
Thanks, I did download the source to check the hist3d demo, but honestly it
didn't look very easy to
41 matches
Mail list logo