Hi,
Thank you! It was indeed a character :) I used my_data$Sampling <- as.factor(my_data$Sampling) and now it works: > levels(my_data$Sampling) [1] "Dec17" "Jan18" "Jun18" "Mar18" "May18" "Nov18" "Oct17" "Sep18" Kr, Vesna From: Torsten Hauffe <torsten.hau...@gmail.com> Sent: Tuesday, June 23, 2020 6:06 PM To: Vesna Gulin <vesna.gu...@biol.pmf.hr> Cc: r-sig-ecology@r-project.org Subject: Re: [R-sig-eco] LEVELS function NULL Hi, What is the output of class(my_data$Sampling)? If it is not factor (but character), you could write my_data$Sampling <- as.factor(my_data$Sampling) Then levels(my_data$Sampling) should return Sep18 etc. Cheers! On Tue, Jun 23, 2020 at 6:00 PM Vesna Gulin <vesna.gu...@biol.pmf.hr <mailto:vesna.gu...@biol.pmf.hr> > wrote: Hi everyone, It has been a couple months now of using R and I am slowly trying to switch from using Statistica to R in order to process my data (for PhD purposes). I did some basic statistics and now I would like to try Kruskal-Wallis (following this guideline: http://www.sthda.com/english/wiki/kruskal-wallis-test-in-r ) but I have been stuck for days as I can't seem to find a reason why the levels function keeps giving me NULL. My data is a data frame: my_data Temperature Sampling 1 9.90 Dec17 2 10.00 Dec17 3 10.00 Dec17 4 10.10 Dec17 5 9.90 Dec17 6 10.10 Dec17 7 10.20 Dec17 8 10.10 Jan18 9 10.50 Jan18 10 10.80 Jan18 11 10.30 Jan18 12 10.30 Jan18 13 10.20 Jan18 14 10.50 Jan18 15 20.90 Jun18 16 20.80 Jun18 17 20.50 Jun18 18 20.50 Jun18 19 20.70 Jun18 20 20.60 Jun18 21 20.50 Jun18 22 10.50 Mar18 23 11.40 Mar18 24 10.90 Mar18 25 10.60 Mar18 26 11.60 Mar18 27 11.20 Mar18 28 12.20 Mar18 29 19.40 May18 30 19.00 May18 31 20.80 May18 32 19.50 May18 33 18.60 May18 34 18.10 May18 35 19.20 May18 36 16.80 Nov18 37 16.50 Nov18 38 18.40 Nov18 39 18.10 Nov18 40 16.70 Nov18 41 16.70 Nov18 42 18.50 Nov18 43 15.50 Oct17 44 15.10 Oct17 45 15.00 Oct17 46 15.80 Oct17 47 15.20 Oct17 48 15.10 Oct17 49 15.20 Oct17 50 23.40 Sep18 51 24.05 Sep18 52 23.70 Sep18 53 23.40 Sep18 54 24.05 Sep18 55 23.80 Sep18 56 24.15 Sep18 When I hit levels(my_data$Sampling) it gives me NULL I would very much appreciate any help. Kind regards, Vesna Vesna Gulin, Research Assistant Department of Biology Faculty of Science University of Zagreb Rooseveltov trg 6, 10000 Zagreb, Croatia [[alternative HTML version deleted]] _______________________________________________ R-sig-ecology mailing list R-sig-ecology@r-project.org <mailto:R-sig-ecology@r-project.org> https://stat.ethz.ch/mailman/listinfo/r-sig-ecology [[alternative HTML version deleted]] _______________________________________________ R-sig-ecology mailing list R-sig-ecology@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology