Re: [R] Help with reshape/reshape2 needed

2017-07-05 Thread Jim Lemon
Oops, that should have been:

stretch_df(tadf,"V1","V2")

Jim

On Thu, Jul 6, 2017 at 8:38 AM, Jim Lemon  wrote:
> Hi Tom,
> Or perhaps:
>
> #assume the data frame is named "tadf"
> library(prettyR)
> stretch_df(tadf,1,2)
>
> Jim
>
>
> On Thu, Jul 6, 2017 at 6:50 AM, Ista Zahn  wrote:
>> The reason it doesn't work easily with reshape/reshape2 is that the
>> order of the rows is not determined. Your answer could be
>>
>>  1957  1958 ...  1985   1986
>> 0.8625000 0.750 ... 0.7307692 0.2375
>> 0.0733945 0.6435644 ...NA 0.05769231
>> 0.5096154NA ...NA 0.65137615
>>
>> or
>>
>>  1957  1958 ...  1985   1986
>> 0.0733945 0.6435644 ...NA 0.05769231
>> 0.8625000 0.750 ... 0.7307692 0.2375
>> 0.5096154NA ...NA 0.65137615
>>
>> or
>>
>>  1957  1958 ...  1985   1986
>> 0.8625000 0.6435644 ...NA 0.2375
>> 0.0733945 NA0.7307692 0.05769231
>> 0.5096154 0.750 ...NA 0.65137615
>>
>> or any other combination of orders. You might not care about the
>> order, but reshape does.
>>
>> The usual way around it is to just make up an order variable, e.g.,
>> assuming your data.frame is named "example_data" and the columns are
>> named "year" and "score":
>>
>> example_data <- do.call(rbind,
>> lapply(split(example_data,
>>  example_data$year),
>>transform,
>>obs = seq_along(year)))
>>
>> dcast(example_data,
>>   obs ~ year,
>>   value.var = "score")
>>
>> Best,
>> Ista
>>
>>
>> On Wed, Jul 5, 2017 at 2:16 PM, Thomas Adams  wrote:
>>> Hi all:
>>>
>>> I'm struggling with getting my data re-formatted using functions in
>>> reshape/reshape2 to get from:
>>>
>>> 1957 0.86250
>>> 1958 0.75000
>>> 1959 0.3
>>> 1960 0.28750
>>> 1963 0.67500
>>> 1964 0.93750
>>> 1965 0.02500
>>> 1966 0.38750
>>> 1969 0.08750
>>> 1970 0.27500
>>> 1973 0.5
>>> 1974 0.36250
>>> 1976 0.92500
>>> 1978 0.71250
>>> 1979 0.33750
>>> 1980 0.7
>>> 1981 0.42500
>>> 1982 0.21250
>>> 1983 0.31250
>>> 1986 0.23750
>>> 1958 0.643564356
>>> 1963 0.25000
>>> 1968 0.211538462
>>> 1976 0.317307692
>>> 1981 0.673076923
>>> 1985 0.730769231
>>> 1986 0.057692308
>>> 1957 0.073394495
>>> 1966 0.742574257
>>> 1961 0.082568807
>>> 1964 0.165137615
>>> 1965 0.137614679
>>> 1959 0.128712871
>>> 1968 0.587155963
>>> 1969 0.660550459
>>> 1970 0.477064220
>>> 1971 0.513761468
>>> 1973 0.449541284
>>> 1974 0.128440367
>>> 1968 0.415841584
>>> 1977 0.009174312
>>> 1979 0.339449541
>>> 1981 0.596330275
>>> 1982 0.348623853
>>> 1984 0.146788991
>>> 1986 0.651376147
>>> 1959 0.451923077
>>> 1965 0.75000
>>> 1962 0.326732673
>>> 1964 0.782178218
>>> 1970 0.336538462
>>> 1975 0.277227723
>>> 1978 0.712871287
>>> 1957 0.509615385
>>> 1960 0.490384615
>>> 1961 0.721153846
>>> 1966 0.298076923
>>> 1969 0.413461538
>>> 1971 0.5
>>> 1972 0.692307692
>>> 1974 0.653846154
>>> 1984 0.049504950
>>> 1978 0.442307692
>>> 1973 0.079207921
>>> 1983 0.355769231
>>> 1984 0.038461538
>>> 1979 0.237623762
>>> 1982 0.564356436
>>>
>>> to:
>>>
>>> 1957  1958   1959 1960 ...
>>> 1985   1986
>>> 0.509615385  0.75000  0.451923077  0.28750 ...
>>> 0.651376147
>>> 0.509615385
>>>
>>> and so on. It's likely the column lengths will be different, so I'm
>>> guessing padding with NAs will be needed. I have on the order of 1335 rows
>>> with years spanning 1957 to 2016.
>>>
>>> Thank you...
>>> Tom
>>>
>>> --
>>>
>>> [[alternative HTML version deleted]]
>>>
>>> __
>>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>>> 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.
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> 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.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R] Help with reshape/reshape2 needed

2017-07-05 Thread Jim Lemon
Hi Tom,
Or perhaps:

#assume the data frame is named "tadf"
library(prettyR)
stretch_df(tadf,1,2)

Jim


On Thu, Jul 6, 2017 at 6:50 AM, Ista Zahn  wrote:
> The reason it doesn't work easily with reshape/reshape2 is that the
> order of the rows is not determined. Your answer could be
>
>  1957  1958 ...  1985   1986
> 0.8625000 0.750 ... 0.7307692 0.2375
> 0.0733945 0.6435644 ...NA 0.05769231
> 0.5096154NA ...NA 0.65137615
>
> or
>
>  1957  1958 ...  1985   1986
> 0.0733945 0.6435644 ...NA 0.05769231
> 0.8625000 0.750 ... 0.7307692 0.2375
> 0.5096154NA ...NA 0.65137615
>
> or
>
>  1957  1958 ...  1985   1986
> 0.8625000 0.6435644 ...NA 0.2375
> 0.0733945 NA0.7307692 0.05769231
> 0.5096154 0.750 ...NA 0.65137615
>
> or any other combination of orders. You might not care about the
> order, but reshape does.
>
> The usual way around it is to just make up an order variable, e.g.,
> assuming your data.frame is named "example_data" and the columns are
> named "year" and "score":
>
> example_data <- do.call(rbind,
> lapply(split(example_data,
>  example_data$year),
>transform,
>obs = seq_along(year)))
>
> dcast(example_data,
>   obs ~ year,
>   value.var = "score")
>
> Best,
> Ista
>
>
> On Wed, Jul 5, 2017 at 2:16 PM, Thomas Adams  wrote:
>> Hi all:
>>
>> I'm struggling with getting my data re-formatted using functions in
>> reshape/reshape2 to get from:
>>
>> 1957 0.86250
>> 1958 0.75000
>> 1959 0.3
>> 1960 0.28750
>> 1963 0.67500
>> 1964 0.93750
>> 1965 0.02500
>> 1966 0.38750
>> 1969 0.08750
>> 1970 0.27500
>> 1973 0.5
>> 1974 0.36250
>> 1976 0.92500
>> 1978 0.71250
>> 1979 0.33750
>> 1980 0.7
>> 1981 0.42500
>> 1982 0.21250
>> 1983 0.31250
>> 1986 0.23750
>> 1958 0.643564356
>> 1963 0.25000
>> 1968 0.211538462
>> 1976 0.317307692
>> 1981 0.673076923
>> 1985 0.730769231
>> 1986 0.057692308
>> 1957 0.073394495
>> 1966 0.742574257
>> 1961 0.082568807
>> 1964 0.165137615
>> 1965 0.137614679
>> 1959 0.128712871
>> 1968 0.587155963
>> 1969 0.660550459
>> 1970 0.477064220
>> 1971 0.513761468
>> 1973 0.449541284
>> 1974 0.128440367
>> 1968 0.415841584
>> 1977 0.009174312
>> 1979 0.339449541
>> 1981 0.596330275
>> 1982 0.348623853
>> 1984 0.146788991
>> 1986 0.651376147
>> 1959 0.451923077
>> 1965 0.75000
>> 1962 0.326732673
>> 1964 0.782178218
>> 1970 0.336538462
>> 1975 0.277227723
>> 1978 0.712871287
>> 1957 0.509615385
>> 1960 0.490384615
>> 1961 0.721153846
>> 1966 0.298076923
>> 1969 0.413461538
>> 1971 0.5
>> 1972 0.692307692
>> 1974 0.653846154
>> 1984 0.049504950
>> 1978 0.442307692
>> 1973 0.079207921
>> 1983 0.355769231
>> 1984 0.038461538
>> 1979 0.237623762
>> 1982 0.564356436
>>
>> to:
>>
>> 1957  1958   1959 1960 ...
>> 1985   1986
>> 0.509615385  0.75000  0.451923077  0.28750 ...
>> 0.651376147
>> 0.509615385
>>
>> and so on. It's likely the column lengths will be different, so I'm
>> guessing padding with NAs will be needed. I have on the order of 1335 rows
>> with years spanning 1957 to 2016.
>>
>> Thank you...
>> Tom
>>
>> --
>>
>> [[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> 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.
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R] [FORGED] Re: Question about correlation

2017-07-05 Thread Rolf Turner


On 06/07/17 10:23, Jim Lemon wrote:


I think that Goran is right, I didn't take "cor(data)" literally.


See fortune(15).

cheers,

Rolf


--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R] Question about correlation

