Ich stelle diese Frage, weil, als jemand neu in R, bin ich neugierig, warum ein Stück Code, den ich schrieb funktioniert gut, und dann die gleiche Codezeile erzeugt einen Fehler der Das nächste Mal wird es ausgeführt.Fehler in dplyr group_by Funktion, Objekt nicht gefunden
Hier ist ein Beispiel für eine Tabelle, mit der ich arbeite.
dput:
structure(list(a5species = structure(c(4L, 1L, 6L, 3L, 14L, 3L,
8L, 8L, 8L, 8L, 8L, 8L, 3L, 4L, 4L, 8L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 8L, 8L, 8L, 8L, 8L, 8L, 4L, 8L, 8L, 8L, 3L, 8L, 8L, 8L,
12L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L,
8L, 8L, 8L, 8L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 3L, 4L, 3L, 6L,
3L, 4L, 4L, 3L, 3L, 6L, 6L, 3L, 3L, 3L, 3L, 3L, 3L, 6L, 3L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 8L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 1L, 4L, 3L, 3L, 3L, 4L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 3L,
4L, 8L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 3L, 12L, 12L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 13L, 4L, 4L, 4L, 6L, 4L, 3L,
12L, 14L, 6L, 3L, 3L, 4L, 4L, 10L, 4L, 3L, 3L, 3L, 3L, 10L, 4L,
4L, 4L, 4L, 12L, 4L, 4L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 6L, 5L, 4L, 10L, 12L, 4L, 4L, 3L, 6L, 4L, 3L,
4L), .Label = c("coustani", "demeilloni", "funestus", "gambiae",
"garnhami", "indetermine", "marshallii", "pharoensis", "pretoriensis",
"rufipes", "salbaii", "squamosus", "tenebrosus", "ziemani"), class = "factor"),
Vila = c("Motaze", "Motaze", "Motaze", "Motaze", "Motaze",
"Motaze", "Motaze", "Motaze", "Motaze", "Motaze", "Motaze",
"Motaze", "Motaze", "Motaze", "Motaze", "Motaze", "Motaze",
"Motaze", "Motaze", "Motaze", "Motaze", "Motaze", "Motaze",
"Motaze", "Motaze", "Motaze", "Motaze", "Motaze", "Motaze",
"Motaze", "Motaze", "Motaze", "Motaze", "Motaze", "Motaze",
"Motaze", "Motaze", "Motaze", "Motaze", "Motaze", "Motaze",
"Motaze", "Motaze", "Motaze", "Motaze", "Motaze", "Motaze",
"Motaze", "Motaze", "Motaze", "Motaze", "Motaze", "Motaze",
"Motaze", "Motaze", "Motaze", "Motaze", "Motaze", "Motaze",
"Motaze", "Motaze", "Motaze", "Motaze", "Motaze", "Motaze",
"Motaze", "Motaze", "Motaze", "Motaze", "Motaze", "Motaze",
"Motaze", "Motaze", "Motaze", "Motaze", "Motaze", "Motaze",
"Motaze", "Motaze", "Motaze", "Motaze", "Motaze", "Motaze",
"Motaze", "Motaze", "Motaze", "Motaze", "Motaze", "Motaze",
"Motaze", "Motaze", "Motaze", "Motaze", "Motaze", "Motaze",
"Motaze", "Motaze", "Motaze", "Motaze", "Motaze", "Motaze",
"Motaze", "Motaze", "Motaze", "Motaze", "Motaze", "Motaze",
"Motaze", "Motaze", "Motaze", "Motaze", "Motaze", "Motaze",
"Motaze", "Motaze", "Motaze", "Motaze", "Motaze", "Motaze",
"Motaze", "Motaze", "Motaze", "Chicutso", "Chicutso", "Chicutso",
"Chicutso", "Chicutso", "Chicutso", "Chicutso", "Chicutso",
"Chicutso", "Chicutso", "Chicutso", "Chicutso", "Chicutso",
"Chicutso", "Chicutso", "Chicutso", "Chicutso", "Chicutso",
"Chicutso", "Chicutso", "Chicutso", "Chicutso", "Chicutso",
"Chicutso", "Chicutso", "Chicutso", "Chicutso", "Chicutso",
"Chicutso", "Chicutso", "Chicutso", "Chicutso", "Chicutso",
"Chicutso", "Chicutso", "Chicutso", "Chicutso", "Chicutso",
"Chicutso", "Chicutso", "Chicutso", "Chicutso", "Chicutso",
"Chicutso", "Chicutso", "Chicutso", "Chicutso", "Chicutso",
"Chicutso", "Chicutso", "Chicutso", "Chicutso", "Chicutso",
"Chicutso", "Chicutso", "Chicutso", "Chicutso", "Chicutso",
"Chicutso", "Chicutso", "Chicutso", "Chicutso", "Chicutso",
"Chicutso", "Chicutso", "Panjane", "Panjane", "Panjane",
"Panjane", "Panjane", "Panjane", "Panjane", "Panjane", "Panjane",
"Panjane", "Panjane", "Panjane", "Panjane", "Panjane", "Magude",
"Magude", "Magude", "Magude", "Magude", "Magude", "Magude",
"Magude", "Magude", "Magude", "Magude", "Magude", "Magude",
"Magude", NA, NA, "Muginge", "Muginge", "Muginge", "Muginge",
"Muginge", "Muginge", "Muginge", "Muginge", "Muginge", "Muginge",
"Muginge", "Muginge", "Muginge", "Muginge", "Muginge", "Muginge",
"Muginge", "Muginge", "Muginge", "Muginge", "Muginge", "Muginge",
"Muginge", "Muginge", "Muginge", "Muginge", "Muginge", "Muginge",
"Muginge", "Muginge", "Muginge", "Muginge", "Muginge", "Muginge",
"Muginge", "Muginge", "Muginge", "Muginge", "Muginge", "Muginge",
"Muginge", "Muginge", "Muginge", "Muginge", "Muginge", "Muginge",
"Muginge", "Muginge", "Muginge", "Muginge", "Muginge", "Muginge",
"Muginge", "Muginge", "Muginge", "Muginge", "Muginge", "Muginge",
"Muginge", "Muginge", "Muginge", "Muginge", "Muginge", "Muginge",
"Muginge", "Muginge", "Muginge", "Muginge", "Muginge", "Muginge",
"Muginge", "Muginge", "Muginge", "Muginge", "Muginge", "Muginge",
"Muginge", "Muginge", "Muginge", "Muginge", NA, NA, "Muginge",
"Muginge", "Muginge", "Muginge", "Muginge", "Muginge", "Muginge",
"Muginge", "Muginge", "Muginge", "Mapulanguene", "Mapulanguene",
"Mapulanguene", "Mapulanguene", "Mapulanguene", "Mapulanguene",
"Mapulanguene", "Mapulanguene", "Mapulanguene", "Mapulanguene",
"Mapulanguene", "Mapulanguene")), class = c("tbl_df", "tbl",
"data.frame"), row.names = c(NA, -321L), .Names = c("a5species",
"Vila"))
Und ich habe diesen Code die Art von Vila zu organisieren:
test %>% + group_by(Vila) %>% filter(a5species=="gambiae") %>% + summarise(n=n())
Mit diesem Code die Tabelle erzeugte ich will, aber das nächste Mal, wenn ich versuchte, das laufen Code funktioniert nicht mehr und erzeugt den Fehler:
Ich realisiere, dass dies ähnlich wie die Frage geschrieben ist hier: R object not found if defined within a function when using data.table dplyr
Aber ich benutze dplyr_0.4.3 und diese Frage deutet darauf hin, dass das Problem, das sie erlebt haben, inzwischen behoben wurde, und auch mein Code hat an einem Punkt funktioniert. Außerdem ist die Diskussion über diesen Beitrag ziemlich technisch und geht mir über den Kopf.
Irgendeine Idee, warum mein Code plötzlich nicht mehr funktioniert?
Vielen Dank.
Ah ich sehe. Es ist mir ein wenig peinlich, dass das so einfach war, und ich habe mich über dieses Pluszeichen gewundert und versucht, es an einem Punkt zu entfernen, muss aber dann einen weiteren Fehler gemacht haben. Vielen Dank! –
Wird als beantwortet in 10 Minuten markiert, wenn ich kann –