Related
I have data of fish stomach contents (prey items).
In my original df, each fish (with a unique FID) had multiple rows(observations) - one row per unique prey taxon found. For example, if fish #10 had both daphnia and goby in its stomach, there were two rows for that same fish (one row with # of daphnia in that fish's stomach and one row for # of goby in that same stomach); if the fish only had daphnia in their stomach then they had one row; and so on.
I have converted my data from long to wide format to have one observation per row (one unique fish per row).
I am trying to calculate the proportion of empty stomachs by month (when totalnumPrey == 0).
Reproducible data (shortened; complete data has 488 observations):
structure(list(id = c("1001_28", "1001_29", "1001_30", "1001_31",
"1001_32", "1001_33", "1001_34", "1001_35", "1023_3", "614_1",
"614_3", "616_1", "616_3", "616_4", "616_5", "616_6", "824_23",
"824_24", "824_25", "824_26", "824_28", "824_29", "824_30", "824_31",
"824_32", "824_33", "824_35"), CRN = c(1001L, 1001L, 1001L, 1001L,
1001L, 1001L, 1001L, 1001L, 1023L, 614L, 614L, 616L, 616L, 616L,
616L, 616L, 824L, 824L, 824L, 824L, 824L, 824L, 824L, 824L, 824L,
824L, 824L), FID = c(28L, 29L, 30L, 31L, 32L, 33L, 34L, 35L,
3L, 1L, 3L, 1L, 3L, 4L, 5L, 6L, 23L, 24L, 25L, 26L, 28L, 29L,
30L, 31L, 32L, 33L, 35L), ac = c(2L, 2L, 1L, 1L, 1L, 1L, 0L,
0L, 1L, 2L, 2L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 1L), mm = c(200L, 159L, 117L, 120L, 108L, 103L, 92L,
97L, 104L, 301L, 163L, 85L, 271L, 290L, 330L, 294L, 270L, 260L,
266L, 197L, 195L, 185L, 160L, 157L, 178L, 166L, 149L), gr = c(95,
44, 15.1, 16.1, 11, 10, 6.9, 7.9, 10.9, 418, 62, 6.8, 311, 453,
593, 395, 283, 275, 261, 96, 90, 90, 56, 50, 57, 62, 45.5), catch = c(2L,
2L, 4L, 4L, 4L, 4L, 2L, 2L, 1L, 3L, 3L, 1L, 5L, 5L, 5L, 5L, 15L,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 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L), Dreissena = c(0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 1L, 1L, 0L, 0L, 0L, 1L
), Goby = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), Eurycercidae = c(0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), Hirudinea = c(0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), totalnumPrey = c(0, 0, 0,
0, 1, 0, 0, 0, 200, 262, 81, 0, 576, 595, 536, 582, 0, 0, 0,
19, 84, 110, 9, 82, 0, 38, 40), MONTH = c(11L, 11L, 11L, 11L,
11L, 11L, 11L, 11L, 11L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 8L, 8L,
8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L), DAY = c(4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 6L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 18L, 18L,
18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L), empty = c("Empty",
"Empty", "Empty", "Empty", "Not_empty", "Empty", "Empty", "Empty",
"Not_empty", "Not_empty", "Not_empty", "Empty", "Not_empty",
"Not_empty", "Not_empty", "Not_empty", "Empty", "Empty", "Empty",
"Not_empty", "Not_empty", "Not_empty", "Not_empty", "Not_empty",
"Empty", "Not_empty", "Not_empty")), row.names = c(NA, -27L), class = c("data.table",
"data.frame"))
I haven't been able to figure out a way to calculate proportion using counts instead of actual values (since I need to count the 0 values by group and not use the actual 0 value to calculate the proportion).
I have tried the following:
example %>%
group_by(empty, MONTH) %>%
summarise(totalnumPrey = n()) %>%
mutate(prop = n / sum(n))
This gives the following error:
Error in `mutate()`:
! Problem while computing `prop = n/sum(n)`.
ℹ The error occurred in group 1: empty = "Empty".
Caused by error in `sum()`:
! invalid 'type' (closure) of argument
I also tried this:
transform(example,
perc = ave(totalnumPrey,
empty,
FUN = prop.table))
but this doesn't give me what I need...
Also this:
example %>%
group_by(MONTH) %>%
summarise(n = n()) %>%
mutate(freq = n / sum(n))
which gives me proportion by month, not what I need (i.e. for June it's doing 127/362 = 0.35)...
I have tried many other ways from examples I found in other SO posts but still can't get what I need.
Is there a way I can calculate the proportion of empty vs non-empty stomachs by month?
I also need to do this for each prey type/taxon. For example, proportion of individual fish that contain "Isopod" and so on for each unique taxon in my data. Presence/absence type of proportions.
I mainly want to do this by month first, but will eventually use other groupings.
When I had the data in long format, I was able to calculate proportion of each prey item within one fish stomach by using:
transform(a,
perc = ave(number,
id,
FUN = prop.table))
data not included here.. but 'number' here being the total count of each unique prey taxa/group per stomach/fish & 'id' unique identifier I created to distinguish between different fish (since there were multiple rows for same fish).
I am happy to clarify anything that is not clear or add additional data if needed.
I have searched online and in SO for a few days but still can't figure this out.
Thank you in advance.
I think this is what you need.
What we need to do is to count the number of times the column empty is equal to "Empty" per each group - so we can do this using sum(empty=="Empty") and then divide by the number of rows in that group n().
library(dplyr)
dat %>%
group_by(MONTH) %>%
summarise(
prop_empty = sum(empty=="Empty")/n(),
prop_not_empy = sum(empty != "Empty")/n()
)
# A tibble: 3 × 3
MONTH prop_empty prop_not_empy
<int> <dbl> <dbl>
1 6 0.143 0.857
2 8 0.364 0.636
3 11 0.778 0.222
I've tried to complete an ANOSIM with data on a study I have carried out but I get multiple errors and i'm not sure how to fix it. Most of the errors are "dissimilarities have 24 observations, but grouping has 23". I'm trying to see the similarity in community structure between multiple samples.
my code so far is
setwd()
#load invertebrate data
Invertebrates<- read.csv(file="Invertebrates.csv",head=TRUE,sep=",")
#install packages
install.packages("vegan")
library(vegan)
#make community matrix
com<-Invertebrates[,2:ncol(Invertebrates)]
m_com<-as.matrix(com)
# group by site
group=Invertebrates[,1]
#ANOSIM
invert.ano<-anosim(m_com,group)
Then I get
Error in anosim(m_com, group) : there should be replicates within groups
Thanks for any help
Invertebrates <- structure(list(Site = structure(c(10L, 14L, 6L, 3L, 24L, 12L, 7L, 18L, 1L, 8L, 15L, 5L, 16L, 23L, 4L, 11L, 21L, 19L, 9L, 13L
), .Label = c("Anax parthenope", "Anisus vortex", "Asellus aquaticus",
"Bathyomphalus contortus", "Bithynia leachii", "Bithynia tentaculata",
"Coenagrion pulchellum", "Corixa punctata", "Dytiscus marginalis",
"Gammarus pulex", "Gyraulus albus", "Haliplus fluviatilis", "Haplotaxis gordioides",
"Ilyocoris cimicoides", "Lymnaea stagnalis", "Lymnaea truncatula",
"Oxygastra curtisii", "Physa fontilnalis", "Piscicola geometra",
"Planorbis cornatus", "Planorbis planorbis", "Radix ovata", "Radix palustris",
"Sialis lutaria"), class = "factor"), Finglesham.Brook.A = c(112L,
1L, 3L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L), Betteshanger.Pond.A = c(0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), Betteshanger.Pond.B = c(0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L), Great.Mongeham.A = c(7L, 0L, 0L, 2L, 2L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), Site.7.SS.A = c(6L,
0L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L, 1L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 2L),
Adelaide.SS.A = c(8L, 0L, 0L, 33L, 9L, 0L, 0L, 0L, 0L, 0L,
0L, 12L, 0L, 4L, 19L, 7L, 4L, 0L, 2L, 0L), Adelaide.SS.B = c(4L,
0L, 20L, 9L, 2L, 0L, 0L, 0L, 0L, 0L, 7L, 0L, 0L, 0L, 14L,
0L, 1L, 0L, 0L, 0L), Ham.Fen.SS = c(1L, 0L, 0L, 6L, 3L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L),
Adelaide.NS.B = c(3L, 0L, 0L, 8L, 0L, 6L, 1L, 0L, 0L, 2L,
0L, 0L, 0L, 0L, 0L, 0L, 12L, 0L, 1L, 0L), Site.6.NS.A = c(58L,
0L, 0L, 2L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L), S3.Broad.dike.SS.A = c(24L, 0L, 0L, 50L,
0L, 0L, 3L, 13L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L), Little.Downs.Bridge.A = c(10L, 16L, 23L, 46L, 0L,
0L, 2L, 0L, 0L, 4L, 0L, 0L, 0L, 0L, 4L, 0L, 5L, 0L, 0L, 0L
)), row.names = c(NA, 20L), class = "data.frame")
If you run
table(Invertebrates$Site)
you will see that there you're grouping variable is not actually grouping anything. That is, there is maximum one observation per group. But ANOSIM requires the data to be grouped.
If I just make up a random grouping variable, like this:
Invertebrates$Group <- sample(c(1,2), nrow(Invertebrates), replace = TRUE)
and rerun your analysis:
Invertebrates$Group <- sample(c(1,2), nrow(Invertebrates), replace = TRUE)
group <- Invertebrates[, "Group"]
invert.ano <- anosim(m_com, group)
It works!
I've been working on this dataset for a while now so I hope I can get some help. I would like to simplify my question to:
How can I select rows having the following time-stamped pattern in column Time: **/**/**** **:**:00?
Hope I was clear! I can attach a head() sample below:
> head(dataraw)
Time ACTIVITY_X ACTIVITY_Y ACTIVITY_Z Vigilance Head-up Grazing Browsing Moving
1: 17/06/2018 09:36:00 34.333333 19.666667 40.000000 0 150 0 35 27
2: 17/06/2018 09:37:20 9.666667 7.000000 12.333333 0 185 0 0 26
3: 17/06/2018 09:38:40 7.333333 4.000000 8.666667 0 168 0 0 11
4: 17/06/2018 09:40:00 14.000000 9.333333 17.333333 0 99 58 0 11
5: 17/06/2018 09:41:20 19.000000 13.000000 23.333333 0 37 124 0 11
6: 17/06/2018 09:42:40 23.000000 14.000000 27.000000 0 8 196 0 0
Grooming Resting Fleeing Unknown End
1: 17 0 0 11 0
2: 23 0 0 6 0
3: 30 0 0 31 0
4: 35 0 0 37 0
5: 31 0 0 37 0
6: 17 0 0 19 0
Find attached a sample below:
> dput(dataraw[(1:280),])
structure(list(Time = c("17/06/2018 09:36:00", "17/06/2018 09:37:20",
"17/06/2018 09:38:40", "17/06/2018 09:40:00", "17/06/2018 09:41:20",
"17/06/2018 09:42:40", "17/06/2018 09:44:00", "17/06/2018 09:45:20",
"17/06/2018 09:46:40", "17/06/2018 09:48:00", "17/06/2018 09:49:20",
"17/06/2018 09:50:40", "17/06/2018 09:52:00", "17/06/2018 09:53:20",
"17/06/2018 09:54:40", "17/06/2018 09:56:00", "17/06/2018 09:57:20",
"17/06/2018 09:58:40", "17/06/2018 10:00:00", "17/06/2018 10:01:20",
"17/06/2018 10:02:40", "17/06/2018 10:04:00", "17/06/2018 10:05:20",
"17/06/2018 10:06:40", "17/06/2018 10:08:00", "17/06/2018 10:09:20",
"17/06/2018 10:10:40", "17/06/2018 10:12:00", "17/06/2018 10:13:20",
"17/06/2018 10:14:40", "17/06/2018 10:16:00", "17/06/2018 10:17:20",
"17/06/2018 10:18:40", "17/06/2018 10:20:00", "17/06/2018 10:21:20",
"17/06/2018 10:22:40", "17/06/2018 10:24:00", "17/06/2018 10:25:20",
"17/06/2018 10:26:40", "17/06/2018 10:28:00", "17/06/2018 10:29:20",
"17/06/2018 10:30:40", "17/06/2018 10:32:00", "17/06/2018 10:33:20",
"17/06/2018 10:34:40", "17/06/2018 10:36:00", "17/06/2018 10:37:20",
"17/06/2018 10:38:40", "17/06/2018 10:40:00", "17/06/2018 10:41:20",
"17/06/2018 10:42:40", "17/06/2018 10:44:00", "17/06/2018 10:45:20",
"17/06/2018 10:46:40", "17/06/2018 10:48:00", "17/06/2018 10:49:20",
"17/06/2018 10:50:40", "17/06/2018 10:52:00", "17/06/2018 10:53:20",
"17/06/2018 10:54:40", "17/06/2018 10:56:00", "17/06/2018 10:57:20",
"17/06/2018 10:58:40", "17/06/2018 11:00:00", "17/06/2018 11:01:20",
"17/06/2018 11:02:40", "17/06/2018 11:04:00", "17/06/2018 11:05:20",
"17/06/2018 11:06:40", "17/06/2018 11:08:00", "17/06/2018 11:09:20",
"17/06/2018 11:10:40", "17/06/2018 11:12:00", "17/06/2018 11:13:20",
"17/06/2018 11:14:40", "17/06/2018 11:16:00", "17/06/2018 11:17:20",
"17/06/2018 11:18:40", "17/06/2018 11:20:00", "17/06/2018 11:21:20",
"17/06/2018 11:22:40", "17/06/2018 11:24:00", "17/06/2018 11:25:20",
"17/06/2018 11:26:40", "17/06/2018 11:28:00", "17/06/2018 11:29:20",
"17/06/2018 11:30:40", "17/06/2018 11:32:00", "17/06/2018 11:33:20",
"17/06/2018 11:34:40", "17/06/2018 11:36:00", "17/06/2018 11:37:20",
"17/06/2018 11:38:40", "17/06/2018 11:40:00", "17/06/2018 11:41:20",
"17/06/2018 11:42:40", "17/06/2018 11:44:00", "17/06/2018 11:45:20",
"17/06/2018 11:46:40", "17/06/2018 11:48:00", "17/06/2018 11:49:20",
"17/06/2018 11:50:40", "17/06/2018 11:52:00", "17/06/2018 11:53:20",
"17/06/2018 11:54:40", "17/06/2018 11:56:00", "17/06/2018 11:57:20",
"17/06/2018 11:58:40", "17/06/2018 12:00:00", "17/06/2018 12:01:20",
"17/06/2018 12:02:40", "17/06/2018 12:04:00", "17/06/2018 12:05:20",
"17/06/2018 12:06:40", "17/06/2018 12:08:00", "17/06/2018 12:09:20",
"17/06/2018 12:10:40", "17/06/2018 12:12:00", "17/06/2018 12:13:20",
"17/06/2018 12:14:40", "17/06/2018 12:16:00", "17/06/2018 12:17:20",
"17/06/2018 12:18:40", "17/06/2018 12:20:00", "17/06/2018 12:21:20",
"17/06/2018 12:22:40", "17/06/2018 12:24:00", "17/06/2018 12:25:20",
"17/06/2018 12:26:40", "17/06/2018 12:28:00", "17/06/2018 12:29:20",
"17/06/2018 12:30:40", "17/06/2018 12:32:00", "17/06/2018 12:33:20",
"17/06/2018 12:34:40", "17/06/2018 12:36:00", "17/06/2018 12:37:20",
"17/06/2018 12:38:40", "17/06/2018 12:40:00", "17/06/2018 12:41:20",
"17/06/2018 12:42:40", "17/06/2018 12:44:00", "17/06/2018 12:45:20",
"17/06/2018 12:46:40", "17/06/2018 12:48:00", "17/06/2018 12:49:20",
"17/06/2018 12:50:40", "17/06/2018 12:52:00", "17/06/2018 12:53:20",
"17/06/2018 12:54:40", "17/06/2018 12:56:00", "17/06/2018 12:57:20",
"17/06/2018 12:58:40", "17/06/2018 13:00:00", "17/06/2018 13:01:20",
"17/06/2018 13:02:40", "17/06/2018 13:04:00", "17/06/2018 13:05:20",
"17/06/2018 13:06:40", "17/06/2018 13:08:00", "17/06/2018 13:09:20",
"17/06/2018 13:10:40", "17/06/2018 13:12:00", "17/06/2018 13:13:20",
"17/06/2018 13:14:40", "17/06/2018 13:16:00", "17/06/2018 13:17:20",
"17/06/2018 13:18:40", "17/06/2018 13:20:00", "17/06/2018 13:21:20",
"17/06/2018 13:22:40", "17/06/2018 13:24:00", "17/06/2018 13:25:20",
"17/06/2018 13:26:40", "17/06/2018 13:28:00", "17/06/2018 13:29:20",
"17/06/2018 13:30:40", "17/06/2018 13:32:00", "17/06/2018 13:33:20",
"17/06/2018 13:34:40", "17/06/2018 13:36:00", "17/06/2018 13:37:20",
"17/06/2018 13:38:40", "17/06/2018 13:40:00", "17/06/2018 13:41:20",
"17/06/2018 13:42:40", "17/06/2018 13:44:00", "17/06/2018 13:45:20",
"17/06/2018 13:46:40", "17/06/2018 13:48:00", "17/06/2018 13:49:20",
"17/06/2018 13:50:40", "17/06/2018 13:52:00", "17/06/2018 13:53:20",
"17/06/2018 13:54:40", "17/06/2018 13:56:00", "17/06/2018 13:57:20",
"17/06/2018 13:58:40", "17/06/2018 14:00:00", "17/06/2018 14:01:20",
"17/06/2018 14:02:40", "17/06/2018 14:04:00", "17/06/2018 14:05:20",
"17/06/2018 14:06:40", "17/06/2018 14:08:00", "17/06/2018 14:09:20",
"17/06/2018 14:10:40", "17/06/2018 14:12:00", "17/06/2018 14:13:20",
"17/06/2018 14:14:40", "17/06/2018 14:16:00", "17/06/2018 14:17:20",
"17/06/2018 14:18:40", "17/06/2018 14:20:00", "17/06/2018 14:21:20",
"17/06/2018 14:22:40", "17/06/2018 14:24:00", "17/06/2018 14:25:20",
"17/06/2018 14:26:40", "17/06/2018 14:28:00", "17/06/2018 14:29:20",
"17/06/2018 14:30:40", "17/06/2018 14:32:00", "17/06/2018 14:33:20",
"17/06/2018 14:34:40", "17/06/2018 14:36:00", "17/06/2018 14:37:20",
"17/06/2018 14:38:40", "17/06/2018 14:40:00", "17/06/2018 14:41:20",
"17/06/2018 14:42:40", "17/06/2018 14:44:00", "17/06/2018 14:45:20",
"17/06/2018 14:46:40", "17/06/2018 14:48:00", "17/06/2018 14:49:20",
"17/06/2018 14:50:40", "17/06/2018 14:52:00", "17/06/2018 14:53:20",
"17/06/2018 14:54:40", "17/06/2018 14:56:00", "17/06/2018 14:57:20",
"17/06/2018 14:58:40", "17/06/2018 15:00:00", "17/06/2018 15:01:20",
"17/06/2018 15:02:40", "17/06/2018 15:04:00", "17/06/2018 15:05:20",
"17/06/2018 15:06:40", "17/06/2018 15:08:00", "17/06/2018 15:09:20",
"17/06/2018 15:10:40", "17/06/2018 15:12:00", "17/06/2018 15:13:20",
"17/06/2018 15:14:40", "17/06/2018 15:16:00", "17/06/2018 15:17:20",
"17/06/2018 15:18:40", "17/06/2018 15:20:00", "17/06/2018 15:21:20",
"17/06/2018 15:22:40", "17/06/2018 15:24:00", "17/06/2018 15:25:20",
"17/06/2018 15:26:40", "17/06/2018 15:28:00", "17/06/2018 15:29:20",
"17/06/2018 15:30:40", "17/06/2018 15:32:00", "17/06/2018 15:33:20",
"17/06/2018 15:34:40", "17/06/2018 15:36:00", "17/06/2018 15:37:20",
"17/06/2018 15:38:40", "17/06/2018 15:40:00", "17/06/2018 15:41:20",
"17/06/2018 15:42:40", "17/06/2018 15:44:00", "17/06/2018 15:45:20",
"17/06/2018 15:46:40", "17/06/2018 15:48:00"), ACTIVITY_X = c(34.33333333,
9.666666667, 7.333333333, 14, 19, 23, 21, 21, 21.33333333, 22.66666667,
20.66666667, 17.66666667, 19.66666667, 32.66666667, 51.33333333,
88, 105, 101, 68.33333333, 62.33333333, 85.66666667, 98.33333333,
105.3333333, 91, 107, 99, 92.66666667, 98, 110.6666667, 120,
104, 110.3333333, 132, 148.6666667, 130, 110.6666667, 89.66666667,
92, 88.66666667, 88.66666667, 90.33333333, 100, 100, 87.66666667,
71.33333333, 67.33333333, 65.33333333, 63, 66.66666667, 68.33333333,
67, 63.33333333, 71.66666667, 80.66666667, 95.33333333, 109.6666667,
122.3333333, 110, 84.66666667, 59.66666667, 59, 70.66666667,
86.66666667, 93, 95, 86, 78.66666667, 69, 73.66666667, 72.66666667,
69.66666667, 49, 42.66666667, 43.66666667, 53.33333333, 48.33333333,
46.33333333, 47.66666667, 54.66666667, 58, 54, 52.33333333, 56.66666667,
58, 60.33333333, 62, 72, 83, 94, 93, 98, 82.33333333, 83, 73,
79.66666667, 75.66666667, 63, 45.33333333, 48.33333333, 44.66666667,
44.66666667, 32, 35.33333333, 38, 39.33333333, 42.33333333, 35,
40.66666667, 49.66666667, 71.33333333, 80.33333333, 76.66666667,
66.66666667, 48.66666667, 38.33333333, 46.66666667, 58, 72.33333333,
68, 71.33333333, 65.66666667, 64.66666667, 54.33333333, 52.66666667,
49.66666667, 57.66666667, 64.66666667, 78.66666667, 83.33333333,
86, 83.66666667, 82.66666667, 77.33333333, 68.33333333, 73.33333333,
76, 72, 50, 47, 50.66666667, 59, 48.33333333, 39.33333333, 35,
35.33333333, 40, 37.66666667, 41.66666667, 40.66666667, 37.66666667,
30.33333333, 25, 24, 24.33333333, 25.66666667, 34.33333333, 37,
36.33333333, 31, 35.66666667, 37.33333333, 42, 37, 39.66666667,
38, 41.66666667, 45.66666667, 40.66666667, 38.66666667, 30, 36.33333333,
55.66666667, 60.66666667, 64.33333333, 48.66666667, 49.33333333,
46.33333333, 45, 47.33333333, 51.33333333, 48.33333333, 40.33333333,
32.66666667, 38.33333333, 44, 47, 49.33333333, 44.33333333, 41.66666667,
34.33333333, 37.66666667, 37.66666667, 37.33333333, 35, 30.66666667,
30, 34.66666667, 46.33333333, 55.66666667, 62.66666667, 98.66666667,
118.6666667, 111, 73.33333333, 55, 54.66666667, 53, 50.66666667,
52.33333333, 58, 55.66666667, 62.66666667, 63.33333333, 66, 60,
54, 47, 44, 40.66666667, 46.33333333, 45.66666667, 50, 46, 45.33333333,
44, 38, 36, 36, 40.66666667, 43, 57, 79, 80.66666667, 64, 35.33333333,
33.33333333, 27.33333333, 35, 33, 34.66666667, 27.33333333, 21,
29.66666667, 32.66666667, 43.33333333, 46.33333333, 54, 55, 37.66666667,
20, 7.666666667, 14, 30.66666667, 33, 29, 17.33333333, 14.66666667,
9.333333333, 14.66666667, 17.66666667, 24.66666667, 17, 18.33333333,
26.33333333, 50, 80.66666667, 97.66666667, 107.6666667, 94.33333333,
76.66666667, 64.66666667, 68.33333333, 65.33333333, 51, 30.33333333,
24.66666667, 20.66666667, 22.33333333, 29.33333333, 46), ACTIVITY_Y = c(19.66666667,
7, 4, 9.333333333, 13, 14, 10, 10.66666667, 12.33333333, 17.33333333,
14.33333333, 11.66666667, 11, 25, 57.33333333, 94.66666667, 123,
109.3333333, 76.33333333, 58, 68, 73.66666667, 75, 63, 69, 58,
57.66666667, 70.66666667, 89, 96.66666667, 84.33333333, 92.66666667,
111, 125.3333333, 121.6666667, 120.3333333, 115.6666667, 102.6666667,
102.6666667, 111.6666667, 110, 104.3333333, 91, 85, 79.33333333,
79.66666667, 76, 58.66666667, 57.33333333, 63.66666667, 79, 80,
97.33333333, 98.33333333, 94.66666667, 89, 84.66666667, 111,
95, 92, 70, 95.33333333, 109, 100.3333333, 80.66666667, 69, 75.33333333,
68, 74, 64.33333333, 65.33333333, 40, 34, 32.33333333, 41, 39.66666667,
38.33333333, 38, 40, 41.33333333, 37.66666667, 34.66666667, 49.33333333,
56.33333333, 61, 53, 55.66666667, 79.33333333, 90.33333333, 113,
147, 141.6666667, 128, 70.66666667, 58.33333333, 46.33333333,
47.66666667, 41.66666667, 55.66666667, 50.33333333, 53.66666667,
29.66666667, 34.66666667, 35.33333333, 41.33333333, 45.66666667,
38, 48.33333333, 53, 80, 92, 97.33333333, 75.33333333, 47.66666667,
30.66666667, 56.33333333, 67.66666667, 98, 79, 78.66666667, 62.66666667,
69, 66.33333333, 51.33333333, 56, 90.33333333, 103, 102.6666667,
78.33333333, 80, 81, 73, 62.33333333, 55.33333333, 61.33333333,
64.66666667, 58.33333333, 44.33333333, 47.33333333, 52.33333333,
68.33333333, 53, 39, 21, 22.66666667, 28.66666667, 24.66666667,
26.33333333, 25.33333333, 23.33333333, 21.33333333, 17, 20.33333333,
19.66666667, 20.66666667, 35.33333333, 39, 37, 21, 24.33333333,
27.66666667, 32, 25.33333333, 27, 24.66666667, 25, 28.33333333,
27.33333333, 31, 23, 29.33333333, 57.66666667, 61.33333333, 64,
38, 40, 40, 38, 37.66666667, 34.66666667, 34.33333333, 31, 27,
25.66666667, 31, 33.66666667, 38.66666667, 33, 29.66666667, 21,
21.33333333, 21, 22.66666667, 22.66666667, 21.66666667, 20.66666667,
22, 30.33333333, 50.66666667, 76.33333333, 141.6666667, 169,
151, 87, 45.66666667, 38.33333333, 33.66666667, 32, 31.66666667,
36, 32.33333333, 35.66666667, 38.66666667, 44.33333333, 46, 40.66666667,
32, 26.66666667, 21, 30, 31, 35.66666667, 31.33333333, 28.33333333,
22.66666667, 17, 16, 23.33333333, 31.33333333, 65, 95.33333333,
98, 74, 37.66666667, 29, 23.66666667, 22.33333333, 34.33333333,
39, 45.33333333, 32, 21.33333333, 26, 30.33333333, 37.33333333,
35, 49.33333333, 56.33333333, 42.66666667, 19.33333333, 4.333333333,
8.666666667, 22.33333333, 23.66666667, 21, 9, 6.666666667, 3.666666667,
11.66666667, 15.33333333, 20.66666667, 17, 28.66666667, 46, 76.66666667,
95.66666667, 108, 103.3333333, 90.33333333, 62.66666667, 48.33333333,
52, 52, 40.33333333, 20.33333333, 22.66666667, 21.33333333, 22,
26.66666667, 52), ACTIVITY_Z = c(40, 12.33333333, 8.666666667,
17.33333333, 23.33333333, 27, 23, 23.33333333, 24.66666667, 28.66666667,
25.66666667, 21.66666667, 22.66666667, 41, 77.66666667, 130,
162.6666667, 149.3333333, 103, 85.33333333, 109.6666667, 123.3333333,
129.6666667, 111, 127.6666667, 115, 109.6666667, 121.3333333,
142, 154, 133.6666667, 144, 172.3333333, 194.3333333, 179.3333333,
165, 146.6666667, 138.3333333, 136.3333333, 143.3333333, 143.6666667,
145.6666667, 135.3333333, 122, 107, 104.6666667, 100.6666667,
86.66666667, 88, 93.66666667, 104, 102.3333333, 121, 127.3333333,
136, 142, 149, 160.6666667, 131, 110.3333333, 91.66666667, 119,
139.6666667, 138.6666667, 125.6666667, 111, 109.3333333, 97,
104.6666667, 97.66666667, 96, 63.33333333, 54.66666667, 54.33333333,
67.33333333, 62.33333333, 60, 61, 68, 71.33333333, 65.66666667,
62.66666667, 76, 82, 86.33333333, 82, 91, 115.3333333, 130.6666667,
147.3333333, 179, 164.3333333, 153.6666667, 103, 100.3333333,
89, 80, 61.66666667, 74, 67.33333333, 69.66666667, 43.66666667,
49.66666667, 52, 57, 62.33333333, 52, 63.33333333, 73, 107.3333333,
122.3333333, 124, 102, 69.33333333, 49.33333333, 73.33333333,
89.33333333, 122.6666667, 105.6666667, 108, 91.33333333, 95,
85.66666667, 74, 76, 109.6666667, 123, 132, 114.3333333, 117.6666667,
116.6666667, 110.6666667, 99.66666667, 88.33333333, 96, 100,
92.66666667, 67, 66.66666667, 72.66666667, 90.66666667, 72.66666667,
57, 40.66666667, 42, 49, 45, 49.33333333, 48, 44.66666667, 37.66666667,
31, 31.66666667, 31.33333333, 33, 50, 54.33333333, 52.66666667,
37.66666667, 43.33333333, 46.33333333, 52.66666667, 44.66666667,
48, 45.33333333, 48.66666667, 53.66666667, 49, 49.66666667, 38,
46.66666667, 80.66666667, 87, 91.66666667, 62, 63.66666667, 61.33333333,
59, 60.66666667, 62, 59.33333333, 51, 42.33333333, 46, 53.66666667,
57.66666667, 62.66666667, 55.33333333, 51.33333333, 40.33333333,
43.33333333, 43.33333333, 44, 42, 37.66666667, 36.33333333, 41,
55.33333333, 76.33333333, 99.66666667, 172.6666667, 206.6666667,
187.6666667, 114.3333333, 72, 67, 62.66666667, 60, 61.33333333,
68.66666667, 65, 72.66666667, 75, 80, 75.66666667, 67.66666667,
57.33333333, 52, 46, 55.33333333, 55.33333333, 61.33333333, 55.66666667,
53.33333333, 49.66666667, 41.66666667, 39.66666667, 43.33333333,
51.66666667, 80.66666667, 113, 133.3333333, 113.3333333, 75.33333333,
46, 41, 35.33333333, 49.33333333, 51.33333333, 57.33333333, 42.66666667,
30.33333333, 39.33333333, 44.66666667, 57.33333333, 58.33333333,
74, 79.66666667, 57.66666667, 28.33333333, 9, 16.66666667, 38.33333333,
41, 36, 19.66666667, 16, 10, 19, 23.66666667, 32.33333333, 24.33333333,
34.66666667, 53, 91.66666667, 125.6666667, 146, 149.3333333,
130.6666667, 99.33333333, 81, 86, 83.33333333, 65, 36.33333333,
34, 30, 31.66666667, 39.66666667, 69.66666667), Vigilance = c(0L,
0L, 0L, 0L, 0L, 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240L, 240L, 240L, 240L, 240L, 240L, 240L,
240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L,
240L, 240L, 240L, 240L, 240L, 179L, 99L, 19L, 0L, 0L, 69L, 149L,
229L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L,
240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L,
240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L,
240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L,
240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L,
240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L,
240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L,
240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L,
240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L,
240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L,
240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L,
240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L,
240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L,
240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L,
240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L,
240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 199L,
119L, 39L, 0L, 0L, 41L, 121L, 201L, 240L, 199L, 119L, 39L, 0L,
79L, 159L, 198L, 133L, 112L, 107L, 173L, 194L, 240L, 240L, 240L,
240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L,
240L, 240L, 240L, 240L, 199L, 119L, 39L, 0L)), row.names = c(NA,
-280L), class = c("data.table", "data.frame"), .internal.selfref = <pointer: 0x0000000002631ef0>)
We can use:
df[grep(":00$",df$Time),]
Results(truncated for visibility):
head(df[grep(":00$",df$Time),1:4])
Time ACTIVITY_X ACTIVITY_Y ACTIVITY_Z
1: 17/06/2018 09:36:00 34.33333 19.666667 40.00000
2: 17/06/2018 09:40:00 14.00000 9.333333 17.33333
3: 17/06/2018 09:44:00 21.00000 10.000000 23.00000
4: 17/06/2018 09:48:00 22.66667 17.333333 28.66667
5: 17/06/2018 09:52:00 19.66667 11.000000 22.66667
6: 17/06/2018 09:56:00 88.00000 94.666667 130.00000
Here are a couple ways to do it in base R if you wanted to convert your column to date/time class. I edited it to create needless columns instead of just converting your time column to show different ways to use POSIXt classes. There are pros and cons to using either. From my understanding using lt is usually a little slower but you can access the time elements using $ b/c it is a named list. Check out ?POSIXlt for a better understanding of both
df1$Timelt <- as.POSIXlt(df1$Time, format = "%d/%m/%Y %H:%M:%S")
df1$Timect <- as.POSIXct(df1$Time, format = "%d/%m/%Y %H:%M:%S")
df1[format(df1$Timect, "%S") == "00",]
df1[df1$Timelt$s == 00,]
df1[format(df1$Timelt, "%S") == "00",]
head(df1[df1$Timelt$sec == 00,])
Time ACTIVITY_X ACTIVITY_Y ACTIVITY_Z Vigilance Head-up Grazing Browsing Moving Grooming
1 17/06/2018 09:36:00 34.33333 19.666667 40.00000 0 150 0 35 27 17
4 17/06/2018 09:40:00 14.00000 9.333333 17.33333 0 99 58 0 11 35
7 17/06/2018 09:44:00 21.00000 10.000000 23.00000 0 8 205 0 0 7
10 17/06/2018 09:48:00 22.66667 17.333333 28.66667 0 0 38 0 10 4
13 17/06/2018 09:52:00 19.66667 11.000000 22.66667 0 41 0 0 0 0
16 17/06/2018 09:56:00 88.00000 94.666667 130.00000 7 225 0 0 0 8
Resting Fleeing Unknown End Timelt Timect
1 0 0 11 0 2018-06-17 09:36:00 2018-06-17 09:36:00
4 0 0 37 0 2018-06-17 09:40:00 2018-06-17 09:40:00
7 0 0 20 0 2018-06-17 09:44:00 2018-06-17 09:44:00
10 0 0 77 111 2018-06-17 09:48:00 2018-06-17 09:48:00
13 0 0 0 199 2018-06-17 09:52:00 2018-06-17 09:52:00
16 0 0 0 0 2018-06-17 09:56:00 2018-06-17 09:56:00
I am quite new to R world. I'm currently working on a flight delay prediction.
I'm getting "object 'date01-01-2004' not found" even though it is present.
I tried converting all the factors into dummy variables and doing random forest on it.
library(caret)
library(dummies)
library(randomForest)
flight<-read.csv("E:\\Rdata\\FlightDelays.csv",header = TRUE)
summary(flight$dest)
summary(flight$carrier)
plot(flight$delay~flight$carrier,ylab="delay",xlab="carrier")
plot(flight$delay~flight$dest,ylab="delay",xlab="destination")
plot(flight$delay~flight$origin,ylab="delay",xlab="origin")
plot(flight$delay~flight$dayweek,ylab="delay",xlab="dayweek")
str(flight)
flight$tailnu<-NULL
fl1<-flight$delay
flight$delay<-NULL
flight<-dummy.data.frame(data=flight)
dput(head(flight,50))
flight$delay<-fl1
rf1<-randomForest(delay~.,data=flight)
The output should not be an error and random forest computed one.But I'm getting following output even though it contains date01-01-200 .
structure(list(schedtime = c(1455L, 1640L, 1245L, 1715L, 1039L,
840L, 1240L, 1645L, 1715L, 2120L, 2120L, 1455L, 930L, 1230L,
1430L, 1730L, 2030L, 1530L, 600L, 1830L, 900L, 1300L, 1400L,
1500L, 1900L, 850L, 900L, 1100L, 1300L, 1500L, 1700L, 2100L,
1455L, 1720L, 1030L, 700L, 1300L, 1730L, 840L, 1710L, 1245L,
2120L, 1700L, 1900L, 1525L, 1900L, 1400L, 1515L, 1300L, 1630L
), carrierCO = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L), carrierDH = c(0L, 1L, 1L,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(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L), carrierUS = c(0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), deptime = c(1455L,
1640L, 1245L, 1709L, 1035L, 839L, 1243L, 1644L, 1710L, 2129L,
2114L, 1458L, 932L, 1228L, 1429L, 1728L, 2029L, 1525L, 556L,
1822L, 853L, 1254L, 1356L, 1452L, 1853L, 841L, 858L, 1056L, 1253L,
1458L, 1655L, 2055L, 1452L, 1710L, 1030L, 656L, 1256L, 1726L,
840L, 1704L, 1245L, 2118L, 1651L, 1850L, 1521L, 1855L, 1357L,
1508L, 1255L, 1625L), destEWR = c(0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), destJFK = c(1L,
1L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 0L, 1L, 0L, 0L, 0L, 0L, 0L,
1L, 1L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L), destLGA = c(0L, 0L, 1L, 1L, 1L, 0L, 0L, 0L, 0L, 0L, 1L,
0L, 1L, 1L, 1L, 1L, 1L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L), distance = c(184L, 213L, 229L, 229L,
229L, 228L, 228L, 228L, 228L, 228L, 229L, 213L, 214L, 214L, 214L,
214L, 214L, 213L, 213L, 213L, 214L, 214L, 214L, 214L, 214L, 229L,
214L, 214L, 214L, 214L, 214L, 214L, 169L, 169L, 169L, 169L, 199L,
199L, 213L, 213L, 213L, 213L, 213L, 213L, 199L, 199L, 199L, 213L,
213L, 199L), `date01-01-2004` = c(1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), `date01-02-2004` = c(0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L), `date01-03-2004` = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L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, 0L), `date1/28/2004` = c(0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L), `date1/29/2004` = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), `date1/30/2004` = c(0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L), `date1/31/2004` = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), flightnumber = c(5935L,
6155L, 7208L, 7215L, 7792L, 7800L, 7806L, 7810L, 7812L, 7814L,
7924L, 746L, 1746L, 1752L, 1756L, 1762L, 1768L, 4752L, 4760L,
4784L, 4956L, 4964L, 4966L, 4968L, 4976L, 846L, 2164L, 2168L,
2172L, 2176L, 2180L, 2188L, 2403L, 2675L,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L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L), daymonth = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L)), .Names = c("schedtime", "carrierCO",
"carrierDH", "carrierDL", "carrierMQ", "carrierOH", "carrierRU",
"carrierUA", "carrierUS", "deptime", "destEWR", "destJFK", "destLGA",
"distance", "date01-01-2004", "date01-02-2004", "date01-03-2004",
"date01-04-2004", "date01-05-2004", "date01-06-2004", "date01-07-2004",
"date01-08-2004", "date01-09-2004", "date01-10-2004", "date01-11-2004",
"date01-12-2004", "date1/13/2004", "date1/14/2004", "date1/15/2004",
"date1/16/2004", "date1/17/2004", "date1/18/2004", "date1/19/2004",
"date1/20/2004", "date1/21/2004", "date1/22/2004", "date1/23/2004",
"date1/24/2004", "date1/25/2004", "date1/26/2004", "date1/27/2004",
"date1/28/2004", "date1/29/2004", "date1/30/2004", "date1/31/2004",
"flightnumber", "originBWI", "originDCA", "originIAD", "weather",
"dayweek", "daymonth"), dummies = structure(list(carrier = 2:9,
dest = 11:13, date = 15:45, origin = 47:49), .Names = c("carrier",
"dest", "date", "origin")), row.names = c("1", "2", "3", "4",
"5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15",
"16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26",
"27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37",
"38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48",
"49", "50"), class = "data.frame")
Error in eval(predvars, data, env) : object 'date01-01-2004' not found
My guess (strongly supported by the example below) is that randomForest() can't handle non-syntactic variable/column names, i.e. ones with spaces or punctuation other than dots in them. You could try names(flight) <- make.names(names(flight)) to fix this. It's surprising that read.csv() didn't already fix the names for you: are you sure you didn't use readr::read_csv() instead?
library(randomForest)
## make up random frame with OK names
dd <- data.frame(y=rnorm(1000),x1=rnorm(1000),x2=rnorm(1000))
r1 <- randomForest(y~., data=dd) ## this works fine
Now modify the names to include a predictor with dashes in its name:
names(dd)[3] <- "a-b-c"
r2 <- randomForest(y~., data=dd)
Error in eval(predvars, data, env) : object 'a-b-c' not found
Now fix the names using make.names():
names(dd) <- make.names(names(dd))
r3 <- randomForest(y~., data=dd) ## works
What did make.names() do?
names(dd)
## [1] "y" "x1" "a.b.c"
I have a file with 30 columns. These include userid, itemid, moviename, rating, date and the rest are to classify genres a movie belongs to. The genre categories are column names with binary values in the rows. If a movie belongs to a genre, it has a 1 under the appropriate column and 0 otherwise. I want to calculate the average rating per genre and want to know if there is a shorter process available?
I have currently tried filtering the data by selecting each genre where the value is '1' and then calculating the average rating. But I have almost 24 genres and doing it in this way is inefficient i think. Another way I have tried is to loop through the genre columns and again filtering each genre where value is '1' but loops consume alot of time and when the data is set is large(more than 100K rows), R can play up sometimes as I have noticed.
I want to ask if there is another way which avoids a loop like melt,dcast or another method that can get the same job done?
I am providing the dput of my dataset.
dput(data)
structure(list(user_id = c(10L, 890L, 867L, 5L, 320L, 630L, 151L,
699L, 21L, 450L, 179L, 135L, 314L, 487L, 735L, 823L, 169L, 889L,
846L), item_id = c(447L, 660L, 191L, 441L, 1052L, 568L, 414L,
1061L, 872L, 33L, 302L, 581L, 568L, 280L, 181L, 503L, 498L, 207L,
497L), Movie_title = structure(c(6L, 11L, 2L, 3L, 9L, 17L, 15L,
10L, 14L, 8L, 13L, 12L, 17L, 18L, 16L, 5L, 1L, 7L, 4L), .Label = c("African Queen, The (1951)",
"Amadeus (1984)", "Amityville Horror, The (1979)", "Bringing Up Baby (1938)",
"Candidate, The (1972)", "Carrie (1976)", "Cyrano de Bergerac (1990)",
"Desperado (1995)", "Dracula: Dead and Loving It (1995)", "Evening Star, The (1996)",
"Fried Green Tomatoes (1991)", "Kalifornia (1993)", "L.A. Confidential (1997)",
"Love Jones (1997)", "My Favorite Year (1982)", "Return of the Jedi (1983)",
"Speed (1994)", "Up Close and Personal (1996)"), class = "factor"),
Rating = c(4L, 2L, 5L, 1L, 2L, 4L, 5L, 3L, 2L, 5L, 4L, 4L,
5L, 5L, 4L, 5L, 3L, 3L, 5L), Date = structure(c(7L, 15L,
12L, 4L, 1L, 2L, 9L, 8L, 19L, 14L, 18L, 10L, 6L, 16L, 5L,
11L, 17L, 13L, 3L), .Label = c("1/14/1998", "1/25/1998",
"1/5/1998", "10/1/1997", "10/13/1997", "10/26/1997", "10/27/1997",
"11/10/1997", "11/15/1997", "11/18/1997", "11/2/1997", "11/21/1997",
"11/22/1997", "12/18/1997", "12/24/1997", "12/30/1997", "3/31/1998",
"4/10/1998", "9/22/1997"), class = "factor"), unknown = c(0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L), Action = c(0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L,
1L, 0L, 0L, 1L, 0L, 1L, 0L, 1L, 1L, 0L), Adventure = c(0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L,
1L, 0L, 0L), Animation = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), Children = c(0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L), Comedy = c(0L, 0L, 0L, 0L, 1L, 0L, 1L, 1L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L), Crime = c(0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 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 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), History = c(0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L), Biography = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), Sport = c(0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L), Family = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L)), .Names = c("user_id",
"item_id", "Movie_title", "Rating", "Date", "unknown", "Action",
"Adventure", "Animation", "Children", "Comedy", "Crime", "Documentary",
"Drama", "Fantasy", "Film.Noir", "Horror", "Musical", "Mystery",
"Romance", "Sci.Fi", "Thriller", "War", "Western", "Short", "History",
"Biography", "Sport", "Family"), class = "data.frame", row.names = c(NA,
-19L))
This is a good use case for dplyr and tidyr:
library(dplyr)
library(tidyr)
dat %>% gather(genre, value, unknown:Family) %>% filter(value == 1) %>%
group_by(genre) %>% summarize(average = mean(Rating))
This code:
gathers each of the movie/genre pairs into a separate row (there will be multiple rows for each movie)
filters for only the cases when a movie belongs to a genre
groups by genre, and summarizes within each to find the average rating (you could perform other operations like the median or standard deviation as well)
the old-fashion way also works:
genres <- c('Action','Adventure','Animation')
means <- numeric(length(genres))
names(means) <- genres
for(g in genres)
meanRatings[g] <- mean(myData$Rating[mydata[,g]==1])
means