HELP please - attempting a Kendall analysis for trend

I'm trying to run a Mann-Kendall test using a data set I have..I'm struggling with code as I keep getting an error (Input vector must contain at least three values).

What I'm trying to do is to run a Mann-Kendall test for these two variables - Year, Age groups - I'm charting the incidence of colo-rectal cancer per 100,000 population for each individual age group.

I have so far run the following commands on R after uploading my dataset
library(modifiedmk)
mkttest(I 35-39)

I 35-39 is the column, incidence in the 35 to 39 year olds. Could the error lie in the fact that the data hasnt originally been rounded up uniformly on the excel sheet. for e.g. I have 5.0292 (incidence for year 1993) in one box and 5.23 (incidence for year 2004) in the other

R is not usually very happy with spaces in variable names You might want to try:

mkttest(`I 35-39`) 

Otherwise can you provide reproducible example (reprex)
FAQ: How to do a minimal reproducible example ( reprex ) for beginners ?

Many thanks,

I created a 'vector' and then entered the mkttest(I30)..I'm finding it hard to conceptualise the need for a vector?
I30-<colorectal_incidence_hidden$nI 30-34 --- where colorectal_incidence_hidden was the file name and nI 30-34 was the column that had the incidence of colorectal cancer for this age group (30-34 years) over the years.

Why do I have to create vector for each of these variables and THEN run the test?? Why can't I just run it directly?

Sorry if this is a daft question. I've only started using R this week. Thanks.

Argh, that was my stupidity. Assuming I understand how your columns are named my code should have read:

mkttest(mydata$`I 35-39`)

where mydata is the nane of your data.frame or tibble.

You do not have to create a vector, just read in the column of data from the data.frame It is a vector. Here is a quick example

dat1 <-   data.frame(aa = 1:50, bb = 50:1)
library(modifiedmk)
mkttest(dat1$aa)

The only issue is that it looks like your variable/column names has spaces which R does not like. Therefore you need the I 35-39 format so that R recognizes that as a column name.

If I am not making sense can you supply some sample data? A handy way to supply sample data is to use the dput() function. See ?dput. If you have a very large data set then something like head(dput(myfile), 100) will likely supply enough data for us to work with.

Thanks for all your help..it's begining to make sense

BTw it should read

`I 35-39`

I forgot the forum formatting.

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.