Syntax Comments in SPSS

There two way to write comments in SPSS: the non executed line and the in-line comment.

The first, the non executed line, look like this:

* reliability of measures.
RELIABILITY
/VARIABLES=it1 it2 it3
/SCALE('ALL VARIABLES') ALL
/MODEL=ALPHA
/STATISTICS=DESCRIPTIVE SCALE
/SUMMARY=TOTAL.

This is ok for making titles before sectionsn out ot a syntax; or to cancel out commands. like in the following example.

if(it1 = 1) dummy = 1 .
if(it1 = 2) dummy = 0 .
*if(it1 = 3) dummy = 1 .
execute .

On the other hand, the inline comments, serve the purpose of including a comment within a line of commands, like this.

if(it1 = 1) dummy = 1 .
if(it1 = 2) dummy = 0 .
if(it1 = 3) dummy = 1 . /* discuss this option in the research meeting */ 
execute .

 

via

http://www.dummies.com/how-to/content/spss-syntax-language-comments.html

How to import an Excel file in R

In order to import an excel file directly into R, without the need to convert it into a CSV file, and create a data frame (i.e. a dataset), we could use the XLConnect library. We will install the library, and call it right away to work, by typing this:

 

install.packages("XLConnect")                                                       #install package
library("XLConnect")                                                                      #calling library

Lets say we have a file called 'file.xlsx' store in D:/data/, from which we want to read the sheet 'info'. To read this file directly, we use the following code:

info <- readWorksheetFromFile("d:/data/file.xlsx", sheet = "Info")   #opening file / directly

This code will create an object call info, which contains in a data frame, the contents of our excel file. Sometimes, excel files may have different characters, in which teh viewer in R (with R Studio, or Rcmdr) may not able to handle. Characters such as ñ,á,é,í,ó or maybe others. To check if the data was read properly we could export it to text, to see how it looks. 

write.table(info, "d:/data/info.txt", sep="\t")                       #export data to see how it looks

We could also export the data, into an excel file again, to see how it looks.

require(XLConnect)                                                                     #it specifies that for the following command, an specific library needs to be used
writeWorksheetToFile("info.xlsx", data = info, sheet = "info")       #export data to see how it looks in excel
 

 

This is a fairly good start to do things in R.

[need to fix the blog, to store code properly, like here]