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] 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] 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] 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] 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] 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] 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

[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] 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

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-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-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

[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] 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

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] 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] 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] 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] 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] 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
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] 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] 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] 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] 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] 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] [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] Variation of bubble sort (based on divisors)

2017-03-31 Thread Boris Steipe
This looks opaque and hard to maintain. It seems to me that a better strategy is to subset your vector with modulo expressions, use a normal sort on each of the subsets, and add the result to each other. 0 and 1 need to be special-cased. myPrimes <- c(2, 3, 5) mySource <- sample(0:10) # specia

Re: [R] Correlation between continuous and binary vectors.

2017-04-01 Thread Boris Steipe
Yes. > On Mar 31, 2017, at 11:53 PM, Art U wrote: > > Hi, > I'm trying to create number of vectors, part of them are binary and part > are continuous. Is there a way in R to generate them with specific > correlation between each pair? > Thank you in advance. > Ariel > -- > *I like to pretend

Re: [R] Combine vectors under the names

2017-04-02 Thread Boris Steipe
Your code is syntactically correct but goes against all R style guides I know. I've changed that - but obviously you don't have to. x1 <- c(a1 = 0, b3 = 2, e2 = -2) x2 <- c(c = 3, d = 4, f = 5) N <- c("a1", "b3", "d", "e2", "c", "f") x3 <- c(x1, x2) # concatenate x3 <- x3[N

Re: [R] Variation of bubble sort (based on divisors)

2017-04-03 Thread Boris Steipe
the attachment. > > > Wolny od wirusów. www.avast.com > > On Sat, Apr 1, 2017 at 2:38 PM, Boris Steipe wrote: > The modulo operator returns remainder after division. The goal is to select a > number if the remainder is zero. Casting a number to logical returns FALSE

Re: [R] R function stopped working

2017-04-04 Thread Boris Steipe
I discourage the use of print() for debugging. Put a browser() statement into your loop and when execution takes you to the debugger interface, examine your variables and expressions one by one. B. > On Apr 4, 2017, at 10:09 AM, DANIEL PRECIADO wrote: > > To your first comment: Yes, the fu

Re: [R] system call removes special characters from text output

2017-04-04 Thread Boris Steipe
The "whatever information" would be the usual minimal reproducible example. Since you think your code works at the shell level, make up an example with a system call to "echo". Then state what you expect to happen and what happens instead. B. > On Apr 4, 2017, at 12:44 AM, stephen sefick wro

Re: [R] Finding Infimum in R

2017-04-09 Thread Boris Steipe
Is the function linear between the discontinuities? Can you give an example of how the function is specified? B. > On Apr 9, 2017, at 8:38 PM, li li wrote: > > Hi Burt, >Yes, the function is monotone increasing and points of discontinuity > are all known. > They are all numbers between 0

Re: [R] Finding Infimum in R

2017-04-10 Thread Boris Steipe
Are you sure this is trivial? I have the impression the combination of an ill-posed problem and digital representation of numbers might just create the illusion that is so. B. > On Apr 10, 2017, at 12:34 AM, Bert Gunter wrote: > > Then it's trivial. Check values at the discontinuities and

Re: [R] Finding Infimum in R

2017-04-10 Thread Boris Steipe
e I suggested fail? > > (Always happy to be corrected). > > -- Bert > Bert Gunter > > "The trouble with having an open mind is that people keep coming along > and sticking things into it." > -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip

Re: [R] Finding Infimum in R

2017-04-10 Thread Boris Steipe
t; "The trouble with having an open mind is that people keep coming along > and sticking things into it." > -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) > > > On Mon, Apr 10, 2017 at 7:56 AM, Boris Steipe > wrote: >> Well - the _proce

Re: [R] Finding Infimum in R

