Re: [R] problems formating scientific collaboration data
Hi, name of the data.frame is assumed to be dt. cnt.tmp - strsplit(dt$Author, ) cnt - sapply(cnt.tmp, length) paper.cnt - dt$Paper[cnt] author - unlist(cnt.tmp) year - dt$Year[cnt] dt.new - data.frame(Paper = paper.cnt, Author = author, Year = year) HTH, Dong-hyun Oh On Aug 27, 2008, at 9:27 PM, Grant Gillis wrote: Hello all and thanks in advance for any help or direction. I have co-authorship data that looks like: PaperAuthor Year 1 SmithKK JonesSD 2008 2 WallaceAR DarwinCA 1999 3 HawkingS2003 I would like: Paper Author Year 1 SmithKK 2008 1 JonesSD 2008 2 WallaceAR 1999 2 DarwinCA1999 3 HawkingS2003 Thanks for your patience with what is likely an easy question r-help@r-project.org [[alternative HTML version deleted]] __ R-help@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. __ R-help@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.
Re: [R] problems formating scientific collaboration data
Dear Grant, Try this: x=Paper,Author, Year 1,SmithKK JonesSD, 2008 2,WallaceAR DarwinCA, 1999 3,HawkingS, 2003 X=read.delim2(textConnection(x),sep=,,header=TRUE) closeAllConnections() author= strsplit(as.character(X$Author), ) l=lapply(author,length) P=rep(X$Paper,l) Y=P=rep(X$Year,l) X.new=data.frame(Paper=P,Authore=unlist(author),Year=Y) X.new HTH, Jorge On Wed, Aug 27, 2008 at 3:27 PM, Grant Gillis [EMAIL PROTECTED]wrote: Hello all and thanks in advance for any help or direction. I have co-authorship data that looks like: PaperAuthor Year 1 SmithKK JonesSD 2008 2 WallaceAR DarwinCA 1999 3 HawkingS2003 I would like: Paper Author Year 1 SmithKK 2008 1 JonesSD 2008 2 WallaceAR 1999 2 DarwinCA1999 3 HawkingS2003 Thanks for your patience with what is likely an easy question r-help@r-project.org [[alternative HTML version deleted]] __ R-help@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. [[alternative HTML version deleted]] __ R-help@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.
Re: [R] problems formating scientific collaboration data
I'm sorry Grant, my bad. To reproduce what you'd like to do, my previous code should be: x=Paper,Author, Year 1,SmithKK JonesSD, 2008 2,WallaceAR DarwinCA, 1999 3,HawkingS, 2003 X=read.delim2(textConnection(x),sep=,,header=TRUE) closeAllConnections() author= strsplit(as.character(X$Author), ) l=lapply(author,length) P=rep(X$Paper,l) Y=rep(X$Year,l) X.new=data.frame(Paper=P,Author=unlist(author),Year=Y) X.new HTH, Jorge On Wed, Aug 27, 2008 at 3:59 PM, Jorge Ivan Velez [EMAIL PROTECTED]wrote: Dear Grant, Try this: x=Paper,Author, Year 1,SmithKK JonesSD, 2008 2,WallaceAR DarwinCA, 1999 3,HawkingS, 2003 X=read.delim2(textConnection(x),sep=,,header=TRUE) closeAllConnections() author= strsplit(as.character(X$Author), ) l=lapply(author,length) P=rep(X$Paper,l) Y=P=rep(X$Year,l) X.new=data.frame(Paper=P,Authore=unlist(author),Year=Y) X.new HTH, Jorge On Wed, Aug 27, 2008 at 3:27 PM, Grant Gillis [EMAIL PROTECTED]wrote: Hello all and thanks in advance for any help or direction. I have co-authorship data that looks like: PaperAuthor Year 1 SmithKK JonesSD 2008 2 WallaceAR DarwinCA 1999 3 HawkingS2003 I would like: Paper Author Year 1 SmithKK 2008 1 JonesSD 2008 2 WallaceAR 1999 2 DarwinCA1999 3 HawkingS2003 Thanks for your patience with what is likely an easy question r-help@r-project.org [[alternative HTML version deleted]] __ R-help@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. [[alternative HTML version deleted]] __ R-help@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.