Hi Ernie,
I'll use the built in mtcars dataset for demonstrative purposes.
You have some condition, which can be used to create an index
## show data frame
mtcars
## create index based on your condition
i <- which(mtcars$carb == 1)
## set those rows of mtcars in your index
## to the index - 1
mt
I've created a data frame in R, but in order to clean up some of the data,
I need to set certain variable observations equal to the value of their
previous observation (it would be conditional, but that part's less
important right now). In Stata, I would simply set var = var[_n-1] in those
cases. W
umesh khatri writes:
> Dear everyone
>
> I'm dealing with a problem related to Poisson Ridge Regression. If
> anyone can help me in this regard by telling if any changes in the
> source code of "glm.fit" may help
As John Kane suggested, the posting guide is a good start.
So is rseek.org where '
On 2012-07-07 14:56, YTP wrote:
Hi Rui,
Thanks for responding. I did not write "raw=raw", and I'm not sure why R
would return such a misleading error message. Indeed, the same error message
comes up when I run the 2nd part of your code:
m <- matrix(1:6, ncol=2)
p6 <- poly(m, degree=6, raw=TRUE
On Jul 7, 2012, at 5:37 PM, John Kane wrote:
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)")
De
On Jul 5, 2012, at 9:30 PM, "qinjiaolong" wrote:
> Dear Michael,
>
> Thanks a lot for your help. As I searched, the âscorâ function is a
> robust correlation, which is cited by Wilcox, R.R., Inferences Based on a
> Skipped Correlation Coefficient. Journal of Applied Statistics, 2004. 31(
HI John,
If I understand the post, in your original data, there is a space between XXY
and (.
If there was no space,
dd1 <- c( "XXY(mat harry)","XXY(jim bob)", "CAMP(joe blow)", "ALP(max jack)")
#Rui's original code will produce
result<-strsplit(sub(close.par,"",dd1),open.par)
> result
[[1]]
Hi,
I have a few questions about glht() and the interpretation of output from
Tukey's in multcomp package for lme() model.
The main issue is that I noticed that a plot that I produced with code
letters seem to contradict the graph itself. I provide data and code
below. I end with my questions.
Hello Joshua,
Thanks for taking time out to help me with problem. Actually the comparison
is to be done among two (if possible, more than two) datasets and not within
the dataset. Each dataset hold 5 variables (i.e Red, Purple, Blue, Grey and
Yellow) for 21 different positions i.e 1-21n. So, we ha
Hi Peter,
I had this same problem, but only when using Rmpi interactively. My scripts
work when run in batch mode, following the examples at
http://math.acadiau.ca/ACMMaC/Rmpi/ . Since this message is old, you may
have discovered this already. Nevertheless, if others have the same problem,
knowi
Hi Rui,
Thanks for responding. I did not write "raw=raw", and I'm not sure why R
would return such a misleading error message. Indeed, the same error message
comes up when I run the 2nd part of your code:
> m <- matrix(1:6, ncol=2)
> p6 <- poly(m, degree=6, raw=TRUE)
Error in poly(dots[[1L]],
Hi, David.
Thank you for the suggestions. If it makes a difference, I've included more
information on the data and how the Gompertz model was fit to each sample
below. I'm sure my methods are inefficient, and I should utilizing R's
process of vectorization. Thanks, again.
--Trey
David Winsem
Please use 'Reply All' in your responses. Others may be better
able to help than I.
See comments inline below.
On 2012-07-06 04:46, Jennifer Kaiser wrote:
You probably intended all the variables that are of
type "integer" (e.g. FAHRL_C) to be _factors_. My guess
is that, for ease of data entry,
You could use xtable (no "s"). It produces latex and html formats, but for
Excel you want to use html format.
> library(xtable)
> agec <- sample(c(rep(1, 15), rep(2, 4), 3), 1000, replace=TRUE)
> table(agec)
> agec
1 2 3
759 202 39
> print(xtable(table(agec)), type="html", file="clipboar
I think I'm geting it a bit. Anyway time to shut down and have a beer. Life
will be much nice tomorrow or Monday when I get back to cleaning up the data
from that spreadsheet.
Many thanks and have a good weekend.
John Kane
Kingston ON Canada
> -Original Message-
> From: ruipbarra..
The space is for a different reason, strsplit doesn't put the split
pattern in the result, so if a space is included it will be
automatically deleted. For instance in "XXY (mat harry)" without the
space it would become "XXY " and "mat harry)" but we want "XXY" so
include the space in the patter
Ah, I think Mark may have it. See my earlier post. Why the space?
John Kane
Kingston ON Canada
> -Original Message-
> From: ruipbarra...@sapo.pt
> Sent: Sat, 07 Jul 2012 23:12:46 +0100
> To: marklee...@gmail.com
> Subject: Re: [R] Splitting a character vector.
>
> Oh, right!
>
> The
How totaly obvious once you tell me! I would have spend days trying to figure
it out.
I think I have a total mental block on regex and their derivatives.
Thanks very much.
John Kane
Kingston ON Canada
> -Original Message-
> From: ruipbarra...@sapo.pt
> Sent: Sat, 07 Jul 2012 23:21:19
It's an empty character string, meant to substitute nothing for
close.par, to get rid of it.
Rui Barradas
Em 07-07-2012 23:17, John Kane escreveu:
No sorry Rui,
In the expression result <- strsplit(sub(close.par, "", dd1), open.par)
there is close.par, ''", open.par
I probably am just blind
mod Ted's comments, I believe that for your situation (not too many digits
to represent, decimal point always present)
countDecDigits <-
function(x)nchar(sapply(strsplit(as.character(x),"\\."),"[",2))
is simple and should work. No need for regular expressions here.
-- Bert
On Sat, Jul 7, 2012
Thanks Jeff.
I actually had that figured out after a good hour of pounding my head against
the wall but I still could not seem to get the syntax correct. I think I
misunderstand strpsplt() just enough to keep making dumb mistakes.
John Kane
Kingston ON Canada
> -Original Message-
> Fr
No sorry Rui,
In the expression result <- strsplit(sub(close.par, "", dd1), open.par)
there is close.par, ''", open.par
I probably am just blind but I don't understand what it is doing.
John Kane
Kingston ON Canada
> -Original Message-
> From: ruipbarra...@sapo.pt
> Sent: Sat, 07 Ju
Oh, right!
The close parenthesis isn't doing nothing in the result, t could be done
after but since we're to it...
Rui Barradas
Em 07-07-2012 23:10, Mark Leeds escreveu:
Hi Rui: I think he's asking about your replacement with blanks.
On Sat, Jul 7, 2012 at 6:08 PM, Rui Barradas mailto:ruip
Just to clarify, the regex engine wants to see a \ before the ( if it is to
treat it as an ordinary character. However, the source code interpreter also
treats \ as an escape character. In order to get a \ into the string, you have
to escape it. So it takes two \ characters in source code to obt
Hello,
Sorry, but I don't understand, you're asking about 4 single quotes, the
double quotes in open.par are just opening and closing the pattern, a
character string.
Rui Barradas
Em 07-07-2012 23:03, John Kane escreveu:
Thanks Rui
It works perfectly so far on the test and real data.
The a
Thanks Rui
It works perfectly so far on the test and real data.
The annoying thing is that I had tried , or thought I'd tried the open.par
format and keep getting an error.
It looks like I had failed to add the , in the term. What is it doing?
John Kane
Kingston ON Canada
> -Or
Hello,
Try the following.
open.par <- " \\(" # with a blank before '('
close.par <- "\\)"
result <- strsplit(sub(close.par, "", dd1), open.par)
Why the two '\\'? Because '(' is a meta-character so it must be escaped.
But '\' is a meta character so it must also be escaped.
Then choose the r
dnewdis <- function(x, a, b, n) {
i <- 0:exp(10)
term <-sum-1)**i)*(choose(b-1,i))*(beta(x+a+a*i,n-x+1
a*b*choose(n,x)*term
}
--
David L Carlson
Associate Professor of Anthropology
Texas A&M University
College Station, TX 77843-4352
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"
This works. First we assign the results of dput() to a variable
So we can use it. Then we eliminate the groups we don't need.
Third we remake the factors to eliminate the groups and genes
that do not appear in the data subset. Finally, compute the tests.
Dta <- structure(list(Gene = structure(c(1
Hi,
I checked the count for the cases (A) and (F) with a variant of Josh's function:
decimalnumcount<-function(x){stopifnot(class(x)=="character")
x<-gsub("(.*)(\\.)|([0]*$)","",x)
nchar(x)
}
A)
x<-"123456789.123456789"
decimalnumcount(x)
#[1] 9
x<-"923456789.123456789"
decimalnumcount(x
Hi,
Probably easier to work with the raw data, but whatever. If your data
is in a data frame, dat,
## create row index
dat$x <- 1:21
## load packages
require(ggplot2)
require(reshape2)
## melt the data frame to be long, long dat, ldat for short
ldat <- melt(dat, id.vars="x")
## plot the distr
On 2012-07-07 03:19, fabiano wrote:
I have been working on the following code but keep getting an err message. My
current thinking is that the problem is on the indexing but do not know how
to fix it. Any help please?
ungulate <- read.csv("Ungulate.csv",row.names=1)
ungulate <-
as.matrix(ungulat
Hi Uwe,
there is no function called apriori in the trio package.
I guess apriori is from the arules package, which however does not depend on or
suggests trio.
The error in some of the package checks of trio is based on some strange,very
rarely occuring behavior of the Fortran code in the tri
Joshua Ulrich wrote
>
> Load the data into an environment, then merge them using do.call():
>
> series.env <- new.env()
> getSymbols(ticker.list, src='FRED', env=series.env)
> series <- do.call(merge, as.list(series.env))
>
>
Thank you very much, Joshua: this works very well!
Thank you :)
-
Thank you very much for you kind explanation Berend Hasselman!!
Is it possible to declare this probability density function without looping?
--
View this message in context:
http://r.789695.n4.nabble.com/Declaring-a-density-function-with-for-loop-tp4635699p4635720.html
Sent from the R help maili
Hello,
I am using R for fitting parameters of a time series model.
The model is as below.
Y(t) = mu + a*X(t) + YN(t)
where YN(t) = b*YN(t-1) + innovation
and Z(t) follows N(0,1).
The main obstacle for me is the autoregressive error term, YN(t).
I can't figure out how to estimate the parameters (
Try the following:
library(TeachingDemos)
?TkPredict
fit.glm1 <- glm( Species=='virginica' ~ Sepal.Width+Sepal.Length,
data=iris, family=binomial)
TkPredict(fit.glm1)
(you may need to install the TeachingDemos package first if you don't
already have it installed)
You
On 05.07.2012 21:28, Ondřej Mikula wrote:
Dear list,
is there a way how to add information to internal nodes (branching
points) in dendrogram created via plot.agnes function (package
cluster)?
I wish to place colored circles on the nodes, but I don't know how to proceed...
I'll be grateful for
On 06.07.2012 12:23, Pascal Oettli wrote:
Good morning,
1. What is your OS?
2. Which package do you use to perform the Apriori?
Given the error message, a good guess is probably that the trio package
is used.
The CRAN checks showed also some (maybe unrelated) problems with the
package un
Hello,
I would like to know how to test the assumption of proportional odds or
parallel lines or slopes for an ordinal logistic regression with svyolr
Thanks
[[alternative HTML version deleted]]
__
Dear Mr Harding,
Thank You very much for Your responsiveness.
>There would seem to be no clean general solution to this
>question. An important issue would be: What use do you
>want to put the result to?
I need this trick for the following task.
I am writing a function which has to determin
Hello,
I haven't found errors in your code. I implemented the test in the paper
(the first, fixed symetric mean) and it also gives me zero Type I
errors, when alpha = 0.05. Try to see the value of min(pv) or to plot
the histogram of 'pv', hist(pv) and you'll see that there are no
significant
Your request fails the reproducibility requirement from the posting guide,
because you have not supplied enough data to run the code and reproduce the
error.
---
Jeff NewmillerThe . .
On Jul 6, 2012, at 6:31 PM, SergeyHC wrote:
David, thanks for your helpful response.
Now i figured out that I do have boot command and do not need to
install any
additional packages. With regards t R GUI, I guess I would like to
use it,
but I could not figure out how to install it. For no
On Jul 6, 2012, at 4:30 PM, Abraham Mathew wrote:
Ok, so let's say I have a logit equation outlined as Y= 2.5 + 3X1 +
2.3X2 +
4X3 + 3.6X4 + 2.2X5
So a one unit increase in X2 is associated with a 2.3 increase in Y,
Assuming, that is, you also understand what Y is. From you comments so
fa
On Fri, 6 Jul 2012, MacQueen, Don wrote:
So what you're faced with is that the cenros() function has no built-in
methods for grouping or subsetting -- unlike some other R methods,
especially those that work with the lattice package, or the many modeling
functions like lm() that have a subset arg
Load the data into an environment, then merge them using do.call():
series.env <- new.env()
getSymbols(ticker.list, src='FRED', env=series.env)
series <- do.call(merge, as.list(series.env))
HTH,
--
Joshua Ulrich | FOSS Trading: www.fosstrading.com
On Sat, Jul 7, 2012 at 7:00 AM, Cren wrote:
Hi all,
I would need to put datas downloaded with quantmod into a matrix or a data
frame.
Suppose to start from here:
*require(quantmod)
ticker.list <- c('AAA', 'ALTSALES','AMBNS','AMBSL','BAA',
'EMRATIO',
'FEDFUNDS', 'GASPRICE', 'GS1', 'GS10', 'GS20', 'LNS141000
I had thought of also (as well as my numerical routing) suggesting
a "gsub()" type solution like Joshua's below, but held back because
the result could depend on how the number arose (keyboard input,
file input, or from computation within R).
However, I now also realise that (again because of bina
From the file INSTALL:
'The main source of information on installation is the `R Installation
and Administration Manual', an HTML copy of which is available as file
`doc/html/R-admin.html'. Please read that before installing R. But
if you are impatient, read on but please refer to the manual to
chamilka wrote
>
> I have an extended binomial distribution which has the following form:
>
> http://r.789695.n4.nabble.com/file/n4635699/kb.png
>
> Here alpha and beta are two parameters and x=0,1,2,3,...n (alike the
> binomial distribution)
> I am writing a function to find out the densit
I have an extended binomial distribution which has the following form:
http://r.789695.n4.nabble.com/file/n4635699/kb.png
Here alpha and beta are two parameters and x=0,1,2,3,...n (alike the
binomial distribution)
I am writing a function to find out the densities (probabilities) of this
distri
A problem came when I installed R-2.15.0 in RedHat Linux from souce. when
./configure is commited , there is a error message like:
===
sudo ./configure
Password:
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
loa
Thank you Michael !!! Problem solved~~
I forgot to hit "Reply all", I will keep that in mind.
Best,
Chenwei
On Fri, Jul 6, 2012 at 11:52 PM, Michael Weylandt <
michael.weyla...@gmail.com> wrote:
> Please do keep messages on list unless there's a particular reason to take
> them private: it in
Hi Martin,
Ted is spot on about the binary representation. A very different
approach from his would be to convert to character and use regular
expressions:
## the example numbers in a vector
x <- c(3.14, 3.142, 3.1400, 123456.123456789, 123456789.123456789, pi, sqrt(2))
nchar(gsub("(.*\\.)|([0]
I have been working on the following code but keep getting an err message. My
current thinking is that the problem is on the indexing but do not know how
to fix it. Any help please?
ungulate <- read.csv("Ungulate.csv",row.names=1)
ungulate <-
as.matrix(ungulate);colnames(ungulate)<-NULL;rownames(u
On 07-Jul-2012 08:52:35 Martin Ivanov wrote:
> Dear R users,
>
> I need a function that gets a number and returns its number of
> actual decimal places.
> For example f(3.14) should return 2, f(3.142) should return 3,
> f(3.1400) should also return 2 and so on. Is such function already
> availabl
Dear R users,
I need a function that gets a number and returns its number of actual decimal
places.
For example f(3.14) should return 2, f(3.142) should return 3, f(3.1400) should
also return 2
and so on. Is such function already available in R? If not, could you give me a
hint how to achieve
On 06/07/2012 09:14, Kunio takezawa wrote:
Dear R users (r-help@r-project.org),
The definition of AIC (Akaike information criterion)
for normal error models has just been changed.
Excuse me, who empowered you to re-write history? Maybe Dr Akaike could
have changed his definition, but he
60 matches
Mail list logo