Displaying 16 results from an estimated 16 matches for "row_names".
2011 Jul 06
1
Subset creates row_names column when exported to MYSQL
Dear R-helpers,
I have a huge dataset and I create a filter selecting only the cases I want
using:
>data <- subset(data, data$var=='x' | data$var=='y' | data$var=='z' | ... )
The problem is, when i check my new data it doen't show a row_names column
but when the data is exported to MYSQL (using RMYSQL) it creates a column
row_names.
I've already tried
>row.names(data)<- NULL
tried
>write.table
then
>read.table
tried
>as.matrix(data)
but the row_names column does not appear in R, but appears everytime I
export to MY...
2004 Nov 25
3
Searching for a string in RSQLite
...ot;SQLite")
> con <- dbConnect(m, dbname = "base.dbms")
> data(USArrests)
> dbWriteTable(con, "USArrests", USArrests, overwrite = T)
[1] TRUE
> state <- "Wyoming"
# this works fine:
> dbGetQuery(con, paste("SELECT * from USArrests where row_names='",state,"'",sep=""))
row_names Murder Assault UrbanPop Rape
1 Wyoming 6.8 161 60 15.6
# Buf if the search string contains characters that SQL interprets, I
# get an error
> state <- "messy: ' ("
> dbGetQuery(con, paste(&qu...
2018 Jan 15
0
sum multiple csv files
...hat you convert the data frames read in by read.csv into matrices before adding them:
All_data <- lapply(filenames
,function(i){
###read cvs files and add the row and column names to each data frame
###
as.matrix( read.csv(i, header=FALSE, sep = "", col.names = col_names, row.names = row_names)
})
result <- Reduce( `+`, All_data )
This will fail if any of the values in your csv files are non-numeric, but dealing with that would require us to know specifics about your files or intent that you have omitted. (The dput function is indispensable for clarifying such issues [1][2].)
---
[...
2011 Jul 28
0
_: how to replace values in x by means in subgroups created in ...(not loops)
...---------------------------
# next to try in looking for faster solutions mayby:
#require(sqldf)
# centered moving average of length 7
#set.seed(1)
#DF <- data.frame(x = rnorm(15, 1:15))
#s18 <- sqldf("select a.x x, avg(b.x) movavgx from DF a, DF b
# where a.row_names - b.row_names between -3 and 3
# group by a.row_names having count(*) = 7
# order by a.row_names+0",
# row.names = TRUE)
#r18 <- data.frame(x = DF[4:12,], movavgx = rowMeans(embed(DF$x, 7)))
#row.names(r18) <- NULL
#all.equal(r18, s18)
#-------------------...
2018 Jan 15
4
sum multiple csv files
...nto a large list, and I
created two
filenames <- list.files('data',full.names=TRUE)
All_data <- lapply(filenames,function(i){
###read cvs files and add the row and column names to each data frame###
read.csv(i, header=FALSE, sep = "", col.names = col_names, row.names =
row_names)
})
However I would like to sum the rows of cvs files to get a single data
frame (each cvs file has 47 rows and colunms, so the final data frame
should have the same). I could only do it one by one data data frame, but I
was wondering if anyone could give an idea of how to write a function for
th...
2017 Aug 29
2
DBI::dbWriteTable syntax error apparently from quotes
...roblems which
may be related to how I set up my driver and/or connection.
The dbWriteTable manual page gives as an example command:
dbWriteTable( pDB$con, "mtcars", mtcars[1:5,])
When I try this I get the following error
Error: <SQL> 'CREATE TABLE "mtcars" (
"row_names" varchar(255),
"mpg" FLOAT,
"cyl" FLOAT,
"disp" FLOAT,
"hp" FLOAT,
"drat" FLOAT,
"wt" FLOAT,
"qsec" FLOAT,
"vs" FLOAT,
"am" FLOAT,
"gear" FLOAT,
"carb" FLOAT
)
...
2011 Nov 07
1
RpgSQL row names
Hello,
Using the RpgSQL package, there must be a way to get the row names into the
table automatically. In the example below, I'm trying to get rid of the
cbind line, yet have the row names of the data frame populate a column.
> bentest = matrix(1:4,2,2)
> dimnames(bentest) = list(c('ra','rb'),c('ca','cb'))
> bentest
ca cb
ra 1 3
rb 2 4
>
2011 Nov 08
1
dbWriteTable with field data type
Hello,
When I do:
dbWriteTable(con, "r.BOD", cbind(row_names = rownames(BOD), BOD))
...can I specify the data types such as varchar(12), float, double
precision, etc. for each of the fields/columns?
If not, what is the best way to create a table with specified field data
types (with the RpgSQL package/R)?
Regards,
Ben
[[alternative HTML version deleted...
2010 Jan 25
1
RMySQL Append data.frame to table
...s the PK and is set to auto increment.
I'd like to load this data.frame using something like:
dbWriteTable(con, "contact", dat, append=TRUE)
However, I get this error:
Error in mysqlExecStatement(conn, statement, ...) :
RS-DBI driver: (could not run statement: Unknown column 'row_names'
in 'field list')
[1] FALSE
Warning message:
In mysqlWriteTable(conn, name, value, ...) : could not load data into table
Can anyone shed light on this error, or how I might bulk load this data
using RMySQL?
Cheers,
Nathan
--
--------------------------------------------------------...
2010 Aug 12
2
How to building my own datafile
Hi folks,
I'm prepared building my own datafiles, simple file at start, for testing
wondering how to process? Which software will be used,
MySQL/MS-SQL/MS-Excel/Open Office-Calc etc?
On searching I found r-cran-rmysql on Ubuntu repo.
Further searching I found;
RMySQL: R interface to the MySQL database
http://cran.r-project.org/web/packages/RMySQL/index.html
Whether install the above
2017 Aug 29
0
DBI::dbWriteTable syntax error apparently from quotes
...how I set up my driver and/or connection.
>The dbWriteTable manual page gives as an example command:
>
>dbWriteTable( pDB$con, "mtcars", mtcars[1:5,])
>
>When I try this I get the following error
>
>Error: <SQL> 'CREATE TABLE "mtcars" (
> "row_names" varchar(255),
> "mpg" FLOAT,
> "cyl" FLOAT,
> "disp" FLOAT,
> "hp" FLOAT,
> "drat" FLOAT,
> "wt" FLOAT,
> "qsec" FLOAT,
> "vs" FLOAT,
> "am" FLOAT,
> "gear&qu...
2008 Sep 23
3
Association error using find since upgrading to Rails 2.1.1
Hi all,
Ruby 1.8.6
Rails 2.1.1
I have a simple association that works fine under 1.2.6 but is failing
under 2.1.1.
require ''active_record''
ActiveRecord::Base.establish_connection(
:adapter => ''postgresql'',
:database => ''my_database,
:username => ''postgres''
)
class Schedule < ActiveRecord::Base
belongs_to
2002 Dec 18
1
A little problem handling logicals in RMySQL under R1.6.1
...con)
> field.types
x y
"tinyint" "tinyint"
# However, in WriteTable, nothing is done to convert the logicals to 0s and 1s.
# And logically, the infile is written in TRUE and FALSE and finally, in MySQL
# all becomes zero. Here is what we get in MySQL:
# row_names x y
# 1 0 0
# 2 0 0
#
# So, logically this is what we get back in R:
> dbWriteTable(con,"test",a)
[1] TRUE
> aa<-dbReadTable(con,"test")
> aa
x y
1 0 0
2 0 0
>
# and this is clearly not what we want...
#
# as a crude patch I added for (i in 1:length(v...
2010 Apr 30
0
RMySQL and dates
...;
food ethanol fcumrec dcumrec rrf rrd
"numeric" "numeric" "numeric" "numeric" "numeric" "numeric"
> dbGetQuery(con, "describe SAC11;")
Field Type Null Key Default Extra
1 row_names text YES <NA>
2 dates text YES <NA>
3 trialnum bigint(20) YES <NA>
4 fooddel double YES <NA>
5 ethdel double YES <NA>
6 trialtime double YES <NA>
7 trialtype double...
2010 Oct 13
2
Rmysql - dbWritetable
Dear Rusers,
I am trying to feed my database with data from a file.
But since my file (2010101000.txt) there`s no headers I am facing problem
because the
result data.frame is not separated my columns.
How could I set variables names for each columns in *dbWriteTable*? I have
tried the command below but I don`t know how to fill the *field.type*option.
dbWriteTable(con, "b20101010",
2010 Apr 15
4
Does "sink" stand for anything?
Hello Everyone,
Learning about R and its wonderful array of functions. If it's not obvious, I usually try to find out what a function stands for. I think this helps me remember better.
One function that has me stumped is "sink." Can anyone tell me if this stands for something?
Thanks,
Paul
__________________________________________________
[[alternative HTML