FAQ Database Discussion Community

## Problems with edges in R plotting

r,graph,plot,rstudio,edges
I'm having a hard time dealing with cutting edges in R plots. The problem: Code: x <- c(130, 145, 170, 175, 180) y <- c(0.00172225, 0.00207025, 0.002304, 0.0025, 0.002704)*1000 plot(x,y,pch=20) fit <- lm(y~x) xx <- seq(120,190, length=50) plot(x,y,xlab=(expression('U'~~'[V]')),main=expression(atop(Something)), ylab=expression(r[1]^2~~"[mm]"),pch=19,xlim=c(120, 190), ylim=c(0.001,0.003)*1000) xHigh <- x+5 yHigh <- y+c(0.083, 0.091, 0.096, 0.100,...

## Howto include js dependencies of DT datatable in Rmarkdown using knitr and pandoc

r,datatable,rstudio,rmarkdown
Is there a way to compile RMarkdown documents with datatables produced by DT outside of RStudio? I'm trying to include a datatable widget in an RMarkdown document that I then want to convert to html using knitr and pandoc. This works fine with RStudio but if I try to do...

r,rstudio

## Error in RStudio with read.table(url…)

r,url,rstudio
I tried to run the code below in RStudio, it always returns the error message of connection failure. It works in RGui. Any idea why this is and how to fix it? Is it problem with my Rstudio (I'm running Windows 8)? survey <- read.table(url("ftp://ftp.ics.uci.edu/pub/machine-learning-databases/adult/adult.data"), header=FALSE, sep=",", quote="", stringsAsFactors=FALSE) Error...

## Render font size of maths in Rmarkdown slides when viewed in then Rstudio viewer

r,markdown,rstudio,rmarkdown,mathjax
Writing some slides for lecture. I want to include a shiny app. I do not have admin rights on the lecture room computer, which means I can run my Rmd file and present the slides via the Rstudio viewer, but they will not display in a web browser. All the...

## Show and report function outputs in “R” programming language

r,rstudio
In R programming language and package pcaPP I have this code: # multivariate data with outliers library(mvtnorm) library(pcaPP) x <- rbind(rmvnorm(200, rep(0, 6), diag(c(5, rep(1,5)))), rmvnorm( 15, c(0, rep(20, 5)), diag(rep(1, 6)))) # Here we calculate the principal components with PCAgrid pc <- PCAproj(x) Here is documentation for the output...

## Using R Studio Console commands not parsed in Knitr markdown file

r,rstudio,knitr
Forgive the very basic question but I'm having some trouble getting the knitr feature to work just like typing in the console. To recreate Download this csv file https://s3.amazonaws.com/udacity-hosted-downloads/ud651/reddit.csv Import it into R Studio calling it reddit so it appears in the Global Environment area of the IDE, Do this...

## ordering non-decreasing functions then adding them in R

r,function,order,sequence,rstudio
Need help with basic R function: Firstly order non-decreasing sequence from 4 different sequences and then order those 4 sequences into one. Im totally green in programing so please make it the simplest way possible. Edit1: puting some input data as required A={3,2,1,2} B={6,7,5,8} C={12,11,9,10} D={65,43,76,13} I would like it...

## Keep getting errors when trying to knit a PDF using R Markdown

r,rstudio,knitr,rmarkdown
cross-post from /r/RStudio Hello everybody, So I've attempted to troubleshoot this issue for about 4 hours last night with no luck. I've looked through all the similar issues in the RStudio community and attempted all the suggested "fixes", but still haven't been able to get this darn thing to work....

## RQDA batch file import not working

r,rstudio
I am trying to import multiple files into RQDA like this: #install.packages("RQDA") library(RQDA) #import list of files into program files<-list.files("C:\\Users\\blah\\Desktop\\SNA_R_Class_code\\Texts") RQDA() setwd("C:\\Users\\blah\\Desktop\\SNA_R_Class_code") openProject("me_classify_class_texts.rqda") #this is a completely empty project I just created write.FileList(files) When I look at the RDQA GUI it shows no project open, I get the following message...

## The error when publishing a shiny app

r,shiny,rstudio,shinyapps
I want to publish my shiny app. For this I created an account in https://www.shinyapps.io/ Then, in RStudio, I go to Tools->Shiny Apps->Publish Apps and paste the token, account and secret information. Finally, I get the error: Error: /v1/users/current/ 426 - shinyapps package out of date. To update visit: https://github.com/rstudio/shinyapps...

## Change background colour of rmarkdown pdf output

r,pdf,render,rstudio,rmarkdown
I am currently using RStudio 0.98.1091 and I am trying to create a pdf document with the render function from the rmarkdown package. R script: library("rmarkdown") render("input.Rmd", "pdf_document") input.Rmd --- title: "Report" output: pdf_document --- <style> body {background-color:lightgray} </style> <body> <h1>This is a heading</h1> <p>This is a paragraph.</p> </body> I...

## R execute script/function during installation

r,installation,rstudio,devtools
I am developing a package and I would like to know what is the best way to execute a script at installation time. Essentially I want to make sure that third-party tools are installed, retrieve them when I can and raise an error if some dependency is missing. I am...

## how to extract specific paragraphs from a text file in R [closed]

regex,r,rstudio,text-processing
I'm using R studio to process a text file which has textual data in the following form: * A name A date A referene number A text....bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla...

## Errors while installing Rstudio

r,rstudio
I am trying to install Rstudio. I have downloaded the rstudio-0.98.1103-deb package. This is the error I am getting when I do: sudo dpkg -i rstudio-0.98.1103-amd64.deb How do I go about the installation? Any suggestions would be great. I am on Ubuntu 14.04. ...

## Is it possible to schedule a script to run automatically in RStudio server? [duplicate]

r,rstudio,rstudio-server
This question already has an answer here: Schedule R script using cron 1 answer I was just wondering if it is possible to schedule a script to run automatically (e.g. every Monday) on RStudio server?...

## using -knitr- to weave Rnw files in RStudio

r,rstudio,knitr
This seems to be a recurrent problem for who is willing to write dynamic documents with knitr in RStudio (see also here for instance). Unfortunately I haven't find a solution on Stack Overflow or by googling more in general. Here is a toy example I am trying to compile in...

## Copy/paste table into gmail

r,gmail,rstudio
This is probably an easy answer, but I can't find anything online about it. Is there an easy way to copy/paste a table from the R console to an email message?

## Plot a histogram of means and label individual mean/PDF

r,plot,rstudio
So I have this plot which is showing average scores of group of people. I would like to know how to, in the same picture, plot or lable X (see the picture, I added X with paint), where X presents the mean of one student compared to others. My code...

## Converting non-standard file to .csv in R

r,file,csv,rstudio,file-conversion
Some of the output files I use are non-standard, space delimited formats with non-standard extensions (.out) that only have meaning to a particular program I use. For example, I might get an output file for water budgets that looks like: waterbalance.out I can open these files in Excel by opening...

## .Rd file generation in a package using Rcpp

r,rstudio,rcpp
I created a test package containing Rcpp code using Rcpp.package.skeleton() command. All the required files as per vignette were generated and I was able to compile the package. I tried to add roxygen2 style comments to the example code #include <Rcpp.h> using namespace Rcpp; //' @param none required //' @return...

## Shiny Presentation (ioslides): Custom CSS and logo Windows 7/8

css,r,shiny,rstudio
I don't yet have the rep to comment on an answer to an existing question so this a follow-up to the question: Shiny Presentation (ioslides): Custom CSS and logo This question was thought to be solved by fix 385bb28 on the Rstudio Github site. However, the issue has not resolved...

## Modifying a Tukey HSD 95% family-wise CL plot in Rstudio

r,plot,rstudio
I wanted to know how I could change the axis of a plot of Tukey's HSD so I could shorten the words to make each comparison fit and not look ridiculous. It would help a lot if you could help me with codes for changing axis labels, font size and...

## Finding the period with the highest rolling sum per category

r,rstudio
Here's the thing. I have rather large set of data (1,5 million rows) that represents 40k clients and some metrics about them for each of 40+ months, so data looks more or less like this: CLIENTID| MONTHID| VALUE --------|--------|------- client1 | month1 | value1 client1 | month2 | value2 client1...

## Is there any direct method to fetch data from a Couchbase server to R Studio?

rstudio,couchbase
I'm fairly new to this issue with virtually no experience with Couchbase, so i might just overlooked some easy and direct way to access data contained in it to R Studio. Do you guys know about a solution? Do i have to process such queries through some other platforms? Any...

## What's the difference in using a semicolon or explicit new line in R code

r,rstudio
I originally thought that the semicolon ; was the equivalent to adding an explicit new line, e.g. x <- 1; y <- 2 is the same as x <- 1 x <- 2 Certainly the R documentation doesn't seem to make a distinction with respect to syntactically complete statements: Both...

## Convert a date to a day number (monday = 1, tuesday = 2) in R

r,date,numbers,rstudio,data-type-conversion
Can someone help me with the following: I have a date, for example: 3-1-2014, And I would like to convert this to the number 5, because it is a friday. So 7-1-2014 would be 1, because it is a monday. Which package/code can do this for me? Thanks...

## Generating LaTeX tables instead of text in Rstudio

r,latex,rstudio
I am new to latex, and would like to generate PDF tables instead of text so my example is: in my METHOD.tex file I have this text: In the first group there were: AAA: items: BBB: items2 and: CCC: items3. We assessed: EEE: implementations. Of the total: VVV: objects to...

## Rstudio 0.98.1028 add background image only to title slide

css,r,rstudio,rmarkdown
I am attempting to create a R Presentation (.Rpres) using RStudio 0.98.1028 with a different background image on the title slide and another background image on the rest of the slides. I am able to place a custom background (foo.png) by creating a css file with this in it: body...

## How do I put multiple boxplots in the same graph in R?

r,plot,ggplot2,rstudio,boxplot
Sorry I don't have example code for this question. All I want to know is if it is possible to create multiple side-by-side boxplots in R representing different columns/variables within my data frame. Each boxplot would also only represent a single variable--I would like to set the y-scale to a...

## Save View() output of RStudio as html

r,rstudio
Is it possible to save the page which I see when use View() command in RStudio on some data as an html file?

## Source R script using 32 bit R from 64 bit RStudio

r,rstudio
On Win7 I have both 32 bit and 64 bit R installed. Because one can't ODBC to 32 bit MS Access from 64 bit R, I want to source an R script using the 32 bit version of R. From this SO question I understand that I can launch 32...

## Connecting RStudio with Remote R machine

I have RStudio installed on my Windows machine and R installed on one of the nodes of a hadoop cluster. I want to connect RStudio to that slave machine and want to run my R script. I have all the R packages required for hadoop integration installed on that slave...

## Extracting text after “?” in R

r,pattern-matching,rstudio
I have a string x <- "Name of the Student? Michael Sneider" I want to extract "Michael Sneider" out of it. I have used: str_extract_all(x,"[a-z]+") str_extract_all(data,"\\?[a-z]+") But can't extract the name....

## Highlighting bash code with knitr / rmarkdown

r,syntax-highlighting,rstudio,knitr,rmarkdown
I'm trying to generate an HTML report using RStudio, R Markdown and knitr. In the report I would like to display some bash code. I do not want to run the code but I would like it to be highlighted. It has been mentioned in another question but the suggestion...

## R how to use files in the same packages

r,rstudio
I am planing to do all my R scripts in the same package in order to move it easily between my friends. What I have done is created an R packages using R studio and the following files have been automatically generated: projectName.Rproj DESCRIPTION man NAMESPACE R Read-and-delete-me I created...

## Trying to make the command lines start plotting from the position zero with a vector as argument

r,rstudio
I'm trying to do a task, where I have to compare the histogram of a sample with poisson distribution of size 100, with the expected frequencies that they should have, so I did this. prob0 = dpois(0, 2.5) prob1 = dpois(1, 2.5) prob2 = dpois(2, 2.5) prob3 = dpois(3, 2.5)...

## Differences in R Markdown syntax highlighting for in-line code

r,syntax-highlighting,rstudio,rmarkdown
The following minimal R Markdown file minimal.Rmd produces different minimal.html output (via "Knit HTML" in RStudio) depending on my system. The first is the result on my Windows 8 machine. The second is the result on my Windows 7 (64-bit) machine. Differences: Red syntax highlighting on in-line code in Win8...

## increasing number of members in a list causes working list to not work

r,rstudio
I am making a list with a lot of members. With small number of members, it works fine. However, increasing members beyond a point causes it to not work. I tracked down the point at which it stops working and it's listed below. However, I don't see anything suspicious in...

## Creating a loop with character variables on R - for two-sample t.test

r,loops,rstudio
I am looking to do multiple two sample t.tests in R. I want to test 50 indicators that have two levels. So at first I used : t.test(m~f) Welch Two Sample t-test data: m by f t = 2.5733, df = 174.416, p-value = 0.01091 alternative hypothesis: true difference in...

## Shiny selectInput produces a list of numbers

r,shiny,rstudio
am wondering why this issue is happening and if there is a fix for it. I create the following sql query below: CompanyNames<-sqlQuery(connection, paste("SELECT Companynm", " FROM RiskMgm_Company", " WHERE CompanyID = ParentID", " ORDER BY Companynm")) CompanyNames comes in the form of a database. Now no matter how I...