r

Installing rgdal - backdate rgdal version versus update gdal version, and how?

假如想象 提交于 2021-02-10 15:57:57
问题 Two part question: 1) Like the person who asked this question (rgdal won't install on AWS RStudio AMI), I'm running into problems installing the rgdal package on R running on Ubuntu 16.04. The package wants GDAL 1.11.4 or later, and Synaptic Package manager is only offering GDAL 1.11.3. The solution offered on the above question is to install an older version of rgdal from the archive. On the other hand, the answer given to this older question (Trouble getting latest version of GDAL on ubuntu

R: Use Regex to Import Specific Sheets from Multiple Excel Files

笑着哭i 提交于 2021-02-10 15:57:02
问题 I have a group of Excel files with multiple sheets which don’t follow a standard naming convention. I want to create a single data frame from specific sheets containing the keyword 'frame' . library(tidyverse) library(openxlsx) # Sample Excel File 1 df1 <- data.frame(replicate(10,sample(0:1,10,rep=TRUE))) data_frame2 <- data.frame(replicate(10,sample(0:1,10,rep=TRUE))) list_of_datasets1 <- list("df" = df1, "date_frame" = data_frame2) write.xlsx(list_of_datasets1, file = "writeXLSX1.xlsx") #

R: Creating a new row based on previous rows

雨燕双飞 提交于 2021-02-10 15:55:59
问题 I'm new to R and trying to create a new row based on values on previous rows. Sample data: df <- data.table(Item = c("a", "b", "c", "d"), "2010FY" = c(3, 5, 2, 2), "2011FY" = c(5, 6, 2, 1), "2012FY" = c(-1, 2, 2, 0.5)) I would like to create a new row that divides the 3rd row by the 4th row. Let's call this Item "e" and ideally should like this: Item 2010FY 2011FY 2012FY 1 a 3 5 -1 2 b 5 6 2 3 c 2 2 2 4 d 2 1 0.5 5 e 1 2 4 Using dplyr, my first attempt is: df <- bind_rows(df, e = df[Item %in%

R: Creating a new row based on previous rows

こ雲淡風輕ζ 提交于 2021-02-10 15:55:02
问题 I'm new to R and trying to create a new row based on values on previous rows. Sample data: df <- data.table(Item = c("a", "b", "c", "d"), "2010FY" = c(3, 5, 2, 2), "2011FY" = c(5, 6, 2, 1), "2012FY" = c(-1, 2, 2, 0.5)) I would like to create a new row that divides the 3rd row by the 4th row. Let's call this Item "e" and ideally should like this: Item 2010FY 2011FY 2012FY 1 a 3 5 -1 2 b 5 6 2 3 c 2 2 2 4 d 2 1 0.5 5 e 1 2 4 Using dplyr, my first attempt is: df <- bind_rows(df, e = df[Item %in%

How to use (new) LinkedIn API from and with R?

蓝咒 提交于 2021-02-10 15:53:26
问题 It seems that Rlinkedin is deprecated, that LinkedIn API has changed, and that LinkedIn does not provide a lot of informations for R users in documentation for developers. I don't understand why. For the moment, there are references only for Bash, NodeJS and Java... Could anyone provide a very basic, recent and working example in R to begin with LinkedIn API? For instance, how to get profiles? This kind of example doesn't work: url <- 'https://www.linkedin.com/in/reidhoffman/' library(httr)

How to use (new) LinkedIn API from and with R?

 ̄綄美尐妖づ 提交于 2021-02-10 15:53:17
问题 It seems that Rlinkedin is deprecated, that LinkedIn API has changed, and that LinkedIn does not provide a lot of informations for R users in documentation for developers. I don't understand why. For the moment, there are references only for Bash, NodeJS and Java... Could anyone provide a very basic, recent and working example in R to begin with LinkedIn API? For instance, how to get profiles? This kind of example doesn't work: url <- 'https://www.linkedin.com/in/reidhoffman/' library(httr)

R: split column

ぃ、小莉子 提交于 2021-02-10 15:51:52
问题 I have a column (geneDesc) in a data frame (bacteria) that I want to split into two columns. The column contains the gene ID and the species name of the organism the gene comes from in brackets. For example: geneDesc hypothetical protein, partial [Vibrio shilonii] ankyrin repeat protein [Leptospira kirschneri] helicase [Alteromonas macleodii] I'm using the following command: bacteria2 <- separate(bacteria, geneDesc, c("gene", "species"), sep = "\\[") But I get this error: Error: Values not

GenomicRanges: C stack usage … is too close to the limit

爷,独闯天下 提交于 2021-02-10 15:50:01
问题 I'm loading a built-in ideogram from the biovizBase package: data("hg19Ideogram", package = "biovizBase") The actual object is fine when inspected with str : > hg19Ideogram %>% str Formal class 'GRanges' [package "GenomicRanges"] with 6 slots ..@ seqnames :Formal class 'Rle' [package "IRanges"] with 4 slots .. .. ..@ values : Factor w/ 93 levels "chr1","chr1_gl000191_random",..: 1 2 3 4 5 6 7 8 9 10 ... .. .. ..@ lengths : int [1:93] 1 1 1 1 1 1 1 1 1 1 ... .. .. ..@ elementMetadata: NULL ..

GenomicRanges: C stack usage … is too close to the limit

橙三吉。 提交于 2021-02-10 15:49:12
问题 I'm loading a built-in ideogram from the biovizBase package: data("hg19Ideogram", package = "biovizBase") The actual object is fine when inspected with str : > hg19Ideogram %>% str Formal class 'GRanges' [package "GenomicRanges"] with 6 slots ..@ seqnames :Formal class 'Rle' [package "IRanges"] with 4 slots .. .. ..@ values : Factor w/ 93 levels "chr1","chr1_gl000191_random",..: 1 2 3 4 5 6 7 8 9 10 ... .. .. ..@ lengths : int [1:93] 1 1 1 1 1 1 1 1 1 1 ... .. .. ..@ elementMetadata: NULL ..

How to pass a count of observations to the facet label?

…衆ロ難τιáo~ 提交于 2021-02-10 15:49:00
问题 I would like to add a count of observations in each facet to the "title" of each facet. For instance, I have this: library(tidyverse) mtcars %>% ggplot(aes(x = cyl)) + geom_bar()+ facet_wrap(~carb) and I would like to add the frequencies from the below function to each label table(mtcars$carb) 1 2 3 4 6 8 7 10 3 10 1 1 Thus the label for 1st row 1st column should be 1; n=7 the 1st row 2nd column 2; n=10 etc... 回答1: A solution using tidyverse . We can create an updated column to show the count