Menu
  • HOME
  • TAGS

Plot width/height not obeyed after RStudio upgrade

r,rstudio,knitr,rmarkdown

You can override the CSS rule, e.g. add this to your document <style> img { max-width: none; } </style> or use a custom CSS file (see the documentation for html_document)....

R View() function does not show data frame

r,rstudio

The View function is from package 'utils' which is not supported by the version of R you are using.

Rmarkdown directing output file into a directory

r,rstudio,knitr,rmarkdown

You could try setting the out_dir variable in the function you are giving knit to render: knit: (function(inputFile, encoding) { out_dir <- 'test'; rmarkdown::render(inputFile, encoding=encoding, output_file=file.path(dirname(inputFile), out_dir, 'analysis.html')) }) ...

Plotting Modeled Data as my Regression Curve in R/RStudio

r,rstudio

First plot line x = c(1,2,3,4,5,6,7,8,9,10,11,12) y = c(.994,.954,.860,.721,.570,.434,.362,.244,.185,.142,.110,.087) plot(x, y, type = "l") Then points x=c(1.11,2.84,3.97,6.40,7.60,7.43,5.75,3.60,3.59) y=c(0.973,0.818,0.74,0.44,0.2688,0.282,0.50,0.613,0.656) points(x, y, col = "red") ...

Counting frequency of value in a column in a data frame in R not giving expected results

r,rstudio

You could try largedf <- totaldataset[Reduce(`|`, lapply(totaldataset[19:43], function(x) x=='4280')), ] ...

R execute script/function during installation

r,installation,rstudio,devtools

Scripts to be run before installation should be placed in an executable file called configure (will be executed on Linux/Unix/Mac computers) or in a file called configure.win (will be executed in Windows computers).

Problems with edges in R plotting

r,graph,plot,rstudio,edges

Before your plot(), increase the size of your left margin: par(mar=c(5,5,4,2)+.1) plot(x,y,pch=20) Base graphics simply provide a fixed number of lines on each side of the plot regardless of what you attempt to draw there....

Shiny selectInput produces a list of numbers

r,shiny,rstudio

Since your example isn't reproducible, I'm going to guess that class(CompanyNames$Companynm) is a "factor" rather than a "character". When you use c() on a factor, it strips all the information used for the levels and converts it to a simple numeric column. For example x<-data.frame(a=c("apple","banana","pear")) x$a # [1] apple banana...

RMarkdown: Why do I have to reinstall all packages everytime I knit?

r,rstudio,rmarkdown

Since "require returns (invisibly) a logical indicating whether the required package is available" you can conveniently use it for programming to either load the package or, if it's not available, (try to) install it and load it afterwards. So you could modify your code along the lines of: if (!require(dplyr))...

savePlot() error message in R: can only copy from 'windows' devices

r,windows,rstudio

You can use png function. For example: png(filename = "testPlot.png", width = 480, height = 480) plot(1:10, type = 'l') dev.off() In filename you should define the path to the plot. ...

using -knitr- to weave Rnw files in RStudio

r,rstudio,knitr

After spending hours to try to figure out the problem, I updated R (v 3.2.0) and everything works fine now. It is not clear if the problem was due to some packages conflict, for sure it wasn't an RStudio problem (as I had initially thought).

sjplot sjt.frq in new window / tab

r,table,tabs,rstudio,sjplot

