[R] problem with data frame to numeric transformation

Rui Barradas ruipbarradas at sapo.pt
Mon May 21 23:02:49 CEST 2012


Hello,

You need to tell read.table that the table has headers.


# needed 'header=TRUE'
first <- read.table("RESIDSNEWr.csv", sep=";", quote="\"",
header=TRUE)[c(1)]
second <- read.table("RESIDSNEWr.csv", sep=";", quote="\"",
header=TRUE)[c(2)]
# see what they look like
str(first)
str(second)

is.numeric(first) ## FALSE
is.numeric(second) ## FALSE

is.numeric(first$aaa) ## TRUE
is.numeric(second$bbb) ## TRUE
# general purpose
sapply(first, is.numeric)
sapply(second, is.numeric)


And the rest works at the first try.

> calibKendallsTau(cc,cor(first,second,method="kendall"))
         bbb
aaa 4.420256
> 
> ## goodness-of-fit tests
> gf.cc <- gofCopula(cc,u,method="itau")
Progress will be displayed every 100 iterations.
Iteration 100 
[...etc...]
Iteration 1000 
> 
> gf.cc$pvalue
[1] 0.0004995005


Hope this helps,

Rui Barradas

Ivette wrote
> 
>  http://r.789695.n4.nabble.com/file/n4630788/GOF_CGIK.R GOF_CGIK.R  
> http://r.789695.n4.nabble.com/file/n4630788/RESIDSNEWr.csv RESIDSNEWr.csv 
> 
> In order to save place, I attach the data and the R code, for which I have
> 2 questions.
> 
> 1/ I cannot convert successfully the data frames with names "first" and
> "second" in numeric format. They participate here: 
> 
> calibKendallsTau(cc,cor(first,second,method="kendall")) and I get an error
> message.
> 
> 2/ I have cut the dates from my data file RESIDSNEWr.csv, but let's
> suppose I want to keep them. How shall I update the code from 1/ in order
> to have also the dates?
> 
> Many thanks in advance to all, who will answer my message
> 


--
View this message in context: http://r.789695.n4.nabble.com/problem-with-data-frame-to-numeric-transformation-tp4630788p4630803.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list