Here is an alternative solution
> foo <- array(data = rnorm(32), dim = c(4,4,2),
+ dimnames=list(letters[1:4], LETTERS[1:4], letters[5:6]))
>
> ind <- which(foo > 0, arr.ind = TRUE)
> row.names(ind) <- NULL ## to avoid warnings.
>
> mapply("[", dimnames(foo), data.frame(ind))
[,1] [,2] [,
Hi Dennis,
Thanks for your answer, it works very well - clever way to sort the problem!
Cheers,
Pierre
2011/5/16 Dennis Murphy :
> Hi:
>
> Does it have to be an array? If all you're interested in is the
> dimnames, how about this?
>
> library(plyr)
> foo <- array(data = rnorm(32), dim = c(4,4,
In your example it appears that you are plotting a histogram (on the
frequency
scale) and then superimposing scalar multiples of gamma and Gaussian
densities.
You should just plot a histogram (with frequency=FALSE) and then
superimpose the
densities --- without any scalar multipliers.
If that
On Sun, 15 May 2011, Duncan Murdoch wrote:
On 15/05/2011 3:02 PM, Aram Fingal wrote:
On May 13, 2011, at 6:38 AM, Michael Haenlein wrote:
Dear all,
I'm currently running R on my laptop -- a Lenovo Thinkpad X201 (Intel Core
i7 CPU, M620, 2.67 Ghz, 8 GB RAM). The problem is that some of my
ca
Hi:
Does it have to be an array? If all you're interested in is the
dimnames, how about this?
library(plyr)
foo <- array(data = rnorm(32), dim = c(4,4,2),
dimnames=list(letters[1:4], LETTERS[1:4], letters[5:6]))
> foo
, , e
A B C D
a -0.2
Hmm; still missing something - hist defaults to frequencies, not prob.
densities; and, I thought I'd scaled the fitted lines to the values in the
data frame. Just going with it, I specified freq=FALSE, and the prob density
was of course at a different order of magnitude than the lines.
What are yo
Thank you for your reply, Prof. Harrell.
I agree with you. Dropping only one variable does not actually help a lot.
I have one more question.
During analysis of this model I found that the confidence
intervals (CIs) of some coefficients provided by bootstrapping (bootcov
function in rms package
That approach relies on df1 and df2 not having overlapping values in b.
Slight variation in df2 gives different results:
> df1 <- data.frame(a=c("A","A"),b=c("B","B"))
> df2 <- data.frame(b=c("B","B"),c=c("c","c"))
> merge(df1,df2,all=TRUE)
b a c
1 B A c
2 B A c
3 B A c
4 B A c
On 5/15/11 11:1
Hi list,
In a function I am writing, I need to extract the dimension names of
an array. I know this can be acheived easily using dimnames() but my
problem is that I want my function to be robust when the number of
dimensions varies. Consider the following case:
foo <- array(data = rnorm(32), dim
> -Original Message-
> From: r-help-boun...@r-project.org
> [mailto:r-help-boun...@r-project.org] On Behalf Of Jonathan Flowers
> Sent: Sunday, May 15, 2011 5:41 PM
> To: r-help@r-project.org
> Subject: [R] rbind with partially overlapping column names
>
> Hello,
>
> I would like to mer
I think you are doing this correctly except for one thing. The validation
and other inferential calculations should be done on the full model. Use
the approximate model to get a simpler nomogram but not to get standard
errors. With only dropping one variable you might consider just running the
n
btw, I installed R.10.1 on the same box (Windows 7, 64bit, 4 cores).
snow/snowfall work fine.
here is my sessionInfo()
R version 2.10.1 (2009-12-14)
i386-pc-mingw32
locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United St
Hi:
Another way, with a little less typing but using the same principle, is
df1$c <- df2$a <- NA
rbind(df1, df2)
Dennis
On Sun, May 15, 2011 at 5:50 PM, Ian Gow wrote:
> Hi:
>
> This is a bit of a kluge, but works for your test case:
>
>> df2[,setdiff(names(df1),names(df2))] <- NA
>> df1[,setd
On Sun, May 15, 2011 at 2:42 PM, Bazman76 wrote:
> Hi there,
>
> I have a spreadsheet in excel which consists of first column of dates and
> then subsequent columns that refer to prices of different securities on
> those dates. (the first row contains each series name)
>
> I saved the excel file
Hi:
This is a bit of a kluge, but works for your test case:
> df2[,setdiff(names(df1),names(df2))] <- NA
> df1[,setdiff(names(df2),names(df1))] <- NA
> df3 <- rbind(df1,df2)
> df3
a b c
1 A B
2 A B
3 b c
4 b c
-Ian
On 5/15/11 7:41 PM, "Jonathan Flowers" wrote:
>Hello,
>
>I would like to
Hello,
I would like to merge two data frames with partially overlapping column
names with an rbind-like operation.
For the follow data frames,
df1 <- data.frame(a=c("A","A"),b=c("B","B"))
df2 <- data.frame(b=c("b","b"),c=c("c","c"))
I would like the output frame to be (with NAs where the frames
additional!!
I now realise that the time series created below is in the wrong order!
clearly the column of dates are not being interpreted as dates by the R. Is
is possible for R to read column one as dates? how can I do this?
dd<-data.frame(prices[,1],prices[,2])
> head(dd,3)
prices...1. pr
OK I got it to work thanks to your example
plot(ser)
however, ultiamtely a I need a stype ts object.
So I used
> xts <- as.ts(ser)
> xts
Time Series:
Start = 1
End = 732
Frequency = 1
which just gets me back to where I started with the correct raw data but no
attached dates?
It is possibl
Same problem as Anna here.
Windows 7 64-bit. Running R 2.13.0. snow + snowfall installed.
Testing:
library(snow)
library(snowfall)
sfInit(parallel=TRUE, cpus=2, type="SOCK")
Then R spins forever (yes, I disabled the Windows firewall).
On the same box, tried the same on Ubuntu under Virtualbox
Significant or not you should look at the p-value of your coefficient
estimation. If your prob. is significantly diff. from zero, you start to
interpret your coefficient from there.
Might help to look up Std.Err definition, its is some what similar to the
standard deviation. Good luck.
--
View th
I have imported the data fram Excel and it comes like this:
Calendar Year/Month 01.2008 01.2008 01.2008 01.2008 01.2008 02.2008 02.2008
Calendar year / week01.2008 02.2008 03.2008 04.2008 05.2008 05.2008 06.2008
There are repeats in the weeks both belonging to two months. It's the same
at
On 15/05/11 13:41, Dan Abner wrote:
Hello everyone,
Is there an R function that returns an object's search path position?
?find
cheers,
Rolf Turner
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEAS
What is it that you want to do? If you move the dates forward a year,
then what does it mean to add one year to 2/29/2008? You did mention
accounting for leap year. It goes the other way with 2/28/2007 and
3/1/2007; what is your expectation in these cases? You can always
convert everything to c
I'd've first said it's "simply"
sapply(df1$time, function(x) if(any(foo <- (x>=df2$from &
x<=df2$to))>0) df2$value[which(foo)] else NA )
but the following are much nicer (except that instead of NA you'll
have 0 but that's easy to change if necessary):
colSums(sapply(df1$time, function(x) (x>=df
I would assume that you have lines of text that do not include 'CIK='
and therefore the 'sub' fails and you get the original string. If
you only want the lines with "CIK", then use 'grepl' to just extract
those lines before processing.
On Sat, May 14, 2011 at 10:14 PM, Sparks, John James wrote:
try this:
> x <- read.table('/temp/tbl.txt', sep = ',', header = TRUE, as.is = TRUE)
> # remove commas from the Cost column
> x$Cost <- gsub(',', '', x$Cost)
> # split the Cost
> temp <- strsplit(x$Cost, "\\$") # "$" is special, so it is escaped
> temp <- do.call(rbind, temp) # create a matrix
>
Hi:
I'd suggest using the zoo package; it allows you to use an index
vector such as dates to map to the series. It is well documented and
well maintained, with vignettes and an FAQ that can be found on its
package help page (among other places). Here is a small example:
dd <- data.frame(time = se
Hi:
Try this:
barchart(Y ~ factor(X), group = X1, data = dat1, col = mcol, origin = 0,
ylab= "y var", xlab = "x var", ylim = c(-3.0, 5.0),
scales = list(x=list(rot= 90, font = 1, cex = 1) ,
y = list(rot= 90, font = 1, cex = 1) ))
The origin = argument
On 15/05/2011 3:02 PM, Aram Fingal wrote:
On May 13, 2011, at 6:38 AM, Michael Haenlein wrote:
Dear all,
I'm currently running R on my laptop -- a Lenovo Thinkpad X201 (Intel Core
i7 CPU, M620, 2.67 Ghz, 8 GB RAM). The problem is that some of my
calculations run for several days sometimes eve
Inline below.
On Sun, May 15, 2011 at 11:11 AM, Jan van der Laan wrote:
> Thanks. I also noticed myself minutes after sending my message to the list.
> My 'please ignore my question it was just a stupid typo' message was sent
> with the wrong account and is now awaiting moderation.
>
> However, m
On May 13, 2011, at 6:38 AM, Michael Haenlein wrote:
> Dear all,
>
> I'm currently running R on my laptop -- a Lenovo Thinkpad X201 (Intel Core
> i7 CPU, M620, 2.67 Ghz, 8 GB RAM). The problem is that some of my
> calculations run for several days sometimes even weeks (mainly simulations
> over
Hi there,
I have a spreadsheet in excel which consists of first column of dates and
then subsequent columns that refer to prices of different securities on
those dates. (the first row contains each series name)
I saved the excel file as type csv and then imported to excel using
prices=read.csv(
I used screen scraping to extract some information and put it into a table
called tbl. Now I want to modify the table a bit so the data can be more
useful. Here's the code I used:
library(XML)
rm(list=ls())
url <-
"http://webapp.montcopa.org/sherreal/salelist.asp?saledate=05/25/2011";
tbl <-data.f
Thank you - it is refreshing to have a helpful answer. I am glad some
people remember the days when they were first learning too.
On Thu, May 12, 2011 at 4:58 PM, jlemaitre [via R] <
ml-node+3518836-766936252-236...@n4.nabble.com> wrote:
> Nielsen,
> The numbers in the brackets reference a com
Dear R experts:
Here is my problem:
#Data 1
Y <- c(0.5, 0.1, 0.5, 1.3, 1.4, 1.6, 1.65, 2.4, 2.6, 3.4, 3.6, 4.3, 4.42,
4.8, 4.7, 3.4, 3.3, 2.8, 2.8, 1.2, 1.1, 0.5, 0.2, 0.1, -0.2, -1.5, -2.5,
-1.3, -0.5, -0.1)
X <- seq(1:30)
X1 <- c(rep("T1", 24), rep("T2", 6))
dat1 <- data.frame(Y, X, X1)
Hi Adrian,
Many thanks for your reply.
Suppose I wanted to increment the date by a year - how would I account for
things like leap years?
Would I just do
> mydaysx[select] <- mydaysx[select] + 365.25*24*60*60
Regards,Dave
From: Adrian Duffner
Cc: "r-help@r
I tried the modification but no luck. Here is exactly what I'm seeing.
The command works fine, but when I add prmsd=TRUE the numbers
disappear.
> print(summary.formula(S~Kyph+Vert, data=radio, method="reverse", overall=T,
> continuous=5, add=TRUE, test=T))
Descriptive Statistics by S
++---
It looks like you can get the text of the document
with
as(mmm[[1]], "character")
and you can use grep, strsplit, gsub, etc. on that text.
Look at the functions in the XML pacakge for ways
to use the XML structure of the data instead of pattern
matching to extract meaningful parts of the documen
On May 15, 2011, at 6:51 AM, meltem gölgeli wrote:
Dear R-users,
I'am really new at R. That's why I probably have a basic quastion. I
have a
function like f(x,y)=\int^{0}_{y}(2*x)*exp(y-t)dt or
f(x,y)=\int^{0}_{y}((2*x)*exp(\int^{0}_{t}(x*k)dk)dt and I can also
define
some basic loops for
On Sun, May 15, 2011 at 9:31 AM, Spencer Graves
wrote:
> Also: A previous post in this tread suggested "Rprof" [sec. 3.2 in "Writing
> R Extensions", available via help.start()]. This should identify the
> functions that consume the most time. The standard procedure to improve
> speed is as foll
Thanks. I also noticed myself minutes after sending my message to the
list. My 'please ignore my question it was just a stupid typo' message
was sent with the wrong account and is now awaiting moderation.
However, my other question still stands: what is the
preferred/fastest/simplest way to cr
On 14/05/2011 9:41 PM, Dan Abner wrote:
Hello everyone,
Is there an R function that returns an object's search path position?
Does find() do what you want? It doesn't give the position in the
search path, but you could get that from something like
name <- "plot"
which( search() %in% find(
Dear Dave,
please always answer to the whole list.
To answer your question: A quick check showed that your proposed code
will not work as you expected it
> tt <- as.POSIXlt(strptime("2011-01-01 00:00:00", "%Y-%m-%d %H:%M:%S",
tz="GMT"))
> tt
[1] "2011-01-01 GMT"
> tt+ 365.25*24*60*60
[1] "20
Dear All,
I have already posted before on the list about data mining and it has
proved very useful.
I have now a training dataset consisting of N objects of M
Also: A previous post in this tread suggested "Rprof" [sec. 3.2 in
"Writing R Extensions", available via help.start()]. This should
identify the functions that consume the most time. The standard
procedure to improve speed is as follows:
1. Experiment with different ways of computing
On Fri, May 13, 2011 at 6:38 AM, Michael Haenlein
wrote:
> I'm currently running R on my laptop -- a Lenovo Thinkpad X201 (Intel Core
> i7 CPU, M620, 2.67 Ghz, 8 GB RAM). The problem is that some of my
> calculations run for several days sometimes even weeks (mainly simulations
> over a large para
In your post, you're missing the final "s" on the stringsAsFactors
argument in the d1 assignment. When I typed it correctly, it works as
expected.
-- Bert
On Sun, May 15, 2011 at 4:25 AM, Jan van der Laan wrote:
> I use the following code to create two data.frames d1 and d2 from a list:
> types
Dear R-users,
I'am really new at R. That's why I probably have a basic quastion. I have a
function like f(x,y)=\int^{0}_{y}(2*x)*exp(y-t)dt or
f(x,y)=\int^{0}_{y}((2*x)*exp(\int^{0}_{t}(x*k)dk)dt and I can also define
some basic loops for x&y like x in 1:3 and y in 1:2. Could anybody please
help me
Good morning
I've made an PCA and I'd like to plot a confidence region based on Hotelling
T2? Does anyone know how to compute it?
Thank you
--
View this message in context:
http://r.789695.n4.nabble.com/hotelling-and-confidence-region-tp3524204p3524204.html
Sent from the R help mailing list a
Hi Dave,
your problem is that you are working with a S3 class, what is mainly a
list with naming convention. Hence it is possible to change just one
entry of the list, but it is nearly never recommendable.
So a slight change to your code should provide you the required output:
> mydaysx[selec
I just downloaded the patched version from the Danish mirror;
http://mirrors.dotsrc.org/cran/
That gave me: R version 2.13.0 Patched (2011-05-10 r55826) - which is *not* the
version you refer to.
Where may one get the latest patch then?
Regards
Søren
_
Hi:
For your specific problem, one way is:
plot( 0, xlim=c(0,5), ylim=c(0,5), type="n", cex = 2)
text(1, 1, expression(symbol('\252')))
text(2, 2, expression(symbol('\251')))
text(3, 3, expression(symbol('\250')))
text(4, 4, expression(symbol('\247')))
More generally, David's advice is sound; se
Hello,
I have a few questions concerning the DCC-GARCH model and its programming in
R.
So here is what I want to do:
I take quotes of two indices - S&P500 and DJ. And the aim is to estimate
coefficients of the DCC-GARCH model for them. This is how I do it:
library(tseries)
p1 = get.hist.quote(ins
On May 15, 2011, at 9:06 AM, ivo welch wrote:
Dear R-experts---is there a relatively low-pain way to get unicode
characters into a plot to a pdf device?
pdf(file="cardsymbols.pdf")
plot( 0, xlim=c(0,5), ylim=c(0,5), type="n")
text(1,1, "♠")
text(2,2, "♥")
text(3,3, "♦")
text(4,4, "♣")
dev.off(
On May 14, 2011, at 11:23 AM, Eli Kamara wrote:
Hello,
I'm a new user to R so apologies if this is a basic question, but
after scouring the web on information for summary.formula, I still
am searching for an answer.
I made a function to analyze my data - I have a categorical variable
a
Hello everyone,
Is there an R function that returns an object's search path position?
Thank you,
Dan
[[alternative HTML version deleted]]
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the pos
I use the following code to create two data.frames d1 and d2 from a list:
types <- c("integer", "character", "double")
nlines <- 10
d1 <- as.data.frame(lapply(types, do.call, list(nlines)),
stringsAsFactor=FALSE)
l2 <- lapply(types, do.call, list(nlines))
d2 <- as.data.frame(l2, s
That raises another question: Will that patched version (2011-05-13 r55886) be
made available as a windows binary - and if so: when?
Regards
Søren
Fra: r-help-boun...@r-project.org [r-help-boun...@r-project.org] På vegne
af Uwe Ligges [lig...@statistik
On 15.05.2011 12:27, Søren Højsgaard wrote:
That raises another question: Will that patched version (2011-05-13 r55886) be
made available as a windows binary - and if so: when?
Daily builds for WIndows of R-patched are available from CRAN.
Best,
uwe
Regards
Søren
__
Hi,
I am trying to construct a logistic regression model from my data (104
patients and 25 events). I build a full model consisting of five
predictors with the use of penalization by rms package (lrm, pentrace
etc) because of events per variable issue. Then, I tried to approximate
the full model by
Hi Jim,
Thanks for your note.
Unfortunately, when I attempt your solution in my exact setting, I get a
weird and slightly different answer.
First, let me be more clear. What I am attempting to do is pull the CIK
number out of the information from the web page itself after it has loaded
to R (th
Dear R-experts---is there a relatively low-pain way to get unicode
characters into a plot to a pdf device?
pdf(file="cardsymbols.pdf")
plot( 0, xlim=c(0,5), ylim=c(0,5), type="n")
text(1,1, "♠")
text(2,2, "♥")
text(3,3, "♦")
text(4,4, "♣")
dev.off()
(these are the characters that I need the most
On 05/14/2011 07:20 AM, whitney.mel...@colorado.edu wrote:
I cannot seem to get a L'abbe plot to work on R. I do not understand what
the X coordinates, or alternatively an object of class metabin, is
supposed to mean. What is a class of metabin?
Hi Whitney,
The L'Abbe plot is a relatively simpl
Here's how I'm trying to solve the diversity problem inherent in the data
(see below for a definition of the problem):
if (interquintile ranges have >=4 ranges at the same freq) then (use
rating=3)
else
(use rating as described in jim's code)
i'll have a go and post an update. in the mean time, if
Dear all,
I have a question related to the POSIXlt function in R.
I have a set of dates and times, for exmaple:
startx <- as.POSIXct("2011-01-01 00:00:00")
finx <- as.POSIXct("2011-12-31 00:00:00")
daysx<- seq(startx, finx, by="24 hours")
I
want to change the dates of all the days falling on
Forget I asked. There was a typo in my example (stringsAsFactor
instead of stringAsFactors) which explained the difference. My
apologies.
My second question however still stands: How does on create a
data.frame with given column types and given dimensions? Thanks.
Regards,
Jan
Quoting J
Hello,
I'm a new user to R so apologies if this is a basic question, but after
scouring the web on information for summary.formula, I still am searching for
an answer.
I made a function to analyze my data - I have a categorical variable and three
continuous variables. I am analyzing my continu
67 matches
Mail list logo