[R] Selection with changing number of columns

2010-07-06 Thread Kunzler, Andreas
Dear list, I'm looking for a way to select rows of a data.frame with changing number of columns (constraint) involved. Assume a data (d) structure like Var.1 Var.2 Var.3 9 2 1 2 9 5 1 2 1 I know the number of involved columns. Is there a way to generate th

[R] Counting defined character within String

2010-07-05 Thread Kunzler, Andreas
Dear list, I'm looking for a way to count the number of "|" within an object. The character "|" is used to separated ids. Assume a data (d) structure like Var NA NA NA NA NA 1 1|2 1|22|45 3 4b|24789 I need to know the maximum number of ids within one object. In this case 3 (1|22|45) Does any

[R] time-series data and time-invariant missing values

2009-04-06 Thread Kunzler, Andreas
Dear list, I have some problems with time-series data and missing values of time-invariant informations like sex or the birth-date. Assume a data (d) structure like id birth sex year of observation 1 NA NA 2006 1 1976-01-01 male2007 1

[R] table for weighted observations

2008-11-24 Thread Kunzler, Andreas
Dear List, I ran into some problems with weighted observations. I am looking for a frequency table listing the frequencies of the whole year as well as the frequencies of first and second half-year. The observation is of the class factor. There are characteristics that have the frequency 0 in

[R] Handling time-series-Data

2008-09-11 Thread Kunzler, Andreas
Dear List, I ran into some problems with time-series-Data. Imagine a data-structure where observations (x) of test attendants (i) are made a four times (q) a year (y). The data is orderd the following way: I y q x 1 20061 1 1 20063 1 1

[R] exporting tapply objects to csv-files

2008-09-09 Thread Kunzler, Andreas
Dear Everyone, I try to create a cvs-file with different results form the table function. Imagine a data-frame with two vectors a and b where b is of the class factor. I use the tapply function to count a for the different values of b. tapply(a,b,table) and I use the table function to have a

Re: [R] NAs - NAs are not allowed in subscripted assignments

2008-07-24 Thread Kunzler, Andreas
Hy Richie, thank you for the quick response. Unfortunately my problems hold on. Once again: 2 vectors (numeric) including NAs My intention: I want to replace the values of vector a that are smaller than 2 and larger than 3 into NAs only in case vector b equals 1 a <- c(rep(seq(1,4),4),NA,NA) b

[R] NAs - NAs are not allowed in subscripted assignments

2008-07-24 Thread Kunzler, Andreas
Dear List, I ran into some trouble handling missing values. Assume 2 vectors (numeric) including NAs a <- c(rep(seq(1,4),4),NA,NA) b <- c(sample(1:2,14,replace=T),NA,NA,1,2) I want to replace the values of vector a that are smaller than 2 and larger than 3 into NAs only in case vector b equals

[R] Table orderd by frequencies

2008-07-22 Thread Kunzler, Andreas
Dear List, I try to order the output of a table by the frequencies of the vector I am look at. The object I am looking at is a factor with a lot of levels that were named only once. Therefore it would be much easier to order the output by the frequencies of the levels. E.g. > levels(a) "a" "b"

[R] calculate differences - strange outcome

2008-07-17 Thread Kunzler, Andreas
Dear List, I ran into some trouble by calculating differences. For me it is important that differences are either 0 or not. So I don't understand the outcome of this calculation 865.56-(782.86+0+63.85+18.85+0) [1] -1.136868e-13 I run R version 2.71 on WinXP I could solve my problem by using ro

[R] Group level frequencies

2008-07-16 Thread Kunzler, Andreas
Dear List, I have Multi-level Data i= Indivitual Level g= Group Level var1= First Variable of interest var2= Second Variable of interest and I want to count the frequency of "var1" and "var2" on the group level. I found a way, but there must be a much simpler way. data.ml <- data.frame(i=c(1:

[R] Frequency-Table on Group Level - Multi Level Analysis

2008-07-14 Thread Kunzler, Andreas
Hello everybody, I've a multi-level structured data.frame. I = Individual Level (factor) G = Group Level (factor) SW= Software (factor) I G SW 1 1 A 2 1 A 3 2 B Im looking for a frequncy-talbe of the used software on the group level. In this case the result has to be: A = 0.5 B = 0.5 Is ther

Re: [R] Manipulate Data (with regular expressions)

2008-07-11 Thread Kunzler, Andreas
tag, 8. Juli 2008 17:20 An: Kunzler, Andreas Cc: r-help@r-project.org Betreff: Re: [R] Manipulate Data (with regular expressions) Try this: x <- factor(c("220", "220a", "221", "221b", "B221")) pat <- "[^0-9]+" # match non-digits nums

[R] Manipulate Data (with regular expressions)

2008-07-08 Thread Kunzler, Andreas
Dear Everyone, I try to automatically manipulate the data of a variable (class = factor) like x 220 220a 221 221b B221 Into two variables (class = numeric) like x y 220 0 220 1 221 0 221 1 221 1 y has to carry the information about the class (number or st