Quantcast
Channel: Active questions tagged r - Stack Overflow
Browsing all 201839 articles
Browse latest View live
↧

Image may be NSFW.
Clik here to view.

paste function in ggtitle: remove extra spaces

Within the shiny context, how can I remove extra space after and before parentheses in the title of a plot? As shown in the below image, there are redundant spaces between "(" and "6" as well as...

View Article


How do I display missing values in my app

I am trying to get my app to display missing values in the table in a situation where the user does not enter text into any of the text fields. But when I run the app, I get an error message. I have...

View Article


Where is the error when I try to create a data frame from objects that...

I want to create a dataframe called Tabla.Sincronizacion with 8 columns (ID,Period,Estimator.type,Value.for.VeDBA,Delay.for.VeDBA,Value.for.RMS,Delay.for.RMS,No.data) and 172 rows. The particularity,...

View Article

Why can i not stack one row on top of another?

I am trying to make an column called ID that contains 5000 rows to act as an identification column for observations on 20 individuals. I want there to be 200 observations for each of the first 10...

View Article

regex strsplit expression in R so it only applies once to the first...

I have a list filled with strings: string<- c("SPG_L_subgenual_ACC_R", "SPG_R_MTG_L_pole", "MTG_L_pole_CerebellumGM_L")I need to split the strings so they appear like:"SPG_L", "subgenual_ACC_R",...

View Article


Modify aesthetic mapping in ggplot2 to obtain correct plotly legend

I have a ggplot2 chart that I want to render with plotly. The x and y variable are obtained from a character variable as in the example below:library(ggplot2) library(plotly) dset <- data.frame(x =...

View Article

Filter according to partial match of string variable in R

I have a data-frame with string variable column "disease". I want to filter the rows with partial match "trauma" or "Trauma". I am currently done the following using dplyr and stringr:trauma_set <-...

View Article

Merge multiple txt files based on one common column

I have 97 files on miRNA data set which has no column name, want to merge in single file. One column is same in all file and another one is different in all files. Some of gene id is not common in all...

View Article


Using an if statement in apply in R for every value in a data frame

I have a data frame that I created using the read_excel function and then duplicated it. I'm going to explain it as if I was using Excel, because it's so easy to do this in Excel. I want to check if...

View Article


rTorch: Loading a model trained in PyTorch to R

I'm hoping to load a model trained in Python using PyTorch to R for deployment in a Shiny app. I was wondering if it would be possible to use rTorch to do this, as I don't see any existing...

View Article

reshaping the data from wide to long [duplicate]

Please help me with the following matter I have a wide data frame that I need to reshape. This is the df I have mydf <- data.frame(date=1983:1985,January=c(5,7,8),February=c(12,18,19)) mydf this is...

View Article

Is it mandatory to use 1 letter arguments in optparse?

I am using optparse in to parse arguments in R. Then I call the R code from command line and pass arguments as follows Rscript myscript.R -a xx -b yy. It works well, but I am a bit confused with the...

View Article

left join in R using two data sets [closed]

I did a left join in R using the following:df_merged <- merge(df1, df2, by ="contactid", all.y = TRUE) however, the values in df1 turned to NA after merge.

View Article


Image may be NSFW.
Clik here to view.

Break R expression into two lines along axis [duplicate]

I have this plot with a really long label along the y axis using 'expression', however, it gets distorted when I try to break it into two lines, see below:year = seq(1980,1990) irrig.area = seq(1,11)...

View Article

Mutate with apply statement in dplyr chain

Let's say I want to get a count of the variables that are greater than 5 in the iris dataset for each row: iris %>% mutate(n_greater=apply(.,1,function(x) length(x[(x>5)])),...

View Article


How to looping over a column and if pattern matches, count related characters...

0I have a data frame (picture is attached) with 1000 rows and 21 columns which the first column is miRNA gene names and other columns show each nucleotide in each position: (picture attached)What I...

View Article

in R, how to calculate mean of all column, by group?

I need to get the mean of all columns of a large data set using R, grouped by 2 variables.Lets try it with mtcars:library(dplyr) g_mtcars <- group_by(mtcars, cyl, gear) summarise(g_mtcars, mean...

View Article


How do i find week number from an arbitrary start date in R?

How do I find the week number from an arbitrary start date in R. Let's say I want my start date to be august 1st.

View Article

unzip a .zip file

I want to unzip a file in R. I completely don't know what to do.I searched and I found it method like this : unzip(zipfile, files = NULL, list = FALSE, overwrite = TRUE, junkpaths = FALSE, exdir = ".",...

View Article

Raster: Extract center of raster images and draw the border

I've like to extract coordinates of the center of 4 raster images in GEOTiff and draw the border of 2 selected images, for this I try:library(raster) library(rgeos) #create GeoTIFF raster r <-...

View Article
Browsing all 201839 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>