我怎樣才能變換數據X到Y在 X = data.frame(
ID = c(1,1,1,2,2),
NAME = c("MIKE","MIKE","MIKE","LUCY","LUCY"),
SEX = c("MALE","MALE","MALE","FEMALE","FEMALE"),
TEST = c(1,2,3,1,2),
SCORE = c(7
我的數據幀主要包含catagorical列和一個數值列,對DF看起來像這樣(簡化): **Home_type** **Garden_type** **NaighbourhoOd** **Rent**
Vila big brooklyn 5000
Vila small bronx 7000
Condo shared Sillicon val
我有一個數據幀如下 id gender group Student_Math_1 Student_Math_2 Student_Read_1 Student_Read_2
46 M Red 23 45 37 56
46 M Red 34 36 33 78
46 M Red 56 63 58
62 F Blue 59
我有兩個變量與多個級別; V1有400級,V2有≈250級。我怎樣才能將V2的因素轉換成幾個不同的變量,並將變量V1作爲唯一標識符? V1 V2
Garza, Mike a
Garza, Mike b
Smith, James a
Smith, James f
Smith, James z
Moore, Jen b
Klein, April f
數據幀應該看起來像下面的例
我需要gather_在數據幀的所有列上,除了一個。例如: # I want to generate a dataframe whose column names are the letters of the alphabet. If you know of a simpler way, let me know!
foo <- as.data.frame(matrix(runif(100), 10
我有一個數據框,並希望將其從寬轉換爲長格式,但我有三個變量,而ref = RR_ref,het = RR_het和hom = RR_hom。 df:
Number ref het RR_het hom RR_hom RR_ref
mary GG AG 0.29 AA 0.0841 1
wayne AA AG 1.7 GG 2.89 1
structure(list(Number = c