我的数据的权变表显示,有一个元素的值为21974。但是,const credentials = {
accessToken: '', // not sure if i needed it if I got refresh token
clientId: 'HIDDEN',
clientSecret: 'HIDDEN',
refreshToken: 'HIDDEN'
};
function main() {
var SPREADSHEET_URL = 'HIDDEN';
var GoogleApis;
(function (GoogleApis) {
GoogleApis.readSheetsService = credentials => readService("https://sheets.googleapis.com/$discovery/rest?version=v4", credentials);
// Creation logic based on https://developers.google.com/discovery/v1/using#usage-simple
function readService(SPREADSHEET_URL, credentials) {
const content = UrlFetchApp.fetch(SPREADSHEET_URL).getContentText();
const discovery = JSON.parse(content);
const accessToken = getAccessToken(credentials);
const standardParameters = discovery.parameters;
}
function getAccessToken(credentials) {
if (credentials.accessToken) {
return credentials.accessToken;
}
const tokenResponse = UrlFetchApp.fetch('https://www.googleapis.com/oauth2/v4/token', { method: 'post', contentType: 'application/x-www-form-urlencoded', muteHttpExceptions: true, payload: { client_id: credentials.clientId, client_secret: credentials.clientSecret, refresh_token: credentials.refreshToken, grant_type: 'refresh_token' } });
const responseCode = tokenResponse.getResponseCode();
const responseText = tokenResponse.getContentText();
if (responseCode >= 200 && responseCode <= 299) {
const accessToken = JSON.parse(responseText)['access_token'];
return accessToken;
}
throw new Error(responseText);
})(GoogleApis || (GoogleApis = {}));
函数无法找到其位置。我想知道我的代码是否有错误。
我有以下代码:
which
“ 21974”组中有一个元素。
但是,如果我使用 table(as.numeric(dat[1,2:ncol(dat)]))
# And the result is:
#(Upper: Groups / Bottom: Frequency for each group)
53 58 59 60 65 67 71 72 74 75 78 79 80 81 82 84 88 89 94 21974
143 142 70 226 63 95 89 181 147 344 131 896 480 205 84 159 351 475 364 1
函数找出它在哪里,我的代码将找不到它:
which
其结果是:
which(dat[1,] == "21974", arr.ind=T)
我不确定这是怎么发生的,想知道我是否滥用了哪个功能。
提前谢谢!
答案 0 :(得分:0)
我认为您可以使用match
:match(21974, df)
来给您在df $ colname等向量中的位置。我认为(我没有使用过),这也可以在行中找到位置:
df[match(21974,df$colname),]