Re: [R] Performing operations only on selected data

2012-11-25 Thread Marcel Curlin
Thank you, this works very well. My only remaining question about this is about how ifelse is working; I understand the basic syntax (df$condition2 gets assigned the value *runif(nrow(df1[df1$condition1<=1,]),0,1)* or the value *df$condition1* depending on whether or not df$condition1 meets the cri

[R] Performing operations only on selected data

2012-11-24 Thread Marcel Curlin
I spent some time on this simple question, also searched the forum, eventually hacked my way to an ugly solution for my particular problem but I would like to improve my coding: I have data of the form: df <- expand.grid(group=c('copper', 'zinc', 'aluminum', 'nickel'), condition1=c(1:4)) I would

[R] Calculating number of elapsed days from starting date

2012-09-26 Thread Marcel Curlin
Hi I have data for events in rows, with columns for person and date. Each person may have more than one event; tC <- textConnection(" Person date bob 1/1/00 bob 1/2/00 bob 1/3/00 dave1/7/00 dave1/8/00 dave1/10/00 kevin 1/2/00 kevin 1/3/00 kevin 1/4/00 ") data <- rea

Re: [R] Loop for multiple plots in figure

2012-06-27 Thread Marcel Curlin
Well at this point I have what I need (rough plot for data exploration) but the simplicity of the first approach is quite elegant and it has become a learning project. I have succeeded in formatting the overall plot OK but have not been able to solve the problem of titles or any kind of label/legen

Re: [R] Loop for multiple plots in figure

2012-06-26 Thread Marcel Curlin
This solution works really nicely & I learned much by working through it. However but I am having trouble with subplot formatting; setting main=d$Subject results in the correct title over each plot but repeated multiple times. Also I can't seem to format the axis labels and numbers to reduce the sp

[R] Loop for multiple plots in figure

2012-06-24 Thread Marcel Curlin
Hello, I have longitudinal data of the form below from N subjects; I am trying to create figure with N small subplots on a single page, in which each plot is from only one subject, and in each plot there is a separate curve for each value of param1. So in this case, there would be four plots on t

[R] linear regression in a ragged array

2011-03-21 Thread Marcel Curlin
Hello, I have a large dataset of the form subj var1 var2 001100200 001120226 001130238 001140245 001150300 002110205 002125209 003101233 003115254 I would like to perform linear regression of var2 on var1 for each subj

[R] trouble with histograms

2010-10-26 Thread Marcel Curlin
Hi, I have tab-delimited data with an unequal number of entries per column, of the sort: A B C 1 2 2 3 4 1 5 2 2 6 2 5 2 3 6 2 I would like to make a histogram of the frequencies of each represented number in a "stacked" histogram, where you can see the contribution of eac

Re: [R] R code output issues

2010-09-03 Thread Marcel Curlin
Thanks for the input Adding "print" took care of the first problem. The output looks like what I would expect, so I think the code is doing what I would like it to for the first 44 observations. > print(results.df) DR D.1 R.1 V1V2dif V1V4dif 1 68.92500 75.00

[R] R code output issues

2010-09-03 Thread Marcel Curlin
Hi all, I have a short R code file that I am using to perform calculations on a dataset. I am having a few issues with output: 1. Although my input data file is 2149 lines long, when I type "results.df" from the command line, I get the appropriate calculation results for only the first 46 rows.

[R] while loop until end of file

2010-08-29 Thread Marcel Curlin
Hi Guys, stumped by a simple problem. I would like to take a file of the form Pair group param1 1 D 10 1 D 10 1 R 10 1 D 10 2 D 10 2 D 10 2 D 10 2

[R] Formatting numerical output

2010-04-24 Thread MARCEL CURLIN
Hello, I am new to R and am having difficulty formatting numerical output from a regression analysis. My code iteratively performs linear regression on a dataset while excluding certain data ranges. My code: rm(list = ls(all = TRUE)) sink("outfile") dat <- read.table("testdat", sep="\t", header