similar to: fast way to find most common value across columns dataframe

Displaying 20 results from an estimated 7000 matches similar to: "fast way to find most common value across columns dataframe"

2020 Oct 31
2
fast way to find most common value across columns dataframe
As usual, a web search ("find statistical mode in R") brought up something that is possibly useful -- Did you try this before posting? If not, please do so in future and let us know what your results were if you subsequently post here. Here's what SO suggested: Mode <- function(x) { ux <- unique(x) ux[which.max(tabulate(match(x, ux)))] } # ergo:
2020 Oct 31
0
fast way to find most common value across columns dataframe
Hi Luigi, If I understand your request: library(prettyR) apply(as.matrix(df),1,Mode) [1] "C" "B" "D" ">1 mode" ">1 mode" ">1 mode" "D" [8] "C" "B" ">1 mode" Jim On Sat, Oct 31, 2020 at 7:56 PM Luigi Marongiu <marongiu.luigi at gmail.com> wrote:
2020 Oct 31
0
fast way to find most common value across columns dataframe
Thank you. The problem was not finding the mode but applying it the R way (I have the tendency to loop into each line of the dataframes, which I believe is NOT the R way). I'll try them. Best regards Luigi On Sat, Oct 31, 2020 at 5:40 PM Bert Gunter <bgunter.4567 at gmail.com> wrote: > > As usual, a web search ("find statistical mode in R") brought up something that is
2018 Jan 22
2
substr gives empty output
In y <- substr(x, i, 1) your third integer needs to be the location not the number of digits, so change it to y <- substr(x, i, i) and you should get what you want. Cheers, Tim > Date: Sun, 21 Jan 2018 10:50:31 -0500 > From: Ek Esawi <esawiek at gmail.com> > To: Luigi Marongiu <marongiu.luigi at gmail.com>, r-help at r-project.org > Subject: Re: [R] substr
2020 Oct 20
2
How to assign the same levels to a dataframe column?
Hello, I have a dataframe df with a column x that has these unique values: "L" "M" "V" "N" "H". I can assign a factor to it: ``` df$x = as.factor(df$x) > [1] L M V N H Levels: H L M N V ``` I now need to get a subset of this dataframe. I could do the same thing as before on the subset sf, but I would like to avoid the possibility that not all
2020 Oct 23
2
How to shade area between lines in ggplot2
Thank you, but this split the area into two and distorts the shape of the plot. (compared to ``` p + geom_abline(slope = slope_1, intercept = intercept_1 - 1/w[2], linetype = "dashed", col = "royalblue") + geom_abline(slope = slope_1, intercept = intercept_1 + 1/w[2], linetype = "dashed", col = "royalblue") ``` Why there
2020 Oct 20
0
How to assign the same levels to a dataframe column?
Stop using as.factor() and start using factor()? Be explicit about what levels you want and in what order. As for extracting subsets, use split() and do your subsets on each set of rows with the same level. It will be on you to decide what statistical properties (proportions?) you want to maintain between the full data set and your subset. On October 20, 2020 6:42:27 AM PDT, Luigi Marongiu
2020 Oct 26
0
How to shade area between lines in ggplot2
Hi Put fill outside aes p+geom_ribbon(aes(ymin = slope_1*x + intercept_1 - 1/w[2], ymax = slope_1*x + intercept_1 + 1/w[2]), fill = "blue", alpha=0.1) The "hole" is because you have two levels of data (red and blue). To get rid of this you should put new data in ribbon call. Something like newdat <- trainset newdat$z <- factor(0) p+geom_ribbon(data=newdat, aes(ymin =
2020 Oct 23
2
How to shade area between lines in ggplot2
also from this site: https://plotly.com/ggplot2/geom_ribbon/ I get the answer is geom_ribbon but I am still missing something ``` #! plot p = ggplot(data = trainset, aes(x=x, y=y, color=z)) + geom_point() + scale_color_manual(values = c("red", "blue")) # show support vectors df_sv = trainset[svm_model$index, ] p = p + geom_point(data = df_sv, aes(x=x, y=y),
2018 Jan 21
3
substr gives empty output
Dear all, I have a string, let's say "testing", and I would like to extract in sequence each letter (character) from it. But when I use substr() I only properly get the first character, the rest is empty (""). What am I getting wrong? For example, I have this code: >>> x <- "testing" k <- nchar(x) for (i in 1:k) { y <- substr(x, i, 1)
2012 Sep 18
4
add reference lines (or grid) in background
Dear all, Is there a simple way to add reference lines in background? I am trying with abline() or grid() but the lines, since they are executed after the plot function, are draw on top. How can I draw such lines beneath the main plot? Here is an example: x<-rnorm(100) boxplot(x) abline(h=c(-1,0,1)) grid(NA, 4, lwd = 2) regards, Luigi Marongiu, MSc [[alternative HTML
2020 Oct 23
0
How to shade area between lines in ggplot2
Hi What about something like p+geom_ribbon(aes(ymin = slope_1*x + intercept_1 - 1/w[2], ymax = slope_1*x + intercept_1 + 1/w[2], fill = "grey70", alpha=0.1)) Cheers Petr > -----Original Message----- > From: Luigi Marongiu <marongiu.luigi at gmail.com> > Sent: Friday, October 23, 2020 11:11 AM > To: PIKAL Petr <petr.pikal at precheza.cz> > Cc: r-help
2023 Oct 24
2
How to Calculate the Mean by Multiple Groups in R
Hi, I think you're misunderstanding which set of variables go on either side of the formula. Is this what you're looking for? > aggregate(OD ~ Time + Target + Conc, data = df, FUN = "mean") Time Target Conc OD 1 1 BACT 1 765.3333 2 1 BACT 2 745.3333 3 1 BACT 3 675.0000 > aggregate(ODnorm ~ Time + Target + Conc, data = df, FUN =
2012 Jun 13
2
Median line with stripchart
Dear all, I would like to ask if it possible to draw a median line in a Stripchart, either using the built-in STRIPCHART function or with another package. I was expecting stripchart() to work more or less like boxplot(), but I couldn't find an easy way to draw a mean or median line, neither I found this option in other packages. Could somebody help? Best regards, Luigi Marongiu, MSc
2020 Oct 27
3
R for-loop to add layer to lattice plot
Hello, I am using e1071 to run support vector machine. I would like to plot the data with lattice and specifically show the hyperplanes created by the system. I can store the hyperplane as a contour in an object, and I can plot one object at a time. Since there will be thousands of elements to plot, I can't manually add them one by one to the plot, so I tried to loop into them, but only the
2023 Oct 24
2
How to Calculate the Mean by Multiple Groups in R
Hello, I have a data frame with different groups (Time, Target, Conc) and each entry has a triplicate value of the measurements OD and ODnorm. How can I merge the triplicates into a single mean value? I tried the following: ``` df = data.frame(Time=rep(1, 9), Well=paste("A", 1:9, sep=""), OD=c(666, 815, 815, 702, 739, 795, 657, 705, 663),
2020 Jul 14
2
How to install libisl.so.19 on chromebook?
Thank you, it looks like I have already libisl: ``` apt search libisl Sorting... Done Full Text Search... Done libisl-dbg/oldstable 0.18-1 amd64 manipulating sets and relations of integer points bounded by linear constraints libisl-dev/oldstable 0.18-1 amd64 manipulating sets and relations of integer points bounded by linear constraints libisl15/oldstable,now 0.18-1 amd64
2020 Jul 14
1
How to install libisl.so.19 on chromebook?
I don't know about the configuration. I installed R using the standard protocol for Chromebook http://blog.sellorm.com/2018/12/20/installing-r-and-rstudio-on-a-chromebook/ the rest, it was done by the system itself... On Tue, Jul 14, 2020 at 1:30 PM Dirk Eddelbuettel <edd at debian.org> wrote: > > > There is something wrong with your system / setup I did not notice first: >
2020 Oct 23
5
How to shade area between lines in ggplot2
Hello, I am running SVM and showing the results with ggplot2. The results include the decision boundaries, which are two dashed lines parallel to a solid line. I would like to remove the dashed lines and use a shaded area instead. How can I do that? Here is the code I wrote.. ``` library(e1071) library(ggplot2) set.seed(100) x1 = rnorm(100, mean = 0.2, sd = 0.1) y1 = rnorm(100, mean = 0.7, sd =
2020 Oct 23
0
How to shade area between lines in ggplot2
Hi Did you try google? I got several answers using your question e.g. https://stackoverflow.com/questions/54687321/fill-area-between-lines-using-g gplot-in-r Cheers Petr > -----Original Message----- > From: R-help <r-help-bounces at r-project.org> On Behalf Of Luigi Marongiu > Sent: Friday, October 23, 2020 9:59 AM > To: r-help <r-help at r-project.org> > Subject: