On Friday 07 October 2005 20:55, Sundar Dorai-Raj wrote:
> Adrian DUSA wrote:
> > [...snip...]
>
> Hi, Adrian,
>
> You need to assign "fix(dataf)" to something:
>
> my.data <- data.frame(age=c(24,35,28), gender=c("Male", "Female", "Male"))
> require(Hmisc)
> label(my.data$age) <- "Respondent's age"
> label(my.data$gender) <- "Responent's gender"
>
> variables <- function(x) {
> dataf <- data.frame(variable=NA, label=NA)
> varlab <- NA
> for (i in 1:length(names(x))) {
> dataf[i,1] <- names(x)[i]
> dataf[i,2] <- label(x[,i])
> varlab[i] <- label(x[,i])
> }
> dataf <- fix(dataf)
> # I assume this would return a modified dataf
> for (i in which(varlab != dataf[,2])) {
> label(x[,i]) <- dataf[i,2]
> }
> # don't forget to return dataf
> dataf
> }
>
> variables(my.data)
>
> HTH,
>
> --sundar
Also, I now have another related two questions: 1. is it possible to "edit" the contents of a cell when using fix() ? In order to change a letter one would have to change the whole string. 2. is it possible to change the width of a column?
Thank you,
Adrian
-- Adrian DUSA Romanian Social Data Archive 1, Schitu Magureanu Bd 050025 Bucharest sector 5 Romania Tel./Fax: +40 21 3126618 \ +40 21 3120210 / int.101 ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.htmlReceived on Sat Oct 08 04:18:02 2005
This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:40:39 EST