[R] select if + other questions

John Kane jrkrideau at yahoo.ca
Fri Apr 27 01:11:16 CEST 2007


Yes but I believe it will vary depending on what
package you're using.  I don't deal with weigthed data
so I'm not a good source

Have a look at help for something like lm in the stats
  package (part of the base installation) for an
example.
 
?lm 

weight is the fourth argument down.

However for more information try
http://finzi.psych.upenn.edu/search.html and type in
weight.

As Brian Ripley says in a reply to a question about
weights:
 "Almost all methods I know of do: logistic
regression, neural nets, classification trees, PPR
.... "


--- Natalie O'Toole <notoole at mtroyal.ca> wrote:

> Hi,
> 
> Thank-you for the response!! That worked great!! Is
> there any way to apply 
> a weight variable to your file similar to what you
> can do in SPSS? So that 
> all of your other variables will be weighted by the
> weight variable?
> 
> Thanks,
> 
> Nat
> 
> __________________
> 
> 
> Hi, 
> 
> i am trying to read a .txt file, do a couple of
> select if statements on my 
> data, and then finally use the ?table function to
> get frequency counts on 
> the data. Specifically, i am looking at answering
> the following question: 
> 
> What is the frequency of Grade 7 students in the
> province of Alberta who 
> are smokers? 
> 
> I am having some problems: 
> 
> 1)i cannot get the column names to show up when
> print to screen 
> 
> 2)I cannot seem to skip variables properly when i
> choose certain other 
> variables 
> 
> 3)i cannot get the combination of Select If
> statements to work to produce 
> a different table with my new criteria
> 
> Here are the variables 
> 
> PUMFID position1 length 5 
> PROV position 6 length 2 
> GRADE position 9 length 2 
> Y_Q10A position 33 length 1 
> 
> 
> Y_Q10A has the following 1=yes 
>                            2=no
>                           9=skip 
> 
> all the others have no skipped or missing values 
> 
> Here is my code: 
> 
> myfile<-("c:/test2.txt") 
> myVariableNames<-c("PUMFID","PROV","GRADE","Y_Q10A")
> 
> myVariableWidths<-c(5,2,2,1) 
> 
> 
>  mydata<-read.fwf( 
> file=myfile, 
> width=myVariableWidths, 
> col.names=myVariableNames, 
> row.names="PUMFID", 
> fill=TRUE, 
> strip.white=TRUE) 
> 
> 
> print(mydata) 
> 
> print( mydata [which(PROV=="AB" & GRADE==7 &
> Y_Q10A<9), ] ) 
> 
> 
> 
> Any help would be greatly appreciated!! 
> 
> Thank-you, 
> 
> Nat 
> 
>
------------------------------------------------------------------------------------------------------------------------
> 
> 
> This communication is intended for the use of the
> recipient to which it is 
> addressed, and may
> contain confidential, personal, and or privileged
> information. Please 
> contact the sender
> immediately if you are not the intended recipient of
> this communication, 
> and do not copy,
> distribute, or take action relying on it. Any
> communication received in 
> error, or subsequent
> reply, should be deleted or destroyed. 
>
------------------------------------------------------------------------------------------------------------------------
> 
> 
> This communication is intended for the use of the
> recipient to which it is 
> addressed, and may
> contain confidential, personal, and or privileged
> information. Please 
> contact the sender
> immediately if you are not the intended recipient of
> this communication, 
> and do not copy,
> distribute, or take action relying on it. Any
> communication received in 
> error, or subsequent
> reply, should be deleted or destroyed.
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at stat.math.ethz.ch 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.
>



More information about the R-help mailing list