Re: [R] Identify first row of each ID within a data frame, create a variable first =1 for the first row and first=0 of all other rows

2024-12-01 Thread Boris Steipe
olddata$first <- as.numeric(! duplicated(olddata$ID)) :-) > On Nov 30, 2024, at 22:27, Sorkin, John wrote: > > ID <- c(rep(1,10),rep(2,6),rep(3,2)) > date <- c(rep(1,2),rep(2,2),rep(3,2),rep(4,2),rep(5,2), > rep(5,3),rep(6,3),rep(10,2)) > olddata <- data.frame(ID=ID,date=date) >

Re: [R] [Tagged] Re: col.names in as.data.frame() ?

2023-10-28 Thread Boris Steipe
Ah - that's an excellent point. Thanks. > On Oct 28, 2023, at 14:54, Jeff Newmiller wrote: > > as.data.frame is a _converter_, while data.frame is a _constructor_. > Changing the object contents is not what a conversion is for. > > On October 28, 2023 11:39:

Re: [R] col.names in as.data.frame() ?

2023-10-28 Thread Boris Steipe
ally need the data.frame created in a single > statement or can you change the column names next as in: > > >> nouns > V1 V2 > 1 gagglegeese > 2 duledoves > 3 wake vultures >> colnames(nouns) > [1] "V1" "V2" >> co

[R] col.names in as.data.frame() ?

2023-10-28 Thread Boris Steipe
t; i.e. the col.names argument does nothing. From my reading of ?as.data.frame, my example should have worked. I know how to get the required result with colnames(), but I would like to understand why the idiom as written didn't work, and how I could have known that from the help file. Thanks

Re: [R] plotly

2023-07-22 Thread Boris Steipe
the gauge displays 2320. > I'm not sure why this occurs. Changing the statement to 56, results in the > gauge reading 60. I'm not sure what needs to be changed in the script or the > environment to stop rounding. > On Jul 22, 2023, at 10:43, Boris Steipe wrote: > >

Re: [R] plotly

2023-07-22 Thread Boris Steipe
What do you mean "Rounded"? What do you expect, what do you get instead? ? > On Jul 22, 2023, at 10:40, Thomas Subia via R-help > wrote: > > Colleagues, > Thanks for the update. > My colleagues at work have run this script but the resulting graph output for > value is rounded. How can one

Re: [R] plotly question

2023-07-21 Thread Boris Steipe
--- That seems to do what was requested - the bar is blue now, and changing "Arial" to "Times" in the code indeed has the expected effect. Nice. Boris > On Jul 21, 2023, at 17:43, Jeff Newmiller wrote: > > plotly is _not_ associated

Re: [R] insert hyperlink into svg graphic

2023-03-07 Thread Boris Steipe
correctly identified the issue and suggested a solution using tags instead. Here's how that would work: Your browser does not support the <object> tag. (Most browsers support the object tag: see https://caniuse.com/mdn-html_elements_object ) Cheers, Boris > On 2023-03-07,

Re: [R] question

2023-01-31 Thread Boris Steipe
ask again if you are not sure how to do that. Cheers, Boris PS. Lets hope that the capture did not stress them to the degree that their cortisol is elevated at recapture :-) > On 2023-01-31, at 09:52, Carolyn J Miller via R-help > wrote: > > Thank you! > > Carol

Re: [R] Background for word

2023-01-11 Thread Boris Steipe
ble preview of named and hexadecimal colors is checked. You can turn it off in the global preferences if it bothers you. Tools > Global Options ... > Code > Display ... there is the checkbox mentioned above I like it, it's really useful to set up colour ramps. Cheers, Boris >

Re: [R] Pipe operator

2023-01-03 Thread Boris Steipe
Working off Avi's example - would: x |> cos() |> max(pi/4) |> round(3) |> assign("x", value = _) ...be even more intuitive to read? Or are there hidden problems with that? Cheers, Boris > On 2023-01-03, at 12:40, avi.e.gr...@gmail.com wrote: > >

Re: [R] Amazing AI

