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

How to reshape and then convert a data frame into dgCMatrix?

I have a data frame like following (the rownames are "1", "2", "3"...). Since there are non unique entries in each column, I cannot assign any of them as row names.gene cell count a c1 1 a c2 1 a c3 4...

View Article


Extract multiple descriptive statistics

Having a dataframe like this: df <- structure(list(id = c(43, 11, 24, 12), a = c(0.291435739245075, 0.309022489024281, 0.342122441665493, 0.302379459085847), b = c(0.200071678165039,...

View Article


Conver Leaflet map to static plot and save it as pdf

How would one convert leaflet map to a static plot and then save it as pdf?, I have createa a large leaflet map, that has over 150 MB, using mapshot does not work because it is very large. Now I think...

View Article

Check if value from one dataframe exists in another

I am a beginner in R and want to know how it will works for each row.Eg.I have a two data frames.I want to see if the rows exist in the other data frame. I want to loop every row in ab$Fruits and check...

View Article

Can I use R to only analyze data past a certain date?

I have an excel sheet that I imported into RStudio which contains data for every subject of a certain population. Each subject has their own set of data with corresponding dates, but I only want to...

View Article


Create aggregate variable in long data format

I'm sure there's a question similar to this already, but I couldn't make them workI am trying to calculate aggregates (or subtotals) in a dataframe of long format. In the group column I want an...

View Article

Count NAs between first and last occured numbers

Here is my toy datasetdf <- tribble( ~x, ~y, ~z, 7, NA, 4, 8, 2, NA, NA, NA, NA, NA, 4, 6) I want to get a dataframe with a number of NAs for each variable only between the first and the last...

View Article

Can you list an exception to tidyselect `everything()`

library(tidyverse) iris %>% as_tibble() %>% select(everything()) #> # A tibble: 150 x 5 #> Sepal.Length Sepal.Width Petal.Length Petal.Width Species #> <dbl> <dbl>...

View Article


Remove all rows below a certain threshold in R

I have a matrix of data and I wanted to remove all rows that have values below a set threshold of 10. I've checked other posts on here and they don't seem to work in my case in R for some reason. I...

View Article


Cross tabs/frequency tables with long-form longitudinal data in R

I have a longitudinal dataset with data in long format (one row for each time point for each participant), and I would like to get cross tabs for demographic variables at each time point. Simplified,...

View Article

convert event dates to time-event columns for survival analysis

I am trying to convert a list of observation for censored data to a proper format for survival analysis in R. To give an exemple, the code should transform like this. event.6mo event.12mo event.24mo 1...

View Article

Image may be NSFW.
Clik here to view.

How to filter and copy a value in R dataframe?

I have a dataframe like as shown belowTest <- c('Sodium','Heamo Index.','Lipae Index','ictoric index','Chloride','Blood pressure','Test Index') value <- c(12,'No haemo',NA,'No ict',21,32,NA)...

View Article

Is there a way to set locales in cluster in r?

I have to run a piece of code using parallel processing to reduce the execution time. Each steps are independent of each other. I have created a cluster, cl = makeCluster(cores) registerDoParallel(cl)...

View Article


Filtering column based on matching conditions in another column

I am trying to perform a simple filtering using dplyr but it doesnt seem to work with what I want to do.I want to filter a dataframe based on Time as an example when only if Time matches the category,...

View Article

Is the colorspace R package part of the Tidyverse? (conflicting information)

Is the colorspace R package part of the Tidyverse? Looking at this list of Tidyverse included packages it appears the answer is "No".However, when I load the tidyverse via library(tidyverse) it appears...

View Article


How can I perform a PCA with variables of three different data frames and...

I have three data frames and I want to perform a Principal Component Analysis (PCA) in R. I merged the data frames with rbind() and did a PCA with that. That worked. But I want to discriminate the dots...

View Article

Split by variable in a specific group using dplyr

stackoverflow! How can I both split and duplicate dataframe using dplyr? Just imagine, that I have got a data frame with grouping variable (i.e. group), sample id (i.e. sample) and...

View Article


How do I create side-by-side barplots with my data set? [closed]

So my data set is full of three variables, year, age group, and annual average. The year goes from 1989 to 2019 for each age group and each age group is 5 years until we get to 65-and over which is...

View Article

Image may be NSFW.
Clik here to view.

Heatmap/Contours based on Transportation Time (Reverse Isochronic Contours)

Note:Solutions in either python or r are desired.Temporary Note:Existing answers do not fully cover the issue, both conceptually and implementation wise.I am trying to draw contours based on...

View Article

how to make a subset of cells expressing certain gene in seurat R

I want to create a subset of cell expressing certain gene only. Here is my coding but it always shows 'No named arguments passed'. I have no idea how to correct that. Dbh.pos <- Idents(my.data,...

View Article
Browsing all 206180 articles
Browse latest View live


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