0

Excuse the horrible title. I don't think I'd be able to summarise this problem in such few words.

So I have a table in R with data whose proportions by row have been calculated using the prop.table function ( prop.table(tab, 1) ). It looks like this:

my R table prop.table(tab, 1)

The row headings (i.e. Q1-00-05, etc.) denote times of the day. The column headings TRUE and FALSE denote whether a particular 999 call was responded to within 10 minutes.

What I need from this table is the proportion of 999 calls responded to efficiently (< 10 mins) between 1800hrs and 0500 hrs.

I tried doing this: tab2<-table(callouts$daytime=="Q4-18-23"|"Q1-00-05", callouts$tenmins) but this proved fruitless. I got an error message saying:

operations are possible only for numeric, logical or complex types

I expected the table to come out with TRUE or FALSE as the row headings (for whether the callout time was within this time frame or not) and TRUE or FALSE as the column headings (for whether the response time was sub-10mins)

Any help would be much appreciated. Thanks!

Mustafa
  • 977
  • 3
  • 12
  • 25
  • Please do not post an image of code/data/errors: it cannot be copied or searched (SEO), it breaks screen-readers, and it may not fit well on some mobile devices. Ref: https://meta.stackoverflow.com/a/285557/3358272 (and https://xkcd.com/2116/). Please just include the code or data (e.g., `dput(head(x))` or `data.frame(...)`) directly. – r2evans Mar 16 '20 at 16:49
  • The `|` operator is logical and expects `logical` vectors on both sides, not strings. We can't help with confidence since you've provided zero data (i.e., what is `callouts`? I can only guess.) Please make this question *reproducible*. This includes sample code, sample *unambiguous* data (e.g., `dput(head(x))` or `data.frame(x=...,y=...)`), and expected output. Refs: https://stackoverflow.com/questions/5963269, https://stackoverflow.com/help/mcve, and https://stackoverflow.com/tags/r/info. – r2evans Mar 16 '20 at 16:51
  • Perhaps `table(callouts$daytime %in% c("Q4-18-23", "Q1-00-05"), ...)`. – r2evans Mar 16 '20 at 16:51

0 Answers0