[R] lists within lists

2011-04-04 Thread Darcy Webber
Hello R users, I am dealing with some resonably big data sets that I have split up into lists based on various factors. In the code below, I have got my code producing 100 values between point1x and point1y for the first matrix in my list. for (k in 1:length(point1x[[1]][, 1])) { linex[[k]] = seq

[R] extracting file names

2011-03-23 Thread Darcy Webber
Dear R users, I am trying to figure out a way to extract the original file name of a .DAT (e.g., IC48.DAT) file imported into R using the file.choose() function, i.e., dat <- read.table(file.choose(), header = FALSE) The reason I would like to do this is to use that file name to name an output f

[R] minimum distance between line segments

2011-03-08 Thread Darcy Webber
Dear R helpers, I think that this may be a bit of a math question as the more I consider it, the harder it seems. I am trying to come up with a way to work out the minimum distance between line segments. For instance, consider 20 random line segments: x1 <- runif(20) y1 <- runif(20) x2 <- runif(2

[R] allocating factor levels

2011-03-07 Thread Darcy Webber
Dear R users, I am working on allocating the rows within a dataframe into some factor levels.Consider the following dataframe: Start.action Start.time 1Start.setting2010-12-30 17:58:00 2Start.setting2010-12-30 18:40:00 3S

[R] splitting and stacking matrices

2011-03-01 Thread Darcy Webber
uch appreciated. Regards Darcy Webber __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.

[R] multiple plots using a loop

2011-02-21 Thread Darcy Webber
Dear R users, I am trying to write myself a loop in order to produce a set of 20 length frequency plots each pertaining to a factor level. I would like each of these plots to be available on the same figure, so I have used par(mfrow = c(4, 5)). However, when I run my loop below, it produces 20 plo

[R] distance between consecutive points

2011-02-15 Thread Darcy Webber
Dear R users, I have two coloumns of data, say x and y, referring to a list of points in 2D space. I am trying to develop a code that will give me the distances (using Pythagoras) between consecutive points (xi,yi) and (xi+1,yi+1). So far I have come up with the following: for (i in 1:length(x))