2017-04-10 Thread Boris Steipe
F is f). The infimum of a set is not > necessarily a member of the set. > > -pd > >> On 10 Apr 2017, at 16:56 , Boris Steipe wrote: >> >> Well - the _procedure_ will give a result. >> >> But think of f(x) = {-1; x <= 1/3 and 1; x > 1/3 >>

Re: [R] Finding Infimum in R

2017-04-10 Thread Boris Steipe
Here's my crossword-puzzle for the day: # A sample monotonous discontinuous function with a single root # (vectorized) F <- function(x) { return((as.numeric(x >= 0.112233445566778899) * 2) - 1) } discRoot <- function(xL, xR, F, k = 10) { # Return the interval containing a single root of

Re: [R] Eliminating numbers, period, and space from a string

2017-04-10 Thread Boris Steipe
Fie, knave, dost thou bid us do thine homework! gsub("[^A-Za-z]", "", ) > On Apr 10, 2017, at 7:11 PM, Olu Ola via R-help wrote: > > Hello,I have a column of my data of the Following format > 10. Arnold125. Jessica1. Romeo117. Juliet > I need to eliminate the numbers, period, and the space be

Re: [R] Setting .Rprofile for RStudio on a Windows 7 x64bit

2017-04-15 Thread Boris Steipe
As with R, do with RStudio: Read The Beautiful Manual, and peruse The Google. For example, searching Google with the two (admittedly hard to guess) cryptograms: "RStudio Rprofile" will present more than a dozen most enlightening links to fulfil your desire. Perhaps the following link works be

Re: [R] qqplot for binomial distribution

2017-04-17 Thread Boris Steipe
Moreover, setting the seed once, then evaluating two functions means you are sampling from the same distributions, but you do in fact have different values. Outliers in the rarefied tails of the distribution may lie quite considerably off the expected diagonal. Try set.seed(123) qqplot(rbinom(n

Re: [R] qqplot for binomial distribution

2017-04-17 Thread Boris Steipe
That's not how qqline() works. The line is drawn with respect to a _reference_distribution_ which is the normal distribution by default. For the binomial distribution, you need to specify the distribution argument. There is an example in the help page that shows you how this is done for qchisq()

Re: [R] Return value from function with For loop

2017-04-17 Thread Boris Steipe
Ramnik, a final mail is actually really important: this is to document in the archives, for the benefit of those who found the thread at a later time, that the responses indeed solved the problem. Other than that, the single most important advice is to - provide a minimal working example of the

Re: [R] qqplot for binomial distribution

2017-04-18 Thread Boris Steipe
ed how often > out of 100 times did the data fall outside the CI.This I expect to be > binomial with n=100,p=.05. I repeated this a 100 times and obtained > count1_vector. > > Best Regards, > Ashim. > > > On Mon, Apr 17, 2017 at 7:51 PM, Boris Steipe > wrote: &

Re: [R] Unknown anomaly

2017-04-18 Thread Boris Steipe
The concept of equality for numbers that are represented on a computer is frequently misapplied. Consider: a <- seq(from=0, to=1, by=0.02) print(a[36]) [1] 0.7 a[36] == 0.7 [1] FALSE print(a[36], digits=22) [1] 0.7000666134 a[36] == 0.7001 [1] TRUE All clear? B.

Re: [R] r codes

2017-04-18 Thread Boris Steipe
Here you go: https://www.google.ca/search?q=r+partial+least+squares https://www.google.ca/search?q=r+ridge+regression > On Apr 18, 2017, at 3:45 PM, SAIRA SALEEM wrote: > > i required r codes to calculate partial least squares and ridge regression > _

Re: [R] Prediction plots

2017-04-19 Thread Boris Steipe
Can you provide a small reproducible example and explain what exactly is going wrong? Just a handful of data points will do. B. > On Apr 18, 2017, at 2:16 PM, Santiago Bueno wrote: > > Thanks Boris, the following is an extract of my data. I have developed > biomass models using codes like:

Re: [R] Asking for help

2017-04-19 Thread Boris Steipe
What about the advice I sent you this morning? B. > On Apr 19, 2017, at 1:49 PM, Boris Steipe wrote: > > No attachments please. Use the dput() function. And keep the correspondence > on the list, there are many colleagues who are far more knowledgeable than I > am. >

Re: [R] Frequency of Combinations

2017-04-24 Thread Boris Steipe
This can be easily done in base R. The solution below is pedestrian, transparent and explicit. Thus it's easy to debug and validate(!) each step. Prepare: (1) Save your Excel spreadsheet as a text file with tab-separated values. (2) Initialize a 128 * 128 matrix to hold your results. It should ha

Re: [R] Multiple-Response Analysis: Cleaning of Duplicate Codes

2017-04-25 Thread Boris Steipe
How about: d_sample_1 <- floor(d_sample/100) * 100 for (i in 1:nrow(d_sample_1)) { d_sample_1[i, duplicated(unlist(d_sample_1[i, ]))] <- NA } B. > On Apr 25, 2017, at 1:10 PM, Bert Gunter wrote: > > If I understand you correctly, one way is: > >> z <- rep(LETTERS[1:3],4) >> z > [1] "A

Re: [R] Counting enumerated items in each element of a character vector

2017-04-25 Thread Boris Steipe
How about: unlist(lapply(strsplit(text1, "Example"), function(x) { length(x) - 1 } )) Splitting your string on the five "Examples" in each gives six elements. length(x) - 1 is the number of matches. You can use any regex instead of "example" if you need to tweak what you are looking for. B.

Re: [R] Counting enumerated items in each element of a character vector

2017-04-25 Thread Boris Steipe
I should add: there's a str_count() function in the stringr package. library(stringr) str_count(text1, "Example") # [1] 5 5 5 5 I guess that would be the neater solution. B. > On Apr 25, 2017, at 8:23 PM, Boris Steipe wrote: > > How about: > > unlist(l

Re: [R] Counting enumerated items in each element of a character vector

2017-04-26 Thread Boris Steipe
;> version that uses regular expressions, the only benefit of which is >>>> that it could be generalized to find more-complicated patterns. >>>> >>>> -- Mike >>>> >>>> counts <- sapply(text1, function(next_string) { >&

Re: [R] Reg. help for SWAT Calibration

2017-04-26 Thread Boris Steipe
Your mental model of what R is and does appears to be misaligned with actuality. Quoting from Wikipedia: R is an open source programming language and software environment for statistical computing and graphics [...]. The R language is widely used among statisticians and data miners for d

Re: [R] Counting enumerated items in each element of a character vector

2017-04-26 Thread Boris Steipe
r a period (.). If > the delimiter is a period and there are hard returns (example 2), then I > expect that will be easy enough to differentiate sentences ending with a > number from enumerated items. However, I imagine it would be much more > difficult to differentiate the two for

Re: [R] read list of binary files and explore them

2017-04-29 Thread Boris Steipe
Given that, you can be certain that your file contains more than one or two numbers, thus your way of reading it must be wrong. B. > On Apr 29, 2017, at 11:34 AM, Ragia . wrote: > > > files size is 7682 kb > > sorry for multiple emails > > Ragia > > > > > ___

Re: [R] nested for loop with data table

2017-05-02 Thread Boris Steipe
There's a lot that doesn't make sense here. I think what you need to do is produce a small, reproducible example, post that with dput() and state your question more clearly - including what you have tried and what didn't work. You'll probably be amazed how quickly you will get good advice if _y

Re: [R] How do I use R to build a dictionary of proper nouns?

2017-05-05 Thread Boris Steipe
Did you try using the table() function, possibly in combination with sort() or rank()? Consider: myNouns <- c("proper", "nouns", "domain", "ontology", "dictionary", "dictionary", "corpus", "patent", "files", "proper", "nouns", "word", "frequency", "file", "preprocess",

Re: [R] How do I use R to build a dictionary of proper nouns?

2017-05-08 Thread Boris Steipe
polish head", "polish system", "polym pad", "polyurethan > pad", "porous", "process paramet", "process path", "process time", > "recoveri", "rotat speed", "rough", "scatter", &

Re: [R] Joining tables with different order and matched values

2017-05-09 Thread Boris Steipe
myDf1 <- data.frame(drugs = c("Ibuprofen", "Simvastatin", "Losartan"), indications = c("pain", "hyperlipidemia", "hypertension"), stringsAsFactors = FALSE) myDf2 <- data.frame(drugs = c("Simvastatin", "Losartan", "Ibuprofen", "Metformin"),

Re: [R] How to replace missing values by mean of subgroup of a group

2017-05-09 Thread Boris Steipe
Pedestrian code, so you can analyze this easily. However entirely untested since I have no ambitionto recreate your input data as a data frame. This code assumes: - your data _is_ a data frame - the desired column is called food.price, not "food price" (cf. ?make.names ) # define a function th

Re: [R] How to replace missing values by mean of subgroup of a group

2017-05-09 Thread Boris Steipe
t; > On Tuesday, May 9, 2017 4:20 PM, Boris Steipe > wrote: > > > Pedestrian code, so you can analyze this easily. However entirely untested > since I have no ambitionto recreate your input data as a data frame. This > code assumes: > - your data _is_ a data frame &

Re: [R] How to replace missing values by mean of subgroup of a group

2017-05-09 Thread Boris Steipe
ad > on another site. > > Cheers, > Bert > > > > On May 9, 2017 3:36 PM, "Boris Steipe" wrote: > Great. > > I am CC'ing the list - this is important so that others who may come across > this thread in the archives know that this question has bee

Re: [R] Force argument to have quotes

2017-06-06 Thread Boris Steipe
If I understand you correctly what you are really asking is how to embed quotes in a string so that it can be parse()'d as an expression. The answer would be: escape the quotes. R > myOptions <- "Hello" R > eval(parse(text = paste( "print(", myOptions, ")" ))) Error in print(Hello) : object 'H

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

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] 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] 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
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] 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] 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] 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] 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] 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] 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] 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-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] 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] 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
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] 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] 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] suggestion of regex pattern

