Skip to content

Shifting cells and removing blanks

3 messages · ankur verma, Nordlund, Dan (DSHS/RDA), arun

#
What does "like this" mean?  Is this a text file, or a list, or a dataframe, or a matrix, or ...?  You say you want to remove all blanks.  Are the hyphens your attempt to represent blanks in the email, or do they actually exist?
Again, do you want this output in a text file or some R structure?  If an R structure, which one?
Not until you provide a reproducible example as the posting guide asks.


Dan

Daniel J. Nordlund
Washington State Department of Social and Health Services
Planning, Performance, and Accountability
Research and Data Analysis Division
Olympia, WA 98504-5204
#
If the OP wanted a list output and if the data is what it looks like, may be this helps.

dat1<-read.table(text="
?ID? Prod1? Prod2? Prod3? Prod4? Prod5
01??? A???????????? -?????????? B??????? -?????????? C
02????? -?????????? F?????????? -?????????? G??????? -
03????? H???????? -???????????? -?????????? -???????? J
",sep="",header=TRUE,stringsAsFactors=FALSE)
?lapply(split(dat1[,-1],dat1$ID),function(x) x[x!="-"]) 

$`1`
[1] "A" "B" "C"

$`2`
[1] "F" "G"

$`3`
[1] "H" "J"
A.K.




----- Original Message -----
From: "Nordlund, Dan (DSHS/RDA)" <NordlDJ at dshs.wa.gov>
To: "r-help at r-project.org" <r-help at r-project.org>
Cc: 
Sent: Tuesday, March 26, 2013 1:34 PM
Subject: Re: [R] Shifting cells and removing blanks
What does "like this" mean?? Is this a text file, or a list, or a dataframe, or a matrix, or ...?? You say you want to remove all blanks.? Are the hyphens your attempt to represent blanks in the email, or do they actually exist?
Again, do you want this output in a text file or some R structure?? If an R structure, which one?
Not until you provide a reproducible example as the posting guide asks.


Dan

Daniel J. Nordlund
Washington State Department of Social and Health Services
Planning, Performance, and Accountability
Research and Data Analysis Division
Olympia, WA 98504-5204

______________________________________________
R-help at r-project.org mailing list
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.