Hello,
Here are 3 solutions, one of them the coercion to factor one.
Since you are using tibbles, I assume you also want a dplyr solution.
library(dplyr)
df1 <- tibble(dates = c(rep("2021-07-04", 2),
rep("2021-07-25", 3),
rep("2021-07-18", 4)))
Dear Friends,
I have been scarce here. This is because I am busy implementing what I have
learned from you. You seem to have answered all my queries and I have not
got any new ones. I will quickly contact you as soon as I encounter
challenges in my analysis.
I hope you are well.
I have two recent
Sure thing. Typically with date related measures I'm going to build a
time series model e.g. ARIMA or maybe something more funky like a
recurrent neural net via Tensorflow. But in theory there's no reason
dates can't be factors if it's in keeping with your particular design
of experiment an
@Tom Okay, yeah. That might actually be an elegant solution. I will mess around
with it. Thank you - I’m not in the habit of using factors and am not super
familiar with how they automatically sort themselves.
@Andrew Yes. Each month is a different 30,000 row file upon which this task
must be p
I wonder if you mean that you want the levels of the factor to reset within
each month? That is not obvious from your example, but implied by your
question.
Andrew
--
Andrew Robinson
Director, CEBRA and Professor of Biosecurity,
School/s of BioSciences and Mathematics & Statistics
University o
You have been told how to do it. If you do not understand, you should find
a suitable tutorial to learn about how R factors work. There are some
difficulties in converting dates on an ongoing basis to factors, so I think
you should take Tom's advice to rethink this. It sounds as if you might
also d
Not if you use as.factor to convert a character type column to factor
levels. It should recode the distinct string values to factors
automatically for you.
i.e.,
df$datefactors <- as.factor(df$datestrings)
Quoting "N. F. Parsons" :
I am not averse to a factor-based solution, but I would
I am not averse to a factor-based solution, but I would still have to manually
enter that factor each month, correct? If possible, I’d just like to point R at
that column and have it do the work.
—
Nathan Parsons, B.SC, M.Sc, G.C.
Ph.D. Candidate, Dept. of Sociology, Portland State University
A
Couldn't you convert the date columns to character type data in a data
frame, and then convert those strings to factors in a 2nd step?
The only downside I think to treating dates as factor levels is that
you might have an awful lot of factors if you have a large enough
dataset.
Quoti
Hi all,
If I have a tibble as follows:
tibble(dates = c(rep("2021-07-04", 2), rep("2021-07-25", 3),
rep("2021-07-18", 4)))
how in the world do I add a column that evaluates each of those dates and
assigns it a categorical value such that
datescycle
2021-07-04
Thank you very much! That worked. I didn't need the unclass(as.Date...) as
the as.POSIXlt required me to use an origin to make the transformation.
The working code is as follows:
> times <- c(42935.5625,42935.569444)
as.POSIXct((times*86400),origin="1904-01-01",tz="America/Chicago")
[1] "2
Hello,
>From playing around with your numbers, it seems like you are using Excel
1904 Date System, which isn't a problem, it just means that your numbers
are days from 1904-01-01 instead of 1900-01-01.
The following is my solution:
times <- c(42935.5625,42935.569444)
as.POSIXlt((
# off
Hi Shawn,
I don't have any trouble with this:
times<-c("7/20/21 13:30","7/20/21 13:40")
strptime(times,"%m/%d/%y %H:%M",tz="GMT")
[1] "2021-07-20 13:30:00 GMT" "2021-07-20 13:40:00 GMT"
I suspect that Excel is causing the problem. Try changing the format
of the date column to "Text" and work on t
Brian,
Check out the corpus and tidytext packages for R.
https://rdrr.io/cran/corpus/f/vignettes/corpus.Rmd
https://www.tidytextmining.com/
Hope this helps.
Jim Milks
:
> Hi,
>
> I am wondering if there is some references on how R can be used to
> analyse legal/court documents. I searched
I've usually had good luck with this, but something is not working well. I
have two datetimes in excel
7/20/21 13:30
7/20/21 13:40
And when I convert these to excel's normal storage schema, I get the following:
42935.5625
42935.56944
Just try to convert this to a POSIX class gives me issues.
15 matches
Mail list logo