Im studying about data but there is a problem. There is a lot of data that I use to study but everytime I want to load the data with read_csv() I use a lot of time to change \ to /.
My files are locaten like this C:\\Users\\Me\\Desktop\\Data\\hotel_bookings.csv
So I can not do;
x <- "C:\Users\Me\Desktop\Data\hotel_bookings.csv"
Because my folder directory saves as \ not as \\
One of the solitions I found is
hotel <- read_csv(file.choose())
The other one is also
path <- "C:\\Users\\Me\\Desktop\\Data\\hotel_bookings.csv"
path <- normalizePath(path)
hotel <- read_csv(path)
but still takes time to insert an extra \.
Need an easier way to get my file location that contains all /
Since R 4.0.0, you can use raw character constants (mentioned on r-devel NEWS):
There is a new syntax for specifying raw character constants similar to the one used in C++:
r"(...)"with...any character sequence not containing the sequence ‘)"’. This makes it easier to write strings that contain backslashes or both single and double quotes.
x <- r"(C:\Users\Me\Desktop\Data\hotel_bookings.csv)"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With