Javed,
It sound ad if you are trying to learn too much all at once. My suggestion would be to break the task down into more manageable pieces.
1. Put away your data for a while and focus on running and modifying lavaan examples to gain familiarity and comfort with the interface. For example, try running the same CFA using different methods to fix the scales of the latent variables. The lavaan HTML tutorial and the model.syntax help file are both helpful.
2. Have a look at as much (little) as you need of the R data Input-Output manual and practice with a simple data set. Go to the CRAN web site and click "Manuals" on the navigation pane. Personally, I like to read and write csv files but it is a matter of taste.
3. Have you read a comprehensive SEM text book? Any text worth its salt should explain the difference between CFA and path analysis and also offer a guide to the basic steps involved in a SEM analysis. I teach using Rex Kline's book.
4. The piece that seems to be confusing you is this: Reading data into your R workspace makes it available for analysis, but that is a prior and separate step from identifying to lavaan what data from your workspace you want to apply the analysis too. Variable names play a critical role in mapping your model onto your data in a SEM analysis. All of the observed variables referenced in a model must be referred to by the same names as they are referred to in the data itself. That includes case sensitivity. You will supply lavaan with both a model and a data set. Lavaan will map the model onto the data using your variable names. In contrast to observed variables, latent variables occur only in the model, and thus are not mapped onto the data.
In the multilevel example that you copied, the variable name conventions appear to work as follows:
y1, ... : observed indicators
x1, w1, ...: observed causal variables at each level
fb, fw: common factors (f) that are either varying between clusters (b) or within clusters (w). These are latent variables that do not appear in the data.
Here are some useful R functions for investigating a data set once read into R:
dim(myData)
names(myData)
str(myData)
head(myData)
summary(myData)
Good luck,
Keith
------------------------
Keith A. Markus
John Jay College of Criminal Justice, CUNY
http://jjcweb.jjay.cuny.edu/kmarkusFrontiers of Test Validity Theory: Measurement, Causation and Meaning.
http://www.routledge.com/books/details/9781841692203/