Override default CSV import in new R studio (R version 3.4.0)

I recently downloaded and installed the latest versions of R / Rstudio and noticed that one of the new changes is that when importing csv, Rstudio now imports the file as a chunk by default. While I understand that the developers had very good reasons for making this change, I personally find it extremely annoying.

Many of the data files I work with have many (> 10) columns and many of the functions that I often use to view data (like head (), tail (), or even pulling certain rows out of data, such as data [1: 5,]) don't work as we would like. In particular, using these functions in a nibble results in the right-most columns not being displayed, which is extremely problematic, since I am often interested in these columns. Even though I haven't worked with this new version for a very long time, I'm already tired of using the View () function every time I want to view the data or transform each imported file using as.data.frame () so that my data is displayed as we would like. While I realize this probably seems like a pretty minor issue, it seems to me personally,that coding is often so frustrating that adding any additional problems or difficulties makes coding more difficult and time consuming.

Just to keep my own sanity, is there a way to override this default and make it so all csv imports are imported as dataframes and not in chiba?

+3


source to share


2 answers


This may not be exactly what you are looking for, but you can change the printing method for tibbles so that they are printed as data.frames.



library(tibble)
tibble_iris = as.tibble(iris)
head(tibble_iris)
# # A tibble: 6 x 5
#         Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#           <dbl>       <dbl>        <dbl>       <dbl>  <fctr>
# 1          5.1         3.5          1.4         0.2  setosa
# 2          4.9         3.0          1.4         0.2  setosa
# 3          4.7         3.2          1.3         0.2  setosa
# 4          4.6         3.1          1.5         0.2  setosa
# 5          5.0         3.6          1.4         0.2  setosa
# 6          5.4         3.9          1.7         0.4  setosa

# here we change print method
# it is needed only once at the begining of your script 
print.tbl_df = print.data.frame

# check that new 'print' method will be used
head(tibble_iris)
#   Sepal.Length Sepal.Width Petal.Length Petal.Width Species
# 1          5.1         3.5          1.4         0.2  setosa
# 2          4.9         3.0          1.4         0.2  setosa
# 3          4.7         3.2          1.3         0.2  setosa
# 4          4.6         3.1          1.5         0.2  setosa
# 5          5.0         3.6          1.4         0.2  setosa
# 6          5.4         3.9          1.7         0.4  setosa

      

+1


source


@yeedle correctly describes how you can change read_csv

to read.csv

in the import window, but @Marius provided a better answer. You have to overcome your frustration with coding because it will save you time in the long run (i.e. you have to worry about new import data values ​​in the GUI).

read.csv

still works the same, although the GUI has changed ... you must enter:



read.csv("TAB

Select the file you want to download using the arrow keys and hitting enter and then enter ,TAB

and all options will be displayed read.csv

.

0


source







All Articles