[R] NAs produced by integer overflow, but only some time ...

2018-05-08 Thread Stefan Th. Gries
eger overflow > m1^2 [1] 3748378176 That is, the multiplication worked with the numbers but not the numeric vectors; the above is literally copied from the console. Why is that happening? Any help would be much appreciated! STG -- Stefan Th. Gries -

Re: [R] NAs produced by integer overflow, but only some time ...

2018-05-09 Thread Stefan Th. Gries
Before responding to Jeff's posting, let me reiterate my question: Why does a function using m1*m1 produce an integer overflow, but m1^2 does not? As for Jeff's 'response': > a) Numeric values may be either integers (signed 32 bit) or double precision > (53 bit mantissa). > b) Double precision c

Re: [R] NAs produced by integer overflow, but only some time ...

2018-05-09 Thread Stefan Th. Gries
> You are right that various arithmetic operators map a pair of integer > arguments to various type: the power and division operators map them to > double precision while the the addition, multiplication, and subtraction > operators map them to integer results (giving NA's if the result cannot f

Re: [R] how to count occurrences of string?

2009-09-21 Thread Stefan Th. Gries
This should do what you want: set.seed(1) # cerating a vector with comments, in which d's will be counted comments<-character(25) for (i in 1:25) { comments[i] <- paste(sample(letters[1:10], 10, replace=T), collapse="") } # creating a vector to cross -tabulate age <-sample(c("old", "young"), 2

Re: [R] break up a string into strings with a fixed length

2009-10-02 Thread Stefan Th. Gries
This should do what you want: x<-"abcdefghijkl" strsplit(x, "(?<=...)", perl=T) HTH, STG -- Stefan Th. Gries --- University of California, Santa Barbara http://www.linguistics.ucsb.edu/faculty/stgries __

[R] Hierarchical multi-level model with lmer: why are the highest-level random adjustments 0?

2013-07-07 Thread Stefan Th. Gries
Hi all I have a hopefully not too stupid question about multi-level / mixed-effects modeling. I was trying to test a strategy from Crawley's 2013 R Book on a data set with the following structure: - dependent variable: CONSTRUCTION (a factor with 2 levels) - independent fixed effect: LENGTH (an i

[R] predict.lrm vs. predict.glm (with newdata)

2010-12-25 Thread Stefan Th. Gries
y.bevor.lrm, pch="b") points(x2, y.nachdem.lrm, pch="n") points(x2, y.weil.lrm, pch="w") plot(x2, y.als.glm, pch="a", xlim=c(-100, 100), ylim=c(0, 1), main="with predict.glm", xlab="Main cl. length - subord. cl. length (in words)", y

Re: [R] predict.lrm vs. predict.glm (with newdata)

2010-12-30 Thread Stefan Th. Gries
weil.lrm, pch="w") plot(x2, y.als.glm, pch="a", xlim=c(-100, 100), ylim=c(0, 1), main="with predict.glm", xlab="Main cl. length - subord. cl. length (in words)", ylab="Predicted probability of 'sc-mc'")

Re: [R] Developing a web crawler

2011-03-03 Thread Stefan Th. Gries
wr/other_5.pdf>) is a web crawler. Best, STG -- Stefan Th. Gries --- University of California, Santa Barbara http://www.linguistics.ucsb.edu/faculty/stgries __ R-help@r-project.org mailing list https:

[R] pvclust crashing R on Ubuntu 10.10

2011-03-04 Thread Stefan Th. Gries
86_64, linux-gnu status major 2 minor 12.2 year 2011 month 02 day 25 svn rev 54585 language R version.string R version 2.12.2 (2011-02-25) ### Paradoxically enough, R for Windows installed on this machine (running with Wine) causes no problems, but on Linux ... Any ideas what that c

Re: [R] lty=NULL crashing R for x11(type="cairo")

2011-03-08 Thread Stefan Th. Gries
Yes, and plotting a pvclust object also works on Windows. STG -- Stefan Th. Gries --- University of California, Santa Barbara http://www.linguistics.ucsb.edu/faculty/stgries --- On Tue, Mar 8, 2011 at 04:06

[R] results of fligner.test

2008-05-28 Thread Stefan Th. Gries
Hi all I have a question regarding the Fligner-Killeen test. I am using - a PC with Windows XP (Build 20600.xpsp080413-2111 (Service Pack 3); - the following R version: > sessionInfo() R version 2.7.0 (2008-04-22) i386-pc-mingw32 I have a vector LENGTH and a factor RELATION that are distributed

[R] Unicode characters (R 2.7.0 on Windows XP SP3 and Hardy Heron)

2008-05-30 Thread Stefan Th. Gries
Hi all Four questions regarding Unicode. Three Windows questions. I am using - a PC with Windows XP (Build 20600.xpsp080413-2111 (Service Pack 3); - the following R version: > R.version platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status

[R] fligner.test

2008-06-20 Thread Stefan Th. Gries
Hi all I have a question regarding the Fligner-Killeen test. I am using - a PC with Windows XP (Build 20600.xpsp080413-2111 (Service Pack 3); - the following R version: > sessionInfo() R version 2.7.0 (2008-04-22) i386-pc-mingw32 I have a vector LENGTH and a factor RELATION that are distributed

Re: [R] text vector clustering

2009-01-23 Thread Stefan Th. Gries
Hans-Joerg Bibiko's function Levenshtein would help; cf. below for an example (very clumsy with two loops, but you can tweak that with apply stuff). HTH, STG levenshtein <- function(string1, string2, case=TRUE, map=NULL) { # levenshtein algorithm in R # #

Re: [R] text vector clustering

2009-01-23 Thread Stefan Th. Gries
On Fri, Jan 23, 2009 at 08:28, Stefan Th. Gries wrote: > Hans-Joerg Bibiko's function Levenshtein would help; cf. below for an > example (very clumsy with two loops, but you can tweak that with apply > stuff). Like this maybe (sorry, should've thought about that earlier): [..

[R] Pairwise intersect comparisons of list elements

2008-11-20 Thread Stefan Th. Gries
Hi all I have two lists that have the same number of numeric vectors such as: q<-list(1, 2:3, 4:6, 7:10) w<-list(0, 1:2, 3:7, 8:10) What I want to do is create a vector desired.result that looks like this but I am thinking there must be some kind of non-loop / "\\wapply" way to so ... desired.re

[R] Regex: workaround for variable length negative lookbehind

2008-11-30 Thread Stefan Th. Gries
Hi all I have the following regular expression problem: I want to find complete elements of a vector that end in a repeated character but where the repetition doesn't make up the whole word. That is, for the vector vec: vec<-c("", "baaa", "bbaa", "bbba", "baamm", "aa") I would like to get "b

[R] Intercept in lm and in library(car): Anova

2007-09-14 Thread Stefan Th. Gries
Hi I have two questions regarding the meaning of intercept outputs of lm. Question 1: In data set 1 (a fully-balanced design), the line with (Intercept) contains the overall mean, and the estimates contain the differences from the overall mean (matching those from model.tables). But in data set 2