0

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:

enter image description here

henrik_ibsen
  • 763
  • 1
  • 7
  • 16
Anouar
  • 191
  • 4
  • 14
  • 2
    That is a syntax error: it is saying that the expressions in your code are not formed properly (e.g. there is a missing comma). It never gets to the stage of reading the dataset. However, I don't get the error from what you posted: you need to look for a typo in the original. – user2554330 Oct 21 '20 at 14:50
  • @user2554330 thanks for your comment, this is also ehat I understand from the error after some searchs in Google but I didn't find what is exactly missing, what do you mean by a typo in the original ? – Anouar Oct 21 '20 at 14:57
  • I think the code where you saw the error is not identical to what you posted here, because I don't get that error from what you posted. – user2554330 Oct 21 '20 at 15:02
  • @user2554330 I have copied from R studio, it is the same code – Anouar Oct 21 '20 at 15:04
  • Okay, but I don't understand what the connection is to R Markdown. – user2554330 Oct 21 '20 at 15:27
  • @user2554330 the code is written in rmd file and what is posted is a included in a form of chunk, by the way, this error is strangely gone, I am getting now some errors of : Problem with `mutate()` input `NF.F`. i NAs durch Umwandlung erzeugt i Input `NF.F` is `.Primitive("as.double")(NF.F)`. 2: In mask$eval_all_mutate(dots[[i]]) : NAs durch Umwandlung erzeugt – Anouar Oct 21 '20 at 15:33
  • @user2554330 sorry I didn't remark that there is some german errors such as durch Umwandlung erzeugt which is mean generated by conversion – Anouar Oct 21 '20 at 15:36
  • @Anouar from which line does the error rise – Abdessabour Mtk Oct 23 '20 at 16:13

0 Answers0