Displaying 20 results from an estimated 3000 matches similar to: "Trouble reshaping some data"
2012 Mar 20
2
Reshaping data from long to wide without a "timevar"
Hello All,
I was wondering if it's possible to reshape data from long to wide in R without using a "timevar". I've pasted some sample data below along with some code. The data are sorted by Subject and Drug. I want to transpose the Drug variable into multiple columns in alphabetical order.
My data have a variable called "RowNo" that functions almost like a
2008 Mar 18
1
Updating selected variables in a data frame
Dear list,
I'd like to update certain rows/columns in a data
frame with new values. The application is that
survey respondents may give an answer of "Other"
to a categorical question and then provide some
text describing what they mean. This text is then
reviewed and placed into a category. These edits
or recodes then need to be merged back into the
main dataset.
A small example
2010 Jan 22
2
sorted reshaping?
dear R wizards:? I am wrestling with reshape.? I have a long data set
that I want to convert into a wide data set, in which rows are firms
and columns are years.
> summary(rin)
firm fyear sim1
Min. :1004.00 Min. :1964.0 Min. : -1.00000
1st Qu.:1010.00 1st Qu.:1979.0 1st Qu.: -0.14334
Median :1016.00 Median :1986.0 Median : 0.00116
Mean
2008 Sep 27
2
reshape "Error in data[, timevar] : incorrect number of dimensions"
I have two waves of a survey given to students at various middle
schools and high schools, with student id numbers for each student. I
am having difficulty reshaping the file from long to wide.
My code is below:
library(foreign)
svy <- read.spss("studsur4.SAV")
svy.wide <- reshape(svy, timevar="WAVE", idvar="id", direction="wide")
2009 Sep 14
2
problems with reshape
Hello *
I would like to reshape wide the following dataset:
> rl <- read.dta("intermedi/rapporti_lavoro.dta") [c("id_rl","prog","sil_pi","sil_cf","sil_dat_avv")]
> dim(rl)
[1] 12964 5
> object.size(rl)
1194728 bytes
> head(rl)
id_rl prog sil_pi sil_cf sil_dat_avv
1 638 1 04567XXXXXX
2006 Feb 22
1
unused factor levels in reshape
When reshaping a dataframe in which there are unused factor levels in the id variable, I get the following error:
Error in if (!all(really.constant)) warning(gettextf("some constant variables (%s) are really varying", :
missing value where TRUE/FALSE needed
For example,
> df <- data.frame(i = factor(rep(1:5, each = 2)), t = factor(rep(1:2, 5)), x = rep(rbinom(5, 1,
2010 Mar 25
1
Problem with reshaping data from wide to long format
Hi,
I have a data.frame in wide format which I would like to reshape into
a long format:
example (nonsense) data:
> dput(perus2)
structure(list(id = c(30L, 38L, 21L, 12L, 22L, 28L, 31L, 44L,
8L, 47L, 23L, 20L, 41L, 42L, 29L, 50L, 5L, 33L, 4L, 17L, 11L,
1L, 18L, 6L, 9L, 32L, 16L, 14L, 39L, 48L, 37L, 43L, 25L, 27L,
35L, 40L, 45L, 49L, 2L, 34L, 10L, 15L, 24L, 26L, 46L, 7L, 13L,
3L, 19L, 36L),
2009 Dec 09
1
reshape() makes R run out of memory (PR#14121)
Full_Name: Alexander L. Belikoff
Version: 2.8.1
OS: Ubuntu 9.04 (x86_64)
Submission from: (NULL) (67.244.71.200)
I'm trying to reshape the following data frame:
ID DATE1 DATE2 VALUE_TYPE VALUE
'abcd1233' 2009-11-12 2009-12-23 'TYPE1' 123.45
...
VALUE_TYPE is a string and is a factor with only 2 values
2008 Feb 10
2
reshape
Dear colleagues,
I'd like to reshape a datafame in a long format to a wide format, but
I do not quite get what I want. Here is an example of the data I've
have (dat):
sp <- c("a", "a", "a", "a", "b", "b", "b", "c", "d", "d", "d", "d")
tr <- c("A",
2009 Oct 04
2
Row to Column help
Dear R Community,
I am attempting to transpose a dataset from rows to columns but am stuck. I
have tried using reshape() with little luck, possibly due to the categorical
nature of the data. For example:
id<-c(1,2,2,3,3,3)
author<-c("j","k","k","l","l","l")
2001 Dec 27
3
reshape error in 1.4 (PR#1231)
Full_Name: Kevin Wright
Version: 1.4
OS: Windows 95
Submission from: (NULL) (170.54.59.160)
Note: This was the 1.4 build for Windows that Brian Ripley made available.
The first example in the help for reshape doesn't work for me. When I cut and
paste, this is what happens:
> data(Indometh,package="nls")
> summary(Indometh)
Subject time conc
2004 Aug 06
1
reshape (was: Comparing rows in a dataframe)
Hi all:
I solved the previous stated problem in something of a brute force way
(but it works). I seem to now be running into one little hiccup using
reshape. Here is a quick snip of the data in long format:
grade stability year schid
6 Grade 4 3 2001 100005
7 Grade 4 3 2002 100005
8 Grade 4 2 2003 100005
10 Grade 5 2 2001 100005
11 Grade 5
2009 Mar 31
2
'sep' argument in reshape()
I wonder if the 'sep' argument in reshape() is being ignored
unintentionally:
## From example(reshape)
df <- data.frame(id=rep(1:4,rep(2,4)),
visit=I(rep(c("Before","After"),4)),
x=rnorm(4), y=runif(4))
reshape(df, timevar="visit", idvar="id", direction="wide", sep = "_")
id x.Before
2008 Nov 18
1
reshape question
Hi,
It's probably a simple issue but I'm struggling with that. I'll use the
example shown in the help page.
head(Indometh)
wide <- reshape(Indometh, v.names="conc", idvar="Subject",
timevar="time", direction="wide")
head(wide)
reshape(wide, idvar="Subject", varying=list(2:12),
v.names="conc",
2006 Nov 29
2
reshape command is (stats) dropping instances
I would really appreciate it if anyone could determine what is going
on with the following command. It is only half-working and is losing
lots of data. For the life of me I cannot even see the pattern of what
it is losing and what it is not.
I am attaching the R data set which you can use with the Load
Workspace menu function.
2004 Feb 19
1
reshape direction=wide
Hello
I am reshaping a data.frame bids --> reshaped as shown below.
I thought this should be possible with a single invocation of
reshape, but the only way I came up with is reshaping subsets for each
keyword and then joining them together. Does anyone have an idea how to
solve this in a more elegant way? Efficiency is a concern as the datasets
are very large.
Is there a way to specify
2010 Jan 28
1
question about reshape
Hello everyone,
I have a bit of a problem with reshape function in R.
I have simulated some normal data, which I have saved in 4 vectors.
y.1,y.2,y.3,y.4 which I combined a dataset:
dataset<cbind(y1,y2,y3,y4). I have also generated some subject id number,
and denoted that by subject.
So, my dataset looks like this:
subject y.1 y.2 y.3 y.4
[1,] 1 20.302707
2008 Aug 25
3
Maintaining repeated ID numbers when transposing with reshape
I have a dataset in "long" format that looks something like this:
ID TEST RESULT
1 A 17
1 A 12
1 B 15
1 C 12
2 B 8
2 B 9
Now what I would like to do is transpose it like so:
ID TEST A TEST B TEST C
1 17 15 12
1 12 . .
2
2011 Oct 31
1
googleVis motionchart - slow with Date class
Hi,
I am trying to create a googleVis motion chart with monthly data. When formatting the date column as a Date class variable, the plot as presented in the browser becomes considerably slower and very prone to crashing the browser. To illustrate this issue I have modified the WorldBank demo.
### objects from demo("WorldBank", package = "googleVis")
M <-
2010 Mar 06
1
transposing data
Hi. I have repeated measures data of the form where each observation
is a trial, and trials are grouped by subject, and variables encode
whatever level of a factor was present during that trial, and the
dependent variable is response time (RT). I want to transpose the
data to a form suitable for MANOVA such that there is one observation
per subject and RT is recoded across many