An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20101018/a0f2e0f5/attachment.pl>
VectorComparison
4 messages · Joshua Wiley, Henrique Dallazuanna, Paolo Agnolucci
Hi,
You might consider ?match For example:
StartDate = as.Date("01/10/2007", "%d/%m/%Y")
TimeSpan = seq(StartDate, by = 'days', length = 40)
TickLabels = as.Date(c("2007-10-01", "2007-11-01", "2007-12-01",
"2008-01-01"), "%Y-%m-%d")
TimeSpan[1:40] == TickLabels # not designed for comparing multiple
values on each side
TickLabels %in% TimeSpan[1:40] # Find which TickLabels are in TimeSpane
TimeSpan[1:40] %in% TickLabels # Find which TimeSpane are in TickLabels
HTH,
Josh
On Mon, Oct 18, 2010 at 5:50 AM, Paolo Agnolucci
<agnolucponr at googlemail.com> wrote:
Hi all, I am not exactly fluent in R and I got stuck with this. I would like to compare each elements of a vector A with any of the elements in Vector B. For some reasons it does not work.
StartDate = as.Date("01/10/2007", "%d/%m/%Y")
TimeSpan = seq(StartDate, by = 'days', length =
length(myAverageCWVs$X1986))
TickLabels = c("2007-10-01", ?"2007-11-01", ?"2007-12-01", ?"2008-01-01")
TimeSpan[1:40] == TickLabels
Here I would expect TRUE for teh first entry and then TRUE for the entry related to "2007-11-01". This doesn't seem to be the case. ?[1] ?TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE [13] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE [25] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE [37] FALSE FALSE FALSE FALSE Thanks you in advance for any help. ? ? ? ?[[alternative HTML version deleted]]
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Joshua Wiley Ph.D. Student, Health Psychology University of California, Los Angeles http://www.joshuawiley.com/
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20101018/1c56f904/attachment.pl>
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20101018/78c91d8d/attachment.pl>