2017-07-05 Thread Jim Lemon
I think that Goran is right, I didn't take "cor(data)" literally.

Jim


On Thu, Jul 6, 2017 at 3:38 AM, Göran Broström  wrote:
> On 2017-07-05 11:56, Jim Lemon wrote:
>>
>> Hi Chin Yi,
>> If you are trying to correlate "Health" with "Disease", i.e.
>>
>> cydf<-read.table(text="OTU ID Health Disease
>>Bacterial 1 0.29 0.34
>>Bacterial 2 0.25 0.07
>>Bacterial 3 0.06 0.06
>>Bacterial 4 0.07 0.09
>>Bacterial 5 0.02 0.05",
>>header=TRUE)
>> print(cor(cydf$Health,cydf$Disease))
>> [1] 0.7103517
>>
>> If you are getting that error, it probably means that either "Health"
>> or "Disease" or perhaps both have been read in as a factor. To test
>> this:
>>
>> is.factor(cydf$Health)
>> [1] FALSE
>>>
>>> is.factor(cydf$Disease)
>>
>> [1] FALSE
>>
>> If either of these returns TRUE, that is almost certainly the problem.
>
>
> Or maybe Chin Yi tried (as it seems)
>
>> cor(cydf)
> Error in cor(cydf) : 'x' must be numeric
>
> (with cydf == data): 'OTU' is not numeric.
>
> Follow Jim's advice.
>
> Göran
>
>
>>
>> Jim
>>
>>
>> On Wed, Jul 5, 2017 at 11:27 AM, SEB140004 Student
>>  wrote:
>>>
>>> Greeting.
>>>
>>> Dear Mr/Mrs/Miss,
>>>
>>> OTU ID Health Disease
>>> Bacterial 1 0.29 0.34
>>> Bacterial 2 0.25 0.07
>>> Bacterial 3 0.06 0.06
>>> Bacterial 4 0.07 0.09
>>> Bacterial 5 0.02 0.05
>>> Above show the first 6 data sets, may I ask that the reason of R show the
>>> error like "Error in cor(data) : 'x' must be numeric" ? And how to solve
>>> it? Besides, isn't this data can conduct correlation matrix?
>>>
>>> Moreover, isn't this data sets can be plot into network? If can, which
>>> package should I use?
>>>
>>> Thank you.
>>>
>>> Best regards,
>>> Kang Chin Yi
>>>
>>>  [[alternative HTML version deleted]]
>>>
>>> __
>>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>>> 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.
>>
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> 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.
>>
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.

Re: [R] Svyglm Error

2017-07-05 Thread Courtney Benjamin
?Problem solved; I did not have the most updated version of R.  When I updated 
it and ran the code, all worked well again.  Thanks very much for helping me 
solve the mistake of an R novice!



Courtney Benjamin

Broome-Tioga BOCES

Automotive Technology II Teacher

Located at Gault Toyota

Doctoral Candidate-Educational Theory & Practice

State University of New York at Binghamton

cbenj...@btboces.org

607-763-8633


From: Anthony Damico 
Sent: Wednesday, July 5, 2017 3:47 PM
To: Courtney Benjamin
Cc: r-help@r-project.org
Subject: Re: [R] Svyglm Error

hi, i am not hitting an error when i copy and paste your code into a fresh 
console.  maybe compare your sessionInfo() to mine?


> sessionInfo()
R version 3.4.1 (2017-06-30)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows Server 2008 R2 x64 (build 7601) Service Pack 1

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United 
States.1252LC_MONETARY=English_United States.1252 LC_NUMERIC=C  
 LC_TIME=English_United States.1252

attached base packages:
[1] grid  stats graphics  grDevices utils datasets  methods   
base

other attached packages:
[1] survey_3.32-1   survival_2.41-3 Matrix_1.2-10   RCurl_1.95-4.8  
bitops_1.0-6

loaded via a namespace (and not attached):
[1] compiler_3.4.1  splines_3.4.1   lattice_0.20-35





On Wed, Jul 5, 2017 at 2:24 PM, Courtney Benjamin 
> wrote:
Greetings,

I am revisiting code from several different files I have saved from the past 
and all used to run flawlessly; now when I run any of the svyglm related 
functions, I am coming up with an error:

