Re: [R] facet_wrap(nrow) ignored

2020-09-10 Thread Ulrik Stervbo via R-help
Dear Ivan, I don't think it is possible to force a number of rows - but I'm honestly just guessing. What you can do is to add an empty plot. Here I use cowplot, but gridExtra should also work well. I add an indication of the row number for the plot to the initial data.frame, and loop over

Re: [R] readxl question

2020-08-27 Thread Ulrik Stervbo via R-help
) }, ranges = ranges, .id = "filename") ``` On 2020-08-27 17:33, Ulrik Stervbo via R-help wrote: Hi Thomas, I am not familiar with the use of the range argument, but it seems to me that the cell value becomes the column name. This might be fine, but you might get into trouble if you hav

Re: [R] readxl question

2020-08-27 Thread Ulrik Stervbo via R-help
Hi Thomas, I am not familiar with the use of the range argument, but it seems to me that the cell value becomes the column name. This might be fine, but you might get into trouble if you have repeated cell values since as.data.frame() will fix these. I am also not sure about what you want,

Re: [R] Binomial PCA Using pcr()

2020-08-19 Thread Ulrik Stervbo via R-help
Hi Prasad, I think this might be a problem with the package, and you can try to contact the package author. The error seem to arise because the pcr() cannot find the 'negative-binomial' distribution ``` library(qualityTools) x <- rnbinom(500, mu = 4, size = 100) pcr(x, distribution =

Re: [R] Help with read.csv.sql()

2020-07-29 Thread Ulrik Stervbo via R-help
ear Ulrik, > >On 2020-07-29 17:14 +0200, Ulrik Stervbo via R-help wrote: >> library(readr) >> read_csv( > >This thread was about >sqldf::read.csv.sql ... > >What is the purpose of bringing up >readr::read_csv? I am unfamilliar with >it, s

Re: [R] Help with read.csv.sql()

2020-07-29 Thread Ulrik Stervbo via R-help
You might achieve this using readr: ``` library(readr) lines <- "Id, Date, Time, Quality, Lat, Long STM05-1, 2005/02/28, 17:35, Good, -35.562, 177.158 STM05-1, 2005/02/28, 19:44, Good, -35.487, 177.129 STM05-1, 2005/02/28, 23:01, Unknown, -35.399, 177.064 STM05-1, 2005/03/01,

Re: [R] Help with read.csv.sql()

2020-07-29 Thread Ulrik Stervbo via R-help
You might achieve this using readr: ``` library(readr) lines <- "Id, Date, Time, Quality, Lat, Long STM05-1, 2005/02/28, 17:35, Good, -35.562, 177.158 STM05-1, 2005/02/28, 19:44, Good, -35.487, 177.129 STM05-1, 2005/02/28, 23:01, Unknown, -35.399, 177.064 STM05-1, 2005/03/01,

Re: [R] Dataframe with different lengths

2020-07-29 Thread Ulrik Stervbo via R-help
Hi Pedro, I see you use dplyr and ggplot2. Are you looking for something like this: ``` library(ggplot2) library(dplyr) test_data <- data.frame( year = c(rep("2018", 10), rep("2019", 8), rep("2020", 6)), value = sample(c(1:100), 24) ) test_data <- test_data %>% group_by(year) %>%

Re: [R] Arranging ggplot2 objects with ggplotGrob()

2020-07-29 Thread Ulrik Stervbo via R-help
Then this should work: ``` library(ggplot2) library(cowplot) p1 <- ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width)) + geom_point() p2 <- ggplot(iris, aes(x = Petal.Length, y = Petal.Width * 1000)) + geom_point() plot_grid(p1, p2, ncol = 1, align = "hv", rel_heights = c(2, 1), axis =

Re: [R] Arranging ggplot2 objects with ggplotGrob()

2020-07-28 Thread Ulrik Stervbo via R-help
Would this work: ``` library(ggplot2) library(cowplot) p1 <- ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width)) + geom_point() p2 <- ggplot(iris, aes(x = Petal.Length, y = Petal.Width * 1000)) + geom_point() plot_grid(p1, p2, ncol = 1, align = "hv", rel_heights = c(2, 1)) ``` Best, Ulrik

Re: [R] Filtering using multiple rows in dplyr

2018-05-31 Thread Ulrik Stervbo via R-help
Hi Sumitrajit, dplyr has a function for this - it's called filter. For each group you can count the number of SNR > 3 (you can use sum on true/false). You can filter on the results directly or add a column as you plan. The latter might make your intention more clear. HTH Ulrik On