r

Plotting Custom PDF in R

爷,独闯天下 提交于 2021-02-10 08:10:45
问题 Given: Consider the density function $\phi$ defined on $\mathbb{R}$ for $a\in \mathbb{R}$ and $b \in \mathbb{R}_+^\star$ such that $\forall x \in \mathbb{R}$ , $$ \phi(x; a,b) = \frac{1}{\sqrt{2\pi b^2}}e^{-\frac{1}{2}\left(\frac{x-a}{b}\right)^2}. $$ Consider now the so-called Bart Simpson probability density function $f$ given by \begin{eqnarray} \label{eq:bart:1d:1} f(x) = \frac{1}{2}\phi(x; 0,1) + \frac{1}{10}\sum_{j=0}^4{\phi(x; (j/2)-1, 1/10)}. \end{eqnarray} Questions: Plot the pdf $f$

Plotting Custom PDF in R

与世无争的帅哥 提交于 2021-02-10 08:08:15
问题 Given: Consider the density function $\phi$ defined on $\mathbb{R}$ for $a\in \mathbb{R}$ and $b \in \mathbb{R}_+^\star$ such that $\forall x \in \mathbb{R}$ , $$ \phi(x; a,b) = \frac{1}{\sqrt{2\pi b^2}}e^{-\frac{1}{2}\left(\frac{x-a}{b}\right)^2}. $$ Consider now the so-called Bart Simpson probability density function $f$ given by \begin{eqnarray} \label{eq:bart:1d:1} f(x) = \frac{1}{2}\phi(x; 0,1) + \frac{1}{10}\sum_{j=0}^4{\phi(x; (j/2)-1, 1/10)}. \end{eqnarray} Questions: Plot the pdf $f$

Calculating percent for missing values using gtsummary in Rstudio

一笑奈何 提交于 2021-02-10 08:05:53
问题 My question is a bit similar to this one here. I have this following codes: library(gtsummary) basicvars <- names(isoq) %in% c("homeless_nonself", "test_result") basictable <- isoq[basicvars] # summarize the data table1 <- tbl_summary(basictable, missing = "always", missing_text = "(Missing)", percent = "cell", type = all_dichotomous() ~"categorical" ) %>% bold_labels() ############Selecting the order of variables basiccompletetable <- basictable %>% select(test_result,homeless_nonself)

Plotly: How to customize colors in a donut chart?

若如初见. 提交于 2021-02-10 08:05:33
问题 I would like to ask you if you could help me in customizing of colors in a donut chart created by plotly. The problem is following - I have to recreate a dashboard (from an excel file to a html file). A part of the dashboard is a chart providing us with information about early production of each entity. The chart is a donut chart type by plotly. As each entity is defined by a specific color (defined in RGB) throughout whole dashboard, I need to keep these colors in the donut chart as well.

Combining dataframes into a list

风流意气都作罢 提交于 2021-02-10 07:57:30
问题 I'm trying to store multiple dataframes in a list. However, at some point, the dataframes end up getting converted into lists, and so I end up with a list of lists. All I'm really trying to do is keep all my dataframes together in some sort of structure. Here's the code that fails: all_dframes <- list() # initialise a list that will hold a dataframe as each item for(file in filelist){ # load each file dframe <- read.csv(file) # read CSV file all_dframes[length(all_dframes)+1] <- dframe # add

Combining dataframes into a list

六眼飞鱼酱① 提交于 2021-02-10 07:57:16
问题 I'm trying to store multiple dataframes in a list. However, at some point, the dataframes end up getting converted into lists, and so I end up with a list of lists. All I'm really trying to do is keep all my dataframes together in some sort of structure. Here's the code that fails: all_dframes <- list() # initialise a list that will hold a dataframe as each item for(file in filelist){ # load each file dframe <- read.csv(file) # read CSV file all_dframes[length(all_dframes)+1] <- dframe # add

Reading an Excel file into an R dataframe from a zipped folder

馋奶兔 提交于 2021-02-10 07:45:30
问题 I have an Excel file (.xls extension) that is inside a zipped folder that I would like to read as a dataframe into R. I loaded the gdata library and set up my working directory to the folder that houses the zipped folder. When I type in the following syntax: data_frame1 <- read.xls( unz("./Data/Project1.zip","schools.xls")) I get the following error messages: Error in path.expand(xls) : invalid 'path' argument Error in file.exists(tfn) : invalid 'file' argument I'm guessing that I'm missing

How to Truncate text in DataTable in R Shiny?

耗尽温柔 提交于 2021-02-10 07:44:50
问题 I am using DataTable in Rshiny app to display the content of the Dataframe. But one element of the dataframe is of text, can have characters more than 1000. When I am displaying the datatable it shows all the text. I want to truncate it to first 250 characters and when hover it should show the full text. How can I do that? ui.r shinyUI(fluidPage( theme = shinythemes::shinytheme("flatly"), titlePanel("title"), sidebarLayout( sidebarPanel( width=0 ), mainPanel( width=12, tabsetPanel(tabPanel(

Update deckgl map in R shiny when clicked on bar

主宰稳场 提交于 2021-02-10 07:38:05
问题 Trying to make a shiny app with these properties. Default view is aggregate layer. There will be number of columns/bars. On click of a column, the view is updated to show the non-aggregated version of data. It is something like to know which bar is getting clicked and filtering the data with respect to it. I have written the below code, which does the aggregate layer. However not sure how to get the "clicked_on_this_bar" details. Here if we get, user clicked on bar of "Area A", then we can

ggplot2 theme: axis.text not inheriting from text?

杀马特。学长 韩版系。学妹 提交于 2021-02-10 07:29:27
问题 The current documentation for theme element axis.text says: axis.text tick labels along axes (element_text; inherits from text) but it seems like the inheritance isn't working. This code gives the plot below, with axis text in grey. library(ggplot2) ggplot(data.frame(x=1:10, y=1:10), aes(x, y)) + geom_point(color='red') + theme(rect = element_rect(fill = 'black'), line = element_line(color = 'white'), text = element_text(color = 'blue'), panel.background = element_blank()) Setting axis.text