2022-12-19 Thread Boris Steipe
line to "concoction" - i.e. an actual academic offence ... Best, Boris > On 2022-12-19, at 03:58, Milan Glacier wrote: > > [You don't often get email from n...@milanglacier.com. Learn why this is > important at https://aka.ms/LearnAboutSenderIdentification ] > &

Re: [R] Amazing AI

2022-12-19 Thread Boris Steipe
05:52, Milan Glacier wrote: > On 12/18/22 19:01, Boris Steipe wrote: > >Technically not a help question. But crucial to be aware of, especially for > >those of us in academia, or otherwise teaching R. I am not aware of a > >suitable alternate forum. If this does not interest

[R] Amazing AI

2022-12-18 Thread Boris Steipe
at's even more OT :-) -------- If you have thoughts to share how your institution is thinking about academic integrity in this situation, or creative ideas how to integrate this into teaching, I'd love to hear from you. All the best! B

Re: [R] cannot print a list with cat

2022-10-24 Thread Boris Steipe
??? t() is the transpose function. It just happens to return your list unchanged. The return value is then printed to console if it is not assigned, or returned invisibly. Transposing your list is probably not what you wanted to do. Returned values do not get printed from within a loop or from

Re: [R] Inappropriate color name

2020-11-17 Thread Boris Steipe
I would not be optimistic about a change - the naming scheme is a community standard, and the community is VERY large; this scheme is employed in thousands of software assets. Ultimately it goes back to X11 color naming in the eighties. See: https://en.wikipedia.org/wiki/X11_color_names for deta

Re: [R] How to pass a character string with a hyphen

2020-11-17 Thread Boris Steipe
tmp <- function(s) { return(str(s)) } key <- "-" tmp(key) # chr "-" ... works for me. Reprex? Cheers, Boris __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mail

Re: [R] Packegs for mathematics

2020-11-17 Thread Boris Steipe
your favourite community forum. Actually downloading and installing packages is very quick, there's no benefit to pre-loading things you don't actually need. Bottom line: don't view this from the perspective of resources, see it from the perspective of what you want to do. Cheers,

Re: [R] paste() turns list element character vector into deparsed expression. Why?

2020-11-09 Thread Boris Steipe
o character. And if that's not possible because there is no good character representation (e.g. if its a closure) than it should return an error. Cheers, Boris > On 2020-11-09, at 22:24, Ege Rubak wrote: > > EXTERNAL EMAIL: Treat content with extra caution. > > I

[R] paste() turns list element character vector into deparsed expression. Why?

2020-11-09 Thread Boris Steipe
te(list(s = c("xyz", "uvw"))$s, collapse = "") But what logic is there in returning a deparsed expression? Thanks! Boris __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/list

Re: [R] newdata for predict.lm() ??

2020-11-04 Thread Boris Steipe
prevents it from applying the formula to another data set. > > Hope that helps, > Achim > > >>> On 4 Nov 2020, at 10:50 , Boris Steipe wrote: >>> >>> Can't get data from a data frame into predict() without a detour that seems >>> quite unne

[R] newdata for predict.lm() ??

2020-11-04 Thread Boris Steipe
to have same name as the coefficient # name should work, right? # Back to the original ... myFit <- lm(DAT$w ~ DAT$h) colnames(myNew) <- "`DAT$h`" # ... same error colnames(myNew) <- "h" # ... same error again. Bottom line: how can I properly specify newdata? The documentation

Re: [R] ??? is to nls() as abline() is to lm() ?

2020-10-17 Thread Boris Steipe
hoped for: curve(predict(myFit, list(x = x)), col = "#FF55", lwd = 2, add = TRUE) Very grateful! Boris > On 2020-10-17, at 20:26, Duncan Murdoch wrote: > > > I haven't followed your example closely, but can't you use the predict() > method for this?

[R] ??? is to nls() as abline() is to lm() ?

2020-10-17 Thread Boris Steipe
(sig*sqrt(2*pi)) * exp( (-1/2)*((x-mu)/sig)^2 ) } # ... and add the curve: curve(mF(x), from = par("usr")[1], to = par("usr")[2], col = "#FF55", lwd = 2, add = TRUE) # But what I would like to do is something much more general, like: curve(myFit$

Re: [R] Best settings for RStudio video recording?

2020-08-16 Thread Boris Steipe
will be doing the best I can to reduce anti-aliasing artefacts and improve legibility? Or does it even matter? Cheers, Boris > On 2020-08-17, at 09:47, Roy Mendelssohn - NOAA Federal via R-help > wrote: > > May I suggest that this discussion is best left for another time an

Re: [R] How to make a vector with string elements without space

2020-05-23 Thread Boris Steipe
The c() is unnecessary. paste() returns a vector. Paste separates elements with " " by default. Set the separator to "" instead. paste("c",1:10, sep = "") ... or use paste0(), which has "" as default separator. paste0("c",1:10) ?paste is your friend. B. > On 2020-05-23, at 22:25, Vahid Bo

Re: [R] Please help translate this program in python to R.

2019-12-14 Thread Boris Steipe
See my response to the C++ question you posted a minute later. B. > On 2019-12-15, at 05:35, Александр Дубровский wrote: > > # Iterative Merge sort (Bottom Up) > > # Iterative mergesort function to > # sort arr[0...n-1] > def mergeSort(a): > >current_size = 1 > ># Outer loop for t

Re: [R] Please help translate this program in C++ to R

2019-12-14 Thread Boris Steipe
See this thread why that's a bad idea ... https://stackoverflow.com/questions/26080716/merge-sort-in-r ... and use the code given there, or give us some context why a literal translation would be important to you. Cheers, Boris > On 2019-12-15, at 05:37, Александр Дубровски

Re: [R] how to find number of unique rows for combination of r columns

2019-11-08 Thread Boris Steipe
know that is about 2 rows > which are non unique. But I would like to extract all 8 columns for those non > unique rows and see what is going on with META value I have in them. > > About duplicated() function I know as well as about unique > > On Fri, 8 Nov 2019 at 10:08,

Re: [R] how to find number of unique rows for combination of r columns

2019-11-08 Thread Boris Steipe
Are you trying to eliminate duplicated rows from your dataframe? Because that would be better achieved with duplicated(). B. > On 2019-11-08, at 10:32, Ana Marija wrote: > > would you know how would I extract from my original data frame, just > these unique rows? > because this gives me on

Re: [R] Help with a third ggplot error

2019-06-17 Thread Boris Steipe
(Technically you are now thread-hijacking. But here goes:) mydf <- data.frame(V11 = c("DD Pack0.002", "FTA English News0.003", "FTA Complimentary0.004"), stringsAsFactors = FALSE) # regex matching start-of-string(letters or

Re: [R] how to identify record with broken format

2019-06-05 Thread Boris Steipe
his" "is "not"' myTxt[3] <- 'This is ok' x <- lengths(regmatches(myTxt, gregexpr('\\"', myTxt))) # (1) which(x %% 2 == 1) [1] 2 Cheers, Boris (1) credit to https://stackoverflow.com/questions/12427385/how-to-calculate-the-number-of-occu

Re: [R] Calculating date difference in days

2019-05-22 Thread Boris Steipe
ed <- as.POSIXlt("2018-03-10") sd <- as.POSIXlt("2018-02-10") as.numeric(ed-sd) [1] 28 ed <- as.POSIXlt("2000-03-10") sd <- as.POSIXlt("2000-02-10") as.numeric(ed-sd) [1] 29 Cheers, B. > On 2019-05-22, at 17:43, reichm...@sbcglobal.net wrote: > > R Help > > I have a function to calculate a da

Re: [R] how to separate string from numbers in a large txt file

2019-05-19 Thread Boris Steipe
u can see the > edge of the expression very well. ^(.{10}) = first. (.{8}) = second. > (<.+>) = third. (.+$) = fourth. So, by the same logic, it would seem > as though in > >> b <- "^([0-9-]{10} [0-9:]{8} )[*]{3} (\\w+ \\w+)" > > that ^([0-9-]{10} [0-9:]{

Re: [R] how to separate string from numbers in a large txt file

2019-05-19 Thread Boris Steipe
ne ^([0-9-]{10} , > directly after the {10}. Why is that? In the second case, I capture without a space, because I don't want the space in the results, after the time. > > Then three *** [*]{3}, then the (\\w+ \\w+)", which Boris explained so > well above. I guess I still don

Re: [R] Nested structure data simulation

2019-05-19 Thread Boris Steipe
000BB44") hist(mySim$Mark[ ! mySim$Teacher %in% tNormal], add = TRUE, col = "#BB000044") Then the challenge is to recover the parameters from your analysis. Cheers, Boris > On 2019-05-19, at 11:14, varin sacha wrote: > > Dear Boris, > > Great But wh

Re: [R] Nested structure data simulation

2019-05-19 Thread Boris Steipe
stringsAsFactors = FALSE) Then you fill mySim$Mark with values from your linear mixed model ... mySim$Mark[i] <- simMarks(mySim[i]) # ... or something equivalent. All good? Cheers, Boris > On 2019-05-19, at 08:05, varin sacha wrote: > > Many thanks

Re: [R] how to separate string from numbers in a large txt file

2019-05-19 Thread Boris Steipe
e are other possibilities, you need a different strategy. In NLP there is no one-approach-fits-all. To validate the structure of the names in your transcripts, you can look at patt <- " <.+?> " # " " m <- regexpr(patt, c) unique(regmatches(c, m)) B.

Re: [R] how to separate string from numbers in a large txt file

2019-05-18 Thread Boris Steipe
ne Doe started a video chat 6 2016-01-27 21:26:57 John Doe ended a video chat B. > On 2019-05-18, at 18:32, Michael Boulineau > wrote: > > Going back and thinking through what Boris and William were saying > (also Ivan), I tried this: > > a <-

Re: [R] Nested structure data simulation

2019-05-18 Thread Boris Steipe
Can you build your data top-down? schools <- paste("s", 1:6, sep="") classes <- character() for (school in schools) { classes <- c(classes, paste(school, paste("c", 1:5, sep=""), sep = ".")) } pupils <- character() for (class in classes) { pupils <- c(pupils, paste(class, paste("p", 1:10,

Re: [R] how to separate string from numbers in a large txt file

2019-05-17 Thread Boris Steipe
Once that is fine, use Bill's approach - or a regular expression of your own design - to create your data frame. Hope this helps, Boris > On 2019-05-17, at 16:18, Michael Boulineau > wrote: > > Very interesting. I'm sure I'll be trying to get rid of the byte ord

Re: [R] saving an R script

2019-05-10 Thread Boris Steipe
If the script is originally in a file. I use ... myScript <- readLines() # [...] modify the myScript vector writeLines(myScript, con = ) If this is not what you mean, perhaps you can describe your intended workflow more explicitly. Cheers, B. > On 2019-05-10, at 09:42, Robert Baer wrote: >

Re: [R] Example for Roxygen @eval tag?

2019-04-21 Thread Boris Steipe
he .Rd - more than before, but not what I thought. An actual example would be most enlightening. Thanks Jeff, Boris > On 2019-04-22, at 02:25, Jeff Newmiller wrote: > > What tag are you creating with the eval? Your example wouldn't create valid > roxygen code... as I said, it lo

Re: [R] Example for Roxygen @eval tag?

2019-04-21 Thread Boris Steipe
ut did you read the vignette [1]? It sounds like it is > a bit more meta than you think it is... > > [1] https://cran.r-project.org/web/packages/roxygen2/vignettes/rd.html > > On April 21, 2019 7:44:17 PM PDT, Boris Steipe > wrote: >> Playing with Roxygen

Re: [R] Help installing netReg

2019-04-21 Thread Boris Steipe
"installation path not writeable" tells you that there is a permissions problem with your setup. Sounds like a pretty standard problem. Someone who works with Windows will know the standard solution. Cheers, B. > On 2019-04-21, at 23:49, Spencer Brackett > wrote: >

Re: [R] Help installing netReg

2019-04-21 Thread Boris Steipe
kages("BiocManager") } if (! requireNamespace("biomaRt", quietly = TRUE)) { BiocManager::install("biomaRt") } Cheers, Boris > On 2019-04-21, at 22:27, Spencer Brackett > wrote: > > R users, > > I am trying to download R Studio onto my Chrombo

[R] Example for Roxygen @eval tag?

2019-04-21 Thread Boris Steipe
Playing with Roxygen features, but can't get @eval to work. E.g. ... #' @eval sprintf("%s", Sys.time()) ... does not do what I thought it would (i.e. substitute the tag and the expression with the string). Instead I see nothing in the .RD file. Any working examples out

Re: [R] R web-scraping a multiple-level page

2019-04-10 Thread Boris Steipe
For similar tasks I usually write a while loop operating on a queue. Conceptually: initialize queue with first page add first url to harvested urls while queue not empty (2) unshift url from queue collect valid child pages that are not already in harvested list (1) add to harvested list

Re: [R] Convert a character to numeric

2019-04-09 Thread Boris Steipe
As there are many possible sources of the warning, to "sort it out" try something like which( is.na() & (! is.na())) B. > On 2019-04-09, at 11:02, Richard M. Heiberger wrote: > > My guess is that numbers formatted with commas are causing an unwanted > coercion. > Remove the commas with

Re: [R] How to rum Multiple ANOVA and Multiple T-test between the same groups?

2019-02-10 Thread Boris Steipe
You need to spend more time getting clear on the fundamentals, what the Bioconductor project is and why its packages are useful in our domain. Bioconductor packages are not installed with the install.packages() function; that is for packages on CRAN. Instead, you use ... install.packages("Bio

Re: [R] Mismatch distribution

2019-01-21 Thread Boris Steipe
se.deletion = FALSE, > variance = FALSE) > Dist <- as.numeric(Dist) > > Data1 <- merge(Data1, Dist) > } > > hist(Data1, prob=TRUE) > > > In the last code, the file Data1 (where I want all the data from the 3 files) > is empty at the end

Re: [R] Mismatch distribution

2019-01-21 Thread Boris Steipe
Myriam - This is the right list in principle, all the packages you use are CRAN packages, not Bioconductor. However I am at a loss as to how you wrote your code: both pegas and seqinr have "read.()" functions, but neither has read.dna(); similarly both pegas and seqinr have "dist.()" functions

Re: [R] help with grouping data and calculating the means

2018-11-15 Thread Boris Steipe
Use round() with the appropriate "digits" argument. Then use unique() to define your groups. HTH, B. > On 2018-11-15, at 11:48, sasa kosanic wrote: > > Dear All, > > I would very much appreciate the help with following: > I need to calculate the mean of different lat/long points that shoul

Re: [R] searching for a specific row name in R

2018-08-13 Thread Boris Steipe
Use the %in% operator: help('%in%') e.g. R > c("d", "v", "4", "s") %in% letters [1] TRUE TRUE FALSE TRUE B. > On 2018-08-13, at 23:36, Deepa wrote: > > Hi Don, > > When there is a list of identifier names that I want to check, the only way > is to loop over each entry stored in the lis

Re: [R] a suggestion about the display of structural variants in R

2018-07-28 Thread Boris Steipe
Maybe the Bioconductor package "intansv" can help you. You asked for linear chromosomes, but such data is commonly plotted in Circos plots as e.g. with the Bioconductor OmicsCircos package (cf. https://bioconductor.org/packages/devel/bioc/vignettes/OmicCircos/inst/doc/OmicCircos_vignette.pdf) H

Re: [R] [FORGED] Re: Generate N random numbers with a given probability and condition

2018-07-11 Thread Boris Steipe
Wasn't there also the requirement that the numbers be drawn from a uniform distribution? These sequences are not. I wonder whether this can for all practical purposes be simplified to consider only the sequence with maximum entropy. B. > On 2018-07-11, at 06:23, Rolf Turner wrote: > > On

Re: [R] Fwd: Quadratic programming, for loop

2018-06-14 Thread Boris Steipe
o do it? > > Thanks again! > > Maija > > 2018-06-13 15:52 GMT+03:00 Boris Steipe : > Q[j-2] gives you Q[0] in your first inner loop iteration. > R arrays start at one. > > B. > > > > On 2018-06-13

Re: [R] Fwd: Quadratic programming, for loop

2018-06-13 Thread Boris Steipe
Q[j-2] gives you Q[0] in your first inner loop iteration. R arrays start at one. B. > On 2018-06-13, at 07:21, Maija Sirkjärvi wrote: > > Amat[J-1+j-2,j-1]= 1/(Q[j] - Q[j-1]) + 1/(Q[j-1] - Q[j-2]) __ R-help@r-project.org mailing list -- To UNSUBSC

Re: [R] How to alpha entire plot?

2018-05-31 Thread Boris Steipe
Interesting problem. I would discretize the x-values and interleave them. Lines from one dataset still overlap, so you see high- density and low-density regions, but lines from the other dataset are drawn into the interval. Like so: interleave <- function(x, MIN, MAX, N, nChannel = 2, channel)

Re: [R] Can't open R files

2018-05-21 Thread Boris Steipe
Just for completeness: there are several ways to open files for editing in RStudio - * Configure your computer to be able to double-click on a file and open it in RStudio: this is OS dependent. Google for "change file associations" to get advice. * Drag and drop a file icon onto the RStu

Re: [R] getting all circular arrangements without accounting for order

2018-03-29 Thread Boris Steipe
If one is equal to the reverse of another, keep only one of the pair. B. > On Mar 29, 2018, at 9:48 PM, Ranjan Maitra wrote: > > Dear friends, > > I would like to get all possible arrangements of n objects listed 1:n on a > circle. > > Now this is easy to do in R. Keep the last spot fixed

Re: [R] Sum of columns of a data frame equal to NA when all the elements are NA

2018-03-21 Thread Boris Steipe
ust > cause trouble. > > -pd > >> On 21 Mar 2018, at 18:05 , Boris Steipe wrote: >> >> Surely the result of summation of non-existent values is not defined, is it >> not? And since the NA values have been _removed_, there's nothing left to >> sum ov

Re: [R] Sum of columns of a data frame equal to NA when all the elements are NA

2018-03-21 Thread Boris Steipe
Surely the result of summation of non-existent values is not defined, is it not? And since the NA values have been _removed_, there's nothing left to sum over. In fact, pretending the the result in that case is zero would appear audacious, no? Cheers, Boris > On Mar 21, 2018, at

Re: [R] Sum of columns of a data frame equal to NA when all the elements are NA

2018-03-21 Thread Boris Steipe
Should not the result be NULL if you have removed the NA with na.rm=TRUE ? B. > On Mar 21, 2018, at 11:44 AM, Stefano Sofia > wrote: > > Dear list users, > let me ask you this trivial question. I worked on that for a long time, by > now. > Suppose to have a data frame with NAs and to sum so

Re: [R] Mean of a row of a data frame

2018-03-20 Thread Boris Steipe
R > rowMeans(roop) [1] 1.67 5.33 3.00 R > mean(as.numeric(roop[1,])) [1] 1.67 :-) > On Mar 20, 2018, at 10:18 PM, Sorkin, John wrote: > > I am trying to get the mean of a row of a data frame. My code follows: > > > roop <- data.frame(x=c(1,2,3),y=c(4,5,2),z=c(0,9,4)) > roo

Re: [R] Modified Band Depth

2018-02-22 Thread Boris Steipe
good with R software. > Since I will be using R in my thesis, it will be helpful if there are R codes > available for that computation. > Can I get your help for this, Sir? > > > Joy Mae > > On Thu, Feb 22, 2018 at 4:08 AM, Boris Steipe > wrote: > If you are

Re: [R] Modified Band Depth

2018-02-21 Thread Boris Steipe
If you are talking about the "Supporting Information" - that contains only one small piece of matlab code that looks pretty trivial to translate if necessary. The rest are R scripts. What then is the problem you need to solve? B. > On Feb 21, 2018, at 9:37 AM, JoyMae Gabion > wrote: > > D

Re: [R] Problem_graphic

2018-02-15 Thread Boris Steipe
I haven't been able to reproduce this because you posted in HTML and no data arrived. Use the dput() function if you want to post data. But: a frequent and trivial reason for disappearing category labels is that the plot window is too small to print them all. Try increasing the plotting window,

Re: [R] Help with regular expressions

2018-02-12 Thread Boris Steipe
You can either use positive lookahead/lookbehind - but support for that is a bit flaky. Or write a proper regex, and use backreferences to keep what you need. R > x <- "abc 1,1 ,1 1, x,y 2,3 " R > gsub("(\\d),(\\d)", "\\1.\\2", x, perl = TRUE) [1] "abc 1.1 ,1 1, x,y 2.3 " B. > On Feb 12, 20

[R] Curiously short cycles in iterated permutations with the same seed

2017-12-07 Thread Boris Steipe
t I don't see why that would lead to such a short cycle (in fact the cycle for the first 100,000 seeds is never longer than 30). Does this have a straightforward explanation? Thanks! Boris __ R-help@r-project.org mailing list -- To UNSUBSCRIBE a

Re: [R] Complicated analysis for huge databases

2017-11-19 Thread Boris Steipe
gt; AllMAFs[[i]] <- apply( SeparatedGroupsofmealsCombs[[i]], 2, > function(x)maf( tabulate( x+1) )) > > refers to a variable "i" that has never been defined. > > Duncan Murdoch > >> >> >> The lapply function : >> results<-lapply(Separ

Re: [R] Complicated analysis for huge databases

2017-11-18 Thread Boris Steipe
gives this error :- > Error in FUN(left, right) : non-numeric argument to binary operator > > I have been trying since yesterday but but until now I'm not able to identify > the correct syntax. > > > > > From: David Winsemius > Sent: 18 November 2017 20:06:56 &

Re: [R] Complicated analysis for huge databases

2017-11-17 Thread Boris Steipe
tput of maf() looks like in your case, and I don't understand why you use tabulate because I would have assumed that's what maf() does - but that's not for me to worry about :-) B. > On Nov 17, 2017, at 7:15 PM, Allaisone 1 wrote: > > > Thanks Boris , this was ve

Re: [R] Complicated analysis for huge databases

2017-11-17 Thread Boris Steipe
Combine columns 1 and 2 into a column with a single ID like "33.55", "44.66" and use split() on these IDs to break up your dataset. Iterate over the list of data frames split() returns. B. > On Nov 17, 2017, at 12:59 PM, Allaisone 1 wrote: > > > Hi all .., > > > I have a large dataset of

[R] Risks of using "function <- package::function" ?

2017-11-16 Thread Boris Steipe
l subset of functions from a larger package. I like that idea and can't see obvious disadvantages(1). Are there subtle risks to that approach? Thanks! Boris (1) I think there could be an issue when packages that are loaded later depend on and extend a function that has has been made local

Re: [R] NEED HELP : Association in single DTM

2017-11-15 Thread Boris Steipe
ame phrase? In the same sentence? Adjacent? Or separated by k words? For what k? Once you come clear on that, we can probably show you ways to translate your procedure into R code. But - as Bert mentioned - we are not well positioned to define the procedure for you. Boris > On Nov 15, 2

Re: [R] NEED HELP : Association in single DTM

2017-11-15 Thread Boris Steipe
If you consider the definition of a DTM, and that findAssoc() computes associations between words as correlations across documents(!), you will realize that you can't what you want from a single document. Indeed, what kind of an "association" would you even be looking for? B. > On Nov 15, 20

Re: [R] Calculating frequencies of multiple values in 200 colomns

2017-11-10 Thread Boris Steipe
|> x <- sample(0:2, 10, replace = TRUE) |> x [1] 1 0 2 1 0 2 2 0 2 1 |> tabulate(x) [1] 3 4 |> table(x) x 0 1 2 3 3 4 B. > On Nov 10, 2017, at 4:32 AM, Allaisone 1 wrote: > > > > Thank you for your effort Bert.., > > > I knew what is the problem now, the values (1,2,3) were only an e

Re: [R] R basic

2017-11-09 Thread Boris Steipe
Hi - This list has a "no homework" policy, but we can certainly help once you show what effort you have put into this yourself. Read the posting guide, especially regarding the instructions re. reproducible examples, and follow them exactly. Cheers, B. > On Nov 9, 2017, at 10:05 AM, Hye Joo

Re: [R] For each entry type in column?

2017-11-06 Thread Boris Steipe
You are right. > On Nov 6, 2017, at 6:47 PM, Bert Gunter wrote: > > Boris: > > "As others have remarked, for added efficiency with large datasets we often > use functions from the apply() family, rather than for-loops." > > That is generally false, t

Re: [R] For each entry type in column?

2017-11-06 Thread Boris Steipe
print(type) } As others have remarked, for added efficiency with large datasets we often use functions from the apply() family, rather than for-loops. I hope this helps, Boris PS: don't call your data frames "df" since df() is a function and this may make your code hard to read.

Re: [R] An iterative function

2017-10-29 Thread Boris Steipe
Write a for-loop that tests your condition and carries the necessary parameters forward. break() when your condition is met. B. > On Oct 29, 2017, at 10:24 PM, li li wrote: > > Dear all, > The function f() below is a function of m1 and m2, both of which are > matrices with 3 rows. The func

Re: [R] comparing two strings from data

2017-10-12 Thread Boris Steipe
It's generally a very good idea to examine the structure of data after you have read it in. str(data2) would have shown you that read.csv() turned your strings into factors, and that's why the == operator no longer does what you think it does. use ... data_2 <- read.csv("excel_data.csv", strin

Re: [R] working with ordinal predictor variables?

2017-10-05 Thread Boris Steipe
This article may be helpful, at least to get you started: https://www.r-bloggers.com/ordinal-data/ Cheers, Boris > On Oct 5, 2017, at 3:35 PM, Bert Gunter wrote: > > I would consider this is a question for a statistics forum such as > stats.stackexchange.com, not R-help, whic

Re: [R] dealing with a messy dataset

2017-10-05 Thread Boris Steipe
is up, but the chance of getting it right is much higher, and most importantly, it's crystal clear, explicit, extensible, and your summer student will see exactly what's going on here. I hope this is helpful, and it comes closer to "how to deal with fixed-width files". Cheers,

Re: [R] dealing with a messy dataset

2017-10-05 Thread Boris Steipe
Since you have an authoritative description of the format, by all means use that - not a guess based on a visual inspection of where data appears in a sample row. B. > On Oct 5, 2017, at 11:02 AM, jean-philippe > wrote: > > dear Jim, > > Thanks for your reply and your proposition. > >

Re: [R] dealing with a messy dataset

2017-10-05 Thread Boris Steipe
Is this a fixed width format? If so, read.fwf() in base, or read_fwf() in the readr package will solve the problem. You may need to trim trailing spaces though. B. > On Oct 5, 2017, at 10:12 AM, jean-philippe > wrote: > > dear R-users, > > > I am facing a quite regular and basic problem

Re: [R] Subset

2017-09-25 Thread Boris Steipe
; to remove 0's rather than NAs , what would it be? > > Thanks > > On Mon, Sep 25, 2017 at 12:41 PM, Boris Steipe > wrote: > myDF <- data.frame(a = c("<0.1", NA, 0.3, 5, "Nil"), >b = c("<0.1", 1, 0.3, 5, "

Re: [R] Subset

2017-09-25 Thread Boris Steipe
ns > > a <- c("<0.1", NA, 0.3, 5, "Nil") > b <- c("<0.1", 1, 0.3, 5, "Nil") > > And I just want to remove the rows from the dataframe where there were NAs in > the b column, what is the syntax for doing that? > > Thanks in adva

Re: [R] Subset

2017-09-22 Thread Boris Steipe
> a <- c("<0.1", NA, 0.3, 5, "Nil") > a [1] "<0.1" NA "0.3" "5""Nil" > b <- as.numeric(a) Warning message: NAs introduced by coercion > b [1] NA NA 0.3 5.0 NA > b[! is.na(b)] [1] 0.3 5.0 B. > On Sep 22, 2017, at 11:48 AM, Shane Carey wrote: > > Hi, > > How do I extract just n

Re: [R] A question about for loop

2017-08-17 Thread Boris Steipe
There are many ways to get the output you want, so your question is ill defined. But it is easy to see where your code goes wrong. And it should be easy for you to fix it. If you subset a vector with the '[' operator, this is like putting a vector of indices "into" the square brackets. So, to d

Re: [R] find similar words in text

2017-08-03 Thread Boris Steipe
Please keep messages on the list so others can pitch in. _Which_ words do you want to consider identical for the purpose of frequency count? _What_ do you want to plot? B. > On Aug 3, 2017, at 4:36 PM, Riaan Van Der Walt > wrote: > > Hallo Boris, > I've loaded the Rs

Re: [R] find similar words in text

2017-07-31 Thread Boris Steipe
You need a stemming algorithm. See here: https://cran.r-project.org/web/views/NaturalLanguageProcessing.html Myself, I've had good experience with Rstem. B. > On Jul 31, 2017, at 4:47 PM, Riaan Van Der Walt > wrote: > > I am new to R. > Busy with Text Analysis. > > Need a script to fin

Re: [R] Conduct Network Analysis

2017-07-14 Thread Boris Steipe
Have a look at the functions available in the igraph package. B. > On Jul 13, 2017, at 11:08 PM, SEB140004 Student > wrote: > > Greeting. > > Dear Mr/Mrs/Miss, > > I want to create a network by using R but I only have a table that contain > OTU ID and the abundance value of two sample

Re: [R] Creating two groups of random numbers

2017-06-29 Thread Boris Steipe
f totals to integers myStudies$cases <- round(myStudies$cases * myStudies$total) Cheers, Boris > On Jun 29, 2017, at 9:44 AM, Naike Wang wrote: > > Hi all, > I want to create two groups of random numbers to calculate proportions. The > first group is to represent the number of case

Re: [R] Nash equilibrium and other game theory tools implemented in networks using igraph or similar

2017-06-28 Thread Boris Steipe
t packages exist because others just > like them contributed something count as being uncivil? Terse, perhaps, since > it bypassed the obvious suggestion to use a search engine, but not rude. > -- > Sent from my phone. Please excuse my brevity. > > On June 28, 2017 5:08:16

Re: [R] Please help(urgent) - How to simulate transactional data for reliability/survival analysis

2017-06-28 Thread Boris Steipe
In principle what you need to do is the following: - break down the time you wish to simulate into intervals. - for each interval, and each failure mode, determine the probability of an event. Determining the probability is the fun part, where you make your domain knowledge explicit and i

Re: [R] Nash equilibrium and other game theory tools implemented in networks using igraph or similar

2017-06-28 Thread Boris Steipe
I don't think OP asked an unreasonable question at all. Civility! > On Jun 27, 2017, at 2:00 PM, Suzen, Mehmet wrote: > > Why don't you implement and uplad the package to CRAN? > > On 27 Jun 2017 17:45, "Chris Buddenhagen" wrote: > > Does anyone know of some code, and examples that implem

Re: [R] Fill in empty cell in data.frame from previous value

2017-06-25 Thread Boris Steipe
Run it through a loop. I assume the cell contents is NA (Not Available). Test for it with is.na(). Whenever that returns TRUE, replace the NA value with the value from the previous row. Cheers, B. > On Jun 24, 2017, at 1:49 PM, Christophe Elek > wrote: > > Hello Total newbie here... I hope

Re: [R] Rainbow in loop

2017-06-08 Thread Boris Steipe
Does: rainbow(3)[1] rainbow(3)[2] rainbow(3)[3] ... solve your issue? B. > On Jun 8, 2017, at 8:20 AM, WRAY NICHOLAS wrote: > > Hi R folk I have a distance time graph for a locomotive and at various times > different events occur on board the loco. I want to put a vertical line on

  1   2   3   4   >