2015-04-18 Thread Boris Steipe
This is not a regular expression but simply a conjunction (sequence of '&') of logical expressions. Moreover it's not wrong. Consider: xyz <- data.frame(municipio = c('Limeira'), mesincident = c('marco'), trechoklmetros = c(3.00, -4.00, 30)) xyz municipio mesincident trechoklmetros 1 Limeir

Re: [R] Problems combining two plots using par(mfrow=)

2015-04-18 Thread Boris Steipe
I can reproduce your problem. It affects both sine-waves if the graph is plotted as the second plot, so it seems that plotting the graph affects all subsequent plots. It affects all plots in subsequent plots to the same window. The window needs to be closed to correct this. I would file a bug re

Re: [R] suggestion of regex pattern

2015-04-18 Thread Boris Steipe
will reveice all strings to filter in a dataset by > subset below: > > > a loop each line: > > subset(dataset_read, desired_fomart[i]) > > My question: taking into consideration this cenario, in your oppinion your > reply is my suitable for my problem, whereas i wil

Re: [R] Error en `*tmp*`[[i]] : subíndice fuera de los límites

2015-04-18 Thread Boris Steipe
You haven't provided nearly enough information for us to be able to help. Please see here for some hints on how to ask questions productively: http://adv-r.had.co.nz/Reproducibility.html http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example ... and please read the po

