1
votes

I've been using the group_by and summarise functions for some time now to summarise my data per data group. I have a data frame with Site_Number, Seeding_depth and plant_Numbers. I used this code:

Marina_Survival2=group_by(Marina_Survival,Site_Number, Seeding_depth) %>% 
summarise(mean=mean(plant_Numbers),sd=sd(plants_Numbers))

The output that I got was a data frame with 4 columns, Site_Number, Seeding_depth, mean and sd, With a mean and standard deviation for each of the combinations.

However, for some reason when I run the exact same code today I get a data frame with only 2 columns, mean and sd and only one value for each. I've tried reloading the tidyverse and dplyr packages but this hasn't worked.

Additionally, the select function also no longer works. It gives the error that I have unused arguments in my select command, even though it had no problem with it yesterday.

Does anyone know what is going wrong here and how I could fix it? As it would be very frustrating to rewrite my entire code so it no longer uses the package.

1
Your code snippet looks fine. Hence I would suggest you try to make a reproducible example of your issue including a snippet of your data and other code you use. Otherwise it's impossible to even guess what's wrong or what could be the issue. - stefan
Replace Marina_Survival2= by Marina_Survival2 %>% - Bappa Das
for that select thing you can specify the library as well dplyr::select . - AlexB
It sounds like you have other packages loaded that are interfering. For example, if you do ecological work, you may have raster loaded, which also has a select function. - Amadou Kone
dbplyr is an R package for working with data stored in a database. You have no mention of a database in your question. Perhaps you meant dplyr? - Simon.S.A.

1 Answers

0
votes

@AmadouKone, you were right. I was using the ggbiplot function which was masking some functions of dplyr like summarise. I placed tidyverse at the end of my package loading list which fixes the problem.

Specifying the package like @AlexB suggested should have worked as well, especially if I wanted to use the functions of both packages. But I only need the one so I like the other solution better to make the script more streamlined.

Thank you all for your suggestions and help!