Re: [R] Accessing objects manipulated in a function

2016-05-14 Thread Bert Gunter
"... wonton (as in "users will change my variables this way") use of that operator will inevitably lead to surprises and puzzlement later. " Is this related to the myriad of choices in a Chinese menu? ;-) (The spelling is "wanton" -- ah the joys of English!) Cheers, Bert Bert Gunter "The tro

Re: [R] Accessing objects manipulated in a function

2016-05-14 Thread Dennis Fisher
Jeff Thanks for your insights. I suspected that this was the case but I was hoping for a work-around. Regardless, I have modified the code so that the source() command is no longer in a function — all the pre- and post-commands are now in two functions, executed before and after the source co

Re: [R] Plot trajectories using ggplot?

2016-05-14 Thread Mike Smith
Thanks very much for the pointer - that was spot on. The key thing was to add df$case <- rownames(df) to generate the row by row case for when I melted the columns. As Ive since found out either of these will work ggplot(ds, aes(x = as.numeric(variable), y = value, colour = case)) + geom_poin

Re: [R] Accessing objects manipulated in a function

2016-05-14 Thread Jeff Newmiller
I think you have boxed yourself into a corner, much like someone painting the floor and failing to work their way toward an exit. The whole premise that you will call "unknown code" that does "unknown things" that change the global environment is a maintenance disaster. Give up on at least one

[R] Accessing objects manipulated in a function

2016-05-14 Thread Fisher Dennis
R 3.2.4 OS X and Windows Colleagues, I distribute some code to co-workers and I am trying to simplify their task. The issue is as follows: 1. The code automates an extensive set of processes. Many of the steps are standardized. However, some of the steps may require that users write snippe

Re: [R] Plot trajectories using ggplot?

2016-05-14 Thread Ulrik Stervbo
You can introduce the row number as a case number, you can group by case and plot the connecting lines #Read raw data df = read.table("http://www.lecturematerials.co.uk/data/sample.csv";, header=TRUE, sep=",", dec=".", na.strings=c("NA")) names(df)<-c("1","2","3","4") df$case <- rownames(df) #Tu

Re: [R] apply formula over columns by subset of rows in a dataframe (to get a new dataframe)

2016-05-14 Thread Massimo Bressan
thank you, what a nice compact solution with ave() I learned something new about the subtleties of R let me here summarize the alternative solutions, just in case someonelse might be interested... thanks, bye # # my user function (an example) mynorm <- function(x) {(x - min(x, na.rm=TRU

[R] Plot trajectories using ggplot?

2016-05-14 Thread Mike Smith
Hi Ive got stuck using the code below to try to plot trajectories - columns are data recorded at time points, rows are cases. Ive used melt to turn the data long allowing me to group by time point and then plot using geom_point but I now need to join the points based upon the correct case (i.e.

[R] R 3.3.0 Crashing: Error in readRDS(nsInfoFilePath) : unknown input format

2016-05-14 Thread Amitava Mukherjee
Dear All, Greetings. I hope you will be able to provide kind help with the following: I am facing a strange problem ever since I have started working with R 3.3.0. I download and work with it, it was fine. Then when I shut down and reopen, it is not working properly. I am getting following mess

[R] aggregate.data.frame(drop=FALSE) in R 3.3.0

2016-05-14 Thread Suharto Anggono Suharto Anggono via R-help
>From NEWS: The data frame and formula methods for aggregate() gain a drop >argument. Here, I highlight behavior of 'aggregate.data.frame' with drop=FALSE in R 3.3.0. Example 1, modified from "example with character variables and NAs" in "Example" in R help on 'aggregate': > testDF <- data.fram

Re: [R] physical constraint with gam

2016-05-14 Thread Simon Wood
On 12/05/16 02:29, Dominik Schneider wrote: > Hi again, > I'm looking for some clarification on 2 things. > 1. On that last note, I realize that s(x1,x2) would be the other > obvious interaction to compare with - and I see that you recommend > te(x1,x2) if they are not on the same scale. - yes th