반응형 R71 (R) Combining Data frame, matrix and vectors using rbind, cbind / Merging data frames using merge() Combining Data frame If you have the two data frame which has the same length of columns and same column names (x,y), you can combine the data frames in a data frame with the columns in common. If the name of variables in columns are different, it prints out the error. > dat2 = data.frame(x = 3:5, y = rep(2, 3))> dat1=data.frame(x=1:6, y=rep(1,6))> dat1 x y1 1 12 2 13 3 14 4 15 5 16 6 1> dat2 = .. 2020. 11. 7. (R) Make a new variable (ex,quantile) >library(MASS)>View(painters) WAY1 EXAMPLE 1) > painters$Drawing.ind=painters$Drawing>=mean(painters$Drawing)> View(painters) #You can see that there is a new variable Drawing.ind > head(painters) Composition Drawing Colour Expression SchoolDa Udine 10 8 16 3 ADa Vinci 15 16 4 14 ADel Piombo 8 13 16 7 ADel Sarto 12 16 9 8 AFr. Penni 0 15 8 0 AGuilio Romano 15 16 4 14 A Drawing.indDa Udine FALSED.. 2020. 11. 5. (R) Extract rows and columns from data frame with conditions library(MASS)View(painters) When you try to adjust Rows ,that is trying to extract some rows that satisfies some conditions, you must handle left side of the comma in the bracket. Such as painters[(Conditions you want to see in rows) , ]. In contrast, you will see what happens when you want to handle the column of data frames. In summary, left side of the bracket is for rows and the right side i.. 2020. 11. 5. (R)Wilkinson dot plot (+boxplot) > library(ggplot2) > str(mpg) tibble [234 x 11] (S3: tbl_df/tbl/data.frame) $ manufacturer: chr [1:234] "audi" "audi" "audi" "audi" ... $ model : chr [1:234] "a4" "a4" "a4" "a4" ... $ displ : num [1:234] 1.8 1.8 2 2 2.8 2.8 3.1 1.8 1.8 2 ... $ year : int [1:234] 1999 1999 2008 2008 1999 1999 2008 1999 1999 2008 ... $ cyl : int [1:234] 4 4 4 4 6 6 6 4 4 4 ... $ trans : chr [1:234] "auto(l5)" "man.. 2020. 10. 29. 이전 1 2 3 4 5 6 7 8 ··· 18 다음 반응형