Displaying 16 results from an estimated 16 matches for "stretch_df".
2018 May 01
2
how can I convert a long to wide matrix?
...quot;B"), class = "factor")), .Names =
> c("ID",
> >
> > "EventDate", "timeGroup", "SITE"), class = "data.frame", row.names =
> c(NA,
> >
> > -5L))
> >
> > library(prettyR)
> >
> > stretch_df(dat,idvar="ID",to.stretch=c("EventDate","SITE"))
> >
> >
> > ID timeGroup EventDate_1 EventDate_2 EventDate_3 SITE_1 SITE_2 SITE_3
> > 1 id_X B1 9/8/16 9/9/16 9/15/17 A A B
> > 2 id_Y B1 9/7/...
2018 May 01
2
how can I convert a long to wide matrix?
...t;factor"), SITE = structure(c(
1L,
1L, 2L, 1L, 2L), .Label = c("A", "B"), class = "factor")), .Names = c("ID",
"EventDate", "timeGroup", "SITE"), class = "data.frame", row.names = c(NA,
-5L))
library(prettyR)
stretch_df(dat,idvar="ID",to.stretch=c("EventDate","SITE"))
ID timeGroup EventDate_1 EventDate_2 EventDate_3 SITE_1 SITE_2 SITE_3
1 id_X B1 9/8/16 9/9/16 9/15/17 A A B
2 id_Y B1 9/7/16 9/15/16 <NA> A B...
2018 May 01
0
how can I convert a long to wide matrix?
Hi Marna,
This is a condition that the function cannot handle. It would be
possible to reformat the result based on the time intervals, but the
stretch_df function doesn't try to interpret the values, just
stretches them out to a wide format.
Jim
On Wed, May 2, 2018 at 9:16 AM, Marna Wagley <marna.wagley at gmail.com> wrote:
> Hi Jim,
> The data set is correct. I took two readings from the "SITE A" within a
> short tim...
2018 May 01
0
how can I convert a long to wide matrix?
Hi Marna,
Try this:
library(prettyR)
stretch_df(dat,idvar="ID",to.stretch=c("EventDate","SITE"))
Jim
On Wed, May 2, 2018 at 8:24 AM, Marna Wagley <marna.wagley at gmail.com> wrote:
> Hi R user,
> I was trying to convert a long matrix to wide? I have an example and would
> like to get a table (Final...
2018 May 01
0
how can I convert a long to wide matrix?
...> 1L, 2L, 1L, 2L), .Label = c("A", "B"), class = "factor")), .Names = c("ID",
>
> "EventDate", "timeGroup", "SITE"), class = "data.frame", row.names = c(NA,
>
> -5L))
>
> library(prettyR)
>
> stretch_df(dat,idvar="ID",to.stretch=c("EventDate","SITE"))
>
>
> ID timeGroup EventDate_1 EventDate_2 EventDate_3 SITE_1 SITE_2 SITE_3
> 1 id_X B1 9/8/16 9/9/16 9/15/17 A A B
> 2 id_Y B1 9/7/16 9/15/16 <...
2017 Jul 05
1
Help with reshape/reshape2 needed
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 <istazahn at gmail.com> 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.8...
2018 Feb 25
0
reshaping column items into rows per unique ID
...c
1 b
2 f
2 a
3 j
4 c
4 c
4 f",
header=TRUE,stringsAsFactors=FALSE)
library(prettyR)
stretch_df(a1df,"CustomerID","DietType")
CustomerID DietType_1 DietType_2 DietType_3
1 1 a c b
2 2 f a <NA>
3 3 j <NA> <NA>
4 4 c c f...
2018 May 01
2
how can I convert a long to wide matrix?
Hi R user,
I was trying to convert a long matrix to wide? I have an example and would
like to get a table (FinalData1):
FinalData1
B1 B2
id_X "A" "B"
id_Y "A" "B"
but I got the following table using the following code.
FinalData1
B1 B2
id_X "A" "A"
id_Y "A" "B"
the code and the
2016 Apr 20
0
Data reshaping with conditions
...susan A
56 340 susan A
22 340 susan B
53 340 susan B
135 351 lee A
114 351 lee A
84 351 lee A
80 351 lee A
19 351 lee A
8 351 lee A
21 351 lee A
88 351 lee B
111 351 lee B
46 351 lee B
108 351 lee B",header=TRUE)
# you can also do this with other reshape functions
library(prettyR)
svdatstr<-stretch_df(svdat,"id",c("Count","type"))
count_ind<-grep("Count",names(svdatstr))
type_ind<-grep("type",names(svdatstr))
svdatstr$maxA<-NA
svdatstr$maxB<-NA
svdatstr$x<-NA
svdatstr$y<-NA
for(row in 1:nrow(svdatstr)) {
svdatstr[row,"maxA...
2016 Apr 21
2
Data reshaping with conditions
...A
> 114 351 lee A
> 84 351 lee A
> 80 351 lee A
> 19 351 lee A
> 8 351 lee A
> 21 351 lee A
> 88 351 lee B
> 111 351 lee B
> 46 351 lee B
> 108 351 lee B",header=TRUE)
> # you can also do this with other reshape functions
> library(prettyR)
> svdatstr<-stretch_df(svdat,"id",c("Count","type"))
> count_ind<-grep("Count",names(svdatstr))
> type_ind<-grep("type",names(svdatstr))
> svdatstr$maxA<-NA
> svdatstr$maxB<-NA
> svdatstr$x<-NA
> svdatstr$y<-NA
> for(row in 1:nrow(sv...
2016 Apr 21
0
Data reshaping with conditions
...susan A
56 340 susan A
22 340 susan B
53 340 susan B
135 351 lee A
114 351 lee A
84 351 lee A
80 351 lee A
19 351 lee A
8 351 lee A
21 351 lee A
88 351 lee B
111 351 lee B
46 351 lee B
108 351 lee B",header=TRUE)
# you can also do this with other reshape functions
library(prettyR)
svdatstr<-stretch_df(svdat,"id",c("Count","type"))
count_ind<-grep("Count",names(svdatstr))
type_ind<-grep("type",names(svdatstr))
svdatstr$maxA<-NA
svdatstr$maxB<-NA
svdatstr$x<-NA
svdatstr$y<-NA
for(row in 1:nrow(svdatstr)) {
indicesA<-count_ind[...
2018 Feb 25
4
reshaping column items into rows per unique ID
Hi All
I have a datafram which looks like this :
CustomerID DietType
1 a
1 c
1 b
2 f
2 a
3 j
4 c
4 c
4 f
And I would like to reshape this so I can
2016 Apr 20
2
Data reshaping with conditions
Dear All,
I am trying to reshape the data with some conditions. A small part of the
data looks like below. Like this there will be more data with repeating ID.
Count id name type
117 335 sally A
19 335 sally A
167 335 sally B
18 340 susan A
56 340 susan A
22 340 susan B
53 340 susan B
135 351 lee A
114 351 lee A
84 351 lee A
80 351 lee A
19 351 lee A
8 351 lee A
21 351 lee A
88 351 lee B
111 351
2017 Jul 05
0
Help with reshape/reshape2 needed
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.7500000 ... 0.7307692 0.23750000
0.0733945 0.6435644 ... NA 0.05769231
0.5096154 NA ... NA 0.65137615
or
1957 1958 ... 1985 1986
0.0733945 0.6435644 ... NA
2013 Jan 04
3
help "reshaping" dataframe
List,
I want to reshape my data, but I'm not sure how to do it... it might be a
simple task, but don't know which package does this.
"occ.data" (see below) is how my original data are arranged, and I know
that with melt() I can reshape it like "y" (see below). However, I just
want to build a matrix like the "y" matrix, but with only 2 dimensions.
Something
2017 Jul 05
4
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.862500000
1958 0.750000000
1959 0.300000000
1960 0.287500000
1963 0.675000000
1964 0.937500000
1965 0.025000000
1966 0.387500000
1969 0.087500000
1970 0.275000000
1973 0.500000000
1974 0.362500000
1976 0.925000000
1978 0.712500000
1979 0.337500000
1980 0.700000000
1981 0.425000000