0

I just wanted to calculate the "ENS" and add it into another split via

pp_wide_count_nlwkn$ENS<-diversity(pp_wide_count_nlwkn[,4:last.spec.col], "invsimpson"
dput(pp_wider_count_nlwkn): 

    structure(list(StationID = c("Bork_W_1", "Bork_W_1", "Bork_W_1", 
    "Bork_W_1", "Bork_W_1", "Bork_W_1", "Bork_W_1", "Bork_W_1", "Bork_W_1", 
    "Bork_W_1", "Bork_W_1", "Bork_W_1", "Bork_W_1", "Bork_W_1", "Bork_W_1", 
    "Bork_W_1", "Bork_W_1", "Bork_W_1", "Bork_W_1", "Bork_W_1", "Bork_W_1", 
    "Bork_W_1", "Bork_W_1", "Bork_W_1", "Bork_W_1", "Bork_W_1", "Bork_W_1", 
    "Bork_W_1", "Bork_W_1", "Bork_W_1", "Bork_W_1", "Bork_W_1", "Bork_W_1", 
    "Bork_W_1", "Bork_W_1", "Bork_W_1", "Bork_W_1", "Bork_W_1", "Bork_W_1", 
    "Bork_W_1", "JaBu_W_1", "JaBu_W_1", "JaBu_W_1", "Nney_W_2", "Nney_W_2", 
    "Nney_W_2", "Nney_W_2", "Nney_W_2", "Nney_W_2", "Nney_W_2", "Nney_W_2", 
    "Nney_W_2", "Nney_W_2", "Nney_W_2", "Nney_W_2", "Nney_W_2", "Nney_W_2", 
    "Nney_W_2", "Nney_W_2", "Nney_W_2", "Nney_W_2", "Nney_W_2", "Nney_W_2", 
    "Nney_W_2", "Nney_W_2", "Nney_W_2", "Nney_W_2", "Nney_W_2", "Nney_W_2", 
    "Nney_W_2", "Nney_W_2", "Nney_W_2", "Nney_W_2", "Nney_W_2", "Nney_W_2", 
    "Nney_W_2", "Nney_W_2", "Nney_W_2", "Nney_W_2", "Nney_W_2", "Nney_W_2", 
    "Nney_W_2", "Nney_W_2", "Nney_W_2", "Nney_W_2", "Nney_W_2", "Nney_W_2", 
    "Nney_W_2", "WeMu_W_1", "WeMu_W_1", "WeMu_W_1", "WeMu_W_1"), 
        month = c("Apr", "Apr", "Apr", "Apr", "Aug", "Aug", "Aug", 
        "Aug", "Aug", "Dec", "Dec", "Feb", "Feb", "Jan", "Jan", "Jan", 
        "Jan", "Jul", "Jul", "Jul", "Jun", "Jun", "Jun", "Mar", "Mar", 
        "Mar", "Mar", "Mar", "May", "May", "May", "May", "Nov", "Oct", 
        "Oct", "Oct", "Sep", "Sep", "Sep", "Sep", "Dec", "Nov", "Sep", 
        "Apr", "Apr", "Apr", "Apr", "Apr", "Aug", "Aug", "Aug", "Aug", 
        "Aug", "Dec", "Dec", "Feb", "Feb", "Feb", "Feb", "Jan", "Jan", 
        "Jan", "Jul", "Jul", "Jul", "Jul", "Jun", "Jun", "Jun", "Jun", 
        "Mar", "Mar", "Mar", "Mar", "Mar", "May", "May", "May", "May", 
        "Nov", "Nov", "Oct", "Oct", "Oct", "Oct", "Sep", "Sep", "Sep", 
        "Dec", "Jul", "May", "May"), year = c(2018L, 2020L, 2021L, 
        2022L, 2018L, 2019L, 2020L, 2021L, 2022L, 2020L, 2021L, 2019L, 
        2021L, 2019L, 2020L, 2021L, 2022L, 2020L, 2021L, 2022L, 2019L, 
        2020L, 2021L, 2018L, 2019L, 2020L, 2021L, 2022L, 2018L, 2019L, 
        2020L, 2022L, 2020L, 2018L, 2020L, 2021L, 2018L, 2019L, 2021L, 
        2022L, 2020L, 2021L, 2022L, 2018L, 2019L, 2020L, 2021L, 2022L, 
        2018L, 2019L, 2020L, 2021L, 2022L, 2020L, 2021L, 2019L, 2020L, 
        2021L, 2022L, 2019L, 2020L, 2021L, 2018L, 2019L, 2020L, 2021L, 
        2018L, 2019L, 2020L, 2021L, 2018L, 2019L, 2020L, 2021L, 2022L, 
        2018L, 2019L, 2020L, 2022L, 2020L, 2021L, 2018L, 2019L, 2020L, 
        2021L, 2018L, 2019L, 2022L, 2020L, 2019L, 2018L, 2021L), 
        brown = c("11.909727", "10.28744", "33.09179", "8.552972", 
        "8.049915", "10.288514", "8.522243", "10.856272", "9.30000", 
        "2.0400", "9.515741", "3.466234", "2.230736", "3.466234", 
        "3.64387", "4.09665", "5.417754", "10.87883", "22.071736", 
        "8.000", "11.22175", "7.931371", "18.76544", "2.806168", 
        "6.596591", "6.088469", "15.451448", "10.489686", "40.890395", 
        "13.702838", "21.029284", "30.634723", "3.041144", "4.654302", 
        "4.956018", "12.26069", "4.253818", "10.767373", "10.147866", 
        "5.35000", "3.876556", "7.899927", "10.44000", "11.163351", 
        "13.448161", "11.397655", "18.89759", "26.275504", "9.609482", 
        "13.822668", "12.237363", "36.092778", "11.74000", "5.111394", 
        "6.52379", "2.751824", "4.214121", "5.152603", "13.799497", 
        "2.751824", "4.397865", "8.725382", "4.124499", "6.573604", 
        "10.073971", "25.290935", "5.098201", "12.225463", "7.755524", 
        "20.381458", "23.28763", "20.532782", "7.279257", "36.476234", 
        "11.989853", "9.981234", "7.325382", "15.388391", "24.70812", 
        "5.539585", "13.542679", "15.928211", "8.316313", "0.000", 
        "26.720851", "12.451093", "12.286297", "6.890000", "3.575335", 
        "7.041796", "46.037498", "9.326106"), chloro = c("0.432055", 
        "1.613869", "23.963067", "1.718876", "2.60845", "4.171254", 
        "1.577413", "5.118589", "4.43000", "0.487125", "1.330656", 
        "0.045261", "0.000", "0.045261", "0.463913", "0.277239", 
        "0.410618", "3.985659", "5.762663", "2.880000", "4.544677", 
        "2.750217", "6.12935", "", "0.968753", "0.764563", "3.226994", 
        "1.934091", "30.577287", "4.261178", "14.885953", "21.385361", 
        "0.000", "0.891628", "0.243961", "1.725863", "0.116469", 
        "3.278837", "1.9662000", "2.670000", "0.224689", "0.728631", 
        "3.39000", "3.971365", "3.067106", "2.304216", "17.102", 
        "11.203186", "7.490241", "4.808695", "4.807177", "12.335842", 
        "4.68000", "0.308144", "0.138825", "0.000", "0.795978", "0.948549", 
        "4.213317", "0.000", "0.627568", "1.912538", "3.594579", 
        "4.209035", "5.214236", "8.139089", "3.156525", "5.47141", 
        "3.254409", "6.715774", "2.41907", "3.238652", "1.480725", 
        "4.193403", "2.141001", "13.816071", "1.973174", "6.347396", 
        "16.833449", "0.017707", "2.879072", "6.905057", "2.361877", 
        "0.000", "5.436869", "7.740713", "7.446193", "5.290000", 
        "0.000", "1.157941", "32.216448", "1.390176"), crypto = c("3.311774", 
        "0.460135", "0.0000, 0.000", "0.000", "0.000", "0.000", "0.000", 
        "0.000", "1.470000", "0.000", "0.000", "0.000", "0.0000", 
        "0.000", "0.000", "0.000", "0.000", "0.006051", "0.357903", 
        "0.87", "0.000", "0.000", "0.276016", "4.018403", "0.13486", 
        "0.000", "", "0.000", "14.020126", "0.115701", "0.000", "0.000", 
        "0.046282", "0.383031", "0.000", "0.000", "0.000", "0.361729", 
        "0.000", "0.08", "0.000", "0.000", "1.000", "4.997642", "0.376314", 
        "0.130099", "0.000", "0.000", "0.0000", "0.000", "0.000", 
        "0.000", "2.0900", "0.000", "0.000", "0.0000", "0.000", "0.000", 
        "0.000", "0.0000", "0.000", "0.000", "0.000", "0.270528", 
        "0.670718", "0.000", "2.703974", "0.0000", "0.000", "0.00", 
        "9.47433", "0.000", "0.000", "0.985621", "0.000", "4.268941", 
        "0.000", "0.000", "0.000", "0.000", "0.000", "0.000", "0.0000", 
        "0.0000", "0.000", "0.000", "0.005918", "0.69", "0.000", 
        "0.000", "19.596002", "0.000"), cyano = c("4.555436", "1.588185", 
        "0.000", "1.302112", "1.570948", "0.000", "1.330527", "0.000", 
        "0.000", "2.452192", "2.455381", "2.858057", "1.017906", 
        "2.858057", "2.364047", "1.362446", "1.241252", "0.886625", 
        "0.000", "0.000", "0.000", "1.779805", "0.000", "0.97951", 
        "1.488302", "2.822638", "1.254545", "1.009695", "0.000", 
        "0.108502", "0.000", "0.000", "0.65934", "1.095232", "0.789945", 
        "1.274856", "0.000", "0.278277", "1.032053", "0.000", "1.324977", 
        "1.638052", "0.000", "3.741225", "0.35597", "1.573125", "0.00", 
        "0.000", "0.000", "0.0000", "1.214833", "0.000", "0.0000", 
        "1.96758", "1.273048", "2.583797", "2.69517", "1.593334", 
        "3.336968", "2.583797", "2.39368", "3.333801", "0.000", "0.265657", 
        "0.890743", "0.00", "0.827637", "0.533924", "0.07967", "0.125481", 
        "4.348959", "1.839877", "3.343654", "1.599393", "1.263824", 
        "0.000", "0.937065", "0.994566", "0.000", "1.387483", "2.492793", 
        "0.000", "2.275364", "4.599323", "1.419497", "0.000", "0.000", 
        "0.000", "1.199652", "2.688333", "0.000", "1.36089")), class = "data.frame", row.names = c(NA, 
    -92L))


The answer:

Error in diversity(pp_wide_count_nlwkn[, 4:last.spec.col], "invsimpson") : input data must be numeric

What is the mistake? And could you tell me what the "4" exactly stands for?

I maybe thought I have to remove the "0"- vlaues?

lxrnax
  • 11
  • 3
  • 2
    The error message is pretty clear: the input data must be numeric. Have you check to ensure the input data are numeric? We’re unable to tell that based off of a screenshot. Would be best to edit your question to include `dput(pp_wide_count_nlwkn)` – jpsmith Aug 13 '23 at 18:14
  • 1
    lxrnax, in general questions need to be _reproducible_. This includes sample code you've attempted (you have that, great!), sample *unambiguous* data (e.g., `data.frame(x=...,y=...)` or the output from `dput(head(x))` into a [code block]), and intended output given that input. Refs: https://stackoverflow.com/q/5963269, [mcve], and https://stackoverflow.com/tags/r/info. This and your previous two questions have no data, making it a bit harder to help you. (It's in your best interests to make it easy for us.) – r2evans Aug 13 '23 at 18:22
  • You asked "And could you tell me what the "4" exactly stands for?". Do you mean the 4 that you self wrote in your code? Well, the only 4 I see is the column index in your code. That means the fourth column in your data. The error is clear, like already told to you: you have non-numeric data. The "photo" does not help us, but you may try something like `summary(pp_wide_count_nlwkn[, 4:last.spec.col])` and if that gives you a non-numeric summary, that variable is non-numeric. – Jari Oksanen Aug 14 '23 at 21:03
  • I have done my best and entered the dput code above. I hope this is more helpful. So far, I haven't delved into R very much, which is why I'm also unsure about what exactly is meant by "numeric"? I thought it distinguishes between numbers and letters, with numbers being considered as numeric variables? Thank you in any case for your kind responses :) – lxrnax Aug 15 '23 at 17:47
  • The result of the summary: brown chloro crypto cyano Length:92 Length:92 Length:92 Length:92 Class :character Class :character Class :character Class :character Mode :character Mode :character Mode :character Mode :character – lxrnax Aug 15 '23 at 17:48
  • I might use as.numeric() to convert a column to a numeric data type: pp_wide_count_nlwkn[, 4] <- as.numeric(pp_wide_count_nlwkn[, 4]) But unfortunately it didn't work out. – lxrnax Aug 15 '23 at 18:08
  • In your case the text is called "character", and a character is not numeric. Strange that `as.numeric` does not work with you: when I copied your data, it worked with me. – Jari Oksanen Aug 17 '23 at 10:31
  • After I tried the as. numeric code, pp_wide_count_nlwkn$ENS<-diversity(pp_wide_count_nlwkn[,4:last.spec.col], "invsimpson" dput(pp_wider_count_nlwkn): still does not work for me. Any other tips? – lxrnax Aug 17 '23 at 16:33
  • some columns are empty or with values like: 0.000, 0.000, what could be the problem? – lxrnax Aug 17 '23 at 16:57

0 Answers0