你能帮我把标签贴在下图上吗?
我使用的代码:
ext <- read.table("C:/Users/AngieLee/Dropbox/TESIS/total_ex.txt", header=T, sep="\t", row.names=1, dec=",", na.strings="NA")
#total_ex.txt is a adjacency matrix with birds species in the columns and plant species in the rows.
ex<-second.extinct(ext,
participant="higher",
method="degree",
details="FALSE",
nrep=50,
ext.row=NULL,
ext.col=NULL)
slope.bipartite(ex, plot.it=TRUE, ann=FALSE)
使用此代码,我获得了附加的图表。
在此链接中,您可以找到我使用的矩阵: https://www.dropbox.com/s/vfu6m3bvkdwrjq9/total_ex.csv?dl=0
我使用的包是Bipartite。
答案 0 :(得分:0)
您可以尝试以下内容:
package ch.revault.java8;
import static java.lang.String.format;
import static java.util.Arrays.asList;
import static java.util.stream.Collectors.toMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.junit.Test;
public class AppTest {
@Test
public void testApp() {
List<Book> books = getBooks();
List<Author> authors = getAuthors();
String yourBookNameFilter = "The martian";
Map<String, Author> authorsByEmail = authors
.stream()
.collect(toMap(a -> a.email, a -> a));
books.stream()
.filter(b -> b.title.contains(yourBookNameFilter)) // <-- simple
// filter,
.flatMap(b -> b.authorEmails.stream())
.distinct()
.map(e -> authorsByEmail.get(e)) // you could inline
// authorsByEmail lookup
.forEach(a -> System.out.println(format("%s, %s", a.firstName, a.lastName)));
}
public class Author {
final String firstName;
final String lastName;
final String email;
public Author(String firstName, String lastName, String email) {
this.firstName = firstName;
this.lastName = lastName;
this.email = email;
}
}
public class Book {
final String title;
final String isbnNummer;
final Set<String> authorEmails;
public Book(String title, String isbnNummer, Set<String> authorEmails) {
this.title = title;
this.isbnNummer = isbnNummer;
this.authorEmails = authorEmails;
}
}
private List<Author> getAuthors() {
return asList(
new Author("f1", "l1", "e1@example.com"),
new Author("f2", "l2", "e2@example.com"),
new Author("f3", "l3", "e3@example.com"),
new Author("f4", "l4", "e4@example.com"));
}
private List<Book> getBooks() {
return asList(
new Book("The martian", "i1", new LinkedHashSet<>(asList("e2@example.com", "e4@example.com"))),
new Book("t2", "i2",
new LinkedHashSet<>(asList("e1@example.com", "e2@example.com", "e3@example.com"))));
}
}