I’ve got two structures:
max_map <-
structure(list(name = structure(1:11, .Label = c("2-Acetylaminofluorene",
"amsacrine", "aniline", "aspartame", "cyclophosphamide", "doxorubicin",
"indomethacin", "phenacetin", "quercetin", "raloxifene", "urethane"
), class = "factor"), value = c(0.811811403850414, 0.8670680916324,
0.794704077953131, 0.652724115286456, 0.946812003911574, 0.94467294086402,
0.99210186168903, 0.965998352825426, 0.953645104970837, 0.903845608662668,
0.858610554863266)), .Names = c("name", "value"), row.names = c(NA,
-11L), class = "data.frame")
maps <-
structure(list(name = c("2-Acetylaminofluorene", "amsacrine",
"aniline", "aspartame", "cyclophosphamide", "doxorubicin", "indomethacin",
"phenacetin", "quercetin", "raloxifene", "urethane"), avg_relations_fan = c(0.596381660936706,
0.627169363301574, 0.52144016932515, 0.335756276148214, 0.710245148396949,
0.786168090022777, 0.931928694886563, 0.797790600434933, 0.836458734127729,
0.764397331494529, 0.548648356310039), baseline = c(0.441175818174093,
0.661376446637227, 0.470246408568704, 0.325159351267395, 0.664171399502648,
0.75247341151084, 0.894791275258052, 0.79447733086043, 0.791316894314006,
0.593161248492605, 0.546928771024265), baseline_mesh = c(0.511440934523423,
0.635334407445469, 0.466187120416127, 0.292197730456067, 0.712015987803737,
0.774493950979802, 0.936857915628513, 0.776404901563741, 0.786072875131457,
0.586564923115283, 0.602183350788001), standard = c(0.441269542443449,
0.656249151603696, 0.451995996997505, 0.331622681220588, 0.680778834932872,
0.742015626142688, 0.883911615393179, 0.791293422595675, 0.760673562009157,
0.559234401021581, 0.555385232882166), sum_relations_fan = c(0.593111715736251,
0.518197244570419, 0.52676186810563, 0.331234383858585, 0.697489423349489,
0.77249112456473, 0.940506641487552, 0.79946569580319, 0.82893149142568,
0.749819491774919, 0.624830313758535), total = c(0.593111715736251,
0.518197244570419, 0.52676186810563, 0.331234383858585, 0.697489423349489,
0.77249112456473, 0.940506641487552, 0.79946569580319, 0.82893149142568,
0.749819491774919, 0.624830313758535)), .Names = c("name", "avg_relations_fan",
"baseline", "baseline_mesh", "standard", "sum_relations_fan",
"total"), row.names = c(NA, 11L), class = c("cast_df", "data.frame"
), idvars = "name", rdimnames = list(structure(list(name = c("2-Acetylaminofluorene",
"amsacrine", "aniline", "aspartame", "cyclophosphamide", "doxorubicin",
"indomethacin", "phenacetin", "quercetin", "raloxifene", "urethane"
)), .Names = "name", row.names = c("2-Acetylaminofluorene", "amsacrine",
"aniline", "aspartame", "cyclophosphamide", "doxorubicin", "indomethacin",
"phenacetin", "quercetin", "raloxifene", "urethane"), class = "data.frame"),
structure(list(series = c("avg_relations_fan", "baseline",
"baseline_mesh", "standard", "sum_relations_fan", "total"
)), .Names = "series", row.names = c("avg_relations_fan",
"baseline", "baseline_mesh", "standard", "sum_relations_fan",
"total"), class = "data.frame")))
And I’d like to apply the function x/y over the maps dataframe,
where x is the current value and y is the corresponding value along
the name.
I already tried
mapply(function(x,y) {x/y}, t(maps[,!names(maps) %in% c('name')]), arrange(max_map, name)$value)
but that gives me one big list without any names associated. I’d like
the results to be similar to the maps dataframe, just with different values.
I’m just guessing here, but maybe you’re looking to do something like this:
Without the
mergeand without specifying how many columns you have:again, assuming that both are in identical orders.