ers to dates.
That's true with the function in the base package, but the zoo package also has
an as.Date() function, which defaults the origin to "1970-01-01". If James is
using zoo his code would be okay. If he's not, he would have got an error, so
I think he must have been.
Du
o I think he must have been.
>
> Duncan Murdoch
>
>>
>> Jim
>>
>> On Sun, Nov 6, 2016 at 12:10 PM, James Hirschorn
>> wrote:
>>> This seemed odd so I wanted to check:
>>>
>>> > x <- foreach(i=1:10100, .combine
Reduce is failing when applied to a list of elements of class
data.table. Perhaps this is a bug?
Example:
library(data.table)
dt1 <- data.table(x = 1:3, y = 4:6)
dt2 <- data.table(x = 4:6, y = 1:3)
dt3 <- data.table(x = 0:-2, y = 0:-2)
# This works fine
dt1 + dt2 + dt2
#x y
# 1: 5 5
# 2:
OpCl works on xts objects but not on quantmod.OHLC objects. Is this a bug?
Example error:
x.Date <- as.Date("2003-02-01") + c(1, 3, 7, 9, 14) - 1
set.seed(1)
x <- zoo(matrix(runif(20, 0, 1), nrow=5, ncol=4), x.Date)
q <- as.quantmod.OHLC(x,c("Open","High","Low","Close"))
# error
OpCl(q)
#> Erro
Can someone please explain the following behavior?
df1 and df2 are data.frames. Suppose I want a subset of the rows
(observations) using extraction, say just the first row. What I want to know
is why if df1 has just one column then df1[1,] returns a vector, whereas if
df2 has 2 or more columns
tions
such as sort().
-Original Message-
From: David Winsemius [mailto:dwinsem...@comcast.net]
Sent: Sunday, October 31, 2010 12:24 PM
To: James Hirschorn
Cc: R-help@r-project.org
Subject: Re: [R] extracting named vector from dataframe
On Oct 31, 2010, at 11:54 AM, James Hirschorn
Suppose df is a dataframe with one named row of numeric observations. I want
to coerce df into a named vector.
as.vector does not work as I expected: as.vector(df) returns the original
dataframe, while as.vector(df,mode="numeric") returns an unnamed vector of
NAs.
This works:
> v <- as
>
> Here is a dodge I often use. This is a mock-up example.
Very instructive (and helpful) ...
>
> ___
>
> bar <- data.frame(matrix(rnorm(1001), nrow = 1))
> names(bar)[1] <- "y" ## say
> head(bar[,1:5])
>
> nbar <- names(bar)
> form <- as.formula(paste(nbar[1], "~", paste(nbar[-1],
What is a good way to enter a very long model formula. For example:
y ~ Input.2 + Input.3 + ... + Input.1000
(assuming the corresponding dataframe has many other columns).
Is there a way to convert a character string to a formula? Are there command
line expansions in R besides the simple '.'?
d columns
differently, analogously to write.table. However, there does not even seem to
be
an option to make read.table behave analogously.
- Original Message ----
From: peter dalgaard
To: james hirschorn
Cc: r-help@r-project.org
Sent: Tue, October 5, 2010 7:25:52 AM
Subject: Re: [R
Suppose I have a data file (possibly with a huge number of columns), where the
columns with factors are coded as "1", "2", "3", etc ... The default behavior
of
read.table is to convert these columns to integer vectors.
Is there a way to get read.table to recognize that columns of quoted number
11 matches
Mail list logo