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 Ala
Europa']", xmlValue)
[1] "30.4 4 95.1 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, &qu
Methoxy mycolic acid synthase 4
3 Mycolic acid synthesis pcaA Rv0470cMycolic acid
synthase (cyclopropane synthase)
4 Mycolic acid synthesis pcaA Rv0470cMycolic acid
synthase (cyclopropane synthase)
--
Chris Stubben
Los Alamos National Lab
Bioscience Divis
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
--
Chr
mple(L3, 10, replace=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 h
> 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
Bioscienc
w.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 87545
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"
ct above, but I'd
rather just work with the results from htmlParse if possible (and not use
readLines to load raw HTML first).
Thanks,
Chris Stubben
--
View this message in context:
http://r.789695.n4.nabble.com/Remove-superscripts-from-HTML-objects-tp4550738p4550738
1
12700 8874.441
7 61 2 9 940 1
22883 8874.441
8 61 2 8 642 1
33016 8874.441
9 71 1 7 9 39 1
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
the 90 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) mat
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
"
## This prints what I'd want, but I'm not sure why its different.
print.diag(d)
[1] "A diagonal matrix d"
Thanks for any help,
Chris Stubben
--
View this message in context:
http://n4.nabble.com/Using-substitute-in-a-print-method-tp1606635p1606635.html
Sent fro
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 p
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(
genus=sappl
0. 147.8957 0.0 0.0 136.36804
220.7370
[5,]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.0000 0.0 0.0 65.86229
0.
Chris St
atrix(numeric(1000*3), ncol=3)
for(i in 1:1000)
{
z <- sample(nrow(y), replace = TRUE)
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.
longch)<-"100 ABCs"
str(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 mai
q[i]+1) with sample( 1:(n-q[i]+1),
replace=TRUE) ?
Also, if you have a list of matrices, 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-s
f (!all(n == dims[1, ]) || !all(p == dims[2, ]))
stop("the matrices must have the same 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 messa
- function(x) chartr("ACGT", "TGCA", x)
n<-cbind(key, rev=reverse(comp(key)))
n<-t(apply(n,1, sort))
do.call(rbind, by(a, n[,1], colSums))
V1 V2 V3 V4
AA 5 13 21 29
AT 2 6 10 14
TA 3 7 11 15
Chris Stubben
jholtman wrote:
>
> Try this:
>
>&
99 40 77 -- Chc -- -- --
3 50 43 44 17 SW99 40 77 -- Chc -- -- --
4 48 43 42 16 SW99 40 83 -- Chc -- -- --
5 45 43 38 15WSW 100 40 93 -- Chc -- -- --
6 42 42 35 14 W
y is located, 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 hel
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
db
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".
years<-
-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
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
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)[y>1]
> 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
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
## lo
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
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 add
> 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" a
> On 10/12/07, Ben Bolker 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 tra
>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 col
Duncan Murdoch 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 simplify. I sw
hadley wickham 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 create
2[j],
y2[j+1]), border=0, col = rev(heat.colors(100))[j])
}
}
Chris Stubben
Van Dongen Stefan wrote:
>
> Hi All,
>
> I would like to fill the area under a curve with a gradient of colors. Are
> there any packages or trick I could use
>
> Thanks
>
> Stefan
&g
41 matches
Mail list logo