Displaying 20 results from an estimated 10000 matches similar to: "Randomly sampling subsets of dataframe variable"
2011 Mar 09
2
Complex sampling?
R users,
I am trying to generate a randomized weekday survey schedule that ensures even coverage of weekdays in
the sample, where the distribution of variable DOW is random with respect to WEEK. To accomplish this I need
to randomly sample without replacement two weekdays per week for each of 27 weeks (only 5 are shown). However,
I need to sample from a sequence (3:7) that needs to be
2011 Mar 22
2
Infinite loop
R experts,
Hello, I am trying to sample a vector 1:40 without replacement such that no element in the new vector
is within 7 units of either of its immediate neighbors. This is part of a larger program I am working
on. The following code works well about 65 % of the time (14/40). The problem I encounter happens when
the last element remaining to be sampled from the vector STRATA is within 7
2009 Aug 22
3
Help on comparing two matrices
Hi,
I need to compare two matrices with each other. If you can get one of
them out of the other one by resorting the rows and/or the columns, then
both of them are equal, otherwise they're not. A matrix could look like
this:
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
[1,] 0 1 1 1 0 1 1 0
[2,] 1 1 0 0 0 1 0 1
[3,] 1 0 1 0 0
2010 Mar 23
3
Converting date format
R community:
Hello, I would to like to convert a character date variable from %m/%d/%Y to %m/%d/%y. Any advice would be greatly appreciated. I have tried functions for changing the formatting and removing the unnecessary digits without success.
Mike
2012 May 11
1
summary for weekdays()
Hi all,
probably really simple: I seem to be lacking some understanding for the
character class: I have a bunch of dates in a dataframe and I want to add a
string variable with the weekday for each date. If I use something like
mydata$day <- weekdays (mydata$date), I can create subsets for each weekday
(eg mydata=="Monday"), but summary (mydata$day) doesn't count the instances
for
2007 Dec 13
1
counting weekday in a month in R
Hi,
I am trying to count weekday of the month using R. For example, 1/4/2001
is the 4th weekday of Jan, and 1/5/2001 is the 5th weekday of the month, and
1/8/2001 is the 6th weekday of the month, etc. I get as far as extracting
the weekdays from a sequence of dates (see below). But I have not yet
figured out a fast way of counting without using a For Loop. Does anyone
know how to do such counting
2010 Mar 05
2
How to assign week numbers to a time-series
Hello everyone,
My progress has stalled on finding a way of creating a somewhat complicated variable to add to my existing dataframe and I am hoping one of you could help me out. The dataframe below contains only a fraction of the data of my complete dataframe, but all of the variables. What I want to do is add another variable named 'WEEK' to this dataframe that is assigned 1 for row 1
2010 May 17
6
Change order of columns in table?
I'm an R noob and have a (maybe) stupid question...
I have a table where I have the weekdays and a number for each weekday of
entries:
Thats what the table looks like...
Now I want to have an pie3D plot of this, but obviously the order of the
weekdays are not as one would expect...
Friday Monday Saturday Sunday Thursday Tuesday Wednesday
119 173 80
2009 Oct 28
3
variable labels to accompany data.frame
Often it is useful to keep a "codebook" to document the contents of a dataset. (By "dataset" I mean
a rectangular structure such as a dataframe.)
The codebook has as many rows as the dataset has columns (variables, fields). The columns (fields)
of the codebook may include:
? variable name
? type (character, factor, integer, etc)
? variable label
2017 Jun 05
2
months not working with local language (weekdays does)
For what it's worth, I tried setting my Region | Formats setting to
Spanish (Peru) in Windows 10 Control Panel, and got Spanish weekday and
month results.
I believe on Windows we use the Microsoft C strftime function to produce
these strings, with the %A (for weekday) or %B (for month) formats. So
this question probably needs to be addressed to Microsoft.
Duncan Murdoch
On 05/06/2017
2011 Jul 22
1
Summing daily values by weekday and weekend
(Sorry for reposting. Please delete previous msgs. Thanks!)
Hi, all
Here I created a data frame like
mydates<- seq(as.Date("2010-05-29"), length = 43, by = "day")
myvalues<-runif(43,0,1)
myframe<-data.frame(dates=mydates, day=weekdays(dates), value=myvalues)
dates day value
1 2010-05-29 Saturday 0.14576143
2 2010-05-30 Sunday 0.37669604
2008 Sep 11
5
How to obtain a sequence of dates consisting of only weekdays
Dear R-users,
How do I obtain a sequence of dates consisting of only weekdays without the weekends in R?
In S, I can do the following:
timeSeq(from="12/17/2007", to="8/25/2008", by="weekdays")
I tried using looking at timeSequence (fSeries package) and seq.Date (base package) but I do not know if I can specify "weekdays" rather than "day".
2011 Jul 22
1
Summing values by weekday and weekend - based on daily dates
Hi, all
Here I created a data frame like
mydates<- seq(as.Date("2010-05-29"), length = 43, by = "day")
myvalues<-runif(43,0,1)
myframe<-data.frame(dates=mydates, day=weekdays(dates), value=myvalues)
dates day value
1 2010-05-29 Saturday 0.14576143
2 2010-05-30 Sunday 0.37669604
3 2010-05-31 Monday 0.74813943
4 2010-06-01 Tuesday
2006 Jun 23
3
Problems with weekday extraction from zoo objects
Hi Folks!
I'm struggling with dates - but enough about my personal life.....
I have two daily time series files. In one (x) the date format is Y/m/d
and the other (y) is d/m/y. I used read.zoo on both and they read into
R with no problem.
Then I use: weekdays(as.Date(x$DATE)) and get what I expect - all the
days of the week in my data set.
When I use:
2009 Nov 02
2
how to print the full name of the factors in summary?
Hi,
I am wondering if there is a simple way to fix the problem I am having.
For unknown reason, I could not get the full name of the factors to be
printed in the summary. I have tried to used summary.lm as well but the
problem still persists.
SJ$Weekday <-
2009 Dec 06
1
R ANOVA question
Hi All,
I'm fitting an intercept ANOVA model using R. I'm using following contrast
statement, so my first level is considered as base level.
options(contrasts = c("contr.treatment", "contr.treatment"))
My data has two factors are "Month" and "WeekDay". Due to default alphabetic
ordering, the Month(April) and WeekDay(Friday) are considered as base
2017 Jun 05
2
months not working with local language (weekdays does)
Hi,
I want to reporte some strange behaviour with the "months" function, from
base R.
When using "months" to extract months from a date column, I'm getting the
months in english, when I was expecting months in spanish.
When using "weekdays" to extract days of week from a date column, I'm
getting the the days in spanish (as expected).
My understanding is
2017 Jun 05
0
months not working with local language (weekdays does)
Thank you Duncan and Rui for your time and interest in this issue.
Maybe it is a problem with Windows 7 and Spanish, and not Windows 10.
Let's wait for someone with the same enviroment, before assuming it's a
problem with my PC/configuration.
2017-06-05 14:37 GMT-05:00 Duncan Murdoch <murdoch.duncan at gmail.com>:
> For what it's worth, I tried setting my Region
2017 Jun 05
0
months not working with local language (weekdays does)
Hello,
This doesn't answer the question, but in portuguese it works as expected.
> x <- as.Date("2017-06-05")
> months(x)
[1] "junho"
> weekdays(x)
[1] "segunda-feira"
> sessionInfo()
R version 3.4.0 (2017-04-21)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
Matrix products: default
2010 Mar 17
3
Adding minutes to 24 hour time
Hi,
Does anyone know how to add minutes (up to 100 min) to a 24 hour time, to create a new 24 hour time? I can't seem to find any documentation or examples explaining how to do this. The variables of interest are 'ARRIVE','WAIT', and 'DEPART' in the attached partial dataframe. I want 'DEPART' to be the "sum" of 'ARRIVE' and 'WAIT' in