Currently, there is no history feature for the Viewer pane in RStudio. You may open the tables in your browser instead (or additional, there's an icon in the Viewer pane), so you have multiple browser tabs, each with a table output. Or you "concat" multiple tables and show them in...

Error with new R 3.1.3 version

r,rstudio

Update to RStudio version 0.98.1103, it's available (even if it says in RStudio's updater that there's not a newer version available).

operating on sub group inside data frame very slow

r,rstudio

You could try dplyr. Order the dataset by "id", "dayofweek" (arrange(..)). Create the "nextdaypushupcount" using lead after grouping by "id". Remove the last observation for each group (slice(..)). Get the cumsum of "pushupcount" to create "cumulativepushups". library(dplyr) df1 <- arrange(df, id, dayofweek)%>% group_by(id) %>% mutate(nextdaypushupcount=lead(pushupcount)) %>% slice(-n())%>% mutate(cumulativepushups=cumsum(pushupcount)) df1 #...

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

regex,r,rstudio,text-processing

replace "/tmp/out" with your filename txt <- readLines("/tmp/out") lns <- data.frame(beg=which(grepl("beginning of the paragraph i want",txt)), end=which(grepl("end of the paragraph i want",txt))) txt.2 <- lapply(seq_along(lns$beg),function(l){ paste(txt[seq(from=lns$beg[l], to=lns$end[l], by=1)],collapse=" ") }) txt.2 # or for referencing by the star, the lns is obtained this way lns <- data.frame(beg=rev(rev(grep("[*]",txt) + 6)[-1]), end=(grep("[*]",txt)...

In “R” iterate over specific columns

r,loops,for-loop,rstudio,lapply

This seems simple enough. I didn't test as we weren't given data but you should get the gist. myFun<-function(col) { myDF$multiple[grep(" Mbps",myDF[,col])] <- 1000000 myDF[,col] <- gsub(" Mbps","",myDF[,col]) myDF$multiple[grep(" Kbps",myDF[,col])] <- 1000 myDF[,col] <- gsub(" Kbps","",myDF[,col]) myDF$multiple[grep(" bps",myDF[,col])] <- 1 myDF[,col] <- gsub(" bps","",myDF[,col]) myDF[,col] <- as.numeric(myDF[,col]) * myDF$multiple }...

How to interact with websocket from within R

r,websocket,client,rstudio

I had a similar question a while back and it was confirmed to me by Joe Cheng (maintainer of httpuv) that httpuv is a websocket server only. That still seems to be true with httpuv 1.3.2 dated 2014-10-22.

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

css,r,shiny,rstudio

This problem can be fixed by installing version 0.5.2 of the rmarkdown package. Currently this is the development version and can be installed from GitHub using: install.packages("devtools") library(devtools) devtools::install_github("rstudio/rmarkdown") ...

Shiny + GGplot - mouse click coordinates

ggplot2,shiny,rstudio

I find a way to resolve: imagens and codes: https://github.com/faustobranco/StackQuestions library(shiny) library(ggplot2) ui <- fluidPage( plotOutput("plot", click = "plot_click"), verbatimTextOutput("info") ) server <- function(input, output, session) { output$plot <- renderPlot({ ggplot(cars, aes(speed, dist)) + geom_bar(stat="identity") }) output$info <- renderText({ xy_str <- function(e) { if(is.null(e)) return("NULL\n") paste0("x=", round(e$x, 1), "\n") }...

Generating LaTeX tables instead of text in Rstudio

r,latex,rstudio

R markdown in R Studio makes this sort of thing much nicer. Blocks of R code can be declared with three backticks{r}code and then inline code with a single backtick and r. The following does something similar to what you want. --- title: "Untitled" author: "user" date: "Tuesday, May 05,...

Save View() output of RStudio as html

r,rstudio

Maybe your data looks like the mtcars data data(mtcars) View(mtcars) library(xtable) sink command sends output to a file sink('somehtmlfile.html') print(xtable(mtcars),type='html') then return things back to normal with sink() now check the somehtmlfile.html in a browser...

Error in RStudio with read.table(url…)

r,url,rstudio

RStudio and RGUI may be using different defaults for setInternet2(), so try running setInternet2(use=FALSE) at the beginning of your session. Here is an explanation from RStudio (2013): Also we call setInternet2(use=TRUE) on startup which takes proxy settings from Internet Explorer to make proxies work in the majority of cases. We...

The error when publishing a shiny app

r,shiny,rstudio,shinyapps

As the error message says, please install shinyapps from https://github.com/rstudio/shinyapps It is not a package on CRAN, so you cannot install.packages().

RQDA batch file import not working

r,rstudio

I needed to set a different file title for every file before it would import correctly

.Rd file generation in a package using Rcpp

r,rstudio,rcpp

As far as I know if you use RStudio all this is done for you -- because RStudio very much supports tboth roxygen2 and of course Rcpp. You may have to ensure you click a box in the RStudio Tools configuration to use roxygen. I still do it by hand,...

Simulating and assigning multiple vectors in R

r,vector,rstudio

Similar to what Jaehyeon Kim proposes above: > vs <- lapply(1:3, function(x) rnorm(100,0,1)) > str(vs) ...produces a list of numeric vectors of length 100: List of 3 $ : num [1:100] 0.367 1.549 0.453 -0.374 -0.105 ... $ : num [1:100] 0.254 -0.333 -1.732 -0.213 2.001 ... $ : num...

R files in capital and lowercase. Difference?

r,rstudio,file-extension

There should be no difference. If you are getting permission denied on reading any files, then you need to change the permissions so you can read them. If you are on unix, you can use the following command assuming you own the files. chmod u+r <filename> ...

R in Ubuntu Server 14.04 - Writing file to a samba sharing in which a directory is protected by user/pass

r,file,ubuntu,rstudio,samba

I found it can be done via a shell script in Ubuntu. The command is write(somefile, file = "|sh shellWriteSamba.sh") Edit: The complete solution is in R - write() a file to a SAMBA share...

Arranging subgroups in ggplot [duplicate]

r,rstudio

Just add this before ggplot(): data$group <- factor(data$group, levels = c("Nor", "i_GS", "GS")) Idea is that ggplot reads from factors the way they are arranged in data frame. Hence you have to rearrange the factor in the data frame if you want to see them visualized differently....

Is there an Rstudio keyboard shortcut to open up the file that contains the source code to a function you've written?

r,rstudio

If you are within a package then F2 will navigate to the source file of functions defined within that package (it would be nice if you could also go to other packages but that doesn't work yet). You can also use Ctrl+. to do a typeahead search of all functions...

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

r,loops,rstudio

I am assuming you are doing the regression of each indicator against the same f. In that case, you can try something like: p_vals = NULL; for(this_indicator in indicators) { this_formula = paste(c(this_indicator, "f"), collapse="~"); res = t.test(as.formula(this_formula)); p_vals = c(p_vals, res$p.value); } One comment, however: are you doing any...

looking at the next column in a data frame based on a condition in previous column

r,rstudio

Assuming that the columns occur in "key/value" pairs, subset the dataset ("df") in to value ('df1') and key ('df2') datasets. df1 <- df[seq(2, ncol(df), by=2)] df2 <- df[seq(1, ncol(df), by=2)] To get the "count" of each class ("High", "Low", "Medium") in each row, we can use the apply with MARGIN=1....

Connecting RStudio with Remote R machine

r,hadoop,rstudio,rhadoop

One solution is to install RStudio Server on that machine (Linux) and then access RStudio Server by pointing your web browser to <IP ADDRESS>:8787.

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

r,rstudio

At the console, the script is evaluated as soon as the a line ends with a complete statement. Hence, this: temp_a temp_b <- 1 temp_c <- 2 is equivelent to calling this: source(textConnection('temp_a')) source(textConnection('temp_b <- 1')) source(textConnection('temp_c <- 2')) in which each line is evaluated as soon as it is...

How to configure R-3.1.2 with --enable-R-shlib

r,rstudio

make uninstall only undoes the make install step, which generally copies the files from the compilation dir to dir(s) on the system as appropriate, and puts binaries in say /usr/bin so they are on the path. If you wanted to clean up the dir where you did a previous compile,...

Can't open connection when shortcut-knitting in RStudio

r,connection,rstudio,knitr

If you only care about a solution under Windows, I believe you need to setInternet2(TRUE) in te Rmd file before you read the file, since it is essentially an HTTPS link, which you cannot read into R by default. A more portable solution is to use the downloader package to...

suppress console output in r markdown, but keep plot

r,markdown,rstudio

Wrapping any object in invisible will prevent automatically printing it. You should be able to use invisible(lapply(obj,function(x) plot(x,main="some plot"))) However the fact that echo=FALSE doesn't work suggests that there might be something else going on....

Render R Presentation from the command line

r,markdown,rstudio,knitr,slidify

I asked this question in on RStudio Support Community page, and the 'official' answer was no. A colleague looked at the code on github and verified the method is only called from the drop down UI. Looks like to do this you would have to actually compile your own wrapper.

Multiple true condition in ifelse command

r,rstudio

This works: a <- "01" ifelse(a=="01", d <- c(sum(b),sum(c)), d <- 0) d #[1] 21 2616 a <- "02" ifelse(a=="01", d <- c(sum(b),sum(c)), d <-0) d #[1] 0 ...

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

r,datatable,rstudio,rmarkdown

The package RStudio is using under the hood is rmarkdown. It handles the Knit command and delegates work to knitr and pandoc, and it's also responsible for bundling dependencies and injecting them into the doc. You likely already have the package installed, so you should be able to do this...

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

r,rstudio,knitr,rmarkdown

For those of you who are having similar issues. I fully uninstalled MIKTEX and reinstalled a complete version of proTeXt (which is basically a full install of MIKTEX plus a LaTeX IDE called TeXstudio) and it fully fixed my issue. I am now able to compile PDFs through RMarkdown without...

How to add logo to each slide in ioslides in RStudio

r,rstudio,knitr,rmarkdown

Have you tried publishing your slides? I've found on Windows 8.1 that the icon does not appear in the RStudio preview, but it's there when I publish them to shinyapps.io. If you want to force the icon to show up in the RStudio preview you can use: --- title: "...

unable to get column names when using skip along with read.csv

r,rstudio

If you skip lines in a file, you skip the complete line, so if your header is in the first line and you skip 100 lines, the header line will be skipped. If you want to skip part of the the file and still keep headers, you'll need to read...

finding rows which don't have NA in a particular column if it already didn't have any NA

r,rstudio

The problem is not limited to NAs. It happens if the indexing vector is empty. The hope is that the whole vector will be returned, but actually, x[numeric(0)] (x indexed by a vector of length 0) returns an empty vector. For example, consider the following: > df[ c(-1), ] #...

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

r,plot,ggplot2,rstudio,boxplot

ggplot2 requires that your data to be plotted on the y-axis are all in one column. Here is an example: set.seed(1) df <- data.frame( value = runif(810,0,6), group = 1:9 ) df library(ggplot2) ggplot(df, aes(factor(group), value)) + geom_boxplot() + coord_cartesian(ylim = c(0,6) The ylim(0,6) sets the y-axis to be between...

Converting non-standard file to .csv in R

r,file,csv,rstudio,file-conversion

Say you have a space separated file: name grade percent john 1 0.3 brian 2 0.25 joshua 5 1.1 You can specify a delimeter for read.csv: > read.csv("test.ssv", sep=" ") name grade percent 1 john 1 0.30 2 brian 2 0.25 3 joshua 5 1.10 Also, fread from the data.table...

Highlighting bash code with knitr / rmarkdown

r,syntax-highlighting,rstudio,knitr,rmarkdown

The default syntax highlighting theme does not work well for non-R code chunks, and you can use other themes, e.g. pygments --- title: "Bash Highlighting" output: html_document: highlight: pygments --- ```{r, engine = 'bash', eval = FALSE} for foo in (ls bar) do echo $foo done ``` ...

How to use relative paths reading data from a directory on a mac in R?

r,osx,rstudio

have you tried data <- read.csv(file=file.path("directory2", "filename"), header=F) ? file.path is supposed to work across platforms.

Evaluate a Chunk based on the output format of knitr

r,rstudio,knitr,rmarkdown

Try this: ```{r eval = knitr::opts_knit$get("rmarkdown.pandoc.to") == "latex"} "Hi, I'm in a PDF!" ``` Or, to evaluate chunks only when you're not rendering to PDF: ```{r eval = knitr::opts_knit$get("rmarkdown.pandoc.to") != "latex"} "Hi, I'm not in a PDF!" ``` ...

RStudio character encoding issue: quotation marks replaced by \x92

r,character-encoding,rstudio,rstudio-server

I just found a solution so I am answering my own question: Somehow my attempts to set the encoding via the global options menu in RStudio server did not have any impact on read.csv (I thought it was supposed to use the encoding specified in the global options by default...

How to create venn diagram in R studio from group of three frequency column

r,rstudio,data-analysis

Here's one way to do it using the package venneuler: df <- read.table(header = TRUE, text = "user has_1 has_2 has_3 3431 true false true 3432 false true false 3433 true false false 3434 true false false 3435 true false false 3436 true false false", colClasses = c("numeric", rep("logical", 3)))...

Rstudio 0.98.1028 add background image only to title slide

css,r,rstudio,rmarkdown

You're 99% of the way there. Just one or two more tweaks and you'll have it. You may consider adding the following to ensure your slides are using the separate css file with something like the following added to your title slide. Intro ====== author: Clever Name css: css-file.css You...

Output R loop content and output in knitr html

r,for-loop,markdown,rstudio,knitr

You should use print or cat to force output : ```{r} for(i in seq_along(dflist)){ print(paste('head data set:' , names(dflist)[i])) ## sub title print(head(dflist[[i]])) ## content cat(rep("*",20),'\n') ## separator } ``` ...

pick rows from every group in data frame only when condition satisfies

r,rstudio

bycol <- split(mydf,as.factor(mydf$col1)) newdf <- data.frame() for (i in 1:length(bycol)) { col <- bycol[[i]][2] lcol <- col >= 100 start <- min(which(lcol == TRUE)) fin <- nrow(col) newdf <- rbind(newdf, bycol[[i]][start:fin,]) } This shows what the OP first asked for, which was: > newdf col1 col2 2 1 100 3...

Extracting text after “?” in R

r,pattern-matching,rstudio

str_match is more helpful in this situation str_match(x, ".*\\?\\s(.*)")[, 2] #[1] "Michael Sneider" ...

Finding the period with the highest rolling sum per category

r,rstudio

It's a little difficult to test this without an idea of what your data looks like, and I can't say how fast it will be, but here's one possible solution. Create sample data frame: set.seed(123) df <- data.frame( CLIENTID = rep(c("a", "b", "c", "d"), each=10), MONTHID = as.vector(replicate(4, sample(1:40, 10))),...

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

r,rstudio

You can just add the x to the plot lines(1 : length(y) - 1, y, col="blue") ...

R how to use files in the same packages

r,rstudio

You appear to misunderstand how package works: by having a file with a function in the R/ directory, it is already visible to other code in the package. If you want to make it available to other packages, you can control this via the NAMESPACE file. All this is well-documented...

Is there a way to have a barplot and a stacked barplot on the same graph using barplot or ggplot?

r,ggplot2,bar-chart,rstudio

Using ggplot, I would do something like one of these. They plot the two sets of data separately. The first arranges the data into one dataframe, then uses facet_wrap() to position the plots side-by-side. The second generates the two plot objects separately, then combines the two plots and the legend...

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

r,date,numbers,rstudio,data-type-conversion

You can do this easily with lubridate although it indexes Sunday as '1'. So since March 1, 2014 was a Saturday it would return '7' library(lubridate) wday(mdy("3-1-2014")) [1] 7 ...

R/RStudio, Yosemite, and Java

java,r,rstudio,osx-yosemite

instead the java you have installed download this one https://support.apple.com/kb/DL1572?viewlocale=en_US&locale=en_US after installing it, your problem will be solved ...

Missing projection file in R's rgdal package for geospatial analysis

r,rstudio,gdal,rgdal

I had a quick Google and came across this post which suggests this was an OS X error where the packages were built incorrectly. On my Mac system, I wasn't able to reproduce your error, so for what it's worth I installed my versions of rgdal and rgeos from http://www.kyngchaos.com/software:frameworks...

Running R and RStudio on Dropbox [duplicate]

r,dropbox,rstudio

Sounds like there are two separate aspects to your question: Can you share the R & RStudio application/executables Can you share the R scripts/project documents Regarding 1, to share the application/executables, you could follow the portable Rstudio approach from @hrbrmstr. That's going to require you providing the correct versions for...

Split the title onto multiple lines?

r,yaml,markdown,rstudio

For an HTML output just us the <br> tag while if your output is a PDF or PDF presentation standard LaTeX code to break line given by \\ should work. Example --- title: 'A title I want to <br> split on two lines' author: date: output: ioslides_presentation --- For PDF...

Create time-series graph in Shiny from user inputs

r,time-series,shiny,rstudio

I am assuming you are going to want to input multiple values at once, so a numeric input box for each point would be a bit cumbersome. I have taken the liberty of making it so you can copy and paste in comma delimited data: (Note: the value is only...

Title not showing on R Markdown with knitr when rendering markdown file

r,rstudio,knitr,rmarkdown

Markdown does not have such a concept as "title". HTML has the <title> tag (and Pandoc also puts the title in <h1> for the HTML output from Markdown so you can see it from the HTML body), and LaTeX has the \title{} command. It is not unexpected to me that...

Multiple plots in one figure in R: Error if only ONE column

r,plot,rstudio

RStudio will throw that error if the plot window is sized too small for what you are trying to plot. You could try dragging that plot window larger relative to the console etc, or you could write your plot directly to a file, for instance using pdf() and dev.off().

Source R script using 32 bit R from 64 bit RStudio

r,rstudio

I think you want to use Rscript.exe to run the file, rather than R.exe. You can do this by just using /bin/i386/Rscript.exe your_rfile.R - this is how I would execute R code from the command line in Windows.

Increasing font size in RStudio

rstudio

Ctrl++, and Ctrl+- More keys might be necessary to generate +/- (for instance, for me Zoom In is Ctrl+Shift+=). Other notes: You can also zoom in using the View menu See a list of keyboard shortcuts with Alt+Shift+K (recent versions of RStudio only) ...

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

rstudio,couchbase

Couchdb has restful http interface so you can query the database directly using that. There is this package for R that should make it easier for you: http://cran.r-project.org/web/packages/RCurl/index.html Here is an example of a Uri that might be used to query a couch view: /database/_design/designdocname/_view/viewname. Bear in mind that couch...

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

r,plot,rstudio

Try this: TukeyHSD(Gastropods.ANOVA) tuk<-TukeyHSD(Gastropods.ANOVA) psig=as.numeric(apply(tuk$`Zone:Species`[,2:3],1,prod)>=0)+1 op=par(mar=c(4.2,9,3.8,2)) plot(tuk,col=psig,yaxt="n") for (j in 1:length(psig)){ axis(2,at=j,labels=rownames(tuk$`Zone:Species`)[length(psig)-j+1], las=1,cex.axis=.8,col.axis=psig[length(psig)-j+1]) } par(op) You will have something similar to this plot ...

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

r,markdown,rstudio,rmarkdown,mathjax

Use a version of RStudio beyond 0.98.1103.

Plot a histogram of means and label individual mean/PDF

r,plot,rstudio

Here are two ways of adding a label. First, some random data and the regular histogram: set.seed(0) means <- rnorm(1000, 4.5, 0.2) hist(means) One way to add what you want is plot one point where you want, using points() points(x=means[1], y=0, pch="X", cex=1.5) Use y for the vertical position, pch...

Finding the sum in R using conditions

r,sum,rstudio

You can subset the data.frame then sum the resulting column. Call that data.frame mydf sum(mydf[ mydf$'STORE ID' == 111111 & mydf$YEAR == 2012, 3]) ...

Is there a R markdown analog of \SweaveInput{} for modular report generation?

r,rstudio,pandoc,sweave,rmarkdown

Use something like this in the main document: ```{r child="CapsuleRInit.Rmd"} ``` ```{r child="CapsuleTitle.Rmd", eval=TRUE} ``` ```{r child="CapsuleBaseline.Rmd", eval=TRUE} ``` Use eval=FALSE to skip one child. For RStudio users: you can define a main document for latex output, but this does not work for RMD documents, so you always have to...

Copy/paste table into gmail

r,gmail,rstudio

I would use knitr and kable in RStudio (New file R markdown, output format html): --- title: "attaching pretty R tables to your gmail message" date: "4 Jun 2015" output: html_document --- This is an example of a pretty table, produced with Knitr in RStudio: * RStudio: New file R...

Using R Studio Console commands not parsed in Knitr markdown file

r,rstudio,knitr

You have to define the object in the Knitr code. Knitr, by design, operates in a clean room and has to be self-contained. It doesn’t look at your existing RStudio environment (in fact, that would be terrible because it would make the resulting code entirely unreproducible). As an example, here’s...

Unable to create plots in Rpres (RStudio's HTML presentation format)

r,plot,ggplot2,rstudio,rpres

Ok, I was able to fix my problem by renaming my Rpres file, so that it does not have any spaces. So instead of "PT terms for each age Strata.Rnw.Rpres" I chose"PT_terms_plots.Rpres" as the filename. If you believe this might be a bug, comment to let me know so that...

Is there any way to disable environment pane in RStudio?

r,rstudio

I can reproduce the problem with lots of small nested list variables. # Populate global environment with lots of nested list variables invisible( replicate( 1000, assign( paste0(sample(letters, 10, replace = TRUE), collapse = ""), list(a = 1, b = list(ba = 2.1, bb = list(bba = 2.21, bbb = 2.22))),...

RStudio R File Corruption

r,rstudio,corruption

It's not clear what happened to corrupt your file (and thus how to fix it if possible) and it is kind of ominous that you're just seeing 0's in other text editors, but I'll give you my best suggestion and some tips. Suggestions for Attempting Recovery Since your other R...

Change background colour of rmarkdown pdf output

r,pdf,render,rstudio,rmarkdown

Well, one solution is to use latex i.e. first create a .Rnw file which loads the latex pagecolor package: \documentclass{article} \usepackage{pagecolor} \begin{document} \pagecolor{yellow} \section{A very yellow page} <<plot1, echo=FALSE>>= hist(rnorm(1000)) @ \clearpage \subsection{Another yellow page} <<summary1>>= summary(mtcars) @ \end{document} In RStudio this will look like: You now want to convert...

How to read every .csv file in R and export them into single large file

r,rstudio

You can use lapply to read all the files, clean and format them, and store the resulting data frames in a list. Then use do.call to combine all of the data frames into single large data frame. # Get vector of files names to read files.to.load = list.files(pattern="csv$") # Read...

What programming language was RStudio written in?

rstudio

It's a mix. The user interface is indeed based on web technology and is written primarily in Java, using GWT to transpile to JavaScript; the back end is mostly C++. The source is hosted on GitHub, where you can see auto-generated language stats: ...

Sourcing the code

r,rstudio

Try using paste0 to break down the path. If you want to source the following file: "/home/user/work_dir/my_project/source_file.R" Then you can break the path by using: source(paste0("/home/user/", "work_dir/my_project/", "source_file.R" ) ) ...

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

r,rstudio

It seems that having very long lines causes problems with the interpreter. I couldn't say exactly why and what is the limit, but breaking the lines into several lines solves the problem: req <- list( Inputs = list( "input1" = list( "ColumnNames" = list("Column 0", "X", "AGE", "FEMALE", "LOS", "NCHRONIC",...

convert NA in a column of class factor to 0

r,rstudio

If you use df$col2 <- addNA(df$col2) you will get a new level 'NA' to the factor....

Setting work directory in knitr using opts_chunk$set(root.dir = …) doesn't work

r,rstudio,knitr

It is knitr::opts_knit instead of knitr::opts_chunk.

Differences in R Markdown syntax highlighting for in-line code

r,syntax-highlighting,rstudio,rmarkdown

We changed the treatment of code in a recent release of rmarkdown (the red was too strong). My guess is that you have two different versions of the rmarkdown package in play. If you update both systems to the most recent version from CRAN (v0.6.1 as of the time of...

How to restrict Shiny fileInput to text files only?

shiny,rstudio

As far as I understand, that's the right way to do it. If you view your app in the RStudio viewer it wouldn't do anything, but in a browser it should. I'm using Chrome and I just ran that code and it did in fact only show me txt and...

ordering non-decreasing functions then adding them in R

r,function,order,sequence,rstudio

If you want a function that takes vectors A, B, C, and D and input and outputs a sorted version of them, you can try: sortAll <- function(A, B, C, D) sort(c(A, B, C, D)) And then you can run it with something like: A <- c(1,2,2,3) B <- c(5,6,7,8)...