[R] strange behavior in base::as.double

2024-05-01 Thread Carl Witthoft
-- or whatever the first digit is. Please let me know if there are additional tests I can try . thanks Carl Witthoft [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch

[R] copying huge strings via clipboard?

2022-03-04 Thread Carl Witthoft
uot;paste" What I found is that, around 5000 characters, a newline ( "\n") char showed up. Is this something that the Windows Clipboard does, or something odd about pasting into a command in R? Postscript: using >> bar <- readChar('thefile.txt',1e6) the import works perfectly

Re: [R] R CMD BUILD converting data file format?

2022-01-28 Thread Carl Witthoft
, Carl Witthoft wrote: When I run the shell command R CMD BUILD mypackage the builder converts *.R files to *.rda data files. This seems to conflict with the information in R-Exts which says a package's /data directory can contain foo.R files which the function data() will call source

[R] R CMD BUILD converting data file format?

2022-01-28 Thread Carl Witthoft
aining the text [1] 'dataA' [2] 'dataB' Where did I go wrong? thanks -- Carl Witthoft c...@witthoft.com __ 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 guid

[R] strange behavior of intToUtf8() and text()

2014-03-06 Thread Carl Witthoft
As posted to Stack Overflow, please try this out: plot(1:10,t='n') text(1,1,c(intToUtf8(c(1,9684))),cex=3) text(2,2,c(intToUtf8(c(9684))),cex=3) text(3,3,c(intToUtf8(c(9679,9684))),cex=3) text(4,4,c(intToUtf8(c(9679))),cex=3) text(5,5,c(intToUtf8(c(9685,9684))),cex=3)

Re: [R] Any R packages support conversion from PDF to XLS ?

2013-12-03 Thread Carl Witthoft
Pretty much nothing can convert arbitrary PDF files to unicode. It depends a lot on what is in the PDF to begin with -- properly encoded text or just bitmapped images, for example. I would recommend you search around to see whether there's a related archive in a different format. And in any

Re: [R] purpose of the set.seed(function)

2013-12-03 Thread Carl Witthoft
Seriously? You should be ashamed of yourself for even considering posting a question like this. Charles Thuo wrote what is the purpose of the subject function Charles [[alternative HTML version deleted]] __ R-help@ mailing list

Re: [R] legend position

2013-12-02 Thread Carl Witthoft
See ?legend . you can add a legend directly to an existing plot. An example: legend('topright',c('hot','cold'),lty=1,col=c('red','green'),bg='white') Now if you're trying to place the legend outside the plot area (i.e. in some other part of the window), you'll need to invoke par(xpd=TRUE) .

Re: [R] legend position

2013-12-02 Thread Carl Witthoft
It occurs to me that perhaps you're referring to the 'color bar' on the right of the plot. AFAIK you cannot get at that from the raster::plot method. However lattice::levelplot does allow you to manipulate or remove that colorbar. -- View this message in context:

Re: [R] How to vectorize plot graphic?

2013-12-01 Thread Carl Witthoft
Off the top of my head, I'd suggest trying ggsave() with the extension .svg . I realize that SVG files are not recognized by some image display apps (Microsoft Windows I'm looking at YOU), but IMHO it's the best choice for vectorized images. Alexander Shenkin wrote Hi Folks, Using

Re: [R] Help with Cast Function

2013-11-29 Thread Carl Witthoft
I see your desired output has rather fewer data than the input data frame. Instead of making us pore over a bunch of numbers, can you explain exactly what filtering you wish to do to get the specific subset of {male/female} {alcohol/caffeine} you're trying to get? BHM wrote Hi, This is

Re: [R] How to draw a shade overlapping of three circles (or other shapes) with certain areas?

2013-11-29 Thread Carl Witthoft
Pardon the pedantry, but doyou know what a Venn Diagram is? Because there are two or three packages at CRAN which will generate Venn diagrams for you given exactly that sort of source data. Yi.Zou wrote Hi all, I am thinking of making a graph with three dataset A,B,C with shared common

Re: [R] convert data frame: two variables into _one_ binary variable

2013-11-25 Thread Carl Witthoft
In R, as.logical() and other functions treat anything 0 as TRUE. Thus: Rgames foo-sample(0:5,10,rep=TRUE) Rgames foo [1] 0 5 1 0 1 5 2 5 4 5 Rgames as.logical(foo) [1] FALSE TRUE TRUE FALSE TRUE TRUE TRUE TRUE TRUE TRUE For your case, simply (womensrole$agreewomensrole$disagree)

