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
I have been trying to create a data frame from some structured text in a single expression. Reprex: nouns <- as.data.frame( matrix(c( "gaggle", "geese", "dule", "doves", "wake", "vultures" ), ncol = 2, byrow = TRUE), col.names = c("collective", "category")

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
Since it is 2023, I asked that question to ChatGPT-4 and got the following response. - The `plotly` library in R uses the `gauge` argument inside the `plot_ly` function to specify the properties of the gauge plot. You can change the indicator color of the arc (also know

Re: [R] insert hyperlink into svg graphic

2023-03-07 Thread Boris Steipe
This was actually the first thing that ChatGPT debugged for me. The issue was that I was able to click on the link when I displayed the raw SVG in the browser (you can use that to test whether the syntax is even correct), but not when the svg displays inside a html page with the tag. ChatGPT c

Re: [R] question

2023-01-31 Thread Boris Steipe
84%7C0%7C0%7C638107722117850198%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=fGQmH7ad%2BtaJdZU4jenuac%2B46daPUmruBJp4ThoO7GM%3D&reserved=0> >> PLEASE do read the posting guide > http://www.R-project.org/postin

Re: [R] Background for word

2023-01-11 Thread Boris Steipe
It's a new editor feature: see the release notes: https://dailies.rstudio.com/version/2022.12.0+353.pro20/ • Code editor can show previews of color in strings (R named colors e.g. “tomato3” or of the forms “#rgb”, “#rrggbb”, “#rrggbbaa”) when Options > Code > Display > [ ] enable preview of name

Re: [R] Pipe operator

2023-01-03 Thread Boris Steipe
ohn > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, mi

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/mailman/listinfo/r-help PLEASE do

Re: [R] Packegs for mathematics

2020-11-17 Thread Boris Steipe
You really don't need to worry about all those packages in the beginning. Base R has all of the functionality you need to get you started. Then, when you actually need additional functions, you can search for this functionality on the Web, on CRAN, by asking on this helpful list, or on your favo

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

2020-11-09 Thread Boris Steipe
e > length one list > > as.character(list(s = c("xyz", "uvw")) > > to return the length 2 character vector `c("xyz", "uvw")`? What should > > as.character(list(s = c("xyz", "uvw"), t = c("a", "b", "c&

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

2020-11-09 Thread Boris Steipe
I was just surprised by very un-intuitive behaviour of paste(), which appears to collapse a one-column data frame or one-element list into a deparsed expression, rather than producing the expected string. Can someone kindly explain what's going on here? reprex: === list(s = c("xyz", "uvw"

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
Can't get data from a data frame into predict() without a detour that seems quite unnecessary ... Reprex: # Data frame with simulated data in columns "h" (independent) and "w" (dependent) DAT <- structure(list(h = c(2.174, 2.092, 2.059, 1.952, 2.216, 2.118, 1.755, 2

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

2020-10-17 Thread Boris Steipe
To draw a curve, the function that will be used in > curve() sets up a newdata dataframe and passes it to predict(fit, > newdata= ...) to get predictions at those locations. > > Duncan Murdoch > > On 17/10/2020 5:27 a.m., Boris Steipe wrote: >> I'm drawing a fitted n

[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
I totally agree with Roy, thank you. I hope that we can get the discussion back on OP's question (which is timely and very important, and actually not specific to the IDE). The problem is that our possibilities to test user experience are usually limited. AFAIK students could be participating v

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, Александр Дубровский wrote: > > /*

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
I've seen that behaviour with a C" atom in a chemical structure. Here is code to identify lines with an uneven number of quotation marks. Read your file with readLines() to use it. myTxt<- '"This" "is" "fine"' myTxt[2] <- '"This" "is "not"' myTxt[3] <- 'This is ok' x <- lengths(regmatches(

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
ng to do with the ^ or with the space after the > } and before the (, as in > >> {3} (\\w+ > No. Just the parentheses. > Back to earlier: > >> The rest of the line is not substituted and appears as-is. > > Is that due to the space after the \\2? in > >> &

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

2019-05-19 Thread Boris Steipe
he {8}. Hu. So, then, any > number with : for 8 characters, followed by any two words separated by > a space and enclosed in <>. And then the \\s* is followed by a single > space? Or maybe it puts space on both sides (on the side of the #s to > the left, and then the comment to

Re: [R] Nested structure data simulation

2019-05-19 Thread Boris Steipe
les like in this example here below : > > library(lme4) > mm=lmer(Mark ~Gender + (1 | School / Class), data=Dataset) > > With your R code, how can I write the lmer function to make it work ? > > Best, > S. > > > > > > > > Le dimanche 19 mai

Re: [R] Nested structure data simulation

2019-05-19 Thread Boris Steipe
data structure more thoroughly, > ideally with example. > > Thanks, > Lei > > On Sat, May 18, 2019 at 10:04 PM varin sacha via R-help > wrote: >> >> Dear Boris, >> >> Yes, top-down, no problem. Many thanks, but in your code did you not forget &g

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
*(.*$)", > + c, proto=data.frame(stringsAsFactors=FALSE, When="", Who="", > + What="")) >> head (d) > When Who What > 1 > 2 > 3 > 4 > 5 > 6 > > I've

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
Don't start putting in extra commas and then reading this as csv. That approach is broken. The correct approach is what Bill outlined: read everything with readLines(), and then use a proper regular expression with strcapture(). You need to pre-process the object that readLines() gives you: rep

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
oks rather meta.... > > On April 21, 2019 10:40:27 PM PDT, Boris Steipe > wrote: >> Yes, that's where I started - the vignette says: >> >> ... Run arbtirary R code with @eval. >> >> ... the @eval tag. It evaluates code and treats th

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
rt, survival > > ***Does it matter that the packages above are unable to be updated? For > insight, I am trying to generate linear regression models that model > expression of methylation w/ in a TCGA dataset.*** > > Best, > > Spencer > > On Sun, Apr 21, 2019 at

Re: [R] Help installing netReg

2019-04-21 Thread Boris Steipe
This is unrelated to the question on the subject line, we call this "thread hijacking" and that's one of the Things Not To Do. Post a new question. I just wanted to give you the proper incantation for Bioconductor packages. As you already know, don't use bioclite(), which needed to be sourced fr

[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 there? Thanks! Boris ___

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
you cannot compute on NULL so no, that doesn't > work. > > See the note under the "Value" section of ?sum as to why zero is returned > when all inputs are removed. > -- > Sent from my phone. Please excuse my brevity. > > On March 21, 2018 9:03:29 AM PDT, Bor

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
I have noticed that when I iterate permutations of short vectors with the same seed, the cycle lengths are much shorter than I would expect by chance. For example: X <- 1:10 Xorig <- X start <- 112358 N <- 10 for (i in 1:N) { seed <- start + i for (j in 1:1000) { # Maximum cycle length to c

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
gt; > when I run this code as before :- > > maf <- apply(SeparatedGroupsofmealsCombs, 2, function(x)maf(tabulate(x+1))) > > an error message says : dim(X) must have a positive length . I'm not sure > which length > I need to specify.. any suggestions to correc

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
Large packages sometimes mask each other's functions and that creates a headache, especially for teaching code, since function signatures may depend on which order packages were loaded in. One of my students proposed using the idiom <- :: ... in a preamble, when we use just a small subset of

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

2017-11-15 Thread Boris Steipe
t; Election speech) in one single TEXT document, and i want to find the > association of the top 3 most frequently occurring words with the other > words in the speech, what method do I adopt ? > > On Wed, Nov 15, 2017 at 7:08 PM, Boris Steipe > wrote: > > > If you co

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
ep coming along and > sticking things into it." > -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) > > On Mon, Nov 6, 2017 at 3:28 PM, Boris Steipe wrote: > Matti - > > Since you are asking about looping through a column, not looping acros

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

2017-11-06 Thread Boris Steipe
Matti - Since you are asking about looping through a column, not looping across columns, it is simply the following: # Note: data.frame() turns strings into factors by default. myDF <- data.frame(type = c("a", "j", "a", "a", "j"), weight = c(12.3, 6.8, 10.5, NA, "5.5")) myDF

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, which is about R pr

Re: [R] dealing with a messy dataset

2017-10-05 Thread Boris Steipe
Just for the record - and posterity: this is the Wrong way to go about defining a fixed width format and the strategy has a significant probability of corrupting data in ways that are hard to spot and hard to debug. If you _have_ the specification, then _use_ the specification. Consider what yo

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
gt; Tel / Phone / Mogala : 27+72+2172429 > Email / Epos / Emeile: riaan.vanderw...@nwu.ac.za > Url: http://www.nwu.ac.za/ > > >>> Boris Steipe 31 Jul 2017 23:37 >>> > You need a stemming algorithm. See here: > https://cran.r-project.org/web/views/NaturalLanguag

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
I'd do it this way ... let me know if you need explanations. minSize <- 15 maxSize <- 100 minSample <- 0.1 maxSample <- 0.8 # setup dataframe with totals, and cases as fractions myStudies <- data.frame(study = 1:Nstudies, cases = runif(Nstudies,

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   >