I want to generate a sequence of date based on a group id(similar IDs
should have same date). The id variable contains unequal observations
and the length of the data set also varies. How could I create a
sequence that starts on specific date (say January 1, 2000 onwards)
and continues until the e
On Tue, 7 Oct 2014 07:25:49 PM Hafizuddin Arshad wrote:
> Dear R users,
>
> I have this kind of data set which is part of my data:
>
> ...
>
> I would like to find the rainfall total for each month within a year. The
> result should be like in this form:
>
> ...
>
> where V1 until V12 as month
ex1 <- c('Y', 'N', 'Y')
ex2 <- c('Y', 'N', 'Y')
ex3 <- c('N', 'N', 'Y')
ex4 <- c('N', 'N', 'Y')
status <- array(NA, dim=3)
# I am trying to return 'Okay' if any of the values
# in a column above is 'Y' but I am not constructing
# the function corrrectly. Any assistance is
# greatly appreciated
Dear Barry,
some thoughts:
1) e in your function status_fnc is a vector when applied on a matrix
like object, but you index it as a matrix (e[,i] should be e[i]).
2) You can simplify the if statement by using the function any
(replacing all the OR statements) on the vector, so use any(e=='Y')
her
If you make a factor with year with levels including all the years that you
want then use tapply eg with dat as the name of the data.frame
The same applies for Month but I have not done so
dat$Yr <- factor(dat$Year, levels = c(1971:1980))
with(dat, tapply(Rain, list(Yr, Month), sum, na.rm=T))
Dear All,
Change the format of the start and end columns so that data appear as the
day of the year. For instance: Apr 24 rather than 115.
The idea is that I want the non=leap years to be 366 days instead of being
365 days. ie. Each year must have 366 days. for example: in the column
Start2, Apr
The idea is that I want the non-leap years to be 366 days instead of being
365 days. ie. Each year must have 366 days.
for example: in the column Start2, Apr 18 will be Apr 17.
> head(Samaru)
Year Start End Length Start2 End2
1 1930 108 288180 Apr 18 Oct 15
2 1931 118 288170 Apr 2
Does this work for you?
df$in1 <- 0
df$in1[match(unique(df$id), df$id)] <- 1
df$date <- as.Date("2000-01-01") + cumsum(df$in1) - 1
Jean
On Wed, Oct 8, 2014 at 2:57 AM, Kuma Raj wrote:
> I want to generate a sequence of date based on a group id(similar IDs
> should have same date). The id varia
Hi,
I'm using R version 3.1.1 on Debian via the CRAN repositories.
Consider the following MWE that writes a data.frame out to a file and
reads it back in (note that one of the strings contains a double
quote):
> write.table(data.frame(a=1:3, b=c("a", "b\"b", "c")), '/tmp/a',
row.names=FALSE,
Using package 'compositions' on count data and scaling with Aitchison
geometry using function acomp(), the summary() function displays matrices
for (among other descriptive statistics) minimum, Q1, median, Q3, and
maximum. These matrices are not symmetric because they are based on
log-ratios. An
Hello!
Could anyone recommend a good book on state space/Kalman filters, please?
Those which include R steps are nice, but not necessary. I'm most
interested in the state space/Kalman filters.
I would like to do a sort of compare and contrast with arima results.
Thanks,
Erin
--
Erin Hodgess
Hi everybody,
I have (as an example) the following
two data tables:
all <-
data.table(ID = c(rep(c(100:105),c(3,2,2,3,3,3))),
value =
c(100,120,110,90,45,35,270,50,65,40,25,55,75,30,95,70))
DT <-
data.table(ID = 100:105, code=c(2,1,3,2,3,1))
My aim is to construct as many sub
Please be aware that by posting your question in HTML format instead of plain
text you have sent us a corrupted message. Please adjust your email software
settings when sending to this list.
I thought the whole purpose of data.table was to allow group data processing
without creating oodles of
Hi,
I'm developing R package with GUI.
I would write a file that run R and load package by double clic.
I am using Kubuntu.
If there is a solution with windows or mac, I am interested too.
Thanks
Karim
[[alternative HTML version deleted]]
__
R-h
Did you try to create a file containing
#!/usr/bin/Rscript
library(mypackage)
you also need to give execute permission like chmod 755 myfile.R
-Original Message-
From: "Karim Mezhoud" [kmezh...@gmail.com]
Date: 10/08/2014 12:16 PM
To: R-help@r-project.org
Subject: [R] Desktop ic
Revolution Analytics staff and guests write about R every weekday at
the Revolutions blog:
http://blog.revolutionanalytics.com
and every month I post a summary of articles from the previous month
of particular interest to readers of r-help.
In case you missed them, here are some articles related
On Oct 7, 2014, at 9:15 PM, Duncan Mackay wrote:
I'm a tad puzzled by the comments about needing to build a panel function for
locfit. The various plot.locfit functions are actually lattice calls.
locfit:::panel.locfit # already exists, and even has versions for 1d, 2d and
3d purposes.
And
How about:
tmp <- data.frame(a=1:3, b=c("a", "b\"b", "c"))
write.table(tmp, './tmp.write', row.names=FALSE, sep="\t², quote=FALSE)
tmp.in <- read.table('./tmp.write', sep='\t', head=TRUE, quote="")
> all.equal(tmp, tmp.in)
[1] TRUE
-Don
--
Don MacQueen
Lawrence Livermore National Labora
On Oct 8, 2014, at 8:06 AM, Frank S. wrote:
>
>
> Hi everybody,
>
>
>
> I have (as an example) the following
> two data tables:
>
>
>
> all <-
> data.table(ID = c(rep(c(100:105),c(3,2,2,3,3,3))),
>
> value =
> c(100,120,110,90,45,35,270,50,65,40,25,55,75,30,95,70))
>
> DT <-
> data.
Folks,
This is just misunderstanding. I did not want a panel function for locfit. In
my email I say:
Instead, I want to put a fit from lm (but
not a simple straight line) and the fit has to be done for each panel
separately, not one fit for the full data set, so sth like an lm
equivalent
This is like using the formula Area=3*r^2 for the area of a circle... you can
figure out a way to do it but it is still wrong. Why not leave the data as day
of year instead of misleading anyone who looks at it?
---
Jeff Newmi
You can adapt: format(as.Date(paste(Year, sep = "-", ifelse(Year %% 4 == 0,
Start, ifelse(Start > 59, Start - 1, Start))), "%Y-%j"), "%b %d”)
But 60% of the dates in your data.frame will then be wrong.
From: Frederic Ntirenganya
Reply: Frederic Ntirenganya >
Date: October 8, 2014 at 9:38:3
If the `ids` are ordered as shown in the example, perhaps you need
tbl <- table(df$id)
rep(seq(as.Date("2000-01-01"), length.out=length(tbl), by=1), tbl)
[1] "2000-01-01" "2000-01-01" "2000-01-01" "2000-01-01" "2000-01-01"
[6] "2000-01-02" "2000-01-02" "2000-01-02" "2000-01-02"
Duncan Murdoch writes:
> On 07/10/2014 2:45 AM, H. Dieter Wilhelm wrote:
>> Hello (),
>>
>> I'd like to do the following
>>
>> a <- 3
>> f1 <- function (x){
>> a*x^2
>> }
>>
>> a <- 5
>> f2 <- function (x){
>> a*x^2
>> }
>>
>> plotting f1, f2, ...
>>
>> but f1 and f2 are the same, how can I e
I am trying to read in data from an instrument that is recorded in
hexadecimal format. Using either:
y.hex <- read.table(file="hex.data", as.is=TRUE)
or
y.hex <- read.table(file="hex.data", text=TRUE)
gets all the data in just fine except points like `055E` or `020E`. In
these cas
I have a strange question concerning the fit of a Gamma generalized linear
model with glm (and further using gamma.shape to measure the shape
parameter).
Actually, I started with rgamma to generate some random vectors because I
wanted to play around with various conditions (and become familiar wi
Hi,
I think I got it!
The clue: Function split!
[[alternative HTML version deleted]]
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
...or some such. I'm trying to work up a function wherein the user
passes a list of matrices to the function, which then (1) takes each
matrix, (2) performs an operation to 'vectorize' the matrix (i.e., given
an (m x n) matrix x, this produces the vector Y of length m*n that
contains the colum
I did not see a reproducible example, but you should use
colClasses="character" to
read in the data as character, then use something like as.hexmode() to
convert it to integers. E.g.,
> z <- read.table(text="ColA ColB\n1e 33\n2e 44\n10 5e\n",
header=TRUE, colClasses="character")
> str(z)
On 08/10/2014 7:02 AM, mark.ho...@srs.gov wrote:
I am trying to read in data from an instrument that is recorded in
hexadecimal format. Using either:
y.hex <- read.table(file="hex.data", as.is=TRUE)
or
y.hex <- read.table(file="hex.data", text=TRUE)
gets all the data in just fine ex
On 08/10/2014 5:53 AM, H. Dieter Wilhelm wrote:
Duncan Murdoch writes:
> On 07/10/2014 2:45 AM, H. Dieter Wilhelm wrote:
>> Hello (),
>>
>> I'd like to do the following
>>
>> a <- 3
>> f1 <- function (x){
>> a*x^2
>> }
>>
>> a <- 5
>> f2 <- function (x){
>> a*x^2
>> }
>>
>> plotting f1, f2,
On Wed, Oct 8, 2014 at 6:02 AM, wrote:
> I am trying to read in data from an instrument that is recorded in
> hexadecimal format. Using either:
>
> y.hex <- read.table(file="hex.data", as.is=TRUE)
>
> or
>
> y.hex <- read.table(file="hex.data", text=TRUE)
>
> gets all the data in just fin
fFactory <- function(args) {
a <- complicated_a_computation(args)
b <- complicated_b_computation(args)
function(x) a*x + b*exp(x)
}
f1 <- fFactory(args1)
f2 <- fFactory(args2)
f1(x)
f2(x) # will get different result than f1(x)
f1 and f2 will look the same but produce different results
How about
> do.call(cbind, lapply(env, as.vector))
[,1] [,2]
[1,] 0.00 0.00
[2,] 0.05 0.15
[3,] 0.00 0.00
[4,] 20.00 15.00
[5,] 0.00 0.00
[6,] 0.10 0.20
[7,] 50.00 45.00
[8,] 0.00 0.00
[9,] 0.00 0.00
-
David L Carlson
Department o
Wim Kreinen gmail.com> writes:
>
[snip]
>
> Actually, I started with rgamma to generate some random vectors because I
> wanted to play around with various conditions (and become familiar with
> gamma shape). But before you can start with gamma shape you need to have a
> glm object.
>
> Assumi
Hi
I need to know how can I do dicky-fuller test in R
Regards
Mideast
من جهاز الـ iPad الخاص بي
[[alternative HTML version deleted]]
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting
Hello,
Try package tseries, function adf.test().
Hope this helps,
Rui Barradas
Em 08-10-2014 20:47, Midea Algaf escreveu:
Hi
I need to know how can I do dicky-fuller test in R
Regards
Mideast
من جهاز الـ iPad الخاص بي
[[alternative HTML version deleted]]
_
Hi
Then try
xyplot(... , type = c("p","r"))
Have a look at
? lattice::panel.xyplot for full type explanation
I cannot remember what Bert wrote. Your mention of smoothers and locfit can
be quite a different story
Duncan
-Original Message-
From: Bond, Stephen [mailto:stephen.b...@c
Hi
The canonical poison is this ...
par(plt)
plot.new()
...
par(plt)
par(new=TRUE)
plot.new()
...
par(plt)
par(new=TRUE)
plot.new()
The idea is to set up parameters that control the placement of a plot,
e.g., par(plt), and then start a plot, with plot.new(). If you want
more than one plot on
That works as well. I'll collate your response and a couple of others,
and post tomorrow.
On 10/8/2014 4:17 PM, David L Carlson wrote:
> How about
>
>> do.call(cbind, lapply(env, as.vector))
> [,1] [,2]
> [1,] 0.00 0.00
> [2,] 0.05 0.15
> [3,] 0.00 0.00
> [4,] 20.00 15.00
>
How can I create an improved version of a method in R, and have it be used?
Short version:
I think plot.histogram has a bug, and I'd like to try a version with a fix.
But when I call hist(), my fixed version doesn't get used.
Long version:
hist() calls plot() which calls plot.histogram() which fa
41 matches
Mail list logo