Masters student struggling with code can anyone help

hey,

i am trying to create a rarefac.plot with my data set but cant get it to work , can anyone help me please ? it says rarefac not found?

any chance someone could help me with this code I've been out this for hours and I have a deadline looming

laura

Please show us the code you ran and the error message. It's difficult to help without more details.

Perhaps you are making a mistake of reading the R console log in the wrong order, when addressing issues, its incorrect to go from bottom up, rather should read down from top to bottom.
You should identify the first error issue that arises in your log as you submit the statements in your script line by line. (the later parts of your script wont work if the earlier parts haven't)

If you want specific help, it will require a reprex

hey like i stated i have got the species richness and abundance plots to work and it reads my data set etc , all the write packages were downloaded first and how do i get specific help as non of my lectuers are getting back to me ?

we don't have beespeciesdata, and would need it to run your code and understand what is the problem.

It simply doesnt make sense that your object is not found, if it was succesfully made so I'm sceptical...
I provided you a link to a guide of how you can share it for the forum.

these are the packages i have downloaded ,

library("tidyverse")

library("iNEXT")

library("vegan")

library("rstatix")

library("ggpubr")
and yes they are in the inext package

how do upload the data set ?

i have tried to produce a reprex for beginners and created the dataset but i dont know where it as disappeared to is there not a way where i can private message one of you guy so i can send my actually r studio file, my head is totally mashed atm

your dataset is presumably one line of code away for you

beespeciesdata <-read.csv("bee data averages.csv")

throw a dput() on it

dput(beespeciesdata)

when you share it to the forum make sure to format your code as code by using triple backticks (so it looks nice)

``` 
my nice code

Yes, I have had problems doing a reprex. Just follow nirgrahamuck's code. You do not even need to use triple backticks but it does look nicer.

If it is a really big dataset just give us a decent sample. Something like

dput(head((beespeciesdata, 50)) probably will do.

As an example

dput(head(mtcars, 10))

gives us

structure(list(mpg = c(21, 21, 22.8, 21.4, 18.7, 18.1, 14.3, 
24.4, 22.8, 19.2), cyl = c(6, 6, 4, 6, 8, 6, 8, 4, 4, 6), disp = c(160, 
160, 108, 258, 360, 225, 360, 146.7, 140.8, 167.6), hp = c(110, 
110, 93, 110, 175, 105, 245, 62, 95, 123), drat = c(3.9, 3.9, 
3.85, 3.08, 3.15, 2.76, 3.21, 3.69, 3.92, 3.92), wt = c(2.62, 
2.875, 2.32, 3.215, 3.44, 3.46, 3.57, 3.19, 3.15, 3.44), qsec = c(16.46, 
17.02, 18.61, 19.44, 17.02, 20.22, 15.84, 20, 22.9, 18.3), vs = c(0, 
0, 1, 1, 0, 1, 0, 1, 1, 1), am = c(1, 1, 1, 0, 0, 0, 0, 0, 0, 
0), gear = c(4, 4, 4, 3, 3, 3, 3, 4, 4, 4), carb = c(4, 4, 1, 
1, 2, 1, 4, 2, 2, 4)), row.names = c("Mazda RX4", "Mazda RX4 Wag", 
"Datsun 710", "Hornet 4 Drive", "Hornet Sportabout", "Valiant", 
"Duster 360", "Merc 240D", "Merc 230", "Merc 280"), class = "data.frame")

we can just assign it a name and we have a perfect copy of the sample data.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.

the error code is Error: object 'rarefac.plot' not found

beespeciesdata <-read.csv("bee data averages.csv")

## Bee abundance  - plot abundance for each of the 10 species across the 4 plots ##

# summarise the data

bee_abundance <-beespeciesdata %>% 
  
  # remove N/A in species column
  filter(Bee_species!="N/A") %>% 
  # group the data by species, plot and day
  group_by(Bee_species, Plot, Day) %>% 
  # calculate the sum of counts per species
  summarise(count = length(Bee_species)) %>% 
  ungroup()
bee_abundance


# Comparing abundance - boxplot
abund.plot <- ggplot(bee_abundance, aes(x = as.factor(Plot), y = count, colour = Plot))+
   geom_boxplot()+
  facet_wrap(~Bee_species)+
  labs(y="Number of individuals", x="Plot")+
  theme_bw()
abund.plot


# richness
bee_richness <-beespeciesdata %>% 
   # remove N/A in species column
   filter(Bee_species!="N/A") %>% 
  # group the data by species, plot
   group_by(Bee_species, Plot) %>% 
   tally() %>% 
   ungroup()
bee_richness

# Comparing richness - boxplot
richness.plot <- ggplot(bee_richness, aes(x = as.factor(Plot), y = n, color = Plot))+
  geom_boxplot()+
  labs(y="Number of bee species", x="Plot")+
  theme_bw()
richness.plot


d <- column_to_rownames(data, var = "Bee_species") # converts the "Species" column to rownames
head(d)

rarefac <- iNEXT(d[,1:3], q=c(0,1,2), datatype = "bee_abundance") # q-values: 0 = richness, 1 = Shannon, 2 = Simpson
rarefac

rarefac.plot <- ggiNEXT(rarefac,facet.var = "order")+
  theme_bw(base_size = 14) +
  theme(legend.position="bottom",
        legend.title=element_blank())
rarefac.plot

i have got the abundance and the species richness plot to work so im trying do a rarefac curve which will show me the Species richness
Shannon diversity index
Simpson Diversity

i am trying figure out the code to work this out

the INEXT packages is installed so i dont get why it is not working?

At the minimum you should declare the library's you use... ( for maximal help provide a reprex)
FAQ: How to do a minimal reproducible example ( reprex ) for beginners

according to your code rarefac is an object you attempted to make with some function called iNEXT.
It will not be found if that iNEXT function call had an error

It would help to have some sample data. Dput() is a handy way to provide some See ?dput.

Am I correct that the iNext& ggiNEXT functions are coming from the iNext package?