I need help in Vector and Factor parts

H Hello I need help with these tasks only what I can do I write in the end please check someone and answer if they can help

  1. Fixed a Vekor named, with 20 random values ​​between 10 and 40
  2. a vector named imt with 50 values ​​randomly drawn from the interval 35 to 120
  3. a factor vector encoding the animals of the VP as 'h', 'k' and 'r' in random order.

a factor that divides the subjects into two groups according to the vector, one group containing values ​​greater than the mean and the other values ​​less than or equal to the mean. For this, it may be necessary to first create any vector with 50 digits, and then replace the digits with indexing.
Then determine the mean, standard deviation, corrected sample variance, and uncorrected sample variance of the first ZVA.

Also, give the following values: * the values ​​of the female VP's imt vector whose fixed values ​​are greater than 25. * the animals of the VP who are in the above-average group of the second factor and have imt values ​​below 100 * the sexes of the VP who have imt values ​​below 100 but above 45.

first task: fixed <-sample (15: 35,50, replace = T)
second: imt <-sample (35: 120,50, replace = T)
third: animals <-factor (c ("m", "f", "d"))

I'm learning that new so that would be very grateful for help

Per Google translate:

Hallo und Willkommen!

Mit freundlichen Grüßen ist der erste deutsche Beitrag, den ich gesehen habe, und ich weiß nicht, wie viele deutsche Sprecher in der Community sind. Hier.

