mercredi 18 avril 2018

switch bloc do not store dataframe in R

I have a very basic question while I am not able to understand where it breaks. I am doing a switch between two block to read_delim within two conditions

A <- function(type) {
  switch(type,
     AA= {
},  

AB= {

  print('i am in the condition') 

 x <- as.data.frame(read_delim("x.txt", delim = "\t",locale=locale(decimal_mark = ",")))

  print('Read from x.txt')   

})
}

A('AB')

The second block return the two prints but the dataframe is not stored in x. Doing it manually is working.

Any help?

I appreciate your time

Aucun commentaire:

Enregistrer un commentaire