vendredi 5 octobre 2018

Can not get any results with return (x), how to extract function result? [duplicate]

This question already has an answer here:

Dear StackOverflow community, I'm new at coding and I've been trying to work with R for my P.hD. thesis. This is the first function that I wrote and it seems to not return(x) the final result.

import_variable_N_columns <- function(x) {
  if (ncol(x) > 3) {
    x <- x[c(1, 2, 3)]
    return(x)
  }
}
import_variable_N_columns(lh_pial_surfarea_1)

The result also have 4 columns, and I want just the first three. Do you have any suggestions?

Thank you, Fernanda

Aucun commentaire:

Enregistrer un commentaire