# R-Studio Question wilcox.test()

Hello,

I am a student using R-Studio. I would like to run a wilcox.test() using:

1. A binomial data (example: People > 180 and people <180) as 1 vs. 0
2. About 80 observation regarding Group 1 and 0

My data is imported from excel. I am able to run wilcox.test() for 1 vs. 0 using for example observation 1. After that, I am running the same wilcox.test() for 1 vs. 0 using observation 2. My main problem is, that my simple method is very slow.
How can i run the wilcox.test() using 1 vs. 0 für all the 80 observations with only one code and have the same output as follows:

Wilcoxon rank sum test with continuity correction

data: Observation 1 by OnevsZero
W = 143.5, p-value = 0.01125
alternative hypothesis: true location shift is not equal to 0
95 percent confidence interval:
-0.18002023 -0.01998433
sample estimates:
difference in location
-0.1100015

Thank you very very much,

Alexandru

See the FAQ: How to do a minimal reproducible example `reprex` for beginners for a better way to attract more directly useful answers.

An analogous problem would be to apply some function to the rows of the `mtcars` dataset of its first column variable, mpg to each of the remaining 10 column variables in turn. Although it is a nonsense calculation, let that be addition.

``````add_cols <- function(x)  mtcars[1] + mtcars[x]
#> [[1]]
#>                      mpg
#> Mazda RX4           27.0
#> Mazda RX4 Wag       27.0
#> Datsun 710          26.8
#> Hornet 4 Drive      27.4
#> Valiant             24.1
#> Duster 360          22.3
#> Merc 240D           28.4
#> Merc 230            26.8
#> Merc 280            25.2
#> Merc 280C           23.8
#> Merc 450SE          24.4
#> Merc 450SL          25.3
#> Merc 450SLC         23.2
#> Lincoln Continental 18.4
#> Chrysler Imperial   22.7
#> Fiat 128            36.4
#> Honda Civic         34.4
#> Toyota Corolla      37.9
#> Toyota Corona       25.5
#> Dodge Challenger    23.5
#> AMC Javelin         23.2
#> Camaro Z28          21.3
#> Pontiac Firebird    27.2
#> Fiat X1-9           31.3
#> Porsche 914-2       30.0
#> Lotus Europa        34.4
#> Ford Pantera L      23.8
#> Ferrari Dino        25.7
#> Maserati Bora       23.0
#> Volvo 142E          25.4
#>
#> [[2]]
#>                       mpg
#> Mazda RX4           181.0
#> Mazda RX4 Wag       181.0
#> Datsun 710          130.8
#> Hornet 4 Drive      279.4
#> Valiant             243.1
#> Duster 360          374.3
#> Merc 240D           171.1
#> Merc 230            163.6
#> Merc 280            186.8
#> Merc 280C           185.4
#> Merc 450SE          292.2
#> Merc 450SL          293.1
#> Merc 450SLC         291.0
#> Lincoln Continental 470.4
#> Chrysler Imperial   454.7
#> Fiat 128            111.1
#> Honda Civic         106.1
#> Toyota Corolla      105.0
#> Toyota Corona       141.6
#> Dodge Challenger    333.5
#> AMC Javelin         319.2
#> Camaro Z28          363.3
#> Pontiac Firebird    419.2
#> Fiat X1-9           106.3
#> Porsche 914-2       146.3
#> Lotus Europa        125.5
#> Ford Pantera L      366.8
#> Ferrari Dino        164.7
#> Maserati Bora       316.0
#> Volvo 142E          142.4
#>
#> [[3]]
#>                       mpg
#> Mazda RX4           131.0
#> Mazda RX4 Wag       131.0
#> Datsun 710          115.8
#> Hornet 4 Drive      131.4
#> Valiant             123.1
#> Duster 360          259.3
#> Merc 240D            86.4
#> Merc 230            117.8
#> Merc 280            142.2
#> Merc 280C           140.8
#> Merc 450SE          196.4
#> Merc 450SL          197.3
#> Merc 450SLC         195.2
#> Lincoln Continental 225.4
#> Chrysler Imperial   244.7
#> Fiat 128             98.4
#> Honda Civic          82.4
#> Toyota Corolla       98.9
#> Toyota Corona       118.5
#> Dodge Challenger    165.5
#> AMC Javelin         165.2
#> Camaro Z28          258.3
#> Pontiac Firebird    194.2
#> Fiat X1-9            93.3
#> Porsche 914-2       117.0
#> Lotus Europa        143.4
#> Ford Pantera L      279.8
#> Ferrari Dino        194.7
#> Maserati Bora       350.0
#> Volvo 142E          130.4
#>
#> [[4]]
#>                       mpg
#> Mazda RX4           24.90
#> Mazda RX4 Wag       24.90
#> Datsun 710          26.65
#> Hornet 4 Drive      24.48
#> Valiant             20.86
#> Duster 360          17.51
#> Merc 240D           28.09
#> Merc 230            26.72
#> Merc 280            23.12
#> Merc 280C           21.72
#> Merc 450SE          19.47
#> Merc 450SL          20.37
#> Merc 450SLC         18.27
#> Lincoln Continental 13.40
#> Chrysler Imperial   17.93
#> Fiat 128            36.48
#> Honda Civic         35.33
#> Toyota Corolla      38.12
#> Toyota Corona       25.20
#> Dodge Challenger    18.26
#> AMC Javelin         18.35
#> Camaro Z28          17.03
#> Pontiac Firebird    22.28
#> Fiat X1-9           31.38
#> Porsche 914-2       30.43
#> Lotus Europa        34.17
#> Ford Pantera L      20.02
#> Ferrari Dino        23.32
#> Maserati Bora       18.54
#> Volvo 142E          25.51
#>
#> [[5]]
#>                        mpg
#> Mazda RX4           23.620
#> Mazda RX4 Wag       23.875
#> Datsun 710          25.120
#> Hornet 4 Drive      24.615
#> Valiant             21.560
#> Duster 360          17.870
#> Merc 240D           27.590
#> Merc 230            25.950
#> Merc 280            22.640
#> Merc 280C           21.240
#> Merc 450SE          20.470
#> Merc 450SL          21.030
#> Merc 450SLC         18.980
#> Lincoln Continental 15.824
#> Chrysler Imperial   20.045
#> Fiat 128            34.600
#> Honda Civic         32.015
#> Toyota Corolla      35.735
#> Toyota Corona       23.965
#> Dodge Challenger    19.020
#> AMC Javelin         18.635
#> Camaro Z28          17.140
#> Pontiac Firebird    23.045
#> Fiat X1-9           29.235
#> Porsche 914-2       28.140
#> Lotus Europa        31.913
#> Ford Pantera L      18.970
#> Ferrari Dino        22.470
#> Maserati Bora       18.570
#> Volvo 142E          24.180
#>
#> [[6]]
#>                       mpg
#> Mazda RX4           37.46
#> Mazda RX4 Wag       38.02
#> Datsun 710          41.41
#> Hornet 4 Drive      40.84
#> Valiant             38.32
#> Duster 360          30.14
#> Merc 240D           44.40
#> Merc 230            45.70
#> Merc 280            37.50
#> Merc 280C           36.70
#> Merc 450SE          33.80
#> Merc 450SL          34.90
#> Merc 450SLC         33.20
#> Lincoln Continental 28.22
#> Chrysler Imperial   32.12
#> Fiat 128            51.87
#> Honda Civic         48.92
#> Toyota Corolla      53.80
#> Toyota Corona       41.51
#> Dodge Challenger    32.37
#> AMC Javelin         32.50
#> Camaro Z28          28.71
#> Pontiac Firebird    36.25
#> Fiat X1-9           46.20
#> Porsche 914-2       42.70
#> Lotus Europa        47.30
#> Ford Pantera L      30.30
#> Ferrari Dino        35.20
#> Maserati Bora       29.60
#> Volvo 142E          40.00
#>
#> [[7]]
#>                      mpg
#> Mazda RX4           21.0
#> Mazda RX4 Wag       21.0
#> Datsun 710          23.8
#> Hornet 4 Drive      22.4
#> Valiant             19.1
#> Duster 360          14.3
#> Merc 240D           25.4
#> Merc 230            23.8
#> Merc 280            20.2
#> Merc 280C           18.8
#> Merc 450SE          16.4
#> Merc 450SL          17.3
#> Merc 450SLC         15.2
#> Lincoln Continental 10.4
#> Chrysler Imperial   14.7
#> Fiat 128            33.4
#> Honda Civic         31.4
#> Toyota Corolla      34.9
#> Toyota Corona       22.5
#> Dodge Challenger    15.5
#> AMC Javelin         15.2
#> Camaro Z28          13.3
#> Pontiac Firebird    19.2
#> Fiat X1-9           28.3
#> Porsche 914-2       26.0
#> Lotus Europa        31.4
#> Ford Pantera L      15.8
#> Ferrari Dino        19.7
#> Maserati Bora       15.0
#> Volvo 142E          22.4
#>
#> [[8]]
#>                      mpg
#> Mazda RX4           22.0
#> Mazda RX4 Wag       22.0
#> Datsun 710          23.8
#> Hornet 4 Drive      21.4
#> Valiant             18.1
#> Duster 360          14.3
#> Merc 240D           24.4
#> Merc 230            22.8
#> Merc 280            19.2
#> Merc 280C           17.8
#> Merc 450SE          16.4
#> Merc 450SL          17.3
#> Merc 450SLC         15.2
#> Lincoln Continental 10.4
#> Chrysler Imperial   14.7
#> Fiat 128            33.4
#> Honda Civic         31.4
#> Toyota Corolla      34.9
#> Toyota Corona       21.5
#> Dodge Challenger    15.5
#> AMC Javelin         15.2
#> Camaro Z28          13.3
#> Pontiac Firebird    19.2
#> Fiat X1-9           28.3
#> Porsche 914-2       27.0
#> Lotus Europa        31.4
#> Ford Pantera L      16.8
#> Ferrari Dino        20.7
#> Maserati Bora       16.0
#> Volvo 142E          22.4
#>
#> [[9]]
#>                      mpg
#> Mazda RX4           25.0
#> Mazda RX4 Wag       25.0
#> Datsun 710          26.8
#> Hornet 4 Drive      24.4
#> Valiant             21.1
#> Duster 360          17.3
#> Merc 240D           28.4
#> Merc 230            26.8
#> Merc 280            23.2
#> Merc 280C           21.8
#> Merc 450SE          19.4
#> Merc 450SL          20.3
#> Merc 450SLC         18.2
#> Lincoln Continental 13.4
#> Chrysler Imperial   17.7
#> Fiat 128            36.4
#> Honda Civic         34.4
#> Toyota Corolla      37.9
#> Toyota Corona       24.5
#> Dodge Challenger    18.5
#> AMC Javelin         18.2
#> Camaro Z28          16.3
#> Pontiac Firebird    22.2
#> Fiat X1-9           31.3
#> Porsche 914-2       31.0
#> Lotus Europa        35.4
#> Ford Pantera L      20.8
#> Ferrari Dino        24.7
#> Maserati Bora       20.0
#> Volvo 142E          25.4
#>
#> [[10]]
#>                      mpg
#> Mazda RX4           25.0
#> Mazda RX4 Wag       25.0
#> Datsun 710          23.8
#> Hornet 4 Drive      22.4
#> Valiant             19.1
#> Duster 360          18.3
#> Merc 240D           26.4
#> Merc 230            24.8
#> Merc 280            23.2
#> Merc 280C           21.8
#> Merc 450SE          19.4
#> Merc 450SL          20.3
#> Merc 450SLC         18.2
#> Lincoln Continental 14.4
#> Chrysler Imperial   18.7
#> Fiat 128            33.4
#> Honda Civic         32.4
#> Toyota Corolla      34.9
#> Toyota Corona       22.5
#> Dodge Challenger    17.5
#> AMC Javelin         17.2
#> Camaro Z28          17.3
#> Pontiac Firebird    21.2
#> Fiat X1-9           28.3
#> Porsche 914-2       28.0
#> Lotus Europa        32.4
#> Ford Pantera L      19.8
#> Ferrari Dino        25.7
#> Maserati Bora       23.0
#> Volvo 142E          23.4
``````

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.