[R] Unable to display titles in final merged SPSS output file - when merged the two SPSS data sets in R

2015-09-03 Thread jagadishpchary
I have two large data sets in SPSS which I am trying to merge the files using
R - (for test purpose I included only two variables with 4 cases) and below
is the R syntax that I am using for merging the files.

data <- read.spss("D:/R_merge/Data.sav")
data1 <- read.spss("D:/R_merge/Data1.sav")
mydata <- smartbind(data, data1)
write.foreign(mydata, "D:/R_merge/data.txt", "D:/R_merge/data.sps",  
package="SPSS")

The issue is: when I export the data from R to SPSS the value labels
(titles) are not shown in the final merged SPSS data set - only the variable
name is shown at the title. 

I have also tried with "haven" package but the smartbind & rbind are working
properly

data <- read_sav("D:/R_merge/Data.sav")
data1 <- read_sav("D:/R_merge/Data1.sav")
mydata <- rbind(data, data1)
write_sav(data.frame(mydata), "D:/R_merge/test2.sav")

Could anyone please help me out. I am attaching 2 spss files. DATA.sav
  
DATA1.sav   



--
View this message in context: 
http://r.789695.n4.nabble.com/Unable-to-display-titles-in-final-merged-SPSS-output-file-when-merged-the-two-SPSS-data-sets-in-R-tp4711786.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Reading the non delimited file with no particular patterns in the data to R

2015-07-10 Thread jagadishpchary
I am beginner in R and I want to read a ASCII file to R environment. However,
the ASCII file is a non delimited and the data is not continuous (have some
blank spaces between the variables) so in order to read the data i have used
the below syntax i.e
test - read.fwf(D:/R_process/ASCII.txt, width = c(10, 4, 1, 4, 9, 9,
1,1,1,1,1,1,1,3,8))

Now i am able to read it but the data read is wrong. Actually my out put
should have only the applicable variables data but not the blank data.
Attached is the ASCII data. Please let me know how should i write the syntax
to read only the applicable data in the file.

Thanks for your help in advance. test.txt
http://r.789695.n4.nabble.com/file/n4709699/test.txt  



--
View this message in context: 
http://r.789695.n4.nabble.com/Cross-tabulation-with-top-one-variable-and-side-as-multiple-variables-tp4708379p4709699.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Cross tabulation with top one variable and side as multiple variables

2015-06-18 Thread jagadishpchary
I think my explanation in the post is not giving the full details on the job
to be done. Sorry for that. Here is what I am doing..

1.  I have a SPSS data set with more than 2000 variables. However for test
purpose I have created a temporary data set with 5 variables which I am
reading it to R environment (Attached the test.sav file).
2.  There is a variable called “TREND” which has the year data. So all I 
need
to do is cross tabulate the variables with this Trend variable. 
In SPSS the syntax would be

CTABLES
/VLABELS VARIABLES =ALL DISPLAY=LABEL
/TABLES (AGET +SEXT +EDUCRT +JOBRT ) [COUNT F40.0] by TREND.

The final cross tabulation results are placed in the attached excel report
with sheet name “Results”.

As I am new to R  - I tried searching the forums for the cross tabulation
with top variable constant and multiple variables as side however I could
not find it. Anyhow I tried using the below syntax :

Xtabs ( ~ AGET +SEXT +EDUCRT +JOBRT + TREND, data=mydata)
summary(~AGET +SEXT +EDUCRT +JOBRT, data= mydata, fun=table)
ftable (mydata, row.vars=c(AGET ,  SEXT ,  EDUCRT  , “JOBRT”),
col.vars=TREND)

the results are not identical to what I am getting in SPSS

Hence I would request to suggest me a R code that helps me in getting the
results as shown in the attached excel report with sheet name “Results”.
Test.sav http://r.789695.n4.nabble.com/file/n4708799/Test.sav  
Cross_tabulation.xlsx
http://r.789695.n4.nabble.com/file/n4708799/Cross_tabulation.xlsx  




--
View this message in context: 
http://r.789695.n4.nabble.com/Cross-tabulation-with-top-one-variable-and-side-as-multiple-variables-tp4708379p4708799.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Cross tabulation with top one variable and side as multiple variables

2015-06-09 Thread jagadishpchary
Hi:

I have a huge data with lot of variables and I need to check the trend
variations from year to year. In order to do so, I have to cross tabulate
the year variable as top (constant) and all the remaining variables as side
(attached the cross tabulation report). I have searched the forums but the
syntax I could find for cross tabulation is between 2 or 3 variables. So i
would request to provide a code which can print the data in the same way as
in the attached.  http://r.789695.n4.nabble.com/file/n4708379/Untitled.png 



--
View this message in context: 
http://r.789695.n4.nabble.com/Cross-tabulation-with-top-one-variable-and-side-as-multiple-variables-tp4708379.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.