有没有办法在R中读取Stata版本13数据集文件?
我试图做以下事情:
> library(foreign)
> data = read.dta("TEAdataSTATA.dta")
Run Code Online (Sandbox Code Playgroud)
但是,我收到了一个错误:
read.dta("TEAdataSTATA.dta")中的错误:
不是Stata版本5-12 .dta文件
有人可以指出是否有办法解决这个问题?
有没有办法fileInput在R闪亮的颜色按钮?它看起来像github 上这个页面上显示的那样可能.但是我找不到要完成的代码.
这是我想要修改的简单应用程序,使按钮和进度条显示为红色.
在ui.R:
library(shiny)
shinyUI(fluidPage(
titlePanel("Test"),
fileInput("Test","")
))
Run Code Online (Sandbox Code Playgroud)
和 server.R
library(shiny)
shinyServer(
function(input, output) {
}
)
Run Code Online (Sandbox Code Playgroud)
谢谢你的建议.
我正在研究使用 RcppArmadillo 的 R 包。我正在尝试利用 OpenBLAS 中更快的矩阵乘法。在C++ armadillo 库的文档中,它说如果我们的机器上有 OpenBLAS,那么 Armadillo 将使用 OpenBLAS 而不是 BLAS。但是,当我编译我的 R 包时,我得到如下信息:
g++ -m64 -std=c++11 -shared -L/usr/lib64/R/lib -Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -o PackageTest.so class1.o class2.o class3.o class4.o class5.o class6.o class7.o RcppExports.o class8.o class9.o class10.o -L/usr/lib64/R/lib -lRlapack -L/usr/lib64/R/lib -lRblas -lgfortran -lm -lquadmath -L/usr/lib64/R/lib -lR
Run Code Online (Sandbox Code Playgroud)
所以它是用-lRlapack和-lRblas选项编译的。如何正确修改Makevars和Makevars.win文件以让 RcppArmadillo 使用选项编译包-lopenblas?我解决这个问题的尝试是Makevars通过以下方式修改文件:
PKG_LIBS = $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)
PKG_CXXFLAGS =-fopenmp -std=c++11 -lopenblas
PKG_CXX1XFLAGS = $(PKG_CXXFLAGS)
Run Code Online (Sandbox Code Playgroud)
该包确实使用 编译-lopenblas,但这是最好的方法吗?
我有一个名为failedfiles.txt以下内容的文件:
failed1
failed2
failed3
Run Code Online (Sandbox Code Playgroud)
我需要使用grep返回该文件中每行的内容,并将输出保存在要访问的列表中.所以我想要这样的东西:
temp_list=$(grep "[a-z]" failedfiles.txt)
Run Code Online (Sandbox Code Playgroud)
但是,这个问题是我打字的时候
echo ${temp_list[0]}
Run Code Online (Sandbox Code Playgroud)
我得到以下输出:
failed1 failed2 failed3
Run Code Online (Sandbox Code Playgroud)
但我想要的是当我这样做时:
echo ${temp_list[0]}
Run Code Online (Sandbox Code Playgroud)
打印
failed1
Run Code Online (Sandbox Code Playgroud)
当我这样做时:
echo ${temp_list[1]}
Run Code Online (Sandbox Code Playgroud)
打印
failed2
Run Code Online (Sandbox Code Playgroud)
谢谢.
我有一堆英语句子,我从文本文件中提取到MYSQL表.这就是我在MYSQL中创建表的方法:
create table sentences ( ID int NOT NULL AUTO_INCREMENT , sentence varchar (255) , primary key (ID) ) character set = utf8;
Run Code Online (Sandbox Code Playgroud)
这是我的python脚本
from bs4 import BeautifulSoup as b
import sys
from fixsentence import *
import MySQLdb as db
bound = sys.argv[1]
con = db.connect('localhost' , 'root' , 'ayrefik1' , 'knowledgebase2')
curs = con.cursor()
def gettext(file):
temp_file = open(file)
soup = b(temp_file)
list = get_sentences(soup.get_text())
for x in list:
curs.execute('SET NAMES utf8;')
curs.execute('insert ignore into sentences (sentence) values (%s);', …Run Code Online (Sandbox Code Playgroud) 我有两个向量x和y。我使用以下函数创建一个网格:
v = expand.grid(x, y)
Run Code Online (Sandbox Code Playgroud)
我有一个定义如下的函数
N <- function(a, b , dat){
m = ncol(Filter(function(z) a*max(z)*min(z) < b , dat[1:ncol(dat)]))
return(m)
}
Run Code Online (Sandbox Code Playgroud)
然后我需要最大化N网格x,y:
Maximize <- function(x , y ,dat){
v = as.matrix(expand.grid(x,y))
# Here is where I want to map the values of v and get the maximum element and
# get the tuple in v that maximized N
temp1 <- max(apply(v , 1 , N(v[[1]] , v[[2]] , dat)))
}
Run Code Online (Sandbox Code Playgroud)
谢谢
有没有办法将CrossTable(从gmodels包中)导出到Latex?
所以,如果我这样做:
let = sample(c("A","B"), 10 , replace=TRUE)
num = sample(1:3, 10 , replace=TRUE)
tab = CrossTable(let , num, prop.c = FALSE,prop.t = FALSE, prop.chisq=FALSE)
Run Code Online (Sandbox Code Playgroud)
有没有办法将标签导出到乳胶表?
使用CrossTable不是偏好.我只需要能够在同一个单元格中获得计数和行百分比的东西.
我有一个数据框,我通过以这种方式导入.dat Stata文件创建:
data = read.dta("TEAdataSTATA2.dta")
Run Code Online (Sandbox Code Playgroud)
然后我写data一个文本文件:
write.table(b , "mydata.txt" , sep="\t")
Run Code Online (Sandbox Code Playgroud)
然后我使用我创建的文本文件以这种方式创建SPSS文件:
write.foreign(b , "mydata.txt" , "DerLeew.sps" , package="SPSS")
Run Code Online (Sandbox Code Playgroud)
但是,我收到一个错误:
Error in writeForeignSPSS(df = list(studyid = c("P0008", "P0018", "P0031", :
I cannot abbreviate the variable names to eight or fewer letters
Run Code Online (Sandbox Code Playgroud)
有人可以指出问题吗?
我的程序由于某种原因没有编译.我有2个C文件,我按以下方式编译它们:gcc showxbits.c xbits.c -o showxbits -lm .Moreover,我收到以下错误:
showxbits.c: In function ‘main’:
showxbits.c:18:3: warning: incompatible implicit declaration of built-in function ‘strcpy’ [enabled by default]
Run Code Online (Sandbox Code Playgroud)
我的第一个文件名为xbits,它位于:
/*
* stubs for functions to study
* integer-hex conversions
*
*/
#include <stdio.h>
#include <math.h>
#include "xbits.h"
/*#include "/home/carl/Programs/C/lab2/cheungr/hw2/solution/reverse.c"
/* function represents the int n as a hexstring which it places in the
hexstring array */
void itox( char hexstring[], int n) {
hexstring[2*sizeof(n) + 1];
int ratio, remainder;
int i = 0;
while( …Run Code Online (Sandbox Code Playgroud) 我正在尝试编写代码来获取此表单列表的子序列:
l = [240,200,160,4,0,0,0,0,4,4,4,0,0,0,1,1,1,1]
基本上,我需要得到非零的子序列,所以我需要这种形式的输出:
output = [[255,200,160,4] , [4,4,4] , [1,1,1,1]]
谢谢.
我以下列方式创建了LinkedLists的arraylist:
ArrayList<LinkedList<Card>> list = new ArrayList<>(5);
Run Code Online (Sandbox Code Playgroud)
然后我需要将链接列表添加到arrayList,所以我这样做,这似乎不起作用,因为ArrayList保持为空
for (position = 0; position < list.size(); position++) {
list.add(new LinkedList<Card>());
}
Run Code Online (Sandbox Code Playgroud)
那么我通过给出LinkedLists引用手动将linkedLists添加到arrayList:
LinkedList<Card> temp_list0 = new LinkedList<Card>();
LinkedList<Card> temp_list1 = new LinkedList<Card>();
LinkedList<Card> temp_list2 = new LinkedList<Card>();
LinkedList<Card> temp_list3 = new LinkedList<Card>();
LinkedList<Card> temp_list4 = new LinkedList<Card>();
list.add(temp_list0);
list.add(temp_list1);
list.add(temp_list2);
list.add(temp_list3);
list.add(temp_list4);
Run Code Online (Sandbox Code Playgroud)
最后,虽然每次迭代,我需要拉出一个LinkedLists来添加一些东西,然后把它放回到它在arraylist中的位置,但是通过这样做我丢失了对LinkedList的引用,因此信息丢失了
for (position = 0; position < deck.length; position++) {
scan = (deck[position]).getValue();
temp_list = list.get(scan);
temp_list.offer(deck[position]);
list.add(scan, temp_list);
}
Run Code Online (Sandbox Code Playgroud)
有没有更好的方法来访问arraylist中的LinkedLists而不会丢失信息,因为我的方式不起作用.