Re: [R] suggestion of regex pattern

2015-04-18 Thread Boris Steipe
> 1 & xyz$b == 4) xyz[eval(expp), ] # evaluate an expression in place a b 2 2 4 ... but really, it's just a guess at what you might be trying to do. B. On Apr 18, 2015, at 1:30 PM, Boris Steipe wrote: > Sorry - it's not entirely clear to me

Re: [R] generate a list as follows: 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, . . . . ., n, n, n, n

2015-04-20 Thread Boris Steipe
That would be the "each" argument to rep()... n <- 5 rep(1:n, each=4) [1] 1 1 1 1 2 2 2 2 3 3 3 3 4 4 4 4 5 5 5 5 Cheers, B. On Apr 19, 2015, at 9:44 AM, John Sorkin wrote: > Windows 7 64-bit > R 3.1.3 > RStudio 0.98.1103 > > > I am trying to generate a list of length 4n which consists of

Re: [R] ABOUT STATS FORUM

2015-04-20 Thread Boris Steipe
Cross Validated at http://stats.stackexchange.com/ B. On Apr 19, 2015, at 10:37 AM, CHIRIBOGA Xavier wrote: > Dear members, > > > > Since this is not a Forum for Stats questions...does anyone can recomend me a > good forum to post questions about statistics? > > > > Thank you for info

