R - The Elite List


Train and Test split in R

# Males - Dataset
# 70% of the sample size
smp_size <- floor(0.7 * nrow(Males))
# Train and Test Split
train_int <- sample(seq_len(nrow(Males)), size = smp_size)
# 70% training data
tr <- Males[train_int, ]
# 30% test data
te <- Males[-train_int, ]

Scatter Plot with custom hover text in Plotly | R

# Males - Dataset
h_dat = paste("Obs No :", rownames(Males))
sc <- plot_ly( data = Males, x = ~school, y = ~exper, hover_data = 'text', text = h_dat )
layout( sc, yaxis = list(title = "school"), xaxis = list(title = "exper") )

Generate Density Plot in Plotly | R

de_b <- density(Males$exper)
de_b <- data.frame(x = de_b$x, y = de_b$y)
before <- plot_ly(data = de_b, x = ~ x, y = ~ y)
layout(add_lines(before), title = "Density plot of non-transformed variable")