Search
 
SCRIPT & CODE EXAMPLE
 

R

rstudio

rna_fc <- rna %>% select(gene, time,
                         gene_biotype, expression_log) %>%
  group_by(gene, time, gene_biotype) %>%
  summarize(mean_exp = mean(expression_log)) %>%
  pivot_wider(names_from = time,
              values_from = mean_exp) %>%
  mutate(time_8_vs_0 = `8` - `0`, time_4_vs_0 = `4` - `0`)
Comment

rstudio

# library
library(tidyverse)
 
# Create dataset
data <- data.frame(
  individual=paste( "Mister ", seq(1,60), sep=""),
  group=c( rep('A', 10), rep('B', 30), rep('C', 14), rep('D', 6)) ,
  value=sample( seq(10,100), 60, replace=T)
)
 
# Set a number of 'empty bar' to add at the end of each group
empty_bar <- 4
to_add <- data.frame( matrix(NA, empty_bar*nlevels(data$group), ncol(data)) )
colnames(to_add) <- colnames(data)
to_add$group <- rep(levels(data$group), each=empty_bar)
data <- rbind(data, to_add)
data <- data %>% arrange(group)
data$id <- seq(1, nrow(data))
 
# Get the name and the y position of each label
label_data <- data
number_of_bar <- nrow(label_data)
angle <- 90 - 360 * (label_data$id-0.5) /number_of_bar     # I substract 0.5 because the letter must have the angle of the center of the bars. Not extreme right(1) or extreme left (0)
label_data$hjust <- ifelse( angle < -90, 1, 0)
label_data$angle <- ifelse(angle < -90, angle+180, angle)
 
# Make the plot
p <- ggplot(data, aes(x=as.factor(id), y=value, fill=group)) +       # Note that id is a factor. If x is numeric, there is some space between the first bar
  geom_bar(stat="identity", alpha=0.5) +
  ylim(-100,120) +
  theme_minimal() +
  theme(
    legend.position = "none",
    axis.text = element_blank(),
    axis.title = element_blank(),
    panel.grid = element_blank(),
    plot.margin = unit(rep(-1,4), "cm") 
  ) +
  coord_polar() + 
  geom_text(data=label_data, aes(x=id, y=value+10, label=individual, hjust=hjust), color="black", fontface="bold",alpha=0.6, size=2.5, angle= label_data$angle, inherit.aes = FALSE ) 
 
p
Comment

rstudio

install_formats()
Comment

rstudio

load("yourdirectory/someworkspace.RData")
Comment

rstudio

isfar<-load("C:/Users/isfar.RData")
Comment

rstudio

load("C:/Users/isfar.RData") 
head(isfar)
Comment

rstudio

load("C:/Users/isfar.RData", ex <- new.env())
ls.str(ex)
Comment

rstudio

rfm_score <- rfm_table_customer(data = df_rfm,customer_id = Customer,
  n_transactions =Freq_order,recency_days = Recency_days,
  total_revenue = Total_revenue, analysis_date = analysis_date,
  recency_bins = 4,frequency_bins =4, monetary_bins = 4)
Comment

PREVIOUS NEXT
Code Example
R :: Score pairs of records probabilistically in r 
R :: formatc in r 
R :: bioFabric r 
R :: Which library allows modification of Excel files from R 
R :: geom_boxplot line width 
R :: slope by row r 
R :: save large nested list to text R 
R :: cut function R 
R :: r select columns by name 
R :: diff division R 
R :: save link tweet in new column in R 
R :: Non-redundant version of expand.grid 
R :: how to get the r2 value in r 
R :: emf from r plot 
Rust :: exit program rust 
Rust :: rust copy trait 
Rust :: How to know the data type in rust 
Rust :: rust create directory if not exists 
Rust :: use module within another module rust 
Rust :: rust•armanriazi•borrowchecker•lifetime 
Rust :: How to make Rust panic ? 
Rust :: armanriazi•rust•concept•dynamic•dispatch 
Rust :: slice indices are of type usize rust 
Rust :: rust•armanriazi•type•wraper 
Rust :: rust closeure 
Rust :: rust tuple vs vec 
Lua :: base64 decode lua 
Lua :: luau make debounce 
Lua :: roblox table.find 
Lua :: lua event 
ADD CONTENT
Topic
Content
Source link
Name
1+2 =