Re: [R] ordered and unordered variables

2013-05-23 Thread Greg Snow
Meng, This really comes down to what question you are trying to answer. Before worrying about details of default contrasts and issues like that you first need to work out what is really the question of interest. The main difference between declaring a variable ordered or not is the default

Re: [R] convert a character string to a name

2013-05-23 Thread Greg Snow
Here are a couple of approaches: dftest-data.frame(x=1:12, y=(1:12)%%4, z=(1:12)%%2) x_test=c(x,y) aggregate( dftest[,x_test], dftest['z'], FUN=mean ) z x y 1 0 7 1 2 1 6 2 ### Or tmp.f - as.formula( paste( 'cbind(', + paste( x_test, collapse=',' ), + ') ~ z' ) ) aggregate( tmp.f,

Re: [R] scatter plot matrix with different x-y variables

2013-05-11 Thread Greg Snow
The pairs2 function in the TeachingDemos package does what you describe. You give it 2 matricies instead of just one and it creates the plots. On Wed, May 8, 2013 at 10:49 AM, Adel adelda...@gmail.com wrote: Dear list-members, I wonder if there is a way of creating a scatter plot table/grid

Re: [R] Factor deletion criteria

2013-05-04 Thread Greg Snow
In addition to David's great answer also read ?contr.SAS ?contr.treatment ?relevel and also sections 4 and 11.1.1 in An Introduction to R. On Fri, May 3, 2013 at 9:47 PM, David Winsemius dwinsem...@comcast.netwrote: On May 3, 2013, at 3:32 PM, Iuri Gavronski wrote: Hi, I would like to

Re: [R] significantly different from one (not zero) using lm

2013-05-04 Thread Greg Snow
The offset(x) term means to include x (or whatever is in the parentheses) into the model as is, without computing a slope for that term. You could also include offset( 1 * x ) instead which might make this a bit more explicit (but would not actually make any difference). Since x by itself is

Re: [R] How to call an object given a string?

2013-05-02 Thread Greg Snow
This is FAQ 7.21 The most important part of that answer is the last few lines where it says in effect Don't Do This and shows the basics of using a list instead. On Mon, Apr 29, 2013 at 5:07 AM, Rui Esteves ruimax...@gmail.com wrote: Hello, This is very basic and very frustrating. Suppose

Re: [R] how to import several files every day