Sie sollten sich der Bedeutung von [reproduzierbares Beispiel, Reprex genannt] bewusst sein (https://community.rstudio.com/t/faq-whats-a-reproducible-example-reprex-and-how-do-i-do-one/ 5219) und gegebenenfalls [Hausaufgabenrichtlinie] (FAQ: Homework Policy).

Könnten Sie ein "reprex" posten?

Hello I need help with these tasks only what I can do I write in the end please check someone and answer if they can help

  1. Fixed a Vekor named, with 20 random values ​​between 10 and 40
  2. a vector named imt with 50 values ​​randomly drawn from the interval 35 to 120
  3. a factor vector encoding the animals of the VP as 'h', 'k' and 'r' in random order.

a factor that divides the subjects into two groups according to the vector, one group containing values ​​greater than the mean and the other values ​​less than or equal to the mean. For this, it may be necessary to first create any vector with 50 digits, and then replace the digits with indexing.
Then determine the mean, standard deviation, corrected sample variance, and uncorrected sample variance of the first ZVA.

Also, give the following values: * the values ​​of the female VP's imt vector whose fixed values ​​are greater than 25. * the animals of the VP who are in the above-average group of the second factor and have imt values ​​below 100 * the sexes of the VP who have imt values ​​below 100 but above 45.

first task: fixed <-sample (15: 35,50, replace = T)
second: imt <-sample (35: 120,50, replace = T)
third: animals <-factor (c ("m", "f", "d"))

I'm learning that new so that would be very grateful for help

can u help with that Problems ? i will correct text

1 Like

This should get you started, I hope. Good luck! Come back with a reprex if you run into problems.

To take n random values from a vector without replacement:

# if you want to make reproducible include the next line
# set.seed(137)
sample(25:75, 15)
#>  [1] 29 74 36 39 54 61 50 67 28 52 35 68 51 49 47

Created on 2019-11-27 by the reprex package (v0.3.0)

To create a vector with random values of factors

# if you want to make reproducible include the next line
# set.seed(137)
tags <- factor(c("h", "k", "r"))
sample(tags, 15, replace = TRUE)
#>  [1] k h h k k h k r k k h k r k k
#> Levels: h k r

Created on 2019-11-27 by the reprex package (v0.3.0)

To subset a vector based on a value, such as its mean, standard deviation or a value (say, 42)

 grist <- sample(25:75, 1500, replace = TRUE)
 subset(grist, grist > mean(grist))
#>   [1] 63 64 56 60 56 66 62 53 69 56 56 68 58 62 66 56 51 56 56 59 52 72 53 61 65
#>  [26] 66 51 69 61 57 75 62 60 53 74 55 62 64 57 65 68 75 64 61 57 57 69 63 60 65
#>  [51] 50 52 71 58 72 59 68 68 63 68 63 62 62 53 75 66 55 67 65 67 60 52 51 70 69
#>  [76] 64 66 56 75 69 69 52 71 52 70 65 68 73 53 62 66 57 72 59 69 73 73 65 70 65
#> [101] 59 63 73 64 52 56 60 56 51 69 69 63 54 51 55 64 62 68 51 57 69 75 61 65 52
#> [126] 56 70 72 73 71 72 71 57 74 65 65 61 71 73 74 68 68 58 62 61 69 52 66 66 55
#> [151] 54 66 51 70 74 69 57 68 74 71 51 65 53 56 62 62 67 64 53 67 72 70 64 60 62
#> [176] 50 52 62 51 75 61 63 69 63 60 59 69 71 64 70 62 70 55 71 52 63 51 61 69 51
#> [201] 68 67 68 68 70 55 50 67 55 74 62 72 73 51 52 56 59 68 66 72 73 60 65 63 50
#> [226] 68 75 59 64 58 70 57 74 55 64 72 70 59 68 66 54 70 57 55 74 65 67 51 54 60
#> [251] 50 62 59 55 56 64 64 56 67 64 71 59 59 69 69 50 66 60 62 56 62 53 64 67 70
#> [276] 56 64 54 50 60 67 50 73 53 60 74 67 63 74 68 70 67 67 74 63 65 63 59 59 54
#> [301] 62 64 58 61 59 54 75 68 60 56 61 52 58 68 65 60 59 58 68 54 67 52 74 50 56
#> [326] 55 68 73 74 73 58 61 64 58 70 68 65 75 53 70 73 50 68 69 57 74 53 75 68 68
#> [351] 50 69 68 74 54 56 61 59 53 58 62 52 72 75 52 54 51 66 61 53 75 73 52 51 67
#> [376] 64 71 64 65 73 63 75 55 71 54 51 50 52 63 51 70 70 56 60 52 51 68 67 53 53
#> [401] 54 63 74 67 51 60 52 74 59 64 52 72 60 69 73 71 58 53 52 61 56 58 69 51 56
#> [426] 66 55 70 56 50 71 61 51 53 53 56 61 75 56 74 55 69 67 51 68 68 72 56 50 57
#> [451] 54 51 53 74 68 61 58 56 61 68 75 65 66 65 50 70 60 63 67 57 69 57 59 52 65
#> [476] 73 63 70 51 62 57 51 54 63 57 62 67 67 71 63 71 55 55 67 70 57 68 61 75 75
#> [501] 74 51 70 50 62 66 57 60 71 52 63 66 61 69 74 68 55 52 57 52 54 75 51 64 57
#> [526] 64 55 65 56 52 56 63 54 66 53 69 69 71 59 66 63 55 56 67 55 60 56 59 61 53
#> [551] 59 71 54 52 74 64 71 65 65 71 71 74 66 58 50 72 74 62 74 64 68 75 56 68 53
#> [576] 74 58 65 74 66 55 62 56 65 63 61 59 55 75 72 73 69 68 75 67 60 72 56 51 71
#> [601] 58 55 60 52 52 70 75 50 50 58 54 73 50 62 55 53 70 69 59 57 54 70 65 75 69
#> [626] 58 54 55 54 65 60 70 71 65 72 50 50 72 55 72 54 70 74 65 74 74 65 55 69 50
#> [651] 68 54 70 63 55 55 70 62 50 59 68 61 72 58 72 50 72 51 54 74 62 71 70 50 64
#> [676] 60 65 75 63 57 60 52 51 74 63 50 75 64 53 53 53 50 62 50 52 62 54 57 73 64
#> [701] 63 53 67 60 66 67 58 62 60 54 71 69 73 66 56 50 59 53 64 75 67 63 61 65 73
#> [726] 64 61 50 54 65 63 64 65 70 75 68 71 56 69 55 60 53 64 63 53 60 51 50 51 67
#> [751] 58 70 54 54 72 57 56 50 60

Created on 2019-11-27 by the reprex package (v0.3.0)

a factor that divides the subjects into two groups according to the vector test, where one group should contain values ​​greater than the mean and the other values ​​less than or equal to the mean. For this, it may be necessary to first create any vector with 50 digits, and then replace the digits with indexing.

means factor of test with valus<=mean , test with results > mean. how i write this in 1 Code
new Vector i make is : v<-c(1:50)

How would you modify this code to do that?

subset(your_vector, your_vector > mean(your_vector))

Also factor is a class in R with specific properties. Are you trying to create an object like the help example

(ff <- factor(substring("statistics", 1:10, 1:10), levels = letters))
#>  [1] s t a t i s t i c s
#> Levels: a b c d e f g h i j k l m n o p q r s t u v w x y z

Created on 2019-11-28 by the reprex package (v0.3.0)

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