Igor Blanco
2010-Jul-21 13:39 UTC
[R] Error message: attempt to set rownames on object with no dimensions
Hi there, I am trying to analyze some data using the lme package. In my case there is a variable called Newmarker that can only take 2 values (number 1 or number 2). I have used the as.factor to remark this fact but an error message appears stating: attempt to set rownames on object with no dimensions. Here is the code I have used: *Dataset <- read.table("Data2.txt", header=TRUE, sep="", na.strings="NA", dec=".", strip.white=TRUE) Dataset$Newmarker <- as.factor(Dataset$Newmarker) attach(Dataset) lme.1 <- lme(Newmarker ~ Age, data=Dataset, random= ~1|ID) summary(lme.1)* If I don't use the as.factor I have no problems but I don't think this is the correct way to proceed... The other variables I use can have any value. Can anybody help me please? Thanking you in advance, Regards, Igor Blanco [[alternative HTML version deleted]]
Prof Brian Ripley
2010-Jul-21 14:02 UTC
[R] Error message: attempt to set rownames on object with no dimensions
?lme (at least the one in package nlme) seems not to mention that the response in 'fixed' must be a numeric variable, but it must (and a factor is not numeric). If you want to use a binary response, you need to use other methods, and it would be better to ask on R-sig-mixed-models making clear what your aims actually are. On Wed, 21 Jul 2010, Igor Blanco wrote:> Hi there, > > I am trying to analyze some data using the lme package.Perhaps you mean the nlme package?> In my case there is a variable called Newmarker that can only take 2 values > (number 1 or number 2). > I have used the as.factor to remark this fact but an error message appears > stating: attempt to set rownames on object with no dimensions. > > Here is the code I have used: > > *Dataset <- read.table("Data2.txt", header=TRUE, sep="", na.strings="NA", > dec=".", strip.white=TRUE) > > Dataset$Newmarker <- as.factor(Dataset$Newmarker) > > attach(Dataset) > > lme.1 <- lme(Newmarker ~ Age, data=Dataset, random= ~1|ID) > > summary(lme.1)* > > If I don't use the as.factor I have no problems but I don't think this is > the correct way to proceed... The other variables I use can have any value. > > Can anybody help me please? > > Thanking you in advance, > > Regards, > > Igor Blanco > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at 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. >-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
David Winsemius
2010-Jul-21 14:07 UTC
[R] Error message: attempt to set rownames on object with no dimensions
On Jul 21, 2010, at 9:39 AM, Igor Blanco wrote:> Hi there, > > I am trying to analyze some data using the lme package. > In my case there is a variable called Newmarker that can only take 2 > values > (number 1 or number 2). > I have used the as.factor to remark this fact but an error message > appears > stating: attempt to set rownames on object with no dimensions. > > Here is the code I have used: > > *Dataset <- read.table("Data2.txt", header=TRUE, sep="", > na.strings="NA", > dec=".", strip.white=TRUE) > > Dataset$Newmarker <- as.factor(Dataset$Newmarker)Why do you use as.factor? It's probably already a factor. What does str(Dataset) show?> > attach(Dataset)You do not need to do this, and it creates potential for confusion. The data= argument will allow the column names to be accessed by the lme() function.> > lme.1 <- lme(Newmarker ~ Age, data=Dataset, random= ~1|ID) > > summary(lme.1)* > > If I don't use the as.factor I have no problems but I don't think > this is > the correct way to proceed... The other variables I use can have any > value.-- David Winsemius, MD West Hartford, CT