Sometimes “R” drives me crazy !

Привет всем, хотя никто ни читает мой блог 😀 Но, всё же : я люблю расказывать о моих проблемах кому-то 😀

I love working with statistic program “R”. yeah its my favorite. However it makes me cry :D. I don’t understand what am I doing wrong, sometimes it works pretty well, sometimes……………. very bad

I love to write scripts, because, after some time I don’t remember anything 😀 I work with the same script with 2 different txt files. In first case it does work, in another case, it does not !

I want to make linear regression in order to get b coefficient from length-weight relationships.

Look at this when I put 1st txt file:

> setwd(“F:\\Rwd”)
> df1 <- read.table(file=”sab.txt”, header=TRUE, sep=”\t”)
> sab<-df1
> sabdf<-as.data.frame(sab)
> is.data.frame(sabdf)
[1] TRUE
> attach(sabdf)
The following objects are masked from sabdf (pos = 3):

SEX, TL, W

fsdf

Cool right?

> lm(log(W)~log(SL))

Call:
lm(formula = log(W) ~ log(SL))

 

Coefficients:
(Intercept) log(SL)
-12.289 3.328

> regsab<-lm(log(W)~log(SL))
> plot(log(W)~log(SL))
> abline(lm(log(W)~log(SL)))
> detach(sabdf)

But when I try different txt file with same structure as 1st 

> setwd(“F:\\Rwd\\SDBS”)
> getwd()
[1] “F:/Rwd/SDBS”
> df1 <- read.table(file=”sabf.txt”, header=TRUE, sep=”\t”)
> sabdf<-as.data.frame(df1)
> is.data.frame(sabdf)
[1] TRUE
> attach(sabdf)
The following objects are masked from sabdf (pos = 3):

SEX, TL, W

> lm(log(W)~log(SL))
Error in Math.factor(W) : ‘log’ not meaningful for factors
># ERRROR ? WTF? R U kidding ?

Вот и всё….

 

Advertisements

2 thoughts on “Sometimes “R” drives me crazy !

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s