[R] Using write.table i have a table with two columns i would like to save it as an excel file
Using write.table i would like to save data as an excel file to a folder. I am not too sure how to write the file path or what to name the file. I would appreciate any feedback. > write.table(x, file = "", append = FALSE, quote = TRUE, sep = " ", + eol = "\n", na = "NA", dec = ".", row.names = TRUE, + col.names = TRUE, qmethod = c("escape", "double"), + fileEncoding = "") "area" "bedrooms" "sale.price" "9" 694 4 192 "10" 905 4 215 "11" 802 4 215 "12" 1366 4 274 "13" 716 4 112.7 "14" 963 4 185 "15" 821 4 212 "16" 714 4 220 "17" 1018 4 276 "18" 887 4 260 "19" 790 4 221.5 "20" 696 5 255 "21" 771 5 260 "22" 1006 5 293 "23" 1191 6 375 -- View this message in context: http://r.789695.n4.nabble.com/Using-write-table-i-have-a-table-with-two-columns-i-would-like-to-save-it-as-an-excel-file-tp3768829p3768829.html Sent from the R help mailing list archive at Nabble.com. __ R-help@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.
Re: [R] Using write.table i have a table with two columns i would like to save it as an excel file
Thank you for the help, csv works much better, Kevin On Thu, Aug 25, 2011 at 11:47 AM, R. Michael Weylandt < michael.weyla...@gmail.com> [via R] < ml-node+3769105-2014137821-262...@n4.nabble.com> wrote: > I'd suggest you should probably just use the simpler write.csv() function > to > make a file type that will move much more conveniently between Excel and R. > > > The syntax is: > > write.csv(ThingBeingSaved, "filename.csv") > > If you only put the file name to write.csv it will be placed in your > working > directory, which you can find by running getwd() at the command line. If > you > put a whole path, R will put it there. If you want to change your working > directory, setwd() can do that. > > As to what to name the file, well -- that's your problem, but it can be > basically anything you want as long as it ends in ".csv". (It doesn't even > technically have to do that, but please do -- it will make your life better > > when dealing with Excel) > > Michael > > On Thu, Aug 25, 2011 at 12:58 PM, kevin123 <[hidden > email]<http://user/SendEmail.jtp?type=node&node=3769105&i=0>> > wrote: > > > Using write.table i would like to save data as an excel file to a > folder. > > I > > am not too sure how to write the file path or what to name the file. I > > would > > appreciate any feedback. > > > > > > > write.table(x, file = "", append = FALSE, quote = TRUE, sep = " ", > > + eol = "\n", na = "NA", dec = ".", row.names = TRUE, > > + col.names = TRUE, qmethod = c("escape", "double"), > > + fileEncoding = "") > > "area" "bedrooms" "sale.price" > > > > "9" 694 4 192 > > "10" 905 4 215 > > "11" 802 4 215 > > "12" 1366 4 274 > > "13" 716 4 112.7 > > "14" 963 4 185 > > "15" 821 4 212 > > "16" 714 4 220 > > "17" 1018 4 276 > > "18" 887 4 260 > > "19" 790 4 221.5 > > "20" 696 5 255 > > "21" 771 5 260 > > "22" 1006 5 293 > > "23" 1191 6 375 > > > > > > -- > > View this message in context: > > > http://r.789695.n4.nabble.com/Using-write-table-i-have-a-table-with-two-columns-i-would-like-to-save-it-as-an-excel-file-tp3768829p3768829.html > > Sent from the R help mailing list archive at Nabble.com. > > > > __ > > [hidden email] > > <http://user/SendEmail.jtp?type=node&node=3769105&i=1>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. > > > > [[alternative HTML version deleted]] > > __ > [hidden email] <http://user/SendEmail.jtp?type=node&node=3769105&i=2>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. > > > -- > If you reply to this email, your message will be added to the discussion > below: > > http://r.789695.n4.nabble.com/Using-write-table-i-have-a-table-with-two-columns-i-would-like-to-save-it-as-an-excel-file-tp3768829p3769105.html > To unsubscribe from Using write.table i have a table with two columns i > would like to save it as an excel file, click > here<http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=3768829&code=a2V2aW5jb3JyeTEyM0BnbWFpbC5jb218Mzc2ODgyOXwxNTc4MTA3MzY1>. > > -- View this message in context: http://r.789695.n4.nabble.com/Using-write-table-i-have-a-table-with-two-columns-i-would-like-to-save-it-as-an-excel-file-tp3768829p3769429.html Sent from the R help mailing list archive at Nabble.com. [[alternative HTML version deleted]] __ R-help@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.
[R] I want to fill a column in with 0 or 1 depending on another columns input
This is a portion of my data frame MemberIDSpecialty Surgery Internal 1 42286978 Surgery NA NA 2 97903248 Internal NA NA 3 2759427 Internal NA NA 4 73570559SurgeryNA NA There are four columns. In the Specialty column there are two options Surgery/Internal, These options have there own columns. I want to fill a column in with 0 or 1 depending on another columns input I am finding it hard to figure out how to do the following: MemberIDSpecialty Surgery Internal 1 42286978 Surgery 1 0 2 97903248 Internal 0 1 3 2759427 Internal 0 1 4 73570559Surgery10 I would greatly appreciate any help regards, Kevin -- View this message in context: http://r.789695.n4.nabble.com/I-want-to-fill-a-column-in-with-0-or-1-depending-on-another-columns-input-tp4447446p4447446.html Sent from the R help mailing list archive at Nabble.com. __ R-help@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.
[R] Rearanging Data
Hi, This is only a small portion of the Data i am working on I want to make a subset of this data set( Data Set=Claims) MemberID ProviderID Vendor PCPYear Specialty 1 422869788013252 172193 37796 Y1Surgery 2 979032483316066 726296 5300Y3Internal 3 27594272997752 140343 91972Y1 Internal 4 735705597053364 240043 70119 Y3 Laboratory I want to put all the rows containing Y1 into a subset. I tried this but it does not work sub <- subset(Claims, Year=Y1) I would greatly appreciate any help Kevin -- View this message in context: http://r.789695.n4.nabble.com/Rearanging-Data-tp4371717p4371717.html Sent from the R help mailing list archive at Nabble.com. __ R-help@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.
[R] How to deal with missing values when using Random Forrest
I am using the package Random Forrest to test and train a model, I aim to predict (LengthOfStay.days),: > library(randomForest) > model <- randomForest( LengthOfStay.days~.,data = training, + importance=TRUE, + keep.forest=TRUE + ) *This is a small portion of the data frame: * *data(training)* LengthOfStay.days CharlsonIndex.numeric DSFS.months 1 0 0.0 8.5 6 0 0.0 3.5 7 0 0.0 0.5 8 0 0.0 0.5 9 0 0.0 1.5 11 0 1.5 NaN *Error message* Error in na.fail.default(list(LengthOfStay.days = c(0, 0, 0, 0, 0, 0, : missing values in object, I would greatly appreciate any help Thanks Kevin -- View this message in context: http://r.789695.n4.nabble.com/How-to-deal-with-missing-values-when-using-Random-Forrest-tp4421254p4421254.html Sent from the R help mailing list archive at Nabble.com. __ R-help@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.