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)....
The View function is from package 'utils' which is not supported by the version of R you are using.
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')) }) ...
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") ...
You could try largedf <- totaldataset[Reduce(`|`, lapply(totaldataset[19:43], function(x) x=='4280')), ] ...
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).
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...
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))...
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. ...
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).
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...
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).
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 #...
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)...
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 }...
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.
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") ...
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") }...
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,...
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...
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...
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().
I needed to set a different file title for every file before it would import correctly
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,...
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...
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> ...
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...
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....
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...
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...
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....
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.
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...
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,...
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...
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....
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.
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 ...
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...
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...
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: "...
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...
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), ] #...
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...
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...
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 ``` ...
have you tried data <- read.csv(file=file.path("directory2", "filename"), header=F) ? file.path is supposed to work across platforms.
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!" ``` ...
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...
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)))...
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...
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 } ``` ...
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...
str_match is more helpful in this situation str_match(x, ".*\\?\\s(.*)")[, 2] #[1] "Michael Sneider" ...
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))),...
You can just add the x to the plot lines(1 : length(y) - 1, y, col="blue") ...
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...
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...
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 ...
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 ...
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...
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...
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...
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...
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...
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().
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.
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) ...
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...
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 ...
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...
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]) ...
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...
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...
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...
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...
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))),...
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...
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...
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...
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: ...
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" ) ) ...
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",...
If you use df$col2 <- addNA(df$col2) you will get a new level 'NA' to the factor....
It is knitr::opts_knit instead of knitr::opts_chunk.
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...
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...
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)...