2013-04-22 Thread Greg Snow
Jim Lemon showed one option of keeping a list of the files that have already been processed and comparing to this list to see which files are new. Here are a couple of other possibilities: You could move a file from the input folder to an archive folder after processing it (file.rename or system

Re: [R] extracting the diagonal of an inverse matrix

2013-04-19 Thread Greg Snow
This link http://math.stackexchange.com/questions/18488/diagonal-of-an-inverse-of-a-sparse-matrix might help. It is about sparse matrices, but the general idea should be able to be extended to non-sparse matrices as well. On Fri, Apr 19, 2013 at 8:13 AM, Camarda, Carlo Giovanni

Re: [R] Remove data 3 standard deviatons from the mean using R?

2013-04-10 Thread Greg Snow
To further David's comment, just think what the world would be like if Alexander Fleming had discarded an obvious outlier in 1928 ( http://en.wikipedia.org/wiki/Penicillin#Discovery). On Tue, Apr 9, 2013 at 7:46 AM, David Winsemius dwinsem...@comcast.netwrote: On Apr 9, 2013, at 4:12 AM,

Re: [R] plot

2013-04-02 Thread Greg Snow
On Mon, Apr 1, 2013 at 10:26 AM, R. Michael Weylandt michael.weyla...@gmail.com wrote: Yes -- in fact that's the way you're supposed to do it and the RStudio way you mentioned above is a shortcut. And the longest distance between any 2 points is a shortcut. -- Gregory (Greg) L. Snow Ph.D.

Re: [R] pairs(X,Y) analog of cor(X,Y)?

2013-03-29 Thread Greg Snow
There is the pairs2 function in the TeachingDemos package that works like cor(x,y) where you give it 2 matricies/data frames and it gives the pairwise plots between the 2 groups. There is currently not a formula interface. On Fri, Mar 29, 2013 at 12:16 PM, Michael Friendly

Re: [R] animated charts

2013-03-28 Thread Greg Snow
The tkexamp function in the TeachingDemos package has an animation control that you can use. The animation package will create video files of animated graphs. On Wed, Mar 27, 2013 at 7:20 AM, catalin roibu catalinro...@gmail.comwrote: Hello all! I want to create animated chart of

Re: [R] How to change background and text colors in script window?

2013-03-26 Thread Greg Snow
You do exactly the same thing, just in the box in the lower left corner (just above the Apply button) you need to scroll down and select editorbg for the background and editortext for the text color. On Fri, Mar 22, 2013 at 8:14 PM, Pfeiffer, Steven (pfeiffss) pfeif...@mail.uc.edu wrote:

Re: [R] Counting confidence intervals

2013-03-20 Thread Greg Snow
The TeachingDemos package has %% and %=% functions that can be chained simply, so you could do something like: sum( 5:1 %=% 1:5 %=% 10:14 ) and other similar approaches. The idea is that you can do comparisons as: lower %% x %% upper instead of lower x x upper On Mon, Mar 18, 2013 at

Re: [R] how to plot u-v wind by R?

2013-03-18 Thread Greg Snow
The my.symbols and ms.arrows functions in the TeachingDemos package may help. On Mon, Mar 18, 2013 at 3:50 AM, Jie Tang totang...@gmail.com wrote: hi R users: I have a dataset including u wind in x-axis and v wind in y-axis. How can I plot the u,v wind data in vector or barb figure?

Re: [R] Equivalent of deal in R?

2013-03-14 Thread Greg Snow
I think that the better approach in R, if you really need to do this, is to convert your array to a list, assign the names to the list, then attach the list to the search path so you can access the variables by name. For example: x - c(1,2,3) x2 - as.list(x) names(x2) - c('a','b','c')

Re: [R] Export R generated tables and figures to MS Word

2013-03-13 Thread Greg Snow
I don't see any mention of odfWeave yet. It works with OpenOffice files. OpenOffice is a free equivalent to MS Office and can read and write Word documents. So you can create your template file in OpenOffice (or use MS word and convert to OpenOffice format, OO will read word docs, and recent

Re: [R] how to convert a data.frame to tree structure object such as dendrogram

2013-03-12 Thread Greg Snow
You can use the lapply or rapply functions on the resulting list to break each piece into a list itself, then apply the lapply or rapply function to those resulting lists, ... On Mon, Mar 11, 2013 at 3:41 PM, Not To Miss not.to.m...@gmail.com wrote: Thanks. That's just an simple example - what

Re: [R] loading data frames and rbind them

2013-03-12 Thread Greg Snow
The only real improveent I can see over Ivan's solution is to use lapply instead of the loop (this may just be person preference though). Something like: list_df - lapply( lista_rea_c, function(x) read.xls( file= paste0(path,x,/,x,.xls),1,header=TRUE,as.data.frame=TRUE)) my_df - do.call(rbind,

Re: [R] funtion equivalent of jitter to move figures on device

2013-03-12 Thread Greg Snow
In addition to the other suggestions that you have received you may want to look at the spread.labs function in the TeachingDemos package and the spread.labels function in the plotrix package. These only spread in 1 dimension, but may be able to do what you want. The thigmaphobe.labels function

Re: [R] 2D filled.contour plot with 1D histograms by axes

2013-03-09 Thread Greg Snow
Instead of read the manual, how about read the answers that you have already received. Or tell us why those answers are not good enough. Or you can read the manual on the .filled.contour function (which is on the same page as filled.contour). On Fri, Mar 8, 2013 at 10:05 AM, Jing Lu

[R] R short course, BYU Summer Institute of Applied Statistics

2013-03-05 Thread Greg Snow
For anyone looking for an intermediate to advanced level short course on R this summer, I will be presenting at the BYU Summer Institute of Applied Statistics June 19-21, 2013. The official page is here: http://statistics.byu.edu/r-beyond-basics-38th-annual-summer-institute-applied-statistics

Re: [R] How to start console output with a comment sign (as in knitr)

2013-03-02 Thread Greg Snow
Try the following to see if it does what you want: ## init con - textConnection(output, w) options(echo=FALSE) sink(con) addTaskCallback( function(expr, out, err, vis) { sink() close(con) if(vis) { cat(paste(#, output, collapse=\n), \n) } con - textConnection(output, w) sink(con) TRUE }) 3+4

Re: [R] help me out

2013-03-01 Thread Greg Snow
If you want to receive all the e-mails, but don't want your e-mail program to pop up a message every time an e-mail from r-help comes in then you can configure your e-mail client to automatically move all the e-mails from r-help to a specific folder/label/etc. and that should make it so you can

Re: [R] query labels in iplot() (or other interactive scatterplot)

2013-02-28 Thread Greg Snow
The HWidentify and HTKidentify functions in the TeachingDemos package let you specify a label for each point, then that label is displayed when you hover over that point with the mouse (and it goes away when you move the mouse away from that point). On Thu, Feb 28, 2013 at 8:36 AM, Agustin Lobo

Re: [R] legend issues.

2013-02-26 Thread Greg Snow
Nicole, Since you seem more interested in accusing David of being rude than recognizing your own rudeness and taking steps to overcome that and increase your chance of getting useful responses I will quote a few lines from the posting guide for you (the entire posting guide is available from the

Re: [R] Adding markers and text for some data points after drawing a plot

2013-02-26 Thread Greg Snow
What have you tried so far? The points function will add points to an existing graph (base) and the text function will add text to an existing graph. If those don't do what you need then give us some more details. On Tue, Feb 26, 2013 at 2:04 PM, Debs Majumdar debs_st...@yahoo.com wrote: Hi

Re: [R] understanding cex (R plots)

2013-02-26 Thread Greg Snow
Have you queried the value of 'cex' and related parameters at the different time points? The help page for par says that when you set mfcol or mfrow that cex is changed, but I don't know if the layout function also changes those or not. I would start by peppering your code with calls to

Re: [R] compute p/t value from pearson r and n

2013-02-25 Thread Greg Snow
Or if David's answer seems like too much work you could use the `mvrnorm` function in the MASS package to generate 2 vectors with the given correlation and sample size and feed those vectors to the `cor.test` function. Or Pearson's test can be computed in 1 line of R code without needing any

Re: [R] Help with layout

2013-02-23 Thread Greg Snow
Part of the space between the boxplots is the margin area, you can remove that. You can also adjust the width of the box within the plot: layout(matrix(c(1,2,3), 3, 1, byrow = TRUE), heights=c(0.3,0.3,0.6)) op - par(mar=c(0,4,0,2)+0.1) boxplot(rnorm(100), horizontal=TRUE, axes=FALSE, width=1)

Re: [R] package ReadImages

2013-02-22 Thread Greg Snow
will give it a try. ** ** Petr ** ** *From:* Greg Snow [mailto:538...@gmail.com] *Sent:* Friday, February 22, 2013 6:45 AM *To:* PIKAL Petr *Cc:* r-help *Subject:* Re: [R] package ReadImages ** ** Some possibilities: The EBImage package on Bioconductor; the jpeg and png

Re: [R] Why R simulation gives same random results?

2013-02-21 Thread Greg Snow
, 2013 at 6:13 PM, Greg Snow 538...@gmail.com wrote: To know for sure we need to know how you are running these different R sessions, but here are some possibilities: The help page for set.seed says that if no seed exists then the seed is set based on the current time (and since 2.14.0

Re: [R] package ReadImages

2013-02-21 Thread Greg Snow
Some possibilities: The EBImage package on Bioconductor; the jpeg and png packages read jpeg and png images. On Thu, Feb 21, 2013 at 8:26 AM, PIKAL Petr petr.pi...@precheza.cz wrote: Dear all I prepared some image processing routine which depended on package ReadImages. Basically I

Re: [R] Why R simulation gives same random results?

2013-02-20 Thread Greg Snow
To know for sure we need to know how you are running these different R sessions, but here are some possibilities: The help page for set.seed says that if no seed exists then the seed is set based on the current time (and since 2.14.0 the process ID). So one possibility is that 2 of the sessions

Re: [R] R nls results different from those of Excel ??

2013-02-18 Thread Greg Snow
Have you plotted the data and the lines to see how they compare? (see fortune(193)). Is there error around the line in the data? The nls function is known to not work well when there is no error around the line. Also check and make sure that the 2 methods are fitting the same model. You

Re: [R] Need Help Plotting Line for multiple linear regression

2013-02-14 Thread Greg Snow
The abline function works fine for simple linear regression because there is only 1 line, but with multiple linear regression there are an infinite number of lines and you need to decide which to plot (or find a way to plot t he plane/hyperplane/surface/etc.). One option is to use the

Re: [R] execute an external program in R

2013-02-14 Thread Greg Snow
?sprintf On Thu, Feb 14, 2013 at 6:59 AM, Esam Tolba eato...@gmail.com wrote: Dear all I am using r (2.15.2) under windows 7 32bit. I want to use system command to execute an external program inside a for loop. this program needs the input and output names. since the names will change in

Re: [R] character strings with embedded commands: perl /gee ?

2013-02-13 Thread Greg Snow
Look at the gsubfn package, it has functionality to do this. Here is an example from the vignette: fn$cat(pi = $pi, exp = `exp(1)`\n) pi = 3.14159265358979, exp = 2.71828182845905 The formula syntax to function conversion in the package may help with the last part. On Fri, Feb 8, 2013 at

Re: [R] Running a R file at a specific time each day

2013-02-13 Thread Greg Snow
If you are on windows then there is a task scheduler for windows. Generally the best solutions are to use the OS tools to schedule your task, chron or task scheduler. If you need a solution inside of R then you can use the tclTaskSchedule function in the tcltk2 package. On Mon, Feb 11, 2013 at

Re: [R] Data sets online for student use

2013-02-13 Thread Greg Snow
The thread starting with this post: https://stat.ethz.ch/pipermail/r-sig-teaching/2013q1/000534.html answers a similar question and many of the answers there should apply here as well. On Tue, Feb 12, 2013 at 11:51 AM, David Arnold dwarnol...@suddenlink.netwrote: All, If you have any good

Re: [R] Is there a place to put executable R scripts in new packages?

2013-02-13 Thread Greg Snow
See ?commandArgs for a way to access the arguments on the command line. With that you can write the FunkyCold.R script to grab the command line arguments and run the proper function (after loading your package). If you give more detail on what you want to accomplish we may be able to give more

Re: [R] Non linear programming: choose R that minimizes corr(y, x^R)

2013-02-05 Thread Greg Snow
The stats package has the optimize function that could be used for this. On Tue, Feb 5, 2013 at 2:08 PM, John Sorkin jsor...@grecc.umaryland.eduwrote: I am looking for a package that will allow me to choose R (a real number) that minimizes the correlation of y and x^R, i.e. find R such that

Re: [R] Loading a list into the environment

2013-02-04 Thread Greg Snow
An often better approach is to use a function like with or within. These allow you to run a command with your list (data frame, environment, etc.) in the first position of the search list so they behave like they are in the global environment (actually better because they temporarily mask rather

Re: [R] use name (not values!) of a dataframe inside a funktion

2013-02-01 Thread Greg Snow
It is strongly discouraged in R to have functions that change data values in the global workspace (or any location other than their local environment). The usual procedure in R is to have your function return a modified version of the object and the user then decides what to do with it. They can

Re: [R] Relative Risk in logistic regression

2013-02-01 Thread Greg Snow
Ivan, In reference to your part 2), in 1989 Li and Duan published a paper where they examined the effect of using the wrong link function ( http://projecteuclid.org/DPubS?service=UIversion=1.0verb=Displayhandle=euclid.aos/1176347254). The short version is that they found that in common models

Re: [R] Automated Start for new Rgui within existing R code?

2013-01-31 Thread Greg Snow
You could always just run something like system(path/to/R/RScript myfile.R) from within R. But this also sounds like something that the parallel package may be helpful with to use your 8 cores to speed up your update process. On Thu, Jan 31, 2013 at 2:12 PM, Brigid Mooney bkmoo...@gmail.com

Re: [R] Programmatically give file name to a matrix

2013-01-30 Thread Greg Snow
This is FAQ 7.21. The most important part of that answer is at the end where it says that it is better to use a list. Your code could be something like: plotroc - list() for (i in levels(mergeTrn$Continent) { # matrix defined here plotroc[[ paste(plotroc_GBM_TRN_,i, sep=) ]] - matrix } now

Re: [R] user units in plotrix

2013-01-22 Thread Greg Snow
If you want to convert between different units using base graphics then look at the grconvertX and grconvertY functions (in the graphics package). These functions will convert from/to user coordinates, inches, device, figure, and plot coordinates. So you could use grconvertX to find out what

Re: [R] how to give a lengend in symbols functions

2013-01-22 Thread Greg Snow
I don't see a symbols function in the gtools package, do you mean the symbols function in the graphics package? If so, there is not a simple legend or key function to create the legend (the number of possible options would make it more complicated than building the legend by hand). You will need

Re: [R] reading multiple key=value pairs per line

2013-01-18 Thread Greg Snow
You could use the strapply function from the gsubfn package to extract the data from strings. This will return a list that you could use with do.call(rbind( The stringr package may have something similar or an alternative (but I am less familiar with that package). On Thu, Jan 17, 2013 at 9:21

Re: [R] A smart way to use $ in data frame

2013-01-18 Thread Greg Snow
The important thing to understand is that $ is a shortcut for [[ and you are moving into the realm where a shortcut is the longest distance between 2 points (see fortune(312)). So your code can be something like: state - 'oldstate' balance - 'oldbalance' dataa[[balance]][ dataa[[state]]=='AR' ]

Re: [R] Using table to get frequencies of several factors at once

2013-01-17 Thread Greg Snow
The tables package may be of use to you for this. On Fri, Jan 11, 2013 at 4:17 AM, Pancho Mulongeni p.mulong...@namibia.pharmaccess.org wrote: Hi, I have a dataframe with n columns, but I am only looking at five of them. And lots of rows, over 700. So I would like to find frequencies for

Re: [R] GPIB-compatible instrument control with R

2013-01-15 Thread Greg Snow
I don't know of any tools within R to do something like this, but one possibility is to use other software that will interface with your device and can then talk with R, one possibility for an intermediate program is here: http://www.windmill.co.uk/index.html. On Fri, Jan 11, 2013 at 4:41 PM,

Re: [R] Drawing a dotted circle.

2013-01-15 Thread Greg Snow
There is also the my.symbols and ms.polygon functions in the TeachingDemos package that have syntax similar to the symbols function: library(TeachingDemos) x - runif(10) y - rnorm(10) my.symbols(x, y, ms.polygon, inches=0.3, n=400, add=FALSE, lty=3) On Sat, Jan 12, 2013 at 7:42 PM, Ved P.

Re: [R] Need help: R for repetitive tasks

2013-01-15 Thread Greg Snow
This is fairly straight forward, you can do something like: myfiles - scan('files.txt', what=) base - sub(\\.[^.]*$, , myfiles) lapply( seq_along(myfiles), function(i) { mydat - read.table( myfiles[i] ) sink( sprintf('%sSummary.txt', base[i]) ) summary(mydat) sink() bmp(

Re: [R] Determining sample size from power function

2013-01-14 Thread Greg Snow
If you have a working function that gives the power for a given sample size then you can use the uniroot function to find which sample size will give the desired power (many of the standard power functions use this internally when computing anything other than power). You just create a function

Re: [R] another R2HTML question, please

2013-01-11 Thread Greg Snow
You might be better off using the knitr package which has options for whether to evaluate code or not (or which pieces of code to evaluate). If you use this in Rstudio then you can knit directly to html from a variety of input formats. Otherwise you can use the external program pandoc to convert

Re: [R] Learning to speak R: simple data processing

2013-01-11 Thread Greg Snow
The apply function takes another function as the argument to be applied to each row (or column) of the matrix. You can use an existing function like you did with 'max' and in this case there is an existing function called 'which.max' that does exactly what you want. If there is not an existing

Re: [R] Problem getting loess tricubic weights

2013-01-10 Thread Greg Snow
To further the understanding of the loess fit and how the tricube weight work you may want to look at the loess.demo function in the TeachingDemos package. It will create a scatterplot of the data and show the loess fit, then when you click on the plot it will show the weights used for predicting

Re: [R] problem adding curve/abline

2013-01-10 Thread Greg Snow
I believe the problem could be that xyplot uses grid graphics and plot.new and curve are base graphics functions and the 2 graphics systems (grid and base) don't play nicely together without a little extra work. In general the gridBase package helps them play nicely, but I am not sure that it

Re: [R] checker/chequer board pattern as a colour

2013-01-07 Thread Greg Snow
Not as a simple color, but you can use the rasterImage function to add a rectangle with a checkerboard pattern to a an existing plot, the examples for the function use a simple checkerboard pattern. Be careful of overusing something like this, too many patterned areas in a plot can be more

Re: [R] Changing mtext direction, or using text for the margin?

2013-01-07 Thread Greg Snow
And look at the grconvertX and grconvertY functions for possibly ways to compute positioning information when using text with base graphics. On Mon, Jan 7, 2013 at 11:35 AM, David Winsemius dwinsem...@comcast.netwrote: On Jan 7, 2013, at 8:06 AM, Michael Rennie wrote: Any thoughts on what

Re: [R] vectorization modifying globals in functions

2012-12-28 Thread Greg Snow
In current versions of R the apply functions do not gain much (if any) in speed over a well written for loop (the for loops are much more efficient than they used to be). Using global variables could actually slow things down a little for what you are doing, if you use `-` then it has to search

Re: [R] multiple sheet in r

2012-12-28 Thread Greg Snow
If you want help from us mere mortals then it would help us to help you if you could tell us not only the number of commands that you tried but what the actual commands were. Also the phrase none worked does not help us help you, see fortune(324). A description of what happened and how the

Re: [R] Any simple way to make this happen?

2012-12-28 Thread Greg Snow
The only way that I can think of that would not use iteration would be to create some type of lookup table with every possible vector you may ever use, then lookup the results in that table. If you are happy with internal iteration then one possibility is: x - c(4,3,5)

Re: [R] how to get a value from a list (using paste function)?

2012-12-27 Thread Greg Snow
There is also another fortune: fortune('toad') The problem here is that the $ notation is a magical shortcut and like any other magic if used incorrectly is likely to do the programmatic equivalent of turning yourself into a toad. -- Greg Snow (in response to a user that wanted to access

Re: [R] how to get a value from a list (using paste function)?

2012-12-27 Thread Greg Snow
Others have mentioned the readability issues (which are important), but think about what would happen in the case where the variable lambda rule ended up with a value like: lambda.rule - a;system('SomeEvilSytemCommand') Or what if the element of the list desired has a space in its name. And

Re: [R] Regarding multiple axes in plots..

2012-12-27 Thread Greg Snow
The idiom of 'par(new=TRUE)' should be hidden, it is never the first thing that you should try and is only rarely needed and as you have seen often causes more problems than it helps. First you should ask yourself if using 2 different coordinate systems in the same plot is the best approach, you

Re: [R] Help in using col in plot()..

2012-12-27 Thread Greg Snow
It would help if we had some idea what data_min1$macdhist actually is. I would not expect to see that error if it is a simple numeric vector, so it probably has a class of some sort which causes the plot command to call a specific method (but we don't know which one) which may not have a col

Re: [R] Legend symbols

2012-12-21 Thread Greg Snow
Using pch you can use all the symbols in the current font, try: plot(0:15, 0:15, type='n') points( (0:255)%%16, (0:255)%/%16, pch=0:255 ) then do it again with points( (0:255)%%16, (0:255)%/%16, pch=0:255, font=5 ) (font 5 is usually a symbol font, fonts 2, 3, and 4 are bold and italic versions

Re: [R] xlim/ylim problem

2012-12-17 Thread Greg Snow
(0,15000)) ** ** With a simple test like f(x)=x*x the ylim-option works fine. So I guess, that it will be something with kind of data set. ** ** A Pro-answer would be great. ** ** Thx a lot ** ** Tom ** ** *Von:* Greg Snow [mailto:538...@gmail.com

Re: [R] average X value of specific Y

2012-12-17 Thread Greg Snow
Look at the tapply function. Possibly using round or cut if needed. Other tools that may be useful (but probably overkill for the simple problem) include aggregate, ave, and the plyr package. On Sat, Dec 15, 2012 at 9:12 PM, Elaine Kuo elaine.kuo...@gmail.com wrote: Hello I have a table

Re: [R] Merge more than 2 dataframe

2012-12-17 Thread Greg Snow
One option is to put all the data frames into a list then use the Reduce function. On Mon, Dec 17, 2012 at 9:03 AM, Vasilchenko Aleksander vasilchenko@gmail.com wrote: Hello. I have for example 4 or more dataframe which like such this example: date value 2006-11 0.4577647

Re: [R] xlim/ylim problem

2012-12-15 Thread Greg Snow
try ylim=c(0,1500) You are missing the c which constructs a vector, without the c it gets confused. On Sat, Dec 15, 2012 at 5:14 PM, Tom Hoffrichter tom.hoffrich...@googlemail.com wrote: Hi everybody, just arrived at R and immediately I got a problem. Here's my script:

Re: [R] remove last row of a data frame

2012-12-12 Thread Greg Snow
Another option (better or worse probably depends on many things) is to use: b - head(a, -1) On Wed, Dec 12, 2012 at 1:14 AM, e-letter inp...@gmail.com wrote: On 12/12/2012, Daniel Nordlund djnordl...@frontier.com wrote: -Original Message- From: r-help-boun...@r-project.org

Re: [R] glm - predict logistic regression - entering the betas manually.

2012-12-11 Thread Greg Snow
It may be overkill, but you can specify the model pieces using the offset function in the model, then the predictions work out (at least for my simple trial case). Something like: fit - glm( y ~ 0+offset(-1 + 2*x), family=binomial, data=data.frame(y=0, x=0) ) predict( fit,

Re: [R] Reassign functions called by other functions in package graphics

2012-12-11 Thread Greg Snow
I think the error is because the other functions are expecting the plot.new function to do some specific things to set up the graphics device for a new plot, but your function did not do those things. You might consider the trace function as an alternative to what you are trying. It can be used

Re: [R] Best way to coerce numerical data to a predetermined histogram bin?

2012-12-06 Thread Greg Snow
?findInterval On Thu, Dec 6, 2012 at 3:00 PM, Jonathan Greenberg j...@illinois.eduwrote: Folks: Say I have a set of histogram breaks: breaks=c(1:10,15) # With bin ids: bin_ids=1:(length(breaks)-1) # and some data (note that some of it falls outside the breaks:

Re: [R] How to reset R settings to original state other than remove .Rdata and .Rhistory

2012-12-05 Thread Greg Snow
Read the ?Startup page, it documents the files that are read on startup and how to skip them, it may suggest another way to start a fresh session without deleting files to see if that works for you, it also gives other files or sources that you may investigate to find the differences in the 2

Re: [R] Simulation in R

2012-12-01 Thread Greg Snow
look at functions replicate and mvrnorm functions (the later in the MASS package). On Sat, Dec 1, 2012 at 12:02 PM, mboricgs mbori...@hotmail.com wrote: Hello! How can I do 100 simulations of length 17 from bivariate bivariate normal distribution, if I know all 5 parameters? -- View

Re: [R] Weight matrix in linear regression

2012-11-29 Thread Greg Snow
The gls function in the nlme package is one approach. If you know the covariance matrix exactly (it is just numerical with nothing that needs to be estimated) then you can also take the Cholesky decomposition of the inverse of the covariance matrix (or other square root method) and multiply the x

Re: [R] wrong data interpretation in R

2012-11-28 Thread Greg Snow
How to change a factor to numeric is FAQ 7.10 Also look at the `colClasses` argument to read.table/read.csv for a way to specify the type of the column when you are reading it in. On Mon, Nov 26, 2012 at 8:59 AM, EcoFranc rob...@gmx.de wrote: Hi, maybe somebody would be kind enough to help

Re: [R] in par(mfrow=c(1, 2)), how to keep one half plot static and the other half changing

2012-11-28 Thread Greg Snow
Duncan showed the way to do it in 1 plotting device, but it may be easier to just open 2 graphics devices, arrange them side by side, then set up the code to let you select in one, then switch to the other to do the plotting. See ?dev.new and ?dev.set. On Tue, Nov 27, 2012 at 8:46 AM, Baoqiang

Re: [R] Can you turn a string into a (working) symbol?

2012-11-28 Thread Greg Snow
Yes, I meant FAQ 7.21, must have stuttered in typing, but it is always good to read other FAQs while looking for a specific one. I did read your full description, though whether I fully understand or not is yet to be seen. It seems like a lot of what you want to do could be simplified by using

Re: [R] Can you turn a string into a (working) symbol?

2012-11-28 Thread Greg Snow
In addition, if you go the route of a data frame then the functions to look at are tapply, aggregate, and ave. On Wed, Nov 28, 2012 at 2:02 PM, Greg Snow 538...@gmail.com wrote: Yes, I meant FAQ 7.21, must have stuttered in typing, but it is always good to read other FAQs while looking

Re: [R] Comparing the Means of Two Normal Distributions

2012-11-24 Thread Greg Snow
You have all the information that you need to do the pooled t-test using the formula in many intro stats textbooks and probably on wikipedia as well, just plug your numbers into the formulas in the book (R can act as the calculator to make this easier). Or sometimes simpler (for the human, the

Re: [R] Barplot with lines

2012-11-23 Thread Greg Snow
Look at the updateusr function in the TeachingDemos package. One of the examples shows adding lines to a barplot. On Fri, Nov 23, 2012 at 12:33 AM, Ripples 9ripp...@gmail.com wrote: Hi, I'm trying to plot stacked barplot with lines on it. Here is the data. emp days val1 val2 score 1 21

Re: [R] plotting 1000 simulations, error message: plot.new has not been called yet

2012-11-22 Thread Greg Snow
Why are you using jpeg to create files with a .png extension? wouldn't it make more sense to use the png function? There are a couple of options, you could plot using the matplot function (with different subsets in the loop). Or you can start an initial empty plot and use lines to add to it,

Re: [R] Plot Area Dimensions

2012-11-19 Thread Greg Snow
The key is to not change the margins, set them once and stick with those margins. The next question then becomes how do I leave area at the top/bottom for the title and common axis? to which the answer is Set outer margins at the beginning. Modifying your code: y-rnorm(1:100) x-rnorm(1:100)

Re: [R] sample mean, variance and SD

2012-11-10 Thread Greg Snow
Your code works for me, can you tell us what output you are getting, what output you expect to see, and how they differ? On Sat, Nov 10, 2012 at 11:23 AM, parvez_200207 parvez.r...@uef.fi wrote: hi could you help me to solve this issue Question: Using command rweibull(100,8,15), simulate n

Re: [R] sample mean, variance and SD

2012-11-10 Thread Greg Snow
This is to all R-helpers (Sarah is just the one that I am replying to), Have we become a little too draconian on the not a homework help list issue? Now if someone just states the HW question, gives no indication that they have done anything to try to solve it themselves, and expects us to give

Re: [R] Fwd: Simulate nested data

2012-11-09 Thread Greg Snow
There are still a lot of things that you did not specify, but maybe this will get you started: n.groups - sample(3:6, 1) n.species - sample(2:10, n.groups, replace=TRUE) n.animals - sample( 10:25, sum(n.species), replace=TRUE ) mu.g - rnorm(n.groups, 100, 50) mu.species - rnorm( sum(n.species),

Re: [R] Can you turn a string into a (working) symbol?

2012-11-07 Thread Greg Snow
Others have shown you ways to do what you asked, and what you asked happens to also be FAQ 7.22 (but with terms different enough that that FAQ is not obvious). However the solutions that you are tending towards are running into the problems addressed in fortune(106) and fortune(236), the

Re: [R] how to generate a set of random numbers that sum to 1 with uniform distribution of elements

2012-11-07 Thread Greg Snow
The Dirichlet distribution will give values that sum to one and with the correct conditions will have uniform margins. There are multiple packages that will generate data from Dirichlet distributions, either gtools or gmodels is one of them, but there are others as well. On Wed, Nov 7, 2012 at

Re: [R] Problem with lm

2012-11-01 Thread Greg Snow
Yes, it is most likely due to scoping. It is safest to create a data frame with all the data in it, then pass that to the data argument of lm. On Thu, Nov 1, 2012 at 2:25 AM, Eva Prieto Castro evapcas...@yahoo.es wrote: Hi, I have a problem in relation with a packahe I made. It runs on my

Re: [R] Problem with lm

2012-11-01 Thread Greg Snow
, Greg Snow 538...@gmail.com wrote: Yes, it is most likely due to scoping. It is safest to create a data frame with all the data in it, then pass that to the data argument of lm. On Thu, Nov 1, 2012 at 2:25 AM, Eva Prieto Castro evapcas...@yahoo.es wrote: Hi, I have a problem in relation

Re: [R] Reduce(paste, x) question

2012-11-01 Thread Greg Snow
It is not clear exactly what you want. Do you want the final object to be a matrix with 2 columns (or the number of columns equal to the number of items in the list? If so you could just use do.call(cbind, x) and you would not need reduce or paste (paste is the wrong tool unless you want a

Re: [R] error in lm

2012-10-30 Thread Greg Snow
First your response in the formula is a matrix which causes the lm function to return an object of type 'mlm' for multivariate linear model. Then when you run the stepAIC function it runs the addterm function which looks for a method(function) to add terms to mlm objects. However nobody has

Re: [R] Is there an lm() equivalent of panel.lmline()?

2012-10-30 Thread Greg Snow
You can use the lmList function in the nlme package to do several seperate regressions, or use a model that allows for multiple intercepts. Possibly Xvalues ~ 0 + log(Qvalues)*Tfac or Xvalues ~ 0 + Tfac + log(Qvalues):Tfac (assuming Tfac is a factor). On Tue, Oct 30, 2012 at 5:53 AM, Alex van

Re: [R] Creating dataframes with unique, sequential names

2012-10-30 Thread Greg Snow
On Tue, Oct 30, 2012 at 8:00 AM, Bart Joosen bartjoo...@hotmail.com wrote: Take a look at ?assign Then read fortune(236) Then learn about lists and environments to learn better methods. Bart, without context it is harder for use to contribute useful advice. Bart -- View this message

<    1   2   3   4   5   6   7   8   9   10   >