From e41cfd4741b332e8512aad6befb9ad2d335eda5b Mon Sep 17 00:00:00 2001 From: Mirindi Kabangu <51299666+MKabangu@users.noreply.github.com> Date: Tue, 20 Apr 2021 01:00:49 -0400 Subject: [PATCH] Moved data frame comments Will make commands easier to read and understand. --- 02-intro2R.Rmd | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/02-intro2R.Rmd b/02-intro2R.Rmd index 24a015d..00cbce8 100644 --- a/02-intro2R.Rmd +++ b/02-intro2R.Rmd @@ -252,11 +252,10 @@ chr <- c("chr1", "chr1", "chr2", "chr2") strand <- c("-","-","+","+") start<- c(200,4000,100,400) end<-c(250,410,200,450) -mydata <- data.frame(chr,start,end,strand) -#change column names -names(mydata) <- c("chr","start","end","strand") -mydata # OR this will work too -mydata <- data.frame(chr=chr,start=start,end=end,strand=strand) +mydata <- data.frame(chr,start,end,strand) # create data frame +names(mydata) <- c("chr","start","end","strand") # change column names +mydata +mydata <- data.frame(chr=chr,start=start,end=end,strand=strand) # OR this will work too mydata ``` There are a variety of ways to extract the elements of a data frame. You can extract certain columns using column numbers or names, or you can extract certain rows by using row numbers. You can also extract data using logical arguments, such as extracting all rows that have a value in a column larger than your threshold.