As you know, Our country is famous for the popular music industry, named "K-POP".
Recently, the 'tuneR' package to analyze 'wav.file' was released in R.
So I want to know any tendency of the K-POP musics and cluster them by using this package.
In analysis, I got a graph to show the notes of a music file (see example below)
My problem is that I don't know how can I extract the peak value's notes from this graph (those circled in blue)
Please let me know some methods if you know any functions to resolve this problem in R.
library("tuneR")
transcribeMusic <- function(wavFile, widthSample = 4096, expNotes = NULL)
{
perioWav <- periodogram(wavFile, width = widthSample)
freqWav <- FF(perioWav)
noteWav <- noteFromFF(freqWav)
melodyplot(perioWav, observed = noteWav, expected = expNotes, plotenergy = FALSE)
}
songHlp <- readMP3("Beenzino.mp3")
testSound_stereo <- extractWave(songHlp, from = 0, to = 12, xunit = "time")
testSound <- mono(testSound_stereo, "both")
transcribeMusic(testSound)
Related
library(data.table)
var = fread("Q:\\Electricity\\Analysis\\6 Working\\NZ Power\\Jack Perry\\Rainfall\\Clutha R (V01).csv")
var.ts = ts(var$Rainfall, start = c(2008,5),end = c(2020), frequency = 53)
n = length(var.ts)
n
print(var.ts)
plot(var.ts);
var.decomp = stl(var.ts,s.window = 'periodic', t.window = 500)
plot(var.decomp)
Hi,
I need help pulling the data from a timeseries decomposition. I want to take the data from the seasonal component (not just look at the plot).
Thanks,
Jack
The structure is a list of elements. So, we extract the 'time.series' component and get the 'seasonal' column
var.decomp$time.series[, "seasonal"]
When I am trying to perform a funnel plot using the "netmeta" package in r. However, when i try to run the code, it returns a NULL.
#sensitivity OR
p1 <- pairwise(type, event = TP, TP+FN, studlab = total$studynames,
data = total, sm = "OR", allstudies = TRUE)
p1
nb1 <- netmetabin(p1, method = "MH", ref = "A")
netleague(nb1, digits = 3)
netrank(nb1)
nb1
plot(netrank(nb1))
forest(nb1)
Forest plot seems to work and calculating SUCRA scores (netrank) seems to work too (meaning the objects are created correctly). When I use the exact same code for the example databases it does work (not binary data). Is it possible that this is due to the fact that my object is "netmetabin" instead of "netmeta"? If so, what is the alternative to making a funnel plot for binary data for a diagnostic network meta-analysis?
thanks in advance.
I have a set of SpatialDataFrames, both Lines and Polygons. I would like to find the lines/polygons where they overlap. Ultimate goal is to keep all overlaps (preferably with data included) and remove the not-overlapping polygons. The users should be able to see which polygons do overlap and can take action.
I am hoping you can give me a little push to complete this task. Thanks!
Preferably it is showed on leaflet. If that’s too difficult a dataframe with overlapping data will work too.
I have tried using st_intersection, which gives me error ‘no applicable method for ‘st_intersection’… and using gIntersects(spgeom1, spgeom2) which gives me results in TRUE/FALSE format. With some editing I can get the results in row (spgeom2) and col (spgeom1) format. But that’s it…
spdf1 = geojsonio::geojson_read("C:/Users/folder/json/data1.json", what = "sp")
spdf2 = geojsonio::geojson_read("C:/Users/folder/json/data2.json", what = "sp")
spdf3 = geojsonio::geojson_read("C:/Users/folder/json/data3.json", what = "sp")
sp1sp2 = gIntersect(spgeom1, spgeom2, byid = TRUE)
dfoverlaps = as.data.frame(sp1sp2)
overlaps = which(dfoverlaps == “TRUE”, arr.ind = TRUE)
I was reading through this blog post on R-bloggers and I'm confused by the last section of the code and can't figure it out.
http://www.r-bloggers.com/self-organising-maps-for-customer-segmentation-using-r/
I've attempted to recreate this with my own data. I have 5 variables that follow an exponential distribution with 2755 points.
I am fine with and can plot the map that it generates:
plot(som_model, type="codes")
The section of the code I don't understand is the:
var <- 1
var_unscaled <- aggregate(as.numeric(training[,var]),by=list(som_model$unit.classif),FUN = mean, simplify=TRUE)[,2]
plot(som_model, type = "property", property=var_unscaled, main = names(training)[var], palette.name=coolBlueHotRed)
As I understand it, this section of the code is suppose to be plotting one of the variables over the map to see what it looks like but this is where I run into problems. When I run this section of the code I get the warning:
Warning message:
In bgcolors[!is.na(showcolors)] <- bgcol[showcolors[!is.na(showcolors)]] :
number of items to replace is not a multiple of replacement length
and it produces the plot:
Which just some how doesn't look right...
Now what I think it has come down to is the way the aggregate function has re-ordered the data. The length of var_unscaled is 789 and the length of som_model$data, training[,var] and unit.classif are all of length 2755. I tried plotting the aggregated data, the result was no warning but an unintelligible graph (as expected).
Now I think it has done this because unit.classif has a lot of repeated numbers inside it and that's why it has reduced in size.
The question is, do I worry about the warning? Is it producing an accurate graph? What exactly is the "Property"'s section looking for in the plot command? Is there a different way I could "Aggregate" the data?
I think that you have to create the palette color. If you put the argument
coolBlueHotRed <- function(n, alpha = 1) {rainbow(n, end=4/6, alpha=alpha)[n:1]}
and then try to get a plot, for example
plot(som_model, type = "count", palette.name = coolBlueHotRed)
the end is succesful.
This link can help you: http://rgm3.lab.nig.ac.jp/RGM/R_rdfile?f=kohonen/man/plot.kohonen.Rd&d=R_CC
I think that not all of the cells on your map have points inside.
You have 30 by 30 map and about 2700 points. In average it's about 3 points per cell. With high probability some cells have more than 3 points and some cells are empty.
The code in the post on R-bloggers works well when all of the cells have points inside.
To make it work on your data try change this part:
var <- 1
var_unscaled <- aggregate(as.numeric(training[, var]), by = list(som_model$unit.classif), FUN = mean, simplify = TRUE)[, 2]
plot(som_model, type = "property", property = var_unscaled, main = names(training)[var], palette.name = coolBlueHotRed)
with this one:
var <- 1
var_unscaled <- aggregate(as.numeric(data.temp[, data.classes][, var]),
by = list(som_model$unit.classif),
FUN = mean,
simplify = T)
v_u <- rep(0, max(var_unscaled$Group.1))
v_u[var_unscaled$Group.1] <- var_unscaled$x
plot(som_model,
type = "property",
property = v_u,
main = colnames(data.temp[, data.classes])[var],
palette.name = coolBlueHotRed)
Hope it helps.
Just add these functions to your script:
coolBlueHotRed <- function(n, alpha = 1) {rainbow(n, end=4/6, alpha=alpha)[n:1]}
pretty_palette <- c("#1f77b4","#ff7f0e","#2ca02c", "#d62728","#9467bd","#8c564b","#e377c2")
I have a graph that is created by complex numbers from the function below. I would like to extract the resulting data points which correpond with the line from the data plot as to be able to work with a vector of data.
library(multitaper)
NW<-10
K<-5
x<-c(2,3,1,3,4,6,7,8,5,4,3,2,4,5,7,8,6,4,3,2,4,5,7,8,6,4,5,3,2,5,7,8,6,4,5,3,6,7,8,8,9,7,6,5,4,7)
resSpec <- spec.mtm(as.ts(x), k= K, nw=NW, nFFT = length(x),
centreWithSlepians = TRUE, Ftest = TRUE,
jackknife = FALSE, maxAdaptiveIterations = 100,
plot =FALSE, na.action = na.fail)
plot(resSpec)
What would be the best procedure. I have tried saving the plot in emf. I wanted to use package ReadImages which was I believe the right package. (however this was not available for R versión 3.02 so I could not use it). What would be the correct procedure of saving and extracting and are there other packages and in what file types could I save the graph (as far as I can see R (OS windows) only permist emf.)
Any help welcomed