I am trying to read some data from a csv data in R and then compute a t-test function but I am getting an error that there is an unexpected symbol in label.
This is my code :
library(tidyverse)
library(magrittr)
library(dplyr)
labels <- list('non-failing heart (NF)', 'failing heart (F)')
data <- read.csv("C:\\Users\\alex\\Downloads\\data.csv", header=T)
data[data == 'NA_integer_'] <- NA
data %>% mutate_all(as.numeric) -> data
t.test(data$NF, data$F)
df <- setNames(do.call(rbind.data.frame,
lapply(data, function(d) data.frame(d[1], d[2]))),
labels)
results <- t.test(df$`non-failing heart (NF)`, df$`failing heart (F)`)
results$statistic
results$estimate
results$p.value
and this the error :
Error: unexpected Symbol in:
" labels)
results"
> results$statistic
Error: Object 'results' not found
This is how my data looks like: