r

Issue with quantile type 2

拜拜、爱过 提交于 2021-02-10 14:16:32
问题 I don't understand the following behavior with quantile . With type=2 it should average at discontinuities, but this doesn't seem to happen always. If I create a list of 100 numbers and look at the percentiles, then shouldn't I take the average at every percentile? This behavior happens for some, but not for all (i.e. 7th percentile). quantile(seq(1, 100, 1), 0.05, type=2) # 5% # 5.5 quantile(seq(1, 100, 1), 0.06, type=2) # 6% # 6.5 quantile(seq(1, 100, 1), 0.07, type=2) # 7% # 8 quantile(seq

Unused argument in summarise n() R

廉价感情. 提交于 2021-02-10 14:14:58
问题 I am trying to run the following code: DF2 %>% group_by(doy, yearadded) %>% summarise(n_entries= n(doy, yearadded)) Which gives me the error: Error in n(doy, yearadded) : unused arguments (doy, yearadded) My yearadded field is a character class and doy is a numeric, is that why it's not working or is there some other reason? 回答1: The n() doesn't take any arguments. It would be library(dplyr) DF2 %>% group_by(doy, yearadded) %>% summarise(n_entries= n()) Or more compactly count(DF2, doy,

Hide labels in plotly donut chart r

◇◆丶佛笑我妖孽 提交于 2021-02-10 14:14:50
问题 I am working on a Shiny app where I am plotting a Donut chart. The slices depend on the variable selected and sometimes are too small. In such cases the labels are displayed outside the chart like in the image below. Is there a way to altogether hide all the labels (values with % sign) in the chart and only allow the hover action to show the details? An reproducible code for a Donut Chart is as below: library(plotly) library(tidyr) library(dplyr) # Get Manufacturer mtcars$manuf <- sapply

How to use the name of the column I'm currently using in a mutate_at?

不问归期 提交于 2021-02-10 14:12:05
问题 I have a datatable with missing data and two columns supposed to help to replace those missing data which looks like : library(data.table) Data = data.table( "H1" = c(NaN,4,NaN), "H2" = c(5,NaN,NaN), "H3" = c(7,NaN,NaN), "Group" = c(1,2,1), "Factor" = c(2,3,4) ) H1 H2 H3 Group Factor 1: NaN 5 7 1 2 2: 4 NaN NaN 2 3 3: NaN NaN NaN 1 4 I would like to use a second dataframe for that Groups = data.table( "H1" = c(1,2,3), "H2" = c(4,5,6), "H3" = c(7,8,9), "Group" = c(1,2,3) ) H1 H2 H3 Group 1: 1

Hide labels in plotly donut chart r

时光总嘲笑我的痴心妄想 提交于 2021-02-10 14:10:20
问题 I am working on a Shiny app where I am plotting a Donut chart. The slices depend on the variable selected and sometimes are too small. In such cases the labels are displayed outside the chart like in the image below. Is there a way to altogether hide all the labels (values with % sign) in the chart and only allow the hover action to show the details? An reproducible code for a Donut Chart is as below: library(plotly) library(tidyr) library(dplyr) # Get Manufacturer mtcars$manuf <- sapply

Error: non-numeric argument to binary operator

 ̄綄美尐妖づ 提交于 2021-02-10 14:08:42
问题 Good Day, making application in RStudio/Shiny is very new to me and I am working with a project in which an external file is to be used as the input data. Here is my CSV: my supposed to be app: So the user insert a csv with appliance name in row 1 and their wattage in row 2 just like in the picture above, then the selectInput will be updated. The user choose what appliance and hours of usage then it will be calculated for its cost Here is my server code: server <- function(input,output

Concatenating data frame rows based on column condition

安稳与你 提交于 2021-02-10 13:58:29
问题 For subsequent discussion, I will refer to the example data frame below: Now, what I wish to achieve is to group all the packet times that are similar - i.e. all the 7s, 12s, etc. Furthermore, the PacketTime field should contain the difference in min and max ( max(PacketTime) - min(PacketTime) ), and the FrameLen , IPLen and TCPLen fields should be lists of all the values that correspond to the grouped time. For example for the 7s group, FrameLen would contain c(304, 276, 276) . My solution

Creating time to event variable in R

牧云@^-^@ 提交于 2021-02-10 13:48:09
问题 Dear all: I've been trying to create a time-to-event variable. Indeed, some time ago, i asked here for help. However, I've detected that it does not fully fulfill my purpose. Below is my data and the variable I want to create "Time-to-event". df2 = structure(list(Country = c("USA", "USA", "USA", "USA", "USA", "USA", "USA", "USA", "USA", "USA", "USA", "USA", "USA"), year = 2000:2012, Event = c(0L, 0L, 1L, 0L, 0L, 0L, 1L, 0L, 1L, 0L, 0L, 0L, 0L), `**Time-to-event**` = c(0L, 1L, 2L, 0L, 1L, 2L,

R: RasterToPolygon works slow, then stop working

允我心安 提交于 2021-02-10 13:45:57
问题 I have a problem to process rasters in R, even if I've done it previously. I can read the data and plot them: however, when I tried to convert my raster to polygon, the R stops working I've tried to update packages, re-install R, on OSX, on Windows 7, always with the same result. Moreover, I've tried to set my projection to NA, but this neither helped. Did you ever experienced problem like this? Do you have some suggestions how to solve the problem? I highly appreciate any suggestions ! MY

R: RasterToPolygon works slow, then stop working

和自甴很熟 提交于 2021-02-10 13:45:25
问题 I have a problem to process rasters in R, even if I've done it previously. I can read the data and plot them: however, when I tried to convert my raster to polygon, the R stops working I've tried to update packages, re-install R, on OSX, on Windows 7, always with the same result. Moreover, I've tried to set my projection to NA, but this neither helped. Did you ever experienced problem like this? Do you have some suggestions how to solve the problem? I highly appreciate any suggestions ! MY