How to assign Mann-Whitney variables and calculate p value on Rstudio?

Complete novice, if anyone could help? This is what i have tried so far. I would like the food.type and inter.distance to be in a data.frame.

factor(df$GROUP,c(1,2,3,4),labels=c('leaves','fruit','bark','none'))
Error in df$GROUP : object of type 'closure' is not subsettable

 food.type	inter.distance
leaves	25
fruit	     15
none	25
none	25
fruit	10
none	15
none	10
none	10
bark	5
fruit	15
fruit	10
none	20
leaves	25
none	25
none	15
bark	25
fruit	15
leaves	15
fruit	25
none	20
fruit	25
fruit	15
none	5
none	5
none	5
none	5
none	10
none	10
none	25
none	20
leaves	5
none	10
none	10
fruit	20
bark	20
none	15
leaves	5
none	5
leaves	20
fruit	15
leaves	25
bark	10
none	20
none	10
# Base R

fruit_df <- data.frame(
  fruit = rep(c('leaves','fruit','bark','none'), 4),
  inter.distance = rnorm(16)
)

str(fruit_df)
#> 'data.frame':    16 obs. of  2 variables:
#>  $ fruit         : Factor w/ 4 levels "bark","fruit",..: 3 2 1 4 3 2 1 4 3 2 ...
#>  $ inter.distance: num  0.227 0.844 -0.851 -2.605 -1.332 ...

# Tidyverse
library(tidyverse) 

fruit_tbl <- tibble(
  fruit = rep(c('leaves','fruit','bark','none'), 4),
  inter.distance = rnorm(16)
)

str(fruit_tbl)
#> Classes 'tbl_df', 'tbl' and 'data.frame':    16 obs. of  2 variables:
#>  $ fruit         : chr  "leaves" "fruit" "bark" "none" ...
#>  $ inter.distance: num  -2.345 -0.234 0.169 -0.83 0.16 ...

Created on 2018-12-21 by the reprex package (v0.2.1)

1 Like

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