

Dear All,
This should be a quite established algorithm, but I have been searching
for a couple days already without finding any satisfactory solution.
I have a matrix defining pairs of SmallerLarger arbitrary character
values, like below
Smaller < c("ASD", "DFE", "ASD", "SDR", "EDF", "ASD")
Larger < c("SDR", "EDF", "KLM", "KLM", "SDR", "EDF"
matComp < cbind(Smaller, Larger)
so that matComp looks like this
Smaller Larger
[1,] "ASD" "SDR"
[2,] "DFE" "EDF"
[3,] "ASD" "KLM"
[4,] "SDR" "KLM"
[5,] "EDF" "SDR"
[6,] "ASD" "EDF"
This matrix establishes six pairs of "larger than" relationships that
can be used to sort the unique values in the matrix,
> unique(as.vector(matComp))
[1] "ASD" "DFE" "SDR" "EDF" "KLM"
Specifically, I would like to get this:
sorted < c("ASD", "DFE", "EDF", "SDR", "KLM")
or, equally valid (my matrix does not have the full information):
sorted < c("DFE", "ASD", "EDF", "SDR", "KLM")
Preferably, I would get the different combinations of the unique values
that satisfy the "larger than" conditions in the matrix...
I am sure this is a trivial problem, but I could not find any algorithm
to solve it.
Any help would be highly appreciated
______________________________________________
[hidden email] mailing list  To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


Try this. Anything that appears only in Smaller is candidate for smallest.
Among those, order is arbitrary.
Anything that appears only in Larger is a candidate for largest. Among
those order is arbitrary.
Remove rows of matComp containing the already classified items. Repeat
with the smaller set.
On Thu, Mar 14, 2019 at 07:30 Pedro Conte de Barros < [hidden email]> wrote:
> Dear All,
>
> This should be a quite established algorithm, but I have been searching
> for a couple days already without finding any satisfactory solution.
>
> I have a matrix defining pairs of SmallerLarger arbitrary character
> values, like below
>
> Smaller < c("ASD", "DFE", "ASD", "SDR", "EDF", "ASD")
>
> Larger < c("SDR", "EDF", "KLM", "KLM", "SDR", "EDF"
>
> matComp < cbind(Smaller, Larger)
>
> so that matComp looks like this
>
> Smaller Larger
> [1,] "ASD" "SDR"
> [2,] "DFE" "EDF"
> [3,] "ASD" "KLM"
> [4,] "SDR" "KLM"
> [5,] "EDF" "SDR"
> [6,] "ASD" "EDF"
>
> This matrix establishes six pairs of "larger than" relationships that
> can be used to sort the unique values in the matrix,
>
> > unique(as.vector(matComp))
> [1] "ASD" "DFE" "SDR" "EDF" "KLM"
>
> Specifically, I would like to get this:
>
> sorted < c("ASD", "DFE", "EDF", "SDR", "KLM")
>
> or, equally valid (my matrix does not have the full information):
>
> sorted < c("DFE", "ASD", "EDF", "SDR", "KLM")
>
> Preferably, I would get the different combinations of the unique values
> that satisfy the "larger than" conditions in the matrix...
>
>
> I am sure this is a trivial problem, but I could not find any algorithm
> to solve it.
>
> Any help would be highly appreciated
>
> ______________________________________________
> [hidden email] mailing list  To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/rhelp> PLEASE do read the posting guide
> http://www.Rproject.org/postingguide.html> and provide commented, minimal, selfcontained, reproducible code.
>
[[alternative HTML version deleted]]
______________________________________________
[hidden email] mailing list  To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


In reply to this post by Pedro Conte de Barros
This cannot be done unless transitivity is guaranteed. Is it?
S L
a b
b c
c a
Bert
On Thu, Mar 14, 2019, 4:30 AM Pedro Conte de Barros < [hidden email]> wrote:
> Dear All,
>
> This should be a quite established algorithm, but I have been searching
> for a couple days already without finding any satisfactory solution.
>
> I have a matrix defining pairs of SmallerLarger arbitrary character
> values, like below
>
> Smaller < c("ASD", "DFE", "ASD", "SDR", "EDF", "ASD")
>
> Larger < c("SDR", "EDF", "KLM", "KLM", "SDR", "EDF"
>
> matComp < cbind(Smaller, Larger)
>
> so that matComp looks like this
>
> Smaller Larger
> [1,] "ASD" "SDR"
> [2,] "DFE" "EDF"
> [3,] "ASD" "KLM"
> [4,] "SDR" "KLM"
> [5,] "EDF" "SDR"
> [6,] "ASD" "EDF"
>
> This matrix establishes six pairs of "larger than" relationships that
> can be used to sort the unique values in the matrix,
>
> > unique(as.vector(matComp))
> [1] "ASD" "DFE" "SDR" "EDF" "KLM"
>
> Specifically, I would like to get this:
>
> sorted < c("ASD", "DFE", "EDF", "SDR", "KLM")
>
> or, equally valid (my matrix does not have the full information):
>
> sorted < c("DFE", "ASD", "EDF", "SDR", "KLM")
>
> Preferably, I would get the different combinations of the unique values
> that satisfy the "larger than" conditions in the matrix...
>
>
> I am sure this is a trivial problem, but I could not find any algorithm
> to solve it.
>
> Any help would be highly appreciated
>
> ______________________________________________
> [hidden email] mailing list  To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/rhelp> PLEASE do read the posting guide
> http://www.Rproject.org/postingguide.html> and provide commented, minimal, selfcontained, reproducible code.
>
[[alternative HTML version deleted]]
______________________________________________
[hidden email] mailing list  To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


Thanks for this.
Yes, this is checked before trying to process this.
Pedro
On 14/03/2019 14.09, Bert Gunter wrote:
This cannot be done unless transitivity is guaranteed. Is it?
S L
a b
b c
c a
Bert
On Thu, Mar 14, 2019, 4:30 AM Pedro Conte de Barros < [hidden email]<mailto: [hidden email]>> wrote:
Dear All,
This should be a quite established algorithm, but I have been searching
for a couple days already without finding any satisfactory solution.
I have a matrix defining pairs of SmallerLarger arbitrary character
values, like below
Smaller < c("ASD", "DFE", "ASD", "SDR", "EDF", "ASD")
Larger < c("SDR", "EDF", "KLM", "KLM", "SDR", "EDF"
matComp < cbind(Smaller, Larger)
so that matComp looks like this
Smaller Larger
[1,] "ASD" "SDR"
[2,] "DFE" "EDF"
[3,] "ASD" "KLM"
[4,] "SDR" "KLM"
[5,] "EDF" "SDR"
[6,] "ASD" "EDF"
This matrix establishes six pairs of "larger than" relationships that
can be used to sort the unique values in the matrix,
> unique(as.vector(matComp))
[1] "ASD" "DFE" "SDR" "EDF" "KLM"
Specifically, I would like to get this:
sorted < c("ASD", "DFE", "EDF", "SDR", "KLM")
or, equally valid (my matrix does not have the full information):
sorted < c("DFE", "ASD", "EDF", "SDR", "KLM")
Preferably, I would get the different combinations of the unique values
that satisfy the "larger than" conditions in the matrix...
I am sure this is a trivial problem, but I could not find any algorithm
to solve it.
Any help would be highly appreciated
______________________________________________
[hidden email]<mailto: [hidden email]> mailing list  To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.
[[alternative HTML version deleted]]
______________________________________________
[hidden email] mailing list  To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


In reply to this post by Pedro Conte de Barros
This is called topological sorting in some circles. The function below
will give you one ordering that is consistent with the contraints but not
all possible orderings. I couldn't find such a function in core R so I
wrote one a while back based on Kahn's algorithm, as described in Wikipedia.
> Smaller < c("ASD", "DFE", "ASD", "SDR", "EDF", "ASD")
> Larger < c("SDR", "EDF", "KLM", "KLM", "SDR", "EDF")
> matComp < cbind(Smaller, Larger)
> sortTopologically(matComp, unique(as.vector(matComp)))
[1] "ASD" "DFE" "EDF" "SDR" "KLM"
Bill Dunlap
TIBCO Software
wdunlap tibco.com
sortTopologically < function(edgeMatrix, V)
{
# edgeMatrix is 2column matrix which describes a partial
# ordering of a set of vertices. The first column is the 'from'
vertex,
# the second the 'to' vertex.
# V is the vector of all the vertices in the graph.
#
# Return a vector, L, consisting of the vertices in
# V in an order consistent with the partial ordering
# described by edgeMatrix.
# Throw an error if such an ordering is not possible.
#
# Use Kahn's algorithm (
https://en.wikipedia.org/wiki/Topological_sorting).
#
# Note that disconnected vertices will not be mentioned in edgeMatrix,
# but will be in V.
stopifnot(is.matrix(edgeMatrix),
ncol(edgeMatrix)==2,
!any(is.na(edgeMatrix)),
!any(is.na(V)),
all(as.vector(edgeMatrix) %in% V))
L < V[0] # match the type of the input
S < setdiff(V, edgeMatrix[, 2])
V < setdiff(V, S)
while(length(S) > 0) {
n < S[1]
# cat("Adding", n, "to L", "\n")
L < c(L, n)
S < S[1]
mRow < edgeMatrix[,1] == n
edgeMatrix < edgeMatrix[ !mRow, , drop=FALSE ]
S < c(S, setdiff(V, edgeMatrix[,2]))
V < setdiff(V, S)
}
if (nrow(edgeMatrix) > 0) {
stop("There are cycles in the dependency graph")
}
L
}
On Thu, Mar 14, 2019 at 4:30 AM Pedro Conte de Barros < [hidden email]>
wrote:
> Dear All,
>
> This should be a quite established algorithm, but I have been searching
> for a couple days already without finding any satisfactory solution.
>
> I have a matrix defining pairs of SmallerLarger arbitrary character
> values, like below
>
> Smaller < c("ASD", "DFE", "ASD", "SDR", "EDF", "ASD")
>
> Larger < c("SDR", "EDF", "KLM", "KLM", "SDR", "EDF"
>
> matComp < cbind(Smaller, Larger)
>
> so that matComp looks like this
>
> Smaller Larger
> [1,] "ASD" "SDR"
> [2,] "DFE" "EDF"
> [3,] "ASD" "KLM"
> [4,] "SDR" "KLM"
> [5,] "EDF" "SDR"
> [6,] "ASD" "EDF"
>
> This matrix establishes six pairs of "larger than" relationships that
> can be used to sort the unique values in the matrix,
>
> > unique(as.vector(matComp))
> [1] "ASD" "DFE" "SDR" "EDF" "KLM"
>
> Specifically, I would like to get this:
>
> sorted < c("ASD", "DFE", "EDF", "SDR", "KLM")
>
> or, equally valid (my matrix does not have the full information):
>
> sorted < c("DFE", "ASD", "EDF", "SDR", "KLM")
>
> Preferably, I would get the different combinations of the unique values
> that satisfy the "larger than" conditions in the matrix...
>
>
> I am sure this is a trivial problem, but I could not find any algorithm
> to solve it.
>
> Any help would be highly appreciated
>
> ______________________________________________
> [hidden email] mailing list  To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/rhelp> PLEASE do read the posting guide
> http://www.Rproject.org/postingguide.html> and provide commented, minimal, selfcontained, reproducible code.
>
[[alternative HTML version deleted]]
______________________________________________
[hidden email] mailing list  To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


In reply to this post by Pedro Conte de Barros
Hi Pedro,
This looks too simple to me, but it seems to work:
swap<function(x,i1,i2) {
tmp<x[i1]
x[i1]<x[i2]
x[i2]<tmp
return(x)
}
mpo<function(x) {
L<unique(as.vector(x))
for(i in 1:nrow(x)) {
i1<which(L==x[i,1])
i2<which(L==x[i,2])
if(i2<i1) L<swap(L,i1,i2)
}
return(L)
}
mpo(matComp)
Jim
On Thu, Mar 14, 2019 at 10:30 PM Pedro Conte de Barros < [hidden email]> wrote:
>
> Dear All,
>
> This should be a quite established algorithm, but I have been searching
> for a couple days already without finding any satisfactory solution.
>
> I have a matrix defining pairs of SmallerLarger arbitrary character
> values, like below
>
> Smaller < c("ASD", "DFE", "ASD", "SDR", "EDF", "ASD")
>
> Larger < c("SDR", "EDF", "KLM", "KLM", "SDR", "EDF"
>
> matComp < cbind(Smaller, Larger)
>
> so that matComp looks like this
>
> Smaller Larger
> [1,] "ASD" "SDR"
> [2,] "DFE" "EDF"
> [3,] "ASD" "KLM"
> [4,] "SDR" "KLM"
> [5,] "EDF" "SDR"
> [6,] "ASD" "EDF"
>
> This matrix establishes six pairs of "larger than" relationships that
> can be used to sort the unique values in the matrix,
>
> > unique(as.vector(matComp))
> [1] "ASD" "DFE" "SDR" "EDF" "KLM"
>
> Specifically, I would like to get this:
>
> sorted < c("ASD", "DFE", "EDF", "SDR", "KLM")
>
> or, equally valid (my matrix does not have the full information):
>
> sorted < c("DFE", "ASD", "EDF", "SDR", "KLM")
>
> Preferably, I would get the different combinations of the unique values
> that satisfy the "larger than" conditions in the matrix...
>
>
> I am sure this is a trivial problem, but I could not find any algorithm
> to solve it.
>
> Any help would be highly appreciated
>
> ______________________________________________
> [hidden email] mailing list  To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/rhelp> PLEASE do read the posting guide http://www.Rproject.org/postingguide.html> and provide commented, minimal, selfcontained, reproducible code.
______________________________________________
[hidden email] mailing list  To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


If I understand correctly, the answer is a topological sort.
Here is an explanation
https://davidurbina.blog/onpartialordertotalorderandthetopologicalsort/This was found by a simple web search on
"Convert partial ordering to total ordering"
Btw. Please use search engines before posting here.
Bert
On Thu, Mar 14, 2019, 10:50 PM Jim Lemon < [hidden email]> wrote:
> Hi Pedro,
> This looks too simple to me, but it seems to work:
>
> swap<function(x,i1,i2) {
> tmp<x[i1]
> x[i1]<x[i2]
> x[i2]<tmp
> return(x)
> }
> mpo<function(x) {
> L<unique(as.vector(x))
> for(i in 1:nrow(x)) {
> i1<which(L==x[i,1])
> i2<which(L==x[i,2])
> if(i2<i1) L<swap(L,i1,i2)
> }
> return(L)
> }
> mpo(matComp)
>
> Jim
>
> On Thu, Mar 14, 2019 at 10:30 PM Pedro Conte de Barros < [hidden email]>
> wrote:
> >
> > Dear All,
> >
> > This should be a quite established algorithm, but I have been searching
> > for a couple days already without finding any satisfactory solution.
> >
> > I have a matrix defining pairs of SmallerLarger arbitrary character
> > values, like below
> >
> > Smaller < c("ASD", "DFE", "ASD", "SDR", "EDF", "ASD")
> >
> > Larger < c("SDR", "EDF", "KLM", "KLM", "SDR", "EDF"
> >
> > matComp < cbind(Smaller, Larger)
> >
> > so that matComp looks like this
> >
> > Smaller Larger
> > [1,] "ASD" "SDR"
> > [2,] "DFE" "EDF"
> > [3,] "ASD" "KLM"
> > [4,] "SDR" "KLM"
> > [5,] "EDF" "SDR"
> > [6,] "ASD" "EDF"
> >
> > This matrix establishes six pairs of "larger than" relationships that
> > can be used to sort the unique values in the matrix,
> >
> > > unique(as.vector(matComp))
> > [1] "ASD" "DFE" "SDR" "EDF" "KLM"
> >
> > Specifically, I would like to get this:
> >
> > sorted < c("ASD", "DFE", "EDF", "SDR", "KLM")
> >
> > or, equally valid (my matrix does not have the full information):
> >
> > sorted < c("DFE", "ASD", "EDF", "SDR", "KLM")
> >
> > Preferably, I would get the different combinations of the unique values
> > that satisfy the "larger than" conditions in the matrix...
> >
> >
> > I am sure this is a trivial problem, but I could not find any algorithm
> > to solve it.
> >
> > Any help would be highly appreciated
> >
> > ______________________________________________
> > [hidden email] mailing list  To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/rhelp> > PLEASE do read the posting guide
> http://www.Rproject.org/postingguide.html> > and provide commented, minimal, selfcontained, reproducible code.
>
> ______________________________________________
> [hidden email] mailing list  To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/rhelp> PLEASE do read the posting guide
> http://www.Rproject.org/postingguide.html> and provide commented, minimal, selfcontained, reproducible code.
>
[[alternative HTML version deleted]]
______________________________________________
[hidden email] mailing list  To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


Thanks Bert. Excellent reference, I learned a lot from it!
Just a note: I did use search engines for at least 2 days before posting. BUT as often happens, I did not use the right keywords. I tried several variants of "Convert ordered pairs to sorted", "Sort vector on paired comparisons" and about anything else I could think of round "paired comparisons". But the problem was, I did not know what was the correct terminology to use for this search, that was why I had to ask.
This is where humans excel versus computer search engines  find things based on imprecise specifications and thanks again for pointing me in the right direction.
Best,
Pedro
On 15/03/2019 08.53, Bert Gunter wrote:
If I understand correctly, the answer is a topological sort.
Here is an explanation
https://davidurbina.blog/onpartialordertotalorderandthetopologicalsort/This was found by a simple web search on
"Convert partial ordering to total ordering"
Btw. Please use search engines before posting here.
Bert
On Thu, Mar 14, 2019, 10:50 PM Jim Lemon < [hidden email]<mailto: [hidden email]>> wrote:
Hi Pedro,
This looks too simple to me, but it seems to work:
swap<function(x,i1,i2) {
tmp<x[i1]
x[i1]<x[i2]
x[i2]<tmp
return(x)
}
mpo<function(x) {
L<unique(as.vector(x))
for(i in 1:nrow(x)) {
i1<which(L==x[i,1])
i2<which(L==x[i,2])
if(i2<i1) L<swap(L,i1,i2)
}
return(L)
}
mpo(matComp)
Jim
On Thu, Mar 14, 2019 at 10:30 PM Pedro Conte de Barros < [hidden email]<mailto: [hidden email]>> wrote:
>
> Dear All,
>
> This should be a quite established algorithm, but I have been searching
> for a couple days already without finding any satisfactory solution.
>
> I have a matrix defining pairs of SmallerLarger arbitrary character
> values, like below
>
> Smaller < c("ASD", "DFE", "ASD", "SDR", "EDF", "ASD")
>
> Larger < c("SDR", "EDF", "KLM", "KLM", "SDR", "EDF"
>
> matComp < cbind(Smaller, Larger)
>
> so that matComp looks like this
>
> Smaller Larger
> [1,] "ASD" "SDR"
> [2,] "DFE" "EDF"
> [3,] "ASD" "KLM"
> [4,] "SDR" "KLM"
> [5,] "EDF" "SDR"
> [6,] "ASD" "EDF"
>
> This matrix establishes six pairs of "larger than" relationships that
> can be used to sort the unique values in the matrix,
>
> > unique(as.vector(matComp))
> [1] "ASD" "DFE" "SDR" "EDF" "KLM"
>
> Specifically, I would like to get this:
>
> sorted < c("ASD", "DFE", "EDF", "SDR", "KLM")
>
> or, equally valid (my matrix does not have the full information):
>
> sorted < c("DFE", "ASD", "EDF", "SDR", "KLM")
>
> Preferably, I would get the different combinations of the unique values
> that satisfy the "larger than" conditions in the matrix...
>
>
> I am sure this is a trivial problem, but I could not find any algorithm
> to solve it.
>
> Any help would be highly appreciated
>
> ______________________________________________
> [hidden email]<mailto: [hidden email]> mailing list  To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/rhelp> PLEASE do read the posting guide http://www.Rproject.org/postingguide.html> and provide commented, minimal, selfcontained, reproducible code.
______________________________________________
[hidden email]<mailto: [hidden email]> mailing list  To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.
[[alternative HTML version deleted]]
______________________________________________
[hidden email] mailing list  To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


Hi Bert,
Good reference and David Urbina's example showed that a simple swap
was position dependent. The reason I pursued this is that it seems
more efficient to sequentially apply the precedence rules to the
arbitrarily sorted elements of the vector than to go through the
directed graph approach. By changing the simple position swap to an
insertion of the outofsequence element before its precedence pair,
both examples work correctly and adding precedence rules to the
initial list also produces a correct result. The output of the
examples below is a bit verbose, as I added a printout of the vector
at each step, ending with a logical indicating whether repos (element
reposition) was called.
repos<function(x,i1,i2) {
tmp<x[i2]
x<x[i2]
if(i1 > 1) return(c(x[1:(i11)],tmp,x[i1:length(x)]))
else return(c(tmp,x))
}
mpo<function(x) {
L<unique(as.vector(x))
for(i in 1:nrow(x)) {
i1<which(L==x[i,1])
i2<which(L==x[i,2])
if(i2<i1) L<repos(L,i1,i2)
cat(L,i2<i1,"\n")
}
cat("\n")
return(L)
}
# Pedro's example
Smaller<c("ASD", "DFE", "ASD", "SDR", "EDF", "ASD")
Larger<c("SDR", "EDF", "KLM", "KLM", "SDR", "EDF")
matComp<cbind(Smaller,Larger)
mpo(matComp)
# David Urbina's example
priors<c("A","B","C","C","D","E","E","F","G")
posts<c("E","H","A","D","E","B","F","G","H")
dinnerMat<cbind(priors,posts)
mpo(dinnerMat)
# add the condition that the taquitos must precede the guacamole
dinnerMat<rbind(dinnerMat,c("G","B"))
mpo(dinnerMat)
To echo David Urbina's disclaimer, I would like to know if I have made
any mistakes.
Jim
______________________________________________
[hidden email] mailing list  To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


In reply to this post by Pedro Conte de Barros
Dear All,
I have tried to load an EDF file using the code below and I received the
following massage :
Error in signals[[sn]]$signal[nextInCSignal[sn]:lastOne] < samples[[sn]] :
replacement has length zero
What this massage means?
Is there any problem with the EDF file?
Code used:
hdr < readEdfHeader("/lasse/neurobit/edf/medidas/g1/G1medida1.edf");
df_id1 < readEdfSignals(hdr, signals = "All", from = 0, till = Inf,
physical = TRUE, fragments = TRUE, recordStarts = TRUE, mergeASignals =
TRUE, simplify = TRUE);
Any help would be highly appreciated.
Mariano
>
>
[[alternative HTML version deleted]]
______________________________________________
[hidden email] mailing list  To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


Dear All,
I have tried to load an EDF file using the code below and I received the
following massage :
Error in signals[[sn]]$signal[nextInCSignal[sn]:lastOne] < samples[[sn]] :
replacement has length zero
What this massage means?
Is there any problem with the EDF file?
Code used:
hdr < readEdfHeader("/lasse/neurobit/edf/medidas/g1/G1medida1.edf");
df_id1 < readEdfSignals(hdr, signals = "All", from = 0, till = Inf,
physical = TRUE, fragments = TRUE, recordStarts = TRUE, mergeASignals =
TRUE, simplify = TRUE);
Any help would be highly appreciated.
Mariano
>
>
[[alternative HTML version deleted]]
______________________________________________
[hidden email] mailing list  To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


Hi Mariano,
The problem appears to be that samples[[sn]] has zero length (or is NULL).
Consider the following code which gives the same error message.
x < 1:10
x[1:5] < as.numeric(NULL)
Error in x[1:5] < as.numeric(NULL) : replacement has length zero
HTH,
Eric
On Fri, May 3, 2019 at 4:32 PM Marcelo Mariano Silva <
[hidden email]> wrote:
> Dear All,
>
> I have tried to load an EDF file using the code below and I received the
> following massage :
>
> Error in signals[[sn]]$signal[nextInCSignal[sn]:lastOne] < samples[[sn]] :
>
> replacement has length zero
>
> What this massage means?
> Is there any problem with the EDF file?
>
> Code used:
> hdr < readEdfHeader("/lasse/neurobit/edf/medidas/g1/G1medida1.edf");
>
>
> df_id1 < readEdfSignals(hdr, signals = "All", from = 0, till = Inf,
> physical = TRUE, fragments = TRUE, recordStarts = TRUE, mergeASignals =
> TRUE, simplify = TRUE);
>
>
> Any help would be highly appreciated.
>
>
> Mariano
>
>
> >
> >
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list  To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/rhelp> PLEASE do read the posting guide
> http://www.Rproject.org/postingguide.html> and provide commented, minimal, selfcontained, reproducible code.
>
[[alternative HTML version deleted]]
______________________________________________
[hidden email] mailing list  To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


Try samples[["sn"]] ?
On Fri, May 3, 2019, 9:53 AM Eric Berger < [hidden email]> wrote:
> Hi Mariano,
> The problem appears to be that samples[[sn]] has zero length (or is NULL).
> Consider the following code which gives the same error message.
>
> x < 1:10
> x[1:5] < as.numeric(NULL)
> Error in x[1:5] < as.numeric(NULL) : replacement has length zero
>
> HTH,
> Eric
>
> On Fri, May 3, 2019 at 4:32 PM Marcelo Mariano Silva <
> [hidden email]> wrote:
>
> > Dear All,
> >
> > I have tried to load an EDF file using the code below and I received the
> > following massage :
> >
> > Error in signals[[sn]]$signal[nextInCSignal[sn]:lastOne] <
> samples[[sn]] :
> >
> > replacement has length zero
> >
> > What this massage means?
> > Is there any problem with the EDF file?
> >
> > Code used:
> > hdr < readEdfHeader("/lasse/neurobit/edf/medidas/g1/G1medida1.edf");
> >
> >
> > df_id1 < readEdfSignals(hdr, signals = "All", from = 0, till = Inf,
> > physical = TRUE, fragments = TRUE, recordStarts = TRUE, mergeASignals =
> > TRUE, simplify = TRUE);
> >
> >
> > Any help would be highly appreciated.
> >
> >
> > Mariano
> >
> >
> > >
> > >
> >
> > [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > [hidden email] mailing list  To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/rhelp> > PLEASE do read the posting guide
> > http://www.Rproject.org/postingguide.html> > and provide commented, minimal, selfcontained, reproducible code.
> >
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list  To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/rhelp> PLEASE do read the posting guide
> http://www.Rproject.org/postingguide.html> and provide commented, minimal, selfcontained, reproducible code.
>
[[alternative HTML version deleted]]
______________________________________________
[hidden email] mailing list  To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.

