[Solved] Plotting multi histograms in one

You should post the output from dput(Ft_max), that would make it easier for people to load your example. Use functions from the tidyverse package to gather your data in two columns: “key” for the grouping and “values” for the actual values require(tidyverse) Ft_max %>% gather(“key”, “values”) %>% ggplot(aes(x = values, fill = as.factor(key))) + geom_histogram() … Read more

[Solved] how to get the cross table in R? [closed]

data$sal.cat <- cut(data$salary, breaks=seq(1855, 1915, by=10), right=FALSE) data$ex.cat <- cut(data$ex, breaks=seq(1855, 1915, by=10), right=FALSE) cbind( xtabs(~ sal.cat+ex.cat, data=data), total=rowSums(xtabs(~ sal.cat+ex.cat, data=data))) [1855,1865) [1865,1875) [1875,1885) [1885,1895) [1855,1865) 0 0 0 0 [1865,1875) 0 0 0 0 [1875,1885) 1 0 0 0 [1885,1895) 2 0 0 0 [1895,1905) 4 5 0 1 [1905,1915) 0 0 0 0 … Read more

[Solved] How to select certain character? [closed]

Please add a reproducible sample next time. Below is the sample input based on the data from the given link. Input: url <- c(“/history/apollo/”, “/shuttle/countdown/”, “/shuttle/missions/sts-73/mission-sts-73.html”, “/shuttle/countdown/liftoff.html”, “/shuttle/missions/sts-73/sts-73-patch-small.gif”, “/images/NASA-logosmall.gif”, “/shuttle/countdown/video/livevideo.gif”, “/shuttle/countdown/countdown.html”, “/shuttle/countdown/”, “https://stackoverflow.com/”, “/shuttle/countdown/count.gif”, “/images/NASA-logosmall.gif”, “/images/KSC-logosmall.gif”, “/shuttle/countdown/count.gif”, “/images/NASA-logosmall.gif”, “/images/KSC-logosmall.gif”, “/images/ksclogo-medium.gif”, “/images/launch-logo.gif”, “/facts/about_ksc.html”, “/shuttle/missions/sts-71/images/KSC-95EC-0916.jpg”) return_code <- c(200, 200, 200, 304, 200, 304, 200, 200, 200, 200, … Read more

[Solved] “How can I conditionally format the letters in a datatable?

Currently, color = ifelse(‘VARIACION'< -0,’#ed1c16′,’#0ca649’) is evaluating whether the string VARIACION is less than 0. While that is not a particularly meaningful question, R does indeed evaluates that to FALSE (in all your cases) and thus prints things in green as a result. More generally, you do not want to use ifelse() in this case. … Read more

[Solved] How can I plot these in matlab or R

Your question isn’t 100% clear, but I believe this is what you’re asking for. I’ve used Matlab. len = 1000; a_ = linspace(0, 5, len); b_ = linspace(0, 5, len); x = zeros(len); for a = 1:len for b = 1:len val(1) = (a_(a)^2 * (1-b_(b))) / (a_(a) + b_(b) – a_(a)*b_(b)) + (1-a_(a))*a_(a); val(2) … Read more

[Solved] R (ggplot2): line with data labels [closed]

You need to combine DATA2 and DATA3 to one vector and create a vector to define your data. library(ggplot2) x1 <- c(0.2, 0.27, 0.4, 0.37, 0.42, 0.45, 0.70) x2 <- c(0.25, 0.32, 0.28, 0.24, 0.20, 0.19, 0.20) data <- data.frame(x = rep(c(1:7), 2), label = rep(c(“x1”, “x2”), each = 7), y = c(x1, x2)) ggplot(data … Read more

[Solved] Unpivot or transpose columns into rows R [duplicate]

We can use pivot_longer from tidyr library(dplyr) library(tidyr) dt %>% pivot_longer(cols = Apples:Oranges, names_to = ‘Type’, values_to = ‘Values’) %>% arrange(Year, Type) -output # A tibble: 6 x 5 # Year Month Location Type Values # <dbl> <chr> <chr> <chr> <dbl> #1 2020 Jan Store_1 Apples 100 #2 2020 Jan Store_1 Apples 150 #3 2020 … Read more

[Solved] R: create seat number using seat from, seat to, n.tickets [duplicate]

Using base R you can do something like this do.call(“rbind”, lapply(split(dd, 1:nrow(dd)), function(x) { data.frame(dd[1:3], seat=dd[1,4]:dd[1,5], dd[6:7]) })) tested with dd <- read.csv(text=”event , section , row, seat from , seat to, price, n.tickets 1, A, 10, 6, 8, 120, 3″) Here we split up the data.frame by rows, then create a new data.frame by … Read more

[Solved] Fixing r sorting values method

The reason for the observed behavior is the fact, that the factor levels are handled as string. Because of that, the sort is done in an alphabetical order. This results in “100” being before “99” in an ascending order. The workaround was a bit tricky, I have used the stringr package for easier manipulation of … Read more

[Solved] How can I analzye only specific sentences in R? [closed]

Data: lorem <- “\nLorem ipsum dolor sit amet, consectetur adipisicing elit,\nsed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\nUt enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi\nut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit\nin voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur\nsint occaecat cupidatat non … Read more