How can I copy and paste data into R? For example, you see a small data set on the web, perhaps in a blog or here on StackOverflow, and you want that data set in your R session. This is a common task for many of us, and there are several ways to go about. Below I present a solution based on this blog post that I have found useful.
First, copy (e.g. “⌘ + C”) the data set.
Then, paste (e.g. “⌘ + V”) to create an R character vector:
x <- " A B C D
1: 2 2 5 3
2: 2 1 2 3
3: 3 4 4 3"
Next, use the read.table() function:
y <- read.table(text = x, header = TRUE)
Done! The data is now in a data frame:
Lately I have been struggling to find a way to accomplish a line break in an R Markdown Report / Notebook. It is in fact described in the RStudio documentation, but it is rather difficult to find and not so well explained. This is what they have to say about it:
A backslash followed by a newline is also a hard line break.
Easy to overlook, and perhaps not so pedagogical.
What they mean is this:
That is, a backslash ( \ ) followed by two space characters ( ⎵⎵ ).
A Shiny module is a piece of code that is included as part of a larger Shiny app. I wrote this small Shiny app as I could not find a really simple example elsewhere. It is based on the “Hello Shiny” example that comes with the Shiny package. You can run it with:
Hello Shiny is a simple application that uses the sidebarLayout, with a sliderInput in the sidebarPanel and a histogram displayed in the mainPanel. My Shiny app modularizes the sidebarPanel part of the sidebarLayout.
You can see it in action here: https://xplor.shinyapps.io/module_example_1
The code is available here: https://github.com/samuel-bohman/module_example_1
Comment below if this was helpful to you.
Added a second version of modularized “Hello Shiny” that uses renderUI in the module that switches between two sliderInput functions.
You can see it in action here: https://xplor.shinyapps.io/module_example_2/
The code is available here: https://github.com/samuel-bohman/module_example_2
Add R repository
sudo echo "deb http://cran.rstudio.com/bin/linux/ubuntu xenial/" | sudo tee -a /etc/apt/sources.list
Add R to Ubuntu Keyring
gpg --keyserver keyserver.ubuntu.com --recv-key E084DAB9
gpg -a --export E084DAB9 | sudo apt-key add -
sudo apt-get update
sudo apt-get install r-base r-base-dev
sudo apt-get install libcurl4-openssl-dev
sudo apt-get install gdebi-core
sudo gdebi -n rstudio-1.0.44-amd64.deb
“One of the idiosyncrasies of Windows is that directory creation may report success but create a directory with a different name, for example dir.create(“G.S.”) creates ‘”G.S”’. This is undocumented, and what are the precise circumstances is unknown (and might depend on the version of Windows). Also avoid directory names with a trailing space. Check it out in the R Documentation by typing ?dir.create() in the R console.