Hello guys I am new to this list and for R too. I am wondering if there is a patch for the SPSS reading code on the foreign package, in order to be able to read long variable names. Right now read.spss() just trunc the names to 8 characters. Or if someone could help me on other way: I have to process everyday a lot of SPSS Syntax Files and Dat files that come from one system that can only export data on through that way. I use PSPP to generate the spss data file (sav) that I read with R.>From R I can export to MySQL, DBF and STATA to satisfy the needs ofdifferent guys here. The problem is the limit of 8 characters long on variable names. Can someone help on that? Caveman
library(Hmisc) spss.get may do it but it's been some time since I used it. --- On Sat, 10/10/09, Orvalho Augusto <orvaquim at gmail.com> wrote:> From: Orvalho Augusto <orvaquim at gmail.com> > Subject: [R] SPSS long variable names > To: r-help at r-project.org > Received: Saturday, October 10, 2009, 12:14 PM > Hello guys I am new to this list and > for R too. > > I am wondering if there is a patch for the SPSS reading > code on the > foreign package, in order to be able to read long variable > names. > Right now read.spss() just trunc the names to 8 > characters. > > Or if someone could help me on other way: > I have to process everyday a lot of SPSS Syntax Files and > Dat files > that come from one system that can only export data on > through that > way. > > I use PSPP to generate the spss data file (sav) that I read > with R. > >From R I can export to MySQL, DBF and STATA to satisfy > the needs of > different guys here. > > The problem is the limit of 8 characters long on variable > names. > > Can someone help on that? > > Caveman > > ______________________________________________ > 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. >__________________________________________________________________ The new Internet Explorer? 8 - Faster, safer, easier. Optimiz etexplorer/
Paul Dennis
2009-Oct-13 13:24 UTC
[R] Identification of variables contributing to differences between factor in adonis
Dear all I have used permutational multivariate analysis of variance (adonis in package vegan) based on Bray-Curtis distances to assess the signifance of carbon, nitrogen and more complex nutrient amendments on soil microbial community structure (microbial fatty acids). I have identified signifant effects of nutrients and would like to know how to identify the fatty acids (microbial markers) that are associated with these differences. So far I have used Pierre Legrendre's "Dufrene-Legendre Indicator Species Analysis" duleg in package 'labdsv' to do this (Calculates the indicator value (fidelity and relative abundance) of species in clusters or types). However, I am not familiar with the implementation of this method and am concerned about the relevance of the output as the 'indicator species' are not probably not based on Bray-Curtis distances. Is there another way to identify fatty acids contributing to differences between my nutrient amendment groups? For example, the output of the permutational multivariate analysis of variance (adonis) has the following attributes: aov.tab 6 data.frame list call 2 -none- call coefficients 74 -none- numeric coef.sites 28 -none- numeric f.perms 999 -none- numeric model.matrix 28 -none- numeric terms 3 terms call Can I use the coefficients to select fatty acids that contribute to the differences between treatment? Thanks Paul _________________________________________________________________ View your other email accounts from your Hotmail inbox. Add them now. [[alternative HTML version deleted]]
----- Original Message ----- From: "Robert Baer" <rbaer at atsu.edu> To: "Orvalho Augusto" <orvaquim at gmail.com> Sent: Tuesday, October 13, 2009 9:52 AM Subject: Re: [R] SPSS long variable names>>> I am wondering if there is a patch for the SPSS reading >>> code on the >>> foreign package, in order to be able to read long variable >>> names. >>> Right now read.spss() just trunc the names to 8 >>> characters. > This sequence seems to access the long filenames for me if I know what you > are asking for: > > library('foreign') > a<-read.spss('fil.sav') > lnames <- attr(a,"variable.labels",exact=FALSE) > > Rob > >
No! That is variable labels. Caveman On Tue, Oct 13, 2009 at 4:52 PM, Robert Baer <rbaer at atsu.edu> wrote:>>> I am wondering if there is a patch for the SPSS reading >>> code on the >>> foreign package, in order to be able to read long variable >>> names. >>> Right now read.spss() just trunc the names to 8 >>> characters. > > This sequence seems to access the long filenames for me if I know what you > are asking for: > > library('foreign') > a<-read.spss('fil.sav') > lnames <- attr(a,"variable.labels",exact=FALSE) > > Rob > > >
Hi The .dat file is a tab delimited file with the long variables names on it. The .sps file has the instructions to read the .dat and place all the variable and value labels. The ideia of reading the dat directely is good but I need the labels placed. Yes I could read the dat file and parese myself the sps to get sps file but that it is a job that to try and by these mails I will have to do so. For now what I made a little script to generate the sav using pspp; Then I read the sav with read.spss. Then I call read.delim to read the long names on the dat file. It works but is not beautfull and uses more resources. The great thing would be to support long variables names on read.spss. Thanks guys for everything Caveman On Wed, Oct 14, 2009 at 4:52 PM, joris meys <jorismeys at gmail.com> wrote:> Hi Orvalho, > > question : where do the .dat files come from and what do you have to > do with the SPSS syntax files. I guess the syntax file is to change > the .dat file into SPSS format. But you could take the shortcut and > read in the .dat file directly. If the SPSS syntax file is a text file > (which should be), you can construct your own function to read in all > specifications from the syntax file. the function regexp() can be a > great help for that. > > If you have no clue how to do that, just send me an example, and I'll > take a look. > > Cheers > Joris > > On Sat, Oct 10, 2009 at 6:14 PM, Orvalho Augusto <orvaquim at gmail.com> wrote: >> Hello guys I am new to this list and for R too. >> >> I am wondering if there is a patch for the SPSS reading code on the >> foreign package, in order to be able to read long variable names. >> Right now read.spss() just trunc the names to 8 characters. >> >> Or if someone could help me on other way: >> I have to process everyday a lot of SPSS Syntax Files and Dat files >> that come from one system that can only export data on through that >> way. >> >> I use PSPP to generate the spss data file (sav) that I read with R. >> >From R I can export to MySQL, DBF and STATA to satisfy the needs of >> different guys here. >> >> The problem is the limit of 8 characters long on variable names. >> >> Can someone help on that? >> >> Caveman >> >> ______________________________________________ >> 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. >> >
Impressive! PSPP produces the sav fine. The sav file produced by the PSPP is seen by SPSS (16) with the long names. I attach my sav produced by the PSPP. And I start to suspect my foreign package version: I am using 0.8.26-1 from the r-cran-foreign a Ubuntu 8.10 package. Can you tell me your version? I am updating mine. Thanks guys. Caveman On Thu, Oct 15, 2009 at 9:02 PM, Robert Baer <rbaer at atsu.edu> wrote:>>>>>> The problem is the limit of 8 characters long on variable >>>>>> names.[in read.spss??????] > > I just created a file in SPSS 17 and saved it in standard format (.sav) The > file had four unique variable NAMES which were much longer than 8 characters > (although not 64). ?I entered two rows of data and saved the file again. The > "variable view" in SPSS looked like the following for the 4 variables I > created. ?(unique in the first postition after the first 9) > > a12345678901234567890987654321098765432011111111111111 Numeric 8 2 > a1234567890 None None 14 Right Scale > a1234567899123456789098765432109876543201 Date 9 0 b1234567890 None None 14 > Right Scale > a1234567898123456789098765432109876543201 String 8 0 c1234567890 None None > 14 Left Nominal > a1234567897123456789098765432109876543201 Numeric 8 2 d1234567890 None None > 14 Right Scale > > I now started R and used read.spss() from the foreign package using the > following code" ?The data frame I read in seemed to reflect the original > file with respect to column names: > >> library(foreign) >> c=read.spss(file.choose(),to.data.frame=TRUE) >> c > > ?a12345678901234567890987654321098765432011111111111111 > a1234567899123456789098765432109876543201 > a1234567898123456789098765432109876543201 > 1 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 33.3 13452825600 > ? ? ? ? ? ? ? ? ? ? ? ? ?a cat > 2 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 22.2 13463280000 > ? ? ? ? ? ? ? ? ? ? ? ? ?dog > ?a1234567897123456789098765432109876543201 > 1 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 32165 > 2 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 321654987 > > It appears these long variable names read in just fine. ?Thus, I would ask > caveman whether the problem is really an R problem at all, or is it a > problem with PSPP writing (in which case this would be the wrong list to be > discussing it on)? > > R >
Robert you are right. I updated the foreign package and I can read long names now!!!! I have checked the changelog and I found that long names reading were introduced after 0.8.29 while I were using 0.8.26-1. So I am really sorry guys for this mess. R can read long names. Caveman On Thu, Oct 15, 2009 at 9:42 PM, Orvalho Augusto <orvaquim at gmail.com> wrote:> Impressive! > > PSPP produces the sav fine. The sav file produced by the PSPP is seen > by SPSS (16) with the long names. > > I attach my sav produced by the PSPP. And I start to suspect my > foreign package version: > I am using 0.8.26-1 from the r-cran-foreign a Ubuntu 8.10 package. Can > you tell me your version? I am updating mine. > > Thanks guys. > > Caveman > > > On Thu, Oct 15, 2009 at 9:02 PM, Robert ?Baer <rbaer at atsu.edu> wrote: >>>>>>> The problem is the limit of 8 characters long on variable >>>>>>> names.[in read.spss??????] >> >> I just created a file in SPSS 17 and saved it in standard format (.sav) The >> file had four unique variable NAMES which were much longer than 8 characters >> (although not 64). ?I entered two rows of data and saved the file again. The >> "variable view" in SPSS looked like the following for the 4 variables I >> created. ?(unique in the first postition after the first 9) >> >> a12345678901234567890987654321098765432011111111111111 Numeric 8 2 >> a1234567890 None None 14 Right Scale >> a1234567899123456789098765432109876543201 Date 9 0 b1234567890 None None 14 >> Right Scale >> a1234567898123456789098765432109876543201 String 8 0 c1234567890 None None >> 14 Left Nominal >> a1234567897123456789098765432109876543201 Numeric 8 2 d1234567890 None None >> 14 Right Scale >> >> I now started R and used read.spss() from the foreign package using the >> following code" ?The data frame I read in seemed to reflect the original >> file with respect to column names: >> >>> library(foreign) >>> c=read.spss(file.choose(),to.data.frame=TRUE) >>> c >> >> ?a12345678901234567890987654321098765432011111111111111 >> a1234567899123456789098765432109876543201 >> a1234567898123456789098765432109876543201 >> 1 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 33.3 13452825600 >> ? ? ? ? ? ? ? ? ? ? ? ? ?a cat >> 2 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 22.2 13463280000 >> ? ? ? ? ? ? ? ? ? ? ? ? ?dog >> ?a1234567897123456789098765432109876543201 >> 1 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 32165 >> 2 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 321654987 >> >> It appears these long variable names read in just fine. ?Thus, I would ask >> caveman whether the problem is really an R problem at all, or is it a >> problem with PSPP writing (in which case this would be the wrong list to be >> discussing it on)? >> >> R >> >