Re: [R] Suggest method

2015-04-22 Thread Boris Steipe
That does not sound like a clustering problem at all since you already know the desired characteristics and are not trying to discover structure in your data. Simply define a score as a suitably weighted sum of individual features, order your passengers by that score, and pick the top few, or an

Re: [R] Suggest method

2015-04-22 Thread Boris Steipe
e the passengers from one level to another > level. But I don't know what method exactly need to follow . > > -Original Message- > From: Boris Steipe [mailto:boris.ste...@utoronto.ca] > Sent: Wednesday, April 22, 2015 9:08 PM > To: Lalitha Kristipati > Cc: R-

Re: [R] LM() and time in R

2015-04-29 Thread Boris Steipe
Have a look at the help page for the function ts() (type ?ts at the R prompt). Other than that, you haven't provided nearly enough information for us to diagnose your issue. Please see here for some hints on how to ask questions productively: http://adv-r.had.co.nz/Reproducibility.html http://

Re: [R] How to solve: error in file(file, "rt") : invalid 'description' argument

2015-04-29 Thread Boris Steipe
If you google for "invalid 'description' argument" it should be pretty clear what's going on - most likely your DirPath_Matrix is not a single item. B. On Apr 28, 2015, at 7:02 PM, catherine peters wrote: > Hi thank you in advance for your assistance. > > I am using the following section o

Re: [R] Need Help!

2015-04-29 Thread Boris Steipe
A: Look at the function seq() e.g. seq(0.01, 1, by=0.005) B: Don't post in HTML. Seriously. Do not. C: You need to invest more time getting the basics down. Google for R introduction. D: Ow. pi is a predefined constant. Your re-defintion loses accuracy. (See C:) Please see here for some hints

Re: [R] Need Help!

2015-05-05 Thread Boris Steipe
For crying out loud Dawood - can you please stop posting screenshots? Do you not know how to copy your output and paste it into the body of a (not HTML formatted!) email? Let us know if you need help with that. B. On May 5, 2015, at 11:05 AM, dawood ahmad wrote: > Dear Daniel, > > Thank yo

Re: [R] does segfault mean (always) a bug?

2015-05-05 Thread Boris Steipe
Wrong. B. On May 5, 2015, at 2:54 PM, lejeczek wrote: > hi eveybody > > I'm trying something simple (Biocunductor packages), so simple I believe it's > example from docs but I get segfault. > I don't suppose incorrect scripting can cause segfault, right? > > regards > > _

Re: [R] Looking up the code for a function

2015-05-06 Thread Boris Steipe
Here's a discussion on stack overflow with more hints ... http://stackoverflow.com/questions/19226816/how-can-i-view-the-source-code-for-a-function ... and a link to an R-News article by Uwe Ligges on the topic http://cran.r-project.org/doc/Rnews/Rnews_2006-4.pdf (p. 43 f) Cheers, Boris On Ma

Re: [R] Grep out columns using a list of strings

2015-05-08 Thread Boris Steipe
How about %in% ? # preparing something that looks like I think your data looks like: ap <- c("aajkss", "dfghjk", "sdfghk", "xxcvvn") af <- matrix(1:10, nrow=2) colnames(af) <- c("aajkss", "b", "c", "dfghjk", "e") # doing what I think you need done: ap[ap %in% colnames(af)] Cheers, B. (PS. a r

Re: [R] get sub elements

2015-05-10 Thread Boris Steipe
I think the "record number" i.e. the indices of the elements were asked for. That would be: which(5 <= allrecords & allrecords <= 9) Cheers, B. On May 10, 2015, at 7:33 AM, Rui Barradas wrote: > Hello, > > You should learn about indexing in R. Read the pdf R-intro.pdf that comes >

  1   2   3   4   >