Category "r"

Format number as fixed width, with leading zeros [duplicate]

The following code a <- seq(1,101,25) b <- paste("name", 1:length(a), sep = "_") produces this output: "name_1" "name_26" "name_51

R- How to set y-axis individually when using `facet_grid_sc()`

I want to plot the trend of the density (Density.est) of 3 species (Emar,Ecos and Sphyr) over time (2008,2009,2010) for two protection levels of a protected are

First day of the month from a POSIXct date time using lubridate

Given a POSIXct date time, how do you extract the first day of the month for aggregation? library(lubridate) full.date <- ymd_hms("2013-01-01 00:00:21")

Heatmaps of RNA SEQ data

This is my first time in working with RNA SEQ data and I have some problems with heatmap My data is as follows Data I wanted to create a heatmap to show tissu

Heatmaps of RNA SEQ data

This is my first time in working with RNA SEQ data and I have some problems with heatmap My data is as follows Data I wanted to create a heatmap to show tissu

Pandoc cannot find image path referenced in external HTML file pulled into R Markdown, despite using here() package

I am producing an HTML document through R Markdown, which uses a few external HTML documents for headers and footers. I am also using the here() package to allo

Using column numbers not names in lm()

Instead of something like lm(bp~height+age, data=mydata) I would like to specify the columns by number, not name. I tried lm(mydata[[1]]~mydata[[2]]+mydata[[3]

Saving an R-Script results in empty file

I have recently started using R for uni. I want to save my code using either save as or ctrl+s. However, the saved file is empty more often than not. For some r

Is there any Package for adding Arrows to lines in leaflet map

I am working on an interactive map in Leaflet thorough R studio, I want to show the direction of the roads with Arrows. I would be grateful if anyone helps me w

Error in if/while (condition) {: missing Value where TRUE/FALSE needed

I received this error message: Error in if (condition) { : missing value where TRUE/FALSE needed or Error in while (condition) { : missing value where TRUE/

How can I check if a matrix is an element of a list of matrices? in R

I'm pretty new to programming in R. I have a matrix of numbers mat, as well as a list of matrices matlist. I want to check if the matrix mat matches with (i.e

fs::dir_ls() returns unreadable output for file paths with chinese characters inside

I'm using fs::dir_ls() to get excel file paths under a directory main_path, but since there are Chinese characters in the file paths, I get an unreadable output

Is there a predict function for plm in R?

I have a small N large T panel which I am estimating via plm::plm (panel linear regression model), with fixed effects. Is there any way to get predicted values

tidyr use separate_rows over multiple columns

I have a data.frame where some cells contain strings of comma separate values: d <- data.frame(a=c(1:3), b=c("name1, name2, name3", "name4", "name5

Failed to compile test.tex. See https://yihui.name/tinytex/r/#debugging for debugging tips. See test.log for more info. Execution halted

output file: test.knit.md ! pdflatex: warning: running with administrator privileges ! Sorry, but C:\Users\jjw11\AppData\Local\Programs\MIKTEX~1.9\miktex\bin\

where and how to apply a filter in a ggplot

I have a set of data called 'theatres' I have prepared a box plot of all the data with this code: There is a column in the data called 'sector' and the data w

Run RSelenium in parallel

How would i go about running RSelenium in parallel. The following is an example using rvest in parallel library(RSelenium) library(rvest) library(magrittr) li

Problems with TermDocumentMatrix function in R

I'm trying to create a TermDocumentMatrix using tm package, but seem to have encountered difficulties. The input: trainDF<-as.matrix(list("I'm going home",

Push an R dataframe to SQL as a new table

I'm trying to make my analysis workflow more efficient connecting my SQL Server Database to R-Studio. What I do now? I develop my queries using MS SQL Managem

knitr/rmarkdown/Latex: How to cross-reference figures and tables?

I'm trying to cross-reference figures and tables in a PDF produced with knitr/rmarkdown. There are some questions on SO and tex.stackexchange (here and here, fo