I am trying to print a string followed by ": [tab]" and then a number. The relevant part of my code looks like:
print(paste("Name",5, sep=":\t"))
But this gives me
"Name:\t5"
. I have tried:
print(paste("Name",5, sep=cat(":\t")))
but this gives me:
Error in paste("Name", 5, sep = cat(":\t")) :
invalid separator
I'm pretty sure the problem is related to the issue discussed in this email thread but I don't understand the solution.
The way to tell R that you mean the tab character is to say "\t" .
To read tab-separated values files with Python, we'll take advantage of the fact that they're similar to CSVs. We'll use Python's csv library and tell it to split things up with tabs instead of commas. Just set the delimiter argument to "\t" . That's it!
First, as with many things in R, there are many ways of bringing data into your workspace. A flexible way to import data is to click on the Environment tab in the upper right window of RStudio and then click the Import Dataset tab. Multiple file type options are shown, such as text, Excel, SPSS, SAS, and Stata.
You can go as follows:
cat("Name","\t", 5, "\n")
When you need help on a function, just type in the name of that function in your R GUI preceded by ?
, eg ?cat
.
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