gene_a <- 120
gene_b <- 200
gene_a + gene_b
## [1] 320
500000 * 600000
## [1] 3e+11
control <- 300
treated <- 150
treated / control
## [1] 0.5
1001000 %% 250000
## [1] 1000
gene_x_count <- 350
gene_x_count
## [1] 350
patient_a <- 100
patient_b <- 120
patient_a + patient_b
## [1] 220
patient_b <- 130
patient_a + patient_b
## [1] 230
marker_gene <- "CD274"
marker_gene
## [1] "CD274"
x <- 100
class(x)
## [1] "numeric"
gene_name <- "TP53"
class(gene_name)
## [1] "character"
is_marker <- TRUE
class(is_marker)
## [1] "logical"
counts <- c(120, 150, 130)
counts
## [1] 120 150 130
names(counts) <- c("TP53", "BRCA1", "EGFR")
counts
## TP53 BRCA1 EGFR
## 120 150 130
counts
## TP53 BRCA1 EGFR
## 120 150 130
names(counts)
## [1] "TP53" "BRCA1" "EGFR"
counts["EGFR"]
## EGFR
## 130
counts[1:2]
## TP53 BRCA1
## 120 150
samples <- c("Sample1", "Sample2", "Sample3")
samples
## [1] "Sample1" "Sample2" "Sample3"
genes <- c("TP53", "BRCA1", "EGFR")
counts <- c(120, 150, 130)
names(counts) <- genes
counts
## TP53 BRCA1 EGFR
## 120 150 130
class(counts)
## [1] "numeric"
patient_ids <- paste("Patient", 1:5, sep = "_")
patient_ids
## [1] "Patient_1" "Patient_2" "Patient_3" "Patient_4" "Patient_5"
mixed_vector <- c("TP53", 100, TRUE)
class(mixed_vector)
## [1] "character"
mixed_vector
## [1] "TP53" "100" "TRUE"
as.numeric("150")
## [1] 150
x <- 5
y <- "6"
x + y
## Error in `x + y`:
## ! non-numeric argument to binary operator
it fail because we are adding number to string/character.
x <- 5
y <- "6"
x + as.numeric(y)
## [1] 11
counts <- c(TP53 = 120, BRCA1 = 90, EGFR = 310)
counts[counts > 100]
## TP53 EGFR
## 120 310