Displaying 20 results from an estimated 11000 matches similar to: "transforming year.weeknumber into dates"
2010 Aug 13
3
transforming dates into years
Hello!
If I have in my data frame MyFrame a variable saved as a Date and want
to translate it into years, I currently do it like this using "zoo":
library(zoo)
as.year <- function(x) as.numeric(floor(as.yearmon(x)))
myFrame$year<-as.year(myFrame$date)
Is there a function that would do it directly - like "as.yearmon" -
but for years?
Thank you!
--
Dimitri
2010 Oct 25
3
finding the year of a date
I know that I can use as.yearmon in the package "zoo" to find the year
and the month of a date.
I can use as. yearqtr to find the year and the quarter.
But how can one find just the year of a date?
Thanks a lot!
--
Dimitri Liakhovitski
Ninah Consulting
www.ninah.com
2009 Sep 04
2
transforming a badly organized data base into a list of data frames
Dear R-ers!
I have a badly organized data base in Excel. Once I read it into R it
looks like this (all variables become factors because of many spaces
and other characters in Excel):
2011 May 06
1
Extracting months and years from Dates while keeping order
Hello!
I'd like to take Dates and extract from them months and years - but so
that it sorts correctly. For example:
x1<-seq(as.Date("2009-01-01"), length = 14, by = "month")
(x1)
order(x1) # produces correct order based on full dates
# Of course, I could do "format" - but this way I am losing the "Date"
quality of the data:
2017 Jul 27
0
na.rm = T treatment by ggplot2's geom_bar
?hanks for the advice, Jeff. Will keep it in mind.
But I am anal - I shy away from using letters and words that "look
familiar" to me in R (such as mean, sd, T, etc.)
But still, it's a good advice.
On Thu, Jul 27, 2017 at 11:53 AM, Jeff Newmiller <jdnewmil at dcn.davis.ca.us>
wrote:
> I think you should be more suspicious of yourself, Dimitri. A letter T
> variable can
2017 Jul 27
2
na.rm = T treatment by ggplot2's geom_bar
I think you should be more suspicious of yourself, Dimitri. A letter T variable can easily arise in the problem domain when you are not thinking of logical values at all, at which point your cavalier use of T as a synonym for TRUE can suddenly become a bug.
--
Sent from my phone. Please excuse my brevity.
On July 27, 2017 8:18:03 AM PDT, Dimitri Liakhovitski <dimitri.liakhovitski at
2011 Aug 02
3
identifying weeks (dates) that certain days (dates) fall into
Hello!
I have dates for the beginning of each week, e.g.:
weekly<-data.frame(week=seq(as.Date("2010-04-01"),
as.Date("2011-12-26"),by="week"))
week # each week starts on a Monday
I also have a vector of dates I am interested in, e.g.:
july4<-as.Date(c("2010-07-04","2011-07-04"))
I would like to flag the weeks in my weekly$week that
2011 Mar 30
2
summing values by week - based on daily dates - but with some dates missing
Dear everybody,
I have the following challenge. I have a data set with 2 subgroups,
dates (days), and corresponding values (see example code below).
Within each subgroup: I need to aggregate (sum) the values by week -
for weeks that start on a Monday (for example, 2008-12-29 was a
Monday).
I find it difficult because I have missing dates in my data - so that
sometimes I don't even have the
2017 Jul 27
2
na.rm = T treatment by ggplot2's geom_bar
Just a thought:
Did you try na.rm = TRUE in case you have an object named "T" in scope?
-- Bert
Bert Gunter
"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
On Thu, Jul 27, 2017 at 7:49 AM, Dimitri Liakhovitski
<dimitri.liakhovitski at
2017 Jul 27
0
na.rm = T treatment by ggplot2's geom_bar
Thank you, Bert!
I do NOT have an object named "T" in scope (I checked - and besides, it
would never occur to me to use this name).
TRUE or T results in the same unexpected behavior:
ggplot(data = md, mapping = aes(x = a)) +
geom_bar(na.rm = TRUE)
On Thu, Jul 27, 2017 at 10:57 AM, Bert Gunter <bgunter.4567 at gmail.com>
wrote:
> Just a thought:
>
> Did you try
2017 Jul 27
0
na.rm = T treatment by ggplot2's geom_bar
To clarify: my question is not about "who could I exclude NAs from being
counted" - I know how to do that.
My question is: Why na.rm = T is not working for geom_bar in this case?
On Thu, Jul 27, 2017 at 8:24 AM, Dimitri Liakhovitski <
dimitri.liakhovitski at gmail.com> wrote:
> Hello!
>
> I am trying to understand how ggplot2's geom_bar treats NAs.
> The help file
2017 Jul 27
1
na.rm = T treatment by ggplot2's geom_bar
I suspect this is by design. Questions about "why" should probably cc the contributed package maintainer(s).
--
Sent from my phone. Please excuse my brevity.
On July 27, 2017 7:49:47 AM PDT, Dimitri Liakhovitski <dimitri.liakhovitski at gmail.com> wrote:
>To clarify: my question is not about "who could I exclude NAs from
>being
>counted" - I know how to do
2011 May 19
1
Creating a "shifted" month (one that starts not on the first of each month but on another date)
Hello!
I have a data frame with dates. I need to create a new "month" that
starts on the 20th of each month - because I'll need to aggregate my
data later by that "shifted" month.
I wrote the code below and it works. However, I was wondering if there
is some ready-made function in some package - that makes it
easier/more elegant?
Thanks a lot!
# Example data:
2009 Apr 23
2
transposing a matrix - row by row?
Hello,
I have a matrix that is a product of tapply on a larger data set.
Let's assume it looks like this:
X<-matrix(c(10,20,30,40,50,60),2,3)
dimnames(X)<-list(c("1","2"),c("1","2","3"))
(X)
1 2 3
1 10 30 50
2 20 40 60
Is there an efficient way of transforming this matrix into the following matrix:
rows columns entries
1
2009 Apr 28
4
Producing customized tickmarks when producing a graph using "curve"
Hello!
I am using function "curve" to create a line graph.
I was wondering, if it's possible to "turn off" the default tick marks
and introduce those tick marks in specific locations.
For example, currently in my X axis tick marks are (automatically) at
10, 11, 12, 13 but I want them to be in 5 specific locations, like
9.89, 10.34, etc.
Any hint would be greatly
2009 Oct 13
4
replacing period with a space
Dear R-ers!
I have x as a variable in a data frame x.
x<-data.frame(x=c("aa.bb","cc.dd.ee"))
x$x<-as.character(x$x)
x
I am sorry for such a simple question - but how can I replace all
periods in x$x with spaces?
sub('.', ' ', x$x) - removes all letters to the left of each period...
Thanks a lot for your advice!
--
Dimitri Liakhovitski
Ninah.com
2009 Sep 23
2
Function to check if a vector contains a given value?
Dear R'rs,
is there a function that checks if a given vector contains a certain value.
E.g., x<-c(1,2,3,4).
How can I get a TRUE or FALSE for whether x contains a 2?
--
Dimitri Liakhovitski
Ninah.com
Dimitri.Liakhovitski at ninah.com
2009 Apr 23
4
rbind data frames stored in a list
Hello everyone!
I have a list X with 3 elements, each of which is a data frame, for example:
a<-data.frame(a=1,b=2,c=3)
b<-data.frame(a=c(4,7),b=c(5,8),c=c(6,9))
c<-data.frame(a=c(10,13,16),b=c(11,14,17),c=c(12,15,18))
X<-list()
X[[1]]<-a
X[[2]]<-b
X[[3]]<-c
(X)
How can I most effectively transform X into a data frame with columns
a, b, and c?
I would love to find a generic
2010 Mar 04
4
Analogue to SPSS regression commands ENTER and REMOVE in R?
I am not sure if this question has been asked before - but is there a
procedure in R (in lm or glm?) that is equivalent to ENTER and REMOVE
regression commands in SPSS?
Thanks a lot!
--
Dimitri Liakhovitski
Ninah.com
Dimitri.Liakhovitski at ninah.com
2010 Mar 18
1
R takes long time to open
Hello.
Until today I've been using R2.9 and since today R2.10 (on a PC).
In both of them it takes about 20 sec for the prompt to appear IN R
console after I start R. And every time it says: "Previous saved work
space restored" - even if I have not saved any workspace or, in case
of R2.10 - even though I have not used it once.
In the older versions - R would start within 2-3 sec.
Is