r

R read_excel: libxls error: Unable to parse file

和自甴很熟 提交于 2021-02-11 14:31:18
问题 I'm trying to read xls file into R using readxl::read_excel , but it's giving the following errors: Error: filepath: //.../data.xls libxls error: Unable to parse file also tried readxl::excel_sheets(), but same errors. readxl::format_from_ext(path) gives "xls" Also tried re-installing readxl packages, didn't work for me. My current alternative is to convert this file to "xlsx" using Excel and then read in with readxl::read_excel, but I would like to import the "xls" directly. How to fix it?

Problems with merge function

南笙酒味 提交于 2021-02-11 14:31:12
问题 I'm trying to create a us map with the total cases of Covid-19 by state. In order to do that task I have this following code: library(readxl) library(maptools) library(spdep) library(RColorBrewer) library(sp) library(sf) hp_usa_states <- readShapeSpatial("USA_States.shp") names(shp_usa_states) shp_usa_states@data infected <- read_excel("C:/Users/BP2646/Desktop/databaseinfUS/US.xlsx") names(infected) I have problems with this part of the code " (Error in fix.by(by.x, x) : 'by' must specify a

How to use italic in label_bquote for strip text lables

天大地大妈咪最大 提交于 2021-02-11 14:29:58
问题 There have been many proposed solutions to many slightly different problems, but none quite catches my specific problem. What I want is the following: I want to mix normal subfig labels (a, b, c, ...) with species names in italics . So far, I only want do this for four species, so I could live with a manual solution. But a custom function automatizing the process would be neat... E.g. the strip text of species a would be: a) Genus species Here is a reproducible example with the iris dataset:

Multithread computation with R: how to get all different random numbers?

梦想与她 提交于 2021-02-11 14:29:57
问题 Anyone knows how to get all the random numbers different in the following code? E.g. with doRNG package? I don't care about reproducibility. Edit: Duplicates by pure chance are accepted. rm(list = ls()) set.seed(666) cat("\014") library(plyr) library(dplyr) library(doRNG) # ====== Data Preparation ====== dt = data.frame(id = 1:10, part = rep("dt",10), HG = c(1,3,6,NA,NA,2,NA,NA,NA,NA), random = NA) # ====== Set Parallel Computing ====== library(foreach) library(doParallel) cl = makeCluster(3,

R read_excel: libxls error: Unable to parse file

放肆的年华 提交于 2021-02-11 14:29:55
问题 I'm trying to read xls file into R using readxl::read_excel , but it's giving the following errors: Error: filepath: //.../data.xls libxls error: Unable to parse file also tried readxl::excel_sheets(), but same errors. readxl::format_from_ext(path) gives "xls" Also tried re-installing readxl packages, didn't work for me. My current alternative is to convert this file to "xlsx" using Excel and then read in with readxl::read_excel, but I would like to import the "xls" directly. How to fix it?

How to prevent ggplotly from altering ggplot figure for colorblind

我是研究僧i 提交于 2021-02-11 14:27:51
问题 I'm trying to generate interactive grayscale heatmap using a plot generated by ggplot, I will provide colored examples of the code and images, here is the colored figure that I have: I tried these options: Option didnot work zmapp023ac + scale_fill_identity() %>% ggplotly(.) I get an error: Error in UseMethod("ggplotly", p): no applicable method for 'ggplotly' applied to an object of class "c('ScaleDiscreteIdentity', 'ScaleDiscrete', 'Scale', 'ggproto', 'gg')" Options worked but altered my

How can I make my dumbbell chart in correct descending order?

爱⌒轻易说出口 提交于 2021-02-11 14:26:40
问题 I made an dumbbell chart to show the difference of product sales among different time windows (e.g.weekday VS weekend), and wanted to select the 20 most distinguished products in an descending order. But it seems my order and selection doesn't work properly. Here is the data for dumbbell chart : >head(product_dumbbell) product_aisle daytime evening long medium short weekday weekend 1: candles 16 4 2 6 12 15 5 2: asian foods 115 25 23 29 88 90 50 3: baby accessories 7 3 0 0 10 7 3 4: baby body

How to indicate two highest observations in group (with two conditions)?

南笙酒味 提交于 2021-02-11 14:25:24
问题 Per request from Ronak. This is my data set: Month Week Y Name Color January 2 1.2 Joe Red January 2 3.3 Eric Red January 2 4.5 Mike Blue January 2 1.7 Brian Blue January 2 2.9 Pete Red January 2 6.8 Dave Red January 3 4.6 Joe Red January 3 5.1 Eric Blue January 3 2.1 Mike Blue January 3 6.9 Pete Red January 3 6.8 Dave Red ... I would like to create a new column ('Highest') which identifies the individuals with the two highest Y values in a given week (identifying them with A and B so it will

R: select by color and by ID

北城余情 提交于 2021-02-11 14:24:16
问题 I have the following data in R Data_I_Have <- data.frame( "Node_A" = c("John", "John", "John", "Peter", "Peter", "Peter", "Tim", "Kevin", "Adam", "Adam", "Xavier"), "Node_B" = c("Claude", "Peter", "Tim", "Tim", "Claude", "Henry", "Kevin", "Claude", "Tim", "Henry", "Claude"), " Place_Where_They_Met" = c("Chicago", "Boston", "Seattle", "Boston", "Paris", "Paris", "Chicago", "London", "Chicago", "London", "Paris"), "Years_They_Have_Known_Each_Other" = c("10", "10", "1", "5", "2", "8", "7", "10",

Change the title by pressing a shiny button Shiny R

一世执手 提交于 2021-02-11 14:22:47
问题 library(shiny) ui <- fluidPage( h1("Free",align = "center"), actionButton("go", "Go") ) server <- function(input, output) { observeEvent(input$go,{ #change the h1 title for code("Busy",align="center") } } shinyApp(ui, server) How to change the title when pressing a button? the idea is to change the word free to busy when the button is pressed. 回答1: Would make the h1 header using uiOutput in the ui . Then, you can dynamically change this text to whatever you want in server . Perhaps for your