Outputting a Dataframe in R to a .csv

后端 未结 3 609
滥情空心
滥情空心 2021-02-07 03:16

So I\'m trying to write a .csv file based on a data frame in R, but for some reason I keep getting the following error:

Error in .External2(C_writetable, x, file         


        
3条回答
  •  旧巷少年郎
    2021-02-07 03:59

    You can also coerce data frames directly in R:

    my.df <- data.frame(lapply(old.df, as.character), stringsAsFactors=FALSE)
    

    CAVEAT: this will coerce your entire dataframe to whatever type you specify. For example, if you want to coerce your dataframe to number, you would replace 'as.characater' with 'as.numeric':

     my.df <- data.frame(lapply(old.df, as.numeric), stringsAsFactors=FALSE)
    

提交回复
热议问题