[R] reshape() not dropping varaibles

Bob O'Hara rn|@boh @end|ng |rom gm@||@com
Sun Dec 10 11:38:02 CET 2023

Hi all!

I1m trying to re-format some data from long to wide format with reshape().
Specifically, the data has SURVEYDATE, which I want to be in the rows, and
COMMON_NAME which should be the columns. The entries should be TOTAL_CATCH.
The data has a bunch of other variables, which can be ignored.

When I run reshape(), it includes all of the variables, not just

Data <- read.csv("
Data.wide <- reshape(Data, direction = "wide",
                idvar = "SURVEYDATE", timevar = "COMMON_NAME",
                v.names = "TOTAL_CATCH")

I tried with the example on the help page, which works fine:

# this works
Indometh$thing <- 1:nrow(Indometh)
wide <- reshape(Indometh, direction = "wide", idvar = "Subject",
                timevar = "time", v.names = "conc", sep= "_")

There are some obvious work-arounds and alternatives, but it would be nice
to have this sorted. Can anyone help?



Bob O'Hara
Institutt for matematiske fag
7491 Trondheim

Mobile: +47 915 54 416
Journal of Negative Results - EEB: www.jnr-eeb.org

	[[alternative HTML version deleted]]

More information about the R-help mailing list