Re: [R] Should there be an R-beginners list?

2013-11-25 Thread Carl Witthoft
A couple things: First, Beginners' lists never work. Beginners invariably can't read (cf. posting guidelines), so they will post to the main list anyway. Second, I see some people prefer to receive email-lists of the topics, and others prefer to work via a webbrowser interface. I'd have to say

Re: [R] Question on xyplot

2013-11-21 Thread Carl Witthoft
you didn't show us the code you used to generate the legend. I'm guessing you want to add to the legend list something like lty=0:7 . KB wrote I recently started using R, so I'm not really experienced with it. My question is on adjusting xyplots to get lty lines instead of coloured lines.

Re: [R] Thoughts for faster indexing

2013-11-21 Thread Carl Witthoft
What the Data Munger Guru said. Plus: this is almost certainly a job for ddply or data.table. Noah Silverman-2 wrote Hello, I have a fairly large data.frame. (About 150,000 rows of 100 variables.) There are case IDs, and multiple entries for each ID, with a date stamp. (i.e. records of

Re: [R] Multiple if statement in loop condition

2013-11-20 Thread Carl Witthoft
What this message means is that a { showed up when some other bracket was unpaired. In this case, if you check your code, you'll see that if(MatriceDist[i,j] 0 ((vectorID[i] 0 | vectorID[j] 0)) is lacking a closing ) for the if clause. Phalaen wrote Hi! I am a Phd student in the

Re: [R] equal horizontal and vertical proportions in graphics

2013-11-19 Thread Carl Witthoft
see ?par . Use the argument asp=TRUE. Mercutio Florid wrote I use several different versions of R, including RGui on Windows and rstudio on Linux.  In all cases, I use graphical commands, such as image().  image() displays rectangles, but I want to be able to guarantee that the

Re: [R] Computational differences in R vs Excel

2013-11-19 Thread Carl Witthoft
There are several problems here. The first is that it's rather unlikely you really need 10-place accuracy to fit your data. This suggests you may be doing something inappropriate such as fitting the wrong function or trying to extrapolate. Since you haven't explained what process you have

Re: [R] Sending a matrix in an email

2013-11-18 Thread Carl Witthoft
I think it'd be easier and safer to save the matrix, either as an .Rdata binary or as a text file, zip that file, and use the sendmailR tools to attach the file to your message. Fuchs Ira-3 wrote I have a matrix which has colnames and I would like to send this matrix using sendmailR. How can I

Re: [R] creating upper triangular matrix

2013-11-18 Thread Carl Witthoft
OK, I'm pre-coffee, but what's wrong with using upper.tri to create a new matrix and then multiplying that matrix by the original dat matrix (direct multiplication, not matrix multiply) to get the desired answer? Bert Gunter wrote I believe matrix indexing makes Arun's complex code wholly

Re: [R] Rotation of parallel lines

2013-11-18 Thread Carl Witthoft
See my answer at Stack Overflow -- repeated here for anyone else who wants a trivial function. # coordinate transform: cartesian plane rotation xyrot-function(pairs,ang){ # pairs must be Nx2 matrix w/ x in first column and y in second xrot - pairs[,1]*cos(ang) - pairs[,2]*sin(ang)

Re: [R] volume of ellipsoid

2013-11-14 Thread Carl Witthoft
Well, given that an upvoted question on math.stackexchange got no answers, I'd say you're asking a very difficult question. Perhaps this paper http://www.geometrictools.com/Documentation/IntersectionOfEllipsoids.pdf will be of some help. It's possible that you could do: 1) find the ellipse

Re: [R] polygon circling a graph

2013-11-14 Thread Carl Witthoft
Please post the packages from which 'barabasi' and 'layout.fruch' originate (not to mention whatever the plot() method is for whatever class your 'g' is). Further, without seeing what your data look like we have no way of knowing whether you've fed the appropriate elements of L to chull.

Re: [R] Ant Colony Optimization Algorithm

2013-11-12 Thread Carl Witthoft
We would need to see the contents of the mplus file that is read in. Quite possibly it's overwriting either iter or count with an incompatible data type. I would also recommend contactingWalter Leite directly to verify you have a proper mplus source file. /* partial quote follows */ The

Re: [R] repeating values in an index two by two

2013-11-11 Thread Carl Witthoft
Here's a rather extreme solution: foo-rep(1:6,each=2) Rgames foo [1] 1 1 2 2 3 3 4 4 5 5 6 6 Rgames foo[rep(c(1,3,2,4),3)+rep(c(0,4,8),each=4)] [1] 1 2 1 2 3 4 3 4 5 6 5 6 In the general case, then, it would be something like foo- rep(1:N, each = 2) # foo is of length(2*N)

Re: [R] Date handling in R is hard to understand

2013-11-09 Thread Carl Witthoft
I agree w/ lubridate.I also would like to mention that date handling is amazingly difficult in ALL computer languages, not just R. Take a stroll through sites like thedailywtf.com to see how quickly people get into tarpits full of thorns when trying to deal with leap years, weeks vs month

Re: [R] C50 Node Assignment

2013-11-09 Thread Carl Witthoft
Just to clarify: I'm guessing the OP is referring to the CRAN package C50 here. A quick skim suggests the rules are a list element of a C5.0-class object, so maybe that's where to start? David Winsemius wrote In my role as a moderator I am attempting to bypass the automatic mail filters

Re: [R] Fitting multiple horizontal lines to data

2013-11-07 Thread Carl Witthoft
You already asked this on StackOverflow. The answer remains the same, pretty much what David W. wrote: this is not a question about fitting lines to data. You need to step back and think about what message you want to deliver to those who will view your graph, and what the meaning of your

Re: [R] Same code - error in one PC but not in other

2013-11-07 Thread Carl Witthoft
In the absence of any description of the computers themselves, it's hard to say, but there's a good chance that there is some object in your working environment that's being accessed by your function -- and that object exists on only one of the machines. I would suggest you use debug() or

Re: [R] WriteBin problem

2013-11-06 Thread Carl Witthoft
First of all, use readBin to verify you get the desired data back. Second, that '00' is, I believe the EOF character you'll find at the end of any file. Harutyun Khachatryan wrote Dear R project officials, I have found that in R 3.0.1 version writeBin function of base package might not

Re: [R] speed issue: gsub on large data frame

2013-11-06 Thread Carl Witthoft
If you could, please identify which responder's idea you used, as well as the strsplit -- related code you ended up with. That may help someone who browses the mail archives in the future. Carl SPi wrote I'll answer myself: using strsplit with fixed=true took like 2minutes! -- View this

Re: [R] hidden functions

2013-11-06 Thread Carl Witthoft
Why would you need to? The whole point of :: and ::: is to specify the origin of a function. -- View this message in context: http://r.789695.n4.nabble.com/hidden-functions-tp4679849p4679856.html Sent from the R help mailing list archive at Nabble.com.

Re: [R] speed issue: gsub on large data frame

2013-11-05 Thread Carl Witthoft
My feeling is that the **result** you want is far more easily achievable via a substitution table or a hash table. Someone better versed in those areas may want to chime in. I'm thinking more or less of splitting your character strings into vectors (separate elements at whitespace) and chunking

Re: [R] Function does not see variables outside the function

2013-11-05 Thread Carl Witthoft
Why would you want to impose this restriction? Perhaps if you explain what you are trying to do, we can suggest approaches that will satisfy your specific needs. (note- one can always redefine whatever variables are to be excluded. E.g. to keep the body of a function from referring to 'foo' in

Re: [R] A warning message generated from 'read.csv'

2013-11-04 Thread Carl Witthoft
Pretty much exactly what it says. Now, keep in mind that a warning message does not indicate a failure or error. Presumably you successfully read your file into filedata. What it's saying is that the EOL character exists inside some character string in one of the elements of your file.

Re: [R] Beginner having issues with making pie charts and other graphs

2013-10-31 Thread Carl Witthoft
Rule Number One: Don't use pie charts. Rule Number Two: NEVER EVER USE PIE CHARTS! To learn how to create graphs in R, start with ?plot , ?points, ?lines. Later on you can investigate ?lattice, ?grid, and ?ggplot2 . The fact that you're looking 'online' instead of in R's builtin help

Re: [R] Read ENVI files and extract stats in R

2013-10-31 Thread Carl Witthoft
That is not an ENVI file. That's an image file... or something. If you can post a small, reproducible sample of the data array containing the dates you wish to manipulate, we may be able to help. -- View this message in context:

Re: [R] Fitting multiple horizontal lines to data

2013-10-30 Thread Carl Witthoft
Your question doesn't make much sense if you really believe that the best fit is to draw a horizontal line at every unique value of y. What is the actual problem you are trying to solve? Clearly it's not a matter of linear fits, so forget about using lm or other regression tools. -- View

Re: [R] big speed difference in source btw. R 2.15.2 and R 3.0.2 ?

2013-10-30 Thread Carl Witthoft
Did you run the identical code on the identical machine, and did you verify there were no other tasks running which might have limited the RAM available to R? And equally important, did you run these tests in the reverse order (in case R was storing large objects from the first run, thus chewing

Re: [R] Can not read Excel file correctly

2013-10-30 Thread Carl Witthoft
Dunno how to break this to you, but R reads exactly what is in that file, with the data in exactly the proper row/column locations. -- View this message in context: http://r.789695.n4.nabble.com/Can-not-read-Excel-file-correctly-tp4679306p4679350.html Sent from the R help mailing list

Re: [R] Optimization failed in fitdistr (Weibull distribution)

2013-10-30 Thread Carl Witthoft
Which suggests the OP should verify that the data in ...$Frequency is the data he expects to be there. Rui Barradas wrote Hello, I can't reproduce your error: windfreq - c(1351L, 2147L, 3317L, 4378L, 5527L, 6667L, 7865L, 8970L, 9987L, 10907L, 11905L, 12642L, 131000L, 14983L, 15847L,

Re: [R] omitting integer(0) rows from data frame

2013-10-30 Thread Carl Witthoft
Both PBurns and DWin are correct. I just thought I'd add a clunky safety check approach I use now and then: Before doing the actual subset, i.e. df[-which(something),] , do something like if (length(which(something)) 1 ) {skip the subsetting} else df[-which(something)] -- View this

Re: [R] Error in scan?

2013-10-24 Thread Carl Witthoft
Obviously row 11 is incomplete. It may contain nothing more than a space or an EOL. Using the fill=TRUE argument to 'scan' or 'read.table' is your friend here. -- View this message in context: http://r.789695.n4.nabble.com/Error-in-scan-tp4678976p4678982.html Sent from the R help mailing

Re: [R] Hey guys I have one slight problem with my code

2013-10-23 Thread Carl Witthoft
What's the range of data you are trying to plot? The error message is pretty clear: you've selected a set of breaks which don't span the data range. Maybe try breaks = c(min(x),seq(4,30,2),max(x)) -- View this message in context:

Re: [R] raster package: merge/mosaic

2013-10-23 Thread Carl Witthoft
According to ?merge, you could try adjusting the default value of the tolerance argument. Nora Ernst wrote I'm working with raster data (satellite imagery) and the raster package. The idea is to merge two raster files that are partially overlaping, do have the same coordinate system

Re: [R] May I send a zip attachment to a post?

2013-10-22 Thread Carl Witthoft
Barry Rowlingson wrote On Mon, Oct 21, 2013 at 10:51 PM, David Winsemius lt; dwinsemius@ gt; wrote: On Oct 21, 2013, at 2:15 PM, Hurr wrote: May I send a .zip file attached to a post? No. That's not explicit from the posting guide: No binary attachments except for PS, PDF, and

Re: [R] More Columns than column names Error

2013-10-22 Thread Carl Witthoft
What is the exact code you are using to try to load this file? I strongly suspect the problem is a mixture of spaces and multiple tabs in your text file. -- View this message in context: http://r.789695.n4.nabble.com/More-Columns-than-column-names-Error-tp4678770p4678787.html Sent from the R

Re: [R] merging matrices

2013-10-21 Thread Carl Witthoft
If you have over a thousand files on your desktop, you have bigger problems than just how to load them into R. Where do these files come from, and why do you want to merge them into a single entity? -- View this message in context:

Re: [R] help creating a simple function to rename columns

2013-10-21 Thread Carl Witthoft
Steve E. wrote Hi R users, I am having some trouble with a very simple function that I hope that you might be able to help me with (and, really, to shed some light on how functions work generally). I have a series of very small 2-column data frames of which I need to change the column

Re: [R] Combining two models into one

2013-10-20 Thread Carl Witthoft
You created a bunch of 'x' items but call for X in your formula. That's part of it. Next, you don't provide a data=x argument in your lm() call, so it goes off and looks for various capital-X items (I suspect). Hint: start with a small, simple dataset and work with it until you know how to

Re: [R] How would i sum the number of NA's in multiple vectors

2013-10-17 Thread Carl Witthoft
mattbju2013 wrote Hi guys this is my first post, i need help summing the number of NA's in a few vectors for example.. c1-c(1,2,NA,3,4) c2-c(NA,1,2,3,4) c3-c(NA,1,2,3,4) how would i get a result that only sums the number of NA's in the vector? the.result.i.want-c(2,0,1,0,0) See

Re: [R] Help with combining functions

2013-10-17 Thread Carl Witthoft
This is the world-famous fizzbuzz problem. You should be able to find lots of implementations by Googling that word. Here's a pointless collection I wrote once: # a really dumb fizzbuzz alg competition #fbfun1 is 2.5x faster than fbfun2 # fbfun3 is 10x faster than fbfun1 # fbfun1 is 2x faster

Re: [R] Convert a factor to a numeric

2013-10-10 Thread Carl Witthoft
foo - as.numeric(as.character(your_factors) ). It's a common mistake to forget the first conversion, in which case you end up with an integer sequence rather than the desired values. -- View this message in context:

Re: [R] optimizing code

2013-10-10 Thread Carl Witthoft
FMRPROG wrote I am generating random numbers from a normal distribution using [snip] I need to optimize the speed WITHOUT using the rnorm function but have no idea how to do this. I assume I should minimise what goes in the loop? Any help would be very much appreciated. Looks like

Re: [R] vector where elements are functions evaluated at integers, but length of vector varies

2013-10-10 Thread Carl Witthoft
Hi, I have two integers a and b (with ab), as well as a function f(x). Is there a way of getting the vector (f(a), ..., f(b)) from R without having to explicitly write it out? as my a and b vary. Thanks for your help lt;/quote What did you try?Further, without knowing what your function

Re: [R] makeCluster help needed

2013-10-10 Thread Carl Witthoft
Jeffrey Flint wrote Good news. I installed 3.0.2, and the parallel package examples ran successfully. This time a firewall window popped up. Probably the firewall was the problem with the snow package too, but for some reason the window didn't pop up with the snow package. Thanks for the

Re: [R] parallels package -can't create cluster

2013-10-09 Thread Carl Witthoft
Never mind -- after getting detailed help at SO, I rebooted Windows and makeCluster() worked just fine. I have no idea what cruft in my system was getting in the way, but all's well. -- View this message in context:

[R] parallels package -can't create cluster

2013-10-08 Thread Carl Witthoft
I am trying to use the parallel package, and found that makeCluster hangs (and no apparent actions have taken place). This is Windows7-64, Enterprise, R 3.0.1 . I've traced the hang to the following line in newPSOCKnode : con - socketConnection(localhost, port = port, server = TRUE,

[R] RE how to cut files from any folder to another folder?

2012-04-22 Thread Carl Witthoft
?file.copy Or ?system From: sagarnikam123 sagarnikam123_at_gmail.com Date: Sun, 22 Apr 2012 01:25:21 -0700 (PDT) i want to cut file from e.g. abc folder put it into another location with folder name e.g. xyz how should i proceed? -- Sent from my Cray XK6 Quidvis recte factum, quamvis

Re: [R] filling the matrix row by row in the order from lower to larger elements

2012-04-06 Thread Carl Witthoft
I think the OP wants to fill values in an arbitrarily large matrix. Now, first of all, I'd like to know what his real problem is, since this seems like a very tedious and unproductive matrix to produce. But in the meantime, since he also left out important information, let's assume the input

[R] RE filling the matrix row by row in the order from lower to larger elements

2012-04-06 Thread Carl Witthoft
Apologies -- I meant to translate that code (which is what the OP provided, albeit in longer form) into a *apply one-liner. -- Sent from my Cray XK6 Quidvis recte factum, quamvis humile, praeclarum. __ R-help@r-project.org mailing list

Re: [R] filling the matrix row by row in the order from lower to larger elements

2012-04-06 Thread Carl Witthoft
Ok, how's this: Rgames foo [,1] [,2] [,3] [,4] [1,]361 16 [2,] 10 14 125 [3,] 117 159 [4,]84 132 Rgames sapply(1:4,FUN=function(k){ foo[k,which(foo==k,arr.ind=T)[2]]-100;return(foo)})-bar Rgames bar [,1] [,2] [,3] [,4] [1,]3

Re: [R] Looking for the name of a certain kind of quantile plot

2012-04-04 Thread Carl Witthoft
Thanks, Chuck. That looks about right. And I would have provided repro code, but I was forced to write it in Matlab on account of corporate rules, and haven't translated to R yet. Carl Witthoft carl at witthoft.com writes: Hi, While playing with quantile-quantile plots, I wrote up some

[R] Looking for the name of a certain kind of quantile plot

2012-04-03 Thread Carl Witthoft
Hi, While playing with quantile-quantile plots, I wrote up some code which plots something strangely different. Here's the pseudocode: testhist - hist(sample_data) refhist - hist(rnorm(n, mean=0,sd=1)) # for some large-ish n cumtest - cumsum(testhist) cumref - cumsum(refhist)

Re: [R] Detect numerical series

2012-02-11 Thread Carl Witthoft
This was actually answered a couple times in StackOverflow. Someone and I indpendently wrote up the following function, stolen directly from the source for rle(). # extended version of rle to find all sorts of sequences # if incr=0, this is rle seqle- function (x,incr=1) { if

Re: [R] an unusual use for R

2012-02-02 Thread Carl Witthoft
Well, I have to say, how nice to find a valid use for string theory :-) . Now that we all know you are in fact the mistress of skulls, guess we better tread lightly! Carl quote From: Sarah Goslee sarah.goslee_at_gmail.com Date: Thu, 02 Feb 2012 17:54:04 -0500 I thought some of you might

Re: [R] Venn Diagram help!!!!

2012-01-31 Thread Carl Witthoft
There are two packages which may be useful: venneuler and VennDiagram. One of them allows up to four sets; the other is pretty much unlimited. I forget which is which :-( . Oops: there's another, evenn. I haven't used that one. -- Sent from my Cray XK6 Pendeo-navem mei anguillae plena

Re: [R] Finding suspicious data points?

2012-01-26 Thread Carl Witthoft
According to the help file for 'outlier' , (quoting) x a data sample, vector in most cases. If argument is a dataframe, then outlier is calculated for each column by sapply. The same behavior is applied by apply when the matrix is given. (endquote) Looks like you could create a matrix that

[R] Code for a plot of a DNA double helix?

2012-01-25 Thread Carl Witthoft
Did you look thru http://addictedtor.free.fr/graphiques/ ? There's a lot of stuff there. sos plot DNA suggests maybe packages ape, forensim , genoPlotR . I have never used those so can't comment further. -- Sent from my Cray XK6 Pendeo-navem mei anguillae plena est.

Re: [R] Solving Equations

2012-01-24 Thread Carl Witthoft
Like the t-shirt says, There's no place like 127.0.0.1 quote Though I wasn't familiar with this I check the repositories list and CRAN (extras) is selected in my installation (R-2.14.1). By the way, when trying Ryacas after what seemed to be a successful install, for a simple example of

Re: [R] Solving Equations

2012-01-24 Thread Carl Witthoft
It was supposed to be a joke :-( On 1/24/12 4:15 PM, Gabor Grothendieck wrote: On Tue, Jan 24, 2012 at 4:07 PM, Carl Witthoftc...@witthoft.com wrote: Like the t-shirt says, There's no place like 127.0.0.1 quote Though I wasn't familiar with this I check the repositories list and CRAN

Re: [R] runif with condition

2012-01-10 Thread Carl Witthoft
AlanM said, Consider the pair {X, 1-X} where X is sampled from a uniform(0,1) distribution. The quantity 1- X also comes from a uniform(0,1) distribution and therefore is probabilistic and not deterministic. The sum of independent random variables is itself a random variable. If X1, X2 X3

Re: [R] R package equivalent to Excel SOLVER - Paquete R equivalente a SOLVER de Excel

2012-01-09 Thread Carl Witthoft
Or package(BB) , depending on exactly what you want to do. quote From: David Winsemius dwinsemius_at_comcast.net Date: Sun, 08 Jan 2012 16:54:28 -0500 On Jan 8, 2012, at 4:51 PM, Ricardo Bandin wrote: Esteemed colleagues I wonder if there is a package in R that performs the functions of the

Re: [R] runif with condition

2012-01-09 Thread Carl Witthoft
This question *screams* for the standard response: What is the problem you are trying to solve? I can think of two related problems off the top of my head. 1) Write a function which generates the four bridge hands from a well-shuffled deck. 2) Throw 100 pennies into a big shaker with four

Re: [R] Putting an index explicitly into function code --- a curiosity.

2012-01-07 Thread Carl Witthoft
Now that we've all satisfied our curiosity :-) about force() in for and while loops, I suppose it would be impolite to ask Rolf whether there isn't a much neater and simpler way to make his internal functions grab whatever the index 'i' is pointing them to? -- Sent from my Cray XK6

[R] venneuler plots may be inaccurate

2012-01-06 Thread Carl Witthoft
Hi, I just started playing w/ venneuler, and have a question about the last method listed for creating inputs. This is the method where the source is a matrix X, for which each column represents a set, and the co-occurrence is defined by the rows. So, for example: Rgames foo [,1]

Re: [R] fractal image analysis

2011-12-20 Thread Carl Witthoft
Let me put my vote in for imageJ as well. It's designed to do (gosh) image analysis stuff, whereas R is not. Of course you can write whatever algorithms you like in R :-), but for specialized work it's often better to use a specialized tool. quote From: Andrés Aragón armandres_at_gmail.com

Re: [R] axis tick colors: only one value allowed?

2011-12-14 Thread Carl Witthoft
That only puts different colors on different axes. I was wondering about the (silly) possibility of having a range of colors for the ticks on a given axis. quote From: Hans W Borchers hwborchers_at_googlemail.com Date: Tue, 13 Dec 2011 14:21:31 + Carl Witthoft carl at witthoft.com writes

[R] axis tick colors: only one value allowed?

2011-12-12 Thread Carl Witthoft
Hi, So far as I can tell, the 'col.ticks' parameter for axis() only uses the first value provided. E.g.: plot(0:1,0:1, col.ticks=c('blue','red','green')) #all ticks are blue Just wondering if there's a different option in the basic plot commands that can handle multiple colors, and also

Re: [R] Polygon

2011-12-12 Thread Carl Witthoft
Please read the posting guide and provide a (small) reproducible example of your data. The statement ...output does not seem good. is not very useful. Please explain what you would like the polygon area to look like, and why you don't like the way it came out. Links to posted images of the

Re: [R] Why can't I figure this out? :S

2011-12-05 Thread Carl Witthoft
If you 'don't speak computer,' what are you doing trying to run R in the first place? Your email address suggests this is homework, but even if it isn't please go talk to your professor or teaching assistant. quote From: Jasmine007 magee20v_at_uregina.ca Date: Mon, 05 Dec 2011 16:32:00 -0800

[R] strange row numbering after rbind-ing a list

2011-12-01 Thread Carl Witthoft
Not that it really matters, but Can someone explain how the row numbers get assigned in the following sequence? It looks like something funky happens when rbind() coerces 'bar' into a dataframe. In either sequence of rbind below, once you get past the first two rows, the row numbers count

Re: [R] strange row numbering after rbind-ing a list

2011-12-01 Thread Carl Witthoft
Sorry -- I meant to write 'row names,' but the question specifically is where those unlikely numbers come from. So I guess it comes down to why, when 'bar' is the first item, the row name is assigned '2' rather than '1' . On 12/1/11 6:26 PM, Sarah Goslee wrote: Those are row *names*, not

Re: [R] what is wrong with this dataset?

2011-11-23 Thread Carl Witthoft
As the Kroger Data Munger Guru would say, What is the problem you are trying to solve? The datasets look just fine from a structural point of view. What do you want to do and what is wrong with the results you get? quote From: Kaiyin Zhong kindlychung_at_gmail.com Date: Thu, 24 Nov 2011

Re: [R] place values into a matrix efficiently?

2011-11-20 Thread Carl Witthoft
Excellent. That's what I was looking for. Thanks, Rolf. Carl On 11/19/11 11:16 PM, Rolf Turner wrote: On 20/11/11 16:27, Carl Witthoft wrote: This question attacked me as I was thinking about matrix value updates. I probably will never need to do this, but wanted to ask

Re: [R] tip: large plots

2011-11-19 Thread Carl Witthoft
Another few data points, just for the heck of it. This is on a 2.66GHz Intel Core Duo iMac. Rgames system.time(plot(runif(1e6),runif(1e6))) user system elapsed 34.405 0.079 34.432 Rgames system.time(plot(runif(1e6),runif(1e6),pch='.')) user system elapsed 12.602 0.032 12.596

[R] place values into a matrix efficiently?

2011-11-19 Thread Carl Witthoft
This question attacked me as I was thinking about matrix value updates. I probably will never need to do this, but wanted to ask if there are efficient methods to perform the for-loop in the following sequence. %xymat-matrix(rep(0,100) nr=10,nc=10) # empty matrix %x-1:10

Re: [R] Deleting rows dataframe in R conditional to “if any of (a specific variable) is equal to”

2011-11-06 Thread Carl Witthoft
Not too difficult. Rgames bar-c(3,5,7) Rgames foo-c(1,3,5,6,8,9,7) Rgames match(bar,foo) [1] 2 3 7 # these are the matching positions Rgames foo[-(match(bar,foo))] [1] 1 6 8 9 quote Dear list, I have been struggling for some time now with this code... I have this vector of unique ID EID

Re: [R] nested for loops

2011-11-05 Thread Carl Witthoft
If in fact this is homework, you will do yourself, your classmates, and possibly your teacher if you let them know that, at least in R, almost anything you can do in a for() loop can be done easier and faster with vectorization. If you teacher can't comprehend this, get him fired. a-c(4,6,3)

Re: [R] How much data can R process?

2011-11-03 Thread Carl Witthoft
My answer is similar: how much data? All of it. And shame on the OP for ever using Excel. From: Rolf Turner rolf.turner_at_xtra.co.nz Date: Thu, 03 Nov 2011 22:20:17 +1300 On 03/11/11 15:59, Nicholay Anne Caumeran wrote: Would like to know how much data can R process - number of rows and

Re: [R] Is it possible to vectorize/accelerate this?

2011-11-03 Thread Carl Witthoft
I have to admit to not doing careful timing tests, but I often eliminate if() lines as follows (bad/good is just my preference) BAD: b[i] - if(a[i]1) a[i] else a[i-1] GOOD: b[i] - a[i]* (a[i]1) + a[i-1] * (a[i]=1) On Thu, Nov 3, 2011 at 12:10 PM, hihi v.p.mail_at_freemail.hu wrote: Dear

Re: [R] palettes for the color-blind

2011-11-02 Thread Carl Witthoft
Before you pick out a palette: you are aware that their are several different types of color-blindness, aren't you? http://en.wikipedia.org/wiki/Color_blind -- Sent from my Cray XK6 Pendeo-navem mei anguillae plena est. __ R-help@r-project.org

Re: [R] plotting with a symbol on every nth point

2011-10-23 Thread Carl Witthoft
If you just want the same symbol at each point, you could use Weylandt's approach, tho' personally I think it's tidier to create a new vector x10 - x[seq(1,length(x),by=10)] and plot that. If you would like a different symbol at each point, then take a look at ?text. quote From: R.

Re: [R] Exponential fit of form y=exp(a*x) and not of form y=l*exp(a*x)

2011-10-23 Thread Carl Witthoft
You misused nls(). Observe: x- 1:101 y2 - 5*exp(x/20) + runif(101)/100 # nls will NOT converge for perfect data. nls(y2 ~ exp(A*x), start=list(A=.1)) Nonlinear regression model model: y2 ~ exp(A * x) data: parent.frame() A 0.06709 residual sum-of-squares: 136703 Number of

Re: [R] how to plot two surfaces with lattice::wireframe

2011-10-15 Thread Carl Witthoft
Thank you! That bit about Re(z) + Im(z) was what I missed. Carl On 10/15/11 12:00 PM, Deepayan Sarkar wrote: On Fri, Oct 14, 2011 at 3:07 AM, Carl Witthoftc...@witthoft.com wrote: Hi all, I'd like to plot the Real and Imaginary parts of some f(z) as two different surfaces in wireframe (the

Re: [R] how to plot two surfaces with lattice::wireframe

2011-10-14 Thread Carl Witthoft
,y)sin(x*y))) cheers. Am 13.10.2011 23:37, schrieb Carl Witthoft: Hi all, I'd like to plot the Real and Imaginary parts of some f(z) as two different surfaces in wireframe (the row/column axes are the real and imag axes). I know I can do it by, roughly speaking, something like plotz

Re: [R] Counting the number of integers at one swoop

2011-10-14 Thread Carl Witthoft
You guys are working too hard. Rgames y - c(0,1,1,3,3,3,5,5,6) Rgames rle(sort(y)) Run Length Encoding lengths: int [1:5] 1 2 3 2 1 values : num [1:5] 0 1 3 5 6 -- - Sent from my Cray XK6 __ R-help@r-project.org mailing list

[R] how to plot two surfaces with lattice::wireframe

2011-10-13 Thread Carl Witthoft
Hi all, I'd like to plot the Real and Imaginary parts of some f(z) as two different surfaces in wireframe (the row/column axes are the real and imag axes). I know I can do it by, roughly speaking, something like plotz - expand.grid(x={range of Re(z)}, y={range of Im(z), groups=1:2)

Re: [R] round() and negative digits

2011-10-08 Thread Carl Witthoft
On 10/8/11 6:11 PM, (Ted Harding) wrote: Carl Witthoft's serendipitous discovery is a nice example of how secrets can be guessed by wondering what if ... ?. So probably you don;t need to tell the secrets. Taking the negative digits to their logical extreme: round(654.321,2) # [1]

  1   2   3   >