Error in model.frame.default(formula = F3ATTAINB ~ F1PARED, data = data,  :
  the ... list does not contain 4 elements
The following is a minimal reproducible example:
library(RCurl)
library(survey)

data <- 
getURL("https://raw.githubusercontent.com/cbenjamin1821/careertech-ed/master/elsq1adj.csv;)
elsq1ch <- read.csv(text = data)

#Specifying the svyrepdesign object which applies the BRR weights
elsq1ch_brr<-svrepdesign(variables = elsq1ch[,1:16], repweights = 
elsq1ch[,18:217], weights = elsq1ch[,17], combined.weights = TRUE, type = "BRR")
elsq1ch_brr

##Resetting baseline levels for predictors
elsq1ch_brr <- update( elsq1ch_brr , F1HIMATH = relevel(F1HIMATH,"PreAlg or 
Less") )
elsq1ch_brr <- update( elsq1ch_brr , BYINCOME = relevel(BYINCOME,"0-25K") )
elsq1ch_brr <- update( elsq1ch_brr , F1RACE = relevel(F1RACE,"White") )
elsq1ch_brr <- update( elsq1ch_brr , F1SEX = relevel(F1SEX,"Male") )
elsq1ch_brr <- update( elsq1ch_brr , F1RTRCC = relevel(F1RTRCC,"Other") )

##Univariate testing for Other subset
Othpared <- 
svyglm(formula=F3ATTAINB~F1PARED,family="quasibinomial",design=subset(elsq1ch_brr,BYSCTRL==1==1=="Other"),na.action=na.omit)
summary(Othpared)?


Any help in resolving this concern would be greatly appreciated.

Sincerely,

Courtney


Courtney Benjamin

Broome-Tioga BOCES

Automotive Technology II Teacher

Located at Gault Toyota

Doctoral Candidate-Educational Theory & Practice

State University of New York at Binghamton

cbenj...@btboces.org>

607-763-8633

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To 
UNSUBSCRIBE and more, see
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.


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R] Help with reshape/reshape2 needed

2017-07-05 Thread Ista Zahn
The reason it doesn't work easily with reshape/reshape2 is that the
order of the rows is not determined. Your answer could be

 1957  1958 ...  1985   1986
0.8625000 0.750 ... 0.7307692 0.2375
0.0733945 0.6435644 ...NA 0.05769231
0.5096154NA ...NA 0.65137615

or

 1957  1958 ...  1985   1986
0.0733945 0.6435644 ...NA 0.05769231
0.8625000 0.750 ... 0.7307692 0.2375
0.5096154NA ...NA 0.65137615

or

 1957  1958 ...  1985   1986
0.8625000 0.6435644 ...NA 0.2375
0.0733945 NA0.7307692 0.05769231
0.5096154 0.750 ...NA 0.65137615

or any other combination of orders. You might not care about the
order, but reshape does.

The usual way around it is to just make up an order variable, e.g.,
assuming your data.frame is named "example_data" and the columns are
named "year" and "score":

example_data <- do.call(rbind,
lapply(split(example_data,
 example_data$year),
   transform,
   obs = seq_along(year)))

dcast(example_data,
  obs ~ year,
  value.var = "score")

Best,
Ista


On Wed, Jul 5, 2017 at 2:16 PM, Thomas Adams  wrote:
> Hi all:
>
> I'm struggling with getting my data re-formatted using functions in
> reshape/reshape2 to get from:
>
> 1957 0.86250
> 1958 0.75000
> 1959 0.3
> 1960 0.28750
> 1963 0.67500
> 1964 0.93750
> 1965 0.02500
> 1966 0.38750
> 1969 0.08750
> 1970 0.27500
> 1973 0.5
> 1974 0.36250
> 1976 0.92500
> 1978 0.71250
> 1979 0.33750
> 1980 0.7
> 1981 0.42500
> 1982 0.21250
> 1983 0.31250
> 1986 0.23750
> 1958 0.643564356
> 1963 0.25000
> 1968 0.211538462
> 1976 0.317307692
> 1981 0.673076923
> 1985 0.730769231
> 1986 0.057692308
> 1957 0.073394495
> 1966 0.742574257
> 1961 0.082568807
> 1964 0.165137615
> 1965 0.137614679
> 1959 0.128712871
> 1968 0.587155963
> 1969 0.660550459
> 1970 0.477064220
> 1971 0.513761468
> 1973 0.449541284
> 1974 0.128440367
> 1968 0.415841584
> 1977 0.009174312
> 1979 0.339449541
> 1981 0.596330275
> 1982 0.348623853
> 1984 0.146788991
> 1986 0.651376147
> 1959 0.451923077
> 1965 0.75000
> 1962 0.326732673
> 1964 0.782178218
> 1970 0.336538462
> 1975 0.277227723
> 1978 0.712871287
> 1957 0.509615385
> 1960 0.490384615
> 1961 0.721153846
> 1966 0.298076923
> 1969 0.413461538
> 1971 0.5
> 1972 0.692307692
> 1974 0.653846154
> 1984 0.049504950
> 1978 0.442307692
> 1973 0.079207921
> 1983 0.355769231
> 1984 0.038461538
> 1979 0.237623762
> 1982 0.564356436
>
> to:
>
> 1957  1958   1959 1960 ...
> 1985   1986
> 0.509615385  0.75000  0.451923077  0.28750 ...
> 0.651376147
> 0.509615385
>
> and so on. It's likely the column lengths will be different, so I'm
> guessing padding with NAs will be needed. I have on the order of 1335 rows
> with years spanning 1957 to 2016.
>
> Thank you...
> Tom
>
> --
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R] Help with reshape/reshape2 needed

2017-07-05 Thread Thomas Adams
David,

That's just awesome! LOL -- no wonder I couldn't see how the reshape
functions could do this; you saved me MANY days!

Thank you so much!

Best,
Tom

On Wed, Jul 5, 2017 at 3:48 PM, David L Carlson  wrote:

> This does not use reshape/reshape2, but it is pretty straightforward.
> Assuming X is your example data:
>
> > Y <- split(X[, 2], X[, 1])
> > vals <- sapply(Y, length)
> > pad <- max(vals) - vals
> > Y2 <- lapply(seq_along(Y), function(x) c(Y[[x]], rep(NA, pad[x])))
> > names(Y2) <- names(Y)
> > X2 <- do.call(cbind, Y2)
> > X2[, 1:6]
>   1957  1958  1959  1960   1961  1962
> [1,] 0.8625000 0.750 0.300 0.2875000 0.08256881 0.3267327
> [2,] 0.0733945 0.6435644 0.1287129 0.4903846 0.72115385NA
> [3,] 0.5096154NA 0.4519231NA NANA
>
> -
> David L Carlson
> Department of Anthropology
> Texas A University
> College Station, TX 77840-4352
>
> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Thomas
> Adams
> Sent: Wednesday, July 5, 2017 1:17 PM
> To: r-help@r-project.org
> Subject: [R] Help with reshape/reshape2 needed
>
> Hi all:
>
> I'm struggling with getting my data re-formatted using functions in
> reshape/reshape2 to get from:
>
> 1957 0.86250
> 1958 0.75000
> 1959 0.3
> 1960 0.28750
> 1963 0.67500
> 1964 0.93750
> 1965 0.02500
> 1966 0.38750
> 1969 0.08750
> 1970 0.27500
> 1973 0.5
> 1974 0.36250
> 1976 0.92500
> 1978 0.71250
> 1979 0.33750
> 1980 0.7
> 1981 0.42500
> 1982 0.21250
> 1983 0.31250
> 1986 0.23750
> 1958 0.643564356
> 1963 0.25000
> 1968 0.211538462
> 1976 0.317307692
> 1981 0.673076923
> 1985 0.730769231
> 1986 0.057692308
> 1957 0.073394495
> 1966 0.742574257
> 1961 0.082568807
> 1964 0.165137615
> 1965 0.137614679
> 1959 0.128712871
> 1968 0.587155963
> 1969 0.660550459
> 1970 0.477064220
> 1971 0.513761468
> 1973 0.449541284
> 1974 0.128440367
> 1968 0.415841584
> 1977 0.009174312
> 1979 0.339449541
> 1981 0.596330275
> 1982 0.348623853
> 1984 0.146788991
> 1986 0.651376147
> 1959 0.451923077
> 1965 0.75000
> 1962 0.326732673
> 1964 0.782178218
> 1970 0.336538462
> 1975 0.277227723
> 1978 0.712871287
> 1957 0.509615385
> 1960 0.490384615
> 1961 0.721153846
> 1966 0.298076923
> 1969 0.413461538
> 1971 0.5
> 1972 0.692307692
> 1974 0.653846154
> 1984 0.049504950
> 1978 0.442307692
> 1973 0.079207921
> 1983 0.355769231
> 1984 0.038461538
> 1979 0.237623762
> 1982 0.564356436
>
> to:
>
> 1957  1958   1959 1960 ...
> 1985   1986
> 0.509615385  0.75000  0.451923077  0.28750 ...
> 0.651376147
> 0.509615385
>
> and so on. It's likely the column lengths will be different, so I'm
> guessing padding with NAs will be needed. I have on the order of 1335 rows
> with years spanning 1957 to 2016.
>
> Thank you...
> Tom
>
> --
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.
>



-- 
Thomas E Adams, III
1724 Sage Lane
Blacksburg, VA 24060
tea...@gmail.com (personal)
t...@terrapredictions.org (work)

1 (513) 739-9512 (cell)

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


[R] unable to collate and parse R files for package ‘colorspace’

2017-07-05 Thread Kabacoff, Robert
When attempting to install the �colorspace� package on RedHat Linux I get the 
following error. Any help would be appreciated.

Rob

Rob Kabacoff, Ph.D.
Professor, Quantitative Analysis Center
Wesleyan University


> install.packages("colorspace")
Installing package into �/home/rkabacoff/R/x86_64-redhat-linux-gnu-library/3.3�
(as �lib� is unspecified)

trying URL 'https://cran.mtu.edu/src/contrib/colorspace_1.3-2.tar.gz'
Content type 'application/x-gzip' length 293433 bytes (286 KB)
==
downloaded 286 KB

* installing *source* package �colorspace� ...
** package �colorspace� successfully unpacked and MD5 sums checked
** libs
gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG  -I/usr/local/include-fpic  
-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector 
--param=ssp-buffer-size=4 -m64 -mtune=generic -fpic -fPIC   -c colorspace.c -o 
colorspace.o
colorspace.c:589: warning: �CheckGamma� defined but not used
gcc -m64 -std=gnu99 -shared -L/usr/lib64/R/lib -o colorspace.so colorspace.o 
-L/usr/lib64/R/lib -lR
installing to 
/home/rkabacoff/R/x86_64-redhat-linux-gnu-library/3.3/colorspace/libs
** R
Error in parse(outFile) :
  
/home/rkabacoff/R/x86_64-redhat-linux-gnu-library/3.3/colorspace/R/colorspace:2:1:
 unexpected $end
ERROR: unable to collate and parse R files for package �colorspace�
* removing �/home/rkabacoff/R/x86_64-redhat-linux-gnu-library/3.3/colorspace�


> sessionInfo()
R version 3.3.2 (2016-10-31)
Platform: x86_64-redhat-linux-gnu (64-bit)
Running under: Oracle Linux Server 6.8

locale:
[1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8   LC_NAME=C
[9] LC_ADDRESS=C   LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base

loaded via a namespace (and not attached):
[1] tools_3.3.2

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.

Re: [R-es] Deep learning y redes neuronales

2017-07-05 Thread Javier Marcuzzi
Estimados

Esos videos no son de R, sin embargo son recomendables, yo supe mirar algunos, 
incluso la explicación de la teoría de la relatividad está genial, entendible 
casi para todo el mundo (hasta para mí).

Tampoco es R, pero hay una librería ahora desactualizada respecto a otras, lo 
importante no es la librería, sino el libro al respecto donde en mi caso me 
ayudo a comprender sobre redes neuronales y algunas otras cosas, luego es muy 
simple ir a R comprendiendo que es casa cosa. La referencia es 
http://www.heatonresearch.com/encog/ 

Javier Rubén Marcuzzi

De: Jesús Para Fernández
Enviado: miércoles, 5 de julio de 2017 16:44
Para: Xavi tibau alberdi
CC: r-help-es@r-project.org
Asunto: Re: [R-es] Deep learning y redes neuronales

Lo esoty viendo y esta muy bien!!

Gracias!!!



De: Xavi tibau alberdi 
Enviado: mi�rcoles, 5 de julio de 2017 21:24
Para: Jes�s Para Fern�ndez
Cc: r-help-es@r-project.org
Asunto: Re: [R-es] Deep learning y redes neuronales

Buenas,

Aqu� tienes un conjunto de videos, poquitos, donde se explica perfectamente, 
todas las operaciones e incluso el algorithmo de backpropagation.

https://www.youtube.com/watch?v=jaEIv_E29sk
[https://www.bing.com/th?id=OVP.Vib71kNk05vSBxAnnegKnQEsCH=Api]

1.- Redes Neuronales: F�cil y desde 
cero
www.youtube.com
Minicurso de redes neuronales que explica paso a paso la construcci�n de un 
perceptr�n multicapa. Los perceptrones se usan frecuentemente en el �mbito de 
la ...



Espero que se te sea �til.

Saludos,

Xavier

2017-07-05 21:17 GMT+02:00 Jes�s Para Fern�ndez 
>:
Buenas,

He estado leyendo publicaciones sobre las redes neuronales ( y el deep 
learning) pero no consigo entender el tipo de operaciones que se hacen en cada 
una de las capas de las redes neuronales. Necesito alguna explicacion m�s para 
tontos. �Alguien entiende bien lo que hace una red neuronal?

Por ejemplo, un randomForest hace el ensamble por boostrap de �rbole sde 
clasificaci�n. Un SVM crea  hiperplanos separando zonas, y una red neuronal 
hace "operaciones" en las capas, y les va asignando pesos, �pero uqe 
transformaciones?

Gracias!!!


[[alternative HTML version deleted]]


___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


[[alternative HTML version deleted]]



[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es

Re: [R] Help with reshape/reshape2 needed

2017-07-05 Thread David L Carlson
This does not use reshape/reshape2, but it is pretty straightforward. Assuming 
X is your example data:

> Y <- split(X[, 2], X[, 1])
> vals <- sapply(Y, length)
> pad <- max(vals) - vals
> Y2 <- lapply(seq_along(Y), function(x) c(Y[[x]], rep(NA, pad[x])))
> names(Y2) <- names(Y)
> X2 <- do.call(cbind, Y2)
> X2[, 1:6]
  1957  1958  1959  1960   1961  1962
[1,] 0.8625000 0.750 0.300 0.2875000 0.08256881 0.3267327
[2,] 0.0733945 0.6435644 0.1287129 0.4903846 0.72115385NA
[3,] 0.5096154NA 0.4519231NA NANA

-
David L Carlson
Department of Anthropology
Texas A University
College Station, TX 77840-4352

-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Thomas Adams
Sent: Wednesday, July 5, 2017 1:17 PM
To: r-help@r-project.org
Subject: [R] Help with reshape/reshape2 needed

Hi all:

I'm struggling with getting my data re-formatted using functions in
reshape/reshape2 to get from:

1957 0.86250
1958 0.75000
1959 0.3
1960 0.28750
1963 0.67500
1964 0.93750
1965 0.02500
1966 0.38750
1969 0.08750
1970 0.27500
1973 0.5
1974 0.36250
1976 0.92500
1978 0.71250
1979 0.33750
1980 0.7
1981 0.42500
1982 0.21250
1983 0.31250
1986 0.23750
1958 0.643564356
1963 0.25000
1968 0.211538462
1976 0.317307692
1981 0.673076923
1985 0.730769231
1986 0.057692308
1957 0.073394495
1966 0.742574257
1961 0.082568807
1964 0.165137615
1965 0.137614679
1959 0.128712871
1968 0.587155963
1969 0.660550459
1970 0.477064220
1971 0.513761468
1973 0.449541284
1974 0.128440367
1968 0.415841584
1977 0.009174312
1979 0.339449541
1981 0.596330275
1982 0.348623853
1984 0.146788991
1986 0.651376147
1959 0.451923077
1965 0.75000
1962 0.326732673
1964 0.782178218
1970 0.336538462
1975 0.277227723
1978 0.712871287
1957 0.509615385
1960 0.490384615
1961 0.721153846
1966 0.298076923
1969 0.413461538
1971 0.5
1972 0.692307692
1974 0.653846154
1984 0.049504950
1978 0.442307692
1973 0.079207921
1983 0.355769231
1984 0.038461538
1979 0.237623762
1982 0.564356436

to:

1957  1958   1959 1960 ...
1985   1986
0.509615385  0.75000  0.451923077  0.28750 ...
0.651376147
0.509615385

and so on. It's likely the column lengths will be different, so I'm
guessing padding with NAs will be needed. I have on the order of 1335 rows
with years spanning 1957 to 2016.

Thank you...
Tom

--

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R] Svyglm Error

2017-07-05 Thread Anthony Damico
hi, i am not hitting an error when i copy and paste your code into a fresh
console.  maybe compare your sessionInfo() to mine?


> sessionInfo()
R version 3.4.1 (2017-06-30)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows Server 2008 R2 x64 (build 7601) Service Pack 1

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United
States.1252LC_MONETARY=English_United States.1252
LC_NUMERIC=C   LC_TIME=English_United
States.1252

attached base packages:
[1] grid  stats graphics  grDevices utils datasets
methods   base

other attached packages:
[1] survey_3.32-1   survival_2.41-3 Matrix_1.2-10   RCurl_1.95-4.8
bitops_1.0-6

loaded via a namespace (and not attached):
[1] compiler_3.4.1  splines_3.4.1   lattice_0.20-35





On Wed, Jul 5, 2017 at 2:24 PM, Courtney Benjamin 
wrote:

> Greetings,
>
> I am revisiting code from several different files I have saved from the
> past and all used to run flawlessly; now when I run any of the svyglm
> related functions, I am coming up with an error:
>
> Error in model.frame.default(formula = F3ATTAINB ~ F1PARED, data = data,  :
>   the ... list does not contain 4 elements
> The following is a minimal reproducible example:
> library(RCurl)
> library(survey)
>
> data <- getURL("https://raw.githubusercontent.com/
> cbenjamin1821/careertech-ed/master/elsq1adj.csv")
> elsq1ch <- read.csv(text = data)
>
> #Specifying the svyrepdesign object which applies the BRR weights
> elsq1ch_brr<-svrepdesign(variables = elsq1ch[,1:16], repweights =
> elsq1ch[,18:217], weights = elsq1ch[,17], combined.weights = TRUE, type =
> "BRR")
> elsq1ch_brr
>
> ##Resetting baseline levels for predictors
> elsq1ch_brr <- update( elsq1ch_brr , F1HIMATH = relevel(F1HIMATH,"PreAlg
> or Less") )
> elsq1ch_brr <- update( elsq1ch_brr , BYINCOME = relevel(BYINCOME,"0-25K") )
> elsq1ch_brr <- update( elsq1ch_brr , F1RACE = relevel(F1RACE,"White") )
> elsq1ch_brr <- update( elsq1ch_brr , F1SEX = relevel(F1SEX,"Male") )
> elsq1ch_brr <- update( elsq1ch_brr , F1RTRCC = relevel(F1RTRCC,"Other") )
>
> ##Univariate testing for Other subset
> Othpared <- svyglm(formula=F3ATTAINB~F1PARED,family="quasibinomial"
> ,design=subset(elsq1ch_brr,BYSCTRL==1==1&
> F1RTRCC=="Other"),na.action=na.omit)
> summary(Othpared)?
>
>
> Any help in resolving this concern would be greatly appreciated.
>
> Sincerely,
>
> Courtney
>
>
> Courtney Benjamin
>
> Broome-Tioga BOCES
>
> Automotive Technology II Teacher
>
> Located at Gault Toyota
>
> Doctoral Candidate-Educational Theory & Practice
>
> State University of New York at Binghamton
>
> cbenj...@btboces.org
>
> 607-763-8633
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R-es] Deep learning y redes neuronales

2017-07-05 Thread Jesús Para Fernández
Lo esoty viendo y esta muy bien!!

Gracias!!!



De: Xavi tibau alberdi 
Enviado: mi�rcoles, 5 de julio de 2017 21:24
Para: Jes�s Para Fern�ndez
Cc: r-help-es@r-project.org
Asunto: Re: [R-es] Deep learning y redes neuronales

Buenas,

Aqu� tienes un conjunto de videos, poquitos, donde se explica perfectamente, 
todas las operaciones e incluso el algorithmo de backpropagation.

https://www.youtube.com/watch?v=jaEIv_E29sk
[https://www.bing.com/th?id=OVP.Vib71kNk05vSBxAnnegKnQEsCH=Api]

1.- Redes Neuronales: F�cil y desde 
cero
www.youtube.com
Minicurso de redes neuronales que explica paso a paso la construcci�n de un 
perceptr�n multicapa. Los perceptrones se usan frecuentemente en el �mbito de 
la ...



Espero que se te sea �til.

Saludos,

Xavier

2017-07-05 21:17 GMT+02:00 Jes�s Para Fern�ndez 
>:
Buenas,

He estado leyendo publicaciones sobre las redes neuronales ( y el deep 
learning) pero no consigo entender el tipo de operaciones que se hacen en cada 
una de las capas de las redes neuronales. Necesito alguna explicacion m�s para 
tontos. �Alguien entiende bien lo que hace una red neuronal?

Por ejemplo, un randomForest hace el ensamble por boostrap de �rbole sde 
clasificaci�n. Un SVM crea  hiperplanos separando zonas, y una red neuronal 
hace "operaciones" en las capas, y les va asignando pesos, �pero uqe 
transformaciones?

Gracias!!!


[[alternative HTML version deleted]]


___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es

Re: [R-es] Deep learning y redes neuronales

2017-07-05 Thread Xavi tibau alberdi
Buenas,

Aquí tienes un conjunto de videos, poquitos, donde se explica
perfectamente, todas las operaciones e incluso el algorithmo de
backpropagation.

https://www.youtube.com/watch?v=jaEIv_E29sk

Espero que se te sea útil.

Saludos,

Xavier

2017-07-05 21:17 GMT+02:00 Jesús Para Fernández <
j.para.fernan...@hotmail.com>:

> Buenas,
>
> He estado leyendo publicaciones sobre las redes neuronales ( y el deep
> learning) pero no consigo entender el tipo de operaciones que se hacen en
> cada una de las capas de las redes neuronales. Necesito alguna explicacion
> más para tontos. ¿Alguien entiende bien lo que hace una red neuronal?
>
> Por ejemplo, un randomForest hace el ensamble por boostrap de árbole sde
> clasificación. Un SVM crea  hiperplanos separando zonas, y una red neuronal
> hace "operaciones" en las capas, y les va asignando pesos, ¿pero uqe
> transformaciones?
>
> Gracias!!!
>
>
> [[alternative HTML version deleted]]
>
>
> ___
> R-help-es mailing list
> R-help-es@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-es
>

[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


Re: [R] Convert date to continuous variable in R

2017-07-05 Thread David L Carlson
How about

> difftime(LAI_simulation$Date, LAI_simulation$Date[1], units="days")
Time differences in days
 [1]  0  1  2  3  4  5  6  7  8  9 10 11 12 13

-
David L Carlson
Department of Anthropology
Texas A University
College Station, TX 77840-4352

-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Ahmed Attia
Sent: Wednesday, July 5, 2017 1:24 PM
To: r-help 
Subject: [R] Convert date to continuous variable in R

How can I convert date to continuous variable staring from 1. I tried
as.numeric but R starts counting from default January 1, 1970 while my data
start Oct 7, 2009.

I need to do this conversion to plot the date on two x-axes (1 and 3).
Ex;
Date LAI
10/7/2009 0
10/8/2009 0.004173
10/9/2009 0.009997
10/10/2009 0.009998
10/11/2009 0.00
10/12/2009 0.00
10/13/2009 0.00
10/14/2009 0.00
10/15/2009 0.009998
10/16/2009 0.009998
10/17/2009 0.009998
10/18/2009 0.009998
10/19/2009 0.009998
10/20/2009 0.009998

LAI_simulation$Date <- as.Date( LAI_simulation$Date, '%Y/%m/%d')
plot(LAI~Date, data=LAI_simulation)
LAI_simulation$Date<- as.numeric(LAI_simulation$Date,origin="2009-10-07")
#R does not see the origin
axis.Date(side=3,at=LAI_simulation$Date)




Ahmed Attia, Ph.D.
Agronomist & Soil Scientist

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


[R] Svyglm Error

2017-07-05 Thread Courtney Benjamin
Greetings,

I am revisiting code from several different files I have saved from the past 
and all used to run flawlessly; now when I run any of the svyglm related 
functions, I am coming up with an error:

Error in model.frame.default(formula = F3ATTAINB ~ F1PARED, data = data,  :
  the ... list does not contain 4 elements
The following is a minimal reproducible example:
library(RCurl)
library(survey)

data <- 
getURL("https://raw.githubusercontent.com/cbenjamin1821/careertech-ed/master/elsq1adj.csv;)
elsq1ch <- read.csv(text = data)

#Specifying the svyrepdesign object which applies the BRR weights
elsq1ch_brr<-svrepdesign(variables = elsq1ch[,1:16], repweights = 
elsq1ch[,18:217], weights = elsq1ch[,17], combined.weights = TRUE, type = "BRR")
elsq1ch_brr

##Resetting baseline levels for predictors
elsq1ch_brr <- update( elsq1ch_brr , F1HIMATH = relevel(F1HIMATH,"PreAlg or 
Less") )
elsq1ch_brr <- update( elsq1ch_brr , BYINCOME = relevel(BYINCOME,"0-25K") )
elsq1ch_brr <- update( elsq1ch_brr , F1RACE = relevel(F1RACE,"White") )
elsq1ch_brr <- update( elsq1ch_brr , F1SEX = relevel(F1SEX,"Male") )
elsq1ch_brr <- update( elsq1ch_brr , F1RTRCC = relevel(F1RTRCC,"Other") )

##Univariate testing for Other subset
Othpared <- 
svyglm(formula=F3ATTAINB~F1PARED,family="quasibinomial",design=subset(elsq1ch_brr,BYSCTRL==1==1=="Other"),na.action=na.omit)
summary(Othpared)?


Any help in resolving this concern would be greatly appreciated.

Sincerely,

Courtney


Courtney Benjamin

Broome-Tioga BOCES

Automotive Technology II Teacher

Located at Gault Toyota

Doctoral Candidate-Educational Theory & Practice

State University of New York at Binghamton

cbenj...@btboces.org

607-763-8633

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


[R] Convert date to continuous variable in R

2017-07-05 Thread Ahmed Attia
How can I convert date to continuous variable staring from 1. I tried
as.numeric but R starts counting from default January 1, 1970 while my data
start Oct 7, 2009.

I need to do this conversion to plot the date on two x-axes (1 and 3).
Ex;
Date LAI
10/7/2009 0
10/8/2009 0.004173
10/9/2009 0.009997
10/10/2009 0.009998
10/11/2009 0.00
10/12/2009 0.00
10/13/2009 0.00
10/14/2009 0.00
10/15/2009 0.009998
10/16/2009 0.009998
10/17/2009 0.009998
10/18/2009 0.009998
10/19/2009 0.009998
10/20/2009 0.009998

LAI_simulation$Date <- as.Date( LAI_simulation$Date, '%Y/%m/%d')
plot(LAI~Date, data=LAI_simulation)
LAI_simulation$Date<- as.numeric(LAI_simulation$Date,origin="2009-10-07")
#R does not see the origin
axis.Date(side=3,at=LAI_simulation$Date)




Ahmed Attia, Ph.D.
Agronomist & Soil Scientist

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


[R] Help with reshape/reshape2 needed

2017-07-05 Thread Thomas Adams
Hi all:

I'm struggling with getting my data re-formatted using functions in
reshape/reshape2 to get from:

1957 0.86250
1958 0.75000
1959 0.3
1960 0.28750
1963 0.67500
1964 0.93750
1965 0.02500
1966 0.38750
1969 0.08750
1970 0.27500
1973 0.5
1974 0.36250
1976 0.92500
1978 0.71250
1979 0.33750
1980 0.7
1981 0.42500
1982 0.21250
1983 0.31250
1986 0.23750
1958 0.643564356
1963 0.25000
1968 0.211538462
1976 0.317307692
1981 0.673076923
1985 0.730769231
1986 0.057692308
1957 0.073394495
1966 0.742574257
1961 0.082568807
1964 0.165137615
1965 0.137614679
1959 0.128712871
1968 0.587155963
1969 0.660550459
1970 0.477064220
1971 0.513761468
1973 0.449541284
1974 0.128440367
1968 0.415841584
1977 0.009174312
1979 0.339449541
1981 0.596330275
1982 0.348623853
1984 0.146788991
1986 0.651376147
1959 0.451923077
1965 0.75000
1962 0.326732673
1964 0.782178218
1970 0.336538462
1975 0.277227723
1978 0.712871287
1957 0.509615385
1960 0.490384615
1961 0.721153846
1966 0.298076923
1969 0.413461538
1971 0.5
1972 0.692307692
1974 0.653846154
1984 0.049504950
1978 0.442307692
1973 0.079207921
1983 0.355769231
1984 0.038461538
1979 0.237623762
1982 0.564356436

to:

1957  1958   1959 1960 ...
1985   1986
0.509615385  0.75000  0.451923077  0.28750 ...
0.651376147
0.509615385

and so on. It's likely the column lengths will be different, so I'm
guessing padding with NAs will be needed. I have on the order of 1335 rows
with years spanning 1957 to 2016.

Thank you...
Tom

--

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R] Question about correlation

2017-07-05 Thread Göran Broström

On 2017-07-05 11:56, Jim Lemon wrote:

Hi Chin Yi,
If you are trying to correlate "Health" with "Disease", i.e.

cydf<-read.table(text="OTU ID Health Disease
   Bacterial 1 0.29 0.34
   Bacterial 2 0.25 0.07
   Bacterial 3 0.06 0.06
   Bacterial 4 0.07 0.09
   Bacterial 5 0.02 0.05",
   header=TRUE)
print(cor(cydf$Health,cydf$Disease))
[1] 0.7103517

If you are getting that error, it probably means that either "Health"
or "Disease" or perhaps both have been read in as a factor. To test
this:

is.factor(cydf$Health)
[1] FALSE

is.factor(cydf$Disease)

[1] FALSE

If either of these returns TRUE, that is almost certainly the problem.


Or maybe Chin Yi tried (as it seems)

> cor(cydf)
Error in cor(cydf) : 'x' must be numeric

(with cydf == data): 'OTU' is not numeric.

Follow Jim's advice.

Göran



Jim


On Wed, Jul 5, 2017 at 11:27 AM, SEB140004 Student
 wrote:

Greeting.

Dear Mr/Mrs/Miss,

OTU ID Health Disease
Bacterial 1 0.29 0.34
Bacterial 2 0.25 0.07
Bacterial 3 0.06 0.06
Bacterial 4 0.07 0.09
Bacterial 5 0.02 0.05
Above show the first 6 data sets, may I ask that the reason of R show the
error like "Error in cor(data) : 'x' must be numeric" ? And how to solve
it? Besides, isn't this data can conduct correlation matrix?

Moreover, isn't this data sets can be plot into network? If can, which
package should I use?

Thank you.

Best regards,
Kang Chin Yi

 [[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.



__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.

Re: [R] Please help(urgent) - How to simulate transactional data for reliability/survival analysis

2017-07-05 Thread Mark Sharp
I am trying to figure out the algorithm you are using to calculate 
event_episodes, event_status, and start_minutes.

Where does the 129600 come from?

Why is the start(minutes) 0 for the last row instead of 40?

Mark
R. Mark Sharp, Ph.D.
msh...@txbiomed.org





> On Jul 5, 2017, at 1:03 AM, Sunny Singha  
> wrote:
>
> Mark,
> Below is the sampled simulated granular data format for pumps for
> trial period of 3 months that I need to transform for survival
> analysis:
> 3 months = (60*24*90) minutes i.e 129600 minutes
>
> pump_id timingsevents   vibration temprature flow
> pump1 01-07-2017 00:00   03.44369.6   139.806
> pump1 01-07-2017 00:10   10.50145.27 140.028
> pump1 01-07-2017 00:20   02.03152.9   137.698
> pump1 01-07-2017 00:30   02.26760.12 139.054
> pump1 01-07-2017 00:40   12.26760.12 139.054
> pump1 01-07-2017 00:50   02.26760.12 139.054
> pump2 01-07-2017 00:00   03.44369.6   139.806
> pump2 01-07-2017 00:10   00.50145.27 140.028
> pump2 01-07-2017 00:20   02.03152.9   137.698
> pump2 01-07-2017 00:30   02.26760.12 139.054
> pump2 01-07-2017 00:40   12.26760.12 139.054
> pump2 01-07-2017 00:50   02.26760.12 139.054
>
> The above data set records observations and timings where 'pumps'
> experienced failure, tagged as '1' in column 'events'.
> In the above granular dataset the pump1 experiences 2 "event episodes."
>
> Below is the desired transformed format. the covariates in this data
> set will have the mean value:
> pump_id  event_episodes  event_status  start(minutes)
> stop(minutes)
> pump1  1 1
>  0   10
> pump1  2 1
> 10  40
> pump1  3 0
> 40  129600
> pump2  1 1
>  0   40
> pump2  2 0
>  0   129600
> .
> .
>
> The 'start' and 'stop' columns are evaluated from the 'timings'
> columns. I need help in performing such transformation in 'R'.
> Please guide and help.
>
> Regards,
> Sandeep
>
> On Wed, Jul 5, 2017 at 7:26 AM, Mark Sharp  wrote:
>> A small example data set that illustrates your question will be of great 
>> value to those trying to help. This appears to be a transformation that you 
>> are wanting to do (timestamp to units of time) so a data representing what 
>> you have (dput() is handy for this) and one representing what you want to 
>> have with any guidance regarding how to use the other columns in you data 
>> set (e.g., the event(0/1)).
>>
>> Mark
>> R. Mark Sharp, Ph.D.
>> msh...@txbiomed.org
>>
>>
>>
>>
>>
>>> On Jul 4, 2017, at 7:02 AM, Sunny Singha  
>>> wrote:
>>>
>>> Thanks Boris and Bret,
>>> I was successful in simulating granular/transactional data.
>>> Now I need some guidance to transform the same data in format acceptable
>>> for survival analysis i.e below format:
>>>
>>> pump_id | event_episode_no. | event(0/1) | start | stop | time_to_dropout
>>>
>>> The challenge I'm experience is to generate the 'start' and 'stop' in units
>>> of minutes/days from single column of 'Timestamp' which is
>>> the column from transactional/granular data based on condition tagged in
>>> separate column, 'event 0/1, (i.e event ).
>>>
>>> Please guide how to do such transformation in 'R'.
>>>
>>> Regards,
>>> Sandeep
>>>
>>>
>>>
>>> On Wed, Jun 28, 2017 at 2:51 PM, Boris Steipe 
>>> wrote:
>>>
 In principle what you need to do is the following:

 - break down the time you wish to simulate into intervals.
 - for each interval, and each failure mode, determine the probability of
 an event.
  Determining the probability is the fun part, where you make your domain
  knowledge explicit and include all the factors into your model:
 cumulative load,
  failure history, pressure, temperature, phase of the moon ...
 - once you have a probability of failure, use the runif() function to
 give you
  a uniformly distributed random number in [0, 1]. If the number is
 smaller than
  your failure probability, accept the failure event, and record it.
 - Repeat many times.

 Hope this helps.
 B.




> On Jun 27, 2017, at 10:58 AM, sandeep Rana  wrote:
>
> Hi friends,
> I haven't done such a simulation 

Re: [R] expand gridded matrix to higher resolution

2017-07-05 Thread Jeff Newmiller
You probably ought to be using the raster package. See the CRAN Spatial Task 
View.
-- 
Sent from my phone. Please excuse my brevity.

On July 5, 2017 12:20:28 AM PDT, "Anthoni, Peter (IMK)"  
wrote:
>Hi all,
>(if me email goes out as html, than my email client don't do as told,
>and I apologies already.)
>
>We need to downscale climate data and therefore first need to expand
>the climate from 0.5deg to the higher resolution 10min, before we can
>add high resolution deviations. We basically need to have the original
>data at each gridcell replicated into 3x3 gridcells. 
>A simple for loop can do this, but I could need a faster procedure.
>Anybody know a faster way? Is there package than can do what we need
>already?
>I tried matrix with rep, but I am missing some magic there, since it
>doesn't do what we need. 
>replicate might be promising, but then still need to rearrange the
>output into the column and row format we need. 
>
>A simple example:
>mm=matrix(1:15,nrow=3,byrow = T)
>xmm=matrix(NA,nrow=nrow(mm)*3,ncol=ncol(mm)*3)
>for(icol in 1:ncol(mm)) {
>  for(irow in 1:nrow(mm)) {
>xicol=(icol-1)*3 +c(1:3)
>xirow=(irow-1)*3 +c(1:3)
>xmm[xirow,xicol]=mm[irow,icol]
>  }
>}
>mm
>> > mm
>>  [,1] [,2] [,3] [,4] [,5]
>> [1,]12345
>> [2,]6789   10
>> [3,]   11   12   13   14   15
>> 
>xmm
>> > xmm
>>   [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12]
>[,13] [,14] [,15]
>>  [1,]111222333 4 4 4 
>   5 5 5
>>  [2,]111222333 4 4 4 
>   5 5 5
>>  [3,]111222333 4 4 4 
>   5 5 5
>>  [4,]666777888 9 9 9 
>  101010
>>  [5,]666777888 9 9 9 
>  101010
>>  [6,]666777888 9 9 9 
>  101010
>>  [7,]   11   11   11   12   12   12   13   13   13141414 
>  151515
>>  [8,]   11   11   11   12   12   12   13   13   13141414 
>  151515
>>  [9,]   11   11   11   12   12   12   13   13   13141414 
>  151515
>
>I tried various rep with matrix, but don't get the right result.
>xmm2=matrix(rep(rep(mm,each=3),times=3),nrow=nrow(mm)*3,ncol=ncol(mm)*3,byrow
>= F)
>> identical(xmm,xmm2)
>[1] FALSE
>
>rr=replicate(3,rep(t(mm),each=3))
>rr
>> > rr
>>   [,1] [,2] [,3]
>>  [1,]111
>>  [2,]111
>>  [3,]111
>>  [4,]222
>>  [5,]222
>>  [6,]222
>>  [7,]333
>> ...
>identical(xmm,matrix(rr,ncol=15,nrow=9,byrow=T))
>> > identical(xmm,matrix(rr,ncol=15,nrow=9,byrow=T))
>> [1] FALSE
> 
>Many thanks for any advice.
>
>cheers
>Peter
>
>__
>R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>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.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R] Please help(urgent) - How to simulate transactional data for reliability/survival analysis

2017-07-05 Thread Bert Gunter
Strictly speaking, this is reliability, not survival, data, since
failed pumps are apparently repaired and put back in service as new.
Also, it is not clear from your data whether there is interval
censoring: is the recorded "event" time (failure) the actual failure
time -- so no censoring -- or the time at which the pump has been
discovered to have failed, so that it is known to have failed in the
interval since the last time it was recorded, but exactly when is
unknown. Presumably there is also standard right censoring -- the pump
is still running when the testing period concludes.

Cheers,
Bert


Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Tue, Jul 4, 2017 at 11:03 PM, Sunny Singha
 wrote:
> Mark,
> Below is the sampled simulated granular data format for pumps for
> trial period of 3 months that I need to transform for survival
> analysis:
> 3 months = (60*24*90) minutes i.e 129600 minutes
>
> pump_id timingsevents   vibration temprature flow
> pump1 01-07-2017 00:00   03.44369.6   139.806
> pump1 01-07-2017 00:10   10.50145.27 140.028
> pump1 01-07-2017 00:20   02.03152.9   137.698
> pump1 01-07-2017 00:30   02.26760.12 139.054
> pump1 01-07-2017 00:40   12.26760.12 139.054
> pump1 01-07-2017 00:50   02.26760.12 139.054
> pump2 01-07-2017 00:00   03.44369.6   139.806
> pump2 01-07-2017 00:10   00.50145.27 140.028
> pump2 01-07-2017 00:20   02.03152.9   137.698
> pump2 01-07-2017 00:30   02.26760.12 139.054
> pump2 01-07-2017 00:40   12.26760.12 139.054
> pump2 01-07-2017 00:50   02.26760.12 139.054
>
> The above data set records observations and timings where 'pumps'
> experienced failure, tagged as '1' in column 'events'.
> In the above granular dataset the pump1 experiences 2 "event episodes."
>
> Below is the desired transformed format. the covariates in this data
> set will have the mean value:
> pump_id  event_episodes  event_status  start(minutes)
> stop(minutes)
> pump1  1 1
>   0   10
> pump1  2 1
>  10  40
> pump1  3 0
>  40  129600
> pump2  1 1
>   0   40
> pump2  2 0
>   0   129600
> .
> .
>
> The 'start' and 'stop' columns are evaluated from the 'timings'
> columns. I need help in performing such transformation in 'R'.
> Please guide and help.
>
> Regards,
> Sandeep
>
> On Wed, Jul 5, 2017 at 7:26 AM, Mark Sharp  wrote:
>> A small example data set that illustrates your question will be of great 
>> value to those trying to help. This appears to be a transformation that you 
>> are wanting to do (timestamp to units of time) so a data representing what 
>> you have (dput() is handy for this) and one representing what you want to 
>> have with any guidance regarding how to use the other columns in you data 
>> set (e.g., the event(0/1)).
>>
>> Mark
>> R. Mark Sharp, Ph.D.
>> msh...@txbiomed.org
>>
>>
>>
>>
>>
>>> On Jul 4, 2017, at 7:02 AM, Sunny Singha  
>>> wrote:
>>>
>>> Thanks Boris and Bret,
>>> I was successful in simulating granular/transactional data.
>>> Now I need some guidance to transform the same data in format acceptable
>>> for survival analysis i.e below format:
>>>
>>> pump_id | event_episode_no. | event(0/1) | start | stop | time_to_dropout
>>>
>>> The challenge I'm experience is to generate the 'start' and 'stop' in units
>>> of minutes/days from single column of 'Timestamp' which is
>>> the column from transactional/granular data based on condition tagged in
>>> separate column, 'event 0/1, (i.e event ).
>>>
>>> Please guide how to do such transformation in 'R'.
>>>
>>> Regards,
>>> Sandeep
>>>
>>>
>>>
>>> On Wed, Jun 28, 2017 at 2:51 PM, Boris Steipe 
>>> wrote:
>>>
 In principle what you need to do is the following:

 - break down the time you wish to simulate into intervals.
 - for each interval, and each failure mode, determine the probability of
 an event.
   Determining the probability is the fun part, where you make your domain
   knowledge explicit and include all the factors into your model:
 cumulative load,
   failure 

Re: [R] expand gridded matrix to higher resolution

2017-07-05 Thread Anthoni, Peter (IMK)
Hi Jim,

thanks that works like a charm.  

cheers
Peter



> On 5. Jul 2017, at 12:01, Jim Lemon  wrote:
> 
> Hi Peter,
> 
> apply(t(apply(mm,1,rep,each=3)),2,rep,each=3)
> 
> Jim
> 
> On Wed, Jul 5, 2017 at 5:20 PM, Anthoni, Peter (IMK)
>  wrote:
>> Hi all,
>> (if me email goes out as html, than my email client don't do as told, and I 
>> apologies already.)
>> 
>> We need to downscale climate data and therefore first need to expand the 
>> climate from 0.5deg to the higher resolution 10min, before we can add high 
>> resolution deviations. We basically need to have the original data at each 
>> gridcell replicated into 3x3 gridcells.
>> A simple for loop can do this, but I could need a faster procedure. Anybody 
>> know a faster way? Is there package than can do what we need already?
>> I tried matrix with rep, but I am missing some magic there, since it doesn't 
>> do what we need.
>> replicate might be promising, but then still need to rearrange the output 
>> into the column and row format we need.
>> 
>> A simple example:
>> mm=matrix(1:15,nrow=3,byrow = T)
>> xmm=matrix(NA,nrow=nrow(mm)*3,ncol=ncol(mm)*3)
>> for(icol in 1:ncol(mm)) {
>>  for(irow in 1:nrow(mm)) {
>>xicol=(icol-1)*3 +c(1:3)
>>xirow=(irow-1)*3 +c(1:3)
>>xmm[xirow,xicol]=mm[irow,icol]
>>  }
>> }
>> mm
 mm
>>> [,1] [,2] [,3] [,4] [,5]
>>> [1,]12345
>>> [2,]6789   10
>>> [3,]   11   12   13   14   15
>>> 
>> xmm
 xmm
>>>  [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] 
>>> [,14] [,15]
>>> [1,]111222333 4 4 4 5   
>>>   5 5
>>> [2,]111222333 4 4 4 5   
>>>   5 5
>>> [3,]111222333 4 4 4 5   
>>>   5 5
>>> [4,]666777888 9 9 910   
>>>  1010
>>> [5,]666777888 9 9 910   
>>>  1010
>>> [6,]666777888 9 9 910   
>>>  1010
>>> [7,]   11   11   11   12   12   12   13   13   1314141415   
>>>  1515
>>> [8,]   11   11   11   12   12   12   13   13   1314141415   
>>>  1515
>>> [9,]   11   11   11   12   12   12   13   13   1314141415   
>>>  1515
>> 
>> I tried various rep with matrix, but don't get the right result.
>> xmm2=matrix(rep(rep(mm,each=3),times=3),nrow=nrow(mm)*3,ncol=ncol(mm)*3,byrow
>>  = F)
>>> identical(xmm,xmm2)
>> [1] FALSE
>> 
>> rr=replicate(3,rep(t(mm),each=3))
>> rr
 rr
>>>  [,1] [,2] [,3]
>>> [1,]111
>>> [2,]111
>>> [3,]111
>>> [4,]222
>>> [5,]222
>>> [6,]222
>>> [7,]333
>>> ...
>> identical(xmm,matrix(rr,ncol=15,nrow=9,byrow=T))
 identical(xmm,matrix(rr,ncol=15,nrow=9,byrow=T))
>>> [1] FALSE
>> 
>> Many thanks for any advice.
>> 
>> cheers
>> Peter
>> 
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> 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.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R] expand gridded matrix to higher resolution

2017-07-05 Thread Jim Lemon
Hi Peter,

apply(t(apply(mm,1,rep,each=3)),2,rep,each=3)

Jim

On Wed, Jul 5, 2017 at 5:20 PM, Anthoni, Peter (IMK)
 wrote:
> Hi all,
> (if me email goes out as html, than my email client don't do as told, and I 
> apologies already.)
>
> We need to downscale climate data and therefore first need to expand the 
> climate from 0.5deg to the higher resolution 10min, before we can add high 
> resolution deviations. We basically need to have the original data at each 
> gridcell replicated into 3x3 gridcells.
> A simple for loop can do this, but I could need a faster procedure. Anybody 
> know a faster way? Is there package than can do what we need already?
> I tried matrix with rep, but I am missing some magic there, since it doesn't 
> do what we need.
> replicate might be promising, but then still need to rearrange the output 
> into the column and row format we need.
>
> A simple example:
> mm=matrix(1:15,nrow=3,byrow = T)
> xmm=matrix(NA,nrow=nrow(mm)*3,ncol=ncol(mm)*3)
> for(icol in 1:ncol(mm)) {
>   for(irow in 1:nrow(mm)) {
> xicol=(icol-1)*3 +c(1:3)
> xirow=(irow-1)*3 +c(1:3)
> xmm[xirow,xicol]=mm[irow,icol]
>   }
> }
> mm
>> > mm
>>  [,1] [,2] [,3] [,4] [,5]
>> [1,]12345
>> [2,]6789   10
>> [3,]   11   12   13   14   15
>>
> xmm
>> > xmm
>>   [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] 
>> [,14] [,15]
>>  [1,]111222333 4 4 4 5   
>>   5 5
>>  [2,]111222333 4 4 4 5   
>>   5 5
>>  [3,]111222333 4 4 4 5   
>>   5 5
>>  [4,]666777888 9 9 910   
>>  1010
>>  [5,]666777888 9 9 910   
>>  1010
>>  [6,]666777888 9 9 910   
>>  1010
>>  [7,]   11   11   11   12   12   12   13   13   1314141415   
>>  1515
>>  [8,]   11   11   11   12   12   12   13   13   1314141415   
>>  1515
>>  [9,]   11   11   11   12   12   12   13   13   1314141415   
>>  1515
>
> I tried various rep with matrix, but don't get the right result.
> xmm2=matrix(rep(rep(mm,each=3),times=3),nrow=nrow(mm)*3,ncol=ncol(mm)*3,byrow 
> = F)
>> identical(xmm,xmm2)
> [1] FALSE
>
> rr=replicate(3,rep(t(mm),each=3))
> rr
>> > rr
>>   [,1] [,2] [,3]
>>  [1,]111
>>  [2,]111
>>  [3,]111
>>  [4,]222
>>  [5,]222
>>  [6,]222
>>  [7,]333
>> ...
> identical(xmm,matrix(rr,ncol=15,nrow=9,byrow=T))
>> > identical(xmm,matrix(rr,ncol=15,nrow=9,byrow=T))
>> [1] FALSE
>
> Many thanks for any advice.
>
> cheers
> Peter
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R] Question about correlation

2017-07-05 Thread Jim Lemon
Hi Chin Yi,
If you are trying to correlate "Health" with "Disease", i.e.

cydf<-read.table(text="OTU ID Health Disease
  Bacterial 1 0.29 0.34
  Bacterial 2 0.25 0.07
  Bacterial 3 0.06 0.06
  Bacterial 4 0.07 0.09
  Bacterial 5 0.02 0.05",
  header=TRUE)
print(cor(cydf$Health,cydf$Disease))
[1] 0.7103517

If you are getting that error, it probably means that either "Health"
or "Disease" or perhaps both have been read in as a factor. To test
this:

is.factor(cydf$Health)
[1] FALSE
> is.factor(cydf$Disease)
[1] FALSE

If either of these returns TRUE, that is almost certainly the problem.

Jim


On Wed, Jul 5, 2017 at 11:27 AM, SEB140004 Student
 wrote:
> Greeting.
>
> Dear Mr/Mrs/Miss,
>
> OTU ID Health Disease
> Bacterial 1 0.29 0.34
> Bacterial 2 0.25 0.07
> Bacterial 3 0.06 0.06
> Bacterial 4 0.07 0.09
> Bacterial 5 0.02 0.05
> Above show the first 6 data sets, may I ask that the reason of R show the
> error like "Error in cor(data) : 'x' must be numeric" ? And how to solve
> it? Besides, isn't this data can conduct correlation matrix?
>
> Moreover, isn't this data sets can be plot into network? If can, which
> package should I use?
>
> Thank you.
>
> Best regards,
> Kang Chin Yi
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


[R] Question about correlation

2017-07-05 Thread SEB140004 Student
Greeting.

Dear Mr/Mrs/Miss,

OTU ID Health Disease
Bacterial 1 0.29 0.34
Bacterial 2 0.25 0.07
Bacterial 3 0.06 0.06
Bacterial 4 0.07 0.09
Bacterial 5 0.02 0.05
Above show the first 6 data sets, may I ask that the reason of R show the
error like "Error in cor(data) : 'x' must be numeric" ? And how to solve
it? Besides, isn't this data can conduct correlation matrix?

Moreover, isn't this data sets can be plot into network? If can, which
package should I use?

Thank you.

Best regards,
Kang Chin Yi

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


[R] expand gridded matrix to higher resolution

2017-07-05 Thread Anthoni, Peter (IMK)
Hi all,
(if me email goes out as html, than my email client don't do as told, and I 
apologies already.)

We need to downscale climate data and therefore first need to expand the 
climate from 0.5deg to the higher resolution 10min, before we can add high 
resolution deviations. We basically need to have the original data at each 
gridcell replicated into 3x3 gridcells. 
A simple for loop can do this, but I could need a faster procedure. Anybody 
know a faster way? Is there package than can do what we need already?
I tried matrix with rep, but I am missing some magic there, since it doesn't do 
what we need. 
replicate might be promising, but then still need to rearrange the output into 
the column and row format we need. 

A simple example:
mm=matrix(1:15,nrow=3,byrow = T)
xmm=matrix(NA,nrow=nrow(mm)*3,ncol=ncol(mm)*3)
for(icol in 1:ncol(mm)) {
  for(irow in 1:nrow(mm)) {
xicol=(icol-1)*3 +c(1:3)
xirow=(irow-1)*3 +c(1:3)
xmm[xirow,xicol]=mm[irow,icol]
  }
}
mm
> > mm
>  [,1] [,2] [,3] [,4] [,5]
> [1,]12345
> [2,]6789   10
> [3,]   11   12   13   14   15
> 
xmm
> > xmm
>   [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] 
> [,14] [,15]
>  [1,]111222333 4 4 4 5
>  5 5
>  [2,]111222333 4 4 4 5
>  5 5
>  [3,]111222333 4 4 4 5
>  5 5
>  [4,]666777888 9 9 910
> 1010
>  [5,]666777888 9 9 910
> 1010
>  [6,]666777888 9 9 910
> 1010
>  [7,]   11   11   11   12   12   12   13   13   1314141415
> 1515
>  [8,]   11   11   11   12   12   12   13   13   1314141415
> 1515
>  [9,]   11   11   11   12   12   12   13   13   1314141415
> 1515

I tried various rep with matrix, but don't get the right result.
xmm2=matrix(rep(rep(mm,each=3),times=3),nrow=nrow(mm)*3,ncol=ncol(mm)*3,byrow = 
F)
> identical(xmm,xmm2)
[1] FALSE

rr=replicate(3,rep(t(mm),each=3))
rr
> > rr
>   [,1] [,2] [,3]
>  [1,]111
>  [2,]111
>  [3,]111
>  [4,]222
>  [5,]222
>  [6,]222
>  [7,]333
> ...
identical(xmm,matrix(rr,ncol=15,nrow=9,byrow=T))
> > identical(xmm,matrix(rr,ncol=15,nrow=9,byrow=T))
> [1] FALSE
 
Many thanks for any advice.

cheers
Peter

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R] Please help(urgent) - How to simulate transactional data for reliability/survival analysis

2017-07-05 Thread Sunny Singha
Mark,
Below is the sampled simulated granular data format for pumps for
trial period of 3 months that I need to transform for survival
analysis:
3 months = (60*24*90) minutes i.e 129600 minutes

pump_id timingsevents   vibration temprature flow
pump1 01-07-2017 00:00   03.44369.6   139.806
pump1 01-07-2017 00:10   10.50145.27 140.028
pump1 01-07-2017 00:20   02.03152.9   137.698
pump1 01-07-2017 00:30   02.26760.12 139.054
pump1 01-07-2017 00:40   12.26760.12 139.054
pump1 01-07-2017 00:50   02.26760.12 139.054
pump2 01-07-2017 00:00   03.44369.6   139.806
pump2 01-07-2017 00:10   00.50145.27 140.028
pump2 01-07-2017 00:20   02.03152.9   137.698
pump2 01-07-2017 00:30   02.26760.12 139.054
pump2 01-07-2017 00:40   12.26760.12 139.054
pump2 01-07-2017 00:50   02.26760.12 139.054

The above data set records observations and timings where 'pumps'
experienced failure, tagged as '1' in column 'events'.
In the above granular dataset the pump1 experiences 2 "event episodes."

Below is the desired transformed format. the covariates in this data
set will have the mean value:
pump_id  event_episodes  event_status  start(minutes)
stop(minutes)
pump1  1 1
  0   10
pump1  2 1
 10  40
pump1  3 0
 40  129600
pump2  1 1
  0   40
pump2  2 0
  0   129600
.
.

The 'start' and 'stop' columns are evaluated from the 'timings'
columns. I need help in performing such transformation in 'R'.
Please guide and help.

Regards,
Sandeep

On Wed, Jul 5, 2017 at 7:26 AM, Mark Sharp  wrote:
> A small example data set that illustrates your question will be of great 
> value to those trying to help. This appears to be a transformation that you 
> are wanting to do (timestamp to units of time) so a data representing what 
> you have (dput() is handy for this) and one representing what you want to 
> have with any guidance regarding how to use the other columns in you data set 
> (e.g., the event(0/1)).
>
> Mark
> R. Mark Sharp, Ph.D.
> msh...@txbiomed.org
>
>
>
>
>
>> On Jul 4, 2017, at 7:02 AM, Sunny Singha  
>> wrote:
>>
>> Thanks Boris and Bret,
>> I was successful in simulating granular/transactional data.
>> Now I need some guidance to transform the same data in format acceptable
>> for survival analysis i.e below format:
>>
>> pump_id | event_episode_no. | event(0/1) | start | stop | time_to_dropout
>>
>> The challenge I'm experience is to generate the 'start' and 'stop' in units
>> of minutes/days from single column of 'Timestamp' which is
>> the column from transactional/granular data based on condition tagged in
>> separate column, 'event 0/1, (i.e event ).
>>
>> Please guide how to do such transformation in 'R'.
>>
>> Regards,
>> Sandeep
>>
>>
>>
>> On Wed, Jun 28, 2017 at 2:51 PM, Boris Steipe 
>> wrote:
>>
>>> In principle what you need to do is the following:
>>>
>>> - break down the time you wish to simulate into intervals.
>>> - for each interval, and each failure mode, determine the probability of
>>> an event.
>>>   Determining the probability is the fun part, where you make your domain
>>>   knowledge explicit and include all the factors into your model:
>>> cumulative load,
>>>   failure history, pressure, temperature, phase of the moon ...
>>> - once you have a probability of failure, use the runif() function to
>>> give you
>>>   a uniformly distributed random number in [0, 1]. If the number is
>>> smaller than
>>>   your failure probability, accept the failure event, and record it.
>>> - Repeat many times.
>>>
>>> Hope this helps.
>>> B.
>>>
>>>
>>>
>>>
 On Jun 27, 2017, at 10:58 AM, sandeep Rana  wrote:

 Hi friends,
 I haven't done such a simulation before and any help would be greatly
>>> appreciated. I need your guidance.

 I need to simulate end to end data for Reliability/survival analysis of
>>> a Pump ,with correlation in place, that is at 'Transactional level' or at
>>> the granularity of time-minutes, where each observation is a reading
>>> captured via Pump's sensors each minute.
 Once transactional data is prepared I Then need to summarise above data
>>> for reliability/ survival analysis.

 To begin with below is